aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap4
-rw-r--r--Documentation/ABI/testing/sysfs-devices-deferred_probe12
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt13
-rw-r--r--Documentation/block/queue-sysfs.txt6
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c.txt8
-rw-r--r--Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt4
-rw-r--r--Documentation/devicetree/bindings/mtd/tango-nand.txt6
-rw-r--r--Documentation/devicetree/bindings/net/ti,dp83867.txt6
-rw-r--r--Documentation/devicetree/bindings/power/supply/tps65217_charger.txt7
-rw-r--r--Documentation/devicetree/bindings/spi/sh-msiof.txt19
-rw-r--r--Documentation/driver-api/infrastructure.rst15
-rw-r--r--Documentation/networking/mpls-sysctl.txt4
-rw-r--r--Documentation/vfio-mediated-device.txt27
-rw-r--r--Documentation/vm/page_frags42
-rw-r--r--MAINTAINERS69
-rw-r--r--Makefile4
-rw-r--r--arch/arc/Kconfig2
-rw-r--r--arch/arc/include/asm/cache.h9
-rw-r--r--arch/arc/include/asm/entry-arcv2.h2
-rw-r--r--arch/arc/include/asm/module.h4
-rw-r--r--arch/arc/include/asm/ptrace.h2
-rw-r--r--arch/arc/include/asm/setup.h1
-rw-r--r--arch/arc/kernel/intc-arcv2.c6
-rw-r--r--arch/arc/kernel/intc-compact.c4
-rw-r--r--arch/arc/kernel/mcip.c4
-rw-r--r--arch/arc/kernel/module.c4
-rw-r--r--arch/arc/mm/cache.c155
-rw-r--r--arch/arc/mm/init.c5
-rw-r--r--arch/arm/Kconfig3
-rw-r--r--arch/arm/boot/dts/Makefile2
-rw-r--r--arch/arm/boot/dts/am335x-bone-common.dtsi8
-rw-r--r--arch/arm/boot/dts/am335x-icev2.dts1
-rw-r--r--arch/arm/boot/dts/am33xx.dtsi1
-rw-r--r--arch/arm/boot/dts/am4372.dtsi1
-rw-r--r--arch/arm/boot/dts/am571x-idk.dts10
-rw-r--r--arch/arm/boot/dts/am572x-idk.dts14
-rw-r--r--arch/arm/boot/dts/am57xx-idk-common.dtsi9
-rw-r--r--arch/arm/boot/dts/bcm-nsp.dtsi2
-rw-r--r--arch/arm/boot/dts/da850-evm.dts1
-rw-r--r--arch/arm/boot/dts/dm814x.dtsi1
-rw-r--r--arch/arm/boot/dts/dm816x.dtsi1
-rw-r--r--arch/arm/boot/dts/dra7.dtsi2
-rw-r--r--arch/arm/boot/dts/dra72-evm-revc.dts2
-rw-r--r--arch/arm/boot/dts/dra72-evm-tps65917.dtsi16
-rw-r--r--arch/arm/boot/dts/imx31.dtsi4
-rw-r--r--arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi4
-rw-r--r--arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi4
-rw-r--r--arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6sl.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6sx.dtsi1
-rw-r--r--arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts11
-rw-r--r--arch/arm/boot/dts/omap2.dtsi1
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/boot/dts/omap3.dtsi1
-rw-r--r--arch/arm/boot/dts/omap4.dtsi1
-rw-r--r--arch/arm/boot/dts/omap5.dtsi2
-rw-r--r--arch/arm/boot/dts/qcom-apq8064.dtsi4
-rw-r--r--arch/arm/boot/dts/qcom-mdm9615.dtsi2
-rw-r--r--arch/arm/boot/dts/sun6i-a31-hummingbird.dts4
-rw-r--r--arch/arm/boot/dts/sun6i-a31.dtsi1
-rw-r--r--arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts2
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts2
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts2
-rw-r--r--arch/arm/boot/dts/vf610-zii-dev-rev-b.dts3
-rw-r--r--arch/arm/configs/multi_v7_defconfig4
-rw-r--r--arch/arm/configs/s3c2410_defconfig6
-rw-r--r--arch/arm/include/asm/cputype.h3
-rw-r--r--arch/arm/include/asm/ftrace.h18
-rw-r--r--arch/arm/include/asm/virt.h5
-rw-r--r--arch/arm/include/uapi/asm/types.h (renamed from arch/arm/include/asm/types.h)6
-rw-r--r--arch/arm/kernel/hw_breakpoint.c16
-rw-r--r--arch/arm/kernel/smp_tlb.c7
-rw-r--r--arch/arm/kvm/arm.c3
-rw-r--r--arch/arm/mach-davinci/clock.c12
-rw-r--r--arch/arm/mach-davinci/clock.h2
-rw-r--r--arch/arm/mach-davinci/da850.c32
-rw-r--r--arch/arm/mach-davinci/usb-da8xx.c34
-rw-r--r--arch/arm/mach-exynos/platsmp.c31
-rw-r--r--arch/arm/mach-imx/mach-imx1.c1
-rw-r--r--arch/arm/mach-omap1/dma.c16
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/board-generic.c2
-rw-r--r--arch/arm/mach-omap2/gpio.c160
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_common_data.h4
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c2
-rw-r--r--arch/arm/mach-omap2/prm_common.c4
-rw-r--r--arch/arm/mach-omap2/timer.c9
-rw-r--r--arch/arm/mach-s3c24xx/common.c76
-rw-r--r--arch/arm/mach-ux500/pm.c4
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gx.dtsi16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts4
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi6
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl.dtsi6
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxm.dtsi4
-rw-r--r--arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts2
-rw-r--r--arch/arm64/boot/dts/exynos/exynos5433.dtsi2
-rw-r--r--arch/arm64/boot/dts/qcom/msm8996.dtsi10
-rw-r--r--arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts2
-rw-r--r--arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts2
-rw-r--r--arch/arm64/boot/dts/xilinx/zynqmp.dtsi6
-rw-r--r--arch/arm64/configs/defconfig1
-rw-r--r--arch/arm64/include/asm/assembler.h36
-rw-r--r--arch/arm64/include/asm/current.h10
-rw-r--r--arch/arm64/include/asm/memory.h2
-rw-r--r--arch/arm64/include/asm/virt.h9
-rw-r--r--arch/arm64/include/uapi/asm/ptrace.h1
-rw-r--r--arch/arm64/kernel/entry.S2
-rw-r--r--arch/arm64/kernel/ptrace.c16
-rw-r--r--arch/arm64/kernel/traps.c28
-rw-r--r--arch/arm64/mm/dma-mapping.c3
-rw-r--r--arch/arm64/mm/fault.c8
-rw-r--r--arch/arm64/mm/hugetlbpage.c2
-rw-r--r--arch/arm64/mm/init.c5
-rw-r--r--arch/mips/kvm/entry.c5
-rw-r--r--arch/mips/kvm/mips.c4
-rw-r--r--arch/openrisc/kernel/vmlinux.lds.S2
-rw-r--r--arch/parisc/include/asm/thread_info.h1
-rw-r--r--arch/parisc/kernel/time.c23
-rw-r--r--arch/parisc/mm/fault.c2
-rw-r--r--arch/powerpc/include/asm/book3s/64/hash-4k.h5
-rw-r--r--arch/powerpc/include/asm/book3s/64/hash.h4
-rw-r--r--arch/powerpc/include/asm/hugetlb.h14
-rw-r--r--arch/powerpc/include/asm/nohash/pgtable.h5
-rw-r--r--arch/powerpc/include/asm/page.h3
-rw-r--r--arch/powerpc/include/asm/perf_event_server.h1
-rw-r--r--arch/powerpc/include/asm/pgtable-be-types.h8
-rw-r--r--arch/powerpc/include/asm/pgtable-types.h7
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h10
-rw-r--r--arch/powerpc/kernel/eeh.c10
-rw-r--r--arch/powerpc/kernel/ptrace.c14
-rw-r--r--arch/powerpc/mm/hash_utils_64.c4
-rw-r--r--arch/powerpc/mm/hugetlbpage-hash64.c5
-rw-r--r--arch/powerpc/mm/hugetlbpage.c31
-rw-r--r--arch/powerpc/mm/init-common.c13
-rw-r--r--arch/powerpc/mm/pgtable-book3s64.c18
-rw-r--r--arch/powerpc/perf/core-book3s.c2
-rw-r--r--arch/powerpc/perf/power9-events-list.h2
-rw-r--r--arch/powerpc/perf/power9-pmu.c2
-rw-r--r--arch/powerpc/sysdev/xics/icp-opal.c31
-rw-r--r--arch/s390/configs/default_defconfig27
-rw-r--r--arch/s390/configs/gcov_defconfig50
-rw-r--r--arch/s390/configs/performance_defconfig33
-rw-r--r--arch/s390/defconfig5
-rw-r--r--arch/s390/include/asm/asm-prototypes.h8
-rw-r--r--arch/s390/include/asm/ctl_reg.h4
-rw-r--r--arch/s390/kernel/vtime.c8
-rw-r--r--arch/s390/kvm/kvm-s390.c4
-rw-r--r--arch/tile/kernel/ptrace.c2
-rw-r--r--arch/x86/boot/string.c1
-rw-r--r--arch/x86/boot/string.h9
-rw-r--r--arch/x86/crypto/aesni-intel_glue.c3
-rw-r--r--arch/x86/entry/entry_32.S30
-rw-r--r--arch/x86/entry/entry_64.S11
-rw-r--r--arch/x86/events/amd/ibs.c2
-rw-r--r--arch/x86/events/core.c4
-rw-r--r--arch/x86/events/intel/core.c9
-rw-r--r--arch/x86/events/intel/cstate.c2
-rw-r--r--arch/x86/events/intel/ds.c6
-rw-r--r--arch/x86/events/intel/rapl.c1
-rw-r--r--arch/x86/events/intel/uncore.c1
-rw-r--r--arch/x86/events/intel/uncore_snbep.c2
-rw-r--r--arch/x86/include/asm/intel-family.h2
-rw-r--r--arch/x86/include/asm/microcode_intel.h15
-rw-r--r--arch/x86/include/asm/processor.h18
-rw-r--r--arch/x86/include/asm/stacktrace.h2
-rw-r--r--arch/x86/include/asm/switch_to.h10
-rw-r--r--arch/x86/kernel/apic/io_apic.c2
-rw-r--r--arch/x86/kernel/cpu/amd.c9
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/intel.c11
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c70
-rw-r--r--arch/x86/kernel/pci-swiotlb.c6
-rw-r--r--arch/x86/kernel/tsc.c1
-rw-r--r--arch/x86/kernel/unwind_frame.c30
-rw-r--r--arch/x86/kvm/emulate.c70
-rw-r--r--arch/x86/kvm/lapic.c6
-rw-r--r--arch/x86/kvm/lapic.h1
-rw-r--r--arch/x86/kvm/vmx.c14
-rw-r--r--arch/x86/kvm/x86.c15
-rw-r--r--arch/x86/mm/mpx.c2
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
-rw-r--r--arch/x86/pci/acpi.c10
-rw-r--r--arch/x86/platform/efi/efi.c66
-rw-r--r--arch/x86/platform/efi/quirks.c4
-rw-r--r--arch/x86/platform/intel-mid/device_libs/Makefile2
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c (renamed from arch/x86/platform/intel-mid/device_libs/platform_spidev.c)4
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c2
-rw-r--r--arch/x86/xen/setup.c6
-rw-r--r--block/blk-lib.c13
-rw-r--r--block/blk-mq.c1
-rw-r--r--block/blk-wbt.c13
-rw-r--r--block/blk-zoned.c4
-rw-r--r--block/partition-generic.c14
-rw-r--r--drivers/acpi/acpi_watchdog.c2
-rw-r--r--drivers/acpi/glue.c11
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/scan.c1
-rw-r--r--drivers/acpi/sysfs.c56
-rw-r--r--drivers/auxdisplay/Kconfig6
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/core.c7
-rw-r--r--drivers/base/dd.c13
-rw-r--r--drivers/base/power/domain.c1
-rw-r--r--drivers/block/nbd.c12
-rw-r--r--drivers/block/virtio_blk.c7
-rw-r--r--drivers/block/zram/zram_drv.c19
-rw-r--r--drivers/char/mem.c10
-rw-r--r--drivers/char/ppdev.c13
-rw-r--r--drivers/char/virtio_console.c2
-rw-r--r--drivers/clk/clk-stm32f4.c4
-rw-r--r--drivers/clk/renesas/clk-mstp.c27
-rw-r--r--drivers/clk/samsung/clk-exynos5420.c14
-rw-r--r--drivers/clocksource/exynos_mct.c1
-rw-r--r--drivers/cpufreq/cpufreq-dt-platdev.c2
-rw-r--r--drivers/cpufreq/intel_pstate.c53
-rw-r--r--drivers/devfreq/devfreq.c15
-rw-r--r--drivers/devfreq/exynos-bus.c2
-rw-r--r--drivers/dma/dw/Kconfig2
-rw-r--r--drivers/dma/ioat/hw.h2
-rw-r--r--drivers/dma/ioat/init.c15
-rw-r--r--drivers/dma/omap-dma.c61
-rw-r--r--drivers/dma/pl330.c11
-rw-r--r--drivers/dma/sh/rcar-dmac.c8
-rw-r--r--drivers/dma/stm32-dma.c17
-rw-r--r--drivers/dma/ti-dma-crossbar.c2
-rw-r--r--drivers/extcon/extcon.c2
-rw-r--r--drivers/firmware/arm_scpi.c10
-rw-r--r--drivers/firmware/efi/fake_mem.c3
-rw-r--r--drivers/firmware/efi/libstub/efistub.h8
-rw-r--r--drivers/firmware/efi/libstub/fdt.c87
-rw-r--r--drivers/firmware/efi/memmap.c38
-rw-r--r--drivers/firmware/psci_checker.c4
-rw-r--r--drivers/gpio/gpio-mxs.c2
-rw-r--r--drivers/gpio/gpiolib.c20
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v10_0.c22
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v11_0.c35
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v6_0.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v8_0.c22
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c31
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c34
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/si_dpm.c84
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c42
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vce_v3_0.c32
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vi.c10
-rw-r--r--drivers/gpu/drm/amd/include/amd_shared.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c4
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c24
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c1
-rw-r--r--drivers/gpu/drm/bridge/analogix/analogix_dp_core.c7
-rw-r--r--drivers/gpu/drm/cirrus/Kconfig9
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c4
-rw-r--r--drivers/gpu/drm/drm_modes.c7
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c63
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_mmu.c7
-rw-r--r--drivers/gpu/drm/exynos/exynos5433_drm_decon.c15
-rw-r--r--drivers/gpu/drm/i915/gvt/aperture_gm.c36
-rw-r--r--drivers/gpu/drm/i915/gvt/cfg_space.c78
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.c120
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.h5
-rw-r--r--drivers/gpu/drm/i915/gvt/gvt.c8
-rw-r--r--drivers/gpu/drm/i915/gvt/gvt.h9
-rw-r--r--drivers/gpu/drm/i915/gvt/handlers.c103
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c78
-rw-r--r--drivers/gpu/drm/i915/gvt/mmio.c84
-rw-r--r--drivers/gpu/drm/i915/gvt/mmio.h4
-rw-r--r--drivers/gpu/drm/i915/gvt/opregion.c10
-rw-r--r--drivers/gpu/drm/i915/gvt/reg.h3
-rw-r--r--drivers/gpu/drm/i915/gvt/scheduler.c14
-rw-r--r--drivers/gpu/drm/i915/gvt/vgpu.c162
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c67
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c1
-rw-r--r--drivers/gpu/drm/i915/i915_gem_request.h19
-rw-r--r--drivers/gpu/drm/i915/intel_display.c35
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c41
-rw-r--r--drivers/gpu/drm/i915/intel_hotplug.c4
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c10
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c9
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c8
-rw-r--r--drivers/gpu/drm/meson/meson_plane.c3
-rw-r--r--drivers/gpu/drm/meson/meson_venc.c19
-rw-r--r--drivers/gpu/drm/meson/meson_venc_cvbs.c2
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c14
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c6
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h4
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c22
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c2
-rw-r--r--drivers/gpu/drm/msm/msm_gem_submit.c18
-rw-r--r--drivers/gpu/drm/msm/msm_ringbuffer.c3
-rw-r--r--drivers/gpu/drm/radeon/si.c79
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c25
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_crtc.c27
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_fb.c2
-rw-r--r--drivers/hid/hid-asus.c17
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-corsair.c60
-rw-r--r--drivers/hid/hid-cypress.c3
-rw-r--r--drivers/hid/hid-ids.h7
-rw-r--r--drivers/hid/hid-sensor-hub.c3
-rw-r--r--drivers/hid/hid-sony.c36
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c9
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/hid/wacom_sys.c16
-rw-r--r--drivers/hid/wacom_wac.c10
-rw-r--r--drivers/hwmon/lm90.c2
-rw-r--r--drivers/i2c/busses/i2c-piix4.c22
-rw-r--r--drivers/i2c/i2c-core.c21
-rw-r--r--drivers/i2c/i2c-dev.c2
-rw-r--r--drivers/iio/accel/st_accel_core.c12
-rw-r--r--drivers/iio/adc/Kconfig2
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_buffer.c4
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c13
-rw-r--r--drivers/iio/counter/104-quad-8.c13
-rw-r--r--drivers/iio/imu/bmi160/bmi160_core.c25
-rw-r--r--drivers/iio/light/max44000.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c14
-rw-r--r--drivers/input/joydev.c1
-rw-r--r--drivers/input/joystick/xpad.c6
-rw-r--r--drivers/input/misc/adxl34x-i2c.c4
-rw-r--r--drivers/input/mouse/alps.h2
-rw-r--r--drivers/input/mouse/synaptics_i2c.c4
-rw-r--r--drivers/input/rmi4/Kconfig3
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h6
-rw-r--r--drivers/input/touchscreen/elants_i2c.c4
-rw-r--r--drivers/iommu/amd_iommu.c2
-rw-r--r--drivers/iommu/dmar.c6
-rw-r--r--drivers/iommu/intel-iommu.c42
-rw-r--r--drivers/md/md.h8
-rw-r--r--drivers/md/raid0.c12
-rw-r--r--drivers/md/raid1.c275
-rw-r--r--drivers/md/raid10.c245
-rw-r--r--drivers/md/raid5-cache.c36
-rw-r--r--drivers/md/raid5.c7
-rw-r--r--drivers/misc/mei/bus-fixup.c3
-rw-r--r--drivers/misc/mei/bus.c2
-rw-r--r--drivers/misc/mei/client.c20
-rw-r--r--drivers/misc/mei/debugfs.c2
-rw-r--r--drivers/misc/mei/hbm.c4
-rw-r--r--drivers/misc/mei/hw.h6
-rw-r--r--drivers/misc/mei/mei_dev.h2
-rw-r--r--drivers/mmc/core/mmc_ops.c25
-rw-r--r--drivers/mmc/host/meson-gx-mmc.c8
-rw-r--r--drivers/mmc/host/mxs-mmc.c6
-rw-r--r--drivers/mmc/host/sdhci-acpi.c3
-rw-r--r--drivers/mtd/nand/Kconfig3
-rw-r--r--drivers/mtd/nand/lpc32xx_mlc.c2
-rw-r--r--drivers/mtd/nand/tango_nand.c4
-rw-r--r--drivers/mtd/nand/xway_nand.c5
-rw-r--r--drivers/net/appletalk/ipddp.c2
-rw-r--r--drivers/net/dsa/bcm_sf2.c11
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c2
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c48
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c3
-rw-r--r--drivers/net/ethernet/cadence/macb_pci.c27
-rw-r--r--drivers/net/ethernet/cavium/Kconfig2
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c11
-rw-r--r--drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c12
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c34
-rw-r--r--drivers/net/ethernet/freescale/dpaa/dpaa_eth.c6
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cq.c38
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_clock.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c23
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/icm.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c33
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c64
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h32
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c92
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/pci_hw.h8
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/switchx2.c1
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-phy.c7
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c6
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c21
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c8
-rw-r--r--drivers/net/ethernet/sfc/ef10.c3
-rw-r--r--drivers/net/ethernet/sfc/ethtool.c2
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h2
-rw-r--r--drivers/net/ethernet/sfc/siena.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c89
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c42
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c6
-rw-r--r--drivers/net/ethernet/ti/cpmac.c2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c3
-rw-r--r--drivers/net/ieee802154/at86rf230.c4
-rw-r--r--drivers/net/ieee802154/atusb.c59
-rw-r--r--drivers/net/phy/Kconfig1
-rw-r--r--drivers/net/phy/dp83867.c18
-rw-r--r--drivers/net/phy/marvell.c3
-rw-r--r--drivers/net/phy/phy.c9
-rw-r--r--drivers/net/usb/asix_devices.c1
-rw-r--r--drivers/net/usb/r8152.c87
-rw-r--r--drivers/net/vrf.c7
-rw-r--r--drivers/net/vxlan.c13
-rw-r--r--drivers/net/wan/slic_ds26522.c2
-rw-r--r--drivers/net/wireless/intersil/orinoco/mic.c44
-rw-r--r--drivers/net/wireless/intersil/orinoco/mic.h3
-rw-r--r--drivers/net/wireless/intersil/orinoco/orinoco.h4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/usb.c1
-rw-r--r--drivers/nvdimm/namespace_devs.c23
-rw-r--r--drivers/nvdimm/pmem.c4
-rw-r--r--drivers/nvme/host/core.c24
-rw-r--r--drivers/nvme/host/fc.c24
-rw-r--r--drivers/nvme/host/nvme.h9
-rw-r--r--drivers/nvme/host/pci.c32
-rw-r--r--drivers/nvme/host/rdma.c15
-rw-r--r--drivers/nvme/host/scsi.c27
-rw-r--r--drivers/nvme/target/admin-cmd.c4
-rw-r--r--drivers/nvme/target/fcloop.c4
-rw-r--r--drivers/nvmem/core.c4
-rw-r--r--drivers/nvmem/imx-ocotp.c2
-rw-r--r--drivers/nvmem/qfprom.c14
-rw-r--r--drivers/pci/host/pci-xgene-msi.c2
-rw-r--r--drivers/pci/host/pcie-designware.c10
-rw-r--r--drivers/pci/probe.c12
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.c2
-rw-r--r--drivers/pinctrl/pinctrl-amd.c19
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.c91
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.h31
-rw-r--r--drivers/platform/x86/Kconfig2
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c42
-rw-r--r--drivers/remoteproc/remoteproc_core.c29
-rw-r--r--drivers/rpmsg/rpmsg_core.c4
-rw-r--r--drivers/s390/virtio/virtio_ccw.c29
-rw-r--r--drivers/scsi/bfa/bfad.c6
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c2
-rw-r--r--drivers/scsi/bfa/bfad_drv.h2
-rw-r--r--drivers/scsi/fnic/fnic.h1
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c16
-rw-r--r--drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c7
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_base.h12
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c40
-rw-r--r--drivers/scsi/qedi/Kconfig2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c21
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h6
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c92
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c37
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.h3
-rw-r--r--drivers/scsi/qla2xxx/qla_nx2.c17
-rw-r--r--drivers/scsi/qla2xxx/qla_nx2.h17
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c57
-rw-r--r--drivers/scsi/qla2xxx/qla_target.h22
-rw-r--r--drivers/scsi/qla2xxx/qla_tmpl.c24
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c4
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.h1
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/sd.c40
-rw-r--r--drivers/scsi/ses.c2
-rw-r--r--drivers/scsi/snic/snic_main.c3
-rw-r--r--drivers/soc/ti/wkup_m3_ipc.c1
-rw-r--r--drivers/spi/Kconfig1
-rw-r--r--drivers/spi/spi-armada-3700.c11
-rw-r--r--drivers/spi/spi-axi-spi-engine.c3
-rw-r--r--drivers/spi/spi-davinci.c4
-rw-r--r--drivers/spi/spi-dw-mid.c4
-rw-r--r--drivers/spi/spi-dw.c5
-rw-r--r--drivers/spi/spi-pxa2xx.c1
-rw-r--r--drivers/spi/spi-sh-msiof.c4
-rw-r--r--drivers/staging/octeon/ethernet.c2
-rw-r--r--drivers/target/target_core_transport.c24
-rw-r--r--drivers/target/target_core_xcopy.c157
-rw-r--r--drivers/target/target_core_xcopy.h7
-rw-r--r--drivers/thermal/rockchip_thermal.c153
-rw-r--r--drivers/thermal/thermal_core.c10
-rw-r--r--drivers/thermal/thermal_hwmon.c20
-rw-r--r--drivers/tty/serial/8250/8250_core.c2
-rw-r--r--drivers/tty/serial/8250/8250_pci.c12
-rw-r--r--drivers/tty/serial/8250/8250_port.c2
-rw-r--r--drivers/tty/serial/atmel_serial.c22
-rw-r--r--drivers/tty/sysrq.c4
-rw-r--r--drivers/usb/core/config.c10
-rw-r--r--drivers/usb/core/hub.c59
-rw-r--r--drivers/usb/dwc2/core.h4
-rw-r--r--drivers/usb/dwc2/gadget.c20
-rw-r--r--drivers/usb/dwc2/hcd.c7
-rw-r--r--drivers/usb/dwc2/params.c40
-rw-r--r--drivers/usb/dwc3/core.h10
-rw-r--r--drivers/usb/dwc3/dwc3-exynos.c4
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c6
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c17
-rw-r--r--drivers/usb/dwc3/ep0.c46
-rw-r--r--drivers/usb/dwc3/gadget.c24
-rw-r--r--drivers/usb/gadget/composite.c14
-rw-r--r--drivers/usb/gadget/function/f_fs.c26
-rw-r--r--drivers/usb/gadget/function/f_hid.c2
-rw-r--r--drivers/usb/gadget/legacy/inode.c18
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c3
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.h1
-rw-r--r--drivers/usb/gadget/udc/core.c6
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c6
-rw-r--r--drivers/usb/host/ohci-at91.c24
-rw-r--r--drivers/usb/host/xhci-mem.c46
-rw-r--r--drivers/usb/host/xhci-mtk.c4
-rw-r--r--drivers/usb/host/xhci-pci.c3
-rw-r--r--drivers/usb/host/xhci-plat.c2
-rw-r--r--drivers/usb/host/xhci-ring.c262
-rw-r--r--drivers/usb/host/xhci.c17
-rw-r--r--drivers/usb/host/xhci.h5
-rw-r--r--drivers/usb/musb/blackfin.c1
-rw-r--r--drivers/usb/musb/musb_core.c2
-rw-r--r--drivers/usb/musb/musb_core.h7
-rw-r--r--drivers/usb/musb/musb_debugfs.c20
-rw-r--r--drivers/usb/musb/musb_dsps.c12
-rw-r--r--drivers/usb/musb/musb_host.c10
-rw-r--r--drivers/usb/musb/musbhsdma.h2
-rw-r--r--drivers/usb/serial/ch341.c108
-rw-r--r--drivers/usb/serial/cyberjack.c10
-rw-r--r--drivers/usb/serial/f81534.c8
-rw-r--r--drivers/usb/serial/garmin_gps.c1
-rw-r--r--drivers/usb/serial/io_edgeport.c5
-rw-r--r--drivers/usb/serial/io_ti.c22
-rw-r--r--drivers/usb/serial/iuu_phoenix.c11
-rw-r--r--drivers/usb/serial/keyspan_pda.c14
-rw-r--r--drivers/usb/serial/kl5kusb105.c9
-rw-r--r--drivers/usb/serial/kobil_sct.c12
-rw-r--r--drivers/usb/serial/mos7720.c56
-rw-r--r--drivers/usb/serial/mos7840.c24
-rw-r--r--drivers/usb/serial/omninet.c13
-rw-r--r--drivers/usb/serial/oti6858.c16
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/quatech2.c4
-rw-r--r--drivers/usb/serial/spcp8x5.c14
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c7
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/usb/wusbcore/crypto.c3
-rw-r--r--drivers/vfio/mdev/mdev_core.c100
-rw-r--r--drivers/vfio/mdev/mdev_private.h29
-rw-r--r--drivers/vfio/mdev/mdev_sysfs.c8
-rw-r--r--drivers/vfio/mdev/vfio_mdev.c12
-rw-r--r--drivers/vfio/pci/vfio_pci.c4
-rw-r--r--drivers/vfio/pci/vfio_pci_rdwr.c5
-rw-r--r--drivers/vfio/vfio_iommu_type1.c102
-rw-r--r--drivers/vhost/scsi.c4
-rw-r--r--drivers/video/fbdev/cobalt_lcdfb.c5
-rw-r--r--drivers/vme/bridges/vme_ca91cx42.c2
-rw-r--r--drivers/xen/arm-device.c8
-rw-r--r--drivers/xen/events/events_fifo.c3
-rw-r--r--drivers/xen/evtchn.c4
-rw-r--r--drivers/xen/platform-pci.c71
-rw-r--r--drivers/xen/swiotlb-xen.c8
-rw-r--r--drivers/xen/xenbus/xenbus_comms.h1
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c49
-rw-r--r--fs/aio.c6
-rw-r--r--fs/binfmt_elf.c1
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/btrfs/async-thread.c15
-rw-r--r--fs/btrfs/extent-tree.c8
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/btrfs/tree-log.c13
-rw-r--r--fs/btrfs/uuid-tree.c4
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/ceph/addr.c4
-rw-r--r--fs/ceph/caps.c7
-rw-r--r--fs/ceph/dir.c5
-rw-r--r--fs/ceph/inode.c3
-rw-r--r--fs/ceph/mds_client.c14
-rw-r--r--fs/coredump.c18
-rw-r--r--fs/crypto/keyinfo.c3
-rw-r--r--fs/crypto/policy.c5
-rw-r--r--fs/dax.c51
-rw-r--r--fs/direct-io.c3
-rw-r--r--fs/f2fs/segment.c4
-rw-r--r--fs/f2fs/super.c6
-rw-r--r--fs/fuse/dev.c3
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/nfs/nfs4proc.c29
-rw-r--r--fs/nfs/nfs4state.c1
-rw-r--r--fs/nfsd/nfs4xdr.c4
-rw-r--r--fs/notify/mark.c12
-rw-r--r--fs/ocfs2/dlmglue.c10
-rw-r--r--fs/ocfs2/stackglue.c6
-rw-r--r--fs/ocfs2/stackglue.h3
-rw-r--r--fs/overlayfs/namei.c27
-rw-r--r--fs/posix_acl.c9
-rw-r--r--fs/ubifs/Kconfig2
-rw-r--r--fs/ubifs/dir.c58
-rw-r--r--fs/ubifs/ioctl.c3
-rw-r--r--fs/ubifs/journal.c2
-rw-r--r--fs/ubifs/tnc.c25
-rw-r--r--fs/xfs/libxfs/xfs_ag_resv.c3
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c115
-rw-r--r--fs/xfs/libxfs/xfs_alloc.h2
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c3
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c3
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c39
-rw-r--r--fs/xfs/libxfs/xfs_dir2.h8
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c10
-rw-r--r--fs/xfs/libxfs/xfs_refcount_btree.c9
-rw-r--r--fs/xfs/libxfs/xfs_refcount_btree.h3
-rw-r--r--fs/xfs/libxfs/xfs_rmap_btree.c14
-rw-r--r--fs/xfs/libxfs/xfs_rmap_btree.h3
-rw-r--r--fs/xfs/xfs_aops.c19
-rw-r--r--fs/xfs/xfs_dquot.c4
-rw-r--r--fs/xfs/xfs_fsops.c14
-rw-r--r--fs/xfs/xfs_icache.c3
-rw-r--r--fs/xfs/xfs_iops.c50
-rw-r--r--fs/xfs/xfs_linux.h6
-rw-r--r--fs/xfs/xfs_log.c12
-rw-r--r--fs/xfs/xfs_refcount_item.c3
-rw-r--r--fs/xfs/xfs_sysfs.c4
-rw-r--r--include/asm-generic/asm-prototypes.h6
-rw-r--r--include/drm/drm_crtc_helper.h1
-rw-r--r--include/dt-bindings/mfd/tps65217.h26
-rw-r--r--include/kvm/arm_arch_timer.h1
-rw-r--r--include/linux/blkdev.h19
-rw-r--r--include/linux/bpf.h2
-rw-r--r--include/linux/coredump.h1
-rw-r--r--include/linux/cpuhotplug.h2
-rw-r--r--include/linux/efi.h2
-rw-r--r--include/linux/filter.h6
-rw-r--r--include/linux/fsnotify_backend.h2
-rw-r--r--include/linux/genhd.h9
-rw-r--r--include/linux/gfp.h22
-rw-r--r--include/linux/gpio/driver.h70
-rw-r--r--include/linux/i2c.h1
-rw-r--r--include/linux/iio/common/st_sensors.h12
-rw-r--r--include/linux/jump_label_ratelimit.h5
-rw-r--r--include/linux/kernel.h4
-rw-r--r--include/linux/mdev.h56
-rw-r--r--include/linux/memcontrol.h26
-rw-r--r--include/linux/mlx4/device.h2
-rw-r--r--include/linux/mlx5/device.h5
-rw-r--r--include/linux/mlx5/driver.h1
-rw-r--r--include/linux/mlx5/mlx5_ifc.h93
-rw-r--r--include/linux/mm.h4
-rw-r--r--include/linux/mm_inline.h2
-rw-r--r--include/linux/netdevice.h9
-rw-r--r--include/linux/perf_event.h1
-rw-r--r--include/linux/radix-tree.h4
-rw-r--r--include/linux/rcupdate.h4
-rw-r--r--include/linux/remoteproc.h4
-rw-r--r--include/linux/sched.h10
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--include/linux/slab.h4
-rw-r--r--include/linux/sunrpc/svc_xprt.h1
-rw-r--r--include/linux/swap.h3
-rw-r--r--include/linux/swiotlb.h11
-rw-r--r--include/linux/tcp.h7
-rw-r--r--include/linux/timerfd.h20
-rw-r--r--include/scsi/libfc.h6
-rw-r--r--include/sound/hdmi-codec.h8
-rw-r--r--include/sound/soc.h3
-rw-r--r--include/target/target_core_base.h4
-rw-r--r--include/trace/events/btrfs.h146
-rw-r--r--include/trace/events/mmflags.h3
-rw-r--r--include/trace/events/swiotlb.h17
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/nl80211.h4
-rw-r--r--include/uapi/linux/pkt_cls.h2
-rw-r--r--include/uapi/linux/tc_act/tc_bpf.h2
-rw-r--r--include/uapi/linux/timerfd.h36
-rw-r--r--include/uapi/linux/usb/functionfs.h1
-rw-r--r--init/Kconfig4
-rw-r--r--ipc/sem.c2
-rw-r--r--kernel/audit_tree.c18
-rw-r--r--kernel/bpf/arraymap.c2
-rw-r--r--kernel/bpf/core.c14
-rw-r--r--kernel/bpf/hashtab.c2
-rw-r--r--kernel/bpf/syscall.c8
-rw-r--r--kernel/bpf/verifier.c2
-rw-r--r--kernel/capability.c1
-rw-r--r--kernel/cpu.c24
-rw-r--r--kernel/events/core.c175
-rw-r--r--kernel/jump_label.c7
-rw-r--r--kernel/memremap.c4
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/panic.c2
-rw-r--r--kernel/rcu/rcu.h1
-rw-r--r--kernel/rcu/tiny.c4
-rw-r--r--kernel/rcu/tiny_plugin.h9
-rw-r--r--kernel/rcu/tree.c33
-rw-r--r--kernel/rcu/tree_exp.h52
-rw-r--r--kernel/rcu/tree_plugin.h2
-rw-r--r--kernel/rcu/update.c38
-rw-r--r--kernel/signal.c4
-rw-r--r--kernel/time/tick-sched.c9
-rw-r--r--kernel/time/tick-sched.h2
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--lib/iov_iter.c54
-rw-r--r--lib/radix-tree.c11
-rw-r--r--lib/swiotlb.c58
-rw-r--r--mm/filemap.c2
-rw-r--r--mm/huge_memory.c9
-rw-r--r--mm/hugetlb.c37
-rw-r--r--mm/khugepaged.c26
-rw-r--r--mm/memcontrol.c18
-rw-r--r--mm/memory.c88
-rw-r--r--mm/page_alloc.c49
-rw-r--r--mm/slab.c8
-rw-r--r--mm/swapfile.c20
-rw-r--r--mm/vmscan.c27
-rw-r--r--mm/workingset.c3
-rw-r--r--net/Kconfig4
-rw-r--r--net/atm/lec.c2
-rw-r--r--net/ax25/ax25_subr.c2
-rw-r--r--net/bridge/br_netfilter_hooks.c2
-rw-r--r--net/ceph/crypto.c2
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/drop_monitor.c39
-rw-r--r--net/core/flow_dissector.c9
-rw-r--r--net/core/rtnetlink.c6
-rw-r--r--net/core/skbuff.c8
-rw-r--r--net/core/sock.c6
-rw-r--r--net/dsa/dsa2.c11
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/fib_semantics.c20
-rw-r--r--net/ipv4/igmp.c7
-rw-r--r--net/ipv4/ip_sockglue.c8
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c34
-rw-r--r--net/ipv4/route.c5
-rw-r--r--net/ipv4/sysctl_net_ipv4.c2
-rw-r--r--net/ipv4/tcp_fastopen.c2
-rw-r--r--net/ipv4/tcp_metrics.c1
-rw-r--r--net/ipv6/ip6_offload.c1
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ip6_tunnel.c4
-rw-r--r--net/ipv6/ip6_vti.c2
-rw-r--r--net/ipv6/mcast.c51
-rw-r--r--net/ipv6/route.c7
-rw-r--r--net/ipv6/seg6_hmac.c2
-rw-r--r--net/ipv6/seg6_iptunnel.c4
-rw-r--r--net/iucv/af_iucv.c25
-rw-r--r--net/l2tp/l2tp_ip.c19
-rw-r--r--net/l2tp/l2tp_ip6.c24
-rw-r--r--net/mac80211/chan.c3
-rw-r--r--net/mac80211/iface.c21
-rw-r--r--net/mac80211/main.c13
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mac80211/rx.c38
-rw-r--r--net/mac80211/sta_info.c4
-rw-r--r--net/mac80211/tx.c20
-rw-r--r--net/mac80211/vht.c4
-rw-r--r--net/netfilter/nf_tables_api.c2
-rw-r--r--net/netfilter/nft_payload.c27
-rw-r--r--net/netfilter/nft_queue.c2
-rw-r--r--net/netfilter/nft_quota.c26
-rw-r--r--net/netlabel/netlabel_kapi.c5
-rw-r--r--net/openvswitch/conntrack.c6
-rw-r--r--net/qrtr/qrtr.c4
-rw-r--r--net/sched/act_api.c5
-rw-r--r--net/sched/act_bpf.c5
-rw-r--r--net/sched/cls_bpf.c4
-rw-r--r--net/sched/cls_flower.c4
-rw-r--r--net/sctp/outqueue.c2
-rw-r--r--net/socket.c4
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c2
-rw-r--r--net/sunrpc/svc_xprt.c10
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_recvfrom.c2
-rw-r--r--net/tipc/discover.c4
-rw-r--r--net/tipc/link.c2
-rw-r--r--net/tipc/msg.c16
-rw-r--r--net/tipc/msg.h2
-rw-r--r--net/tipc/name_distr.c2
-rw-r--r--net/wireless/nl80211.c31
-rw-r--r--samples/Kconfig7
-rw-r--r--samples/Makefile3
-rw-r--r--samples/bpf/sock_example.h2
-rw-r--r--samples/bpf/trace_output_user.c1
-rw-r--r--samples/vfio-mdev/Makefile14
-rw-r--r--samples/vfio-mdev/mtty.c55
-rw-r--r--scripts/gcc-plugins/gcc-common.h85
-rw-r--r--scripts/gcc-plugins/latent_entropy_plugin.c4
-rw-r--r--sound/firewire/fireworks/fireworks_stream.c2
-rw-r--r--sound/firewire/tascam/tascam-stream.c2
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/soc/codecs/nau8825.c9
-rw-r--r--sound/soc/codecs/nau8825.h7
-rw-r--r--sound/soc/codecs/rt5645.c3
-rw-r--r--sound/soc/codecs/tlv320aic3x.c13
-rw-r--r--sound/soc/codecs/wm_adsp.c25
-rw-r--r--sound/soc/dwc/designware_i2s.c25
-rw-r--r--sound/soc/fsl/fsl_ssi.c74
-rw-r--r--sound/soc/intel/boards/bytcr_rt5640.c18
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c3
-rw-r--r--sound/soc/intel/skylake/skl-sst.c3
-rw-r--r--sound/soc/sh/rcar/core.c4
-rw-r--r--sound/soc/soc-core.c10
-rw-r--r--sound/soc/soc-pcm.c4
-rw-r--r--sound/soc/soc-topology.c3
-rw-r--r--sound/usb/endpoint.c20
-rw-r--r--sound/usb/endpoint.h2
-rw-r--r--sound/usb/pcm.c10
-rw-r--r--sound/usb/quirks.c1
-rw-r--r--tools/lib/subcmd/parse-options.c3
-rw-r--r--tools/lib/subcmd/parse-options.h5
-rw-r--r--tools/lib/traceevent/plugin_sched_switch.c4
-rw-r--r--tools/perf/Documentation/perf-record.txt4
-rw-r--r--tools/perf/Makefile.perf4
-rw-r--r--tools/perf/builtin-kmem.c1
-rw-r--r--tools/perf/builtin-record.c4
-rw-r--r--tools/perf/builtin-sched.c17
-rw-r--r--tools/perf/util/probe-event.c166
-rw-r--r--tools/perf/util/probe-finder.c15
-rw-r--r--tools/perf/util/probe-finder.h3
-rw-r--r--tools/perf/util/symbol-elf.c6
-rw-r--r--tools/testing/selftests/Makefile2
-rwxr-xr-xtools/testing/selftests/bpf/test_kmod.sh2
-rwxr-xr-xtools/testing/selftests/net/run_netsocktests2
-rw-r--r--tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c2
-rw-r--r--tools/testing/selftests/x86/protection_keys.c2
-rw-r--r--tools/virtio/ringtest/main.h12
-rwxr-xr-xtools/virtio/ringtest/run-on-all.sh5
-rw-r--r--usr/Makefile16
-rw-r--r--virt/kvm/arm/arch_timer.c26
-rw-r--r--virt/kvm/arm/hyp/timer-sr.c33
-rw-r--r--virt/kvm/arm/vgic/vgic-init.c18
-rw-r--r--virt/kvm/arm/vgic/vgic-v2.c2
-rw-r--r--virt/kvm/arm/vgic/vgic-v3.c2
-rw-r--r--virt/lib/irqbypass.c4
843 files changed, 8015 insertions, 4932 deletions
diff --git a/.mailmap b/.mailmap
index 02d261407683..67dc22ffc9a8 100644
--- a/.mailmap
+++ b/.mailmap
@@ -137,6 +137,7 @@ Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
137Rudolf Marek <R.Marek@sh.cvut.cz> 137Rudolf Marek <R.Marek@sh.cvut.cz>
138Rui Saraiva <rmps@joel.ist.utl.pt> 138Rui Saraiva <rmps@joel.ist.utl.pt>
139Sachin P Sant <ssant@in.ibm.com> 139Sachin P Sant <ssant@in.ibm.com>
140Sarangdhar Joshi <spjoshi@codeaurora.org>
140Sam Ravnborg <sam@mars.ravnborg.org> 141Sam Ravnborg <sam@mars.ravnborg.org>
141Santosh Shilimkar <ssantosh@kernel.org> 142Santosh Shilimkar <ssantosh@kernel.org>
142Santosh Shilimkar <santosh.shilimkar@oracle.org> 143Santosh Shilimkar <santosh.shilimkar@oracle.org>
@@ -150,10 +151,13 @@ Shuah Khan <shuah@kernel.org> <shuah.kh@samsung.com>
150Simon Kelley <simon@thekelleys.org.uk> 151Simon Kelley <simon@thekelleys.org.uk>
151Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr> 152Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr>
152Stephen Hemminger <shemminger@osdl.org> 153Stephen Hemminger <shemminger@osdl.org>
154Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
155Subhash Jadavani <subhashj@codeaurora.org>
153Sudeep Holla <sudeep.holla@arm.com> Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com> 156Sudeep Holla <sudeep.holla@arm.com> Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
154Sumit Semwal <sumit.semwal@ti.com> 157Sumit Semwal <sumit.semwal@ti.com>
155Tejun Heo <htejun@gmail.com> 158Tejun Heo <htejun@gmail.com>
156Thomas Graf <tgraf@suug.ch> 159Thomas Graf <tgraf@suug.ch>
160Thomas Pedersen <twp@codeaurora.org>
157Tony Luck <tony.luck@intel.com> 161Tony Luck <tony.luck@intel.com>
158Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com> 162Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com>
159Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> 163Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
diff --git a/Documentation/ABI/testing/sysfs-devices-deferred_probe b/Documentation/ABI/testing/sysfs-devices-deferred_probe
deleted file mode 100644
index 58553d7a321f..000000000000
--- a/Documentation/ABI/testing/sysfs-devices-deferred_probe
+++ /dev/null
@@ -1,12 +0,0 @@
1What: /sys/devices/.../deferred_probe
2Date: August 2016
3Contact: Ben Hutchings <ben.hutchings@codethink.co.uk>
4Description:
5 The /sys/devices/.../deferred_probe attribute is
6 present for all devices. If a driver detects during
7 probing a device that a related device is not yet
8 ready, it may defer probing of the first device. The
9 kernel will retry probing the first device after any
10 other device is successfully probed. This attribute
11 reads as 1 if probing of this device is currently
12 deferred, or 0 otherwise.
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 21e2d8863705..be7c0d9506b1 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -106,6 +106,16 @@
106 use by PCI 106 use by PCI
107 Format: <irq>,<irq>... 107 Format: <irq>,<irq>...
108 108
109 acpi_mask_gpe= [HW,ACPI]
110 Due to the existence of _Lxx/_Exx, some GPEs triggered
111 by unsupported hardware/firmware features can result in
112 GPE floodings that cannot be automatically disabled by
113 the GPE dispatcher.
114 This facility can be used to prevent such uncontrolled
115 GPE floodings.
116 Format: <int>
117 Support masking of GPEs numbered from 0x00 to 0x7f.
118
109 acpi_no_auto_serialize [HW,ACPI] 119 acpi_no_auto_serialize [HW,ACPI]
110 Disable auto-serialization of AML methods 120 Disable auto-serialization of AML methods
111 AML control methods that contain the opcodes to create 121 AML control methods that contain the opcodes to create
@@ -3811,10 +3821,11 @@
3811 it if 0 is given (See Documentation/cgroup-v1/memory.txt) 3821 it if 0 is given (See Documentation/cgroup-v1/memory.txt)
3812 3822
3813 swiotlb= [ARM,IA-64,PPC,MIPS,X86] 3823 swiotlb= [ARM,IA-64,PPC,MIPS,X86]
3814 Format: { <int> | force } 3824 Format: { <int> | force | noforce }
3815 <int> -- Number of I/O TLB slabs 3825 <int> -- Number of I/O TLB slabs
3816 force -- force using of bounce buffers even if they 3826 force -- force using of bounce buffers even if they
3817 wouldn't be automatically used by the kernel 3827 wouldn't be automatically used by the kernel
3828 noforce -- Never use bounce buffers (for debugging)
3818 3829
3819 switches= [HW,M68k] 3830 switches= [HW,M68k]
3820 3831
diff --git a/Documentation/block/queue-sysfs.txt b/Documentation/block/queue-sysfs.txt
index 51642159aedb..c0a3bb5a6e4e 100644
--- a/Documentation/block/queue-sysfs.txt
+++ b/Documentation/block/queue-sysfs.txt
@@ -54,9 +54,9 @@ This is the hardware sector size of the device, in bytes.
54 54
55io_poll (RW) 55io_poll (RW)
56------------ 56------------
57When read, this file shows the total number of block IO polls and how 57When read, this file shows whether polling is enabled (1) or disabled
58many returned success. Writing '0' to this file will disable polling 58(0). Writing '0' to this file will disable polling for this device.
59for this device. Writing any non-zero value will enable this feature. 59Writing any non-zero value will enable this feature.
60 60
61io_poll_delay (RW) 61io_poll_delay (RW)
62------------------ 62------------------
diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt
index 5fa691e6f638..cee9d5055fa2 100644
--- a/Documentation/devicetree/bindings/i2c/i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c.txt
@@ -62,6 +62,9 @@ wants to support one of the below features, it should adapt the bindings below.
62 "irq" and "wakeup" names are recognized by I2C core, other names are 62 "irq" and "wakeup" names are recognized by I2C core, other names are
63 left to individual drivers. 63 left to individual drivers.
64 64
65- host-notify
66 device uses SMBus host notify protocol instead of interrupt line.
67
65- multi-master 68- multi-master
66 states that there is another master active on this bus. The OS can use 69 states that there is another master active on this bus. The OS can use
67 this information to adapt power management to keep the arbitration awake 70 this information to adapt power management to keep the arbitration awake
@@ -81,6 +84,11 @@ Binding may contain optional "interrupts" property, describing interrupts
81used by the device. I2C core will assign "irq" interrupt (or the very first 84used by the device. I2C core will assign "irq" interrupt (or the very first
82interrupt if not using interrupt names) as primary interrupt for the slave. 85interrupt if not using interrupt names) as primary interrupt for the slave.
83 86
87Alternatively, devices supporting SMbus Host Notify, and connected to
88adapters that support this feature, may use "host-notify" property. I2C
89core will create a virtual interrupt for Host Notify and assign it as
90primary interrupt for the slave.
91
84Also, if device is marked as a wakeup source, I2C core will set up "wakeup" 92Also, if device is marked as a wakeup source, I2C core will set up "wakeup"
85interrupt for the device. If "wakeup" interrupt name is not present in the 93interrupt for the device. If "wakeup" interrupt name is not present in the
86binding, then primary interrupt will be used as wakeup interrupt. 94binding, then primary interrupt will be used as wakeup interrupt.
diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
index 3e5b9793341f..8682ab6d4a50 100644
--- a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
@@ -8,8 +8,9 @@ This driver provides a simple power button event via an Interrupt.
8Required properties: 8Required properties:
9- compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton" 9- compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton"
10 10
11Required properties for TPS65218: 11Required properties:
12- interrupts: should be one of the following 12- interrupts: should be one of the following
13 - <2>: For controllers compatible with tps65217
13 - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218 14 - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218
14 15
15Examples: 16Examples:
@@ -17,6 +18,7 @@ Examples:
17&tps { 18&tps {
18 tps65217-pwrbutton { 19 tps65217-pwrbutton {
19 compatible = "ti,tps65217-pwrbutton"; 20 compatible = "ti,tps65217-pwrbutton";
21 interrupts = <2>;
20 }; 22 };
21}; 23};
22 24
diff --git a/Documentation/devicetree/bindings/mtd/tango-nand.txt b/Documentation/devicetree/bindings/mtd/tango-nand.txt
index ad5a02f2ac8c..cd1bf2ac9055 100644
--- a/Documentation/devicetree/bindings/mtd/tango-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/tango-nand.txt
@@ -5,7 +5,7 @@ Required properties:
5- compatible: "sigma,smp8758-nand" 5- compatible: "sigma,smp8758-nand"
6- reg: address/size of nfc_reg, nfc_mem, and pbus_reg 6- reg: address/size of nfc_reg, nfc_mem, and pbus_reg
7- dmas: reference to the DMA channel used by the controller 7- dmas: reference to the DMA channel used by the controller
8- dma-names: "nfc_sbox" 8- dma-names: "rxtx"
9- clocks: reference to the system clock 9- clocks: reference to the system clock
10- #address-cells: <1> 10- #address-cells: <1>
11- #size-cells: <0> 11- #size-cells: <0>
@@ -17,9 +17,9 @@ Example:
17 17
18 nandc: nand-controller@2c000 { 18 nandc: nand-controller@2c000 {
19 compatible = "sigma,smp8758-nand"; 19 compatible = "sigma,smp8758-nand";
20 reg = <0x2c000 0x30 0x2d000 0x800 0x20000 0x1000>; 20 reg = <0x2c000 0x30>, <0x2d000 0x800>, <0x20000 0x1000>;
21 dmas = <&dma0 3>; 21 dmas = <&dma0 3>;
22 dma-names = "nfc_sbox"; 22 dma-names = "rxtx";
23 clocks = <&clkgen SYS_CLK>; 23 clocks = <&clkgen SYS_CLK>;
24 #address-cells = <1>; 24 #address-cells = <1>;
25 #size-cells = <0>; 25 #size-cells = <0>;
diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.txt b/Documentation/devicetree/bindings/net/ti,dp83867.txt
index 85bf945b898f..afe9630a5e7d 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.txt
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.txt
@@ -3,9 +3,11 @@
3Required properties: 3Required properties:
4 - reg - The ID number for the phy, usually a small integer 4 - reg - The ID number for the phy, usually a small integer
5 - ti,rx-internal-delay - RGMII Receive Clock Delay - see dt-bindings/net/ti-dp83867.h 5 - ti,rx-internal-delay - RGMII Receive Clock Delay - see dt-bindings/net/ti-dp83867.h
6 for applicable values 6 for applicable values. Required only if interface type is
7 PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_RXID
7 - ti,tx-internal-delay - RGMII Transmit Clock Delay - see dt-bindings/net/ti-dp83867.h 8 - ti,tx-internal-delay - RGMII Transmit Clock Delay - see dt-bindings/net/ti-dp83867.h
8 for applicable values 9 for applicable values. Required only if interface type is
10 PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_TXID
9 - ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h 11 - ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h
10 for applicable values 12 for applicable values
11 13
diff --git a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
index 98d131acee95..a11072c5a866 100644
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
@@ -2,11 +2,16 @@ TPS65217 Charger
2 2
3Required Properties: 3Required Properties:
4-compatible: "ti,tps65217-charger" 4-compatible: "ti,tps65217-charger"
5-interrupts: TPS65217 interrupt numbers for the AC and USB charger input change.
6 Should be <0> for the USB charger and <1> for the AC adapter.
7-interrupt-names: Should be "USB" and "AC"
5 8
6This node is a subnode of the tps65217 PMIC. 9This node is a subnode of the tps65217 PMIC.
7 10
8Example: 11Example:
9 12
10 tps65217-charger { 13 tps65217-charger {
11 compatible = "ti,tps65090-charger"; 14 compatible = "ti,tps65217-charger";
15 interrupts = <0>, <1>;
16 interrupt-names = "USB", "AC";
12 }; 17 };
diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index da6614c63796..dc975064fa27 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -1,17 +1,23 @@
1Renesas MSIOF spi controller 1Renesas MSIOF spi controller
2 2
3Required properties: 3Required properties:
4- compatible : "renesas,msiof-<soctype>" for SoCs, 4- compatible : "renesas,msiof-r8a7790" (R-Car H2)
5 "renesas,sh-msiof" for SuperH, or
6 "renesas,sh-mobile-msiof" for SH Mobile series.
7 Examples with soctypes are:
8 "renesas,msiof-r8a7790" (R-Car H2)
9 "renesas,msiof-r8a7791" (R-Car M2-W) 5 "renesas,msiof-r8a7791" (R-Car M2-W)
10 "renesas,msiof-r8a7792" (R-Car V2H) 6 "renesas,msiof-r8a7792" (R-Car V2H)
11 "renesas,msiof-r8a7793" (R-Car M2-N) 7 "renesas,msiof-r8a7793" (R-Car M2-N)
12 "renesas,msiof-r8a7794" (R-Car E2) 8 "renesas,msiof-r8a7794" (R-Car E2)
13 "renesas,msiof-r8a7796" (R-Car M3-W) 9 "renesas,msiof-r8a7796" (R-Car M3-W)
14 "renesas,msiof-sh73a0" (SH-Mobile AG5) 10 "renesas,msiof-sh73a0" (SH-Mobile AG5)
11 "renesas,sh-mobile-msiof" (generic SH-Mobile compatibile device)
12 "renesas,rcar-gen2-msiof" (generic R-Car Gen2 compatible device)
13 "renesas,rcar-gen3-msiof" (generic R-Car Gen3 compatible device)
14 "renesas,sh-msiof" (deprecated)
15
16 When compatible with the generic version, nodes
17 must list the SoC-specific version corresponding
18 to the platform first followed by the generic
19 version.
20
15- reg : A list of offsets and lengths of the register sets for 21- reg : A list of offsets and lengths of the register sets for
16 the device. 22 the device.
17 If only one register set is present, it is to be used 23 If only one register set is present, it is to be used
@@ -61,7 +67,8 @@ Documentation/devicetree/bindings/pinctrl/renesas,*.
61Example: 67Example:
62 68
63 msiof0: spi@e6e20000 { 69 msiof0: spi@e6e20000 {
64 compatible = "renesas,msiof-r8a7791"; 70 compatible = "renesas,msiof-r8a7791",
71 "renesas,rcar-gen2-msiof";
65 reg = <0 0xe6e20000 0 0x0064>; 72 reg = <0 0xe6e20000 0 0x0064>;
66 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; 73 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
67 clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; 74 clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
diff --git a/Documentation/driver-api/infrastructure.rst b/Documentation/driver-api/infrastructure.rst
index 0bb0b5fc9512..6d9ff316b608 100644
--- a/Documentation/driver-api/infrastructure.rst
+++ b/Documentation/driver-api/infrastructure.rst
@@ -55,21 +55,6 @@ Device Drivers DMA Management
55.. kernel-doc:: drivers/base/dma-mapping.c 55.. kernel-doc:: drivers/base/dma-mapping.c
56 :export: 56 :export:
57 57
58Device Drivers Power Management
59-------------------------------
60
61.. kernel-doc:: drivers/base/power/main.c
62 :export:
63
64Device Drivers ACPI Support
65---------------------------
66
67.. kernel-doc:: drivers/acpi/scan.c
68 :export:
69
70.. kernel-doc:: drivers/acpi/scan.c
71 :internal:
72
73Device drivers PnP support 58Device drivers PnP support
74-------------------------- 59--------------------------
75 60
diff --git a/Documentation/networking/mpls-sysctl.txt b/Documentation/networking/mpls-sysctl.txt
index 9ed15f86c17c..15d8d16934fd 100644
--- a/Documentation/networking/mpls-sysctl.txt
+++ b/Documentation/networking/mpls-sysctl.txt
@@ -5,8 +5,8 @@ platform_labels - INTEGER
5 possible to configure forwarding for label values equal to or 5 possible to configure forwarding for label values equal to or
6 greater than the number of platform labels. 6 greater than the number of platform labels.
7 7
8 A dense utliziation of the entries in the platform label table 8 A dense utilization of the entries in the platform label table
9 is possible and expected aas the platform labels are locally 9 is possible and expected as the platform labels are locally
10 allocated. 10 allocated.
11 11
12 If the number of platform label table entries is set to 0 no 12 If the number of platform label table entries is set to 0 no
diff --git a/Documentation/vfio-mediated-device.txt b/Documentation/vfio-mediated-device.txt
index b38afec35edc..d226c7a5ba8b 100644
--- a/Documentation/vfio-mediated-device.txt
+++ b/Documentation/vfio-mediated-device.txt
@@ -127,22 +127,22 @@ the VFIO when devices are unbound from the driver.
127Physical Device Driver Interface 127Physical Device Driver Interface
128-------------------------------- 128--------------------------------
129 129
130The physical device driver interface provides the parent_ops[3] structure to 130The physical device driver interface provides the mdev_parent_ops[3] structure
131define the APIs to manage work in the mediated core driver that is related to 131to define the APIs to manage work in the mediated core driver that is related
132the physical device. 132to the physical device.
133 133
134The structures in the parent_ops structure are as follows: 134The structures in the mdev_parent_ops structure are as follows:
135 135
136* dev_attr_groups: attributes of the parent device 136* dev_attr_groups: attributes of the parent device
137* mdev_attr_groups: attributes of the mediated device 137* mdev_attr_groups: attributes of the mediated device
138* supported_config: attributes to define supported configurations 138* supported_config: attributes to define supported configurations
139 139
140The functions in the parent_ops structure are as follows: 140The functions in the mdev_parent_ops structure are as follows:
141 141
142* create: allocate basic resources in a driver for a mediated device 142* create: allocate basic resources in a driver for a mediated device
143* remove: free resources in a driver when a mediated device is destroyed 143* remove: free resources in a driver when a mediated device is destroyed
144 144
145The callbacks in the parent_ops structure are as follows: 145The callbacks in the mdev_parent_ops structure are as follows:
146 146
147* open: open callback of mediated device 147* open: open callback of mediated device
148* close: close callback of mediated device 148* close: close callback of mediated device
@@ -151,14 +151,14 @@ The callbacks in the parent_ops structure are as follows:
151* write: write emulation callback 151* write: write emulation callback
152* mmap: mmap emulation callback 152* mmap: mmap emulation callback
153 153
154A driver should use the parent_ops structure in the function call to register 154A driver should use the mdev_parent_ops structure in the function call to
155itself with the mdev core driver: 155register itself with the mdev core driver:
156 156
157extern int mdev_register_device(struct device *dev, 157extern int mdev_register_device(struct device *dev,
158 const struct parent_ops *ops); 158 const struct mdev_parent_ops *ops);
159 159
160However, the parent_ops structure is not required in the function call that a 160However, the mdev_parent_ops structure is not required in the function call
161driver should use to unregister itself with the mdev core driver: 161that a driver should use to unregister itself with the mdev core driver:
162 162
163extern void mdev_unregister_device(struct device *dev); 163extern void mdev_unregister_device(struct device *dev);
164 164
@@ -223,6 +223,9 @@ Directories and files under the sysfs for Each Physical Device
223 223
224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name); 224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name);
225 225
226 (or using mdev_parent_dev(mdev) to arrive at the parent device outside
227 of the core mdev code)
228
226* device_api 229* device_api
227 230
228 This attribute should show which device API is being created, for example, 231 This attribute should show which device API is being created, for example,
@@ -394,5 +397,5 @@ References
394 397
395[1] See Documentation/vfio.txt for more information on VFIO. 398[1] See Documentation/vfio.txt for more information on VFIO.
396[2] struct mdev_driver in include/linux/mdev.h 399[2] struct mdev_driver in include/linux/mdev.h
397[3] struct parent_ops in include/linux/mdev.h 400[3] struct mdev_parent_ops in include/linux/mdev.h
398[4] struct vfio_iommu_driver_ops in include/linux/vfio.h 401[4] struct vfio_iommu_driver_ops in include/linux/vfio.h
diff --git a/Documentation/vm/page_frags b/Documentation/vm/page_frags
new file mode 100644
index 000000000000..a6714565dbf9
--- /dev/null
+++ b/Documentation/vm/page_frags
@@ -0,0 +1,42 @@
1Page fragments
2--------------
3
4A page fragment is an arbitrary-length arbitrary-offset area of memory
5which resides within a 0 or higher order compound page. Multiple
6fragments within that page are individually refcounted, in the page's
7reference counter.
8
9The page_frag functions, page_frag_alloc and page_frag_free, provide a
10simple allocation framework for page fragments. This is used by the
11network stack and network device drivers to provide a backing region of
12memory for use as either an sk_buff->head, or to be used in the "frags"
13portion of skb_shared_info.
14
15In order to make use of the page fragment APIs a backing page fragment
16cache is needed. This provides a central point for the fragment allocation
17and tracks allows multiple calls to make use of a cached page. The
18advantage to doing this is that multiple calls to get_page can be avoided
19which can be expensive at allocation time. However due to the nature of
20this caching it is required that any calls to the cache be protected by
21either a per-cpu limitation, or a per-cpu limitation and forcing interrupts
22to be disabled when executing the fragment allocation.
23
24The network stack uses two separate caches per CPU to handle fragment
25allocation. The netdev_alloc_cache is used by callers making use of the
26__netdev_alloc_frag and __netdev_alloc_skb calls. The napi_alloc_cache is
27used by callers of the __napi_alloc_frag and __napi_alloc_skb calls. The
28main difference between these two calls is the context in which they may be
29called. The "netdev" prefixed functions are usable in any context as these
30functions will disable interrupts, while the "napi" prefixed functions are
31only usable within the softirq context.
32
33Many network device drivers use a similar methodology for allocating page
34fragments, but the page fragments are cached at the ring or descriptor
35level. In order to enable these cases it is necessary to provide a generic
36way of tearing down a page cache. For this reason __page_frag_cache_drain
37was implemented. It allows for freeing multiple references from a single
38page via a single call. The advantage to doing this is that it allows for
39cleaning up the multiple references that were added to a page in order to
40avoid calling get_page per allocation.
41
42Alexander Duyck, Nov 29, 2016.
diff --git a/MAINTAINERS b/MAINTAINERS
index cfff2c9e3d94..2fd11b439ab3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -81,7 +81,6 @@ Descriptions of section entries:
81 Q: Patchwork web based patch tracking system site 81 Q: Patchwork web based patch tracking system site
82 T: SCM tree type and location. 82 T: SCM tree type and location.
83 Type is one of: git, hg, quilt, stgit, topgit 83 Type is one of: git, hg, quilt, stgit, topgit
84 B: Bug tracking system location.
85 S: Status, one of the following: 84 S: Status, one of the following:
86 Supported: Someone is actually paid to look after this. 85 Supported: Someone is actually paid to look after this.
87 Maintained: Someone actually looks after it. 86 Maintained: Someone actually looks after it.
@@ -977,6 +976,7 @@ M: Russell King <linux@armlinux.org.uk>
977L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 976L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
978W: http://www.armlinux.org.uk/ 977W: http://www.armlinux.org.uk/
979S: Maintained 978S: Maintained
979T: git git://git.armlinux.org.uk/~rmk/linux-arm.git
980F: arch/arm/ 980F: arch/arm/
981 981
982ARM SUB-ARCHITECTURES 982ARM SUB-ARCHITECTURES
@@ -1154,6 +1154,7 @@ ARM/CLKDEV SUPPORT
1154M: Russell King <linux@armlinux.org.uk> 1154M: Russell King <linux@armlinux.org.uk>
1155L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1155L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1156S: Maintained 1156S: Maintained
1157T: git git://git.armlinux.org.uk/~rmk/linux-arm.git clkdev
1157F: arch/arm/include/asm/clkdev.h 1158F: arch/arm/include/asm/clkdev.h
1158F: drivers/clk/clkdev.c 1159F: drivers/clk/clkdev.c
1159 1160
@@ -1689,6 +1690,7 @@ M: Krzysztof Kozlowski <krzk@kernel.org>
1689R: Javier Martinez Canillas <javier@osg.samsung.com> 1690R: Javier Martinez Canillas <javier@osg.samsung.com>
1690L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1691L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1691L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 1692L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
1693Q: https://patchwork.kernel.org/project/linux-samsung-soc/list/
1692S: Maintained 1694S: Maintained
1693F: arch/arm/boot/dts/s3c* 1695F: arch/arm/boot/dts/s3c*
1694F: arch/arm/boot/dts/s5p* 1696F: arch/arm/boot/dts/s5p*
@@ -2194,14 +2196,6 @@ L: alsa-devel@alsa-project.org (moderated for non-subscribers)
2194S: Supported 2196S: Supported
2195F: sound/soc/atmel 2197F: sound/soc/atmel
2196 2198
2197ATMEL DMA DRIVER
2198M: Nicolas Ferre <nicolas.ferre@atmel.com>
2199L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
2200S: Supported
2201F: drivers/dma/at_hdmac.c
2202F: drivers/dma/at_hdmac_regs.h
2203F: include/linux/platform_data/dma-atmel.h
2204
2205ATMEL XDMA DRIVER 2199ATMEL XDMA DRIVER
2206M: Ludovic Desroches <ludovic.desroches@atmel.com> 2200M: Ludovic Desroches <ludovic.desroches@atmel.com>
2207L: linux-arm-kernel@lists.infradead.org 2201L: linux-arm-kernel@lists.infradead.org
@@ -3800,6 +3794,7 @@ F: include/linux/devcoredump.h
3800DEVICE FREQUENCY (DEVFREQ) 3794DEVICE FREQUENCY (DEVFREQ)
3801M: MyungJoo Ham <myungjoo.ham@samsung.com> 3795M: MyungJoo Ham <myungjoo.ham@samsung.com>
3802M: Kyungmin Park <kyungmin.park@samsung.com> 3796M: Kyungmin Park <kyungmin.park@samsung.com>
3797R: Chanwoo Choi <cw00.choi@samsung.com>
3803L: linux-pm@vger.kernel.org 3798L: linux-pm@vger.kernel.org
3804T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git 3799T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git
3805S: Maintained 3800S: Maintained
@@ -4105,18 +4100,24 @@ F: drivers/gpu/drm/bridge/
4105 4100
4106DRM DRIVER FOR BOCHS VIRTUAL GPU 4101DRM DRIVER FOR BOCHS VIRTUAL GPU
4107M: Gerd Hoffmann <kraxel@redhat.com> 4102M: Gerd Hoffmann <kraxel@redhat.com>
4108S: Odd Fixes 4103L: virtualization@lists.linux-foundation.org
4104T: git git://git.kraxel.org/linux drm-qemu
4105S: Maintained
4109F: drivers/gpu/drm/bochs/ 4106F: drivers/gpu/drm/bochs/
4110 4107
4111DRM DRIVER FOR QEMU'S CIRRUS DEVICE 4108DRM DRIVER FOR QEMU'S CIRRUS DEVICE
4112M: Dave Airlie <airlied@redhat.com> 4109M: Dave Airlie <airlied@redhat.com>
4113S: Odd Fixes 4110M: Gerd Hoffmann <kraxel@redhat.com>
4111L: virtualization@lists.linux-foundation.org
4112T: git git://git.kraxel.org/linux drm-qemu
4113S: Obsolete
4114W: https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
4114F: drivers/gpu/drm/cirrus/ 4115F: drivers/gpu/drm/cirrus/
4115 4116
4116RADEON and AMDGPU DRM DRIVERS 4117RADEON and AMDGPU DRM DRIVERS
4117M: Alex Deucher <alexander.deucher@amd.com> 4118M: Alex Deucher <alexander.deucher@amd.com>
4118M: Christian König <christian.koenig@amd.com> 4119M: Christian König <christian.koenig@amd.com>
4119L: dri-devel@lists.freedesktop.org 4120L: amd-gfx@lists.freedesktop.org
4120T: git git://people.freedesktop.org/~agd5f/linux 4121T: git git://people.freedesktop.org/~agd5f/linux
4121S: Supported 4122S: Supported
4122F: drivers/gpu/drm/radeon/ 4123F: drivers/gpu/drm/radeon/
@@ -4303,7 +4304,10 @@ F: Documentation/devicetree/bindings/display/renesas,du.txt
4303 4304
4304DRM DRIVER FOR QXL VIRTUAL GPU 4305DRM DRIVER FOR QXL VIRTUAL GPU
4305M: Dave Airlie <airlied@redhat.com> 4306M: Dave Airlie <airlied@redhat.com>
4306S: Odd Fixes 4307M: Gerd Hoffmann <kraxel@redhat.com>
4308L: virtualization@lists.linux-foundation.org
4309T: git git://git.kraxel.org/linux drm-qemu
4310S: Maintained
4307F: drivers/gpu/drm/qxl/ 4311F: drivers/gpu/drm/qxl/
4308F: include/uapi/drm/qxl_drm.h 4312F: include/uapi/drm/qxl_drm.h
4309 4313
@@ -5080,9 +5084,11 @@ F: drivers/net/wan/dlci.c
5080F: drivers/net/wan/sdla.c 5084F: drivers/net/wan/sdla.c
5081 5085
5082FRAMEBUFFER LAYER 5086FRAMEBUFFER LAYER
5087M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
5083L: linux-fbdev@vger.kernel.org 5088L: linux-fbdev@vger.kernel.org
5089T: git git://github.com/bzolnier/linux.git
5084Q: http://patchwork.kernel.org/project/linux-fbdev/list/ 5090Q: http://patchwork.kernel.org/project/linux-fbdev/list/
5085S: Orphan 5091S: Maintained
5086F: Documentation/fb/ 5092F: Documentation/fb/
5087F: drivers/video/ 5093F: drivers/video/
5088F: include/video/ 5094F: include/video/
@@ -5504,6 +5510,7 @@ M: Alex Elder <elder@kernel.org>
5504M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 5510M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5505S: Maintained 5511S: Maintained
5506F: drivers/staging/greybus/ 5512F: drivers/staging/greybus/
5513L: greybus-dev@lists.linaro.org
5507 5514
5508GREYBUS AUDIO PROTOCOLS DRIVERS 5515GREYBUS AUDIO PROTOCOLS DRIVERS
5509M: Vaibhav Agarwal <vaibhav.sr@gmail.com> 5516M: Vaibhav Agarwal <vaibhav.sr@gmail.com>
@@ -5961,6 +5968,7 @@ F: drivers/media/platform/sti/hva
5961Hyper-V CORE AND DRIVERS 5968Hyper-V CORE AND DRIVERS
5962M: "K. Y. Srinivasan" <kys@microsoft.com> 5969M: "K. Y. Srinivasan" <kys@microsoft.com>
5963M: Haiyang Zhang <haiyangz@microsoft.com> 5970M: Haiyang Zhang <haiyangz@microsoft.com>
5971M: Stephen Hemminger <sthemmin@microsoft.com>
5964L: devel@linuxdriverproject.org 5972L: devel@linuxdriverproject.org
5965S: Maintained 5973S: Maintained
5966F: arch/x86/include/asm/mshyperv.h 5974F: arch/x86/include/asm/mshyperv.h
@@ -7701,8 +7709,10 @@ F: drivers/net/dsa/mv88e6xxx/
7701F: Documentation/devicetree/bindings/net/dsa/marvell.txt 7709F: Documentation/devicetree/bindings/net/dsa/marvell.txt
7702 7710
7703MARVELL ARMADA DRM SUPPORT 7711MARVELL ARMADA DRM SUPPORT
7704M: Russell King <rmk+kernel@armlinux.org.uk> 7712M: Russell King <linux@armlinux.org.uk>
7705S: Maintained 7713S: Maintained
7714T: git git://git.armlinux.org.uk/~rmk/linux-arm.git drm-armada-devel
7715T: git git://git.armlinux.org.uk/~rmk/linux-arm.git drm-armada-fixes
7706F: drivers/gpu/drm/armada/ 7716F: drivers/gpu/drm/armada/
7707F: include/uapi/drm/armada_drm.h 7717F: include/uapi/drm/armada_drm.h
7708F: Documentation/devicetree/bindings/display/armada/ 7718F: Documentation/devicetree/bindings/display/armada/
@@ -8174,6 +8184,15 @@ S: Maintained
8174F: drivers/tty/serial/atmel_serial.c 8184F: drivers/tty/serial/atmel_serial.c
8175F: include/linux/atmel_serial.h 8185F: include/linux/atmel_serial.h
8176 8186
8187MICROCHIP / ATMEL DMA DRIVER
8188M: Ludovic Desroches <ludovic.desroches@microchip.com>
8189L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
8190L: dmaengine@vger.kernel.org
8191S: Supported
8192F: drivers/dma/at_hdmac.c
8193F: drivers/dma/at_hdmac_regs.h
8194F: include/linux/platform_data/dma-atmel.h
8195
8177MICROCHIP / ATMEL ISC DRIVER 8196MICROCHIP / ATMEL ISC DRIVER
8178M: Songjun Wu <songjun.wu@microchip.com> 8197M: Songjun Wu <songjun.wu@microchip.com>
8179L: linux-media@vger.kernel.org 8198L: linux-media@vger.kernel.org
@@ -8852,17 +8871,22 @@ F: drivers/video/fbdev/nvidia/
8852NVM EXPRESS DRIVER 8871NVM EXPRESS DRIVER
8853M: Keith Busch <keith.busch@intel.com> 8872M: Keith Busch <keith.busch@intel.com>
8854M: Jens Axboe <axboe@fb.com> 8873M: Jens Axboe <axboe@fb.com>
8874M: Christoph Hellwig <hch@lst.de>
8875M: Sagi Grimberg <sagi@grimberg.me>
8855L: linux-nvme@lists.infradead.org 8876L: linux-nvme@lists.infradead.org
8856T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 8877T: git://git.infradead.org/nvme.git
8857W: https://kernel.googlesource.com/pub/scm/linux/kernel/git/axboe/linux-block/ 8878W: http://git.infradead.org/nvme.git
8858S: Supported 8879S: Supported
8859F: drivers/nvme/host/ 8880F: drivers/nvme/host/
8860F: include/linux/nvme.h 8881F: include/linux/nvme.h
8882F: include/uapi/linux/nvme_ioctl.h
8861 8883
8862NVM EXPRESS TARGET DRIVER 8884NVM EXPRESS TARGET DRIVER
8863M: Christoph Hellwig <hch@lst.de> 8885M: Christoph Hellwig <hch@lst.de>
8864M: Sagi Grimberg <sagi@grimberg.me> 8886M: Sagi Grimberg <sagi@grimberg.me>
8865L: linux-nvme@lists.infradead.org 8887L: linux-nvme@lists.infradead.org
8888T: git://git.infradead.org/nvme.git
8889W: http://git.infradead.org/nvme.git
8866S: Supported 8890S: Supported
8867F: drivers/nvme/target/ 8891F: drivers/nvme/target/
8868 8892
@@ -8893,8 +8917,10 @@ S: Supported
8893F: drivers/nfc/nxp-nci 8917F: drivers/nfc/nxp-nci
8894 8918
8895NXP TDA998X DRM DRIVER 8919NXP TDA998X DRM DRIVER
8896M: Russell King <rmk+kernel@armlinux.org.uk> 8920M: Russell King <linux@armlinux.org.uk>
8897S: Supported 8921S: Supported
8922T: git git://git.armlinux.org.uk/~rmk/linux-arm.git drm-tda998x-devel
8923T: git git://git.armlinux.org.uk/~rmk/linux-arm.git drm-tda998x-fixes
8898F: drivers/gpu/drm/i2c/tda998x_drv.c 8924F: drivers/gpu/drm/i2c/tda998x_drv.c
8899F: include/drm/i2c/tda998x.h 8925F: include/drm/i2c/tda998x.h
8900 8926
@@ -9842,7 +9868,7 @@ M: Mark Rutland <mark.rutland@arm.com>
9842M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 9868M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
9843L: linux-arm-kernel@lists.infradead.org 9869L: linux-arm-kernel@lists.infradead.org
9844S: Maintained 9870S: Maintained
9845F: drivers/firmware/psci.c 9871F: drivers/firmware/psci*.c
9846F: include/linux/psci.h 9872F: include/linux/psci.h
9847F: include/uapi/linux/psci.h 9873F: include/uapi/linux/psci.h
9848 9874
@@ -13075,6 +13101,7 @@ M: David Airlie <airlied@linux.ie>
13075M: Gerd Hoffmann <kraxel@redhat.com> 13101M: Gerd Hoffmann <kraxel@redhat.com>
13076L: dri-devel@lists.freedesktop.org 13102L: dri-devel@lists.freedesktop.org
13077L: virtualization@lists.linux-foundation.org 13103L: virtualization@lists.linux-foundation.org
13104T: git git://git.kraxel.org/linux drm-qemu
13078S: Maintained 13105S: Maintained
13079F: drivers/gpu/drm/virtio/ 13106F: drivers/gpu/drm/virtio/
13080F: include/uapi/linux/virtio_gpu.h 13107F: include/uapi/linux/virtio_gpu.h
@@ -13527,11 +13554,11 @@ F: arch/x86/xen/*swiotlb*
13527F: drivers/xen/*swiotlb* 13554F: drivers/xen/*swiotlb*
13528 13555
13529XFS FILESYSTEM 13556XFS FILESYSTEM
13530M: Dave Chinner <david@fromorbit.com> 13557M: Darrick J. Wong <darrick.wong@oracle.com>
13531M: linux-xfs@vger.kernel.org 13558M: linux-xfs@vger.kernel.org
13532L: linux-xfs@vger.kernel.org 13559L: linux-xfs@vger.kernel.org
13533W: http://xfs.org/ 13560W: http://xfs.org/
13534T: git git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git 13561T: git git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git
13535S: Supported 13562S: Supported
13536F: Documentation/filesystems/xfs.txt 13563F: Documentation/filesystems/xfs.txt
13537F: fs/xfs/ 13564F: fs/xfs/
diff --git a/Makefile b/Makefile
index 5470d599384a..098840012b9b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 10 2PATCHLEVEL = 10
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc5
5NAME = Roaring Lionus 5NAME = Anniversary Edition
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index c75d29077e4a..283099c9560a 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -29,7 +29,7 @@ config ARC
29 select HAVE_KPROBES 29 select HAVE_KPROBES
30 select HAVE_KRETPROBES 30 select HAVE_KRETPROBES
31 select HAVE_MEMBLOCK 31 select HAVE_MEMBLOCK
32 select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND 32 select HAVE_MOD_ARCH_SPECIFIC
33 select HAVE_OPROFILE 33 select HAVE_OPROFILE
34 select HAVE_PERF_EVENTS 34 select HAVE_PERF_EVENTS
35 select HANDLE_DOMAIN_IRQ 35 select HANDLE_DOMAIN_IRQ
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index b3410ff6a62d..5008021fba98 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -67,7 +67,7 @@ extern unsigned long perip_base, perip_end;
67#define ARC_REG_IC_PTAG_HI 0x1F 67#define ARC_REG_IC_PTAG_HI 0x1F
68 68
69/* Bit val in IC_CTRL */ 69/* Bit val in IC_CTRL */
70#define IC_CTRL_CACHE_DISABLE 0x1 70#define IC_CTRL_DIS 0x1
71 71
72/* Data cache related Auxiliary registers */ 72/* Data cache related Auxiliary registers */
73#define ARC_REG_DC_BCR 0x72 /* Build Config reg */ 73#define ARC_REG_DC_BCR 0x72 /* Build Config reg */
@@ -80,8 +80,9 @@ extern unsigned long perip_base, perip_end;
80#define ARC_REG_DC_PTAG_HI 0x5F 80#define ARC_REG_DC_PTAG_HI 0x5F
81 81
82/* Bit val in DC_CTRL */ 82/* Bit val in DC_CTRL */
83#define DC_CTRL_INV_MODE_FLUSH 0x40 83#define DC_CTRL_DIS 0x001
84#define DC_CTRL_FLUSH_STATUS 0x100 84#define DC_CTRL_INV_MODE_FLUSH 0x040
85#define DC_CTRL_FLUSH_STATUS 0x100
85 86
86/*System-level cache (L2 cache) related Auxiliary registers */ 87/*System-level cache (L2 cache) related Auxiliary registers */
87#define ARC_REG_SLC_CFG 0x901 88#define ARC_REG_SLC_CFG 0x901
@@ -92,8 +93,8 @@ extern unsigned long perip_base, perip_end;
92#define ARC_REG_SLC_RGN_END 0x916 93#define ARC_REG_SLC_RGN_END 0x916
93 94
94/* Bit val in SLC_CONTROL */ 95/* Bit val in SLC_CONTROL */
96#define SLC_CTRL_DIS 0x001
95#define SLC_CTRL_IM 0x040 97#define SLC_CTRL_IM 0x040
96#define SLC_CTRL_DISABLE 0x001
97#define SLC_CTRL_BUSY 0x100 98#define SLC_CTRL_BUSY 0x100
98#define SLC_CTRL_RGN_OP_INV 0x200 99#define SLC_CTRL_RGN_OP_INV 0x200
99 100
diff --git a/arch/arc/include/asm/entry-arcv2.h b/arch/arc/include/asm/entry-arcv2.h
index b5ff87e6f4b7..aee1a77934cf 100644
--- a/arch/arc/include/asm/entry-arcv2.h
+++ b/arch/arc/include/asm/entry-arcv2.h
@@ -16,6 +16,7 @@
16 ; 16 ;
17 ; Now manually save: r12, sp, fp, gp, r25 17 ; Now manually save: r12, sp, fp, gp, r25
18 18
19 PUSH r30
19 PUSH r12 20 PUSH r12
20 21
21 ; Saving pt_regs->sp correctly requires some extra work due to the way 22 ; Saving pt_regs->sp correctly requires some extra work due to the way
@@ -72,6 +73,7 @@
72 POPAX AUX_USER_SP 73 POPAX AUX_USER_SP
731: 741:
74 POP r12 75 POP r12
76 POP r30
75 77
76.endm 78.endm
77 79
diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h
index 6e91d8b339c3..567590ea8f6c 100644
--- a/arch/arc/include/asm/module.h
+++ b/arch/arc/include/asm/module.h
@@ -14,13 +14,13 @@
14 14
15#include <asm-generic/module.h> 15#include <asm-generic/module.h>
16 16
17#ifdef CONFIG_ARC_DW2_UNWIND
18struct mod_arch_specific { 17struct mod_arch_specific {
18#ifdef CONFIG_ARC_DW2_UNWIND
19 void *unw_info; 19 void *unw_info;
20 int unw_sec_idx; 20 int unw_sec_idx;
21#endif
21 const char *secstr; 22 const char *secstr;
22}; 23};
23#endif
24 24
25#define MODULE_PROC_FAMILY "ARC700" 25#define MODULE_PROC_FAMILY "ARC700"
26 26
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 69095da1fcfd..47111d565a95 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -84,7 +84,7 @@ struct pt_regs {
84 unsigned long fp; 84 unsigned long fp;
85 unsigned long sp; /* user/kernel sp depending on where we came from */ 85 unsigned long sp; /* user/kernel sp depending on where we came from */
86 86
87 unsigned long r12; 87 unsigned long r12, r30;
88 88
89 /*------- Below list auto saved by h/w -----------*/ 89 /*------- Below list auto saved by h/w -----------*/
90 unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; 90 unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
diff --git a/arch/arc/include/asm/setup.h b/arch/arc/include/asm/setup.h
index cb954cdab070..c568a9df82b1 100644
--- a/arch/arc/include/asm/setup.h
+++ b/arch/arc/include/asm/setup.h
@@ -31,6 +31,7 @@ extern int root_mountflags, end_mem;
31 31
32void setup_processor(void); 32void setup_processor(void);
33void __init setup_arch_memory(void); 33void __init setup_arch_memory(void);
34long __init arc_get_mem_sz(void);
34 35
35/* Helpers used in arc_*_mumbojumbo routines */ 36/* Helpers used in arc_*_mumbojumbo routines */
36#define IS_AVAIL1(v, s) ((v) ? s : "") 37#define IS_AVAIL1(v, s) ((v) ? s : "")
diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c
index 994dca7014db..ecef0fb0b66c 100644
--- a/arch/arc/kernel/intc-arcv2.c
+++ b/arch/arc/kernel/intc-arcv2.c
@@ -77,20 +77,20 @@ void arc_init_IRQ(void)
77 77
78static void arcv2_irq_mask(struct irq_data *data) 78static void arcv2_irq_mask(struct irq_data *data)
79{ 79{
80 write_aux_reg(AUX_IRQ_SELECT, data->irq); 80 write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
81 write_aux_reg(AUX_IRQ_ENABLE, 0); 81 write_aux_reg(AUX_IRQ_ENABLE, 0);
82} 82}
83 83
84static void arcv2_irq_unmask(struct irq_data *data) 84static void arcv2_irq_unmask(struct irq_data *data)
85{ 85{
86 write_aux_reg(AUX_IRQ_SELECT, data->irq); 86 write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
87 write_aux_reg(AUX_IRQ_ENABLE, 1); 87 write_aux_reg(AUX_IRQ_ENABLE, 1);
88} 88}
89 89
90void arcv2_irq_enable(struct irq_data *data) 90void arcv2_irq_enable(struct irq_data *data)
91{ 91{
92 /* set default priority */ 92 /* set default priority */
93 write_aux_reg(AUX_IRQ_SELECT, data->irq); 93 write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
94 write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO); 94 write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
95 95
96 /* 96 /*
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index ce9deb953ca9..8c1fd5c00782 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -57,7 +57,7 @@ static void arc_irq_mask(struct irq_data *data)
57 unsigned int ienb; 57 unsigned int ienb;
58 58
59 ienb = read_aux_reg(AUX_IENABLE); 59 ienb = read_aux_reg(AUX_IENABLE);
60 ienb &= ~(1 << data->irq); 60 ienb &= ~(1 << data->hwirq);
61 write_aux_reg(AUX_IENABLE, ienb); 61 write_aux_reg(AUX_IENABLE, ienb);
62} 62}
63 63
@@ -66,7 +66,7 @@ static void arc_irq_unmask(struct irq_data *data)
66 unsigned int ienb; 66 unsigned int ienb;
67 67
68 ienb = read_aux_reg(AUX_IENABLE); 68 ienb = read_aux_reg(AUX_IENABLE);
69 ienb |= (1 << data->irq); 69 ienb |= (1 << data->hwirq);
70 write_aux_reg(AUX_IENABLE, ienb); 70 write_aux_reg(AUX_IENABLE, ienb);
71} 71}
72 72
diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c
index 560c4afc2af4..9274f8ade8c7 100644
--- a/arch/arc/kernel/mcip.c
+++ b/arch/arc/kernel/mcip.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/irqchip/chained_irq.h>
13#include <linux/spinlock.h> 14#include <linux/spinlock.h>
14#include <soc/arc/mcip.h> 15#include <soc/arc/mcip.h>
15#include <asm/irqflags-arcv2.h> 16#include <asm/irqflags-arcv2.h>
@@ -221,10 +222,13 @@ static irq_hw_number_t idu_first_hwirq;
221static void idu_cascade_isr(struct irq_desc *desc) 222static void idu_cascade_isr(struct irq_desc *desc)
222{ 223{
223 struct irq_domain *idu_domain = irq_desc_get_handler_data(desc); 224 struct irq_domain *idu_domain = irq_desc_get_handler_data(desc);
225 struct irq_chip *core_chip = irq_desc_get_chip(desc);
224 irq_hw_number_t core_hwirq = irqd_to_hwirq(irq_desc_get_irq_data(desc)); 226 irq_hw_number_t core_hwirq = irqd_to_hwirq(irq_desc_get_irq_data(desc));
225 irq_hw_number_t idu_hwirq = core_hwirq - idu_first_hwirq; 227 irq_hw_number_t idu_hwirq = core_hwirq - idu_first_hwirq;
226 228
229 chained_irq_enter(core_chip, desc);
227 generic_handle_irq(irq_find_mapping(idu_domain, idu_hwirq)); 230 generic_handle_irq(irq_find_mapping(idu_domain, idu_hwirq));
231 chained_irq_exit(core_chip, desc);
228} 232}
229 233
230static int idu_irq_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq) 234static int idu_irq_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq)
diff --git a/arch/arc/kernel/module.c b/arch/arc/kernel/module.c
index 42e964db2967..3d99a6091332 100644
--- a/arch/arc/kernel/module.c
+++ b/arch/arc/kernel/module.c
@@ -32,8 +32,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
32#ifdef CONFIG_ARC_DW2_UNWIND 32#ifdef CONFIG_ARC_DW2_UNWIND
33 mod->arch.unw_sec_idx = 0; 33 mod->arch.unw_sec_idx = 0;
34 mod->arch.unw_info = NULL; 34 mod->arch.unw_info = NULL;
35 mod->arch.secstr = secstr;
36#endif 35#endif
36 mod->arch.secstr = secstr;
37 return 0; 37 return 0;
38} 38}
39 39
@@ -113,8 +113,10 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
113 113
114 } 114 }
115 115
116#ifdef CONFIG_ARC_DW2_UNWIND
116 if (strcmp(module->arch.secstr+sechdrs[tgtsec].sh_name, ".eh_frame") == 0) 117 if (strcmp(module->arch.secstr+sechdrs[tgtsec].sh_name, ".eh_frame") == 0)
117 module->arch.unw_sec_idx = tgtsec; 118 module->arch.unw_sec_idx = tgtsec;
119#endif
118 120
119 return 0; 121 return 0;
120 122
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index ec86ac0e3321..d408fa21a07c 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -23,7 +23,7 @@
23 23
24static int l2_line_sz; 24static int l2_line_sz;
25static int ioc_exists; 25static int ioc_exists;
26int slc_enable = 1, ioc_enable = 0; 26int slc_enable = 1, ioc_enable = 1;
27unsigned long perip_base = ARC_UNCACHED_ADDR_SPACE; /* legacy value for boot */ 27unsigned long perip_base = ARC_UNCACHED_ADDR_SPACE; /* legacy value for boot */
28unsigned long perip_end = 0xFFFFFFFF; /* legacy value */ 28unsigned long perip_end = 0xFFFFFFFF; /* legacy value */
29 29
@@ -271,7 +271,11 @@ void __cache_line_loop_v2(phys_addr_t paddr, unsigned long vaddr,
271 271
272/* 272/*
273 * For ARC700 MMUv3 I-cache and D-cache flushes 273 * For ARC700 MMUv3 I-cache and D-cache flushes
274 * Also reused for HS38 aliasing I-cache configuration 274 * - ARC700 programming model requires paddr and vaddr be passed in seperate
275 * AUX registers (*_IV*L and *_PTAG respectively) irrespective of whether the
276 * caches actually alias or not.
277 * - For HS38, only the aliasing I-cache configuration uses the PTAG reg
278 * (non aliasing I-cache version doesn't; while D-cache can't possibly alias)
275 */ 279 */
276static inline 280static inline
277void __cache_line_loop_v3(phys_addr_t paddr, unsigned long vaddr, 281void __cache_line_loop_v3(phys_addr_t paddr, unsigned long vaddr,
@@ -458,6 +462,21 @@ static inline void __dc_entire_op(const int op)
458 __after_dc_op(op); 462 __after_dc_op(op);
459} 463}
460 464
465static inline void __dc_disable(void)
466{
467 const int r = ARC_REG_DC_CTRL;
468
469 __dc_entire_op(OP_FLUSH_N_INV);
470 write_aux_reg(r, read_aux_reg(r) | DC_CTRL_DIS);
471}
472
473static void __dc_enable(void)
474{
475 const int r = ARC_REG_DC_CTRL;
476
477 write_aux_reg(r, read_aux_reg(r) & ~DC_CTRL_DIS);
478}
479
461/* For kernel mappings cache operation: index is same as paddr */ 480/* For kernel mappings cache operation: index is same as paddr */
462#define __dc_line_op_k(p, sz, op) __dc_line_op(p, p, sz, op) 481#define __dc_line_op_k(p, sz, op) __dc_line_op(p, p, sz, op)
463 482
@@ -483,6 +502,8 @@ static inline void __dc_line_op(phys_addr_t paddr, unsigned long vaddr,
483#else 502#else
484 503
485#define __dc_entire_op(op) 504#define __dc_entire_op(op)
505#define __dc_disable()
506#define __dc_enable()
486#define __dc_line_op(paddr, vaddr, sz, op) 507#define __dc_line_op(paddr, vaddr, sz, op)
487#define __dc_line_op_k(paddr, sz, op) 508#define __dc_line_op_k(paddr, sz, op)
488 509
@@ -597,6 +618,40 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op)
597#endif 618#endif
598} 619}
599 620
621noinline static void slc_entire_op(const int op)
622{
623 unsigned int ctrl, r = ARC_REG_SLC_CTRL;
624
625 ctrl = read_aux_reg(r);
626
627 if (!(op & OP_FLUSH)) /* i.e. OP_INV */
628 ctrl &= ~SLC_CTRL_IM; /* clear IM: Disable flush before Inv */
629 else
630 ctrl |= SLC_CTRL_IM;
631
632 write_aux_reg(r, ctrl);
633
634 write_aux_reg(ARC_REG_SLC_INVALIDATE, 1);
635
636 /* Important to wait for flush to complete */
637 while (read_aux_reg(r) & SLC_CTRL_BUSY);
638}
639
640static inline void arc_slc_disable(void)
641{
642 const int r = ARC_REG_SLC_CTRL;
643
644 slc_entire_op(OP_FLUSH_N_INV);
645 write_aux_reg(r, read_aux_reg(r) | SLC_CTRL_DIS);
646}
647
648static inline void arc_slc_enable(void)
649{
650 const int r = ARC_REG_SLC_CTRL;
651
652 write_aux_reg(r, read_aux_reg(r) & ~SLC_CTRL_DIS);
653}
654
600/*********************************************************** 655/***********************************************************
601 * Exported APIs 656 * Exported APIs
602 */ 657 */
@@ -923,21 +978,54 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags)
923 return 0; 978 return 0;
924} 979}
925 980
926void arc_cache_init(void) 981/*
982 * IO-Coherency (IOC) setup rules:
983 *
984 * 1. Needs to be at system level, so only once by Master core
985 * Non-Masters need not be accessing caches at that time
986 * - They are either HALT_ON_RESET and kick started much later or
987 * - if run on reset, need to ensure that arc_platform_smp_wait_to_boot()
988 * doesn't perturb caches or coherency unit
989 *
990 * 2. caches (L1 and SLC) need to be purged (flush+inv) before setting up IOC,
991 * otherwise any straggler data might behave strangely post IOC enabling
992 *
993 * 3. All Caches need to be disabled when setting up IOC to elide any in-flight
994 * Coherency transactions
995 */
996noinline void __init arc_ioc_setup(void)
927{ 997{
928 unsigned int __maybe_unused cpu = smp_processor_id(); 998 unsigned int ap_sz;
929 char str[256];
930 999
931 printk(arc_cache_mumbojumbo(0, str, sizeof(str))); 1000 /* Flush + invalidate + disable L1 dcache */
1001 __dc_disable();
1002
1003 /* Flush + invalidate SLC */
1004 if (read_aux_reg(ARC_REG_SLC_BCR))
1005 slc_entire_op(OP_FLUSH_N_INV);
1006
1007 /* IOC Aperture start: TDB: handle non default CONFIG_LINUX_LINK_BASE */
1008 write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000);
932 1009
933 /* 1010 /*
934 * Only master CPU needs to execute rest of function: 1011 * IOC Aperture size:
935 * - Assume SMP so all cores will have same cache config so 1012 * decoded as 2 ^ (SIZE + 2) KB: so setting 0x11 implies 512M
936 * any geomtry checks will be same for all 1013 * TBD: fix for PGU + 1GB of low mem
937 * - IOC setup / dma callbacks only need to be setup once 1014 * TBD: fix for PAE
938 */ 1015 */
939 if (cpu) 1016 ap_sz = order_base_2(arc_get_mem_sz()/1024) - 2;
940 return; 1017 write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, ap_sz);
1018
1019 write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1);
1020 write_aux_reg(ARC_REG_IO_COH_ENABLE, 1);
1021
1022 /* Re-enable L1 dcache */
1023 __dc_enable();
1024}
1025
1026void __init arc_cache_init_master(void)
1027{
1028 unsigned int __maybe_unused cpu = smp_processor_id();
941 1029
942 if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { 1030 if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) {
943 struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; 1031 struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache;
@@ -985,30 +1073,14 @@ void arc_cache_init(void)
985 } 1073 }
986 } 1074 }
987 1075
988 if (is_isa_arcv2() && l2_line_sz && !slc_enable) { 1076 /* Note that SLC disable not formally supported till HS 3.0 */
989 1077 if (is_isa_arcv2() && l2_line_sz && !slc_enable)
990 /* IM set : flush before invalidate */ 1078 arc_slc_disable();
991 write_aux_reg(ARC_REG_SLC_CTRL,
992 read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_IM);
993 1079
994 write_aux_reg(ARC_REG_SLC_INVALIDATE, 1); 1080 if (is_isa_arcv2() && ioc_enable)
995 1081 arc_ioc_setup();
996 /* Important to wait for flush to complete */
997 while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY);
998 write_aux_reg(ARC_REG_SLC_CTRL,
999 read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_DISABLE);
1000 }
1001 1082
1002 if (is_isa_arcv2() && ioc_enable) { 1083 if (is_isa_arcv2() && ioc_enable) {
1003 /* IO coherency base - 0x8z */
1004 write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000);
1005 /* IO coherency aperture size - 512Mb: 0x8z-0xAz */
1006 write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, 0x11);
1007 /* Enable partial writes */
1008 write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1);
1009 /* Enable IO coherency */
1010 write_aux_reg(ARC_REG_IO_COH_ENABLE, 1);
1011
1012 __dma_cache_wback_inv = __dma_cache_wback_inv_ioc; 1084 __dma_cache_wback_inv = __dma_cache_wback_inv_ioc;
1013 __dma_cache_inv = __dma_cache_inv_ioc; 1085 __dma_cache_inv = __dma_cache_inv_ioc;
1014 __dma_cache_wback = __dma_cache_wback_ioc; 1086 __dma_cache_wback = __dma_cache_wback_ioc;
@@ -1022,3 +1094,20 @@ void arc_cache_init(void)
1022 __dma_cache_wback = __dma_cache_wback_l1; 1094 __dma_cache_wback = __dma_cache_wback_l1;
1023 } 1095 }
1024} 1096}
1097
1098void __ref arc_cache_init(void)
1099{
1100 unsigned int __maybe_unused cpu = smp_processor_id();
1101 char str[256];
1102
1103 printk(arc_cache_mumbojumbo(0, str, sizeof(str)));
1104
1105 /*
1106 * Only master CPU needs to execute rest of function:
1107 * - Assume SMP so all cores will have same cache config so
1108 * any geomtry checks will be same for all
1109 * - IOC setup / dma callbacks only need to be setup once
1110 */
1111 if (!cpu)
1112 arc_cache_init_master();
1113}
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 399e2f223d25..8c9415ed6280 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -40,6 +40,11 @@ struct pglist_data node_data[MAX_NUMNODES] __read_mostly;
40EXPORT_SYMBOL(node_data); 40EXPORT_SYMBOL(node_data);
41#endif 41#endif
42 42
43long __init arc_get_mem_sz(void)
44{
45 return low_mem_sz;
46}
47
43/* User can over-ride above with "mem=nnn[KkMm]" in cmdline */ 48/* User can over-ride above with "mem=nnn[KkMm]" in cmdline */
44static int __init setup_mem_sz(char *str) 49static int __init setup_mem_sz(char *str)
45{ 50{
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5fab553fd03a..186c4c214e0a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1502,8 +1502,7 @@ source kernel/Kconfig.preempt
1502 1502
1503config HZ_FIXED 1503config HZ_FIXED
1504 int 1504 int
1505 default 200 if ARCH_EBSA110 || ARCH_S3C24XX || \ 1505 default 200 if ARCH_EBSA110
1506 ARCH_S5PV210 || ARCH_EXYNOS4
1507 default 128 if SOC_AT91RM9200 1506 default 128 if SOC_AT91RM9200
1508 default 0 1507 default 0
1509 1508
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..f10fe8526239 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -501,6 +501,7 @@ dtb-$(CONFIG_ARCH_OMAP3) += \
501 am3517-evm.dtb \ 501 am3517-evm.dtb \
502 am3517_mt_ventoux.dtb \ 502 am3517_mt_ventoux.dtb \
503 logicpd-torpedo-37xx-devkit.dtb \ 503 logicpd-torpedo-37xx-devkit.dtb \
504 logicpd-som-lv-37xx-devkit.dtb \
504 omap3430-sdp.dtb \ 505 omap3430-sdp.dtb \
505 omap3-beagle.dtb \ 506 omap3-beagle.dtb \
506 omap3-beagle-xm.dtb \ 507 omap3-beagle-xm.dtb \
@@ -845,6 +846,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
845 sun8i-a83t-allwinner-h8homlet-v2.dtb \ 846 sun8i-a83t-allwinner-h8homlet-v2.dtb \
846 sun8i-a83t-cubietruck-plus.dtb \ 847 sun8i-a83t-cubietruck-plus.dtb \
847 sun8i-h3-bananapi-m2-plus.dtb \ 848 sun8i-h3-bananapi-m2-plus.dtb \
849 sun8i-h3-nanopi-m1.dtb \
848 sun8i-h3-nanopi-neo.dtb \ 850 sun8i-h3-nanopi-neo.dtb \
849 sun8i-h3-orangepi-2.dtb \ 851 sun8i-h3-orangepi-2.dtb \
850 sun8i-h3-orangepi-lite.dtb \ 852 sun8i-h3-orangepi-lite.dtb \
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index dc561d505bbe..3e32dd18fd25 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -6,8 +6,6 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <dt-bindings/mfd/tps65217.h>
10
11/ { 9/ {
12 cpus { 10 cpus {
13 cpu@0 { 11 cpu@0 {
@@ -319,13 +317,13 @@
319 ti,pmic-shutdown-controller; 317 ti,pmic-shutdown-controller;
320 318
321 charger { 319 charger {
322 interrupts = <TPS65217_IRQ_AC>, <TPS65217_IRQ_USB>; 320 interrupts = <0>, <1>;
323 interrupts-names = "AC", "USB"; 321 interrupt-names = "USB", "AC";
324 status = "okay"; 322 status = "okay";
325 }; 323 };
326 324
327 pwrbutton { 325 pwrbutton {
328 interrupts = <TPS65217_IRQ_PB>; 326 interrupts = <2>;
329 status = "okay"; 327 status = "okay";
330 }; 328 };
331 329
diff --git a/arch/arm/boot/dts/am335x-icev2.dts b/arch/arm/boot/dts/am335x-icev2.dts
index 1463df3b5b19..8ed46f9d79b7 100644
--- a/arch/arm/boot/dts/am335x-icev2.dts
+++ b/arch/arm/boot/dts/am335x-icev2.dts
@@ -170,7 +170,6 @@
170 AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0) /* (G16) mmc0_dat0.mmc0_dat0 */ 170 AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0) /* (G16) mmc0_dat0.mmc0_dat0 */
171 AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0) /* (G17) mmc0_clk.mmc0_clk */ 171 AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0) /* (G17) mmc0_clk.mmc0_clk */
172 AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0) /* (G18) mmc0_cmd.mmc0_cmd */ 172 AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0) /* (G18) mmc0_cmd.mmc0_cmd */
173 AM33XX_IOPAD(0x960, PIN_INPUT_PULLUP | MUX_MODE5) /* (C15) spi0_cs1.mmc0_sdcd */
174 >; 173 >;
175 }; 174 };
176 175
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 64c8aa9057a3..18d72a245e88 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -16,6 +16,7 @@
16 interrupt-parent = <&intc>; 16 interrupt-parent = <&intc>;
17 #address-cells = <1>; 17 #address-cells = <1>;
18 #size-cells = <1>; 18 #size-cells = <1>;
19 chosen { };
19 20
20 aliases { 21 aliases {
21 i2c0 = &i2c0; 22 i2c0 = &i2c0;
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index ac55f93fc91e..2df9e6050c2f 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -16,6 +16,7 @@
16 interrupt-parent = <&wakeupgen>; 16 interrupt-parent = <&wakeupgen>;
17 #address-cells = <1>; 17 #address-cells = <1>;
18 #size-cells = <1>; 18 #size-cells = <1>;
19 chosen { };
19 20
20 memory@0 { 21 memory@0 {
21 device_type = "memory"; 22 device_type = "memory";
diff --git a/arch/arm/boot/dts/am571x-idk.dts b/arch/arm/boot/dts/am571x-idk.dts
index d6e43e5184c1..ad68d1eb3bc3 100644
--- a/arch/arm/boot/dts/am571x-idk.dts
+++ b/arch/arm/boot/dts/am571x-idk.dts
@@ -62,11 +62,6 @@
62 linux,default-trigger = "mmc0"; 62 linux,default-trigger = "mmc0";
63 }; 63 };
64 }; 64 };
65
66 extcon_usb2: extcon_usb2 {
67 compatible = "linux,extcon-usb-gpio";
68 id-gpio = <&gpio5 7 GPIO_ACTIVE_HIGH>;
69 };
70}; 65};
71 66
72&mmc1 { 67&mmc1 {
@@ -79,3 +74,8 @@
79&omap_dwc3_2 { 74&omap_dwc3_2 {
80 extcon = <&extcon_usb2>; 75 extcon = <&extcon_usb2>;
81}; 76};
77
78&extcon_usb2 {
79 id-gpio = <&gpio5 7 GPIO_ACTIVE_HIGH>;
80 vbus-gpio = <&gpio7 22 GPIO_ACTIVE_HIGH>;
81};
diff --git a/arch/arm/boot/dts/am572x-idk.dts b/arch/arm/boot/dts/am572x-idk.dts
index 27d9149cedba..8350b4b34b08 100644
--- a/arch/arm/boot/dts/am572x-idk.dts
+++ b/arch/arm/boot/dts/am572x-idk.dts
@@ -23,11 +23,6 @@
23 reg = <0x0 0x80000000 0x0 0x80000000>; 23 reg = <0x0 0x80000000 0x0 0x80000000>;
24 }; 24 };
25 25
26 extcon_usb2: extcon_usb2 {
27 compatible = "linux,extcon-usb-gpio";
28 id-gpio = <&gpio3 16 GPIO_ACTIVE_HIGH>;
29 };
30
31 status-leds { 26 status-leds {
32 compatible = "gpio-leds"; 27 compatible = "gpio-leds";
33 cpu0-led { 28 cpu0-led {
@@ -76,6 +71,11 @@
76 extcon = <&extcon_usb2>; 71 extcon = <&extcon_usb2>;
77}; 72};
78 73
74&extcon_usb2 {
75 id-gpio = <&gpio3 16 GPIO_ACTIVE_HIGH>;
76 vbus-gpio = <&gpio3 26 GPIO_ACTIVE_HIGH>;
77};
78
79&mmc1 { 79&mmc1 {
80 status = "okay"; 80 status = "okay";
81 vmmc-supply = <&v3_3d>; 81 vmmc-supply = <&v3_3d>;
@@ -87,3 +87,7 @@
87&sn65hvs882 { 87&sn65hvs882 {
88 load-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>; 88 load-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
89}; 89};
90
91&pcie1 {
92 gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
93};
diff --git a/arch/arm/boot/dts/am57xx-idk-common.dtsi b/arch/arm/boot/dts/am57xx-idk-common.dtsi
index 555ae21f2b9a..814a720d5c3d 100644
--- a/arch/arm/boot/dts/am57xx-idk-common.dtsi
+++ b/arch/arm/boot/dts/am57xx-idk-common.dtsi
@@ -303,6 +303,13 @@
303 gpio-controller; 303 gpio-controller;
304 #gpio-cells = <2>; 304 #gpio-cells = <2>;
305 }; 305 };
306
307 extcon_usb2: tps659038_usb {
308 compatible = "ti,palmas-usb-vid";
309 ti,enable-vbus-detection;
310 ti,enable-id-detection;
311 /* ID & VBUS GPIOs provided in board dts */
312 };
306 }; 313 };
307}; 314};
308 315
@@ -369,7 +376,7 @@
369}; 376};
370 377
371&usb2 { 378&usb2 {
372 dr_mode = "otg"; 379 dr_mode = "peripheral";
373}; 380};
374 381
375&mmc2 { 382&mmc2 {
diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
index b6142bda661e..15f07f9af3b3 100644
--- a/arch/arm/boot/dts/bcm-nsp.dtsi
+++ b/arch/arm/boot/dts/bcm-nsp.dtsi
@@ -160,7 +160,7 @@
160 160
161 axi { 161 axi {
162 compatible = "simple-bus"; 162 compatible = "simple-bus";
163 ranges = <0x00000000 0x18000000 0x0011c40a>; 163 ranges = <0x00000000 0x18000000 0x0011c40c>;
164 #address-cells = <1>; 164 #address-cells = <1>;
165 #size-cells = <1>; 165 #size-cells = <1>;
166 166
diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts
index 41de15fe15a2..78492a0bbbab 100644
--- a/arch/arm/boot/dts/da850-evm.dts
+++ b/arch/arm/boot/dts/da850-evm.dts
@@ -99,6 +99,7 @@
99 #size-cells = <1>; 99 #size-cells = <1>;
100 compatible = "m25p64"; 100 compatible = "m25p64";
101 spi-max-frequency = <30000000>; 101 spi-max-frequency = <30000000>;
102 m25p,fast-read;
102 reg = <0>; 103 reg = <0>;
103 partition@0 { 104 partition@0 {
104 label = "U-Boot-SPL"; 105 label = "U-Boot-SPL";
diff --git a/arch/arm/boot/dts/dm814x.dtsi b/arch/arm/boot/dts/dm814x.dtsi
index 1facc5f12cef..81b8cecb5820 100644
--- a/arch/arm/boot/dts/dm814x.dtsi
+++ b/arch/arm/boot/dts/dm814x.dtsi
@@ -12,6 +12,7 @@
12 interrupt-parent = <&intc>; 12 interrupt-parent = <&intc>;
13 #address-cells = <1>; 13 #address-cells = <1>;
14 #size-cells = <1>; 14 #size-cells = <1>;
15 chosen { };
15 16
16 aliases { 17 aliases {
17 i2c0 = &i2c1; 18 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 61dd2f6b02bc..6db652ae9bd5 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -12,6 +12,7 @@
12 interrupt-parent = <&intc>; 12 interrupt-parent = <&intc>;
13 #address-cells = <1>; 13 #address-cells = <1>;
14 #size-cells = <1>; 14 #size-cells = <1>;
15 chosen { };
15 16
16 aliases { 17 aliases {
17 i2c0 = &i2c1; 18 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index addb7530cfbe..5ba161679e01 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -18,6 +18,7 @@
18 18
19 compatible = "ti,dra7xx"; 19 compatible = "ti,dra7xx";
20 interrupt-parent = <&crossbar_mpu>; 20 interrupt-parent = <&crossbar_mpu>;
21 chosen { };
21 22
22 aliases { 23 aliases {
23 i2c0 = &i2c1; 24 i2c0 = &i2c1;
@@ -1377,6 +1378,7 @@
1377 phy-names = "sata-phy"; 1378 phy-names = "sata-phy";
1378 clocks = <&sata_ref_clk>; 1379 clocks = <&sata_ref_clk>;
1379 ti,hwmods = "sata"; 1380 ti,hwmods = "sata";
1381 ports-implemented = <0x1>;
1380 }; 1382 };
1381 1383
1382 rtc: rtc@48838000 { 1384 rtc: rtc@48838000 {
diff --git a/arch/arm/boot/dts/dra72-evm-revc.dts b/arch/arm/boot/dts/dra72-evm-revc.dts
index c3d939c9666c..3f808a47df03 100644
--- a/arch/arm/boot/dts/dra72-evm-revc.dts
+++ b/arch/arm/boot/dts/dra72-evm-revc.dts
@@ -75,6 +75,6 @@
75 ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>; 75 ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
76 ti,tx-internal-delay = <DP83867_RGMIIDCTL_250_PS>; 76 ti,tx-internal-delay = <DP83867_RGMIIDCTL_250_PS>;
77 ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>; 77 ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>;
78 ti,min-output-imepdance; 78 ti,min-output-impedance;
79 }; 79 };
80}; 80};
diff --git a/arch/arm/boot/dts/dra72-evm-tps65917.dtsi b/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
index ee6dac44edf1..e6df676886c0 100644
--- a/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
+++ b/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
@@ -132,3 +132,19 @@
132 ti,palmas-long-press-seconds = <6>; 132 ti,palmas-long-press-seconds = <6>;
133 }; 133 };
134}; 134};
135
136&usb2_phy1 {
137 phy-supply = <&ldo4_reg>;
138};
139
140&usb2_phy2 {
141 phy-supply = <&ldo4_reg>;
142};
143
144&dss {
145 vdda_video-supply = <&ldo5_reg>;
146};
147
148&mmc1 {
149 vmmc_aux-supply = <&ldo1_reg>;
150};
diff --git a/arch/arm/boot/dts/imx31.dtsi b/arch/arm/boot/dts/imx31.dtsi
index 685916e3d8a1..85cd8be22f71 100644
--- a/arch/arm/boot/dts/imx31.dtsi
+++ b/arch/arm/boot/dts/imx31.dtsi
@@ -31,11 +31,11 @@
31 }; 31 };
32 }; 32 };
33 33
34 avic: avic-interrupt-controller@60000000 { 34 avic: interrupt-controller@68000000 {
35 compatible = "fsl,imx31-avic", "fsl,avic"; 35 compatible = "fsl,imx31-avic", "fsl,avic";
36 interrupt-controller; 36 interrupt-controller;
37 #interrupt-cells = <1>; 37 #interrupt-cells = <1>;
38 reg = <0x60000000 0x100000>; 38 reg = <0x68000000 0x100000>;
39 }; 39 };
40 40
41 soc { 41 soc {
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
index 34887a10c5f1..47ba97229a48 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
@@ -319,8 +319,6 @@
319 compatible = "fsl,imx6q-nitrogen6_max-sgtl5000", 319 compatible = "fsl,imx6q-nitrogen6_max-sgtl5000",
320 "fsl,imx-audio-sgtl5000"; 320 "fsl,imx-audio-sgtl5000";
321 model = "imx6q-nitrogen6_max-sgtl5000"; 321 model = "imx6q-nitrogen6_max-sgtl5000";
322 pinctrl-names = "default";
323 pinctrl-0 = <&pinctrl_sgtl5000>;
324 ssi-controller = <&ssi1>; 322 ssi-controller = <&ssi1>;
325 audio-codec = <&codec>; 323 audio-codec = <&codec>;
326 audio-routing = 324 audio-routing =
@@ -402,6 +400,8 @@
402 400
403 codec: sgtl5000@0a { 401 codec: sgtl5000@0a {
404 compatible = "fsl,sgtl5000"; 402 compatible = "fsl,sgtl5000";
403 pinctrl-names = "default";
404 pinctrl-0 = <&pinctrl_sgtl5000>;
405 reg = <0x0a>; 405 reg = <0x0a>;
406 clocks = <&clks IMX6QDL_CLK_CKO>; 406 clocks = <&clks IMX6QDL_CLK_CKO>;
407 VDDA-supply = <&reg_2p5v>; 407 VDDA-supply = <&reg_2p5v>;
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
index d80f21abea62..31d4cc62dbc7 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
@@ -250,8 +250,6 @@
250 compatible = "fsl,imx6q-nitrogen6_som2-sgtl5000", 250 compatible = "fsl,imx6q-nitrogen6_som2-sgtl5000",
251 "fsl,imx-audio-sgtl5000"; 251 "fsl,imx-audio-sgtl5000";
252 model = "imx6q-nitrogen6_som2-sgtl5000"; 252 model = "imx6q-nitrogen6_som2-sgtl5000";
253 pinctrl-names = "default";
254 pinctrl-0 = <&pinctrl_sgtl5000>;
255 ssi-controller = <&ssi1>; 253 ssi-controller = <&ssi1>;
256 audio-codec = <&codec>; 254 audio-codec = <&codec>;
257 audio-routing = 255 audio-routing =
@@ -320,6 +318,8 @@
320 318
321 codec: sgtl5000@0a { 319 codec: sgtl5000@0a {
322 compatible = "fsl,sgtl5000"; 320 compatible = "fsl,sgtl5000";
321 pinctrl-names = "default";
322 pinctrl-0 = <&pinctrl_sgtl5000>;
323 reg = <0x0a>; 323 reg = <0x0a>;
324 clocks = <&clks IMX6QDL_CLK_CKO>; 324 clocks = <&clks IMX6QDL_CLK_CKO>;
325 VDDA-supply = <&reg_2p5v>; 325 VDDA-supply = <&reg_2p5v>;
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
index e476d01959ea..26d060484728 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
@@ -533,7 +533,6 @@
533 MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17071 533 MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17071
534 MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17071 534 MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17071
535 MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17071 535 MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17071
536 MX6QDL_PAD_NANDF_CS2__GPIO6_IO15 0x000b0
537 >; 536 >;
538 }; 537 };
539 538
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 53e6e63cbb02..89b834f3fa17 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1100,6 +1100,7 @@
1100 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>; 1100 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>;
1101 clocks = <&clks IMX6QDL_CLK_EIM_SLOW>; 1101 clocks = <&clks IMX6QDL_CLK_EIM_SLOW>;
1102 fsl,weim-cs-gpr = <&gpr>; 1102 fsl,weim-cs-gpr = <&gpr>;
1103 status = "disabled";
1103 }; 1104 };
1104 1105
1105 ocotp: ocotp@021bc000 { 1106 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi
index 4fd6de29f07d..19cbd879c448 100644
--- a/arch/arm/boot/dts/imx6sl.dtsi
+++ b/arch/arm/boot/dts/imx6sl.dtsi
@@ -900,6 +900,7 @@
900 reg = <0x021b8000 0x4000>; 900 reg = <0x021b8000 0x4000>;
901 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>; 901 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>;
902 fsl,weim-cs-gpr = <&gpr>; 902 fsl,weim-cs-gpr = <&gpr>;
903 status = "disabled";
903 }; 904 };
904 905
905 ocotp: ocotp@021bc000 { 906 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/imx6sx.dtsi b/arch/arm/boot/dts/imx6sx.dtsi
index 076a30f9bcae..10f333016197 100644
--- a/arch/arm/boot/dts/imx6sx.dtsi
+++ b/arch/arm/boot/dts/imx6sx.dtsi
@@ -977,6 +977,7 @@
977 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; 977 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
978 clocks = <&clks IMX6SX_CLK_EIM_SLOW>; 978 clocks = <&clks IMX6SX_CLK_EIM_SLOW>;
979 fsl,weim-cs-gpr = <&gpr>; 979 fsl,weim-cs-gpr = <&gpr>;
980 status = "disabled";
980 }; 981 };
981 982
982 ocotp: ocotp@021bc000 { 983 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
index da8598402ab8..38faa90007d7 100644
--- a/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
+++ b/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
@@ -158,7 +158,7 @@
158&mmc1 { 158&mmc1 {
159 interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>; 159 interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>;
160 pinctrl-names = "default"; 160 pinctrl-names = "default";
161 pinctrl-0 = <&mmc1_pins &mmc1_cd>; 161 pinctrl-0 = <&mmc1_pins>;
162 wp-gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>; /* gpio_126 */ 162 wp-gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>; /* gpio_126 */
163 cd-gpios = <&gpio4 14 IRQ_TYPE_LEVEL_LOW>; /* gpio_110 */ 163 cd-gpios = <&gpio4 14 IRQ_TYPE_LEVEL_LOW>; /* gpio_110 */
164 vmmc-supply = <&vmmc1>; 164 vmmc-supply = <&vmmc1>;
@@ -193,7 +193,8 @@
193 OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */ 193 OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */
194 OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */ 194 OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */
195 OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */ 195 OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */
196 OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 sdmmc1_wp*/ 196 OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 */
197 OMAP3_CORE1_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
197 >; 198 >;
198 }; 199 };
199 200
@@ -242,12 +243,6 @@
242 OMAP3_WKUP_IOPAD(0x2a16, PIN_OUTPUT | PIN_OFF_OUTPUT_LOW | MUX_MODE4) /* sys_boot6.gpio_8 */ 243 OMAP3_WKUP_IOPAD(0x2a16, PIN_OUTPUT | PIN_OFF_OUTPUT_LOW | MUX_MODE4) /* sys_boot6.gpio_8 */
243 >; 244 >;
244 }; 245 };
245
246 mmc1_cd: pinmux_mmc1_cd {
247 pinctrl-single,pins = <
248 OMAP3_WKUP_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
249 >;
250 };
251}; 246};
252 247
253 248
diff --git a/arch/arm/boot/dts/omap2.dtsi b/arch/arm/boot/dts/omap2.dtsi
index 4f793a025a72..f1d6de8b3c19 100644
--- a/arch/arm/boot/dts/omap2.dtsi
+++ b/arch/arm/boot/dts/omap2.dtsi
@@ -17,6 +17,7 @@
17 interrupt-parent = <&intc>; 17 interrupt-parent = <&intc>;
18 #address-cells = <1>; 18 #address-cells = <1>;
19 #size-cells = <1>; 19 #size-cells = <1>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 serial0 = &uart1; 23 serial0 = &uart1;
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 87ca50b53002..4d448f145ed1 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -734,6 +734,8 @@
734 vmmc_aux-supply = <&vsim>; 734 vmmc_aux-supply = <&vsim>;
735 bus-width = <8>; 735 bus-width = <8>;
736 non-removable; 736 non-removable;
737 no-sdio;
738 no-sd;
737}; 739};
738 740
739&mmc3 { 741&mmc3 {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index ecf5eb584c75..a3ff4933dbc1 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -17,6 +17,7 @@
17 interrupt-parent = <&intc>; 17 interrupt-parent = <&intc>;
18 #address-cells = <1>; 18 #address-cells = <1>;
19 #size-cells = <1>; 19 #size-cells = <1>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 i2c0 = &i2c1; 23 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 8087456b5fbe..578c53f08309 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -15,6 +15,7 @@
15 interrupt-parent = <&wakeupgen>; 15 interrupt-parent = <&wakeupgen>;
16 #address-cells = <1>; 16 #address-cells = <1>;
17 #size-cells = <1>; 17 #size-cells = <1>;
18 chosen { };
18 19
19 aliases { 20 aliases {
20 i2c0 = &i2c1; 21 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 968c67a49dbd..0844737b72b2 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -17,6 +17,7 @@
17 17
18 compatible = "ti,omap5"; 18 compatible = "ti,omap5";
19 interrupt-parent = <&wakeupgen>; 19 interrupt-parent = <&wakeupgen>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 i2c0 = &i2c1; 23 i2c0 = &i2c1;
@@ -987,6 +988,7 @@
987 phy-names = "sata-phy"; 988 phy-names = "sata-phy";
988 clocks = <&sata_ref_clk>; 989 clocks = <&sata_ref_clk>;
989 ti,hwmods = "sata"; 990 ti,hwmods = "sata";
991 ports-implemented = <0x1>;
990 }; 992 };
991 993
992 dss: dss@58000000 { 994 dss: dss@58000000 {
diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
index 268bd470c865..407a4610f4a7 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -4,6 +4,7 @@
4#include <dt-bindings/clock/qcom,gcc-msm8960.h> 4#include <dt-bindings/clock/qcom,gcc-msm8960.h>
5#include <dt-bindings/reset/qcom,gcc-msm8960.h> 5#include <dt-bindings/reset/qcom,gcc-msm8960.h>
6#include <dt-bindings/clock/qcom,mmcc-msm8960.h> 6#include <dt-bindings/clock/qcom,mmcc-msm8960.h>
7#include <dt-bindings/clock/qcom,rpmcc.h>
7#include <dt-bindings/soc/qcom,gsbi.h> 8#include <dt-bindings/soc/qcom,gsbi.h>
8#include <dt-bindings/interrupt-controller/irq.h> 9#include <dt-bindings/interrupt-controller/irq.h>
9#include <dt-bindings/interrupt-controller/arm-gic.h> 10#include <dt-bindings/interrupt-controller/arm-gic.h>
@@ -303,6 +304,9 @@
303 firmware { 304 firmware {
304 scm { 305 scm {
305 compatible = "qcom,scm-apq8064"; 306 compatible = "qcom,scm-apq8064";
307
308 clocks = <&rpmcc RPM_DAYTONA_FABRIC_CLK>;
309 clock-names = "core";
306 }; 310 };
307 }; 311 };
308 312
diff --git a/arch/arm/boot/dts/qcom-mdm9615.dtsi b/arch/arm/boot/dts/qcom-mdm9615.dtsi
index 5ae4ec59e6ea..c852b69229c9 100644
--- a/arch/arm/boot/dts/qcom-mdm9615.dtsi
+++ b/arch/arm/boot/dts/qcom-mdm9615.dtsi
@@ -357,7 +357,7 @@
357 }; 357 };
358 358
359 amba { 359 amba {
360 compatible = "arm,amba-bus"; 360 compatible = "simple-bus";
361 #address-cells = <1>; 361 #address-cells = <1>;
362 #size-cells = <1>; 362 #size-cells = <1>;
363 ranges; 363 ranges;
diff --git a/arch/arm/boot/dts/sun6i-a31-hummingbird.dts b/arch/arm/boot/dts/sun6i-a31-hummingbird.dts
index 735914f6ae44..7cae328398b1 100644
--- a/arch/arm/boot/dts/sun6i-a31-hummingbird.dts
+++ b/arch/arm/boot/dts/sun6i-a31-hummingbird.dts
@@ -140,6 +140,10 @@
140 cpu-supply = <&reg_dcdc3>; 140 cpu-supply = <&reg_dcdc3>;
141}; 141};
142 142
143&de {
144 status = "okay";
145};
146
143&ehci0 { 147&ehci0 {
144 status = "okay"; 148 status = "okay";
145}; 149};
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 2b26175d55d1..e78faaf9243c 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -234,6 +234,7 @@
234 de: display-engine { 234 de: display-engine {
235 compatible = "allwinner,sun6i-a31-display-engine"; 235 compatible = "allwinner,sun6i-a31-display-engine";
236 allwinner,pipelines = <&fe0>; 236 allwinner,pipelines = <&fe0>;
237 status = "disabled";
237 }; 238 };
238 239
239 soc@01c00000 { 240 soc@01c00000 {
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
index 5ea4915f6d75..10d307408f23 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dts
@@ -56,7 +56,7 @@
56}; 56};
57 57
58&pio { 58&pio {
59 mmc2_pins_nrst: mmc2@0 { 59 mmc2_pins_nrst: mmc2-rst-pin {
60 allwinner,pins = "PC16"; 60 allwinner,pins = "PC16";
61 allwinner,function = "gpio_out"; 61 allwinner,function = "gpio_out";
62 allwinner,drive = <SUN4I_PINCTRL_10_MA>; 62 allwinner,drive = <SUN4I_PINCTRL_10_MA>;
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
index 102838fcc588..15f4fd3f4695 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
@@ -81,7 +81,7 @@
81 #address-cells = <0>; 81 #address-cells = <0>;
82 interrupt-controller; 82 interrupt-controller;
83 reg = <0 0x2c001000 0 0x1000>, 83 reg = <0 0x2c001000 0 0x1000>,
84 <0 0x2c002000 0 0x1000>, 84 <0 0x2c002000 0 0x2000>,
85 <0 0x2c004000 0 0x2000>, 85 <0 0x2c004000 0 0x2000>,
86 <0 0x2c006000 0 0x2000>; 86 <0 0x2c006000 0 0x2000>;
87 interrupts = <1 9 0xf04>; 87 interrupts = <1 9 0xf04>;
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
index 45d08cc37b01..bd107c5a0226 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
@@ -131,7 +131,7 @@
131 #address-cells = <0>; 131 #address-cells = <0>;
132 interrupt-controller; 132 interrupt-controller;
133 reg = <0 0x2c001000 0 0x1000>, 133 reg = <0 0x2c001000 0 0x1000>,
134 <0 0x2c002000 0 0x1000>, 134 <0 0x2c002000 0 0x2000>,
135 <0 0x2c004000 0 0x2000>, 135 <0 0x2c004000 0 0x2000>,
136 <0 0x2c006000 0 0x2000>; 136 <0 0x2c006000 0 0x2000>;
137 interrupts = <1 9 0xf04>; 137 interrupts = <1 9 0xf04>;
diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 7ea617e47fe4..958b4c42d320 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -153,7 +153,8 @@
153 switch0phy1: switch1phy0@1 { 153 switch0phy1: switch1phy0@1 {
154 reg = <1>; 154 reg = <1>;
155 interrupt-parent = <&switch0>; 155 interrupt-parent = <&switch0>;
156 interrupts = <1 IRQ_TYPE_LEVEL_HIGH>; }; 156 interrupts = <1 IRQ_TYPE_LEVEL_HIGH>;
157 };
157 switch0phy2: switch1phy0@2 { 158 switch0phy2: switch1phy0@2 {
158 reg = <2>; 159 reg = <2>;
159 interrupt-parent = <&switch0>; 160 interrupt-parent = <&switch0>;
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index b01a43851294..028d2b70e3b5 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -471,7 +471,7 @@ CONFIG_MESON_WATCHDOG=y
471CONFIG_DW_WATCHDOG=y 471CONFIG_DW_WATCHDOG=y
472CONFIG_DIGICOLOR_WATCHDOG=y 472CONFIG_DIGICOLOR_WATCHDOG=y
473CONFIG_BCM2835_WDT=y 473CONFIG_BCM2835_WDT=y
474CONFIG_BCM47XX_WATCHDOG=y 474CONFIG_BCM47XX_WDT=y
475CONFIG_BCM7038_WDT=m 475CONFIG_BCM7038_WDT=m
476CONFIG_BCM_KONA_WDT=y 476CONFIG_BCM_KONA_WDT=y
477CONFIG_MFD_ACT8945A=y 477CONFIG_MFD_ACT8945A=y
@@ -893,7 +893,7 @@ CONFIG_BCM2835_MBOX=y
893CONFIG_RASPBERRYPI_FIRMWARE=y 893CONFIG_RASPBERRYPI_FIRMWARE=y
894CONFIG_EFI_VARS=m 894CONFIG_EFI_VARS=m
895CONFIG_EFI_CAPSULE_LOADER=m 895CONFIG_EFI_CAPSULE_LOADER=m
896CONFIG_CONFIG_BCM47XX_NVRAM=y 896CONFIG_BCM47XX_NVRAM=y
897CONFIG_BCM47XX_SPROM=y 897CONFIG_BCM47XX_SPROM=y
898CONFIG_EXT4_FS=y 898CONFIG_EXT4_FS=y
899CONFIG_AUTOFS4_FS=y 899CONFIG_AUTOFS4_FS=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 4364040ed696..1e6c48dd7b11 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -86,9 +86,9 @@ CONFIG_IPV6_TUNNEL=m
86CONFIG_NETFILTER=y 86CONFIG_NETFILTER=y
87CONFIG_NF_CONNTRACK=m 87CONFIG_NF_CONNTRACK=m
88CONFIG_NF_CONNTRACK_EVENTS=y 88CONFIG_NF_CONNTRACK_EVENTS=y
89CONFIG_NF_CT_PROTO_DCCP=m 89CONFIG_NF_CT_PROTO_DCCP=y
90CONFIG_NF_CT_PROTO_SCTP=m 90CONFIG_NF_CT_PROTO_SCTP=y
91CONFIG_NF_CT_PROTO_UDPLITE=m 91CONFIG_NF_CT_PROTO_UDPLITE=y
92CONFIG_NF_CONNTRACK_AMANDA=m 92CONFIG_NF_CONNTRACK_AMANDA=m
93CONFIG_NF_CONNTRACK_FTP=m 93CONFIG_NF_CONNTRACK_FTP=m
94CONFIG_NF_CONNTRACK_H323=m 94CONFIG_NF_CONNTRACK_H323=m
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index 522b5feb4eaa..b62eaeb147aa 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -94,6 +94,9 @@
94#define ARM_CPU_XSCALE_ARCH_V2 0x4000 94#define ARM_CPU_XSCALE_ARCH_V2 0x4000
95#define ARM_CPU_XSCALE_ARCH_V3 0x6000 95#define ARM_CPU_XSCALE_ARCH_V3 0x6000
96 96
97/* Qualcomm implemented cores */
98#define ARM_CPU_PART_SCORPION 0x510002d0
99
97extern unsigned int processor_id; 100extern unsigned int processor_id;
98 101
99#ifdef CONFIG_CPU_CP15 102#ifdef CONFIG_CPU_CP15
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
index bfe2a2f5a644..22b73112b75f 100644
--- a/arch/arm/include/asm/ftrace.h
+++ b/arch/arm/include/asm/ftrace.h
@@ -54,6 +54,24 @@ static inline void *return_address(unsigned int level)
54 54
55#define ftrace_return_address(n) return_address(n) 55#define ftrace_return_address(n) return_address(n)
56 56
57#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
58
59static inline bool arch_syscall_match_sym_name(const char *sym,
60 const char *name)
61{
62 if (!strcmp(sym, "sys_mmap2"))
63 sym = "sys_mmap_pgoff";
64 else if (!strcmp(sym, "sys_statfs64_wrapper"))
65 sym = "sys_statfs64";
66 else if (!strcmp(sym, "sys_fstatfs64_wrapper"))
67 sym = "sys_fstatfs64";
68 else if (!strcmp(sym, "sys_arm_fadvise64_64"))
69 sym = "sys_fadvise64_64";
70
71 /* Ignore case since sym may start with "SyS" instead of "sys" */
72 return !strcasecmp(sym, name);
73}
74
57#endif /* ifndef __ASSEMBLY__ */ 75#endif /* ifndef __ASSEMBLY__ */
58 76
59#endif /* _ASM_ARM_FTRACE */ 77#endif /* _ASM_ARM_FTRACE */
diff --git a/arch/arm/include/asm/virt.h b/arch/arm/include/asm/virt.h
index a2e75b84e2ae..6dae1956c74d 100644
--- a/arch/arm/include/asm/virt.h
+++ b/arch/arm/include/asm/virt.h
@@ -80,6 +80,11 @@ static inline bool is_kernel_in_hyp_mode(void)
80 return false; 80 return false;
81} 81}
82 82
83static inline bool has_vhe(void)
84{
85 return false;
86}
87
83/* The section containing the hypervisor idmap text */ 88/* The section containing the hypervisor idmap text */
84extern char __hyp_idmap_text_start[]; 89extern char __hyp_idmap_text_start[];
85extern char __hyp_idmap_text_end[]; 90extern char __hyp_idmap_text_end[];
diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/uapi/asm/types.h
index a53cdb8f068c..9435a42f575e 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/uapi/asm/types.h
@@ -1,5 +1,5 @@
1#ifndef _ASM_TYPES_H 1#ifndef _UAPI_ASM_TYPES_H
2#define _ASM_TYPES_H 2#define _UAPI_ASM_TYPES_H
3 3
4#include <asm-generic/int-ll64.h> 4#include <asm-generic/int-ll64.h>
5 5
@@ -37,4 +37,4 @@
37#define __UINTPTR_TYPE__ unsigned long 37#define __UINTPTR_TYPE__ unsigned long
38#endif 38#endif
39 39
40#endif /* _ASM_TYPES_H */ 40#endif /* _UAPI_ASM_TYPES_H */
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index 188180b5523d..be3b3fbd382f 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -1063,6 +1063,22 @@ static int __init arch_hw_breakpoint_init(void)
1063 return 0; 1063 return 0;
1064 } 1064 }
1065 1065
1066 /*
1067 * Scorpion CPUs (at least those in APQ8060) seem to set DBGPRSR.SPD
1068 * whenever a WFI is issued, even if the core is not powered down, in
1069 * violation of the architecture. When DBGPRSR.SPD is set, accesses to
1070 * breakpoint and watchpoint registers are treated as undefined, so
1071 * this results in boot time and runtime failures when these are
1072 * accessed and we unexpectedly take a trap.
1073 *
1074 * It's not clear if/how this can be worked around, so we blacklist
1075 * Scorpion CPUs to avoid these issues.
1076 */
1077 if (read_cpuid_part() == ARM_CPU_PART_SCORPION) {
1078 pr_info("Scorpion CPU detected. Hardware breakpoints and watchpoints disabled\n");
1079 return 0;
1080 }
1081
1066 has_ossr = core_has_os_save_restore(); 1082 has_ossr = core_has_os_save_restore();
1067 1083
1068 /* Determine how many BRPs/WRPs are available. */ 1084 /* Determine how many BRPs/WRPs are available. */
diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
index 22313cb53362..9af0701f7094 100644
--- a/arch/arm/kernel/smp_tlb.c
+++ b/arch/arm/kernel/smp_tlb.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/preempt.h> 10#include <linux/preempt.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/uaccess.h>
12 13
13#include <asm/smp_plat.h> 14#include <asm/smp_plat.h>
14#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
@@ -40,8 +41,11 @@ static inline void ipi_flush_tlb_mm(void *arg)
40static inline void ipi_flush_tlb_page(void *arg) 41static inline void ipi_flush_tlb_page(void *arg)
41{ 42{
42 struct tlb_args *ta = (struct tlb_args *)arg; 43 struct tlb_args *ta = (struct tlb_args *)arg;
44 unsigned int __ua_flags = uaccess_save_and_enable();
43 45
44 local_flush_tlb_page(ta->ta_vma, ta->ta_start); 46 local_flush_tlb_page(ta->ta_vma, ta->ta_start);
47
48 uaccess_restore(__ua_flags);
45} 49}
46 50
47static inline void ipi_flush_tlb_kernel_page(void *arg) 51static inline void ipi_flush_tlb_kernel_page(void *arg)
@@ -54,8 +58,11 @@ static inline void ipi_flush_tlb_kernel_page(void *arg)
54static inline void ipi_flush_tlb_range(void *arg) 58static inline void ipi_flush_tlb_range(void *arg)
55{ 59{
56 struct tlb_args *ta = (struct tlb_args *)arg; 60 struct tlb_args *ta = (struct tlb_args *)arg;
61 unsigned int __ua_flags = uaccess_save_and_enable();
57 62
58 local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end); 63 local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end);
64
65 uaccess_restore(__ua_flags);
59} 66}
60 67
61static inline void ipi_flush_tlb_kernel_range(void *arg) 68static inline void ipi_flush_tlb_kernel_range(void *arg)
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 11676787ad49..9d7446456e0c 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -1099,6 +1099,9 @@ static void cpu_init_hyp_mode(void *dummy)
1099 __cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr); 1099 __cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr);
1100 __cpu_init_stage2(); 1100 __cpu_init_stage2();
1101 1101
1102 if (is_kernel_in_hyp_mode())
1103 kvm_timer_init_vhe();
1104
1102 kvm_arm_init_debug(); 1105 kvm_arm_init_debug();
1103} 1106}
1104 1107
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index df42c93a93d6..f5dce9b4e617 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,10 +31,10 @@ static LIST_HEAD(clocks);
31static DEFINE_MUTEX(clocks_mutex); 31static DEFINE_MUTEX(clocks_mutex);
32static DEFINE_SPINLOCK(clockfw_lock); 32static DEFINE_SPINLOCK(clockfw_lock);
33 33
34static void __clk_enable(struct clk *clk) 34void davinci_clk_enable(struct clk *clk)
35{ 35{
36 if (clk->parent) 36 if (clk->parent)
37 __clk_enable(clk->parent); 37 davinci_clk_enable(clk->parent);
38 if (clk->usecount++ == 0) { 38 if (clk->usecount++ == 0) {
39 if (clk->flags & CLK_PSC) 39 if (clk->flags & CLK_PSC)
40 davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, 40 davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
@@ -44,7 +44,7 @@ static void __clk_enable(struct clk *clk)
44 } 44 }
45} 45}
46 46
47static void __clk_disable(struct clk *clk) 47void davinci_clk_disable(struct clk *clk)
48{ 48{
49 if (WARN_ON(clk->usecount == 0)) 49 if (WARN_ON(clk->usecount == 0))
50 return; 50 return;
@@ -56,7 +56,7 @@ static void __clk_disable(struct clk *clk)
56 clk->clk_disable(clk); 56 clk->clk_disable(clk);
57 } 57 }
58 if (clk->parent) 58 if (clk->parent)
59 __clk_disable(clk->parent); 59 davinci_clk_disable(clk->parent);
60} 60}
61 61
62int davinci_clk_reset(struct clk *clk, bool reset) 62int davinci_clk_reset(struct clk *clk, bool reset)
@@ -103,7 +103,7 @@ int clk_enable(struct clk *clk)
103 return -EINVAL; 103 return -EINVAL;
104 104
105 spin_lock_irqsave(&clockfw_lock, flags); 105 spin_lock_irqsave(&clockfw_lock, flags);
106 __clk_enable(clk); 106 davinci_clk_enable(clk);
107 spin_unlock_irqrestore(&clockfw_lock, flags); 107 spin_unlock_irqrestore(&clockfw_lock, flags);
108 108
109 return 0; 109 return 0;
@@ -118,7 +118,7 @@ void clk_disable(struct clk *clk)
118 return; 118 return;
119 119
120 spin_lock_irqsave(&clockfw_lock, flags); 120 spin_lock_irqsave(&clockfw_lock, flags);
121 __clk_disable(clk); 121 davinci_clk_disable(clk);
122 spin_unlock_irqrestore(&clockfw_lock, flags); 122 spin_unlock_irqrestore(&clockfw_lock, flags);
123} 123}
124EXPORT_SYMBOL(clk_disable); 124EXPORT_SYMBOL(clk_disable);
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index e2a5437a1aee..fa2b83752e03 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -132,6 +132,8 @@ int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
132int davinci_set_refclk_rate(unsigned long rate); 132int davinci_set_refclk_rate(unsigned long rate);
133int davinci_simple_set_rate(struct clk *clk, unsigned long rate); 133int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
134int davinci_clk_reset(struct clk *clk, bool reset); 134int davinci_clk_reset(struct clk *clk, bool reset);
135void davinci_clk_enable(struct clk *clk);
136void davinci_clk_disable(struct clk *clk);
135 137
136extern struct platform_device davinci_wdt_device; 138extern struct platform_device davinci_wdt_device;
137extern void davinci_watchdog_reset(struct platform_device *); 139extern void davinci_watchdog_reset(struct platform_device *);
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index e770c97ea45c..1d873d15b545 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -319,6 +319,16 @@ static struct clk emac_clk = {
319 .gpsc = 1, 319 .gpsc = 1,
320}; 320};
321 321
322/*
323 * In order to avoid adding the emac_clk to the clock lookup table twice (and
324 * screwing up the linked list in the process) create a separate clock for
325 * mdio inheriting the rate from emac_clk.
326 */
327static struct clk mdio_clk = {
328 .name = "mdio",
329 .parent = &emac_clk,
330};
331
322static struct clk mcasp_clk = { 332static struct clk mcasp_clk = {
323 .name = "mcasp", 333 .name = "mcasp",
324 .parent = &async3_clk, 334 .parent = &async3_clk,
@@ -367,6 +377,16 @@ static struct clk aemif_clk = {
367 .flags = ALWAYS_ENABLED, 377 .flags = ALWAYS_ENABLED,
368}; 378};
369 379
380/*
381 * In order to avoid adding the aemif_clk to the clock lookup table twice (and
382 * screwing up the linked list in the process) create a separate clock for
383 * nand inheriting the rate from aemif_clk.
384 */
385static struct clk aemif_nand_clk = {
386 .name = "nand",
387 .parent = &aemif_clk,
388};
389
370static struct clk usb11_clk = { 390static struct clk usb11_clk = {
371 .name = "usb11", 391 .name = "usb11",
372 .parent = &pll0_sysclk4, 392 .parent = &pll0_sysclk4,
@@ -529,7 +549,7 @@ static struct clk_lookup da850_clks[] = {
529 CLK(NULL, "arm", &arm_clk), 549 CLK(NULL, "arm", &arm_clk),
530 CLK(NULL, "rmii", &rmii_clk), 550 CLK(NULL, "rmii", &rmii_clk),
531 CLK("davinci_emac.1", NULL, &emac_clk), 551 CLK("davinci_emac.1", NULL, &emac_clk),
532 CLK("davinci_mdio.0", "fck", &emac_clk), 552 CLK("davinci_mdio.0", "fck", &mdio_clk),
533 CLK("davinci-mcasp.0", NULL, &mcasp_clk), 553 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
534 CLK("davinci-mcbsp.0", NULL, &mcbsp0_clk), 554 CLK("davinci-mcbsp.0", NULL, &mcbsp0_clk),
535 CLK("davinci-mcbsp.1", NULL, &mcbsp1_clk), 555 CLK("davinci-mcbsp.1", NULL, &mcbsp1_clk),
@@ -537,7 +557,15 @@ static struct clk_lookup da850_clks[] = {
537 CLK("da830-mmc.0", NULL, &mmcsd0_clk), 557 CLK("da830-mmc.0", NULL, &mmcsd0_clk),
538 CLK("da830-mmc.1", NULL, &mmcsd1_clk), 558 CLK("da830-mmc.1", NULL, &mmcsd1_clk),
539 CLK("ti-aemif", NULL, &aemif_clk), 559 CLK("ti-aemif", NULL, &aemif_clk),
540 CLK(NULL, "aemif", &aemif_clk), 560 /*
561 * The only user of this clock is davinci_nand and it get's it through
562 * con_id. The nand node itself is created from within the aemif
563 * driver to guarantee that it's probed after the aemif timing
564 * parameters are configured. of_dev_auxdata is not accessible from
565 * the aemif driver and can't be passed to of_platform_populate(). For
566 * that reason we're leaving the dev_id here as NULL.
567 */
568 CLK(NULL, "aemif", &aemif_nand_clk),
541 CLK("ohci-da8xx", "usb11", &usb11_clk), 569 CLK("ohci-da8xx", "usb11", &usb11_clk),
542 CLK("musb-da8xx", "usb20", &usb20_clk), 570 CLK("musb-da8xx", "usb20", &usb20_clk),
543 CLK("spi_davinci.0", NULL, &spi0_clk), 571 CLK("spi_davinci.0", NULL, &spi0_clk),
diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c
index c6feecf7ae24..9a6af0bd5dc3 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -22,6 +22,8 @@
22#define DA8XX_USB0_BASE 0x01e00000 22#define DA8XX_USB0_BASE 0x01e00000
23#define DA8XX_USB1_BASE 0x01e25000 23#define DA8XX_USB1_BASE 0x01e25000
24 24
25static struct clk *usb20_clk;
26
25static struct platform_device da8xx_usb_phy = { 27static struct platform_device da8xx_usb_phy = {
26 .name = "da8xx-usb-phy", 28 .name = "da8xx-usb-phy",
27 .id = -1, 29 .id = -1,
@@ -158,26 +160,13 @@ int __init da8xx_register_usb_refclkin(int rate)
158 160
159static void usb20_phy_clk_enable(struct clk *clk) 161static void usb20_phy_clk_enable(struct clk *clk)
160{ 162{
161 struct clk *usb20_clk;
162 int err;
163 u32 val; 163 u32 val;
164 u32 timeout = 500000; /* 500 msec */ 164 u32 timeout = 500000; /* 500 msec */
165 165
166 val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); 166 val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
167 167
168 usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
169 if (IS_ERR(usb20_clk)) {
170 pr_err("could not get usb20 clk: %ld\n", PTR_ERR(usb20_clk));
171 return;
172 }
173
174 /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ 168 /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */
175 err = clk_prepare_enable(usb20_clk); 169 davinci_clk_enable(usb20_clk);
176 if (err) {
177 pr_err("failed to enable usb20 clk: %d\n", err);
178 clk_put(usb20_clk);
179 return;
180 }
181 170
182 /* 171 /*
183 * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1 172 * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1
@@ -197,8 +186,7 @@ static void usb20_phy_clk_enable(struct clk *clk)
197 186
198 pr_err("Timeout waiting for USB 2.0 PHY clock good\n"); 187 pr_err("Timeout waiting for USB 2.0 PHY clock good\n");
199done: 188done:
200 clk_disable_unprepare(usb20_clk); 189 davinci_clk_disable(usb20_clk);
201 clk_put(usb20_clk);
202} 190}
203 191
204static void usb20_phy_clk_disable(struct clk *clk) 192static void usb20_phy_clk_disable(struct clk *clk)
@@ -285,11 +273,19 @@ static struct clk_lookup usb20_phy_clk_lookup =
285int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) 273int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin)
286{ 274{
287 struct clk *parent; 275 struct clk *parent;
288 int ret = 0; 276 int ret;
277
278 usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
279 ret = PTR_ERR_OR_ZERO(usb20_clk);
280 if (ret)
281 return ret;
289 282
290 parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); 283 parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux");
291 if (IS_ERR(parent)) 284 ret = PTR_ERR_OR_ZERO(parent);
292 return PTR_ERR(parent); 285 if (ret) {
286 clk_put(usb20_clk);
287 return ret;
288 }
293 289
294 usb20_phy_clk.parent = parent; 290 usb20_phy_clk.parent = parent;
295 ret = clk_register(&usb20_phy_clk); 291 ret = clk_register(&usb20_phy_clk);
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 98ffe1e62ad5..a5d68411a037 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -385,36 +385,6 @@ fail:
385 return pen_release != -1 ? ret : 0; 385 return pen_release != -1 ? ret : 0;
386} 386}
387 387
388/*
389 * Initialise the CPU possible map early - this describes the CPUs
390 * which may be present or become present in the system.
391 */
392
393static void __init exynos_smp_init_cpus(void)
394{
395 void __iomem *scu_base = scu_base_addr();
396 unsigned int i, ncores;
397
398 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
399 ncores = scu_base ? scu_get_core_count(scu_base) : 1;
400 else
401 /*
402 * CPU Nodes are passed thru DT and set_cpu_possible
403 * is set by "arm_dt_init_cpu_maps".
404 */
405 return;
406
407 /* sanity check */
408 if (ncores > nr_cpu_ids) {
409 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
410 ncores, nr_cpu_ids);
411 ncores = nr_cpu_ids;
412 }
413
414 for (i = 0; i < ncores; i++)
415 set_cpu_possible(i, true);
416}
417
418static void __init exynos_smp_prepare_cpus(unsigned int max_cpus) 388static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
419{ 389{
420 int i; 390 int i;
@@ -479,7 +449,6 @@ static void exynos_cpu_die(unsigned int cpu)
479#endif /* CONFIG_HOTPLUG_CPU */ 449#endif /* CONFIG_HOTPLUG_CPU */
480 450
481const struct smp_operations exynos_smp_ops __initconst = { 451const struct smp_operations exynos_smp_ops __initconst = {
482 .smp_init_cpus = exynos_smp_init_cpus,
483 .smp_prepare_cpus = exynos_smp_prepare_cpus, 452 .smp_prepare_cpus = exynos_smp_prepare_cpus,
484 .smp_secondary_init = exynos_secondary_init, 453 .smp_secondary_init = exynos_secondary_init,
485 .smp_boot_secondary = exynos_boot_secondary, 454 .smp_boot_secondary = exynos_boot_secondary,
diff --git a/arch/arm/mach-imx/mach-imx1.c b/arch/arm/mach-imx/mach-imx1.c
index de5ab8d88549..3a8406e45b65 100644
--- a/arch/arm/mach-imx/mach-imx1.c
+++ b/arch/arm/mach-imx/mach-imx1.c
@@ -37,7 +37,6 @@ static const char * const imx1_dt_board_compat[] __initconst = {
37}; 37};
38 38
39DT_MACHINE_START(IMX1_DT, "Freescale i.MX1 (Device Tree Support)") 39DT_MACHINE_START(IMX1_DT, "Freescale i.MX1 (Device Tree Support)")
40 .map_io = debug_ll_io_init,
41 .init_early = imx1_init_early, 40 .init_early = imx1_init_early,
42 .init_irq = imx1_init_irq, 41 .init_irq = imx1_init_irq,
43 .dt_compat = imx1_dt_board_compat, 42 .dt_compat = imx1_dt_board_compat,
diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
index f6ba589cd312..c821c1d5610e 100644
--- a/arch/arm/mach-omap1/dma.c
+++ b/arch/arm/mach-omap1/dma.c
@@ -32,7 +32,6 @@
32#include "soc.h" 32#include "soc.h"
33 33
34#define OMAP1_DMA_BASE (0xfffed800) 34#define OMAP1_DMA_BASE (0xfffed800)
35#define OMAP1_LOGICAL_DMA_CH_COUNT 17
36 35
37static u32 enable_1510_mode; 36static u32 enable_1510_mode;
38 37
@@ -348,8 +347,6 @@ static int __init omap1_system_dma_init(void)
348 goto exit_iounmap; 347 goto exit_iounmap;
349 } 348 }
350 349
351 d->lch_count = OMAP1_LOGICAL_DMA_CH_COUNT;
352
353 /* Valid attributes for omap1 plus processors */ 350 /* Valid attributes for omap1 plus processors */
354 if (cpu_is_omap15xx()) 351 if (cpu_is_omap15xx())
355 d->dev_caps = ENABLE_1510_MODE; 352 d->dev_caps = ENABLE_1510_MODE;
@@ -366,13 +363,14 @@ static int __init omap1_system_dma_init(void)
366 d->dev_caps |= CLEAR_CSR_ON_READ; 363 d->dev_caps |= CLEAR_CSR_ON_READ;
367 d->dev_caps |= IS_WORD_16; 364 d->dev_caps |= IS_WORD_16;
368 365
369 if (cpu_is_omap15xx()) 366 /* available logical channels */
370 d->chan_count = 9; 367 if (cpu_is_omap15xx()) {
371 else if (cpu_is_omap16xx() || cpu_is_omap7xx()) { 368 d->lch_count = 9;
372 if (!(d->dev_caps & ENABLE_1510_MODE)) 369 } else {
373 d->chan_count = 16; 370 if (d->dev_caps & ENABLE_1510_MODE)
371 d->lch_count = 9;
374 else 372 else
375 d->chan_count = 9; 373 d->lch_count = 16;
376 } 374 }
377 375
378 p = dma_plat_info; 376 p = dma_plat_info;
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 469894082fea..093458b62c8d 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -I$(srctree)/$(src)/include \
7 7
8# Common support 8# Common support
9obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \ 9obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \
10 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \ 10 common.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
11 omap_device.o omap-headsmp.o sram.o drm.o 11 omap_device.o omap-headsmp.o sram.o drm.o
12 12
13hwmod-common = omap_hwmod.o omap_hwmod_reset.o \ 13hwmod-common = omap_hwmod.o omap_hwmod_reset.o \
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 36d9943205ca..dc9e34e670a2 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -304,7 +304,7 @@ DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
304 .init_late = am43xx_init_late, 304 .init_late = am43xx_init_late,
305 .init_irq = omap_gic_of_init, 305 .init_irq = omap_gic_of_init,
306 .init_machine = omap_generic_init, 306 .init_machine = omap_generic_init,
307 .init_time = omap4_local_timer_init, 307 .init_time = omap3_gptimer_timer_init,
308 .dt_compat = am43_boards_compat, 308 .dt_compat = am43_boards_compat,
309 .restart = omap44xx_restart, 309 .restart = omap44xx_restart,
310MACHINE_END 310MACHINE_END
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
deleted file mode 100644
index 7a577145b68b..000000000000
--- a/arch/arm/mach-omap2/gpio.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/*
2 * OMAP2+ specific gpio initialization
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/gpio.h>
20#include <linux/err.h>
21#include <linux/slab.h>
22#include <linux/interrupt.h>
23#include <linux/of.h>
24#include <linux/platform_data/gpio-omap.h>
25
26#include "soc.h"
27#include "omap_hwmod.h"
28#include "omap_device.h"
29#include "omap-pm.h"
30
31#include "powerdomain.h"
32
33static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
34{
35 struct platform_device *pdev;
36 struct omap_gpio_platform_data *pdata;
37 struct omap_gpio_dev_attr *dev_attr;
38 char *name = "omap_gpio";
39 int id;
40 struct powerdomain *pwrdm;
41
42 /*
43 * extract the device id from name field available in the
44 * hwmod database and use the same for constructing ids for
45 * gpio devices.
46 * CAUTION: Make sure the name in the hwmod database does
47 * not change. If changed, make corresponding change here
48 * or make use of static variable mechanism to handle this.
49 */
50 sscanf(oh->name, "gpio%d", &id);
51
52 pdata = kzalloc(sizeof(struct omap_gpio_platform_data), GFP_KERNEL);
53 if (!pdata) {
54 pr_err("gpio%d: Memory allocation failed\n", id);
55 return -ENOMEM;
56 }
57
58 dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr;
59 pdata->bank_width = dev_attr->bank_width;
60 pdata->dbck_flag = dev_attr->dbck_flag;
61 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
62 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
63 if (!pdata->regs) {
64 pr_err("gpio%d: Memory allocation failed\n", id);
65 kfree(pdata);
66 return -ENOMEM;
67 }
68
69 switch (oh->class->rev) {
70 case 0:
71 if (id == 1)
72 /* non-wakeup GPIO pins for OMAP2 Bank1 */
73 pdata->non_wakeup_gpios = 0xe203ffc0;
74 else if (id == 2)
75 /* non-wakeup GPIO pins for OMAP2 Bank2 */
76 pdata->non_wakeup_gpios = 0x08700040;
77 /* fall through */
78
79 case 1:
80 pdata->regs->revision = OMAP24XX_GPIO_REVISION;
81 pdata->regs->direction = OMAP24XX_GPIO_OE;
82 pdata->regs->datain = OMAP24XX_GPIO_DATAIN;
83 pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT;
84 pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT;
85 pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT;
86 pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1;
87 pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2;
88 pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1;
89 pdata->regs->irqenable2 = OMAP24XX_GPIO_IRQENABLE2;
90 pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1;
91 pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
92 pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
93 pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
94 pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
95 pdata->regs->wkup_en = OMAP24XX_GPIO_WAKE_EN;
96 pdata->regs->leveldetect0 = OMAP24XX_GPIO_LEVELDETECT0;
97 pdata->regs->leveldetect1 = OMAP24XX_GPIO_LEVELDETECT1;
98 pdata->regs->risingdetect = OMAP24XX_GPIO_RISINGDETECT;
99 pdata->regs->fallingdetect = OMAP24XX_GPIO_FALLINGDETECT;
100 break;
101 case 2:
102 pdata->regs->revision = OMAP4_GPIO_REVISION;
103 pdata->regs->direction = OMAP4_GPIO_OE;
104 pdata->regs->datain = OMAP4_GPIO_DATAIN;
105 pdata->regs->dataout = OMAP4_GPIO_DATAOUT;
106 pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT;
107 pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT;
108 pdata->regs->irqstatus_raw0 = OMAP4_GPIO_IRQSTATUSRAW0;
109 pdata->regs->irqstatus_raw1 = OMAP4_GPIO_IRQSTATUSRAW1;
110 pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0;
111 pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
112 pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0;
113 pdata->regs->irqenable2 = OMAP4_GPIO_IRQSTATUSSET1;
114 pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0;
115 pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
116 pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
117 pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
118 pdata->regs->ctrl = OMAP4_GPIO_CTRL;
119 pdata->regs->wkup_en = OMAP4_GPIO_IRQWAKEN0;
120 pdata->regs->leveldetect0 = OMAP4_GPIO_LEVELDETECT0;
121 pdata->regs->leveldetect1 = OMAP4_GPIO_LEVELDETECT1;
122 pdata->regs->risingdetect = OMAP4_GPIO_RISINGDETECT;
123 pdata->regs->fallingdetect = OMAP4_GPIO_FALLINGDETECT;
124 break;
125 default:
126 WARN(1, "Invalid gpio bank_type\n");
127 kfree(pdata->regs);
128 kfree(pdata);
129 return -EINVAL;
130 }
131
132 pwrdm = omap_hwmod_get_pwrdm(oh);
133 pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
134
135 pdev = omap_device_build(name, id - 1, oh, pdata, sizeof(*pdata));
136 kfree(pdata);
137
138 if (IS_ERR(pdev)) {
139 WARN(1, "Can't build omap_device for %s:%s.\n",
140 name, oh->name);
141 return PTR_ERR(pdev);
142 }
143
144 return 0;
145}
146
147/*
148 * gpio_init needs to be done before
149 * machine_init functions access gpio APIs.
150 * Hence gpio_init is a omap_postcore_initcall.
151 */
152static int __init omap2_gpio_init(void)
153{
154 /* If dtb is there, the devices will be created dynamically */
155 if (of_have_populated_dt())
156 return -ENODEV;
157
158 return omap_hwmod_for_each_by_class("gpio", omap2_gpio_dev_init, NULL);
159}
160omap_postcore_initcall(omap2_gpio_init);
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 759e1d45ba25..e8b988714a09 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -741,14 +741,14 @@ static int _init_main_clk(struct omap_hwmod *oh)
741 int ret = 0; 741 int ret = 0;
742 char name[MOD_CLK_MAX_NAME_LEN]; 742 char name[MOD_CLK_MAX_NAME_LEN];
743 struct clk *clk; 743 struct clk *clk;
744 static const char modck[] = "_mod_ck";
744 745
745 /* +7 magic comes from '_mod_ck' suffix */ 746 if (strlen(oh->name) >= MOD_CLK_MAX_NAME_LEN - strlen(modck))
746 if (strlen(oh->name) + 7 > MOD_CLK_MAX_NAME_LEN)
747 pr_warn("%s: warning: cropping name for %s\n", __func__, 747 pr_warn("%s: warning: cropping name for %s\n", __func__,
748 oh->name); 748 oh->name);
749 749
750 strncpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - 7); 750 strlcpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - strlen(modck));
751 strcat(name, "_mod_ck"); 751 strlcat(name, modck, MOD_CLK_MAX_NAME_LEN);
752 752
753 clk = clk_get(NULL, name); 753 clk = clk_get(NULL, name);
754 if (!IS_ERR(clk)) { 754 if (!IS_ERR(clk)) {
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.h b/arch/arm/mach-omap2/omap_hwmod_common_data.h
index cdfbb44ceb0c..f22e9cb39f4a 100644
--- a/arch/arm/mach-omap2/omap_hwmod_common_data.h
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.h
@@ -121,10 +121,6 @@ extern struct omap_hwmod_irq_info omap2_uart3_mpu_irqs[];
121extern struct omap_hwmod_irq_info omap2_dispc_irqs[]; 121extern struct omap_hwmod_irq_info omap2_dispc_irqs[];
122extern struct omap_hwmod_irq_info omap2_i2c1_mpu_irqs[]; 122extern struct omap_hwmod_irq_info omap2_i2c1_mpu_irqs[];
123extern struct omap_hwmod_irq_info omap2_i2c2_mpu_irqs[]; 123extern struct omap_hwmod_irq_info omap2_i2c2_mpu_irqs[];
124extern struct omap_hwmod_irq_info omap2_gpio1_irqs[];
125extern struct omap_hwmod_irq_info omap2_gpio2_irqs[];
126extern struct omap_hwmod_irq_info omap2_gpio3_irqs[];
127extern struct omap_hwmod_irq_info omap2_gpio4_irqs[];
128extern struct omap_hwmod_irq_info omap2_dma_system_irqs[]; 124extern struct omap_hwmod_irq_info omap2_dma_system_irqs[];
129extern struct omap_hwmod_irq_info omap2_mcspi1_mpu_irqs[]; 125extern struct omap_hwmod_irq_info omap2_mcspi1_mpu_irqs[];
130extern struct omap_hwmod_irq_info omap2_mcspi2_mpu_irqs[]; 126extern struct omap_hwmod_irq_info omap2_mcspi2_mpu_irqs[];
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 477910a48448..70c004794880 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -161,7 +161,7 @@ static struct ti_st_plat_data wilink7_pdata = {
161 .nshutdown_gpio = 162, 161 .nshutdown_gpio = 162,
162 .dev_name = "/dev/ttyO1", 162 .dev_name = "/dev/ttyO1",
163 .flow_cntrl = 1, 163 .flow_cntrl = 1,
164 .baud_rate = 300000, 164 .baud_rate = 3000000,
165}; 165};
166 166
167static struct platform_device wl128x_device = { 167static struct platform_device wl128x_device = {
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 5b2f5138d938..2b138b65129a 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -295,10 +295,8 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
295 GFP_KERNEL); 295 GFP_KERNEL);
296 296
297 if (!prcm_irq_chips || !prcm_irq_setup->saved_mask || 297 if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
298 !prcm_irq_setup->priority_mask) { 298 !prcm_irq_setup->priority_mask)
299 pr_err("PRCM: kzalloc failed\n");
300 goto err; 299 goto err;
301 }
302 300
303 memset(mask, 0, sizeof(mask)); 301 memset(mask, 0, sizeof(mask));
304 302
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 56128da23c3a..07dd692c4737 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -510,18 +510,19 @@ void __init omap3_secure_sync32k_timer_init(void)
510} 510}
511#endif /* CONFIG_ARCH_OMAP3 */ 511#endif /* CONFIG_ARCH_OMAP3 */
512 512
513#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) 513#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) || \
514 defined(CONFIG_SOC_AM43XX)
514void __init omap3_gptimer_timer_init(void) 515void __init omap3_gptimer_timer_init(void)
515{ 516{
516 __omap_sync32k_timer_init(2, "timer_sys_ck", NULL, 517 __omap_sync32k_timer_init(2, "timer_sys_ck", NULL,
517 1, "timer_sys_ck", "ti,timer-alwon", true); 518 1, "timer_sys_ck", "ti,timer-alwon", true);
518 519 if (of_have_populated_dt())
519 clocksource_probe(); 520 clocksource_probe();
520} 521}
521#endif 522#endif
522 523
523#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \ 524#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
524 defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM43XX) 525 defined(CONFIG_SOC_DRA7XX)
525static void __init omap4_sync32k_timer_init(void) 526static void __init omap4_sync32k_timer_init(void)
526{ 527{
527 __omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon", 528 __omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c
index f6c3f151d0d4..b59f4f4f256f 100644
--- a/arch/arm/mach-s3c24xx/common.c
+++ b/arch/arm/mach-s3c24xx/common.c
@@ -345,10 +345,40 @@ static struct s3c24xx_dma_channel s3c2410_dma_channels[DMACH_MAX] = {
345 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), }, 345 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), },
346}; 346};
347 347
348static const struct dma_slave_map s3c2410_dma_slave_map[] = {
349 { "s3c2410-sdi", "rx-tx", (void *)DMACH_SDI },
350 { "s3c2410-spi.0", "rx", (void *)DMACH_SPI0_RX },
351 { "s3c2410-spi.0", "tx", (void *)DMACH_SPI0_TX },
352 { "s3c2410-spi.1", "rx", (void *)DMACH_SPI1_RX },
353 { "s3c2410-spi.1", "tx", (void *)DMACH_SPI1_TX },
354 /*
355 * The DMA request source[1] (DMACH_UARTx_SRC2) are
356 * not used in the UART driver.
357 */
358 { "s3c2410-uart.0", "rx", (void *)DMACH_UART0 },
359 { "s3c2410-uart.0", "tx", (void *)DMACH_UART0 },
360 { "s3c2410-uart.1", "rx", (void *)DMACH_UART1 },
361 { "s3c2410-uart.1", "tx", (void *)DMACH_UART1 },
362 { "s3c2410-uart.2", "rx", (void *)DMACH_UART2 },
363 { "s3c2410-uart.2", "tx", (void *)DMACH_UART2 },
364 { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
365 { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
366 { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
367 { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
368 { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
369 { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
370 { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
371 { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
372 { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
373 { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
374};
375
348static struct s3c24xx_dma_platdata s3c2410_dma_platdata = { 376static struct s3c24xx_dma_platdata s3c2410_dma_platdata = {
349 .num_phy_channels = 4, 377 .num_phy_channels = 4,
350 .channels = s3c2410_dma_channels, 378 .channels = s3c2410_dma_channels,
351 .num_channels = DMACH_MAX, 379 .num_channels = DMACH_MAX,
380 .slave_map = s3c2410_dma_slave_map,
381 .slavecnt = ARRAY_SIZE(s3c2410_dma_slave_map),
352}; 382};
353 383
354struct platform_device s3c2410_device_dma = { 384struct platform_device s3c2410_device_dma = {
@@ -388,10 +418,36 @@ static struct s3c24xx_dma_channel s3c2412_dma_channels[DMACH_MAX] = {
388 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 }, 418 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 },
389}; 419};
390 420
421static const struct dma_slave_map s3c2412_dma_slave_map[] = {
422 { "s3c2412-sdi", "rx-tx", (void *)DMACH_SDI },
423 { "s3c2412-spi.0", "rx", (void *)DMACH_SPI0_RX },
424 { "s3c2412-spi.0", "tx", (void *)DMACH_SPI0_TX },
425 { "s3c2412-spi.1", "rx", (void *)DMACH_SPI1_RX },
426 { "s3c2412-spi.1", "tx", (void *)DMACH_SPI1_TX },
427 { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
428 { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
429 { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
430 { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
431 { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
432 { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
433 { "s3c2412-iis", "rx", (void *)DMACH_I2S_IN },
434 { "s3c2412-iis", "tx", (void *)DMACH_I2S_OUT },
435 { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
436 { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
437 { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
438 { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
439 { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
440 { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
441 { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
442 { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
443};
444
391static struct s3c24xx_dma_platdata s3c2412_dma_platdata = { 445static struct s3c24xx_dma_platdata s3c2412_dma_platdata = {
392 .num_phy_channels = 4, 446 .num_phy_channels = 4,
393 .channels = s3c2412_dma_channels, 447 .channels = s3c2412_dma_channels,
394 .num_channels = DMACH_MAX, 448 .num_channels = DMACH_MAX,
449 .slave_map = s3c2412_dma_slave_map,
450 .slavecnt = ARRAY_SIZE(s3c2412_dma_slave_map),
395}; 451};
396 452
397struct platform_device s3c2412_device_dma = { 453struct platform_device s3c2412_device_dma = {
@@ -534,10 +590,30 @@ static struct s3c24xx_dma_channel s3c2443_dma_channels[DMACH_MAX] = {
534 [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 }, 590 [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 },
535}; 591};
536 592
593static const struct dma_slave_map s3c2443_dma_slave_map[] = {
594 { "s3c2440-sdi", "rx-tx", (void *)DMACH_SDI },
595 { "s3c2443-spi.0", "rx", (void *)DMACH_SPI0_RX },
596 { "s3c2443-spi.0", "tx", (void *)DMACH_SPI0_TX },
597 { "s3c2443-spi.1", "rx", (void *)DMACH_SPI1_RX },
598 { "s3c2443-spi.1", "tx", (void *)DMACH_SPI1_TX },
599 { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
600 { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
601 { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
602 { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
603 { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
604 { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
605 { "s3c2440-uart.3", "rx", (void *)DMACH_UART3 },
606 { "s3c2440-uart.3", "tx", (void *)DMACH_UART3 },
607 { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
608 { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
609};
610
537static struct s3c24xx_dma_platdata s3c2443_dma_platdata = { 611static struct s3c24xx_dma_platdata s3c2443_dma_platdata = {
538 .num_phy_channels = 6, 612 .num_phy_channels = 6,
539 .channels = s3c2443_dma_channels, 613 .channels = s3c2443_dma_channels,
540 .num_channels = DMACH_MAX, 614 .num_channels = DMACH_MAX,
615 .slave_map = s3c2443_dma_slave_map,
616 .slavecnt = ARRAY_SIZE(s3c2443_dma_slave_map),
541}; 617};
542 618
543struct platform_device s3c2443_device_dma = { 619struct platform_device s3c2443_device_dma = {
diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
index 8538910db202..a970e7fcba9e 100644
--- a/arch/arm/mach-ux500/pm.c
+++ b/arch/arm/mach-ux500/pm.c
@@ -134,8 +134,8 @@ bool prcmu_pending_irq(void)
134 */ 134 */
135bool prcmu_is_cpu_in_wfi(int cpu) 135bool prcmu_is_cpu_in_wfi(int cpu)
136{ 136{
137 return readl(PRCM_ARM_WFI_STANDBY) & cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : 137 return readl(PRCM_ARM_WFI_STANDBY) &
138 PRCM_ARM_WFI_STANDBY_WFI0; 138 (cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : PRCM_ARM_WFI_STANDBY_WFI0);
139} 139}
140 140
141/* 141/*
diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
index fc033c0d2a0f..eada0b58ba1c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -356,5 +356,21 @@
356 status = "disabled"; 356 status = "disabled";
357 }; 357 };
358 }; 358 };
359
360 vpu: vpu@d0100000 {
361 compatible = "amlogic,meson-gx-vpu";
362 reg = <0x0 0xd0100000 0x0 0x100000>,
363 <0x0 0xc883c000 0x0 0x1000>,
364 <0x0 0xc8838000 0x0 0x1000>;
365 reg-names = "vpu", "hhi", "dmc";
366 interrupts = <GIC_SPI 3 IRQ_TYPE_EDGE_RISING>;
367 #address-cells = <1>;
368 #size-cells = <0>;
369
370 /* CVBS VDAC output port */
371 cvbs_vdac_port: port@0 {
372 reg = <0>;
373 };
374 };
359 }; 375 };
360}; 376};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
index 969682092e0f..4cbd626a9e88 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
@@ -142,6 +142,16 @@
142 clocks = <&wifi32k>; 142 clocks = <&wifi32k>;
143 clock-names = "ext_clock"; 143 clock-names = "ext_clock";
144 }; 144 };
145
146 cvbs-connector {
147 compatible = "composite-video-connector";
148
149 port {
150 cvbs_connector_in: endpoint {
151 remote-endpoint = <&cvbs_vdac_out>;
152 };
153 };
154 };
145}; 155};
146 156
147&uart_AO { 157&uart_AO {
@@ -229,3 +239,9 @@
229 clocks = <&clkc CLKID_FCLK_DIV4>; 239 clocks = <&clkc CLKID_FCLK_DIV4>;
230 clock-names = "clkin0"; 240 clock-names = "clkin0";
231}; 241};
242
243&cvbs_vdac_port {
244 cvbs_vdac_out: endpoint {
245 remote-endpoint = <&cvbs_connector_in>;
246 };
247};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 238fbeacd330..5d28e1cdc998 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -137,6 +137,10 @@
137 }; 137 };
138}; 138};
139 139
140&scpi_clocks {
141 status = "disabled";
142};
143
140&uart_AO { 144&uart_AO {
141 status = "okay"; 145 status = "okay";
142 pinctrl-0 = <&uart_ao_a_pins>; 146 pinctrl-0 = <&uart_ao_a_pins>;
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
index 203be28978d5..4a96e0f6f926 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
@@ -125,6 +125,16 @@
125 clocks = <&wifi32k>; 125 clocks = <&wifi32k>;
126 clock-names = "ext_clock"; 126 clock-names = "ext_clock";
127 }; 127 };
128
129 cvbs-connector {
130 compatible = "composite-video-connector";
131
132 port {
133 cvbs_connector_in: endpoint {
134 remote-endpoint = <&cvbs_vdac_out>;
135 };
136 };
137 };
128}; 138};
129 139
130/* This UART is brought out to the DB9 connector */ 140/* This UART is brought out to the DB9 connector */
@@ -234,3 +244,9 @@
234 clocks = <&clkc CLKID_FCLK_DIV4>; 244 clocks = <&clkc CLKID_FCLK_DIV4>;
235 clock-names = "clkin0"; 245 clock-names = "clkin0";
236}; 246};
247
248&cvbs_vdac_port {
249 cvbs_vdac_out: endpoint {
250 remote-endpoint = <&cvbs_connector_in>;
251 };
252};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 51edd5b5c460..b35307321b63 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -55,7 +55,7 @@
55 mboxes = <&mailbox 1 &mailbox 2>; 55 mboxes = <&mailbox 1 &mailbox 2>;
56 shmem = <&cpu_scp_lpri &cpu_scp_hpri>; 56 shmem = <&cpu_scp_lpri &cpu_scp_hpri>;
57 57
58 clocks { 58 scpi_clocks: clocks {
59 compatible = "arm,scpi-clocks"; 59 compatible = "arm,scpi-clocks";
60 60
61 scpi_dvfs: scpi_clocks@0 { 61 scpi_dvfs: scpi_clocks@0 {
@@ -506,3 +506,7 @@
506 <&clkc CLKID_FCLK_DIV2>; 506 <&clkc CLKID_FCLK_DIV2>;
507 clock-names = "core", "clkin0", "clkin1"; 507 clock-names = "core", "clkin0", "clkin1";
508}; 508};
509
510&vpu {
511 compatible = "amlogic,meson-gxbb-vpu", "amlogic,meson-gx-vpu";
512};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
index e99101ae9664..cea4a3eded9b 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
@@ -117,6 +117,16 @@
117 clocks = <&wifi32k>; 117 clocks = <&wifi32k>;
118 clock-names = "ext_clock"; 118 clock-names = "ext_clock";
119 }; 119 };
120
121 cvbs-connector {
122 compatible = "composite-video-connector";
123
124 port {
125 cvbs_connector_in: endpoint {
126 remote-endpoint = <&cvbs_vdac_out>;
127 };
128 };
129 };
120}; 130};
121 131
122&uart_AO { 132&uart_AO {
@@ -203,3 +213,9 @@
203 clocks = <&clkc CLKID_FCLK_DIV4>; 213 clocks = <&clkc CLKID_FCLK_DIV4>;
204 clock-names = "clkin0"; 214 clock-names = "clkin0";
205}; 215};
216
217&cvbs_vdac_port {
218 cvbs_vdac_out: endpoint {
219 remote-endpoint = <&cvbs_connector_in>;
220 };
221};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index 9f89b99c4806..69216246275d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -43,7 +43,7 @@
43 43
44#include "meson-gx.dtsi" 44#include "meson-gx.dtsi"
45#include <dt-bindings/clock/gxbb-clkc.h> 45#include <dt-bindings/clock/gxbb-clkc.h>
46#include <dt-bindings/gpio/meson-gxbb-gpio.h> 46#include <dt-bindings/gpio/meson-gxl-gpio.h>
47 47
48/ { 48/ {
49 compatible = "amlogic,meson-gxl"; 49 compatible = "amlogic,meson-gxl";
@@ -299,3 +299,7 @@
299 <&clkc CLKID_FCLK_DIV2>; 299 <&clkc CLKID_FCLK_DIV2>;
300 clock-names = "core", "clkin0", "clkin1"; 300 clock-names = "core", "clkin0", "clkin1";
301}; 301};
302
303&vpu {
304 compatible = "amlogic,meson-gxl-vpu", "amlogic,meson-gx-vpu";
305};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
index f859d75db8bd..5a337d339df1 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
@@ -90,6 +90,16 @@
90 compatible = "mmc-pwrseq-emmc"; 90 compatible = "mmc-pwrseq-emmc";
91 reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>; 91 reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
92 }; 92 };
93
94 cvbs-connector {
95 compatible = "composite-video-connector";
96
97 port {
98 cvbs_connector_in: endpoint {
99 remote-endpoint = <&cvbs_vdac_out>;
100 };
101 };
102 };
93}; 103};
94 104
95/* This UART is brought out to the DB9 connector */ 105/* This UART is brought out to the DB9 connector */
@@ -167,3 +177,9 @@
167 max-speed = <1000>; 177 max-speed = <1000>;
168 }; 178 };
169}; 179};
180
181&cvbs_vdac_port {
182 cvbs_vdac_out: endpoint {
183 remote-endpoint = <&cvbs_connector_in>;
184 };
185};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
index c1974bbbddea..eb2f0c3e5e53 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
@@ -112,3 +112,7 @@
112 }; 112 };
113 }; 113 };
114}; 114};
115
116&vpu {
117 compatible = "amlogic,meson-gxm-vpu", "amlogic,meson-gx-vpu";
118};
diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
index a852e28a40e1..a83ed2c6bbf7 100644
--- a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
+++ b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
@@ -81,7 +81,7 @@
81 #address-cells = <0>; 81 #address-cells = <0>;
82 interrupt-controller; 82 interrupt-controller;
83 reg = <0x0 0x2c001000 0 0x1000>, 83 reg = <0x0 0x2c001000 0 0x1000>,
84 <0x0 0x2c002000 0 0x1000>, 84 <0x0 0x2c002000 0 0x2000>,
85 <0x0 0x2c004000 0 0x2000>, 85 <0x0 0x2c004000 0 0x2000>,
86 <0x0 0x2c006000 0 0x2000>; 86 <0x0 0x2c006000 0 0x2000>;
87 interrupts = <1 9 0xf04>; 87 interrupts = <1 9 0xf04>;
diff --git a/arch/arm64/boot/dts/exynos/exynos5433.dtsi b/arch/arm64/boot/dts/exynos/exynos5433.dtsi
index 64226d5ae471..135890cd8a85 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynos5433.dtsi
@@ -1367,7 +1367,7 @@
1367 }; 1367 };
1368 1368
1369 amba { 1369 amba {
1370 compatible = "arm,amba-bus"; 1370 compatible = "simple-bus";
1371 #address-cells = <1>; 1371 #address-cells = <1>;
1372 #size-cells = <1>; 1372 #size-cells = <1>;
1373 ranges; 1373 ranges;
diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 9d1d7ad9b075..29ed6b61c737 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -64,6 +64,16 @@
64 reg = <0x0 0x86000000 0x0 0x200000>; 64 reg = <0x0 0x86000000 0x0 0x200000>;
65 no-map; 65 no-map;
66 }; 66 };
67
68 memory@85800000 {
69 reg = <0x0 0x85800000 0x0 0x800000>;
70 no-map;
71 };
72
73 memory@86200000 {
74 reg = <0x0 0x86200000 0x0 0x2600000>;
75 no-map;
76 };
67 }; 77 };
68 78
69 cpus { 79 cpus {
diff --git a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
index 6ffb0517421a..dbea2c3d8f0c 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
@@ -169,7 +169,7 @@
169 power-source = <3300>; 169 power-source = <3300>;
170 }; 170 };
171 171
172 sdhi0_pins_uhs: sd0 { 172 sdhi0_pins_uhs: sd0_uhs {
173 groups = "sdhi0_data4", "sdhi0_ctrl"; 173 groups = "sdhi0_data4", "sdhi0_ctrl";
174 function = "sdhi0"; 174 function = "sdhi0";
175 power-source = <1800>; 175 power-source = <1800>;
diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
index 358089687a69..ef1b9e573af0 100644
--- a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
+++ b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
@@ -27,7 +27,7 @@
27 stdout-path = "serial0:115200n8"; 27 stdout-path = "serial0:115200n8";
28 }; 28 };
29 29
30 memory { 30 memory@0 {
31 device_type = "memory"; 31 device_type = "memory";
32 reg = <0x0 0x0 0x0 0x40000000>; 32 reg = <0x0 0x0 0x0 0x40000000>;
33 }; 33 };
diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
index 68a908334c7b..54dc28351c8c 100644
--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
+++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
@@ -72,7 +72,7 @@
72 <1 10 0xf08>; 72 <1 10 0xf08>;
73 }; 73 };
74 74
75 amba_apu { 75 amba_apu: amba_apu@0 {
76 compatible = "simple-bus"; 76 compatible = "simple-bus";
77 #address-cells = <2>; 77 #address-cells = <2>;
78 #size-cells = <1>; 78 #size-cells = <1>;
@@ -175,7 +175,7 @@
175 }; 175 };
176 176
177 i2c0: i2c@ff020000 { 177 i2c0: i2c@ff020000 {
178 compatible = "cdns,i2c-r1p10"; 178 compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
179 status = "disabled"; 179 status = "disabled";
180 interrupt-parent = <&gic>; 180 interrupt-parent = <&gic>;
181 interrupts = <0 17 4>; 181 interrupts = <0 17 4>;
@@ -185,7 +185,7 @@
185 }; 185 };
186 186
187 i2c1: i2c@ff030000 { 187 i2c1: i2c@ff030000 {
188 compatible = "cdns,i2c-r1p10"; 188 compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
189 status = "disabled"; 189 status = "disabled";
190 interrupt-parent = <&gic>; 190 interrupt-parent = <&gic>;
191 interrupts = <0 18 4>; 191 interrupts = <0 18 4>;
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 869dded0f09f..33b744d54739 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -331,6 +331,7 @@ CONFIG_DRM_VC4=m
331CONFIG_DRM_PANEL_SIMPLE=m 331CONFIG_DRM_PANEL_SIMPLE=m
332CONFIG_DRM_I2C_ADV7511=m 332CONFIG_DRM_I2C_ADV7511=m
333CONFIG_DRM_HISI_KIRIN=m 333CONFIG_DRM_HISI_KIRIN=m
334CONFIG_DRM_MESON=m
334CONFIG_FB=y 335CONFIG_FB=y
335CONFIG_FB_ARMCLCD=y 336CONFIG_FB_ARMCLCD=y
336CONFIG_BACKLIGHT_GENERIC=m 337CONFIG_BACKLIGHT_GENERIC=m
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 446f6c46d4b1..3a4301163e04 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -164,22 +164,25 @@ lr .req x30 // link register
164 164
165/* 165/*
166 * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where 166 * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
167 * <symbol> is within the range +/- 4 GB of the PC. 167 * <symbol> is within the range +/- 4 GB of the PC when running
168 * in core kernel context. In module context, a movz/movk sequence
169 * is used, since modules may be loaded far away from the kernel
170 * when KASLR is in effect.
168 */ 171 */
169 /* 172 /*
170 * @dst: destination register (64 bit wide) 173 * @dst: destination register (64 bit wide)
171 * @sym: name of the symbol 174 * @sym: name of the symbol
172 * @tmp: optional scratch register to be used if <dst> == sp, which
173 * is not allowed in an adrp instruction
174 */ 175 */
175 .macro adr_l, dst, sym, tmp= 176 .macro adr_l, dst, sym
176 .ifb \tmp 177#ifndef MODULE
177 adrp \dst, \sym 178 adrp \dst, \sym
178 add \dst, \dst, :lo12:\sym 179 add \dst, \dst, :lo12:\sym
179 .else 180#else
180 adrp \tmp, \sym 181 movz \dst, #:abs_g3:\sym
181 add \dst, \tmp, :lo12:\sym 182 movk \dst, #:abs_g2_nc:\sym
182 .endif 183 movk \dst, #:abs_g1_nc:\sym
184 movk \dst, #:abs_g0_nc:\sym
185#endif
183 .endm 186 .endm
184 187
185 /* 188 /*
@@ -190,6 +193,7 @@ lr .req x30 // link register
190 * the address 193 * the address
191 */ 194 */
192 .macro ldr_l, dst, sym, tmp= 195 .macro ldr_l, dst, sym, tmp=
196#ifndef MODULE
193 .ifb \tmp 197 .ifb \tmp
194 adrp \dst, \sym 198 adrp \dst, \sym
195 ldr \dst, [\dst, :lo12:\sym] 199 ldr \dst, [\dst, :lo12:\sym]
@@ -197,6 +201,15 @@ lr .req x30 // link register
197 adrp \tmp, \sym 201 adrp \tmp, \sym
198 ldr \dst, [\tmp, :lo12:\sym] 202 ldr \dst, [\tmp, :lo12:\sym]
199 .endif 203 .endif
204#else
205 .ifb \tmp
206 adr_l \dst, \sym
207 ldr \dst, [\dst]
208 .else
209 adr_l \tmp, \sym
210 ldr \dst, [\tmp]
211 .endif
212#endif
200 .endm 213 .endm
201 214
202 /* 215 /*
@@ -206,8 +219,13 @@ lr .req x30 // link register
206 * while <src> needs to be preserved. 219 * while <src> needs to be preserved.
207 */ 220 */
208 .macro str_l, src, sym, tmp 221 .macro str_l, src, sym, tmp
222#ifndef MODULE
209 adrp \tmp, \sym 223 adrp \tmp, \sym
210 str \src, [\tmp, :lo12:\sym] 224 str \src, [\tmp, :lo12:\sym]
225#else
226 adr_l \tmp, \sym
227 str \src, [\tmp]
228#endif
211 .endm 229 .endm
212 230
213 /* 231 /*
diff --git a/arch/arm64/include/asm/current.h b/arch/arm64/include/asm/current.h
index f2bcbe2d9889..86c404171305 100644
--- a/arch/arm64/include/asm/current.h
+++ b/arch/arm64/include/asm/current.h
@@ -9,9 +9,17 @@
9 9
10struct task_struct; 10struct task_struct;
11 11
12/*
13 * We don't use read_sysreg() as we want the compiler to cache the value where
14 * possible.
15 */
12static __always_inline struct task_struct *get_current(void) 16static __always_inline struct task_struct *get_current(void)
13{ 17{
14 return (struct task_struct *)read_sysreg(sp_el0); 18 unsigned long sp_el0;
19
20 asm ("mrs %0, sp_el0" : "=r" (sp_el0));
21
22 return (struct task_struct *)sp_el0;
15} 23}
16 24
17#define current get_current() 25#define current get_current()
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index bfe632808d77..90c39a662379 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -222,7 +222,7 @@ static inline void *phys_to_virt(phys_addr_t x)
222#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 222#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
223#else 223#else
224#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page)) 224#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page))
225#define __page_to_voff(page) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page)) 225#define __page_to_voff(kaddr) (((u64)(kaddr) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
226 226
227#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET)) 227#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET))
228#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START)) 228#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index fea10736b11f..439f6b5d31f6 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -47,6 +47,7 @@
47#include <asm/ptrace.h> 47#include <asm/ptrace.h>
48#include <asm/sections.h> 48#include <asm/sections.h>
49#include <asm/sysreg.h> 49#include <asm/sysreg.h>
50#include <asm/cpufeature.h>
50 51
51/* 52/*
52 * __boot_cpu_mode records what mode CPUs were booted in. 53 * __boot_cpu_mode records what mode CPUs were booted in.
@@ -80,6 +81,14 @@ static inline bool is_kernel_in_hyp_mode(void)
80 return read_sysreg(CurrentEL) == CurrentEL_EL2; 81 return read_sysreg(CurrentEL) == CurrentEL_EL2;
81} 82}
82 83
84static inline bool has_vhe(void)
85{
86 if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN))
87 return true;
88
89 return false;
90}
91
83#ifdef CONFIG_ARM64_VHE 92#ifdef CONFIG_ARM64_VHE
84extern void verify_cpu_run_el(void); 93extern void verify_cpu_run_el(void);
85#else 94#else
diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h
index b5c3933ed441..d1ff83dfe5de 100644
--- a/arch/arm64/include/uapi/asm/ptrace.h
+++ b/arch/arm64/include/uapi/asm/ptrace.h
@@ -77,6 +77,7 @@ struct user_fpsimd_state {
77 __uint128_t vregs[32]; 77 __uint128_t vregs[32];
78 __u32 fpsr; 78 __u32 fpsr;
79 __u32 fpcr; 79 __u32 fpcr;
80 __u32 __reserved[2];
80}; 81};
81 82
82struct user_hwdebug_state { 83struct user_hwdebug_state {
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 923841ffe4a9..43512d4d7df2 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -683,7 +683,7 @@ el0_inv:
683 mov x0, sp 683 mov x0, sp
684 mov x1, #BAD_SYNC 684 mov x1, #BAD_SYNC
685 mov x2, x25 685 mov x2, x25
686 bl bad_mode 686 bl bad_el0_sync
687 b ret_to_user 687 b ret_to_user
688ENDPROC(el0_sync) 688ENDPROC(el0_sync)
689 689
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index fc35e06ccaac..a22161ccf447 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -551,6 +551,8 @@ static int hw_break_set(struct task_struct *target,
551 /* (address, ctrl) registers */ 551 /* (address, ctrl) registers */
552 limit = regset->n * regset->size; 552 limit = regset->n * regset->size;
553 while (count && offset < limit) { 553 while (count && offset < limit) {
554 if (count < PTRACE_HBP_ADDR_SZ)
555 return -EINVAL;
554 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr, 556 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
555 offset, offset + PTRACE_HBP_ADDR_SZ); 557 offset, offset + PTRACE_HBP_ADDR_SZ);
556 if (ret) 558 if (ret)
@@ -560,6 +562,8 @@ static int hw_break_set(struct task_struct *target,
560 return ret; 562 return ret;
561 offset += PTRACE_HBP_ADDR_SZ; 563 offset += PTRACE_HBP_ADDR_SZ;
562 564
565 if (!count)
566 break;
563 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, 567 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl,
564 offset, offset + PTRACE_HBP_CTRL_SZ); 568 offset, offset + PTRACE_HBP_CTRL_SZ);
565 if (ret) 569 if (ret)
@@ -596,7 +600,7 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
596 const void *kbuf, const void __user *ubuf) 600 const void *kbuf, const void __user *ubuf)
597{ 601{
598 int ret; 602 int ret;
599 struct user_pt_regs newregs; 603 struct user_pt_regs newregs = task_pt_regs(target)->user_regs;
600 604
601 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs, 0, -1); 605 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs, 0, -1);
602 if (ret) 606 if (ret)
@@ -626,7 +630,8 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
626 const void *kbuf, const void __user *ubuf) 630 const void *kbuf, const void __user *ubuf)
627{ 631{
628 int ret; 632 int ret;
629 struct user_fpsimd_state newstate; 633 struct user_fpsimd_state newstate =
634 target->thread.fpsimd_state.user_fpsimd;
630 635
631 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1); 636 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1);
632 if (ret) 637 if (ret)
@@ -650,7 +655,7 @@ static int tls_set(struct task_struct *target, const struct user_regset *regset,
650 const void *kbuf, const void __user *ubuf) 655 const void *kbuf, const void __user *ubuf)
651{ 656{
652 int ret; 657 int ret;
653 unsigned long tls; 658 unsigned long tls = target->thread.tp_value;
654 659
655 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1); 660 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
656 if (ret) 661 if (ret)
@@ -676,7 +681,8 @@ static int system_call_set(struct task_struct *target,
676 unsigned int pos, unsigned int count, 681 unsigned int pos, unsigned int count,
677 const void *kbuf, const void __user *ubuf) 682 const void *kbuf, const void __user *ubuf)
678{ 683{
679 int syscallno, ret; 684 int syscallno = task_pt_regs(target)->syscallno;
685 int ret;
680 686
681 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &syscallno, 0, -1); 687 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &syscallno, 0, -1);
682 if (ret) 688 if (ret)
@@ -948,7 +954,7 @@ static int compat_tls_set(struct task_struct *target,
948 const void __user *ubuf) 954 const void __user *ubuf)
949{ 955{
950 int ret; 956 int ret;
951 compat_ulong_t tls; 957 compat_ulong_t tls = target->thread.tp_value;
952 958
953 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1); 959 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
954 if (ret) 960 if (ret)
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 5b830be79c01..659b2e6b6cf7 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -604,17 +604,34 @@ const char *esr_get_class_string(u32 esr)
604} 604}
605 605
606/* 606/*
607 * bad_mode handles the impossible case in the exception vector. 607 * bad_mode handles the impossible case in the exception vector. This is always
608 * fatal.
608 */ 609 */
609asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr) 610asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
610{ 611{
611 siginfo_t info;
612 void __user *pc = (void __user *)instruction_pointer(regs);
613 console_verbose(); 612 console_verbose();
614 613
615 pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n", 614 pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
616 handler[reason], smp_processor_id(), esr, 615 handler[reason], smp_processor_id(), esr,
617 esr_get_class_string(esr)); 616 esr_get_class_string(esr));
617
618 die("Oops - bad mode", regs, 0);
619 local_irq_disable();
620 panic("bad mode");
621}
622
623/*
624 * bad_el0_sync handles unexpected, but potentially recoverable synchronous
625 * exceptions taken from EL0. Unlike bad_mode, this returns.
626 */
627asmlinkage void bad_el0_sync(struct pt_regs *regs, int reason, unsigned int esr)
628{
629 siginfo_t info;
630 void __user *pc = (void __user *)instruction_pointer(regs);
631 console_verbose();
632
633 pr_crit("Bad EL0 synchronous exception detected on CPU%d, code 0x%08x -- %s\n",
634 smp_processor_id(), esr, esr_get_class_string(esr));
618 __show_regs(regs); 635 __show_regs(regs);
619 636
620 info.si_signo = SIGILL; 637 info.si_signo = SIGILL;
@@ -622,7 +639,10 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
622 info.si_code = ILL_ILLOPC; 639 info.si_code = ILL_ILLOPC;
623 info.si_addr = pc; 640 info.si_addr = pc;
624 641
625 arm64_notify_die("Oops - bad mode", regs, &info, 0); 642 current->thread.fault_address = 0;
643 current->thread.fault_code = 0;
644
645 force_sig_info(info.si_signo, &info, current);
626} 646}
627 647
628void __pte_error(const char *file, int line, unsigned long val) 648void __pte_error(const char *file, int line, unsigned long val)
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 290a84f3351f..e04082700bb1 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -524,7 +524,8 @@ EXPORT_SYMBOL(dummy_dma_ops);
524 524
525static int __init arm64_dma_init(void) 525static int __init arm64_dma_init(void)
526{ 526{
527 if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) 527 if (swiotlb_force == SWIOTLB_FORCE ||
528 max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
528 swiotlb = 1; 529 swiotlb = 1;
529 530
530 return atomic_pool_init(); 531 return atomic_pool_init();
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index a78a5c401806..156169c6981b 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -88,21 +88,21 @@ void show_pte(struct mm_struct *mm, unsigned long addr)
88 break; 88 break;
89 89
90 pud = pud_offset(pgd, addr); 90 pud = pud_offset(pgd, addr);
91 printk(", *pud=%016llx", pud_val(*pud)); 91 pr_cont(", *pud=%016llx", pud_val(*pud));
92 if (pud_none(*pud) || pud_bad(*pud)) 92 if (pud_none(*pud) || pud_bad(*pud))
93 break; 93 break;
94 94
95 pmd = pmd_offset(pud, addr); 95 pmd = pmd_offset(pud, addr);
96 printk(", *pmd=%016llx", pmd_val(*pmd)); 96 pr_cont(", *pmd=%016llx", pmd_val(*pmd));
97 if (pmd_none(*pmd) || pmd_bad(*pmd)) 97 if (pmd_none(*pmd) || pmd_bad(*pmd))
98 break; 98 break;
99 99
100 pte = pte_offset_map(pmd, addr); 100 pte = pte_offset_map(pmd, addr);
101 printk(", *pte=%016llx", pte_val(*pte)); 101 pr_cont(", *pte=%016llx", pte_val(*pte));
102 pte_unmap(pte); 102 pte_unmap(pte);
103 } while(0); 103 } while(0);
104 104
105 printk("\n"); 105 pr_cont("\n");
106} 106}
107 107
108#ifdef CONFIG_ARM64_HW_AFDBM 108#ifdef CONFIG_ARM64_HW_AFDBM
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 964b7549af5c..e25584d72396 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -239,7 +239,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
239 ncontig = find_num_contig(vma->vm_mm, addr, cpte, 239 ncontig = find_num_contig(vma->vm_mm, addr, cpte,
240 *cpte, &pgsize); 240 *cpte, &pgsize);
241 for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize) { 241 for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize) {
242 changed = ptep_set_access_flags(vma, addr, cpte, 242 changed |= ptep_set_access_flags(vma, addr, cpte,
243 pfn_pte(pfn, 243 pfn_pte(pfn,
244 hugeprot), 244 hugeprot),
245 dirty); 245 dirty);
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 212c4d1e2f26..380ebe705093 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -401,8 +401,11 @@ static void __init free_unused_memmap(void)
401 */ 401 */
402void __init mem_init(void) 402void __init mem_init(void)
403{ 403{
404 if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) 404 if (swiotlb_force == SWIOTLB_FORCE ||
405 max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
405 swiotlb_init(1); 406 swiotlb_init(1);
407 else
408 swiotlb_force = SWIOTLB_NO_FORCE;
406 409
407 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 410 set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
408 411
diff --git a/arch/mips/kvm/entry.c b/arch/mips/kvm/entry.c
index 6a02b3a3fa65..e92fb190e2d6 100644
--- a/arch/mips/kvm/entry.c
+++ b/arch/mips/kvm/entry.c
@@ -521,6 +521,9 @@ void *kvm_mips_build_exit(void *addr)
521 uasm_i_and(&p, V0, V0, AT); 521 uasm_i_and(&p, V0, V0, AT);
522 uasm_i_lui(&p, AT, ST0_CU0 >> 16); 522 uasm_i_lui(&p, AT, ST0_CU0 >> 16);
523 uasm_i_or(&p, V0, V0, AT); 523 uasm_i_or(&p, V0, V0, AT);
524#ifdef CONFIG_64BIT
525 uasm_i_ori(&p, V0, V0, ST0_SX | ST0_UX);
526#endif
524 uasm_i_mtc0(&p, V0, C0_STATUS); 527 uasm_i_mtc0(&p, V0, C0_STATUS);
525 uasm_i_ehb(&p); 528 uasm_i_ehb(&p);
526 529
@@ -643,7 +646,7 @@ static void *kvm_mips_build_ret_to_guest(void *addr)
643 646
644 /* Setup status register for running guest in UM */ 647 /* Setup status register for running guest in UM */
645 uasm_i_ori(&p, V1, V1, ST0_EXL | KSU_USER | ST0_IE); 648 uasm_i_ori(&p, V1, V1, ST0_EXL | KSU_USER | ST0_IE);
646 UASM_i_LA(&p, AT, ~(ST0_CU0 | ST0_MX)); 649 UASM_i_LA(&p, AT, ~(ST0_CU0 | ST0_MX | ST0_SX | ST0_UX));
647 uasm_i_and(&p, V1, V1, AT); 650 uasm_i_and(&p, V1, V1, AT);
648 uasm_i_mtc0(&p, V1, C0_STATUS); 651 uasm_i_mtc0(&p, V1, C0_STATUS);
649 uasm_i_ehb(&p); 652 uasm_i_ehb(&p);
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 06a60b19acfb..29ec9ab3fd55 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -360,8 +360,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
360 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); 360 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run);
361 361
362 /* Invalidate the icache for these ranges */ 362 /* Invalidate the icache for these ranges */
363 local_flush_icache_range((unsigned long)gebase, 363 flush_icache_range((unsigned long)gebase,
364 (unsigned long)gebase + ALIGN(size, PAGE_SIZE)); 364 (unsigned long)gebase + ALIGN(size, PAGE_SIZE));
365 365
366 /* 366 /*
367 * Allocate comm page for guest kernel, a TLB will be reserved for 367 * Allocate comm page for guest kernel, a TLB will be reserved for
diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
index ef31fc24344e..552544616b9d 100644
--- a/arch/openrisc/kernel/vmlinux.lds.S
+++ b/arch/openrisc/kernel/vmlinux.lds.S
@@ -44,6 +44,8 @@ SECTIONS
44 /* Read-only sections, merged into text segment: */ 44 /* Read-only sections, merged into text segment: */
45 . = LOAD_BASE ; 45 . = LOAD_BASE ;
46 46
47 _text = .;
48
47 /* _s_kernel_ro must be page aligned */ 49 /* _s_kernel_ro must be page aligned */
48 . = ALIGN(PAGE_SIZE); 50 . = ALIGN(PAGE_SIZE);
49 _s_kernel_ro = .; 51 _s_kernel_ro = .;
diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
index 7581330ea35b..88fe0aad4390 100644
--- a/arch/parisc/include/asm/thread_info.h
+++ b/arch/parisc/include/asm/thread_info.h
@@ -49,7 +49,6 @@ struct thread_info {
49#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 49#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling TIF_NEED_RESCHED */
50#define TIF_32BIT 4 /* 32 bit binary */ 50#define TIF_32BIT 4 /* 32 bit binary */
51#define TIF_MEMDIE 5 /* is terminating due to OOM killer */ 51#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
52#define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */
53#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 52#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
54#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */ 53#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
55#define TIF_SINGLESTEP 9 /* single stepping? */ 54#define TIF_SINGLESTEP 9 /* single stepping? */
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index da0d9cb63403..1e22f981cd81 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -235,9 +235,26 @@ void __init time_init(void)
235 235
236 cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */ 236 cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */
237 237
238 /* register at clocksource framework */
239 clocksource_register_hz(&clocksource_cr16, cr16_hz);
240
241 /* register as sched_clock source */ 238 /* register as sched_clock source */
242 sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz); 239 sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz);
243} 240}
241
242static int __init init_cr16_clocksource(void)
243{
244 /*
245 * The cr16 interval timers are not syncronized across CPUs, so mark
246 * them unstable and lower rating on SMP systems.
247 */
248 if (num_online_cpus() > 1) {
249 clocksource_cr16.flags = CLOCK_SOURCE_UNSTABLE;
250 clocksource_cr16.rating = 0;
251 }
252
253 /* register at clocksource framework */
254 clocksource_register_hz(&clocksource_cr16,
255 100 * PAGE0->mem_10msec);
256
257 return 0;
258}
259
260device_initcall(init_cr16_clocksource);
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 8ff9253930af..1a0b4f63f0e9 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -234,7 +234,7 @@ show_signal_msg(struct pt_regs *regs, unsigned long code,
234 tsk->comm, code, address); 234 tsk->comm, code, address);
235 print_vma_addr(KERN_CONT " in ", regs->iaoq[0]); 235 print_vma_addr(KERN_CONT " in ", regs->iaoq[0]);
236 236
237 pr_cont(" trap #%lu: %s%c", code, trap_name(code), 237 pr_cont("\ntrap #%lu: %s%c", code, trap_name(code),
238 vma ? ',':'\n'); 238 vma ? ',':'\n');
239 239
240 if (vma) 240 if (vma)
diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
index 1c64bc6330bc..0c4e470571ca 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
@@ -36,12 +36,13 @@
36#ifdef CONFIG_HUGETLB_PAGE 36#ifdef CONFIG_HUGETLB_PAGE
37static inline int hash__hugepd_ok(hugepd_t hpd) 37static inline int hash__hugepd_ok(hugepd_t hpd)
38{ 38{
39 unsigned long hpdval = hpd_val(hpd);
39 /* 40 /*
40 * if it is not a pte and have hugepd shift mask 41 * if it is not a pte and have hugepd shift mask
41 * set, then it is a hugepd directory pointer 42 * set, then it is a hugepd directory pointer
42 */ 43 */
43 if (!(hpd.pd & _PAGE_PTE) && 44 if (!(hpdval & _PAGE_PTE) &&
44 ((hpd.pd & HUGEPD_SHIFT_MASK) != 0)) 45 ((hpdval & HUGEPD_SHIFT_MASK) != 0))
45 return true; 46 return true;
46 return false; 47 return false;
47} 48}
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
index f61cad3de4e6..4c935f7504f7 100644
--- a/arch/powerpc/include/asm/book3s/64/hash.h
+++ b/arch/powerpc/include/asm/book3s/64/hash.h
@@ -201,6 +201,10 @@ extern int __meminit hash__vmemmap_create_mapping(unsigned long start,
201 unsigned long phys); 201 unsigned long phys);
202extern void hash__vmemmap_remove_mapping(unsigned long start, 202extern void hash__vmemmap_remove_mapping(unsigned long start,
203 unsigned long page_size); 203 unsigned long page_size);
204
205int hash__create_section_mapping(unsigned long start, unsigned long end);
206int hash__remove_section_mapping(unsigned long start, unsigned long end);
207
204#endif /* !__ASSEMBLY__ */ 208#endif /* !__ASSEMBLY__ */
205#endif /* __KERNEL__ */ 209#endif /* __KERNEL__ */
206#endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */ 210#endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index ede215167d1a..7f4025a6c69e 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -21,12 +21,12 @@ static inline pte_t *hugepd_page(hugepd_t hpd)
21 * We have only four bits to encode, MMU page size 21 * We have only four bits to encode, MMU page size
22 */ 22 */
23 BUILD_BUG_ON((MMU_PAGE_COUNT - 1) > 0xf); 23 BUILD_BUG_ON((MMU_PAGE_COUNT - 1) > 0xf);
24 return __va(hpd.pd & HUGEPD_ADDR_MASK); 24 return __va(hpd_val(hpd) & HUGEPD_ADDR_MASK);
25} 25}
26 26
27static inline unsigned int hugepd_mmu_psize(hugepd_t hpd) 27static inline unsigned int hugepd_mmu_psize(hugepd_t hpd)
28{ 28{
29 return (hpd.pd & HUGEPD_SHIFT_MASK) >> 2; 29 return (hpd_val(hpd) & HUGEPD_SHIFT_MASK) >> 2;
30} 30}
31 31
32static inline unsigned int hugepd_shift(hugepd_t hpd) 32static inline unsigned int hugepd_shift(hugepd_t hpd)
@@ -52,18 +52,20 @@ static inline pte_t *hugepd_page(hugepd_t hpd)
52{ 52{
53 BUG_ON(!hugepd_ok(hpd)); 53 BUG_ON(!hugepd_ok(hpd));
54#ifdef CONFIG_PPC_8xx 54#ifdef CONFIG_PPC_8xx
55 return (pte_t *)__va(hpd.pd & ~(_PMD_PAGE_MASK | _PMD_PRESENT_MASK)); 55 return (pte_t *)__va(hpd_val(hpd) &
56 ~(_PMD_PAGE_MASK | _PMD_PRESENT_MASK));
56#else 57#else
57 return (pte_t *)((hpd.pd & ~HUGEPD_SHIFT_MASK) | PD_HUGE); 58 return (pte_t *)((hpd_val(hpd) &
59 ~HUGEPD_SHIFT_MASK) | PD_HUGE);
58#endif 60#endif
59} 61}
60 62
61static inline unsigned int hugepd_shift(hugepd_t hpd) 63static inline unsigned int hugepd_shift(hugepd_t hpd)
62{ 64{
63#ifdef CONFIG_PPC_8xx 65#ifdef CONFIG_PPC_8xx
64 return ((hpd.pd & _PMD_PAGE_MASK) >> 1) + 17; 66 return ((hpd_val(hpd) & _PMD_PAGE_MASK) >> 1) + 17;
65#else 67#else
66 return hpd.pd & HUGEPD_SHIFT_MASK; 68 return hpd_val(hpd) & HUGEPD_SHIFT_MASK;
67#endif 69#endif
68} 70}
69 71
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 172849727054..0cd8a3852763 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -227,9 +227,10 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
227static inline int hugepd_ok(hugepd_t hpd) 227static inline int hugepd_ok(hugepd_t hpd)
228{ 228{
229#ifdef CONFIG_PPC_8xx 229#ifdef CONFIG_PPC_8xx
230 return ((hpd.pd & 0x4) != 0); 230 return ((hpd_val(hpd) & 0x4) != 0);
231#else 231#else
232 return (hpd.pd > 0); 232 /* We clear the top bit to indicate hugepd */
233 return ((hpd_val(hpd) & PD_HUGE) == 0);
233#endif 234#endif
234} 235}
235 236
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 56398e7e6100..47120bf2670c 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -294,15 +294,12 @@ extern long long virt_phys_offset;
294#include <asm/pgtable-types.h> 294#include <asm/pgtable-types.h>
295#endif 295#endif
296 296
297typedef struct { signed long pd; } hugepd_t;
298 297
299#ifndef CONFIG_HUGETLB_PAGE 298#ifndef CONFIG_HUGETLB_PAGE
300#define is_hugepd(pdep) (0) 299#define is_hugepd(pdep) (0)
301#define pgd_huge(pgd) (0) 300#define pgd_huge(pgd) (0)
302#endif /* CONFIG_HUGETLB_PAGE */ 301#endif /* CONFIG_HUGETLB_PAGE */
303 302
304#define __hugepd(x) ((hugepd_t) { (x) })
305
306struct page; 303struct page;
307extern void clear_user_page(void *page, unsigned long vaddr, struct page *pg); 304extern void clear_user_page(void *page, unsigned long vaddr, struct page *pg);
308extern void copy_user_page(void *to, void *from, unsigned long vaddr, 305extern void copy_user_page(void *to, void *from, unsigned long vaddr,
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index e157489ee7a1..ae0a23091a9b 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -65,6 +65,7 @@ struct power_pmu {
65#define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */ 65#define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */
66#define PPMU_HAS_SIER 0x00000040 /* Has SIER */ 66#define PPMU_HAS_SIER 0x00000040 /* Has SIER */
67#define PPMU_ARCH_207S 0x00000080 /* PMC is architecture v2.07S */ 67#define PPMU_ARCH_207S 0x00000080 /* PMC is architecture v2.07S */
68#define PPMU_NO_SIAR 0x00000100 /* Do not use SIAR */
68 69
69/* 70/*
70 * Values for flags to get_alternatives() 71 * Values for flags to get_alternatives()
diff --git a/arch/powerpc/include/asm/pgtable-be-types.h b/arch/powerpc/include/asm/pgtable-be-types.h
index 49c0a5a80efa..9c0f5db5cf46 100644
--- a/arch/powerpc/include/asm/pgtable-be-types.h
+++ b/arch/powerpc/include/asm/pgtable-be-types.h
@@ -104,4 +104,12 @@ static inline bool pmd_xchg(pmd_t *pmdp, pmd_t old, pmd_t new)
104 return pmd_raw(old) == prev; 104 return pmd_raw(old) == prev;
105} 105}
106 106
107typedef struct { __be64 pdbe; } hugepd_t;
108#define __hugepd(x) ((hugepd_t) { cpu_to_be64(x) })
109
110static inline unsigned long hpd_val(hugepd_t x)
111{
112 return be64_to_cpu(x.pdbe);
113}
114
107#endif /* _ASM_POWERPC_PGTABLE_BE_TYPES_H */ 115#endif /* _ASM_POWERPC_PGTABLE_BE_TYPES_H */
diff --git a/arch/powerpc/include/asm/pgtable-types.h b/arch/powerpc/include/asm/pgtable-types.h
index e7f4f3e0fcde..8bd3b13fe2fb 100644
--- a/arch/powerpc/include/asm/pgtable-types.h
+++ b/arch/powerpc/include/asm/pgtable-types.h
@@ -66,4 +66,11 @@ static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
66} 66}
67#endif 67#endif
68 68
69typedef struct { unsigned long pd; } hugepd_t;
70#define __hugepd(x) ((hugepd_t) { (x) })
71static inline unsigned long hpd_val(hugepd_t x)
72{
73 return x.pd;
74}
75
69#endif /* _ASM_POWERPC_PGTABLE_TYPES_H */ 76#endif /* _ASM_POWERPC_PGTABLE_TYPES_H */
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index c56ea8c84abb..c4ced1d01d57 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -157,7 +157,7 @@
157#define PPC_INST_MCRXR 0x7c000400 157#define PPC_INST_MCRXR 0x7c000400
158#define PPC_INST_MCRXR_MASK 0xfc0007fe 158#define PPC_INST_MCRXR_MASK 0xfc0007fe
159#define PPC_INST_MFSPR_PVR 0x7c1f42a6 159#define PPC_INST_MFSPR_PVR 0x7c1f42a6
160#define PPC_INST_MFSPR_PVR_MASK 0xfc1fffff 160#define PPC_INST_MFSPR_PVR_MASK 0xfc1ffffe
161#define PPC_INST_MFTMR 0x7c0002dc 161#define PPC_INST_MFTMR 0x7c0002dc
162#define PPC_INST_MSGSND 0x7c00019c 162#define PPC_INST_MSGSND 0x7c00019c
163#define PPC_INST_MSGCLR 0x7c0001dc 163#define PPC_INST_MSGCLR 0x7c0001dc
@@ -174,13 +174,13 @@
174#define PPC_INST_RFDI 0x4c00004e 174#define PPC_INST_RFDI 0x4c00004e
175#define PPC_INST_RFMCI 0x4c00004c 175#define PPC_INST_RFMCI 0x4c00004c
176#define PPC_INST_MFSPR_DSCR 0x7c1102a6 176#define PPC_INST_MFSPR_DSCR 0x7c1102a6
177#define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff 177#define PPC_INST_MFSPR_DSCR_MASK 0xfc1ffffe
178#define PPC_INST_MTSPR_DSCR 0x7c1103a6 178#define PPC_INST_MTSPR_DSCR 0x7c1103a6
179#define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff 179#define PPC_INST_MTSPR_DSCR_MASK 0xfc1ffffe
180#define PPC_INST_MFSPR_DSCR_USER 0x7c0302a6 180#define PPC_INST_MFSPR_DSCR_USER 0x7c0302a6
181#define PPC_INST_MFSPR_DSCR_USER_MASK 0xfc1fffff 181#define PPC_INST_MFSPR_DSCR_USER_MASK 0xfc1ffffe
182#define PPC_INST_MTSPR_DSCR_USER 0x7c0303a6 182#define PPC_INST_MTSPR_DSCR_USER 0x7c0303a6
183#define PPC_INST_MTSPR_DSCR_USER_MASK 0xfc1fffff 183#define PPC_INST_MTSPR_DSCR_USER_MASK 0xfc1ffffe
184#define PPC_INST_MFVSRD 0x7c000066 184#define PPC_INST_MFVSRD 0x7c000066
185#define PPC_INST_MTVSRD 0x7c000166 185#define PPC_INST_MTVSRD 0x7c000166
186#define PPC_INST_SLBFEE 0x7c0007a7 186#define PPC_INST_SLBFEE 0x7c0007a7
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 8180bfd7ab93..9de7f79e702b 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -298,9 +298,17 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
298 * 298 *
299 * For pHyp, we have to enable IO for log retrieval. Otherwise, 299 * For pHyp, we have to enable IO for log retrieval. Otherwise,
300 * 0xFF's is always returned from PCI config space. 300 * 0xFF's is always returned from PCI config space.
301 *
302 * When the @severity is EEH_LOG_PERM, the PE is going to be
303 * removed. Prior to that, the drivers for devices included in
304 * the PE will be closed. The drivers rely on working IO path
305 * to bring the devices to quiet state. Otherwise, PCI traffic
306 * from those devices after they are removed is like to cause
307 * another unexpected EEH error.
301 */ 308 */
302 if (!(pe->type & EEH_PE_PHB)) { 309 if (!(pe->type & EEH_PE_PHB)) {
303 if (eeh_has_flag(EEH_ENABLE_IO_FOR_LOG)) 310 if (eeh_has_flag(EEH_ENABLE_IO_FOR_LOG) ||
311 severity == EEH_LOG_PERM)
304 eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); 312 eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
305 313
306 /* 314 /*
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index e4744ff38a17..925a4ef90559 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -463,6 +463,10 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
463 463
464 flush_fp_to_thread(target); 464 flush_fp_to_thread(target);
465 465
466 for (i = 0; i < 32 ; i++)
467 buf[i] = target->thread.TS_FPR(i);
468 buf[32] = target->thread.fp_state.fpscr;
469
466 /* copy to local buffer then write that out */ 470 /* copy to local buffer then write that out */
467 i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1); 471 i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
468 if (i) 472 if (i)
@@ -672,6 +676,9 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,
672 flush_altivec_to_thread(target); 676 flush_altivec_to_thread(target);
673 flush_vsx_to_thread(target); 677 flush_vsx_to_thread(target);
674 678
679 for (i = 0; i < 32 ; i++)
680 buf[i] = target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
681
675 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 682 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
676 buf, 0, 32 * sizeof(double)); 683 buf, 0, 32 * sizeof(double));
677 if (!ret) 684 if (!ret)
@@ -1019,6 +1026,10 @@ static int tm_cfpr_set(struct task_struct *target,
1019 flush_fp_to_thread(target); 1026 flush_fp_to_thread(target);
1020 flush_altivec_to_thread(target); 1027 flush_altivec_to_thread(target);
1021 1028
1029 for (i = 0; i < 32; i++)
1030 buf[i] = target->thread.TS_CKFPR(i);
1031 buf[32] = target->thread.ckfp_state.fpscr;
1032
1022 /* copy to local buffer then write that out */ 1033 /* copy to local buffer then write that out */
1023 i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1); 1034 i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
1024 if (i) 1035 if (i)
@@ -1283,6 +1294,9 @@ static int tm_cvsx_set(struct task_struct *target,
1283 flush_altivec_to_thread(target); 1294 flush_altivec_to_thread(target);
1284 flush_vsx_to_thread(target); 1295 flush_vsx_to_thread(target);
1285 1296
1297 for (i = 0; i < 32 ; i++)
1298 buf[i] = target->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET];
1299
1286 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 1300 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
1287 buf, 0, 32 * sizeof(double)); 1301 buf, 0, 32 * sizeof(double));
1288 if (!ret) 1302 if (!ret)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 80334937e14f..67e19a0821be 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -747,7 +747,7 @@ static unsigned long __init htab_get_table_size(void)
747} 747}
748 748
749#ifdef CONFIG_MEMORY_HOTPLUG 749#ifdef CONFIG_MEMORY_HOTPLUG
750int create_section_mapping(unsigned long start, unsigned long end) 750int hash__create_section_mapping(unsigned long start, unsigned long end)
751{ 751{
752 int rc = htab_bolt_mapping(start, end, __pa(start), 752 int rc = htab_bolt_mapping(start, end, __pa(start),
753 pgprot_val(PAGE_KERNEL), mmu_linear_psize, 753 pgprot_val(PAGE_KERNEL), mmu_linear_psize,
@@ -761,7 +761,7 @@ int create_section_mapping(unsigned long start, unsigned long end)
761 return rc; 761 return rc;
762} 762}
763 763
764int remove_section_mapping(unsigned long start, unsigned long end) 764int hash__remove_section_mapping(unsigned long start, unsigned long end)
765{ 765{
766 int rc = htab_remove_mapping(start, end, mmu_linear_psize, 766 int rc = htab_remove_mapping(start, end, mmu_linear_psize,
767 mmu_kernel_ssize); 767 mmu_kernel_ssize);
diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c
index d5026f3800b6..37b5f91e381b 100644
--- a/arch/powerpc/mm/hugetlbpage-hash64.c
+++ b/arch/powerpc/mm/hugetlbpage-hash64.c
@@ -125,11 +125,14 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,
125int hugepd_ok(hugepd_t hpd) 125int hugepd_ok(hugepd_t hpd)
126{ 126{
127 bool is_hugepd; 127 bool is_hugepd;
128 unsigned long hpdval;
129
130 hpdval = hpd_val(hpd);
128 131
129 /* 132 /*
130 * We should not find this format in page directory, warn otherwise. 133 * We should not find this format in page directory, warn otherwise.
131 */ 134 */
132 is_hugepd = (((hpd.pd & 0x3) == 0x0) && ((hpd.pd & HUGEPD_SHIFT_MASK) != 0)); 135 is_hugepd = (((hpdval & 0x3) == 0x0) && ((hpdval & HUGEPD_SHIFT_MASK) != 0));
133 WARN(is_hugepd, "Found wrong page directory format\n"); 136 WARN(is_hugepd, "Found wrong page directory format\n");
134 return 0; 137 return 0;
135} 138}
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 289df38fb7e0..8c3389cbcd12 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -53,7 +53,7 @@ static u64 gpage_freearray[MAX_NUMBER_GPAGES];
53static unsigned nr_gpages; 53static unsigned nr_gpages;
54#endif 54#endif
55 55
56#define hugepd_none(hpd) ((hpd).pd == 0) 56#define hugepd_none(hpd) (hpd_val(hpd) == 0)
57 57
58pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 58pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
59{ 59{
@@ -103,24 +103,24 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
103 for (i = 0; i < num_hugepd; i++, hpdp++) { 103 for (i = 0; i < num_hugepd; i++, hpdp++) {
104 if (unlikely(!hugepd_none(*hpdp))) 104 if (unlikely(!hugepd_none(*hpdp)))
105 break; 105 break;
106 else 106 else {
107#ifdef CONFIG_PPC_BOOK3S_64 107#ifdef CONFIG_PPC_BOOK3S_64
108 hpdp->pd = __pa(new) | 108 *hpdp = __hugepd(__pa(new) |
109 (shift_to_mmu_psize(pshift) << 2); 109 (shift_to_mmu_psize(pshift) << 2));
110#elif defined(CONFIG_PPC_8xx) 110#elif defined(CONFIG_PPC_8xx)
111 hpdp->pd = __pa(new) | 111 *hpdp = __hugepd(__pa(new) |
112 (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : 112 (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M :
113 _PMD_PAGE_512K) | 113 _PMD_PAGE_512K) | _PMD_PRESENT);
114 _PMD_PRESENT;
115#else 114#else
116 /* We use the old format for PPC_FSL_BOOK3E */ 115 /* We use the old format for PPC_FSL_BOOK3E */
117 hpdp->pd = ((unsigned long)new & ~PD_HUGE) | pshift; 116 *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift);
118#endif 117#endif
118 }
119 } 119 }
120 /* If we bailed from the for loop early, an error occurred, clean up */ 120 /* If we bailed from the for loop early, an error occurred, clean up */
121 if (i < num_hugepd) { 121 if (i < num_hugepd) {
122 for (i = i - 1 ; i >= 0; i--, hpdp--) 122 for (i = i - 1 ; i >= 0; i--, hpdp--)
123 hpdp->pd = 0; 123 *hpdp = __hugepd(0);
124 kmem_cache_free(cachep, new); 124 kmem_cache_free(cachep, new);
125 } 125 }
126 spin_unlock(&mm->page_table_lock); 126 spin_unlock(&mm->page_table_lock);
@@ -454,7 +454,7 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif
454 return; 454 return;
455 455
456 for (i = 0; i < num_hugepd; i++, hpdp++) 456 for (i = 0; i < num_hugepd; i++, hpdp++)
457 hpdp->pd = 0; 457 *hpdp = __hugepd(0);
458 458
459 if (shift >= pdshift) 459 if (shift >= pdshift)
460 hugepd_free(tlb, hugepte); 460 hugepd_free(tlb, hugepte);
@@ -810,12 +810,8 @@ static int __init hugetlbpage_init(void)
810 * if we have pdshift and shift value same, we don't 810 * if we have pdshift and shift value same, we don't
811 * use pgt cache for hugepd. 811 * use pgt cache for hugepd.
812 */ 812 */
813 if (pdshift > shift) { 813 if (pdshift > shift)
814 pgtable_cache_add(pdshift - shift, NULL); 814 pgtable_cache_add(pdshift - shift, NULL);
815 if (!PGT_CACHE(pdshift - shift))
816 panic("hugetlbpage_init(): could not create "
817 "pgtable cache for %d bit pagesize\n", shift);
818 }
819#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx) 815#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx)
820 else if (!hugepte_cache) { 816 else if (!hugepte_cache) {
821 /* 817 /*
@@ -852,9 +848,6 @@ static int __init hugetlbpage_init(void)
852 else if (mmu_psize_defs[MMU_PAGE_2M].shift) 848 else if (mmu_psize_defs[MMU_PAGE_2M].shift)
853 HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_2M].shift; 849 HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_2M].shift;
854#endif 850#endif
855 else
856 panic("%s: Unable to set default huge page size\n", __func__);
857
858 return 0; 851 return 0;
859} 852}
860 853
diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c
index a175cd82ae8c..f2108c40e697 100644
--- a/arch/powerpc/mm/init-common.c
+++ b/arch/powerpc/mm/init-common.c
@@ -78,8 +78,12 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *))
78 align = max_t(unsigned long, align, minalign); 78 align = max_t(unsigned long, align, minalign);
79 name = kasprintf(GFP_KERNEL, "pgtable-2^%d", shift); 79 name = kasprintf(GFP_KERNEL, "pgtable-2^%d", shift);
80 new = kmem_cache_create(name, table_size, align, 0, ctor); 80 new = kmem_cache_create(name, table_size, align, 0, ctor);
81 if (!new)
82 panic("Could not allocate pgtable cache for order %d", shift);
83
81 kfree(name); 84 kfree(name);
82 pgtable_cache[shift - 1] = new; 85 pgtable_cache[shift - 1] = new;
86
83 pr_debug("Allocated pgtable cache for order %d\n", shift); 87 pr_debug("Allocated pgtable cache for order %d\n", shift);
84} 88}
85 89
@@ -88,7 +92,7 @@ void pgtable_cache_init(void)
88{ 92{
89 pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor); 93 pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor);
90 94
91 if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE)) 95 if (PMD_CACHE_INDEX && !PGT_CACHE(PMD_CACHE_INDEX))
92 pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor); 96 pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor);
93 /* 97 /*
94 * In all current configs, when the PUD index exists it's the 98 * In all current configs, when the PUD index exists it's the
@@ -97,11 +101,4 @@ void pgtable_cache_init(void)
97 */ 101 */
98 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) 102 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE))
99 pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor); 103 pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor);
100
101 if (!PGT_CACHE(PGD_INDEX_SIZE))
102 panic("Couldn't allocate pgd cache");
103 if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE))
104 panic("Couldn't allocate pmd pgtable caches");
105 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE))
106 panic("Couldn't allocate pud pgtable caches");
107} 104}
diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c
index ebf9782bacf9..653ff6c74ebe 100644
--- a/arch/powerpc/mm/pgtable-book3s64.c
+++ b/arch/powerpc/mm/pgtable-book3s64.c
@@ -126,3 +126,21 @@ void mmu_cleanup_all(void)
126 else if (mmu_hash_ops.hpte_clear_all) 126 else if (mmu_hash_ops.hpte_clear_all)
127 mmu_hash_ops.hpte_clear_all(); 127 mmu_hash_ops.hpte_clear_all();
128} 128}
129
130#ifdef CONFIG_MEMORY_HOTPLUG
131int create_section_mapping(unsigned long start, unsigned long end)
132{
133 if (radix_enabled())
134 return -ENODEV;
135
136 return hash__create_section_mapping(start, end);
137}
138
139int remove_section_mapping(unsigned long start, unsigned long end)
140{
141 if (radix_enabled())
142 return -ENODEV;
143
144 return hash__remove_section_mapping(start, end);
145}
146#endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index fd3e4034c04d..270eb9b74e2e 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -295,6 +295,8 @@ static inline void perf_read_regs(struct pt_regs *regs)
295 */ 295 */
296 if (TRAP(regs) != 0xf00) 296 if (TRAP(regs) != 0xf00)
297 use_siar = 0; 297 use_siar = 0;
298 else if ((ppmu->flags & PPMU_NO_SIAR))
299 use_siar = 0;
298 else if (marked) 300 else if (marked)
299 use_siar = 1; 301 use_siar = 1;
300 else if ((ppmu->flags & PPMU_NO_CONT_SAMPLING)) 302 else if ((ppmu->flags & PPMU_NO_CONT_SAMPLING))
diff --git a/arch/powerpc/perf/power9-events-list.h b/arch/powerpc/perf/power9-events-list.h
index 6447dc1c3d89..929b56d47ad9 100644
--- a/arch/powerpc/perf/power9-events-list.h
+++ b/arch/powerpc/perf/power9-events-list.h
@@ -16,7 +16,7 @@ EVENT(PM_CYC, 0x0001e)
16EVENT(PM_ICT_NOSLOT_CYC, 0x100f8) 16EVENT(PM_ICT_NOSLOT_CYC, 0x100f8)
17EVENT(PM_CMPLU_STALL, 0x1e054) 17EVENT(PM_CMPLU_STALL, 0x1e054)
18EVENT(PM_INST_CMPL, 0x00002) 18EVENT(PM_INST_CMPL, 0x00002)
19EVENT(PM_BRU_CMPL, 0x40060) 19EVENT(PM_BRU_CMPL, 0x10012)
20EVENT(PM_BR_MPRED_CMPL, 0x400f6) 20EVENT(PM_BR_MPRED_CMPL, 0x400f6)
21 21
22/* All L1 D cache load references counted at finish, gated by reject */ 22/* All L1 D cache load references counted at finish, gated by reject */
diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
index 346010e8d463..7332634e18c9 100644
--- a/arch/powerpc/perf/power9-pmu.c
+++ b/arch/powerpc/perf/power9-pmu.c
@@ -384,7 +384,7 @@ static struct power_pmu power9_isa207_pmu = {
384 .bhrb_filter_map = power9_bhrb_filter_map, 384 .bhrb_filter_map = power9_bhrb_filter_map,
385 .get_constraint = isa207_get_constraint, 385 .get_constraint = isa207_get_constraint,
386 .disable_pmc = isa207_disable_pmc, 386 .disable_pmc = isa207_disable_pmc,
387 .flags = PPMU_HAS_SIER | PPMU_ARCH_207S, 387 .flags = PPMU_NO_SIAR | PPMU_ARCH_207S,
388 .n_generic = ARRAY_SIZE(power9_generic_events), 388 .n_generic = ARRAY_SIZE(power9_generic_events),
389 .generic_events = power9_generic_events, 389 .generic_events = power9_generic_events,
390 .cache_events = &power9_cache_events, 390 .cache_events = &power9_cache_events,
diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
index d38e86fd5720..60c57657c772 100644
--- a/arch/powerpc/sysdev/xics/icp-opal.c
+++ b/arch/powerpc/sysdev/xics/icp-opal.c
@@ -20,6 +20,7 @@
20#include <asm/xics.h> 20#include <asm/xics.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/opal.h> 22#include <asm/opal.h>
23#include <asm/kvm_ppc.h>
23 24
24static void icp_opal_teardown_cpu(void) 25static void icp_opal_teardown_cpu(void)
25{ 26{
@@ -39,7 +40,26 @@ static void icp_opal_flush_ipi(void)
39 * Should we be flagging idle loop instead? 40 * Should we be flagging idle loop instead?
40 * Or creating some task to be scheduled? 41 * Or creating some task to be scheduled?
41 */ 42 */
42 opal_int_eoi((0x00 << 24) | XICS_IPI); 43 if (opal_int_eoi((0x00 << 24) | XICS_IPI) > 0)
44 force_external_irq_replay();
45}
46
47static unsigned int icp_opal_get_xirr(void)
48{
49 unsigned int kvm_xirr;
50 __be32 hw_xirr;
51 int64_t rc;
52
53 /* Handle an interrupt latched by KVM first */
54 kvm_xirr = kvmppc_get_xics_latch();
55 if (kvm_xirr)
56 return kvm_xirr;
57
58 /* Then ask OPAL */
59 rc = opal_int_get_xirr(&hw_xirr, false);
60 if (rc < 0)
61 return 0;
62 return be32_to_cpu(hw_xirr);
43} 63}
44 64
45static unsigned int icp_opal_get_irq(void) 65static unsigned int icp_opal_get_irq(void)
@@ -47,12 +67,8 @@ static unsigned int icp_opal_get_irq(void)
47 unsigned int xirr; 67 unsigned int xirr;
48 unsigned int vec; 68 unsigned int vec;
49 unsigned int irq; 69 unsigned int irq;
50 int64_t rc;
51 70
52 rc = opal_int_get_xirr(&xirr, false); 71 xirr = icp_opal_get_xirr();
53 if (rc < 0)
54 return 0;
55 xirr = be32_to_cpu(xirr);
56 vec = xirr & 0x00ffffff; 72 vec = xirr & 0x00ffffff;
57 if (vec == XICS_IRQ_SPURIOUS) 73 if (vec == XICS_IRQ_SPURIOUS)
58 return 0; 74 return 0;
@@ -67,7 +83,8 @@ static unsigned int icp_opal_get_irq(void)
67 xics_mask_unknown_vec(vec); 83 xics_mask_unknown_vec(vec);
68 84
69 /* We might learn about it later, so EOI it */ 85 /* We might learn about it later, so EOI it */
70 opal_int_eoi(xirr); 86 if (opal_int_eoi(xirr) > 0)
87 force_external_irq_replay();
71 88
72 return 0; 89 return 0;
73} 90}
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig
index e659daffe368..e00975361fec 100644
--- a/arch/s390/configs/default_defconfig
+++ b/arch/s390/configs/default_defconfig
@@ -69,7 +69,7 @@ CONFIG_CMA=y
69CONFIG_CMA_DEBUG=y 69CONFIG_CMA_DEBUG=y
70CONFIG_CMA_DEBUGFS=y 70CONFIG_CMA_DEBUGFS=y
71CONFIG_MEM_SOFT_DIRTY=y 71CONFIG_MEM_SOFT_DIRTY=y
72CONFIG_ZPOOL=m 72CONFIG_ZSWAP=y
73CONFIG_ZBUD=m 73CONFIG_ZBUD=m
74CONFIG_ZSMALLOC=m 74CONFIG_ZSMALLOC=m
75CONFIG_ZSMALLOC_STAT=y 75CONFIG_ZSMALLOC_STAT=y
@@ -141,8 +141,6 @@ CONFIG_NF_CONNTRACK_SECMARK=y
141CONFIG_NF_CONNTRACK_EVENTS=y 141CONFIG_NF_CONNTRACK_EVENTS=y
142CONFIG_NF_CONNTRACK_TIMEOUT=y 142CONFIG_NF_CONNTRACK_TIMEOUT=y
143CONFIG_NF_CONNTRACK_TIMESTAMP=y 143CONFIG_NF_CONNTRACK_TIMESTAMP=y
144CONFIG_NF_CT_PROTO_DCCP=m
145CONFIG_NF_CT_PROTO_UDPLITE=m
146CONFIG_NF_CONNTRACK_AMANDA=m 144CONFIG_NF_CONNTRACK_AMANDA=m
147CONFIG_NF_CONNTRACK_FTP=m 145CONFIG_NF_CONNTRACK_FTP=m
148CONFIG_NF_CONNTRACK_H323=m 146CONFIG_NF_CONNTRACK_H323=m
@@ -159,13 +157,12 @@ CONFIG_NF_TABLES=m
159CONFIG_NFT_EXTHDR=m 157CONFIG_NFT_EXTHDR=m
160CONFIG_NFT_META=m 158CONFIG_NFT_META=m
161CONFIG_NFT_CT=m 159CONFIG_NFT_CT=m
162CONFIG_NFT_RBTREE=m
163CONFIG_NFT_HASH=m
164CONFIG_NFT_COUNTER=m 160CONFIG_NFT_COUNTER=m
165CONFIG_NFT_LOG=m 161CONFIG_NFT_LOG=m
166CONFIG_NFT_LIMIT=m 162CONFIG_NFT_LIMIT=m
167CONFIG_NFT_NAT=m 163CONFIG_NFT_NAT=m
168CONFIG_NFT_COMPAT=m 164CONFIG_NFT_COMPAT=m
165CONFIG_NFT_HASH=m
169CONFIG_NETFILTER_XT_SET=m 166CONFIG_NETFILTER_XT_SET=m
170CONFIG_NETFILTER_XT_TARGET_AUDIT=m 167CONFIG_NETFILTER_XT_TARGET_AUDIT=m
171CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m 168CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
@@ -219,7 +216,6 @@ CONFIG_NETFILTER_XT_MATCH_QUOTA=m
219CONFIG_NETFILTER_XT_MATCH_RATEEST=m 216CONFIG_NETFILTER_XT_MATCH_RATEEST=m
220CONFIG_NETFILTER_XT_MATCH_REALM=m 217CONFIG_NETFILTER_XT_MATCH_REALM=m
221CONFIG_NETFILTER_XT_MATCH_RECENT=m 218CONFIG_NETFILTER_XT_MATCH_RECENT=m
222CONFIG_NETFILTER_XT_MATCH_SOCKET=m
223CONFIG_NETFILTER_XT_MATCH_STATE=m 219CONFIG_NETFILTER_XT_MATCH_STATE=m
224CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 220CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
225CONFIG_NETFILTER_XT_MATCH_STRING=m 221CONFIG_NETFILTER_XT_MATCH_STRING=m
@@ -258,7 +254,6 @@ CONFIG_IP_VS_NQ=m
258CONFIG_IP_VS_FTP=m 254CONFIG_IP_VS_FTP=m
259CONFIG_IP_VS_PE_SIP=m 255CONFIG_IP_VS_PE_SIP=m
260CONFIG_NF_CONNTRACK_IPV4=m 256CONFIG_NF_CONNTRACK_IPV4=m
261# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
262CONFIG_NF_TABLES_IPV4=m 257CONFIG_NF_TABLES_IPV4=m
263CONFIG_NFT_CHAIN_ROUTE_IPV4=m 258CONFIG_NFT_CHAIN_ROUTE_IPV4=m
264CONFIG_NF_TABLES_ARP=m 259CONFIG_NF_TABLES_ARP=m
@@ -436,7 +431,6 @@ CONFIG_EQUALIZER=m
436CONFIG_IFB=m 431CONFIG_IFB=m
437CONFIG_MACVLAN=m 432CONFIG_MACVLAN=m
438CONFIG_MACVTAP=m 433CONFIG_MACVTAP=m
439CONFIG_IPVLAN=m
440CONFIG_VXLAN=m 434CONFIG_VXLAN=m
441CONFIG_TUN=m 435CONFIG_TUN=m
442CONFIG_VETH=m 436CONFIG_VETH=m
@@ -480,6 +474,7 @@ CONFIG_VIRTIO_BALLOON=m
480CONFIG_EXT4_FS=y 474CONFIG_EXT4_FS=y
481CONFIG_EXT4_FS_POSIX_ACL=y 475CONFIG_EXT4_FS_POSIX_ACL=y
482CONFIG_EXT4_FS_SECURITY=y 476CONFIG_EXT4_FS_SECURITY=y
477CONFIG_EXT4_ENCRYPTION=y
483CONFIG_JBD2_DEBUG=y 478CONFIG_JBD2_DEBUG=y
484CONFIG_JFS_FS=m 479CONFIG_JFS_FS=m
485CONFIG_JFS_POSIX_ACL=y 480CONFIG_JFS_POSIX_ACL=y
@@ -592,14 +587,12 @@ CONFIG_LOCK_STAT=y
592CONFIG_DEBUG_LOCKDEP=y 587CONFIG_DEBUG_LOCKDEP=y
593CONFIG_DEBUG_ATOMIC_SLEEP=y 588CONFIG_DEBUG_ATOMIC_SLEEP=y
594CONFIG_DEBUG_LOCKING_API_SELFTESTS=y 589CONFIG_DEBUG_LOCKING_API_SELFTESTS=y
595CONFIG_DEBUG_LIST=y
596CONFIG_DEBUG_SG=y 590CONFIG_DEBUG_SG=y
597CONFIG_DEBUG_NOTIFIERS=y 591CONFIG_DEBUG_NOTIFIERS=y
598CONFIG_DEBUG_CREDENTIALS=y 592CONFIG_DEBUG_CREDENTIALS=y
599CONFIG_RCU_TORTURE_TEST=m 593CONFIG_RCU_TORTURE_TEST=m
600CONFIG_RCU_CPU_STALL_TIMEOUT=300 594CONFIG_RCU_CPU_STALL_TIMEOUT=300
601CONFIG_NOTIFIER_ERROR_INJECTION=m 595CONFIG_NOTIFIER_ERROR_INJECTION=m
602CONFIG_CPU_NOTIFIER_ERROR_INJECT=m
603CONFIG_PM_NOTIFIER_ERROR_INJECT=m 596CONFIG_PM_NOTIFIER_ERROR_INJECT=m
604CONFIG_FAULT_INJECTION=y 597CONFIG_FAULT_INJECTION=y
605CONFIG_FAILSLAB=y 598CONFIG_FAILSLAB=y
@@ -618,6 +611,7 @@ CONFIG_STACK_TRACER=y
618CONFIG_BLK_DEV_IO_TRACE=y 611CONFIG_BLK_DEV_IO_TRACE=y
619CONFIG_UPROBE_EVENT=y 612CONFIG_UPROBE_EVENT=y
620CONFIG_FUNCTION_PROFILER=y 613CONFIG_FUNCTION_PROFILER=y
614CONFIG_HIST_TRIGGERS=y
621CONFIG_TRACE_ENUM_MAP_FILE=y 615CONFIG_TRACE_ENUM_MAP_FILE=y
622CONFIG_LKDTM=m 616CONFIG_LKDTM=m
623CONFIG_TEST_LIST_SORT=y 617CONFIG_TEST_LIST_SORT=y
@@ -630,6 +624,7 @@ CONFIG_TEST_STRING_HELPERS=y
630CONFIG_TEST_KSTRTOX=y 624CONFIG_TEST_KSTRTOX=y
631CONFIG_DMA_API_DEBUG=y 625CONFIG_DMA_API_DEBUG=y
632CONFIG_TEST_BPF=m 626CONFIG_TEST_BPF=m
627CONFIG_BUG_ON_DATA_CORRUPTION=y
633CONFIG_S390_PTDUMP=y 628CONFIG_S390_PTDUMP=y
634CONFIG_ENCRYPTED_KEYS=m 629CONFIG_ENCRYPTED_KEYS=m
635CONFIG_SECURITY=y 630CONFIG_SECURITY=y
@@ -640,16 +635,18 @@ CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
640CONFIG_SECURITY_SELINUX_DISABLE=y 635CONFIG_SECURITY_SELINUX_DISABLE=y
641CONFIG_IMA=y 636CONFIG_IMA=y
642CONFIG_IMA_APPRAISE=y 637CONFIG_IMA_APPRAISE=y
638CONFIG_CRYPTO_RSA=m
639CONFIG_CRYPTO_DH=m
640CONFIG_CRYPTO_ECDH=m
643CONFIG_CRYPTO_USER=m 641CONFIG_CRYPTO_USER=m
644# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
645CONFIG_CRYPTO_CRYPTD=m 642CONFIG_CRYPTO_CRYPTD=m
646CONFIG_CRYPTO_TEST=m 643CONFIG_CRYPTO_TEST=m
647CONFIG_CRYPTO_CCM=m 644CONFIG_CRYPTO_CCM=m
648CONFIG_CRYPTO_GCM=m 645CONFIG_CRYPTO_GCM=m
649CONFIG_CRYPTO_CTS=m 646CONFIG_CRYPTO_CHACHA20POLY1305=m
650CONFIG_CRYPTO_LRW=m 647CONFIG_CRYPTO_LRW=m
651CONFIG_CRYPTO_PCBC=m 648CONFIG_CRYPTO_PCBC=m
652CONFIG_CRYPTO_XTS=m 649CONFIG_CRYPTO_KEYWRAP=m
653CONFIG_CRYPTO_XCBC=m 650CONFIG_CRYPTO_XCBC=m
654CONFIG_CRYPTO_VMAC=m 651CONFIG_CRYPTO_VMAC=m
655CONFIG_CRYPTO_CRC32=m 652CONFIG_CRYPTO_CRC32=m
@@ -673,11 +670,13 @@ CONFIG_CRYPTO_SEED=m
673CONFIG_CRYPTO_SERPENT=m 670CONFIG_CRYPTO_SERPENT=m
674CONFIG_CRYPTO_TEA=m 671CONFIG_CRYPTO_TEA=m
675CONFIG_CRYPTO_TWOFISH=m 672CONFIG_CRYPTO_TWOFISH=m
676CONFIG_CRYPTO_LZO=m 673CONFIG_CRYPTO_842=m
677CONFIG_CRYPTO_LZ4=m 674CONFIG_CRYPTO_LZ4=m
678CONFIG_CRYPTO_LZ4HC=m 675CONFIG_CRYPTO_LZ4HC=m
679CONFIG_CRYPTO_USER_API_HASH=m 676CONFIG_CRYPTO_USER_API_HASH=m
680CONFIG_CRYPTO_USER_API_SKCIPHER=m 677CONFIG_CRYPTO_USER_API_SKCIPHER=m
678CONFIG_CRYPTO_USER_API_RNG=m
679CONFIG_CRYPTO_USER_API_AEAD=m
681CONFIG_ZCRYPT=m 680CONFIG_ZCRYPT=m
682CONFIG_CRYPTO_SHA1_S390=m 681CONFIG_CRYPTO_SHA1_S390=m
683CONFIG_CRYPTO_SHA256_S390=m 682CONFIG_CRYPTO_SHA256_S390=m
diff --git a/arch/s390/configs/gcov_defconfig b/arch/s390/configs/gcov_defconfig
index 95ceac50bc65..f05d2d6e1087 100644
--- a/arch/s390/configs/gcov_defconfig
+++ b/arch/s390/configs/gcov_defconfig
@@ -12,6 +12,7 @@ CONFIG_TASK_IO_ACCOUNTING=y
12CONFIG_IKCONFIG=y 12CONFIG_IKCONFIG=y
13CONFIG_IKCONFIG_PROC=y 13CONFIG_IKCONFIG_PROC=y
14CONFIG_NUMA_BALANCING=y 14CONFIG_NUMA_BALANCING=y
15# CONFIG_NUMA_BALANCING_DEFAULT_ENABLED is not set
15CONFIG_MEMCG=y 16CONFIG_MEMCG=y
16CONFIG_MEMCG_SWAP=y 17CONFIG_MEMCG_SWAP=y
17CONFIG_BLK_CGROUP=y 18CONFIG_BLK_CGROUP=y
@@ -54,8 +55,9 @@ CONFIG_SOLARIS_X86_PARTITION=y
54CONFIG_UNIXWARE_DISKLABEL=y 55CONFIG_UNIXWARE_DISKLABEL=y
55CONFIG_CFQ_GROUP_IOSCHED=y 56CONFIG_CFQ_GROUP_IOSCHED=y
56CONFIG_DEFAULT_DEADLINE=y 57CONFIG_DEFAULT_DEADLINE=y
58CONFIG_LIVEPATCH=y
57CONFIG_TUNE_ZEC12=y 59CONFIG_TUNE_ZEC12=y
58CONFIG_NR_CPUS=256 60CONFIG_NR_CPUS=512
59CONFIG_NUMA=y 61CONFIG_NUMA=y
60CONFIG_HZ_100=y 62CONFIG_HZ_100=y
61CONFIG_MEMORY_HOTPLUG=y 63CONFIG_MEMORY_HOTPLUG=y
@@ -65,6 +67,7 @@ CONFIG_TRANSPARENT_HUGEPAGE=y
65CONFIG_CLEANCACHE=y 67CONFIG_CLEANCACHE=y
66CONFIG_FRONTSWAP=y 68CONFIG_FRONTSWAP=y
67CONFIG_CMA=y 69CONFIG_CMA=y
70CONFIG_MEM_SOFT_DIRTY=y
68CONFIG_ZSWAP=y 71CONFIG_ZSWAP=y
69CONFIG_ZBUD=m 72CONFIG_ZBUD=m
70CONFIG_ZSMALLOC=m 73CONFIG_ZSMALLOC=m
@@ -136,8 +139,6 @@ CONFIG_NF_CONNTRACK_SECMARK=y
136CONFIG_NF_CONNTRACK_EVENTS=y 139CONFIG_NF_CONNTRACK_EVENTS=y
137CONFIG_NF_CONNTRACK_TIMEOUT=y 140CONFIG_NF_CONNTRACK_TIMEOUT=y
138CONFIG_NF_CONNTRACK_TIMESTAMP=y 141CONFIG_NF_CONNTRACK_TIMESTAMP=y
139CONFIG_NF_CT_PROTO_DCCP=m
140CONFIG_NF_CT_PROTO_UDPLITE=m
141CONFIG_NF_CONNTRACK_AMANDA=m 142CONFIG_NF_CONNTRACK_AMANDA=m
142CONFIG_NF_CONNTRACK_FTP=m 143CONFIG_NF_CONNTRACK_FTP=m
143CONFIG_NF_CONNTRACK_H323=m 144CONFIG_NF_CONNTRACK_H323=m
@@ -154,13 +155,12 @@ CONFIG_NF_TABLES=m
154CONFIG_NFT_EXTHDR=m 155CONFIG_NFT_EXTHDR=m
155CONFIG_NFT_META=m 156CONFIG_NFT_META=m
156CONFIG_NFT_CT=m 157CONFIG_NFT_CT=m
157CONFIG_NFT_RBTREE=m
158CONFIG_NFT_HASH=m
159CONFIG_NFT_COUNTER=m 158CONFIG_NFT_COUNTER=m
160CONFIG_NFT_LOG=m 159CONFIG_NFT_LOG=m
161CONFIG_NFT_LIMIT=m 160CONFIG_NFT_LIMIT=m
162CONFIG_NFT_NAT=m 161CONFIG_NFT_NAT=m
163CONFIG_NFT_COMPAT=m 162CONFIG_NFT_COMPAT=m
163CONFIG_NFT_HASH=m
164CONFIG_NETFILTER_XT_SET=m 164CONFIG_NETFILTER_XT_SET=m
165CONFIG_NETFILTER_XT_TARGET_AUDIT=m 165CONFIG_NETFILTER_XT_TARGET_AUDIT=m
166CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m 166CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
@@ -214,7 +214,6 @@ CONFIG_NETFILTER_XT_MATCH_QUOTA=m
214CONFIG_NETFILTER_XT_MATCH_RATEEST=m 214CONFIG_NETFILTER_XT_MATCH_RATEEST=m
215CONFIG_NETFILTER_XT_MATCH_REALM=m 215CONFIG_NETFILTER_XT_MATCH_REALM=m
216CONFIG_NETFILTER_XT_MATCH_RECENT=m 216CONFIG_NETFILTER_XT_MATCH_RECENT=m
217CONFIG_NETFILTER_XT_MATCH_SOCKET=m
218CONFIG_NETFILTER_XT_MATCH_STATE=m 217CONFIG_NETFILTER_XT_MATCH_STATE=m
219CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 218CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
220CONFIG_NETFILTER_XT_MATCH_STRING=m 219CONFIG_NETFILTER_XT_MATCH_STRING=m
@@ -253,7 +252,6 @@ CONFIG_IP_VS_NQ=m
253CONFIG_IP_VS_FTP=m 252CONFIG_IP_VS_FTP=m
254CONFIG_IP_VS_PE_SIP=m 253CONFIG_IP_VS_PE_SIP=m
255CONFIG_NF_CONNTRACK_IPV4=m 254CONFIG_NF_CONNTRACK_IPV4=m
256# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
257CONFIG_NF_TABLES_IPV4=m 255CONFIG_NF_TABLES_IPV4=m
258CONFIG_NFT_CHAIN_ROUTE_IPV4=m 256CONFIG_NFT_CHAIN_ROUTE_IPV4=m
259CONFIG_NF_TABLES_ARP=m 257CONFIG_NF_TABLES_ARP=m
@@ -430,7 +428,6 @@ CONFIG_EQUALIZER=m
430CONFIG_IFB=m 428CONFIG_IFB=m
431CONFIG_MACVLAN=m 429CONFIG_MACVLAN=m
432CONFIG_MACVTAP=m 430CONFIG_MACVTAP=m
433CONFIG_IPVLAN=m
434CONFIG_VXLAN=m 431CONFIG_VXLAN=m
435CONFIG_TUN=m 432CONFIG_TUN=m
436CONFIG_VETH=m 433CONFIG_VETH=m
@@ -460,6 +457,7 @@ CONFIG_HW_RANDOM_VIRTIO=m
460CONFIG_RAW_DRIVER=m 457CONFIG_RAW_DRIVER=m
461CONFIG_HANGCHECK_TIMER=m 458CONFIG_HANGCHECK_TIMER=m
462CONFIG_TN3270_FS=y 459CONFIG_TN3270_FS=y
460# CONFIG_HWMON is not set
463CONFIG_WATCHDOG=y 461CONFIG_WATCHDOG=y
464CONFIG_WATCHDOG_NOWAYOUT=y 462CONFIG_WATCHDOG_NOWAYOUT=y
465CONFIG_SOFT_WATCHDOG=m 463CONFIG_SOFT_WATCHDOG=m
@@ -473,6 +471,7 @@ CONFIG_VIRTIO_BALLOON=m
473CONFIG_EXT4_FS=y 471CONFIG_EXT4_FS=y
474CONFIG_EXT4_FS_POSIX_ACL=y 472CONFIG_EXT4_FS_POSIX_ACL=y
475CONFIG_EXT4_FS_SECURITY=y 473CONFIG_EXT4_FS_SECURITY=y
474CONFIG_EXT4_ENCRYPTION=y
476CONFIG_JBD2_DEBUG=y 475CONFIG_JBD2_DEBUG=y
477CONFIG_JFS_FS=m 476CONFIG_JFS_FS=m
478CONFIG_JFS_POSIX_ACL=y 477CONFIG_JFS_POSIX_ACL=y
@@ -495,6 +494,7 @@ CONFIG_AUTOFS4_FS=m
495CONFIG_FUSE_FS=y 494CONFIG_FUSE_FS=y
496CONFIG_CUSE=m 495CONFIG_CUSE=m
497CONFIG_OVERLAY_FS=m 496CONFIG_OVERLAY_FS=m
497CONFIG_OVERLAY_FS_REDIRECT_DIR=y
498CONFIG_FSCACHE=m 498CONFIG_FSCACHE=m
499CONFIG_CACHEFILES=m 499CONFIG_CACHEFILES=m
500CONFIG_ISO9660_FS=y 500CONFIG_ISO9660_FS=y
@@ -551,25 +551,27 @@ CONFIG_FRAME_WARN=1024
551CONFIG_UNUSED_SYMBOLS=y 551CONFIG_UNUSED_SYMBOLS=y
552CONFIG_MAGIC_SYSRQ=y 552CONFIG_MAGIC_SYSRQ=y
553CONFIG_DEBUG_MEMORY_INIT=y 553CONFIG_DEBUG_MEMORY_INIT=y
554CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
555CONFIG_PANIC_ON_OOPS=y 554CONFIG_PANIC_ON_OOPS=y
556CONFIG_TIMER_STATS=y 555CONFIG_TIMER_STATS=y
557CONFIG_RCU_TORTURE_TEST=m 556CONFIG_RCU_TORTURE_TEST=m
558CONFIG_RCU_CPU_STALL_TIMEOUT=60 557CONFIG_RCU_CPU_STALL_TIMEOUT=60
559CONFIG_NOTIFIER_ERROR_INJECTION=m
560CONFIG_CPU_NOTIFIER_ERROR_INJECT=m
561CONFIG_PM_NOTIFIER_ERROR_INJECT=m
562CONFIG_LATENCYTOP=y 558CONFIG_LATENCYTOP=y
559CONFIG_SCHED_TRACER=y
560CONFIG_FTRACE_SYSCALLS=y
561CONFIG_STACK_TRACER=y
563CONFIG_BLK_DEV_IO_TRACE=y 562CONFIG_BLK_DEV_IO_TRACE=y
564# CONFIG_KPROBE_EVENT is not set 563CONFIG_UPROBE_EVENT=y
564CONFIG_FUNCTION_PROFILER=y
565CONFIG_HIST_TRIGGERS=y
565CONFIG_TRACE_ENUM_MAP_FILE=y 566CONFIG_TRACE_ENUM_MAP_FILE=y
566CONFIG_LKDTM=m 567CONFIG_LKDTM=m
567CONFIG_RBTREE_TEST=m
568CONFIG_INTERVAL_TREE_TEST=m
569CONFIG_PERCPU_TEST=m 568CONFIG_PERCPU_TEST=m
570CONFIG_ATOMIC64_SELFTEST=y 569CONFIG_ATOMIC64_SELFTEST=y
571CONFIG_TEST_BPF=m 570CONFIG_TEST_BPF=m
571CONFIG_BUG_ON_DATA_CORRUPTION=y
572CONFIG_S390_PTDUMP=y 572CONFIG_S390_PTDUMP=y
573CONFIG_PERSISTENT_KEYRINGS=y
574CONFIG_BIG_KEYS=y
573CONFIG_ENCRYPTED_KEYS=m 575CONFIG_ENCRYPTED_KEYS=m
574CONFIG_SECURITY=y 576CONFIG_SECURITY=y
575CONFIG_SECURITY_NETWORK=y 577CONFIG_SECURITY_NETWORK=y
@@ -577,18 +579,25 @@ CONFIG_SECURITY_SELINUX=y
577CONFIG_SECURITY_SELINUX_BOOTPARAM=y 579CONFIG_SECURITY_SELINUX_BOOTPARAM=y
578CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0 580CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
579CONFIG_SECURITY_SELINUX_DISABLE=y 581CONFIG_SECURITY_SELINUX_DISABLE=y
582CONFIG_INTEGRITY_SIGNATURE=y
583CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
580CONFIG_IMA=y 584CONFIG_IMA=y
585CONFIG_IMA_WRITE_POLICY=y
581CONFIG_IMA_APPRAISE=y 586CONFIG_IMA_APPRAISE=y
587CONFIG_CRYPTO_DH=m
588CONFIG_CRYPTO_ECDH=m
582CONFIG_CRYPTO_USER=m 589CONFIG_CRYPTO_USER=m
583# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set 590# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
591CONFIG_CRYPTO_PCRYPT=m
584CONFIG_CRYPTO_CRYPTD=m 592CONFIG_CRYPTO_CRYPTD=m
593CONFIG_CRYPTO_MCRYPTD=m
585CONFIG_CRYPTO_TEST=m 594CONFIG_CRYPTO_TEST=m
586CONFIG_CRYPTO_CCM=m 595CONFIG_CRYPTO_CCM=m
587CONFIG_CRYPTO_GCM=m 596CONFIG_CRYPTO_GCM=m
588CONFIG_CRYPTO_CTS=m 597CONFIG_CRYPTO_CHACHA20POLY1305=m
589CONFIG_CRYPTO_LRW=m 598CONFIG_CRYPTO_LRW=m
590CONFIG_CRYPTO_PCBC=m 599CONFIG_CRYPTO_PCBC=m
591CONFIG_CRYPTO_XTS=m 600CONFIG_CRYPTO_KEYWRAP=m
592CONFIG_CRYPTO_XCBC=m 601CONFIG_CRYPTO_XCBC=m
593CONFIG_CRYPTO_VMAC=m 602CONFIG_CRYPTO_VMAC=m
594CONFIG_CRYPTO_CRC32=m 603CONFIG_CRYPTO_CRC32=m
@@ -598,6 +607,7 @@ CONFIG_CRYPTO_RMD160=m
598CONFIG_CRYPTO_RMD256=m 607CONFIG_CRYPTO_RMD256=m
599CONFIG_CRYPTO_RMD320=m 608CONFIG_CRYPTO_RMD320=m
600CONFIG_CRYPTO_SHA512=m 609CONFIG_CRYPTO_SHA512=m
610CONFIG_CRYPTO_SHA3=m
601CONFIG_CRYPTO_TGR192=m 611CONFIG_CRYPTO_TGR192=m
602CONFIG_CRYPTO_WP512=m 612CONFIG_CRYPTO_WP512=m
603CONFIG_CRYPTO_ANUBIS=m 613CONFIG_CRYPTO_ANUBIS=m
@@ -612,10 +622,13 @@ CONFIG_CRYPTO_SEED=m
612CONFIG_CRYPTO_SERPENT=m 622CONFIG_CRYPTO_SERPENT=m
613CONFIG_CRYPTO_TEA=m 623CONFIG_CRYPTO_TEA=m
614CONFIG_CRYPTO_TWOFISH=m 624CONFIG_CRYPTO_TWOFISH=m
625CONFIG_CRYPTO_842=m
615CONFIG_CRYPTO_LZ4=m 626CONFIG_CRYPTO_LZ4=m
616CONFIG_CRYPTO_LZ4HC=m 627CONFIG_CRYPTO_LZ4HC=m
617CONFIG_CRYPTO_USER_API_HASH=m 628CONFIG_CRYPTO_USER_API_HASH=m
618CONFIG_CRYPTO_USER_API_SKCIPHER=m 629CONFIG_CRYPTO_USER_API_SKCIPHER=m
630CONFIG_CRYPTO_USER_API_RNG=m
631CONFIG_CRYPTO_USER_API_AEAD=m
619CONFIG_ZCRYPT=m 632CONFIG_ZCRYPT=m
620CONFIG_CRYPTO_SHA1_S390=m 633CONFIG_CRYPTO_SHA1_S390=m
621CONFIG_CRYPTO_SHA256_S390=m 634CONFIG_CRYPTO_SHA256_S390=m
@@ -624,9 +637,6 @@ CONFIG_CRYPTO_DES_S390=m
624CONFIG_CRYPTO_AES_S390=m 637CONFIG_CRYPTO_AES_S390=m
625CONFIG_CRYPTO_GHASH_S390=m 638CONFIG_CRYPTO_GHASH_S390=m
626CONFIG_CRYPTO_CRC32_S390=y 639CONFIG_CRYPTO_CRC32_S390=y
627CONFIG_ASYMMETRIC_KEY_TYPE=y
628CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=m
629CONFIG_X509_CERTIFICATE_PARSER=m
630CONFIG_CRC7=m 640CONFIG_CRC7=m
631CONFIG_CRC8=m 641CONFIG_CRC8=m
632CONFIG_CORDIC=m 642CONFIG_CORDIC=m
diff --git a/arch/s390/configs/performance_defconfig b/arch/s390/configs/performance_defconfig
index bc7b176f5795..2cf87343b590 100644
--- a/arch/s390/configs/performance_defconfig
+++ b/arch/s390/configs/performance_defconfig
@@ -65,6 +65,7 @@ CONFIG_TRANSPARENT_HUGEPAGE=y
65CONFIG_CLEANCACHE=y 65CONFIG_CLEANCACHE=y
66CONFIG_FRONTSWAP=y 66CONFIG_FRONTSWAP=y
67CONFIG_CMA=y 67CONFIG_CMA=y
68CONFIG_MEM_SOFT_DIRTY=y
68CONFIG_ZSWAP=y 69CONFIG_ZSWAP=y
69CONFIG_ZBUD=m 70CONFIG_ZBUD=m
70CONFIG_ZSMALLOC=m 71CONFIG_ZSMALLOC=m
@@ -136,8 +137,6 @@ CONFIG_NF_CONNTRACK_SECMARK=y
136CONFIG_NF_CONNTRACK_EVENTS=y 137CONFIG_NF_CONNTRACK_EVENTS=y
137CONFIG_NF_CONNTRACK_TIMEOUT=y 138CONFIG_NF_CONNTRACK_TIMEOUT=y
138CONFIG_NF_CONNTRACK_TIMESTAMP=y 139CONFIG_NF_CONNTRACK_TIMESTAMP=y
139CONFIG_NF_CT_PROTO_DCCP=m
140CONFIG_NF_CT_PROTO_UDPLITE=m
141CONFIG_NF_CONNTRACK_AMANDA=m 140CONFIG_NF_CONNTRACK_AMANDA=m
142CONFIG_NF_CONNTRACK_FTP=m 141CONFIG_NF_CONNTRACK_FTP=m
143CONFIG_NF_CONNTRACK_H323=m 142CONFIG_NF_CONNTRACK_H323=m
@@ -154,13 +153,12 @@ CONFIG_NF_TABLES=m
154CONFIG_NFT_EXTHDR=m 153CONFIG_NFT_EXTHDR=m
155CONFIG_NFT_META=m 154CONFIG_NFT_META=m
156CONFIG_NFT_CT=m 155CONFIG_NFT_CT=m
157CONFIG_NFT_RBTREE=m
158CONFIG_NFT_HASH=m
159CONFIG_NFT_COUNTER=m 156CONFIG_NFT_COUNTER=m
160CONFIG_NFT_LOG=m 157CONFIG_NFT_LOG=m
161CONFIG_NFT_LIMIT=m 158CONFIG_NFT_LIMIT=m
162CONFIG_NFT_NAT=m 159CONFIG_NFT_NAT=m
163CONFIG_NFT_COMPAT=m 160CONFIG_NFT_COMPAT=m
161CONFIG_NFT_HASH=m
164CONFIG_NETFILTER_XT_SET=m 162CONFIG_NETFILTER_XT_SET=m
165CONFIG_NETFILTER_XT_TARGET_AUDIT=m 163CONFIG_NETFILTER_XT_TARGET_AUDIT=m
166CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m 164CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
@@ -214,7 +212,6 @@ CONFIG_NETFILTER_XT_MATCH_QUOTA=m
214CONFIG_NETFILTER_XT_MATCH_RATEEST=m 212CONFIG_NETFILTER_XT_MATCH_RATEEST=m
215CONFIG_NETFILTER_XT_MATCH_REALM=m 213CONFIG_NETFILTER_XT_MATCH_REALM=m
216CONFIG_NETFILTER_XT_MATCH_RECENT=m 214CONFIG_NETFILTER_XT_MATCH_RECENT=m
217CONFIG_NETFILTER_XT_MATCH_SOCKET=m
218CONFIG_NETFILTER_XT_MATCH_STATE=m 215CONFIG_NETFILTER_XT_MATCH_STATE=m
219CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 216CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
220CONFIG_NETFILTER_XT_MATCH_STRING=m 217CONFIG_NETFILTER_XT_MATCH_STRING=m
@@ -253,7 +250,6 @@ CONFIG_IP_VS_NQ=m
253CONFIG_IP_VS_FTP=m 250CONFIG_IP_VS_FTP=m
254CONFIG_IP_VS_PE_SIP=m 251CONFIG_IP_VS_PE_SIP=m
255CONFIG_NF_CONNTRACK_IPV4=m 252CONFIG_NF_CONNTRACK_IPV4=m
256# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
257CONFIG_NF_TABLES_IPV4=m 253CONFIG_NF_TABLES_IPV4=m
258CONFIG_NFT_CHAIN_ROUTE_IPV4=m 254CONFIG_NFT_CHAIN_ROUTE_IPV4=m
259CONFIG_NF_TABLES_ARP=m 255CONFIG_NF_TABLES_ARP=m
@@ -430,7 +426,6 @@ CONFIG_EQUALIZER=m
430CONFIG_IFB=m 426CONFIG_IFB=m
431CONFIG_MACVLAN=m 427CONFIG_MACVLAN=m
432CONFIG_MACVTAP=m 428CONFIG_MACVTAP=m
433CONFIG_IPVLAN=m
434CONFIG_VXLAN=m 429CONFIG_VXLAN=m
435CONFIG_TUN=m 430CONFIG_TUN=m
436CONFIG_VETH=m 431CONFIG_VETH=m
@@ -474,6 +469,7 @@ CONFIG_VIRTIO_BALLOON=m
474CONFIG_EXT4_FS=y 469CONFIG_EXT4_FS=y
475CONFIG_EXT4_FS_POSIX_ACL=y 470CONFIG_EXT4_FS_POSIX_ACL=y
476CONFIG_EXT4_FS_SECURITY=y 471CONFIG_EXT4_FS_SECURITY=y
472CONFIG_EXT4_ENCRYPTION=y
477CONFIG_JBD2_DEBUG=y 473CONFIG_JBD2_DEBUG=y
478CONFIG_JFS_FS=m 474CONFIG_JFS_FS=m
479CONFIG_JFS_POSIX_ACL=y 475CONFIG_JFS_POSIX_ACL=y
@@ -496,6 +492,7 @@ CONFIG_AUTOFS4_FS=m
496CONFIG_FUSE_FS=y 492CONFIG_FUSE_FS=y
497CONFIG_CUSE=m 493CONFIG_CUSE=m
498CONFIG_OVERLAY_FS=m 494CONFIG_OVERLAY_FS=m
495CONFIG_OVERLAY_FS_REDIRECT_DIR=y
499CONFIG_FSCACHE=m 496CONFIG_FSCACHE=m
500CONFIG_CACHEFILES=m 497CONFIG_CACHEFILES=m
501CONFIG_ISO9660_FS=y 498CONFIG_ISO9660_FS=y
@@ -563,12 +560,16 @@ CONFIG_STACK_TRACER=y
563CONFIG_BLK_DEV_IO_TRACE=y 560CONFIG_BLK_DEV_IO_TRACE=y
564CONFIG_UPROBE_EVENT=y 561CONFIG_UPROBE_EVENT=y
565CONFIG_FUNCTION_PROFILER=y 562CONFIG_FUNCTION_PROFILER=y
563CONFIG_HIST_TRIGGERS=y
566CONFIG_TRACE_ENUM_MAP_FILE=y 564CONFIG_TRACE_ENUM_MAP_FILE=y
567CONFIG_LKDTM=m 565CONFIG_LKDTM=m
568CONFIG_PERCPU_TEST=m 566CONFIG_PERCPU_TEST=m
569CONFIG_ATOMIC64_SELFTEST=y 567CONFIG_ATOMIC64_SELFTEST=y
570CONFIG_TEST_BPF=m 568CONFIG_TEST_BPF=m
569CONFIG_BUG_ON_DATA_CORRUPTION=y
571CONFIG_S390_PTDUMP=y 570CONFIG_S390_PTDUMP=y
571CONFIG_PERSISTENT_KEYRINGS=y
572CONFIG_BIG_KEYS=y
572CONFIG_ENCRYPTED_KEYS=m 573CONFIG_ENCRYPTED_KEYS=m
573CONFIG_SECURITY=y 574CONFIG_SECURITY=y
574CONFIG_SECURITY_NETWORK=y 575CONFIG_SECURITY_NETWORK=y
@@ -576,18 +577,25 @@ CONFIG_SECURITY_SELINUX=y
576CONFIG_SECURITY_SELINUX_BOOTPARAM=y 577CONFIG_SECURITY_SELINUX_BOOTPARAM=y
577CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0 578CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
578CONFIG_SECURITY_SELINUX_DISABLE=y 579CONFIG_SECURITY_SELINUX_DISABLE=y
580CONFIG_INTEGRITY_SIGNATURE=y
581CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
579CONFIG_IMA=y 582CONFIG_IMA=y
583CONFIG_IMA_WRITE_POLICY=y
580CONFIG_IMA_APPRAISE=y 584CONFIG_IMA_APPRAISE=y
585CONFIG_CRYPTO_DH=m
586CONFIG_CRYPTO_ECDH=m
581CONFIG_CRYPTO_USER=m 587CONFIG_CRYPTO_USER=m
582# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set 588# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
589CONFIG_CRYPTO_PCRYPT=m
583CONFIG_CRYPTO_CRYPTD=m 590CONFIG_CRYPTO_CRYPTD=m
591CONFIG_CRYPTO_MCRYPTD=m
584CONFIG_CRYPTO_TEST=m 592CONFIG_CRYPTO_TEST=m
585CONFIG_CRYPTO_CCM=m 593CONFIG_CRYPTO_CCM=m
586CONFIG_CRYPTO_GCM=m 594CONFIG_CRYPTO_GCM=m
587CONFIG_CRYPTO_CTS=m 595CONFIG_CRYPTO_CHACHA20POLY1305=m
588CONFIG_CRYPTO_LRW=m 596CONFIG_CRYPTO_LRW=m
589CONFIG_CRYPTO_PCBC=m 597CONFIG_CRYPTO_PCBC=m
590CONFIG_CRYPTO_XTS=m 598CONFIG_CRYPTO_KEYWRAP=m
591CONFIG_CRYPTO_XCBC=m 599CONFIG_CRYPTO_XCBC=m
592CONFIG_CRYPTO_VMAC=m 600CONFIG_CRYPTO_VMAC=m
593CONFIG_CRYPTO_CRC32=m 601CONFIG_CRYPTO_CRC32=m
@@ -597,6 +605,7 @@ CONFIG_CRYPTO_RMD160=m
597CONFIG_CRYPTO_RMD256=m 605CONFIG_CRYPTO_RMD256=m
598CONFIG_CRYPTO_RMD320=m 606CONFIG_CRYPTO_RMD320=m
599CONFIG_CRYPTO_SHA512=m 607CONFIG_CRYPTO_SHA512=m
608CONFIG_CRYPTO_SHA3=m
600CONFIG_CRYPTO_TGR192=m 609CONFIG_CRYPTO_TGR192=m
601CONFIG_CRYPTO_WP512=m 610CONFIG_CRYPTO_WP512=m
602CONFIG_CRYPTO_ANUBIS=m 611CONFIG_CRYPTO_ANUBIS=m
@@ -611,10 +620,13 @@ CONFIG_CRYPTO_SEED=m
611CONFIG_CRYPTO_SERPENT=m 620CONFIG_CRYPTO_SERPENT=m
612CONFIG_CRYPTO_TEA=m 621CONFIG_CRYPTO_TEA=m
613CONFIG_CRYPTO_TWOFISH=m 622CONFIG_CRYPTO_TWOFISH=m
623CONFIG_CRYPTO_842=m
614CONFIG_CRYPTO_LZ4=m 624CONFIG_CRYPTO_LZ4=m
615CONFIG_CRYPTO_LZ4HC=m 625CONFIG_CRYPTO_LZ4HC=m
616CONFIG_CRYPTO_USER_API_HASH=m 626CONFIG_CRYPTO_USER_API_HASH=m
617CONFIG_CRYPTO_USER_API_SKCIPHER=m 627CONFIG_CRYPTO_USER_API_SKCIPHER=m
628CONFIG_CRYPTO_USER_API_RNG=m
629CONFIG_CRYPTO_USER_API_AEAD=m
618CONFIG_ZCRYPT=m 630CONFIG_ZCRYPT=m
619CONFIG_CRYPTO_SHA1_S390=m 631CONFIG_CRYPTO_SHA1_S390=m
620CONFIG_CRYPTO_SHA256_S390=m 632CONFIG_CRYPTO_SHA256_S390=m
@@ -623,9 +635,6 @@ CONFIG_CRYPTO_DES_S390=m
623CONFIG_CRYPTO_AES_S390=m 635CONFIG_CRYPTO_AES_S390=m
624CONFIG_CRYPTO_GHASH_S390=m 636CONFIG_CRYPTO_GHASH_S390=m
625CONFIG_CRYPTO_CRC32_S390=y 637CONFIG_CRYPTO_CRC32_S390=y
626CONFIG_ASYMMETRIC_KEY_TYPE=y
627CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=m
628CONFIG_X509_CERTIFICATE_PARSER=m
629CONFIG_CRC7=m 638CONFIG_CRC7=m
630CONFIG_CRC8=m 639CONFIG_CRC8=m
631CONFIG_CORDIC=m 640CONFIG_CORDIC=m
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 2d40ef0a6295..d00e368fb5e6 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -38,7 +38,6 @@ CONFIG_JUMP_LABEL=y
38CONFIG_STATIC_KEYS_SELFTEST=y 38CONFIG_STATIC_KEYS_SELFTEST=y
39CONFIG_MODULES=y 39CONFIG_MODULES=y
40CONFIG_MODULE_UNLOAD=y 40CONFIG_MODULE_UNLOAD=y
41CONFIG_MODVERSIONS=y
42CONFIG_BLK_DEV_INTEGRITY=y 41CONFIG_BLK_DEV_INTEGRITY=y
43CONFIG_PARTITION_ADVANCED=y 42CONFIG_PARTITION_ADVANCED=y
44CONFIG_IBM_PARTITION=y 43CONFIG_IBM_PARTITION=y
@@ -130,8 +129,11 @@ CONFIG_DUMMY=m
130CONFIG_EQUALIZER=m 129CONFIG_EQUALIZER=m
131CONFIG_TUN=m 130CONFIG_TUN=m
132CONFIG_VIRTIO_NET=y 131CONFIG_VIRTIO_NET=y
132# CONFIG_NET_VENDOR_ALACRITECH is not set
133# CONFIG_NET_VENDOR_SOLARFLARE is not set
133# CONFIG_INPUT is not set 134# CONFIG_INPUT is not set
134# CONFIG_SERIO is not set 135# CONFIG_SERIO is not set
136CONFIG_DEVKMEM=y
135CONFIG_RAW_DRIVER=m 137CONFIG_RAW_DRIVER=m
136CONFIG_VIRTIO_BALLOON=y 138CONFIG_VIRTIO_BALLOON=y
137CONFIG_EXT4_FS=y 139CONFIG_EXT4_FS=y
@@ -183,7 +185,6 @@ CONFIG_TRACE_ENUM_MAP_FILE=y
183CONFIG_KPROBES_SANITY_TEST=y 185CONFIG_KPROBES_SANITY_TEST=y
184CONFIG_S390_PTDUMP=y 186CONFIG_S390_PTDUMP=y
185CONFIG_CRYPTO_CRYPTD=m 187CONFIG_CRYPTO_CRYPTD=m
186CONFIG_CRYPTO_AUTHENC=m
187CONFIG_CRYPTO_TEST=m 188CONFIG_CRYPTO_TEST=m
188CONFIG_CRYPTO_CCM=m 189CONFIG_CRYPTO_CCM=m
189CONFIG_CRYPTO_GCM=m 190CONFIG_CRYPTO_GCM=m
diff --git a/arch/s390/include/asm/asm-prototypes.h b/arch/s390/include/asm/asm-prototypes.h
new file mode 100644
index 000000000000..2c3413b0ca52
--- /dev/null
+++ b/arch/s390/include/asm/asm-prototypes.h
@@ -0,0 +1,8 @@
1#ifndef _ASM_S390_PROTOTYPES_H
2
3#include <linux/kvm_host.h>
4#include <linux/ftrace.h>
5#include <asm/fpu/api.h>
6#include <asm-generic/asm-prototypes.h>
7
8#endif /* _ASM_S390_PROTOTYPES_H */
diff --git a/arch/s390/include/asm/ctl_reg.h b/arch/s390/include/asm/ctl_reg.h
index d7697ab802f6..8e136b88cdf4 100644
--- a/arch/s390/include/asm/ctl_reg.h
+++ b/arch/s390/include/asm/ctl_reg.h
@@ -15,7 +15,9 @@
15 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\ 15 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
16 asm volatile( \ 16 asm volatile( \
17 " lctlg %1,%2,%0\n" \ 17 " lctlg %1,%2,%0\n" \
18 : : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high));\ 18 : \
19 : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high) \
20 : "memory"); \
19} 21}
20 22
21#define __ctl_store(array, low, high) { \ 23#define __ctl_store(array, low, high) { \
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 6b246aadf311..1b5c5ee9fc1b 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -94,7 +94,7 @@ static void update_mt_scaling(void)
94 * Update process times based on virtual cpu times stored by entry.S 94 * Update process times based on virtual cpu times stored by entry.S
95 * to the lowcore fields user_timer, system_timer & steal_clock. 95 * to the lowcore fields user_timer, system_timer & steal_clock.
96 */ 96 */
97static int do_account_vtime(struct task_struct *tsk, int hardirq_offset) 97static int do_account_vtime(struct task_struct *tsk)
98{ 98{
99 u64 timer, clock, user, system, steal; 99 u64 timer, clock, user, system, steal;
100 u64 user_scaled, system_scaled; 100 u64 user_scaled, system_scaled;
@@ -138,7 +138,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
138 } 138 }
139 account_user_time(tsk, user); 139 account_user_time(tsk, user);
140 tsk->utimescaled += user_scaled; 140 tsk->utimescaled += user_scaled;
141 account_system_time(tsk, hardirq_offset, system); 141 account_system_time(tsk, 0, system);
142 tsk->stimescaled += system_scaled; 142 tsk->stimescaled += system_scaled;
143 143
144 steal = S390_lowcore.steal_timer; 144 steal = S390_lowcore.steal_timer;
@@ -152,7 +152,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
152 152
153void vtime_task_switch(struct task_struct *prev) 153void vtime_task_switch(struct task_struct *prev)
154{ 154{
155 do_account_vtime(prev, 0); 155 do_account_vtime(prev);
156 prev->thread.user_timer = S390_lowcore.user_timer; 156 prev->thread.user_timer = S390_lowcore.user_timer;
157 prev->thread.system_timer = S390_lowcore.system_timer; 157 prev->thread.system_timer = S390_lowcore.system_timer;
158 S390_lowcore.user_timer = current->thread.user_timer; 158 S390_lowcore.user_timer = current->thread.user_timer;
@@ -166,7 +166,7 @@ void vtime_task_switch(struct task_struct *prev)
166 */ 166 */
167void vtime_account_user(struct task_struct *tsk) 167void vtime_account_user(struct task_struct *tsk)
168{ 168{
169 if (do_account_vtime(tsk, HARDIRQ_OFFSET)) 169 if (do_account_vtime(tsk))
170 virt_timer_expire(); 170 virt_timer_expire();
171} 171}
172 172
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index bec71e902be3..6484a250021e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -916,7 +916,7 @@ static int kvm_s390_get_machine(struct kvm *kvm, struct kvm_device_attr *attr)
916 memcpy(&mach->fac_mask, kvm->arch.model.fac_mask, 916 memcpy(&mach->fac_mask, kvm->arch.model.fac_mask,
917 S390_ARCH_FAC_LIST_SIZE_BYTE); 917 S390_ARCH_FAC_LIST_SIZE_BYTE);
918 memcpy((unsigned long *)&mach->fac_list, S390_lowcore.stfle_fac_list, 918 memcpy((unsigned long *)&mach->fac_list, S390_lowcore.stfle_fac_list,
919 S390_ARCH_FAC_LIST_SIZE_BYTE); 919 sizeof(S390_lowcore.stfle_fac_list));
920 if (copy_to_user((void __user *)attr->addr, mach, sizeof(*mach))) 920 if (copy_to_user((void __user *)attr->addr, mach, sizeof(*mach)))
921 ret = -EFAULT; 921 ret = -EFAULT;
922 kfree(mach); 922 kfree(mach);
@@ -1437,7 +1437,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
1437 1437
1438 /* Populate the facility mask initially. */ 1438 /* Populate the facility mask initially. */
1439 memcpy(kvm->arch.model.fac_mask, S390_lowcore.stfle_fac_list, 1439 memcpy(kvm->arch.model.fac_mask, S390_lowcore.stfle_fac_list,
1440 S390_ARCH_FAC_LIST_SIZE_BYTE); 1440 sizeof(S390_lowcore.stfle_fac_list));
1441 for (i = 0; i < S390_ARCH_FAC_LIST_SIZE_U64; i++) { 1441 for (i = 0; i < S390_ARCH_FAC_LIST_SIZE_U64; i++) {
1442 if (i < kvm_s390_fac_list_mask_size()) 1442 if (i < kvm_s390_fac_list_mask_size())
1443 kvm->arch.model.fac_mask[i] &= kvm_s390_fac_list_mask[i]; 1443 kvm->arch.model.fac_mask[i] &= kvm_s390_fac_list_mask[i];
diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index d89b7011667c..e279572824b1 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -111,7 +111,7 @@ static int tile_gpr_set(struct task_struct *target,
111 const void *kbuf, const void __user *ubuf) 111 const void *kbuf, const void __user *ubuf)
112{ 112{
113 int ret; 113 int ret;
114 struct pt_regs regs; 114 struct pt_regs regs = *task_pt_regs(target);
115 115
116 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0, 116 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0,
117 sizeof(regs)); 117 sizeof(regs));
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index cc3bd583dce1..9e240fcba784 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/types.h> 15#include <linux/types.h>
16#include "ctype.h" 16#include "ctype.h"
17#include "string.h"
17 18
18int memcmp(const void *s1, const void *s2, size_t len) 19int memcmp(const void *s1, const void *s2, size_t len)
19{ 20{
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h
index 725e820602b1..113588ddb43f 100644
--- a/arch/x86/boot/string.h
+++ b/arch/x86/boot/string.h
@@ -18,4 +18,13 @@ int memcmp(const void *s1, const void *s2, size_t len);
18#define memset(d,c,l) __builtin_memset(d,c,l) 18#define memset(d,c,l) __builtin_memset(d,c,l)
19#define memcmp __builtin_memcmp 19#define memcmp __builtin_memcmp
20 20
21extern int strcmp(const char *str1, const char *str2);
22extern int strncmp(const char *cs, const char *ct, size_t count);
23extern size_t strlen(const char *s);
24extern char *strstr(const char *s1, const char *s2);
25extern size_t strnlen(const char *s, size_t maxlen);
26extern unsigned int atou(const char *s);
27extern unsigned long long simple_strtoull(const char *cp, char **endp,
28 unsigned int base);
29
21#endif /* BOOT_STRING_H */ 30#endif /* BOOT_STRING_H */
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 31c34ee131f3..6ef688a1ef3e 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -1020,7 +1020,8 @@ struct {
1020 const char *basename; 1020 const char *basename;
1021 struct simd_skcipher_alg *simd; 1021 struct simd_skcipher_alg *simd;
1022} aesni_simd_skciphers2[] = { 1022} aesni_simd_skciphers2[] = {
1023#if IS_ENABLED(CONFIG_CRYPTO_PCBC) 1023#if (defined(MODULE) && IS_ENABLED(CONFIG_CRYPTO_PCBC)) || \
1024 IS_BUILTIN(CONFIG_CRYPTO_PCBC)
1024 { 1025 {
1025 .algname = "pcbc(aes)", 1026 .algname = "pcbc(aes)",
1026 .drvname = "pcbc-aes-aesni", 1027 .drvname = "pcbc-aes-aesni",
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 701d29f8e4d3..57f7ec35216e 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -255,23 +255,6 @@ ENTRY(__switch_to_asm)
255END(__switch_to_asm) 255END(__switch_to_asm)
256 256
257/* 257/*
258 * The unwinder expects the last frame on the stack to always be at the same
259 * offset from the end of the page, which allows it to validate the stack.
260 * Calling schedule_tail() directly would break that convention because its an
261 * asmlinkage function so its argument has to be pushed on the stack. This
262 * wrapper creates a proper "end of stack" frame header before the call.
263 */
264ENTRY(schedule_tail_wrapper)
265 FRAME_BEGIN
266
267 pushl %eax
268 call schedule_tail
269 popl %eax
270
271 FRAME_END
272 ret
273ENDPROC(schedule_tail_wrapper)
274/*
275 * A newly forked process directly context switches into this address. 258 * A newly forked process directly context switches into this address.
276 * 259 *
277 * eax: prev task we switched from 260 * eax: prev task we switched from
@@ -279,15 +262,24 @@ ENDPROC(schedule_tail_wrapper)
279 * edi: kernel thread arg 262 * edi: kernel thread arg
280 */ 263 */
281ENTRY(ret_from_fork) 264ENTRY(ret_from_fork)
282 call schedule_tail_wrapper 265 FRAME_BEGIN /* help unwinder find end of stack */
266
267 /*
268 * schedule_tail() is asmlinkage so we have to put its 'prev' argument
269 * on the stack.
270 */
271 pushl %eax
272 call schedule_tail
273 popl %eax
283 274
284 testl %ebx, %ebx 275 testl %ebx, %ebx
285 jnz 1f /* kernel threads are uncommon */ 276 jnz 1f /* kernel threads are uncommon */
286 277
2872: 2782:
288 /* When we fork, we trace the syscall return in the child, too. */ 279 /* When we fork, we trace the syscall return in the child, too. */
289 movl %esp, %eax 280 leal FRAME_OFFSET(%esp), %eax
290 call syscall_return_slowpath 281 call syscall_return_slowpath
282 FRAME_END
291 jmp restore_all 283 jmp restore_all
292 284
293 /* kernel thread */ 285 /* kernel thread */
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 5b219707c2f2..044d18ebc43c 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -36,6 +36,7 @@
36#include <asm/smap.h> 36#include <asm/smap.h>
37#include <asm/pgtable_types.h> 37#include <asm/pgtable_types.h>
38#include <asm/export.h> 38#include <asm/export.h>
39#include <asm/frame.h>
39#include <linux/err.h> 40#include <linux/err.h>
40 41
41.code64 42.code64
@@ -408,17 +409,19 @@ END(__switch_to_asm)
408 * r12: kernel thread arg 409 * r12: kernel thread arg
409 */ 410 */
410ENTRY(ret_from_fork) 411ENTRY(ret_from_fork)
412 FRAME_BEGIN /* help unwinder find end of stack */
411 movq %rax, %rdi 413 movq %rax, %rdi
412 call schedule_tail /* rdi: 'prev' task parameter */ 414 call schedule_tail /* rdi: 'prev' task parameter */
413 415
414 testq %rbx, %rbx /* from kernel_thread? */ 416 testq %rbx, %rbx /* from kernel_thread? */
415 jnz 1f /* kernel threads are uncommon */ 417 jnz 1f /* kernel threads are uncommon */
416 418
4172: 4192:
418 movq %rsp, %rdi 420 leaq FRAME_OFFSET(%rsp),%rdi /* pt_regs pointer */
419 call syscall_return_slowpath /* returns with IRQs disabled */ 421 call syscall_return_slowpath /* returns with IRQs disabled */
420 TRACE_IRQS_ON /* user mode is traced as IRQS on */ 422 TRACE_IRQS_ON /* user mode is traced as IRQS on */
421 SWAPGS 423 SWAPGS
424 FRAME_END
422 jmp restore_regs_and_iret 425 jmp restore_regs_and_iret
423 426
4241: 4271:
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 05612a2529c8..496e60391fac 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -1010,7 +1010,7 @@ static __init int amd_ibs_init(void)
1010 * all online cpus. 1010 * all online cpus.
1011 */ 1011 */
1012 cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING, 1012 cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING,
1013 "perf/x86/amd/ibs:STARTING", 1013 "perf/x86/amd/ibs:starting",
1014 x86_pmu_amd_ibs_starting_cpu, 1014 x86_pmu_amd_ibs_starting_cpu,
1015 x86_pmu_amd_ibs_dying_cpu); 1015 x86_pmu_amd_ibs_dying_cpu);
1016 1016
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 019c5887b698..1635c0c8df23 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -505,6 +505,10 @@ int x86_pmu_hw_config(struct perf_event *event)
505 505
506 if (event->attr.precise_ip > precise) 506 if (event->attr.precise_ip > precise)
507 return -EOPNOTSUPP; 507 return -EOPNOTSUPP;
508
509 /* There's no sense in having PEBS for non sampling events: */
510 if (!is_sampling_event(event))
511 return -EINVAL;
508 } 512 }
509 /* 513 /*
510 * check that PEBS LBR correction does not conflict with 514 * check that PEBS LBR correction does not conflict with
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 86138267b68a..eb1484c86bb4 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3176,13 +3176,16 @@ static void intel_pmu_cpu_starting(int cpu)
3176 3176
3177 if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) { 3177 if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
3178 for_each_cpu(i, topology_sibling_cpumask(cpu)) { 3178 for_each_cpu(i, topology_sibling_cpumask(cpu)) {
3179 struct cpu_hw_events *sibling;
3179 struct intel_excl_cntrs *c; 3180 struct intel_excl_cntrs *c;
3180 3181
3181 c = per_cpu(cpu_hw_events, i).excl_cntrs; 3182 sibling = &per_cpu(cpu_hw_events, i);
3183 c = sibling->excl_cntrs;
3182 if (c && c->core_id == core_id) { 3184 if (c && c->core_id == core_id) {
3183 cpuc->kfree_on_online[1] = cpuc->excl_cntrs; 3185 cpuc->kfree_on_online[1] = cpuc->excl_cntrs;
3184 cpuc->excl_cntrs = c; 3186 cpuc->excl_cntrs = c;
3185 cpuc->excl_thread_id = 1; 3187 if (!sibling->excl_thread_id)
3188 cpuc->excl_thread_id = 1;
3186 break; 3189 break;
3187 } 3190 }
3188 } 3191 }
@@ -3987,7 +3990,7 @@ __init int intel_pmu_init(void)
3987 x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC); 3990 x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC);
3988 x86_pmu.num_counters = INTEL_PMC_MAX_GENERIC; 3991 x86_pmu.num_counters = INTEL_PMC_MAX_GENERIC;
3989 } 3992 }
3990 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1; 3993 x86_pmu.intel_ctrl = (1ULL << x86_pmu.num_counters) - 1;
3991 3994
3992 if (x86_pmu.num_counters_fixed > INTEL_PMC_MAX_FIXED) { 3995 if (x86_pmu.num_counters_fixed > INTEL_PMC_MAX_FIXED) {
3993 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!", 3996 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index fec8a461bdef..1076c9a77292 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -434,6 +434,7 @@ static struct pmu cstate_core_pmu = {
434 .stop = cstate_pmu_event_stop, 434 .stop = cstate_pmu_event_stop,
435 .read = cstate_pmu_event_update, 435 .read = cstate_pmu_event_update,
436 .capabilities = PERF_PMU_CAP_NO_INTERRUPT, 436 .capabilities = PERF_PMU_CAP_NO_INTERRUPT,
437 .module = THIS_MODULE,
437}; 438};
438 439
439static struct pmu cstate_pkg_pmu = { 440static struct pmu cstate_pkg_pmu = {
@@ -447,6 +448,7 @@ static struct pmu cstate_pkg_pmu = {
447 .stop = cstate_pmu_event_stop, 448 .stop = cstate_pmu_event_stop,
448 .read = cstate_pmu_event_update, 449 .read = cstate_pmu_event_update,
449 .capabilities = PERF_PMU_CAP_NO_INTERRUPT, 450 .capabilities = PERF_PMU_CAP_NO_INTERRUPT,
451 .module = THIS_MODULE,
450}; 452};
451 453
452static const struct cstate_model nhm_cstates __initconst = { 454static const struct cstate_model nhm_cstates __initconst = {
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index be202390bbd3..9dfeeeca0ea8 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -1389,9 +1389,13 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
1389 continue; 1389 continue;
1390 1390
1391 /* log dropped samples number */ 1391 /* log dropped samples number */
1392 if (error[bit]) 1392 if (error[bit]) {
1393 perf_log_lost_samples(event, error[bit]); 1393 perf_log_lost_samples(event, error[bit]);
1394 1394
1395 if (perf_event_account_interrupt(event))
1396 x86_pmu_stop(event, 0);
1397 }
1398
1395 if (counts[bit]) { 1399 if (counts[bit]) {
1396 __intel_pmu_pebs_event(event, iregs, base, 1400 __intel_pmu_pebs_event(event, iregs, base,
1397 top, bit, counts[bit]); 1401 top, bit, counts[bit]);
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index bd34124449b0..17c3564d087a 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -697,6 +697,7 @@ static int __init init_rapl_pmus(void)
697 rapl_pmus->pmu.start = rapl_pmu_event_start; 697 rapl_pmus->pmu.start = rapl_pmu_event_start;
698 rapl_pmus->pmu.stop = rapl_pmu_event_stop; 698 rapl_pmus->pmu.stop = rapl_pmu_event_stop;
699 rapl_pmus->pmu.read = rapl_pmu_event_read; 699 rapl_pmus->pmu.read = rapl_pmu_event_read;
700 rapl_pmus->pmu.module = THIS_MODULE;
700 return 0; 701 return 0;
701} 702}
702 703
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 97c246f84dea..8c4ccdc3a3f3 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -733,6 +733,7 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
733 .start = uncore_pmu_event_start, 733 .start = uncore_pmu_event_start,
734 .stop = uncore_pmu_event_stop, 734 .stop = uncore_pmu_event_stop,
735 .read = uncore_pmu_event_read, 735 .read = uncore_pmu_event_read,
736 .module = THIS_MODULE,
736 }; 737 };
737 } else { 738 } else {
738 pmu->pmu = *pmu->type->pmu; 739 pmu->pmu = *pmu->type->pmu;
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index e6832be714bc..dae2fedc1601 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -2686,7 +2686,7 @@ static struct intel_uncore_type *hswep_msr_uncores[] = {
2686 2686
2687void hswep_uncore_cpu_init(void) 2687void hswep_uncore_cpu_init(void)
2688{ 2688{
2689 int pkg = topology_phys_to_logical_pkg(0); 2689 int pkg = boot_cpu_data.logical_proc_id;
2690 2690
2691 if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) 2691 if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
2692 hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; 2692 hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
diff --git a/arch/x86/include/asm/intel-family.h b/arch/x86/include/asm/intel-family.h
index 34a46dc076d3..8167fdb67ae8 100644
--- a/arch/x86/include/asm/intel-family.h
+++ b/arch/x86/include/asm/intel-family.h
@@ -57,7 +57,7 @@
57#define INTEL_FAM6_ATOM_SILVERMONT2 0x4D /* Avaton/Rangely */ 57#define INTEL_FAM6_ATOM_SILVERMONT2 0x4D /* Avaton/Rangely */
58#define INTEL_FAM6_ATOM_AIRMONT 0x4C /* CherryTrail / Braswell */ 58#define INTEL_FAM6_ATOM_AIRMONT 0x4C /* CherryTrail / Braswell */
59#define INTEL_FAM6_ATOM_MERRIFIELD 0x4A /* Tangier */ 59#define INTEL_FAM6_ATOM_MERRIFIELD 0x4A /* Tangier */
60#define INTEL_FAM6_ATOM_MOOREFIELD 0x5A /* Annidale */ 60#define INTEL_FAM6_ATOM_MOOREFIELD 0x5A /* Anniedale */
61#define INTEL_FAM6_ATOM_GOLDMONT 0x5C 61#define INTEL_FAM6_ATOM_GOLDMONT 0x5C
62#define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */ 62#define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */
63 63
diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h
index 195becc6f780..e793fc9a9b20 100644
--- a/arch/x86/include/asm/microcode_intel.h
+++ b/arch/x86/include/asm/microcode_intel.h
@@ -52,6 +52,21 @@ struct extended_sigtable {
52 52
53#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) 53#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
54 54
55static inline u32 intel_get_microcode_revision(void)
56{
57 u32 rev, dummy;
58
59 native_wrmsrl(MSR_IA32_UCODE_REV, 0);
60
61 /* As documented in the SDM: Do a CPUID 1 here */
62 native_cpuid_eax(1);
63
64 /* get the current revision from MSR 0x8B */
65 native_rdmsr(MSR_IA32_UCODE_REV, dummy, rev);
66
67 return rev;
68}
69
55#ifdef CONFIG_MICROCODE_INTEL 70#ifdef CONFIG_MICROCODE_INTEL
56extern void __init load_ucode_intel_bsp(void); 71extern void __init load_ucode_intel_bsp(void);
57extern void load_ucode_intel_ap(void); 72extern void load_ucode_intel_ap(void);
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index eaf100508c36..1be64da0384e 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -219,6 +219,24 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
219 : "memory"); 219 : "memory");
220} 220}
221 221
222#define native_cpuid_reg(reg) \
223static inline unsigned int native_cpuid_##reg(unsigned int op) \
224{ \
225 unsigned int eax = op, ebx, ecx = 0, edx; \
226 \
227 native_cpuid(&eax, &ebx, &ecx, &edx); \
228 \
229 return reg; \
230}
231
232/*
233 * Native CPUID functions returning a single datum.
234 */
235native_cpuid_reg(eax)
236native_cpuid_reg(ebx)
237native_cpuid_reg(ecx)
238native_cpuid_reg(edx)
239
222static inline void load_cr3(pgd_t *pgdir) 240static inline void load_cr3(pgd_t *pgdir)
223{ 241{
224 write_cr3(__pa(pgdir)); 242 write_cr3(__pa(pgdir));
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
index a3269c897ec5..2e41c50ddf47 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -58,7 +58,7 @@ get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
58 if (task == current) 58 if (task == current)
59 return __builtin_frame_address(0); 59 return __builtin_frame_address(0);
60 60
61 return (unsigned long *)((struct inactive_task_frame *)task->thread.sp)->bp; 61 return &((struct inactive_task_frame *)task->thread.sp)->bp;
62} 62}
63#else 63#else
64static inline unsigned long * 64static inline unsigned long *
diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
index 5cb436acd463..fcc5cd387fd1 100644
--- a/arch/x86/include/asm/switch_to.h
+++ b/arch/x86/include/asm/switch_to.h
@@ -36,7 +36,10 @@ static inline void prepare_switch_to(struct task_struct *prev,
36 36
37asmlinkage void ret_from_fork(void); 37asmlinkage void ret_from_fork(void);
38 38
39/* data that is pointed to by thread.sp */ 39/*
40 * This is the structure pointed to by thread.sp for an inactive task. The
41 * order of the fields must match the code in __switch_to_asm().
42 */
40struct inactive_task_frame { 43struct inactive_task_frame {
41#ifdef CONFIG_X86_64 44#ifdef CONFIG_X86_64
42 unsigned long r15; 45 unsigned long r15;
@@ -48,6 +51,11 @@ struct inactive_task_frame {
48 unsigned long di; 51 unsigned long di;
49#endif 52#endif
50 unsigned long bx; 53 unsigned long bx;
54
55 /*
56 * These two fields must be together. They form a stack frame header,
57 * needed by get_frame_pointer().
58 */
51 unsigned long bp; 59 unsigned long bp;
52 unsigned long ret_addr; 60 unsigned long ret_addr;
53}; 61};
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 945e512a112a..1e35dd06b090 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1875,6 +1875,7 @@ static struct irq_chip ioapic_chip __read_mostly = {
1875 .irq_ack = irq_chip_ack_parent, 1875 .irq_ack = irq_chip_ack_parent,
1876 .irq_eoi = ioapic_ack_level, 1876 .irq_eoi = ioapic_ack_level,
1877 .irq_set_affinity = ioapic_set_affinity, 1877 .irq_set_affinity = ioapic_set_affinity,
1878 .irq_retrigger = irq_chip_retrigger_hierarchy,
1878 .flags = IRQCHIP_SKIP_SET_WAKE, 1879 .flags = IRQCHIP_SKIP_SET_WAKE,
1879}; 1880};
1880 1881
@@ -1886,6 +1887,7 @@ static struct irq_chip ioapic_ir_chip __read_mostly = {
1886 .irq_ack = irq_chip_ack_parent, 1887 .irq_ack = irq_chip_ack_parent,
1887 .irq_eoi = ioapic_ir_ack_level, 1888 .irq_eoi = ioapic_ir_ack_level,
1888 .irq_set_affinity = ioapic_set_affinity, 1889 .irq_set_affinity = ioapic_set_affinity,
1890 .irq_retrigger = irq_chip_retrigger_hierarchy,
1889 .flags = IRQCHIP_SKIP_SET_WAKE, 1891 .flags = IRQCHIP_SKIP_SET_WAKE,
1890}; 1892};
1891 1893
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 71cae73a5076..1d3167269a67 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -309,15 +309,8 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
309 309
310 /* get information required for multi-node processors */ 310 /* get information required for multi-node processors */
311 if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { 311 if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
312 u32 eax, ebx, ecx, edx;
313 312
314 cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); 313 node_id = cpuid_ecx(0x8000001e) & 7;
315 node_id = ecx & 7;
316
317 /* get compute unit information */
318 smp_num_siblings = ((ebx >> 8) & 3) + 1;
319 c->x86_max_cores /= smp_num_siblings;
320 c->cpu_core_id = ebx & 0xff;
321 314
322 /* 315 /*
323 * We may have multiple LLCs if L3 caches exist, so check if we 316 * We may have multiple LLCs if L3 caches exist, so check if we
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index dc1697ca5191..9bab7a8a4293 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1221,7 +1221,7 @@ static __init int setup_disablecpuid(char *arg)
1221{ 1221{
1222 int bit; 1222 int bit;
1223 1223
1224 if (get_option(&arg, &bit) && bit < NCAPINTS*32) 1224 if (get_option(&arg, &bit) && bit >= 0 && bit < NCAPINTS * 32)
1225 setup_clear_cpu_cap(bit); 1225 setup_clear_cpu_cap(bit);
1226 else 1226 else
1227 return 0; 1227 return 0;
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index fcd484d2bb03..203f860d2ab3 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -14,6 +14,7 @@
14#include <asm/bugs.h> 14#include <asm/bugs.h>
15#include <asm/cpu.h> 15#include <asm/cpu.h>
16#include <asm/intel-family.h> 16#include <asm/intel-family.h>
17#include <asm/microcode_intel.h>
17 18
18#ifdef CONFIG_X86_64 19#ifdef CONFIG_X86_64
19#include <linux/topology.h> 20#include <linux/topology.h>
@@ -78,14 +79,8 @@ static void early_init_intel(struct cpuinfo_x86 *c)
78 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 79 (c->x86 == 0x6 && c->x86_model >= 0x0e))
79 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 80 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
80 81
81 if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) { 82 if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
82 unsigned lower_word; 83 c->microcode = intel_get_microcode_revision();
83
84 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
85 /* Required by the SDM */
86 sync_core();
87 rdmsr(MSR_IA32_UCODE_REV, lower_word, c->microcode);
88 }
89 84
90 /* 85 /*
91 * Atom erratum AAE44/AAF40/AAG38/AAH41: 86 * Atom erratum AAE44/AAF40/AAG38/AAH41:
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index b624b54912e1..3f329b74e040 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -150,7 +150,7 @@ static struct ucode_patch *__alloc_microcode_buf(void *data, unsigned int size)
150{ 150{
151 struct ucode_patch *p; 151 struct ucode_patch *p;
152 152
153 p = kzalloc(size, GFP_KERNEL); 153 p = kzalloc(sizeof(struct ucode_patch), GFP_KERNEL);
154 if (!p) 154 if (!p)
155 return ERR_PTR(-ENOMEM); 155 return ERR_PTR(-ENOMEM);
156 156
@@ -368,26 +368,6 @@ next:
368 return patch; 368 return patch;
369} 369}
370 370
371static void cpuid_1(void)
372{
373 /*
374 * According to the Intel SDM, Volume 3, 9.11.7:
375 *
376 * CPUID returns a value in a model specific register in
377 * addition to its usual register return values. The
378 * semantics of CPUID cause it to deposit an update ID value
379 * in the 64-bit model-specific register at address 08BH
380 * (IA32_BIOS_SIGN_ID). If no update is present in the
381 * processor, the value in the MSR remains unmodified.
382 *
383 * Use native_cpuid -- this code runs very early and we don't
384 * want to mess with paravirt.
385 */
386 unsigned int eax = 1, ebx, ecx = 0, edx;
387
388 native_cpuid(&eax, &ebx, &ecx, &edx);
389}
390
391static int collect_cpu_info_early(struct ucode_cpu_info *uci) 371static int collect_cpu_info_early(struct ucode_cpu_info *uci)
392{ 372{
393 unsigned int val[2]; 373 unsigned int val[2];
@@ -410,15 +390,8 @@ static int collect_cpu_info_early(struct ucode_cpu_info *uci)
410 native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); 390 native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
411 csig.pf = 1 << ((val[1] >> 18) & 7); 391 csig.pf = 1 << ((val[1] >> 18) & 7);
412 } 392 }
413 native_wrmsrl(MSR_IA32_UCODE_REV, 0);
414
415 /* As documented in the SDM: Do a CPUID 1 here */
416 cpuid_1();
417 393
418 /* get the current revision from MSR 0x8B */ 394 csig.rev = intel_get_microcode_revision();
419 native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
420
421 csig.rev = val[1];
422 395
423 uci->cpu_sig = csig; 396 uci->cpu_sig = csig;
424 uci->valid = 1; 397 uci->valid = 1;
@@ -602,7 +575,7 @@ static inline void print_ucode(struct ucode_cpu_info *uci)
602static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) 575static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
603{ 576{
604 struct microcode_intel *mc; 577 struct microcode_intel *mc;
605 unsigned int val[2]; 578 u32 rev;
606 579
607 mc = uci->mc; 580 mc = uci->mc;
608 if (!mc) 581 if (!mc)
@@ -610,21 +583,16 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
610 583
611 /* write microcode via MSR 0x79 */ 584 /* write microcode via MSR 0x79 */
612 native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); 585 native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
613 native_wrmsrl(MSR_IA32_UCODE_REV, 0);
614 586
615 /* As documented in the SDM: Do a CPUID 1 here */ 587 rev = intel_get_microcode_revision();
616 cpuid_1(); 588 if (rev != mc->hdr.rev)
617
618 /* get the current revision from MSR 0x8B */
619 native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
620 if (val[1] != mc->hdr.rev)
621 return -1; 589 return -1;
622 590
623#ifdef CONFIG_X86_64 591#ifdef CONFIG_X86_64
624 /* Flush global tlb. This is precaution. */ 592 /* Flush global tlb. This is precaution. */
625 flush_tlb_early(); 593 flush_tlb_early();
626#endif 594#endif
627 uci->cpu_sig.rev = val[1]; 595 uci->cpu_sig.rev = rev;
628 596
629 if (early) 597 if (early)
630 print_ucode(uci); 598 print_ucode(uci);
@@ -804,8 +772,8 @@ static int apply_microcode_intel(int cpu)
804 struct microcode_intel *mc; 772 struct microcode_intel *mc;
805 struct ucode_cpu_info *uci; 773 struct ucode_cpu_info *uci;
806 struct cpuinfo_x86 *c; 774 struct cpuinfo_x86 *c;
807 unsigned int val[2];
808 static int prev_rev; 775 static int prev_rev;
776 u32 rev;
809 777
810 /* We should bind the task to the CPU */ 778 /* We should bind the task to the CPU */
811 if (WARN_ON(raw_smp_processor_id() != cpu)) 779 if (WARN_ON(raw_smp_processor_id() != cpu))
@@ -822,33 +790,28 @@ static int apply_microcode_intel(int cpu)
822 790
823 /* write microcode via MSR 0x79 */ 791 /* write microcode via MSR 0x79 */
824 wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); 792 wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
825 wrmsrl(MSR_IA32_UCODE_REV, 0);
826
827 /* As documented in the SDM: Do a CPUID 1 here */
828 cpuid_1();
829 793
830 /* get the current revision from MSR 0x8B */ 794 rev = intel_get_microcode_revision();
831 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
832 795
833 if (val[1] != mc->hdr.rev) { 796 if (rev != mc->hdr.rev) {
834 pr_err("CPU%d update to revision 0x%x failed\n", 797 pr_err("CPU%d update to revision 0x%x failed\n",
835 cpu, mc->hdr.rev); 798 cpu, mc->hdr.rev);
836 return -1; 799 return -1;
837 } 800 }
838 801
839 if (val[1] != prev_rev) { 802 if (rev != prev_rev) {
840 pr_info("updated to revision 0x%x, date = %04x-%02x-%02x\n", 803 pr_info("updated to revision 0x%x, date = %04x-%02x-%02x\n",
841 val[1], 804 rev,
842 mc->hdr.date & 0xffff, 805 mc->hdr.date & 0xffff,
843 mc->hdr.date >> 24, 806 mc->hdr.date >> 24,
844 (mc->hdr.date >> 16) & 0xff); 807 (mc->hdr.date >> 16) & 0xff);
845 prev_rev = val[1]; 808 prev_rev = rev;
846 } 809 }
847 810
848 c = &cpu_data(cpu); 811 c = &cpu_data(cpu);
849 812
850 uci->cpu_sig.rev = val[1]; 813 uci->cpu_sig.rev = rev;
851 c->microcode = val[1]; 814 c->microcode = rev;
852 815
853 return 0; 816 return 0;
854} 817}
@@ -860,7 +823,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
860 u8 *ucode_ptr = data, *new_mc = NULL, *mc = NULL; 823 u8 *ucode_ptr = data, *new_mc = NULL, *mc = NULL;
861 int new_rev = uci->cpu_sig.rev; 824 int new_rev = uci->cpu_sig.rev;
862 unsigned int leftover = size; 825 unsigned int leftover = size;
863 unsigned int curr_mc_size = 0; 826 unsigned int curr_mc_size = 0, new_mc_size = 0;
864 unsigned int csig, cpf; 827 unsigned int csig, cpf;
865 828
866 while (leftover) { 829 while (leftover) {
@@ -901,6 +864,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
901 vfree(new_mc); 864 vfree(new_mc);
902 new_rev = mc_header.rev; 865 new_rev = mc_header.rev;
903 new_mc = mc; 866 new_mc = mc;
867 new_mc_size = mc_size;
904 mc = NULL; /* trigger new vmalloc */ 868 mc = NULL; /* trigger new vmalloc */
905 } 869 }
906 870
@@ -926,7 +890,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
926 * permanent memory. So it will be loaded early when a CPU is hot added 890 * permanent memory. So it will be loaded early when a CPU is hot added
927 * or resumes. 891 * or resumes.
928 */ 892 */
929 save_mc_for_early(new_mc, curr_mc_size); 893 save_mc_for_early(new_mc, new_mc_size);
930 894
931 pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n", 895 pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n",
932 cpu, new_rev, uci->cpu_sig.rev); 896 cpu, new_rev, uci->cpu_sig.rev);
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index b47edb8f5256..410efb2c7b80 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -68,12 +68,10 @@ static struct dma_map_ops swiotlb_dma_ops = {
68 */ 68 */
69int __init pci_swiotlb_detect_override(void) 69int __init pci_swiotlb_detect_override(void)
70{ 70{
71 int use_swiotlb = swiotlb | swiotlb_force; 71 if (swiotlb_force == SWIOTLB_FORCE)
72
73 if (swiotlb_force)
74 swiotlb = 1; 72 swiotlb = 1;
75 73
76 return use_swiotlb; 74 return swiotlb;
77} 75}
78IOMMU_INIT_FINISH(pci_swiotlb_detect_override, 76IOMMU_INIT_FINISH(pci_swiotlb_detect_override,
79 pci_xen_swiotlb_detect, 77 pci_xen_swiotlb_detect,
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index be3a49ee0356..e41af597aed8 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -694,6 +694,7 @@ unsigned long native_calibrate_tsc(void)
694 crystal_khz = 24000; /* 24.0 MHz */ 694 crystal_khz = 24000; /* 24.0 MHz */
695 break; 695 break;
696 case INTEL_FAM6_SKYLAKE_X: 696 case INTEL_FAM6_SKYLAKE_X:
697 case INTEL_FAM6_ATOM_DENVERTON:
697 crystal_khz = 25000; /* 25.0 MHz */ 698 crystal_khz = 25000; /* 25.0 MHz */
698 break; 699 break;
699 case INTEL_FAM6_ATOM_GOLDMONT: 700 case INTEL_FAM6_ATOM_GOLDMONT:
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 4443e499f279..23d15565d02a 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -6,6 +6,21 @@
6 6
7#define FRAME_HEADER_SIZE (sizeof(long) * 2) 7#define FRAME_HEADER_SIZE (sizeof(long) * 2)
8 8
9/*
10 * This disables KASAN checking when reading a value from another task's stack,
11 * since the other task could be running on another CPU and could have poisoned
12 * the stack in the meantime.
13 */
14#define READ_ONCE_TASK_STACK(task, x) \
15({ \
16 unsigned long val; \
17 if (task == current) \
18 val = READ_ONCE(x); \
19 else \
20 val = READ_ONCE_NOCHECK(x); \
21 val; \
22})
23
9static void unwind_dump(struct unwind_state *state, unsigned long *sp) 24static void unwind_dump(struct unwind_state *state, unsigned long *sp)
10{ 25{
11 static bool dumped_before = false; 26 static bool dumped_before = false;
@@ -48,7 +63,8 @@ unsigned long unwind_get_return_address(struct unwind_state *state)
48 if (state->regs && user_mode(state->regs)) 63 if (state->regs && user_mode(state->regs))
49 return 0; 64 return 0;
50 65
51 addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, *addr_p, 66 addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
67 addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, addr,
52 addr_p); 68 addr_p);
53 69
54 return __kernel_text_address(addr) ? addr : 0; 70 return __kernel_text_address(addr) ? addr : 0;
@@ -162,7 +178,7 @@ bool unwind_next_frame(struct unwind_state *state)
162 if (state->regs) 178 if (state->regs)
163 next_bp = (unsigned long *)state->regs->bp; 179 next_bp = (unsigned long *)state->regs->bp;
164 else 180 else
165 next_bp = (unsigned long *)*state->bp; 181 next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task,*state->bp);
166 182
167 /* is the next frame pointer an encoded pointer to pt_regs? */ 183 /* is the next frame pointer an encoded pointer to pt_regs? */
168 regs = decode_frame_pointer(next_bp); 184 regs = decode_frame_pointer(next_bp);
@@ -207,6 +223,16 @@ bool unwind_next_frame(struct unwind_state *state)
207 return true; 223 return true;
208 224
209bad_address: 225bad_address:
226 /*
227 * When unwinding a non-current task, the task might actually be
228 * running on another CPU, in which case it could be modifying its
229 * stack while we're reading it. This is generally not a problem and
230 * can be ignored as long as the caller understands that unwinding
231 * another task will not always succeed.
232 */
233 if (state->task != current)
234 goto the_end;
235
210 if (state->regs) { 236 if (state->regs) {
211 printk_deferred_once(KERN_WARNING 237 printk_deferred_once(KERN_WARNING
212 "WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n", 238 "WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n",
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 56628a44668b..cedbba0f3402 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -818,6 +818,20 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
818 return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception); 818 return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
819} 819}
820 820
821static int segmented_write_std(struct x86_emulate_ctxt *ctxt,
822 struct segmented_address addr,
823 void *data,
824 unsigned int size)
825{
826 int rc;
827 ulong linear;
828
829 rc = linearize(ctxt, addr, size, true, &linear);
830 if (rc != X86EMUL_CONTINUE)
831 return rc;
832 return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception);
833}
834
821/* 835/*
822 * Prefetch the remaining bytes of the instruction without crossing page 836 * Prefetch the remaining bytes of the instruction without crossing page
823 * boundary if they are not in fetch_cache yet. 837 * boundary if they are not in fetch_cache yet.
@@ -1571,7 +1585,6 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1571 &ctxt->exception); 1585 &ctxt->exception);
1572} 1586}
1573 1587
1574/* Does not support long mode */
1575static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt, 1588static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1576 u16 selector, int seg, u8 cpl, 1589 u16 selector, int seg, u8 cpl,
1577 enum x86_transfer_type transfer, 1590 enum x86_transfer_type transfer,
@@ -1608,20 +1621,34 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1608 1621
1609 rpl = selector & 3; 1622 rpl = selector & 3;
1610 1623
1611 /* NULL selector is not valid for TR, CS and SS (except for long mode) */
1612 if ((seg == VCPU_SREG_CS
1613 || (seg == VCPU_SREG_SS
1614 && (ctxt->mode != X86EMUL_MODE_PROT64 || rpl != cpl))
1615 || seg == VCPU_SREG_TR)
1616 && null_selector)
1617 goto exception;
1618
1619 /* TR should be in GDT only */ 1624 /* TR should be in GDT only */
1620 if (seg == VCPU_SREG_TR && (selector & (1 << 2))) 1625 if (seg == VCPU_SREG_TR && (selector & (1 << 2)))
1621 goto exception; 1626 goto exception;
1622 1627
1623 if (null_selector) /* for NULL selector skip all following checks */ 1628 /* NULL selector is not valid for TR, CS and (except for long mode) SS */
1629 if (null_selector) {
1630 if (seg == VCPU_SREG_CS || seg == VCPU_SREG_TR)
1631 goto exception;
1632
1633 if (seg == VCPU_SREG_SS) {
1634 if (ctxt->mode != X86EMUL_MODE_PROT64 || rpl != cpl)
1635 goto exception;
1636
1637 /*
1638 * ctxt->ops->set_segment expects the CPL to be in
1639 * SS.DPL, so fake an expand-up 32-bit data segment.
1640 */
1641 seg_desc.type = 3;
1642 seg_desc.p = 1;
1643 seg_desc.s = 1;
1644 seg_desc.dpl = cpl;
1645 seg_desc.d = 1;
1646 seg_desc.g = 1;
1647 }
1648
1649 /* Skip all following checks */
1624 goto load; 1650 goto load;
1651 }
1625 1652
1626 ret = read_segment_descriptor(ctxt, selector, &seg_desc, &desc_addr); 1653 ret = read_segment_descriptor(ctxt, selector, &seg_desc, &desc_addr);
1627 if (ret != X86EMUL_CONTINUE) 1654 if (ret != X86EMUL_CONTINUE)
@@ -1737,6 +1764,21 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1737 u16 selector, int seg) 1764 u16 selector, int seg)
1738{ 1765{
1739 u8 cpl = ctxt->ops->cpl(ctxt); 1766 u8 cpl = ctxt->ops->cpl(ctxt);
1767
1768 /*
1769 * None of MOV, POP and LSS can load a NULL selector in CPL=3, but
1770 * they can load it at CPL<3 (Intel's manual says only LSS can,
1771 * but it's wrong).
1772 *
1773 * However, the Intel manual says that putting IST=1/DPL=3 in
1774 * an interrupt gate will result in SS=3 (the AMD manual instead
1775 * says it doesn't), so allow SS=3 in __load_segment_descriptor
1776 * and only forbid it here.
1777 */
1778 if (seg == VCPU_SREG_SS && selector == 3 &&
1779 ctxt->mode == X86EMUL_MODE_PROT64)
1780 return emulate_exception(ctxt, GP_VECTOR, 0, true);
1781
1740 return __load_segment_descriptor(ctxt, selector, seg, cpl, 1782 return __load_segment_descriptor(ctxt, selector, seg, cpl,
1741 X86_TRANSFER_NONE, NULL); 1783 X86_TRANSFER_NONE, NULL);
1742} 1784}
@@ -3685,8 +3727,8 @@ static int emulate_store_desc_ptr(struct x86_emulate_ctxt *ctxt,
3685 } 3727 }
3686 /* Disable writeback. */ 3728 /* Disable writeback. */
3687 ctxt->dst.type = OP_NONE; 3729 ctxt->dst.type = OP_NONE;
3688 return segmented_write(ctxt, ctxt->dst.addr.mem, 3730 return segmented_write_std(ctxt, ctxt->dst.addr.mem,
3689 &desc_ptr, 2 + ctxt->op_bytes); 3731 &desc_ptr, 2 + ctxt->op_bytes);
3690} 3732}
3691 3733
3692static int em_sgdt(struct x86_emulate_ctxt *ctxt) 3734static int em_sgdt(struct x86_emulate_ctxt *ctxt)
@@ -3932,7 +3974,7 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt)
3932 else 3974 else
3933 size = offsetof(struct fxregs_state, xmm_space[0]); 3975 size = offsetof(struct fxregs_state, xmm_space[0]);
3934 3976
3935 return segmented_write(ctxt, ctxt->memop.addr.mem, &fx_state, size); 3977 return segmented_write_std(ctxt, ctxt->memop.addr.mem, &fx_state, size);
3936} 3978}
3937 3979
3938static int fxrstor_fixup(struct x86_emulate_ctxt *ctxt, 3980static int fxrstor_fixup(struct x86_emulate_ctxt *ctxt,
@@ -3974,7 +4016,7 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
3974 if (rc != X86EMUL_CONTINUE) 4016 if (rc != X86EMUL_CONTINUE)
3975 return rc; 4017 return rc;
3976 4018
3977 rc = segmented_read(ctxt, ctxt->memop.addr.mem, &fx_state, 512); 4019 rc = segmented_read_std(ctxt, ctxt->memop.addr.mem, &fx_state, 512);
3978 if (rc != X86EMUL_CONTINUE) 4020 if (rc != X86EMUL_CONTINUE)
3979 return rc; 4021 return rc;
3980 4022
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5fe290c1b7d8..2f6ef5121a4c 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2426,3 +2426,9 @@ void kvm_lapic_init(void)
2426 jump_label_rate_limit(&apic_hw_disabled, HZ); 2426 jump_label_rate_limit(&apic_hw_disabled, HZ);
2427 jump_label_rate_limit(&apic_sw_disabled, HZ); 2427 jump_label_rate_limit(&apic_sw_disabled, HZ);
2428} 2428}
2429
2430void kvm_lapic_exit(void)
2431{
2432 static_key_deferred_flush(&apic_hw_disabled);
2433 static_key_deferred_flush(&apic_sw_disabled);
2434}
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index e0c80233b3e1..ff8039d61672 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -110,6 +110,7 @@ static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu)
110 110
111int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); 111int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data);
112void kvm_lapic_init(void); 112void kvm_lapic_init(void);
113void kvm_lapic_exit(void);
113 114
114#define VEC_POS(v) ((v) & (32 - 1)) 115#define VEC_POS(v) ((v) & (32 - 1))
115#define REG_POS(v) (((v) >> 5) << 4) 116#define REG_POS(v) (((v) >> 5) << 4)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 24db5fb6f575..a236decb81e4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -132,12 +132,6 @@ module_param_named(preemption_timer, enable_preemption_timer, bool, S_IRUGO);
132 132
133#define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5 133#define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5
134 134
135#define VMX_VPID_EXTENT_SUPPORTED_MASK \
136 (VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT | \
137 VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | \
138 VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT | \
139 VMX_VPID_EXTENT_SINGLE_NON_GLOBAL_BIT)
140
141/* 135/*
142 * Hyper-V requires all of these, so mark them as supported even though 136 * Hyper-V requires all of these, so mark them as supported even though
143 * they are just treated the same as all-context. 137 * they are just treated the same as all-context.
@@ -10473,12 +10467,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10473 !nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4)) { 10467 !nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4)) {
10474 nested_vmx_entry_failure(vcpu, vmcs12, 10468 nested_vmx_entry_failure(vcpu, vmcs12,
10475 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10469 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10476 goto out; 10470 return 1;
10477 } 10471 }
10478 if (vmcs12->vmcs_link_pointer != -1ull) { 10472 if (vmcs12->vmcs_link_pointer != -1ull) {
10479 nested_vmx_entry_failure(vcpu, vmcs12, 10473 nested_vmx_entry_failure(vcpu, vmcs12,
10480 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR); 10474 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR);
10481 goto out; 10475 return 1;
10482 } 10476 }
10483 10477
10484 /* 10478 /*
@@ -10498,7 +10492,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10498 ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) { 10492 ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) {
10499 nested_vmx_entry_failure(vcpu, vmcs12, 10493 nested_vmx_entry_failure(vcpu, vmcs12,
10500 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10494 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10501 goto out; 10495 return 1;
10502 } 10496 }
10503 } 10497 }
10504 10498
@@ -10516,7 +10510,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10516 ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) { 10510 ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) {
10517 nested_vmx_entry_failure(vcpu, vmcs12, 10511 nested_vmx_entry_failure(vcpu, vmcs12,
10518 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10512 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10519 goto out; 10513 return 1;
10520 } 10514 }
10521 } 10515 }
10522 10516
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 51ccfe08e32f..d153be8929a6 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3070,6 +3070,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
3070 memset(&events->reserved, 0, sizeof(events->reserved)); 3070 memset(&events->reserved, 0, sizeof(events->reserved));
3071} 3071}
3072 3072
3073static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags);
3074
3073static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, 3075static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
3074 struct kvm_vcpu_events *events) 3076 struct kvm_vcpu_events *events)
3075{ 3077{
@@ -3106,10 +3108,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
3106 vcpu->arch.apic->sipi_vector = events->sipi_vector; 3108 vcpu->arch.apic->sipi_vector = events->sipi_vector;
3107 3109
3108 if (events->flags & KVM_VCPUEVENT_VALID_SMM) { 3110 if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
3111 u32 hflags = vcpu->arch.hflags;
3109 if (events->smi.smm) 3112 if (events->smi.smm)
3110 vcpu->arch.hflags |= HF_SMM_MASK; 3113 hflags |= HF_SMM_MASK;
3111 else 3114 else
3112 vcpu->arch.hflags &= ~HF_SMM_MASK; 3115 hflags &= ~HF_SMM_MASK;
3116 kvm_set_hflags(vcpu, hflags);
3117
3113 vcpu->arch.smi_pending = events->smi.pending; 3118 vcpu->arch.smi_pending = events->smi.pending;
3114 if (events->smi.smm_inside_nmi) 3119 if (events->smi.smm_inside_nmi)
3115 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK; 3120 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
@@ -3337,6 +3342,8 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
3337 3342
3338 switch (cap->cap) { 3343 switch (cap->cap) {
3339 case KVM_CAP_HYPERV_SYNIC: 3344 case KVM_CAP_HYPERV_SYNIC:
3345 if (!irqchip_in_kernel(vcpu->kvm))
3346 return -EINVAL;
3340 return kvm_hv_activate_synic(vcpu); 3347 return kvm_hv_activate_synic(vcpu);
3341 default: 3348 default:
3342 return -EINVAL; 3349 return -EINVAL;
@@ -6040,6 +6047,7 @@ out:
6040 6047
6041void kvm_arch_exit(void) 6048void kvm_arch_exit(void)
6042{ 6049{
6050 kvm_lapic_exit();
6043 perf_unregister_guest_info_callbacks(&kvm_guest_cbs); 6051 perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
6044 6052
6045 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 6053 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
@@ -6163,7 +6171,8 @@ static int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt)
6163 6171
6164 kvm_x86_ops->patch_hypercall(vcpu, instruction); 6172 kvm_x86_ops->patch_hypercall(vcpu, instruction);
6165 6173
6166 return emulator_write_emulated(ctxt, rip, instruction, 3, NULL); 6174 return emulator_write_emulated(ctxt, rip, instruction, 3,
6175 &ctxt->exception);
6167} 6176}
6168 6177
6169static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu) 6178static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index 324e5713d386..af59f808742f 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -293,7 +293,7 @@ siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
293 * We were not able to extract an address from the instruction, 293 * We were not able to extract an address from the instruction,
294 * probably because there was something invalid in it. 294 * probably because there was something invalid in it.
295 */ 295 */
296 if (info->si_addr == (void *)-1) { 296 if (info->si_addr == (void __user *)-1) {
297 err = -EINVAL; 297 err = -EINVAL;
298 goto err_out; 298 goto err_out;
299 } 299 }
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index e76d1af60f7a..bb660e53cbd6 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1172,6 +1172,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1172 set_memory_ro((unsigned long)header, header->pages); 1172 set_memory_ro((unsigned long)header, header->pages);
1173 prog->bpf_func = (void *)image; 1173 prog->bpf_func = (void *)image;
1174 prog->jited = 1; 1174 prog->jited = 1;
1175 } else {
1176 prog = orig_prog;
1175 } 1177 }
1176 1178
1177out_addrs: 1179out_addrs:
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 3cd69832d7f4..3961103e9176 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -114,6 +114,16 @@ static const struct dmi_system_id pci_crs_quirks[] __initconst = {
114 DMI_MATCH(DMI_BIOS_VERSION, "6JET85WW (1.43 )"), 114 DMI_MATCH(DMI_BIOS_VERSION, "6JET85WW (1.43 )"),
115 }, 115 },
116 }, 116 },
117 /* https://bugzilla.kernel.org/show_bug.cgi?id=42606 */
118 {
119 .callback = set_nouse_crs,
120 .ident = "Supermicro X8DTH",
121 .matches = {
122 DMI_MATCH(DMI_SYS_VENDOR, "Supermicro"),
123 DMI_MATCH(DMI_PRODUCT_NAME, "X8DTH-i/6/iF/6F"),
124 DMI_MATCH(DMI_BIOS_VERSION, "2.0a"),
125 },
126 },
117 127
118 /* https://bugzilla.kernel.org/show_bug.cgi?id=15362 */ 128 /* https://bugzilla.kernel.org/show_bug.cgi?id=15362 */
119 { 129 {
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 936a488d6cf6..274dfc481849 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -210,6 +210,70 @@ int __init efi_memblock_x86_reserve_range(void)
210 return 0; 210 return 0;
211} 211}
212 212
213#define OVERFLOW_ADDR_SHIFT (64 - EFI_PAGE_SHIFT)
214#define OVERFLOW_ADDR_MASK (U64_MAX << OVERFLOW_ADDR_SHIFT)
215#define U64_HIGH_BIT (~(U64_MAX >> 1))
216
217static bool __init efi_memmap_entry_valid(const efi_memory_desc_t *md, int i)
218{
219 u64 end = (md->num_pages << EFI_PAGE_SHIFT) + md->phys_addr - 1;
220 u64 end_hi = 0;
221 char buf[64];
222
223 if (md->num_pages == 0) {
224 end = 0;
225 } else if (md->num_pages > EFI_PAGES_MAX ||
226 EFI_PAGES_MAX - md->num_pages <
227 (md->phys_addr >> EFI_PAGE_SHIFT)) {
228 end_hi = (md->num_pages & OVERFLOW_ADDR_MASK)
229 >> OVERFLOW_ADDR_SHIFT;
230
231 if ((md->phys_addr & U64_HIGH_BIT) && !(end & U64_HIGH_BIT))
232 end_hi += 1;
233 } else {
234 return true;
235 }
236
237 pr_warn_once(FW_BUG "Invalid EFI memory map entries:\n");
238
239 if (end_hi) {
240 pr_warn("mem%02u: %s range=[0x%016llx-0x%llx%016llx] (invalid)\n",
241 i, efi_md_typeattr_format(buf, sizeof(buf), md),
242 md->phys_addr, end_hi, end);
243 } else {
244 pr_warn("mem%02u: %s range=[0x%016llx-0x%016llx] (invalid)\n",
245 i, efi_md_typeattr_format(buf, sizeof(buf), md),
246 md->phys_addr, end);
247 }
248 return false;
249}
250
251static void __init efi_clean_memmap(void)
252{
253 efi_memory_desc_t *out = efi.memmap.map;
254 const efi_memory_desc_t *in = out;
255 const efi_memory_desc_t *end = efi.memmap.map_end;
256 int i, n_removal;
257
258 for (i = n_removal = 0; in < end; i++) {
259 if (efi_memmap_entry_valid(in, i)) {
260 if (out != in)
261 memcpy(out, in, efi.memmap.desc_size);
262 out = (void *)out + efi.memmap.desc_size;
263 } else {
264 n_removal++;
265 }
266 in = (void *)in + efi.memmap.desc_size;
267 }
268
269 if (n_removal > 0) {
270 u64 size = efi.memmap.nr_map - n_removal;
271
272 pr_warn("Removing %d invalid memory map entries.\n", n_removal);
273 efi_memmap_install(efi.memmap.phys_map, size);
274 }
275}
276
213void __init efi_print_memmap(void) 277void __init efi_print_memmap(void)
214{ 278{
215 efi_memory_desc_t *md; 279 efi_memory_desc_t *md;
@@ -472,6 +536,8 @@ void __init efi_init(void)
472 } 536 }
473 } 537 }
474 538
539 efi_clean_memmap();
540
475 if (efi_enabled(EFI_DBG)) 541 if (efi_enabled(EFI_DBG))
476 efi_print_memmap(); 542 efi_print_memmap();
477} 543}
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 10aca63a50d7..30031d5293c4 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -214,7 +214,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
214 214
215 new_size = efi.memmap.desc_size * num_entries; 215 new_size = efi.memmap.desc_size * num_entries;
216 216
217 new_phys = memblock_alloc(new_size, 0); 217 new_phys = efi_memmap_alloc(num_entries);
218 if (!new_phys) { 218 if (!new_phys) {
219 pr_err("Could not allocate boot services memmap\n"); 219 pr_err("Could not allocate boot services memmap\n");
220 return; 220 return;
@@ -355,7 +355,7 @@ void __init efi_free_boot_services(void)
355 } 355 }
356 356
357 new_size = efi.memmap.desc_size * num_entries; 357 new_size = efi.memmap.desc_size * num_entries;
358 new_phys = memblock_alloc(new_size, 0); 358 new_phys = efi_memmap_alloc(num_entries);
359 if (!new_phys) { 359 if (!new_phys) {
360 pr_err("Failed to allocate new EFI memmap\n"); 360 pr_err("Failed to allocate new EFI memmap\n");
361 return; 361 return;
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index 61b5ed2b7d40..90e4f2a6625b 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -15,7 +15,7 @@ obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o
15obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o 15obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o
16obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o 16obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o
17# SPI Devices 17# SPI Devices
18obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_spidev.o 18obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_mrfld_spidev.o
19# I2C Devices 19# I2C Devices
20obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o 20obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o
21obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o 21obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
index 30c601b399ee..27186ad654c9 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c
@@ -11,6 +11,7 @@
11 * of the License. 11 * of the License.
12 */ 12 */
13 13
14#include <linux/err.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/sfi.h> 16#include <linux/sfi.h>
16#include <linux/spi/pxa2xx_spi.h> 17#include <linux/spi/pxa2xx_spi.h>
@@ -34,6 +35,9 @@ static void __init *spidev_platform_data(void *info)
34{ 35{
35 struct spi_board_info *spi_info = info; 36 struct spi_board_info *spi_info = info;
36 37
38 if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
39 return ERR_PTR(-ENODEV);
40
37 spi_info->mode = SPI_MODE_0; 41 spi_info->mode = SPI_MODE_0;
38 spi_info->controller_data = &spidev_spi_chip; 42 spi_info->controller_data = &spidev_spi_chip;
39 43
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index a9fafb5c8738..a0b36a9d5df1 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -48,7 +48,7 @@ int __init pci_xen_swiotlb_detect(void)
48 * activate this IOMMU. If running as PV privileged, activate it 48 * activate this IOMMU. If running as PV privileged, activate it
49 * irregardless. 49 * irregardless.
50 */ 50 */
51 if ((xen_initial_domain() || swiotlb || swiotlb_force)) 51 if (xen_initial_domain() || swiotlb || swiotlb_force == SWIOTLB_FORCE)
52 xen_swiotlb = 1; 52 xen_swiotlb = 1;
53 53
54 /* If we are running under Xen, we MUST disable the native SWIOTLB. 54 /* If we are running under Xen, we MUST disable the native SWIOTLB.
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 8c394e30e5fe..f3f7b41116f7 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -713,10 +713,9 @@ static void __init xen_reserve_xen_mfnlist(void)
713 size = PFN_PHYS(xen_start_info->nr_p2m_frames); 713 size = PFN_PHYS(xen_start_info->nr_p2m_frames);
714 } 714 }
715 715
716 if (!xen_is_e820_reserved(start, size)) { 716 memblock_reserve(start, size);
717 memblock_reserve(start, size); 717 if (!xen_is_e820_reserved(start, size))
718 return; 718 return;
719 }
720 719
721#ifdef CONFIG_X86_32 720#ifdef CONFIG_X86_32
722 /* 721 /*
@@ -727,6 +726,7 @@ static void __init xen_reserve_xen_mfnlist(void)
727 BUG(); 726 BUG();
728#else 727#else
729 xen_relocate_p2m(); 728 xen_relocate_p2m();
729 memblock_free(start, size);
730#endif 730#endif
731} 731}
732 732
diff --git a/block/blk-lib.c b/block/blk-lib.c
index ed89c8f4b2a0..f8c82a9b4012 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -301,13 +301,6 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
301 if ((sector | nr_sects) & bs_mask) 301 if ((sector | nr_sects) & bs_mask)
302 return -EINVAL; 302 return -EINVAL;
303 303
304 if (discard) {
305 ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask,
306 BLKDEV_DISCARD_ZERO, biop);
307 if (ret == 0 || (ret && ret != -EOPNOTSUPP))
308 goto out;
309 }
310
311 ret = __blkdev_issue_write_zeroes(bdev, sector, nr_sects, gfp_mask, 304 ret = __blkdev_issue_write_zeroes(bdev, sector, nr_sects, gfp_mask,
312 biop); 305 biop);
313 if (ret == 0 || (ret && ret != -EOPNOTSUPP)) 306 if (ret == 0 || (ret && ret != -EOPNOTSUPP))
@@ -370,6 +363,12 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
370 struct bio *bio = NULL; 363 struct bio *bio = NULL;
371 struct blk_plug plug; 364 struct blk_plug plug;
372 365
366 if (discard) {
367 if (!blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask,
368 BLKDEV_DISCARD_ZERO))
369 return 0;
370 }
371
373 blk_start_plug(&plug); 372 blk_start_plug(&plug);
374 ret = __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask, 373 ret = __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask,
375 &bio, discard); 374 &bio, discard);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a8e67a155d04..c3400b5444a7 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -912,7 +912,6 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
912static void blk_mq_process_rq_list(struct blk_mq_hw_ctx *hctx) 912static void blk_mq_process_rq_list(struct blk_mq_hw_ctx *hctx)
913{ 913{
914 LIST_HEAD(rq_list); 914 LIST_HEAD(rq_list);
915 LIST_HEAD(driver_list);
916 915
917 if (unlikely(blk_mq_hctx_stopped(hctx))) 916 if (unlikely(blk_mq_hctx_stopped(hctx)))
918 return; 917 return;
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 6e82769f4042..f0a9c07b4c7a 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -544,6 +544,8 @@ static inline bool may_queue(struct rq_wb *rwb, struct rq_wait *rqw,
544 * the timer to kick off queuing again. 544 * the timer to kick off queuing again.
545 */ 545 */
546static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock) 546static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
547 __releases(lock)
548 __acquires(lock)
547{ 549{
548 struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd()); 550 struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd());
549 DEFINE_WAIT(wait); 551 DEFINE_WAIT(wait);
@@ -558,13 +560,12 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
558 if (may_queue(rwb, rqw, &wait, rw)) 560 if (may_queue(rwb, rqw, &wait, rw))
559 break; 561 break;
560 562
561 if (lock) 563 if (lock) {
562 spin_unlock_irq(lock); 564 spin_unlock_irq(lock);
563 565 io_schedule();
564 io_schedule();
565
566 if (lock)
567 spin_lock_irq(lock); 566 spin_lock_irq(lock);
567 } else
568 io_schedule();
568 } while (1); 569 } while (1);
569 570
570 finish_wait(&rqw->wait, &wait); 571 finish_wait(&rqw->wait, &wait);
@@ -595,7 +596,7 @@ static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio)
595 * in an irq held spinlock, if it holds one when calling this function. 596 * in an irq held spinlock, if it holds one when calling this function.
596 * If we do sleep, we'll release and re-grab it. 597 * If we do sleep, we'll release and re-grab it.
597 */ 598 */
598unsigned int wbt_wait(struct rq_wb *rwb, struct bio *bio, spinlock_t *lock) 599enum wbt_flags wbt_wait(struct rq_wb *rwb, struct bio *bio, spinlock_t *lock)
599{ 600{
600 unsigned int ret = 0; 601 unsigned int ret = 0;
601 602
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 472211fa183a..3bd15d8095b1 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -16,7 +16,7 @@
16static inline sector_t blk_zone_start(struct request_queue *q, 16static inline sector_t blk_zone_start(struct request_queue *q,
17 sector_t sector) 17 sector_t sector)
18{ 18{
19 sector_t zone_mask = blk_queue_zone_size(q) - 1; 19 sector_t zone_mask = blk_queue_zone_sectors(q) - 1;
20 20
21 return sector & ~zone_mask; 21 return sector & ~zone_mask;
22} 22}
@@ -222,7 +222,7 @@ int blkdev_reset_zones(struct block_device *bdev,
222 return -EINVAL; 222 return -EINVAL;
223 223
224 /* Check alignment (handle eventual smaller last zone) */ 224 /* Check alignment (handle eventual smaller last zone) */
225 zone_sectors = blk_queue_zone_size(q); 225 zone_sectors = blk_queue_zone_sectors(q);
226 if (sector & (zone_sectors - 1)) 226 if (sector & (zone_sectors - 1))
227 return -EINVAL; 227 return -EINVAL;
228 228
diff --git a/block/partition-generic.c b/block/partition-generic.c
index d7beb6bbbf66..7afb9907821f 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -434,7 +434,7 @@ static bool part_zone_aligned(struct gendisk *disk,
434 struct block_device *bdev, 434 struct block_device *bdev,
435 sector_t from, sector_t size) 435 sector_t from, sector_t size)
436{ 436{
437 unsigned int zone_size = bdev_zone_size(bdev); 437 unsigned int zone_sectors = bdev_zone_sectors(bdev);
438 438
439 /* 439 /*
440 * If this function is called, then the disk is a zoned block device 440 * If this function is called, then the disk is a zoned block device
@@ -446,7 +446,7 @@ static bool part_zone_aligned(struct gendisk *disk,
446 * regular block devices (no zone operation) and their zone size will 446 * regular block devices (no zone operation) and their zone size will
447 * be reported as 0. Allow this case. 447 * be reported as 0. Allow this case.
448 */ 448 */
449 if (!zone_size) 449 if (!zone_sectors)
450 return true; 450 return true;
451 451
452 /* 452 /*
@@ -455,24 +455,24 @@ static bool part_zone_aligned(struct gendisk *disk,
455 * use it. Check the zone size too: it should be a power of 2 number 455 * use it. Check the zone size too: it should be a power of 2 number
456 * of sectors. 456 * of sectors.
457 */ 457 */
458 if (WARN_ON_ONCE(!is_power_of_2(zone_size))) { 458 if (WARN_ON_ONCE(!is_power_of_2(zone_sectors))) {
459 u32 rem; 459 u32 rem;
460 460
461 div_u64_rem(from, zone_size, &rem); 461 div_u64_rem(from, zone_sectors, &rem);
462 if (rem) 462 if (rem)
463 return false; 463 return false;
464 if ((from + size) < get_capacity(disk)) { 464 if ((from + size) < get_capacity(disk)) {
465 div_u64_rem(size, zone_size, &rem); 465 div_u64_rem(size, zone_sectors, &rem);
466 if (rem) 466 if (rem)
467 return false; 467 return false;
468 } 468 }
469 469
470 } else { 470 } else {
471 471
472 if (from & (zone_size - 1)) 472 if (from & (zone_sectors - 1))
473 return false; 473 return false;
474 if ((from + size) < get_capacity(disk) && 474 if ((from + size) < get_capacity(disk) &&
475 (size & (zone_size - 1))) 475 (size & (zone_sectors - 1)))
476 return false; 476 return false;
477 477
478 } 478 }
diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
index 13caebd679f5..8c4e0a18460a 100644
--- a/drivers/acpi/acpi_watchdog.c
+++ b/drivers/acpi/acpi_watchdog.c
@@ -114,7 +114,7 @@ void __init acpi_watchdog_init(void)
114 pdev = platform_device_register_simple("wdat_wdt", PLATFORM_DEVID_NONE, 114 pdev = platform_device_register_simple("wdat_wdt", PLATFORM_DEVID_NONE,
115 resources, nresources); 115 resources, nresources);
116 if (IS_ERR(pdev)) 116 if (IS_ERR(pdev))
117 pr_err("Failed to create platform device\n"); 117 pr_err("Device creation failed: %ld\n", PTR_ERR(pdev));
118 118
119 kfree(resources); 119 kfree(resources);
120 120
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f8d65647ea79..fb19e1cdb641 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -98,7 +98,15 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
98 if (check_children && list_empty(&adev->children)) 98 if (check_children && list_empty(&adev->children))
99 return -ENODEV; 99 return -ENODEV;
100 100
101 return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; 101 /*
102 * If the device has a _HID (or _CID) returning a valid ACPI/PNP
103 * device ID, it is better to make it look less attractive here, so that
104 * the other device with the same _ADR value (that may not have a valid
105 * device ID) can be matched going forward. [This means a second spec
106 * violation in a row, so whatever we do here is best effort anyway.]
107 */
108 return sta_present && list_empty(&adev->pnp.ids) ?
109 FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
102} 110}
103 111
104struct acpi_device *acpi_find_child_device(struct acpi_device *parent, 112struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
@@ -250,7 +258,6 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
250 return 0; 258 return 0;
251 259
252 err: 260 err:
253 acpi_dma_deconfigure(dev);
254 ACPI_COMPANION_SET(dev, NULL); 261 ACPI_COMPANION_SET(dev, NULL);
255 put_device(dev); 262 put_device(dev);
256 put_device(&acpi_dev->dev); 263 put_device(&acpi_dev->dev);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 1b41a2739dac..0c452265c111 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -37,6 +37,7 @@ void acpi_amba_init(void);
37static inline void acpi_amba_init(void) {} 37static inline void acpi_amba_init(void) {}
38#endif 38#endif
39int acpi_sysfs_init(void); 39int acpi_sysfs_init(void);
40void acpi_gpe_apply_masked_gpes(void);
40void acpi_container_init(void); 41void acpi_container_init(void);
41void acpi_memory_hotplug_init(void); 42void acpi_memory_hotplug_init(void);
42#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 43#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 45dec874ea55..192691880d55 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2074,6 +2074,7 @@ int __init acpi_scan_init(void)
2074 } 2074 }
2075 } 2075 }
2076 2076
2077 acpi_gpe_apply_masked_gpes();
2077 acpi_update_all_gpes(); 2078 acpi_update_all_gpes();
2078 acpi_ec_ecdt_start(); 2079 acpi_ec_ecdt_start();
2079 2080
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 703c26e7022c..cf05ae973381 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -708,6 +708,62 @@ end:
708 return result ? result : size; 708 return result ? result : size;
709} 709}
710 710
711/*
712 * A Quirk Mechanism for GPE Flooding Prevention:
713 *
714 * Quirks may be needed to prevent GPE flooding on a specific GPE. The
715 * flooding typically cannot be detected and automatically prevented by
716 * ACPI_GPE_DISPATCH_NONE check because there is a _Lxx/_Exx prepared in
717 * the AML tables. This normally indicates a feature gap in Linux, thus
718 * instead of providing endless quirk tables, we provide a boot parameter
719 * for those who want this quirk. For example, if the users want to prevent
720 * the GPE flooding for GPE 00, they need to specify the following boot
721 * parameter:
722 * acpi_mask_gpe=0x00
723 * The masking status can be modified by the following runtime controlling
724 * interface:
725 * echo unmask > /sys/firmware/acpi/interrupts/gpe00
726 */
727
728/*
729 * Currently, the GPE flooding prevention only supports to mask the GPEs
730 * numbered from 00 to 7f.
731 */
732#define ACPI_MASKABLE_GPE_MAX 0x80
733
734static u64 __initdata acpi_masked_gpes;
735
736static int __init acpi_gpe_set_masked_gpes(char *val)
737{
738 u8 gpe;
739
740 if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)
741 return -EINVAL;
742 acpi_masked_gpes |= ((u64)1<<gpe);
743
744 return 1;
745}
746__setup("acpi_mask_gpe=", acpi_gpe_set_masked_gpes);
747
748void __init acpi_gpe_apply_masked_gpes(void)
749{
750 acpi_handle handle;
751 acpi_status status;
752 u8 gpe;
753
754 for (gpe = 0;
755 gpe < min_t(u8, ACPI_MASKABLE_GPE_MAX, acpi_current_gpe_count);
756 gpe++) {
757 if (acpi_masked_gpes & ((u64)1<<gpe)) {
758 status = acpi_get_gpe_device(gpe, &handle);
759 if (ACPI_SUCCESS(status)) {
760 pr_info("Masking GPE 0x%x.\n", gpe);
761 (void)acpi_mask_gpe(handle, gpe, TRUE);
762 }
763 }
764 }
765}
766
711void acpi_irq_stats_init(void) 767void acpi_irq_stats_init(void)
712{ 768{
713 acpi_status status; 769 acpi_status status;
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index 4ef4c5caed4f..8a8e403644d6 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -132,9 +132,9 @@ config HT16K33
132 tristate "Holtek Ht16K33 LED controller with keyscan" 132 tristate "Holtek Ht16K33 LED controller with keyscan"
133 depends on FB && OF && I2C && INPUT 133 depends on FB && OF && I2C && INPUT
134 select FB_SYS_FOPS 134 select FB_SYS_FOPS
135 select FB_CFB_FILLRECT 135 select FB_SYS_FILLRECT
136 select FB_CFB_COPYAREA 136 select FB_SYS_COPYAREA
137 select FB_CFB_IMAGEBLIT 137 select FB_SYS_IMAGEBLIT
138 select INPUT_MATRIXKMAP 138 select INPUT_MATRIXKMAP
139 select FB_BACKLIGHT 139 select FB_BACKLIGHT
140 help 140 help
diff --git a/drivers/base/base.h b/drivers/base/base.h
index ada9dce34e6d..e19b1008e5fb 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -141,8 +141,6 @@ extern void device_unblock_probing(void);
141extern struct kset *devices_kset; 141extern struct kset *devices_kset;
142extern void devices_kset_move_last(struct device *dev); 142extern void devices_kset_move_last(struct device *dev);
143 143
144extern struct device_attribute dev_attr_deferred_probe;
145
146#if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 144#if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS)
147extern void module_add_driver(struct module *mod, struct device_driver *drv); 145extern void module_add_driver(struct module *mod, struct device_driver *drv);
148extern void module_remove_driver(struct device_driver *drv); 146extern void module_remove_driver(struct device_driver *drv);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 020ea7f05520..8c25e68e67d7 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1060,14 +1060,8 @@ static int device_add_attrs(struct device *dev)
1060 goto err_remove_dev_groups; 1060 goto err_remove_dev_groups;
1061 } 1061 }
1062 1062
1063 error = device_create_file(dev, &dev_attr_deferred_probe);
1064 if (error)
1065 goto err_remove_online;
1066
1067 return 0; 1063 return 0;
1068 1064
1069 err_remove_online:
1070 device_remove_file(dev, &dev_attr_online);
1071 err_remove_dev_groups: 1065 err_remove_dev_groups:
1072 device_remove_groups(dev, dev->groups); 1066 device_remove_groups(dev, dev->groups);
1073 err_remove_type_groups: 1067 err_remove_type_groups:
@@ -1085,7 +1079,6 @@ static void device_remove_attrs(struct device *dev)
1085 struct class *class = dev->class; 1079 struct class *class = dev->class;
1086 const struct device_type *type = dev->type; 1080 const struct device_type *type = dev->type;
1087 1081
1088 device_remove_file(dev, &dev_attr_deferred_probe);
1089 device_remove_file(dev, &dev_attr_online); 1082 device_remove_file(dev, &dev_attr_online);
1090 device_remove_groups(dev, dev->groups); 1083 device_remove_groups(dev, dev->groups);
1091 1084
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a8b258e5407b..a1fbf55c4d3a 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -53,19 +53,6 @@ static LIST_HEAD(deferred_probe_pending_list);
53static LIST_HEAD(deferred_probe_active_list); 53static LIST_HEAD(deferred_probe_active_list);
54static atomic_t deferred_trigger_count = ATOMIC_INIT(0); 54static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
55 55
56static ssize_t deferred_probe_show(struct device *dev,
57 struct device_attribute *attr, char *buf)
58{
59 bool value;
60
61 mutex_lock(&deferred_probe_mutex);
62 value = !list_empty(&dev->p->deferred_probe);
63 mutex_unlock(&deferred_probe_mutex);
64
65 return sprintf(buf, "%d\n", value);
66}
67DEVICE_ATTR_RO(deferred_probe);
68
69/* 56/*
70 * In some cases, like suspend to RAM or hibernation, It might be reasonable 57 * In some cases, like suspend to RAM or hibernation, It might be reasonable
71 * to prohibit probing of devices as it could be unsafe. 58 * to prohibit probing of devices as it could be unsafe.
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index a5e1262b964b..2997026b4dfb 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -626,6 +626,7 @@ static int genpd_runtime_resume(struct device *dev)
626 626
627 out: 627 out:
628 /* Measure resume latency. */ 628 /* Measure resume latency. */
629 time_start = 0;
629 if (timed && runtime_pm) 630 if (timed && runtime_pm)
630 time_start = ktime_get(); 631 time_start = ktime_get();
631 632
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 38c576f76d36..9fd06eeb1a17 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -271,7 +271,7 @@ static inline int sock_send_bvec(struct nbd_device *nbd, int index,
271static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) 271static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
272{ 272{
273 struct request *req = blk_mq_rq_from_pdu(cmd); 273 struct request *req = blk_mq_rq_from_pdu(cmd);
274 int result, flags; 274 int result;
275 struct nbd_request request; 275 struct nbd_request request;
276 unsigned long size = blk_rq_bytes(req); 276 unsigned long size = blk_rq_bytes(req);
277 struct bio *bio; 277 struct bio *bio;
@@ -310,7 +310,6 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
310 if (type != NBD_CMD_WRITE) 310 if (type != NBD_CMD_WRITE)
311 return 0; 311 return 0;
312 312
313 flags = 0;
314 bio = req->bio; 313 bio = req->bio;
315 while (bio) { 314 while (bio) {
316 struct bio *next = bio->bi_next; 315 struct bio *next = bio->bi_next;
@@ -319,9 +318,8 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
319 318
320 bio_for_each_segment(bvec, bio, iter) { 319 bio_for_each_segment(bvec, bio, iter) {
321 bool is_last = !next && bio_iter_last(bvec, iter); 320 bool is_last = !next && bio_iter_last(bvec, iter);
321 int flags = is_last ? 0 : MSG_MORE;
322 322
323 if (is_last)
324 flags = MSG_MORE;
325 dev_dbg(nbd_to_dev(nbd), "request %p: sending %d bytes data\n", 323 dev_dbg(nbd_to_dev(nbd), "request %p: sending %d bytes data\n",
326 cmd, bvec.bv_len); 324 cmd, bvec.bv_len);
327 result = sock_send_bvec(nbd, index, &bvec, flags); 325 result = sock_send_bvec(nbd, index, &bvec, flags);
@@ -1042,6 +1040,7 @@ static int __init nbd_init(void)
1042 return -ENOMEM; 1040 return -ENOMEM;
1043 1041
1044 for (i = 0; i < nbds_max; i++) { 1042 for (i = 0; i < nbds_max; i++) {
1043 struct request_queue *q;
1045 struct gendisk *disk = alloc_disk(1 << part_shift); 1044 struct gendisk *disk = alloc_disk(1 << part_shift);
1046 if (!disk) 1045 if (!disk)
1047 goto out; 1046 goto out;
@@ -1067,12 +1066,13 @@ static int __init nbd_init(void)
1067 * every gendisk to have its very own request_queue struct. 1066 * every gendisk to have its very own request_queue struct.
1068 * These structs are big so we dynamically allocate them. 1067 * These structs are big so we dynamically allocate them.
1069 */ 1068 */
1070 disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set); 1069 q = blk_mq_init_queue(&nbd_dev[i].tag_set);
1071 if (!disk->queue) { 1070 if (IS_ERR(q)) {
1072 blk_mq_free_tag_set(&nbd_dev[i].tag_set); 1071 blk_mq_free_tag_set(&nbd_dev[i].tag_set);
1073 put_disk(disk); 1072 put_disk(disk);
1074 goto out; 1073 goto out;
1075 } 1074 }
1075 disk->queue = q;
1076 1076
1077 /* 1077 /*
1078 * Tell the block layer that we are not a rotational device 1078 * Tell the block layer that we are not a rotational device
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 5545a679abd8..10332c24f961 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -56,6 +56,7 @@ struct virtblk_req {
56 struct virtio_blk_outhdr out_hdr; 56 struct virtio_blk_outhdr out_hdr;
57 struct virtio_scsi_inhdr in_hdr; 57 struct virtio_scsi_inhdr in_hdr;
58 u8 status; 58 u8 status;
59 u8 sense[SCSI_SENSE_BUFFERSIZE];
59 struct scatterlist sg[]; 60 struct scatterlist sg[];
60}; 61};
61 62
@@ -102,7 +103,8 @@ static int __virtblk_add_req(struct virtqueue *vq,
102 } 103 }
103 104
104 if (type == cpu_to_virtio32(vq->vdev, VIRTIO_BLK_T_SCSI_CMD)) { 105 if (type == cpu_to_virtio32(vq->vdev, VIRTIO_BLK_T_SCSI_CMD)) {
105 sg_init_one(&sense, vbr->req->sense, SCSI_SENSE_BUFFERSIZE); 106 memcpy(vbr->sense, vbr->req->sense, SCSI_SENSE_BUFFERSIZE);
107 sg_init_one(&sense, vbr->sense, SCSI_SENSE_BUFFERSIZE);
106 sgs[num_out + num_in++] = &sense; 108 sgs[num_out + num_in++] = &sense;
107 sg_init_one(&inhdr, &vbr->in_hdr, sizeof(vbr->in_hdr)); 109 sg_init_one(&inhdr, &vbr->in_hdr, sizeof(vbr->in_hdr));
108 sgs[num_out + num_in++] = &inhdr; 110 sgs[num_out + num_in++] = &inhdr;
@@ -628,11 +630,12 @@ static int virtblk_probe(struct virtio_device *vdev)
628 if (err) 630 if (err)
629 goto out_put_disk; 631 goto out_put_disk;
630 632
631 q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set); 633 q = blk_mq_init_queue(&vblk->tag_set);
632 if (IS_ERR(q)) { 634 if (IS_ERR(q)) {
633 err = -ENOMEM; 635 err = -ENOMEM;
634 goto out_free_tags; 636 goto out_free_tags;
635 } 637 }
638 vblk->disk->queue = q;
636 639
637 q->queuedata = vblk; 640 q->queuedata = vblk;
638 641
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 15f58ab44d0b..e5ab7d9e8c45 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -25,6 +25,7 @@
25#include <linux/genhd.h> 25#include <linux/genhd.h>
26#include <linux/highmem.h> 26#include <linux/highmem.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/backing-dev.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
30#include <linux/err.h> 31#include <linux/err.h>
@@ -112,6 +113,14 @@ static inline bool is_partial_io(struct bio_vec *bvec)
112 return bvec->bv_len != PAGE_SIZE; 113 return bvec->bv_len != PAGE_SIZE;
113} 114}
114 115
116static void zram_revalidate_disk(struct zram *zram)
117{
118 revalidate_disk(zram->disk);
119 /* revalidate_disk reset the BDI_CAP_STABLE_WRITES so set again */
120 zram->disk->queue->backing_dev_info.capabilities |=
121 BDI_CAP_STABLE_WRITES;
122}
123
115/* 124/*
116 * Check if request is within bounds and aligned on zram logical blocks. 125 * Check if request is within bounds and aligned on zram logical blocks.
117 */ 126 */
@@ -1095,15 +1104,9 @@ static ssize_t disksize_store(struct device *dev,
1095 zram->comp = comp; 1104 zram->comp = comp;
1096 zram->disksize = disksize; 1105 zram->disksize = disksize;
1097 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); 1106 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
1107 zram_revalidate_disk(zram);
1098 up_write(&zram->init_lock); 1108 up_write(&zram->init_lock);
1099 1109
1100 /*
1101 * Revalidate disk out of the init_lock to avoid lockdep splat.
1102 * It's okay because disk's capacity is protected by init_lock
1103 * so that revalidate_disk always sees up-to-date capacity.
1104 */
1105 revalidate_disk(zram->disk);
1106
1107 return len; 1110 return len;
1108 1111
1109out_destroy_comp: 1112out_destroy_comp:
@@ -1149,7 +1152,7 @@ static ssize_t reset_store(struct device *dev,
1149 /* Make sure all the pending I/O are finished */ 1152 /* Make sure all the pending I/O are finished */
1150 fsync_bdev(bdev); 1153 fsync_bdev(bdev);
1151 zram_reset_device(zram); 1154 zram_reset_device(zram);
1152 revalidate_disk(zram->disk); 1155 zram_revalidate_disk(zram);
1153 bdput(bdev); 1156 bdput(bdev);
1154 1157
1155 mutex_lock(&bdev->bd_mutex); 1158 mutex_lock(&bdev->bd_mutex);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 5bb1985ec484..6d9cc2d39d22 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -381,9 +381,6 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
381 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */ 381 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
382 int err = 0; 382 int err = 0;
383 383
384 if (!pfn_valid(PFN_DOWN(p)))
385 return -EIO;
386
387 read = 0; 384 read = 0;
388 if (p < (unsigned long) high_memory) { 385 if (p < (unsigned long) high_memory) {
389 low_count = count; 386 low_count = count;
@@ -412,6 +409,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
412 * by the kernel or data corruption may occur 409 * by the kernel or data corruption may occur
413 */ 410 */
414 kbuf = xlate_dev_kmem_ptr((void *)p); 411 kbuf = xlate_dev_kmem_ptr((void *)p);
412 if (!virt_addr_valid(kbuf))
413 return -ENXIO;
415 414
416 if (copy_to_user(buf, kbuf, sz)) 415 if (copy_to_user(buf, kbuf, sz))
417 return -EFAULT; 416 return -EFAULT;
@@ -482,6 +481,8 @@ static ssize_t do_write_kmem(unsigned long p, const char __user *buf,
482 * corruption may occur. 481 * corruption may occur.
483 */ 482 */
484 ptr = xlate_dev_kmem_ptr((void *)p); 483 ptr = xlate_dev_kmem_ptr((void *)p);
484 if (!virt_addr_valid(ptr))
485 return -ENXIO;
485 486
486 copied = copy_from_user(ptr, buf, sz); 487 copied = copy_from_user(ptr, buf, sz);
487 if (copied) { 488 if (copied) {
@@ -512,9 +513,6 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,
512 char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ 513 char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
513 int err = 0; 514 int err = 0;
514 515
515 if (!pfn_valid(PFN_DOWN(p)))
516 return -EIO;
517
518 if (p < (unsigned long) high_memory) { 516 if (p < (unsigned long) high_memory) {
519 unsigned long to_write = min_t(unsigned long, count, 517 unsigned long to_write = min_t(unsigned long, count,
520 (unsigned long)high_memory - p); 518 (unsigned long)high_memory - p);
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 02819e0703c8..87885d146dbb 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -290,6 +290,7 @@ static int register_device(int minor, struct pp_struct *pp)
290 struct pardevice *pdev = NULL; 290 struct pardevice *pdev = NULL;
291 char *name; 291 char *name;
292 struct pardev_cb ppdev_cb; 292 struct pardev_cb ppdev_cb;
293 int rc = 0;
293 294
294 name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor); 295 name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
295 if (name == NULL) 296 if (name == NULL)
@@ -298,8 +299,8 @@ static int register_device(int minor, struct pp_struct *pp)
298 port = parport_find_number(minor); 299 port = parport_find_number(minor);
299 if (!port) { 300 if (!port) {
300 pr_warn("%s: no associated port!\n", name); 301 pr_warn("%s: no associated port!\n", name);
301 kfree(name); 302 rc = -ENXIO;
302 return -ENXIO; 303 goto err;
303 } 304 }
304 305
305 memset(&ppdev_cb, 0, sizeof(ppdev_cb)); 306 memset(&ppdev_cb, 0, sizeof(ppdev_cb));
@@ -308,16 +309,18 @@ static int register_device(int minor, struct pp_struct *pp)
308 ppdev_cb.private = pp; 309 ppdev_cb.private = pp;
309 pdev = parport_register_dev_model(port, name, &ppdev_cb, minor); 310 pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
310 parport_put_port(port); 311 parport_put_port(port);
311 kfree(name);
312 312
313 if (!pdev) { 313 if (!pdev) {
314 pr_warn("%s: failed to register device!\n", name); 314 pr_warn("%s: failed to register device!\n", name);
315 return -ENXIO; 315 rc = -ENXIO;
316 goto err;
316 } 317 }
317 318
318 pp->pdev = pdev; 319 pp->pdev = pdev;
319 dev_dbg(&pdev->dev, "registered pardevice\n"); 320 dev_dbg(&pdev->dev, "registered pardevice\n");
320 return 0; 321err:
322 kfree(name);
323 return rc;
321} 324}
322 325
323static enum ieee1284_phase init_phase(int mode) 326static enum ieee1284_phase init_phase(int mode)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 8b00e79c2683..17857beb4892 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1862,7 +1862,7 @@ static void config_work_handler(struct work_struct *work)
1862{ 1862{
1863 struct ports_device *portdev; 1863 struct ports_device *portdev;
1864 1864
1865 portdev = container_of(work, struct ports_device, control_work); 1865 portdev = container_of(work, struct ports_device, config_work);
1866 if (!use_multiport(portdev)) { 1866 if (!use_multiport(portdev)) {
1867 struct virtio_device *vdev; 1867 struct virtio_device *vdev;
1868 struct port *port; 1868 struct port *port;
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
index 5eb05dbf59b8..fc585f370549 100644
--- a/drivers/clk/clk-stm32f4.c
+++ b/drivers/clk/clk-stm32f4.c
@@ -768,5 +768,5 @@ fail:
768 kfree(clks); 768 kfree(clks);
769 iounmap(base); 769 iounmap(base);
770} 770}
771CLK_OF_DECLARE(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init); 771CLK_OF_DECLARE_DRIVER(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init);
772CLK_OF_DECLARE(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init); 772CLK_OF_DECLARE_DRIVER(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init);
diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 9375777776d9..b533f99550e1 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -37,12 +37,14 @@
37 * @smstpcr: module stop control register 37 * @smstpcr: module stop control register
38 * @mstpsr: module stop status register (optional) 38 * @mstpsr: module stop status register (optional)
39 * @lock: protects writes to SMSTPCR 39 * @lock: protects writes to SMSTPCR
40 * @width_8bit: registers are 8-bit, not 32-bit
40 */ 41 */
41struct mstp_clock_group { 42struct mstp_clock_group {
42 struct clk_onecell_data data; 43 struct clk_onecell_data data;
43 void __iomem *smstpcr; 44 void __iomem *smstpcr;
44 void __iomem *mstpsr; 45 void __iomem *mstpsr;
45 spinlock_t lock; 46 spinlock_t lock;
47 bool width_8bit;
46}; 48};
47 49
48/** 50/**
@@ -59,6 +61,18 @@ struct mstp_clock {
59 61
60#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw) 62#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw)
61 63
64static inline u32 cpg_mstp_read(struct mstp_clock_group *group,
65 u32 __iomem *reg)
66{
67 return group->width_8bit ? readb(reg) : clk_readl(reg);
68}
69
70static inline void cpg_mstp_write(struct mstp_clock_group *group, u32 val,
71 u32 __iomem *reg)
72{
73 group->width_8bit ? writeb(val, reg) : clk_writel(val, reg);
74}
75
62static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) 76static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
63{ 77{
64 struct mstp_clock *clock = to_mstp_clock(hw); 78 struct mstp_clock *clock = to_mstp_clock(hw);
@@ -70,12 +84,12 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
70 84
71 spin_lock_irqsave(&group->lock, flags); 85 spin_lock_irqsave(&group->lock, flags);
72 86
73 value = clk_readl(group->smstpcr); 87 value = cpg_mstp_read(group, group->smstpcr);
74 if (enable) 88 if (enable)
75 value &= ~bitmask; 89 value &= ~bitmask;
76 else 90 else
77 value |= bitmask; 91 value |= bitmask;
78 clk_writel(value, group->smstpcr); 92 cpg_mstp_write(group, value, group->smstpcr);
79 93
80 spin_unlock_irqrestore(&group->lock, flags); 94 spin_unlock_irqrestore(&group->lock, flags);
81 95
@@ -83,7 +97,7 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
83 return 0; 97 return 0;
84 98
85 for (i = 1000; i > 0; --i) { 99 for (i = 1000; i > 0; --i) {
86 if (!(clk_readl(group->mstpsr) & bitmask)) 100 if (!(cpg_mstp_read(group, group->mstpsr) & bitmask))
87 break; 101 break;
88 cpu_relax(); 102 cpu_relax();
89 } 103 }
@@ -114,9 +128,9 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
114 u32 value; 128 u32 value;
115 129
116 if (group->mstpsr) 130 if (group->mstpsr)
117 value = clk_readl(group->mstpsr); 131 value = cpg_mstp_read(group, group->mstpsr);
118 else 132 else
119 value = clk_readl(group->smstpcr); 133 value = cpg_mstp_read(group, group->smstpcr);
120 134
121 return !(value & BIT(clock->bit_index)); 135 return !(value & BIT(clock->bit_index));
122} 136}
@@ -188,6 +202,9 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
188 return; 202 return;
189 } 203 }
190 204
205 if (of_device_is_compatible(np, "renesas,r7s72100-mstp-clocks"))
206 group->width_8bit = true;
207
191 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) 208 for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
192 clks[i] = ERR_PTR(-ENOENT); 209 clks[i] = ERR_PTR(-ENOENT);
193 210
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 8c8b495cbf0d..cdc092a1d9ef 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -586,7 +586,7 @@ static const struct samsung_gate_clock exynos5800_gate_clks[] __initconst = {
586 GATE(CLK_ACLK550_CAM, "aclk550_cam", "mout_user_aclk550_cam", 586 GATE(CLK_ACLK550_CAM, "aclk550_cam", "mout_user_aclk550_cam",
587 GATE_BUS_TOP, 24, 0, 0), 587 GATE_BUS_TOP, 24, 0, 0),
588 GATE(CLK_ACLK432_SCALER, "aclk432_scaler", "mout_user_aclk432_scaler", 588 GATE(CLK_ACLK432_SCALER, "aclk432_scaler", "mout_user_aclk432_scaler",
589 GATE_BUS_TOP, 27, 0, 0), 589 GATE_BUS_TOP, 27, CLK_IS_CRITICAL, 0),
590}; 590};
591 591
592static const struct samsung_mux_clock exynos5420_mux_clks[] __initconst = { 592static const struct samsung_mux_clock exynos5420_mux_clks[] __initconst = {
@@ -956,20 +956,20 @@ static const struct samsung_gate_clock exynos5x_gate_clks[] __initconst = {
956 GATE(CLK_SMMU_G2D, "smmu_g2d", "aclk333_g2d", GATE_IP_G2D, 7, 0, 0), 956 GATE(CLK_SMMU_G2D, "smmu_g2d", "aclk333_g2d", GATE_IP_G2D, 7, 0, 0),
957 957
958 GATE(0, "aclk200_fsys", "mout_user_aclk200_fsys", 958 GATE(0, "aclk200_fsys", "mout_user_aclk200_fsys",
959 GATE_BUS_FSYS0, 9, CLK_IGNORE_UNUSED, 0), 959 GATE_BUS_FSYS0, 9, CLK_IS_CRITICAL, 0),
960 GATE(0, "aclk200_fsys2", "mout_user_aclk200_fsys2", 960 GATE(0, "aclk200_fsys2", "mout_user_aclk200_fsys2",
961 GATE_BUS_FSYS0, 10, CLK_IGNORE_UNUSED, 0), 961 GATE_BUS_FSYS0, 10, CLK_IGNORE_UNUSED, 0),
962 962
963 GATE(0, "aclk333_g2d", "mout_user_aclk333_g2d", 963 GATE(0, "aclk333_g2d", "mout_user_aclk333_g2d",
964 GATE_BUS_TOP, 0, CLK_IGNORE_UNUSED, 0), 964 GATE_BUS_TOP, 0, CLK_IGNORE_UNUSED, 0),
965 GATE(0, "aclk266_g2d", "mout_user_aclk266_g2d", 965 GATE(0, "aclk266_g2d", "mout_user_aclk266_g2d",
966 GATE_BUS_TOP, 1, CLK_IGNORE_UNUSED, 0), 966 GATE_BUS_TOP, 1, CLK_IS_CRITICAL, 0),
967 GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg", 967 GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg",
968 GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0), 968 GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0),
969 GATE(0, "aclk333_432_isp0", "mout_user_aclk333_432_isp0", 969 GATE(0, "aclk333_432_isp0", "mout_user_aclk333_432_isp0",
970 GATE_BUS_TOP, 5, 0, 0), 970 GATE_BUS_TOP, 5, 0, 0),
971 GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl", 971 GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl",
972 GATE_BUS_TOP, 6, CLK_IGNORE_UNUSED, 0), 972 GATE_BUS_TOP, 6, CLK_IS_CRITICAL, 0),
973 GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl", 973 GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl",
974 GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0), 974 GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0),
975 GATE(0, "aclk333_432_isp", "mout_user_aclk333_432_isp", 975 GATE(0, "aclk333_432_isp", "mout_user_aclk333_432_isp",
@@ -983,20 +983,20 @@ static const struct samsung_gate_clock exynos5x_gate_clks[] __initconst = {
983 GATE(0, "aclk166", "mout_user_aclk166", 983 GATE(0, "aclk166", "mout_user_aclk166",
984 GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0), 984 GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0),
985 GATE(CLK_ACLK333, "aclk333", "mout_user_aclk333", 985 GATE(CLK_ACLK333, "aclk333", "mout_user_aclk333",
986 GATE_BUS_TOP, 15, CLK_IGNORE_UNUSED, 0), 986 GATE_BUS_TOP, 15, CLK_IS_CRITICAL, 0),
987 GATE(0, "aclk400_isp", "mout_user_aclk400_isp", 987 GATE(0, "aclk400_isp", "mout_user_aclk400_isp",
988 GATE_BUS_TOP, 16, 0, 0), 988 GATE_BUS_TOP, 16, 0, 0),
989 GATE(0, "aclk400_mscl", "mout_user_aclk400_mscl", 989 GATE(0, "aclk400_mscl", "mout_user_aclk400_mscl",
990 GATE_BUS_TOP, 17, 0, 0), 990 GATE_BUS_TOP, 17, 0, 0),
991 GATE(0, "aclk200_disp1", "mout_user_aclk200_disp1", 991 GATE(0, "aclk200_disp1", "mout_user_aclk200_disp1",
992 GATE_BUS_TOP, 18, 0, 0), 992 GATE_BUS_TOP, 18, CLK_IS_CRITICAL, 0),
993 GATE(CLK_SCLK_MPHY_IXTAL24, "sclk_mphy_ixtal24", "mphy_refclk_ixtal24", 993 GATE(CLK_SCLK_MPHY_IXTAL24, "sclk_mphy_ixtal24", "mphy_refclk_ixtal24",
994 GATE_BUS_TOP, 28, 0, 0), 994 GATE_BUS_TOP, 28, 0, 0),
995 GATE(CLK_SCLK_HSIC_12M, "sclk_hsic_12m", "ff_hsic_12m", 995 GATE(CLK_SCLK_HSIC_12M, "sclk_hsic_12m", "ff_hsic_12m",
996 GATE_BUS_TOP, 29, 0, 0), 996 GATE_BUS_TOP, 29, 0, 0),
997 997
998 GATE(0, "aclk300_disp1", "mout_user_aclk300_disp1", 998 GATE(0, "aclk300_disp1", "mout_user_aclk300_disp1",
999 SRC_MASK_TOP2, 24, 0, 0), 999 SRC_MASK_TOP2, 24, CLK_IS_CRITICAL, 0),
1000 1000
1001 GATE(CLK_MAU_EPLL, "mau_epll", "mout_mau_epll_clk", 1001 GATE(CLK_MAU_EPLL, "mau_epll", "mout_mau_epll_clk",
1002 SRC_MASK_TOP7, 20, 0, 0), 1002 SRC_MASK_TOP7, 20, 0, 0),
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index 4da1dc2278bd..670ff0f25b67 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -495,6 +495,7 @@ static int exynos4_mct_dying_cpu(unsigned int cpu)
495 if (mct_int_type == MCT_INT_SPI) { 495 if (mct_int_type == MCT_INT_SPI) {
496 if (evt->irq != -1) 496 if (evt->irq != -1)
497 disable_irq_nosync(evt->irq); 497 disable_irq_nosync(evt->irq);
498 exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET);
498 } else { 499 } else {
499 disable_percpu_irq(mct_irqs[MCT_L0_IRQ]); 500 disable_percpu_irq(mct_irqs[MCT_L0_IRQ]);
500 } 501 }
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index bc97b6a4b1cf..7fcaf26e8f81 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -26,6 +26,8 @@ static const struct of_device_id machines[] __initconst = {
26 { .compatible = "allwinner,sun8i-a83t", }, 26 { .compatible = "allwinner,sun8i-a83t", },
27 { .compatible = "allwinner,sun8i-h3", }, 27 { .compatible = "allwinner,sun8i-h3", },
28 28
29 { .compatible = "apm,xgene-shadowcat", },
30
29 { .compatible = "arm,integrator-ap", }, 31 { .compatible = "arm,integrator-ap", },
30 { .compatible = "arm,integrator-cp", }, 32 { .compatible = "arm,integrator-cp", },
31 33
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 6acbd4af632e..f91c25718d16 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -857,13 +857,13 @@ static struct freq_attr *hwp_cpufreq_attrs[] = {
857 NULL, 857 NULL,
858}; 858};
859 859
860static void intel_pstate_hwp_set(const struct cpumask *cpumask) 860static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
861{ 861{
862 int min, hw_min, max, hw_max, cpu, range, adj_range; 862 int min, hw_min, max, hw_max, cpu, range, adj_range;
863 struct perf_limits *perf_limits = limits; 863 struct perf_limits *perf_limits = limits;
864 u64 value, cap; 864 u64 value, cap;
865 865
866 for_each_cpu(cpu, cpumask) { 866 for_each_cpu(cpu, policy->cpus) {
867 int max_perf_pct, min_perf_pct; 867 int max_perf_pct, min_perf_pct;
868 struct cpudata *cpu_data = all_cpu_data[cpu]; 868 struct cpudata *cpu_data = all_cpu_data[cpu];
869 s16 epp; 869 s16 epp;
@@ -949,7 +949,7 @@ skip_epp:
949static int intel_pstate_hwp_set_policy(struct cpufreq_policy *policy) 949static int intel_pstate_hwp_set_policy(struct cpufreq_policy *policy)
950{ 950{
951 if (hwp_active) 951 if (hwp_active)
952 intel_pstate_hwp_set(policy->cpus); 952 intel_pstate_hwp_set(policy);
953 953
954 return 0; 954 return 0;
955} 955}
@@ -968,19 +968,28 @@ static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)
968 968
969static int intel_pstate_resume(struct cpufreq_policy *policy) 969static int intel_pstate_resume(struct cpufreq_policy *policy)
970{ 970{
971 int ret;
972
971 if (!hwp_active) 973 if (!hwp_active)
972 return 0; 974 return 0;
973 975
976 mutex_lock(&intel_pstate_limits_lock);
977
974 all_cpu_data[policy->cpu]->epp_policy = 0; 978 all_cpu_data[policy->cpu]->epp_policy = 0;
975 979
976 return intel_pstate_hwp_set_policy(policy); 980 ret = intel_pstate_hwp_set_policy(policy);
981
982 mutex_unlock(&intel_pstate_limits_lock);
983
984 return ret;
977} 985}
978 986
979static void intel_pstate_hwp_set_online_cpus(void) 987static void intel_pstate_update_policies(void)
980{ 988{
981 get_online_cpus(); 989 int cpu;
982 intel_pstate_hwp_set(cpu_online_mask); 990
983 put_online_cpus(); 991 for_each_possible_cpu(cpu)
992 cpufreq_update_policy(cpu);
984} 993}
985 994
986/************************** debugfs begin ************************/ 995/************************** debugfs begin ************************/
@@ -1018,10 +1027,6 @@ static void __init intel_pstate_debug_expose_params(void)
1018 struct dentry *debugfs_parent; 1027 struct dentry *debugfs_parent;
1019 int i = 0; 1028 int i = 0;
1020 1029
1021 if (hwp_active ||
1022 pstate_funcs.get_target_pstate == get_target_pstate_use_cpu_load)
1023 return;
1024
1025 debugfs_parent = debugfs_create_dir("pstate_snb", NULL); 1030 debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
1026 if (IS_ERR_OR_NULL(debugfs_parent)) 1031 if (IS_ERR_OR_NULL(debugfs_parent))
1027 return; 1032 return;
@@ -1105,11 +1110,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
1105 1110
1106 limits->no_turbo = clamp_t(int, input, 0, 1); 1111 limits->no_turbo = clamp_t(int, input, 0, 1);
1107 1112
1108 if (hwp_active)
1109 intel_pstate_hwp_set_online_cpus();
1110
1111 mutex_unlock(&intel_pstate_limits_lock); 1113 mutex_unlock(&intel_pstate_limits_lock);
1112 1114
1115 intel_pstate_update_policies();
1116
1113 return count; 1117 return count;
1114} 1118}
1115 1119
@@ -1134,11 +1138,10 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
1134 limits->max_perf_pct); 1138 limits->max_perf_pct);
1135 limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); 1139 limits->max_perf = div_ext_fp(limits->max_perf_pct, 100);
1136 1140
1137 if (hwp_active)
1138 intel_pstate_hwp_set_online_cpus();
1139
1140 mutex_unlock(&intel_pstate_limits_lock); 1141 mutex_unlock(&intel_pstate_limits_lock);
1141 1142
1143 intel_pstate_update_policies();
1144
1142 return count; 1145 return count;
1143} 1146}
1144 1147
@@ -1163,11 +1166,10 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
1163 limits->min_perf_pct); 1166 limits->min_perf_pct);
1164 limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); 1167 limits->min_perf = div_ext_fp(limits->min_perf_pct, 100);
1165 1168
1166 if (hwp_active)
1167 intel_pstate_hwp_set_online_cpus();
1168
1169 mutex_unlock(&intel_pstate_limits_lock); 1169 mutex_unlock(&intel_pstate_limits_lock);
1170 1170
1171 intel_pstate_update_policies();
1172
1171 return count; 1173 return count;
1172} 1174}
1173 1175
@@ -2153,8 +2155,12 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
2153 if (per_cpu_limits) 2155 if (per_cpu_limits)
2154 perf_limits = cpu->perf_limits; 2156 perf_limits = cpu->perf_limits;
2155 2157
2158 mutex_lock(&intel_pstate_limits_lock);
2159
2156 intel_pstate_update_perf_limits(policy, perf_limits); 2160 intel_pstate_update_perf_limits(policy, perf_limits);
2157 2161
2162 mutex_unlock(&intel_pstate_limits_lock);
2163
2158 return 0; 2164 return 0;
2159} 2165}
2160 2166
@@ -2487,7 +2493,10 @@ hwp_cpu_matched:
2487 if (rc) 2493 if (rc)
2488 goto out; 2494 goto out;
2489 2495
2490 intel_pstate_debug_expose_params(); 2496 if (intel_pstate_driver == &intel_pstate && !hwp_active &&
2497 pstate_funcs.get_target_pstate != get_target_pstate_use_cpu_load)
2498 intel_pstate_debug_expose_params();
2499
2491 intel_pstate_sysfs_expose_params(); 2500 intel_pstate_sysfs_expose_params();
2492 2501
2493 if (hwp_active) 2502 if (hwp_active)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a324801d6a66..47206a21bb90 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -593,11 +593,16 @@ struct devfreq *devfreq_add_device(struct device *dev,
593 list_add(&devfreq->node, &devfreq_list); 593 list_add(&devfreq->node, &devfreq_list);
594 594
595 governor = find_devfreq_governor(devfreq->governor_name); 595 governor = find_devfreq_governor(devfreq->governor_name);
596 if (!IS_ERR(governor)) 596 if (IS_ERR(governor)) {
597 devfreq->governor = governor; 597 dev_err(dev, "%s: Unable to find governor for the device\n",
598 if (devfreq->governor) 598 __func__);
599 err = devfreq->governor->event_handler(devfreq, 599 err = PTR_ERR(governor);
600 DEVFREQ_GOV_START, NULL); 600 goto err_init;
601 }
602
603 devfreq->governor = governor;
604 err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START,
605 NULL);
601 if (err) { 606 if (err) {
602 dev_err(dev, "%s: Unable to start governor for the device\n", 607 dev_err(dev, "%s: Unable to start governor for the device\n",
603 __func__); 608 __func__);
diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index a8ed7792ece2..9af86f46fbec 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -497,7 +497,7 @@ passive:
497 if (IS_ERR(bus->devfreq)) { 497 if (IS_ERR(bus->devfreq)) {
498 dev_err(dev, 498 dev_err(dev,
499 "failed to add devfreq dev with passive governor\n"); 499 "failed to add devfreq dev with passive governor\n");
500 ret = -EPROBE_DEFER; 500 ret = PTR_ERR(bus->devfreq);
501 goto err; 501 goto err;
502 } 502 }
503 503
diff --git a/drivers/dma/dw/Kconfig b/drivers/dma/dw/Kconfig
index e00c9b022964..5a37b9fcf40d 100644
--- a/drivers/dma/dw/Kconfig
+++ b/drivers/dma/dw/Kconfig
@@ -24,5 +24,5 @@ config DW_DMAC_PCI
24 select DW_DMAC_CORE 24 select DW_DMAC_CORE
25 help 25 help
26 Support the Synopsys DesignWare AHB DMA controller on the 26 Support the Synopsys DesignWare AHB DMA controller on the
27 platfroms that enumerate it as a PCI device. For example, 27 platforms that enumerate it as a PCI device. For example,
28 Intel Medfield has integrated this GPDMA controller. 28 Intel Medfield has integrated this GPDMA controller.
diff --git a/drivers/dma/ioat/hw.h b/drivers/dma/ioat/hw.h
index 8e67895bcca3..abcc51b343ce 100644
--- a/drivers/dma/ioat/hw.h
+++ b/drivers/dma/ioat/hw.h
@@ -64,6 +64,8 @@
64#define PCI_DEVICE_ID_INTEL_IOAT_BDX8 0x6f2e 64#define PCI_DEVICE_ID_INTEL_IOAT_BDX8 0x6f2e
65#define PCI_DEVICE_ID_INTEL_IOAT_BDX9 0x6f2f 65#define PCI_DEVICE_ID_INTEL_IOAT_BDX9 0x6f2f
66 66
67#define PCI_DEVICE_ID_INTEL_IOAT_SKX 0x2021
68
67#define IOAT_VER_1_2 0x12 /* Version 1.2 */ 69#define IOAT_VER_1_2 0x12 /* Version 1.2 */
68#define IOAT_VER_2_0 0x20 /* Version 2.0 */ 70#define IOAT_VER_2_0 0x20 /* Version 2.0 */
69#define IOAT_VER_3_0 0x30 /* Version 3.0 */ 71#define IOAT_VER_3_0 0x30 /* Version 3.0 */
diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index 90eddd9f07e4..cc5259b881d4 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -106,6 +106,8 @@ static struct pci_device_id ioat_pci_tbl[] = {
106 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX8) }, 106 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX8) },
107 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX9) }, 107 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX9) },
108 108
109 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SKX) },
110
109 /* I/OAT v3.3 platforms */ 111 /* I/OAT v3.3 platforms */
110 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD0) }, 112 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD0) },
111 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD1) }, 113 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD1) },
@@ -243,10 +245,15 @@ static bool is_bdx_ioat(struct pci_dev *pdev)
243 } 245 }
244} 246}
245 247
248static inline bool is_skx_ioat(struct pci_dev *pdev)
249{
250 return (pdev->device == PCI_DEVICE_ID_INTEL_IOAT_SKX) ? true : false;
251}
252
246static bool is_xeon_cb32(struct pci_dev *pdev) 253static bool is_xeon_cb32(struct pci_dev *pdev)
247{ 254{
248 return is_jf_ioat(pdev) || is_snb_ioat(pdev) || is_ivb_ioat(pdev) || 255 return is_jf_ioat(pdev) || is_snb_ioat(pdev) || is_ivb_ioat(pdev) ||
249 is_hsw_ioat(pdev) || is_bdx_ioat(pdev); 256 is_hsw_ioat(pdev) || is_bdx_ioat(pdev) || is_skx_ioat(pdev);
250} 257}
251 258
252bool is_bwd_ioat(struct pci_dev *pdev) 259bool is_bwd_ioat(struct pci_dev *pdev)
@@ -693,7 +700,7 @@ static int ioat_alloc_chan_resources(struct dma_chan *c)
693 /* doing 2 32bit writes to mmio since 1 64b write doesn't work */ 700 /* doing 2 32bit writes to mmio since 1 64b write doesn't work */
694 ioat_chan->completion = 701 ioat_chan->completion =
695 dma_pool_zalloc(ioat_chan->ioat_dma->completion_pool, 702 dma_pool_zalloc(ioat_chan->ioat_dma->completion_pool,
696 GFP_KERNEL, &ioat_chan->completion_dma); 703 GFP_NOWAIT, &ioat_chan->completion_dma);
697 if (!ioat_chan->completion) 704 if (!ioat_chan->completion)
698 return -ENOMEM; 705 return -ENOMEM;
699 706
@@ -703,7 +710,7 @@ static int ioat_alloc_chan_resources(struct dma_chan *c)
703 ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH); 710 ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH);
704 711
705 order = IOAT_MAX_ORDER; 712 order = IOAT_MAX_ORDER;
706 ring = ioat_alloc_ring(c, order, GFP_KERNEL); 713 ring = ioat_alloc_ring(c, order, GFP_NOWAIT);
707 if (!ring) 714 if (!ring)
708 return -ENOMEM; 715 return -ENOMEM;
709 716
@@ -1357,6 +1364,8 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1357 1364
1358 device->version = readb(device->reg_base + IOAT_VER_OFFSET); 1365 device->version = readb(device->reg_base + IOAT_VER_OFFSET);
1359 if (device->version >= IOAT_VER_3_0) { 1366 if (device->version >= IOAT_VER_3_0) {
1367 if (is_skx_ioat(pdev))
1368 device->version = IOAT_VER_3_2;
1360 err = ioat3_dma_probe(device, ioat_dca_enabled); 1369 err = ioat3_dma_probe(device, ioat_dca_enabled);
1361 1370
1362 if (device->version >= IOAT_VER_3_3) 1371 if (device->version >= IOAT_VER_3_3)
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index ac68666cd3f4..daf479cce691 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -938,21 +938,14 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
938 d->ccr |= CCR_DST_AMODE_POSTINC; 938 d->ccr |= CCR_DST_AMODE_POSTINC;
939 if (port_window) { 939 if (port_window) {
940 d->ccr |= CCR_SRC_AMODE_DBLIDX; 940 d->ccr |= CCR_SRC_AMODE_DBLIDX;
941 d->ei = 1;
942 /*
943 * One frame covers the port_window and by configure
944 * the source frame index to be -1 * (port_window - 1)
945 * we instruct the sDMA that after a frame is processed
946 * it should move back to the start of the window.
947 */
948 d->fi = -(port_window_bytes - 1);
949 941
950 if (port_window_bytes >= 64) 942 if (port_window_bytes >= 64)
951 d->csdp = CSDP_SRC_BURST_64 | CSDP_SRC_PACKED; 943 d->csdp |= CSDP_SRC_BURST_64;
952 else if (port_window_bytes >= 32) 944 else if (port_window_bytes >= 32)
953 d->csdp = CSDP_SRC_BURST_32 | CSDP_SRC_PACKED; 945 d->csdp |= CSDP_SRC_BURST_32;
954 else if (port_window_bytes >= 16) 946 else if (port_window_bytes >= 16)
955 d->csdp = CSDP_SRC_BURST_16 | CSDP_SRC_PACKED; 947 d->csdp |= CSDP_SRC_BURST_16;
948
956 } else { 949 } else {
957 d->ccr |= CCR_SRC_AMODE_CONSTANT; 950 d->ccr |= CCR_SRC_AMODE_CONSTANT;
958 } 951 }
@@ -962,13 +955,21 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
962 d->ccr |= CCR_SRC_AMODE_POSTINC; 955 d->ccr |= CCR_SRC_AMODE_POSTINC;
963 if (port_window) { 956 if (port_window) {
964 d->ccr |= CCR_DST_AMODE_DBLIDX; 957 d->ccr |= CCR_DST_AMODE_DBLIDX;
958 d->ei = 1;
959 /*
960 * One frame covers the port_window and by configure
961 * the source frame index to be -1 * (port_window - 1)
962 * we instruct the sDMA that after a frame is processed
963 * it should move back to the start of the window.
964 */
965 d->fi = -(port_window_bytes - 1);
965 966
966 if (port_window_bytes >= 64) 967 if (port_window_bytes >= 64)
967 d->csdp = CSDP_DST_BURST_64 | CSDP_DST_PACKED; 968 d->csdp |= CSDP_DST_BURST_64;
968 else if (port_window_bytes >= 32) 969 else if (port_window_bytes >= 32)
969 d->csdp = CSDP_DST_BURST_32 | CSDP_DST_PACKED; 970 d->csdp |= CSDP_DST_BURST_32;
970 else if (port_window_bytes >= 16) 971 else if (port_window_bytes >= 16)
971 d->csdp = CSDP_DST_BURST_16 | CSDP_DST_PACKED; 972 d->csdp |= CSDP_DST_BURST_16;
972 } else { 973 } else {
973 d->ccr |= CCR_DST_AMODE_CONSTANT; 974 d->ccr |= CCR_DST_AMODE_CONSTANT;
974 } 975 }
@@ -1017,7 +1018,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
1017 osg->addr = sg_dma_address(sgent); 1018 osg->addr = sg_dma_address(sgent);
1018 osg->en = en; 1019 osg->en = en;
1019 osg->fn = sg_dma_len(sgent) / frame_bytes; 1020 osg->fn = sg_dma_len(sgent) / frame_bytes;
1020 if (port_window && dir == DMA_MEM_TO_DEV) { 1021 if (port_window && dir == DMA_DEV_TO_MEM) {
1021 osg->ei = 1; 1022 osg->ei = 1;
1022 /* 1023 /*
1023 * One frame covers the port_window and by configure 1024 * One frame covers the port_window and by configure
@@ -1452,6 +1453,7 @@ static int omap_dma_probe(struct platform_device *pdev)
1452 struct omap_dmadev *od; 1453 struct omap_dmadev *od;
1453 struct resource *res; 1454 struct resource *res;
1454 int rc, i, irq; 1455 int rc, i, irq;
1456 u32 lch_count;
1455 1457
1456 od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL); 1458 od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL);
1457 if (!od) 1459 if (!od)
@@ -1494,20 +1496,31 @@ static int omap_dma_probe(struct platform_device *pdev)
1494 spin_lock_init(&od->lock); 1496 spin_lock_init(&od->lock);
1495 spin_lock_init(&od->irq_lock); 1497 spin_lock_init(&od->irq_lock);
1496 1498
1497 if (!pdev->dev.of_node) { 1499 /* Number of DMA requests */
1498 od->dma_requests = od->plat->dma_attr->lch_count; 1500 od->dma_requests = OMAP_SDMA_REQUESTS;
1499 if (unlikely(!od->dma_requests)) 1501 if (pdev->dev.of_node && of_property_read_u32(pdev->dev.of_node,
1500 od->dma_requests = OMAP_SDMA_REQUESTS; 1502 "dma-requests",
1501 } else if (of_property_read_u32(pdev->dev.of_node, "dma-requests", 1503 &od->dma_requests)) {
1502 &od->dma_requests)) {
1503 dev_info(&pdev->dev, 1504 dev_info(&pdev->dev,
1504 "Missing dma-requests property, using %u.\n", 1505 "Missing dma-requests property, using %u.\n",
1505 OMAP_SDMA_REQUESTS); 1506 OMAP_SDMA_REQUESTS);
1506 od->dma_requests = OMAP_SDMA_REQUESTS;
1507 } 1507 }
1508 1508
1509 od->lch_map = devm_kcalloc(&pdev->dev, od->dma_requests, 1509 /* Number of available logical channels */
1510 sizeof(*od->lch_map), GFP_KERNEL); 1510 if (!pdev->dev.of_node) {
1511 lch_count = od->plat->dma_attr->lch_count;
1512 if (unlikely(!lch_count))
1513 lch_count = OMAP_SDMA_CHANNELS;
1514 } else if (of_property_read_u32(pdev->dev.of_node, "dma-channels",
1515 &lch_count)) {
1516 dev_info(&pdev->dev,
1517 "Missing dma-channels property, using %u.\n",
1518 OMAP_SDMA_CHANNELS);
1519 lch_count = OMAP_SDMA_CHANNELS;
1520 }
1521
1522 od->lch_map = devm_kcalloc(&pdev->dev, lch_count, sizeof(*od->lch_map),
1523 GFP_KERNEL);
1511 if (!od->lch_map) 1524 if (!od->lch_map)
1512 return -ENOMEM; 1525 return -ENOMEM;
1513 1526
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 87fd01539fcb..740bbb942594 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -448,6 +448,9 @@ struct dma_pl330_chan {
448 448
449 /* for cyclic capability */ 449 /* for cyclic capability */
450 bool cyclic; 450 bool cyclic;
451
452 /* for runtime pm tracking */
453 bool active;
451}; 454};
452 455
453struct pl330_dmac { 456struct pl330_dmac {
@@ -2033,6 +2036,7 @@ static void pl330_tasklet(unsigned long data)
2033 _stop(pch->thread); 2036 _stop(pch->thread);
2034 spin_unlock(&pch->thread->dmac->lock); 2037 spin_unlock(&pch->thread->dmac->lock);
2035 power_down = true; 2038 power_down = true;
2039 pch->active = false;
2036 } else { 2040 } else {
2037 /* Make sure the PL330 Channel thread is active */ 2041 /* Make sure the PL330 Channel thread is active */
2038 spin_lock(&pch->thread->dmac->lock); 2042 spin_lock(&pch->thread->dmac->lock);
@@ -2052,6 +2056,7 @@ static void pl330_tasklet(unsigned long data)
2052 desc->status = PREP; 2056 desc->status = PREP;
2053 list_move_tail(&desc->node, &pch->work_list); 2057 list_move_tail(&desc->node, &pch->work_list);
2054 if (power_down) { 2058 if (power_down) {
2059 pch->active = true;
2055 spin_lock(&pch->thread->dmac->lock); 2060 spin_lock(&pch->thread->dmac->lock);
2056 _start(pch->thread); 2061 _start(pch->thread);
2057 spin_unlock(&pch->thread->dmac->lock); 2062 spin_unlock(&pch->thread->dmac->lock);
@@ -2166,6 +2171,7 @@ static int pl330_terminate_all(struct dma_chan *chan)
2166 unsigned long flags; 2171 unsigned long flags;
2167 struct pl330_dmac *pl330 = pch->dmac; 2172 struct pl330_dmac *pl330 = pch->dmac;
2168 LIST_HEAD(list); 2173 LIST_HEAD(list);
2174 bool power_down = false;
2169 2175
2170 pm_runtime_get_sync(pl330->ddma.dev); 2176 pm_runtime_get_sync(pl330->ddma.dev);
2171 spin_lock_irqsave(&pch->lock, flags); 2177 spin_lock_irqsave(&pch->lock, flags);
@@ -2176,6 +2182,8 @@ static int pl330_terminate_all(struct dma_chan *chan)
2176 pch->thread->req[0].desc = NULL; 2182 pch->thread->req[0].desc = NULL;
2177 pch->thread->req[1].desc = NULL; 2183 pch->thread->req[1].desc = NULL;
2178 pch->thread->req_running = -1; 2184 pch->thread->req_running = -1;
2185 power_down = pch->active;
2186 pch->active = false;
2179 2187
2180 /* Mark all desc done */ 2188 /* Mark all desc done */
2181 list_for_each_entry(desc, &pch->submitted_list, node) { 2189 list_for_each_entry(desc, &pch->submitted_list, node) {
@@ -2193,6 +2201,8 @@ static int pl330_terminate_all(struct dma_chan *chan)
2193 list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); 2201 list_splice_tail_init(&pch->completed_list, &pl330->desc_pool);
2194 spin_unlock_irqrestore(&pch->lock, flags); 2202 spin_unlock_irqrestore(&pch->lock, flags);
2195 pm_runtime_mark_last_busy(pl330->ddma.dev); 2203 pm_runtime_mark_last_busy(pl330->ddma.dev);
2204 if (power_down)
2205 pm_runtime_put_autosuspend(pl330->ddma.dev);
2196 pm_runtime_put_autosuspend(pl330->ddma.dev); 2206 pm_runtime_put_autosuspend(pl330->ddma.dev);
2197 2207
2198 return 0; 2208 return 0;
@@ -2357,6 +2367,7 @@ static void pl330_issue_pending(struct dma_chan *chan)
2357 * updated on work_list emptiness status. 2367 * updated on work_list emptiness status.
2358 */ 2368 */
2359 WARN_ON(list_empty(&pch->submitted_list)); 2369 WARN_ON(list_empty(&pch->submitted_list));
2370 pch->active = true;
2360 pm_runtime_get_sync(pch->dmac->ddma.dev); 2371 pm_runtime_get_sync(pch->dmac->ddma.dev);
2361 } 2372 }
2362 list_splice_tail_init(&pch->submitted_list, &pch->work_list); 2373 list_splice_tail_init(&pch->submitted_list, &pch->work_list);
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2e441d0ccd79..4c357d475465 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -986,6 +986,7 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
986{ 986{
987 struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan); 987 struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
988 struct rcar_dmac *dmac = to_rcar_dmac(chan->device); 988 struct rcar_dmac *dmac = to_rcar_dmac(chan->device);
989 struct rcar_dmac_chan_map *map = &rchan->map;
989 struct rcar_dmac_desc_page *page, *_page; 990 struct rcar_dmac_desc_page *page, *_page;
990 struct rcar_dmac_desc *desc; 991 struct rcar_dmac_desc *desc;
991 LIST_HEAD(list); 992 LIST_HEAD(list);
@@ -1019,6 +1020,13 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
1019 free_page((unsigned long)page); 1020 free_page((unsigned long)page);
1020 } 1021 }
1021 1022
1023 /* Remove slave mapping if present. */
1024 if (map->slave.xfer_size) {
1025 dma_unmap_resource(chan->device->dev, map->addr,
1026 map->slave.xfer_size, map->dir, 0);
1027 map->slave.xfer_size = 0;
1028 }
1029
1022 pm_runtime_put(chan->device->dev); 1030 pm_runtime_put(chan->device->dev);
1023} 1031}
1024 1032
diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 3688d0873a3e..3056ce7f8c69 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -880,7 +880,7 @@ static enum dma_status stm32_dma_tx_status(struct dma_chan *c,
880 struct virt_dma_desc *vdesc; 880 struct virt_dma_desc *vdesc;
881 enum dma_status status; 881 enum dma_status status;
882 unsigned long flags; 882 unsigned long flags;
883 u32 residue; 883 u32 residue = 0;
884 884
885 status = dma_cookie_status(c, cookie, state); 885 status = dma_cookie_status(c, cookie, state);
886 if ((status == DMA_COMPLETE) || (!state)) 886 if ((status == DMA_COMPLETE) || (!state))
@@ -888,16 +888,12 @@ static enum dma_status stm32_dma_tx_status(struct dma_chan *c,
888 888
889 spin_lock_irqsave(&chan->vchan.lock, flags); 889 spin_lock_irqsave(&chan->vchan.lock, flags);
890 vdesc = vchan_find_desc(&chan->vchan, cookie); 890 vdesc = vchan_find_desc(&chan->vchan, cookie);
891 if (cookie == chan->desc->vdesc.tx.cookie) { 891 if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
892 residue = stm32_dma_desc_residue(chan, chan->desc, 892 residue = stm32_dma_desc_residue(chan, chan->desc,
893 chan->next_sg); 893 chan->next_sg);
894 } else if (vdesc) { 894 else if (vdesc)
895 residue = stm32_dma_desc_residue(chan, 895 residue = stm32_dma_desc_residue(chan,
896 to_stm32_dma_desc(vdesc), 0); 896 to_stm32_dma_desc(vdesc), 0);
897 } else {
898 residue = 0;
899 }
900
901 dma_set_residue(state, residue); 897 dma_set_residue(state, residue);
902 898
903 spin_unlock_irqrestore(&chan->vchan.lock, flags); 899 spin_unlock_irqrestore(&chan->vchan.lock, flags);
@@ -972,21 +968,18 @@ static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,
972 struct stm32_dma_chan *chan; 968 struct stm32_dma_chan *chan;
973 struct dma_chan *c; 969 struct dma_chan *c;
974 970
975 if (dma_spec->args_count < 3) 971 if (dma_spec->args_count < 4)
976 return NULL; 972 return NULL;
977 973
978 cfg.channel_id = dma_spec->args[0]; 974 cfg.channel_id = dma_spec->args[0];
979 cfg.request_line = dma_spec->args[1]; 975 cfg.request_line = dma_spec->args[1];
980 cfg.stream_config = dma_spec->args[2]; 976 cfg.stream_config = dma_spec->args[2];
981 cfg.threshold = 0; 977 cfg.threshold = dma_spec->args[3];
982 978
983 if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) || (cfg.request_line >= 979 if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) || (cfg.request_line >=
984 STM32_DMA_MAX_REQUEST_ID)) 980 STM32_DMA_MAX_REQUEST_ID))
985 return NULL; 981 return NULL;
986 982
987 if (dma_spec->args_count > 3)
988 cfg.threshold = dma_spec->args[3];
989
990 chan = &dmadev->chan[cfg.channel_id]; 983 chan = &dmadev->chan[cfg.channel_id];
991 984
992 c = dma_get_slave_channel(&chan->vchan.chan); 985 c = dma_get_slave_channel(&chan->vchan.chan);
diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 3f24aeb48c0e..2403475a37cf 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -149,6 +149,7 @@ static int ti_am335x_xbar_probe(struct platform_device *pdev)
149 match = of_match_node(ti_am335x_master_match, dma_node); 149 match = of_match_node(ti_am335x_master_match, dma_node);
150 if (!match) { 150 if (!match) {
151 dev_err(&pdev->dev, "DMA master is not supported\n"); 151 dev_err(&pdev->dev, "DMA master is not supported\n");
152 of_node_put(dma_node);
152 return -EINVAL; 153 return -EINVAL;
153 } 154 }
154 155
@@ -339,6 +340,7 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
339 match = of_match_node(ti_dra7_master_match, dma_node); 340 match = of_match_node(ti_dra7_master_match, dma_node);
340 if (!match) { 341 if (!match) {
341 dev_err(&pdev->dev, "DMA master is not supported\n"); 342 dev_err(&pdev->dev, "DMA master is not supported\n");
343 of_node_put(dma_node);
342 return -EINVAL; 344 return -EINVAL;
343 } 345 }
344 346
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 78298460d168..7c1e3a7b14e0 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -453,7 +453,7 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id)
453 dev_err(&edev->dev, "out of memory in extcon_set_state\n"); 453 dev_err(&edev->dev, "out of memory in extcon_set_state\n");
454 kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE); 454 kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE);
455 455
456 return 0; 456 return -ENOMEM;
457 } 457 }
458 458
459 length = name_show(&edev->dev, NULL, prop_buf); 459 length = name_show(&edev->dev, NULL, prop_buf);
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 70e13230d8db..9ad0b1934be9 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -721,11 +721,17 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val)
721 721
722 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id), 722 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id),
723 &buf, sizeof(buf)); 723 &buf, sizeof(buf));
724 if (!ret) 724 if (ret)
725 return ret;
726
727 if (scpi_info->is_legacy)
728 /* only 32-bits supported, hi_val can be junk */
729 *val = le32_to_cpu(buf.lo_val);
730 else
725 *val = (u64)le32_to_cpu(buf.hi_val) << 32 | 731 *val = (u64)le32_to_cpu(buf.hi_val) << 32 |
726 le32_to_cpu(buf.lo_val); 732 le32_to_cpu(buf.lo_val);
727 733
728 return ret; 734 return 0;
729} 735}
730 736
731static int scpi_device_get_power_state(u16 dev_id) 737static int scpi_device_get_power_state(u16 dev_id)
diff --git a/drivers/firmware/efi/fake_mem.c b/drivers/firmware/efi/fake_mem.c
index 520a40e5e0e4..6c7d60c239b5 100644
--- a/drivers/firmware/efi/fake_mem.c
+++ b/drivers/firmware/efi/fake_mem.c
@@ -71,8 +71,7 @@ void __init efi_fake_memmap(void)
71 } 71 }
72 72
73 /* allocate memory for new EFI memmap */ 73 /* allocate memory for new EFI memmap */
74 new_memmap_phy = memblock_alloc(efi.memmap.desc_size * new_nr_map, 74 new_memmap_phy = efi_memmap_alloc(new_nr_map);
75 PAGE_SIZE);
76 if (!new_memmap_phy) 75 if (!new_memmap_phy)
77 return; 76 return;
78 77
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index b98824e3800a..0e2a96b12cb3 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -39,14 +39,6 @@ efi_status_t efi_file_close(void *handle);
39 39
40unsigned long get_dram_base(efi_system_table_t *sys_table_arg); 40unsigned long get_dram_base(efi_system_table_t *sys_table_arg);
41 41
42efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
43 unsigned long orig_fdt_size,
44 void *fdt, int new_fdt_size, char *cmdline_ptr,
45 u64 initrd_addr, u64 initrd_size,
46 efi_memory_desc_t *memory_map,
47 unsigned long map_size, unsigned long desc_size,
48 u32 desc_ver);
49
50efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, 42efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
51 void *handle, 43 void *handle,
52 unsigned long *new_fdt_addr, 44 unsigned long *new_fdt_addr,
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index a6a93116a8f0..921dfa047202 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -16,13 +16,10 @@
16 16
17#include "efistub.h" 17#include "efistub.h"
18 18
19efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, 19static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
20 unsigned long orig_fdt_size, 20 unsigned long orig_fdt_size,
21 void *fdt, int new_fdt_size, char *cmdline_ptr, 21 void *fdt, int new_fdt_size, char *cmdline_ptr,
22 u64 initrd_addr, u64 initrd_size, 22 u64 initrd_addr, u64 initrd_size)
23 efi_memory_desc_t *memory_map,
24 unsigned long map_size, unsigned long desc_size,
25 u32 desc_ver)
26{ 23{
27 int node, num_rsv; 24 int node, num_rsv;
28 int status; 25 int status;
@@ -101,25 +98,23 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
101 if (status) 98 if (status)
102 goto fdt_set_fail; 99 goto fdt_set_fail;
103 100
104 fdt_val64 = cpu_to_fdt64((u64)(unsigned long)memory_map); 101 fdt_val64 = U64_MAX; /* placeholder */
105 status = fdt_setprop(fdt, node, "linux,uefi-mmap-start", 102 status = fdt_setprop(fdt, node, "linux,uefi-mmap-start",
106 &fdt_val64, sizeof(fdt_val64)); 103 &fdt_val64, sizeof(fdt_val64));
107 if (status) 104 if (status)
108 goto fdt_set_fail; 105 goto fdt_set_fail;
109 106
110 fdt_val32 = cpu_to_fdt32(map_size); 107 fdt_val32 = U32_MAX; /* placeholder */
111 status = fdt_setprop(fdt, node, "linux,uefi-mmap-size", 108 status = fdt_setprop(fdt, node, "linux,uefi-mmap-size",
112 &fdt_val32, sizeof(fdt_val32)); 109 &fdt_val32, sizeof(fdt_val32));
113 if (status) 110 if (status)
114 goto fdt_set_fail; 111 goto fdt_set_fail;
115 112
116 fdt_val32 = cpu_to_fdt32(desc_size);
117 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size", 113 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size",
118 &fdt_val32, sizeof(fdt_val32)); 114 &fdt_val32, sizeof(fdt_val32));
119 if (status) 115 if (status)
120 goto fdt_set_fail; 116 goto fdt_set_fail;
121 117
122 fdt_val32 = cpu_to_fdt32(desc_ver);
123 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver", 118 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver",
124 &fdt_val32, sizeof(fdt_val32)); 119 &fdt_val32, sizeof(fdt_val32));
125 if (status) 120 if (status)
@@ -148,6 +143,43 @@ fdt_set_fail:
148 return EFI_LOAD_ERROR; 143 return EFI_LOAD_ERROR;
149} 144}
150 145
146static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
147{
148 int node = fdt_path_offset(fdt, "/chosen");
149 u64 fdt_val64;
150 u32 fdt_val32;
151 int err;
152
153 if (node < 0)
154 return EFI_LOAD_ERROR;
155
156 fdt_val64 = cpu_to_fdt64((unsigned long)*map->map);
157 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-start",
158 &fdt_val64, sizeof(fdt_val64));
159 if (err)
160 return EFI_LOAD_ERROR;
161
162 fdt_val32 = cpu_to_fdt32(*map->map_size);
163 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-size",
164 &fdt_val32, sizeof(fdt_val32));
165 if (err)
166 return EFI_LOAD_ERROR;
167
168 fdt_val32 = cpu_to_fdt32(*map->desc_size);
169 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-size",
170 &fdt_val32, sizeof(fdt_val32));
171 if (err)
172 return EFI_LOAD_ERROR;
173
174 fdt_val32 = cpu_to_fdt32(*map->desc_ver);
175 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-ver",
176 &fdt_val32, sizeof(fdt_val32));
177 if (err)
178 return EFI_LOAD_ERROR;
179
180 return EFI_SUCCESS;
181}
182
151#ifndef EFI_FDT_ALIGN 183#ifndef EFI_FDT_ALIGN
152#define EFI_FDT_ALIGN EFI_PAGE_SIZE 184#define EFI_FDT_ALIGN EFI_PAGE_SIZE
153#endif 185#endif
@@ -243,20 +275,10 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
243 goto fail; 275 goto fail;
244 } 276 }
245 277
246 /*
247 * Now that we have done our final memory allocation (and free)
248 * we can get the memory map key needed for
249 * exit_boot_services().
250 */
251 status = efi_get_memory_map(sys_table, &map);
252 if (status != EFI_SUCCESS)
253 goto fail_free_new_fdt;
254
255 status = update_fdt(sys_table, 278 status = update_fdt(sys_table,
256 (void *)fdt_addr, fdt_size, 279 (void *)fdt_addr, fdt_size,
257 (void *)*new_fdt_addr, new_fdt_size, 280 (void *)*new_fdt_addr, new_fdt_size,
258 cmdline_ptr, initrd_addr, initrd_size, 281 cmdline_ptr, initrd_addr, initrd_size);
259 memory_map, map_size, desc_size, desc_ver);
260 282
261 /* Succeeding the first time is the expected case. */ 283 /* Succeeding the first time is the expected case. */
262 if (status == EFI_SUCCESS) 284 if (status == EFI_SUCCESS)
@@ -266,20 +288,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
266 /* 288 /*
267 * We need to allocate more space for the new 289 * We need to allocate more space for the new
268 * device tree, so free existing buffer that is 290 * device tree, so free existing buffer that is
269 * too small. Also free memory map, as we will need 291 * too small.
270 * to get new one that reflects the free/alloc we do
271 * on the device tree buffer.
272 */ 292 */
273 efi_free(sys_table, new_fdt_size, *new_fdt_addr); 293 efi_free(sys_table, new_fdt_size, *new_fdt_addr);
274 sys_table->boottime->free_pool(memory_map);
275 new_fdt_size += EFI_PAGE_SIZE; 294 new_fdt_size += EFI_PAGE_SIZE;
276 } else { 295 } else {
277 pr_efi_err(sys_table, "Unable to construct new device tree.\n"); 296 pr_efi_err(sys_table, "Unable to construct new device tree.\n");
278 goto fail_free_mmap; 297 goto fail_free_new_fdt;
279 } 298 }
280 } 299 }
281 300
282 sys_table->boottime->free_pool(memory_map);
283 priv.runtime_map = runtime_map; 301 priv.runtime_map = runtime_map;
284 priv.runtime_entry_count = &runtime_entry_count; 302 priv.runtime_entry_count = &runtime_entry_count;
285 status = efi_exit_boot_services(sys_table, handle, &map, &priv, 303 status = efi_exit_boot_services(sys_table, handle, &map, &priv,
@@ -288,6 +306,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
288 if (status == EFI_SUCCESS) { 306 if (status == EFI_SUCCESS) {
289 efi_set_virtual_address_map_t *svam; 307 efi_set_virtual_address_map_t *svam;
290 308
309 status = update_fdt_memmap((void *)*new_fdt_addr, &map);
310 if (status != EFI_SUCCESS) {
311 /*
312 * The kernel won't get far without the memory map, but
313 * may still be able to print something meaningful so
314 * return success here.
315 */
316 return EFI_SUCCESS;
317 }
318
291 /* Install the new virtual address map */ 319 /* Install the new virtual address map */
292 svam = sys_table->runtime->set_virtual_address_map; 320 svam = sys_table->runtime->set_virtual_address_map;
293 status = svam(runtime_entry_count * desc_size, desc_size, 321 status = svam(runtime_entry_count * desc_size, desc_size,
@@ -319,9 +347,6 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
319 347
320 pr_efi_err(sys_table, "Exit boot services failed.\n"); 348 pr_efi_err(sys_table, "Exit boot services failed.\n");
321 349
322fail_free_mmap:
323 sys_table->boottime->free_pool(memory_map);
324
325fail_free_new_fdt: 350fail_free_new_fdt:
326 efi_free(sys_table, new_fdt_size, *new_fdt_addr); 351 efi_free(sys_table, new_fdt_size, *new_fdt_addr);
327 352
diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
index f03ddecd232b..78686443cb37 100644
--- a/drivers/firmware/efi/memmap.c
+++ b/drivers/firmware/efi/memmap.c
@@ -9,6 +9,44 @@
9#include <linux/efi.h> 9#include <linux/efi.h>
10#include <linux/io.h> 10#include <linux/io.h>
11#include <asm/early_ioremap.h> 11#include <asm/early_ioremap.h>
12#include <linux/memblock.h>
13#include <linux/slab.h>
14
15static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size)
16{
17 return memblock_alloc(size, 0);
18}
19
20static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size)
21{
22 unsigned int order = get_order(size);
23 struct page *p = alloc_pages(GFP_KERNEL, order);
24
25 if (!p)
26 return 0;
27
28 return PFN_PHYS(page_to_pfn(p));
29}
30
31/**
32 * efi_memmap_alloc - Allocate memory for the EFI memory map
33 * @num_entries: Number of entries in the allocated map.
34 *
35 * Depending on whether mm_init() has already been invoked or not,
36 * either memblock or "normal" page allocation is used.
37 *
38 * Returns the physical address of the allocated memory map on
39 * success, zero on failure.
40 */
41phys_addr_t __init efi_memmap_alloc(unsigned int num_entries)
42{
43 unsigned long size = num_entries * efi.memmap.desc_size;
44
45 if (slab_is_available())
46 return __efi_memmap_alloc_late(size);
47
48 return __efi_memmap_alloc_early(size);
49}
12 50
13/** 51/**
14 * __efi_memmap_init - Common code for mapping the EFI memory map 52 * __efi_memmap_init - Common code for mapping the EFI memory map
diff --git a/drivers/firmware/psci_checker.c b/drivers/firmware/psci_checker.c
index 44bdb78f837b..29d58feaf675 100644
--- a/drivers/firmware/psci_checker.c
+++ b/drivers/firmware/psci_checker.c
@@ -270,8 +270,7 @@ static int suspend_test_thread(void *arg)
270 struct cpuidle_device *dev; 270 struct cpuidle_device *dev;
271 struct cpuidle_driver *drv; 271 struct cpuidle_driver *drv;
272 /* No need for an actual callback, we just want to wake up the CPU. */ 272 /* No need for an actual callback, we just want to wake up the CPU. */
273 struct timer_list wakeup_timer = 273 struct timer_list wakeup_timer;
274 TIMER_INITIALIZER(dummy_callback, 0, 0);
275 274
276 /* Wait for the main thread to give the start signal. */ 275 /* Wait for the main thread to give the start signal. */
277 wait_for_completion(&suspend_threads_started); 276 wait_for_completion(&suspend_threads_started);
@@ -287,6 +286,7 @@ static int suspend_test_thread(void *arg)
287 pr_info("CPU %d entering suspend cycles, states 1 through %d\n", 286 pr_info("CPU %d entering suspend cycles, states 1 through %d\n",
288 cpu, drv->state_count - 1); 287 cpu, drv->state_count - 1);
289 288
289 setup_timer_on_stack(&wakeup_timer, dummy_callback, 0);
290 for (i = 0; i < NUM_SUSPEND_CYCLE; ++i) { 290 for (i = 0; i < NUM_SUSPEND_CYCLE; ++i) {
291 int index; 291 int index;
292 /* 292 /*
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 1e8fde8cb803..2292742eac8f 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -205,7 +205,7 @@ static int mxs_gpio_set_wake_irq(struct irq_data *d, unsigned int enable)
205 return 0; 205 return 0;
206} 206}
207 207
208static int __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) 208static int mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base)
209{ 209{
210 struct irq_chip_generic *gc; 210 struct irq_chip_generic *gc;
211 struct irq_chip_type *ct; 211 struct irq_chip_type *ct;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f4c26c7826cd..a07ae9e37930 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1317,12 +1317,12 @@ void gpiochip_remove(struct gpio_chip *chip)
1317 1317
1318 /* FIXME: should the legacy sysfs handling be moved to gpio_device? */ 1318 /* FIXME: should the legacy sysfs handling be moved to gpio_device? */
1319 gpiochip_sysfs_unregister(gdev); 1319 gpiochip_sysfs_unregister(gdev);
1320 gpiochip_free_hogs(chip);
1320 /* Numb the device, cancelling all outstanding operations */ 1321 /* Numb the device, cancelling all outstanding operations */
1321 gdev->chip = NULL; 1322 gdev->chip = NULL;
1322 gpiochip_irqchip_remove(chip); 1323 gpiochip_irqchip_remove(chip);
1323 acpi_gpiochip_remove(chip); 1324 acpi_gpiochip_remove(chip);
1324 gpiochip_remove_pin_ranges(chip); 1325 gpiochip_remove_pin_ranges(chip);
1325 gpiochip_free_hogs(chip);
1326 of_gpiochip_remove(chip); 1326 of_gpiochip_remove(chip);
1327 /* 1327 /*
1328 * We accept no more calls into the driver from this point, so 1328 * We accept no more calls into the driver from this point, so
@@ -1723,7 +1723,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
1723} 1723}
1724 1724
1725/** 1725/**
1726 * _gpiochip_irqchip_add() - adds an irqchip to a gpiochip 1726 * gpiochip_irqchip_add_key() - adds an irqchip to a gpiochip
1727 * @gpiochip: the gpiochip to add the irqchip to 1727 * @gpiochip: the gpiochip to add the irqchip to
1728 * @irqchip: the irqchip to add to the gpiochip 1728 * @irqchip: the irqchip to add to the gpiochip
1729 * @first_irq: if not dynamically assigned, the base (first) IRQ to 1729 * @first_irq: if not dynamically assigned, the base (first) IRQ to
@@ -1749,13 +1749,13 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
1749 * the pins on the gpiochip can generate a unique IRQ. Everything else 1749 * the pins on the gpiochip can generate a unique IRQ. Everything else
1750 * need to be open coded. 1750 * need to be open coded.
1751 */ 1751 */
1752int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, 1752int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
1753 struct irq_chip *irqchip, 1753 struct irq_chip *irqchip,
1754 unsigned int first_irq, 1754 unsigned int first_irq,
1755 irq_flow_handler_t handler, 1755 irq_flow_handler_t handler,
1756 unsigned int type, 1756 unsigned int type,
1757 bool nested, 1757 bool nested,
1758 struct lock_class_key *lock_key) 1758 struct lock_class_key *lock_key)
1759{ 1759{
1760 struct device_node *of_node; 1760 struct device_node *of_node;
1761 bool irq_base_set = false; 1761 bool irq_base_set = false;
@@ -1840,7 +1840,7 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip,
1840 1840
1841 return 0; 1841 return 0;
1842} 1842}
1843EXPORT_SYMBOL_GPL(_gpiochip_irqchip_add); 1843EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_key);
1844 1844
1845#else /* CONFIG_GPIOLIB_IRQCHIP */ 1845#else /* CONFIG_GPIOLIB_IRQCHIP */
1846 1846
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 9ada56c16a58..4c851fde1e82 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -840,6 +840,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
840 else if (type == CGS_UCODE_ID_SMU_SK) 840 else if (type == CGS_UCODE_ID_SMU_SK)
841 strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin"); 841 strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
842 break; 842 break;
843 case CHIP_POLARIS12:
844 strcpy(fw_name, "amdgpu/polaris12_smc.bin");
845 break;
843 default: 846 default:
844 DRM_ERROR("SMC firmware not supported\n"); 847 DRM_ERROR("SMC firmware not supported\n");
845 return -EINVAL; 848 return -EINVAL;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 60bd4afe45c8..fe3bb94fe58d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -73,6 +73,7 @@ static const char *amdgpu_asic_name[] = {
73 "STONEY", 73 "STONEY",
74 "POLARIS10", 74 "POLARIS10",
75 "POLARIS11", 75 "POLARIS11",
76 "POLARIS12",
76 "LAST", 77 "LAST",
77}; 78};
78 79
@@ -1277,6 +1278,7 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
1277 case CHIP_FIJI: 1278 case CHIP_FIJI:
1278 case CHIP_POLARIS11: 1279 case CHIP_POLARIS11:
1279 case CHIP_POLARIS10: 1280 case CHIP_POLARIS10:
1281 case CHIP_POLARIS12:
1280 case CHIP_CARRIZO: 1282 case CHIP_CARRIZO:
1281 case CHIP_STONEY: 1283 case CHIP_STONEY:
1282 if (adev->asic_type == CHIP_CARRIZO || adev->asic_type == CHIP_STONEY) 1284 if (adev->asic_type == CHIP_CARRIZO || adev->asic_type == CHIP_STONEY)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 8cb937b2bfcc..2534adaebe30 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -418,6 +418,13 @@ static const struct pci_device_id pciidlist[] = {
418 {0x1002, 0x67CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10}, 418 {0x1002, 0x67CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
419 {0x1002, 0x67CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10}, 419 {0x1002, 0x67CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
420 {0x1002, 0x67CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10}, 420 {0x1002, 0x67CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
421 /* Polaris12 */
422 {0x1002, 0x6980, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
423 {0x1002, 0x6981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
424 {0x1002, 0x6985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
425 {0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
426 {0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
427 {0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
421 428
422 {0, 0, 0} 429 {0, 0, 0}
423}; 430};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index fc592c2b0e16..95a568df8551 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -98,6 +98,7 @@ static int amdgpu_pp_early_init(void *handle)
98 switch (adev->asic_type) { 98 switch (adev->asic_type) {
99 case CHIP_POLARIS11: 99 case CHIP_POLARIS11:
100 case CHIP_POLARIS10: 100 case CHIP_POLARIS10:
101 case CHIP_POLARIS12:
101 case CHIP_TONGA: 102 case CHIP_TONGA:
102 case CHIP_FIJI: 103 case CHIP_FIJI:
103 case CHIP_TOPAZ: 104 case CHIP_TOPAZ:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index a81dfaeeb8c0..1d564beb0fde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -65,6 +65,7 @@
65#define FIRMWARE_STONEY "amdgpu/stoney_uvd.bin" 65#define FIRMWARE_STONEY "amdgpu/stoney_uvd.bin"
66#define FIRMWARE_POLARIS10 "amdgpu/polaris10_uvd.bin" 66#define FIRMWARE_POLARIS10 "amdgpu/polaris10_uvd.bin"
67#define FIRMWARE_POLARIS11 "amdgpu/polaris11_uvd.bin" 67#define FIRMWARE_POLARIS11 "amdgpu/polaris11_uvd.bin"
68#define FIRMWARE_POLARIS12 "amdgpu/polaris12_uvd.bin"
68 69
69/** 70/**
70 * amdgpu_uvd_cs_ctx - Command submission parser context 71 * amdgpu_uvd_cs_ctx - Command submission parser context
@@ -98,6 +99,7 @@ MODULE_FIRMWARE(FIRMWARE_FIJI);
98MODULE_FIRMWARE(FIRMWARE_STONEY); 99MODULE_FIRMWARE(FIRMWARE_STONEY);
99MODULE_FIRMWARE(FIRMWARE_POLARIS10); 100MODULE_FIRMWARE(FIRMWARE_POLARIS10);
100MODULE_FIRMWARE(FIRMWARE_POLARIS11); 101MODULE_FIRMWARE(FIRMWARE_POLARIS11);
102MODULE_FIRMWARE(FIRMWARE_POLARIS12);
101 103
102static void amdgpu_uvd_idle_work_handler(struct work_struct *work); 104static void amdgpu_uvd_idle_work_handler(struct work_struct *work);
103 105
@@ -149,6 +151,9 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
149 case CHIP_POLARIS11: 151 case CHIP_POLARIS11:
150 fw_name = FIRMWARE_POLARIS11; 152 fw_name = FIRMWARE_POLARIS11;
151 break; 153 break;
154 case CHIP_POLARIS12:
155 fw_name = FIRMWARE_POLARIS12;
156 break;
152 default: 157 default:
153 return -EINVAL; 158 return -EINVAL;
154 } 159 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index 69b66b9e7f57..8fec802d3908 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -52,6 +52,7 @@
52#define FIRMWARE_STONEY "amdgpu/stoney_vce.bin" 52#define FIRMWARE_STONEY "amdgpu/stoney_vce.bin"
53#define FIRMWARE_POLARIS10 "amdgpu/polaris10_vce.bin" 53#define FIRMWARE_POLARIS10 "amdgpu/polaris10_vce.bin"
54#define FIRMWARE_POLARIS11 "amdgpu/polaris11_vce.bin" 54#define FIRMWARE_POLARIS11 "amdgpu/polaris11_vce.bin"
55#define FIRMWARE_POLARIS12 "amdgpu/polaris12_vce.bin"
55 56
56#ifdef CONFIG_DRM_AMDGPU_CIK 57#ifdef CONFIG_DRM_AMDGPU_CIK
57MODULE_FIRMWARE(FIRMWARE_BONAIRE); 58MODULE_FIRMWARE(FIRMWARE_BONAIRE);
@@ -66,6 +67,7 @@ MODULE_FIRMWARE(FIRMWARE_FIJI);
66MODULE_FIRMWARE(FIRMWARE_STONEY); 67MODULE_FIRMWARE(FIRMWARE_STONEY);
67MODULE_FIRMWARE(FIRMWARE_POLARIS10); 68MODULE_FIRMWARE(FIRMWARE_POLARIS10);
68MODULE_FIRMWARE(FIRMWARE_POLARIS11); 69MODULE_FIRMWARE(FIRMWARE_POLARIS11);
70MODULE_FIRMWARE(FIRMWARE_POLARIS12);
69 71
70static void amdgpu_vce_idle_work_handler(struct work_struct *work); 72static void amdgpu_vce_idle_work_handler(struct work_struct *work);
71 73
@@ -121,6 +123,9 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size)
121 case CHIP_POLARIS11: 123 case CHIP_POLARIS11:
122 fw_name = FIRMWARE_POLARIS11; 124 fw_name = FIRMWARE_POLARIS11;
123 break; 125 break;
126 case CHIP_POLARIS12:
127 fw_name = FIRMWARE_POLARIS12;
128 break;
124 129
125 default: 130 default:
126 return -EINVAL; 131 return -EINVAL;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9999dc71b998..ccb5e02e7b20 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2512,6 +2512,8 @@ static int dce_v10_0_cursor_move_locked(struct drm_crtc *crtc,
2512 2512
2513 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); 2513 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y);
2514 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); 2514 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin);
2515 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2516 ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1));
2515 2517
2516 return 0; 2518 return 0;
2517} 2519}
@@ -2537,7 +2539,6 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,
2537 int32_t hot_y) 2539 int32_t hot_y)
2538{ 2540{
2539 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2541 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2540 struct amdgpu_device *adev = crtc->dev->dev_private;
2541 struct drm_gem_object *obj; 2542 struct drm_gem_object *obj;
2542 struct amdgpu_bo *aobj; 2543 struct amdgpu_bo *aobj;
2543 int ret; 2544 int ret;
@@ -2578,7 +2579,9 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,
2578 2579
2579 dce_v10_0_lock_cursor(crtc, true); 2580 dce_v10_0_lock_cursor(crtc, true);
2580 2581
2581 if (hot_x != amdgpu_crtc->cursor_hot_x || 2582 if (width != amdgpu_crtc->cursor_width ||
2583 height != amdgpu_crtc->cursor_height ||
2584 hot_x != amdgpu_crtc->cursor_hot_x ||
2582 hot_y != amdgpu_crtc->cursor_hot_y) { 2585 hot_y != amdgpu_crtc->cursor_hot_y) {
2583 int x, y; 2586 int x, y;
2584 2587
@@ -2587,16 +2590,10 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,
2587 2590
2588 dce_v10_0_cursor_move_locked(crtc, x, y); 2591 dce_v10_0_cursor_move_locked(crtc, x, y);
2589 2592
2590 amdgpu_crtc->cursor_hot_x = hot_x;
2591 amdgpu_crtc->cursor_hot_y = hot_y;
2592 }
2593
2594 if (width != amdgpu_crtc->cursor_width ||
2595 height != amdgpu_crtc->cursor_height) {
2596 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2597 (width - 1) << 16 | (height - 1));
2598 amdgpu_crtc->cursor_width = width; 2593 amdgpu_crtc->cursor_width = width;
2599 amdgpu_crtc->cursor_height = height; 2594 amdgpu_crtc->cursor_height = height;
2595 amdgpu_crtc->cursor_hot_x = hot_x;
2596 amdgpu_crtc->cursor_hot_y = hot_y;
2600 } 2597 }
2601 2598
2602 dce_v10_0_show_cursor(crtc); 2599 dce_v10_0_show_cursor(crtc);
@@ -2620,7 +2617,6 @@ unpin:
2620static void dce_v10_0_cursor_reset(struct drm_crtc *crtc) 2617static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
2621{ 2618{
2622 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2619 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2623 struct amdgpu_device *adev = crtc->dev->dev_private;
2624 2620
2625 if (amdgpu_crtc->cursor_bo) { 2621 if (amdgpu_crtc->cursor_bo) {
2626 dce_v10_0_lock_cursor(crtc, true); 2622 dce_v10_0_lock_cursor(crtc, true);
@@ -2628,10 +2624,6 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
2628 dce_v10_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, 2624 dce_v10_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x,
2629 amdgpu_crtc->cursor_y); 2625 amdgpu_crtc->cursor_y);
2630 2626
2631 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2632 (amdgpu_crtc->cursor_width - 1) << 16 |
2633 (amdgpu_crtc->cursor_height - 1));
2634
2635 dce_v10_0_show_cursor(crtc); 2627 dce_v10_0_show_cursor(crtc);
2636 2628
2637 dce_v10_0_lock_cursor(crtc, false); 2629 dce_v10_0_lock_cursor(crtc, false);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index b3d62b909f43..a7af5b33a5e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -167,6 +167,7 @@ static void dce_v11_0_init_golden_registers(struct amdgpu_device *adev)
167 (const u32)ARRAY_SIZE(stoney_golden_settings_a11)); 167 (const u32)ARRAY_SIZE(stoney_golden_settings_a11));
168 break; 168 break;
169 case CHIP_POLARIS11: 169 case CHIP_POLARIS11:
170 case CHIP_POLARIS12:
170 amdgpu_program_register_sequence(adev, 171 amdgpu_program_register_sequence(adev,
171 polaris11_golden_settings_a11, 172 polaris11_golden_settings_a11,
172 (const u32)ARRAY_SIZE(polaris11_golden_settings_a11)); 173 (const u32)ARRAY_SIZE(polaris11_golden_settings_a11));
@@ -608,6 +609,7 @@ static int dce_v11_0_get_num_crtc (struct amdgpu_device *adev)
608 num_crtc = 6; 609 num_crtc = 6;
609 break; 610 break;
610 case CHIP_POLARIS11: 611 case CHIP_POLARIS11:
612 case CHIP_POLARIS12:
611 num_crtc = 5; 613 num_crtc = 5;
612 break; 614 break;
613 default: 615 default:
@@ -1589,6 +1591,7 @@ static int dce_v11_0_audio_init(struct amdgpu_device *adev)
1589 adev->mode_info.audio.num_pins = 8; 1591 adev->mode_info.audio.num_pins = 8;
1590 break; 1592 break;
1591 case CHIP_POLARIS11: 1593 case CHIP_POLARIS11:
1594 case CHIP_POLARIS12:
1592 adev->mode_info.audio.num_pins = 6; 1595 adev->mode_info.audio.num_pins = 6;
1593 break; 1596 break;
1594 default: 1597 default:
@@ -2388,7 +2391,8 @@ static u32 dce_v11_0_pick_pll(struct drm_crtc *crtc)
2388 int pll; 2391 int pll;
2389 2392
2390 if ((adev->asic_type == CHIP_POLARIS10) || 2393 if ((adev->asic_type == CHIP_POLARIS10) ||
2391 (adev->asic_type == CHIP_POLARIS11)) { 2394 (adev->asic_type == CHIP_POLARIS11) ||
2395 (adev->asic_type == CHIP_POLARIS12)) {
2392 struct amdgpu_encoder *amdgpu_encoder = 2396 struct amdgpu_encoder *amdgpu_encoder =
2393 to_amdgpu_encoder(amdgpu_crtc->encoder); 2397 to_amdgpu_encoder(amdgpu_crtc->encoder);
2394 struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; 2398 struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
@@ -2528,6 +2532,8 @@ static int dce_v11_0_cursor_move_locked(struct drm_crtc *crtc,
2528 2532
2529 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); 2533 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y);
2530 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); 2534 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin);
2535 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2536 ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1));
2531 2537
2532 return 0; 2538 return 0;
2533} 2539}
@@ -2553,7 +2559,6 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,
2553 int32_t hot_y) 2559 int32_t hot_y)
2554{ 2560{
2555 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2561 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2556 struct amdgpu_device *adev = crtc->dev->dev_private;
2557 struct drm_gem_object *obj; 2562 struct drm_gem_object *obj;
2558 struct amdgpu_bo *aobj; 2563 struct amdgpu_bo *aobj;
2559 int ret; 2564 int ret;
@@ -2594,7 +2599,9 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,
2594 2599
2595 dce_v11_0_lock_cursor(crtc, true); 2600 dce_v11_0_lock_cursor(crtc, true);
2596 2601
2597 if (hot_x != amdgpu_crtc->cursor_hot_x || 2602 if (width != amdgpu_crtc->cursor_width ||
2603 height != amdgpu_crtc->cursor_height ||
2604 hot_x != amdgpu_crtc->cursor_hot_x ||
2598 hot_y != amdgpu_crtc->cursor_hot_y) { 2605 hot_y != amdgpu_crtc->cursor_hot_y) {
2599 int x, y; 2606 int x, y;
2600 2607
@@ -2603,16 +2610,10 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,
2603 2610
2604 dce_v11_0_cursor_move_locked(crtc, x, y); 2611 dce_v11_0_cursor_move_locked(crtc, x, y);
2605 2612
2606 amdgpu_crtc->cursor_hot_x = hot_x;
2607 amdgpu_crtc->cursor_hot_y = hot_y;
2608 }
2609
2610 if (width != amdgpu_crtc->cursor_width ||
2611 height != amdgpu_crtc->cursor_height) {
2612 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2613 (width - 1) << 16 | (height - 1));
2614 amdgpu_crtc->cursor_width = width; 2613 amdgpu_crtc->cursor_width = width;
2615 amdgpu_crtc->cursor_height = height; 2614 amdgpu_crtc->cursor_height = height;
2615 amdgpu_crtc->cursor_hot_x = hot_x;
2616 amdgpu_crtc->cursor_hot_y = hot_y;
2616 } 2617 }
2617 2618
2618 dce_v11_0_show_cursor(crtc); 2619 dce_v11_0_show_cursor(crtc);
@@ -2636,7 +2637,6 @@ unpin:
2636static void dce_v11_0_cursor_reset(struct drm_crtc *crtc) 2637static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
2637{ 2638{
2638 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2639 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2639 struct amdgpu_device *adev = crtc->dev->dev_private;
2640 2640
2641 if (amdgpu_crtc->cursor_bo) { 2641 if (amdgpu_crtc->cursor_bo) {
2642 dce_v11_0_lock_cursor(crtc, true); 2642 dce_v11_0_lock_cursor(crtc, true);
@@ -2644,10 +2644,6 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
2644 dce_v11_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, 2644 dce_v11_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x,
2645 amdgpu_crtc->cursor_y); 2645 amdgpu_crtc->cursor_y);
2646 2646
2647 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2648 (amdgpu_crtc->cursor_width - 1) << 16 |
2649 (amdgpu_crtc->cursor_height - 1));
2650
2651 dce_v11_0_show_cursor(crtc); 2647 dce_v11_0_show_cursor(crtc);
2652 2648
2653 dce_v11_0_lock_cursor(crtc, false); 2649 dce_v11_0_lock_cursor(crtc, false);
@@ -2822,7 +2818,8 @@ static int dce_v11_0_crtc_mode_set(struct drm_crtc *crtc,
2822 return -EINVAL; 2818 return -EINVAL;
2823 2819
2824 if ((adev->asic_type == CHIP_POLARIS10) || 2820 if ((adev->asic_type == CHIP_POLARIS10) ||
2825 (adev->asic_type == CHIP_POLARIS11)) { 2821 (adev->asic_type == CHIP_POLARIS11) ||
2822 (adev->asic_type == CHIP_POLARIS12)) {
2826 struct amdgpu_encoder *amdgpu_encoder = 2823 struct amdgpu_encoder *amdgpu_encoder =
2827 to_amdgpu_encoder(amdgpu_crtc->encoder); 2824 to_amdgpu_encoder(amdgpu_crtc->encoder);
2828 int encoder_mode = 2825 int encoder_mode =
@@ -2992,6 +2989,7 @@ static int dce_v11_0_early_init(void *handle)
2992 adev->mode_info.num_dig = 6; 2989 adev->mode_info.num_dig = 6;
2993 break; 2990 break;
2994 case CHIP_POLARIS11: 2991 case CHIP_POLARIS11:
2992 case CHIP_POLARIS12:
2995 adev->mode_info.num_hpd = 5; 2993 adev->mode_info.num_hpd = 5;
2996 adev->mode_info.num_dig = 5; 2994 adev->mode_info.num_dig = 5;
2997 break; 2995 break;
@@ -3101,7 +3099,8 @@ static int dce_v11_0_hw_init(void *handle)
3101 amdgpu_atombios_crtc_powergate_init(adev); 3099 amdgpu_atombios_crtc_powergate_init(adev);
3102 amdgpu_atombios_encoder_init_dig(adev); 3100 amdgpu_atombios_encoder_init_dig(adev);
3103 if ((adev->asic_type == CHIP_POLARIS10) || 3101 if ((adev->asic_type == CHIP_POLARIS10) ||
3104 (adev->asic_type == CHIP_POLARIS11)) { 3102 (adev->asic_type == CHIP_POLARIS11) ||
3103 (adev->asic_type == CHIP_POLARIS12)) {
3105 amdgpu_atombios_crtc_set_dce_clock(adev, adev->clock.default_dispclk, 3104 amdgpu_atombios_crtc_set_dce_clock(adev, adev->clock.default_dispclk,
3106 DCE_CLOCK_TYPE_DISPCLK, ATOM_GCK_DFS); 3105 DCE_CLOCK_TYPE_DISPCLK, ATOM_GCK_DFS);
3107 amdgpu_atombios_crtc_set_dce_clock(adev, 0, 3106 amdgpu_atombios_crtc_set_dce_clock(adev, 0,
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index b4e4ec630e8c..39df6a50637f 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1859,6 +1859,8 @@ static int dce_v6_0_cursor_move_locked(struct drm_crtc *crtc,
1859 struct amdgpu_device *adev = crtc->dev->dev_private; 1859 struct amdgpu_device *adev = crtc->dev->dev_private;
1860 int xorigin = 0, yorigin = 0; 1860 int xorigin = 0, yorigin = 0;
1861 1861
1862 int w = amdgpu_crtc->cursor_width;
1863
1862 amdgpu_crtc->cursor_x = x; 1864 amdgpu_crtc->cursor_x = x;
1863 amdgpu_crtc->cursor_y = y; 1865 amdgpu_crtc->cursor_y = y;
1864 1866
@@ -1878,6 +1880,8 @@ static int dce_v6_0_cursor_move_locked(struct drm_crtc *crtc,
1878 1880
1879 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); 1881 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y);
1880 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); 1882 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin);
1883 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
1884 ((w - 1) << 16) | (amdgpu_crtc->cursor_height - 1));
1881 1885
1882 return 0; 1886 return 0;
1883} 1887}
@@ -1903,7 +1907,6 @@ static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc,
1903 int32_t hot_y) 1907 int32_t hot_y)
1904{ 1908{
1905 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 1909 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
1906 struct amdgpu_device *adev = crtc->dev->dev_private;
1907 struct drm_gem_object *obj; 1910 struct drm_gem_object *obj;
1908 struct amdgpu_bo *aobj; 1911 struct amdgpu_bo *aobj;
1909 int ret; 1912 int ret;
@@ -1944,7 +1947,9 @@ static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc,
1944 1947
1945 dce_v6_0_lock_cursor(crtc, true); 1948 dce_v6_0_lock_cursor(crtc, true);
1946 1949
1947 if (hot_x != amdgpu_crtc->cursor_hot_x || 1950 if (width != amdgpu_crtc->cursor_width ||
1951 height != amdgpu_crtc->cursor_height ||
1952 hot_x != amdgpu_crtc->cursor_hot_x ||
1948 hot_y != amdgpu_crtc->cursor_hot_y) { 1953 hot_y != amdgpu_crtc->cursor_hot_y) {
1949 int x, y; 1954 int x, y;
1950 1955
@@ -1953,16 +1958,10 @@ static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc,
1953 1958
1954 dce_v6_0_cursor_move_locked(crtc, x, y); 1959 dce_v6_0_cursor_move_locked(crtc, x, y);
1955 1960
1956 amdgpu_crtc->cursor_hot_x = hot_x;
1957 amdgpu_crtc->cursor_hot_y = hot_y;
1958 }
1959
1960 if (width != amdgpu_crtc->cursor_width ||
1961 height != amdgpu_crtc->cursor_height) {
1962 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
1963 (width - 1) << 16 | (height - 1));
1964 amdgpu_crtc->cursor_width = width; 1961 amdgpu_crtc->cursor_width = width;
1965 amdgpu_crtc->cursor_height = height; 1962 amdgpu_crtc->cursor_height = height;
1963 amdgpu_crtc->cursor_hot_x = hot_x;
1964 amdgpu_crtc->cursor_hot_y = hot_y;
1966 } 1965 }
1967 1966
1968 dce_v6_0_show_cursor(crtc); 1967 dce_v6_0_show_cursor(crtc);
@@ -1986,7 +1985,6 @@ unpin:
1986static void dce_v6_0_cursor_reset(struct drm_crtc *crtc) 1985static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
1987{ 1986{
1988 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 1987 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
1989 struct amdgpu_device *adev = crtc->dev->dev_private;
1990 1988
1991 if (amdgpu_crtc->cursor_bo) { 1989 if (amdgpu_crtc->cursor_bo) {
1992 dce_v6_0_lock_cursor(crtc, true); 1990 dce_v6_0_lock_cursor(crtc, true);
@@ -1994,10 +1992,6 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
1994 dce_v6_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, 1992 dce_v6_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x,
1995 amdgpu_crtc->cursor_y); 1993 amdgpu_crtc->cursor_y);
1996 1994
1997 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
1998 (amdgpu_crtc->cursor_width - 1) << 16 |
1999 (amdgpu_crtc->cursor_height - 1));
2000
2001 dce_v6_0_show_cursor(crtc); 1995 dce_v6_0_show_cursor(crtc);
2002 dce_v6_0_lock_cursor(crtc, false); 1996 dce_v6_0_lock_cursor(crtc, false);
2003 } 1997 }
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 584abe834a3c..28102bb1704d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2363,6 +2363,8 @@ static int dce_v8_0_cursor_move_locked(struct drm_crtc *crtc,
2363 2363
2364 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); 2364 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y);
2365 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); 2365 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin);
2366 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2367 ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1));
2366 2368
2367 return 0; 2369 return 0;
2368} 2370}
@@ -2388,7 +2390,6 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
2388 int32_t hot_y) 2390 int32_t hot_y)
2389{ 2391{
2390 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2392 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2391 struct amdgpu_device *adev = crtc->dev->dev_private;
2392 struct drm_gem_object *obj; 2393 struct drm_gem_object *obj;
2393 struct amdgpu_bo *aobj; 2394 struct amdgpu_bo *aobj;
2394 int ret; 2395 int ret;
@@ -2429,7 +2430,9 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
2429 2430
2430 dce_v8_0_lock_cursor(crtc, true); 2431 dce_v8_0_lock_cursor(crtc, true);
2431 2432
2432 if (hot_x != amdgpu_crtc->cursor_hot_x || 2433 if (width != amdgpu_crtc->cursor_width ||
2434 height != amdgpu_crtc->cursor_height ||
2435 hot_x != amdgpu_crtc->cursor_hot_x ||
2433 hot_y != amdgpu_crtc->cursor_hot_y) { 2436 hot_y != amdgpu_crtc->cursor_hot_y) {
2434 int x, y; 2437 int x, y;
2435 2438
@@ -2438,16 +2441,10 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
2438 2441
2439 dce_v8_0_cursor_move_locked(crtc, x, y); 2442 dce_v8_0_cursor_move_locked(crtc, x, y);
2440 2443
2441 amdgpu_crtc->cursor_hot_x = hot_x;
2442 amdgpu_crtc->cursor_hot_y = hot_y;
2443 }
2444
2445 if (width != amdgpu_crtc->cursor_width ||
2446 height != amdgpu_crtc->cursor_height) {
2447 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2448 (width - 1) << 16 | (height - 1));
2449 amdgpu_crtc->cursor_width = width; 2444 amdgpu_crtc->cursor_width = width;
2450 amdgpu_crtc->cursor_height = height; 2445 amdgpu_crtc->cursor_height = height;
2446 amdgpu_crtc->cursor_hot_x = hot_x;
2447 amdgpu_crtc->cursor_hot_y = hot_y;
2451 } 2448 }
2452 2449
2453 dce_v8_0_show_cursor(crtc); 2450 dce_v8_0_show_cursor(crtc);
@@ -2471,7 +2468,6 @@ unpin:
2471static void dce_v8_0_cursor_reset(struct drm_crtc *crtc) 2468static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
2472{ 2469{
2473 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2470 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2474 struct amdgpu_device *adev = crtc->dev->dev_private;
2475 2471
2476 if (amdgpu_crtc->cursor_bo) { 2472 if (amdgpu_crtc->cursor_bo) {
2477 dce_v8_0_lock_cursor(crtc, true); 2473 dce_v8_0_lock_cursor(crtc, true);
@@ -2479,10 +2475,6 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
2479 dce_v8_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, 2475 dce_v8_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x,
2480 amdgpu_crtc->cursor_y); 2476 amdgpu_crtc->cursor_y);
2481 2477
2482 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2483 (amdgpu_crtc->cursor_width - 1) << 16 |
2484 (amdgpu_crtc->cursor_height - 1));
2485
2486 dce_v8_0_show_cursor(crtc); 2478 dce_v8_0_show_cursor(crtc);
2487 2479
2488 dce_v8_0_lock_cursor(crtc, false); 2480 dce_v8_0_lock_cursor(crtc, false);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index d0ec00986f38..373374164bd5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -139,6 +139,13 @@ MODULE_FIRMWARE("amdgpu/polaris10_mec.bin");
139MODULE_FIRMWARE("amdgpu/polaris10_mec2.bin"); 139MODULE_FIRMWARE("amdgpu/polaris10_mec2.bin");
140MODULE_FIRMWARE("amdgpu/polaris10_rlc.bin"); 140MODULE_FIRMWARE("amdgpu/polaris10_rlc.bin");
141 141
142MODULE_FIRMWARE("amdgpu/polaris12_ce.bin");
143MODULE_FIRMWARE("amdgpu/polaris12_pfp.bin");
144MODULE_FIRMWARE("amdgpu/polaris12_me.bin");
145MODULE_FIRMWARE("amdgpu/polaris12_mec.bin");
146MODULE_FIRMWARE("amdgpu/polaris12_mec2.bin");
147MODULE_FIRMWARE("amdgpu/polaris12_rlc.bin");
148
142static const struct amdgpu_gds_reg_offset amdgpu_gds_reg_offset[] = 149static const struct amdgpu_gds_reg_offset amdgpu_gds_reg_offset[] =
143{ 150{
144 {mmGDS_VMID0_BASE, mmGDS_VMID0_SIZE, mmGDS_GWS_VMID0, mmGDS_OA_VMID0}, 151 {mmGDS_VMID0_BASE, mmGDS_VMID0_SIZE, mmGDS_GWS_VMID0, mmGDS_OA_VMID0},
@@ -689,6 +696,7 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
689 (const u32)ARRAY_SIZE(tonga_golden_common_all)); 696 (const u32)ARRAY_SIZE(tonga_golden_common_all));
690 break; 697 break;
691 case CHIP_POLARIS11: 698 case CHIP_POLARIS11:
699 case CHIP_POLARIS12:
692 amdgpu_program_register_sequence(adev, 700 amdgpu_program_register_sequence(adev,
693 golden_settings_polaris11_a11, 701 golden_settings_polaris11_a11,
694 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11)); 702 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11));
@@ -903,6 +911,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
903 case CHIP_POLARIS10: 911 case CHIP_POLARIS10:
904 chip_name = "polaris10"; 912 chip_name = "polaris10";
905 break; 913 break;
914 case CHIP_POLARIS12:
915 chip_name = "polaris12";
916 break;
906 case CHIP_STONEY: 917 case CHIP_STONEY:
907 chip_name = "stoney"; 918 chip_name = "stoney";
908 break; 919 break;
@@ -1768,6 +1779,7 @@ static int gfx_v8_0_gpu_early_init(struct amdgpu_device *adev)
1768 gb_addr_config = TONGA_GB_ADDR_CONFIG_GOLDEN; 1779 gb_addr_config = TONGA_GB_ADDR_CONFIG_GOLDEN;
1769 break; 1780 break;
1770 case CHIP_POLARIS11: 1781 case CHIP_POLARIS11:
1782 case CHIP_POLARIS12:
1771 ret = amdgpu_atombios_get_gfx_info(adev); 1783 ret = amdgpu_atombios_get_gfx_info(adev);
1772 if (ret) 1784 if (ret)
1773 return ret; 1785 return ret;
@@ -2682,6 +2694,7 @@ static void gfx_v8_0_tiling_mode_table_init(struct amdgpu_device *adev)
2682 2694
2683 break; 2695 break;
2684 case CHIP_POLARIS11: 2696 case CHIP_POLARIS11:
2697 case CHIP_POLARIS12:
2685 modearray[0] = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | 2698 modearray[0] = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
2686 PIPE_CONFIG(ADDR_SURF_P4_16x16) | 2699 PIPE_CONFIG(ADDR_SURF_P4_16x16) |
2687 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) | 2700 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
@@ -3503,6 +3516,7 @@ gfx_v8_0_raster_config(struct amdgpu_device *adev, u32 *rconf, u32 *rconf1)
3503 *rconf1 |= 0x0; 3516 *rconf1 |= 0x0;
3504 break; 3517 break;
3505 case CHIP_POLARIS11: 3518 case CHIP_POLARIS11:
3519 case CHIP_POLARIS12:
3506 *rconf |= RB_MAP_PKR0(2) | RB_XSEL2(1) | SE_MAP(2) | 3520 *rconf |= RB_MAP_PKR0(2) | RB_XSEL2(1) | SE_MAP(2) |
3507 SE_XSEL(1) | SE_YSEL(1); 3521 SE_XSEL(1) | SE_YSEL(1);
3508 *rconf1 |= 0x0; 3522 *rconf1 |= 0x0;
@@ -4021,7 +4035,8 @@ static void gfx_v8_0_init_pg(struct amdgpu_device *adev)
4021 cz_enable_cp_power_gating(adev, true); 4035 cz_enable_cp_power_gating(adev, true);
4022 else 4036 else
4023 cz_enable_cp_power_gating(adev, false); 4037 cz_enable_cp_power_gating(adev, false);
4024 } else if (adev->asic_type == CHIP_POLARIS11) { 4038 } else if ((adev->asic_type == CHIP_POLARIS11) ||
4039 (adev->asic_type == CHIP_POLARIS12)) {
4025 gfx_v8_0_init_csb(adev); 4040 gfx_v8_0_init_csb(adev);
4026 gfx_v8_0_init_save_restore_list(adev); 4041 gfx_v8_0_init_save_restore_list(adev);
4027 gfx_v8_0_enable_save_restore_machine(adev); 4042 gfx_v8_0_enable_save_restore_machine(adev);
@@ -4095,7 +4110,8 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
4095 RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK); 4110 RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK);
4096 WREG32(mmRLC_CGCG_CGLS_CTRL, tmp); 4111 WREG32(mmRLC_CGCG_CGLS_CTRL, tmp);
4097 if (adev->asic_type == CHIP_POLARIS11 || 4112 if (adev->asic_type == CHIP_POLARIS11 ||
4098 adev->asic_type == CHIP_POLARIS10) { 4113 adev->asic_type == CHIP_POLARIS10 ||
4114 adev->asic_type == CHIP_POLARIS12) {
4099 tmp = RREG32(mmRLC_CGCG_CGLS_CTRL_3D); 4115 tmp = RREG32(mmRLC_CGCG_CGLS_CTRL_3D);
4100 tmp &= ~0x3; 4116 tmp &= ~0x3;
4101 WREG32(mmRLC_CGCG_CGLS_CTRL_3D, tmp); 4117 WREG32(mmRLC_CGCG_CGLS_CTRL_3D, tmp);
@@ -4283,6 +4299,7 @@ static int gfx_v8_0_cp_gfx_start(struct amdgpu_device *adev)
4283 amdgpu_ring_write(ring, 0x0000002A); 4299 amdgpu_ring_write(ring, 0x0000002A);
4284 break; 4300 break;
4285 case CHIP_POLARIS11: 4301 case CHIP_POLARIS11:
4302 case CHIP_POLARIS12:
4286 amdgpu_ring_write(ring, 0x16000012); 4303 amdgpu_ring_write(ring, 0x16000012);
4287 amdgpu_ring_write(ring, 0x00000000); 4304 amdgpu_ring_write(ring, 0x00000000);
4288 break; 4305 break;
@@ -4664,7 +4681,8 @@ static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev)
4664 (adev->asic_type == CHIP_FIJI) || 4681 (adev->asic_type == CHIP_FIJI) ||
4665 (adev->asic_type == CHIP_STONEY) || 4682 (adev->asic_type == CHIP_STONEY) ||
4666 (adev->asic_type == CHIP_POLARIS11) || 4683 (adev->asic_type == CHIP_POLARIS11) ||
4667 (adev->asic_type == CHIP_POLARIS10)) { 4684 (adev->asic_type == CHIP_POLARIS10) ||
4685 (adev->asic_type == CHIP_POLARIS12)) {
4668 WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER, 4686 WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER,
4669 AMDGPU_DOORBELL_KIQ << 2); 4687 AMDGPU_DOORBELL_KIQ << 2);
4670 WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER, 4688 WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER,
@@ -4700,7 +4718,8 @@ static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev)
4700 mqd->cp_hqd_persistent_state = tmp; 4718 mqd->cp_hqd_persistent_state = tmp;
4701 if (adev->asic_type == CHIP_STONEY || 4719 if (adev->asic_type == CHIP_STONEY ||
4702 adev->asic_type == CHIP_POLARIS11 || 4720 adev->asic_type == CHIP_POLARIS11 ||
4703 adev->asic_type == CHIP_POLARIS10) { 4721 adev->asic_type == CHIP_POLARIS10 ||
4722 adev->asic_type == CHIP_POLARIS12) {
4704 tmp = RREG32(mmCP_ME1_PIPE3_INT_CNTL); 4723 tmp = RREG32(mmCP_ME1_PIPE3_INT_CNTL);
4705 tmp = REG_SET_FIELD(tmp, CP_ME1_PIPE3_INT_CNTL, GENERIC2_INT_ENABLE, 1); 4724 tmp = REG_SET_FIELD(tmp, CP_ME1_PIPE3_INT_CNTL, GENERIC2_INT_ENABLE, 1);
4706 WREG32(mmCP_ME1_PIPE3_INT_CNTL, tmp); 4725 WREG32(mmCP_ME1_PIPE3_INT_CNTL, tmp);
@@ -5279,7 +5298,8 @@ static int gfx_v8_0_late_init(void *handle)
5279static void gfx_v8_0_enable_gfx_static_mg_power_gating(struct amdgpu_device *adev, 5298static void gfx_v8_0_enable_gfx_static_mg_power_gating(struct amdgpu_device *adev,
5280 bool enable) 5299 bool enable)
5281{ 5300{
5282 if (adev->asic_type == CHIP_POLARIS11) 5301 if ((adev->asic_type == CHIP_POLARIS11) ||
5302 (adev->asic_type == CHIP_POLARIS12))
5283 /* Send msg to SMU via Powerplay */ 5303 /* Send msg to SMU via Powerplay */
5284 amdgpu_set_powergating_state(adev, 5304 amdgpu_set_powergating_state(adev,
5285 AMD_IP_BLOCK_TYPE_SMC, 5305 AMD_IP_BLOCK_TYPE_SMC,
@@ -5353,6 +5373,7 @@ static int gfx_v8_0_set_powergating_state(void *handle,
5353 gfx_v8_0_enable_gfx_dynamic_mg_power_gating(adev, false); 5373 gfx_v8_0_enable_gfx_dynamic_mg_power_gating(adev, false);
5354 break; 5374 break;
5355 case CHIP_POLARIS11: 5375 case CHIP_POLARIS11:
5376 case CHIP_POLARIS12:
5356 if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG) && enable) 5377 if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG) && enable)
5357 gfx_v8_0_enable_gfx_static_mg_power_gating(adev, true); 5378 gfx_v8_0_enable_gfx_static_mg_power_gating(adev, true);
5358 else 5379 else
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 45a573e63d4a..e2b0b1646f99 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -44,6 +44,7 @@ MODULE_FIRMWARE("radeon/tahiti_mc.bin");
44MODULE_FIRMWARE("radeon/pitcairn_mc.bin"); 44MODULE_FIRMWARE("radeon/pitcairn_mc.bin");
45MODULE_FIRMWARE("radeon/verde_mc.bin"); 45MODULE_FIRMWARE("radeon/verde_mc.bin");
46MODULE_FIRMWARE("radeon/oland_mc.bin"); 46MODULE_FIRMWARE("radeon/oland_mc.bin");
47MODULE_FIRMWARE("radeon/si58_mc.bin");
47 48
48#define MC_SEQ_MISC0__MT__MASK 0xf0000000 49#define MC_SEQ_MISC0__MT__MASK 0xf0000000
49#define MC_SEQ_MISC0__MT__GDDR1 0x10000000 50#define MC_SEQ_MISC0__MT__GDDR1 0x10000000
@@ -113,6 +114,7 @@ static int gmc_v6_0_init_microcode(struct amdgpu_device *adev)
113 const char *chip_name; 114 const char *chip_name;
114 char fw_name[30]; 115 char fw_name[30];
115 int err; 116 int err;
117 bool is_58_fw = false;
116 118
117 DRM_DEBUG("\n"); 119 DRM_DEBUG("\n");
118 120
@@ -135,7 +137,14 @@ static int gmc_v6_0_init_microcode(struct amdgpu_device *adev)
135 default: BUG(); 137 default: BUG();
136 } 138 }
137 139
138 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); 140 /* this memory configuration requires special firmware */
141 if (((RREG32(mmMC_SEQ_MISC0) & 0xff000000) >> 24) == 0x58)
142 is_58_fw = true;
143
144 if (is_58_fw)
145 snprintf(fw_name, sizeof(fw_name), "radeon/si58_mc.bin");
146 else
147 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
139 err = request_firmware(&adev->mc.fw, fw_name, adev->dev); 148 err = request_firmware(&adev->mc.fw, fw_name, adev->dev);
140 if (err) 149 if (err)
141 goto out; 150 goto out;
@@ -463,19 +472,11 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
463 WREG32(mmVM_CONTEXT1_CNTL, 472 WREG32(mmVM_CONTEXT1_CNTL,
464 VM_CONTEXT1_CNTL__ENABLE_CONTEXT_MASK | 473 VM_CONTEXT1_CNTL__ENABLE_CONTEXT_MASK |
465 (1UL << VM_CONTEXT1_CNTL__PAGE_TABLE_DEPTH__SHIFT) | 474 (1UL << VM_CONTEXT1_CNTL__PAGE_TABLE_DEPTH__SHIFT) |
466 ((amdgpu_vm_block_size - 9) << VM_CONTEXT1_CNTL__PAGE_TABLE_BLOCK_SIZE__SHIFT) | 475 ((amdgpu_vm_block_size - 9) << VM_CONTEXT1_CNTL__PAGE_TABLE_BLOCK_SIZE__SHIFT));
467 VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | 476 if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS)
468 VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK | 477 gmc_v6_0_set_fault_enable_default(adev, false);
469 VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK | 478 else
470 VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK | 479 gmc_v6_0_set_fault_enable_default(adev, true);
471 VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
472 VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_DEFAULT_MASK |
473 VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
474 VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_DEFAULT_MASK |
475 VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
476 VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_DEFAULT_MASK |
477 VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
478 VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_DEFAULT_MASK);
479 480
480 gmc_v6_0_gart_flush_gpu_tlb(adev, 0); 481 gmc_v6_0_gart_flush_gpu_tlb(adev, 0);
481 dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", 482 dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
@@ -754,7 +755,10 @@ static int gmc_v6_0_late_init(void *handle)
754{ 755{
755 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 756 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
756 757
757 return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0); 758 if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
759 return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
760 else
761 return 0;
758} 762}
759 763
760static int gmc_v6_0_sw_init(void *handle) 764static int gmc_v6_0_sw_init(void *handle)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 0daac3a5be79..476bc9f1954b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -46,6 +46,7 @@ static int gmc_v8_0_wait_for_idle(void *handle);
46MODULE_FIRMWARE("amdgpu/tonga_mc.bin"); 46MODULE_FIRMWARE("amdgpu/tonga_mc.bin");
47MODULE_FIRMWARE("amdgpu/polaris11_mc.bin"); 47MODULE_FIRMWARE("amdgpu/polaris11_mc.bin");
48MODULE_FIRMWARE("amdgpu/polaris10_mc.bin"); 48MODULE_FIRMWARE("amdgpu/polaris10_mc.bin");
49MODULE_FIRMWARE("amdgpu/polaris12_mc.bin");
49 50
50static const u32 golden_settings_tonga_a11[] = 51static const u32 golden_settings_tonga_a11[] =
51{ 52{
@@ -130,6 +131,7 @@ static void gmc_v8_0_init_golden_registers(struct amdgpu_device *adev)
130 (const u32)ARRAY_SIZE(golden_settings_tonga_a11)); 131 (const u32)ARRAY_SIZE(golden_settings_tonga_a11));
131 break; 132 break;
132 case CHIP_POLARIS11: 133 case CHIP_POLARIS11:
134 case CHIP_POLARIS12:
133 amdgpu_program_register_sequence(adev, 135 amdgpu_program_register_sequence(adev,
134 golden_settings_polaris11_a11, 136 golden_settings_polaris11_a11,
135 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11)); 137 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11));
@@ -225,6 +227,9 @@ static int gmc_v8_0_init_microcode(struct amdgpu_device *adev)
225 case CHIP_POLARIS10: 227 case CHIP_POLARIS10:
226 chip_name = "polaris10"; 228 chip_name = "polaris10";
227 break; 229 break;
230 case CHIP_POLARIS12:
231 chip_name = "polaris12";
232 break;
228 case CHIP_FIJI: 233 case CHIP_FIJI:
229 case CHIP_CARRIZO: 234 case CHIP_CARRIZO:
230 case CHIP_STONEY: 235 case CHIP_STONEY:
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 1170a64a3184..034ace79ed49 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -60,6 +60,8 @@ MODULE_FIRMWARE("amdgpu/polaris10_sdma.bin");
60MODULE_FIRMWARE("amdgpu/polaris10_sdma1.bin"); 60MODULE_FIRMWARE("amdgpu/polaris10_sdma1.bin");
61MODULE_FIRMWARE("amdgpu/polaris11_sdma.bin"); 61MODULE_FIRMWARE("amdgpu/polaris11_sdma.bin");
62MODULE_FIRMWARE("amdgpu/polaris11_sdma1.bin"); 62MODULE_FIRMWARE("amdgpu/polaris11_sdma1.bin");
63MODULE_FIRMWARE("amdgpu/polaris12_sdma.bin");
64MODULE_FIRMWARE("amdgpu/polaris12_sdma1.bin");
63 65
64 66
65static const u32 sdma_offsets[SDMA_MAX_INSTANCE] = 67static const u32 sdma_offsets[SDMA_MAX_INSTANCE] =
@@ -206,6 +208,7 @@ static void sdma_v3_0_init_golden_registers(struct amdgpu_device *adev)
206 (const u32)ARRAY_SIZE(golden_settings_tonga_a11)); 208 (const u32)ARRAY_SIZE(golden_settings_tonga_a11));
207 break; 209 break;
208 case CHIP_POLARIS11: 210 case CHIP_POLARIS11:
211 case CHIP_POLARIS12:
209 amdgpu_program_register_sequence(adev, 212 amdgpu_program_register_sequence(adev,
210 golden_settings_polaris11_a11, 213 golden_settings_polaris11_a11,
211 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11)); 214 (const u32)ARRAY_SIZE(golden_settings_polaris11_a11));
@@ -278,6 +281,9 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev)
278 case CHIP_POLARIS10: 281 case CHIP_POLARIS10:
279 chip_name = "polaris10"; 282 chip_name = "polaris10";
280 break; 283 break;
284 case CHIP_POLARIS12:
285 chip_name = "polaris12";
286 break;
281 case CHIP_CARRIZO: 287 case CHIP_CARRIZO:
282 chip_name = "carrizo"; 288 chip_name = "carrizo";
283 break; 289 break;
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
index 6c65a1a2de79..6e150db8f380 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
@@ -56,7 +56,6 @@
56#define BIOS_SCRATCH_4 0x5cd 56#define BIOS_SCRATCH_4 0x5cd
57 57
58MODULE_FIRMWARE("radeon/tahiti_smc.bin"); 58MODULE_FIRMWARE("radeon/tahiti_smc.bin");
59MODULE_FIRMWARE("radeon/tahiti_k_smc.bin");
60MODULE_FIRMWARE("radeon/pitcairn_smc.bin"); 59MODULE_FIRMWARE("radeon/pitcairn_smc.bin");
61MODULE_FIRMWARE("radeon/pitcairn_k_smc.bin"); 60MODULE_FIRMWARE("radeon/pitcairn_k_smc.bin");
62MODULE_FIRMWARE("radeon/verde_smc.bin"); 61MODULE_FIRMWARE("radeon/verde_smc.bin");
@@ -65,6 +64,7 @@ MODULE_FIRMWARE("radeon/oland_smc.bin");
65MODULE_FIRMWARE("radeon/oland_k_smc.bin"); 64MODULE_FIRMWARE("radeon/oland_k_smc.bin");
66MODULE_FIRMWARE("radeon/hainan_smc.bin"); 65MODULE_FIRMWARE("radeon/hainan_smc.bin");
67MODULE_FIRMWARE("radeon/hainan_k_smc.bin"); 66MODULE_FIRMWARE("radeon/hainan_k_smc.bin");
67MODULE_FIRMWARE("radeon/banks_k_2_smc.bin");
68 68
69union power_info { 69union power_info {
70 struct _ATOM_POWERPLAY_INFO info; 70 struct _ATOM_POWERPLAY_INFO info;
@@ -3488,30 +3488,6 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
3488 (adev->pdev->device == 0x6817) || 3488 (adev->pdev->device == 0x6817) ||
3489 (adev->pdev->device == 0x6806)) 3489 (adev->pdev->device == 0x6806))
3490 max_mclk = 120000; 3490 max_mclk = 120000;
3491 } else if (adev->asic_type == CHIP_VERDE) {
3492 if ((adev->pdev->revision == 0x81) ||
3493 (adev->pdev->revision == 0x83) ||
3494 (adev->pdev->revision == 0x87) ||
3495 (adev->pdev->device == 0x6820) ||
3496 (adev->pdev->device == 0x6821) ||
3497 (adev->pdev->device == 0x6822) ||
3498 (adev->pdev->device == 0x6823) ||
3499 (adev->pdev->device == 0x682A) ||
3500 (adev->pdev->device == 0x682B)) {
3501 max_sclk = 75000;
3502 max_mclk = 80000;
3503 }
3504 } else if (adev->asic_type == CHIP_OLAND) {
3505 if ((adev->pdev->revision == 0xC7) ||
3506 (adev->pdev->revision == 0x80) ||
3507 (adev->pdev->revision == 0x81) ||
3508 (adev->pdev->revision == 0x83) ||
3509 (adev->pdev->revision == 0x87) ||
3510 (adev->pdev->device == 0x6604) ||
3511 (adev->pdev->device == 0x6605)) {
3512 max_sclk = 75000;
3513 max_mclk = 80000;
3514 }
3515 } else if (adev->asic_type == CHIP_HAINAN) { 3491 } else if (adev->asic_type == CHIP_HAINAN) {
3516 if ((adev->pdev->revision == 0x81) || 3492 if ((adev->pdev->revision == 0x81) ||
3517 (adev->pdev->revision == 0x83) || 3493 (adev->pdev->revision == 0x83) ||
@@ -3520,7 +3496,6 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
3520 (adev->pdev->device == 0x6665) || 3496 (adev->pdev->device == 0x6665) ||
3521 (adev->pdev->device == 0x6667)) { 3497 (adev->pdev->device == 0x6667)) {
3522 max_sclk = 75000; 3498 max_sclk = 75000;
3523 max_mclk = 80000;
3524 } 3499 }
3525 } 3500 }
3526 /* Apply dpm quirks */ 3501 /* Apply dpm quirks */
@@ -7687,50 +7662,51 @@ static int si_dpm_init_microcode(struct amdgpu_device *adev)
7687 chip_name = "tahiti"; 7662 chip_name = "tahiti";
7688 break; 7663 break;
7689 case CHIP_PITCAIRN: 7664 case CHIP_PITCAIRN:
7690 if ((adev->pdev->revision == 0x81) || 7665 if ((adev->pdev->revision == 0x81) &&
7691 (adev->pdev->device == 0x6810) || 7666 ((adev->pdev->device == 0x6810) ||
7692 (adev->pdev->device == 0x6811) || 7667 (adev->pdev->device == 0x6811)))
7693 (adev->pdev->device == 0x6816) ||
7694 (adev->pdev->device == 0x6817) ||
7695 (adev->pdev->device == 0x6806))
7696 chip_name = "pitcairn_k"; 7668 chip_name = "pitcairn_k";
7697 else 7669 else
7698 chip_name = "pitcairn"; 7670 chip_name = "pitcairn";
7699 break; 7671 break;
7700 case CHIP_VERDE: 7672 case CHIP_VERDE:
7701 if ((adev->pdev->revision == 0x81) || 7673 if (((adev->pdev->device == 0x6820) &&
7702 (adev->pdev->revision == 0x83) || 7674 ((adev->pdev->revision == 0x81) ||
7703 (adev->pdev->revision == 0x87) || 7675 (adev->pdev->revision == 0x83))) ||
7704 (adev->pdev->device == 0x6820) || 7676 ((adev->pdev->device == 0x6821) &&
7705 (adev->pdev->device == 0x6821) || 7677 ((adev->pdev->revision == 0x83) ||
7706 (adev->pdev->device == 0x6822) || 7678 (adev->pdev->revision == 0x87))) ||
7707 (adev->pdev->device == 0x6823) || 7679 ((adev->pdev->revision == 0x87) &&
7708 (adev->pdev->device == 0x682A) || 7680 ((adev->pdev->device == 0x6823) ||
7709 (adev->pdev->device == 0x682B)) 7681 (adev->pdev->device == 0x682b))))
7710 chip_name = "verde_k"; 7682 chip_name = "verde_k";
7711 else 7683 else
7712 chip_name = "verde"; 7684 chip_name = "verde";
7713 break; 7685 break;
7714 case CHIP_OLAND: 7686 case CHIP_OLAND:
7715 if ((adev->pdev->revision == 0xC7) || 7687 if (((adev->pdev->revision == 0x81) &&
7716 (adev->pdev->revision == 0x80) || 7688 ((adev->pdev->device == 0x6600) ||
7717 (adev->pdev->revision == 0x81) || 7689 (adev->pdev->device == 0x6604) ||
7718 (adev->pdev->revision == 0x83) || 7690 (adev->pdev->device == 0x6605) ||
7719 (adev->pdev->revision == 0x87) || 7691 (adev->pdev->device == 0x6610))) ||
7720 (adev->pdev->device == 0x6604) || 7692 ((adev->pdev->revision == 0x83) &&
7721 (adev->pdev->device == 0x6605)) 7693 (adev->pdev->device == 0x6610)))
7722 chip_name = "oland_k"; 7694 chip_name = "oland_k";
7723 else 7695 else
7724 chip_name = "oland"; 7696 chip_name = "oland";
7725 break; 7697 break;
7726 case CHIP_HAINAN: 7698 case CHIP_HAINAN:
7727 if ((adev->pdev->revision == 0x81) || 7699 if (((adev->pdev->revision == 0x81) &&
7728 (adev->pdev->revision == 0x83) || 7700 (adev->pdev->device == 0x6660)) ||
7729 (adev->pdev->revision == 0xC3) || 7701 ((adev->pdev->revision == 0x83) &&
7730 (adev->pdev->device == 0x6664) || 7702 ((adev->pdev->device == 0x6660) ||
7731 (adev->pdev->device == 0x6665) || 7703 (adev->pdev->device == 0x6663) ||
7732 (adev->pdev->device == 0x6667)) 7704 (adev->pdev->device == 0x6665) ||
7705 (adev->pdev->device == 0x6667))))
7733 chip_name = "hainan_k"; 7706 chip_name = "hainan_k";
7707 else if ((adev->pdev->revision == 0xc3) &&
7708 (adev->pdev->device == 0x6665))
7709 chip_name = "banks_k_2";
7734 else 7710 else
7735 chip_name = "hainan"; 7711 chip_name = "hainan";
7736 break; 7712 break;
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
index 96444e4d862a..7fb9137dd89b 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
@@ -40,13 +40,14 @@
40#include "smu/smu_7_0_1_sh_mask.h" 40#include "smu/smu_7_0_1_sh_mask.h"
41 41
42static void uvd_v4_2_mc_resume(struct amdgpu_device *adev); 42static void uvd_v4_2_mc_resume(struct amdgpu_device *adev);
43static void uvd_v4_2_init_cg(struct amdgpu_device *adev);
44static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev); 43static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev);
45static void uvd_v4_2_set_irq_funcs(struct amdgpu_device *adev); 44static void uvd_v4_2_set_irq_funcs(struct amdgpu_device *adev);
46static int uvd_v4_2_start(struct amdgpu_device *adev); 45static int uvd_v4_2_start(struct amdgpu_device *adev);
47static void uvd_v4_2_stop(struct amdgpu_device *adev); 46static void uvd_v4_2_stop(struct amdgpu_device *adev);
48static int uvd_v4_2_set_clockgating_state(void *handle, 47static int uvd_v4_2_set_clockgating_state(void *handle,
49 enum amd_clockgating_state state); 48 enum amd_clockgating_state state);
49static void uvd_v4_2_set_dcm(struct amdgpu_device *adev,
50 bool sw_mode);
50/** 51/**
51 * uvd_v4_2_ring_get_rptr - get read pointer 52 * uvd_v4_2_ring_get_rptr - get read pointer
52 * 53 *
@@ -140,7 +141,8 @@ static int uvd_v4_2_sw_fini(void *handle)
140 141
141 return r; 142 return r;
142} 143}
143 144static void uvd_v4_2_enable_mgcg(struct amdgpu_device *adev,
145 bool enable);
144/** 146/**
145 * uvd_v4_2_hw_init - start and test UVD block 147 * uvd_v4_2_hw_init - start and test UVD block
146 * 148 *
@@ -155,8 +157,7 @@ static int uvd_v4_2_hw_init(void *handle)
155 uint32_t tmp; 157 uint32_t tmp;
156 int r; 158 int r;
157 159
158 uvd_v4_2_init_cg(adev); 160 uvd_v4_2_enable_mgcg(adev, true);
159 uvd_v4_2_set_clockgating_state(adev, AMD_CG_STATE_GATE);
160 amdgpu_asic_set_uvd_clocks(adev, 10000, 10000); 161 amdgpu_asic_set_uvd_clocks(adev, 10000, 10000);
161 r = uvd_v4_2_start(adev); 162 r = uvd_v4_2_start(adev);
162 if (r) 163 if (r)
@@ -266,11 +267,13 @@ static int uvd_v4_2_start(struct amdgpu_device *adev)
266 struct amdgpu_ring *ring = &adev->uvd.ring; 267 struct amdgpu_ring *ring = &adev->uvd.ring;
267 uint32_t rb_bufsz; 268 uint32_t rb_bufsz;
268 int i, j, r; 269 int i, j, r;
269
270 /* disable byte swapping */ 270 /* disable byte swapping */
271 u32 lmi_swap_cntl = 0; 271 u32 lmi_swap_cntl = 0;
272 u32 mp_swap_cntl = 0; 272 u32 mp_swap_cntl = 0;
273 273
274 WREG32(mmUVD_CGC_GATE, 0);
275 uvd_v4_2_set_dcm(adev, true);
276
274 uvd_v4_2_mc_resume(adev); 277 uvd_v4_2_mc_resume(adev);
275 278
276 /* disable interupt */ 279 /* disable interupt */
@@ -406,6 +409,8 @@ static void uvd_v4_2_stop(struct amdgpu_device *adev)
406 409
407 /* Unstall UMC and register bus */ 410 /* Unstall UMC and register bus */
408 WREG32_P(mmUVD_LMI_CTRL2, 0, ~(1 << 8)); 411 WREG32_P(mmUVD_LMI_CTRL2, 0, ~(1 << 8));
412
413 uvd_v4_2_set_dcm(adev, false);
409} 414}
410 415
411/** 416/**
@@ -619,19 +624,6 @@ static void uvd_v4_2_set_dcm(struct amdgpu_device *adev,
619 WREG32_UVD_CTX(ixUVD_CGC_CTRL2, tmp2); 624 WREG32_UVD_CTX(ixUVD_CGC_CTRL2, tmp2);
620} 625}
621 626
622static void uvd_v4_2_init_cg(struct amdgpu_device *adev)
623{
624 bool hw_mode = true;
625
626 if (hw_mode) {
627 uvd_v4_2_set_dcm(adev, false);
628 } else {
629 u32 tmp = RREG32(mmUVD_CGC_CTRL);
630 tmp &= ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK;
631 WREG32(mmUVD_CGC_CTRL, tmp);
632 }
633}
634
635static bool uvd_v4_2_is_idle(void *handle) 627static bool uvd_v4_2_is_idle(void *handle)
636{ 628{
637 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 629 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -685,17 +677,6 @@ static int uvd_v4_2_process_interrupt(struct amdgpu_device *adev,
685static int uvd_v4_2_set_clockgating_state(void *handle, 677static int uvd_v4_2_set_clockgating_state(void *handle,
686 enum amd_clockgating_state state) 678 enum amd_clockgating_state state)
687{ 679{
688 bool gate = false;
689 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
690
691 if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
692 return 0;
693
694 if (state == AMD_CG_STATE_GATE)
695 gate = true;
696
697 uvd_v4_2_enable_mgcg(adev, gate);
698
699 return 0; 680 return 0;
700} 681}
701 682
@@ -711,9 +692,6 @@ static int uvd_v4_2_set_powergating_state(void *handle,
711 */ 692 */
712 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 693 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
713 694
714 if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
715 return 0;
716
717 if (state == AMD_PG_STATE_GATE) { 695 if (state == AMD_PG_STATE_GATE) {
718 uvd_v4_2_stop(adev); 696 uvd_v4_2_stop(adev);
719 return 0; 697 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
index a79e283590fb..6de6becce745 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
@@ -791,15 +791,10 @@ static int uvd_v5_0_set_clockgating_state(void *handle,
791{ 791{
792 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 792 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
793 bool enable = (state == AMD_CG_STATE_GATE) ? true : false; 793 bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
794 static int curstate = -1;
795 794
796 if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG)) 795 if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
797 return 0; 796 return 0;
798 797
799 if (curstate == state)
800 return 0;
801
802 curstate = state;
803 if (enable) { 798 if (enable) {
804 /* wait for STATUS to clear */ 799 /* wait for STATUS to clear */
805 if (uvd_v5_0_wait_for_idle(handle)) 800 if (uvd_v5_0_wait_for_idle(handle))
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 6b3293a1c7b8..37ca685e5a9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -43,9 +43,13 @@
43 43
44#define GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT 0x04 44#define GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT 0x04
45#define GRBM_GFX_INDEX__VCE_INSTANCE_MASK 0x10 45#define GRBM_GFX_INDEX__VCE_INSTANCE_MASK 0x10
46#define GRBM_GFX_INDEX__VCE_ALL_PIPE 0x07
47
46#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR0 0x8616 48#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR0 0x8616
47#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR1 0x8617 49#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR1 0x8617
48#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR2 0x8618 50#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR2 0x8618
51#define mmGRBM_GFX_INDEX_DEFAULT 0xE0000000
52
49#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02 53#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
50 54
51#define VCE_V3_0_FW_SIZE (384 * 1024) 55#define VCE_V3_0_FW_SIZE (384 * 1024)
@@ -54,6 +58,9 @@
54 58
55#define FW_52_8_3 ((52 << 24) | (8 << 16) | (3 << 8)) 59#define FW_52_8_3 ((52 << 24) | (8 << 16) | (3 << 8))
56 60
61#define GET_VCE_INSTANCE(i) ((i) << GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT \
62 | GRBM_GFX_INDEX__VCE_ALL_PIPE)
63
57static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx); 64static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx);
58static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev); 65static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev);
59static void vce_v3_0_set_irq_funcs(struct amdgpu_device *adev); 66static void vce_v3_0_set_irq_funcs(struct amdgpu_device *adev);
@@ -175,7 +182,7 @@ static void vce_v3_0_set_vce_sw_clock_gating(struct amdgpu_device *adev,
175 WREG32(mmVCE_UENC_CLOCK_GATING_2, data); 182 WREG32(mmVCE_UENC_CLOCK_GATING_2, data);
176 183
177 data = RREG32(mmVCE_UENC_REG_CLOCK_GATING); 184 data = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
178 data &= ~0xffc00000; 185 data &= ~0x3ff;
179 WREG32(mmVCE_UENC_REG_CLOCK_GATING, data); 186 WREG32(mmVCE_UENC_REG_CLOCK_GATING, data);
180 187
181 data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL); 188 data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL);
@@ -249,7 +256,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
249 if (adev->vce.harvest_config & (1 << idx)) 256 if (adev->vce.harvest_config & (1 << idx))
250 continue; 257 continue;
251 258
252 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, idx); 259 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx));
253 vce_v3_0_mc_resume(adev, idx); 260 vce_v3_0_mc_resume(adev, idx);
254 WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1); 261 WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1);
255 262
@@ -273,7 +280,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
273 } 280 }
274 } 281 }
275 282
276 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0); 283 WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
277 mutex_unlock(&adev->grbm_idx_mutex); 284 mutex_unlock(&adev->grbm_idx_mutex);
278 285
279 return 0; 286 return 0;
@@ -288,7 +295,7 @@ static int vce_v3_0_stop(struct amdgpu_device *adev)
288 if (adev->vce.harvest_config & (1 << idx)) 295 if (adev->vce.harvest_config & (1 << idx))
289 continue; 296 continue;
290 297
291 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, idx); 298 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx));
292 299
293 if (adev->asic_type >= CHIP_STONEY) 300 if (adev->asic_type >= CHIP_STONEY)
294 WREG32_P(mmVCE_VCPU_CNTL, 0, ~0x200001); 301 WREG32_P(mmVCE_VCPU_CNTL, 0, ~0x200001);
@@ -306,7 +313,7 @@ static int vce_v3_0_stop(struct amdgpu_device *adev)
306 vce_v3_0_set_vce_sw_clock_gating(adev, false); 313 vce_v3_0_set_vce_sw_clock_gating(adev, false);
307 } 314 }
308 315
309 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0); 316 WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
310 mutex_unlock(&adev->grbm_idx_mutex); 317 mutex_unlock(&adev->grbm_idx_mutex);
311 318
312 return 0; 319 return 0;
@@ -320,11 +327,12 @@ static unsigned vce_v3_0_get_harvest_config(struct amdgpu_device *adev)
320{ 327{
321 u32 tmp; 328 u32 tmp;
322 329
323 /* Fiji, Stoney, Polaris10, Polaris11 are single pipe */ 330 /* Fiji, Stoney, Polaris10, Polaris11, Polaris12 are single pipe */
324 if ((adev->asic_type == CHIP_FIJI) || 331 if ((adev->asic_type == CHIP_FIJI) ||
325 (adev->asic_type == CHIP_STONEY) || 332 (adev->asic_type == CHIP_STONEY) ||
326 (adev->asic_type == CHIP_POLARIS10) || 333 (adev->asic_type == CHIP_POLARIS10) ||
327 (adev->asic_type == CHIP_POLARIS11)) 334 (adev->asic_type == CHIP_POLARIS11) ||
335 (adev->asic_type == CHIP_POLARIS12))
328 return AMDGPU_VCE_HARVEST_VCE1; 336 return AMDGPU_VCE_HARVEST_VCE1;
329 337
330 /* Tonga and CZ are dual or single pipe */ 338 /* Tonga and CZ are dual or single pipe */
@@ -585,17 +593,17 @@ static bool vce_v3_0_check_soft_reset(void *handle)
585 * VCE team suggest use bit 3--bit 6 for busy status check 593 * VCE team suggest use bit 3--bit 6 for busy status check
586 */ 594 */
587 mutex_lock(&adev->grbm_idx_mutex); 595 mutex_lock(&adev->grbm_idx_mutex);
588 WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0); 596 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(0));
589 if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) { 597 if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) {
590 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1); 598 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1);
591 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1); 599 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1);
592 } 600 }
593 WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0x10); 601 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
594 if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) { 602 if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) {
595 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1); 603 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1);
596 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1); 604 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1);
597 } 605 }
598 WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0); 606 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(0));
599 mutex_unlock(&adev->grbm_idx_mutex); 607 mutex_unlock(&adev->grbm_idx_mutex);
600 608
601 if (srbm_soft_reset) { 609 if (srbm_soft_reset) {
@@ -733,7 +741,7 @@ static int vce_v3_0_set_clockgating_state(void *handle,
733 if (adev->vce.harvest_config & (1 << i)) 741 if (adev->vce.harvest_config & (1 << i))
734 continue; 742 continue;
735 743
736 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, i); 744 WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(i));
737 745
738 if (enable) { 746 if (enable) {
739 /* initialize VCE_CLOCK_GATING_A: Clock ON/OFF delay */ 747 /* initialize VCE_CLOCK_GATING_A: Clock ON/OFF delay */
@@ -752,7 +760,7 @@ static int vce_v3_0_set_clockgating_state(void *handle,
752 vce_v3_0_set_vce_sw_clock_gating(adev, enable); 760 vce_v3_0_set_vce_sw_clock_gating(adev, enable);
753 } 761 }
754 762
755 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0); 763 WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
756 mutex_unlock(&adev->grbm_idx_mutex); 764 mutex_unlock(&adev->grbm_idx_mutex);
757 765
758 return 0; 766 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index bf088d6d9bf1..c2ac54f11341 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -88,6 +88,7 @@ MODULE_FIRMWARE("amdgpu/polaris10_smc.bin");
88MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin"); 88MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin");
89MODULE_FIRMWARE("amdgpu/polaris11_smc.bin"); 89MODULE_FIRMWARE("amdgpu/polaris11_smc.bin");
90MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); 90MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin");
91MODULE_FIRMWARE("amdgpu/polaris12_smc.bin");
91 92
92/* 93/*
93 * Indirect registers accessor 94 * Indirect registers accessor
@@ -312,6 +313,7 @@ static void vi_init_golden_registers(struct amdgpu_device *adev)
312 break; 313 break;
313 case CHIP_POLARIS11: 314 case CHIP_POLARIS11:
314 case CHIP_POLARIS10: 315 case CHIP_POLARIS10:
316 case CHIP_POLARIS12:
315 default: 317 default:
316 break; 318 break;
317 } 319 }
@@ -671,6 +673,7 @@ static int vi_read_register(struct amdgpu_device *adev, u32 se_num,
671 case CHIP_TONGA: 673 case CHIP_TONGA:
672 case CHIP_POLARIS11: 674 case CHIP_POLARIS11:
673 case CHIP_POLARIS10: 675 case CHIP_POLARIS10:
676 case CHIP_POLARIS12:
674 case CHIP_CARRIZO: 677 case CHIP_CARRIZO:
675 case CHIP_STONEY: 678 case CHIP_STONEY:
676 asic_register_table = cz_allowed_read_registers; 679 asic_register_table = cz_allowed_read_registers;
@@ -994,6 +997,11 @@ static int vi_common_early_init(void *handle)
994 adev->pg_flags = 0; 997 adev->pg_flags = 0;
995 adev->external_rev_id = adev->rev_id + 0x50; 998 adev->external_rev_id = adev->rev_id + 0x50;
996 break; 999 break;
1000 case CHIP_POLARIS12:
1001 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG;
1002 adev->pg_flags = 0;
1003 adev->external_rev_id = adev->rev_id + 0x64;
1004 break;
997 case CHIP_CARRIZO: 1005 case CHIP_CARRIZO:
998 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG | 1006 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG |
999 AMD_CG_SUPPORT_GFX_MGCG | 1007 AMD_CG_SUPPORT_GFX_MGCG |
@@ -1346,6 +1354,7 @@ static int vi_common_set_clockgating_state(void *handle,
1346 case CHIP_TONGA: 1354 case CHIP_TONGA:
1347 case CHIP_POLARIS10: 1355 case CHIP_POLARIS10:
1348 case CHIP_POLARIS11: 1356 case CHIP_POLARIS11:
1357 case CHIP_POLARIS12:
1349 vi_common_set_clockgating_state_by_smu(adev, state); 1358 vi_common_set_clockgating_state_by_smu(adev, state);
1350 default: 1359 default:
1351 break; 1360 break;
@@ -1429,6 +1438,7 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1429 break; 1438 break;
1430 case CHIP_POLARIS11: 1439 case CHIP_POLARIS11:
1431 case CHIP_POLARIS10: 1440 case CHIP_POLARIS10:
1441 case CHIP_POLARIS12:
1432 amdgpu_ip_block_add(adev, &vi_common_ip_block); 1442 amdgpu_ip_block_add(adev, &vi_common_ip_block);
1433 amdgpu_ip_block_add(adev, &gmc_v8_1_ip_block); 1443 amdgpu_ip_block_add(adev, &gmc_v8_1_ip_block);
1434 amdgpu_ip_block_add(adev, &tonga_ih_ip_block); 1444 amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index c02469ada9f1..85f358764bbc 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -23,7 +23,7 @@
23#ifndef __AMD_SHARED_H__ 23#ifndef __AMD_SHARED_H__
24#define __AMD_SHARED_H__ 24#define __AMD_SHARED_H__
25 25
26#define AMD_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 26#define AMD_MAX_USEC_TIMEOUT 200000 /* 200 ms */
27 27
28/* 28/*
29 * Supported ASIC types 29 * Supported ASIC types
@@ -46,6 +46,7 @@ enum amd_asic_type {
46 CHIP_STONEY, 46 CHIP_STONEY,
47 CHIP_POLARIS10, 47 CHIP_POLARIS10,
48 CHIP_POLARIS11, 48 CHIP_POLARIS11,
49 CHIP_POLARIS12,
49 CHIP_LAST, 50 CHIP_LAST,
50}; 51};
51 52
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
index b0c63c5f54c9..6bb79c94cb9f 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
@@ -200,7 +200,7 @@ int cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
200 cgs_set_clockgating_state( 200 cgs_set_clockgating_state(
201 hwmgr->device, 201 hwmgr->device,
202 AMD_IP_BLOCK_TYPE_VCE, 202 AMD_IP_BLOCK_TYPE_VCE,
203 AMD_CG_STATE_UNGATE); 203 AMD_CG_STATE_GATE);
204 cgs_set_powergating_state( 204 cgs_set_powergating_state(
205 hwmgr->device, 205 hwmgr->device,
206 AMD_IP_BLOCK_TYPE_VCE, 206 AMD_IP_BLOCK_TYPE_VCE,
@@ -218,7 +218,7 @@ int cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
218 cgs_set_clockgating_state( 218 cgs_set_clockgating_state(
219 hwmgr->device, 219 hwmgr->device,
220 AMD_IP_BLOCK_TYPE_VCE, 220 AMD_IP_BLOCK_TYPE_VCE,
221 AMD_PG_STATE_GATE); 221 AMD_PG_STATE_UNGATE);
222 cz_dpm_update_vce_dpm(hwmgr); 222 cz_dpm_update_vce_dpm(hwmgr);
223 cz_enable_disable_vce_dpm(hwmgr, true); 223 cz_enable_disable_vce_dpm(hwmgr, true);
224 return 0; 224 return 0;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index 4b14f259a147..0fb4e8c8f5e1 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -1402,14 +1402,22 @@ int cz_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr)
1402 cz_hwmgr->vce_dpm.hard_min_clk, 1402 cz_hwmgr->vce_dpm.hard_min_clk,
1403 PPSMC_MSG_SetEclkHardMin)); 1403 PPSMC_MSG_SetEclkHardMin));
1404 } else { 1404 } else {
1405 /*EPR# 419220 -HW limitation to to */ 1405 /*Program HardMin based on the vce_arbiter.ecclk */
1406 cz_hwmgr->vce_dpm.hard_min_clk = hwmgr->vce_arbiter.ecclk; 1406 if (hwmgr->vce_arbiter.ecclk == 0) {
1407 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, 1407 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
1408 PPSMC_MSG_SetEclkHardMin, 1408 PPSMC_MSG_SetEclkHardMin, 0);
1409 cz_get_eclk_level(hwmgr, 1409 /* disable ECLK DPM 0. Otherwise VCE could hang if
1410 cz_hwmgr->vce_dpm.hard_min_clk, 1410 * switching SCLK from DPM 0 to 6/7 */
1411 PPSMC_MSG_SetEclkHardMin)); 1411 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
1412 1412 PPSMC_MSG_SetEclkSoftMin, 1);
1413 } else {
1414 cz_hwmgr->vce_dpm.hard_min_clk = hwmgr->vce_arbiter.ecclk;
1415 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
1416 PPSMC_MSG_SetEclkHardMin,
1417 cz_get_eclk_level(hwmgr,
1418 cz_hwmgr->vce_dpm.hard_min_clk,
1419 PPSMC_MSG_SetEclkHardMin));
1420 }
1413 } 1421 }
1414 return 0; 1422 return 0;
1415} 1423}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index dc6700aee18f..b03606405a53 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -95,6 +95,7 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
95 break; 95 break;
96 case CHIP_POLARIS11: 96 case CHIP_POLARIS11:
97 case CHIP_POLARIS10: 97 case CHIP_POLARIS10:
98 case CHIP_POLARIS12:
98 polaris_set_asic_special_caps(hwmgr); 99 polaris_set_asic_special_caps(hwmgr);
99 hwmgr->feature_mask &= ~(PP_UVD_HANDSHAKE_MASK); 100 hwmgr->feature_mask &= ~(PP_UVD_HANDSHAKE_MASK);
100 break; 101 break;
@@ -745,7 +746,7 @@ int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr)
745 phm_cap_set(hwmgr->platform_descriptor.platformCaps, 746 phm_cap_set(hwmgr->platform_descriptor.platformCaps,
746 PHM_PlatformCaps_TablelessHardwareInterface); 747 PHM_PlatformCaps_TablelessHardwareInterface);
747 748
748 if (hwmgr->chip_id == CHIP_POLARIS11) 749 if ((hwmgr->chip_id == CHIP_POLARIS11) || (hwmgr->chip_id == CHIP_POLARIS12))
749 phm_cap_set(hwmgr->platform_descriptor.platformCaps, 750 phm_cap_set(hwmgr->platform_descriptor.platformCaps,
750 PHM_PlatformCaps_SPLLShutdownSupport); 751 PHM_PlatformCaps_SPLLShutdownSupport);
751 return 0; 752 return 0;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
index 26477f0f09dc..6cd1287a7a8f 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
@@ -521,7 +521,7 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr)
521 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); 521 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result);
522 result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris10); 522 result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris10);
523 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); 523 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result);
524 } else if (hwmgr->chip_id == CHIP_POLARIS11) { 524 } else if ((hwmgr->chip_id == CHIP_POLARIS11) || (hwmgr->chip_id == CHIP_POLARIS12)) {
525 result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); 525 result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11);
526 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); 526 PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result);
527 result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11); 527 result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11);
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index e5812aa456f3..6e618aa20719 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -65,6 +65,7 @@ int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
65 break; 65 break;
66 case CHIP_POLARIS11: 66 case CHIP_POLARIS11:
67 case CHIP_POLARIS10: 67 case CHIP_POLARIS10:
68 case CHIP_POLARIS12:
68 polaris10_smum_init(smumgr); 69 polaris10_smum_init(smumgr);
69 break; 70 break;
70 default: 71 default:
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index eb9bf8786c24..18eefdcbf1ba 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1382,6 +1382,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
1382 1382
1383 pm_runtime_enable(dev); 1383 pm_runtime_enable(dev);
1384 1384
1385 pm_runtime_get_sync(dev);
1385 phy_power_on(dp->phy); 1386 phy_power_on(dp->phy);
1386 1387
1387 analogix_dp_init_dp(dp); 1388 analogix_dp_init_dp(dp);
@@ -1414,9 +1415,15 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
1414 goto err_disable_pm_runtime; 1415 goto err_disable_pm_runtime;
1415 } 1416 }
1416 1417
1418 phy_power_off(dp->phy);
1419 pm_runtime_put(dev);
1420
1417 return 0; 1421 return 0;
1418 1422
1419err_disable_pm_runtime: 1423err_disable_pm_runtime:
1424
1425 phy_power_off(dp->phy);
1426 pm_runtime_put(dev);
1420 pm_runtime_disable(dev); 1427 pm_runtime_disable(dev);
1421 1428
1422 return ret; 1429 return ret;
diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
index 04b3c161dfae..7f4cc6e172ab 100644
--- a/drivers/gpu/drm/cirrus/Kconfig
+++ b/drivers/gpu/drm/cirrus/Kconfig
@@ -7,3 +7,12 @@ config DRM_CIRRUS_QEMU
7 This is a KMS driver for emulated cirrus device in qemu. 7 This is a KMS driver for emulated cirrus device in qemu.
8 It is *NOT* intended for real cirrus devices. This requires 8 It is *NOT* intended for real cirrus devices. This requires
9 the modesetting userspace X.org driver. 9 the modesetting userspace X.org driver.
10
11 Cirrus is obsolete, the hardware was designed in the 90ies
12 and can't keep up with todays needs. More background:
13 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
14
15 Better alternatives are:
16 - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
17 - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
18 - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 583f47f27b36..34f757bcabae 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1259,8 +1259,10 @@ int drm_atomic_helper_commit(struct drm_device *dev,
1259 1259
1260 if (!nonblock) { 1260 if (!nonblock) {
1261 ret = drm_atomic_helper_wait_for_fences(dev, state, true); 1261 ret = drm_atomic_helper_wait_for_fences(dev, state, true);
1262 if (ret) 1262 if (ret) {
1263 drm_atomic_helper_cleanup_planes(dev, state);
1263 return ret; 1264 return ret;
1265 }
1264 } 1266 }
1265 1267
1266 /* 1268 /*
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ac6a35212501..e6b19bc9021a 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1460 return NULL; 1460 return NULL;
1461 1461
1462 mode->type |= DRM_MODE_TYPE_USERDEF; 1462 mode->type |= DRM_MODE_TYPE_USERDEF;
1463 /* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
1464 if (cmd->xres == 1366 && mode->hdisplay == 1368) {
1465 mode->hdisplay = 1366;
1466 mode->hsync_start--;
1467 mode->hsync_end--;
1468 drm_mode_set_name(mode);
1469 }
1463 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 1470 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1464 return mode; 1471 return mode;
1465} 1472}
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index ac953f037be7..b452a7ccd84b 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -115,24 +115,27 @@ static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
115 115
116#define DRM_OUTPUT_POLL_PERIOD (10*HZ) 116#define DRM_OUTPUT_POLL_PERIOD (10*HZ)
117/** 117/**
118 * drm_kms_helper_poll_enable_locked - re-enable output polling. 118 * drm_kms_helper_poll_enable - re-enable output polling.
119 * @dev: drm_device 119 * @dev: drm_device
120 * 120 *
121 * This function re-enables the output polling work without 121 * This function re-enables the output polling work, after it has been
122 * locking the mode_config mutex. 122 * temporarily disabled using drm_kms_helper_poll_disable(), for example over
123 * suspend/resume.
123 * 124 *
124 * This is like drm_kms_helper_poll_enable() however it is to be 125 * Drivers can call this helper from their device resume implementation. It is
125 * called from a context where the mode_config mutex is locked 126 * an error to call this when the output polling support has not yet been set
126 * already. 127 * up.
128 *
129 * Note that calls to enable and disable polling must be strictly ordered, which
130 * is automatically the case when they're only call from suspend/resume
131 * callbacks.
127 */ 132 */
128void drm_kms_helper_poll_enable_locked(struct drm_device *dev) 133void drm_kms_helper_poll_enable(struct drm_device *dev)
129{ 134{
130 bool poll = false; 135 bool poll = false;
131 struct drm_connector *connector; 136 struct drm_connector *connector;
132 unsigned long delay = DRM_OUTPUT_POLL_PERIOD; 137 unsigned long delay = DRM_OUTPUT_POLL_PERIOD;
133 138
134 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
135
136 if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll) 139 if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll)
137 return; 140 return;
138 141
@@ -143,14 +146,24 @@ void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
143 } 146 }
144 147
145 if (dev->mode_config.delayed_event) { 148 if (dev->mode_config.delayed_event) {
149 /*
150 * FIXME:
151 *
152 * Use short (1s) delay to handle the initial delayed event.
153 * This delay should not be needed, but Optimus/nouveau will
154 * fail in a mysterious way if the delayed event is handled as
155 * soon as possible like it is done in
156 * drm_helper_probe_single_connector_modes() in case the poll
157 * was enabled before.
158 */
146 poll = true; 159 poll = true;
147 delay = 0; 160 delay = HZ;
148 } 161 }
149 162
150 if (poll) 163 if (poll)
151 schedule_delayed_work(&dev->mode_config.output_poll_work, delay); 164 schedule_delayed_work(&dev->mode_config.output_poll_work, delay);
152} 165}
153EXPORT_SYMBOL(drm_kms_helper_poll_enable_locked); 166EXPORT_SYMBOL(drm_kms_helper_poll_enable);
154 167
155static enum drm_connector_status 168static enum drm_connector_status
156drm_connector_detect(struct drm_connector *connector, bool force) 169drm_connector_detect(struct drm_connector *connector, bool force)
@@ -277,7 +290,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
277 290
278 /* Re-enable polling in case the global poll config changed. */ 291 /* Re-enable polling in case the global poll config changed. */
279 if (drm_kms_helper_poll != dev->mode_config.poll_running) 292 if (drm_kms_helper_poll != dev->mode_config.poll_running)
280 drm_kms_helper_poll_enable_locked(dev); 293 drm_kms_helper_poll_enable(dev);
281 294
282 dev->mode_config.poll_running = drm_kms_helper_poll; 295 dev->mode_config.poll_running = drm_kms_helper_poll;
283 296
@@ -469,8 +482,12 @@ out:
469 * This function disables the output polling work. 482 * This function disables the output polling work.
470 * 483 *
471 * Drivers can call this helper from their device suspend implementation. It is 484 * Drivers can call this helper from their device suspend implementation. It is
472 * not an error to call this even when output polling isn't enabled or arlready 485 * not an error to call this even when output polling isn't enabled or already
473 * disabled. 486 * disabled. Polling is re-enabled by calling drm_kms_helper_poll_enable().
487 *
488 * Note that calls to enable and disable polling must be strictly ordered, which
489 * is automatically the case when they're only call from suspend/resume
490 * callbacks.
474 */ 491 */
475void drm_kms_helper_poll_disable(struct drm_device *dev) 492void drm_kms_helper_poll_disable(struct drm_device *dev)
476{ 493{
@@ -481,24 +498,6 @@ void drm_kms_helper_poll_disable(struct drm_device *dev)
481EXPORT_SYMBOL(drm_kms_helper_poll_disable); 498EXPORT_SYMBOL(drm_kms_helper_poll_disable);
482 499
483/** 500/**
484 * drm_kms_helper_poll_enable - re-enable output polling.
485 * @dev: drm_device
486 *
487 * This function re-enables the output polling work.
488 *
489 * Drivers can call this helper from their device resume implementation. It is
490 * an error to call this when the output polling support has not yet been set
491 * up.
492 */
493void drm_kms_helper_poll_enable(struct drm_device *dev)
494{
495 mutex_lock(&dev->mode_config.mutex);
496 drm_kms_helper_poll_enable_locked(dev);
497 mutex_unlock(&dev->mode_config.mutex);
498}
499EXPORT_SYMBOL(drm_kms_helper_poll_enable);
500
501/**
502 * drm_kms_helper_poll_init - initialize and enable output polling 501 * drm_kms_helper_poll_init - initialize and enable output polling
503 * @dev: drm_device 502 * @dev: drm_device
504 * 503 *
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
index 169ac96e8f08..fe0e85b41310 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
@@ -116,9 +116,14 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,
116 struct list_head list; 116 struct list_head list;
117 bool found; 117 bool found;
118 118
119 /*
120 * XXX: The DRM_MM_SEARCH_BELOW is really a hack to trick
121 * drm_mm into giving out a low IOVA after address space
122 * rollover. This needs a proper fix.
123 */
119 ret = drm_mm_insert_node_in_range(&mmu->mm, node, 124 ret = drm_mm_insert_node_in_range(&mmu->mm, node,
120 size, 0, mmu->last_iova, ~0UL, 125 size, 0, mmu->last_iova, ~0UL,
121 DRM_MM_SEARCH_DEFAULT); 126 mmu->last_iova ? DRM_MM_SEARCH_DEFAULT : DRM_MM_SEARCH_BELOW);
122 127
123 if (ret != -ENOSPC) 128 if (ret != -ENOSPC)
124 break; 129 break;
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 6ca1f3117fe8..75eeb831ed6a 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -46,7 +46,8 @@ enum decon_flag_bits {
46 BIT_CLKS_ENABLED, 46 BIT_CLKS_ENABLED,
47 BIT_IRQS_ENABLED, 47 BIT_IRQS_ENABLED,
48 BIT_WIN_UPDATED, 48 BIT_WIN_UPDATED,
49 BIT_SUSPENDED 49 BIT_SUSPENDED,
50 BIT_REQUEST_UPDATE
50}; 51};
51 52
52struct decon_context { 53struct decon_context {
@@ -141,12 +142,6 @@ static void decon_commit(struct exynos_drm_crtc *crtc)
141 m->crtc_vsync_end = m->crtc_vsync_start + 1; 142 m->crtc_vsync_end = m->crtc_vsync_start + 1;
142 } 143 }
143 144
144 decon_set_bits(ctx, DECON_VIDCON0, VIDCON0_ENVID, 0);
145
146 /* enable clock gate */
147 val = CMU_CLKGAGE_MODE_SFR_F | CMU_CLKGAGE_MODE_MEM_F;
148 writel(val, ctx->addr + DECON_CMU);
149
150 if (ctx->out_type & (IFTYPE_I80 | I80_HW_TRG)) 145 if (ctx->out_type & (IFTYPE_I80 | I80_HW_TRG))
151 decon_setup_trigger(ctx); 146 decon_setup_trigger(ctx);
152 147
@@ -315,6 +310,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
315 310
316 /* window enable */ 311 /* window enable */
317 decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0); 312 decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);
313 set_bit(BIT_REQUEST_UPDATE, &ctx->flags);
318} 314}
319 315
320static void decon_disable_plane(struct exynos_drm_crtc *crtc, 316static void decon_disable_plane(struct exynos_drm_crtc *crtc,
@@ -327,6 +323,7 @@ static void decon_disable_plane(struct exynos_drm_crtc *crtc,
327 return; 323 return;
328 324
329 decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, 0); 325 decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, 0);
326 set_bit(BIT_REQUEST_UPDATE, &ctx->flags);
330} 327}
331 328
332static void decon_atomic_flush(struct exynos_drm_crtc *crtc) 329static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
@@ -340,8 +337,8 @@ static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
340 for (i = ctx->first_win; i < WINDOWS_NR; i++) 337 for (i = ctx->first_win; i < WINDOWS_NR; i++)
341 decon_shadow_protect_win(ctx, i, false); 338 decon_shadow_protect_win(ctx, i, false);
342 339
343 /* standalone update */ 340 if (test_and_clear_bit(BIT_REQUEST_UPDATE, &ctx->flags))
344 decon_set_bits(ctx, DECON_UPDATE, STANDALONE_UPDATE_F, ~0); 341 decon_set_bits(ctx, DECON_UPDATE, STANDALONE_UPDATE_F, ~0);
345 342
346 if (ctx->out_type & IFTYPE_I80) 343 if (ctx->out_type & IFTYPE_I80)
347 set_bit(BIT_WIN_UPDATED, &ctx->flags); 344 set_bit(BIT_WIN_UPDATED, &ctx->flags);
diff --git a/drivers/gpu/drm/i915/gvt/aperture_gm.c b/drivers/gpu/drm/i915/gvt/aperture_gm.c
index 0d41ebc4aea6..f7bce8603958 100644
--- a/drivers/gpu/drm/i915/gvt/aperture_gm.c
+++ b/drivers/gpu/drm/i915/gvt/aperture_gm.c
@@ -37,13 +37,6 @@
37#include "i915_drv.h" 37#include "i915_drv.h"
38#include "gvt.h" 38#include "gvt.h"
39 39
40#define MB_TO_BYTES(mb) ((mb) << 20ULL)
41#define BYTES_TO_MB(b) ((b) >> 20ULL)
42
43#define HOST_LOW_GM_SIZE MB_TO_BYTES(128)
44#define HOST_HIGH_GM_SIZE MB_TO_BYTES(384)
45#define HOST_FENCE 4
46
47static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm) 40static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm)
48{ 41{
49 struct intel_gvt *gvt = vgpu->gvt; 42 struct intel_gvt *gvt = vgpu->gvt;
@@ -165,6 +158,14 @@ void intel_vgpu_write_fence(struct intel_vgpu *vgpu,
165 POSTING_READ(fence_reg_lo); 158 POSTING_READ(fence_reg_lo);
166} 159}
167 160
161static void _clear_vgpu_fence(struct intel_vgpu *vgpu)
162{
163 int i;
164
165 for (i = 0; i < vgpu_fence_sz(vgpu); i++)
166 intel_vgpu_write_fence(vgpu, i, 0);
167}
168
168static void free_vgpu_fence(struct intel_vgpu *vgpu) 169static void free_vgpu_fence(struct intel_vgpu *vgpu)
169{ 170{
170 struct intel_gvt *gvt = vgpu->gvt; 171 struct intel_gvt *gvt = vgpu->gvt;
@@ -178,9 +179,9 @@ static void free_vgpu_fence(struct intel_vgpu *vgpu)
178 intel_runtime_pm_get(dev_priv); 179 intel_runtime_pm_get(dev_priv);
179 180
180 mutex_lock(&dev_priv->drm.struct_mutex); 181 mutex_lock(&dev_priv->drm.struct_mutex);
182 _clear_vgpu_fence(vgpu);
181 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { 183 for (i = 0; i < vgpu_fence_sz(vgpu); i++) {
182 reg = vgpu->fence.regs[i]; 184 reg = vgpu->fence.regs[i];
183 intel_vgpu_write_fence(vgpu, i, 0);
184 list_add_tail(&reg->link, 185 list_add_tail(&reg->link,
185 &dev_priv->mm.fence_list); 186 &dev_priv->mm.fence_list);
186 } 187 }
@@ -208,13 +209,14 @@ static int alloc_vgpu_fence(struct intel_vgpu *vgpu)
208 continue; 209 continue;
209 list_del(pos); 210 list_del(pos);
210 vgpu->fence.regs[i] = reg; 211 vgpu->fence.regs[i] = reg;
211 intel_vgpu_write_fence(vgpu, i, 0);
212 if (++i == vgpu_fence_sz(vgpu)) 212 if (++i == vgpu_fence_sz(vgpu))
213 break; 213 break;
214 } 214 }
215 if (i != vgpu_fence_sz(vgpu)) 215 if (i != vgpu_fence_sz(vgpu))
216 goto out_free_fence; 216 goto out_free_fence;
217 217
218 _clear_vgpu_fence(vgpu);
219
218 mutex_unlock(&dev_priv->drm.struct_mutex); 220 mutex_unlock(&dev_priv->drm.struct_mutex);
219 intel_runtime_pm_put(dev_priv); 221 intel_runtime_pm_put(dev_priv);
220 return 0; 222 return 0;
@@ -314,6 +316,22 @@ void intel_vgpu_free_resource(struct intel_vgpu *vgpu)
314} 316}
315 317
316/** 318/**
319 * intel_vgpu_reset_resource - reset resource state owned by a vGPU
320 * @vgpu: a vGPU
321 *
322 * This function is used to reset resource state owned by a vGPU.
323 *
324 */
325void intel_vgpu_reset_resource(struct intel_vgpu *vgpu)
326{
327 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
328
329 intel_runtime_pm_get(dev_priv);
330 _clear_vgpu_fence(vgpu);
331 intel_runtime_pm_put(dev_priv);
332}
333
334/**
317 * intel_alloc_vgpu_resource - allocate HW resource for a vGPU 335 * intel_alloc_vgpu_resource - allocate HW resource for a vGPU
318 * @vgpu: vGPU 336 * @vgpu: vGPU
319 * @param: vGPU creation params 337 * @param: vGPU creation params
diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c
index db516382a4d4..4a6a2ed65732 100644
--- a/drivers/gpu/drm/i915/gvt/cfg_space.c
+++ b/drivers/gpu/drm/i915/gvt/cfg_space.c
@@ -123,6 +123,7 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu,
123 u8 changed = old ^ new; 123 u8 changed = old ^ new;
124 int ret; 124 int ret;
125 125
126 memcpy(vgpu_cfg_space(vgpu) + offset, p_data, bytes);
126 if (!(changed & PCI_COMMAND_MEMORY)) 127 if (!(changed & PCI_COMMAND_MEMORY))
127 return 0; 128 return 0;
128 129
@@ -142,7 +143,6 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu,
142 return ret; 143 return ret;
143 } 144 }
144 145
145 memcpy(vgpu_cfg_space(vgpu) + offset, p_data, bytes);
146 return 0; 146 return 0;
147} 147}
148 148
@@ -240,7 +240,7 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset,
240 if (WARN_ON(bytes > 4)) 240 if (WARN_ON(bytes > 4))
241 return -EINVAL; 241 return -EINVAL;
242 242
243 if (WARN_ON(offset + bytes >= INTEL_GVT_MAX_CFG_SPACE_SZ)) 243 if (WARN_ON(offset + bytes > INTEL_GVT_MAX_CFG_SPACE_SZ))
244 return -EINVAL; 244 return -EINVAL;
245 245
246 /* First check if it's PCI_COMMAND */ 246 /* First check if it's PCI_COMMAND */
@@ -282,3 +282,77 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset,
282 } 282 }
283 return 0; 283 return 0;
284} 284}
285
286/**
287 * intel_vgpu_init_cfg_space - init vGPU configuration space when create vGPU
288 *
289 * @vgpu: a vGPU
290 * @primary: is the vGPU presented as primary
291 *
292 */
293void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
294 bool primary)
295{
296 struct intel_gvt *gvt = vgpu->gvt;
297 const struct intel_gvt_device_info *info = &gvt->device_info;
298 u16 *gmch_ctl;
299 int i;
300
301 memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space,
302 info->cfg_space_size);
303
304 if (!primary) {
305 vgpu_cfg_space(vgpu)[PCI_CLASS_DEVICE] =
306 INTEL_GVT_PCI_CLASS_VGA_OTHER;
307 vgpu_cfg_space(vgpu)[PCI_CLASS_PROG] =
308 INTEL_GVT_PCI_CLASS_VGA_OTHER;
309 }
310
311 /* Show guest that there isn't any stolen memory.*/
312 gmch_ctl = (u16 *)(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_GMCH_CONTROL);
313 *gmch_ctl &= ~(BDW_GMCH_GMS_MASK << BDW_GMCH_GMS_SHIFT);
314
315 intel_vgpu_write_pci_bar(vgpu, PCI_BASE_ADDRESS_2,
316 gvt_aperture_pa_base(gvt), true);
317
318 vgpu_cfg_space(vgpu)[PCI_COMMAND] &= ~(PCI_COMMAND_IO
319 | PCI_COMMAND_MEMORY
320 | PCI_COMMAND_MASTER);
321 /*
322 * Clear the bar upper 32bit and let guest to assign the new value
323 */
324 memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_1, 0, 4);
325 memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_3, 0, 4);
326 memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4);
327
328 for (i = 0; i < INTEL_GVT_MAX_BAR_NUM; i++) {
329 vgpu->cfg_space.bar[i].size = pci_resource_len(
330 gvt->dev_priv->drm.pdev, i * 2);
331 vgpu->cfg_space.bar[i].tracked = false;
332 }
333}
334
335/**
336 * intel_vgpu_reset_cfg_space - reset vGPU configuration space
337 *
338 * @vgpu: a vGPU
339 *
340 */
341void intel_vgpu_reset_cfg_space(struct intel_vgpu *vgpu)
342{
343 u8 cmd = vgpu_cfg_space(vgpu)[PCI_COMMAND];
344 bool primary = vgpu_cfg_space(vgpu)[PCI_CLASS_DEVICE] !=
345 INTEL_GVT_PCI_CLASS_VGA_OTHER;
346
347 if (cmd & PCI_COMMAND_MEMORY) {
348 trap_gttmmio(vgpu, false);
349 map_aperture(vgpu, false);
350 }
351
352 /**
353 * Currently we only do such reset when vGPU is not
354 * owned by any VM, so we simply restore entire cfg
355 * space to default value.
356 */
357 intel_vgpu_init_cfg_space(vgpu, primary);
358}
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 7eaaf1c9ed2b..47dec4acf7ff 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -240,15 +240,8 @@ static inline int get_pse_type(int type)
240static u64 read_pte64(struct drm_i915_private *dev_priv, unsigned long index) 240static u64 read_pte64(struct drm_i915_private *dev_priv, unsigned long index)
241{ 241{
242 void __iomem *addr = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm + index; 242 void __iomem *addr = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm + index;
243 u64 pte;
244 243
245#ifdef readq 244 return readq(addr);
246 pte = readq(addr);
247#else
248 pte = ioread32(addr);
249 pte |= (u64)ioread32(addr + 4) << 32;
250#endif
251 return pte;
252} 245}
253 246
254static void write_pte64(struct drm_i915_private *dev_priv, 247static void write_pte64(struct drm_i915_private *dev_priv,
@@ -256,12 +249,8 @@ static void write_pte64(struct drm_i915_private *dev_priv,
256{ 249{
257 void __iomem *addr = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm + index; 250 void __iomem *addr = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm + index;
258 251
259#ifdef writeq
260 writeq(pte, addr); 252 writeq(pte, addr);
261#else 253
262 iowrite32((u32)pte, addr);
263 iowrite32(pte >> 32, addr + 4);
264#endif
265 I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN); 254 I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
266 POSTING_READ(GFX_FLSH_CNTL_GEN6); 255 POSTING_READ(GFX_FLSH_CNTL_GEN6);
267} 256}
@@ -1380,8 +1369,7 @@ static int gen8_mm_alloc_page_table(struct intel_vgpu_mm *mm)
1380 info->gtt_entry_size; 1369 info->gtt_entry_size;
1381 mem = kzalloc(mm->has_shadow_page_table ? 1370 mem = kzalloc(mm->has_shadow_page_table ?
1382 mm->page_table_entry_size * 2 1371 mm->page_table_entry_size * 2
1383 : mm->page_table_entry_size, 1372 : mm->page_table_entry_size, GFP_KERNEL);
1384 GFP_ATOMIC);
1385 if (!mem) 1373 if (!mem)
1386 return -ENOMEM; 1374 return -ENOMEM;
1387 mm->virtual_page_table = mem; 1375 mm->virtual_page_table = mem;
@@ -1532,7 +1520,7 @@ struct intel_vgpu_mm *intel_vgpu_create_mm(struct intel_vgpu *vgpu,
1532 struct intel_vgpu_mm *mm; 1520 struct intel_vgpu_mm *mm;
1533 int ret; 1521 int ret;
1534 1522
1535 mm = kzalloc(sizeof(*mm), GFP_ATOMIC); 1523 mm = kzalloc(sizeof(*mm), GFP_KERNEL);
1536 if (!mm) { 1524 if (!mm) {
1537 ret = -ENOMEM; 1525 ret = -ENOMEM;
1538 goto fail; 1526 goto fail;
@@ -1886,30 +1874,27 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu,
1886 struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; 1874 struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;
1887 int page_entry_num = GTT_PAGE_SIZE >> 1875 int page_entry_num = GTT_PAGE_SIZE >>
1888 vgpu->gvt->device_info.gtt_entry_size_shift; 1876 vgpu->gvt->device_info.gtt_entry_size_shift;
1889 struct page *scratch_pt; 1877 void *scratch_pt;
1890 unsigned long mfn; 1878 unsigned long mfn;
1891 int i; 1879 int i;
1892 void *p;
1893 1880
1894 if (WARN_ON(type < GTT_TYPE_PPGTT_PTE_PT || type >= GTT_TYPE_MAX)) 1881 if (WARN_ON(type < GTT_TYPE_PPGTT_PTE_PT || type >= GTT_TYPE_MAX))
1895 return -EINVAL; 1882 return -EINVAL;
1896 1883
1897 scratch_pt = alloc_page(GFP_KERNEL | GFP_ATOMIC | __GFP_ZERO); 1884 scratch_pt = (void *)get_zeroed_page(GFP_KERNEL);
1898 if (!scratch_pt) { 1885 if (!scratch_pt) {
1899 gvt_err("fail to allocate scratch page\n"); 1886 gvt_err("fail to allocate scratch page\n");
1900 return -ENOMEM; 1887 return -ENOMEM;
1901 } 1888 }
1902 1889
1903 p = kmap_atomic(scratch_pt); 1890 mfn = intel_gvt_hypervisor_virt_to_mfn(scratch_pt);
1904 mfn = intel_gvt_hypervisor_virt_to_mfn(p);
1905 if (mfn == INTEL_GVT_INVALID_ADDR) { 1891 if (mfn == INTEL_GVT_INVALID_ADDR) {
1906 gvt_err("fail to translate vaddr:0x%llx\n", (u64)p); 1892 gvt_err("fail to translate vaddr:0x%lx\n", (unsigned long)scratch_pt);
1907 kunmap_atomic(p); 1893 free_page((unsigned long)scratch_pt);
1908 __free_page(scratch_pt);
1909 return -EFAULT; 1894 return -EFAULT;
1910 } 1895 }
1911 gtt->scratch_pt[type].page_mfn = mfn; 1896 gtt->scratch_pt[type].page_mfn = mfn;
1912 gtt->scratch_pt[type].page = scratch_pt; 1897 gtt->scratch_pt[type].page = virt_to_page(scratch_pt);
1913 gvt_dbg_mm("vgpu%d create scratch_pt: type %d mfn=0x%lx\n", 1898 gvt_dbg_mm("vgpu%d create scratch_pt: type %d mfn=0x%lx\n",
1914 vgpu->id, type, mfn); 1899 vgpu->id, type, mfn);
1915 1900
@@ -1918,7 +1903,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu,
1918 * scratch_pt[type] indicate the scratch pt/scratch page used by the 1903 * scratch_pt[type] indicate the scratch pt/scratch page used by the
1919 * 'type' pt. 1904 * 'type' pt.
1920 * e.g. scratch_pt[GTT_TYPE_PPGTT_PDE_PT] is used by 1905 * e.g. scratch_pt[GTT_TYPE_PPGTT_PDE_PT] is used by
1921 * GTT_TYPE_PPGTT_PDE_PT level pt, that means this scatch_pt it self 1906 * GTT_TYPE_PPGTT_PDE_PT level pt, that means this scratch_pt it self
1922 * is GTT_TYPE_PPGTT_PTE_PT, and full filled by scratch page mfn. 1907 * is GTT_TYPE_PPGTT_PTE_PT, and full filled by scratch page mfn.
1923 */ 1908 */
1924 if (type > GTT_TYPE_PPGTT_PTE_PT && type < GTT_TYPE_MAX) { 1909 if (type > GTT_TYPE_PPGTT_PTE_PT && type < GTT_TYPE_MAX) {
@@ -1936,11 +1921,9 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu,
1936 se.val64 |= PPAT_CACHED_INDEX; 1921 se.val64 |= PPAT_CACHED_INDEX;
1937 1922
1938 for (i = 0; i < page_entry_num; i++) 1923 for (i = 0; i < page_entry_num; i++)
1939 ops->set_entry(p, &se, i, false, 0, vgpu); 1924 ops->set_entry(scratch_pt, &se, i, false, 0, vgpu);
1940 } 1925 }
1941 1926
1942 kunmap_atomic(p);
1943
1944 return 0; 1927 return 0;
1945} 1928}
1946 1929
@@ -1998,6 +1981,8 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
1998 INIT_LIST_HEAD(&gtt->oos_page_list_head); 1981 INIT_LIST_HEAD(&gtt->oos_page_list_head);
1999 INIT_LIST_HEAD(&gtt->post_shadow_list_head); 1982 INIT_LIST_HEAD(&gtt->post_shadow_list_head);
2000 1983
1984 intel_vgpu_reset_ggtt(vgpu);
1985
2001 ggtt_mm = intel_vgpu_create_mm(vgpu, INTEL_GVT_MM_GGTT, 1986 ggtt_mm = intel_vgpu_create_mm(vgpu, INTEL_GVT_MM_GGTT,
2002 NULL, 1, 0); 1987 NULL, 1, 0);
2003 if (IS_ERR(ggtt_mm)) { 1988 if (IS_ERR(ggtt_mm)) {
@@ -2206,6 +2191,7 @@ int intel_vgpu_g2v_destroy_ppgtt_mm(struct intel_vgpu *vgpu,
2206int intel_gvt_init_gtt(struct intel_gvt *gvt) 2191int intel_gvt_init_gtt(struct intel_gvt *gvt)
2207{ 2192{
2208 int ret; 2193 int ret;
2194 void *page;
2209 2195
2210 gvt_dbg_core("init gtt\n"); 2196 gvt_dbg_core("init gtt\n");
2211 2197
@@ -2218,6 +2204,20 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt)
2218 return -ENODEV; 2204 return -ENODEV;
2219 } 2205 }
2220 2206
2207 page = (void *)get_zeroed_page(GFP_KERNEL);
2208 if (!page) {
2209 gvt_err("fail to allocate scratch ggtt page\n");
2210 return -ENOMEM;
2211 }
2212 gvt->gtt.scratch_ggtt_page = virt_to_page(page);
2213
2214 gvt->gtt.scratch_ggtt_mfn = intel_gvt_hypervisor_virt_to_mfn(page);
2215 if (gvt->gtt.scratch_ggtt_mfn == INTEL_GVT_INVALID_ADDR) {
2216 gvt_err("fail to translate scratch ggtt page\n");
2217 __free_page(gvt->gtt.scratch_ggtt_page);
2218 return -EFAULT;
2219 }
2220
2221 if (enable_out_of_sync) { 2221 if (enable_out_of_sync) {
2222 ret = setup_spt_oos(gvt); 2222 ret = setup_spt_oos(gvt);
2223 if (ret) { 2223 if (ret) {
@@ -2239,6 +2239,68 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt)
2239 */ 2239 */
2240void intel_gvt_clean_gtt(struct intel_gvt *gvt) 2240void intel_gvt_clean_gtt(struct intel_gvt *gvt)
2241{ 2241{
2242 __free_page(gvt->gtt.scratch_ggtt_page);
2243
2242 if (enable_out_of_sync) 2244 if (enable_out_of_sync)
2243 clean_spt_oos(gvt); 2245 clean_spt_oos(gvt);
2244} 2246}
2247
2248/**
2249 * intel_vgpu_reset_ggtt - reset the GGTT entry
2250 * @vgpu: a vGPU
2251 *
2252 * This function is called at the vGPU create stage
2253 * to reset all the GGTT entries.
2254 *
2255 */
2256void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu)
2257{
2258 struct intel_gvt *gvt = vgpu->gvt;
2259 struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;
2260 u32 index;
2261 u32 offset;
2262 u32 num_entries;
2263 struct intel_gvt_gtt_entry e;
2264
2265 memset(&e, 0, sizeof(struct intel_gvt_gtt_entry));
2266 e.type = GTT_TYPE_GGTT_PTE;
2267 ops->set_pfn(&e, gvt->gtt.scratch_ggtt_mfn);
2268 e.val64 |= _PAGE_PRESENT;
2269
2270 index = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT;
2271 num_entries = vgpu_aperture_sz(vgpu) >> PAGE_SHIFT;
2272 for (offset = 0; offset < num_entries; offset++)
2273 ops->set_entry(NULL, &e, index + offset, false, 0, vgpu);
2274
2275 index = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT;
2276 num_entries = vgpu_hidden_sz(vgpu) >> PAGE_SHIFT;
2277 for (offset = 0; offset < num_entries; offset++)
2278 ops->set_entry(NULL, &e, index + offset, false, 0, vgpu);
2279}
2280
2281/**
2282 * intel_vgpu_reset_gtt - reset the all GTT related status
2283 * @vgpu: a vGPU
2284 * @dmlr: true for vGPU Device Model Level Reset, false for GT Reset
2285 *
2286 * This function is called from vfio core to reset reset all
2287 * GTT related status, including GGTT, PPGTT, scratch page.
2288 *
2289 */
2290void intel_vgpu_reset_gtt(struct intel_vgpu *vgpu, bool dmlr)
2291{
2292 int i;
2293
2294 ppgtt_free_all_shadow_page(vgpu);
2295 if (!dmlr)
2296 return;
2297
2298 intel_vgpu_reset_ggtt(vgpu);
2299
2300 /* clear scratch page for security */
2301 for (i = GTT_TYPE_PPGTT_PTE_PT; i < GTT_TYPE_MAX; i++) {
2302 if (vgpu->gtt.scratch_pt[i].page != NULL)
2303 memset(page_address(vgpu->gtt.scratch_pt[i].page),
2304 0, PAGE_SIZE);
2305 }
2306}
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h
index d250013bc37b..f88eb5e89bea 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.h
+++ b/drivers/gpu/drm/i915/gvt/gtt.h
@@ -81,6 +81,9 @@ struct intel_gvt_gtt {
81 struct list_head oos_page_use_list_head; 81 struct list_head oos_page_use_list_head;
82 struct list_head oos_page_free_list_head; 82 struct list_head oos_page_free_list_head;
83 struct list_head mm_lru_list_head; 83 struct list_head mm_lru_list_head;
84
85 struct page *scratch_ggtt_page;
86 unsigned long scratch_ggtt_mfn;
84}; 87};
85 88
86enum { 89enum {
@@ -202,8 +205,10 @@ struct intel_vgpu_gtt {
202 205
203extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu); 206extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
204extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu); 207extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
208void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu);
205 209
206extern int intel_gvt_init_gtt(struct intel_gvt *gvt); 210extern int intel_gvt_init_gtt(struct intel_gvt *gvt);
211extern void intel_vgpu_reset_gtt(struct intel_vgpu *vgpu, bool dmlr);
207extern void intel_gvt_clean_gtt(struct intel_gvt *gvt); 212extern void intel_gvt_clean_gtt(struct intel_gvt *gvt);
208 213
209extern struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu, 214extern struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu,
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
index 398877c3d2fd..e6bf5c533fbe 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.c
+++ b/drivers/gpu/drm/i915/gvt/gvt.c
@@ -201,6 +201,8 @@ void intel_gvt_clean_device(struct drm_i915_private *dev_priv)
201 intel_gvt_hypervisor_host_exit(&dev_priv->drm.pdev->dev, gvt); 201 intel_gvt_hypervisor_host_exit(&dev_priv->drm.pdev->dev, gvt);
202 intel_gvt_clean_vgpu_types(gvt); 202 intel_gvt_clean_vgpu_types(gvt);
203 203
204 idr_destroy(&gvt->vgpu_idr);
205
204 kfree(dev_priv->gvt); 206 kfree(dev_priv->gvt);
205 dev_priv->gvt = NULL; 207 dev_priv->gvt = NULL;
206} 208}
@@ -237,6 +239,8 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv)
237 239
238 gvt_dbg_core("init gvt device\n"); 240 gvt_dbg_core("init gvt device\n");
239 241
242 idr_init(&gvt->vgpu_idr);
243
240 mutex_init(&gvt->lock); 244 mutex_init(&gvt->lock);
241 gvt->dev_priv = dev_priv; 245 gvt->dev_priv = dev_priv;
242 246
@@ -244,7 +248,7 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv)
244 248
245 ret = intel_gvt_setup_mmio_info(gvt); 249 ret = intel_gvt_setup_mmio_info(gvt);
246 if (ret) 250 if (ret)
247 return ret; 251 goto out_clean_idr;
248 252
249 ret = intel_gvt_load_firmware(gvt); 253 ret = intel_gvt_load_firmware(gvt);
250 if (ret) 254 if (ret)
@@ -313,6 +317,8 @@ out_free_firmware:
313 intel_gvt_free_firmware(gvt); 317 intel_gvt_free_firmware(gvt);
314out_clean_mmio_info: 318out_clean_mmio_info:
315 intel_gvt_clean_mmio_info(gvt); 319 intel_gvt_clean_mmio_info(gvt);
320out_clean_idr:
321 idr_destroy(&gvt->vgpu_idr);
316 kfree(gvt); 322 kfree(gvt);
317 return ret; 323 return ret;
318} 324}
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index ad0e9364ee70..e227caf5859e 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -175,6 +175,7 @@ struct intel_vgpu {
175 struct notifier_block group_notifier; 175 struct notifier_block group_notifier;
176 struct kvm *kvm; 176 struct kvm *kvm;
177 struct work_struct release_work; 177 struct work_struct release_work;
178 atomic_t released;
178 } vdev; 179 } vdev;
179#endif 180#endif
180}; 181};
@@ -322,6 +323,7 @@ struct intel_vgpu_creation_params {
322 323
323int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu, 324int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu,
324 struct intel_vgpu_creation_params *param); 325 struct intel_vgpu_creation_params *param);
326void intel_vgpu_reset_resource(struct intel_vgpu *vgpu);
325void intel_vgpu_free_resource(struct intel_vgpu *vgpu); 327void intel_vgpu_free_resource(struct intel_vgpu *vgpu);
326void intel_vgpu_write_fence(struct intel_vgpu *vgpu, 328void intel_vgpu_write_fence(struct intel_vgpu *vgpu,
327 u32 fence, u64 value); 329 u32 fence, u64 value);
@@ -374,6 +376,8 @@ void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt);
374struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt, 376struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
375 struct intel_vgpu_type *type); 377 struct intel_vgpu_type *type);
376void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu); 378void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu);
379void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
380 unsigned int engine_mask);
377void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu); 381void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu);
378 382
379 383
@@ -410,6 +414,10 @@ int intel_gvt_ggtt_index_g2h(struct intel_vgpu *vgpu, unsigned long g_index,
410int intel_gvt_ggtt_h2g_index(struct intel_vgpu *vgpu, unsigned long h_index, 414int intel_gvt_ggtt_h2g_index(struct intel_vgpu *vgpu, unsigned long h_index,
411 unsigned long *g_index); 415 unsigned long *g_index);
412 416
417void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
418 bool primary);
419void intel_vgpu_reset_cfg_space(struct intel_vgpu *vgpu);
420
413int intel_vgpu_emulate_cfg_read(struct intel_vgpu *vgpu, unsigned int offset, 421int intel_vgpu_emulate_cfg_read(struct intel_vgpu *vgpu, unsigned int offset,
414 void *p_data, unsigned int bytes); 422 void *p_data, unsigned int bytes);
415 423
@@ -423,7 +431,6 @@ void intel_vgpu_clean_opregion(struct intel_vgpu *vgpu);
423int intel_vgpu_init_opregion(struct intel_vgpu *vgpu, u32 gpa); 431int intel_vgpu_init_opregion(struct intel_vgpu *vgpu, u32 gpa);
424 432
425int intel_vgpu_emulate_opregion_request(struct intel_vgpu *vgpu, u32 swsci); 433int intel_vgpu_emulate_opregion_request(struct intel_vgpu *vgpu, u32 swsci);
426int setup_vgpu_mmio(struct intel_vgpu *vgpu);
427void populate_pvinfo_page(struct intel_vgpu *vgpu); 434void populate_pvinfo_page(struct intel_vgpu *vgpu);
428 435
429struct intel_gvt_ops { 436struct intel_gvt_ops {
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 522809710312..ab2ea157da4c 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -93,7 +93,8 @@ static void write_vreg(struct intel_vgpu *vgpu, unsigned int offset,
93static int new_mmio_info(struct intel_gvt *gvt, 93static int new_mmio_info(struct intel_gvt *gvt,
94 u32 offset, u32 flags, u32 size, 94 u32 offset, u32 flags, u32 size,
95 u32 addr_mask, u32 ro_mask, u32 device, 95 u32 addr_mask, u32 ro_mask, u32 device,
96 void *read, void *write) 96 int (*read)(struct intel_vgpu *, unsigned int, void *, unsigned int),
97 int (*write)(struct intel_vgpu *, unsigned int, void *, unsigned int))
97{ 98{
98 struct intel_gvt_mmio_info *info, *p; 99 struct intel_gvt_mmio_info *info, *p;
99 u32 start, end, i; 100 u32 start, end, i;
@@ -219,7 +220,7 @@ static int mul_force_wake_write(struct intel_vgpu *vgpu,
219 default: 220 default:
220 /*should not hit here*/ 221 /*should not hit here*/
221 gvt_err("invalid forcewake offset 0x%x\n", offset); 222 gvt_err("invalid forcewake offset 0x%x\n", offset);
222 return 1; 223 return -EINVAL;
223 } 224 }
224 } else { 225 } else {
225 ack_reg_offset = FORCEWAKE_ACK_HSW_REG; 226 ack_reg_offset = FORCEWAKE_ACK_HSW_REG;
@@ -230,77 +231,45 @@ static int mul_force_wake_write(struct intel_vgpu *vgpu,
230 return 0; 231 return 0;
231} 232}
232 233
233static int handle_device_reset(struct intel_vgpu *vgpu, unsigned int offset,
234 void *p_data, unsigned int bytes, unsigned long bitmap)
235{
236 struct intel_gvt_workload_scheduler *scheduler =
237 &vgpu->gvt->scheduler;
238
239 vgpu->resetting = true;
240
241 intel_vgpu_stop_schedule(vgpu);
242 /*
243 * The current_vgpu will set to NULL after stopping the
244 * scheduler when the reset is triggered by current vgpu.
245 */
246 if (scheduler->current_vgpu == NULL) {
247 mutex_unlock(&vgpu->gvt->lock);
248 intel_gvt_wait_vgpu_idle(vgpu);
249 mutex_lock(&vgpu->gvt->lock);
250 }
251
252 intel_vgpu_reset_execlist(vgpu, bitmap);
253
254 /* full GPU reset */
255 if (bitmap == 0xff) {
256 mutex_unlock(&vgpu->gvt->lock);
257 intel_vgpu_clean_gtt(vgpu);
258 mutex_lock(&vgpu->gvt->lock);
259 setup_vgpu_mmio(vgpu);
260 populate_pvinfo_page(vgpu);
261 intel_vgpu_init_gtt(vgpu);
262 }
263
264 vgpu->resetting = false;
265
266 return 0;
267}
268
269static int gdrst_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, 234static int gdrst_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
270 void *p_data, unsigned int bytes) 235 void *p_data, unsigned int bytes)
271{ 236{
237 unsigned int engine_mask = 0;
272 u32 data; 238 u32 data;
273 u64 bitmap = 0;
274 239
275 write_vreg(vgpu, offset, p_data, bytes); 240 write_vreg(vgpu, offset, p_data, bytes);
276 data = vgpu_vreg(vgpu, offset); 241 data = vgpu_vreg(vgpu, offset);
277 242
278 if (data & GEN6_GRDOM_FULL) { 243 if (data & GEN6_GRDOM_FULL) {
279 gvt_dbg_mmio("vgpu%d: request full GPU reset\n", vgpu->id); 244 gvt_dbg_mmio("vgpu%d: request full GPU reset\n", vgpu->id);
280 bitmap = 0xff; 245 engine_mask = ALL_ENGINES;
281 } 246 } else {
282 if (data & GEN6_GRDOM_RENDER) { 247 if (data & GEN6_GRDOM_RENDER) {
283 gvt_dbg_mmio("vgpu%d: request RCS reset\n", vgpu->id); 248 gvt_dbg_mmio("vgpu%d: request RCS reset\n", vgpu->id);
284 bitmap |= (1 << RCS); 249 engine_mask |= (1 << RCS);
285 } 250 }
286 if (data & GEN6_GRDOM_MEDIA) { 251 if (data & GEN6_GRDOM_MEDIA) {
287 gvt_dbg_mmio("vgpu%d: request VCS reset\n", vgpu->id); 252 gvt_dbg_mmio("vgpu%d: request VCS reset\n", vgpu->id);
288 bitmap |= (1 << VCS); 253 engine_mask |= (1 << VCS);
289 } 254 }
290 if (data & GEN6_GRDOM_BLT) { 255 if (data & GEN6_GRDOM_BLT) {
291 gvt_dbg_mmio("vgpu%d: request BCS Reset\n", vgpu->id); 256 gvt_dbg_mmio("vgpu%d: request BCS Reset\n", vgpu->id);
292 bitmap |= (1 << BCS); 257 engine_mask |= (1 << BCS);
293 } 258 }
294 if (data & GEN6_GRDOM_VECS) { 259 if (data & GEN6_GRDOM_VECS) {
295 gvt_dbg_mmio("vgpu%d: request VECS Reset\n", vgpu->id); 260 gvt_dbg_mmio("vgpu%d: request VECS Reset\n", vgpu->id);
296 bitmap |= (1 << VECS); 261 engine_mask |= (1 << VECS);
297 } 262 }
298 if (data & GEN8_GRDOM_MEDIA2) { 263 if (data & GEN8_GRDOM_MEDIA2) {
299 gvt_dbg_mmio("vgpu%d: request VCS2 Reset\n", vgpu->id); 264 gvt_dbg_mmio("vgpu%d: request VCS2 Reset\n", vgpu->id);
300 if (HAS_BSD2(vgpu->gvt->dev_priv)) 265 if (HAS_BSD2(vgpu->gvt->dev_priv))
301 bitmap |= (1 << VCS2); 266 engine_mask |= (1 << VCS2);
267 }
302 } 268 }
303 return handle_device_reset(vgpu, offset, p_data, bytes, bitmap); 269
270 intel_gvt_reset_vgpu_locked(vgpu, false, engine_mask);
271
272 return 0;
304} 273}
305 274
306static int gmbus_mmio_read(struct intel_vgpu *vgpu, unsigned int offset, 275static int gmbus_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
@@ -974,7 +943,7 @@ static int sbi_data_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
974 return 0; 943 return 0;
975} 944}
976 945
977static bool sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, 946static int sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
978 void *p_data, unsigned int bytes) 947 void *p_data, unsigned int bytes)
979{ 948{
980 u32 data; 949 u32 data;
@@ -1366,7 +1335,6 @@ static int ring_mode_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
1366static int gvt_reg_tlb_control_handler(struct intel_vgpu *vgpu, 1335static int gvt_reg_tlb_control_handler(struct intel_vgpu *vgpu,
1367 unsigned int offset, void *p_data, unsigned int bytes) 1336 unsigned int offset, void *p_data, unsigned int bytes)
1368{ 1337{
1369 int rc = 0;
1370 unsigned int id = 0; 1338 unsigned int id = 0;
1371 1339
1372 write_vreg(vgpu, offset, p_data, bytes); 1340 write_vreg(vgpu, offset, p_data, bytes);
@@ -1389,12 +1357,11 @@ static int gvt_reg_tlb_control_handler(struct intel_vgpu *vgpu,
1389 id = VECS; 1357 id = VECS;
1390 break; 1358 break;
1391 default: 1359 default:
1392 rc = -EINVAL; 1360 return -EINVAL;
1393 break;
1394 } 1361 }
1395 set_bit(id, (void *)vgpu->tlb_handle_pending); 1362 set_bit(id, (void *)vgpu->tlb_handle_pending);
1396 1363
1397 return rc; 1364 return 0;
1398} 1365}
1399 1366
1400static int ring_reset_ctl_write(struct intel_vgpu *vgpu, 1367static int ring_reset_ctl_write(struct intel_vgpu *vgpu,
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4dd6722a7339..0c9234a87a20 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -114,12 +114,15 @@ out:
114static kvm_pfn_t gvt_cache_find(struct intel_vgpu *vgpu, gfn_t gfn) 114static kvm_pfn_t gvt_cache_find(struct intel_vgpu *vgpu, gfn_t gfn)
115{ 115{
116 struct gvt_dma *entry; 116 struct gvt_dma *entry;
117 kvm_pfn_t pfn;
117 118
118 mutex_lock(&vgpu->vdev.cache_lock); 119 mutex_lock(&vgpu->vdev.cache_lock);
120
119 entry = __gvt_cache_find(vgpu, gfn); 121 entry = __gvt_cache_find(vgpu, gfn);
120 mutex_unlock(&vgpu->vdev.cache_lock); 122 pfn = (entry == NULL) ? 0 : entry->pfn;
121 123
122 return entry == NULL ? 0 : entry->pfn; 124 mutex_unlock(&vgpu->vdev.cache_lock);
125 return pfn;
123} 126}
124 127
125static void gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn, kvm_pfn_t pfn) 128static void gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn, kvm_pfn_t pfn)
@@ -166,7 +169,7 @@ static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
166 169
167static void gvt_cache_remove(struct intel_vgpu *vgpu, gfn_t gfn) 170static void gvt_cache_remove(struct intel_vgpu *vgpu, gfn_t gfn)
168{ 171{
169 struct device *dev = &vgpu->vdev.mdev->dev; 172 struct device *dev = mdev_dev(vgpu->vdev.mdev);
170 struct gvt_dma *this; 173 struct gvt_dma *this;
171 unsigned long g1; 174 unsigned long g1;
172 int rc; 175 int rc;
@@ -195,7 +198,7 @@ static void gvt_cache_destroy(struct intel_vgpu *vgpu)
195{ 198{
196 struct gvt_dma *dma; 199 struct gvt_dma *dma;
197 struct rb_node *node = NULL; 200 struct rb_node *node = NULL;
198 struct device *dev = &vgpu->vdev.mdev->dev; 201 struct device *dev = mdev_dev(vgpu->vdev.mdev);
199 unsigned long gfn; 202 unsigned long gfn;
200 203
201 mutex_lock(&vgpu->vdev.cache_lock); 204 mutex_lock(&vgpu->vdev.cache_lock);
@@ -395,21 +398,24 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
395 struct intel_vgpu_type *type; 398 struct intel_vgpu_type *type;
396 struct device *pdev; 399 struct device *pdev;
397 void *gvt; 400 void *gvt;
401 int ret;
398 402
399 pdev = mdev->parent->dev; 403 pdev = mdev_parent_dev(mdev);
400 gvt = kdev_to_i915(pdev)->gvt; 404 gvt = kdev_to_i915(pdev)->gvt;
401 405
402 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); 406 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
403 if (!type) { 407 if (!type) {
404 gvt_err("failed to find type %s to create\n", 408 gvt_err("failed to find type %s to create\n",
405 kobject_name(kobj)); 409 kobject_name(kobj));
406 return -EINVAL; 410 ret = -EINVAL;
411 goto out;
407 } 412 }
408 413
409 vgpu = intel_gvt_ops->vgpu_create(gvt, type); 414 vgpu = intel_gvt_ops->vgpu_create(gvt, type);
410 if (IS_ERR_OR_NULL(vgpu)) { 415 if (IS_ERR_OR_NULL(vgpu)) {
411 gvt_err("create intel vgpu failed\n"); 416 ret = vgpu == NULL ? -EFAULT : PTR_ERR(vgpu);
412 return -EINVAL; 417 gvt_err("failed to create intel vgpu: %d\n", ret);
418 goto out;
413 } 419 }
414 420
415 INIT_WORK(&vgpu->vdev.release_work, intel_vgpu_release_work); 421 INIT_WORK(&vgpu->vdev.release_work, intel_vgpu_release_work);
@@ -418,8 +424,11 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
418 mdev_set_drvdata(mdev, vgpu); 424 mdev_set_drvdata(mdev, vgpu);
419 425
420 gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n", 426 gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n",
421 dev_name(&mdev->dev)); 427 dev_name(mdev_dev(mdev)));
422 return 0; 428 ret = 0;
429
430out:
431 return ret;
423} 432}
424 433
425static int intel_vgpu_remove(struct mdev_device *mdev) 434static int intel_vgpu_remove(struct mdev_device *mdev)
@@ -482,7 +491,7 @@ static int intel_vgpu_open(struct mdev_device *mdev)
482 vgpu->vdev.group_notifier.notifier_call = intel_vgpu_group_notifier; 491 vgpu->vdev.group_notifier.notifier_call = intel_vgpu_group_notifier;
483 492
484 events = VFIO_IOMMU_NOTIFY_DMA_UNMAP; 493 events = VFIO_IOMMU_NOTIFY_DMA_UNMAP;
485 ret = vfio_register_notifier(&mdev->dev, VFIO_IOMMU_NOTIFY, &events, 494 ret = vfio_register_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY, &events,
486 &vgpu->vdev.iommu_notifier); 495 &vgpu->vdev.iommu_notifier);
487 if (ret != 0) { 496 if (ret != 0) {
488 gvt_err("vfio_register_notifier for iommu failed: %d\n", ret); 497 gvt_err("vfio_register_notifier for iommu failed: %d\n", ret);
@@ -490,17 +499,26 @@ static int intel_vgpu_open(struct mdev_device *mdev)
490 } 499 }
491 500
492 events = VFIO_GROUP_NOTIFY_SET_KVM; 501 events = VFIO_GROUP_NOTIFY_SET_KVM;
493 ret = vfio_register_notifier(&mdev->dev, VFIO_GROUP_NOTIFY, &events, 502 ret = vfio_register_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY, &events,
494 &vgpu->vdev.group_notifier); 503 &vgpu->vdev.group_notifier);
495 if (ret != 0) { 504 if (ret != 0) {
496 gvt_err("vfio_register_notifier for group failed: %d\n", ret); 505 gvt_err("vfio_register_notifier for group failed: %d\n", ret);
497 goto undo_iommu; 506 goto undo_iommu;
498 } 507 }
499 508
500 return kvmgt_guest_init(mdev); 509 ret = kvmgt_guest_init(mdev);
510 if (ret)
511 goto undo_group;
512
513 atomic_set(&vgpu->vdev.released, 0);
514 return ret;
515
516undo_group:
517 vfio_unregister_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY,
518 &vgpu->vdev.group_notifier);
501 519
502undo_iommu: 520undo_iommu:
503 vfio_unregister_notifier(&mdev->dev, VFIO_IOMMU_NOTIFY, 521 vfio_unregister_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
504 &vgpu->vdev.iommu_notifier); 522 &vgpu->vdev.iommu_notifier);
505out: 523out:
506 return ret; 524 return ret;
@@ -509,17 +527,26 @@ out:
509static void __intel_vgpu_release(struct intel_vgpu *vgpu) 527static void __intel_vgpu_release(struct intel_vgpu *vgpu)
510{ 528{
511 struct kvmgt_guest_info *info; 529 struct kvmgt_guest_info *info;
530 int ret;
512 531
513 if (!handle_valid(vgpu->handle)) 532 if (!handle_valid(vgpu->handle))
514 return; 533 return;
515 534
516 vfio_unregister_notifier(&vgpu->vdev.mdev->dev, VFIO_IOMMU_NOTIFY, 535 if (atomic_cmpxchg(&vgpu->vdev.released, 0, 1))
536 return;
537
538 ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_IOMMU_NOTIFY,
517 &vgpu->vdev.iommu_notifier); 539 &vgpu->vdev.iommu_notifier);
518 vfio_unregister_notifier(&vgpu->vdev.mdev->dev, VFIO_GROUP_NOTIFY, 540 WARN(ret, "vfio_unregister_notifier for iommu failed: %d\n", ret);
541
542 ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_GROUP_NOTIFY,
519 &vgpu->vdev.group_notifier); 543 &vgpu->vdev.group_notifier);
544 WARN(ret, "vfio_unregister_notifier for group failed: %d\n", ret);
520 545
521 info = (struct kvmgt_guest_info *)vgpu->handle; 546 info = (struct kvmgt_guest_info *)vgpu->handle;
522 kvmgt_guest_exit(info); 547 kvmgt_guest_exit(info);
548
549 vgpu->vdev.kvm = NULL;
523 vgpu->handle = 0; 550 vgpu->handle = 0;
524} 551}
525 552
@@ -534,6 +561,7 @@ static void intel_vgpu_release_work(struct work_struct *work)
534{ 561{
535 struct intel_vgpu *vgpu = container_of(work, struct intel_vgpu, 562 struct intel_vgpu *vgpu = container_of(work, struct intel_vgpu,
536 vdev.release_work); 563 vdev.release_work);
564
537 __intel_vgpu_release(vgpu); 565 __intel_vgpu_release(vgpu);
538} 566}
539 567
@@ -1089,7 +1117,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1089 return 0; 1117 return 0;
1090} 1118}
1091 1119
1092static const struct parent_ops intel_vgpu_ops = { 1120static const struct mdev_parent_ops intel_vgpu_ops = {
1093 .supported_type_groups = intel_vgpu_type_groups, 1121 .supported_type_groups = intel_vgpu_type_groups,
1094 .create = intel_vgpu_create, 1122 .create = intel_vgpu_create,
1095 .remove = intel_vgpu_remove, 1123 .remove = intel_vgpu_remove,
@@ -1134,6 +1162,10 @@ static int kvmgt_write_protect_add(unsigned long handle, u64 gfn)
1134 1162
1135 idx = srcu_read_lock(&kvm->srcu); 1163 idx = srcu_read_lock(&kvm->srcu);
1136 slot = gfn_to_memslot(kvm, gfn); 1164 slot = gfn_to_memslot(kvm, gfn);
1165 if (!slot) {
1166 srcu_read_unlock(&kvm->srcu, idx);
1167 return -EINVAL;
1168 }
1137 1169
1138 spin_lock(&kvm->mmu_lock); 1170 spin_lock(&kvm->mmu_lock);
1139 1171
@@ -1164,6 +1196,10 @@ static int kvmgt_write_protect_remove(unsigned long handle, u64 gfn)
1164 1196
1165 idx = srcu_read_lock(&kvm->srcu); 1197 idx = srcu_read_lock(&kvm->srcu);
1166 slot = gfn_to_memslot(kvm, gfn); 1198 slot = gfn_to_memslot(kvm, gfn);
1199 if (!slot) {
1200 srcu_read_unlock(&kvm->srcu, idx);
1201 return -EINVAL;
1202 }
1167 1203
1168 spin_lock(&kvm->mmu_lock); 1204 spin_lock(&kvm->mmu_lock);
1169 1205
@@ -1311,18 +1347,14 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
1311 1347
1312static bool kvmgt_guest_exit(struct kvmgt_guest_info *info) 1348static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
1313{ 1349{
1314 struct intel_vgpu *vgpu;
1315
1316 if (!info) { 1350 if (!info) {
1317 gvt_err("kvmgt_guest_info invalid\n"); 1351 gvt_err("kvmgt_guest_info invalid\n");
1318 return false; 1352 return false;
1319 } 1353 }
1320 1354
1321 vgpu = info->vgpu;
1322
1323 kvm_page_track_unregister_notifier(info->kvm, &info->track_node); 1355 kvm_page_track_unregister_notifier(info->kvm, &info->track_node);
1324 kvmgt_protect_table_destroy(info); 1356 kvmgt_protect_table_destroy(info);
1325 gvt_cache_destroy(vgpu); 1357 gvt_cache_destroy(info->vgpu);
1326 vfree(info); 1358 vfree(info);
1327 1359
1328 return true; 1360 return true;
@@ -1372,7 +1404,7 @@ static unsigned long kvmgt_gfn_to_pfn(unsigned long handle, unsigned long gfn)
1372 return pfn; 1404 return pfn;
1373 1405
1374 pfn = INTEL_GVT_INVALID_ADDR; 1406 pfn = INTEL_GVT_INVALID_ADDR;
1375 dev = &info->vgpu->vdev.mdev->dev; 1407 dev = mdev_dev(info->vgpu->vdev.mdev);
1376 rc = vfio_pin_pages(dev, &gfn, 1, IOMMU_READ | IOMMU_WRITE, &pfn); 1408 rc = vfio_pin_pages(dev, &gfn, 1, IOMMU_READ | IOMMU_WRITE, &pfn);
1377 if (rc != 1) { 1409 if (rc != 1) {
1378 gvt_err("vfio_pin_pages failed for gfn 0x%lx: %d\n", gfn, rc); 1410 gvt_err("vfio_pin_pages failed for gfn 0x%lx: %d\n", gfn, rc);
diff --git a/drivers/gpu/drm/i915/gvt/mmio.c b/drivers/gpu/drm/i915/gvt/mmio.c
index 09c9450a1946..4df078bc5d04 100644
--- a/drivers/gpu/drm/i915/gvt/mmio.c
+++ b/drivers/gpu/drm/i915/gvt/mmio.c
@@ -125,25 +125,12 @@ int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, uint64_t pa,
125 if (WARN_ON(!reg_is_mmio(gvt, offset + bytes - 1))) 125 if (WARN_ON(!reg_is_mmio(gvt, offset + bytes - 1)))
126 goto err; 126 goto err;
127 127
128 mmio = intel_gvt_find_mmio_info(gvt, rounddown(offset, 4));
129 if (!mmio && !vgpu->mmio.disable_warn_untrack) {
130 gvt_err("vgpu%d: read untracked MMIO %x len %d val %x\n",
131 vgpu->id, offset, bytes, *(u32 *)p_data);
132
133 if (offset == 0x206c) {
134 gvt_err("------------------------------------------\n");
135 gvt_err("vgpu%d: likely triggers a gfx reset\n",
136 vgpu->id);
137 gvt_err("------------------------------------------\n");
138 vgpu->mmio.disable_warn_untrack = true;
139 }
140 }
141
142 if (!intel_gvt_mmio_is_unalign(gvt, offset)) { 128 if (!intel_gvt_mmio_is_unalign(gvt, offset)) {
143 if (WARN_ON(!IS_ALIGNED(offset, bytes))) 129 if (WARN_ON(!IS_ALIGNED(offset, bytes)))
144 goto err; 130 goto err;
145 } 131 }
146 132
133 mmio = intel_gvt_find_mmio_info(gvt, rounddown(offset, 4));
147 if (mmio) { 134 if (mmio) {
148 if (!intel_gvt_mmio_is_unalign(gvt, mmio->offset)) { 135 if (!intel_gvt_mmio_is_unalign(gvt, mmio->offset)) {
149 if (WARN_ON(offset + bytes > mmio->offset + mmio->size)) 136 if (WARN_ON(offset + bytes > mmio->offset + mmio->size))
@@ -152,9 +139,23 @@ int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, uint64_t pa,
152 goto err; 139 goto err;
153 } 140 }
154 ret = mmio->read(vgpu, offset, p_data, bytes); 141 ret = mmio->read(vgpu, offset, p_data, bytes);
155 } else 142 } else {
156 ret = intel_vgpu_default_mmio_read(vgpu, offset, p_data, bytes); 143 ret = intel_vgpu_default_mmio_read(vgpu, offset, p_data, bytes);
157 144
145 if (!vgpu->mmio.disable_warn_untrack) {
146 gvt_err("vgpu%d: read untracked MMIO %x(%dB) val %x\n",
147 vgpu->id, offset, bytes, *(u32 *)p_data);
148
149 if (offset == 0x206c) {
150 gvt_err("------------------------------------------\n");
151 gvt_err("vgpu%d: likely triggers a gfx reset\n",
152 vgpu->id);
153 gvt_err("------------------------------------------\n");
154 vgpu->mmio.disable_warn_untrack = true;
155 }
156 }
157 }
158
158 if (ret) 159 if (ret)
159 goto err; 160 goto err;
160 161
@@ -302,3 +303,56 @@ err:
302 mutex_unlock(&gvt->lock); 303 mutex_unlock(&gvt->lock);
303 return ret; 304 return ret;
304} 305}
306
307
308/**
309 * intel_vgpu_reset_mmio - reset virtual MMIO space
310 * @vgpu: a vGPU
311 *
312 */
313void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu)
314{
315 struct intel_gvt *gvt = vgpu->gvt;
316 const struct intel_gvt_device_info *info = &gvt->device_info;
317
318 memcpy(vgpu->mmio.vreg, gvt->firmware.mmio, info->mmio_size);
319 memcpy(vgpu->mmio.sreg, gvt->firmware.mmio, info->mmio_size);
320
321 vgpu_vreg(vgpu, GEN6_GT_THREAD_STATUS_REG) = 0;
322
323 /* set the bit 0:2(Core C-State ) to C0 */
324 vgpu_vreg(vgpu, GEN6_GT_CORE_STATUS) = 0;
325}
326
327/**
328 * intel_vgpu_init_mmio - init MMIO space
329 * @vgpu: a vGPU
330 *
331 * Returns:
332 * Zero on success, negative error code if failed
333 */
334int intel_vgpu_init_mmio(struct intel_vgpu *vgpu)
335{
336 const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
337
338 vgpu->mmio.vreg = vzalloc(info->mmio_size * 2);
339 if (!vgpu->mmio.vreg)
340 return -ENOMEM;
341
342 vgpu->mmio.sreg = vgpu->mmio.vreg + info->mmio_size;
343
344 intel_vgpu_reset_mmio(vgpu);
345
346 return 0;
347}
348
349/**
350 * intel_vgpu_clean_mmio - clean MMIO space
351 * @vgpu: a vGPU
352 *
353 */
354void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu)
355{
356 vfree(vgpu->mmio.vreg);
357 vgpu->mmio.vreg = vgpu->mmio.sreg = NULL;
358}
diff --git a/drivers/gpu/drm/i915/gvt/mmio.h b/drivers/gpu/drm/i915/gvt/mmio.h
index 87d5b5e366a3..3bc620f56f35 100644
--- a/drivers/gpu/drm/i915/gvt/mmio.h
+++ b/drivers/gpu/drm/i915/gvt/mmio.h
@@ -86,6 +86,10 @@ struct intel_gvt_mmio_info *intel_gvt_find_mmio_info(struct intel_gvt *gvt,
86 *offset; \ 86 *offset; \
87}) 87})
88 88
89int intel_vgpu_init_mmio(struct intel_vgpu *vgpu);
90void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu);
91void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu);
92
89int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa); 93int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa);
90 94
91int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa, 95int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa,
diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
index d2a0fbc896c3..d9fb41ab7119 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -36,9 +36,9 @@ static int init_vgpu_opregion(struct intel_vgpu *vgpu, u32 gpa)
36 vgpu->id)) 36 vgpu->id))
37 return -EINVAL; 37 return -EINVAL;
38 38
39 vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_ATOMIC | 39 vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
40 GFP_DMA32 | __GFP_ZERO, 40 __GFP_ZERO,
41 INTEL_GVT_OPREGION_PORDER); 41 get_order(INTEL_GVT_OPREGION_SIZE));
42 42
43 if (!vgpu_opregion(vgpu)->va) 43 if (!vgpu_opregion(vgpu)->va)
44 return -ENOMEM; 44 return -ENOMEM;
@@ -65,7 +65,7 @@ static int map_vgpu_opregion(struct intel_vgpu *vgpu, bool map)
65 int i, ret; 65 int i, ret;
66 66
67 for (i = 0; i < INTEL_GVT_OPREGION_PAGES; i++) { 67 for (i = 0; i < INTEL_GVT_OPREGION_PAGES; i++) {
68 mfn = intel_gvt_hypervisor_virt_to_mfn(vgpu_opregion(vgpu) 68 mfn = intel_gvt_hypervisor_virt_to_mfn(vgpu_opregion(vgpu)->va
69 + i * PAGE_SIZE); 69 + i * PAGE_SIZE);
70 if (mfn == INTEL_GVT_INVALID_ADDR) { 70 if (mfn == INTEL_GVT_INVALID_ADDR) {
71 gvt_err("fail to get MFN from VA\n"); 71 gvt_err("fail to get MFN from VA\n");
@@ -97,7 +97,7 @@ void intel_vgpu_clean_opregion(struct intel_vgpu *vgpu)
97 if (intel_gvt_host.hypervisor_type == INTEL_GVT_HYPERVISOR_XEN) { 97 if (intel_gvt_host.hypervisor_type == INTEL_GVT_HYPERVISOR_XEN) {
98 map_vgpu_opregion(vgpu, false); 98 map_vgpu_opregion(vgpu, false);
99 free_pages((unsigned long)vgpu_opregion(vgpu)->va, 99 free_pages((unsigned long)vgpu_opregion(vgpu)->va,
100 INTEL_GVT_OPREGION_PORDER); 100 get_order(INTEL_GVT_OPREGION_SIZE));
101 101
102 vgpu_opregion(vgpu)->va = NULL; 102 vgpu_opregion(vgpu)->va = NULL;
103 } 103 }
diff --git a/drivers/gpu/drm/i915/gvt/reg.h b/drivers/gpu/drm/i915/gvt/reg.h
index 0dfe789d8f02..fbd023a16f18 100644
--- a/drivers/gpu/drm/i915/gvt/reg.h
+++ b/drivers/gpu/drm/i915/gvt/reg.h
@@ -50,8 +50,7 @@
50#define INTEL_GVT_OPREGION_PARM 0x204 50#define INTEL_GVT_OPREGION_PARM 0x204
51 51
52#define INTEL_GVT_OPREGION_PAGES 2 52#define INTEL_GVT_OPREGION_PAGES 2
53#define INTEL_GVT_OPREGION_PORDER 1 53#define INTEL_GVT_OPREGION_SIZE (INTEL_GVT_OPREGION_PAGES * PAGE_SIZE)
54#define INTEL_GVT_OPREGION_SIZE (2 * 4096)
55 54
56#define VGT_SPRSTRIDE(pipe) _PIPE(pipe, _SPRA_STRIDE, _PLANE_STRIDE_2_B) 55#define VGT_SPRSTRIDE(pipe) _PIPE(pipe, _SPRA_STRIDE, _PLANE_STRIDE_2_B)
57 56
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 4db242250235..e91885dffeff 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -350,13 +350,15 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
350{ 350{
351 struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler; 351 struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
352 struct intel_vgpu_workload *workload; 352 struct intel_vgpu_workload *workload;
353 struct intel_vgpu *vgpu;
353 int event; 354 int event;
354 355
355 mutex_lock(&gvt->lock); 356 mutex_lock(&gvt->lock);
356 357
357 workload = scheduler->current_workload[ring_id]; 358 workload = scheduler->current_workload[ring_id];
359 vgpu = workload->vgpu;
358 360
359 if (!workload->status && !workload->vgpu->resetting) { 361 if (!workload->status && !vgpu->resetting) {
360 wait_event(workload->shadow_ctx_status_wq, 362 wait_event(workload->shadow_ctx_status_wq,
361 !atomic_read(&workload->shadow_ctx_active)); 363 !atomic_read(&workload->shadow_ctx_active));
362 364
@@ -364,8 +366,7 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
364 366
365 for_each_set_bit(event, workload->pending_events, 367 for_each_set_bit(event, workload->pending_events,
366 INTEL_GVT_EVENT_MAX) 368 INTEL_GVT_EVENT_MAX)
367 intel_vgpu_trigger_virtual_event(workload->vgpu, 369 intel_vgpu_trigger_virtual_event(vgpu, event);
368 event);
369 } 370 }
370 371
371 gvt_dbg_sched("ring id %d complete workload %p status %d\n", 372 gvt_dbg_sched("ring id %d complete workload %p status %d\n",
@@ -373,11 +374,10 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
373 374
374 scheduler->current_workload[ring_id] = NULL; 375 scheduler->current_workload[ring_id] = NULL;
375 376
376 atomic_dec(&workload->vgpu->running_workload_num);
377
378 list_del_init(&workload->list); 377 list_del_init(&workload->list);
379 workload->complete(workload); 378 workload->complete(workload);
380 379
380 atomic_dec(&vgpu->running_workload_num);
381 wake_up(&scheduler->workload_complete_wq); 381 wake_up(&scheduler->workload_complete_wq);
382 mutex_unlock(&gvt->lock); 382 mutex_unlock(&gvt->lock);
383} 383}
@@ -459,11 +459,11 @@ complete:
459 gvt_dbg_sched("will complete workload %p\n, status: %d\n", 459 gvt_dbg_sched("will complete workload %p\n, status: %d\n",
460 workload, workload->status); 460 workload, workload->status);
461 461
462 complete_current_workload(gvt, ring_id);
463
464 if (workload->req) 462 if (workload->req)
465 i915_gem_request_put(fetch_and_zero(&workload->req)); 463 i915_gem_request_put(fetch_and_zero(&workload->req));
466 464
465 complete_current_workload(gvt, ring_id);
466
467 if (need_force_wake) 467 if (need_force_wake)
468 intel_uncore_forcewake_put(gvt->dev_priv, 468 intel_uncore_forcewake_put(gvt->dev_priv,
469 FORCEWAKE_ALL); 469 FORCEWAKE_ALL);
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
index 536d2b9d5777..7295bc8e12fb 100644
--- a/drivers/gpu/drm/i915/gvt/vgpu.c
+++ b/drivers/gpu/drm/i915/gvt/vgpu.c
@@ -35,79 +35,6 @@
35#include "gvt.h" 35#include "gvt.h"
36#include "i915_pvinfo.h" 36#include "i915_pvinfo.h"
37 37
38static void clean_vgpu_mmio(struct intel_vgpu *vgpu)
39{
40 vfree(vgpu->mmio.vreg);
41 vgpu->mmio.vreg = vgpu->mmio.sreg = NULL;
42}
43
44int setup_vgpu_mmio(struct intel_vgpu *vgpu)
45{
46 struct intel_gvt *gvt = vgpu->gvt;
47 const struct intel_gvt_device_info *info = &gvt->device_info;
48
49 if (vgpu->mmio.vreg)
50 memset(vgpu->mmio.vreg, 0, info->mmio_size * 2);
51 else {
52 vgpu->mmio.vreg = vzalloc(info->mmio_size * 2);
53 if (!vgpu->mmio.vreg)
54 return -ENOMEM;
55 }
56
57 vgpu->mmio.sreg = vgpu->mmio.vreg + info->mmio_size;
58
59 memcpy(vgpu->mmio.vreg, gvt->firmware.mmio, info->mmio_size);
60 memcpy(vgpu->mmio.sreg, gvt->firmware.mmio, info->mmio_size);
61
62 vgpu_vreg(vgpu, GEN6_GT_THREAD_STATUS_REG) = 0;
63
64 /* set the bit 0:2(Core C-State ) to C0 */
65 vgpu_vreg(vgpu, GEN6_GT_CORE_STATUS) = 0;
66 return 0;
67}
68
69static void setup_vgpu_cfg_space(struct intel_vgpu *vgpu,
70 struct intel_vgpu_creation_params *param)
71{
72 struct intel_gvt *gvt = vgpu->gvt;
73 const struct intel_gvt_device_info *info = &gvt->device_info;
74 u16 *gmch_ctl;
75 int i;
76
77 memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space,
78 info->cfg_space_size);
79
80 if (!param->primary) {
81 vgpu_cfg_space(vgpu)[PCI_CLASS_DEVICE] =
82 INTEL_GVT_PCI_CLASS_VGA_OTHER;
83 vgpu_cfg_space(vgpu)[PCI_CLASS_PROG] =
84 INTEL_GVT_PCI_CLASS_VGA_OTHER;
85 }
86
87 /* Show guest that there isn't any stolen memory.*/
88 gmch_ctl = (u16 *)(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_GMCH_CONTROL);
89 *gmch_ctl &= ~(BDW_GMCH_GMS_MASK << BDW_GMCH_GMS_SHIFT);
90
91 intel_vgpu_write_pci_bar(vgpu, PCI_BASE_ADDRESS_2,
92 gvt_aperture_pa_base(gvt), true);
93
94 vgpu_cfg_space(vgpu)[PCI_COMMAND] &= ~(PCI_COMMAND_IO
95 | PCI_COMMAND_MEMORY
96 | PCI_COMMAND_MASTER);
97 /*
98 * Clear the bar upper 32bit and let guest to assign the new value
99 */
100 memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_1, 0, 4);
101 memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_3, 0, 4);
102 memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4);
103
104 for (i = 0; i < INTEL_GVT_MAX_BAR_NUM; i++) {
105 vgpu->cfg_space.bar[i].size = pci_resource_len(
106 gvt->dev_priv->drm.pdev, i * 2);
107 vgpu->cfg_space.bar[i].tracked = false;
108 }
109}
110
111void populate_pvinfo_page(struct intel_vgpu *vgpu) 38void populate_pvinfo_page(struct intel_vgpu *vgpu)
112{ 39{
113 /* setup the ballooning information */ 40 /* setup the ballooning information */
@@ -177,7 +104,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
177 if (low_avail / min_low == 0) 104 if (low_avail / min_low == 0)
178 break; 105 break;
179 gvt->types[i].low_gm_size = min_low; 106 gvt->types[i].low_gm_size = min_low;
180 gvt->types[i].high_gm_size = 3 * gvt->types[i].low_gm_size; 107 gvt->types[i].high_gm_size = max((min_low<<3), MB_TO_BYTES(384U));
181 gvt->types[i].fence = 4; 108 gvt->types[i].fence = 4;
182 gvt->types[i].max_instance = low_avail / min_low; 109 gvt->types[i].max_instance = low_avail / min_low;
183 gvt->types[i].avail_instance = gvt->types[i].max_instance; 110 gvt->types[i].avail_instance = gvt->types[i].max_instance;
@@ -217,7 +144,7 @@ static void intel_gvt_update_vgpu_types(struct intel_gvt *gvt)
217 */ 144 */
218 low_gm_avail = MB_TO_BYTES(256) - HOST_LOW_GM_SIZE - 145 low_gm_avail = MB_TO_BYTES(256) - HOST_LOW_GM_SIZE -
219 gvt->gm.vgpu_allocated_low_gm_size; 146 gvt->gm.vgpu_allocated_low_gm_size;
220 high_gm_avail = MB_TO_BYTES(256) * 3 - HOST_HIGH_GM_SIZE - 147 high_gm_avail = MB_TO_BYTES(256) * 8UL - HOST_HIGH_GM_SIZE -
221 gvt->gm.vgpu_allocated_high_gm_size; 148 gvt->gm.vgpu_allocated_high_gm_size;
222 fence_avail = gvt_fence_sz(gvt) - HOST_FENCE - 149 fence_avail = gvt_fence_sz(gvt) - HOST_FENCE -
223 gvt->fence.vgpu_allocated_fence_num; 150 gvt->fence.vgpu_allocated_fence_num;
@@ -268,7 +195,7 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
268 intel_vgpu_clean_gtt(vgpu); 195 intel_vgpu_clean_gtt(vgpu);
269 intel_gvt_hypervisor_detach_vgpu(vgpu); 196 intel_gvt_hypervisor_detach_vgpu(vgpu);
270 intel_vgpu_free_resource(vgpu); 197 intel_vgpu_free_resource(vgpu);
271 clean_vgpu_mmio(vgpu); 198 intel_vgpu_clean_mmio(vgpu);
272 vfree(vgpu); 199 vfree(vgpu);
273 200
274 intel_gvt_update_vgpu_types(gvt); 201 intel_gvt_update_vgpu_types(gvt);
@@ -300,11 +227,11 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
300 vgpu->gvt = gvt; 227 vgpu->gvt = gvt;
301 bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES); 228 bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES);
302 229
303 setup_vgpu_cfg_space(vgpu, param); 230 intel_vgpu_init_cfg_space(vgpu, param->primary);
304 231
305 ret = setup_vgpu_mmio(vgpu); 232 ret = intel_vgpu_init_mmio(vgpu);
306 if (ret) 233 if (ret)
307 goto out_free_vgpu; 234 goto out_clean_idr;
308 235
309 ret = intel_vgpu_alloc_resource(vgpu, param); 236 ret = intel_vgpu_alloc_resource(vgpu, param);
310 if (ret) 237 if (ret)
@@ -354,7 +281,9 @@ out_detach_hypervisor_vgpu:
354out_clean_vgpu_resource: 281out_clean_vgpu_resource:
355 intel_vgpu_free_resource(vgpu); 282 intel_vgpu_free_resource(vgpu);
356out_clean_vgpu_mmio: 283out_clean_vgpu_mmio:
357 clean_vgpu_mmio(vgpu); 284 intel_vgpu_clean_mmio(vgpu);
285out_clean_idr:
286 idr_remove(&gvt->vgpu_idr, vgpu->id);
358out_free_vgpu: 287out_free_vgpu:
359 vfree(vgpu); 288 vfree(vgpu);
360 mutex_unlock(&gvt->lock); 289 mutex_unlock(&gvt->lock);
@@ -398,7 +327,75 @@ struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
398} 327}
399 328
400/** 329/**
401 * intel_gvt_reset_vgpu - reset a virtual GPU 330 * intel_gvt_reset_vgpu_locked - reset a virtual GPU by DMLR or GT reset
331 * @vgpu: virtual GPU
332 * @dmlr: vGPU Device Model Level Reset or GT Reset
333 * @engine_mask: engines to reset for GT reset
334 *
335 * This function is called when user wants to reset a virtual GPU through
336 * device model reset or GT reset. The caller should hold the gvt lock.
337 *
338 * vGPU Device Model Level Reset (DMLR) simulates the PCI level reset to reset
339 * the whole vGPU to default state as when it is created. This vGPU function
340 * is required both for functionary and security concerns.The ultimate goal
341 * of vGPU FLR is that reuse a vGPU instance by virtual machines. When we
342 * assign a vGPU to a virtual machine we must isse such reset first.
343 *
344 * Full GT Reset and Per-Engine GT Reset are soft reset flow for GPU engines
345 * (Render, Blitter, Video, Video Enhancement). It is defined by GPU Spec.
346 * Unlike the FLR, GT reset only reset particular resource of a vGPU per
347 * the reset request. Guest driver can issue a GT reset by programming the
348 * virtual GDRST register to reset specific virtual GPU engine or all
349 * engines.
350 *
351 * The parameter dev_level is to identify if we will do DMLR or GT reset.
352 * The parameter engine_mask is to specific the engines that need to be
353 * resetted. If value ALL_ENGINES is given for engine_mask, it means
354 * the caller requests a full GT reset that we will reset all virtual
355 * GPU engines. For FLR, engine_mask is ignored.
356 */
357void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
358 unsigned int engine_mask)
359{
360 struct intel_gvt *gvt = vgpu->gvt;
361 struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
362
363 gvt_dbg_core("------------------------------------------\n");
364 gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n",
365 vgpu->id, dmlr, engine_mask);
366 vgpu->resetting = true;
367
368 intel_vgpu_stop_schedule(vgpu);
369 /*
370 * The current_vgpu will set to NULL after stopping the
371 * scheduler when the reset is triggered by current vgpu.
372 */
373 if (scheduler->current_vgpu == NULL) {
374 mutex_unlock(&gvt->lock);
375 intel_gvt_wait_vgpu_idle(vgpu);
376 mutex_lock(&gvt->lock);
377 }
378
379 intel_vgpu_reset_execlist(vgpu, dmlr ? ALL_ENGINES : engine_mask);
380
381 /* full GPU reset or device model level reset */
382 if (engine_mask == ALL_ENGINES || dmlr) {
383 intel_vgpu_reset_gtt(vgpu, dmlr);
384 intel_vgpu_reset_resource(vgpu);
385 intel_vgpu_reset_mmio(vgpu);
386 populate_pvinfo_page(vgpu);
387
388 if (dmlr)
389 intel_vgpu_reset_cfg_space(vgpu);
390 }
391
392 vgpu->resetting = false;
393 gvt_dbg_core("reset vgpu%d done\n", vgpu->id);
394 gvt_dbg_core("------------------------------------------\n");
395}
396
397/**
398 * intel_gvt_reset_vgpu - reset a virtual GPU (Function Level)
402 * @vgpu: virtual GPU 399 * @vgpu: virtual GPU
403 * 400 *
404 * This function is called when user wants to reset a virtual GPU. 401 * This function is called when user wants to reset a virtual GPU.
@@ -406,4 +403,7 @@ struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
406 */ 403 */
407void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu) 404void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu)
408{ 405{
406 mutex_lock(&vgpu->gvt->lock);
407 intel_gvt_reset_vgpu_locked(vgpu, true, 0);
408 mutex_unlock(&vgpu->gvt->lock);
409} 409}
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4a31b7a891ec..4b23a7814713 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -244,14 +244,16 @@ err_phys:
244 244
245static void 245static void
246__i915_gem_object_release_shmem(struct drm_i915_gem_object *obj, 246__i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
247 struct sg_table *pages) 247 struct sg_table *pages,
248 bool needs_clflush)
248{ 249{
249 GEM_BUG_ON(obj->mm.madv == __I915_MADV_PURGED); 250 GEM_BUG_ON(obj->mm.madv == __I915_MADV_PURGED);
250 251
251 if (obj->mm.madv == I915_MADV_DONTNEED) 252 if (obj->mm.madv == I915_MADV_DONTNEED)
252 obj->mm.dirty = false; 253 obj->mm.dirty = false;
253 254
254 if ((obj->base.read_domains & I915_GEM_DOMAIN_CPU) == 0 && 255 if (needs_clflush &&
256 (obj->base.read_domains & I915_GEM_DOMAIN_CPU) == 0 &&
255 !cpu_cache_is_coherent(obj->base.dev, obj->cache_level)) 257 !cpu_cache_is_coherent(obj->base.dev, obj->cache_level))
256 drm_clflush_sg(pages); 258 drm_clflush_sg(pages);
257 259
@@ -263,7 +265,7 @@ static void
263i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj, 265i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
264 struct sg_table *pages) 266 struct sg_table *pages)
265{ 267{
266 __i915_gem_object_release_shmem(obj, pages); 268 __i915_gem_object_release_shmem(obj, pages, false);
267 269
268 if (obj->mm.dirty) { 270 if (obj->mm.dirty) {
269 struct address_space *mapping = obj->base.filp->f_mapping; 271 struct address_space *mapping = obj->base.filp->f_mapping;
@@ -593,47 +595,21 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
593 struct drm_i915_gem_pwrite *args, 595 struct drm_i915_gem_pwrite *args,
594 struct drm_file *file) 596 struct drm_file *file)
595{ 597{
596 struct drm_device *dev = obj->base.dev;
597 void *vaddr = obj->phys_handle->vaddr + args->offset; 598 void *vaddr = obj->phys_handle->vaddr + args->offset;
598 char __user *user_data = u64_to_user_ptr(args->data_ptr); 599 char __user *user_data = u64_to_user_ptr(args->data_ptr);
599 int ret;
600 600
601 /* We manually control the domain here and pretend that it 601 /* We manually control the domain here and pretend that it
602 * remains coherent i.e. in the GTT domain, like shmem_pwrite. 602 * remains coherent i.e. in the GTT domain, like shmem_pwrite.
603 */ 603 */
604 lockdep_assert_held(&obj->base.dev->struct_mutex);
605 ret = i915_gem_object_wait(obj,
606 I915_WAIT_INTERRUPTIBLE |
607 I915_WAIT_LOCKED |
608 I915_WAIT_ALL,
609 MAX_SCHEDULE_TIMEOUT,
610 to_rps_client(file));
611 if (ret)
612 return ret;
613
614 intel_fb_obj_invalidate(obj, ORIGIN_CPU); 604 intel_fb_obj_invalidate(obj, ORIGIN_CPU);
615 if (__copy_from_user_inatomic_nocache(vaddr, user_data, args->size)) { 605 if (copy_from_user(vaddr, user_data, args->size))
616 unsigned long unwritten; 606 return -EFAULT;
617
618 /* The physical object once assigned is fixed for the lifetime
619 * of the obj, so we can safely drop the lock and continue
620 * to access vaddr.
621 */
622 mutex_unlock(&dev->struct_mutex);
623 unwritten = copy_from_user(vaddr, user_data, args->size);
624 mutex_lock(&dev->struct_mutex);
625 if (unwritten) {
626 ret = -EFAULT;
627 goto out;
628 }
629 }
630 607
631 drm_clflush_virt_range(vaddr, args->size); 608 drm_clflush_virt_range(vaddr, args->size);
632 i915_gem_chipset_flush(to_i915(dev)); 609 i915_gem_chipset_flush(to_i915(obj->base.dev));
633 610
634out:
635 intel_fb_obj_flush(obj, false, ORIGIN_CPU); 611 intel_fb_obj_flush(obj, false, ORIGIN_CPU);
636 return ret; 612 return 0;
637} 613}
638 614
639void *i915_gem_object_alloc(struct drm_device *dev) 615void *i915_gem_object_alloc(struct drm_device *dev)
@@ -2231,7 +2207,7 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj,
2231 struct sgt_iter sgt_iter; 2207 struct sgt_iter sgt_iter;
2232 struct page *page; 2208 struct page *page;
2233 2209
2234 __i915_gem_object_release_shmem(obj, pages); 2210 __i915_gem_object_release_shmem(obj, pages, true);
2235 2211
2236 i915_gem_gtt_finish_pages(obj, pages); 2212 i915_gem_gtt_finish_pages(obj, pages);
2237 2213
@@ -2304,15 +2280,6 @@ unlock:
2304 mutex_unlock(&obj->mm.lock); 2280 mutex_unlock(&obj->mm.lock);
2305} 2281}
2306 2282
2307static unsigned int swiotlb_max_size(void)
2308{
2309#if IS_ENABLED(CONFIG_SWIOTLB)
2310 return rounddown(swiotlb_nr_tbl() << IO_TLB_SHIFT, PAGE_SIZE);
2311#else
2312 return 0;
2313#endif
2314}
2315
2316static void i915_sg_trim(struct sg_table *orig_st) 2283static void i915_sg_trim(struct sg_table *orig_st)
2317{ 2284{
2318 struct sg_table new_st; 2285 struct sg_table new_st;
@@ -2322,7 +2289,7 @@ static void i915_sg_trim(struct sg_table *orig_st)
2322 if (orig_st->nents == orig_st->orig_nents) 2289 if (orig_st->nents == orig_st->orig_nents)
2323 return; 2290 return;
2324 2291
2325 if (sg_alloc_table(&new_st, orig_st->nents, GFP_KERNEL)) 2292 if (sg_alloc_table(&new_st, orig_st->nents, GFP_KERNEL | __GFP_NOWARN))
2326 return; 2293 return;
2327 2294
2328 new_sg = new_st.sgl; 2295 new_sg = new_st.sgl;
@@ -2360,7 +2327,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
2360 GEM_BUG_ON(obj->base.read_domains & I915_GEM_GPU_DOMAINS); 2327 GEM_BUG_ON(obj->base.read_domains & I915_GEM_GPU_DOMAINS);
2361 GEM_BUG_ON(obj->base.write_domain & I915_GEM_GPU_DOMAINS); 2328 GEM_BUG_ON(obj->base.write_domain & I915_GEM_GPU_DOMAINS);
2362 2329
2363 max_segment = swiotlb_max_size(); 2330 max_segment = swiotlb_max_segment();
2364 if (!max_segment) 2331 if (!max_segment)
2365 max_segment = rounddown(UINT_MAX, PAGE_SIZE); 2332 max_segment = rounddown(UINT_MAX, PAGE_SIZE);
2366 2333
@@ -2728,6 +2695,7 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine)
2728 struct drm_i915_gem_request *request; 2695 struct drm_i915_gem_request *request;
2729 struct i915_gem_context *incomplete_ctx; 2696 struct i915_gem_context *incomplete_ctx;
2730 struct intel_timeline *timeline; 2697 struct intel_timeline *timeline;
2698 unsigned long flags;
2731 bool ring_hung; 2699 bool ring_hung;
2732 2700
2733 if (engine->irq_seqno_barrier) 2701 if (engine->irq_seqno_barrier)
@@ -2763,13 +2731,20 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine)
2763 if (i915_gem_context_is_default(incomplete_ctx)) 2731 if (i915_gem_context_is_default(incomplete_ctx))
2764 return; 2732 return;
2765 2733
2734 timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine);
2735
2736 spin_lock_irqsave(&engine->timeline->lock, flags);
2737 spin_lock(&timeline->lock);
2738
2766 list_for_each_entry_continue(request, &engine->timeline->requests, link) 2739 list_for_each_entry_continue(request, &engine->timeline->requests, link)
2767 if (request->ctx == incomplete_ctx) 2740 if (request->ctx == incomplete_ctx)
2768 reset_request(request); 2741 reset_request(request);
2769 2742
2770 timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine);
2771 list_for_each_entry(request, &timeline->requests, link) 2743 list_for_each_entry(request, &timeline->requests, link)
2772 reset_request(request); 2744 reset_request(request);
2745
2746 spin_unlock(&timeline->lock);
2747 spin_unlock_irqrestore(&engine->timeline->lock, flags);
2773} 2748}
2774 2749
2775void i915_gem_reset(struct drm_i915_private *dev_priv) 2750void i915_gem_reset(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index bd08814b015c..d534a316a16e 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -199,6 +199,7 @@ found:
199 } 199 }
200 200
201 /* Unbinding will emit any required flushes */ 201 /* Unbinding will emit any required flushes */
202 ret = 0;
202 while (!list_empty(&eviction_list)) { 203 while (!list_empty(&eviction_list)) {
203 vma = list_first_entry(&eviction_list, 204 vma = list_first_entry(&eviction_list,
204 struct i915_vma, 205 struct i915_vma,
diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index e2b077df2da0..d229f47d1028 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -413,6 +413,25 @@ i915_gem_active_set(struct i915_gem_active *active,
413 rcu_assign_pointer(active->request, request); 413 rcu_assign_pointer(active->request, request);
414} 414}
415 415
416/**
417 * i915_gem_active_set_retire_fn - updates the retirement callback
418 * @active - the active tracker
419 * @fn - the routine called when the request is retired
420 * @mutex - struct_mutex used to guard retirements
421 *
422 * i915_gem_active_set_retire_fn() updates the function pointer that
423 * is called when the final request associated with the @active tracker
424 * is retired.
425 */
426static inline void
427i915_gem_active_set_retire_fn(struct i915_gem_active *active,
428 i915_gem_retire_fn fn,
429 struct mutex *mutex)
430{
431 lockdep_assert_held(mutex);
432 active->retire = fn ?: i915_gem_retire_noop;
433}
434
416static inline struct drm_i915_gem_request * 435static inline struct drm_i915_gem_request *
417__i915_gem_active_peek(const struct i915_gem_active *active) 436__i915_gem_active_peek(const struct i915_gem_active *active)
418{ 437{
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6daad8613760..8d702cf1a616 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2967,6 +2967,9 @@ int skl_check_plane_surface(struct intel_plane_state *plane_state)
2967 unsigned int rotation = plane_state->base.rotation; 2967 unsigned int rotation = plane_state->base.rotation;
2968 int ret; 2968 int ret;
2969 2969
2970 if (!plane_state->base.visible)
2971 return 0;
2972
2970 /* Rotate src coordinates to match rotated GTT view */ 2973 /* Rotate src coordinates to match rotated GTT view */
2971 if (drm_rotation_90_or_270(rotation)) 2974 if (drm_rotation_90_or_270(rotation))
2972 drm_rect_rotate(&plane_state->base.src, 2975 drm_rect_rotate(&plane_state->base.src,
@@ -16791,7 +16794,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16791 16794
16792 for_each_intel_crtc(dev, crtc) { 16795 for_each_intel_crtc(dev, crtc) {
16793 struct intel_crtc_state *crtc_state = crtc->config; 16796 struct intel_crtc_state *crtc_state = crtc->config;
16794 int pixclk = 0;
16795 16797
16796 __drm_atomic_helper_crtc_destroy_state(&crtc_state->base); 16798 __drm_atomic_helper_crtc_destroy_state(&crtc_state->base);
16797 memset(crtc_state, 0, sizeof(*crtc_state)); 16799 memset(crtc_state, 0, sizeof(*crtc_state));
@@ -16803,23 +16805,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16803 crtc->base.enabled = crtc_state->base.enable; 16805 crtc->base.enabled = crtc_state->base.enable;
16804 crtc->active = crtc_state->base.active; 16806 crtc->active = crtc_state->base.active;
16805 16807
16806 if (crtc_state->base.active) { 16808 if (crtc_state->base.active)
16807 dev_priv->active_crtcs |= 1 << crtc->pipe; 16809 dev_priv->active_crtcs |= 1 << crtc->pipe;
16808 16810
16809 if (INTEL_GEN(dev_priv) >= 9 || IS_BROADWELL(dev_priv))
16810 pixclk = ilk_pipe_pixel_rate(crtc_state);
16811 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
16812 pixclk = crtc_state->base.adjusted_mode.crtc_clock;
16813 else
16814 WARN_ON(dev_priv->display.modeset_calc_cdclk);
16815
16816 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
16817 if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
16818 pixclk = DIV_ROUND_UP(pixclk * 100, 95);
16819 }
16820
16821 dev_priv->min_pixclk[crtc->pipe] = pixclk;
16822
16823 readout_plane_state(crtc); 16811 readout_plane_state(crtc);
16824 16812
16825 DRM_DEBUG_KMS("[CRTC:%d:%s] hw state readout: %s\n", 16813 DRM_DEBUG_KMS("[CRTC:%d:%s] hw state readout: %s\n",
@@ -16892,6 +16880,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16892 } 16880 }
16893 16881
16894 for_each_intel_crtc(dev, crtc) { 16882 for_each_intel_crtc(dev, crtc) {
16883 int pixclk = 0;
16884
16895 crtc->base.hwmode = crtc->config->base.adjusted_mode; 16885 crtc->base.hwmode = crtc->config->base.adjusted_mode;
16896 16886
16897 memset(&crtc->base.mode, 0, sizeof(crtc->base.mode)); 16887 memset(&crtc->base.mode, 0, sizeof(crtc->base.mode));
@@ -16919,10 +16909,23 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16919 */ 16909 */
16920 crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED; 16910 crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED;
16921 16911
16912 if (INTEL_GEN(dev_priv) >= 9 || IS_BROADWELL(dev_priv))
16913 pixclk = ilk_pipe_pixel_rate(crtc->config);
16914 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
16915 pixclk = crtc->config->base.adjusted_mode.crtc_clock;
16916 else
16917 WARN_ON(dev_priv->display.modeset_calc_cdclk);
16918
16919 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
16920 if (IS_BROADWELL(dev_priv) && crtc->config->ips_enabled)
16921 pixclk = DIV_ROUND_UP(pixclk * 100, 95);
16922
16922 drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode); 16923 drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode);
16923 update_scanline_offset(crtc); 16924 update_scanline_offset(crtc);
16924 } 16925 }
16925 16926
16927 dev_priv->min_pixclk[crtc->pipe] = pixclk;
16928
16926 intel_pipe_config_sanity_check(dev_priv, crtc->config); 16929 intel_pipe_config_sanity_check(dev_priv, crtc->config);
16927 } 16930 }
16928} 16931}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d9bc19be855e..0b8e8eb85c19 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -355,7 +355,8 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev,
355 struct intel_dp *intel_dp); 355 struct intel_dp *intel_dp);
356static void 356static void
357intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, 357intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
358 struct intel_dp *intel_dp); 358 struct intel_dp *intel_dp,
359 bool force_disable_vdd);
359static void 360static void
360intel_dp_pps_init(struct drm_device *dev, struct intel_dp *intel_dp); 361intel_dp_pps_init(struct drm_device *dev, struct intel_dp *intel_dp);
361 362
@@ -516,7 +517,7 @@ vlv_power_sequencer_pipe(struct intel_dp *intel_dp)
516 517
517 /* init power sequencer on this pipe and port */ 518 /* init power sequencer on this pipe and port */
518 intel_dp_init_panel_power_sequencer(dev, intel_dp); 519 intel_dp_init_panel_power_sequencer(dev, intel_dp);
519 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 520 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true);
520 521
521 /* 522 /*
522 * Even vdd force doesn't work until we've made 523 * Even vdd force doesn't work until we've made
@@ -553,7 +554,7 @@ bxt_power_sequencer_idx(struct intel_dp *intel_dp)
553 * Only the HW needs to be reprogrammed, the SW state is fixed and 554 * Only the HW needs to be reprogrammed, the SW state is fixed and
554 * has been setup during connector init. 555 * has been setup during connector init.
555 */ 556 */
556 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 557 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
557 558
558 return 0; 559 return 0;
559} 560}
@@ -636,7 +637,7 @@ vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp)
636 port_name(port), pipe_name(intel_dp->pps_pipe)); 637 port_name(port), pipe_name(intel_dp->pps_pipe));
637 638
638 intel_dp_init_panel_power_sequencer(dev, intel_dp); 639 intel_dp_init_panel_power_sequencer(dev, intel_dp);
639 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 640 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
640} 641}
641 642
642void intel_power_sequencer_reset(struct drm_i915_private *dev_priv) 643void intel_power_sequencer_reset(struct drm_i915_private *dev_priv)
@@ -2912,7 +2913,7 @@ static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp)
2912 2913
2913 /* init power sequencer on this pipe and port */ 2914 /* init power sequencer on this pipe and port */
2914 intel_dp_init_panel_power_sequencer(dev, intel_dp); 2915 intel_dp_init_panel_power_sequencer(dev, intel_dp);
2915 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 2916 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true);
2916} 2917}
2917 2918
2918static void vlv_pre_enable_dp(struct intel_encoder *encoder, 2919static void vlv_pre_enable_dp(struct intel_encoder *encoder,
@@ -5055,7 +5056,8 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev,
5055 5056
5056static void 5057static void
5057intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, 5058intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
5058 struct intel_dp *intel_dp) 5059 struct intel_dp *intel_dp,
5060 bool force_disable_vdd)
5059{ 5061{
5060 struct drm_i915_private *dev_priv = to_i915(dev); 5062 struct drm_i915_private *dev_priv = to_i915(dev);
5061 u32 pp_on, pp_off, pp_div, port_sel = 0; 5063 u32 pp_on, pp_off, pp_div, port_sel = 0;
@@ -5068,6 +5070,31 @@ intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
5068 5070
5069 intel_pps_get_registers(dev_priv, intel_dp, &regs); 5071 intel_pps_get_registers(dev_priv, intel_dp, &regs);
5070 5072
5073 /*
5074 * On some VLV machines the BIOS can leave the VDD
5075 * enabled even on power seqeuencers which aren't
5076 * hooked up to any port. This would mess up the
5077 * power domain tracking the first time we pick
5078 * one of these power sequencers for use since
5079 * edp_panel_vdd_on() would notice that the VDD was
5080 * already on and therefore wouldn't grab the power
5081 * domain reference. Disable VDD first to avoid this.
5082 * This also avoids spuriously turning the VDD on as
5083 * soon as the new power seqeuencer gets initialized.
5084 */
5085 if (force_disable_vdd) {
5086 u32 pp = ironlake_get_pp_control(intel_dp);
5087
5088 WARN(pp & PANEL_POWER_ON, "Panel power already on\n");
5089
5090 if (pp & EDP_FORCE_VDD)
5091 DRM_DEBUG_KMS("VDD already on, disabling first\n");
5092
5093 pp &= ~EDP_FORCE_VDD;
5094
5095 I915_WRITE(regs.pp_ctrl, pp);
5096 }
5097
5071 pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) | 5098 pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |
5072 (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT); 5099 (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT);
5073 pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) | 5100 pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |
@@ -5122,7 +5149,7 @@ static void intel_dp_pps_init(struct drm_device *dev,
5122 vlv_initial_power_sequencer_setup(intel_dp); 5149 vlv_initial_power_sequencer_setup(intel_dp);
5123 } else { 5150 } else {
5124 intel_dp_init_panel_power_sequencer(dev, intel_dp); 5151 intel_dp_init_panel_power_sequencer(dev, intel_dp);
5125 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 5152 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
5126 } 5153 }
5127} 5154}
5128 5155
diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
index 3d546c019de0..b62e3f8ad415 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -180,7 +180,7 @@ static void intel_hpd_irq_storm_disable(struct drm_i915_private *dev_priv)
180 180
181 /* Enable polling and queue hotplug re-enabling. */ 181 /* Enable polling and queue hotplug re-enabling. */
182 if (hpd_disabled) { 182 if (hpd_disabled) {
183 drm_kms_helper_poll_enable_locked(dev); 183 drm_kms_helper_poll_enable(dev);
184 mod_delayed_work(system_wq, &dev_priv->hotplug.reenable_work, 184 mod_delayed_work(system_wq, &dev_priv->hotplug.reenable_work,
185 msecs_to_jiffies(HPD_STORM_REENABLE_DELAY)); 185 msecs_to_jiffies(HPD_STORM_REENABLE_DELAY));
186 } 186 }
@@ -511,7 +511,7 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
511 } 511 }
512 512
513 if (enabled) 513 if (enabled)
514 drm_kms_helper_poll_enable_locked(dev); 514 drm_kms_helper_poll_enable(dev);
515 515
516 mutex_unlock(&dev->mode_config.mutex); 516 mutex_unlock(&dev->mode_config.mutex);
517 517
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index d4961fa20c73..beabc17e7c8a 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -979,18 +979,8 @@ static inline int gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine,
979 uint32_t *batch, 979 uint32_t *batch,
980 uint32_t index) 980 uint32_t index)
981{ 981{
982 struct drm_i915_private *dev_priv = engine->i915;
983 uint32_t l3sqc4_flush = (0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES); 982 uint32_t l3sqc4_flush = (0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES);
984 983
985 /*
986 * WaDisableLSQCROPERFforOCL:kbl
987 * This WA is implemented in skl_init_clock_gating() but since
988 * this batch updates GEN8_L3SQCREG4 with default value we need to
989 * set this bit here to retain the WA during flush.
990 */
991 if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0))
992 l3sqc4_flush |= GEN8_LQSC_RO_PERF_DIS;
993
994 wa_ctx_emit(batch, index, (MI_STORE_REGISTER_MEM_GEN8 | 984 wa_ctx_emit(batch, index, (MI_STORE_REGISTER_MEM_GEN8 |
995 MI_SRM_LRM_GLOBAL_GTT)); 985 MI_SRM_LRM_GLOBAL_GTT));
996 wa_ctx_emit_reg(batch, index, GEN8_L3SQCREG4); 986 wa_ctx_emit_reg(batch, index, GEN8_L3SQCREG4);
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index fd0e4dac7cc1..e589e17876dc 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -216,7 +216,8 @@ static void intel_overlay_submit_request(struct intel_overlay *overlay,
216{ 216{
217 GEM_BUG_ON(i915_gem_active_peek(&overlay->last_flip, 217 GEM_BUG_ON(i915_gem_active_peek(&overlay->last_flip,
218 &overlay->i915->drm.struct_mutex)); 218 &overlay->i915->drm.struct_mutex));
219 overlay->last_flip.retire = retire; 219 i915_gem_active_set_retire_fn(&overlay->last_flip, retire,
220 &overlay->i915->drm.struct_mutex);
220 i915_gem_active_set(&overlay->last_flip, req); 221 i915_gem_active_set(&overlay->last_flip, req);
221 i915_add_request(req); 222 i915_add_request(req);
222} 223}
@@ -839,8 +840,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
839 if (ret) 840 if (ret)
840 goto out_unpin; 841 goto out_unpin;
841 842
842 i915_gem_track_fb(overlay->vma->obj, new_bo, 843 i915_gem_track_fb(overlay->vma ? overlay->vma->obj : NULL,
843 INTEL_FRONTBUFFER_OVERLAY(pipe)); 844 vma->obj, INTEL_FRONTBUFFER_OVERLAY(pipe));
844 845
845 overlay->old_vma = overlay->vma; 846 overlay->old_vma = overlay->vma;
846 overlay->vma = vma; 847 overlay->vma = vma;
@@ -1430,6 +1431,8 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv)
1430 overlay->contrast = 75; 1431 overlay->contrast = 75;
1431 overlay->saturation = 146; 1432 overlay->saturation = 146;
1432 1433
1434 init_request_active(&overlay->last_flip, NULL);
1435
1433 regs = intel_overlay_map_regs(overlay); 1436 regs = intel_overlay_map_regs(overlay);
1434 if (!regs) 1437 if (!regs)
1435 goto out_unpin_bo; 1438 goto out_unpin_bo;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index aeb637dc1fdf..91cb4c422ad5 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1095,14 +1095,6 @@ static int kbl_init_workarounds(struct intel_engine_cs *engine)
1095 WA_SET_BIT_MASKED(HDC_CHICKEN0, 1095 WA_SET_BIT_MASKED(HDC_CHICKEN0,
1096 HDC_FENCE_DEST_SLM_DISABLE); 1096 HDC_FENCE_DEST_SLM_DISABLE);
1097 1097
1098 /* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes
1099 * involving this register should also be added to WA batch as required.
1100 */
1101 if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0))
1102 /* WaDisableLSQCROPERFforOCL:kbl */
1103 I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) |
1104 GEN8_LQSC_RO_PERF_DIS);
1105
1106 /* WaToEnableHwFixForPushConstHWBug:kbl */ 1098 /* WaToEnableHwFixForPushConstHWBug:kbl */
1107 if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) 1099 if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER))
1108 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1100 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 4942ca090b46..7890e30eb584 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -51,6 +51,9 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
51 struct drm_crtc_state *crtc_state; 51 struct drm_crtc_state *crtc_state;
52 struct drm_rect clip = { 0, }; 52 struct drm_rect clip = { 0, };
53 53
54 if (!state->crtc)
55 return 0;
56
54 crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); 57 crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
55 if (IS_ERR(crtc_state)) 58 if (IS_ERR(crtc_state))
56 return PTR_ERR(crtc_state); 59 return PTR_ERR(crtc_state);
diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c
index d836b2274531..f7c870172220 100644
--- a/drivers/gpu/drm/meson/meson_venc.c
+++ b/drivers/gpu/drm/meson/meson_venc.c
@@ -38,6 +38,11 @@
38 * - TV Panel encoding via ENCT 38 * - TV Panel encoding via ENCT
39 */ 39 */
40 40
41/* HHI Registers */
42#define HHI_VDAC_CNTL0 0x2F4 /* 0xbd offset in data sheet */
43#define HHI_VDAC_CNTL1 0x2F8 /* 0xbe offset in data sheet */
44#define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 offset in data sheet */
45
41struct meson_cvbs_enci_mode meson_cvbs_enci_pal = { 46struct meson_cvbs_enci_mode meson_cvbs_enci_pal = {
42 .mode_tag = MESON_VENC_MODE_CVBS_PAL, 47 .mode_tag = MESON_VENC_MODE_CVBS_PAL,
43 .hso_begin = 3, 48 .hso_begin = 3,
@@ -242,6 +247,20 @@ void meson_venc_disable_vsync(struct meson_drm *priv)
242 247
243void meson_venc_init(struct meson_drm *priv) 248void meson_venc_init(struct meson_drm *priv)
244{ 249{
250 /* Disable CVBS VDAC */
251 regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0);
252 regmap_write(priv->hhi, HHI_VDAC_CNTL1, 8);
253
254 /* Power Down Dacs */
255 writel_relaxed(0xff, priv->io_base + _REG(VENC_VDAC_SETTING));
256
257 /* Disable HDMI PHY */
258 regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0);
259
260 /* Disable HDMI */
261 writel_bits_relaxed(0x3, 0,
262 priv->io_base + _REG(VPU_HDMI_SETTING));
263
245 /* Disable all encoders */ 264 /* Disable all encoders */
246 writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN)); 265 writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN));
247 writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN)); 266 writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN));
diff --git a/drivers/gpu/drm/meson/meson_venc_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c
index c809c085fd78..a2bcc70a03ef 100644
--- a/drivers/gpu/drm/meson/meson_venc_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c
@@ -167,7 +167,7 @@ static void meson_venc_cvbs_encoder_disable(struct drm_encoder *encoder)
167 167
168 /* Disable CVBS VDAC */ 168 /* Disable CVBS VDAC */
169 regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0); 169 regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0);
170 regmap_write(priv->hhi, HHI_VDAC_CNTL1, 0); 170 regmap_write(priv->hhi, HHI_VDAC_CNTL1, 8);
171} 171}
172 172
173static void meson_venc_cvbs_encoder_enable(struct drm_encoder *encoder) 173static void meson_venc_cvbs_encoder_enable(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index a18126150e11..686a580c711a 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -213,7 +213,14 @@ void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
213void adreno_flush(struct msm_gpu *gpu) 213void adreno_flush(struct msm_gpu *gpu)
214{ 214{
215 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); 215 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
216 uint32_t wptr = get_wptr(gpu->rb); 216 uint32_t wptr;
217
218 /*
219 * Mask wptr value that we calculate to fit in the HW range. This is
220 * to account for the possibility that the last command fit exactly into
221 * the ringbuffer and rb->next hasn't wrapped to zero yet
222 */
223 wptr = get_wptr(gpu->rb) & ((gpu->rb->size / 4) - 1);
217 224
218 /* ensure writes to ringbuffer have hit system memory: */ 225 /* ensure writes to ringbuffer have hit system memory: */
219 mb(); 226 mb();
@@ -338,7 +345,6 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
338{ 345{
339 struct adreno_platform_config *config = pdev->dev.platform_data; 346 struct adreno_platform_config *config = pdev->dev.platform_data;
340 struct msm_gpu *gpu = &adreno_gpu->base; 347 struct msm_gpu *gpu = &adreno_gpu->base;
341 struct msm_mmu *mmu;
342 int ret; 348 int ret;
343 349
344 adreno_gpu->funcs = funcs; 350 adreno_gpu->funcs = funcs;
@@ -378,8 +384,8 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
378 return ret; 384 return ret;
379 } 385 }
380 386
381 mmu = gpu->aspace->mmu; 387 if (gpu->aspace && gpu->aspace->mmu) {
382 if (mmu) { 388 struct msm_mmu *mmu = gpu->aspace->mmu;
383 ret = mmu->funcs->attach(mmu, iommu_ports, 389 ret = mmu->funcs->attach(mmu, iommu_ports,
384 ARRAY_SIZE(iommu_ports)); 390 ARRAY_SIZE(iommu_ports));
385 if (ret) 391 if (ret)
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index 5f6cd8745dbc..c396d459a9d0 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -119,13 +119,7 @@ static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st
119 119
120static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state) 120static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
121{ 121{
122 int i;
123 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); 122 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
124 struct drm_plane *plane;
125 struct drm_plane_state *plane_state;
126
127 for_each_plane_in_state(state, plane, plane_state, i)
128 mdp5_plane_complete_commit(plane, plane_state);
129 123
130 if (mdp5_kms->smp) 124 if (mdp5_kms->smp)
131 mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_kms->state->smp); 125 mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_kms->state->smp);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
index 17b0cc101171..cdfc63d90c7b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
@@ -104,8 +104,6 @@ struct mdp5_plane_state {
104 104
105 /* assigned by crtc blender */ 105 /* assigned by crtc blender */
106 enum mdp_mixer_stage_id stage; 106 enum mdp_mixer_stage_id stage;
107
108 bool pending : 1;
109}; 107};
110#define to_mdp5_plane_state(x) \ 108#define to_mdp5_plane_state(x) \
111 container_of(x, struct mdp5_plane_state, base) 109 container_of(x, struct mdp5_plane_state, base)
@@ -232,8 +230,6 @@ int mdp5_irq_domain_init(struct mdp5_kms *mdp5_kms);
232void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms); 230void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
233 231
234uint32_t mdp5_plane_get_flush(struct drm_plane *plane); 232uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
235void mdp5_plane_complete_commit(struct drm_plane *plane,
236 struct drm_plane_state *state);
237enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane); 233enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
238struct drm_plane *mdp5_plane_init(struct drm_device *dev, bool primary); 234struct drm_plane *mdp5_plane_init(struct drm_device *dev, bool primary);
239 235
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index c099da7bc212..25d9d0a97156 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -179,7 +179,6 @@ mdp5_plane_atomic_print_state(struct drm_printer *p,
179 drm_printf(p, "\tzpos=%u\n", pstate->zpos); 179 drm_printf(p, "\tzpos=%u\n", pstate->zpos);
180 drm_printf(p, "\talpha=%u\n", pstate->alpha); 180 drm_printf(p, "\talpha=%u\n", pstate->alpha);
181 drm_printf(p, "\tstage=%s\n", stage2name(pstate->stage)); 181 drm_printf(p, "\tstage=%s\n", stage2name(pstate->stage));
182 drm_printf(p, "\tpending=%u\n", pstate->pending);
183} 182}
184 183
185static void mdp5_plane_reset(struct drm_plane *plane) 184static void mdp5_plane_reset(struct drm_plane *plane)
@@ -220,8 +219,6 @@ mdp5_plane_duplicate_state(struct drm_plane *plane)
220 if (mdp5_state && mdp5_state->base.fb) 219 if (mdp5_state && mdp5_state->base.fb)
221 drm_framebuffer_reference(mdp5_state->base.fb); 220 drm_framebuffer_reference(mdp5_state->base.fb);
222 221
223 mdp5_state->pending = false;
224
225 return &mdp5_state->base; 222 return &mdp5_state->base;
226} 223}
227 224
@@ -288,13 +285,6 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
288 DBG("%s: check (%d -> %d)", plane->name, 285 DBG("%s: check (%d -> %d)", plane->name,
289 plane_enabled(old_state), plane_enabled(state)); 286 plane_enabled(old_state), plane_enabled(state));
290 287
291 /* We don't allow faster-than-vblank updates.. if we did add this
292 * some day, we would need to disallow in cases where hwpipe
293 * changes
294 */
295 if (WARN_ON(to_mdp5_plane_state(old_state)->pending))
296 return -EBUSY;
297
298 max_width = config->hw->lm.max_width << 16; 288 max_width = config->hw->lm.max_width << 16;
299 max_height = config->hw->lm.max_height << 16; 289 max_height = config->hw->lm.max_height << 16;
300 290
@@ -370,12 +360,9 @@ static void mdp5_plane_atomic_update(struct drm_plane *plane,
370 struct drm_plane_state *old_state) 360 struct drm_plane_state *old_state)
371{ 361{
372 struct drm_plane_state *state = plane->state; 362 struct drm_plane_state *state = plane->state;
373 struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(state);
374 363
375 DBG("%s: update", plane->name); 364 DBG("%s: update", plane->name);
376 365
377 mdp5_state->pending = true;
378
379 if (plane_enabled(state)) { 366 if (plane_enabled(state)) {
380 int ret; 367 int ret;
381 368
@@ -851,15 +838,6 @@ uint32_t mdp5_plane_get_flush(struct drm_plane *plane)
851 return pstate->hwpipe->flush_mask; 838 return pstate->hwpipe->flush_mask;
852} 839}
853 840
854/* called after vsync in thread context */
855void mdp5_plane_complete_commit(struct drm_plane *plane,
856 struct drm_plane_state *state)
857{
858 struct mdp5_plane_state *pstate = to_mdp5_plane_state(plane->state);
859
860 pstate->pending = false;
861}
862
863/* initialize plane */ 841/* initialize plane */
864struct drm_plane *mdp5_plane_init(struct drm_device *dev, bool primary) 842struct drm_plane *mdp5_plane_init(struct drm_device *dev, bool primary)
865{ 843{
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index d8bc59c7e261..8098677a3916 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -294,6 +294,8 @@ put_iova(struct drm_gem_object *obj)
294 WARN_ON(!mutex_is_locked(&dev->struct_mutex)); 294 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
295 295
296 for (id = 0; id < ARRAY_SIZE(msm_obj->domain); id++) { 296 for (id = 0; id < ARRAY_SIZE(msm_obj->domain); id++) {
297 if (!priv->aspace[id])
298 continue;
297 msm_gem_unmap_vma(priv->aspace[id], 299 msm_gem_unmap_vma(priv->aspace[id],
298 &msm_obj->domain[id], msm_obj->sgt); 300 &msm_obj->domain[id], msm_obj->sgt);
299 } 301 }
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 166e84e4f0d4..489676568a10 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -106,7 +106,8 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
106 pagefault_disable(); 106 pagefault_disable();
107 } 107 }
108 108
109 if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { 109 if ((submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) ||
110 !(submit_bo.flags & MSM_SUBMIT_BO_FLAGS)) {
110 DRM_ERROR("invalid flags: %x\n", submit_bo.flags); 111 DRM_ERROR("invalid flags: %x\n", submit_bo.flags);
111 ret = -EINVAL; 112 ret = -EINVAL;
112 goto out_unlock; 113 goto out_unlock;
@@ -290,7 +291,7 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
290{ 291{
291 uint32_t i, last_offset = 0; 292 uint32_t i, last_offset = 0;
292 uint32_t *ptr; 293 uint32_t *ptr;
293 int ret; 294 int ret = 0;
294 295
295 if (offset % 4) { 296 if (offset % 4) {
296 DRM_ERROR("non-aligned cmdstream buffer: %u\n", offset); 297 DRM_ERROR("non-aligned cmdstream buffer: %u\n", offset);
@@ -318,12 +319,13 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
318 319
319 ret = copy_from_user(&submit_reloc, userptr, sizeof(submit_reloc)); 320 ret = copy_from_user(&submit_reloc, userptr, sizeof(submit_reloc));
320 if (ret) 321 if (ret)
321 return -EFAULT; 322 goto out;
322 323
323 if (submit_reloc.submit_offset % 4) { 324 if (submit_reloc.submit_offset % 4) {
324 DRM_ERROR("non-aligned reloc offset: %u\n", 325 DRM_ERROR("non-aligned reloc offset: %u\n",
325 submit_reloc.submit_offset); 326 submit_reloc.submit_offset);
326 return -EINVAL; 327 ret = -EINVAL;
328 goto out;
327 } 329 }
328 330
329 /* offset in dwords: */ 331 /* offset in dwords: */
@@ -332,12 +334,13 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
332 if ((off >= (obj->base.size / 4)) || 334 if ((off >= (obj->base.size / 4)) ||
333 (off < last_offset)) { 335 (off < last_offset)) {
334 DRM_ERROR("invalid offset %u at reloc %u\n", off, i); 336 DRM_ERROR("invalid offset %u at reloc %u\n", off, i);
335 return -EINVAL; 337 ret = -EINVAL;
338 goto out;
336 } 339 }
337 340
338 ret = submit_bo(submit, submit_reloc.reloc_idx, NULL, &iova, &valid); 341 ret = submit_bo(submit, submit_reloc.reloc_idx, NULL, &iova, &valid);
339 if (ret) 342 if (ret)
340 return ret; 343 goto out;
341 344
342 if (valid) 345 if (valid)
343 continue; 346 continue;
@@ -354,9 +357,10 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
354 last_offset = off; 357 last_offset = off;
355 } 358 }
356 359
360out:
357 msm_gem_put_vaddr_locked(&obj->base); 361 msm_gem_put_vaddr_locked(&obj->base);
358 362
359 return 0; 363 return ret;
360} 364}
361 365
362static void submit_cleanup(struct msm_gem_submit *submit) 366static void submit_cleanup(struct msm_gem_submit *submit)
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
index f326cf6a32e6..67b34e069abf 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -23,7 +23,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size)
23 struct msm_ringbuffer *ring; 23 struct msm_ringbuffer *ring;
24 int ret; 24 int ret;
25 25
26 size = ALIGN(size, 4); /* size should be dword aligned */ 26 if (WARN_ON(!is_power_of_2(size)))
27 return ERR_PTR(-EINVAL);
27 28
28 ring = kzalloc(sizeof(*ring), GFP_KERNEL); 29 ring = kzalloc(sizeof(*ring), GFP_KERNEL);
29 if (!ring) { 30 if (!ring) {
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index ad4d7b8b8322..414776811e71 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -50,7 +50,6 @@ MODULE_FIRMWARE("radeon/tahiti_ce.bin");
50MODULE_FIRMWARE("radeon/tahiti_mc.bin"); 50MODULE_FIRMWARE("radeon/tahiti_mc.bin");
51MODULE_FIRMWARE("radeon/tahiti_rlc.bin"); 51MODULE_FIRMWARE("radeon/tahiti_rlc.bin");
52MODULE_FIRMWARE("radeon/tahiti_smc.bin"); 52MODULE_FIRMWARE("radeon/tahiti_smc.bin");
53MODULE_FIRMWARE("radeon/tahiti_k_smc.bin");
54 53
55MODULE_FIRMWARE("radeon/PITCAIRN_pfp.bin"); 54MODULE_FIRMWARE("radeon/PITCAIRN_pfp.bin");
56MODULE_FIRMWARE("radeon/PITCAIRN_me.bin"); 55MODULE_FIRMWARE("radeon/PITCAIRN_me.bin");
@@ -115,6 +114,9 @@ MODULE_FIRMWARE("radeon/hainan_mc.bin");
115MODULE_FIRMWARE("radeon/hainan_rlc.bin"); 114MODULE_FIRMWARE("radeon/hainan_rlc.bin");
116MODULE_FIRMWARE("radeon/hainan_smc.bin"); 115MODULE_FIRMWARE("radeon/hainan_smc.bin");
117MODULE_FIRMWARE("radeon/hainan_k_smc.bin"); 116MODULE_FIRMWARE("radeon/hainan_k_smc.bin");
117MODULE_FIRMWARE("radeon/banks_k_2_smc.bin");
118
119MODULE_FIRMWARE("radeon/si58_mc.bin");
118 120
119static u32 si_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh); 121static u32 si_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh);
120static void si_pcie_gen3_enable(struct radeon_device *rdev); 122static void si_pcie_gen3_enable(struct radeon_device *rdev);
@@ -1651,15 +1653,14 @@ static int si_init_microcode(struct radeon_device *rdev)
1651 int err; 1653 int err;
1652 int new_fw = 0; 1654 int new_fw = 0;
1653 bool new_smc = false; 1655 bool new_smc = false;
1656 bool si58_fw = false;
1657 bool banks2_fw = false;
1654 1658
1655 DRM_DEBUG("\n"); 1659 DRM_DEBUG("\n");
1656 1660
1657 switch (rdev->family) { 1661 switch (rdev->family) {
1658 case CHIP_TAHITI: 1662 case CHIP_TAHITI:
1659 chip_name = "TAHITI"; 1663 chip_name = "TAHITI";
1660 /* XXX: figure out which Tahitis need the new ucode */
1661 if (0)
1662 new_smc = true;
1663 new_chip_name = "tahiti"; 1664 new_chip_name = "tahiti";
1664 pfp_req_size = SI_PFP_UCODE_SIZE * 4; 1665 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
1665 me_req_size = SI_PM4_UCODE_SIZE * 4; 1666 me_req_size = SI_PM4_UCODE_SIZE * 4;
@@ -1671,12 +1672,9 @@ static int si_init_microcode(struct radeon_device *rdev)
1671 break; 1672 break;
1672 case CHIP_PITCAIRN: 1673 case CHIP_PITCAIRN:
1673 chip_name = "PITCAIRN"; 1674 chip_name = "PITCAIRN";
1674 if ((rdev->pdev->revision == 0x81) || 1675 if ((rdev->pdev->revision == 0x81) &&
1675 (rdev->pdev->device == 0x6810) || 1676 ((rdev->pdev->device == 0x6810) ||
1676 (rdev->pdev->device == 0x6811) || 1677 (rdev->pdev->device == 0x6811)))
1677 (rdev->pdev->device == 0x6816) ||
1678 (rdev->pdev->device == 0x6817) ||
1679 (rdev->pdev->device == 0x6806))
1680 new_smc = true; 1678 new_smc = true;
1681 new_chip_name = "pitcairn"; 1679 new_chip_name = "pitcairn";
1682 pfp_req_size = SI_PFP_UCODE_SIZE * 4; 1680 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
@@ -1689,15 +1687,15 @@ static int si_init_microcode(struct radeon_device *rdev)
1689 break; 1687 break;
1690 case CHIP_VERDE: 1688 case CHIP_VERDE:
1691 chip_name = "VERDE"; 1689 chip_name = "VERDE";
1692 if ((rdev->pdev->revision == 0x81) || 1690 if (((rdev->pdev->device == 0x6820) &&
1693 (rdev->pdev->revision == 0x83) || 1691 ((rdev->pdev->revision == 0x81) ||
1694 (rdev->pdev->revision == 0x87) || 1692 (rdev->pdev->revision == 0x83))) ||
1695 (rdev->pdev->device == 0x6820) || 1693 ((rdev->pdev->device == 0x6821) &&
1696 (rdev->pdev->device == 0x6821) || 1694 ((rdev->pdev->revision == 0x83) ||
1697 (rdev->pdev->device == 0x6822) || 1695 (rdev->pdev->revision == 0x87))) ||
1698 (rdev->pdev->device == 0x6823) || 1696 ((rdev->pdev->revision == 0x87) &&
1699 (rdev->pdev->device == 0x682A) || 1697 ((rdev->pdev->device == 0x6823) ||
1700 (rdev->pdev->device == 0x682B)) 1698 (rdev->pdev->device == 0x682b))))
1701 new_smc = true; 1699 new_smc = true;
1702 new_chip_name = "verde"; 1700 new_chip_name = "verde";
1703 pfp_req_size = SI_PFP_UCODE_SIZE * 4; 1701 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
@@ -1710,13 +1708,13 @@ static int si_init_microcode(struct radeon_device *rdev)
1710 break; 1708 break;
1711 case CHIP_OLAND: 1709 case CHIP_OLAND:
1712 chip_name = "OLAND"; 1710 chip_name = "OLAND";
1713 if ((rdev->pdev->revision == 0xC7) || 1711 if (((rdev->pdev->revision == 0x81) &&
1714 (rdev->pdev->revision == 0x80) || 1712 ((rdev->pdev->device == 0x6600) ||
1715 (rdev->pdev->revision == 0x81) || 1713 (rdev->pdev->device == 0x6604) ||
1716 (rdev->pdev->revision == 0x83) || 1714 (rdev->pdev->device == 0x6605) ||
1717 (rdev->pdev->revision == 0x87) || 1715 (rdev->pdev->device == 0x6610))) ||
1718 (rdev->pdev->device == 0x6604) || 1716 ((rdev->pdev->revision == 0x83) &&
1719 (rdev->pdev->device == 0x6605)) 1717 (rdev->pdev->device == 0x6610)))
1720 new_smc = true; 1718 new_smc = true;
1721 new_chip_name = "oland"; 1719 new_chip_name = "oland";
1722 pfp_req_size = SI_PFP_UCODE_SIZE * 4; 1720 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
@@ -1728,13 +1726,17 @@ static int si_init_microcode(struct radeon_device *rdev)
1728 break; 1726 break;
1729 case CHIP_HAINAN: 1727 case CHIP_HAINAN:
1730 chip_name = "HAINAN"; 1728 chip_name = "HAINAN";
1731 if ((rdev->pdev->revision == 0x81) || 1729 if (((rdev->pdev->revision == 0x81) &&
1732 (rdev->pdev->revision == 0x83) || 1730 (rdev->pdev->device == 0x6660)) ||
1733 (rdev->pdev->revision == 0xC3) || 1731 ((rdev->pdev->revision == 0x83) &&
1734 (rdev->pdev->device == 0x6664) || 1732 ((rdev->pdev->device == 0x6660) ||
1735 (rdev->pdev->device == 0x6665) || 1733 (rdev->pdev->device == 0x6663) ||
1736 (rdev->pdev->device == 0x6667)) 1734 (rdev->pdev->device == 0x6665) ||
1735 (rdev->pdev->device == 0x6667))))
1737 new_smc = true; 1736 new_smc = true;
1737 else if ((rdev->pdev->revision == 0xc3) &&
1738 (rdev->pdev->device == 0x6665))
1739 banks2_fw = true;
1738 new_chip_name = "hainan"; 1740 new_chip_name = "hainan";
1739 pfp_req_size = SI_PFP_UCODE_SIZE * 4; 1741 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
1740 me_req_size = SI_PM4_UCODE_SIZE * 4; 1742 me_req_size = SI_PM4_UCODE_SIZE * 4;
@@ -1746,6 +1748,10 @@ static int si_init_microcode(struct radeon_device *rdev)
1746 default: BUG(); 1748 default: BUG();
1747 } 1749 }
1748 1750
1751 /* this memory configuration requires special firmware */
1752 if (((RREG32(MC_SEQ_MISC0) & 0xff000000) >> 24) == 0x58)
1753 si58_fw = true;
1754
1749 DRM_INFO("Loading %s Microcode\n", new_chip_name); 1755 DRM_INFO("Loading %s Microcode\n", new_chip_name);
1750 1756
1751 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", new_chip_name); 1757 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", new_chip_name);
@@ -1849,7 +1855,10 @@ static int si_init_microcode(struct radeon_device *rdev)
1849 } 1855 }
1850 } 1856 }
1851 1857
1852 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", new_chip_name); 1858 if (si58_fw)
1859 snprintf(fw_name, sizeof(fw_name), "radeon/si58_mc.bin");
1860 else
1861 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", new_chip_name);
1853 err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); 1862 err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
1854 if (err) { 1863 if (err) {
1855 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc2.bin", chip_name); 1864 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc2.bin", chip_name);
@@ -1880,7 +1889,9 @@ static int si_init_microcode(struct radeon_device *rdev)
1880 } 1889 }
1881 } 1890 }
1882 1891
1883 if (new_smc) 1892 if (banks2_fw)
1893 snprintf(fw_name, sizeof(fw_name), "radeon/banks_k_2_smc.bin");
1894 else if (new_smc)
1884 snprintf(fw_name, sizeof(fw_name), "radeon/%s_k_smc.bin", new_chip_name); 1895 snprintf(fw_name, sizeof(fw_name), "radeon/%s_k_smc.bin", new_chip_name);
1885 else 1896 else
1886 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", new_chip_name); 1897 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", new_chip_name);
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 8b5e697f2549..2944916f7102 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -3008,30 +3008,6 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
3008 (rdev->pdev->device == 0x6817) || 3008 (rdev->pdev->device == 0x6817) ||
3009 (rdev->pdev->device == 0x6806)) 3009 (rdev->pdev->device == 0x6806))
3010 max_mclk = 120000; 3010 max_mclk = 120000;
3011 } else if (rdev->family == CHIP_VERDE) {
3012 if ((rdev->pdev->revision == 0x81) ||
3013 (rdev->pdev->revision == 0x83) ||
3014 (rdev->pdev->revision == 0x87) ||
3015 (rdev->pdev->device == 0x6820) ||
3016 (rdev->pdev->device == 0x6821) ||
3017 (rdev->pdev->device == 0x6822) ||
3018 (rdev->pdev->device == 0x6823) ||
3019 (rdev->pdev->device == 0x682A) ||
3020 (rdev->pdev->device == 0x682B)) {
3021 max_sclk = 75000;
3022 max_mclk = 80000;
3023 }
3024 } else if (rdev->family == CHIP_OLAND) {
3025 if ((rdev->pdev->revision == 0xC7) ||
3026 (rdev->pdev->revision == 0x80) ||
3027 (rdev->pdev->revision == 0x81) ||
3028 (rdev->pdev->revision == 0x83) ||
3029 (rdev->pdev->revision == 0x87) ||
3030 (rdev->pdev->device == 0x6604) ||
3031 (rdev->pdev->device == 0x6605)) {
3032 max_sclk = 75000;
3033 max_mclk = 80000;
3034 }
3035 } else if (rdev->family == CHIP_HAINAN) { 3011 } else if (rdev->family == CHIP_HAINAN) {
3036 if ((rdev->pdev->revision == 0x81) || 3012 if ((rdev->pdev->revision == 0x81) ||
3037 (rdev->pdev->revision == 0x83) || 3013 (rdev->pdev->revision == 0x83) ||
@@ -3040,7 +3016,6 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
3040 (rdev->pdev->device == 0x6665) || 3016 (rdev->pdev->device == 0x6665) ||
3041 (rdev->pdev->device == 0x6667)) { 3017 (rdev->pdev->device == 0x6667)) {
3042 max_sclk = 75000; 3018 max_sclk = 75000;
3043 max_mclk = 80000;
3044 } 3019 }
3045 } 3020 }
3046 /* Apply dpm quirks */ 3021 /* Apply dpm quirks */
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 725dffad5640..6dfdb145f3bb 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -856,7 +856,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
856 struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); 856 struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
857 struct drm_device *dev = crtc->dev; 857 struct drm_device *dev = crtc->dev;
858 struct tilcdc_drm_private *priv = dev->dev_private; 858 struct tilcdc_drm_private *priv = dev->dev_private;
859 uint32_t stat; 859 uint32_t stat, reg;
860 860
861 stat = tilcdc_read_irqstatus(dev); 861 stat = tilcdc_read_irqstatus(dev);
862 tilcdc_clear_irqstatus(dev, stat); 862 tilcdc_clear_irqstatus(dev, stat);
@@ -921,17 +921,26 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
921 dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost", 921 dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
922 __func__, stat); 922 __func__, stat);
923 tilcdc_crtc->frame_intact = false; 923 tilcdc_crtc->frame_intact = false;
924 if (tilcdc_crtc->sync_lost_count++ > 924 if (priv->rev == 1) {
925 SYNC_LOST_COUNT_LIMIT) { 925 reg = tilcdc_read(dev, LCDC_RASTER_CTRL_REG);
926 dev_err(dev->dev, "%s(0x%08x): Sync lost flood detected, recovering", __func__, stat); 926 if (reg & LCDC_RASTER_ENABLE) {
927 queue_work(system_wq, &tilcdc_crtc->recover_work);
928 if (priv->rev == 1)
929 tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, 927 tilcdc_clear(dev, LCDC_RASTER_CTRL_REG,
930 LCDC_V1_SYNC_LOST_INT_ENA); 928 LCDC_RASTER_ENABLE);
931 else 929 tilcdc_set(dev, LCDC_RASTER_CTRL_REG,
930 LCDC_RASTER_ENABLE);
931 }
932 } else {
933 if (tilcdc_crtc->sync_lost_count++ >
934 SYNC_LOST_COUNT_LIMIT) {
935 dev_err(dev->dev,
936 "%s(0x%08x): Sync lost flood detected, recovering",
937 __func__, stat);
938 queue_work(system_wq,
939 &tilcdc_crtc->recover_work);
932 tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG, 940 tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
933 LCDC_SYNC_LOST); 941 LCDC_SYNC_LOST);
934 tilcdc_crtc->sync_lost_count = 0; 942 tilcdc_crtc->sync_lost_count = 0;
943 }
935 } 944 }
936 } 945 }
937 946
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index dd21f950e129..cde9f3758106 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -331,7 +331,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
331 info->fbops = &virtio_gpufb_ops; 331 info->fbops = &virtio_gpufb_ops;
332 info->pixmap.flags = FB_PIXMAP_SYSTEM; 332 info->pixmap.flags = FB_PIXMAP_SYSTEM;
333 333
334 info->screen_base = obj->vmap; 334 info->screen_buffer = obj->vmap;
335 info->screen_size = obj->gem_base.size; 335 info->screen_size = obj->gem_base.size;
336 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth); 336 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
337 drm_fb_helper_fill_var(info, &vfbdev->helper, 337 drm_fb_helper_fill_var(info, &vfbdev->helper,
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index d40ed9fdf68d..70b12f89a193 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -64,7 +64,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
64#define QUIRK_SKIP_INPUT_MAPPING BIT(2) 64#define QUIRK_SKIP_INPUT_MAPPING BIT(2)
65#define QUIRK_IS_MULTITOUCH BIT(3) 65#define QUIRK_IS_MULTITOUCH BIT(3)
66 66
67#define NOTEBOOK_QUIRKS QUIRK_FIX_NOTEBOOK_REPORT 67#define KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
68 QUIRK_NO_INIT_REPORTS)
68#define TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \ 69#define TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \
69 QUIRK_SKIP_INPUT_MAPPING | \ 70 QUIRK_SKIP_INPUT_MAPPING | \
70 QUIRK_IS_MULTITOUCH) 71 QUIRK_IS_MULTITOUCH)
@@ -170,11 +171,11 @@ static int asus_raw_event(struct hid_device *hdev,
170 171
171static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi) 172static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
172{ 173{
174 struct input_dev *input = hi->input;
173 struct asus_drvdata *drvdata = hid_get_drvdata(hdev); 175 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
174 176
175 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) { 177 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
176 int ret; 178 int ret;
177 struct input_dev *input = hi->input;
178 179
179 input_set_abs_params(input, ABS_MT_POSITION_X, 0, MAX_X, 0, 0); 180 input_set_abs_params(input, ABS_MT_POSITION_X, 0, MAX_X, 0, 0);
180 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0); 181 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0);
@@ -191,10 +192,10 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
191 hid_err(hdev, "Asus input mt init slots failed: %d\n", ret); 192 hid_err(hdev, "Asus input mt init slots failed: %d\n", ret);
192 return ret; 193 return ret;
193 } 194 }
194
195 drvdata->input = input;
196 } 195 }
197 196
197 drvdata->input = input;
198
198 return 0; 199 return 0;
199} 200}
200 201
@@ -286,7 +287,11 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
286 goto err_stop_hw; 287 goto err_stop_hw;
287 } 288 }
288 289
289 drvdata->input->name = "Asus TouchPad"; 290 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
291 drvdata->input->name = "Asus TouchPad";
292 } else {
293 drvdata->input->name = "Asus Keyboard";
294 }
290 295
291 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) { 296 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
292 ret = asus_start_multitouch(hdev); 297 ret = asus_start_multitouch(hdev);
@@ -315,7 +320,7 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
315 320
316static const struct hid_device_id asus_devices[] = { 321static const struct hid_device_id asus_devices[] = {
317 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, 322 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
318 USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), NOTEBOOK_QUIRKS}, 323 USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), KEYBOARD_QUIRKS},
319 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, 324 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
320 USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS }, 325 USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS },
321 { } 326 { }
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index cff060b56da9..ea36b557d5ee 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2496,6 +2496,7 @@ static const struct hid_device_id hid_ignore_list[] = {
2496 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 2496 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
2497 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 2497 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
2498 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 2498 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
2499 { HID_USB_DEVICE(USB_VENDOR_ID_PETZL, USB_DEVICE_ID_PETZL_HEADLAMP) },
2499 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 2500 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
2500 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 2501 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
2501#if IS_ENABLED(CONFIG_MOUSE_SYNAPTICS_USB) 2502#if IS_ENABLED(CONFIG_MOUSE_SYNAPTICS_USB)
diff --git a/drivers/hid/hid-corsair.c b/drivers/hid/hid-corsair.c
index 717704e9ae07..c0303f61c26a 100644
--- a/drivers/hid/hid-corsair.c
+++ b/drivers/hid/hid-corsair.c
@@ -148,26 +148,36 @@ static enum led_brightness k90_backlight_get(struct led_classdev *led_cdev)
148 struct usb_interface *usbif = to_usb_interface(dev->parent); 148 struct usb_interface *usbif = to_usb_interface(dev->parent);
149 struct usb_device *usbdev = interface_to_usbdev(usbif); 149 struct usb_device *usbdev = interface_to_usbdev(usbif);
150 int brightness; 150 int brightness;
151 char data[8]; 151 char *data;
152
153 data = kmalloc(8, GFP_KERNEL);
154 if (!data)
155 return -ENOMEM;
152 156
153 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 157 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
154 K90_REQUEST_STATUS, 158 K90_REQUEST_STATUS,
155 USB_DIR_IN | USB_TYPE_VENDOR | 159 USB_DIR_IN | USB_TYPE_VENDOR |
156 USB_RECIP_DEVICE, 0, 0, data, 8, 160 USB_RECIP_DEVICE, 0, 0, data, 8,
157 USB_CTRL_SET_TIMEOUT); 161 USB_CTRL_SET_TIMEOUT);
158 if (ret < 0) { 162 if (ret < 5) {
159 dev_warn(dev, "Failed to get K90 initial state (error %d).\n", 163 dev_warn(dev, "Failed to get K90 initial state (error %d).\n",
160 ret); 164 ret);
161 return -EIO; 165 ret = -EIO;
166 goto out;
162 } 167 }
163 brightness = data[4]; 168 brightness = data[4];
164 if (brightness < 0 || brightness > 3) { 169 if (brightness < 0 || brightness > 3) {
165 dev_warn(dev, 170 dev_warn(dev,
166 "Read invalid backlight brightness: %02hhx.\n", 171 "Read invalid backlight brightness: %02hhx.\n",
167 data[4]); 172 data[4]);
168 return -EIO; 173 ret = -EIO;
174 goto out;
169 } 175 }
170 return brightness; 176 ret = brightness;
177out:
178 kfree(data);
179
180 return ret;
171} 181}
172 182
173static enum led_brightness k90_record_led_get(struct led_classdev *led_cdev) 183static enum led_brightness k90_record_led_get(struct led_classdev *led_cdev)
@@ -253,17 +263,22 @@ static ssize_t k90_show_macro_mode(struct device *dev,
253 struct usb_interface *usbif = to_usb_interface(dev->parent); 263 struct usb_interface *usbif = to_usb_interface(dev->parent);
254 struct usb_device *usbdev = interface_to_usbdev(usbif); 264 struct usb_device *usbdev = interface_to_usbdev(usbif);
255 const char *macro_mode; 265 const char *macro_mode;
256 char data[8]; 266 char *data;
267
268 data = kmalloc(2, GFP_KERNEL);
269 if (!data)
270 return -ENOMEM;
257 271
258 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 272 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
259 K90_REQUEST_GET_MODE, 273 K90_REQUEST_GET_MODE,
260 USB_DIR_IN | USB_TYPE_VENDOR | 274 USB_DIR_IN | USB_TYPE_VENDOR |
261 USB_RECIP_DEVICE, 0, 0, data, 2, 275 USB_RECIP_DEVICE, 0, 0, data, 2,
262 USB_CTRL_SET_TIMEOUT); 276 USB_CTRL_SET_TIMEOUT);
263 if (ret < 0) { 277 if (ret < 1) {
264 dev_warn(dev, "Failed to get K90 initial mode (error %d).\n", 278 dev_warn(dev, "Failed to get K90 initial mode (error %d).\n",
265 ret); 279 ret);
266 return -EIO; 280 ret = -EIO;
281 goto out;
267 } 282 }
268 283
269 switch (data[0]) { 284 switch (data[0]) {
@@ -277,10 +292,15 @@ static ssize_t k90_show_macro_mode(struct device *dev,
277 default: 292 default:
278 dev_warn(dev, "K90 in unknown mode: %02hhx.\n", 293 dev_warn(dev, "K90 in unknown mode: %02hhx.\n",
279 data[0]); 294 data[0]);
280 return -EIO; 295 ret = -EIO;
296 goto out;
281 } 297 }
282 298
283 return snprintf(buf, PAGE_SIZE, "%s\n", macro_mode); 299 ret = snprintf(buf, PAGE_SIZE, "%s\n", macro_mode);
300out:
301 kfree(data);
302
303 return ret;
284} 304}
285 305
286static ssize_t k90_store_macro_mode(struct device *dev, 306static ssize_t k90_store_macro_mode(struct device *dev,
@@ -320,26 +340,36 @@ static ssize_t k90_show_current_profile(struct device *dev,
320 struct usb_interface *usbif = to_usb_interface(dev->parent); 340 struct usb_interface *usbif = to_usb_interface(dev->parent);
321 struct usb_device *usbdev = interface_to_usbdev(usbif); 341 struct usb_device *usbdev = interface_to_usbdev(usbif);
322 int current_profile; 342 int current_profile;
323 char data[8]; 343 char *data;
344
345 data = kmalloc(8, GFP_KERNEL);
346 if (!data)
347 return -ENOMEM;
324 348
325 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 349 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
326 K90_REQUEST_STATUS, 350 K90_REQUEST_STATUS,
327 USB_DIR_IN | USB_TYPE_VENDOR | 351 USB_DIR_IN | USB_TYPE_VENDOR |
328 USB_RECIP_DEVICE, 0, 0, data, 8, 352 USB_RECIP_DEVICE, 0, 0, data, 8,
329 USB_CTRL_SET_TIMEOUT); 353 USB_CTRL_SET_TIMEOUT);
330 if (ret < 0) { 354 if (ret < 8) {
331 dev_warn(dev, "Failed to get K90 initial state (error %d).\n", 355 dev_warn(dev, "Failed to get K90 initial state (error %d).\n",
332 ret); 356 ret);
333 return -EIO; 357 ret = -EIO;
358 goto out;
334 } 359 }
335 current_profile = data[7]; 360 current_profile = data[7];
336 if (current_profile < 1 || current_profile > 3) { 361 if (current_profile < 1 || current_profile > 3) {
337 dev_warn(dev, "Read invalid current profile: %02hhx.\n", 362 dev_warn(dev, "Read invalid current profile: %02hhx.\n",
338 data[7]); 363 data[7]);
339 return -EIO; 364 ret = -EIO;
365 goto out;
340 } 366 }
341 367
342 return snprintf(buf, PAGE_SIZE, "%d\n", current_profile); 368 ret = snprintf(buf, PAGE_SIZE, "%d\n", current_profile);
369out:
370 kfree(data);
371
372 return ret;
343} 373}
344 374
345static ssize_t k90_store_current_profile(struct device *dev, 375static ssize_t k90_store_current_profile(struct device *dev,
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
index 1b764d1745f3..1689568b597d 100644
--- a/drivers/hid/hid-cypress.c
+++ b/drivers/hid/hid-cypress.c
@@ -39,6 +39,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) 39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
40 return rdesc; 40 return rdesc;
41 41
42 if (*rsize < 4)
43 return rdesc;
44
42 for (i = 0; i < *rsize - 4; i++) 45 for (i = 0; i < *rsize - 4; i++)
43 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { 46 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
44 rdesc[i] = 0x19; 47 rdesc[i] = 0x19;
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index ec277b96eaa1..f46f2c5117fa 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -319,6 +319,7 @@
319#define USB_VENDOR_ID_DRAGONRISE 0x0079 319#define USB_VENDOR_ID_DRAGONRISE 0x0079
320#define USB_DEVICE_ID_DRAGONRISE_WIIU 0x1800 320#define USB_DEVICE_ID_DRAGONRISE_WIIU 0x1800
321#define USB_DEVICE_ID_DRAGONRISE_PS3 0x1801 321#define USB_DEVICE_ID_DRAGONRISE_PS3 0x1801
322#define USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR 0x1803
322#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE 0x1843 323#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE 0x1843
323 324
324#define USB_VENDOR_ID_DWAV 0x0eef 325#define USB_VENDOR_ID_DWAV 0x0eef
@@ -365,6 +366,9 @@
365#define USB_VENDOR_ID_FLATFROG 0x25b5 366#define USB_VENDOR_ID_FLATFROG 0x25b5
366#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002 367#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002
367 368
369#define USB_VENDOR_ID_FUTABA 0x0547
370#define USB_DEVICE_ID_LED_DISPLAY 0x7000
371
368#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f 372#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
369#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 373#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
370 374
@@ -812,6 +816,9 @@
812#define USB_VENDOR_ID_PETALYNX 0x18b1 816#define USB_VENDOR_ID_PETALYNX 0x18b1
813#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 817#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
814 818
819#define USB_VENDOR_ID_PETZL 0x2122
820#define USB_DEVICE_ID_PETZL_HEADLAMP 0x1234
821
815#define USB_VENDOR_ID_PHILIPS 0x0471 822#define USB_VENDOR_ID_PHILIPS 0x0471
816#define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617 823#define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617
817 824
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 5c925228847c..4ef73374a8f9 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -212,7 +212,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
212 __s32 value; 212 __s32 value;
213 int ret = 0; 213 int ret = 0;
214 214
215 memset(buffer, 0, buffer_size);
216 mutex_lock(&data->mutex); 215 mutex_lock(&data->mutex);
217 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); 216 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
218 if (!report || (field_index >= report->maxfield)) { 217 if (!report || (field_index >= report->maxfield)) {
@@ -256,6 +255,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
256 int buffer_index = 0; 255 int buffer_index = 0;
257 int i; 256 int i;
258 257
258 memset(buffer, 0, buffer_size);
259
259 mutex_lock(&data->mutex); 260 mutex_lock(&data->mutex);
260 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); 261 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
261 if (!report || (field_index >= report->maxfield) || 262 if (!report || (field_index >= report->maxfield) ||
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 7687c0875395..f405b07d0381 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1099,8 +1099,11 @@ struct sony_sc {
1099 u8 led_delay_on[MAX_LEDS]; 1099 u8 led_delay_on[MAX_LEDS];
1100 u8 led_delay_off[MAX_LEDS]; 1100 u8 led_delay_off[MAX_LEDS];
1101 u8 led_count; 1101 u8 led_count;
1102 bool ds4_dongle_connected;
1102}; 1103};
1103 1104
1105static void sony_set_leds(struct sony_sc *sc);
1106
1104static inline void sony_schedule_work(struct sony_sc *sc) 1107static inline void sony_schedule_work(struct sony_sc *sc)
1105{ 1108{
1106 if (!sc->defer_initialization) 1109 if (!sc->defer_initialization)
@@ -1430,6 +1433,31 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
1430 return -EILSEQ; 1433 return -EILSEQ;
1431 } 1434 }
1432 } 1435 }
1436
1437 /*
1438 * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates
1439 * if a DS4 is actually connected (indicated by '0').
1440 * For non-dongle, this bit is always 0 (connected).
1441 */
1442 if (sc->hdev->vendor == USB_VENDOR_ID_SONY &&
1443 sc->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
1444 bool connected = (rd[31] & 0x04) ? false : true;
1445
1446 if (!sc->ds4_dongle_connected && connected) {
1447 hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n");
1448 sony_set_leds(sc);
1449 sc->ds4_dongle_connected = true;
1450 } else if (sc->ds4_dongle_connected && !connected) {
1451 hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n");
1452 sc->ds4_dongle_connected = false;
1453 /* Return 0, so hidraw can get the report. */
1454 return 0;
1455 } else if (!sc->ds4_dongle_connected) {
1456 /* Return 0, so hidraw can get the report. */
1457 return 0;
1458 }
1459 }
1460
1433 dualshock4_parse_report(sc, rd, size); 1461 dualshock4_parse_report(sc, rd, size);
1434 } 1462 }
1435 1463
@@ -2390,6 +2418,12 @@ static int sony_check_add(struct sony_sc *sc)
2390 } 2418 }
2391 2419
2392 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); 2420 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
2421
2422 snprintf(sc->hdev->uniq, sizeof(sc->hdev->uniq),
2423 "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
2424 sc->mac_address[5], sc->mac_address[4],
2425 sc->mac_address[3], sc->mac_address[2],
2426 sc->mac_address[1], sc->mac_address[0]);
2393 } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || 2427 } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
2394 (sc->quirks & NAVIGATION_CONTROLLER_USB)) { 2428 (sc->quirks & NAVIGATION_CONTROLLER_USB)) {
2395 buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL); 2429 buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL);
@@ -2548,7 +2582,7 @@ static int sony_input_configured(struct hid_device *hdev,
2548 hid_err(sc->hdev, 2582 hid_err(sc->hdev,
2549 "Unable to initialize multi-touch slots: %d\n", 2583 "Unable to initialize multi-touch slots: %d\n",
2550 ret); 2584 ret);
2551 return ret; 2585 goto err_stop;
2552 } 2586 }
2553 2587
2554 sony_init_output_report(sc, dualshock4_send_output_report); 2588 sony_init_output_report(sc, dualshock4_send_output_report);
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 78fb32a7b103..ea3c3546cef7 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -426,6 +426,15 @@ static int i2c_hid_hwreset(struct i2c_client *client)
426 if (ret) 426 if (ret)
427 goto out_unlock; 427 goto out_unlock;
428 428
429 /*
430 * The HID over I2C specification states that if a DEVICE needs time
431 * after the PWR_ON request, it should utilise CLOCK stretching.
432 * However, it has been observered that the Windows driver provides a
433 * 1ms sleep between the PWR_ON and RESET requests and that some devices
434 * rely on this.
435 */
436 usleep_range(1000, 5000);
437
429 i2c_hid_dbg(ihid, "resetting...\n"); 438 i2c_hid_dbg(ihid, "resetting...\n");
430 439
431 ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0); 440 ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index b3e01c82af05..e9d6cc7cdfc5 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -83,11 +83,13 @@ static const struct hid_blacklist {
83 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 83 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
84 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT }, 84 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT },
85 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3, HID_QUIRK_MULTI_INPUT }, 85 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3, HID_QUIRK_MULTI_INPUT },
86 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR, HID_QUIRK_MULTI_INPUT },
86 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE, HID_QUIRK_MULTI_INPUT }, 87 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE, HID_QUIRK_MULTI_INPUT },
87 { USB_VENDOR_ID_ELAN, HID_ANY_ID, HID_QUIRK_ALWAYS_POLL }, 88 { USB_VENDOR_ID_ELAN, HID_ANY_ID, HID_QUIRK_ALWAYS_POLL },
88 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 89 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
89 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 90 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
90 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 91 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
92 { USB_VENDOR_ID_FUTABA, USB_DEVICE_ID_LED_DISPLAY, HID_QUIRK_NO_INIT_REPORTS },
91 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL }, 93 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL },
92 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL }, 94 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL },
93 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, 95 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index b9779bcbd140..8aeca038cc73 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -740,6 +740,11 @@ static int wacom_add_shared_data(struct hid_device *hdev)
740 return retval; 740 return retval;
741 } 741 }
742 742
743 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
744 wacom_wac->shared->touch = hdev;
745 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN)
746 wacom_wac->shared->pen = hdev;
747
743out: 748out:
744 mutex_unlock(&wacom_udev_list_lock); 749 mutex_unlock(&wacom_udev_list_lock);
745 return retval; 750 return retval;
@@ -2036,10 +2041,6 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2036 if (error) 2041 if (error)
2037 goto fail; 2042 goto fail;
2038 2043
2039 error = wacom_add_shared_data(hdev);
2040 if (error)
2041 goto fail;
2042
2043 /* 2044 /*
2044 * Bamboo Pad has a generic hid handling for the Pen, and we switch it 2045 * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2045 * into debug mode for the touch part. 2046 * into debug mode for the touch part.
@@ -2080,10 +2081,9 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2080 2081
2081 wacom_update_name(wacom, wireless ? " (WL)" : ""); 2082 wacom_update_name(wacom, wireless ? " (WL)" : "");
2082 2083
2083 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) 2084 error = wacom_add_shared_data(hdev);
2084 wacom_wac->shared->touch = hdev; 2085 if (error)
2085 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) 2086 goto fail;
2086 wacom_wac->shared->pen = hdev;
2087 2087
2088 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) && 2088 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) &&
2089 (features->quirks & WACOM_QUIRK_BATTERY)) { 2089 (features->quirks & WACOM_QUIRK_BATTERY)) {
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index b1a9a3ca6d56..0884dc9554fd 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2187,6 +2187,16 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2187 2187
2188 wacom_report_events(hdev, report); 2188 wacom_report_events(hdev, report);
2189 2189
2190 /*
2191 * Non-input reports may be sent prior to the device being
2192 * completely initialized. Since only their events need
2193 * to be processed, exit after 'wacom_report_events' has
2194 * been called to prevent potential crashes in the report-
2195 * processing functions.
2196 */
2197 if (report->type != HID_INPUT_REPORT)
2198 return;
2199
2190 if (WACOM_PAD_FIELD(field)) { 2200 if (WACOM_PAD_FIELD(field)) {
2191 wacom_wac_pad_battery_report(hdev, report); 2201 wacom_wac_pad_battery_report(hdev, report);
2192 if (wacom->wacom_wac.pad_input) 2202 if (wacom->wacom_wac.pad_input)
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 322ed9272811..841f2428e84a 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1036,7 +1036,7 @@ static const u8 lm90_temp_emerg_index[3] = {
1036}; 1036};
1037 1037
1038static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 }; 1038static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
1039static const u8 lm90_max_alarm_bits[3] = { 0, 4, 12 }; 1039static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
1040static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 }; 1040static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
1041static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 }; 1041static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
1042static const u8 lm90_fault_bits[3] = { 0, 2, 10 }; 1042static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index c2268cdf38e8..e34d82e79b98 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -585,10 +585,29 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
585 u8 command, int size, union i2c_smbus_data *data) 585 u8 command, int size, union i2c_smbus_data *data)
586{ 586{
587 struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); 587 struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap);
588 unsigned short piix4_smba = adapdata->smba;
589 int retries = MAX_TIMEOUT;
590 int smbslvcnt;
588 u8 smba_en_lo; 591 u8 smba_en_lo;
589 u8 port; 592 u8 port;
590 int retval; 593 int retval;
591 594
595 /* Request the SMBUS semaphore, avoid conflicts with the IMC */
596 smbslvcnt = inb_p(SMBSLVCNT);
597 do {
598 outb_p(smbslvcnt | 0x10, SMBSLVCNT);
599
600 /* Check the semaphore status */
601 smbslvcnt = inb_p(SMBSLVCNT);
602 if (smbslvcnt & 0x10)
603 break;
604
605 usleep_range(1000, 2000);
606 } while (--retries);
607 /* SMBus is still owned by the IMC, we give up */
608 if (!retries)
609 return -EBUSY;
610
592 mutex_lock(&piix4_mutex_sb800); 611 mutex_lock(&piix4_mutex_sb800);
593 612
594 outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); 613 outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
@@ -606,6 +625,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
606 625
607 mutex_unlock(&piix4_mutex_sb800); 626 mutex_unlock(&piix4_mutex_sb800);
608 627
628 /* Release the semaphore */
629 outb_p(smbslvcnt | 0x20, SMBSLVCNT);
630
609 return retval; 631 return retval;
610} 632}
611 633
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index cf9e396d7702..583e95042a21 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -931,7 +931,10 @@ static int i2c_device_probe(struct device *dev)
931 if (!client->irq) { 931 if (!client->irq) {
932 int irq = -ENOENT; 932 int irq = -ENOENT;
933 933
934 if (dev->of_node) { 934 if (client->flags & I2C_CLIENT_HOST_NOTIFY) {
935 dev_dbg(dev, "Using Host Notify IRQ\n");
936 irq = i2c_smbus_host_notify_to_irq(client);
937 } else if (dev->of_node) {
935 irq = of_irq_get_byname(dev->of_node, "irq"); 938 irq = of_irq_get_byname(dev->of_node, "irq");
936 if (irq == -EINVAL || irq == -ENODATA) 939 if (irq == -EINVAL || irq == -ENODATA)
937 irq = of_irq_get(dev->of_node, 0); 940 irq = of_irq_get(dev->of_node, 0);
@@ -940,14 +943,7 @@ static int i2c_device_probe(struct device *dev)
940 } 943 }
941 if (irq == -EPROBE_DEFER) 944 if (irq == -EPROBE_DEFER)
942 return irq; 945 return irq;
943 /* 946
944 * ACPI and OF did not find any useful IRQ, try to see
945 * if Host Notify can be used.
946 */
947 if (irq < 0) {
948 dev_dbg(dev, "Using Host Notify IRQ\n");
949 irq = i2c_smbus_host_notify_to_irq(client);
950 }
951 if (irq < 0) 947 if (irq < 0)
952 irq = 0; 948 irq = 0;
953 949
@@ -1708,7 +1704,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
1708 1704
1709 if (i2c_check_addr_validity(addr, info.flags)) { 1705 if (i2c_check_addr_validity(addr, info.flags)) {
1710 dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n", 1706 dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
1711 info.addr, node->full_name); 1707 addr, node->full_name);
1712 return ERR_PTR(-EINVAL); 1708 return ERR_PTR(-EINVAL);
1713 } 1709 }
1714 1710
@@ -1716,6 +1712,9 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
1716 info.of_node = of_node_get(node); 1712 info.of_node = of_node_get(node);
1717 info.archdata = &dev_ad; 1713 info.archdata = &dev_ad;
1718 1714
1715 if (of_property_read_bool(node, "host-notify"))
1716 info.flags |= I2C_CLIENT_HOST_NOTIFY;
1717
1719 if (of_get_property(node, "wakeup-source", NULL)) 1718 if (of_get_property(node, "wakeup-source", NULL))
1720 info.flags |= I2C_CLIENT_WAKE; 1719 info.flags |= I2C_CLIENT_WAKE;
1721 1720
@@ -3633,7 +3632,7 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
3633 int ret; 3632 int ret;
3634 3633
3635 if (!client || !slave_cb) { 3634 if (!client || !slave_cb) {
3636 WARN(1, "insufficent data\n"); 3635 WARN(1, "insufficient data\n");
3637 return -EINVAL; 3636 return -EINVAL;
3638 } 3637 }
3639 3638
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 66f323fd3982..6f638bbc922d 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -331,7 +331,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
331 unsigned long arg) 331 unsigned long arg)
332{ 332{
333 struct i2c_smbus_ioctl_data data_arg; 333 struct i2c_smbus_ioctl_data data_arg;
334 union i2c_smbus_data temp; 334 union i2c_smbus_data temp = {};
335 int datasize, res; 335 int datasize, res;
336 336
337 if (copy_from_user(&data_arg, 337 if (copy_from_user(&data_arg,
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index f6b6d42385e1..784670e2736b 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -353,12 +353,12 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
353 [0] = { 353 [0] = {
354 .num = ST_ACCEL_FS_AVL_2G, 354 .num = ST_ACCEL_FS_AVL_2G,
355 .value = 0x00, 355 .value = 0x00,
356 .gain = IIO_G_TO_M_S_2(1024), 356 .gain = IIO_G_TO_M_S_2(1000),
357 }, 357 },
358 [1] = { 358 [1] = {
359 .num = ST_ACCEL_FS_AVL_6G, 359 .num = ST_ACCEL_FS_AVL_6G,
360 .value = 0x01, 360 .value = 0x01,
361 .gain = IIO_G_TO_M_S_2(340), 361 .gain = IIO_G_TO_M_S_2(3000),
362 }, 362 },
363 }, 363 },
364 }, 364 },
@@ -366,6 +366,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
366 .addr = 0x21, 366 .addr = 0x21,
367 .mask = 0x40, 367 .mask = 0x40,
368 }, 368 },
369 /*
370 * Data Alignment Setting - needs to be set to get
371 * left-justified data like all other sensors.
372 */
373 .das = {
374 .addr = 0x21,
375 .mask = 0x01,
376 },
369 .drdy_irq = { 377 .drdy_irq = {
370 .addr = 0x21, 378 .addr = 0x21,
371 .mask_int1 = 0x04, 379 .mask_int1 = 0x04,
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 38bc319904c4..9c8b558ba19e 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -561,7 +561,7 @@ config TI_ADS8688
561 561
562config TI_AM335X_ADC 562config TI_AM335X_ADC
563 tristate "TI's AM335X ADC driver" 563 tristate "TI's AM335X ADC driver"
564 depends on MFD_TI_AM335X_TSCADC 564 depends on MFD_TI_AM335X_TSCADC && HAS_DMA
565 select IIO_BUFFER 565 select IIO_BUFFER
566 select IIO_KFIFO_BUF 566 select IIO_KFIFO_BUF
567 help 567 help
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index fe7775bb3740..df4045203a07 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -30,7 +30,9 @@ static int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
30 30
31 for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) { 31 for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) {
32 const struct iio_chan_spec *channel = &indio_dev->channels[i]; 32 const struct iio_chan_spec *channel = &indio_dev->channels[i];
33 unsigned int bytes_to_read = channel->scan_type.realbits >> 3; 33 unsigned int bytes_to_read =
34 DIV_ROUND_UP(channel->scan_type.realbits +
35 channel->scan_type.shift, 8);
34 unsigned int storage_bytes = 36 unsigned int storage_bytes =
35 channel->scan_type.storagebits >> 3; 37 channel->scan_type.storagebits >> 3;
36 38
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 975a1f19f747..79c8c7cd70d5 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -401,6 +401,15 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
401 return err; 401 return err;
402 } 402 }
403 403
404 /* set DAS */
405 if (sdata->sensor_settings->das.addr) {
406 err = st_sensors_write_data_with_mask(indio_dev,
407 sdata->sensor_settings->das.addr,
408 sdata->sensor_settings->das.mask, 1);
409 if (err < 0)
410 return err;
411 }
412
404 if (sdata->int_pin_open_drain) { 413 if (sdata->int_pin_open_drain) {
405 dev_info(&indio_dev->dev, 414 dev_info(&indio_dev->dev,
406 "set interrupt line to open drain mode\n"); 415 "set interrupt line to open drain mode\n");
@@ -483,8 +492,10 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
483 int err; 492 int err;
484 u8 *outdata; 493 u8 *outdata;
485 struct st_sensor_data *sdata = iio_priv(indio_dev); 494 struct st_sensor_data *sdata = iio_priv(indio_dev);
486 unsigned int byte_for_channel = ch->scan_type.realbits >> 3; 495 unsigned int byte_for_channel;
487 496
497 byte_for_channel = DIV_ROUND_UP(ch->scan_type.realbits +
498 ch->scan_type.shift, 8);
488 outdata = kmalloc(byte_for_channel, GFP_KERNEL); 499 outdata = kmalloc(byte_for_channel, GFP_KERNEL);
489 if (!outdata) 500 if (!outdata)
490 return -ENOMEM; 501 return -ENOMEM;
diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c
index 2d2ee353dde7..a5913e97945e 100644
--- a/drivers/iio/counter/104-quad-8.c
+++ b/drivers/iio/counter/104-quad-8.c
@@ -153,7 +153,7 @@ static int quad8_write_raw(struct iio_dev *indio_dev,
153 ior_cfg = val | priv->preset_enable[chan->channel] << 1; 153 ior_cfg = val | priv->preset_enable[chan->channel] << 1;
154 154
155 /* Load I/O control configuration */ 155 /* Load I/O control configuration */
156 outb(0x40 | ior_cfg, base_offset); 156 outb(0x40 | ior_cfg, base_offset + 1);
157 157
158 return 0; 158 return 0;
159 case IIO_CHAN_INFO_SCALE: 159 case IIO_CHAN_INFO_SCALE:
@@ -233,7 +233,7 @@ static ssize_t quad8_read_set_to_preset_on_index(struct iio_dev *indio_dev,
233 const struct quad8_iio *const priv = iio_priv(indio_dev); 233 const struct quad8_iio *const priv = iio_priv(indio_dev);
234 234
235 return snprintf(buf, PAGE_SIZE, "%u\n", 235 return snprintf(buf, PAGE_SIZE, "%u\n",
236 priv->preset_enable[chan->channel]); 236 !priv->preset_enable[chan->channel]);
237} 237}
238 238
239static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev, 239static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
@@ -241,7 +241,7 @@ static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
241 size_t len) 241 size_t len)
242{ 242{
243 struct quad8_iio *const priv = iio_priv(indio_dev); 243 struct quad8_iio *const priv = iio_priv(indio_dev);
244 const int base_offset = priv->base + 2 * chan->channel; 244 const int base_offset = priv->base + 2 * chan->channel + 1;
245 bool preset_enable; 245 bool preset_enable;
246 int ret; 246 int ret;
247 unsigned int ior_cfg; 247 unsigned int ior_cfg;
@@ -250,6 +250,9 @@ static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
250 if (ret) 250 if (ret)
251 return ret; 251 return ret;
252 252
253 /* Preset enable is active low in Input/Output Control register */
254 preset_enable = !preset_enable;
255
253 priv->preset_enable[chan->channel] = preset_enable; 256 priv->preset_enable[chan->channel] = preset_enable;
254 257
255 ior_cfg = priv->ab_enable[chan->channel] | 258 ior_cfg = priv->ab_enable[chan->channel] |
@@ -362,7 +365,7 @@ static int quad8_set_synchronous_mode(struct iio_dev *indio_dev,
362 priv->synchronous_mode[chan->channel] = synchronous_mode; 365 priv->synchronous_mode[chan->channel] = synchronous_mode;
363 366
364 /* Load Index Control configuration to Index Control Register */ 367 /* Load Index Control configuration to Index Control Register */
365 outb(0x40 | idr_cfg, base_offset); 368 outb(0x60 | idr_cfg, base_offset);
366 369
367 return 0; 370 return 0;
368} 371}
@@ -444,7 +447,7 @@ static int quad8_set_index_polarity(struct iio_dev *indio_dev,
444 priv->index_polarity[chan->channel] = index_polarity; 447 priv->index_polarity[chan->channel] = index_polarity;
445 448
446 /* Load Index Control configuration to Index Control Register */ 449 /* Load Index Control configuration to Index Control Register */
447 outb(0x40 | idr_cfg, base_offset); 450 outb(0x60 | idr_cfg, base_offset);
448 451
449 return 0; 452 return 0;
450} 453}
diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 5355507f8fa1..c9e319bff58b 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -66,10 +66,8 @@
66 66
67#define BMI160_REG_DUMMY 0x7F 67#define BMI160_REG_DUMMY 0x7F
68 68
69#define BMI160_ACCEL_PMU_MIN_USLEEP 3200 69#define BMI160_ACCEL_PMU_MIN_USLEEP 3800
70#define BMI160_ACCEL_PMU_MAX_USLEEP 3800 70#define BMI160_GYRO_PMU_MIN_USLEEP 80000
71#define BMI160_GYRO_PMU_MIN_USLEEP 55000
72#define BMI160_GYRO_PMU_MAX_USLEEP 80000
73#define BMI160_SOFTRESET_USLEEP 1000 71#define BMI160_SOFTRESET_USLEEP 1000
74 72
75#define BMI160_CHANNEL(_type, _axis, _index) { \ 73#define BMI160_CHANNEL(_type, _axis, _index) { \
@@ -151,20 +149,9 @@ static struct bmi160_regs bmi160_regs[] = {
151 }, 149 },
152}; 150};
153 151
154struct bmi160_pmu_time { 152static unsigned long bmi160_pmu_time[] = {
155 unsigned long min; 153 [BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP,
156 unsigned long max; 154 [BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP,
157};
158
159static struct bmi160_pmu_time bmi160_pmu_time[] = {
160 [BMI160_ACCEL] = {
161 .min = BMI160_ACCEL_PMU_MIN_USLEEP,
162 .max = BMI160_ACCEL_PMU_MAX_USLEEP
163 },
164 [BMI160_GYRO] = {
165 .min = BMI160_GYRO_PMU_MIN_USLEEP,
166 .max = BMI160_GYRO_PMU_MIN_USLEEP,
167 },
168}; 155};
169 156
170struct bmi160_scale { 157struct bmi160_scale {
@@ -289,7 +276,7 @@ int bmi160_set_mode(struct bmi160_data *data, enum bmi160_sensor_type t,
289 if (ret < 0) 276 if (ret < 0)
290 return ret; 277 return ret;
291 278
292 usleep_range(bmi160_pmu_time[t].min, bmi160_pmu_time[t].max); 279 usleep_range(bmi160_pmu_time[t], bmi160_pmu_time[t] + 1000);
293 280
294 return 0; 281 return 0;
295} 282}
diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index a144ca3461fc..81bd8e8da4a6 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -113,7 +113,7 @@ static const char max44000_int_time_avail_str[] =
113 "0.100 " 113 "0.100 "
114 "0.025 " 114 "0.025 "
115 "0.00625 " 115 "0.00625 "
116 "0.001625"; 116 "0.0015625";
117 117
118/* Available scales (internal to ulux) with pretty manual alignment: */ 118/* Available scales (internal to ulux) with pretty manual alignment: */
119static const int max44000_scale_avail_ulux_array[] = { 119static const int max44000_scale_avail_ulux_array[] = {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c8413fc120e6..7031a8dd4d14 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1682,9 +1682,19 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
1682 size += ret; 1682 size += ret;
1683 } 1683 }
1684 1684
1685 if (mlx4_is_master(mdev->dev) && flow_type == MLX4_FS_REGULAR &&
1686 flow_attr->num_of_specs == 1) {
1687 struct _rule_hw *rule_header = (struct _rule_hw *)(ctrl + 1);
1688 enum ib_flow_spec_type header_spec =
1689 ((union ib_flow_spec *)(flow_attr + 1))->type;
1690
1691 if (header_spec == IB_FLOW_SPEC_ETH)
1692 mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
1693 }
1694
1685 ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0, 1695 ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
1686 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, 1696 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
1687 MLX4_CMD_WRAPPED); 1697 MLX4_CMD_NATIVE);
1688 if (ret == -ENOMEM) 1698 if (ret == -ENOMEM)
1689 pr_err("mcg table is full. Fail to register network rule.\n"); 1699 pr_err("mcg table is full. Fail to register network rule.\n");
1690 else if (ret == -ENXIO) 1700 else if (ret == -ENXIO)
@@ -1701,7 +1711,7 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
1701 int err; 1711 int err;
1702 err = mlx4_cmd(dev, reg_id, 0, 0, 1712 err = mlx4_cmd(dev, reg_id, 0, 0,
1703 MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, 1713 MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
1704 MLX4_CMD_WRAPPED); 1714 MLX4_CMD_NATIVE);
1705 if (err) 1715 if (err)
1706 pr_err("Fail to detach network rule. registration id = 0x%llx\n", 1716 pr_err("Fail to detach network rule. registration id = 0x%llx\n",
1707 reg_id); 1717 reg_id);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index f3135ae22df4..abd18f31b24f 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -22,7 +22,6 @@
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/miscdevice.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/poll.h> 26#include <linux/poll.h>
28#include <linux/init.h> 27#include <linux/init.h>
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 6d9499658671..c7d5b2b643d1 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1377,6 +1377,12 @@ static int xpad_init_input(struct usb_xpad *xpad)
1377 input_dev->name = xpad->name; 1377 input_dev->name = xpad->name;
1378 input_dev->phys = xpad->phys; 1378 input_dev->phys = xpad->phys;
1379 usb_to_input_id(xpad->udev, &input_dev->id); 1379 usb_to_input_id(xpad->udev, &input_dev->id);
1380
1381 if (xpad->xtype == XTYPE_XBOX360W) {
1382 /* x360w controllers and the receiver have different ids */
1383 input_dev->id.product = 0x02a1;
1384 }
1385
1380 input_dev->dev.parent = &xpad->intf->dev; 1386 input_dev->dev.parent = &xpad->intf->dev;
1381 1387
1382 input_set_drvdata(input_dev, xpad); 1388 input_set_drvdata(input_dev, xpad);
diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c
index a8b0a2eec344..7fed92fb8cc1 100644
--- a/drivers/input/misc/adxl34x-i2c.c
+++ b/drivers/input/misc/adxl34x-i2c.c
@@ -136,7 +136,6 @@ static const struct i2c_device_id adxl34x_id[] = {
136 136
137MODULE_DEVICE_TABLE(i2c, adxl34x_id); 137MODULE_DEVICE_TABLE(i2c, adxl34x_id);
138 138
139#ifdef CONFIG_OF
140static const struct of_device_id adxl34x_of_id[] = { 139static const struct of_device_id adxl34x_of_id[] = {
141 /* 140 /*
142 * The ADXL346 is backward-compatible with the ADXL345. Differences are 141 * The ADXL346 is backward-compatible with the ADXL345. Differences are
@@ -153,13 +152,12 @@ static const struct of_device_id adxl34x_of_id[] = {
153}; 152};
154 153
155MODULE_DEVICE_TABLE(of, adxl34x_of_id); 154MODULE_DEVICE_TABLE(of, adxl34x_of_id);
156#endif
157 155
158static struct i2c_driver adxl34x_driver = { 156static struct i2c_driver adxl34x_driver = {
159 .driver = { 157 .driver = {
160 .name = "adxl34x", 158 .name = "adxl34x",
161 .pm = &adxl34x_i2c_pm, 159 .pm = &adxl34x_i2c_pm,
162 .of_match_table = of_match_ptr(adxl34x_of_id), 160 .of_match_table = adxl34x_of_id,
163 }, 161 },
164 .probe = adxl34x_i2c_probe, 162 .probe = adxl34x_i2c_probe,
165 .remove = adxl34x_i2c_remove, 163 .remove = adxl34x_i2c_remove,
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index cde6f4bd8ea2..6d279aa27cb9 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -114,7 +114,7 @@ enum SS4_PACKET_ID {
114 (_b[1] & 0x7F) \ 114 (_b[1] & 0x7F) \
115 ) 115 )
116 116
117#define SS4_TS_Y_V2(_b) (s8)( \ 117#define SS4_TS_Y_V2(_b) -(s8)( \
118 ((_b[3] & 0x01) << 7) | \ 118 ((_b[3] & 0x01) << 7) | \
119 (_b[2] & 0x7F) \ 119 (_b[2] & 0x7F) \
120 ) 120 )
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index aa7c5da60800..cb2bf203f4ca 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -29,7 +29,7 @@
29 * after soft reset, we should wait for 1 ms 29 * after soft reset, we should wait for 1 ms
30 * before the device becomes operational 30 * before the device becomes operational
31 */ 31 */
32#define SOFT_RESET_DELAY_MS 3 32#define SOFT_RESET_DELAY_US 3000
33/* and after hard reset, we should wait for max 500ms */ 33/* and after hard reset, we should wait for max 500ms */
34#define HARD_RESET_DELAY_MS 500 34#define HARD_RESET_DELAY_MS 500
35 35
@@ -311,7 +311,7 @@ static int synaptics_i2c_reset_config(struct i2c_client *client)
311 if (ret) { 311 if (ret) {
312 dev_err(&client->dev, "Unable to reset device\n"); 312 dev_err(&client->dev, "Unable to reset device\n");
313 } else { 313 } else {
314 msleep(SOFT_RESET_DELAY_MS); 314 usleep_range(SOFT_RESET_DELAY_US, SOFT_RESET_DELAY_US + 100);
315 ret = synaptics_i2c_config(client); 315 ret = synaptics_i2c_config(client);
316 if (ret) 316 if (ret)
317 dev_err(&client->dev, "Unable to config device\n"); 317 dev_err(&client->dev, "Unable to config device\n");
diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
index 30cc627a4f45..8993983e3fe4 100644
--- a/drivers/input/rmi4/Kconfig
+++ b/drivers/input/rmi4/Kconfig
@@ -41,7 +41,8 @@ config RMI4_SMB
41 41
42config RMI4_F03 42config RMI4_F03
43 bool "RMI4 Function 03 (PS2 Guest)" 43 bool "RMI4 Function 03 (PS2 Guest)"
44 depends on RMI4_CORE && SERIO 44 depends on RMI4_CORE
45 depends on SERIO=y || RMI4_CORE=SERIO
45 help 46 help
46 Say Y here if you want to add support for RMI4 function 03. 47 Say Y here if you want to add support for RMI4 function 03.
47 48
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 77551f522202..a7618776705a 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -211,6 +211,12 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
211 DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"), 211 DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
212 }, 212 },
213 }, 213 },
214 {
215 .matches = {
216 DMI_MATCH(DMI_SYS_VENDOR, "PEGATRON CORPORATION"),
217 DMI_MATCH(DMI_PRODUCT_NAME, "C15B"),
218 },
219 },
214 { } 220 { }
215}; 221};
216 222
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 02aec284deca..3e6003d32e56 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -914,9 +914,9 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
914 914
915 case QUEUE_HEADER_NORMAL: 915 case QUEUE_HEADER_NORMAL:
916 report_count = ts->buf[FW_HDR_COUNT]; 916 report_count = ts->buf[FW_HDR_COUNT];
917 if (report_count > 3) { 917 if (report_count == 0 || report_count > 3) {
918 dev_err(&client->dev, 918 dev_err(&client->dev,
919 "too large report count: %*ph\n", 919 "bad report count: %*ph\n",
920 HEADER_SIZE, ts->buf); 920 HEADER_SIZE, ts->buf);
921 break; 921 break;
922 } 922 }
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 019e02707cd5..3ef0f42984f2 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1023,7 +1023,7 @@ again:
1023 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE; 1023 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;
1024 left = (head - next_tail) % CMD_BUFFER_SIZE; 1024 left = (head - next_tail) % CMD_BUFFER_SIZE;
1025 1025
1026 if (left <= 2) { 1026 if (left <= 0x20) {
1027 struct iommu_cmd sync_cmd; 1027 struct iommu_cmd sync_cmd;
1028 int ret; 1028 int ret;
1029 1029
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index a88576d50740..8ccbd7023194 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
903 x86_init.iommu.iommu_init = intel_iommu_init; 903 x86_init.iommu.iommu_init = intel_iommu_init;
904#endif 904#endif
905 905
906 acpi_put_table(dmar_tbl); 906 if (dmar_tbl) {
907 dmar_tbl = NULL; 907 acpi_put_table(dmar_tbl);
908 dmar_tbl = NULL;
909 }
908 up_write(&dmar_global_lock); 910 up_write(&dmar_global_lock);
909 911
910 return ret ? 1 : -ENODEV; 912 return ret ? 1 : -ENODEV;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c66c273dfd8a..8a185250ae5a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2037,6 +2037,25 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
2037 if (context_present(context)) 2037 if (context_present(context))
2038 goto out_unlock; 2038 goto out_unlock;
2039 2039
2040 /*
2041 * For kdump cases, old valid entries may be cached due to the
2042 * in-flight DMA and copied pgtable, but there is no unmapping
2043 * behaviour for them, thus we need an explicit cache flush for
2044 * the newly-mapped device. For kdump, at this point, the device
2045 * is supposed to finish reset at its driver probe stage, so no
2046 * in-flight DMA will exist, and we don't need to worry anymore
2047 * hereafter.
2048 */
2049 if (context_copied(context)) {
2050 u16 did_old = context_domain_id(context);
2051
2052 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap))
2053 iommu->flush.flush_context(iommu, did_old,
2054 (((u16)bus) << 8) | devfn,
2055 DMA_CCMD_MASK_NOBIT,
2056 DMA_CCMD_DEVICE_INVL);
2057 }
2058
2040 pgd = domain->pgd; 2059 pgd = domain->pgd;
2041 2060
2042 context_clear_entry(context); 2061 context_clear_entry(context);
@@ -5185,6 +5204,25 @@ static void intel_iommu_remove_device(struct device *dev)
5185} 5204}
5186 5205
5187#ifdef CONFIG_INTEL_IOMMU_SVM 5206#ifdef CONFIG_INTEL_IOMMU_SVM
5207#define MAX_NR_PASID_BITS (20)
5208static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
5209{
5210 /*
5211 * Convert ecap_pss to extend context entry pts encoding, also
5212 * respect the soft pasid_max value set by the iommu.
5213 * - number of PASID bits = ecap_pss + 1
5214 * - number of PASID table entries = 2^(pts + 5)
5215 * Therefore, pts = ecap_pss - 4
5216 * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
5217 */
5218 if (ecap_pss(iommu->ecap) < 5)
5219 return 0;
5220
5221 /* pasid_max is encoded as actual number of entries not the bits */
5222 return find_first_bit((unsigned long *)&iommu->pasid_max,
5223 MAX_NR_PASID_BITS) - 5;
5224}
5225
5188int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev) 5226int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
5189{ 5227{
5190 struct device_domain_info *info; 5228 struct device_domain_info *info;
@@ -5217,7 +5255,9 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
5217 5255
5218 if (!(ctx_lo & CONTEXT_PASIDE)) { 5256 if (!(ctx_lo & CONTEXT_PASIDE)) {
5219 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table); 5257 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
5220 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | ecap_pss(iommu->ecap); 5258 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
5259 intel_iommu_get_pts(iommu);
5260
5221 wmb(); 5261 wmb();
5222 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both 5262 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both
5223 * extended to permit requests-with-PASID if the PASIDE bit 5263 * extended to permit requests-with-PASID if the PASIDE bit
diff --git a/drivers/md/md.h b/drivers/md/md.h
index e38936d05df1..2a514036a83d 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -212,6 +212,7 @@ extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
212 int is_new); 212 int is_new);
213struct md_cluster_info; 213struct md_cluster_info;
214 214
215/* change UNSUPPORTED_MDDEV_FLAGS for each array type if new flag is added */
215enum mddev_flags { 216enum mddev_flags {
216 MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */ 217 MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */
217 MD_CLOSING, /* If set, we are closing the array, do not open 218 MD_CLOSING, /* If set, we are closing the array, do not open
@@ -702,4 +703,11 @@ static inline int mddev_is_clustered(struct mddev *mddev)
702{ 703{
703 return mddev->cluster_info && mddev->bitmap_info.nodes > 1; 704 return mddev->cluster_info && mddev->bitmap_info.nodes > 1;
704} 705}
706
707/* clear unsupported mddev_flags */
708static inline void mddev_clear_unsupported_flags(struct mddev *mddev,
709 unsigned long unsupported_flags)
710{
711 mddev->flags &= ~unsupported_flags;
712}
705#endif /* _MD_MD_H */ 713#endif /* _MD_MD_H */
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index a162fedeb51a..848365d474f3 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -26,6 +26,11 @@
26#include "raid0.h" 26#include "raid0.h"
27#include "raid5.h" 27#include "raid5.h"
28 28
29#define UNSUPPORTED_MDDEV_FLAGS \
30 ((1L << MD_HAS_JOURNAL) | \
31 (1L << MD_JOURNAL_CLEAN) | \
32 (1L << MD_FAILFAST_SUPPORTED))
33
29static int raid0_congested(struct mddev *mddev, int bits) 34static int raid0_congested(struct mddev *mddev, int bits)
30{ 35{
31 struct r0conf *conf = mddev->private; 36 struct r0conf *conf = mddev->private;
@@ -539,8 +544,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
539 mddev->delta_disks = -1; 544 mddev->delta_disks = -1;
540 /* make sure it will be not marked as dirty */ 545 /* make sure it will be not marked as dirty */
541 mddev->recovery_cp = MaxSector; 546 mddev->recovery_cp = MaxSector;
542 clear_bit(MD_HAS_JOURNAL, &mddev->flags); 547 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
543 clear_bit(MD_JOURNAL_CLEAN, &mddev->flags);
544 548
545 create_strip_zones(mddev, &priv_conf); 549 create_strip_zones(mddev, &priv_conf);
546 550
@@ -583,7 +587,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
583 mddev->degraded = 0; 587 mddev->degraded = 0;
584 /* make sure it will be not marked as dirty */ 588 /* make sure it will be not marked as dirty */
585 mddev->recovery_cp = MaxSector; 589 mddev->recovery_cp = MaxSector;
586 clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); 590 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
587 591
588 create_strip_zones(mddev, &priv_conf); 592 create_strip_zones(mddev, &priv_conf);
589 return priv_conf; 593 return priv_conf;
@@ -626,7 +630,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
626 mddev->raid_disks = 1; 630 mddev->raid_disks = 1;
627 /* make sure it will be not marked as dirty */ 631 /* make sure it will be not marked as dirty */
628 mddev->recovery_cp = MaxSector; 632 mddev->recovery_cp = MaxSector;
629 clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); 633 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
630 634
631 create_strip_zones(mddev, &priv_conf); 635 create_strip_zones(mddev, &priv_conf);
632 return priv_conf; 636 return priv_conf;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a1f3fbed9100..7b0f647bcccb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -42,6 +42,10 @@
42#include "raid1.h" 42#include "raid1.h"
43#include "bitmap.h" 43#include "bitmap.h"
44 44
45#define UNSUPPORTED_MDDEV_FLAGS \
46 ((1L << MD_HAS_JOURNAL) | \
47 (1L << MD_JOURNAL_CLEAN))
48
45/* 49/*
46 * Number of guaranteed r1bios in case of extreme VM load: 50 * Number of guaranteed r1bios in case of extreme VM load:
47 */ 51 */
@@ -1066,17 +1070,107 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
1066 kfree(plug); 1070 kfree(plug);
1067} 1071}
1068 1072
1069static void raid1_make_request(struct mddev *mddev, struct bio * bio) 1073static void raid1_read_request(struct mddev *mddev, struct bio *bio,
1074 struct r1bio *r1_bio)
1070{ 1075{
1071 struct r1conf *conf = mddev->private; 1076 struct r1conf *conf = mddev->private;
1072 struct raid1_info *mirror; 1077 struct raid1_info *mirror;
1073 struct r1bio *r1_bio;
1074 struct bio *read_bio; 1078 struct bio *read_bio;
1079 struct bitmap *bitmap = mddev->bitmap;
1080 const int op = bio_op(bio);
1081 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
1082 int sectors_handled;
1083 int max_sectors;
1084 int rdisk;
1085
1086 wait_barrier(conf, bio);
1087
1088read_again:
1089 rdisk = read_balance(conf, r1_bio, &max_sectors);
1090
1091 if (rdisk < 0) {
1092 /* couldn't find anywhere to read from */
1093 raid_end_bio_io(r1_bio);
1094 return;
1095 }
1096 mirror = conf->mirrors + rdisk;
1097
1098 if (test_bit(WriteMostly, &mirror->rdev->flags) &&
1099 bitmap) {
1100 /*
1101 * Reading from a write-mostly device must take care not to
1102 * over-take any writes that are 'behind'
1103 */
1104 raid1_log(mddev, "wait behind writes");
1105 wait_event(bitmap->behind_wait,
1106 atomic_read(&bitmap->behind_writes) == 0);
1107 }
1108 r1_bio->read_disk = rdisk;
1109 r1_bio->start_next_window = 0;
1110
1111 read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1112 bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
1113 max_sectors);
1114
1115 r1_bio->bios[rdisk] = read_bio;
1116
1117 read_bio->bi_iter.bi_sector = r1_bio->sector +
1118 mirror->rdev->data_offset;
1119 read_bio->bi_bdev = mirror->rdev->bdev;
1120 read_bio->bi_end_io = raid1_end_read_request;
1121 bio_set_op_attrs(read_bio, op, do_sync);
1122 if (test_bit(FailFast, &mirror->rdev->flags) &&
1123 test_bit(R1BIO_FailFast, &r1_bio->state))
1124 read_bio->bi_opf |= MD_FAILFAST;
1125 read_bio->bi_private = r1_bio;
1126
1127 if (mddev->gendisk)
1128 trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev),
1129 read_bio, disk_devt(mddev->gendisk),
1130 r1_bio->sector);
1131
1132 if (max_sectors < r1_bio->sectors) {
1133 /*
1134 * could not read all from this device, so we will need another
1135 * r1_bio.
1136 */
1137 sectors_handled = (r1_bio->sector + max_sectors
1138 - bio->bi_iter.bi_sector);
1139 r1_bio->sectors = max_sectors;
1140 spin_lock_irq(&conf->device_lock);
1141 if (bio->bi_phys_segments == 0)
1142 bio->bi_phys_segments = 2;
1143 else
1144 bio->bi_phys_segments++;
1145 spin_unlock_irq(&conf->device_lock);
1146
1147 /*
1148 * Cannot call generic_make_request directly as that will be
1149 * queued in __make_request and subsequent mempool_alloc might
1150 * block waiting for it. So hand bio over to raid1d.
1151 */
1152 reschedule_retry(r1_bio);
1153
1154 r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);
1155
1156 r1_bio->master_bio = bio;
1157 r1_bio->sectors = bio_sectors(bio) - sectors_handled;
1158 r1_bio->state = 0;
1159 r1_bio->mddev = mddev;
1160 r1_bio->sector = bio->bi_iter.bi_sector + sectors_handled;
1161 goto read_again;
1162 } else
1163 generic_make_request(read_bio);
1164}
1165
1166static void raid1_write_request(struct mddev *mddev, struct bio *bio,
1167 struct r1bio *r1_bio)
1168{
1169 struct r1conf *conf = mddev->private;
1075 int i, disks; 1170 int i, disks;
1076 struct bitmap *bitmap; 1171 struct bitmap *bitmap = mddev->bitmap;
1077 unsigned long flags; 1172 unsigned long flags;
1078 const int op = bio_op(bio); 1173 const int op = bio_op(bio);
1079 const int rw = bio_data_dir(bio);
1080 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); 1174 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
1081 const unsigned long do_flush_fua = (bio->bi_opf & 1175 const unsigned long do_flush_fua = (bio->bi_opf &
1082 (REQ_PREFLUSH | REQ_FUA)); 1176 (REQ_PREFLUSH | REQ_FUA));
@@ -1096,15 +1190,15 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio)
1096 1190
1097 md_write_start(mddev, bio); /* wait on superblock update early */ 1191 md_write_start(mddev, bio); /* wait on superblock update early */
1098 1192
1099 if (bio_data_dir(bio) == WRITE && 1193 if ((bio_end_sector(bio) > mddev->suspend_lo &&
1100 ((bio_end_sector(bio) > mddev->suspend_lo &&
1101 bio->bi_iter.bi_sector < mddev->suspend_hi) || 1194 bio->bi_iter.bi_sector < mddev->suspend_hi) ||
1102 (mddev_is_clustered(mddev) && 1195 (mddev_is_clustered(mddev) &&
1103 md_cluster_ops->area_resyncing(mddev, WRITE, 1196 md_cluster_ops->area_resyncing(mddev, WRITE,
1104 bio->bi_iter.bi_sector, bio_end_sector(bio))))) { 1197 bio->bi_iter.bi_sector, bio_end_sector(bio)))) {
1105 /* As the suspend_* range is controlled by 1198
1106 * userspace, we want an interruptible 1199 /*
1107 * wait. 1200 * As the suspend_* range is controlled by userspace, we want
1201 * an interruptible wait.
1108 */ 1202 */
1109 DEFINE_WAIT(w); 1203 DEFINE_WAIT(w);
1110 for (;;) { 1204 for (;;) {
@@ -1115,128 +1209,15 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio)
1115 bio->bi_iter.bi_sector >= mddev->suspend_hi || 1209 bio->bi_iter.bi_sector >= mddev->suspend_hi ||
1116 (mddev_is_clustered(mddev) && 1210 (mddev_is_clustered(mddev) &&
1117 !md_cluster_ops->area_resyncing(mddev, WRITE, 1211 !md_cluster_ops->area_resyncing(mddev, WRITE,
1118 bio->bi_iter.bi_sector, bio_end_sector(bio)))) 1212 bio->bi_iter.bi_sector,
1213 bio_end_sector(bio))))
1119 break; 1214 break;
1120 schedule(); 1215 schedule();
1121 } 1216 }
1122 finish_wait(&conf->wait_barrier, &w); 1217 finish_wait(&conf->wait_barrier, &w);
1123 } 1218 }
1124
1125 start_next_window = wait_barrier(conf, bio); 1219 start_next_window = wait_barrier(conf, bio);
1126 1220
1127 bitmap = mddev->bitmap;
1128
1129 /*
1130 * make_request() can abort the operation when read-ahead is being
1131 * used and no empty request is available.
1132 *
1133 */
1134 r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);
1135
1136 r1_bio->master_bio = bio;
1137 r1_bio->sectors = bio_sectors(bio);
1138 r1_bio->state = 0;
1139 r1_bio->mddev = mddev;
1140 r1_bio->sector = bio->bi_iter.bi_sector;
1141
1142 /* We might need to issue multiple reads to different
1143 * devices if there are bad blocks around, so we keep
1144 * track of the number of reads in bio->bi_phys_segments.
1145 * If this is 0, there is only one r1_bio and no locking
1146 * will be needed when requests complete. If it is
1147 * non-zero, then it is the number of not-completed requests.
1148 */
1149 bio->bi_phys_segments = 0;
1150 bio_clear_flag(bio, BIO_SEG_VALID);
1151
1152 if (rw == READ) {
1153 /*
1154 * read balancing logic:
1155 */
1156 int rdisk;
1157
1158read_again:
1159 rdisk = read_balance(conf, r1_bio, &max_sectors);
1160
1161 if (rdisk < 0) {
1162 /* couldn't find anywhere to read from */
1163 raid_end_bio_io(r1_bio);
1164 return;
1165 }
1166 mirror = conf->mirrors + rdisk;
1167
1168 if (test_bit(WriteMostly, &mirror->rdev->flags) &&
1169 bitmap) {
1170 /* Reading from a write-mostly device must
1171 * take care not to over-take any writes
1172 * that are 'behind'
1173 */
1174 raid1_log(mddev, "wait behind writes");
1175 wait_event(bitmap->behind_wait,
1176 atomic_read(&bitmap->behind_writes) == 0);
1177 }
1178 r1_bio->read_disk = rdisk;
1179 r1_bio->start_next_window = 0;
1180
1181 read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1182 bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
1183 max_sectors);
1184
1185 r1_bio->bios[rdisk] = read_bio;
1186
1187 read_bio->bi_iter.bi_sector = r1_bio->sector +
1188 mirror->rdev->data_offset;
1189 read_bio->bi_bdev = mirror->rdev->bdev;
1190 read_bio->bi_end_io = raid1_end_read_request;
1191 bio_set_op_attrs(read_bio, op, do_sync);
1192 if (test_bit(FailFast, &mirror->rdev->flags) &&
1193 test_bit(R1BIO_FailFast, &r1_bio->state))
1194 read_bio->bi_opf |= MD_FAILFAST;
1195 read_bio->bi_private = r1_bio;
1196
1197 if (mddev->gendisk)
1198 trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev),
1199 read_bio, disk_devt(mddev->gendisk),
1200 r1_bio->sector);
1201
1202 if (max_sectors < r1_bio->sectors) {
1203 /* could not read all from this device, so we will
1204 * need another r1_bio.
1205 */
1206
1207 sectors_handled = (r1_bio->sector + max_sectors
1208 - bio->bi_iter.bi_sector);
1209 r1_bio->sectors = max_sectors;
1210 spin_lock_irq(&conf->device_lock);
1211 if (bio->bi_phys_segments == 0)
1212 bio->bi_phys_segments = 2;
1213 else
1214 bio->bi_phys_segments++;
1215 spin_unlock_irq(&conf->device_lock);
1216 /* Cannot call generic_make_request directly
1217 * as that will be queued in __make_request
1218 * and subsequent mempool_alloc might block waiting
1219 * for it. So hand bio over to raid1d.
1220 */
1221 reschedule_retry(r1_bio);
1222
1223 r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);
1224
1225 r1_bio->master_bio = bio;
1226 r1_bio->sectors = bio_sectors(bio) - sectors_handled;
1227 r1_bio->state = 0;
1228 r1_bio->mddev = mddev;
1229 r1_bio->sector = bio->bi_iter.bi_sector +
1230 sectors_handled;
1231 goto read_again;
1232 } else
1233 generic_make_request(read_bio);
1234 return;
1235 }
1236
1237 /*
1238 * WRITE:
1239 */
1240 if (conf->pending_count >= max_queued_requests) { 1221 if (conf->pending_count >= max_queued_requests) {
1241 md_wakeup_thread(mddev->thread); 1222 md_wakeup_thread(mddev->thread);
1242 raid1_log(mddev, "wait queued"); 1223 raid1_log(mddev, "wait queued");
@@ -1280,8 +1261,7 @@ read_again:
1280 int bad_sectors; 1261 int bad_sectors;
1281 int is_bad; 1262 int is_bad;
1282 1263
1283 is_bad = is_badblock(rdev, r1_bio->sector, 1264 is_bad = is_badblock(rdev, r1_bio->sector, max_sectors,
1284 max_sectors,
1285 &first_bad, &bad_sectors); 1265 &first_bad, &bad_sectors);
1286 if (is_bad < 0) { 1266 if (is_bad < 0) {
1287 /* mustn't write here until the bad block is 1267 /* mustn't write here until the bad block is
@@ -1370,7 +1350,8 @@ read_again:
1370 continue; 1350 continue;
1371 1351
1372 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); 1352 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1373 bio_trim(mbio, r1_bio->sector - bio->bi_iter.bi_sector, max_sectors); 1353 bio_trim(mbio, r1_bio->sector - bio->bi_iter.bi_sector,
1354 max_sectors);
1374 1355
1375 if (first_clone) { 1356 if (first_clone) {
1376 /* do behind I/O ? 1357 /* do behind I/O ?
@@ -1464,6 +1445,40 @@ read_again:
1464 wake_up(&conf->wait_barrier); 1445 wake_up(&conf->wait_barrier);
1465} 1446}
1466 1447
1448static void raid1_make_request(struct mddev *mddev, struct bio *bio)
1449{
1450 struct r1conf *conf = mddev->private;
1451 struct r1bio *r1_bio;
1452
1453 /*
1454 * make_request() can abort the operation when read-ahead is being
1455 * used and no empty request is available.
1456 *
1457 */
1458 r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);
1459
1460 r1_bio->master_bio = bio;
1461 r1_bio->sectors = bio_sectors(bio);
1462 r1_bio->state = 0;
1463 r1_bio->mddev = mddev;
1464 r1_bio->sector = bio->bi_iter.bi_sector;
1465
1466 /*
1467 * We might need to issue multiple reads to different devices if there
1468 * are bad blocks around, so we keep track of the number of reads in
1469 * bio->bi_phys_segments. If this is 0, there is only one r1_bio and
1470 * no locking will be needed when requests complete. If it is
1471 * non-zero, then it is the number of not-completed requests.
1472 */
1473 bio->bi_phys_segments = 0;
1474 bio_clear_flag(bio, BIO_SEG_VALID);
1475
1476 if (bio_data_dir(bio) == READ)
1477 raid1_read_request(mddev, bio, r1_bio);
1478 else
1479 raid1_write_request(mddev, bio, r1_bio);
1480}
1481
1467static void raid1_status(struct seq_file *seq, struct mddev *mddev) 1482static void raid1_status(struct seq_file *seq, struct mddev *mddev)
1468{ 1483{
1469 struct r1conf *conf = mddev->private; 1484 struct r1conf *conf = mddev->private;
@@ -3246,8 +3261,8 @@ static void *raid1_takeover(struct mddev *mddev)
3246 if (!IS_ERR(conf)) { 3261 if (!IS_ERR(conf)) {
3247 /* Array must appear to be quiesced */ 3262 /* Array must appear to be quiesced */
3248 conf->array_frozen = 1; 3263 conf->array_frozen = 1;
3249 clear_bit(MD_HAS_JOURNAL, &mddev->flags); 3264 mddev_clear_unsupported_flags(mddev,
3250 clear_bit(MD_JOURNAL_CLEAN, &mddev->flags); 3265 UNSUPPORTED_MDDEV_FLAGS);
3251 } 3266 }
3252 return conf; 3267 return conf;
3253 } 3268 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ab5e86209322..1920756828df 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1087,23 +1087,122 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
1087 kfree(plug); 1087 kfree(plug);
1088} 1088}
1089 1089
1090static void __make_request(struct mddev *mddev, struct bio *bio) 1090static void raid10_read_request(struct mddev *mddev, struct bio *bio,
1091 struct r10bio *r10_bio)
1091{ 1092{
1092 struct r10conf *conf = mddev->private; 1093 struct r10conf *conf = mddev->private;
1093 struct r10bio *r10_bio;
1094 struct bio *read_bio; 1094 struct bio *read_bio;
1095 const int op = bio_op(bio);
1096 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
1097 int sectors_handled;
1098 int max_sectors;
1099 sector_t sectors;
1100 struct md_rdev *rdev;
1101 int slot;
1102
1103 /*
1104 * Register the new request and wait if the reconstruction
1105 * thread has put up a bar for new requests.
1106 * Continue immediately if no resync is active currently.
1107 */
1108 wait_barrier(conf);
1109
1110 sectors = bio_sectors(bio);
1111 while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
1112 bio->bi_iter.bi_sector < conf->reshape_progress &&
1113 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) {
1114 /*
1115 * IO spans the reshape position. Need to wait for reshape to
1116 * pass
1117 */
1118 raid10_log(conf->mddev, "wait reshape");
1119 allow_barrier(conf);
1120 wait_event(conf->wait_barrier,
1121 conf->reshape_progress <= bio->bi_iter.bi_sector ||
1122 conf->reshape_progress >= bio->bi_iter.bi_sector +
1123 sectors);
1124 wait_barrier(conf);
1125 }
1126
1127read_again:
1128 rdev = read_balance(conf, r10_bio, &max_sectors);
1129 if (!rdev) {
1130 raid_end_bio_io(r10_bio);
1131 return;
1132 }
1133 slot = r10_bio->read_slot;
1134
1135 read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1136 bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector,
1137 max_sectors);
1138
1139 r10_bio->devs[slot].bio = read_bio;
1140 r10_bio->devs[slot].rdev = rdev;
1141
1142 read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr +
1143 choose_data_offset(r10_bio, rdev);
1144 read_bio->bi_bdev = rdev->bdev;
1145 read_bio->bi_end_io = raid10_end_read_request;
1146 bio_set_op_attrs(read_bio, op, do_sync);
1147 if (test_bit(FailFast, &rdev->flags) &&
1148 test_bit(R10BIO_FailFast, &r10_bio->state))
1149 read_bio->bi_opf |= MD_FAILFAST;
1150 read_bio->bi_private = r10_bio;
1151
1152 if (mddev->gendisk)
1153 trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev),
1154 read_bio, disk_devt(mddev->gendisk),
1155 r10_bio->sector);
1156 if (max_sectors < r10_bio->sectors) {
1157 /*
1158 * Could not read all from this device, so we will need another
1159 * r10_bio.
1160 */
1161 sectors_handled = (r10_bio->sector + max_sectors
1162 - bio->bi_iter.bi_sector);
1163 r10_bio->sectors = max_sectors;
1164 spin_lock_irq(&conf->device_lock);
1165 if (bio->bi_phys_segments == 0)
1166 bio->bi_phys_segments = 2;
1167 else
1168 bio->bi_phys_segments++;
1169 spin_unlock_irq(&conf->device_lock);
1170 /*
1171 * Cannot call generic_make_request directly as that will be
1172 * queued in __generic_make_request and subsequent
1173 * mempool_alloc might block waiting for it. so hand bio over
1174 * to raid10d.
1175 */
1176 reschedule_retry(r10_bio);
1177
1178 r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO);
1179
1180 r10_bio->master_bio = bio;
1181 r10_bio->sectors = bio_sectors(bio) - sectors_handled;
1182 r10_bio->state = 0;
1183 r10_bio->mddev = mddev;
1184 r10_bio->sector = bio->bi_iter.bi_sector + sectors_handled;
1185 goto read_again;
1186 } else
1187 generic_make_request(read_bio);
1188 return;
1189}
1190
1191static void raid10_write_request(struct mddev *mddev, struct bio *bio,
1192 struct r10bio *r10_bio)
1193{
1194 struct r10conf *conf = mddev->private;
1095 int i; 1195 int i;
1096 const int op = bio_op(bio); 1196 const int op = bio_op(bio);
1097 const int rw = bio_data_dir(bio);
1098 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); 1197 const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
1099 const unsigned long do_fua = (bio->bi_opf & REQ_FUA); 1198 const unsigned long do_fua = (bio->bi_opf & REQ_FUA);
1100 unsigned long flags; 1199 unsigned long flags;
1101 struct md_rdev *blocked_rdev; 1200 struct md_rdev *blocked_rdev;
1102 struct blk_plug_cb *cb; 1201 struct blk_plug_cb *cb;
1103 struct raid10_plug_cb *plug = NULL; 1202 struct raid10_plug_cb *plug = NULL;
1203 sector_t sectors;
1104 int sectors_handled; 1204 int sectors_handled;
1105 int max_sectors; 1205 int max_sectors;
1106 int sectors;
1107 1206
1108 md_write_start(mddev, bio); 1207 md_write_start(mddev, bio);
1109 1208
@@ -1118,8 +1217,9 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
1118 while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && 1217 while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
1119 bio->bi_iter.bi_sector < conf->reshape_progress && 1218 bio->bi_iter.bi_sector < conf->reshape_progress &&
1120 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { 1219 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) {
1121 /* IO spans the reshape position. Need to wait for 1220 /*
1122 * reshape to pass 1221 * IO spans the reshape position. Need to wait for reshape to
1222 * pass
1123 */ 1223 */
1124 raid10_log(conf->mddev, "wait reshape"); 1224 raid10_log(conf->mddev, "wait reshape");
1125 allow_barrier(conf); 1225 allow_barrier(conf);
@@ -1129,8 +1229,8 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
1129 sectors); 1229 sectors);
1130 wait_barrier(conf); 1230 wait_barrier(conf);
1131 } 1231 }
1232
1132 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && 1233 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
1133 bio_data_dir(bio) == WRITE &&
1134 (mddev->reshape_backwards 1234 (mddev->reshape_backwards
1135 ? (bio->bi_iter.bi_sector < conf->reshape_safe && 1235 ? (bio->bi_iter.bi_sector < conf->reshape_safe &&
1136 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) 1236 bio->bi_iter.bi_sector + sectors > conf->reshape_progress)
@@ -1148,98 +1248,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
1148 conf->reshape_safe = mddev->reshape_position; 1248 conf->reshape_safe = mddev->reshape_position;
1149 } 1249 }
1150 1250
1151 r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO);
1152
1153 r10_bio->master_bio = bio;
1154 r10_bio->sectors = sectors;
1155
1156 r10_bio->mddev = mddev;
1157 r10_bio->sector = bio->bi_iter.bi_sector;
1158 r10_bio->state = 0;
1159
1160 /* We might need to issue multiple reads to different
1161 * devices if there are bad blocks around, so we keep
1162 * track of the number of reads in bio->bi_phys_segments.
1163 * If this is 0, there is only one r10_bio and no locking
1164 * will be needed when the request completes. If it is
1165 * non-zero, then it is the number of not-completed requests.
1166 */
1167 bio->bi_phys_segments = 0;
1168 bio_clear_flag(bio, BIO_SEG_VALID);
1169
1170 if (rw == READ) {
1171 /*
1172 * read balancing logic:
1173 */
1174 struct md_rdev *rdev;
1175 int slot;
1176
1177read_again:
1178 rdev = read_balance(conf, r10_bio, &max_sectors);
1179 if (!rdev) {
1180 raid_end_bio_io(r10_bio);
1181 return;
1182 }
1183 slot = r10_bio->read_slot;
1184
1185 read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1186 bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector,
1187 max_sectors);
1188
1189 r10_bio->devs[slot].bio = read_bio;
1190 r10_bio->devs[slot].rdev = rdev;
1191
1192 read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr +
1193 choose_data_offset(r10_bio, rdev);
1194 read_bio->bi_bdev = rdev->bdev;
1195 read_bio->bi_end_io = raid10_end_read_request;
1196 bio_set_op_attrs(read_bio, op, do_sync);
1197 if (test_bit(FailFast, &rdev->flags) &&
1198 test_bit(R10BIO_FailFast, &r10_bio->state))
1199 read_bio->bi_opf |= MD_FAILFAST;
1200 read_bio->bi_private = r10_bio;
1201
1202 if (mddev->gendisk)
1203 trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev),
1204 read_bio, disk_devt(mddev->gendisk),
1205 r10_bio->sector);
1206 if (max_sectors < r10_bio->sectors) {
1207 /* Could not read all from this device, so we will
1208 * need another r10_bio.
1209 */
1210 sectors_handled = (r10_bio->sector + max_sectors
1211 - bio->bi_iter.bi_sector);
1212 r10_bio->sectors = max_sectors;
1213 spin_lock_irq(&conf->device_lock);
1214 if (bio->bi_phys_segments == 0)
1215 bio->bi_phys_segments = 2;
1216 else
1217 bio->bi_phys_segments++;
1218 spin_unlock_irq(&conf->device_lock);
1219 /* Cannot call generic_make_request directly
1220 * as that will be queued in __generic_make_request
1221 * and subsequent mempool_alloc might block
1222 * waiting for it. so hand bio over to raid10d.
1223 */
1224 reschedule_retry(r10_bio);
1225
1226 r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO);
1227
1228 r10_bio->master_bio = bio;
1229 r10_bio->sectors = bio_sectors(bio) - sectors_handled;
1230 r10_bio->state = 0;
1231 r10_bio->mddev = mddev;
1232 r10_bio->sector = bio->bi_iter.bi_sector +
1233 sectors_handled;
1234 goto read_again;
1235 } else
1236 generic_make_request(read_bio);
1237 return;
1238 }
1239
1240 /*
1241 * WRITE:
1242 */
1243 if (conf->pending_count >= max_queued_requests) { 1251 if (conf->pending_count >= max_queued_requests) {
1244 md_wakeup_thread(mddev->thread); 1252 md_wakeup_thread(mddev->thread);
1245 raid10_log(mddev, "wait queued"); 1253 raid10_log(mddev, "wait queued");
@@ -1300,8 +1308,7 @@ retry_write:
1300 int bad_sectors; 1308 int bad_sectors;
1301 int is_bad; 1309 int is_bad;
1302 1310
1303 is_bad = is_badblock(rdev, dev_sector, 1311 is_bad = is_badblock(rdev, dev_sector, max_sectors,
1304 max_sectors,
1305 &first_bad, &bad_sectors); 1312 &first_bad, &bad_sectors);
1306 if (is_bad < 0) { 1313 if (is_bad < 0) {
1307 /* Mustn't write here until the bad block 1314 /* Mustn't write here until the bad block
@@ -1405,8 +1412,7 @@ retry_write:
1405 r10_bio->devs[i].bio = mbio; 1412 r10_bio->devs[i].bio = mbio;
1406 1413
1407 mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ 1414 mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+
1408 choose_data_offset(r10_bio, 1415 choose_data_offset(r10_bio, rdev));
1409 rdev));
1410 mbio->bi_bdev = rdev->bdev; 1416 mbio->bi_bdev = rdev->bdev;
1411 mbio->bi_end_io = raid10_end_write_request; 1417 mbio->bi_end_io = raid10_end_write_request;
1412 bio_set_op_attrs(mbio, op, do_sync | do_fua); 1418 bio_set_op_attrs(mbio, op, do_sync | do_fua);
@@ -1457,8 +1463,7 @@ retry_write:
1457 r10_bio->devs[i].repl_bio = mbio; 1463 r10_bio->devs[i].repl_bio = mbio;
1458 1464
1459 mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr + 1465 mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr +
1460 choose_data_offset( 1466 choose_data_offset(r10_bio, rdev));
1461 r10_bio, rdev));
1462 mbio->bi_bdev = rdev->bdev; 1467 mbio->bi_bdev = rdev->bdev;
1463 mbio->bi_end_io = raid10_end_write_request; 1468 mbio->bi_end_io = raid10_end_write_request;
1464 bio_set_op_attrs(mbio, op, do_sync | do_fua); 1469 bio_set_op_attrs(mbio, op, do_sync | do_fua);
@@ -1503,6 +1508,36 @@ retry_write:
1503 one_write_done(r10_bio); 1508 one_write_done(r10_bio);
1504} 1509}
1505 1510
1511static void __make_request(struct mddev *mddev, struct bio *bio)
1512{
1513 struct r10conf *conf = mddev->private;
1514 struct r10bio *r10_bio;
1515
1516 r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO);
1517
1518 r10_bio->master_bio = bio;
1519 r10_bio->sectors = bio_sectors(bio);
1520
1521 r10_bio->mddev = mddev;
1522 r10_bio->sector = bio->bi_iter.bi_sector;
1523 r10_bio->state = 0;
1524
1525 /*
1526 * We might need to issue multiple reads to different devices if there
1527 * are bad blocks around, so we keep track of the number of reads in
1528 * bio->bi_phys_segments. If this is 0, there is only one r10_bio and
1529 * no locking will be needed when the request completes. If it is
1530 * non-zero, then it is the number of not-completed requests.
1531 */
1532 bio->bi_phys_segments = 0;
1533 bio_clear_flag(bio, BIO_SEG_VALID);
1534
1535 if (bio_data_dir(bio) == READ)
1536 raid10_read_request(mddev, bio, r10_bio);
1537 else
1538 raid10_write_request(mddev, bio, r10_bio);
1539}
1540
1506static void raid10_make_request(struct mddev *mddev, struct bio *bio) 1541static void raid10_make_request(struct mddev *mddev, struct bio *bio)
1507{ 1542{
1508 struct r10conf *conf = mddev->private; 1543 struct r10conf *conf = mddev->private;
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index d7bfb6fc8aef..0e8ed2c327b0 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -1682,8 +1682,7 @@ out:
1682 1682
1683static struct stripe_head * 1683static struct stripe_head *
1684r5c_recovery_alloc_stripe(struct r5conf *conf, 1684r5c_recovery_alloc_stripe(struct r5conf *conf,
1685 sector_t stripe_sect, 1685 sector_t stripe_sect)
1686 sector_t log_start)
1687{ 1686{
1688 struct stripe_head *sh; 1687 struct stripe_head *sh;
1689 1688
@@ -1692,7 +1691,6 @@ r5c_recovery_alloc_stripe(struct r5conf *conf,
1692 return NULL; /* no more stripe available */ 1691 return NULL; /* no more stripe available */
1693 1692
1694 r5l_recovery_reset_stripe(sh); 1693 r5l_recovery_reset_stripe(sh);
1695 sh->log_start = log_start;
1696 1694
1697 return sh; 1695 return sh;
1698} 1696}
@@ -1862,7 +1860,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,
1862 stripe_sect); 1860 stripe_sect);
1863 1861
1864 if (!sh) { 1862 if (!sh) {
1865 sh = r5c_recovery_alloc_stripe(conf, stripe_sect, ctx->pos); 1863 sh = r5c_recovery_alloc_stripe(conf, stripe_sect);
1866 /* 1864 /*
1867 * cannot get stripe from raid5_get_active_stripe 1865 * cannot get stripe from raid5_get_active_stripe
1868 * try replay some stripes 1866 * try replay some stripes
@@ -1871,7 +1869,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,
1871 r5c_recovery_replay_stripes( 1869 r5c_recovery_replay_stripes(
1872 cached_stripe_list, ctx); 1870 cached_stripe_list, ctx);
1873 sh = r5c_recovery_alloc_stripe( 1871 sh = r5c_recovery_alloc_stripe(
1874 conf, stripe_sect, ctx->pos); 1872 conf, stripe_sect);
1875 } 1873 }
1876 if (!sh) { 1874 if (!sh) {
1877 pr_debug("md/raid:%s: Increasing stripe cache size to %d to recovery data on journal.\n", 1875 pr_debug("md/raid:%s: Increasing stripe cache size to %d to recovery data on journal.\n",
@@ -1879,8 +1877,8 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,
1879 conf->min_nr_stripes * 2); 1877 conf->min_nr_stripes * 2);
1880 raid5_set_cache_size(mddev, 1878 raid5_set_cache_size(mddev,
1881 conf->min_nr_stripes * 2); 1879 conf->min_nr_stripes * 2);
1882 sh = r5c_recovery_alloc_stripe( 1880 sh = r5c_recovery_alloc_stripe(conf,
1883 conf, stripe_sect, ctx->pos); 1881 stripe_sect);
1884 } 1882 }
1885 if (!sh) { 1883 if (!sh) {
1886 pr_err("md/raid:%s: Cannot get enough stripes due to memory pressure. Recovery failed.\n", 1884 pr_err("md/raid:%s: Cannot get enough stripes due to memory pressure. Recovery failed.\n",
@@ -1894,7 +1892,6 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,
1894 if (!test_bit(STRIPE_R5C_CACHING, &sh->state) && 1892 if (!test_bit(STRIPE_R5C_CACHING, &sh->state) &&
1895 test_bit(R5_Wantwrite, &sh->dev[sh->pd_idx].flags)) { 1893 test_bit(R5_Wantwrite, &sh->dev[sh->pd_idx].flags)) {
1896 r5l_recovery_replay_one_stripe(conf, sh, ctx); 1894 r5l_recovery_replay_one_stripe(conf, sh, ctx);
1897 sh->log_start = ctx->pos;
1898 list_move_tail(&sh->lru, cached_stripe_list); 1895 list_move_tail(&sh->lru, cached_stripe_list);
1899 } 1896 }
1900 r5l_recovery_load_data(log, sh, ctx, payload, 1897 r5l_recovery_load_data(log, sh, ctx, payload,
@@ -1933,8 +1930,6 @@ static void r5c_recovery_load_one_stripe(struct r5l_log *log,
1933 set_bit(R5_UPTODATE, &dev->flags); 1930 set_bit(R5_UPTODATE, &dev->flags);
1934 } 1931 }
1935 } 1932 }
1936 list_add_tail(&sh->r5c, &log->stripe_in_journal_list);
1937 atomic_inc(&log->stripe_in_journal_count);
1938} 1933}
1939 1934
1940/* 1935/*
@@ -2070,6 +2065,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
2070 struct stripe_head *sh, *next; 2065 struct stripe_head *sh, *next;
2071 struct mddev *mddev = log->rdev->mddev; 2066 struct mddev *mddev = log->rdev->mddev;
2072 struct page *page; 2067 struct page *page;
2068 sector_t next_checkpoint = MaxSector;
2073 2069
2074 page = alloc_page(GFP_KERNEL); 2070 page = alloc_page(GFP_KERNEL);
2075 if (!page) { 2071 if (!page) {
@@ -2078,6 +2074,8 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
2078 return -ENOMEM; 2074 return -ENOMEM;
2079 } 2075 }
2080 2076
2077 WARN_ON(list_empty(&ctx->cached_list));
2078
2081 list_for_each_entry_safe(sh, next, &ctx->cached_list, lru) { 2079 list_for_each_entry_safe(sh, next, &ctx->cached_list, lru) {
2082 struct r5l_meta_block *mb; 2080 struct r5l_meta_block *mb;
2083 int i; 2081 int i;
@@ -2123,12 +2121,15 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
2123 sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page, 2121 sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page,
2124 REQ_OP_WRITE, REQ_FUA, false); 2122 REQ_OP_WRITE, REQ_FUA, false);
2125 sh->log_start = ctx->pos; 2123 sh->log_start = ctx->pos;
2124 list_add_tail(&sh->r5c, &log->stripe_in_journal_list);
2125 atomic_inc(&log->stripe_in_journal_count);
2126 ctx->pos = write_pos; 2126 ctx->pos = write_pos;
2127 ctx->seq += 1; 2127 ctx->seq += 1;
2128 2128 next_checkpoint = sh->log_start;
2129 list_del_init(&sh->lru); 2129 list_del_init(&sh->lru);
2130 raid5_release_stripe(sh); 2130 raid5_release_stripe(sh);
2131 } 2131 }
2132 log->next_checkpoint = next_checkpoint;
2132 __free_page(page); 2133 __free_page(page);
2133 return 0; 2134 return 0;
2134} 2135}
@@ -2139,7 +2140,6 @@ static int r5l_recovery_log(struct r5l_log *log)
2139 struct r5l_recovery_ctx ctx; 2140 struct r5l_recovery_ctx ctx;
2140 int ret; 2141 int ret;
2141 sector_t pos; 2142 sector_t pos;
2142 struct stripe_head *sh;
2143 2143
2144 ctx.pos = log->last_checkpoint; 2144 ctx.pos = log->last_checkpoint;
2145 ctx.seq = log->last_cp_seq; 2145 ctx.seq = log->last_cp_seq;
@@ -2164,16 +2164,13 @@ static int r5l_recovery_log(struct r5l_log *log)
2164 log->next_checkpoint = ctx.pos; 2164 log->next_checkpoint = ctx.pos;
2165 r5l_log_write_empty_meta_block(log, ctx.pos, ctx.seq++); 2165 r5l_log_write_empty_meta_block(log, ctx.pos, ctx.seq++);
2166 ctx.pos = r5l_ring_add(log, ctx.pos, BLOCK_SECTORS); 2166 ctx.pos = r5l_ring_add(log, ctx.pos, BLOCK_SECTORS);
2167 } else {
2168 sh = list_last_entry(&ctx.cached_list, struct stripe_head, lru);
2169 log->next_checkpoint = sh->log_start;
2170 } 2167 }
2171 2168
2172 if ((ctx.data_only_stripes == 0) && (ctx.data_parity_stripes == 0)) 2169 if ((ctx.data_only_stripes == 0) && (ctx.data_parity_stripes == 0))
2173 pr_debug("md/raid:%s: starting from clean shutdown\n", 2170 pr_debug("md/raid:%s: starting from clean shutdown\n",
2174 mdname(mddev)); 2171 mdname(mddev));
2175 else { 2172 else {
2176 pr_debug("md/raid:%s: recoverying %d data-only stripes and %d data-parity stripes\n", 2173 pr_debug("md/raid:%s: recovering %d data-only stripes and %d data-parity stripes\n",
2177 mdname(mddev), ctx.data_only_stripes, 2174 mdname(mddev), ctx.data_only_stripes,
2178 ctx.data_parity_stripes); 2175 ctx.data_parity_stripes);
2179 2176
@@ -2418,9 +2415,6 @@ void r5c_finish_stripe_write_out(struct r5conf *conf,
2418 if (do_wakeup) 2415 if (do_wakeup)
2419 wake_up(&conf->wait_for_overlap); 2416 wake_up(&conf->wait_for_overlap);
2420 2417
2421 if (conf->log->r5c_journal_mode == R5C_JOURNAL_MODE_WRITE_THROUGH)
2422 return;
2423
2424 spin_lock_irq(&conf->log->stripe_in_journal_lock); 2418 spin_lock_irq(&conf->log->stripe_in_journal_lock);
2425 list_del_init(&sh->r5c); 2419 list_del_init(&sh->r5c);
2426 spin_unlock_irq(&conf->log->stripe_in_journal_lock); 2420 spin_unlock_irq(&conf->log->stripe_in_journal_lock);
@@ -2639,14 +2633,16 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
2639 spin_lock_init(&log->stripe_in_journal_lock); 2633 spin_lock_init(&log->stripe_in_journal_lock);
2640 atomic_set(&log->stripe_in_journal_count, 0); 2634 atomic_set(&log->stripe_in_journal_count, 0);
2641 2635
2636 rcu_assign_pointer(conf->log, log);
2637
2642 if (r5l_load_log(log)) 2638 if (r5l_load_log(log))
2643 goto error; 2639 goto error;
2644 2640
2645 rcu_assign_pointer(conf->log, log);
2646 set_bit(MD_HAS_JOURNAL, &conf->mddev->flags); 2641 set_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
2647 return 0; 2642 return 0;
2648 2643
2649error: 2644error:
2645 rcu_assign_pointer(conf->log, NULL);
2650 md_unregister_thread(&log->reclaim_thread); 2646 md_unregister_thread(&log->reclaim_thread);
2651reclaim_thread: 2647reclaim_thread:
2652 mempool_destroy(log->meta_pool); 2648 mempool_destroy(log->meta_pool);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 06d7279bdd04..36c13e4be9c9 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -62,6 +62,8 @@
62#include "raid0.h" 62#include "raid0.h"
63#include "bitmap.h" 63#include "bitmap.h"
64 64
65#define UNSUPPORTED_MDDEV_FLAGS (1L << MD_FAILFAST_SUPPORTED)
66
65#define cpu_to_group(cpu) cpu_to_node(cpu) 67#define cpu_to_group(cpu) cpu_to_node(cpu)
66#define ANY_GROUP NUMA_NO_NODE 68#define ANY_GROUP NUMA_NO_NODE
67 69
@@ -7829,8 +7831,9 @@ static void *raid5_takeover_raid1(struct mddev *mddev)
7829 mddev->new_chunk_sectors = chunksect; 7831 mddev->new_chunk_sectors = chunksect;
7830 7832
7831 ret = setup_conf(mddev); 7833 ret = setup_conf(mddev);
7832 if (!IS_ERR_VALUE(ret)) 7834 if (!IS_ERR(ret))
7833 clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); 7835 mddev_clear_unsupported_flags(mddev,
7836 UNSUPPORTED_MDDEV_FLAGS);
7834 return ret; 7837 return ret;
7835} 7838}
7836 7839
diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
index 18e05ca7584f..3600c9993a98 100644
--- a/drivers/misc/mei/bus-fixup.c
+++ b/drivers/misc/mei/bus-fixup.c
@@ -152,6 +152,9 @@ static void mei_mkhi_fix(struct mei_cl_device *cldev)
152{ 152{
153 int ret; 153 int ret;
154 154
155 if (!cldev->bus->hbm_f_os_supported)
156 return;
157
155 ret = mei_cldev_enable(cldev); 158 ret = mei_cldev_enable(cldev);
156 if (ret) 159 if (ret)
157 return; 160 return;
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 0037153c80a6..2d9c5dd06e42 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -450,7 +450,7 @@ bool mei_cldev_enabled(struct mei_cl_device *cldev)
450EXPORT_SYMBOL_GPL(mei_cldev_enabled); 450EXPORT_SYMBOL_GPL(mei_cldev_enabled);
451 451
452/** 452/**
453 * mei_cldev_enable_device - enable me client device 453 * mei_cldev_enable - enable me client device
454 * create connection with me client 454 * create connection with me client
455 * 455 *
456 * @cldev: me client device 456 * @cldev: me client device
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 391936c1aa04..b0395601c6ae 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -1541,7 +1541,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1541 1541
1542 rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1; 1542 rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1;
1543 if (rets < 0) 1543 if (rets < 0)
1544 return rets; 1544 goto err;
1545 1545
1546 if (rets == 0) { 1546 if (rets == 0) {
1547 cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); 1547 cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
@@ -1575,11 +1575,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1575 cb->buf.size, cb->buf_idx); 1575 cb->buf.size, cb->buf_idx);
1576 1576
1577 rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx); 1577 rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
1578 if (rets) { 1578 if (rets)
1579 cl->status = rets; 1579 goto err;
1580 list_move_tail(&cb->list, &cmpl_list->list);
1581 return rets;
1582 }
1583 1580
1584 cl->status = 0; 1581 cl->status = 0;
1585 cl->writing_state = MEI_WRITING; 1582 cl->writing_state = MEI_WRITING;
@@ -1587,14 +1584,21 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1587 cb->completed = mei_hdr.msg_complete == 1; 1584 cb->completed = mei_hdr.msg_complete == 1;
1588 1585
1589 if (first_chunk) { 1586 if (first_chunk) {
1590 if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) 1587 if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
1591 return -EIO; 1588 rets = -EIO;
1589 goto err;
1590 }
1592 } 1591 }
1593 1592
1594 if (mei_hdr.msg_complete) 1593 if (mei_hdr.msg_complete)
1595 list_move_tail(&cb->list, &dev->write_waiting_list.list); 1594 list_move_tail(&cb->list, &dev->write_waiting_list.list);
1596 1595
1597 return 0; 1596 return 0;
1597
1598err:
1599 cl->status = rets;
1600 list_move_tail(&cb->list, &cmpl_list->list);
1601 return rets;
1598} 1602}
1599 1603
1600/** 1604/**
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index c6c051b52f55..c6217a4993ad 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -180,6 +180,8 @@ static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf,
180 dev->hbm_f_ev_supported); 180 dev->hbm_f_ev_supported);
181 pos += scnprintf(buf + pos, bufsz - pos, "\tFA: %01d\n", 181 pos += scnprintf(buf + pos, bufsz - pos, "\tFA: %01d\n",
182 dev->hbm_f_fa_supported); 182 dev->hbm_f_fa_supported);
183 pos += scnprintf(buf + pos, bufsz - pos, "\tOS: %01d\n",
184 dev->hbm_f_os_supported);
183 } 185 }
184 186
185 pos += scnprintf(buf + pos, bufsz - pos, "pg: %s, %s\n", 187 pos += scnprintf(buf + pos, bufsz - pos, "pg: %s, %s\n",
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index dd7f15a65eed..25b4a1ba522d 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -989,6 +989,10 @@ static void mei_hbm_config_features(struct mei_device *dev)
989 /* Fixed Address Client Support */ 989 /* Fixed Address Client Support */
990 if (dev->version.major_version >= HBM_MAJOR_VERSION_FA) 990 if (dev->version.major_version >= HBM_MAJOR_VERSION_FA)
991 dev->hbm_f_fa_supported = 1; 991 dev->hbm_f_fa_supported = 1;
992
993 /* OS ver message Support */
994 if (dev->version.major_version >= HBM_MAJOR_VERSION_OS)
995 dev->hbm_f_os_supported = 1;
992} 996}
993 997
994/** 998/**
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h
index 9daf3f9aed25..e1e4d47d4d7d 100644
--- a/drivers/misc/mei/hw.h
+++ b/drivers/misc/mei/hw.h
@@ -76,6 +76,12 @@
76#define HBM_MINOR_VERSION_FA 0 76#define HBM_MINOR_VERSION_FA 0
77#define HBM_MAJOR_VERSION_FA 2 77#define HBM_MAJOR_VERSION_FA 2
78 78
79/*
80 * MEI version with OS ver message support
81 */
82#define HBM_MINOR_VERSION_OS 0
83#define HBM_MAJOR_VERSION_OS 2
84
79/* Host bus message command opcode */ 85/* Host bus message command opcode */
80#define MEI_HBM_CMD_OP_MSK 0x7f 86#define MEI_HBM_CMD_OP_MSK 0x7f
81/* Host bus message command RESPONSE */ 87/* Host bus message command RESPONSE */
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 699693cd8c59..8dadb98662a9 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -406,6 +406,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
406 * @hbm_f_ev_supported : hbm feature event notification 406 * @hbm_f_ev_supported : hbm feature event notification
407 * @hbm_f_fa_supported : hbm feature fixed address client 407 * @hbm_f_fa_supported : hbm feature fixed address client
408 * @hbm_f_ie_supported : hbm feature immediate reply to enum request 408 * @hbm_f_ie_supported : hbm feature immediate reply to enum request
409 * @hbm_f_os_supported : hbm feature support OS ver message
409 * 410 *
410 * @me_clients_rwsem: rw lock over me_clients list 411 * @me_clients_rwsem: rw lock over me_clients list
411 * @me_clients : list of FW clients 412 * @me_clients : list of FW clients
@@ -487,6 +488,7 @@ struct mei_device {
487 unsigned int hbm_f_ev_supported:1; 488 unsigned int hbm_f_ev_supported:1;
488 unsigned int hbm_f_fa_supported:1; 489 unsigned int hbm_f_fa_supported:1;
489 unsigned int hbm_f_ie_supported:1; 490 unsigned int hbm_f_ie_supported:1;
491 unsigned int hbm_f_os_supported:1;
490 492
491 struct rw_semaphore me_clients_rwsem; 493 struct rw_semaphore me_clients_rwsem;
492 struct list_head me_clients; 494 struct list_head me_clients;
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index b11c3455b040..e6ea8503f40c 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -506,9 +506,6 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
506 } 506 }
507 } while (busy); 507 } while (busy);
508 508
509 if (host->ops->card_busy && send_status)
510 return mmc_switch_status(card);
511
512 return 0; 509 return 0;
513} 510}
514 511
@@ -577,24 +574,26 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
577 if (!use_busy_signal) 574 if (!use_busy_signal)
578 goto out; 575 goto out;
579 576
580 /* Switch to new timing before poll and check switch status. */
581 if (timing)
582 mmc_set_timing(host, timing);
583
584 /*If SPI or used HW busy detection above, then we don't need to poll. */ 577 /*If SPI or used HW busy detection above, then we don't need to poll. */
585 if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) || 578 if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
586 mmc_host_is_spi(host)) { 579 mmc_host_is_spi(host))
587 if (send_status)
588 err = mmc_switch_status(card);
589 goto out_tim; 580 goto out_tim;
590 }
591 581
592 /* Let's try to poll to find out when the command is completed. */ 582 /* Let's try to poll to find out when the command is completed. */
593 err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err); 583 err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err);
584 if (err)
585 goto out;
594 586
595out_tim: 587out_tim:
596 if (err && timing) 588 /* Switch to new timing before check switch status. */
597 mmc_set_timing(host, old_timing); 589 if (timing)
590 mmc_set_timing(host, timing);
591
592 if (send_status) {
593 err = mmc_switch_status(card);
594 if (err && timing)
595 mmc_set_timing(host, old_timing);
596 }
598out: 597out:
599 mmc_retune_release(host); 598 mmc_retune_release(host);
600 599
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index b352760c041e..09739352834c 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -578,13 +578,15 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
578{ 578{
579 struct meson_host *host = dev_id; 579 struct meson_host *host = dev_id;
580 struct mmc_request *mrq; 580 struct mmc_request *mrq;
581 struct mmc_command *cmd = host->cmd; 581 struct mmc_command *cmd;
582 u32 irq_en, status, raw_status; 582 u32 irq_en, status, raw_status;
583 irqreturn_t ret = IRQ_HANDLED; 583 irqreturn_t ret = IRQ_HANDLED;
584 584
585 if (WARN_ON(!host)) 585 if (WARN_ON(!host))
586 return IRQ_NONE; 586 return IRQ_NONE;
587 587
588 cmd = host->cmd;
589
588 mrq = host->mrq; 590 mrq = host->mrq;
589 591
590 if (WARN_ON(!mrq)) 592 if (WARN_ON(!mrq))
@@ -670,10 +672,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
670 int ret = IRQ_HANDLED; 672 int ret = IRQ_HANDLED;
671 673
672 if (WARN_ON(!mrq)) 674 if (WARN_ON(!mrq))
673 ret = IRQ_NONE; 675 return IRQ_NONE;
674 676
675 if (WARN_ON(!cmd)) 677 if (WARN_ON(!cmd))
676 ret = IRQ_NONE; 678 return IRQ_NONE;
677 679
678 data = cmd->data; 680 data = cmd->data;
679 if (data) { 681 if (data) {
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 44ecebd1ea8c..c8b8ac66ff7e 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -309,6 +309,9 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host)
309 cmd0 = BF_SSP(cmd->opcode, CMD0_CMD); 309 cmd0 = BF_SSP(cmd->opcode, CMD0_CMD);
310 cmd1 = cmd->arg; 310 cmd1 = cmd->arg;
311 311
312 if (cmd->opcode == MMC_STOP_TRANSMISSION)
313 cmd0 |= BM_SSP_CMD0_APPEND_8CYC;
314
312 if (host->sdio_irq_en) { 315 if (host->sdio_irq_en) {
313 ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK; 316 ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
314 cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN; 317 cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
@@ -417,8 +420,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
417 ssp->base + HW_SSP_BLOCK_SIZE); 420 ssp->base + HW_SSP_BLOCK_SIZE);
418 } 421 }
419 422
420 if ((cmd->opcode == MMC_STOP_TRANSMISSION) || 423 if (cmd->opcode == SD_IO_RW_EXTENDED)
421 (cmd->opcode == SD_IO_RW_EXTENDED))
422 cmd0 |= BM_SSP_CMD0_APPEND_8CYC; 424 cmd0 |= BM_SSP_CMD0_APPEND_8CYC;
423 425
424 cmd1 = cmd->arg; 426 cmd1 = cmd->arg;
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 160f695cc09c..278a5a435ab7 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -395,7 +395,8 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
395 /* Power on the SDHCI controller and its children */ 395 /* Power on the SDHCI controller and its children */
396 acpi_device_fix_up_power(device); 396 acpi_device_fix_up_power(device);
397 list_for_each_entry(child, &device->children, node) 397 list_for_each_entry(child, &device->children, node)
398 acpi_device_fix_up_power(child); 398 if (child->status.present && child->status.enabled)
399 acpi_device_fix_up_power(child);
399 400
400 if (acpi_bus_get_status(device) || !device->status.present) 401 if (acpi_bus_get_status(device) || !device->status.present)
401 return -ENODEV; 402 return -ENODEV;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 353a9ddf6b97..9ce5dcb4abd0 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -426,6 +426,7 @@ config MTD_NAND_ORION
426 426
427config MTD_NAND_OXNAS 427config MTD_NAND_OXNAS
428 tristate "NAND Flash support for Oxford Semiconductor SoC" 428 tristate "NAND Flash support for Oxford Semiconductor SoC"
429 depends on HAS_IOMEM
429 help 430 help
430 This enables the NAND flash controller on Oxford Semiconductor SoCs. 431 This enables the NAND flash controller on Oxford Semiconductor SoCs.
431 432
@@ -540,7 +541,7 @@ config MTD_NAND_FSMC
540 Flexible Static Memory Controller (FSMC) 541 Flexible Static Memory Controller (FSMC)
541 542
542config MTD_NAND_XWAY 543config MTD_NAND_XWAY
543 tristate "Support for NAND on Lantiq XWAY SoC" 544 bool "Support for NAND on Lantiq XWAY SoC"
544 depends on LANTIQ && SOC_TYPE_XWAY 545 depends on LANTIQ && SOC_TYPE_XWAY
545 help 546 help
546 Enables support for NAND Flash chips on Lantiq XWAY SoCs. NAND is attached 547 Enables support for NAND Flash chips on Lantiq XWAY SoCs. NAND is attached
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
index 5553a5d9efd1..846a66c1b133 100644
--- a/drivers/mtd/nand/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/lpc32xx_mlc.c
@@ -775,7 +775,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
775 init_completion(&host->comp_controller); 775 init_completion(&host->comp_controller);
776 776
777 host->irq = platform_get_irq(pdev, 0); 777 host->irq = platform_get_irq(pdev, 0);
778 if ((host->irq < 0) || (host->irq >= NR_IRQS)) { 778 if (host->irq < 0) {
779 dev_err(&pdev->dev, "failed to get platform irq\n"); 779 dev_err(&pdev->dev, "failed to get platform irq\n");
780 res = -EINVAL; 780 res = -EINVAL;
781 goto err_exit3; 781 goto err_exit3;
diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
index 28c7f474be77..4a5e948c62df 100644
--- a/drivers/mtd/nand/tango_nand.c
+++ b/drivers/mtd/nand/tango_nand.c
@@ -632,11 +632,13 @@ static int tango_nand_probe(struct platform_device *pdev)
632 if (IS_ERR(nfc->pbus_base)) 632 if (IS_ERR(nfc->pbus_base))
633 return PTR_ERR(nfc->pbus_base); 633 return PTR_ERR(nfc->pbus_base);
634 634
635 writel_relaxed(MODE_RAW, nfc->pbus_base + PBUS_PAD_MODE);
636
635 clk = clk_get(&pdev->dev, NULL); 637 clk = clk_get(&pdev->dev, NULL);
636 if (IS_ERR(clk)) 638 if (IS_ERR(clk))
637 return PTR_ERR(clk); 639 return PTR_ERR(clk);
638 640
639 nfc->chan = dma_request_chan(&pdev->dev, "nfc_sbox"); 641 nfc->chan = dma_request_chan(&pdev->dev, "rxtx");
640 if (IS_ERR(nfc->chan)) 642 if (IS_ERR(nfc->chan))
641 return PTR_ERR(nfc->chan); 643 return PTR_ERR(nfc->chan);
642 644
diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c
index 1f2948c0c458..895101a5e686 100644
--- a/drivers/mtd/nand/xway_nand.c
+++ b/drivers/mtd/nand/xway_nand.c
@@ -232,7 +232,6 @@ static const struct of_device_id xway_nand_match[] = {
232 { .compatible = "lantiq,nand-xway" }, 232 { .compatible = "lantiq,nand-xway" },
233 {}, 233 {},
234}; 234};
235MODULE_DEVICE_TABLE(of, xway_nand_match);
236 235
237static struct platform_driver xway_nand_driver = { 236static struct platform_driver xway_nand_driver = {
238 .probe = xway_nand_probe, 237 .probe = xway_nand_probe,
@@ -243,6 +242,4 @@ static struct platform_driver xway_nand_driver = {
243 }, 242 },
244}; 243};
245 244
246module_platform_driver(xway_nand_driver); 245builtin_platform_driver(xway_nand_driver);
247
248MODULE_LICENSE("GPL");
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index b8c293373ecc..a306de4318d7 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -190,7 +190,7 @@ static netdev_tx_t ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
190 */ 190 */
191static int ipddp_create(struct ipddp_route *new_rt) 191static int ipddp_create(struct ipddp_route *new_rt)
192{ 192{
193 struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL); 193 struct ipddp_route *rt = kzalloc(sizeof(*rt), GFP_KERNEL);
194 194
195 if (rt == NULL) 195 if (rt == NULL)
196 return -ENOMEM; 196 return -ENOMEM;
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 9ec33b51a0ed..2ce7ae97ac91 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -393,7 +393,7 @@ static int bcm_sf2_sw_mdio_read(struct mii_bus *bus, int addr, int regnum)
393 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) 393 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
394 return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0); 394 return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
395 else 395 else
396 return mdiobus_read(priv->master_mii_bus, addr, regnum); 396 return mdiobus_read_nested(priv->master_mii_bus, addr, regnum);
397} 397}
398 398
399static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, 399static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
@@ -407,7 +407,7 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
407 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) 407 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
408 bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val); 408 bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
409 else 409 else
410 mdiobus_write(priv->master_mii_bus, addr, regnum, val); 410 mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val);
411 411
412 return 0; 412 return 0;
413} 413}
@@ -982,6 +982,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
982 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME; 982 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
983 struct device_node *dn = pdev->dev.of_node; 983 struct device_node *dn = pdev->dev.of_node;
984 struct b53_platform_data *pdata; 984 struct b53_platform_data *pdata;
985 struct dsa_switch_ops *ops;
985 struct bcm_sf2_priv *priv; 986 struct bcm_sf2_priv *priv;
986 struct b53_device *dev; 987 struct b53_device *dev;
987 struct dsa_switch *ds; 988 struct dsa_switch *ds;
@@ -995,6 +996,10 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
995 if (!priv) 996 if (!priv)
996 return -ENOMEM; 997 return -ENOMEM;
997 998
999 ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
1000 if (!ops)
1001 return -ENOMEM;
1002
998 dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv); 1003 dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv);
999 if (!dev) 1004 if (!dev)
1000 return -ENOMEM; 1005 return -ENOMEM;
@@ -1014,6 +1019,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
1014 ds = dev->ds; 1019 ds = dev->ds;
1015 1020
1016 /* Override the parts that are non-standard wrt. normal b53 devices */ 1021 /* Override the parts that are non-standard wrt. normal b53 devices */
1022 memcpy(ops, ds->ops, sizeof(*ops));
1023 ds->ops = ops;
1017 ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol; 1024 ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol;
1018 ds->ops->setup = bcm_sf2_sw_setup; 1025 ds->ops->setup = bcm_sf2_sw_setup;
1019 ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags; 1026 ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 155190db682d..9943629fcbf9 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -539,6 +539,7 @@ static irqreturn_t xgbe_isr(int irq, void *data)
539 } 539 }
540 } 540 }
541 541
542isr_done:
542 /* If there is not a separate AN irq, handle it here */ 543 /* If there is not a separate AN irq, handle it here */
543 if (pdata->dev_irq == pdata->an_irq) 544 if (pdata->dev_irq == pdata->an_irq)
544 pdata->phy_if.an_isr(irq, pdata); 545 pdata->phy_if.an_isr(irq, pdata);
@@ -551,7 +552,6 @@ static irqreturn_t xgbe_isr(int irq, void *data)
551 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq)) 552 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq))
552 pdata->i2c_if.i2c_isr(irq, pdata); 553 pdata->i2c_if.i2c_isr(irq, pdata);
553 554
554isr_done:
555 return IRQ_HANDLED; 555 return IRQ_HANDLED;
556} 556}
557 557
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 25d1eb4933d0..744ed6ddaf37 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -710,11 +710,8 @@ static unsigned int __bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv,
710 unsigned int c_index, last_c_index, last_tx_cn, num_tx_cbs; 710 unsigned int c_index, last_c_index, last_tx_cn, num_tx_cbs;
711 unsigned int pkts_compl = 0, bytes_compl = 0; 711 unsigned int pkts_compl = 0, bytes_compl = 0;
712 struct bcm_sysport_cb *cb; 712 struct bcm_sysport_cb *cb;
713 struct netdev_queue *txq;
714 u32 hw_ind; 713 u32 hw_ind;
715 714
716 txq = netdev_get_tx_queue(ndev, ring->index);
717
718 /* Compute how many descriptors have been processed since last call */ 715 /* Compute how many descriptors have been processed since last call */
719 hw_ind = tdma_readl(priv, TDMA_DESC_RING_PROD_CONS_INDEX(ring->index)); 716 hw_ind = tdma_readl(priv, TDMA_DESC_RING_PROD_CONS_INDEX(ring->index));
720 c_index = (hw_ind >> RING_CONS_INDEX_SHIFT) & RING_CONS_INDEX_MASK; 717 c_index = (hw_ind >> RING_CONS_INDEX_SHIFT) & RING_CONS_INDEX_MASK;
@@ -745,9 +742,6 @@ static unsigned int __bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv,
745 742
746 ring->c_index = c_index; 743 ring->c_index = c_index;
747 744
748 if (netif_tx_queue_stopped(txq) && pkts_compl)
749 netif_tx_wake_queue(txq);
750
751 netif_dbg(priv, tx_done, ndev, 745 netif_dbg(priv, tx_done, ndev,
752 "ring=%d c_index=%d pkts_compl=%d, bytes_compl=%d\n", 746 "ring=%d c_index=%d pkts_compl=%d, bytes_compl=%d\n",
753 ring->index, ring->c_index, pkts_compl, bytes_compl); 747 ring->index, ring->c_index, pkts_compl, bytes_compl);
@@ -759,16 +753,33 @@ static unsigned int __bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv,
759static unsigned int bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv, 753static unsigned int bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv,
760 struct bcm_sysport_tx_ring *ring) 754 struct bcm_sysport_tx_ring *ring)
761{ 755{
756 struct netdev_queue *txq;
762 unsigned int released; 757 unsigned int released;
763 unsigned long flags; 758 unsigned long flags;
764 759
760 txq = netdev_get_tx_queue(priv->netdev, ring->index);
761
765 spin_lock_irqsave(&ring->lock, flags); 762 spin_lock_irqsave(&ring->lock, flags);
766 released = __bcm_sysport_tx_reclaim(priv, ring); 763 released = __bcm_sysport_tx_reclaim(priv, ring);
764 if (released)
765 netif_tx_wake_queue(txq);
766
767 spin_unlock_irqrestore(&ring->lock, flags); 767 spin_unlock_irqrestore(&ring->lock, flags);
768 768
769 return released; 769 return released;
770} 770}
771 771
772/* Locked version of the per-ring TX reclaim, but does not wake the queue */
773static void bcm_sysport_tx_clean(struct bcm_sysport_priv *priv,
774 struct bcm_sysport_tx_ring *ring)
775{
776 unsigned long flags;
777
778 spin_lock_irqsave(&ring->lock, flags);
779 __bcm_sysport_tx_reclaim(priv, ring);
780 spin_unlock_irqrestore(&ring->lock, flags);
781}
782
772static int bcm_sysport_tx_poll(struct napi_struct *napi, int budget) 783static int bcm_sysport_tx_poll(struct napi_struct *napi, int budget)
773{ 784{
774 struct bcm_sysport_tx_ring *ring = 785 struct bcm_sysport_tx_ring *ring =
@@ -1012,15 +1023,6 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
1012 goto out; 1023 goto out;
1013 } 1024 }
1014 1025
1015 /* Insert TSB and checksum infos */
1016 if (priv->tsb_en) {
1017 skb = bcm_sysport_insert_tsb(skb, dev);
1018 if (!skb) {
1019 ret = NETDEV_TX_OK;
1020 goto out;
1021 }
1022 }
1023
1024 /* The Ethernet switch we are interfaced with needs packets to be at 1026 /* The Ethernet switch we are interfaced with needs packets to be at
1025 * least 64 bytes (including FCS) otherwise they will be discarded when 1027 * least 64 bytes (including FCS) otherwise they will be discarded when
1026 * they enter the switch port logic. When Broadcom tags are enabled, we 1028 * they enter the switch port logic. When Broadcom tags are enabled, we
@@ -1028,13 +1030,21 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
1028 * (including FCS and tag) because the length verification is done after 1030 * (including FCS and tag) because the length verification is done after
1029 * the Broadcom tag is stripped off the ingress packet. 1031 * the Broadcom tag is stripped off the ingress packet.
1030 */ 1032 */
1031 if (skb_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) { 1033 if (skb_put_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) {
1032 ret = NETDEV_TX_OK; 1034 ret = NETDEV_TX_OK;
1033 goto out; 1035 goto out;
1034 } 1036 }
1035 1037
1036 skb_len = skb->len < ETH_ZLEN + ENET_BRCM_TAG_LEN ? 1038 /* Insert TSB and checksum infos */
1037 ETH_ZLEN + ENET_BRCM_TAG_LEN : skb->len; 1039 if (priv->tsb_en) {
1040 skb = bcm_sysport_insert_tsb(skb, dev);
1041 if (!skb) {
1042 ret = NETDEV_TX_OK;
1043 goto out;
1044 }
1045 }
1046
1047 skb_len = skb->len;
1038 1048
1039 mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); 1049 mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
1040 if (dma_mapping_error(kdev, mapping)) { 1050 if (dma_mapping_error(kdev, mapping)) {
@@ -1253,7 +1263,7 @@ static void bcm_sysport_fini_tx_ring(struct bcm_sysport_priv *priv,
1253 napi_disable(&ring->napi); 1263 napi_disable(&ring->napi);
1254 netif_napi_del(&ring->napi); 1264 netif_napi_del(&ring->napi);
1255 1265
1256 bcm_sysport_tx_reclaim(priv, ring); 1266 bcm_sysport_tx_clean(priv, ring);
1257 1267
1258 kfree(ring->cbs); 1268 kfree(ring->cbs);
1259 ring->cbs = NULL; 1269 ring->cbs = NULL;
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 185e9e047aa9..ae42de4fdddf 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8720,11 +8720,14 @@ static void tg3_free_consistent(struct tg3 *tp)
8720 tg3_mem_rx_release(tp); 8720 tg3_mem_rx_release(tp);
8721 tg3_mem_tx_release(tp); 8721 tg3_mem_tx_release(tp);
8722 8722
8723 /* Protect tg3_get_stats64() from reading freed tp->hw_stats. */
8724 tg3_full_lock(tp, 0);
8723 if (tp->hw_stats) { 8725 if (tp->hw_stats) {
8724 dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), 8726 dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats),
8725 tp->hw_stats, tp->stats_mapping); 8727 tp->hw_stats, tp->stats_mapping);
8726 tp->hw_stats = NULL; 8728 tp->hw_stats = NULL;
8727 } 8729 }
8730 tg3_full_unlock(tp);
8728} 8731}
8729 8732
8730/* 8733/*
diff --git a/drivers/net/ethernet/cadence/macb_pci.c b/drivers/net/ethernet/cadence/macb_pci.c
index 92be2cd8f817..9906fda76087 100644
--- a/drivers/net/ethernet/cadence/macb_pci.c
+++ b/drivers/net/ethernet/cadence/macb_pci.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * macb_pci.c - Cadence GEM PCI wrapper. 2 * Cadence GEM PCI wrapper.
3 * 3 *
4 * Copyright (C) 2016 Cadence Design Systems - http://www.cadence.com 4 * Copyright (C) 2016 Cadence Design Systems - http://www.cadence.com
5 * 5 *
@@ -45,32 +45,27 @@ static int macb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
45 struct macb_platform_data plat_data; 45 struct macb_platform_data plat_data;
46 struct resource res[2]; 46 struct resource res[2];
47 47
48 /* sanity check */
49 if (!id)
50 return -EINVAL;
51
52 /* enable pci device */ 48 /* enable pci device */
53 err = pci_enable_device(pdev); 49 err = pcim_enable_device(pdev);
54 if (err < 0) { 50 if (err < 0) {
55 dev_err(&pdev->dev, "Enabling PCI device has failed: 0x%04X", 51 dev_err(&pdev->dev, "Enabling PCI device has failed: %d", err);
56 err); 52 return err;
57 return -EACCES;
58 } 53 }
59 54
60 pci_set_master(pdev); 55 pci_set_master(pdev);
61 56
62 /* set up resources */ 57 /* set up resources */
63 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res)); 58 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
64 res[0].start = pdev->resource[0].start; 59 res[0].start = pci_resource_start(pdev, 0);
65 res[0].end = pdev->resource[0].end; 60 res[0].end = pci_resource_end(pdev, 0);
66 res[0].name = PCI_DRIVER_NAME; 61 res[0].name = PCI_DRIVER_NAME;
67 res[0].flags = IORESOURCE_MEM; 62 res[0].flags = IORESOURCE_MEM;
68 res[1].start = pdev->irq; 63 res[1].start = pci_irq_vector(pdev, 0);
69 res[1].name = PCI_DRIVER_NAME; 64 res[1].name = PCI_DRIVER_NAME;
70 res[1].flags = IORESOURCE_IRQ; 65 res[1].flags = IORESOURCE_IRQ;
71 66
72 dev_info(&pdev->dev, "EMAC physical base addr = 0x%p\n", 67 dev_info(&pdev->dev, "EMAC physical base addr: %pa\n",
73 (void *)(uintptr_t)pci_resource_start(pdev, 0)); 68 &res[0].start);
74 69
75 /* set up macb platform data */ 70 /* set up macb platform data */
76 memset(&plat_data, 0, sizeof(plat_data)); 71 memset(&plat_data, 0, sizeof(plat_data));
@@ -100,7 +95,7 @@ static int macb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
100 plat_info.num_res = ARRAY_SIZE(res); 95 plat_info.num_res = ARRAY_SIZE(res);
101 plat_info.data = &plat_data; 96 plat_info.data = &plat_data;
102 plat_info.size_data = sizeof(plat_data); 97 plat_info.size_data = sizeof(plat_data);
103 plat_info.dma_mask = DMA_BIT_MASK(32); 98 plat_info.dma_mask = pdev->dma_mask;
104 99
105 /* register platform device */ 100 /* register platform device */
106 plat_dev = platform_device_register_full(&plat_info); 101 plat_dev = platform_device_register_full(&plat_info);
@@ -120,7 +115,6 @@ err_hclk_register:
120 clk_unregister(plat_data.pclk); 115 clk_unregister(plat_data.pclk);
121 116
122err_pclk_register: 117err_pclk_register:
123 pci_disable_device(pdev);
124 return err; 118 return err;
125} 119}
126 120
@@ -130,7 +124,6 @@ static void macb_remove(struct pci_dev *pdev)
130 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev); 124 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev);
131 125
132 platform_device_unregister(plat_dev); 126 platform_device_unregister(plat_dev);
133 pci_disable_device(pdev);
134 clk_unregister(plat_data->pclk); 127 clk_unregister(plat_data->pclk);
135 clk_unregister(plat_data->hclk); 128 clk_unregister(plat_data->hclk);
136} 129}
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index bbc8bd16cb97..dcbce6cac63e 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -77,7 +77,7 @@ config OCTEON_MGMT_ETHERNET
77config LIQUIDIO_VF 77config LIQUIDIO_VF
78 tristate "Cavium LiquidIO VF support" 78 tristate "Cavium LiquidIO VF support"
79 depends on 64BIT && PCI_MSI 79 depends on 64BIT && PCI_MSI
80 select PTP_1588_CLOCK 80 imply PTP_1588_CLOCK
81 ---help--- 81 ---help---
82 This driver supports Cavium LiquidIO Intelligent Server Adapter 82 This driver supports Cavium LiquidIO Intelligent Server Adapter
83 based on CN23XX chips. 83 based on CN23XX chips.
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 9211c750e064..2f85b64f01fa 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -47,8 +47,9 @@ struct lmac {
47struct bgx { 47struct bgx {
48 u8 bgx_id; 48 u8 bgx_id;
49 struct lmac lmac[MAX_LMAC_PER_BGX]; 49 struct lmac lmac[MAX_LMAC_PER_BGX];
50 int lmac_count; 50 u8 lmac_count;
51 u8 max_lmac; 51 u8 max_lmac;
52 u8 acpi_lmac_idx;
52 void __iomem *reg_base; 53 void __iomem *reg_base;
53 struct pci_dev *pdev; 54 struct pci_dev *pdev;
54 bool is_dlm; 55 bool is_dlm;
@@ -1143,13 +1144,13 @@ static acpi_status bgx_acpi_register_phy(acpi_handle handle,
1143 if (acpi_bus_get_device(handle, &adev)) 1144 if (acpi_bus_get_device(handle, &adev))
1144 goto out; 1145 goto out;
1145 1146
1146 acpi_get_mac_address(dev, adev, bgx->lmac[bgx->lmac_count].mac); 1147 acpi_get_mac_address(dev, adev, bgx->lmac[bgx->acpi_lmac_idx].mac);
1147 1148
1148 SET_NETDEV_DEV(&bgx->lmac[bgx->lmac_count].netdev, dev); 1149 SET_NETDEV_DEV(&bgx->lmac[bgx->acpi_lmac_idx].netdev, dev);
1149 1150
1150 bgx->lmac[bgx->lmac_count].lmacid = bgx->lmac_count; 1151 bgx->lmac[bgx->acpi_lmac_idx].lmacid = bgx->acpi_lmac_idx;
1152 bgx->acpi_lmac_idx++; /* move to next LMAC */
1151out: 1153out:
1152 bgx->lmac_count++;
1153 return AE_OK; 1154 return AE_OK;
1154} 1155}
1155 1156
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
index 0f0de5b63622..d04a6c163445 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
@@ -133,17 +133,15 @@ cxgb_find_route6(struct cxgb4_lld_info *lldi,
133 if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL) 133 if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)
134 fl6.flowi6_oif = sin6_scope_id; 134 fl6.flowi6_oif = sin6_scope_id;
135 dst = ip6_route_output(&init_net, NULL, &fl6); 135 dst = ip6_route_output(&init_net, NULL, &fl6);
136 if (!dst) 136 if (dst->error ||
137 goto out; 137 (!cxgb_our_interface(lldi, get_real_dev,
138 if (!cxgb_our_interface(lldi, get_real_dev, 138 ip6_dst_idev(dst)->dev) &&
139 ip6_dst_idev(dst)->dev) && 139 !(ip6_dst_idev(dst)->dev->flags & IFF_LOOPBACK))) {
140 !(ip6_dst_idev(dst)->dev->flags & IFF_LOOPBACK)) {
141 dst_release(dst); 140 dst_release(dst);
142 dst = NULL; 141 return NULL;
143 } 142 }
144 } 143 }
145 144
146out:
147 return dst; 145 return dst;
148} 146}
149EXPORT_SYMBOL(cxgb_find_route6); 147EXPORT_SYMBOL(cxgb_find_route6);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 0e74529a4209..30e855004c57 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1118,7 +1118,7 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
1118err: 1118err:
1119 mutex_unlock(&adapter->mcc_lock); 1119 mutex_unlock(&adapter->mcc_lock);
1120 1120
1121 if (status == MCC_STATUS_UNAUTHORIZED_REQUEST) 1121 if (base_status(status) == MCC_STATUS_UNAUTHORIZED_REQUEST)
1122 status = -EPERM; 1122 status = -EPERM;
1123 1123
1124 return status; 1124 return status;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 7e1633bf5a22..1a7f8ad7b9c6 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -275,8 +275,7 @@ static int be_dev_mac_add(struct be_adapter *adapter, u8 *mac)
275 275
276 /* Check if mac has already been added as part of uc-list */ 276 /* Check if mac has already been added as part of uc-list */
277 for (i = 0; i < adapter->uc_macs; i++) { 277 for (i = 0; i < adapter->uc_macs; i++) {
278 if (ether_addr_equal((u8 *)&adapter->uc_list[i * ETH_ALEN], 278 if (ether_addr_equal(adapter->uc_list[i].mac, mac)) {
279 mac)) {
280 /* mac already added, skip addition */ 279 /* mac already added, skip addition */
281 adapter->pmac_id[0] = adapter->pmac_id[i + 1]; 280 adapter->pmac_id[0] = adapter->pmac_id[i + 1];
282 return 0; 281 return 0;
@@ -319,6 +318,13 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
319 if (ether_addr_equal(addr->sa_data, adapter->dev_mac)) 318 if (ether_addr_equal(addr->sa_data, adapter->dev_mac))
320 return 0; 319 return 0;
321 320
321 /* BE3 VFs without FILTMGMT privilege are not allowed to set its MAC
322 * address
323 */
324 if (BEx_chip(adapter) && be_virtfn(adapter) &&
325 !check_privilege(adapter, BE_PRIV_FILTMGMT))
326 return -EPERM;
327
322 /* if device is not running, copy MAC to netdev->dev_addr */ 328 /* if device is not running, copy MAC to netdev->dev_addr */
323 if (!netif_running(netdev)) 329 if (!netif_running(netdev))
324 goto done; 330 goto done;
@@ -1655,14 +1661,12 @@ static void be_clear_mc_list(struct be_adapter *adapter)
1655 1661
1656static int be_uc_mac_add(struct be_adapter *adapter, int uc_idx) 1662static int be_uc_mac_add(struct be_adapter *adapter, int uc_idx)
1657{ 1663{
1658 if (ether_addr_equal((u8 *)&adapter->uc_list[uc_idx * ETH_ALEN], 1664 if (ether_addr_equal(adapter->uc_list[uc_idx].mac, adapter->dev_mac)) {
1659 adapter->dev_mac)) {
1660 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0]; 1665 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0];
1661 return 0; 1666 return 0;
1662 } 1667 }
1663 1668
1664 return be_cmd_pmac_add(adapter, 1669 return be_cmd_pmac_add(adapter, adapter->uc_list[uc_idx].mac,
1665 (u8 *)&adapter->uc_list[uc_idx * ETH_ALEN],
1666 adapter->if_handle, 1670 adapter->if_handle,
1667 &adapter->pmac_id[uc_idx + 1], 0); 1671 &adapter->pmac_id[uc_idx + 1], 0);
1668} 1672}
@@ -1698,9 +1702,8 @@ static void be_set_uc_list(struct be_adapter *adapter)
1698 } 1702 }
1699 1703
1700 if (adapter->update_uc_list) { 1704 if (adapter->update_uc_list) {
1701 i = 1; /* First slot is claimed by the Primary MAC */
1702
1703 /* cache the uc-list in adapter array */ 1705 /* cache the uc-list in adapter array */
1706 i = 0;
1704 netdev_for_each_uc_addr(ha, netdev) { 1707 netdev_for_each_uc_addr(ha, netdev) {
1705 ether_addr_copy(adapter->uc_list[i].mac, ha->addr); 1708 ether_addr_copy(adapter->uc_list[i].mac, ha->addr);
1706 i++; 1709 i++;
@@ -3613,7 +3616,11 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
3613 3616
3614static void be_disable_if_filters(struct be_adapter *adapter) 3617static void be_disable_if_filters(struct be_adapter *adapter)
3615{ 3618{
3616 be_dev_mac_del(adapter, adapter->pmac_id[0]); 3619 /* Don't delete MAC on BE3 VFs without FILTMGMT privilege */
3620 if (!BEx_chip(adapter) || !be_virtfn(adapter) ||
3621 check_privilege(adapter, BE_PRIV_FILTMGMT))
3622 be_dev_mac_del(adapter, adapter->pmac_id[0]);
3623
3617 be_clear_uc_list(adapter); 3624 be_clear_uc_list(adapter);
3618 be_clear_mc_list(adapter); 3625 be_clear_mc_list(adapter);
3619 3626
@@ -3766,8 +3773,9 @@ static int be_enable_if_filters(struct be_adapter *adapter)
3766 if (status) 3773 if (status)
3767 return status; 3774 return status;
3768 3775
3769 /* For BE3 VFs, the PF programs the initial MAC address */ 3776 /* Don't add MAC on BE3 VFs without FILTMGMT privilege */
3770 if (!(BEx_chip(adapter) && be_virtfn(adapter))) { 3777 if (!BEx_chip(adapter) || !be_virtfn(adapter) ||
3778 check_privilege(adapter, BE_PRIV_FILTMGMT)) {
3771 status = be_dev_mac_add(adapter, adapter->netdev->dev_addr); 3779 status = be_dev_mac_add(adapter, adapter->netdev->dev_addr);
3772 if (status) 3780 if (status)
3773 return status; 3781 return status;
@@ -5155,7 +5163,9 @@ static netdev_features_t be_features_check(struct sk_buff *skb,
5155 skb->inner_protocol_type != ENCAP_TYPE_ETHER || 5163 skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
5156 skb->inner_protocol != htons(ETH_P_TEB) || 5164 skb->inner_protocol != htons(ETH_P_TEB) ||
5157 skb_inner_mac_header(skb) - skb_transport_header(skb) != 5165 skb_inner_mac_header(skb) - skb_transport_header(skb) !=
5158 sizeof(struct udphdr) + sizeof(struct vxlanhdr)) 5166 sizeof(struct udphdr) + sizeof(struct vxlanhdr) ||
5167 !adapter->vxlan_port ||
5168 udp_hdr(skb)->dest != adapter->vxlan_port)
5159 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 5169 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
5160 5170
5161 return features; 5171 return features;
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 624ba9058dc4..c9b7ad65e563 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -733,6 +733,7 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn; 733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn;
734 734
735 /* Enable Congestion State Change Notifications and CS taildrop */ 735 /* Enable Congestion State Change Notifications and CS taildrop */
736 memset(&initcgr, 0, sizeof(initcgr));
736 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES); 737 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES);
737 initcgr.cgr.cscn_en = QM_CGR_EN; 738 initcgr.cgr.cscn_en = QM_CGR_EN;
738 739
@@ -2291,7 +2292,8 @@ static int dpaa_open(struct net_device *net_dev)
2291 net_dev->phydev = mac_dev->init_phy(net_dev, priv->mac_dev); 2292 net_dev->phydev = mac_dev->init_phy(net_dev, priv->mac_dev);
2292 if (!net_dev->phydev) { 2293 if (!net_dev->phydev) {
2293 netif_err(priv, ifup, net_dev, "init_phy() failed\n"); 2294 netif_err(priv, ifup, net_dev, "init_phy() failed\n");
2294 return -ENODEV; 2295 err = -ENODEV;
2296 goto phy_init_failed;
2295 } 2297 }
2296 2298
2297 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { 2299 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -2314,6 +2316,7 @@ mac_start_failed:
2314 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) 2316 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++)
2315 fman_port_disable(mac_dev->port[i]); 2317 fman_port_disable(mac_dev->port[i]);
2316 2318
2319phy_init_failed:
2317 dpaa_eth_napi_disable(priv); 2320 dpaa_eth_napi_disable(priv);
2318 2321
2319 return err; 2322 return err;
@@ -2420,6 +2423,7 @@ static int dpaa_ingress_cgr_init(struct dpaa_priv *priv)
2420 } 2423 }
2421 2424
2422 /* Enable CS TD, but disable Congestion State Change Notifications. */ 2425 /* Enable CS TD, but disable Congestion State Change Notifications. */
2426 memset(&initcgr, 0, sizeof(initcgr));
2423 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES); 2427 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES);
2424 initcgr.cgr.cscn_en = QM_CGR_EN; 2428 initcgr.cgr.cscn_en = QM_CGR_EN;
2425 cs_th = DPAA_INGRESS_CS_THRESHOLD; 2429 cs_th = DPAA_INGRESS_CS_THRESHOLD;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a761001308dc..1515abaa5ac9 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3962,8 +3962,8 @@ static void igb_clean_rx_ring(struct igb_ring *rx_ring)
3962 PAGE_SIZE, 3962 PAGE_SIZE,
3963 DMA_FROM_DEVICE, 3963 DMA_FROM_DEVICE,
3964 DMA_ATTR_SKIP_CPU_SYNC); 3964 DMA_ATTR_SKIP_CPU_SYNC);
3965 __page_frag_drain(buffer_info->page, 0, 3965 __page_frag_cache_drain(buffer_info->page,
3966 buffer_info->pagecnt_bias); 3966 buffer_info->pagecnt_bias);
3967 3967
3968 buffer_info->page = NULL; 3968 buffer_info->page = NULL;
3969 } 3969 }
@@ -6991,7 +6991,7 @@ static struct sk_buff *igb_fetch_rx_buffer(struct igb_ring *rx_ring,
6991 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, 6991 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma,
6992 PAGE_SIZE, DMA_FROM_DEVICE, 6992 PAGE_SIZE, DMA_FROM_DEVICE,
6993 DMA_ATTR_SKIP_CPU_SYNC); 6993 DMA_ATTR_SKIP_CPU_SYNC);
6994 __page_frag_drain(page, 0, rx_buffer->pagecnt_bias); 6994 __page_frag_cache_drain(page, rx_buffer->pagecnt_bias);
6995 } 6995 }
6996 6996
6997 /* clear contents of rx_buffer */ 6997 /* clear contents of rx_buffer */
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index a849da92f857..6b8635378f1f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -101,13 +101,19 @@ void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn)
101{ 101{
102 struct mlx4_cq *cq; 102 struct mlx4_cq *cq;
103 103
104 rcu_read_lock();
104 cq = radix_tree_lookup(&mlx4_priv(dev)->cq_table.tree, 105 cq = radix_tree_lookup(&mlx4_priv(dev)->cq_table.tree,
105 cqn & (dev->caps.num_cqs - 1)); 106 cqn & (dev->caps.num_cqs - 1));
107 rcu_read_unlock();
108
106 if (!cq) { 109 if (!cq) {
107 mlx4_dbg(dev, "Completion event for bogus CQ %08x\n", cqn); 110 mlx4_dbg(dev, "Completion event for bogus CQ %08x\n", cqn);
108 return; 111 return;
109 } 112 }
110 113
114 /* Acessing the CQ outside of rcu_read_lock is safe, because
115 * the CQ is freed only after interrupt handling is completed.
116 */
111 ++cq->arm_sn; 117 ++cq->arm_sn;
112 118
113 cq->comp(cq); 119 cq->comp(cq);
@@ -118,23 +124,19 @@ void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type)
118 struct mlx4_cq_table *cq_table = &mlx4_priv(dev)->cq_table; 124 struct mlx4_cq_table *cq_table = &mlx4_priv(dev)->cq_table;
119 struct mlx4_cq *cq; 125 struct mlx4_cq *cq;
120 126
121 spin_lock(&cq_table->lock); 127 rcu_read_lock();
122
123 cq = radix_tree_lookup(&cq_table->tree, cqn & (dev->caps.num_cqs - 1)); 128 cq = radix_tree_lookup(&cq_table->tree, cqn & (dev->caps.num_cqs - 1));
124 if (cq) 129 rcu_read_unlock();
125 atomic_inc(&cq->refcount);
126
127 spin_unlock(&cq_table->lock);
128 130
129 if (!cq) { 131 if (!cq) {
130 mlx4_warn(dev, "Async event for bogus CQ %08x\n", cqn); 132 mlx4_dbg(dev, "Async event for bogus CQ %08x\n", cqn);
131 return; 133 return;
132 } 134 }
133 135
136 /* Acessing the CQ outside of rcu_read_lock is safe, because
137 * the CQ is freed only after interrupt handling is completed.
138 */
134 cq->event(cq, event_type); 139 cq->event(cq, event_type);
135
136 if (atomic_dec_and_test(&cq->refcount))
137 complete(&cq->free);
138} 140}
139 141
140static int mlx4_SW2HW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 142static int mlx4_SW2HW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
@@ -301,9 +303,9 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent,
301 if (err) 303 if (err)
302 return err; 304 return err;
303 305
304 spin_lock_irq(&cq_table->lock); 306 spin_lock(&cq_table->lock);
305 err = radix_tree_insert(&cq_table->tree, cq->cqn, cq); 307 err = radix_tree_insert(&cq_table->tree, cq->cqn, cq);
306 spin_unlock_irq(&cq_table->lock); 308 spin_unlock(&cq_table->lock);
307 if (err) 309 if (err)
308 goto err_icm; 310 goto err_icm;
309 311
@@ -349,9 +351,9 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent,
349 return 0; 351 return 0;
350 352
351err_radix: 353err_radix:
352 spin_lock_irq(&cq_table->lock); 354 spin_lock(&cq_table->lock);
353 radix_tree_delete(&cq_table->tree, cq->cqn); 355 radix_tree_delete(&cq_table->tree, cq->cqn);
354 spin_unlock_irq(&cq_table->lock); 356 spin_unlock(&cq_table->lock);
355 357
356err_icm: 358err_icm:
357 mlx4_cq_free_icm(dev, cq->cqn); 359 mlx4_cq_free_icm(dev, cq->cqn);
@@ -370,15 +372,15 @@ void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq)
370 if (err) 372 if (err)
371 mlx4_warn(dev, "HW2SW_CQ failed (%d) for CQN %06x\n", err, cq->cqn); 373 mlx4_warn(dev, "HW2SW_CQ failed (%d) for CQN %06x\n", err, cq->cqn);
372 374
375 spin_lock(&cq_table->lock);
376 radix_tree_delete(&cq_table->tree, cq->cqn);
377 spin_unlock(&cq_table->lock);
378
373 synchronize_irq(priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(cq->vector)].irq); 379 synchronize_irq(priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(cq->vector)].irq);
374 if (priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(cq->vector)].irq != 380 if (priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(cq->vector)].irq !=
375 priv->eq_table.eq[MLX4_EQ_ASYNC].irq) 381 priv->eq_table.eq[MLX4_EQ_ASYNC].irq)
376 synchronize_irq(priv->eq_table.eq[MLX4_EQ_ASYNC].irq); 382 synchronize_irq(priv->eq_table.eq[MLX4_EQ_ASYNC].irq);
377 383
378 spin_lock_irq(&cq_table->lock);
379 radix_tree_delete(&cq_table->tree, cq->cqn);
380 spin_unlock_irq(&cq_table->lock);
381
382 if (atomic_dec_and_test(&cq->refcount)) 384 if (atomic_dec_and_test(&cq->refcount))
383 complete(&cq->free); 385 complete(&cq->free);
384 wait_for_completion(&cq->free); 386 wait_for_completion(&cq->free);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 015198c14fa8..504461a464c5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -245,13 +245,9 @@ static u32 freq_to_shift(u16 freq)
245{ 245{
246 u32 freq_khz = freq * 1000; 246 u32 freq_khz = freq * 1000;
247 u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC; 247 u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC;
248 u64 tmp_rounded = 248 u64 max_val_cycles_rounded = 1ULL << fls64(max_val_cycles - 1);
249 roundup_pow_of_two(max_val_cycles) > max_val_cycles ?
250 roundup_pow_of_two(max_val_cycles) - 1 : UINT_MAX;
251 u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ?
252 max_val_cycles : tmp_rounded;
253 /* calculate max possible multiplier in order to fit in 64bit */ 249 /* calculate max possible multiplier in order to fit in 64bit */
254 u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded); 250 u64 max_mul = div64_u64(ULLONG_MAX, max_val_cycles_rounded);
255 251
256 /* This comes from the reverse of clocksource_khz2mult */ 252 /* This comes from the reverse of clocksource_khz2mult */
257 return ilog2(div_u64(max_mul * freq_khz, 1000000)); 253 return ilog2(div_u64(max_mul * freq_khz, 1000000));
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index edbe200ac2fa..761f8b12399c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1748,8 +1748,11 @@ int mlx4_en_start_port(struct net_device *dev)
1748 /* Process all completions if exist to prevent 1748 /* Process all completions if exist to prevent
1749 * the queues freezing if they are full 1749 * the queues freezing if they are full
1750 */ 1750 */
1751 for (i = 0; i < priv->rx_ring_num; i++) 1751 for (i = 0; i < priv->rx_ring_num; i++) {
1752 local_bh_disable();
1752 napi_schedule(&priv->rx_cq[i]->napi); 1753 napi_schedule(&priv->rx_cq[i]->napi);
1754 local_bh_enable();
1755 }
1753 1756
1754 netif_tx_start_all_queues(dev); 1757 netif_tx_start_all_queues(dev);
1755 netif_device_attach(dev); 1758 netif_device_attach(dev);
@@ -2277,7 +2280,7 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
2277 2280
2278 if (priv->tx_ring_num[TX_XDP] && 2281 if (priv->tx_ring_num[TX_XDP] &&
2279 !mlx4_en_check_xdp_mtu(dev, new_mtu)) 2282 !mlx4_en_check_xdp_mtu(dev, new_mtu))
2280 return -ENOTSUPP; 2283 return -EOPNOTSUPP;
2281 2284
2282 dev->mtu = new_mtu; 2285 dev->mtu = new_mtu;
2283 2286
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 3c37e216bbf3..eac527e25ec9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -445,8 +445,14 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
445 ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn; 445 ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn;
446 446
447 ring->stride = stride; 447 ring->stride = stride;
448 if (ring->stride <= TXBB_SIZE) 448 if (ring->stride <= TXBB_SIZE) {
449 /* Stamp first unused send wqe */
450 __be32 *ptr = (__be32 *)ring->buf;
451 __be32 stamp = cpu_to_be32(1 << STAMP_SHIFT);
452 *ptr = stamp;
453 /* Move pointer to start of rx section */
449 ring->buf += TXBB_SIZE; 454 ring->buf += TXBB_SIZE;
455 }
450 456
451 ring->log_stride = ffs(ring->stride) - 1; 457 ring->log_stride = ffs(ring->stride) - 1;
452 ring->buf_size = ring->size * ring->stride; 458 ring->buf_size = ring->size * ring->stride;
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index cd3638e6fe25..0509996957d9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -554,8 +554,9 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
554 break; 554 break;
555 555
556 case MLX4_EVENT_TYPE_SRQ_LIMIT: 556 case MLX4_EVENT_TYPE_SRQ_LIMIT:
557 mlx4_dbg(dev, "%s: MLX4_EVENT_TYPE_SRQ_LIMIT\n", 557 mlx4_dbg(dev, "%s: MLX4_EVENT_TYPE_SRQ_LIMIT. srq_no=0x%x, eq 0x%x\n",
558 __func__); 558 __func__, be32_to_cpu(eqe->event.srq.srqn),
559 eq->eqn);
559 case MLX4_EVENT_TYPE_SRQ_CATAS_ERROR: 560 case MLX4_EVENT_TYPE_SRQ_CATAS_ERROR:
560 if (mlx4_is_master(dev)) { 561 if (mlx4_is_master(dev)) {
561 /* forward only to slave owning the SRQ */ 562 /* forward only to slave owning the SRQ */
@@ -570,15 +571,19 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
570 eq->eqn, eq->cons_index, ret); 571 eq->eqn, eq->cons_index, ret);
571 break; 572 break;
572 } 573 }
573 mlx4_warn(dev, "%s: slave:%d, srq_no:0x%x, event: %02x(%02x)\n", 574 if (eqe->type ==
574 __func__, slave, 575 MLX4_EVENT_TYPE_SRQ_CATAS_ERROR)
575 be32_to_cpu(eqe->event.srq.srqn), 576 mlx4_warn(dev, "%s: slave:%d, srq_no:0x%x, event: %02x(%02x)\n",
576 eqe->type, eqe->subtype); 577 __func__, slave,
578 be32_to_cpu(eqe->event.srq.srqn),
579 eqe->type, eqe->subtype);
577 580
578 if (!ret && slave != dev->caps.function) { 581 if (!ret && slave != dev->caps.function) {
579 mlx4_warn(dev, "%s: sending event %02x(%02x) to slave:%d\n", 582 if (eqe->type ==
580 __func__, eqe->type, 583 MLX4_EVENT_TYPE_SRQ_CATAS_ERROR)
581 eqe->subtype, slave); 584 mlx4_warn(dev, "%s: sending event %02x(%02x) to slave:%d\n",
585 __func__, eqe->type,
586 eqe->subtype, slave);
582 mlx4_slave_event(dev, slave, eqe); 587 mlx4_slave_event(dev, slave, eqe);
583 break; 588 break;
584 } 589 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
index 2a9dd460a95f..e1f9e7cebf8f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
118 if (!buf) 118 if (!buf)
119 return -ENOMEM; 119 return -ENOMEM;
120 120
121 if (offset_in_page(buf)) {
122 dma_free_coherent(dev, PAGE_SIZE << order,
123 buf, sg_dma_address(mem));
124 return -ENOMEM;
125 }
126
121 sg_set_buf(mem, buf, PAGE_SIZE << order); 127 sg_set_buf(mem, buf, PAGE_SIZE << order);
122 BUG_ON(mem->offset);
123 sg_dma_len(mem) = PAGE_SIZE << order; 128 sg_dma_len(mem) = PAGE_SIZE << order;
124 return 0; 129 return 0;
125} 130}
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 5e7840a7a33b..bffa6f345f2f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -42,6 +42,7 @@
42#include <linux/io-mapping.h> 42#include <linux/io-mapping.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/kmod.h> 44#include <linux/kmod.h>
45#include <linux/etherdevice.h>
45#include <net/devlink.h> 46#include <net/devlink.h>
46 47
47#include <linux/mlx4/device.h> 48#include <linux/mlx4/device.h>
@@ -782,6 +783,23 @@ int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
782} 783}
783EXPORT_SYMBOL(mlx4_is_slave_active); 784EXPORT_SYMBOL(mlx4_is_slave_active);
784 785
786void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
787 struct _rule_hw *eth_header)
788{
789 if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
790 is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
791 struct mlx4_net_trans_rule_hw_eth *eth =
792 (struct mlx4_net_trans_rule_hw_eth *)eth_header;
793 struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
794 bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
795 next_rule->rsvd == 0;
796
797 if (last_rule)
798 ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
799 }
800}
801EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
802
785static void slave_adjust_steering_mode(struct mlx4_dev *dev, 803static void slave_adjust_steering_mode(struct mlx4_dev *dev,
786 struct mlx4_dev_cap *dev_cap, 804 struct mlx4_dev_cap *dev_cap,
787 struct mlx4_init_hca_param *hca_param) 805 struct mlx4_init_hca_param *hca_param)
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index c548beaaf910..1822382212ee 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2980,6 +2980,9 @@ int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
2980 put_res(dev, slave, srqn, RES_SRQ); 2980 put_res(dev, slave, srqn, RES_SRQ);
2981 qp->srq = srq; 2981 qp->srq = srq;
2982 } 2982 }
2983
2984 /* Save param3 for dynamic changes from VST back to VGT */
2985 qp->param3 = qpc->param3;
2983 put_res(dev, slave, rcqn, RES_CQ); 2986 put_res(dev, slave, rcqn, RES_CQ);
2984 put_res(dev, slave, mtt_base, RES_MTT); 2987 put_res(dev, slave, mtt_base, RES_MTT);
2985 res_end_move(dev, slave, RES_QP, qpn); 2988 res_end_move(dev, slave, RES_QP, qpn);
@@ -3772,7 +3775,6 @@ int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave,
3772 int qpn = vhcr->in_modifier & 0x7fffff; 3775 int qpn = vhcr->in_modifier & 0x7fffff;
3773 struct res_qp *qp; 3776 struct res_qp *qp;
3774 u8 orig_sched_queue; 3777 u8 orig_sched_queue;
3775 __be32 orig_param3 = qpc->param3;
3776 u8 orig_vlan_control = qpc->pri_path.vlan_control; 3778 u8 orig_vlan_control = qpc->pri_path.vlan_control;
3777 u8 orig_fvl_rx = qpc->pri_path.fvl_rx; 3779 u8 orig_fvl_rx = qpc->pri_path.fvl_rx;
3778 u8 orig_pri_path_fl = qpc->pri_path.fl; 3780 u8 orig_pri_path_fl = qpc->pri_path.fl;
@@ -3814,7 +3816,6 @@ out:
3814 */ 3816 */
3815 if (!err) { 3817 if (!err) {
3816 qp->sched_queue = orig_sched_queue; 3818 qp->sched_queue = orig_sched_queue;
3817 qp->param3 = orig_param3;
3818 qp->vlan_control = orig_vlan_control; 3819 qp->vlan_control = orig_vlan_control;
3819 qp->fvl_rx = orig_fvl_rx; 3820 qp->fvl_rx = orig_fvl_rx;
3820 qp->pri_path_fl = orig_pri_path_fl; 3821 qp->pri_path_fl = orig_pri_path_fl;
@@ -4164,22 +4165,6 @@ static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header,
4164 return 0; 4165 return 0;
4165} 4166}
4166 4167
4167static void handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
4168 struct _rule_hw *eth_header)
4169{
4170 if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
4171 is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
4172 struct mlx4_net_trans_rule_hw_eth *eth =
4173 (struct mlx4_net_trans_rule_hw_eth *)eth_header;
4174 struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
4175 bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
4176 next_rule->rsvd == 0;
4177
4178 if (last_rule)
4179 ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
4180 }
4181}
4182
4183/* 4168/*
4184 * In case of missing eth header, append eth header with a MAC address 4169 * In case of missing eth header, append eth header with a MAC address
4185 * assigned to the VF. 4170 * assigned to the VF.
@@ -4363,10 +4348,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
4363 header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id)); 4348 header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
4364 4349
4365 if (header_id == MLX4_NET_TRANS_RULE_ID_ETH) 4350 if (header_id == MLX4_NET_TRANS_RULE_ID_ETH)
4366 handle_eth_header_mcast_prio(ctrl, rule_header); 4351 mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
4367
4368 if (slave == dev->caps.function)
4369 goto execute;
4370 4352
4371 switch (header_id) { 4353 switch (header_id) {
4372 case MLX4_NET_TRANS_RULE_ID_ETH: 4354 case MLX4_NET_TRANS_RULE_ID_ETH:
@@ -4394,7 +4376,6 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
4394 goto err_put_qp; 4376 goto err_put_qp;
4395 } 4377 }
4396 4378
4397execute:
4398 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param, 4379 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
4399 vhcr->in_modifier, 0, 4380 vhcr->in_modifier, 0,
4400 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, 4381 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
@@ -4473,6 +4454,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4473 struct res_qp *rqp; 4454 struct res_qp *rqp;
4474 struct res_fs_rule *rrule; 4455 struct res_fs_rule *rrule;
4475 u64 mirr_reg_id; 4456 u64 mirr_reg_id;
4457 int qpn;
4476 4458
4477 if (dev->caps.steering_mode != 4459 if (dev->caps.steering_mode !=
4478 MLX4_STEERING_MODE_DEVICE_MANAGED) 4460 MLX4_STEERING_MODE_DEVICE_MANAGED)
@@ -4489,10 +4471,11 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4489 } 4471 }
4490 mirr_reg_id = rrule->mirr_rule_id; 4472 mirr_reg_id = rrule->mirr_rule_id;
4491 kfree(rrule->mirr_mbox); 4473 kfree(rrule->mirr_mbox);
4474 qpn = rrule->qpn;
4492 4475
4493 /* Release the rule form busy state before removal */ 4476 /* Release the rule form busy state before removal */
4494 put_res(dev, slave, vhcr->in_param, RES_FS_RULE); 4477 put_res(dev, slave, vhcr->in_param, RES_FS_RULE);
4495 err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp); 4478 err = get_res(dev, slave, qpn, RES_QP, &rqp);
4496 if (err) 4479 if (err)
4497 return err; 4480 return err;
4498 4481
@@ -4517,7 +4500,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4517 if (!err) 4500 if (!err)
4518 atomic_dec(&rqp->ref_count); 4501 atomic_dec(&rqp->ref_count);
4519out: 4502out:
4520 put_res(dev, slave, rrule->qpn, RES_QP); 4503 put_res(dev, slave, qpn, RES_QP);
4521 return err; 4504 return err;
4522} 4505}
4523 4506
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 7f6c225666c1..f0b460f47f29 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -723,6 +723,9 @@ static void mlx5e_ets_init(struct mlx5e_priv *priv)
723 int i; 723 int i;
724 struct ieee_ets ets; 724 struct ieee_ets ets;
725 725
726 if (!MLX5_CAP_GEN(priv->mdev, ets))
727 return;
728
726 memset(&ets, 0, sizeof(ets)); 729 memset(&ets, 0, sizeof(ets));
727 ets.ets_cap = mlx5_max_tc(priv->mdev) + 1; 730 ets.ets_cap = mlx5_max_tc(priv->mdev) + 1;
728 for (i = 0; i < ets.ets_cap; i++) { 731 for (i = 0; i < ets.ets_cap; i++) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 352462af8d51..33a399a8b5d5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -171,7 +171,6 @@ static int mlx5e_get_sset_count(struct net_device *dev, int sset)
171 return NUM_SW_COUNTERS + 171 return NUM_SW_COUNTERS +
172 MLX5E_NUM_Q_CNTRS(priv) + 172 MLX5E_NUM_Q_CNTRS(priv) +
173 NUM_VPORT_COUNTERS + NUM_PPORT_COUNTERS + 173 NUM_VPORT_COUNTERS + NUM_PPORT_COUNTERS +
174 NUM_PCIE_COUNTERS +
175 MLX5E_NUM_RQ_STATS(priv) + 174 MLX5E_NUM_RQ_STATS(priv) +
176 MLX5E_NUM_SQ_STATS(priv) + 175 MLX5E_NUM_SQ_STATS(priv) +
177 MLX5E_NUM_PFC_COUNTERS(priv) + 176 MLX5E_NUM_PFC_COUNTERS(priv) +
@@ -219,14 +218,6 @@ static void mlx5e_fill_stats_strings(struct mlx5e_priv *priv, uint8_t *data)
219 strcpy(data + (idx++) * ETH_GSTRING_LEN, 218 strcpy(data + (idx++) * ETH_GSTRING_LEN,
220 pport_2819_stats_desc[i].format); 219 pport_2819_stats_desc[i].format);
221 220
222 for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++)
223 strcpy(data + (idx++) * ETH_GSTRING_LEN,
224 pcie_perf_stats_desc[i].format);
225
226 for (i = 0; i < NUM_PCIE_TAS_COUNTERS; i++)
227 strcpy(data + (idx++) * ETH_GSTRING_LEN,
228 pcie_tas_stats_desc[i].format);
229
230 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { 221 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
231 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) 222 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
232 sprintf(data + (idx++) * ETH_GSTRING_LEN, 223 sprintf(data + (idx++) * ETH_GSTRING_LEN,
@@ -339,14 +330,6 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
339 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.RFC_2819_counters, 330 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.RFC_2819_counters,
340 pport_2819_stats_desc, i); 331 pport_2819_stats_desc, i);
341 332
342 for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++)
343 data[idx++] = MLX5E_READ_CTR32_BE(&priv->stats.pcie.pcie_perf_counters,
344 pcie_perf_stats_desc, i);
345
346 for (i = 0; i < NUM_PCIE_TAS_COUNTERS; i++)
347 data[idx++] = MLX5E_READ_CTR32_BE(&priv->stats.pcie.pcie_tas_counters,
348 pcie_tas_stats_desc, i);
349
350 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { 333 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
351 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) 334 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
352 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[prio], 335 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[prio],
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index 3691451c728c..d088effd7160 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -247,6 +247,7 @@ static int set_flow_attrs(u32 *match_c, u32 *match_v,
247 } 247 }
248 if (fs->flow_type & FLOW_MAC_EXT && 248 if (fs->flow_type & FLOW_MAC_EXT &&
249 !is_zero_ether_addr(fs->m_ext.h_dest)) { 249 !is_zero_ether_addr(fs->m_ext.h_dest)) {
250 mask_spec(fs->m_ext.h_dest, fs->h_ext.h_dest, ETH_ALEN);
250 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, 251 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
251 outer_headers_c, dmac_47_16), 252 outer_headers_c, dmac_47_16),
252 fs->m_ext.h_dest); 253 fs->m_ext.h_dest);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index cbfa38fc72c0..2b7dd315020c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -291,36 +291,12 @@ static void mlx5e_update_q_counter(struct mlx5e_priv *priv)
291 &qcnt->rx_out_of_buffer); 291 &qcnt->rx_out_of_buffer);
292} 292}
293 293
294static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
295{
296 struct mlx5e_pcie_stats *pcie_stats = &priv->stats.pcie;
297 struct mlx5_core_dev *mdev = priv->mdev;
298 int sz = MLX5_ST_SZ_BYTES(mpcnt_reg);
299 void *out;
300 u32 *in;
301
302 in = mlx5_vzalloc(sz);
303 if (!in)
304 return;
305
306 out = pcie_stats->pcie_perf_counters;
307 MLX5_SET(mpcnt_reg, in, grp, MLX5_PCIE_PERFORMANCE_COUNTERS_GROUP);
308 mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
309
310 out = pcie_stats->pcie_tas_counters;
311 MLX5_SET(mpcnt_reg, in, grp, MLX5_PCIE_TIMERS_AND_STATES_COUNTERS_GROUP);
312 mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
313
314 kvfree(in);
315}
316
317void mlx5e_update_stats(struct mlx5e_priv *priv) 294void mlx5e_update_stats(struct mlx5e_priv *priv)
318{ 295{
319 mlx5e_update_q_counter(priv); 296 mlx5e_update_q_counter(priv);
320 mlx5e_update_vport_counters(priv); 297 mlx5e_update_vport_counters(priv);
321 mlx5e_update_pport_counters(priv); 298 mlx5e_update_pport_counters(priv);
322 mlx5e_update_sw_counters(priv); 299 mlx5e_update_sw_counters(priv);
323 mlx5e_update_pcie_counters(priv);
324} 300}
325 301
326void mlx5e_update_stats_work(struct work_struct *work) 302void mlx5e_update_stats_work(struct work_struct *work)
@@ -3699,14 +3675,8 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
3699 3675
3700static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) 3676static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
3701{ 3677{
3702 struct mlx5_core_dev *mdev = priv->mdev;
3703 struct mlx5_eswitch *esw = mdev->priv.eswitch;
3704
3705 mlx5e_vxlan_cleanup(priv); 3678 mlx5e_vxlan_cleanup(priv);
3706 3679
3707 if (MLX5_CAP_GEN(mdev, vport_group_manager))
3708 mlx5_eswitch_unregister_vport_rep(esw, 0);
3709
3710 if (priv->xdp_prog) 3680 if (priv->xdp_prog)
3711 bpf_prog_put(priv->xdp_prog); 3681 bpf_prog_put(priv->xdp_prog);
3712} 3682}
@@ -3805,14 +3775,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3805 3775
3806 mlx5_lag_add(mdev, netdev); 3776 mlx5_lag_add(mdev, netdev);
3807 3777
3808 if (mlx5e_vxlan_allowed(mdev)) {
3809 rtnl_lock();
3810 udp_tunnel_get_rx_info(netdev);
3811 rtnl_unlock();
3812 }
3813
3814 mlx5e_enable_async_events(priv); 3778 mlx5e_enable_async_events(priv);
3815 queue_work(priv->wq, &priv->set_rx_mode_work);
3816 3779
3817 if (MLX5_CAP_GEN(mdev, vport_group_manager)) { 3780 if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
3818 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id); 3781 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
@@ -3822,13 +3785,30 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3822 rep.netdev = netdev; 3785 rep.netdev = netdev;
3823 mlx5_eswitch_register_vport_rep(esw, 0, &rep); 3786 mlx5_eswitch_register_vport_rep(esw, 0, &rep);
3824 } 3787 }
3788
3789 if (netdev->reg_state != NETREG_REGISTERED)
3790 return;
3791
3792 /* Device already registered: sync netdev system state */
3793 if (mlx5e_vxlan_allowed(mdev)) {
3794 rtnl_lock();
3795 udp_tunnel_get_rx_info(netdev);
3796 rtnl_unlock();
3797 }
3798
3799 queue_work(priv->wq, &priv->set_rx_mode_work);
3825} 3800}
3826 3801
3827static void mlx5e_nic_disable(struct mlx5e_priv *priv) 3802static void mlx5e_nic_disable(struct mlx5e_priv *priv)
3828{ 3803{
3804 struct mlx5_core_dev *mdev = priv->mdev;
3805 struct mlx5_eswitch *esw = mdev->priv.eswitch;
3806
3829 queue_work(priv->wq, &priv->set_rx_mode_work); 3807 queue_work(priv->wq, &priv->set_rx_mode_work);
3808 if (MLX5_CAP_GEN(mdev, vport_group_manager))
3809 mlx5_eswitch_unregister_vport_rep(esw, 0);
3830 mlx5e_disable_async_events(priv); 3810 mlx5e_disable_async_events(priv);
3831 mlx5_lag_remove(priv->mdev); 3811 mlx5_lag_remove(mdev);
3832} 3812}
3833 3813
3834static const struct mlx5e_profile mlx5e_nic_profile = { 3814static const struct mlx5e_profile mlx5e_nic_profile = {
@@ -3966,10 +3946,6 @@ void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3966 const struct mlx5e_profile *profile = priv->profile; 3946 const struct mlx5e_profile *profile = priv->profile;
3967 3947
3968 set_bit(MLX5E_STATE_DESTROYING, &priv->state); 3948 set_bit(MLX5E_STATE_DESTROYING, &priv->state);
3969 if (profile->disable)
3970 profile->disable(priv);
3971
3972 flush_workqueue(priv->wq);
3973 3949
3974 rtnl_lock(); 3950 rtnl_lock();
3975 if (netif_running(netdev)) 3951 if (netif_running(netdev))
@@ -3977,6 +3953,10 @@ void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3977 netif_device_detach(netdev); 3953 netif_device_detach(netdev);
3978 rtnl_unlock(); 3954 rtnl_unlock();
3979 3955
3956 if (profile->disable)
3957 profile->disable(priv);
3958 flush_workqueue(priv->wq);
3959
3980 mlx5e_destroy_q_counter(priv); 3960 mlx5e_destroy_q_counter(priv);
3981 profile->cleanup_rx(priv); 3961 profile->cleanup_rx(priv);
3982 mlx5e_close_drop_rq(priv); 3962 mlx5e_close_drop_rq(priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
index 1fffe48a93cc..cbfac06b7ffd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
@@ -109,7 +109,6 @@ static bool mlx5e_am_on_top(struct mlx5e_rx_am *am)
109 switch (am->tune_state) { 109 switch (am->tune_state) {
110 case MLX5E_AM_PARKING_ON_TOP: 110 case MLX5E_AM_PARKING_ON_TOP:
111 case MLX5E_AM_PARKING_TIRED: 111 case MLX5E_AM_PARKING_TIRED:
112 WARN_ONCE(true, "mlx5e_am_on_top: PARKING\n");
113 return true; 112 return true;
114 case MLX5E_AM_GOING_RIGHT: 113 case MLX5E_AM_GOING_RIGHT:
115 return (am->steps_left > 1) && (am->steps_right == 1); 114 return (am->steps_left > 1) && (am->steps_right == 1);
@@ -123,7 +122,6 @@ static void mlx5e_am_turn(struct mlx5e_rx_am *am)
123 switch (am->tune_state) { 122 switch (am->tune_state) {
124 case MLX5E_AM_PARKING_ON_TOP: 123 case MLX5E_AM_PARKING_ON_TOP:
125 case MLX5E_AM_PARKING_TIRED: 124 case MLX5E_AM_PARKING_TIRED:
126 WARN_ONCE(true, "mlx5e_am_turn: PARKING\n");
127 break; 125 break;
128 case MLX5E_AM_GOING_RIGHT: 126 case MLX5E_AM_GOING_RIGHT:
129 am->tune_state = MLX5E_AM_GOING_LEFT; 127 am->tune_state = MLX5E_AM_GOING_LEFT;
@@ -144,7 +142,6 @@ static int mlx5e_am_step(struct mlx5e_rx_am *am)
144 switch (am->tune_state) { 142 switch (am->tune_state) {
145 case MLX5E_AM_PARKING_ON_TOP: 143 case MLX5E_AM_PARKING_ON_TOP:
146 case MLX5E_AM_PARKING_TIRED: 144 case MLX5E_AM_PARKING_TIRED:
147 WARN_ONCE(true, "mlx5e_am_step: PARKING\n");
148 break; 145 break;
149 case MLX5E_AM_GOING_RIGHT: 146 case MLX5E_AM_GOING_RIGHT:
150 if (am->profile_ix == (MLX5E_PARAMS_AM_NUM_PROFILES - 1)) 147 if (am->profile_ix == (MLX5E_PARAMS_AM_NUM_PROFILES - 1))
@@ -282,10 +279,8 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
282 u32 delta_us = ktime_us_delta(end->time, start->time); 279 u32 delta_us = ktime_us_delta(end->time, start->time);
283 unsigned int npkts = end->pkt_ctr - start->pkt_ctr; 280 unsigned int npkts = end->pkt_ctr - start->pkt_ctr;
284 281
285 if (!delta_us) { 282 if (!delta_us)
286 WARN_ONCE(true, "mlx5e_am_calc_stats: delta_us=0\n");
287 return; 283 return;
288 }
289 284
290 curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us; 285 curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us;
291 curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us; 286 curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index f202f872f57f..ba5db1dd23a9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -39,7 +39,7 @@
39#define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \ 39#define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \
40 (*(u32 *)((char *)ptr + dsc[i].offset)) 40 (*(u32 *)((char *)ptr + dsc[i].offset))
41#define MLX5E_READ_CTR32_BE(ptr, dsc, i) \ 41#define MLX5E_READ_CTR32_BE(ptr, dsc, i) \
42 be32_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset)) 42 be64_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
43 43
44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld) 44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld) 45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld)
@@ -276,32 +276,6 @@ static const struct counter_desc pport_per_prio_pfc_stats_desc[] = {
276 { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) }, 276 { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) },
277}; 277};
278 278
279#define PCIE_PERF_OFF(c) \
280 MLX5_BYTE_OFF(mpcnt_reg, counter_set.pcie_perf_cntrs_grp_data_layout.c)
281#define PCIE_PERF_GET(pcie_stats, c) \
282 MLX5_GET(mpcnt_reg, pcie_stats->pcie_perf_counters, \
283 counter_set.pcie_perf_cntrs_grp_data_layout.c)
284#define PCIE_TAS_OFF(c) \
285 MLX5_BYTE_OFF(mpcnt_reg, counter_set.pcie_tas_cntrs_grp_data_layout.c)
286#define PCIE_TAS_GET(pcie_stats, c) \
287 MLX5_GET(mpcnt_reg, pcie_stats->pcie_tas_counters, \
288 counter_set.pcie_tas_cntrs_grp_data_layout.c)
289
290struct mlx5e_pcie_stats {
291 __be64 pcie_perf_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
292 __be64 pcie_tas_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
293};
294
295static const struct counter_desc pcie_perf_stats_desc[] = {
296 { "rx_pci_signal_integrity", PCIE_PERF_OFF(rx_errors) },
297 { "tx_pci_signal_integrity", PCIE_PERF_OFF(tx_errors) },
298};
299
300static const struct counter_desc pcie_tas_stats_desc[] = {
301 { "tx_pci_transport_nonfatal_msg", PCIE_TAS_OFF(non_fatal_err_msg_sent) },
302 { "tx_pci_transport_fatal_msg", PCIE_TAS_OFF(fatal_err_msg_sent) },
303};
304
305struct mlx5e_rq_stats { 279struct mlx5e_rq_stats {
306 u64 packets; 280 u64 packets;
307 u64 bytes; 281 u64 bytes;
@@ -386,8 +360,6 @@ static const struct counter_desc sq_stats_desc[] = {
386#define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc) 360#define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc)
387#define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc) 361#define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc)
388#define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc) 362#define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc)
389#define NUM_PCIE_PERF_COUNTERS ARRAY_SIZE(pcie_perf_stats_desc)
390#define NUM_PCIE_TAS_COUNTERS ARRAY_SIZE(pcie_tas_stats_desc)
391#define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \ 363#define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \
392 ARRAY_SIZE(pport_per_prio_traffic_stats_desc) 364 ARRAY_SIZE(pport_per_prio_traffic_stats_desc)
393#define NUM_PPORT_PER_PRIO_PFC_COUNTERS \ 365#define NUM_PPORT_PER_PRIO_PFC_COUNTERS \
@@ -397,7 +369,6 @@ static const struct counter_desc sq_stats_desc[] = {
397 NUM_PPORT_2819_COUNTERS + \ 369 NUM_PPORT_2819_COUNTERS + \
398 NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \ 370 NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \
399 NUM_PPORT_PRIO) 371 NUM_PPORT_PRIO)
400#define NUM_PCIE_COUNTERS (NUM_PCIE_PERF_COUNTERS + NUM_PCIE_TAS_COUNTERS)
401#define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc) 372#define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc)
402#define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc) 373#define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc)
403 374
@@ -406,7 +377,6 @@ struct mlx5e_stats {
406 struct mlx5e_qcounter_stats qcnt; 377 struct mlx5e_qcounter_stats qcnt;
407 struct mlx5e_vport_stats vport; 378 struct mlx5e_vport_stats vport;
408 struct mlx5e_pport_stats pport; 379 struct mlx5e_pport_stats pport;
409 struct mlx5e_pcie_stats pcie;
410 struct rtnl_link_stats64 vf_vport; 380 struct rtnl_link_stats64 vf_vport;
411}; 381};
412 382
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index f8829b517156..46bef6a26a8c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -161,15 +161,21 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
161 } 161 }
162} 162}
163 163
164/* we get here also when setting rule to the FW failed, etc. It means that the
165 * flow rule itself might not exist, but some offloading related to the actions
166 * should be cleaned.
167 */
164static void mlx5e_tc_del_flow(struct mlx5e_priv *priv, 168static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
165 struct mlx5e_tc_flow *flow) 169 struct mlx5e_tc_flow *flow)
166{ 170{
167 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 171 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
168 struct mlx5_fc *counter = NULL; 172 struct mlx5_fc *counter = NULL;
169 173
170 counter = mlx5_flow_rule_counter(flow->rule); 174 if (!IS_ERR(flow->rule)) {
171 175 counter = mlx5_flow_rule_counter(flow->rule);
172 mlx5_del_flow_rules(flow->rule); 176 mlx5_del_flow_rules(flow->rule);
177 mlx5_fc_destroy(priv->mdev, counter);
178 }
173 179
174 if (esw && esw->mode == SRIOV_OFFLOADS) { 180 if (esw && esw->mode == SRIOV_OFFLOADS) {
175 mlx5_eswitch_del_vlan_action(esw, flow->attr); 181 mlx5_eswitch_del_vlan_action(esw, flow->attr);
@@ -177,8 +183,6 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
177 mlx5e_detach_encap(priv, flow); 183 mlx5e_detach_encap(priv, flow);
178 } 184 }
179 185
180 mlx5_fc_destroy(priv->mdev, counter);
181
182 if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) { 186 if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
183 mlx5_destroy_flow_table(priv->fs.tc.t); 187 mlx5_destroy_flow_table(priv->fs.tc.t);
184 priv->fs.tc.t = NULL; 188 priv->fs.tc.t = NULL;
@@ -225,6 +229,11 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
225 void *headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, 229 void *headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
226 outer_headers); 230 outer_headers);
227 231
232 struct flow_dissector_key_control *enc_control =
233 skb_flow_dissector_target(f->dissector,
234 FLOW_DISSECTOR_KEY_ENC_CONTROL,
235 f->key);
236
228 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ENC_PORTS)) { 237 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ENC_PORTS)) {
229 struct flow_dissector_key_ports *key = 238 struct flow_dissector_key_ports *key =
230 skb_flow_dissector_target(f->dissector, 239 skb_flow_dissector_target(f->dissector,
@@ -237,28 +246,34 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
237 246
238 /* Full udp dst port must be given */ 247 /* Full udp dst port must be given */
239 if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst))) 248 if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
240 return -EOPNOTSUPP; 249 goto vxlan_match_offload_err;
241
242 /* udp src port isn't supported */
243 if (memchr_inv(&mask->src, 0, sizeof(mask->src)))
244 return -EOPNOTSUPP;
245 250
246 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) && 251 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) &&
247 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) 252 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
248 parse_vxlan_attr(spec, f); 253 parse_vxlan_attr(spec, f);
249 else 254 else {
255 netdev_warn(priv->netdev,
256 "%d isn't an offloaded vxlan udp dport\n", be16_to_cpu(key->dst));
250 return -EOPNOTSUPP; 257 return -EOPNOTSUPP;
258 }
251 259
252 MLX5_SET(fte_match_set_lyr_2_4, headers_c, 260 MLX5_SET(fte_match_set_lyr_2_4, headers_c,
253 udp_dport, ntohs(mask->dst)); 261 udp_dport, ntohs(mask->dst));
254 MLX5_SET(fte_match_set_lyr_2_4, headers_v, 262 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
255 udp_dport, ntohs(key->dst)); 263 udp_dport, ntohs(key->dst));
256 264
265 MLX5_SET(fte_match_set_lyr_2_4, headers_c,
266 udp_sport, ntohs(mask->src));
267 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
268 udp_sport, ntohs(key->src));
257 } else { /* udp dst port must be given */ 269 } else { /* udp dst port must be given */
258 return -EOPNOTSUPP; 270vxlan_match_offload_err:
271 netdev_warn(priv->netdev,
272 "IP tunnel decap offload supported only for vxlan, must set UDP dport\n");
273 return -EOPNOTSUPP;
259 } 274 }
260 275
261 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) { 276 if (enc_control->addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
262 struct flow_dissector_key_ipv4_addrs *key = 277 struct flow_dissector_key_ipv4_addrs *key =
263 skb_flow_dissector_target(f->dissector, 278 skb_flow_dissector_target(f->dissector,
264 FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS, 279 FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS,
@@ -280,10 +295,10 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
280 MLX5_SET(fte_match_set_lyr_2_4, headers_v, 295 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
281 dst_ipv4_dst_ipv6.ipv4_layout.ipv4, 296 dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
282 ntohl(key->dst)); 297 ntohl(key->dst));
283 }
284 298
285 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype); 299 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);
286 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IP); 300 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IP);
301 }
287 302
288 /* Enforce DMAC when offloading incoming tunneled flows. 303 /* Enforce DMAC when offloading incoming tunneled flows.
289 * Flow counters require a match on the DMAC. 304 * Flow counters require a match on the DMAC.
@@ -346,6 +361,9 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
346 if (parse_tunnel_attr(priv, spec, f)) 361 if (parse_tunnel_attr(priv, spec, f))
347 return -EOPNOTSUPP; 362 return -EOPNOTSUPP;
348 break; 363 break;
364 case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
365 netdev_warn(priv->netdev,
366 "IPv6 tunnel decap offload isn't supported\n");
349 default: 367 default:
350 return -EOPNOTSUPP; 368 return -EOPNOTSUPP;
351 } 369 }
@@ -375,6 +393,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
375 MLX5_SET(fte_match_set_lyr_2_4, headers_c, frag, 1); 393 MLX5_SET(fte_match_set_lyr_2_4, headers_c, frag, 1);
376 MLX5_SET(fte_match_set_lyr_2_4, headers_v, frag, 394 MLX5_SET(fte_match_set_lyr_2_4, headers_v, frag,
377 key->flags & FLOW_DIS_IS_FRAGMENT); 395 key->flags & FLOW_DIS_IS_FRAGMENT);
396
397 /* the HW doesn't need L3 inline to match on frag=no */
398 if (key->flags & FLOW_DIS_IS_FRAGMENT)
399 *min_inline = MLX5_INLINE_MODE_IP;
378 } 400 }
379 } 401 }
380 402
@@ -646,18 +668,18 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
646 int ttl; 668 int ttl;
647 669
648#if IS_ENABLED(CONFIG_INET) 670#if IS_ENABLED(CONFIG_INET)
671 int ret;
672
649 rt = ip_route_output_key(dev_net(mirred_dev), fl4); 673 rt = ip_route_output_key(dev_net(mirred_dev), fl4);
650 if (IS_ERR(rt)) { 674 ret = PTR_ERR_OR_ZERO(rt);
651 pr_warn("%s: no route to %pI4\n", __func__, &fl4->daddr); 675 if (ret)
652 return -EOPNOTSUPP; 676 return ret;
653 }
654#else 677#else
655 return -EOPNOTSUPP; 678 return -EOPNOTSUPP;
656#endif 679#endif
657 680
658 if (!switchdev_port_same_parent_id(priv->netdev, rt->dst.dev)) { 681 if (!switchdev_port_same_parent_id(priv->netdev, rt->dst.dev)) {
659 pr_warn("%s: Can't offload the flow, netdevices aren't on the same HW e-switch\n", 682 pr_warn("%s: can't offload, devices not on same HW e-switch\n", __func__);
660 __func__);
661 ip_rt_put(rt); 683 ip_rt_put(rt);
662 return -EOPNOTSUPP; 684 return -EOPNOTSUPP;
663 } 685 }
@@ -718,8 +740,8 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
718 struct net_device **out_dev) 740 struct net_device **out_dev)
719{ 741{
720 int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size); 742 int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);
743 struct neighbour *n = NULL;
721 struct flowi4 fl4 = {}; 744 struct flowi4 fl4 = {};
722 struct neighbour *n;
723 char *encap_header; 745 char *encap_header;
724 int encap_size; 746 int encap_size;
725 __be32 saddr; 747 __be32 saddr;
@@ -750,7 +772,8 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
750 e->out_dev = *out_dev; 772 e->out_dev = *out_dev;
751 773
752 if (!(n->nud_state & NUD_VALID)) { 774 if (!(n->nud_state & NUD_VALID)) {
753 err = -ENOTSUPP; 775 pr_warn("%s: can't offload, neighbour to %pI4 invalid\n", __func__, &fl4.daddr);
776 err = -EOPNOTSUPP;
754 goto out; 777 goto out;
755 } 778 }
756 779
@@ -772,6 +795,8 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
772 err = mlx5_encap_alloc(priv->mdev, e->tunnel_type, 795 err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,
773 encap_size, encap_header, &e->encap_id); 796 encap_size, encap_header, &e->encap_id);
774out: 797out:
798 if (err && n)
799 neigh_release(n);
775 kfree(encap_header); 800 kfree(encap_header);
776 return err; 801 return err;
777} 802}
@@ -792,9 +817,17 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
792 int tunnel_type; 817 int tunnel_type;
793 int err; 818 int err;
794 819
795 /* udp dst port must be given */ 820 /* udp dst port must be set */
796 if (!memchr_inv(&key->tp_dst, 0, sizeof(key->tp_dst))) 821 if (!memchr_inv(&key->tp_dst, 0, sizeof(key->tp_dst)))
822 goto vxlan_encap_offload_err;
823
824 /* setting udp src port isn't supported */
825 if (memchr_inv(&key->tp_src, 0, sizeof(key->tp_src))) {
826vxlan_encap_offload_err:
827 netdev_warn(priv->netdev,
828 "must set udp dst port and not set udp src port\n");
797 return -EOPNOTSUPP; 829 return -EOPNOTSUPP;
830 }
798 831
799 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) && 832 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&
800 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) { 833 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
@@ -802,6 +835,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
802 info.tun_id = tunnel_id_to_key32(key->tun_id); 835 info.tun_id = tunnel_id_to_key32(key->tun_id);
803 tunnel_type = MLX5_HEADER_TYPE_VXLAN; 836 tunnel_type = MLX5_HEADER_TYPE_VXLAN;
804 } else { 837 } else {
838 netdev_warn(priv->netdev,
839 "%d isn't an offloaded vxlan udp dport\n", be16_to_cpu(key->tp_dst));
805 return -EOPNOTSUPP; 840 return -EOPNOTSUPP;
806 } 841 }
807 842
@@ -809,6 +844,9 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
809 case AF_INET: 844 case AF_INET:
810 info.daddr = key->u.ipv4.dst; 845 info.daddr = key->u.ipv4.dst;
811 break; 846 break;
847 case AF_INET6:
848 netdev_warn(priv->netdev,
849 "IPv6 tunnel encap offload isn't supported\n");
812 default: 850 default:
813 return -EOPNOTSUPP; 851 return -EOPNOTSUPP;
814 } 852 }
@@ -986,7 +1024,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
986 1024
987 if (IS_ERR(flow->rule)) { 1025 if (IS_ERR(flow->rule)) {
988 err = PTR_ERR(flow->rule); 1026 err = PTR_ERR(flow->rule);
989 goto err_free; 1027 goto err_del_rule;
990 } 1028 }
991 1029
992 err = rhashtable_insert_fast(&tc->ht, &flow->node, 1030 err = rhashtable_insert_fast(&tc->ht, &flow->node,
@@ -997,7 +1035,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
997 goto out; 1035 goto out;
998 1036
999err_del_rule: 1037err_del_rule:
1000 mlx5_del_flow_rules(flow->rule); 1038 mlx5e_tc_del_flow(priv, flow);
1001 1039
1002err_free: 1040err_free:
1003 kfree(flow); 1041 kfree(flow);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index d6807c3cc461..f14d9c9ba773 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1860,7 +1860,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
1860 1860
1861 if (!ESW_ALLOWED(esw)) 1861 if (!ESW_ALLOWED(esw))
1862 return -EPERM; 1862 return -EPERM;
1863 if (!LEGAL_VPORT(esw, vport)) 1863 if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
1864 return -EINVAL; 1864 return -EINVAL;
1865 1865
1866 mutex_lock(&esw->state_lock); 1866 mutex_lock(&esw->state_lock);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 466e161010f7..03293ed1cc22 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -695,6 +695,12 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
695 if (err) 695 if (err)
696 goto err_reps; 696 goto err_reps;
697 } 697 }
698
699 /* disable PF RoCE so missed packets don't go through RoCE steering */
700 mlx5_dev_list_lock();
701 mlx5_remove_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
702 mlx5_dev_list_unlock();
703
698 return 0; 704 return 0;
699 705
700err_reps: 706err_reps:
@@ -718,6 +724,11 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw)
718{ 724{
719 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs; 725 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
720 726
727 /* enable back PF RoCE */
728 mlx5_dev_list_lock();
729 mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
730 mlx5_dev_list_unlock();
731
721 mlx5_eswitch_disable_sriov(esw); 732 mlx5_eswitch_disable_sriov(esw);
722 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY); 733 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
723 if (err) { 734 if (err) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index a263d8904a4c..0ac7a2fc916c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1263,6 +1263,7 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
1263 nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD); 1263 nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD);
1264 handle = add_rule_fte(fte, fg, dest, dest_num, false); 1264 handle = add_rule_fte(fte, fg, dest, dest_num, false);
1265 if (IS_ERR(handle)) { 1265 if (IS_ERR(handle)) {
1266 unlock_ref_node(&fte->node);
1266 kfree(fte); 1267 kfree(fte);
1267 goto unlock_fg; 1268 goto unlock_fg;
1268 } 1269 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 54e5a786f191..d01e9f21d469 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -503,6 +503,13 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
503 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size, 503 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size,
504 to_fw_pkey_sz(dev, 128)); 504 to_fw_pkey_sz(dev, 128));
505 505
506 /* Check log_max_qp from HCA caps to set in current profile */
507 if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) {
508 mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n",
509 profile[prof_sel].log_max_qp,
510 MLX5_CAP_GEN_MAX(dev, log_max_qp));
511 profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
512 }
506 if (prof->mask & MLX5_PROF_MASK_QP_SIZE) 513 if (prof->mask & MLX5_PROF_MASK_QP_SIZE)
507 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp, 514 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
508 prof->log_max_qp); 515 prof->log_max_qp);
@@ -575,7 +582,6 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
575 struct mlx5_priv *priv = &mdev->priv; 582 struct mlx5_priv *priv = &mdev->priv;
576 struct msix_entry *msix = priv->msix_arr; 583 struct msix_entry *msix = priv->msix_arr;
577 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector; 584 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector;
578 int numa_node = priv->numa_node;
579 int err; 585 int err;
580 586
581 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) { 587 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) {
@@ -583,7 +589,7 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
583 return -ENOMEM; 589 return -ENOMEM;
584 } 590 }
585 591
586 cpumask_set_cpu(cpumask_local_spread(i, numa_node), 592 cpumask_set_cpu(cpumask_local_spread(i, priv->numa_node),
587 priv->irq_info[i].mask); 593 priv->irq_info[i].mask);
588 594
589 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask); 595 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask);
@@ -1189,6 +1195,9 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
1189{ 1195{
1190 int err = 0; 1196 int err = 0;
1191 1197
1198 if (cleanup)
1199 mlx5_drain_health_wq(dev);
1200
1192 mutex_lock(&dev->intf_state_mutex); 1201 mutex_lock(&dev->intf_state_mutex);
1193 if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) { 1202 if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) {
1194 dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n", 1203 dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n",
@@ -1351,7 +1360,7 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
1351 1360
1352 mlx5_enter_error_state(dev); 1361 mlx5_enter_error_state(dev);
1353 mlx5_unload_one(dev, priv, false); 1362 mlx5_unload_one(dev, priv, false);
1354 /* In case of kernel call save the pci state and drain health wq */ 1363 /* In case of kernel call save the pci state and drain the health wq */
1355 if (state) { 1364 if (state) {
1356 pci_save_state(pdev); 1365 pci_save_state(pdev);
1357 mlx5_drain_health_wq(dev); 1366 mlx5_drain_health_wq(dev);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h b/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
index d147ddd97997..0af3338bfcb4 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
@@ -209,21 +209,21 @@ MLXSW_ITEM32(pci, eqe, owner, 0x0C, 0, 1);
209/* pci_eqe_cmd_token 209/* pci_eqe_cmd_token
210 * Command completion event - token 210 * Command completion event - token
211 */ 211 */
212MLXSW_ITEM32(pci, eqe, cmd_token, 0x08, 16, 16); 212MLXSW_ITEM32(pci, eqe, cmd_token, 0x00, 16, 16);
213 213
214/* pci_eqe_cmd_status 214/* pci_eqe_cmd_status
215 * Command completion event - status 215 * Command completion event - status
216 */ 216 */
217MLXSW_ITEM32(pci, eqe, cmd_status, 0x08, 0, 8); 217MLXSW_ITEM32(pci, eqe, cmd_status, 0x00, 0, 8);
218 218
219/* pci_eqe_cmd_out_param_h 219/* pci_eqe_cmd_out_param_h
220 * Command completion event - output parameter - higher part 220 * Command completion event - output parameter - higher part
221 */ 221 */
222MLXSW_ITEM32(pci, eqe, cmd_out_param_h, 0x0C, 0, 32); 222MLXSW_ITEM32(pci, eqe, cmd_out_param_h, 0x04, 0, 32);
223 223
224/* pci_eqe_cmd_out_param_l 224/* pci_eqe_cmd_out_param_l
225 * Command completion event - output parameter - lower part 225 * Command completion event - output parameter - lower part
226 */ 226 */
227MLXSW_ITEM32(pci, eqe, cmd_out_param_l, 0x10, 0, 32); 227MLXSW_ITEM32(pci, eqe, cmd_out_param_l, 0x08, 0, 32);
228 228
229#endif 229#endif
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index d768c7b6c6d6..003093abb170 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -684,6 +684,7 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
684 dev_kfree_skb_any(skb_orig); 684 dev_kfree_skb_any(skb_orig);
685 return NETDEV_TX_OK; 685 return NETDEV_TX_OK;
686 } 686 }
687 dev_consume_skb_any(skb_orig);
687 } 688 }
688 689
689 if (eth_skb_pad(skb)) { 690 if (eth_skb_pad(skb)) {
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 150ccf5192a9..2e88115e8735 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -345,6 +345,7 @@ static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb,
345 dev_kfree_skb_any(skb_orig); 345 dev_kfree_skb_any(skb_orig);
346 return NETDEV_TX_OK; 346 return NETDEV_TX_OK;
347 } 347 }
348 dev_consume_skb_any(skb_orig);
348 } 349 }
349 mlxsw_sx_txhdr_construct(skb, &tx_info); 350 mlxsw_sx_txhdr_construct(skb, &tx_info);
350 /* TX header is consumed by HW on the way so we shouldn't count its 351 /* TX header is consumed by HW on the way so we shouldn't count its
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
index 99a14df28b96..2851b4c56570 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
@@ -201,6 +201,13 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
201 else 201 else
202 adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr); 202 adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr);
203 203
204 /* of_phy_find_device() claims a reference to the phydev,
205 * so we do that here manually as well. When the driver
206 * later unloads, it can unilaterally drop the reference
207 * without worrying about ACPI vs DT.
208 */
209 if (adpt->phydev)
210 get_device(&adpt->phydev->mdio.dev);
204 } else { 211 } else {
205 struct device_node *phy_np; 212 struct device_node *phy_np;
206 213
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 422289c232bc..f46d300bd585 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -719,8 +719,7 @@ static int emac_probe(struct platform_device *pdev)
719err_undo_napi: 719err_undo_napi:
720 netif_napi_del(&adpt->rx_q.napi); 720 netif_napi_del(&adpt->rx_q.napi);
721err_undo_mdiobus: 721err_undo_mdiobus:
722 if (!has_acpi_companion(&pdev->dev)) 722 put_device(&adpt->phydev->mdio.dev);
723 put_device(&adpt->phydev->mdio.dev);
724 mdiobus_unregister(adpt->mii_bus); 723 mdiobus_unregister(adpt->mii_bus);
725err_undo_clocks: 724err_undo_clocks:
726 emac_clks_teardown(adpt); 725 emac_clks_teardown(adpt);
@@ -740,8 +739,7 @@ static int emac_remove(struct platform_device *pdev)
740 739
741 emac_clks_teardown(adpt); 740 emac_clks_teardown(adpt);
742 741
743 if (!has_acpi_companion(&pdev->dev)) 742 put_device(&adpt->phydev->mdio.dev);
744 put_device(&adpt->phydev->mdio.dev);
745 mdiobus_unregister(adpt->mii_bus); 743 mdiobus_unregister(adpt->mii_bus);
746 free_netdev(netdev); 744 free_netdev(netdev);
747 745
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 44389c90056a..8f1623bf2134 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -696,7 +696,7 @@ enum rtl_tx_desc_bit_1 {
696enum rtl_rx_desc_bit { 696enum rtl_rx_desc_bit {
697 /* Rx private */ 697 /* Rx private */
698 PID1 = (1 << 18), /* Protocol ID bit 1/2 */ 698 PID1 = (1 << 18), /* Protocol ID bit 1/2 */
699 PID0 = (1 << 17), /* Protocol ID bit 2/2 */ 699 PID0 = (1 << 17), /* Protocol ID bit 0/2 */
700 700
701#define RxProtoUDP (PID1) 701#define RxProtoUDP (PID1)
702#define RxProtoTCP (PID0) 702#define RxProtoTCP (PID0)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 92d7692c840d..89ac1e3f6175 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -926,14 +926,10 @@ static int ravb_poll(struct napi_struct *napi, int budget)
926 /* Receive error message handling */ 926 /* Receive error message handling */
927 priv->rx_over_errors = priv->stats[RAVB_BE].rx_over_errors; 927 priv->rx_over_errors = priv->stats[RAVB_BE].rx_over_errors;
928 priv->rx_over_errors += priv->stats[RAVB_NC].rx_over_errors; 928 priv->rx_over_errors += priv->stats[RAVB_NC].rx_over_errors;
929 if (priv->rx_over_errors != ndev->stats.rx_over_errors) { 929 if (priv->rx_over_errors != ndev->stats.rx_over_errors)
930 ndev->stats.rx_over_errors = priv->rx_over_errors; 930 ndev->stats.rx_over_errors = priv->rx_over_errors;
931 netif_err(priv, rx_err, ndev, "Receive Descriptor Empty\n"); 931 if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors)
932 }
933 if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) {
934 ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; 932 ndev->stats.rx_fifo_errors = priv->rx_fifo_errors;
935 netif_err(priv, rx_err, ndev, "Receive FIFO Overflow\n");
936 }
937out: 933out:
938 return budget - quota; 934 return budget - quota;
939} 935}
@@ -1508,6 +1504,19 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1508 buffer = PTR_ALIGN(priv->tx_align[q], DPTR_ALIGN) + 1504 buffer = PTR_ALIGN(priv->tx_align[q], DPTR_ALIGN) +
1509 entry / NUM_TX_DESC * DPTR_ALIGN; 1505 entry / NUM_TX_DESC * DPTR_ALIGN;
1510 len = PTR_ALIGN(skb->data, DPTR_ALIGN) - skb->data; 1506 len = PTR_ALIGN(skb->data, DPTR_ALIGN) - skb->data;
1507 /* Zero length DMA descriptors are problematic as they seem to
1508 * terminate DMA transfers. Avoid them by simply using a length of
1509 * DPTR_ALIGN (4) when skb data is aligned to DPTR_ALIGN.
1510 *
1511 * As skb is guaranteed to have at least ETH_ZLEN (60) bytes of
1512 * data by the call to skb_put_padto() above this is safe with
1513 * respect to both the length of the first DMA descriptor (len)
1514 * overflowing the available data and the length of the second DMA
1515 * descriptor (skb->len - len) being negative.
1516 */
1517 if (len == 0)
1518 len = DPTR_ALIGN;
1519
1511 memcpy(buffer, skb->data, len); 1520 memcpy(buffer, skb->data, len);
1512 dma_addr = dma_map_single(ndev->dev.parent, buffer, len, DMA_TO_DEVICE); 1521 dma_addr = dma_map_single(ndev->dev.parent, buffer, len, DMA_TO_DEVICE);
1513 if (dma_mapping_error(ndev->dev.parent, dma_addr)) 1522 if (dma_mapping_error(ndev->dev.parent, dma_addr))
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index f341c1bc7001..f729a6b43958 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -574,6 +574,7 @@ static struct sh_eth_cpu_data r8a7740_data = {
574 .rpadir_value = 2 << 16, 574 .rpadir_value = 2 << 16,
575 .no_trimd = 1, 575 .no_trimd = 1,
576 .no_ade = 1, 576 .no_ade = 1,
577 .hw_crc = 1,
577 .tsu = 1, 578 .tsu = 1,
578 .select_mii = 1, 579 .select_mii = 1,
579 .shift_rd0 = 1, 580 .shift_rd0 = 1,
@@ -802,7 +803,7 @@ static struct sh_eth_cpu_data sh7734_data = {
802 803
803 .ecsr_value = ECSR_ICD | ECSR_MPD, 804 .ecsr_value = ECSR_ICD | ECSR_MPD,
804 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, 805 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
805 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, 806 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
806 807
807 .tx_check = EESR_TC1 | EESR_FTC, 808 .tx_check = EESR_TC1 | EESR_FTC,
808 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 809 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
@@ -819,6 +820,7 @@ static struct sh_eth_cpu_data sh7734_data = {
819 .tsu = 1, 820 .tsu = 1,
820 .hw_crc = 1, 821 .hw_crc = 1,
821 .select_mii = 1, 822 .select_mii = 1,
823 .shift_rd0 = 1,
822}; 824};
823 825
824/* SH7763 */ 826/* SH7763 */
@@ -831,7 +833,7 @@ static struct sh_eth_cpu_data sh7763_data = {
831 833
832 .ecsr_value = ECSR_ICD | ECSR_MPD, 834 .ecsr_value = ECSR_ICD | ECSR_MPD,
833 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, 835 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
834 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, 836 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
835 837
836 .tx_check = EESR_TC1 | EESR_FTC, 838 .tx_check = EESR_TC1 | EESR_FTC,
837 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 839 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
@@ -1656,7 +1658,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
1656 else 1658 else
1657 goto out; 1659 goto out;
1658 1660
1659 if (!likely(mdp->irq_enabled)) { 1661 if (unlikely(!mdp->irq_enabled)) {
1660 sh_eth_write(ndev, 0, EESIPR); 1662 sh_eth_write(ndev, 0, EESIPR);
1661 goto out; 1663 goto out;
1662 } 1664 }
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index de2947ccc5ad..5eb0e684fd76 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -1323,7 +1323,8 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
1323 } 1323 }
1324 1324
1325 /* don't fail init if RSS setup doesn't work */ 1325 /* don't fail init if RSS setup doesn't work */
1326 efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table); 1326 rc = efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table);
1327 efx->rss_active = (rc == 0);
1327 1328
1328 return 0; 1329 return 0;
1329} 1330}
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 87bdc56b4e3a..18ebaea44e82 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -975,6 +975,8 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,
975 975
976 case ETHTOOL_GRXFH: { 976 case ETHTOOL_GRXFH: {
977 info->data = 0; 977 info->data = 0;
978 if (!efx->rss_active) /* No RSS */
979 return 0;
978 switch (info->flow_type) { 980 switch (info->flow_type) {
979 case UDP_V4_FLOW: 981 case UDP_V4_FLOW:
980 if (efx->rx_hash_udp_4tuple) 982 if (efx->rx_hash_udp_4tuple)
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index 1a635ced62d0..1c62c1a00fca 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -860,6 +860,7 @@ struct vfdi_status;
860 * @rx_hash_key: Toeplitz hash key for RSS 860 * @rx_hash_key: Toeplitz hash key for RSS
861 * @rx_indir_table: Indirection table for RSS 861 * @rx_indir_table: Indirection table for RSS
862 * @rx_scatter: Scatter mode enabled for receives 862 * @rx_scatter: Scatter mode enabled for receives
863 * @rss_active: RSS enabled on hardware
863 * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled 864 * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled
864 * @int_error_count: Number of internal errors seen recently 865 * @int_error_count: Number of internal errors seen recently
865 * @int_error_expire: Time at which error count will be expired 866 * @int_error_expire: Time at which error count will be expired
@@ -998,6 +999,7 @@ struct efx_nic {
998 u8 rx_hash_key[40]; 999 u8 rx_hash_key[40];
999 u32 rx_indir_table[128]; 1000 u32 rx_indir_table[128];
1000 bool rx_scatter; 1001 bool rx_scatter;
1002 bool rss_active;
1001 bool rx_hash_udp_4tuple; 1003 bool rx_hash_udp_4tuple;
1002 1004
1003 unsigned int_error_count; 1005 unsigned int_error_count;
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
index a3901bc96586..4e54e5dc9fcb 100644
--- a/drivers/net/ethernet/sfc/siena.c
+++ b/drivers/net/ethernet/sfc/siena.c
@@ -403,6 +403,7 @@ static int siena_init_nic(struct efx_nic *efx)
403 efx_writeo(efx, &temp, FR_AZ_RX_CFG); 403 efx_writeo(efx, &temp, FR_AZ_RX_CFG);
404 404
405 siena_rx_push_rss_config(efx, false, efx->rx_indir_table); 405 siena_rx_push_rss_config(efx, false, efx->rx_indir_table);
406 efx->rss_active = true;
406 407
407 /* Enable event logging */ 408 /* Enable event logging */
408 rc = efx_mcdi_log_ctrl(efx, true, false, 0); 409 rc = efx_mcdi_log_ctrl(efx, true, false, 0);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
index c35597586121..3dc7d279f805 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
@@ -60,8 +60,9 @@ struct oxnas_dwmac {
60 struct regmap *regmap; 60 struct regmap *regmap;
61}; 61};
62 62
63static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac) 63static int oxnas_dwmac_init(struct platform_device *pdev, void *priv)
64{ 64{
65 struct oxnas_dwmac *dwmac = priv;
65 unsigned int value; 66 unsigned int value;
66 int ret; 67 int ret;
67 68
@@ -105,20 +106,20 @@ static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
105 return 0; 106 return 0;
106} 107}
107 108
109static void oxnas_dwmac_exit(struct platform_device *pdev, void *priv)
110{
111 struct oxnas_dwmac *dwmac = priv;
112
113 clk_disable_unprepare(dwmac->clk);
114}
115
108static int oxnas_dwmac_probe(struct platform_device *pdev) 116static int oxnas_dwmac_probe(struct platform_device *pdev)
109{ 117{
110 struct plat_stmmacenet_data *plat_dat; 118 struct plat_stmmacenet_data *plat_dat;
111 struct stmmac_resources stmmac_res; 119 struct stmmac_resources stmmac_res;
112 struct device_node *sysctrl;
113 struct oxnas_dwmac *dwmac; 120 struct oxnas_dwmac *dwmac;
114 int ret; 121 int ret;
115 122
116 sysctrl = of_parse_phandle(pdev->dev.of_node, "oxsemi,sys-ctrl", 0);
117 if (!sysctrl) {
118 dev_err(&pdev->dev, "failed to get sys-ctrl node\n");
119 return -EINVAL;
120 }
121
122 ret = stmmac_get_platform_resources(pdev, &stmmac_res); 123 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
123 if (ret) 124 if (ret)
124 return ret; 125 return ret;
@@ -128,72 +129,48 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
128 return PTR_ERR(plat_dat); 129 return PTR_ERR(plat_dat);
129 130
130 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 131 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
131 if (!dwmac) 132 if (!dwmac) {
132 return -ENOMEM; 133 ret = -ENOMEM;
134 goto err_remove_config_dt;
135 }
133 136
134 dwmac->dev = &pdev->dev; 137 dwmac->dev = &pdev->dev;
135 plat_dat->bsp_priv = dwmac; 138 plat_dat->bsp_priv = dwmac;
139 plat_dat->init = oxnas_dwmac_init;
140 plat_dat->exit = oxnas_dwmac_exit;
136 141
137 dwmac->regmap = syscon_node_to_regmap(sysctrl); 142 dwmac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
143 "oxsemi,sys-ctrl");
138 if (IS_ERR(dwmac->regmap)) { 144 if (IS_ERR(dwmac->regmap)) {
139 dev_err(&pdev->dev, "failed to have sysctrl regmap\n"); 145 dev_err(&pdev->dev, "failed to have sysctrl regmap\n");
140 return PTR_ERR(dwmac->regmap); 146 ret = PTR_ERR(dwmac->regmap);
147 goto err_remove_config_dt;
141 } 148 }
142 149
143 dwmac->clk = devm_clk_get(&pdev->dev, "gmac"); 150 dwmac->clk = devm_clk_get(&pdev->dev, "gmac");
144 if (IS_ERR(dwmac->clk)) 151 if (IS_ERR(dwmac->clk)) {
145 return PTR_ERR(dwmac->clk); 152 ret = PTR_ERR(dwmac->clk);
153 goto err_remove_config_dt;
154 }
146 155
147 ret = oxnas_dwmac_init(dwmac); 156 ret = oxnas_dwmac_init(pdev, plat_dat->bsp_priv);
148 if (ret) 157 if (ret)
149 return ret; 158 goto err_remove_config_dt;
150 159
151 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 160 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
152 if (ret) 161 if (ret)
153 clk_disable_unprepare(dwmac->clk); 162 goto err_dwmac_exit;
154 163
155 return ret;
156}
157 164
158static int oxnas_dwmac_remove(struct platform_device *pdev) 165 return 0;
159{
160 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
161 int ret = stmmac_dvr_remove(&pdev->dev);
162
163 clk_disable_unprepare(dwmac->clk);
164
165 return ret;
166}
167
168#ifdef CONFIG_PM_SLEEP
169static int oxnas_dwmac_suspend(struct device *dev)
170{
171 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
172 int ret;
173
174 ret = stmmac_suspend(dev);
175 clk_disable_unprepare(dwmac->clk);
176
177 return ret;
178}
179
180static int oxnas_dwmac_resume(struct device *dev)
181{
182 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
183 int ret;
184
185 ret = oxnas_dwmac_init(dwmac);
186 if (ret)
187 return ret;
188 166
189 ret = stmmac_resume(dev); 167err_dwmac_exit:
168 oxnas_dwmac_exit(pdev, plat_dat->bsp_priv);
169err_remove_config_dt:
170 stmmac_remove_config_dt(pdev, plat_dat);
190 171
191 return ret; 172 return ret;
192} 173}
193#endif /* CONFIG_PM_SLEEP */
194
195static SIMPLE_DEV_PM_OPS(oxnas_dwmac_pm_ops,
196 oxnas_dwmac_suspend, oxnas_dwmac_resume);
197 174
198static const struct of_device_id oxnas_dwmac_match[] = { 175static const struct of_device_id oxnas_dwmac_match[] = {
199 { .compatible = "oxsemi,ox820-dwmac" }, 176 { .compatible = "oxsemi,ox820-dwmac" },
@@ -203,10 +180,10 @@ MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
203 180
204static struct platform_driver oxnas_dwmac_driver = { 181static struct platform_driver oxnas_dwmac_driver = {
205 .probe = oxnas_dwmac_probe, 182 .probe = oxnas_dwmac_probe,
206 .remove = oxnas_dwmac_remove, 183 .remove = stmmac_pltfr_remove,
207 .driver = { 184 .driver = {
208 .name = "oxnas-dwmac", 185 .name = "oxnas-dwmac",
209 .pm = &oxnas_dwmac_pm_ops, 186 .pm = &stmmac_pltfr_pm_ops,
210 .of_match_table = oxnas_dwmac_match, 187 .of_match_table = oxnas_dwmac_match,
211 }, 188 },
212}; 189};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index bb40382e205d..e3f6389e1b01 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3319,8 +3319,16 @@ int stmmac_dvr_probe(struct device *device,
3319 ndev->max_mtu = JUMBO_LEN; 3319 ndev->max_mtu = JUMBO_LEN;
3320 else 3320 else
3321 ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); 3321 ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
3322 if (priv->plat->maxmtu < ndev->max_mtu) 3322 /* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
3323 * as well as plat->maxmtu < ndev->min_mtu which is a invalid range.
3324 */
3325 if ((priv->plat->maxmtu < ndev->max_mtu) &&
3326 (priv->plat->maxmtu >= ndev->min_mtu))
3323 ndev->max_mtu = priv->plat->maxmtu; 3327 ndev->max_mtu = priv->plat->maxmtu;
3328 else if (priv->plat->maxmtu < ndev->min_mtu)
3329 dev_warn(priv->device,
3330 "%s: warning: maxmtu having invalid value (%d)\n",
3331 __func__, priv->plat->maxmtu);
3324 3332
3325 if (flow_ctrl) 3333 if (flow_ctrl)
3326 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ 3334 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */
@@ -3332,20 +3340,14 @@ int stmmac_dvr_probe(struct device *device,
3332 */ 3340 */
3333 if ((priv->synopsys_id >= DWMAC_CORE_3_50) && (!priv->plat->riwt_off)) { 3341 if ((priv->synopsys_id >= DWMAC_CORE_3_50) && (!priv->plat->riwt_off)) {
3334 priv->use_riwt = 1; 3342 priv->use_riwt = 1;
3335 netdev_info(priv->dev, "Enable RX Mitigation via HW Watchdog Timer\n"); 3343 dev_info(priv->device,
3344 "Enable RX Mitigation via HW Watchdog Timer\n");
3336 } 3345 }
3337 3346
3338 netif_napi_add(ndev, &priv->napi, stmmac_poll, 64); 3347 netif_napi_add(ndev, &priv->napi, stmmac_poll, 64);
3339 3348
3340 spin_lock_init(&priv->lock); 3349 spin_lock_init(&priv->lock);
3341 3350
3342 ret = register_netdev(ndev);
3343 if (ret) {
3344 netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
3345 __func__, ret);
3346 goto error_netdev_register;
3347 }
3348
3349 /* If a specific clk_csr value is passed from the platform 3351 /* If a specific clk_csr value is passed from the platform
3350 * this means that the CSR Clock Range selection cannot be 3352 * this means that the CSR Clock Range selection cannot be
3351 * changed at run-time and it is fixed. Viceversa the driver'll try to 3353 * changed at run-time and it is fixed. Viceversa the driver'll try to
@@ -3365,18 +3367,28 @@ int stmmac_dvr_probe(struct device *device,
3365 /* MDIO bus Registration */ 3367 /* MDIO bus Registration */
3366 ret = stmmac_mdio_register(ndev); 3368 ret = stmmac_mdio_register(ndev);
3367 if (ret < 0) { 3369 if (ret < 0) {
3368 netdev_err(priv->dev, 3370 dev_err(priv->device,
3369 "%s: MDIO bus (id: %d) registration failed", 3371 "%s: MDIO bus (id: %d) registration failed",
3370 __func__, priv->plat->bus_id); 3372 __func__, priv->plat->bus_id);
3371 goto error_mdio_register; 3373 goto error_mdio_register;
3372 } 3374 }
3373 } 3375 }
3374 3376
3375 return 0; 3377 ret = register_netdev(ndev);
3378 if (ret) {
3379 dev_err(priv->device, "%s: ERROR %i registering the device\n",
3380 __func__, ret);
3381 goto error_netdev_register;
3382 }
3383
3384 return ret;
3376 3385
3377error_mdio_register:
3378 unregister_netdev(ndev);
3379error_netdev_register: 3386error_netdev_register:
3387 if (priv->hw->pcs != STMMAC_PCS_RGMII &&
3388 priv->hw->pcs != STMMAC_PCS_TBI &&
3389 priv->hw->pcs != STMMAC_PCS_RTBI)
3390 stmmac_mdio_unregister(ndev);
3391error_mdio_register:
3380 netif_napi_del(&priv->napi); 3392 netif_napi_del(&priv->napi);
3381error_hw_init: 3393error_hw_init:
3382 clk_disable_unprepare(priv->pclk); 3394 clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index a2831773431a..3da4737620cb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -89,6 +89,9 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
89 89
90 /* Set default value for unicast filter entries */ 90 /* Set default value for unicast filter entries */
91 plat->unicast_filter_entries = 1; 91 plat->unicast_filter_entries = 1;
92
93 /* Set the maxmtu to a default of JUMBO_LEN */
94 plat->maxmtu = JUMBO_LEN;
92} 95}
93 96
94static int quark_default_data(struct plat_stmmacenet_data *plat, 97static int quark_default_data(struct plat_stmmacenet_data *plat,
@@ -126,6 +129,9 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
126 /* Set default value for unicast filter entries */ 129 /* Set default value for unicast filter entries */
127 plat->unicast_filter_entries = 1; 130 plat->unicast_filter_entries = 1;
128 131
132 /* Set the maxmtu to a default of JUMBO_LEN */
133 plat->maxmtu = JUMBO_LEN;
134
129 return 0; 135 return 0;
130} 136}
131 137
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 77c88fcf2b86..9b8a30bf939b 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1210,7 +1210,7 @@ int cpmac_init(void)
1210 goto fail_alloc; 1210 goto fail_alloc;
1211 } 1211 }
1212 1212
1213#warning FIXME: unhardcode gpio&reset bits 1213 /* FIXME: unhardcode gpio&reset bits */
1214 ar7_gpio_disable(26); 1214 ar7_gpio_disable(26);
1215 ar7_gpio_disable(27); 1215 ar7_gpio_disable(27);
1216 ar7_device_reset(AR7_RESET_BIT_CPMAC_LO); 1216 ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c9414c054852..fcab8019dda0 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -659,6 +659,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
659 * policy filters on the host). Deliver these via the VF 659 * policy filters on the host). Deliver these via the VF
660 * interface in the guest. 660 * interface in the guest.
661 */ 661 */
662 rcu_read_lock();
662 vf_netdev = rcu_dereference(net_device_ctx->vf_netdev); 663 vf_netdev = rcu_dereference(net_device_ctx->vf_netdev);
663 if (vf_netdev && (vf_netdev->flags & IFF_UP)) 664 if (vf_netdev && (vf_netdev->flags & IFF_UP))
664 net = vf_netdev; 665 net = vf_netdev;
@@ -667,6 +668,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
667 skb = netvsc_alloc_recv_skb(net, packet, csum_info, *data, vlan_tci); 668 skb = netvsc_alloc_recv_skb(net, packet, csum_info, *data, vlan_tci);
668 if (unlikely(!skb)) { 669 if (unlikely(!skb)) {
669 ++net->stats.rx_dropped; 670 ++net->stats.rx_dropped;
671 rcu_read_unlock();
670 return NVSP_STAT_FAIL; 672 return NVSP_STAT_FAIL;
671 } 673 }
672 674
@@ -696,6 +698,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
696 * TODO - use NAPI? 698 * TODO - use NAPI?
697 */ 699 */
698 netif_rx(skb); 700 netif_rx(skb);
701 rcu_read_unlock();
699 702
700 return 0; 703 return 0;
701} 704}
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 46d53a6c8cf8..76ba7ecfe142 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1715,9 +1715,9 @@ static int at86rf230_probe(struct spi_device *spi)
1715 /* Reset */ 1715 /* Reset */
1716 if (gpio_is_valid(rstn)) { 1716 if (gpio_is_valid(rstn)) {
1717 udelay(1); 1717 udelay(1);
1718 gpio_set_value(rstn, 0); 1718 gpio_set_value_cansleep(rstn, 0);
1719 udelay(1); 1719 udelay(1);
1720 gpio_set_value(rstn, 1); 1720 gpio_set_value_cansleep(rstn, 1);
1721 usleep_range(120, 240); 1721 usleep_range(120, 240);
1722 } 1722 }
1723 1723
diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 1253f864737a..ef688518ad77 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -117,13 +117,26 @@ static int atusb_read_reg(struct atusb *atusb, uint8_t reg)
117{ 117{
118 struct usb_device *usb_dev = atusb->usb_dev; 118 struct usb_device *usb_dev = atusb->usb_dev;
119 int ret; 119 int ret;
120 uint8_t *buffer;
120 uint8_t value; 121 uint8_t value;
121 122
123 buffer = kmalloc(1, GFP_KERNEL);
124 if (!buffer)
125 return -ENOMEM;
126
122 dev_dbg(&usb_dev->dev, "atusb: reg = 0x%x\n", reg); 127 dev_dbg(&usb_dev->dev, "atusb: reg = 0x%x\n", reg);
123 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), 128 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
124 ATUSB_REG_READ, ATUSB_REQ_FROM_DEV, 129 ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
125 0, reg, &value, 1, 1000); 130 0, reg, buffer, 1, 1000);
126 return ret >= 0 ? value : ret; 131
132 if (ret >= 0) {
133 value = buffer[0];
134 kfree(buffer);
135 return value;
136 } else {
137 kfree(buffer);
138 return ret;
139 }
127} 140}
128 141
129static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask, 142static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask,
@@ -549,13 +562,6 @@ static int
549atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries) 562atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
550{ 563{
551 struct atusb *atusb = hw->priv; 564 struct atusb *atusb = hw->priv;
552 struct device *dev = &atusb->usb_dev->dev;
553
554 if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
555 dev_info(dev, "Automatic frame retransmission is only available from "
556 "firmware version 0.3. Please update if you want this feature.");
557 return -EINVAL;
558 }
559 565
560 return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries); 566 return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
561} 567}
@@ -608,9 +614,13 @@ static const struct ieee802154_ops atusb_ops = {
608static int atusb_get_and_show_revision(struct atusb *atusb) 614static int atusb_get_and_show_revision(struct atusb *atusb)
609{ 615{
610 struct usb_device *usb_dev = atusb->usb_dev; 616 struct usb_device *usb_dev = atusb->usb_dev;
611 unsigned char buffer[3]; 617 unsigned char *buffer;
612 int ret; 618 int ret;
613 619
620 buffer = kmalloc(3, GFP_KERNEL);
621 if (!buffer)
622 return -ENOMEM;
623
614 /* Get a couple of the ATMega Firmware values */ 624 /* Get a couple of the ATMega Firmware values */
615 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), 625 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
616 ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0, 626 ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
@@ -631,15 +641,20 @@ static int atusb_get_and_show_revision(struct atusb *atusb)
631 dev_info(&usb_dev->dev, "Please update to version 0.2 or newer"); 641 dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
632 } 642 }
633 643
644 kfree(buffer);
634 return ret; 645 return ret;
635} 646}
636 647
637static int atusb_get_and_show_build(struct atusb *atusb) 648static int atusb_get_and_show_build(struct atusb *atusb)
638{ 649{
639 struct usb_device *usb_dev = atusb->usb_dev; 650 struct usb_device *usb_dev = atusb->usb_dev;
640 char build[ATUSB_BUILD_SIZE + 1]; 651 char *build;
641 int ret; 652 int ret;
642 653
654 build = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);
655 if (!build)
656 return -ENOMEM;
657
643 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), 658 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
644 ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0, 659 ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
645 build, ATUSB_BUILD_SIZE, 1000); 660 build, ATUSB_BUILD_SIZE, 1000);
@@ -648,6 +663,7 @@ static int atusb_get_and_show_build(struct atusb *atusb)
648 dev_info(&usb_dev->dev, "Firmware: build %s\n", build); 663 dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
649 } 664 }
650 665
666 kfree(build);
651 return ret; 667 return ret;
652} 668}
653 669
@@ -698,7 +714,7 @@ fail:
698static int atusb_set_extended_addr(struct atusb *atusb) 714static int atusb_set_extended_addr(struct atusb *atusb)
699{ 715{
700 struct usb_device *usb_dev = atusb->usb_dev; 716 struct usb_device *usb_dev = atusb->usb_dev;
701 unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN]; 717 unsigned char *buffer;
702 __le64 extended_addr; 718 __le64 extended_addr;
703 u64 addr; 719 u64 addr;
704 int ret; 720 int ret;
@@ -710,12 +726,20 @@ static int atusb_set_extended_addr(struct atusb *atusb)
710 return 0; 726 return 0;
711 } 727 }
712 728
729 buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
730 if (!buffer)
731 return -ENOMEM;
732
713 /* Firmware is new enough so we fetch the address from EEPROM */ 733 /* Firmware is new enough so we fetch the address from EEPROM */
714 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), 734 ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
715 ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0, 735 ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
716 buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000); 736 buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
717 if (ret < 0) 737 if (ret < 0) {
718 dev_err(&usb_dev->dev, "failed to fetch extended address\n"); 738 dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
739 ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
740 kfree(buffer);
741 return ret;
742 }
719 743
720 memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN); 744 memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN);
721 /* Check if read address is not empty and the unicast bit is set correctly */ 745 /* Check if read address is not empty and the unicast bit is set correctly */
@@ -729,6 +753,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
729 &addr); 753 &addr);
730 } 754 }
731 755
756 kfree(buffer);
732 return ret; 757 return ret;
733} 758}
734 759
@@ -770,8 +795,7 @@ static int atusb_probe(struct usb_interface *interface,
770 795
771 hw->parent = &usb_dev->dev; 796 hw->parent = &usb_dev->dev;
772 hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT | 797 hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
773 IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS | 798 IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
774 IEEE802154_HW_FRAME_RETRIES;
775 799
776 hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL | 800 hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL |
777 WPAN_PHY_FLAG_CCA_MODE; 801 WPAN_PHY_FLAG_CCA_MODE;
@@ -800,6 +824,9 @@ static int atusb_probe(struct usb_interface *interface,
800 atusb_get_and_show_build(atusb); 824 atusb_get_and_show_build(atusb);
801 atusb_set_extended_addr(atusb); 825 atusb_set_extended_addr(atusb);
802 826
827 if (atusb->fw_ver_maj >= 0 && atusb->fw_ver_min >= 3)
828 hw->flags |= IEEE802154_HW_FRAME_RETRIES;
829
803 ret = atusb_get_and_clear_error(atusb); 830 ret = atusb_get_and_clear_error(atusb);
804 if (ret) { 831 if (ret) {
805 dev_err(&atusb->usb_dev->dev, 832 dev_err(&atusb->usb_dev->dev,
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d361835b315d..8dbd59baa34d 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -279,6 +279,7 @@ config MARVELL_PHY
279 279
280config MESON_GXL_PHY 280config MESON_GXL_PHY
281 tristate "Amlogic Meson GXL Internal PHY" 281 tristate "Amlogic Meson GXL Internal PHY"
282 depends on ARCH_MESON || COMPILE_TEST
282 ---help--- 283 ---help---
283 Currently has a driver for the Amlogic Meson GXL Internal PHY 284 Currently has a driver for the Amlogic Meson GXL Internal PHY
284 285
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 1b639242f9e2..ca1b462bf7b2 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -29,6 +29,7 @@
29#define MII_DP83867_MICR 0x12 29#define MII_DP83867_MICR 0x12
30#define MII_DP83867_ISR 0x13 30#define MII_DP83867_ISR 0x13
31#define DP83867_CTRL 0x1f 31#define DP83867_CTRL 0x1f
32#define DP83867_CFG3 0x1e
32 33
33/* Extended Registers */ 34/* Extended Registers */
34#define DP83867_RGMIICTL 0x0032 35#define DP83867_RGMIICTL 0x0032
@@ -98,6 +99,8 @@ static int dp83867_config_intr(struct phy_device *phydev)
98 micr_status |= 99 micr_status |=
99 (MII_DP83867_MICR_AN_ERR_INT_EN | 100 (MII_DP83867_MICR_AN_ERR_INT_EN |
100 MII_DP83867_MICR_SPEED_CHNG_INT_EN | 101 MII_DP83867_MICR_SPEED_CHNG_INT_EN |
102 MII_DP83867_MICR_AUTONEG_COMP_INT_EN |
103 MII_DP83867_MICR_LINK_STS_CHNG_INT_EN |
101 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN | 104 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN |
102 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN); 105 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN);
103 106
@@ -129,12 +132,16 @@ static int dp83867_of_init(struct phy_device *phydev)
129 132
130 ret = of_property_read_u32(of_node, "ti,rx-internal-delay", 133 ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
131 &dp83867->rx_id_delay); 134 &dp83867->rx_id_delay);
132 if (ret) 135 if (ret &&
136 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
137 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID))
133 return ret; 138 return ret;
134 139
135 ret = of_property_read_u32(of_node, "ti,tx-internal-delay", 140 ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
136 &dp83867->tx_id_delay); 141 &dp83867->tx_id_delay);
137 if (ret) 142 if (ret &&
143 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
144 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID))
138 return ret; 145 return ret;
139 146
140 return of_property_read_u32(of_node, "ti,fifo-depth", 147 return of_property_read_u32(of_node, "ti,fifo-depth",
@@ -214,6 +221,13 @@ static int dp83867_config_init(struct phy_device *phydev)
214 } 221 }
215 } 222 }
216 223
224 /* Enable Interrupt output INT_OE in CFG3 register */
225 if (phy_interrupt_is_valid(phydev)) {
226 val = phy_read(phydev, DP83867_CFG3);
227 val |= BIT(7);
228 phy_write(phydev, DP83867_CFG3, val);
229 }
230
217 return 0; 231 return 0;
218} 232}
219 233
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index e269262471a4..0b78210c0fa7 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1192,7 +1192,8 @@ static int marvell_read_status(struct phy_device *phydev)
1192 int err; 1192 int err;
1193 1193
1194 /* Check the fiber mode first */ 1194 /* Check the fiber mode first */
1195 if (phydev->supported & SUPPORTED_FIBRE) { 1195 if (phydev->supported & SUPPORTED_FIBRE &&
1196 phydev->interface != PHY_INTERFACE_MODE_SGMII) {
1196 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_FIBER); 1197 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_FIBER);
1197 if (err < 0) 1198 if (err < 0)
1198 goto error; 1199 goto error;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 25f93a98863b..48da6e93c3f7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1065,6 +1065,15 @@ void phy_state_machine(struct work_struct *work)
1065 if (old_link != phydev->link) 1065 if (old_link != phydev->link)
1066 phydev->state = PHY_CHANGELINK; 1066 phydev->state = PHY_CHANGELINK;
1067 } 1067 }
1068 /*
1069 * Failsafe: check that nobody set phydev->link=0 between two
1070 * poll cycles, otherwise we won't leave RUNNING state as long
1071 * as link remains down.
1072 */
1073 if (!phydev->link && phydev->state == PHY_RUNNING) {
1074 phydev->state = PHY_CHANGELINK;
1075 phydev_err(phydev, "no link in PHY_RUNNING\n");
1076 }
1068 break; 1077 break;
1069 case PHY_CHANGELINK: 1078 case PHY_CHANGELINK:
1070 err = phy_read_status(phydev); 1079 err = phy_read_status(phydev);
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 6c646e228833..6e98ede997d3 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -1367,6 +1367,7 @@ static struct usb_driver asix_driver = {
1367 .probe = usbnet_probe, 1367 .probe = usbnet_probe,
1368 .suspend = asix_suspend, 1368 .suspend = asix_suspend,
1369 .resume = asix_resume, 1369 .resume = asix_resume,
1370 .reset_resume = asix_resume,
1370 .disconnect = usbnet_disconnect, 1371 .disconnect = usbnet_disconnect,
1371 .supports_autosuspend = 1, 1372 .supports_autosuspend = 1,
1372 .disable_hub_initiated_lpm = 1, 1373 .disable_hub_initiated_lpm = 1,
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 7dc61228c55b..f3b48ad90865 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1730,7 +1730,7 @@ static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc)
1730 u8 checksum = CHECKSUM_NONE; 1730 u8 checksum = CHECKSUM_NONE;
1731 u32 opts2, opts3; 1731 u32 opts2, opts3;
1732 1732
1733 if (tp->version == RTL_VER_01 || tp->version == RTL_VER_02) 1733 if (!(tp->netdev->features & NETIF_F_RXCSUM))
1734 goto return_result; 1734 goto return_result;
1735 1735
1736 opts2 = le32_to_cpu(rx_desc->opts2); 1736 opts2 = le32_to_cpu(rx_desc->opts2);
@@ -3576,39 +3576,87 @@ static bool delay_autosuspend(struct r8152 *tp)
3576 return false; 3576 return false;
3577} 3577}
3578 3578
3579static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) 3579static int rtl8152_rumtime_suspend(struct r8152 *tp)
3580{ 3580{
3581 struct r8152 *tp = usb_get_intfdata(intf);
3582 struct net_device *netdev = tp->netdev; 3581 struct net_device *netdev = tp->netdev;
3583 int ret = 0; 3582 int ret = 0;
3584 3583
3585 mutex_lock(&tp->control); 3584 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3585 u32 rcr = 0;
3586 3586
3587 if (PMSG_IS_AUTO(message)) { 3587 if (delay_autosuspend(tp)) {
3588 if (netif_running(netdev) && delay_autosuspend(tp)) {
3589 ret = -EBUSY; 3588 ret = -EBUSY;
3590 goto out1; 3589 goto out1;
3591 } 3590 }
3592 3591
3593 set_bit(SELECTIVE_SUSPEND, &tp->flags); 3592 if (netif_carrier_ok(netdev)) {
3594 } else { 3593 u32 ocp_data;
3595 netif_device_detach(netdev); 3594
3595 rcr = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
3596 ocp_data = rcr & ~RCR_ACPT_ALL;
3597 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
3598 rxdy_gated_en(tp, true);
3599 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA,
3600 PLA_OOB_CTRL);
3601 if (!(ocp_data & RXFIFO_EMPTY)) {
3602 rxdy_gated_en(tp, false);
3603 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
3604 ret = -EBUSY;
3605 goto out1;
3606 }
3607 }
3608
3609 clear_bit(WORK_ENABLE, &tp->flags);
3610 usb_kill_urb(tp->intr_urb);
3611
3612 tp->rtl_ops.autosuspend_en(tp, true);
3613
3614 if (netif_carrier_ok(netdev)) {
3615 napi_disable(&tp->napi);
3616 rtl_stop_rx(tp);
3617 rxdy_gated_en(tp, false);
3618 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
3619 napi_enable(&tp->napi);
3620 }
3596 } 3621 }
3597 3622
3623 set_bit(SELECTIVE_SUSPEND, &tp->flags);
3624
3625out1:
3626 return ret;
3627}
3628
3629static int rtl8152_system_suspend(struct r8152 *tp)
3630{
3631 struct net_device *netdev = tp->netdev;
3632 int ret = 0;
3633
3634 netif_device_detach(netdev);
3635
3598 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { 3636 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3599 clear_bit(WORK_ENABLE, &tp->flags); 3637 clear_bit(WORK_ENABLE, &tp->flags);
3600 usb_kill_urb(tp->intr_urb); 3638 usb_kill_urb(tp->intr_urb);
3601 napi_disable(&tp->napi); 3639 napi_disable(&tp->napi);
3602 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3640 cancel_delayed_work_sync(&tp->schedule);
3603 rtl_stop_rx(tp); 3641 tp->rtl_ops.down(tp);
3604 tp->rtl_ops.autosuspend_en(tp, true);
3605 } else {
3606 cancel_delayed_work_sync(&tp->schedule);
3607 tp->rtl_ops.down(tp);
3608 }
3609 napi_enable(&tp->napi); 3642 napi_enable(&tp->napi);
3610 } 3643 }
3611out1: 3644
3645 return ret;
3646}
3647
3648static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3649{
3650 struct r8152 *tp = usb_get_intfdata(intf);
3651 int ret;
3652
3653 mutex_lock(&tp->control);
3654
3655 if (PMSG_IS_AUTO(message))
3656 ret = rtl8152_rumtime_suspend(tp);
3657 else
3658 ret = rtl8152_system_suspend(tp);
3659
3612 mutex_unlock(&tp->control); 3660 mutex_unlock(&tp->control);
3613 3661
3614 return ret; 3662 return ret;
@@ -4308,6 +4356,11 @@ static int rtl8152_probe(struct usb_interface *intf,
4308 NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | 4356 NETIF_F_HIGHDMA | NETIF_F_FRAGLIST |
4309 NETIF_F_IPV6_CSUM | NETIF_F_TSO6; 4357 NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
4310 4358
4359 if (tp->version == RTL_VER_01) {
4360 netdev->features &= ~NETIF_F_RXCSUM;
4361 netdev->hw_features &= ~NETIF_F_RXCSUM;
4362 }
4363
4311 netdev->ethtool_ops = &ops; 4364 netdev->ethtool_ops = &ops;
4312 netif_set_gso_max_size(netdev, RTL_LIMITED_TSO_SIZE); 4365 netif_set_gso_max_size(netdev, RTL_LIMITED_TSO_SIZE);
4313 4366
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 7532646c3b7b..454f907d419a 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -263,7 +263,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
263 .flowi4_iif = LOOPBACK_IFINDEX, 263 .flowi4_iif = LOOPBACK_IFINDEX,
264 .flowi4_tos = RT_TOS(ip4h->tos), 264 .flowi4_tos = RT_TOS(ip4h->tos),
265 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF, 265 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF,
266 .flowi4_proto = ip4h->protocol,
266 .daddr = ip4h->daddr, 267 .daddr = ip4h->daddr,
268 .saddr = ip4h->saddr,
267 }; 269 };
268 struct net *net = dev_net(vrf_dev); 270 struct net *net = dev_net(vrf_dev);
269 struct rtable *rt; 271 struct rtable *rt;
@@ -967,6 +969,7 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
967 */ 969 */
968 need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr); 970 need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr);
969 if (!ipv6_ndisc_frame(skb) && !need_strict) { 971 if (!ipv6_ndisc_frame(skb) && !need_strict) {
972 vrf_rx_stats(vrf_dev, skb->len);
970 skb->dev = vrf_dev; 973 skb->dev = vrf_dev;
971 skb->skb_iif = vrf_dev->ifindex; 974 skb->skb_iif = vrf_dev->ifindex;
972 975
@@ -1011,6 +1014,8 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev,
1011 goto out; 1014 goto out;
1012 } 1015 }
1013 1016
1017 vrf_rx_stats(vrf_dev, skb->len);
1018
1014 skb_push(skb, skb->mac_len); 1019 skb_push(skb, skb->mac_len);
1015 dev_queue_xmit_nit(skb, vrf_dev); 1020 dev_queue_xmit_nit(skb, vrf_dev);
1016 skb_pull(skb, skb->mac_len); 1021 skb_pull(skb, skb->mac_len);
@@ -1247,6 +1252,8 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev,
1247 return -EINVAL; 1252 return -EINVAL;
1248 1253
1249 vrf->tb_id = nla_get_u32(data[IFLA_VRF_TABLE]); 1254 vrf->tb_id = nla_get_u32(data[IFLA_VRF_TABLE]);
1255 if (vrf->tb_id == RT_TABLE_UNSPEC)
1256 return -EINVAL;
1250 1257
1251 dev->priv_flags |= IFF_L3MDEV_MASTER; 1258 dev->priv_flags |= IFF_L3MDEV_MASTER;
1252 1259
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index bb70dd5723b5..ca7196c40060 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1798,7 +1798,7 @@ static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,
1798static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device *dev, 1798static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device *dev,
1799 struct vxlan_sock *sock4, 1799 struct vxlan_sock *sock4,
1800 struct sk_buff *skb, int oif, u8 tos, 1800 struct sk_buff *skb, int oif, u8 tos,
1801 __be32 daddr, __be32 *saddr, 1801 __be32 daddr, __be32 *saddr, __be16 dport, __be16 sport,
1802 struct dst_cache *dst_cache, 1802 struct dst_cache *dst_cache,
1803 const struct ip_tunnel_info *info) 1803 const struct ip_tunnel_info *info)
1804{ 1804{
@@ -1824,6 +1824,8 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device
1824 fl4.flowi4_proto = IPPROTO_UDP; 1824 fl4.flowi4_proto = IPPROTO_UDP;
1825 fl4.daddr = daddr; 1825 fl4.daddr = daddr;
1826 fl4.saddr = *saddr; 1826 fl4.saddr = *saddr;
1827 fl4.fl4_dport = dport;
1828 fl4.fl4_sport = sport;
1827 1829
1828 rt = ip_route_output_key(vxlan->net, &fl4); 1830 rt = ip_route_output_key(vxlan->net, &fl4);
1829 if (likely(!IS_ERR(rt))) { 1831 if (likely(!IS_ERR(rt))) {
@@ -1851,6 +1853,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
1851 __be32 label, 1853 __be32 label,
1852 const struct in6_addr *daddr, 1854 const struct in6_addr *daddr,
1853 struct in6_addr *saddr, 1855 struct in6_addr *saddr,
1856 __be16 dport, __be16 sport,
1854 struct dst_cache *dst_cache, 1857 struct dst_cache *dst_cache,
1855 const struct ip_tunnel_info *info) 1858 const struct ip_tunnel_info *info)
1856{ 1859{
@@ -1877,6 +1880,8 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
1877 fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tos), label); 1880 fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tos), label);
1878 fl6.flowi6_mark = skb->mark; 1881 fl6.flowi6_mark = skb->mark;
1879 fl6.flowi6_proto = IPPROTO_UDP; 1882 fl6.flowi6_proto = IPPROTO_UDP;
1883 fl6.fl6_dport = dport;
1884 fl6.fl6_sport = sport;
1880 1885
1881 err = ipv6_stub->ipv6_dst_lookup(vxlan->net, 1886 err = ipv6_stub->ipv6_dst_lookup(vxlan->net,
1882 sock6->sock->sk, 1887 sock6->sock->sk,
@@ -2068,6 +2073,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2068 rdst ? rdst->remote_ifindex : 0, tos, 2073 rdst ? rdst->remote_ifindex : 0, tos,
2069 dst->sin.sin_addr.s_addr, 2074 dst->sin.sin_addr.s_addr,
2070 &src->sin.sin_addr.s_addr, 2075 &src->sin.sin_addr.s_addr,
2076 dst_port, src_port,
2071 dst_cache, info); 2077 dst_cache, info);
2072 if (IS_ERR(rt)) { 2078 if (IS_ERR(rt)) {
2073 err = PTR_ERR(rt); 2079 err = PTR_ERR(rt);
@@ -2104,6 +2110,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2104 rdst ? rdst->remote_ifindex : 0, tos, 2110 rdst ? rdst->remote_ifindex : 0, tos,
2105 label, &dst->sin6.sin6_addr, 2111 label, &dst->sin6.sin6_addr,
2106 &src->sin6.sin6_addr, 2112 &src->sin6.sin6_addr,
2113 dst_port, src_port,
2107 dst_cache, info); 2114 dst_cache, info);
2108 if (IS_ERR(ndst)) { 2115 if (IS_ERR(ndst)) {
2109 err = PTR_ERR(ndst); 2116 err = PTR_ERR(ndst);
@@ -2430,7 +2437,7 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2430 2437
2431 rt = vxlan_get_route(vxlan, dev, sock4, skb, 0, info->key.tos, 2438 rt = vxlan_get_route(vxlan, dev, sock4, skb, 0, info->key.tos,
2432 info->key.u.ipv4.dst, 2439 info->key.u.ipv4.dst,
2433 &info->key.u.ipv4.src, NULL, info); 2440 &info->key.u.ipv4.src, dport, sport, NULL, info);
2434 if (IS_ERR(rt)) 2441 if (IS_ERR(rt))
2435 return PTR_ERR(rt); 2442 return PTR_ERR(rt);
2436 ip_rt_put(rt); 2443 ip_rt_put(rt);
@@ -2441,7 +2448,7 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2441 2448
2442 ndst = vxlan6_get_route(vxlan, dev, sock6, skb, 0, info->key.tos, 2449 ndst = vxlan6_get_route(vxlan, dev, sock6, skb, 0, info->key.tos,
2443 info->key.label, &info->key.u.ipv6.dst, 2450 info->key.label, &info->key.u.ipv6.dst,
2444 &info->key.u.ipv6.src, NULL, info); 2451 &info->key.u.ipv6.src, dport, sport, NULL, info);
2445 if (IS_ERR(ndst)) 2452 if (IS_ERR(ndst))
2446 return PTR_ERR(ndst); 2453 return PTR_ERR(ndst);
2447 dst_release(ndst); 2454 dst_release(ndst);
diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index b776a0ab106c..9d9b4e0def2a 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -218,7 +218,7 @@ static int slic_ds26522_probe(struct spi_device *spi)
218 218
219 ret = slic_ds26522_init_configure(spi); 219 ret = slic_ds26522_init_configure(spi);
220 if (ret == 0) 220 if (ret == 0)
221 pr_info("DS26522 cs%d configurated\n", spi->chip_select); 221 pr_info("DS26522 cs%d configured\n", spi->chip_select);
222 222
223 return ret; 223 return ret;
224} 224}
diff --git a/drivers/net/wireless/intersil/orinoco/mic.c b/drivers/net/wireless/intersil/orinoco/mic.c
index bc7397d709d3..08bc7822f820 100644
--- a/drivers/net/wireless/intersil/orinoco/mic.c
+++ b/drivers/net/wireless/intersil/orinoco/mic.c
@@ -16,7 +16,7 @@
16/********************************************************************/ 16/********************************************************************/
17int orinoco_mic_init(struct orinoco_private *priv) 17int orinoco_mic_init(struct orinoco_private *priv)
18{ 18{
19 priv->tx_tfm_mic = crypto_alloc_ahash("michael_mic", 0, 19 priv->tx_tfm_mic = crypto_alloc_shash("michael_mic", 0,
20 CRYPTO_ALG_ASYNC); 20 CRYPTO_ALG_ASYNC);
21 if (IS_ERR(priv->tx_tfm_mic)) { 21 if (IS_ERR(priv->tx_tfm_mic)) {
22 printk(KERN_DEBUG "orinoco_mic_init: could not allocate " 22 printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
@@ -25,7 +25,7 @@ int orinoco_mic_init(struct orinoco_private *priv)
25 return -ENOMEM; 25 return -ENOMEM;
26 } 26 }
27 27
28 priv->rx_tfm_mic = crypto_alloc_ahash("michael_mic", 0, 28 priv->rx_tfm_mic = crypto_alloc_shash("michael_mic", 0,
29 CRYPTO_ALG_ASYNC); 29 CRYPTO_ALG_ASYNC);
30 if (IS_ERR(priv->rx_tfm_mic)) { 30 if (IS_ERR(priv->rx_tfm_mic)) {
31 printk(KERN_DEBUG "orinoco_mic_init: could not allocate " 31 printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
@@ -40,17 +40,16 @@ int orinoco_mic_init(struct orinoco_private *priv)
40void orinoco_mic_free(struct orinoco_private *priv) 40void orinoco_mic_free(struct orinoco_private *priv)
41{ 41{
42 if (priv->tx_tfm_mic) 42 if (priv->tx_tfm_mic)
43 crypto_free_ahash(priv->tx_tfm_mic); 43 crypto_free_shash(priv->tx_tfm_mic);
44 if (priv->rx_tfm_mic) 44 if (priv->rx_tfm_mic)
45 crypto_free_ahash(priv->rx_tfm_mic); 45 crypto_free_shash(priv->rx_tfm_mic);
46} 46}
47 47
48int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key, 48int orinoco_mic(struct crypto_shash *tfm_michael, u8 *key,
49 u8 *da, u8 *sa, u8 priority, 49 u8 *da, u8 *sa, u8 priority,
50 u8 *data, size_t data_len, u8 *mic) 50 u8 *data, size_t data_len, u8 *mic)
51{ 51{
52 AHASH_REQUEST_ON_STACK(req, tfm_michael); 52 SHASH_DESC_ON_STACK(desc, tfm_michael);
53 struct scatterlist sg[2];
54 u8 hdr[ETH_HLEN + 2]; /* size of header + padding */ 53 u8 hdr[ETH_HLEN + 2]; /* size of header + padding */
55 int err; 54 int err;
56 55
@@ -67,18 +66,27 @@ int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key,
67 hdr[ETH_ALEN * 2 + 2] = 0; 66 hdr[ETH_ALEN * 2 + 2] = 0;
68 hdr[ETH_ALEN * 2 + 3] = 0; 67 hdr[ETH_ALEN * 2 + 3] = 0;
69 68
70 /* Use scatter gather to MIC header and data in one go */ 69 desc->tfm = tfm_michael;
71 sg_init_table(sg, 2); 70 desc->flags = 0;
72 sg_set_buf(&sg[0], hdr, sizeof(hdr));
73 sg_set_buf(&sg[1], data, data_len);
74 71
75 if (crypto_ahash_setkey(tfm_michael, key, MIC_KEYLEN)) 72 err = crypto_shash_setkey(tfm_michael, key, MIC_KEYLEN);
76 return -1; 73 if (err)
74 return err;
75
76 err = crypto_shash_init(desc);
77 if (err)
78 return err;
79
80 err = crypto_shash_update(desc, hdr, sizeof(hdr));
81 if (err)
82 return err;
83
84 err = crypto_shash_update(desc, data, data_len);
85 if (err)
86 return err;
87
88 err = crypto_shash_final(desc, mic);
89 shash_desc_zero(desc);
77 90
78 ahash_request_set_tfm(req, tfm_michael);
79 ahash_request_set_callback(req, 0, NULL, NULL);
80 ahash_request_set_crypt(req, sg, mic, data_len + sizeof(hdr));
81 err = crypto_ahash_digest(req);
82 ahash_request_zero(req);
83 return err; 91 return err;
84} 92}
diff --git a/drivers/net/wireless/intersil/orinoco/mic.h b/drivers/net/wireless/intersil/orinoco/mic.h
index ce731d05cc98..e8724e889219 100644
--- a/drivers/net/wireless/intersil/orinoco/mic.h
+++ b/drivers/net/wireless/intersil/orinoco/mic.h
@@ -6,6 +6,7 @@
6#define _ORINOCO_MIC_H_ 6#define _ORINOCO_MIC_H_
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9#include <crypto/hash.h>
9 10
10#define MICHAEL_MIC_LEN 8 11#define MICHAEL_MIC_LEN 8
11 12
@@ -15,7 +16,7 @@ struct crypto_ahash;
15 16
16int orinoco_mic_init(struct orinoco_private *priv); 17int orinoco_mic_init(struct orinoco_private *priv);
17void orinoco_mic_free(struct orinoco_private *priv); 18void orinoco_mic_free(struct orinoco_private *priv);
18int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key, 19int orinoco_mic(struct crypto_shash *tfm_michael, u8 *key,
19 u8 *da, u8 *sa, u8 priority, 20 u8 *da, u8 *sa, u8 priority,
20 u8 *data, size_t data_len, u8 *mic); 21 u8 *data, size_t data_len, u8 *mic);
21 22
diff --git a/drivers/net/wireless/intersil/orinoco/orinoco.h b/drivers/net/wireless/intersil/orinoco/orinoco.h
index 2f0c84b1c440..5fa1c3e3713f 100644
--- a/drivers/net/wireless/intersil/orinoco/orinoco.h
+++ b/drivers/net/wireless/intersil/orinoco/orinoco.h
@@ -152,8 +152,8 @@ struct orinoco_private {
152 u8 *wpa_ie; 152 u8 *wpa_ie;
153 int wpa_ie_len; 153 int wpa_ie_len;
154 154
155 struct crypto_ahash *rx_tfm_mic; 155 struct crypto_shash *rx_tfm_mic;
156 struct crypto_ahash *tx_tfm_mic; 156 struct crypto_shash *tx_tfm_mic;
157 157
158 unsigned int wpa_enabled:1; 158 unsigned int wpa_enabled:1;
159 unsigned int tkip_cm_active:1; 159 unsigned int tkip_cm_active:1;
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 0a508649903d..49015b05f3d1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1063,6 +1063,7 @@ int rtl_usb_probe(struct usb_interface *intf,
1063 return -ENOMEM; 1063 return -ENOMEM;
1064 } 1064 }
1065 rtlpriv = hw->priv; 1065 rtlpriv = hw->priv;
1066 rtlpriv->hw = hw;
1066 rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32), 1067 rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
1067 GFP_KERNEL); 1068 GFP_KERNEL);
1068 if (!rtlpriv->usb_data) 1069 if (!rtlpriv->usb_data)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 6307088b375f..a518cb1b59d4 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -957,6 +957,7 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
957{ 957{
958 resource_size_t allocated = 0, available = 0; 958 resource_size_t allocated = 0, available = 0;
959 struct nd_region *nd_region = to_nd_region(dev->parent); 959 struct nd_region *nd_region = to_nd_region(dev->parent);
960 struct nd_namespace_common *ndns = to_ndns(dev);
960 struct nd_mapping *nd_mapping; 961 struct nd_mapping *nd_mapping;
961 struct nvdimm_drvdata *ndd; 962 struct nvdimm_drvdata *ndd;
962 struct nd_label_id label_id; 963 struct nd_label_id label_id;
@@ -964,7 +965,7 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
964 u8 *uuid = NULL; 965 u8 *uuid = NULL;
965 int rc, i; 966 int rc, i;
966 967
967 if (dev->driver || to_ndns(dev)->claim) 968 if (dev->driver || ndns->claim)
968 return -EBUSY; 969 return -EBUSY;
969 970
970 if (is_namespace_pmem(dev)) { 971 if (is_namespace_pmem(dev)) {
@@ -1034,20 +1035,16 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
1034 1035
1035 nd_namespace_pmem_set_resource(nd_region, nspm, 1036 nd_namespace_pmem_set_resource(nd_region, nspm,
1036 val * nd_region->ndr_mappings); 1037 val * nd_region->ndr_mappings);
1037 } else if (is_namespace_blk(dev)) {
1038 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1039
1040 /*
1041 * Try to delete the namespace if we deleted all of its
1042 * allocation, this is not the seed device for the
1043 * region, and it is not actively claimed by a btt
1044 * instance.
1045 */
1046 if (val == 0 && nd_region->ns_seed != dev
1047 && !nsblk->common.claim)
1048 nd_device_unregister(dev, ND_ASYNC);
1049 } 1038 }
1050 1039
1040 /*
1041 * Try to delete the namespace if we deleted all of its
1042 * allocation, this is not the seed device for the region, and
1043 * it is not actively claimed by a btt instance.
1044 */
1045 if (val == 0 && nd_region->ns_seed != dev && !ndns->claim)
1046 nd_device_unregister(dev, ND_ASYNC);
1047
1051 return rc; 1048 return rc;
1052} 1049}
1053 1050
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 7282d7495bf1..5b536be5a12e 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -90,7 +90,9 @@ static int read_pmem(struct page *page, unsigned int off,
90 90
91 rc = memcpy_from_pmem(mem + off, pmem_addr, len); 91 rc = memcpy_from_pmem(mem + off, pmem_addr, len);
92 kunmap_atomic(mem); 92 kunmap_atomic(mem);
93 return rc; 93 if (rc)
94 return -EIO;
95 return 0;
94} 96}
95 97
96static int pmem_do_bvec(struct pmem_device *pmem, struct page *page, 98static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b40cfb076f02..8a3c3e32a704 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1106,12 +1106,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap)
1106 if (ret) 1106 if (ret)
1107 return ret; 1107 return ret;
1108 1108
1109 /* Checking for ctrl->tagset is a trick to avoid sleeping on module 1109 if (ctrl->quirks & NVME_QUIRK_DELAY_BEFORE_CHK_RDY)
1110 * load, since we only need the quirk on reset_controller. Notice
1111 * that the HGST device needs this delay only in firmware activation
1112 * procedure; unfortunately we have no (easy) way to verify this.
1113 */
1114 if ((ctrl->quirks & NVME_QUIRK_DELAY_BEFORE_CHK_RDY) && ctrl->tagset)
1115 msleep(NVME_QUIRK_DELAY_AMOUNT); 1110 msleep(NVME_QUIRK_DELAY_AMOUNT);
1116 1111
1117 return nvme_wait_ready(ctrl, cap, false); 1112 return nvme_wait_ready(ctrl, cap, false);
@@ -1193,8 +1188,8 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
1193 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); 1188 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
1194 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); 1189 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
1195 } 1190 }
1196 if (ctrl->stripe_size) 1191 if (ctrl->quirks & NVME_QUIRK_STRIPE_SIZE)
1197 blk_queue_chunk_sectors(q, ctrl->stripe_size >> 9); 1192 blk_queue_chunk_sectors(q, ctrl->max_hw_sectors);
1198 blk_queue_virt_boundary(q, ctrl->page_size - 1); 1193 blk_queue_virt_boundary(q, ctrl->page_size - 1);
1199 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) 1194 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
1200 vwc = true; 1195 vwc = true;
@@ -1250,19 +1245,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1250 ctrl->max_hw_sectors = 1245 ctrl->max_hw_sectors =
1251 min_not_zero(ctrl->max_hw_sectors, max_hw_sectors); 1246 min_not_zero(ctrl->max_hw_sectors, max_hw_sectors);
1252 1247
1253 if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && id->vs[3]) {
1254 unsigned int max_hw_sectors;
1255
1256 ctrl->stripe_size = 1 << (id->vs[3] + page_shift);
1257 max_hw_sectors = ctrl->stripe_size >> (page_shift - 9);
1258 if (ctrl->max_hw_sectors) {
1259 ctrl->max_hw_sectors = min(max_hw_sectors,
1260 ctrl->max_hw_sectors);
1261 } else {
1262 ctrl->max_hw_sectors = max_hw_sectors;
1263 }
1264 }
1265
1266 nvme_set_queue_limits(ctrl, ctrl->admin_q); 1248 nvme_set_queue_limits(ctrl, ctrl->admin_q);
1267 ctrl->sgls = le32_to_cpu(id->sgls); 1249 ctrl->sgls = le32_to_cpu(id->sgls);
1268 ctrl->kas = le16_to_cpu(id->kas); 1250 ctrl->kas = le16_to_cpu(id->kas);
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 771e2e761872..fcc9dcfdf675 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1491,19 +1491,20 @@ static int
1491nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) 1491nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)
1492{ 1492{
1493 struct nvme_fc_queue *queue = &ctrl->queues[1]; 1493 struct nvme_fc_queue *queue = &ctrl->queues[1];
1494 int i, j, ret; 1494 int i, ret;
1495 1495
1496 for (i = 1; i < ctrl->queue_count; i++, queue++) { 1496 for (i = 1; i < ctrl->queue_count; i++, queue++) {
1497 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); 1497 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize);
1498 if (ret) { 1498 if (ret)
1499 for (j = i-1; j >= 0; j--) 1499 goto delete_queues;
1500 __nvme_fc_delete_hw_queue(ctrl,
1501 &ctrl->queues[j], j);
1502 return ret;
1503 }
1504 } 1500 }
1505 1501
1506 return 0; 1502 return 0;
1503
1504delete_queues:
1505 for (; i >= 0; i--)
1506 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i);
1507 return ret;
1507} 1508}
1508 1509
1509static int 1510static int
@@ -1653,13 +1654,12 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq,
1653 struct nvme_fc_fcp_op *op) 1654 struct nvme_fc_fcp_op *op)
1654{ 1655{
1655 struct nvmefc_fcp_req *freq = &op->fcp_req; 1656 struct nvmefc_fcp_req *freq = &op->fcp_req;
1656 u32 map_len = nvme_map_len(rq);
1657 enum dma_data_direction dir; 1657 enum dma_data_direction dir;
1658 int ret; 1658 int ret;
1659 1659
1660 freq->sg_cnt = 0; 1660 freq->sg_cnt = 0;
1661 1661
1662 if (!map_len) 1662 if (!blk_rq_payload_bytes(rq))
1663 return 0; 1663 return 0;
1664 1664
1665 freq->sg_table.sgl = freq->first_sgl; 1665 freq->sg_table.sgl = freq->first_sgl;
@@ -1853,7 +1853,7 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx,
1853 if (ret) 1853 if (ret)
1854 return ret; 1854 return ret;
1855 1855
1856 data_len = nvme_map_len(rq); 1856 data_len = blk_rq_payload_bytes(rq);
1857 if (data_len) 1857 if (data_len)
1858 io_dir = ((rq_data_dir(rq) == WRITE) ? 1858 io_dir = ((rq_data_dir(rq) == WRITE) ?
1859 NVMEFC_FCP_WRITE : NVMEFC_FCP_READ); 1859 NVMEFC_FCP_WRITE : NVMEFC_FCP_READ);
@@ -2401,8 +2401,8 @@ __nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2401 WARN_ON_ONCE(!changed); 2401 WARN_ON_ONCE(!changed);
2402 2402
2403 dev_info(ctrl->ctrl.device, 2403 dev_info(ctrl->ctrl.device,
2404 "NVME-FC{%d}: new ctrl: NQN \"%s\" (%p)\n", 2404 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n",
2405 ctrl->cnum, ctrl->ctrl.opts->subsysnqn, &ctrl); 2405 ctrl->cnum, ctrl->ctrl.opts->subsysnqn);
2406 2406
2407 kref_get(&ctrl->ctrl.kref); 2407 kref_get(&ctrl->ctrl.kref);
2408 2408
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index bd5321441d12..aead6d08ed2c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -135,7 +135,6 @@ struct nvme_ctrl {
135 135
136 u32 page_size; 136 u32 page_size;
137 u32 max_hw_sectors; 137 u32 max_hw_sectors;
138 u32 stripe_size;
139 u16 oncs; 138 u16 oncs;
140 u16 vid; 139 u16 vid;
141 atomic_t abort_limit; 140 atomic_t abort_limit;
@@ -226,14 +225,6 @@ static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
226 return (sector >> (ns->lba_shift - 9)); 225 return (sector >> (ns->lba_shift - 9));
227} 226}
228 227
229static inline unsigned nvme_map_len(struct request *rq)
230{
231 if (req_op(rq) == REQ_OP_DISCARD)
232 return sizeof(struct nvme_dsm_range);
233 else
234 return blk_rq_bytes(rq);
235}
236
237static inline void nvme_cleanup_cmd(struct request *req) 228static inline void nvme_cleanup_cmd(struct request *req)
238{ 229{
239 if (req->rq_flags & RQF_SPECIAL_PAYLOAD) { 230 if (req->rq_flags & RQF_SPECIAL_PAYLOAD) {
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3d21a154dce7..3faefabf339c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -306,11 +306,11 @@ static __le64 **iod_list(struct request *req)
306 return (__le64 **)(iod->sg + blk_rq_nr_phys_segments(req)); 306 return (__le64 **)(iod->sg + blk_rq_nr_phys_segments(req));
307} 307}
308 308
309static int nvme_init_iod(struct request *rq, unsigned size, 309static int nvme_init_iod(struct request *rq, struct nvme_dev *dev)
310 struct nvme_dev *dev)
311{ 310{
312 struct nvme_iod *iod = blk_mq_rq_to_pdu(rq); 311 struct nvme_iod *iod = blk_mq_rq_to_pdu(rq);
313 int nseg = blk_rq_nr_phys_segments(rq); 312 int nseg = blk_rq_nr_phys_segments(rq);
313 unsigned int size = blk_rq_payload_bytes(rq);
314 314
315 if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) { 315 if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) {
316 iod->sg = kmalloc(nvme_iod_alloc_size(dev, size, nseg), GFP_ATOMIC); 316 iod->sg = kmalloc(nvme_iod_alloc_size(dev, size, nseg), GFP_ATOMIC);
@@ -420,12 +420,11 @@ static void nvme_dif_complete(u32 p, u32 v, struct t10_pi_tuple *pi)
420} 420}
421#endif 421#endif
422 422
423static bool nvme_setup_prps(struct nvme_dev *dev, struct request *req, 423static bool nvme_setup_prps(struct nvme_dev *dev, struct request *req)
424 int total_len)
425{ 424{
426 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 425 struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
427 struct dma_pool *pool; 426 struct dma_pool *pool;
428 int length = total_len; 427 int length = blk_rq_payload_bytes(req);
429 struct scatterlist *sg = iod->sg; 428 struct scatterlist *sg = iod->sg;
430 int dma_len = sg_dma_len(sg); 429 int dma_len = sg_dma_len(sg);
431 u64 dma_addr = sg_dma_address(sg); 430 u64 dma_addr = sg_dma_address(sg);
@@ -501,7 +500,7 @@ static bool nvme_setup_prps(struct nvme_dev *dev, struct request *req,
501} 500}
502 501
503static int nvme_map_data(struct nvme_dev *dev, struct request *req, 502static int nvme_map_data(struct nvme_dev *dev, struct request *req,
504 unsigned size, struct nvme_command *cmnd) 503 struct nvme_command *cmnd)
505{ 504{
506 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 505 struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
507 struct request_queue *q = req->q; 506 struct request_queue *q = req->q;
@@ -519,7 +518,7 @@ static int nvme_map_data(struct nvme_dev *dev, struct request *req,
519 DMA_ATTR_NO_WARN)) 518 DMA_ATTR_NO_WARN))
520 goto out; 519 goto out;
521 520
522 if (!nvme_setup_prps(dev, req, size)) 521 if (!nvme_setup_prps(dev, req))
523 goto out_unmap; 522 goto out_unmap;
524 523
525 ret = BLK_MQ_RQ_QUEUE_ERROR; 524 ret = BLK_MQ_RQ_QUEUE_ERROR;
@@ -580,7 +579,6 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
580 struct nvme_dev *dev = nvmeq->dev; 579 struct nvme_dev *dev = nvmeq->dev;
581 struct request *req = bd->rq; 580 struct request *req = bd->rq;
582 struct nvme_command cmnd; 581 struct nvme_command cmnd;
583 unsigned map_len;
584 int ret = BLK_MQ_RQ_QUEUE_OK; 582 int ret = BLK_MQ_RQ_QUEUE_OK;
585 583
586 /* 584 /*
@@ -600,13 +598,12 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
600 if (ret != BLK_MQ_RQ_QUEUE_OK) 598 if (ret != BLK_MQ_RQ_QUEUE_OK)
601 return ret; 599 return ret;
602 600
603 map_len = nvme_map_len(req); 601 ret = nvme_init_iod(req, dev);
604 ret = nvme_init_iod(req, map_len, dev);
605 if (ret != BLK_MQ_RQ_QUEUE_OK) 602 if (ret != BLK_MQ_RQ_QUEUE_OK)
606 goto out_free_cmd; 603 goto out_free_cmd;
607 604
608 if (blk_rq_nr_phys_segments(req)) 605 if (blk_rq_nr_phys_segments(req))
609 ret = nvme_map_data(dev, req, map_len, &cmnd); 606 ret = nvme_map_data(dev, req, &cmnd);
610 607
611 if (ret != BLK_MQ_RQ_QUEUE_OK) 608 if (ret != BLK_MQ_RQ_QUEUE_OK)
612 goto out_cleanup_iod; 609 goto out_cleanup_iod;
@@ -712,15 +709,8 @@ static void __nvme_process_cq(struct nvme_queue *nvmeq, unsigned int *tag)
712 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe.command_id); 709 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe.command_id);
713 nvme_req(req)->result = cqe.result; 710 nvme_req(req)->result = cqe.result;
714 blk_mq_complete_request(req, le16_to_cpu(cqe.status) >> 1); 711 blk_mq_complete_request(req, le16_to_cpu(cqe.status) >> 1);
715
716 } 712 }
717 713
718 /* If the controller ignores the cq head doorbell and continuously
719 * writes to the queue, it is theoretically possible to wrap around
720 * the queue twice and mistakenly return IRQ_NONE. Linux only
721 * requires that 0.1% of your interrupts are handled, so this isn't
722 * a big problem.
723 */
724 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase) 714 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
725 return; 715 return;
726 716
@@ -1909,10 +1899,10 @@ static int nvme_dev_map(struct nvme_dev *dev)
1909 if (!dev->bar) 1899 if (!dev->bar)
1910 goto release; 1900 goto release;
1911 1901
1912 return 0; 1902 return 0;
1913 release: 1903 release:
1914 pci_release_mem_regions(pdev); 1904 pci_release_mem_regions(pdev);
1915 return -ENODEV; 1905 return -ENODEV;
1916} 1906}
1917 1907
1918static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1908static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index f587af345889..557f29b1f1bb 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -981,8 +981,7 @@ static int nvme_rdma_map_sg_fr(struct nvme_rdma_queue *queue,
981} 981}
982 982
983static int nvme_rdma_map_data(struct nvme_rdma_queue *queue, 983static int nvme_rdma_map_data(struct nvme_rdma_queue *queue,
984 struct request *rq, unsigned int map_len, 984 struct request *rq, struct nvme_command *c)
985 struct nvme_command *c)
986{ 985{
987 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); 986 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
988 struct nvme_rdma_device *dev = queue->device; 987 struct nvme_rdma_device *dev = queue->device;
@@ -1014,9 +1013,9 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue *queue,
1014 } 1013 }
1015 1014
1016 if (count == 1) { 1015 if (count == 1) {
1017 if (rq_data_dir(rq) == WRITE && 1016 if (rq_data_dir(rq) == WRITE && nvme_rdma_queue_idx(queue) &&
1018 map_len <= nvme_rdma_inline_data_size(queue) && 1017 blk_rq_payload_bytes(rq) <=
1019 nvme_rdma_queue_idx(queue)) 1018 nvme_rdma_inline_data_size(queue))
1020 return nvme_rdma_map_sg_inline(queue, req, c); 1019 return nvme_rdma_map_sg_inline(queue, req, c);
1021 1020
1022 if (dev->pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY) 1021 if (dev->pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY)
@@ -1422,7 +1421,7 @@ static inline bool nvme_rdma_queue_is_ready(struct nvme_rdma_queue *queue,
1422 struct request *rq) 1421 struct request *rq)
1423{ 1422{
1424 if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) { 1423 if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) {
1425 struct nvme_command *cmd = (struct nvme_command *)rq->cmd; 1424 struct nvme_command *cmd = nvme_req(rq)->cmd;
1426 1425
1427 if (rq->cmd_type != REQ_TYPE_DRV_PRIV || 1426 if (rq->cmd_type != REQ_TYPE_DRV_PRIV ||
1428 cmd->common.opcode != nvme_fabrics_command || 1427 cmd->common.opcode != nvme_fabrics_command ||
@@ -1444,7 +1443,6 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
1444 struct nvme_command *c = sqe->data; 1443 struct nvme_command *c = sqe->data;
1445 bool flush = false; 1444 bool flush = false;
1446 struct ib_device *dev; 1445 struct ib_device *dev;
1447 unsigned int map_len;
1448 int ret; 1446 int ret;
1449 1447
1450 WARN_ON_ONCE(rq->tag < 0); 1448 WARN_ON_ONCE(rq->tag < 0);
@@ -1462,8 +1460,7 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
1462 1460
1463 blk_mq_start_request(rq); 1461 blk_mq_start_request(rq);
1464 1462
1465 map_len = nvme_map_len(rq); 1463 ret = nvme_rdma_map_data(queue, rq, c);
1466 ret = nvme_rdma_map_data(queue, rq, map_len, c);
1467 if (ret < 0) { 1464 if (ret < 0) {
1468 dev_err(queue->ctrl->ctrl.device, 1465 dev_err(queue->ctrl->ctrl.device,
1469 "Failed to map data (%d)\n", ret); 1466 "Failed to map data (%d)\n", ret);
diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c
index b71e95044b43..a5c09e703bd8 100644
--- a/drivers/nvme/host/scsi.c
+++ b/drivers/nvme/host/scsi.c
@@ -2160,30 +2160,6 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns,
2160 return nvme_trans_status_code(hdr, nvme_sc); 2160 return nvme_trans_status_code(hdr, nvme_sc);
2161} 2161}
2162 2162
2163static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2164 u8 *cmd)
2165{
2166 u8 immed, no_flush;
2167
2168 immed = cmd[1] & 0x01;
2169 no_flush = cmd[4] & 0x04;
2170
2171 if (immed != 0) {
2172 return nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION,
2173 ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB,
2174 SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
2175 } else {
2176 if (no_flush == 0) {
2177 /* Issue NVME FLUSH command prior to START STOP UNIT */
2178 int res = nvme_trans_synchronize_cache(ns, hdr);
2179 if (res)
2180 return res;
2181 }
2182
2183 return 0;
2184 }
2185}
2186
2187static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr, 2163static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2188 u8 *cmd) 2164 u8 *cmd)
2189{ 2165{
@@ -2439,9 +2415,6 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr)
2439 case SECURITY_PROTOCOL_OUT: 2415 case SECURITY_PROTOCOL_OUT:
2440 retcode = nvme_trans_security_protocol(ns, hdr, cmd); 2416 retcode = nvme_trans_security_protocol(ns, hdr, cmd);
2441 break; 2417 break;
2442 case START_STOP:
2443 retcode = nvme_trans_start_stop(ns, hdr, cmd);
2444 break;
2445 case SYNCHRONIZE_CACHE: 2418 case SYNCHRONIZE_CACHE:
2446 retcode = nvme_trans_synchronize_cache(ns, hdr); 2419 retcode = nvme_trans_synchronize_cache(ns, hdr);
2447 break; 2420 break;
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ec1ad2aa0a4c..95ae52390478 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -382,7 +382,6 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
382{ 382{
383 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; 383 struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
384 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]); 384 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
385 u64 val;
386 u32 val32; 385 u32 val32;
387 u16 status = 0; 386 u16 status = 0;
388 387
@@ -392,8 +391,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
392 (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16)); 391 (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
393 break; 392 break;
394 case NVME_FEAT_KATO: 393 case NVME_FEAT_KATO:
395 val = le64_to_cpu(req->cmd->prop_set.value); 394 val32 = le32_to_cpu(req->cmd->common.cdw10[1]);
396 val32 = val & 0xffff;
397 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); 395 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000);
398 nvmet_set_result(req, req->sq->ctrl->kato); 396 nvmet_set_result(req, req->sq->ctrl->kato);
399 break; 397 break;
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index bcb8ebeb01c5..4e8e6a22bce1 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -845,7 +845,7 @@ fcloop_create_remote_port(struct device *dev, struct device_attribute *attr,
845 rport->lport = nport->lport; 845 rport->lport = nport->lport;
846 nport->rport = rport; 846 nport->rport = rport;
847 847
848 return ret ? ret : count; 848 return count;
849} 849}
850 850
851 851
@@ -952,7 +952,7 @@ fcloop_create_target_port(struct device *dev, struct device_attribute *attr,
952 tport->lport = nport->lport; 952 tport->lport = nport->lport;
953 nport->tport = tport; 953 nport->tport = tport;
954 954
955 return ret ? ret : count; 955 return count;
956} 956}
957 957
958 958
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 965911d9b36a..398ea7f54826 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -981,8 +981,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
981 * @cell: nvmem cell to be read. 981 * @cell: nvmem cell to be read.
982 * @len: pointer to length of cell which will be populated on successful read. 982 * @len: pointer to length of cell which will be populated on successful read.
983 * 983 *
984 * Return: ERR_PTR() on error or a valid pointer to a char * buffer on success. 984 * Return: ERR_PTR() on error or a valid pointer to a buffer on success. The
985 * The buffer should be freed by the consumer with a kfree(). 985 * buffer should be freed by the consumer with a kfree().
986 */ 986 */
987void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) 987void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
988{ 988{
diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index ac27b9bac3b9..8e7b120696fa 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -71,7 +71,7 @@ static struct nvmem_config imx_ocotp_nvmem_config = {
71 71
72static const struct of_device_id imx_ocotp_dt_ids[] = { 72static const struct of_device_id imx_ocotp_dt_ids[] = {
73 { .compatible = "fsl,imx6q-ocotp", (void *)128 }, 73 { .compatible = "fsl,imx6q-ocotp", (void *)128 },
74 { .compatible = "fsl,imx6sl-ocotp", (void *)32 }, 74 { .compatible = "fsl,imx6sl-ocotp", (void *)64 },
75 { .compatible = "fsl,imx6sx-ocotp", (void *)128 }, 75 { .compatible = "fsl,imx6sx-ocotp", (void *)128 },
76 { }, 76 { },
77}; 77};
diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
index b5305f08b184..2bdb6c389328 100644
--- a/drivers/nvmem/qfprom.c
+++ b/drivers/nvmem/qfprom.c
@@ -21,11 +21,11 @@ static int qfprom_reg_read(void *context,
21 unsigned int reg, void *_val, size_t bytes) 21 unsigned int reg, void *_val, size_t bytes)
22{ 22{
23 void __iomem *base = context; 23 void __iomem *base = context;
24 u32 *val = _val; 24 u8 *val = _val;
25 int i = 0, words = bytes / 4; 25 int i = 0, words = bytes;
26 26
27 while (words--) 27 while (words--)
28 *val++ = readl(base + reg + (i++ * 4)); 28 *val++ = readb(base + reg + i++);
29 29
30 return 0; 30 return 0;
31} 31}
@@ -34,11 +34,11 @@ static int qfprom_reg_write(void *context,
34 unsigned int reg, void *_val, size_t bytes) 34 unsigned int reg, void *_val, size_t bytes)
35{ 35{
36 void __iomem *base = context; 36 void __iomem *base = context;
37 u32 *val = _val; 37 u8 *val = _val;
38 int i = 0, words = bytes / 4; 38 int i = 0, words = bytes;
39 39
40 while (words--) 40 while (words--)
41 writel(*val++, base + reg + (i++ * 4)); 41 writeb(*val++, base + reg + i++);
42 42
43 return 0; 43 return 0;
44} 44}
@@ -53,7 +53,7 @@ static int qfprom_remove(struct platform_device *pdev)
53static struct nvmem_config econfig = { 53static struct nvmem_config econfig = {
54 .name = "qfprom", 54 .name = "qfprom",
55 .owner = THIS_MODULE, 55 .owner = THIS_MODULE,
56 .stride = 4, 56 .stride = 1,
57 .word_size = 1, 57 .word_size = 1,
58 .reg_read = qfprom_reg_read, 58 .reg_read = qfprom_reg_read,
59 .reg_write = qfprom_reg_write, 59 .reg_write = qfprom_reg_write,
diff --git a/drivers/pci/host/pci-xgene-msi.c b/drivers/pci/host/pci-xgene-msi.c
index 1f38d0836751..f1b633bce525 100644
--- a/drivers/pci/host/pci-xgene-msi.c
+++ b/drivers/pci/host/pci-xgene-msi.c
@@ -517,7 +517,7 @@ static int xgene_msi_probe(struct platform_device *pdev)
517 517
518 rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "pci/xgene:online", 518 rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "pci/xgene:online",
519 xgene_msi_hwirq_alloc, NULL); 519 xgene_msi_hwirq_alloc, NULL);
520 if (rc) 520 if (rc < 0)
521 goto err_cpuhp; 521 goto err_cpuhp;
522 pci_xgene_online = rc; 522 pci_xgene_online = rc;
523 rc = cpuhp_setup_state(CPUHP_PCI_XGENE_DEAD, "pci/xgene:dead", NULL, 523 rc = cpuhp_setup_state(CPUHP_PCI_XGENE_DEAD, "pci/xgene:dead", NULL,
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index bed19994c1e9..af8f6e92e885 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -807,11 +807,6 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
807{ 807{
808 u32 val; 808 u32 val;
809 809
810 /* get iATU unroll support */
811 pp->iatu_unroll_enabled = dw_pcie_iatu_unroll_enabled(pp);
812 dev_dbg(pp->dev, "iATU unroll: %s\n",
813 pp->iatu_unroll_enabled ? "enabled" : "disabled");
814
815 /* set the number of lanes */ 810 /* set the number of lanes */
816 val = dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL); 811 val = dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL);
817 val &= ~PORT_LINK_MODE_MASK; 812 val &= ~PORT_LINK_MODE_MASK;
@@ -882,6 +877,11 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
882 * we should not program the ATU here. 877 * we should not program the ATU here.
883 */ 878 */
884 if (!pp->ops->rd_other_conf) { 879 if (!pp->ops->rd_other_conf) {
880 /* get iATU unroll support */
881 pp->iatu_unroll_enabled = dw_pcie_iatu_unroll_enabled(pp);
882 dev_dbg(pp->dev, "iATU unroll: %s\n",
883 pp->iatu_unroll_enabled ? "enabled" : "disabled");
884
885 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0, 885 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
886 PCIE_ATU_TYPE_MEM, pp->mem_base, 886 PCIE_ATU_TYPE_MEM, pp->mem_base,
887 pp->mem_bus_addr, pp->mem_size); 887 pp->mem_bus_addr, pp->mem_size);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e164b5c9f0f0..204960e70333 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1169,6 +1169,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
1169 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 1169 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
1170 if (!pos) 1170 if (!pos)
1171 return; 1171 return;
1172
1172 pdev->pcie_cap = pos; 1173 pdev->pcie_cap = pos;
1173 pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16); 1174 pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16);
1174 pdev->pcie_flags_reg = reg16; 1175 pdev->pcie_flags_reg = reg16;
@@ -1176,13 +1177,14 @@ void set_pcie_port_type(struct pci_dev *pdev)
1176 pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; 1177 pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD;
1177 1178
1178 /* 1179 /*
1179 * A Root Port is always the upstream end of a Link. No PCIe 1180 * A Root Port or a PCI-to-PCIe bridge is always the upstream end
1180 * component has two Links. Two Links are connected by a Switch 1181 * of a Link. No PCIe component has two Links. Two Links are
1181 * that has a Port on each Link and internal logic to connect the 1182 * connected by a Switch that has a Port on each Link and internal
1182 * two Ports. 1183 * logic to connect the two Ports.
1183 */ 1184 */
1184 type = pci_pcie_type(pdev); 1185 type = pci_pcie_type(pdev);
1185 if (type == PCI_EXP_TYPE_ROOT_PORT) 1186 if (type == PCI_EXP_TYPE_ROOT_PORT ||
1187 type == PCI_EXP_TYPE_PCIE_BRIDGE)
1186 pdev->has_secondary_link = 1; 1188 pdev->has_secondary_link = 1;
1187 else if (type == PCI_EXP_TYPE_UPSTREAM || 1189 else if (type == PCI_EXP_TYPE_UPSTREAM ||
1188 type == PCI_EXP_TYPE_DOWNSTREAM) { 1190 type == PCI_EXP_TYPE_DOWNSTREAM) {
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index a579126832af..620c231a2889 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -212,7 +212,7 @@ static int meson_pmx_request_gpio(struct pinctrl_dev *pcdev,
212{ 212{
213 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 213 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev);
214 214
215 meson_pmx_disable_other_groups(pc, range->pin_base + offset, -1); 215 meson_pmx_disable_other_groups(pc, offset, -1);
216 216
217 return 0; 217 return 0;
218} 218}
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index aea310a91821..c9a146948192 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -382,26 +382,21 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
382{ 382{
383 int ret = 0; 383 int ret = 0;
384 u32 pin_reg; 384 u32 pin_reg;
385 unsigned long flags; 385 unsigned long flags, irq_flags;
386 bool level_trig;
387 u32 active_level;
388 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 386 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
389 struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 387 struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
390 388
391 spin_lock_irqsave(&gpio_dev->lock, flags); 389 spin_lock_irqsave(&gpio_dev->lock, flags);
392 pin_reg = readl(gpio_dev->base + (d->hwirq)*4); 390 pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
393 391
394 /* 392 /* Ignore the settings coming from the client and
395 * When level_trig is set EDGE and active_level is set HIGH in BIOS 393 * read the values from the ACPI tables
396 * default settings, ignore incoming settings from client and use 394 * while setting the trigger type
397 * BIOS settings to configure GPIO register.
398 */ 395 */
399 level_trig = !(pin_reg & (LEVEL_TRIGGER << LEVEL_TRIG_OFF));
400 active_level = pin_reg & (ACTIVE_LEVEL_MASK << ACTIVE_LEVEL_OFF);
401 396
402 if(level_trig && 397 irq_flags = irq_get_trigger_type(d->irq);
403 ((active_level >> ACTIVE_LEVEL_OFF) == ACTIVE_HIGH)) 398 if (irq_flags != IRQ_TYPE_NONE)
404 type = IRQ_TYPE_EDGE_FALLING; 399 type = irq_flags;
405 400
406 switch (type & IRQ_TYPE_SENSE_MASK) { 401 switch (type & IRQ_TYPE_SENSE_MASK) {
407 case IRQ_TYPE_EDGE_RISING: 402 case IRQ_TYPE_EDGE_RISING:
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 12f7d1eb65bc..07409fde02b2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -56,6 +56,17 @@ static const struct samsung_pin_bank_type bank_type_alive = {
56 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, }, 56 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, },
57}; 57};
58 58
59/* Exynos5433 has the 4bit widths for PINCFG_TYPE_DRV bitfields. */
60static const struct samsung_pin_bank_type exynos5433_bank_type_off = {
61 .fld_width = { 4, 1, 2, 4, 2, 2, },
62 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, },
63};
64
65static const struct samsung_pin_bank_type exynos5433_bank_type_alive = {
66 .fld_width = { 4, 1, 2, 4, },
67 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, },
68};
69
59static void exynos_irq_mask(struct irq_data *irqd) 70static void exynos_irq_mask(struct irq_data *irqd)
60{ 71{
61 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 72 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
@@ -1335,82 +1346,82 @@ const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
1335 1346
1336/* pin banks of exynos5433 pin-controller - ALIVE */ 1347/* pin banks of exynos5433 pin-controller - ALIVE */
1337static const struct samsung_pin_bank_data exynos5433_pin_banks0[] = { 1348static const struct samsung_pin_bank_data exynos5433_pin_banks0[] = {
1338 EXYNOS_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00), 1349 EXYNOS5433_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00),
1339 EXYNOS_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04), 1350 EXYNOS5433_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04),
1340 EXYNOS_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08), 1351 EXYNOS5433_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08),
1341 EXYNOS_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c), 1352 EXYNOS5433_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c),
1342 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1), 1353 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1),
1343 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1), 1354 EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1),
1344 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1), 1355 EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1),
1345 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1), 1356 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1),
1346 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1), 1357 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1),
1347}; 1358};
1348 1359
1349/* pin banks of exynos5433 pin-controller - AUD */ 1360/* pin banks of exynos5433 pin-controller - AUD */
1350static const struct samsung_pin_bank_data exynos5433_pin_banks1[] = { 1361static const struct samsung_pin_bank_data exynos5433_pin_banks1[] = {
1351 EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00), 1362 EXYNOS5433_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00),
1352 EXYNOS_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04), 1363 EXYNOS5433_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04),
1353}; 1364};
1354 1365
1355/* pin banks of exynos5433 pin-controller - CPIF */ 1366/* pin banks of exynos5433 pin-controller - CPIF */
1356static const struct samsung_pin_bank_data exynos5433_pin_banks2[] = { 1367static const struct samsung_pin_bank_data exynos5433_pin_banks2[] = {
1357 EXYNOS_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00), 1368 EXYNOS5433_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00),
1358}; 1369};
1359 1370
1360/* pin banks of exynos5433 pin-controller - eSE */ 1371/* pin banks of exynos5433 pin-controller - eSE */
1361static const struct samsung_pin_bank_data exynos5433_pin_banks3[] = { 1372static const struct samsung_pin_bank_data exynos5433_pin_banks3[] = {
1362 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00), 1373 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00),
1363}; 1374};
1364 1375
1365/* pin banks of exynos5433 pin-controller - FINGER */ 1376/* pin banks of exynos5433 pin-controller - FINGER */
1366static const struct samsung_pin_bank_data exynos5433_pin_banks4[] = { 1377static const struct samsung_pin_bank_data exynos5433_pin_banks4[] = {
1367 EXYNOS_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00), 1378 EXYNOS5433_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00),
1368}; 1379};
1369 1380
1370/* pin banks of exynos5433 pin-controller - FSYS */ 1381/* pin banks of exynos5433 pin-controller - FSYS */
1371static const struct samsung_pin_bank_data exynos5433_pin_banks5[] = { 1382static const struct samsung_pin_bank_data exynos5433_pin_banks5[] = {
1372 EXYNOS_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00), 1383 EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00),
1373 EXYNOS_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04), 1384 EXYNOS5433_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04),
1374 EXYNOS_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08), 1385 EXYNOS5433_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08),
1375 EXYNOS_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c), 1386 EXYNOS5433_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c),
1376 EXYNOS_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10), 1387 EXYNOS5433_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10),
1377 EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14), 1388 EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14),
1378}; 1389};
1379 1390
1380/* pin banks of exynos5433 pin-controller - IMEM */ 1391/* pin banks of exynos5433 pin-controller - IMEM */
1381static const struct samsung_pin_bank_data exynos5433_pin_banks6[] = { 1392static const struct samsung_pin_bank_data exynos5433_pin_banks6[] = {
1382 EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00), 1393 EXYNOS5433_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00),
1383}; 1394};
1384 1395
1385/* pin banks of exynos5433 pin-controller - NFC */ 1396/* pin banks of exynos5433 pin-controller - NFC */
1386static const struct samsung_pin_bank_data exynos5433_pin_banks7[] = { 1397static const struct samsung_pin_bank_data exynos5433_pin_banks7[] = {
1387 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00), 1398 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00),
1388}; 1399};
1389 1400
1390/* pin banks of exynos5433 pin-controller - PERIC */ 1401/* pin banks of exynos5433 pin-controller - PERIC */
1391static const struct samsung_pin_bank_data exynos5433_pin_banks8[] = { 1402static const struct samsung_pin_bank_data exynos5433_pin_banks8[] = {
1392 EXYNOS_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00), 1403 EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00),
1393 EXYNOS_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04), 1404 EXYNOS5433_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04),
1394 EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08), 1405 EXYNOS5433_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08),
1395 EXYNOS_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c), 1406 EXYNOS5433_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c),
1396 EXYNOS_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10), 1407 EXYNOS5433_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10),
1397 EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14), 1408 EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14),
1398 EXYNOS_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18), 1409 EXYNOS5433_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18),
1399 EXYNOS_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c), 1410 EXYNOS5433_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c),
1400 EXYNOS_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20), 1411 EXYNOS5433_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20),
1401 EXYNOS_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24), 1412 EXYNOS5433_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24),
1402 EXYNOS_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28), 1413 EXYNOS5433_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28),
1403 EXYNOS_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c), 1414 EXYNOS5433_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c),
1404 EXYNOS_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30), 1415 EXYNOS5433_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30),
1405 EXYNOS_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34), 1416 EXYNOS5433_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34),
1406 EXYNOS_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38), 1417 EXYNOS5433_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38),
1407 EXYNOS_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c), 1418 EXYNOS5433_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c),
1408 EXYNOS_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40), 1419 EXYNOS5433_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40),
1409}; 1420};
1410 1421
1411/* pin banks of exynos5433 pin-controller - TOUCH */ 1422/* pin banks of exynos5433 pin-controller - TOUCH */
1412static const struct samsung_pin_bank_data exynos5433_pin_banks9[] = { 1423static const struct samsung_pin_bank_data exynos5433_pin_banks9[] = {
1413 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00), 1424 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00),
1414}; 1425};
1415 1426
1416/* 1427/*
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.h b/drivers/pinctrl/samsung/pinctrl-exynos.h
index 5821525a2c84..a473092fb8d2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.h
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.h
@@ -90,6 +90,37 @@
90 .pctl_res_idx = pctl_idx, \ 90 .pctl_res_idx = pctl_idx, \
91 } \ 91 } \
92 92
93#define EXYNOS5433_PIN_BANK_EINTG(pins, reg, id, offs) \
94 { \
95 .type = &exynos5433_bank_type_off, \
96 .pctl_offset = reg, \
97 .nr_pins = pins, \
98 .eint_type = EINT_TYPE_GPIO, \
99 .eint_offset = offs, \
100 .name = id \
101 }
102
103#define EXYNOS5433_PIN_BANK_EINTW(pins, reg, id, offs) \
104 { \
105 .type = &exynos5433_bank_type_alive, \
106 .pctl_offset = reg, \
107 .nr_pins = pins, \
108 .eint_type = EINT_TYPE_WKUP, \
109 .eint_offset = offs, \
110 .name = id \
111 }
112
113#define EXYNOS5433_PIN_BANK_EINTW_EXT(pins, reg, id, offs, pctl_idx) \
114 { \
115 .type = &exynos5433_bank_type_alive, \
116 .pctl_offset = reg, \
117 .nr_pins = pins, \
118 .eint_type = EINT_TYPE_WKUP, \
119 .eint_offset = offs, \
120 .name = id, \
121 .pctl_res_idx = pctl_idx, \
122 } \
123
93/** 124/**
94 * struct exynos_weint_data: irq specific data for all the wakeup interrupts 125 * struct exynos_weint_data: irq specific data for all the wakeup interrupts
95 * generated by the external wakeup interrupt controller. 126 * generated by the external wakeup interrupt controller.
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 5fe8be089b8b..59aa8e302bc3 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1034,7 +1034,7 @@ config SURFACE_PRO3_BUTTON
1034 1034
1035config SURFACE_3_BUTTON 1035config SURFACE_3_BUTTON
1036 tristate "Power/home/volume buttons driver for Microsoft Surface 3 tablet" 1036 tristate "Power/home/volume buttons driver for Microsoft Surface 3 tablet"
1037 depends on ACPI && KEYBOARD_GPIO 1037 depends on ACPI && KEYBOARD_GPIO && I2C
1038 ---help--- 1038 ---help---
1039 This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. 1039 This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet.
1040 1040
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 61f39abf5dc8..82d67715ce76 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -177,43 +177,43 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
177 177
178#if IS_ENABLED(CONFIG_LEDS_CLASS) 178#if IS_ENABLED(CONFIG_LEDS_CLASS)
179static enum led_brightness logolamp_get(struct led_classdev *cdev); 179static enum led_brightness logolamp_get(struct led_classdev *cdev);
180static void logolamp_set(struct led_classdev *cdev, 180static int logolamp_set(struct led_classdev *cdev,
181 enum led_brightness brightness); 181 enum led_brightness brightness);
182 182
183static struct led_classdev logolamp_led = { 183static struct led_classdev logolamp_led = {
184 .name = "fujitsu::logolamp", 184 .name = "fujitsu::logolamp",
185 .brightness_get = logolamp_get, 185 .brightness_get = logolamp_get,
186 .brightness_set = logolamp_set 186 .brightness_set_blocking = logolamp_set
187}; 187};
188 188
189static enum led_brightness kblamps_get(struct led_classdev *cdev); 189static enum led_brightness kblamps_get(struct led_classdev *cdev);
190static void kblamps_set(struct led_classdev *cdev, 190static int kblamps_set(struct led_classdev *cdev,
191 enum led_brightness brightness); 191 enum led_brightness brightness);
192 192
193static struct led_classdev kblamps_led = { 193static struct led_classdev kblamps_led = {
194 .name = "fujitsu::kblamps", 194 .name = "fujitsu::kblamps",
195 .brightness_get = kblamps_get, 195 .brightness_get = kblamps_get,
196 .brightness_set = kblamps_set 196 .brightness_set_blocking = kblamps_set
197}; 197};
198 198
199static enum led_brightness radio_led_get(struct led_classdev *cdev); 199static enum led_brightness radio_led_get(struct led_classdev *cdev);
200static void radio_led_set(struct led_classdev *cdev, 200static int radio_led_set(struct led_classdev *cdev,
201 enum led_brightness brightness); 201 enum led_brightness brightness);
202 202
203static struct led_classdev radio_led = { 203static struct led_classdev radio_led = {
204 .name = "fujitsu::radio_led", 204 .name = "fujitsu::radio_led",
205 .brightness_get = radio_led_get, 205 .brightness_get = radio_led_get,
206 .brightness_set = radio_led_set 206 .brightness_set_blocking = radio_led_set
207}; 207};
208 208
209static enum led_brightness eco_led_get(struct led_classdev *cdev); 209static enum led_brightness eco_led_get(struct led_classdev *cdev);
210static void eco_led_set(struct led_classdev *cdev, 210static int eco_led_set(struct led_classdev *cdev,
211 enum led_brightness brightness); 211 enum led_brightness brightness);
212 212
213static struct led_classdev eco_led = { 213static struct led_classdev eco_led = {
214 .name = "fujitsu::eco_led", 214 .name = "fujitsu::eco_led",
215 .brightness_get = eco_led_get, 215 .brightness_get = eco_led_get,
216 .brightness_set = eco_led_set 216 .brightness_set_blocking = eco_led_set
217}; 217};
218#endif 218#endif
219 219
@@ -267,48 +267,48 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
267#if IS_ENABLED(CONFIG_LEDS_CLASS) 267#if IS_ENABLED(CONFIG_LEDS_CLASS)
268/* LED class callbacks */ 268/* LED class callbacks */
269 269
270static void logolamp_set(struct led_classdev *cdev, 270static int logolamp_set(struct led_classdev *cdev,
271 enum led_brightness brightness) 271 enum led_brightness brightness)
272{ 272{
273 if (brightness >= LED_FULL) { 273 if (brightness >= LED_FULL) {
274 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); 274 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
275 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON); 275 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
276 } else if (brightness >= LED_HALF) { 276 } else if (brightness >= LED_HALF) {
277 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); 277 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
278 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF); 278 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
279 } else { 279 } else {
280 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF); 280 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
281 } 281 }
282} 282}
283 283
284static void kblamps_set(struct led_classdev *cdev, 284static int kblamps_set(struct led_classdev *cdev,
285 enum led_brightness brightness) 285 enum led_brightness brightness)
286{ 286{
287 if (brightness >= LED_FULL) 287 if (brightness >= LED_FULL)
288 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON); 288 return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
289 else 289 else
290 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF); 290 return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
291} 291}
292 292
293static void radio_led_set(struct led_classdev *cdev, 293static int radio_led_set(struct led_classdev *cdev,
294 enum led_brightness brightness) 294 enum led_brightness brightness)
295{ 295{
296 if (brightness >= LED_FULL) 296 if (brightness >= LED_FULL)
297 call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON); 297 return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON);
298 else 298 else
299 call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0); 299 return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0);
300} 300}
301 301
302static void eco_led_set(struct led_classdev *cdev, 302static int eco_led_set(struct led_classdev *cdev,
303 enum led_brightness brightness) 303 enum led_brightness brightness)
304{ 304{
305 int curr; 305 int curr;
306 306
307 curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0); 307 curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0);
308 if (brightness >= LED_FULL) 308 if (brightness >= LED_FULL)
309 call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON); 309 return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON);
310 else 310 else
311 call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON); 311 return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON);
312} 312}
313 313
314static enum led_brightness logolamp_get(struct led_classdev *cdev) 314static enum led_brightness logolamp_get(struct led_classdev *cdev)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 9a507e77eced..90b05c72186c 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -396,9 +396,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
396 goto unwind_vring_allocations; 396 goto unwind_vring_allocations;
397 } 397 }
398 398
399 /* track the rvdevs list reference */
400 kref_get(&rvdev->refcount);
401
402 list_add_tail(&rvdev->node, &rproc->rvdevs); 399 list_add_tail(&rvdev->node, &rproc->rvdevs);
403 400
404 rproc_add_subdev(rproc, &rvdev->subdev, 401 rproc_add_subdev(rproc, &rvdev->subdev,
@@ -889,13 +886,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
889 /* 886 /*
890 * Create a copy of the resource table. When a virtio device starts 887 * Create a copy of the resource table. When a virtio device starts
891 * and calls vring_new_virtqueue() the address of the allocated vring 888 * and calls vring_new_virtqueue() the address of the allocated vring
892 * will be stored in the table_ptr. Before the device is started, 889 * will be stored in the cached_table. Before the device is started,
893 * table_ptr will be copied into device memory. 890 * cached_table will be copied into device memory.
894 */ 891 */
895 rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL); 892 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
896 if (!rproc->table_ptr) 893 if (!rproc->cached_table)
897 goto clean_up; 894 goto clean_up;
898 895
896 rproc->table_ptr = rproc->cached_table;
897
899 /* reset max_notifyid */ 898 /* reset max_notifyid */
900 rproc->max_notifyid = -1; 899 rproc->max_notifyid = -1;
901 900
@@ -914,16 +913,18 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
914 } 913 }
915 914
916 /* 915 /*
917 * The starting device has been given the rproc->table_ptr as the 916 * The starting device has been given the rproc->cached_table as the
918 * resource table. The address of the vring along with the other 917 * resource table. The address of the vring along with the other
919 * allocated resources (carveouts etc) is stored in table_ptr. 918 * allocated resources (carveouts etc) is stored in cached_table.
920 * In order to pass this information to the remote device we must copy 919 * In order to pass this information to the remote device we must copy
921 * this information to device memory. We also update the table_ptr so 920 * this information to device memory. We also update the table_ptr so
922 * that any subsequent changes will be applied to the loaded version. 921 * that any subsequent changes will be applied to the loaded version.
923 */ 922 */
924 loaded_table = rproc_find_loaded_rsc_table(rproc, fw); 923 loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
925 if (loaded_table) 924 if (loaded_table) {
926 memcpy(loaded_table, rproc->table_ptr, tablesz); 925 memcpy(loaded_table, rproc->cached_table, tablesz);
926 rproc->table_ptr = loaded_table;
927 }
927 928
928 /* power up the remote processor */ 929 /* power up the remote processor */
929 ret = rproc->ops->start(rproc); 930 ret = rproc->ops->start(rproc);
@@ -951,7 +952,8 @@ stop_rproc:
951clean_up_resources: 952clean_up_resources:
952 rproc_resource_cleanup(rproc); 953 rproc_resource_cleanup(rproc);
953clean_up: 954clean_up:
954 kfree(rproc->table_ptr); 955 kfree(rproc->cached_table);
956 rproc->cached_table = NULL;
955 rproc->table_ptr = NULL; 957 rproc->table_ptr = NULL;
956 958
957 rproc_disable_iommu(rproc); 959 rproc_disable_iommu(rproc);
@@ -1185,7 +1187,8 @@ void rproc_shutdown(struct rproc *rproc)
1185 rproc_disable_iommu(rproc); 1187 rproc_disable_iommu(rproc);
1186 1188
1187 /* Free the copy of the resource table */ 1189 /* Free the copy of the resource table */
1188 kfree(rproc->table_ptr); 1190 kfree(rproc->cached_table);
1191 rproc->cached_table = NULL;
1189 rproc->table_ptr = NULL; 1192 rproc->table_ptr = NULL;
1190 1193
1191 /* if in crash state, unlock crash handler */ 1194 /* if in crash state, unlock crash handler */
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index a79cb5a9e5f2..1cfb775e8e82 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -453,8 +453,8 @@ int rpmsg_register_device(struct rpmsg_device *rpdev)
453 struct device *dev = &rpdev->dev; 453 struct device *dev = &rpdev->dev;
454 int ret; 454 int ret;
455 455
456 dev_set_name(&rpdev->dev, "%s:%s", 456 dev_set_name(&rpdev->dev, "%s.%s.%d.%d", dev_name(dev->parent),
457 dev_name(dev->parent), rpdev->id.name); 457 rpdev->id.name, rpdev->src, rpdev->dst);
458 458
459 rpdev->dev.bus = &rpmsg_bus; 459 rpdev->dev.bus = &rpmsg_bus;
460 rpdev->dev.release = rpmsg_release_device; 460 rpdev->dev.release = rpmsg_release_device;
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 639ed4e6afd1..070c4da95f48 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -145,6 +145,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
145#define CCW_CMD_WRITE_CONF 0x21 145#define CCW_CMD_WRITE_CONF 0x21
146#define CCW_CMD_WRITE_STATUS 0x31 146#define CCW_CMD_WRITE_STATUS 0x31
147#define CCW_CMD_READ_VQ_CONF 0x32 147#define CCW_CMD_READ_VQ_CONF 0x32
148#define CCW_CMD_READ_STATUS 0x72
148#define CCW_CMD_SET_IND_ADAPTER 0x73 149#define CCW_CMD_SET_IND_ADAPTER 0x73
149#define CCW_CMD_SET_VIRTIO_REV 0x83 150#define CCW_CMD_SET_VIRTIO_REV 0x83
150 151
@@ -160,6 +161,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
160#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000 161#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000
161#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000 162#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000
162#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000 163#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000
164#define VIRTIO_CCW_DOING_READ_STATUS 0x20000000
163#define VIRTIO_CCW_INTPARM_MASK 0xffff0000 165#define VIRTIO_CCW_INTPARM_MASK 0xffff0000
164 166
165static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev) 167static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev)
@@ -452,7 +454,7 @@ static void virtio_ccw_del_vq(struct virtqueue *vq, struct ccw1 *ccw)
452 * This may happen on device detach. 454 * This may happen on device detach.
453 */ 455 */
454 if (ret && (ret != -ENODEV)) 456 if (ret && (ret != -ENODEV))
455 dev_warn(&vq->vdev->dev, "Error %d while deleting queue %d", 457 dev_warn(&vq->vdev->dev, "Error %d while deleting queue %d\n",
456 ret, index); 458 ret, index);
457 459
458 vring_del_virtqueue(vq); 460 vring_del_virtqueue(vq);
@@ -892,6 +894,28 @@ out_free:
892static u8 virtio_ccw_get_status(struct virtio_device *vdev) 894static u8 virtio_ccw_get_status(struct virtio_device *vdev)
893{ 895{
894 struct virtio_ccw_device *vcdev = to_vc_device(vdev); 896 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
897 u8 old_status = *vcdev->status;
898 struct ccw1 *ccw;
899
900 if (vcdev->revision < 1)
901 return *vcdev->status;
902
903 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
904 if (!ccw)
905 return old_status;
906
907 ccw->cmd_code = CCW_CMD_READ_STATUS;
908 ccw->flags = 0;
909 ccw->count = sizeof(*vcdev->status);
910 ccw->cda = (__u32)(unsigned long)vcdev->status;
911 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_STATUS);
912/*
913 * If the channel program failed (should only happen if the device
914 * was hotunplugged, and then we clean up via the machine check
915 * handler anyway), vcdev->status was not overwritten and we just
916 * return the old status, which is fine.
917*/
918 kfree(ccw);
895 919
896 return *vcdev->status; 920 return *vcdev->status;
897} 921}
@@ -920,7 +944,7 @@ static void virtio_ccw_set_status(struct virtio_device *vdev, u8 status)
920 kfree(ccw); 944 kfree(ccw);
921} 945}
922 946
923static struct virtio_config_ops virtio_ccw_config_ops = { 947static const struct virtio_config_ops virtio_ccw_config_ops = {
924 .get_features = virtio_ccw_get_features, 948 .get_features = virtio_ccw_get_features,
925 .finalize_features = virtio_ccw_finalize_features, 949 .finalize_features = virtio_ccw_finalize_features,
926 .get = virtio_ccw_get_config, 950 .get = virtio_ccw_get_config,
@@ -987,6 +1011,7 @@ static void virtio_ccw_check_activity(struct virtio_ccw_device *vcdev,
987 case VIRTIO_CCW_DOING_READ_CONFIG: 1011 case VIRTIO_CCW_DOING_READ_CONFIG:
988 case VIRTIO_CCW_DOING_WRITE_CONFIG: 1012 case VIRTIO_CCW_DOING_WRITE_CONFIG:
989 case VIRTIO_CCW_DOING_WRITE_STATUS: 1013 case VIRTIO_CCW_DOING_WRITE_STATUS:
1014 case VIRTIO_CCW_DOING_READ_STATUS:
990 case VIRTIO_CCW_DOING_SET_VQ: 1015 case VIRTIO_CCW_DOING_SET_VQ:
991 case VIRTIO_CCW_DOING_SET_IND: 1016 case VIRTIO_CCW_DOING_SET_IND:
992 case VIRTIO_CCW_DOING_SET_CONF_IND: 1017 case VIRTIO_CCW_DOING_SET_CONF_IND:
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index d9e15210b110..5caf5f3ff642 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -64,9 +64,9 @@ int max_rport_logins = BFA_FCS_MAX_RPORT_LOGINS;
64u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size; 64u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
65u32 *bfi_image_cb, *bfi_image_ct, *bfi_image_ct2; 65u32 *bfi_image_cb, *bfi_image_ct, *bfi_image_ct2;
66 66
67#define BFAD_FW_FILE_CB "cbfw-3.2.3.0.bin" 67#define BFAD_FW_FILE_CB "cbfw-3.2.5.1.bin"
68#define BFAD_FW_FILE_CT "ctfw-3.2.3.0.bin" 68#define BFAD_FW_FILE_CT "ctfw-3.2.5.1.bin"
69#define BFAD_FW_FILE_CT2 "ct2fw-3.2.3.0.bin" 69#define BFAD_FW_FILE_CT2 "ct2fw-3.2.5.1.bin"
70 70
71static u32 *bfad_load_fwimg(struct pci_dev *pdev); 71static u32 *bfad_load_fwimg(struct pci_dev *pdev);
72static void bfad_free_fwimg(void); 72static void bfad_free_fwimg(void);
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index a9a00169ad91..b2e8c0dfc79c 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3363,7 +3363,7 @@ bfad_im_bsg_els_ct_request(struct bsg_job *job)
3363 struct bfad_fcxp *drv_fcxp; 3363 struct bfad_fcxp *drv_fcxp;
3364 struct bfa_fcs_lport_s *fcs_port; 3364 struct bfa_fcs_lport_s *fcs_port;
3365 struct bfa_fcs_rport_s *fcs_rport; 3365 struct bfa_fcs_rport_s *fcs_rport;
3366 struct fc_bsg_request *bsg_request = bsg_request; 3366 struct fc_bsg_request *bsg_request = job->request;
3367 struct fc_bsg_reply *bsg_reply = job->reply; 3367 struct fc_bsg_reply *bsg_reply = job->reply;
3368 uint32_t command_type = bsg_request->msgcode; 3368 uint32_t command_type = bsg_request->msgcode;
3369 unsigned long flags; 3369 unsigned long flags;
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index f9e862093a25..cfcfff48e8e1 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -58,7 +58,7 @@
58#ifdef BFA_DRIVER_VERSION 58#ifdef BFA_DRIVER_VERSION
59#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION 59#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
60#else 60#else
61#define BFAD_DRIVER_VERSION "3.2.25.0" 61#define BFAD_DRIVER_VERSION "3.2.25.1"
62#endif 62#endif
63 63
64#define BFAD_PROTO_NAME FCPI_NAME 64#define BFAD_PROTO_NAME FCPI_NAME
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 9ddc9200e0a4..9e4b7709043e 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -248,6 +248,7 @@ struct fnic {
248 struct completion *remove_wait; /* device remove thread blocks */ 248 struct completion *remove_wait; /* device remove thread blocks */
249 249
250 atomic_t in_flight; /* io counter */ 250 atomic_t in_flight; /* io counter */
251 bool internal_reset_inprogress;
251 u32 _reserved; /* fill hole */ 252 u32 _reserved; /* fill hole */
252 unsigned long state_flags; /* protected by host lock */ 253 unsigned long state_flags; /* protected by host lock */
253 enum fnic_state state; 254 enum fnic_state state;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37ece0a..adb3d5871e74 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2581,6 +2581,19 @@ int fnic_host_reset(struct scsi_cmnd *sc)
2581 unsigned long wait_host_tmo; 2581 unsigned long wait_host_tmo;
2582 struct Scsi_Host *shost = sc->device->host; 2582 struct Scsi_Host *shost = sc->device->host;
2583 struct fc_lport *lp = shost_priv(shost); 2583 struct fc_lport *lp = shost_priv(shost);
2584 struct fnic *fnic = lport_priv(lp);
2585 unsigned long flags;
2586
2587 spin_lock_irqsave(&fnic->fnic_lock, flags);
2588 if (fnic->internal_reset_inprogress == 0) {
2589 fnic->internal_reset_inprogress = 1;
2590 } else {
2591 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
2592 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
2593 "host reset in progress skipping another host reset\n");
2594 return SUCCESS;
2595 }
2596 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
2584 2597
2585 /* 2598 /*
2586 * If fnic_reset is successful, wait for fabric login to complete 2599 * If fnic_reset is successful, wait for fabric login to complete
@@ -2601,6 +2614,9 @@ int fnic_host_reset(struct scsi_cmnd *sc)
2601 } 2614 }
2602 } 2615 }
2603 2616
2617 spin_lock_irqsave(&fnic->fnic_lock, flags);
2618 fnic->internal_reset_inprogress = 0;
2619 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
2604 return ret; 2620 return ret;
2605} 2621}
2606 2622
diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index 3d3768aaab4f..99b747cedbeb 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -46,6 +46,7 @@
46 46
47#define INITIAL_SRP_LIMIT 800 47#define INITIAL_SRP_LIMIT 800
48#define DEFAULT_MAX_SECTORS 256 48#define DEFAULT_MAX_SECTORS 256
49#define MAX_TXU 1024 * 1024
49 50
50static uint max_vdma_size = MAX_H_COPY_RDMA; 51static uint max_vdma_size = MAX_H_COPY_RDMA;
51 52
@@ -1391,7 +1392,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
1391 } 1392 }
1392 1393
1393 info = dma_alloc_coherent(&vscsi->dma_dev->dev, sizeof(*info), &token, 1394 info = dma_alloc_coherent(&vscsi->dma_dev->dev, sizeof(*info), &token,
1394 GFP_KERNEL); 1395 GFP_ATOMIC);
1395 if (!info) { 1396 if (!info) {
1396 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n", 1397 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n",
1397 iue->target); 1398 iue->target);
@@ -1443,7 +1444,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
1443 info->mad_version = cpu_to_be32(MAD_VERSION_1); 1444 info->mad_version = cpu_to_be32(MAD_VERSION_1);
1444 info->os_type = cpu_to_be32(LINUX); 1445 info->os_type = cpu_to_be32(LINUX);
1445 memset(&info->port_max_txu[0], 0, sizeof(info->port_max_txu)); 1446 memset(&info->port_max_txu[0], 0, sizeof(info->port_max_txu));
1446 info->port_max_txu[0] = cpu_to_be32(128 * PAGE_SIZE); 1447 info->port_max_txu[0] = cpu_to_be32(MAX_TXU);
1447 1448
1448 dma_wmb(); 1449 dma_wmb();
1449 rc = h_copy_rdma(sizeof(*info), vscsi->dds.window[LOCAL].liobn, 1450 rc = h_copy_rdma(sizeof(*info), vscsi->dds.window[LOCAL].liobn,
@@ -1509,7 +1510,7 @@ static int ibmvscsis_cap_mad(struct scsi_info *vscsi, struct iu_entry *iue)
1509 } 1510 }
1510 1511
1511 cap = dma_alloc_coherent(&vscsi->dma_dev->dev, olen, &token, 1512 cap = dma_alloc_coherent(&vscsi->dma_dev->dev, olen, &token,
1512 GFP_KERNEL); 1513 GFP_ATOMIC);
1513 if (!cap) { 1514 if (!cap) {
1514 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n", 1515 dev_err(&vscsi->dev, "bad dma_alloc_coherent %p\n",
1515 iue->target); 1516 iue->target);
@@ -3585,7 +3586,7 @@ static int ibmvscsis_write_pending(struct se_cmd *se_cmd)
3585 1, 1); 3586 1, 1);
3586 if (rc) { 3587 if (rc) {
3587 pr_err("srp_transfer_data() failed: %d\n", rc); 3588 pr_err("srp_transfer_data() failed: %d\n", rc);
3588 return -EAGAIN; 3589 return -EIO;
3589 } 3590 }
3590 /* 3591 /*
3591 * We now tell TCM to add this WRITE CDB directly into the TCM storage 3592 * We now tell TCM to add this WRITE CDB directly into the TCM storage
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 236e4e51d161..7b6bd8ed0d0b 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -3590,12 +3590,14 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb)
3590 } else { 3590 } else {
3591 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; 3591 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
3592 lpfc_els_free_data(phba, buf_ptr1); 3592 lpfc_els_free_data(phba, buf_ptr1);
3593 elsiocb->context2 = NULL;
3593 } 3594 }
3594 } 3595 }
3595 3596
3596 if (elsiocb->context3) { 3597 if (elsiocb->context3) {
3597 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; 3598 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;
3598 lpfc_els_free_bpl(phba, buf_ptr); 3599 lpfc_els_free_bpl(phba, buf_ptr);
3600 elsiocb->context3 = NULL;
3599 } 3601 }
3600 lpfc_sli_release_iocbq(phba, elsiocb); 3602 lpfc_sli_release_iocbq(phba, elsiocb);
3601 return 0; 3603 return 0;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4faa7672fc1d..a78a3df68f67 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -5954,18 +5954,25 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
5954 5954
5955 free_vfi_bmask: 5955 free_vfi_bmask:
5956 kfree(phba->sli4_hba.vfi_bmask); 5956 kfree(phba->sli4_hba.vfi_bmask);
5957 phba->sli4_hba.vfi_bmask = NULL;
5957 free_xri_ids: 5958 free_xri_ids:
5958 kfree(phba->sli4_hba.xri_ids); 5959 kfree(phba->sli4_hba.xri_ids);
5960 phba->sli4_hba.xri_ids = NULL;
5959 free_xri_bmask: 5961 free_xri_bmask:
5960 kfree(phba->sli4_hba.xri_bmask); 5962 kfree(phba->sli4_hba.xri_bmask);
5963 phba->sli4_hba.xri_bmask = NULL;
5961 free_vpi_ids: 5964 free_vpi_ids:
5962 kfree(phba->vpi_ids); 5965 kfree(phba->vpi_ids);
5966 phba->vpi_ids = NULL;
5963 free_vpi_bmask: 5967 free_vpi_bmask:
5964 kfree(phba->vpi_bmask); 5968 kfree(phba->vpi_bmask);
5969 phba->vpi_bmask = NULL;
5965 free_rpi_ids: 5970 free_rpi_ids:
5966 kfree(phba->sli4_hba.rpi_ids); 5971 kfree(phba->sli4_hba.rpi_ids);
5972 phba->sli4_hba.rpi_ids = NULL;
5967 free_rpi_bmask: 5973 free_rpi_bmask:
5968 kfree(phba->sli4_hba.rpi_bmask); 5974 kfree(phba->sli4_hba.rpi_bmask);
5975 phba->sli4_hba.rpi_bmask = NULL;
5969 err_exit: 5976 err_exit:
5970 return rc; 5977 return rc;
5971} 5978}
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 394fe1338d09..dcb33f4fa687 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -393,6 +393,7 @@ struct MPT3SAS_TARGET {
393 * @eedp_enable: eedp support enable bit 393 * @eedp_enable: eedp support enable bit
394 * @eedp_type: 0(type_1), 1(type_2), 2(type_3) 394 * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
395 * @eedp_block_length: block size 395 * @eedp_block_length: block size
396 * @ata_command_pending: SATL passthrough outstanding for device
396 */ 397 */
397struct MPT3SAS_DEVICE { 398struct MPT3SAS_DEVICE {
398 struct MPT3SAS_TARGET *sas_target; 399 struct MPT3SAS_TARGET *sas_target;
@@ -404,6 +405,17 @@ struct MPT3SAS_DEVICE {
404 u8 ignore_delay_remove; 405 u8 ignore_delay_remove;
405 /* Iopriority Command Handling */ 406 /* Iopriority Command Handling */
406 u8 ncq_prio_enable; 407 u8 ncq_prio_enable;
408 /*
409 * Bug workaround for SATL handling: the mpt2/3sas firmware
410 * doesn't return BUSY or TASK_SET_FULL for subsequent
411 * commands while a SATL pass through is in operation as the
412 * spec requires, it simply does nothing with them until the
413 * pass through completes, causing them possibly to timeout if
414 * the passthrough is a long executing command (like format or
415 * secure erase). This variable allows us to do the right
416 * thing while a SATL command is pending.
417 */
418 unsigned long ata_command_pending;
407 419
408}; 420};
409 421
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index b5c966e319d3..75f3fce1c867 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3899,9 +3899,18 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
3899 } 3899 }
3900} 3900}
3901 3901
3902static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd) 3902static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
3903{ 3903{
3904 return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16); 3904 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
3905
3906 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
3907 return 0;
3908
3909 if (pending)
3910 return test_and_set_bit(0, &priv->ata_command_pending);
3911
3912 clear_bit(0, &priv->ata_command_pending);
3913 return 0;
3905} 3914}
3906 3915
3907/** 3916/**
@@ -3925,9 +3934,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
3925 if (!scmd) 3934 if (!scmd)
3926 continue; 3935 continue;
3927 count++; 3936 count++;
3928 if (ata_12_16_cmd(scmd)) 3937 _scsih_set_satl_pending(scmd, false);
3929 scsi_internal_device_unblock(scmd->device,
3930 SDEV_RUNNING);
3931 mpt3sas_base_free_smid(ioc, smid); 3938 mpt3sas_base_free_smid(ioc, smid);
3932 scsi_dma_unmap(scmd); 3939 scsi_dma_unmap(scmd);
3933 if (ioc->pci_error_recovery) 3940 if (ioc->pci_error_recovery)
@@ -4063,13 +4070,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
4063 if (ioc->logging_level & MPT_DEBUG_SCSI) 4070 if (ioc->logging_level & MPT_DEBUG_SCSI)
4064 scsi_print_command(scmd); 4071 scsi_print_command(scmd);
4065 4072
4066 /*
4067 * Lock the device for any subsequent command until command is
4068 * done.
4069 */
4070 if (ata_12_16_cmd(scmd))
4071 scsi_internal_device_block(scmd->device);
4072
4073 sas_device_priv_data = scmd->device->hostdata; 4073 sas_device_priv_data = scmd->device->hostdata;
4074 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { 4074 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
4075 scmd->result = DID_NO_CONNECT << 16; 4075 scmd->result = DID_NO_CONNECT << 16;
@@ -4083,6 +4083,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
4083 return 0; 4083 return 0;
4084 } 4084 }
4085 4085
4086 /*
4087 * Bug work around for firmware SATL handling. The loop
4088 * is based on atomic operations and ensures consistency
4089 * since we're lockless at this point
4090 */
4091 do {
4092 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4093 scmd->result = SAM_STAT_BUSY;
4094 scmd->scsi_done(scmd);
4095 return 0;
4096 }
4097 } while (_scsih_set_satl_pending(scmd, true));
4098
4086 sas_target_priv_data = sas_device_priv_data->sas_target; 4099 sas_target_priv_data = sas_device_priv_data->sas_target;
4087 4100
4088 /* invalid device handle */ 4101 /* invalid device handle */
@@ -4650,8 +4663,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
4650 if (scmd == NULL) 4663 if (scmd == NULL)
4651 return 1; 4664 return 1;
4652 4665
4653 if (ata_12_16_cmd(scmd)) 4666 _scsih_set_satl_pending(scmd, false);
4654 scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
4655 4667
4656 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); 4668 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
4657 4669
diff --git a/drivers/scsi/qedi/Kconfig b/drivers/scsi/qedi/Kconfig
index 23ca8a274586..21331453db7b 100644
--- a/drivers/scsi/qedi/Kconfig
+++ b/drivers/scsi/qedi/Kconfig
@@ -1,6 +1,6 @@
1config QEDI 1config QEDI
2 tristate "QLogic QEDI 25/40/100Gb iSCSI Initiator Driver Support" 2 tristate "QLogic QEDI 25/40/100Gb iSCSI Initiator Driver Support"
3 depends on PCI && SCSI 3 depends on PCI && SCSI && UIO
4 depends on QED 4 depends on QED
5 select SCSI_ISCSI_ATTRS 5 select SCSI_ISCSI_ATTRS
6 select QED_LL2 6 select QED_LL2
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 47eb4d545d13..f201f4099620 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -243,12 +243,15 @@ qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj,
243 struct qla_hw_data *ha = vha->hw; 243 struct qla_hw_data *ha = vha->hw;
244 ssize_t rval = 0; 244 ssize_t rval = 0;
245 245
246 mutex_lock(&ha->optrom_mutex);
247
246 if (ha->optrom_state != QLA_SREADING) 248 if (ha->optrom_state != QLA_SREADING)
247 return 0; 249 goto out;
248 250
249 mutex_lock(&ha->optrom_mutex);
250 rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer, 251 rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
251 ha->optrom_region_size); 252 ha->optrom_region_size);
253
254out:
252 mutex_unlock(&ha->optrom_mutex); 255 mutex_unlock(&ha->optrom_mutex);
253 256
254 return rval; 257 return rval;
@@ -263,14 +266,19 @@ qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj,
263 struct device, kobj))); 266 struct device, kobj)));
264 struct qla_hw_data *ha = vha->hw; 267 struct qla_hw_data *ha = vha->hw;
265 268
266 if (ha->optrom_state != QLA_SWRITING) 269 mutex_lock(&ha->optrom_mutex);
270
271 if (ha->optrom_state != QLA_SWRITING) {
272 mutex_unlock(&ha->optrom_mutex);
267 return -EINVAL; 273 return -EINVAL;
268 if (off > ha->optrom_region_size) 274 }
275 if (off > ha->optrom_region_size) {
276 mutex_unlock(&ha->optrom_mutex);
269 return -ERANGE; 277 return -ERANGE;
278 }
270 if (off + count > ha->optrom_region_size) 279 if (off + count > ha->optrom_region_size)
271 count = ha->optrom_region_size - off; 280 count = ha->optrom_region_size - off;
272 281
273 mutex_lock(&ha->optrom_mutex);
274 memcpy(&ha->optrom_buffer[off], buf, count); 282 memcpy(&ha->optrom_buffer[off], buf, count);
275 mutex_unlock(&ha->optrom_mutex); 283 mutex_unlock(&ha->optrom_mutex);
276 284
@@ -753,7 +761,6 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
753 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, 761 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
754 struct device, kobj))); 762 struct device, kobj)));
755 int type; 763 int type;
756 int rval = 0;
757 port_id_t did; 764 port_id_t did;
758 765
759 type = simple_strtol(buf, NULL, 10); 766 type = simple_strtol(buf, NULL, 10);
@@ -767,7 +774,7 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
767 774
768 ql_log(ql_log_info, vha, 0x70e4, "%s: %d\n", __func__, type); 775 ql_log(ql_log_info, vha, 0x70e4, "%s: %d\n", __func__, type);
769 776
770 rval = qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, did); 777 qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, did);
771 return count; 778 return count;
772} 779}
773 780
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index f7df01b76714..5b1287a63c49 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1556,7 +1556,8 @@ typedef struct {
1556struct atio { 1556struct atio {
1557 uint8_t entry_type; /* Entry type. */ 1557 uint8_t entry_type; /* Entry type. */
1558 uint8_t entry_count; /* Entry count. */ 1558 uint8_t entry_count; /* Entry count. */
1559 uint8_t data[58]; 1559 __le16 attr_n_length;
1560 uint8_t data[56];
1560 uint32_t signature; 1561 uint32_t signature;
1561#define ATIO_PROCESSED 0xDEADDEAD /* Signature */ 1562#define ATIO_PROCESSED 0xDEADDEAD /* Signature */
1562}; 1563};
@@ -2732,7 +2733,7 @@ struct isp_operations {
2732#define QLA_MSIX_FW_MODE(m) (((m) & (BIT_7|BIT_8|BIT_9)) >> 7) 2733#define QLA_MSIX_FW_MODE(m) (((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
2733#define QLA_MSIX_FW_MODE_1(m) (QLA_MSIX_FW_MODE(m) == 1) 2734#define QLA_MSIX_FW_MODE_1(m) (QLA_MSIX_FW_MODE(m) == 1)
2734 2735
2735#define QLA_MSIX_DEFAULT 0x00 2736#define QLA_BASE_VECTORS 2 /* default + RSP */
2736#define QLA_MSIX_RSP_Q 0x01 2737#define QLA_MSIX_RSP_Q 0x01
2737#define QLA_ATIO_VECTOR 0x02 2738#define QLA_ATIO_VECTOR 0x02
2738#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x03 2739#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x03
@@ -2754,7 +2755,6 @@ struct qla_msix_entry {
2754 uint16_t entry; 2755 uint16_t entry;
2755 char name[30]; 2756 char name[30];
2756 void *handle; 2757 void *handle;
2757 struct irq_affinity_notify irq_notify;
2758 int cpuid; 2758 int cpuid;
2759}; 2759};
2760 2760
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 632d5f30386a..7b6317c8c2e9 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1191,7 +1191,7 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
1191 1191
1192 /* Wait for soft-reset to complete. */ 1192 /* Wait for soft-reset to complete. */
1193 RD_REG_DWORD(&reg->ctrl_status); 1193 RD_REG_DWORD(&reg->ctrl_status);
1194 for (cnt = 0; cnt < 6000000; cnt++) { 1194 for (cnt = 0; cnt < 60; cnt++) {
1195 barrier(); 1195 barrier();
1196 if ((RD_REG_DWORD(&reg->ctrl_status) & 1196 if ((RD_REG_DWORD(&reg->ctrl_status) &
1197 CSRX_ISP_SOFT_RESET) == 0) 1197 CSRX_ISP_SOFT_RESET) == 0)
@@ -1234,7 +1234,7 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
1234 RD_REG_DWORD(&reg->hccr); 1234 RD_REG_DWORD(&reg->hccr);
1235 1235
1236 RD_REG_WORD(&reg->mailbox0); 1236 RD_REG_WORD(&reg->mailbox0);
1237 for (cnt = 6000000; RD_REG_WORD(&reg->mailbox0) != 0 && 1237 for (cnt = 60; RD_REG_WORD(&reg->mailbox0) != 0 &&
1238 rval == QLA_SUCCESS; cnt--) { 1238 rval == QLA_SUCCESS; cnt--) {
1239 barrier(); 1239 barrier();
1240 if (cnt) 1240 if (cnt)
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 5093ca9b02ec..dc88a09f9043 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -19,10 +19,6 @@ static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *);
19static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *); 19static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *);
20static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *, 20static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
21 sts_entry_t *); 21 sts_entry_t *);
22static void qla_irq_affinity_notify(struct irq_affinity_notify *,
23 const cpumask_t *);
24static void qla_irq_affinity_release(struct kref *);
25
26 22
27/** 23/**
28 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. 24 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
@@ -2496,6 +2492,10 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
2496 if (pkt->entry_status & RF_BUSY) 2492 if (pkt->entry_status & RF_BUSY)
2497 res = DID_BUS_BUSY << 16; 2493 res = DID_BUS_BUSY << 16;
2498 2494
2495 if (pkt->entry_type == NOTIFY_ACK_TYPE &&
2496 pkt->handle == QLA_TGT_SKIP_HANDLE)
2497 return;
2498
2499 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); 2499 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
2500 if (sp) { 2500 if (sp) {
2501 sp->done(ha, sp, res); 2501 sp->done(ha, sp, res);
@@ -2572,14 +2572,6 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
2572 if (!vha->flags.online) 2572 if (!vha->flags.online)
2573 return; 2573 return;
2574 2574
2575 if (rsp->msix && rsp->msix->cpuid != smp_processor_id()) {
2576 /* if kernel does not notify qla of IRQ's CPU change,
2577 * then set it here.
2578 */
2579 rsp->msix->cpuid = smp_processor_id();
2580 ha->tgt.rspq_vector_cpuid = rsp->msix->cpuid;
2581 }
2582
2583 while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { 2575 while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) {
2584 pkt = (struct sts_entry_24xx *)rsp->ring_ptr; 2576 pkt = (struct sts_entry_24xx *)rsp->ring_ptr;
2585 2577
@@ -3018,13 +3010,20 @@ static struct qla_init_msix_entry qla82xx_msix_entries[] = {
3018static int 3010static int
3019qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) 3011qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
3020{ 3012{
3021#define MIN_MSIX_COUNT 2
3022 int i, ret; 3013 int i, ret;
3023 struct qla_msix_entry *qentry; 3014 struct qla_msix_entry *qentry;
3024 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); 3015 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
3016 struct irq_affinity desc = {
3017 .pre_vectors = QLA_BASE_VECTORS,
3018 };
3019
3020 if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha))
3021 desc.pre_vectors++;
3022
3023 ret = pci_alloc_irq_vectors_affinity(ha->pdev, QLA_BASE_VECTORS,
3024 ha->msix_count, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY,
3025 &desc);
3025 3026
3026 ret = pci_alloc_irq_vectors(ha->pdev, MIN_MSIX_COUNT, ha->msix_count,
3027 PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
3028 if (ret < 0) { 3027 if (ret < 0) {
3029 ql_log(ql_log_fatal, vha, 0x00c7, 3028 ql_log(ql_log_fatal, vha, 0x00c7,
3030 "MSI-X: Failed to enable support, " 3029 "MSI-X: Failed to enable support, "
@@ -3069,13 +3068,10 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
3069 qentry->have_irq = 0; 3068 qentry->have_irq = 0;
3070 qentry->in_use = 0; 3069 qentry->in_use = 0;
3071 qentry->handle = NULL; 3070 qentry->handle = NULL;
3072 qentry->irq_notify.notify = qla_irq_affinity_notify;
3073 qentry->irq_notify.release = qla_irq_affinity_release;
3074 qentry->cpuid = -1;
3075 } 3071 }
3076 3072
3077 /* Enable MSI-X vectors for the base queue */ 3073 /* Enable MSI-X vectors for the base queue */
3078 for (i = 0; i < (QLA_MSIX_RSP_Q + 1); i++) { 3074 for (i = 0; i < QLA_BASE_VECTORS; i++) {
3079 qentry = &ha->msix_entries[i]; 3075 qentry = &ha->msix_entries[i];
3080 qentry->handle = rsp; 3076 qentry->handle = rsp;
3081 rsp->msix = qentry; 3077 rsp->msix = qentry;
@@ -3093,18 +3089,6 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
3093 goto msix_register_fail; 3089 goto msix_register_fail;
3094 qentry->have_irq = 1; 3090 qentry->have_irq = 1;
3095 qentry->in_use = 1; 3091 qentry->in_use = 1;
3096
3097 /* Register for CPU affinity notification. */
3098 irq_set_affinity_notifier(qentry->vector, &qentry->irq_notify);
3099
3100 /* Schedule work (ie. trigger a notification) to read cpu
3101 * mask for this specific irq.
3102 * kref_get is required because
3103 * irq_affinity_notify() will do
3104 * kref_put().
3105 */
3106 kref_get(&qentry->irq_notify.kref);
3107 schedule_work(&qentry->irq_notify.work);
3108 } 3092 }
3109 3093
3110 /* 3094 /*
@@ -3301,49 +3285,3 @@ int qla25xx_request_irq(struct qla_hw_data *ha, struct qla_qpair *qpair,
3301 msix->handle = qpair; 3285 msix->handle = qpair;
3302 return ret; 3286 return ret;
3303} 3287}
3304
3305
3306/* irq_set_affinity/irqbalance will trigger notification of cpu mask update */
3307static void qla_irq_affinity_notify(struct irq_affinity_notify *notify,
3308 const cpumask_t *mask)
3309{
3310 struct qla_msix_entry *e =
3311 container_of(notify, struct qla_msix_entry, irq_notify);
3312 struct qla_hw_data *ha;
3313 struct scsi_qla_host *base_vha;
3314 struct rsp_que *rsp = e->handle;
3315
3316 /* user is recommended to set mask to just 1 cpu */
3317 e->cpuid = cpumask_first(mask);
3318
3319 ha = rsp->hw;
3320 base_vha = pci_get_drvdata(ha->pdev);
3321
3322 ql_dbg(ql_dbg_init, base_vha, 0xffff,
3323 "%s: host %ld : vector %d cpu %d \n", __func__,
3324 base_vha->host_no, e->vector, e->cpuid);
3325
3326 if (e->have_irq) {
3327 if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) &&
3328 (e->entry == QLA83XX_RSPQ_MSIX_ENTRY_NUMBER)) {
3329 ha->tgt.rspq_vector_cpuid = e->cpuid;
3330 ql_dbg(ql_dbg_init, base_vha, 0xffff,
3331 "%s: host%ld: rspq vector %d cpu %d runtime change\n",
3332 __func__, base_vha->host_no, e->vector, e->cpuid);
3333 }
3334 }
3335}
3336
3337static void qla_irq_affinity_release(struct kref *ref)
3338{
3339 struct irq_affinity_notify *notify =
3340 container_of(ref, struct irq_affinity_notify, kref);
3341 struct qla_msix_entry *e =
3342 container_of(notify, struct qla_msix_entry, irq_notify);
3343 struct rsp_que *rsp = e->handle;
3344 struct scsi_qla_host *base_vha = pci_get_drvdata(rsp->hw->pdev);
3345
3346 ql_dbg(ql_dbg_init, base_vha, 0xffff,
3347 "%s: host%ld: vector %d cpu %d\n", __func__,
3348 base_vha->host_no, e->vector, e->cpuid);
3349}
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 2819ceb96041..67f64db390b0 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -10,7 +10,7 @@
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12 12
13struct rom_cmd { 13static struct rom_cmd {
14 uint16_t cmd; 14 uint16_t cmd;
15} rom_cmds[] = { 15} rom_cmds[] = {
16 { MBC_LOAD_RAM }, 16 { MBC_LOAD_RAM },
@@ -101,12 +101,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
101 return QLA_FUNCTION_TIMEOUT; 101 return QLA_FUNCTION_TIMEOUT;
102 } 102 }
103 103
104 /* if PCI error, then avoid mbx processing.*/ 104 /* if PCI error, then avoid mbx processing.*/
105 if (test_bit(PCI_ERR, &base_vha->dpc_flags)) { 105 if (test_bit(PCI_ERR, &base_vha->dpc_flags)) {
106 ql_log(ql_log_warn, vha, 0x1191, 106 ql_log(ql_log_warn, vha, 0x1191,
107 "PCI error, exiting.\n"); 107 "PCI error, exiting.\n");
108 return QLA_FUNCTION_TIMEOUT; 108 return QLA_FUNCTION_TIMEOUT;
109 } 109 }
110 110
111 reg = ha->iobase; 111 reg = ha->iobase;
112 io_lock_on = base_vha->flags.init_done; 112 io_lock_on = base_vha->flags.init_done;
@@ -323,20 +323,33 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
323 } 323 }
324 } else { 324 } else {
325 325
326 uint16_t mb0; 326 uint16_t mb[8];
327 uint32_t ictrl; 327 uint32_t ictrl, host_status, hccr;
328 uint16_t w; 328 uint16_t w;
329 329
330 if (IS_FWI2_CAPABLE(ha)) { 330 if (IS_FWI2_CAPABLE(ha)) {
331 mb0 = RD_REG_WORD(&reg->isp24.mailbox0); 331 mb[0] = RD_REG_WORD(&reg->isp24.mailbox0);
332 mb[1] = RD_REG_WORD(&reg->isp24.mailbox1);
333 mb[2] = RD_REG_WORD(&reg->isp24.mailbox2);
334 mb[3] = RD_REG_WORD(&reg->isp24.mailbox3);
335 mb[7] = RD_REG_WORD(&reg->isp24.mailbox7);
332 ictrl = RD_REG_DWORD(&reg->isp24.ictrl); 336 ictrl = RD_REG_DWORD(&reg->isp24.ictrl);
337 host_status = RD_REG_DWORD(&reg->isp24.host_status);
338 hccr = RD_REG_DWORD(&reg->isp24.hccr);
339
340 ql_log(ql_log_warn, vha, 0x1119,
341 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
342 "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n",
343 command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3],
344 mb[7], host_status, hccr);
345
333 } else { 346 } else {
334 mb0 = RD_MAILBOX_REG(ha, &reg->isp, 0); 347 mb[0] = RD_MAILBOX_REG(ha, &reg->isp, 0);
335 ictrl = RD_REG_WORD(&reg->isp.ictrl); 348 ictrl = RD_REG_WORD(&reg->isp.ictrl);
349 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
350 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
351 "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]);
336 } 352 }
337 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
338 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
339 "mb[0]=0x%x\n", command, ictrl, jiffies, mb0);
340 ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); 353 ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019);
341 354
342 /* Capture FW dump only, if PCI device active */ 355 /* Capture FW dump only, if PCI device active */
@@ -684,7 +697,6 @@ qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
684 mbx_cmd_t mc; 697 mbx_cmd_t mc;
685 mbx_cmd_t *mcp = &mc; 698 mbx_cmd_t *mcp = &mc;
686 struct qla_hw_data *ha = vha->hw; 699 struct qla_hw_data *ha = vha->hw;
687 int configured_count;
688 700
689 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a, 701 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a,
690 "Entered %s.\n", __func__); 702 "Entered %s.\n", __func__);
@@ -707,7 +719,6 @@ qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
707 /*EMPTY*/ 719 /*EMPTY*/
708 ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval); 720 ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval);
709 } else { 721 } else {
710 configured_count = mcp->mb[11];
711 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c, 722 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
712 "Done %s.\n", __func__); 723 "Done %s.\n", __func__);
713 } 724 }
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 54380b434b30..0a1723cc08cf 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -42,6 +42,11 @@ static int qla82xx_crb_table_initialized;
42 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \ 42 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \
43 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20) 43 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20)
44 44
45const int MD_MIU_TEST_AGT_RDDATA[] = {
46 0x410000A8, 0x410000AC,
47 0x410000B8, 0x410000BC
48};
49
45static void qla82xx_crb_addr_transform_setup(void) 50static void qla82xx_crb_addr_transform_setup(void)
46{ 51{
47 qla82xx_crb_addr_transform(XDMA); 52 qla82xx_crb_addr_transform(XDMA);
diff --git a/drivers/scsi/qla2xxx/qla_nx.h b/drivers/scsi/qla2xxx/qla_nx.h
index 6201dce3553b..77624eac95a4 100644
--- a/drivers/scsi/qla2xxx/qla_nx.h
+++ b/drivers/scsi/qla2xxx/qla_nx.h
@@ -1176,8 +1176,7 @@ struct qla82xx_md_entry_queue {
1176#define MD_MIU_TEST_AGT_ADDR_LO 0x41000094 1176#define MD_MIU_TEST_AGT_ADDR_LO 0x41000094
1177#define MD_MIU_TEST_AGT_ADDR_HI 0x41000098 1177#define MD_MIU_TEST_AGT_ADDR_HI 0x41000098
1178 1178
1179static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8, 0x410000AC, 1179extern const int MD_MIU_TEST_AGT_RDDATA[4];
1180 0x410000B8, 0x410000BC };
1181 1180
1182#define CRB_NIU_XG_PAUSE_CTL_P0 0x1 1181#define CRB_NIU_XG_PAUSE_CTL_P0 0x1
1183#define CRB_NIU_XG_PAUSE_CTL_P1 0x8 1182#define CRB_NIU_XG_PAUSE_CTL_P1 0x8
diff --git a/drivers/scsi/qla2xxx/qla_nx2.c b/drivers/scsi/qla2xxx/qla_nx2.c
index 007192d7bad8..dc1ec9b61027 100644
--- a/drivers/scsi/qla2xxx/qla_nx2.c
+++ b/drivers/scsi/qla2xxx/qla_nx2.c
@@ -15,6 +15,23 @@
15 15
16#define TIMEOUT_100_MS 100 16#define TIMEOUT_100_MS 100
17 17
18static const uint32_t qla8044_reg_tbl[] = {
19 QLA8044_PEG_HALT_STATUS1,
20 QLA8044_PEG_HALT_STATUS2,
21 QLA8044_PEG_ALIVE_COUNTER,
22 QLA8044_CRB_DRV_ACTIVE,
23 QLA8044_CRB_DEV_STATE,
24 QLA8044_CRB_DRV_STATE,
25 QLA8044_CRB_DRV_SCRATCH,
26 QLA8044_CRB_DEV_PART_INFO1,
27 QLA8044_CRB_IDC_VER_MAJOR,
28 QLA8044_FW_VER_MAJOR,
29 QLA8044_FW_VER_MINOR,
30 QLA8044_FW_VER_SUB,
31 QLA8044_CMDPEG_STATE,
32 QLA8044_ASIC_TEMP,
33};
34
18/* 8044 Flash Read/Write functions */ 35/* 8044 Flash Read/Write functions */
19uint32_t 36uint32_t
20qla8044_rd_reg(struct qla_hw_data *ha, ulong addr) 37qla8044_rd_reg(struct qla_hw_data *ha, ulong addr)
diff --git a/drivers/scsi/qla2xxx/qla_nx2.h b/drivers/scsi/qla2xxx/qla_nx2.h
index 02fe3c4cdf55..83c1b7e17c80 100644
--- a/drivers/scsi/qla2xxx/qla_nx2.h
+++ b/drivers/scsi/qla2xxx/qla_nx2.h
@@ -535,23 +535,6 @@ enum qla_regs {
535#define CRB_CMDPEG_CHECK_RETRY_COUNT 60 535#define CRB_CMDPEG_CHECK_RETRY_COUNT 60
536#define CRB_CMDPEG_CHECK_DELAY 500 536#define CRB_CMDPEG_CHECK_DELAY 500
537 537
538static const uint32_t qla8044_reg_tbl[] = {
539 QLA8044_PEG_HALT_STATUS1,
540 QLA8044_PEG_HALT_STATUS2,
541 QLA8044_PEG_ALIVE_COUNTER,
542 QLA8044_CRB_DRV_ACTIVE,
543 QLA8044_CRB_DEV_STATE,
544 QLA8044_CRB_DRV_STATE,
545 QLA8044_CRB_DRV_SCRATCH,
546 QLA8044_CRB_DEV_PART_INFO1,
547 QLA8044_CRB_IDC_VER_MAJOR,
548 QLA8044_FW_VER_MAJOR,
549 QLA8044_FW_VER_MINOR,
550 QLA8044_FW_VER_SUB,
551 QLA8044_CMDPEG_STATE,
552 QLA8044_ASIC_TEMP,
553};
554
555/* MiniDump Structures */ 538/* MiniDump Structures */
556 539
557/* Driver_code is for driver to write some info about the entry 540/* Driver_code is for driver to write some info about the entry
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 8521cfe302e9..0a000ecf0881 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -466,7 +466,7 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
466 continue; 466 continue;
467 467
468 rsp = ha->rsp_q_map[cnt]; 468 rsp = ha->rsp_q_map[cnt];
469 clear_bit(cnt, ha->req_qid_map); 469 clear_bit(cnt, ha->rsp_qid_map);
470 ha->rsp_q_map[cnt] = NULL; 470 ha->rsp_q_map[cnt] = NULL;
471 spin_unlock_irqrestore(&ha->hardware_lock, flags); 471 spin_unlock_irqrestore(&ha->hardware_lock, flags);
472 qla2x00_free_rsp_que(ha, rsp); 472 qla2x00_free_rsp_que(ha, rsp);
@@ -3662,7 +3662,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3662 sizeof(struct ct6_dsd), 0, 3662 sizeof(struct ct6_dsd), 0,
3663 SLAB_HWCACHE_ALIGN, NULL); 3663 SLAB_HWCACHE_ALIGN, NULL);
3664 if (!ctx_cachep) 3664 if (!ctx_cachep)
3665 goto fail_free_gid_list; 3665 goto fail_free_srb_mempool;
3666 } 3666 }
3667 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, 3667 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ,
3668 ctx_cachep); 3668 ctx_cachep);
@@ -3815,7 +3815,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3815 ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), 3815 ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long),
3816 GFP_KERNEL); 3816 GFP_KERNEL);
3817 if (!ha->loop_id_map) 3817 if (!ha->loop_id_map)
3818 goto fail_async_pd; 3818 goto fail_loop_id_map;
3819 else { 3819 else {
3820 qla2x00_set_reserved_loop_ids(ha); 3820 qla2x00_set_reserved_loop_ids(ha);
3821 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, 3821 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123,
@@ -3824,6 +3824,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3824 3824
3825 return 0; 3825 return 0;
3826 3826
3827fail_loop_id_map:
3828 dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
3827fail_async_pd: 3829fail_async_pd:
3828 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); 3830 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
3829fail_ex_init_cb: 3831fail_ex_init_cb:
@@ -3851,6 +3853,10 @@ fail_free_ms_iocb:
3851 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); 3853 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
3852 ha->ms_iocb = NULL; 3854 ha->ms_iocb = NULL;
3853 ha->ms_iocb_dma = 0; 3855 ha->ms_iocb_dma = 0;
3856
3857 if (ha->sns_cmd)
3858 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
3859 ha->sns_cmd, ha->sns_cmd_dma);
3854fail_dma_pool: 3860fail_dma_pool:
3855 if (IS_QLA82XX(ha) || ql2xenabledif) { 3861 if (IS_QLA82XX(ha) || ql2xenabledif) {
3856 dma_pool_destroy(ha->fcp_cmnd_dma_pool); 3862 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
@@ -3868,10 +3874,12 @@ fail_free_nvram:
3868 kfree(ha->nvram); 3874 kfree(ha->nvram);
3869 ha->nvram = NULL; 3875 ha->nvram = NULL;
3870fail_free_ctx_mempool: 3876fail_free_ctx_mempool:
3871 mempool_destroy(ha->ctx_mempool); 3877 if (ha->ctx_mempool)
3878 mempool_destroy(ha->ctx_mempool);
3872 ha->ctx_mempool = NULL; 3879 ha->ctx_mempool = NULL;
3873fail_free_srb_mempool: 3880fail_free_srb_mempool:
3874 mempool_destroy(ha->srb_mempool); 3881 if (ha->srb_mempool)
3882 mempool_destroy(ha->srb_mempool);
3875 ha->srb_mempool = NULL; 3883 ha->srb_mempool = NULL;
3876fail_free_gid_list: 3884fail_free_gid_list:
3877 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), 3885 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index bff9689f5ca9..e4fda84b959e 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -668,11 +668,9 @@ static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd)
668{ 668{
669 struct qla_hw_data *ha = vha->hw; 669 struct qla_hw_data *ha = vha->hw;
670 struct qla_tgt_sess *sess = NULL; 670 struct qla_tgt_sess *sess = NULL;
671 uint32_t unpacked_lun, lun = 0;
672 uint16_t loop_id; 671 uint16_t loop_id;
673 int res = 0; 672 int res = 0;
674 struct imm_ntfy_from_isp *n = (struct imm_ntfy_from_isp *)iocb; 673 struct imm_ntfy_from_isp *n = (struct imm_ntfy_from_isp *)iocb;
675 struct atio_from_isp *a = (struct atio_from_isp *)iocb;
676 unsigned long flags; 674 unsigned long flags;
677 675
678 loop_id = le16_to_cpu(n->u.isp24.nport_handle); 676 loop_id = le16_to_cpu(n->u.isp24.nport_handle);
@@ -725,11 +723,7 @@ static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd)
725 "loop_id %d)\n", vha->host_no, sess, sess->port_name, 723 "loop_id %d)\n", vha->host_no, sess, sess->port_name,
726 mcmd, loop_id); 724 mcmd, loop_id);
727 725
728 lun = a->u.isp24.fcp_cmnd.lun; 726 return qlt_issue_task_mgmt(sess, 0, mcmd, iocb, QLA24XX_MGMT_SEND_NACK);
729 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
730
731 return qlt_issue_task_mgmt(sess, unpacked_lun, mcmd,
732 iocb, QLA24XX_MGMT_SEND_NACK);
733} 727}
734 728
735/* ha->tgt.sess_lock supposed to be held on entry */ 729/* ha->tgt.sess_lock supposed to be held on entry */
@@ -3067,7 +3061,7 @@ static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha,
3067 3061
3068 pkt->entry_type = NOTIFY_ACK_TYPE; 3062 pkt->entry_type = NOTIFY_ACK_TYPE;
3069 pkt->entry_count = 1; 3063 pkt->entry_count = 1;
3070 pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; 3064 pkt->handle = QLA_TGT_SKIP_HANDLE;
3071 3065
3072 nack = (struct nack_to_isp *)pkt; 3066 nack = (struct nack_to_isp *)pkt;
3073 nack->ox_id = ntfy->ox_id; 3067 nack->ox_id = ntfy->ox_id;
@@ -3110,6 +3104,9 @@ static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
3110#if 0 /* Todo */ 3104#if 0 /* Todo */
3111 if (rc == -ENOMEM) 3105 if (rc == -ENOMEM)
3112 qlt_alloc_qfull_cmd(vha, imm, 0, 0); 3106 qlt_alloc_qfull_cmd(vha, imm, 0, 0);
3107#else
3108 if (rc) {
3109 }
3113#endif 3110#endif
3114 goto done; 3111 goto done;
3115 } 3112 }
@@ -6457,12 +6454,29 @@ qlt_24xx_process_atio_queue(struct scsi_qla_host *vha, uint8_t ha_locked)
6457 if (!vha->flags.online) 6454 if (!vha->flags.online)
6458 return; 6455 return;
6459 6456
6460 while (ha->tgt.atio_ring_ptr->signature != ATIO_PROCESSED) { 6457 while ((ha->tgt.atio_ring_ptr->signature != ATIO_PROCESSED) ||
6458 fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr)) {
6461 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr; 6459 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr;
6462 cnt = pkt->u.raw.entry_count; 6460 cnt = pkt->u.raw.entry_count;
6463 6461
6464 qlt_24xx_atio_pkt_all_vps(vha, (struct atio_from_isp *)pkt, 6462 if (unlikely(fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr))) {
6465 ha_locked); 6463 /*
6464 * This packet is corrupted. The header + payload
6465 * can not be trusted. There is no point in passing
6466 * it further up.
6467 */
6468 ql_log(ql_log_warn, vha, 0xffff,
6469 "corrupted fcp frame SID[%3phN] OXID[%04x] EXCG[%x] %64phN\n",
6470 pkt->u.isp24.fcp_hdr.s_id,
6471 be16_to_cpu(pkt->u.isp24.fcp_hdr.ox_id),
6472 le32_to_cpu(pkt->u.isp24.exchange_addr), pkt);
6473
6474 adjust_corrupted_atio(pkt);
6475 qlt_send_term_exchange(vha, NULL, pkt, ha_locked, 0);
6476 } else {
6477 qlt_24xx_atio_pkt_all_vps(vha,
6478 (struct atio_from_isp *)pkt, ha_locked);
6479 }
6466 6480
6467 for (i = 0; i < cnt; i++) { 6481 for (i = 0; i < cnt; i++) {
6468 ha->tgt.atio_ring_index++; 6482 ha->tgt.atio_ring_index++;
@@ -6545,6 +6559,13 @@ qlt_24xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_24xx *nv)
6545 6559
6546 /* Disable Full Login after LIP */ 6560 /* Disable Full Login after LIP */
6547 nv->host_p &= cpu_to_le32(~BIT_10); 6561 nv->host_p &= cpu_to_le32(~BIT_10);
6562
6563 /*
6564 * clear BIT 15 explicitly as we have seen at least
6565 * a couple of instances where this was set and this
6566 * was causing the firmware to not be initialized.
6567 */
6568 nv->firmware_options_1 &= cpu_to_le32(~BIT_15);
6548 /* Enable target PRLI control */ 6569 /* Enable target PRLI control */
6549 nv->firmware_options_2 |= cpu_to_le32(BIT_14); 6570 nv->firmware_options_2 |= cpu_to_le32(BIT_14);
6550 } else { 6571 } else {
@@ -6560,9 +6581,6 @@ qlt_24xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_24xx *nv)
6560 return; 6581 return;
6561 } 6582 }
6562 6583
6563 /* out-of-order frames reassembly */
6564 nv->firmware_options_3 |= BIT_6|BIT_9;
6565
6566 if (ha->tgt.enable_class_2) { 6584 if (ha->tgt.enable_class_2) {
6567 if (vha->flags.init_done) 6585 if (vha->flags.init_done)
6568 fc_host_supported_classes(vha->host) = 6586 fc_host_supported_classes(vha->host) =
@@ -6629,11 +6647,17 @@ qlt_81xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_81xx *nv)
6629 /* Disable ini mode, if requested */ 6647 /* Disable ini mode, if requested */
6630 if (!qla_ini_mode_enabled(vha)) 6648 if (!qla_ini_mode_enabled(vha))
6631 nv->firmware_options_1 |= cpu_to_le32(BIT_5); 6649 nv->firmware_options_1 |= cpu_to_le32(BIT_5);
6632
6633 /* Disable Full Login after LIP */ 6650 /* Disable Full Login after LIP */
6634 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); 6651 nv->firmware_options_1 &= cpu_to_le32(~BIT_13);
6635 /* Enable initial LIP */ 6652 /* Enable initial LIP */
6636 nv->firmware_options_1 &= cpu_to_le32(~BIT_9); 6653 nv->firmware_options_1 &= cpu_to_le32(~BIT_9);
6654 /*
6655 * clear BIT 15 explicitly as we have seen at
6656 * least a couple of instances where this was set
6657 * and this was causing the firmware to not be
6658 * initialized.
6659 */
6660 nv->firmware_options_1 &= cpu_to_le32(~BIT_15);
6637 if (ql2xtgt_tape_enable) 6661 if (ql2xtgt_tape_enable)
6638 /* Enable FC tape support */ 6662 /* Enable FC tape support */
6639 nv->firmware_options_2 |= cpu_to_le32(BIT_12); 6663 nv->firmware_options_2 |= cpu_to_le32(BIT_12);
@@ -6658,9 +6682,6 @@ qlt_81xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_81xx *nv)
6658 return; 6682 return;
6659 } 6683 }
6660 6684
6661 /* out-of-order frames reassembly */
6662 nv->firmware_options_3 |= BIT_6|BIT_9;
6663
6664 if (ha->tgt.enable_class_2) { 6685 if (ha->tgt.enable_class_2) {
6665 if (vha->flags.init_done) 6686 if (vha->flags.init_done)
6666 fc_host_supported_classes(vha->host) = 6687 fc_host_supported_classes(vha->host) =
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index f26c5f60eedd..0824a8164a24 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -427,13 +427,33 @@ struct atio_from_isp {
427 struct { 427 struct {
428 uint8_t entry_type; /* Entry type. */ 428 uint8_t entry_type; /* Entry type. */
429 uint8_t entry_count; /* Entry count. */ 429 uint8_t entry_count; /* Entry count. */
430 uint8_t data[58]; 430 __le16 attr_n_length;
431#define FCP_CMD_LENGTH_MASK 0x0fff
432#define FCP_CMD_LENGTH_MIN 0x38
433 uint8_t data[56];
431 uint32_t signature; 434 uint32_t signature;
432#define ATIO_PROCESSED 0xDEADDEAD /* Signature */ 435#define ATIO_PROCESSED 0xDEADDEAD /* Signature */
433 } raw; 436 } raw;
434 } u; 437 } u;
435} __packed; 438} __packed;
436 439
440static inline int fcpcmd_is_corrupted(struct atio *atio)
441{
442 if (atio->entry_type == ATIO_TYPE7 &&
443 (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) <
444 FCP_CMD_LENGTH_MIN))
445 return 1;
446 else
447 return 0;
448}
449
450/* adjust corrupted atio so we won't trip over the same entry again. */
451static inline void adjust_corrupted_atio(struct atio_from_isp *atio)
452{
453 atio->u.raw.attr_n_length = cpu_to_le16(FCP_CMD_LENGTH_MIN);
454 atio->u.isp24.fcp_cmnd.add_cdb_len = 0;
455}
456
437#define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */ 457#define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */
438 458
439/* 459/*
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 36935c9ed669..8a58ef3adab4 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -433,6 +433,18 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
433 count++; 433 count++;
434 } 434 }
435 } 435 }
436 } else if (QLA_TGT_MODE_ENABLED() &&
437 ent->t263.queue_type == T263_QUEUE_TYPE_ATIO) {
438 struct qla_hw_data *ha = vha->hw;
439 struct atio *atr = ha->tgt.atio_ring;
440
441 if (atr || !buf) {
442 length = ha->tgt.atio_q_length;
443 qla27xx_insert16(0, buf, len);
444 qla27xx_insert16(length, buf, len);
445 qla27xx_insertbuf(atr, length * sizeof(*atr), buf, len);
446 count++;
447 }
436 } else { 448 } else {
437 ql_dbg(ql_dbg_misc, vha, 0xd026, 449 ql_dbg(ql_dbg_misc, vha, 0xd026,
438 "%s: unknown queue %x\n", __func__, ent->t263.queue_type); 450 "%s: unknown queue %x\n", __func__, ent->t263.queue_type);
@@ -676,6 +688,18 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
676 count++; 688 count++;
677 } 689 }
678 } 690 }
691 } else if (QLA_TGT_MODE_ENABLED() &&
692 ent->t274.queue_type == T274_QUEUE_TYPE_ATIO_SHAD) {
693 struct qla_hw_data *ha = vha->hw;
694 struct atio *atr = ha->tgt.atio_ring_ptr;
695
696 if (atr || !buf) {
697 qla27xx_insert16(0, buf, len);
698 qla27xx_insert16(1, buf, len);
699 qla27xx_insert32(ha->tgt.atio_q_in ?
700 readl(ha->tgt.atio_q_in) : 0, buf, len);
701 count++;
702 }
679 } else { 703 } else {
680 ql_dbg(ql_dbg_misc, vha, 0xd02f, 704 ql_dbg(ql_dbg_misc, vha, 0xd02f,
681 "%s: unknown queue %x\n", __func__, ent->t274.queue_type); 705 "%s: unknown queue %x\n", __func__, ent->t274.queue_type);
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 6643f6fc7795..d925910be761 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1800,7 +1800,7 @@ static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item,
1800{ 1800{
1801 return sprintf(page, 1801 return sprintf(page,
1802 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " 1802 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
1803 UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname, 1803 UTS_RELEASE"\n", QLA2XXX_VERSION, utsname()->sysname,
1804 utsname()->machine); 1804 utsname()->machine);
1805} 1805}
1806 1806
@@ -1906,7 +1906,7 @@ static int tcm_qla2xxx_register_configfs(void)
1906 int ret; 1906 int ret;
1907 1907
1908 pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on " 1908 pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on "
1909 UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname, 1909 UTS_RELEASE"\n", QLA2XXX_VERSION, utsname()->sysname,
1910 utsname()->machine); 1910 utsname()->machine);
1911 1911
1912 ret = target_register_template(&tcm_qla2xxx_ops); 1912 ret = target_register_template(&tcm_qla2xxx_ops);
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 37e026a4823d..cf8430be183b 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -1,7 +1,6 @@
1#include <target/target_core_base.h> 1#include <target/target_core_base.h>
2#include <linux/btree.h> 2#include <linux/btree.h>
3 3
4#define TCM_QLA2XXX_VERSION "v0.1"
5/* length of ASCII WWPNs including pad */ 4/* length of ASCII WWPNs including pad */
6#define TCM_QLA2XXX_NAMELEN 32 5#define TCM_QLA2XXX_NAMELEN 32
7/* 6/*
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c35b6de4ca64..e9e1e141af9c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1018,7 +1018,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb)
1018 count = blk_rq_map_sg(req->q, req, sdb->table.sgl); 1018 count = blk_rq_map_sg(req->q, req, sdb->table.sgl);
1019 BUG_ON(count > sdb->table.nents); 1019 BUG_ON(count > sdb->table.nents);
1020 sdb->table.nents = count; 1020 sdb->table.nents = count;
1021 sdb->length = blk_rq_bytes(req); 1021 sdb->length = blk_rq_payload_bytes(req);
1022 return BLKPREP_OK; 1022 return BLKPREP_OK;
1023} 1023}
1024 1024
@@ -2893,7 +2893,7 @@ scsi_internal_device_block(struct scsi_device *sdev)
2893 * request queue. 2893 * request queue.
2894 */ 2894 */
2895 if (q->mq_ops) { 2895 if (q->mq_ops) {
2896 blk_mq_stop_hw_queues(q); 2896 blk_mq_quiesce_queue(q);
2897 } else { 2897 } else {
2898 spin_lock_irqsave(q->queue_lock, flags); 2898 spin_lock_irqsave(q->queue_lock, flags);
2899 blk_stop_queue(q); 2899 blk_stop_queue(q);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b1933041da39..0b09638fa39b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -836,7 +836,6 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
836 struct bio *bio = rq->bio; 836 struct bio *bio = rq->bio;
837 sector_t sector = blk_rq_pos(rq); 837 sector_t sector = blk_rq_pos(rq);
838 unsigned int nr_sectors = blk_rq_sectors(rq); 838 unsigned int nr_sectors = blk_rq_sectors(rq);
839 unsigned int nr_bytes = blk_rq_bytes(rq);
840 int ret; 839 int ret;
841 840
842 if (sdkp->device->no_write_same) 841 if (sdkp->device->no_write_same)
@@ -869,21 +868,7 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
869 868
870 cmd->transfersize = sdp->sector_size; 869 cmd->transfersize = sdp->sector_size;
871 cmd->allowed = SD_MAX_RETRIES; 870 cmd->allowed = SD_MAX_RETRIES;
872 871 return scsi_init_io(cmd);
873 /*
874 * For WRITE_SAME the data transferred in the DATA IN buffer is
875 * different from the amount of data actually written to the target.
876 *
877 * We set up __data_len to the amount of data transferred from the
878 * DATA IN buffer so that blk_rq_map_sg set up the proper S/G list
879 * to transfer a single sector of data first, but then reset it to
880 * the amount of data to be written right after so that the I/O path
881 * knows how much to actually write.
882 */
883 rq->__data_len = sdp->sector_size;
884 ret = scsi_init_io(cmd);
885 rq->__data_len = nr_bytes;
886 return ret;
887} 872}
888 873
889static int sd_setup_flush_cmnd(struct scsi_cmnd *cmd) 874static int sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
@@ -2600,7 +2585,8 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
2600 if (sdp->broken_fua) { 2585 if (sdp->broken_fua) {
2601 sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n"); 2586 sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n");
2602 sdkp->DPOFUA = 0; 2587 sdkp->DPOFUA = 0;
2603 } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { 2588 } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw &&
2589 !sdkp->device->use_16_for_rw) {
2604 sd_first_printk(KERN_NOTICE, sdkp, 2590 sd_first_printk(KERN_NOTICE, sdkp,
2605 "Uses READ/WRITE(6), disabling FUA\n"); 2591 "Uses READ/WRITE(6), disabling FUA\n");
2606 sdkp->DPOFUA = 0; 2592 sdkp->DPOFUA = 0;
@@ -2783,13 +2769,21 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
2783 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q); 2769 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
2784 } 2770 }
2785 2771
2786 sdkp->zoned = (buffer[8] >> 4) & 3; 2772 if (sdkp->device->type == TYPE_ZBC) {
2787 if (sdkp->zoned == 1) 2773 /* Host-managed */
2788 q->limits.zoned = BLK_ZONED_HA;
2789 else if (sdkp->device->type == TYPE_ZBC)
2790 q->limits.zoned = BLK_ZONED_HM; 2774 q->limits.zoned = BLK_ZONED_HM;
2791 else 2775 } else {
2792 q->limits.zoned = BLK_ZONED_NONE; 2776 sdkp->zoned = (buffer[8] >> 4) & 3;
2777 if (sdkp->zoned == 1)
2778 /* Host-aware */
2779 q->limits.zoned = BLK_ZONED_HA;
2780 else
2781 /*
2782 * Treat drive-managed devices as
2783 * regular block devices.
2784 */
2785 q->limits.zoned = BLK_ZONED_NONE;
2786 }
2793 if (blk_queue_is_zoned(q) && sdkp->first_scan) 2787 if (blk_queue_is_zoned(q) && sdkp->first_scan)
2794 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", 2788 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
2795 q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware"); 2789 q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 8c9a35c91705..50adabbb5808 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
587 587
588 ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0); 588 ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);
589 589
590 if (scsi_is_sas_rphy(&sdev->sdev_gendev)) 590 if (scsi_is_sas_rphy(sdev->sdev_target->dev.parent))
591 efd.addr = sas_get_address(sdev); 591 efd.addr = sas_get_address(sdev);
592 592
593 if (efd.addr) { 593 if (efd.addr) {
diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
index 396b32dca074..7cf70aaec0ba 100644
--- a/drivers/scsi/snic/snic_main.c
+++ b/drivers/scsi/snic/snic_main.c
@@ -591,6 +591,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
591 if (!pool) { 591 if (!pool) {
592 SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n"); 592 SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n");
593 593
594 ret = -ENOMEM;
594 goto err_free_res; 595 goto err_free_res;
595 } 596 }
596 597
@@ -601,6 +602,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
601 if (!pool) { 602 if (!pool) {
602 SNIC_HOST_ERR(shost, "max sgl pool creation failed\n"); 603 SNIC_HOST_ERR(shost, "max sgl pool creation failed\n");
603 604
605 ret = -ENOMEM;
604 goto err_free_dflt_sgl_pool; 606 goto err_free_dflt_sgl_pool;
605 } 607 }
606 608
@@ -611,6 +613,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
611 if (!pool) { 613 if (!pool) {
612 SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n"); 614 SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n");
613 615
616 ret = -ENOMEM;
614 goto err_free_max_sgl_pool; 617 goto err_free_max_sgl_pool;
615 } 618 }
616 619
diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
index 8823cc81ae45..5bb376009d98 100644
--- a/drivers/soc/ti/wkup_m3_ipc.c
+++ b/drivers/soc/ti/wkup_m3_ipc.c
@@ -459,6 +459,7 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
459 459
460 if (IS_ERR(task)) { 460 if (IS_ERR(task)) {
461 dev_err(dev, "can't create rproc_boot thread\n"); 461 dev_err(dev, "can't create rproc_boot thread\n");
462 ret = PTR_ERR(task);
462 goto err_put_rproc; 463 goto err_put_rproc;
463 } 464 }
464 465
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index ec4aa252d6e8..2922a9908302 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -378,6 +378,7 @@ config SPI_FSL_SPI
378config SPI_FSL_DSPI 378config SPI_FSL_DSPI
379 tristate "Freescale DSPI controller" 379 tristate "Freescale DSPI controller"
380 select REGMAP_MMIO 380 select REGMAP_MMIO
381 depends on HAS_DMA
381 depends on SOC_VF610 || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST 382 depends on SOC_VF610 || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST
382 help 383 help
383 This enables support for the Freescale DSPI controller in master 384 This enables support for the Freescale DSPI controller in master
diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
index e89da0af45d2..0314c6b9e044 100644
--- a/drivers/spi/spi-armada-3700.c
+++ b/drivers/spi/spi-armada-3700.c
@@ -800,7 +800,7 @@ static int a3700_spi_probe(struct platform_device *pdev)
800 struct spi_master *master; 800 struct spi_master *master;
801 struct a3700_spi *spi; 801 struct a3700_spi *spi;
802 u32 num_cs = 0; 802 u32 num_cs = 0;
803 int ret = 0; 803 int irq, ret = 0;
804 804
805 master = spi_alloc_master(dev, sizeof(*spi)); 805 master = spi_alloc_master(dev, sizeof(*spi));
806 if (!master) { 806 if (!master) {
@@ -825,7 +825,7 @@ static int a3700_spi_probe(struct platform_device *pdev)
825 master->unprepare_message = a3700_spi_unprepare_message; 825 master->unprepare_message = a3700_spi_unprepare_message;
826 master->set_cs = a3700_spi_set_cs; 826 master->set_cs = a3700_spi_set_cs;
827 master->flags = SPI_MASTER_HALF_DUPLEX; 827 master->flags = SPI_MASTER_HALF_DUPLEX;
828 master->mode_bits |= (SPI_RX_DUAL | SPI_RX_DUAL | 828 master->mode_bits |= (SPI_RX_DUAL | SPI_TX_DUAL |
829 SPI_RX_QUAD | SPI_TX_QUAD); 829 SPI_RX_QUAD | SPI_TX_QUAD);
830 830
831 platform_set_drvdata(pdev, master); 831 platform_set_drvdata(pdev, master);
@@ -846,12 +846,13 @@ static int a3700_spi_probe(struct platform_device *pdev)
846 goto error; 846 goto error;
847 } 847 }
848 848
849 spi->irq = platform_get_irq(pdev, 0); 849 irq = platform_get_irq(pdev, 0);
850 if (spi->irq < 0) { 850 if (irq < 0) {
851 dev_err(dev, "could not get irq: %d\n", spi->irq); 851 dev_err(dev, "could not get irq: %d\n", irq);
852 ret = -ENXIO; 852 ret = -ENXIO;
853 goto error; 853 goto error;
854 } 854 }
855 spi->irq = irq;
855 856
856 init_completion(&spi->done); 857 init_completion(&spi->done);
857 858
diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index 319225d7e761..6ab4c7700228 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -494,7 +494,8 @@ static int spi_engine_probe(struct platform_device *pdev)
494 SPI_ENGINE_VERSION_MAJOR(version), 494 SPI_ENGINE_VERSION_MAJOR(version),
495 SPI_ENGINE_VERSION_MINOR(version), 495 SPI_ENGINE_VERSION_MINOR(version),
496 SPI_ENGINE_VERSION_PATCH(version)); 496 SPI_ENGINE_VERSION_PATCH(version));
497 return -ENODEV; 497 ret = -ENODEV;
498 goto err_put_master;
498 } 499 }
499 500
500 spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); 501 spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index d36c11b73a35..02fb96797ac8 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -646,7 +646,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
646 buf = t->rx_buf; 646 buf = t->rx_buf;
647 t->rx_dma = dma_map_single(&spi->dev, buf, 647 t->rx_dma = dma_map_single(&spi->dev, buf,
648 t->len, DMA_FROM_DEVICE); 648 t->len, DMA_FROM_DEVICE);
649 if (!t->rx_dma) { 649 if (dma_mapping_error(&spi->dev, !t->rx_dma)) {
650 ret = -EFAULT; 650 ret = -EFAULT;
651 goto err_rx_map; 651 goto err_rx_map;
652 } 652 }
@@ -660,7 +660,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
660 buf = (void *)t->tx_buf; 660 buf = (void *)t->tx_buf;
661 t->tx_dma = dma_map_single(&spi->dev, buf, 661 t->tx_dma = dma_map_single(&spi->dev, buf,
662 t->len, DMA_TO_DEVICE); 662 t->len, DMA_TO_DEVICE);
663 if (!t->tx_dma) { 663 if (dma_mapping_error(&spi->dev, t->tx_dma)) {
664 ret = -EFAULT; 664 ret = -EFAULT;
665 goto err_tx_map; 665 goto err_tx_map;
666 } 666 }
diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index e31971f91475..837cb8d0bac6 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -274,11 +274,11 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)
274static void mid_spi_dma_stop(struct dw_spi *dws) 274static void mid_spi_dma_stop(struct dw_spi *dws)
275{ 275{
276 if (test_bit(TX_BUSY, &dws->dma_chan_busy)) { 276 if (test_bit(TX_BUSY, &dws->dma_chan_busy)) {
277 dmaengine_terminate_all(dws->txchan); 277 dmaengine_terminate_sync(dws->txchan);
278 clear_bit(TX_BUSY, &dws->dma_chan_busy); 278 clear_bit(TX_BUSY, &dws->dma_chan_busy);
279 } 279 }
280 if (test_bit(RX_BUSY, &dws->dma_chan_busy)) { 280 if (test_bit(RX_BUSY, &dws->dma_chan_busy)) {
281 dmaengine_terminate_all(dws->rxchan); 281 dmaengine_terminate_sync(dws->rxchan);
282 clear_bit(RX_BUSY, &dws->dma_chan_busy); 282 clear_bit(RX_BUSY, &dws->dma_chan_busy);
283 } 283 }
284} 284}
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index b715a26a9148..054012f87567 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -107,7 +107,10 @@ static const struct file_operations dw_spi_regs_ops = {
107 107
108static int dw_spi_debugfs_init(struct dw_spi *dws) 108static int dw_spi_debugfs_init(struct dw_spi *dws)
109{ 109{
110 dws->debugfs = debugfs_create_dir("dw_spi", NULL); 110 char name[128];
111
112 snprintf(name, 128, "dw_spi-%s", dev_name(&dws->master->dev));
113 dws->debugfs = debugfs_create_dir(name, NULL);
111 if (!dws->debugfs) 114 if (!dws->debugfs)
112 return -ENOMEM; 115 return -ENOMEM;
113 116
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index dd7b5b47291d..d6239fa718be 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1690,6 +1690,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
1690 pxa2xx_spi_write(drv_data, SSCR1, tmp); 1690 pxa2xx_spi_write(drv_data, SSCR1, tmp);
1691 tmp = SSCR0_SCR(2) | SSCR0_Motorola | SSCR0_DataSize(8); 1691 tmp = SSCR0_SCR(2) | SSCR0_Motorola | SSCR0_DataSize(8);
1692 pxa2xx_spi_write(drv_data, SSCR0, tmp); 1692 pxa2xx_spi_write(drv_data, SSCR0, tmp);
1693 break;
1693 default: 1694 default:
1694 tmp = SSCR1_RxTresh(RX_THRESH_DFLT) | 1695 tmp = SSCR1_RxTresh(RX_THRESH_DFLT) |
1695 SSCR1_TxTresh(TX_THRESH_DFLT); 1696 SSCR1_TxTresh(TX_THRESH_DFLT);
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0012ad02e569..1f00eeb0b5a3 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -973,14 +973,16 @@ static const struct sh_msiof_chipdata r8a779x_data = {
973}; 973};
974 974
975static const struct of_device_id sh_msiof_match[] = { 975static const struct of_device_id sh_msiof_match[] = {
976 { .compatible = "renesas,sh-msiof", .data = &sh_data },
977 { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data }, 976 { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
978 { .compatible = "renesas,msiof-r8a7790", .data = &r8a779x_data }, 977 { .compatible = "renesas,msiof-r8a7790", .data = &r8a779x_data },
979 { .compatible = "renesas,msiof-r8a7791", .data = &r8a779x_data }, 978 { .compatible = "renesas,msiof-r8a7791", .data = &r8a779x_data },
980 { .compatible = "renesas,msiof-r8a7792", .data = &r8a779x_data }, 979 { .compatible = "renesas,msiof-r8a7792", .data = &r8a779x_data },
981 { .compatible = "renesas,msiof-r8a7793", .data = &r8a779x_data }, 980 { .compatible = "renesas,msiof-r8a7793", .data = &r8a779x_data },
982 { .compatible = "renesas,msiof-r8a7794", .data = &r8a779x_data }, 981 { .compatible = "renesas,msiof-r8a7794", .data = &r8a779x_data },
982 { .compatible = "renesas,rcar-gen2-msiof", .data = &r8a779x_data },
983 { .compatible = "renesas,msiof-r8a7796", .data = &r8a779x_data }, 983 { .compatible = "renesas,msiof-r8a7796", .data = &r8a779x_data },
984 { .compatible = "renesas,rcar-gen3-msiof", .data = &r8a779x_data },
985 { .compatible = "renesas,sh-msiof", .data = &sh_data }, /* Deprecated */
984 {}, 986 {},
985}; 987};
986MODULE_DEVICE_TABLE(of, sh_msiof_match); 988MODULE_DEVICE_TABLE(of, sh_msiof_match);
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 8130dfe89745..4971aa54756a 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -770,6 +770,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
770 /* Initialize the device private structure. */ 770 /* Initialize the device private structure. */
771 struct octeon_ethernet *priv = netdev_priv(dev); 771 struct octeon_ethernet *priv = netdev_priv(dev);
772 772
773 SET_NETDEV_DEV(dev, &pdev->dev);
773 dev->netdev_ops = &cvm_oct_pow_netdev_ops; 774 dev->netdev_ops = &cvm_oct_pow_netdev_ops;
774 priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; 775 priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
775 priv->port = CVMX_PIP_NUM_INPUT_PORTS; 776 priv->port = CVMX_PIP_NUM_INPUT_PORTS;
@@ -816,6 +817,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
816 } 817 }
817 818
818 /* Initialize the device private structure. */ 819 /* Initialize the device private structure. */
820 SET_NETDEV_DEV(dev, &pdev->dev);
819 priv = netdev_priv(dev); 821 priv = netdev_priv(dev);
820 priv->netdev = dev; 822 priv->netdev = dev;
821 priv->of_node = cvm_oct_node_for_port(pip, interface, 823 priv->of_node = cvm_oct_node_for_port(pip, interface,
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 7dfefd66df93..1cadc9eefa21 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1693,6 +1693,10 @@ void transport_generic_request_failure(struct se_cmd *cmd,
1693 case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED: 1693 case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED:
1694 case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED: 1694 case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED:
1695 case TCM_COPY_TARGET_DEVICE_NOT_REACHABLE: 1695 case TCM_COPY_TARGET_DEVICE_NOT_REACHABLE:
1696 case TCM_TOO_MANY_TARGET_DESCS:
1697 case TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE:
1698 case TCM_TOO_MANY_SEGMENT_DESCS:
1699 case TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE:
1696 break; 1700 break;
1697 case TCM_OUT_OF_RESOURCES: 1701 case TCM_OUT_OF_RESOURCES:
1698 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1702 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -2808,6 +2812,26 @@ static const struct sense_info sense_info_table[] = {
2808 .key = ILLEGAL_REQUEST, 2812 .key = ILLEGAL_REQUEST,
2809 .asc = 0x26, /* INVALID FIELD IN PARAMETER LIST */ 2813 .asc = 0x26, /* INVALID FIELD IN PARAMETER LIST */
2810 }, 2814 },
2815 [TCM_TOO_MANY_TARGET_DESCS] = {
2816 .key = ILLEGAL_REQUEST,
2817 .asc = 0x26,
2818 .ascq = 0x06, /* TOO MANY TARGET DESCRIPTORS */
2819 },
2820 [TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE] = {
2821 .key = ILLEGAL_REQUEST,
2822 .asc = 0x26,
2823 .ascq = 0x07, /* UNSUPPORTED TARGET DESCRIPTOR TYPE CODE */
2824 },
2825 [TCM_TOO_MANY_SEGMENT_DESCS] = {
2826 .key = ILLEGAL_REQUEST,
2827 .asc = 0x26,
2828 .ascq = 0x08, /* TOO MANY SEGMENT DESCRIPTORS */
2829 },
2830 [TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE] = {
2831 .key = ILLEGAL_REQUEST,
2832 .asc = 0x26,
2833 .ascq = 0x09, /* UNSUPPORTED SEGMENT DESCRIPTOR TYPE CODE */
2834 },
2811 [TCM_PARAMETER_LIST_LENGTH_ERROR] = { 2835 [TCM_PARAMETER_LIST_LENGTH_ERROR] = {
2812 .key = ILLEGAL_REQUEST, 2836 .key = ILLEGAL_REQUEST,
2813 .asc = 0x1a, /* PARAMETER LIST LENGTH ERROR */ 2837 .asc = 0x1a, /* PARAMETER LIST LENGTH ERROR */
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 37d5caebffa6..d828b3b5000b 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -53,18 +53,13 @@ static int target_xcopy_gen_naa_ieee(struct se_device *dev, unsigned char *buf)
53 return 0; 53 return 0;
54} 54}
55 55
56static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op *xop, 56static int target_xcopy_locate_se_dev_e4(const unsigned char *dev_wwn,
57 bool src) 57 struct se_device **found_dev)
58{ 58{
59 struct se_device *se_dev; 59 struct se_device *se_dev;
60 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn; 60 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
61 int rc; 61 int rc;
62 62
63 if (src)
64 dev_wwn = &xop->dst_tid_wwn[0];
65 else
66 dev_wwn = &xop->src_tid_wwn[0];
67
68 mutex_lock(&g_device_mutex); 63 mutex_lock(&g_device_mutex);
69 list_for_each_entry(se_dev, &g_device_list, g_dev_node) { 64 list_for_each_entry(se_dev, &g_device_list, g_dev_node) {
70 65
@@ -78,15 +73,8 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
78 if (rc != 0) 73 if (rc != 0)
79 continue; 74 continue;
80 75
81 if (src) { 76 *found_dev = se_dev;
82 xop->dst_dev = se_dev; 77 pr_debug("XCOPY 0xe4: located se_dev: %p\n", se_dev);
83 pr_debug("XCOPY 0xe4: Setting xop->dst_dev: %p from located"
84 " se_dev\n", xop->dst_dev);
85 } else {
86 xop->src_dev = se_dev;
87 pr_debug("XCOPY 0xe4: Setting xop->src_dev: %p from located"
88 " se_dev\n", xop->src_dev);
89 }
90 78
91 rc = target_depend_item(&se_dev->dev_group.cg_item); 79 rc = target_depend_item(&se_dev->dev_group.cg_item);
92 if (rc != 0) { 80 if (rc != 0) {
@@ -110,7 +98,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
110} 98}
111 99
112static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op *xop, 100static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op *xop,
113 unsigned char *p, bool src) 101 unsigned char *p, unsigned short cscd_index)
114{ 102{
115 unsigned char *desc = p; 103 unsigned char *desc = p;
116 unsigned short ript; 104 unsigned short ript;
@@ -155,7 +143,13 @@ static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op
155 return -EINVAL; 143 return -EINVAL;
156 } 144 }
157 145
158 if (src) { 146 if (cscd_index != xop->stdi && cscd_index != xop->dtdi) {
147 pr_debug("XCOPY 0xe4: ignoring CSCD entry %d - neither src nor "
148 "dest\n", cscd_index);
149 return 0;
150 }
151
152 if (cscd_index == xop->stdi) {
159 memcpy(&xop->src_tid_wwn[0], &desc[8], XCOPY_NAA_IEEE_REGEX_LEN); 153 memcpy(&xop->src_tid_wwn[0], &desc[8], XCOPY_NAA_IEEE_REGEX_LEN);
160 /* 154 /*
161 * Determine if the source designator matches the local device 155 * Determine if the source designator matches the local device
@@ -167,10 +161,15 @@ static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op
167 pr_debug("XCOPY 0xe4: Set xop->src_dev %p from source" 161 pr_debug("XCOPY 0xe4: Set xop->src_dev %p from source"
168 " received xop\n", xop->src_dev); 162 " received xop\n", xop->src_dev);
169 } 163 }
170 } else { 164 }
165
166 if (cscd_index == xop->dtdi) {
171 memcpy(&xop->dst_tid_wwn[0], &desc[8], XCOPY_NAA_IEEE_REGEX_LEN); 167 memcpy(&xop->dst_tid_wwn[0], &desc[8], XCOPY_NAA_IEEE_REGEX_LEN);
172 /* 168 /*
173 * Determine if the destination designator matches the local device 169 * Determine if the destination designator matches the local
170 * device. If @cscd_index corresponds to both source (stdi) and
171 * destination (dtdi), or dtdi comes after stdi, then
172 * XCOL_DEST_RECV_OP wins.
174 */ 173 */
175 if (!memcmp(&xop->local_dev_wwn[0], &xop->dst_tid_wwn[0], 174 if (!memcmp(&xop->local_dev_wwn[0], &xop->dst_tid_wwn[0],
176 XCOPY_NAA_IEEE_REGEX_LEN)) { 175 XCOPY_NAA_IEEE_REGEX_LEN)) {
@@ -190,20 +189,23 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
190{ 189{
191 struct se_device *local_dev = se_cmd->se_dev; 190 struct se_device *local_dev = se_cmd->se_dev;
192 unsigned char *desc = p; 191 unsigned char *desc = p;
193 int offset = tdll % XCOPY_TARGET_DESC_LEN, rc, ret = 0; 192 int offset = tdll % XCOPY_TARGET_DESC_LEN, rc;
193 unsigned short cscd_index = 0;
194 unsigned short start = 0; 194 unsigned short start = 0;
195 bool src = true;
196 195
197 *sense_ret = TCM_INVALID_PARAMETER_LIST; 196 *sense_ret = TCM_INVALID_PARAMETER_LIST;
198 197
199 if (offset != 0) { 198 if (offset != 0) {
200 pr_err("XCOPY target descriptor list length is not" 199 pr_err("XCOPY target descriptor list length is not"
201 " multiple of %d\n", XCOPY_TARGET_DESC_LEN); 200 " multiple of %d\n", XCOPY_TARGET_DESC_LEN);
201 *sense_ret = TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE;
202 return -EINVAL; 202 return -EINVAL;
203 } 203 }
204 if (tdll > 64) { 204 if (tdll > RCR_OP_MAX_TARGET_DESC_COUNT * XCOPY_TARGET_DESC_LEN) {
205 pr_err("XCOPY target descriptor supports a maximum" 205 pr_err("XCOPY target descriptor supports a maximum"
206 " two src/dest descriptors, tdll: %hu too large..\n", tdll); 206 " two src/dest descriptors, tdll: %hu too large..\n", tdll);
207 /* spc4r37 6.4.3.4 CSCD DESCRIPTOR LIST LENGTH field */
208 *sense_ret = TCM_TOO_MANY_TARGET_DESCS;
207 return -EINVAL; 209 return -EINVAL;
208 } 210 }
209 /* 211 /*
@@ -215,37 +217,43 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
215 217
216 while (start < tdll) { 218 while (start < tdll) {
217 /* 219 /*
218 * Check target descriptor identification with 0xE4 type with 220 * Check target descriptor identification with 0xE4 type, and
219 * use VPD 0x83 WWPN matching .. 221 * compare the current index with the CSCD descriptor IDs in
222 * the segment descriptor. Use VPD 0x83 WWPN matching ..
220 */ 223 */
221 switch (desc[0]) { 224 switch (desc[0]) {
222 case 0xe4: 225 case 0xe4:
223 rc = target_xcopy_parse_tiddesc_e4(se_cmd, xop, 226 rc = target_xcopy_parse_tiddesc_e4(se_cmd, xop,
224 &desc[0], src); 227 &desc[0], cscd_index);
225 if (rc != 0) 228 if (rc != 0)
226 goto out; 229 goto out;
227 /*
228 * Assume target descriptors are in source -> destination order..
229 */
230 if (src)
231 src = false;
232 else
233 src = true;
234 start += XCOPY_TARGET_DESC_LEN; 230 start += XCOPY_TARGET_DESC_LEN;
235 desc += XCOPY_TARGET_DESC_LEN; 231 desc += XCOPY_TARGET_DESC_LEN;
236 ret++; 232 cscd_index++;
237 break; 233 break;
238 default: 234 default:
239 pr_err("XCOPY unsupported descriptor type code:" 235 pr_err("XCOPY unsupported descriptor type code:"
240 " 0x%02x\n", desc[0]); 236 " 0x%02x\n", desc[0]);
237 *sense_ret = TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE;
241 goto out; 238 goto out;
242 } 239 }
243 } 240 }
244 241
245 if (xop->op_origin == XCOL_SOURCE_RECV_OP) 242 switch (xop->op_origin) {
246 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, true); 243 case XCOL_SOURCE_RECV_OP:
247 else 244 rc = target_xcopy_locate_se_dev_e4(xop->dst_tid_wwn,
248 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, false); 245 &xop->dst_dev);
246 break;
247 case XCOL_DEST_RECV_OP:
248 rc = target_xcopy_locate_se_dev_e4(xop->src_tid_wwn,
249 &xop->src_dev);
250 break;
251 default:
252 pr_err("XCOPY CSCD descriptor IDs not found in CSCD list - "
253 "stdi: %hu dtdi: %hu\n", xop->stdi, xop->dtdi);
254 rc = -EINVAL;
255 break;
256 }
249 /* 257 /*
250 * If a matching IEEE NAA 0x83 descriptor for the requested device 258 * If a matching IEEE NAA 0x83 descriptor for the requested device
251 * is not located on this node, return COPY_ABORTED with ASQ/ASQC 259 * is not located on this node, return COPY_ABORTED with ASQ/ASQC
@@ -262,7 +270,7 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
262 pr_debug("XCOPY TGT desc: Dest dev: %p NAA IEEE WWN: 0x%16phN\n", 270 pr_debug("XCOPY TGT desc: Dest dev: %p NAA IEEE WWN: 0x%16phN\n",
263 xop->dst_dev, &xop->dst_tid_wwn[0]); 271 xop->dst_dev, &xop->dst_tid_wwn[0]);
264 272
265 return ret; 273 return cscd_index;
266 274
267out: 275out:
268 return -EINVAL; 276 return -EINVAL;
@@ -284,6 +292,14 @@ static int target_xcopy_parse_segdesc_02(struct se_cmd *se_cmd, struct xcopy_op
284 292
285 xop->stdi = get_unaligned_be16(&desc[4]); 293 xop->stdi = get_unaligned_be16(&desc[4]);
286 xop->dtdi = get_unaligned_be16(&desc[6]); 294 xop->dtdi = get_unaligned_be16(&desc[6]);
295
296 if (xop->stdi > XCOPY_CSCD_DESC_ID_LIST_OFF_MAX ||
297 xop->dtdi > XCOPY_CSCD_DESC_ID_LIST_OFF_MAX) {
298 pr_err("XCOPY segment desc 0x02: unsupported CSCD ID > 0x%x; stdi: %hu dtdi: %hu\n",
299 XCOPY_CSCD_DESC_ID_LIST_OFF_MAX, xop->stdi, xop->dtdi);
300 return -EINVAL;
301 }
302
287 pr_debug("XCOPY seg desc 0x02: desc_len: %hu stdi: %hu dtdi: %hu, DC: %d\n", 303 pr_debug("XCOPY seg desc 0x02: desc_len: %hu stdi: %hu dtdi: %hu, DC: %d\n",
288 desc_len, xop->stdi, xop->dtdi, dc); 304 desc_len, xop->stdi, xop->dtdi, dc);
289 305
@@ -306,15 +322,25 @@ static int target_xcopy_parse_segdesc_02(struct se_cmd *se_cmd, struct xcopy_op
306 322
307static int target_xcopy_parse_segment_descriptors(struct se_cmd *se_cmd, 323static int target_xcopy_parse_segment_descriptors(struct se_cmd *se_cmd,
308 struct xcopy_op *xop, unsigned char *p, 324 struct xcopy_op *xop, unsigned char *p,
309 unsigned int sdll) 325 unsigned int sdll, sense_reason_t *sense_ret)
310{ 326{
311 unsigned char *desc = p; 327 unsigned char *desc = p;
312 unsigned int start = 0; 328 unsigned int start = 0;
313 int offset = sdll % XCOPY_SEGMENT_DESC_LEN, rc, ret = 0; 329 int offset = sdll % XCOPY_SEGMENT_DESC_LEN, rc, ret = 0;
314 330
331 *sense_ret = TCM_INVALID_PARAMETER_LIST;
332
315 if (offset != 0) { 333 if (offset != 0) {
316 pr_err("XCOPY segment descriptor list length is not" 334 pr_err("XCOPY segment descriptor list length is not"
317 " multiple of %d\n", XCOPY_SEGMENT_DESC_LEN); 335 " multiple of %d\n", XCOPY_SEGMENT_DESC_LEN);
336 *sense_ret = TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE;
337 return -EINVAL;
338 }
339 if (sdll > RCR_OP_MAX_SG_DESC_COUNT * XCOPY_SEGMENT_DESC_LEN) {
340 pr_err("XCOPY supports %u segment descriptor(s), sdll: %u too"
341 " large..\n", RCR_OP_MAX_SG_DESC_COUNT, sdll);
342 /* spc4r37 6.4.3.5 SEGMENT DESCRIPTOR LIST LENGTH field */
343 *sense_ret = TCM_TOO_MANY_SEGMENT_DESCS;
318 return -EINVAL; 344 return -EINVAL;
319 } 345 }
320 346
@@ -335,6 +361,7 @@ static int target_xcopy_parse_segment_descriptors(struct se_cmd *se_cmd,
335 default: 361 default:
336 pr_err("XCOPY unsupported segment descriptor" 362 pr_err("XCOPY unsupported segment descriptor"
337 "type: 0x%02x\n", desc[0]); 363 "type: 0x%02x\n", desc[0]);
364 *sense_ret = TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE;
338 goto out; 365 goto out;
339 } 366 }
340 } 367 }
@@ -861,6 +888,16 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
861 return TCM_UNSUPPORTED_SCSI_OPCODE; 888 return TCM_UNSUPPORTED_SCSI_OPCODE;
862 } 889 }
863 890
891 if (se_cmd->data_length == 0) {
892 target_complete_cmd(se_cmd, SAM_STAT_GOOD);
893 return TCM_NO_SENSE;
894 }
895 if (se_cmd->data_length < XCOPY_HDR_LEN) {
896 pr_err("XCOPY parameter truncation: length %u < hdr_len %u\n",
897 se_cmd->data_length, XCOPY_HDR_LEN);
898 return TCM_PARAMETER_LIST_LENGTH_ERROR;
899 }
900
864 xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL); 901 xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL);
865 if (!xop) { 902 if (!xop) {
866 pr_err("Unable to allocate xcopy_op\n"); 903 pr_err("Unable to allocate xcopy_op\n");
@@ -883,6 +920,12 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
883 */ 920 */
884 tdll = get_unaligned_be16(&p[2]); 921 tdll = get_unaligned_be16(&p[2]);
885 sdll = get_unaligned_be32(&p[8]); 922 sdll = get_unaligned_be32(&p[8]);
923 if (tdll + sdll > RCR_OP_MAX_DESC_LIST_LEN) {
924 pr_err("XCOPY descriptor list length %u exceeds maximum %u\n",
925 tdll + sdll, RCR_OP_MAX_DESC_LIST_LEN);
926 ret = TCM_PARAMETER_LIST_LENGTH_ERROR;
927 goto out;
928 }
886 929
887 inline_dl = get_unaligned_be32(&p[12]); 930 inline_dl = get_unaligned_be32(&p[12]);
888 if (inline_dl != 0) { 931 if (inline_dl != 0) {
@@ -890,10 +933,32 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
890 goto out; 933 goto out;
891 } 934 }
892 935
936 if (se_cmd->data_length < (XCOPY_HDR_LEN + tdll + sdll + inline_dl)) {
937 pr_err("XCOPY parameter truncation: data length %u too small "
938 "for tdll: %hu sdll: %u inline_dl: %u\n",
939 se_cmd->data_length, tdll, sdll, inline_dl);
940 ret = TCM_PARAMETER_LIST_LENGTH_ERROR;
941 goto out;
942 }
943
893 pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x" 944 pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x"
894 " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, 945 " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage,
895 tdll, sdll, inline_dl); 946 tdll, sdll, inline_dl);
896 947
948 /*
949 * skip over the target descriptors until segment descriptors
950 * have been passed - CSCD ids are needed to determine src and dest.
951 */
952 seg_desc = &p[16] + tdll;
953
954 rc = target_xcopy_parse_segment_descriptors(se_cmd, xop, seg_desc,
955 sdll, &ret);
956 if (rc <= 0)
957 goto out;
958
959 pr_debug("XCOPY: Processed %d segment descriptors, length: %u\n", rc,
960 rc * XCOPY_SEGMENT_DESC_LEN);
961
897 rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll, &ret); 962 rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll, &ret);
898 if (rc <= 0) 963 if (rc <= 0)
899 goto out; 964 goto out;
@@ -911,18 +976,8 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
911 976
912 pr_debug("XCOPY: Processed %d target descriptors, length: %u\n", rc, 977 pr_debug("XCOPY: Processed %d target descriptors, length: %u\n", rc,
913 rc * XCOPY_TARGET_DESC_LEN); 978 rc * XCOPY_TARGET_DESC_LEN);
914 seg_desc = &p[16];
915 seg_desc += (rc * XCOPY_TARGET_DESC_LEN);
916
917 rc = target_xcopy_parse_segment_descriptors(se_cmd, xop, seg_desc, sdll);
918 if (rc <= 0) {
919 xcopy_pt_undepend_remotedev(xop);
920 goto out;
921 }
922 transport_kunmap_data_sg(se_cmd); 979 transport_kunmap_data_sg(se_cmd);
923 980
924 pr_debug("XCOPY: Processed %d segment descriptors, length: %u\n", rc,
925 rc * XCOPY_SEGMENT_DESC_LEN);
926 INIT_WORK(&xop->xop_work, target_xcopy_do_work); 981 INIT_WORK(&xop->xop_work, target_xcopy_do_work);
927 queue_work(xcopy_wq, &xop->xop_work); 982 queue_work(xcopy_wq, &xop->xop_work);
928 return TCM_NO_SENSE; 983 return TCM_NO_SENSE;
diff --git a/drivers/target/target_core_xcopy.h b/drivers/target/target_core_xcopy.h
index 4d3d4dd060f2..7c0b105cbe1b 100644
--- a/drivers/target/target_core_xcopy.h
+++ b/drivers/target/target_core_xcopy.h
@@ -1,10 +1,17 @@
1#include <target/target_core_base.h> 1#include <target/target_core_base.h>
2 2
3#define XCOPY_HDR_LEN 16
3#define XCOPY_TARGET_DESC_LEN 32 4#define XCOPY_TARGET_DESC_LEN 32
4#define XCOPY_SEGMENT_DESC_LEN 28 5#define XCOPY_SEGMENT_DESC_LEN 28
5#define XCOPY_NAA_IEEE_REGEX_LEN 16 6#define XCOPY_NAA_IEEE_REGEX_LEN 16
6#define XCOPY_MAX_SECTORS 1024 7#define XCOPY_MAX_SECTORS 1024
7 8
9/*
10 * SPC4r37 6.4.6.1
11 * Table 150 — CSCD descriptor ID values
12 */
13#define XCOPY_CSCD_DESC_ID_LIST_OFF_MAX 0x07FF
14
8enum xcopy_origin_list { 15enum xcopy_origin_list {
9 XCOL_SOURCE_RECV_OP = 0x01, 16 XCOL_SOURCE_RECV_OP = 0x01,
10 XCOL_DEST_RECV_OP = 0x02, 17 XCOL_DEST_RECV_OP = 0x02,
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index b811b0fb61b1..4c7796512453 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -118,12 +118,12 @@ struct rockchip_tsadc_chip {
118 void (*control)(void __iomem *reg, bool on); 118 void (*control)(void __iomem *reg, bool on);
119 119
120 /* Per-sensor methods */ 120 /* Per-sensor methods */
121 int (*get_temp)(struct chip_tsadc_table table, 121 int (*get_temp)(const struct chip_tsadc_table *table,
122 int chn, void __iomem *reg, int *temp); 122 int chn, void __iomem *reg, int *temp);
123 void (*set_alarm_temp)(struct chip_tsadc_table table, 123 int (*set_alarm_temp)(const struct chip_tsadc_table *table,
124 int chn, void __iomem *reg, int temp); 124 int chn, void __iomem *reg, int temp);
125 void (*set_tshut_temp)(struct chip_tsadc_table table, 125 int (*set_tshut_temp)(const struct chip_tsadc_table *table,
126 int chn, void __iomem *reg, int temp); 126 int chn, void __iomem *reg, int temp);
127 void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m); 127 void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
128 128
129 /* Per-table methods */ 129 /* Per-table methods */
@@ -317,6 +317,7 @@ static const struct tsadc_table rk3288_code_table[] = {
317 {3452, 115000}, 317 {3452, 115000},
318 {3437, 120000}, 318 {3437, 120000},
319 {3421, 125000}, 319 {3421, 125000},
320 {0, 125000},
320}; 321};
321 322
322static const struct tsadc_table rk3368_code_table[] = { 323static const struct tsadc_table rk3368_code_table[] = {
@@ -397,59 +398,80 @@ static const struct tsadc_table rk3399_code_table[] = {
397 {TSADCV3_DATA_MASK, 125000}, 398 {TSADCV3_DATA_MASK, 125000},
398}; 399};
399 400
400static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table, 401static u32 rk_tsadcv2_temp_to_code(const struct chip_tsadc_table *table,
401 int temp) 402 int temp)
402{ 403{
403 int high, low, mid; 404 int high, low, mid;
404 u32 error = 0; 405 unsigned long num;
406 unsigned int denom;
407 u32 error = table->data_mask;
405 408
406 low = 0; 409 low = 0;
407 high = table.length - 1; 410 high = (table->length - 1) - 1; /* ignore the last check for table */
408 mid = (high + low) / 2; 411 mid = (high + low) / 2;
409 412
410 /* Return mask code data when the temp is over table range */ 413 /* Return mask code data when the temp is over table range */
411 if (temp < table.id[low].temp || temp > table.id[high].temp) { 414 if (temp < table->id[low].temp || temp > table->id[high].temp)
412 error = table.data_mask;
413 goto exit; 415 goto exit;
414 }
415 416
416 while (low <= high) { 417 while (low <= high) {
417 if (temp == table.id[mid].temp) 418 if (temp == table->id[mid].temp)
418 return table.id[mid].code; 419 return table->id[mid].code;
419 else if (temp < table.id[mid].temp) 420 else if (temp < table->id[mid].temp)
420 high = mid - 1; 421 high = mid - 1;
421 else 422 else
422 low = mid + 1; 423 low = mid + 1;
423 mid = (low + high) / 2; 424 mid = (low + high) / 2;
424 } 425 }
425 426
427 /*
428 * The conversion code granularity provided by the table. Let's
429 * assume that the relationship between temperature and
430 * analog value between 2 table entries is linear and interpolate
431 * to produce less granular result.
432 */
433 num = abs(table->id[mid + 1].code - table->id[mid].code);
434 num *= temp - table->id[mid].temp;
435 denom = table->id[mid + 1].temp - table->id[mid].temp;
436
437 switch (table->mode) {
438 case ADC_DECREMENT:
439 return table->id[mid].code - (num / denom);
440 case ADC_INCREMENT:
441 return table->id[mid].code + (num / denom);
442 default:
443 pr_err("%s: unknown table mode: %d\n", __func__, table->mode);
444 return error;
445 }
446
426exit: 447exit:
427 pr_err("Invalid the conversion, error=%d\n", error); 448 pr_err("%s: invalid temperature, temp=%d error=%d\n",
449 __func__, temp, error);
428 return error; 450 return error;
429} 451}
430 452
431static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code, 453static int rk_tsadcv2_code_to_temp(const struct chip_tsadc_table *table,
432 int *temp) 454 u32 code, int *temp)
433{ 455{
434 unsigned int low = 1; 456 unsigned int low = 1;
435 unsigned int high = table.length - 1; 457 unsigned int high = table->length - 1;
436 unsigned int mid = (low + high) / 2; 458 unsigned int mid = (low + high) / 2;
437 unsigned int num; 459 unsigned int num;
438 unsigned long denom; 460 unsigned long denom;
439 461
440 WARN_ON(table.length < 2); 462 WARN_ON(table->length < 2);
441 463
442 switch (table.mode) { 464 switch (table->mode) {
443 case ADC_DECREMENT: 465 case ADC_DECREMENT:
444 code &= table.data_mask; 466 code &= table->data_mask;
445 if (code < table.id[high].code) 467 if (code <= table->id[high].code)
446 return -EAGAIN; /* Incorrect reading */ 468 return -EAGAIN; /* Incorrect reading */
447 469
448 while (low <= high) { 470 while (low <= high) {
449 if (code >= table.id[mid].code && 471 if (code >= table->id[mid].code &&
450 code < table.id[mid - 1].code) 472 code < table->id[mid - 1].code)
451 break; 473 break;
452 else if (code < table.id[mid].code) 474 else if (code < table->id[mid].code)
453 low = mid + 1; 475 low = mid + 1;
454 else 476 else
455 high = mid - 1; 477 high = mid - 1;
@@ -458,15 +480,15 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
458 } 480 }
459 break; 481 break;
460 case ADC_INCREMENT: 482 case ADC_INCREMENT:
461 code &= table.data_mask; 483 code &= table->data_mask;
462 if (code < table.id[low].code) 484 if (code < table->id[low].code)
463 return -EAGAIN; /* Incorrect reading */ 485 return -EAGAIN; /* Incorrect reading */
464 486
465 while (low <= high) { 487 while (low <= high) {
466 if (code <= table.id[mid].code && 488 if (code <= table->id[mid].code &&
467 code > table.id[mid - 1].code) 489 code > table->id[mid - 1].code)
468 break; 490 break;
469 else if (code > table.id[mid].code) 491 else if (code > table->id[mid].code)
470 low = mid + 1; 492 low = mid + 1;
471 else 493 else
472 high = mid - 1; 494 high = mid - 1;
@@ -475,7 +497,8 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
475 } 497 }
476 break; 498 break;
477 default: 499 default:
478 pr_err("Invalid the conversion table\n"); 500 pr_err("%s: unknown table mode: %d\n", __func__, table->mode);
501 return -EINVAL;
479 } 502 }
480 503
481 /* 504 /*
@@ -484,10 +507,10 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
484 * temperature between 2 table entries is linear and interpolate 507 * temperature between 2 table entries is linear and interpolate
485 * to produce less granular result. 508 * to produce less granular result.
486 */ 509 */
487 num = table.id[mid].temp - table.id[mid - 1].temp; 510 num = table->id[mid].temp - table->id[mid - 1].temp;
488 num *= abs(table.id[mid - 1].code - code); 511 num *= abs(table->id[mid - 1].code - code);
489 denom = abs(table.id[mid - 1].code - table.id[mid].code); 512 denom = abs(table->id[mid - 1].code - table->id[mid].code);
490 *temp = table.id[mid - 1].temp + (num / denom); 513 *temp = table->id[mid - 1].temp + (num / denom);
491 514
492 return 0; 515 return 0;
493} 516}
@@ -638,7 +661,7 @@ static void rk_tsadcv3_control(void __iomem *regs, bool enable)
638 writel_relaxed(val, regs + TSADCV2_AUTO_CON); 661 writel_relaxed(val, regs + TSADCV2_AUTO_CON);
639} 662}
640 663
641static int rk_tsadcv2_get_temp(struct chip_tsadc_table table, 664static int rk_tsadcv2_get_temp(const struct chip_tsadc_table *table,
642 int chn, void __iomem *regs, int *temp) 665 int chn, void __iomem *regs, int *temp)
643{ 666{
644 u32 val; 667 u32 val;
@@ -648,39 +671,57 @@ static int rk_tsadcv2_get_temp(struct chip_tsadc_table table,
648 return rk_tsadcv2_code_to_temp(table, val, temp); 671 return rk_tsadcv2_code_to_temp(table, val, temp);
649} 672}
650 673
651static void rk_tsadcv2_alarm_temp(struct chip_tsadc_table table, 674static int rk_tsadcv2_alarm_temp(const struct chip_tsadc_table *table,
652 int chn, void __iomem *regs, int temp) 675 int chn, void __iomem *regs, int temp)
653{ 676{
654 u32 alarm_value, int_en; 677 u32 alarm_value;
678 u32 int_en, int_clr;
679
680 /*
681 * In some cases, some sensors didn't need the trip points, the
682 * set_trips will pass {-INT_MAX, INT_MAX} to trigger tsadc alarm
683 * in the end, ignore this case and disable the high temperature
684 * interrupt.
685 */
686 if (temp == INT_MAX) {
687 int_clr = readl_relaxed(regs + TSADCV2_INT_EN);
688 int_clr &= ~TSADCV2_INT_SRC_EN(chn);
689 writel_relaxed(int_clr, regs + TSADCV2_INT_EN);
690 return 0;
691 }
655 692
656 /* Make sure the value is valid */ 693 /* Make sure the value is valid */
657 alarm_value = rk_tsadcv2_temp_to_code(table, temp); 694 alarm_value = rk_tsadcv2_temp_to_code(table, temp);
658 if (alarm_value == table.data_mask) 695 if (alarm_value == table->data_mask)
659 return; 696 return -ERANGE;
660 697
661 writel_relaxed(alarm_value & table.data_mask, 698 writel_relaxed(alarm_value & table->data_mask,
662 regs + TSADCV2_COMP_INT(chn)); 699 regs + TSADCV2_COMP_INT(chn));
663 700
664 int_en = readl_relaxed(regs + TSADCV2_INT_EN); 701 int_en = readl_relaxed(regs + TSADCV2_INT_EN);
665 int_en |= TSADCV2_INT_SRC_EN(chn); 702 int_en |= TSADCV2_INT_SRC_EN(chn);
666 writel_relaxed(int_en, regs + TSADCV2_INT_EN); 703 writel_relaxed(int_en, regs + TSADCV2_INT_EN);
704
705 return 0;
667} 706}
668 707
669static void rk_tsadcv2_tshut_temp(struct chip_tsadc_table table, 708static int rk_tsadcv2_tshut_temp(const struct chip_tsadc_table *table,
670 int chn, void __iomem *regs, int temp) 709 int chn, void __iomem *regs, int temp)
671{ 710{
672 u32 tshut_value, val; 711 u32 tshut_value, val;
673 712
674 /* Make sure the value is valid */ 713 /* Make sure the value is valid */
675 tshut_value = rk_tsadcv2_temp_to_code(table, temp); 714 tshut_value = rk_tsadcv2_temp_to_code(table, temp);
676 if (tshut_value == table.data_mask) 715 if (tshut_value == table->data_mask)
677 return; 716 return -ERANGE;
678 717
679 writel_relaxed(tshut_value, regs + TSADCV2_COMP_SHUT(chn)); 718 writel_relaxed(tshut_value, regs + TSADCV2_COMP_SHUT(chn));
680 719
681 /* TSHUT will be valid */ 720 /* TSHUT will be valid */
682 val = readl_relaxed(regs + TSADCV2_AUTO_CON); 721 val = readl_relaxed(regs + TSADCV2_AUTO_CON);
683 writel_relaxed(val | TSADCV2_AUTO_SRC_EN(chn), regs + TSADCV2_AUTO_CON); 722 writel_relaxed(val | TSADCV2_AUTO_SRC_EN(chn), regs + TSADCV2_AUTO_CON);
723
724 return 0;
684} 725}
685 726
686static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs, 727static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
@@ -883,10 +924,8 @@ static int rockchip_thermal_set_trips(void *_sensor, int low, int high)
883 dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n", 924 dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n",
884 __func__, sensor->id, low, high); 925 __func__, sensor->id, low, high);
885 926
886 tsadc->set_alarm_temp(tsadc->table, 927 return tsadc->set_alarm_temp(&tsadc->table,
887 sensor->id, thermal->regs, high); 928 sensor->id, thermal->regs, high);
888
889 return 0;
890} 929}
891 930
892static int rockchip_thermal_get_temp(void *_sensor, int *out_temp) 931static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
@@ -896,7 +935,7 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
896 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; 935 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
897 int retval; 936 int retval;
898 937
899 retval = tsadc->get_temp(tsadc->table, 938 retval = tsadc->get_temp(&tsadc->table,
900 sensor->id, thermal->regs, out_temp); 939 sensor->id, thermal->regs, out_temp);
901 dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n", 940 dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n",
902 sensor->id, *out_temp, retval); 941 sensor->id, *out_temp, retval);
@@ -982,8 +1021,12 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
982 int error; 1021 int error;
983 1022
984 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode); 1023 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode);
985 tsadc->set_tshut_temp(tsadc->table, id, thermal->regs, 1024
1025 error = tsadc->set_tshut_temp(&tsadc->table, id, thermal->regs,
986 thermal->tshut_temp); 1026 thermal->tshut_temp);
1027 if (error)
1028 dev_err(&pdev->dev, "%s: invalid tshut=%d, error=%d\n",
1029 __func__, thermal->tshut_temp, error);
987 1030
988 sensor->thermal = thermal; 1031 sensor->thermal = thermal;
989 sensor->id = id; 1032 sensor->id = id;
@@ -1196,9 +1239,13 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
1196 1239
1197 thermal->chip->set_tshut_mode(id, thermal->regs, 1240 thermal->chip->set_tshut_mode(id, thermal->regs,
1198 thermal->tshut_mode); 1241 thermal->tshut_mode);
1199 thermal->chip->set_tshut_temp(thermal->chip->table, 1242
1243 error = thermal->chip->set_tshut_temp(&thermal->chip->table,
1200 id, thermal->regs, 1244 id, thermal->regs,
1201 thermal->tshut_temp); 1245 thermal->tshut_temp);
1246 if (error)
1247 dev_err(&pdev->dev, "%s: invalid tshut=%d, error=%d\n",
1248 __func__, thermal->tshut_temp, error);
1202 } 1249 }
1203 1250
1204 thermal->chip->control(thermal->regs, true); 1251 thermal->chip->control(thermal->regs, true);
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 641faab6e24b..655591316a88 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -799,6 +799,11 @@ static void thermal_release(struct device *dev)
799 if (!strncmp(dev_name(dev), "thermal_zone", 799 if (!strncmp(dev_name(dev), "thermal_zone",
800 sizeof("thermal_zone") - 1)) { 800 sizeof("thermal_zone") - 1)) {
801 tz = to_thermal_zone(dev); 801 tz = to_thermal_zone(dev);
802 kfree(tz->trip_type_attrs);
803 kfree(tz->trip_temp_attrs);
804 kfree(tz->trip_hyst_attrs);
805 kfree(tz->trips_attribute_group.attrs);
806 kfree(tz->device.groups);
802 kfree(tz); 807 kfree(tz);
803 } else if (!strncmp(dev_name(dev), "cooling_device", 808 } else if (!strncmp(dev_name(dev), "cooling_device",
804 sizeof("cooling_device") - 1)) { 809 sizeof("cooling_device") - 1)) {
@@ -1305,10 +1310,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1305 1310
1306 thermal_zone_device_set_polling(tz, 0); 1311 thermal_zone_device_set_polling(tz, 0);
1307 1312
1308 kfree(tz->trip_type_attrs);
1309 kfree(tz->trip_temp_attrs);
1310 kfree(tz->trip_hyst_attrs);
1311 kfree(tz->trips_attribute_group.attrs);
1312 thermal_set_governor(tz, NULL); 1313 thermal_set_governor(tz, NULL);
1313 1314
1314 thermal_remove_hwmon_sysfs(tz); 1315 thermal_remove_hwmon_sysfs(tz);
@@ -1316,7 +1317,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1316 idr_destroy(&tz->idr); 1317 idr_destroy(&tz->idr);
1317 mutex_destroy(&tz->lock); 1318 mutex_destroy(&tz->lock);
1318 device_unregister(&tz->device); 1319 device_unregister(&tz->device);
1319 kfree(tz->device.groups);
1320} 1320}
1321EXPORT_SYMBOL_GPL(thermal_zone_device_unregister); 1321EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
1322 1322
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index 541af5946203..c4a508a124dc 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -59,14 +59,6 @@ static LIST_HEAD(thermal_hwmon_list);
59static DEFINE_MUTEX(thermal_hwmon_list_lock); 59static DEFINE_MUTEX(thermal_hwmon_list_lock);
60 60
61static ssize_t 61static ssize_t
62name_show(struct device *dev, struct device_attribute *attr, char *buf)
63{
64 struct thermal_hwmon_device *hwmon = dev_get_drvdata(dev);
65 return sprintf(buf, "%s\n", hwmon->type);
66}
67static DEVICE_ATTR_RO(name);
68
69static ssize_t
70temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) 62temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)
71{ 63{
72 int temperature; 64 int temperature;
@@ -165,15 +157,12 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
165 157
166 INIT_LIST_HEAD(&hwmon->tz_list); 158 INIT_LIST_HEAD(&hwmon->tz_list);
167 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH); 159 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
168 hwmon->device = hwmon_device_register(NULL); 160 hwmon->device = hwmon_device_register_with_info(NULL, hwmon->type,
161 hwmon, NULL, NULL);
169 if (IS_ERR(hwmon->device)) { 162 if (IS_ERR(hwmon->device)) {
170 result = PTR_ERR(hwmon->device); 163 result = PTR_ERR(hwmon->device);
171 goto free_mem; 164 goto free_mem;
172 } 165 }
173 dev_set_drvdata(hwmon->device, hwmon);
174 result = device_create_file(hwmon->device, &dev_attr_name);
175 if (result)
176 goto free_mem;
177 166
178 register_sys_interface: 167 register_sys_interface:
179 temp = kzalloc(sizeof(*temp), GFP_KERNEL); 168 temp = kzalloc(sizeof(*temp), GFP_KERNEL);
@@ -222,10 +211,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
222 free_temp_mem: 211 free_temp_mem:
223 kfree(temp); 212 kfree(temp);
224 unregister_name: 213 unregister_name:
225 if (new_hwmon_device) { 214 if (new_hwmon_device)
226 device_remove_file(hwmon->device, &dev_attr_name);
227 hwmon_device_unregister(hwmon->device); 215 hwmon_device_unregister(hwmon->device);
228 }
229 free_mem: 216 free_mem:
230 if (new_hwmon_device) 217 if (new_hwmon_device)
231 kfree(hwmon); 218 kfree(hwmon);
@@ -267,7 +254,6 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
267 list_del(&hwmon->node); 254 list_del(&hwmon->node);
268 mutex_unlock(&thermal_hwmon_list_lock); 255 mutex_unlock(&thermal_hwmon_list_lock);
269 256
270 device_remove_file(hwmon->device, &dev_attr_name);
271 hwmon_device_unregister(hwmon->device); 257 hwmon_device_unregister(hwmon->device);
272 kfree(hwmon); 258 kfree(hwmon);
273} 259}
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 61569a765d9e..76e03a7de9cc 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -675,7 +675,7 @@ static struct console univ8250_console = {
675 .device = uart_console_device, 675 .device = uart_console_device,
676 .setup = univ8250_console_setup, 676 .setup = univ8250_console_setup,
677 .match = univ8250_console_match, 677 .match = univ8250_console_match,
678 .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_CONSDEV, 678 .flags = CON_PRINTBUFFER | CON_ANYTIME,
679 .index = -1, 679 .index = -1,
680 .data = &serial8250_reg, 680 .data = &serial8250_reg,
681}; 681};
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index aa0166b6d450..116436b7fa52 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -5642,17 +5642,15 @@ static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
5642static void serial8250_io_resume(struct pci_dev *dev) 5642static void serial8250_io_resume(struct pci_dev *dev)
5643{ 5643{
5644 struct serial_private *priv = pci_get_drvdata(dev); 5644 struct serial_private *priv = pci_get_drvdata(dev);
5645 const struct pciserial_board *board; 5645 struct serial_private *new;
5646 5646
5647 if (!priv) 5647 if (!priv)
5648 return; 5648 return;
5649 5649
5650 board = priv->board; 5650 new = pciserial_init_ports(dev, priv->board);
5651 kfree(priv); 5651 if (!IS_ERR(new)) {
5652 priv = pciserial_init_ports(dev, board); 5652 pci_set_drvdata(dev, new);
5653 5653 kfree(priv);
5654 if (!IS_ERR(priv)) {
5655 pci_set_drvdata(dev, priv);
5656 } 5654 }
5657} 5655}
5658 5656
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index fe4399b41df6..c13fec451d03 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1413,7 +1413,7 @@ static void __do_stop_tx_rs485(struct uart_8250_port *p)
1413 * Enable previously disabled RX interrupts. 1413 * Enable previously disabled RX interrupts.
1414 */ 1414 */
1415 if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) { 1415 if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
1416 serial8250_clear_fifos(p); 1416 serial8250_clear_and_reinit_fifos(p);
1417 1417
1418 p->ier |= UART_IER_RLSI | UART_IER_RDI; 1418 p->ier |= UART_IER_RLSI | UART_IER_RDI;
1419 serial_port_out(&p->port, UART_IER, p->ier); 1419 serial_port_out(&p->port, UART_IER, p->ier);
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 168b10cad47b..fabbe76203bb 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -481,6 +481,14 @@ static void atmel_stop_tx(struct uart_port *port)
481 /* disable PDC transmit */ 481 /* disable PDC transmit */
482 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); 482 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS);
483 } 483 }
484
485 /*
486 * Disable the transmitter.
487 * This is mandatory when DMA is used, otherwise the DMA buffer
488 * is fully transmitted.
489 */
490 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
491
484 /* Disable interrupts */ 492 /* Disable interrupts */
485 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); 493 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
486 494
@@ -513,6 +521,9 @@ static void atmel_start_tx(struct uart_port *port)
513 521
514 /* Enable interrupts */ 522 /* Enable interrupts */
515 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); 523 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);
524
525 /* re-enable the transmitter */
526 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
516} 527}
517 528
518/* 529/*
@@ -798,6 +809,11 @@ static void atmel_complete_tx_dma(void *arg)
798 */ 809 */
799 if (!uart_circ_empty(xmit)) 810 if (!uart_circ_empty(xmit))
800 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); 811 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
812 else if ((port->rs485.flags & SER_RS485_ENABLED) &&
813 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) {
814 /* DMA done, stop TX, start RX for RS485 */
815 atmel_start_rx(port);
816 }
801 817
802 spin_unlock_irqrestore(&port->lock, flags); 818 spin_unlock_irqrestore(&port->lock, flags);
803} 819}
@@ -900,12 +916,6 @@ static void atmel_tx_dma(struct uart_port *port)
900 desc->callback = atmel_complete_tx_dma; 916 desc->callback = atmel_complete_tx_dma;
901 desc->callback_param = atmel_port; 917 desc->callback_param = atmel_port;
902 atmel_port->cookie_tx = dmaengine_submit(desc); 918 atmel_port->cookie_tx = dmaengine_submit(desc);
903
904 } else {
905 if (port->rs485.flags & SER_RS485_ENABLED) {
906 /* DMA done, stop TX, start RX for RS485 */
907 atmel_start_rx(port);
908 }
909 } 919 }
910 920
911 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 921 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 52bbd27e93ae..701c085bb19b 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -946,8 +946,8 @@ static const struct input_device_id sysrq_ids[] = {
946 { 946 {
947 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 947 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
948 INPUT_DEVICE_ID_MATCH_KEYBIT, 948 INPUT_DEVICE_ID_MATCH_KEYBIT,
949 .evbit = { BIT_MASK(EV_KEY) }, 949 .evbit = { [BIT_WORD(EV_KEY)] = BIT_MASK(EV_KEY) },
950 .keybit = { BIT_MASK(KEY_LEFTALT) }, 950 .keybit = { [BIT_WORD(KEY_LEFTALT)] = BIT_MASK(KEY_LEFTALT) },
951 }, 951 },
952 { }, 952 { },
953}; 953};
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 0aa9e7d697a5..25dbd8c7aec7 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -239,6 +239,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
239 if (ifp->desc.bNumEndpoints >= num_ep) 239 if (ifp->desc.bNumEndpoints >= num_ep)
240 goto skip_to_next_endpoint_or_interface_descriptor; 240 goto skip_to_next_endpoint_or_interface_descriptor;
241 241
242 /* Check for duplicate endpoint addresses */
243 for (i = 0; i < ifp->desc.bNumEndpoints; ++i) {
244 if (ifp->endpoint[i].desc.bEndpointAddress ==
245 d->bEndpointAddress) {
246 dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
247 cfgno, inum, asnum, d->bEndpointAddress);
248 goto skip_to_next_endpoint_or_interface_descriptor;
249 }
250 }
251
242 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; 252 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
243 ++ifp->desc.bNumEndpoints; 253 ++ifp->desc.bNumEndpoints;
244 254
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1fa5c0f29c64..a56c75e09786 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -103,8 +103,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
103 103
104static void hub_release(struct kref *kref); 104static void hub_release(struct kref *kref);
105static int usb_reset_and_verify_device(struct usb_device *udev); 105static int usb_reset_and_verify_device(struct usb_device *udev);
106static void hub_usb3_port_prepare_disable(struct usb_hub *hub, 106static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
107 struct usb_port *port_dev);
108 107
109static inline char *portspeed(struct usb_hub *hub, int portstatus) 108static inline char *portspeed(struct usb_hub *hub, int portstatus)
110{ 109{
@@ -903,34 +902,6 @@ static int hub_set_port_link_state(struct usb_hub *hub, int port1,
903} 902}
904 903
905/* 904/*
906 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
907 * a connection with a plugged-in cable but will signal the host when the cable
908 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
909 */
910static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
911{
912 struct usb_port *port_dev = hub->ports[port1 - 1];
913 struct usb_device *hdev = hub->hdev;
914 int ret = 0;
915
916 if (!hub->error) {
917 if (hub_is_superspeed(hub->hdev)) {
918 hub_usb3_port_prepare_disable(hub, port_dev);
919 ret = hub_set_port_link_state(hub, port_dev->portnum,
920 USB_SS_PORT_LS_U3);
921 } else {
922 ret = usb_clear_port_feature(hdev, port1,
923 USB_PORT_FEAT_ENABLE);
924 }
925 }
926 if (port_dev->child && set_state)
927 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
928 if (ret && ret != -ENODEV)
929 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
930 return ret;
931}
932
933/*
934 * Disable a port and mark a logical connect-change event, so that some 905 * Disable a port and mark a logical connect-change event, so that some
935 * time later hub_wq will disconnect() any existing usb_device on the port 906 * time later hub_wq will disconnect() any existing usb_device on the port
936 * and will re-enumerate if there actually is a device attached. 907 * and will re-enumerate if there actually is a device attached.
@@ -4162,6 +4133,34 @@ static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port,
4162 4133
4163#endif /* CONFIG_PM */ 4134#endif /* CONFIG_PM */
4164 4135
4136/*
4137 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
4138 * a connection with a plugged-in cable but will signal the host when the cable
4139 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
4140 */
4141static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
4142{
4143 struct usb_port *port_dev = hub->ports[port1 - 1];
4144 struct usb_device *hdev = hub->hdev;
4145 int ret = 0;
4146
4147 if (!hub->error) {
4148 if (hub_is_superspeed(hub->hdev)) {
4149 hub_usb3_port_prepare_disable(hub, port_dev);
4150 ret = hub_set_port_link_state(hub, port_dev->portnum,
4151 USB_SS_PORT_LS_U3);
4152 } else {
4153 ret = usb_clear_port_feature(hdev, port1,
4154 USB_PORT_FEAT_ENABLE);
4155 }
4156 }
4157 if (port_dev->child && set_state)
4158 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
4159 if (ret && ret != -ENODEV)
4160 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
4161 return ret;
4162}
4163
4165 4164
4166/* USB 2.0 spec, 7.1.7.3 / fig 7-29: 4165/* USB 2.0 spec, 7.1.7.3 / fig 7-29:
4167 * 4166 *
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9548d3e03453..302b8f5f7d27 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -513,8 +513,8 @@ struct dwc2_core_params {
513 /* Gadget parameters */ 513 /* Gadget parameters */
514 bool g_dma; 514 bool g_dma;
515 bool g_dma_desc; 515 bool g_dma_desc;
516 u16 g_rx_fifo_size; 516 u32 g_rx_fifo_size;
517 u16 g_np_tx_fifo_size; 517 u32 g_np_tx_fifo_size;
518 u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; 518 u32 g_tx_fifo_size[MAX_EPS_CHANNELS];
519}; 519};
520 520
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index b95930f20d90..77c5fcf3a5bf 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3169,7 +3169,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
3169 /* keep other bits untouched (so e.g. forced modes are not lost) */ 3169 /* keep other bits untouched (so e.g. forced modes are not lost) */
3170 usbcfg = dwc2_readl(hsotg->regs + GUSBCFG); 3170 usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
3171 usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP | 3171 usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
3172 GUSBCFG_HNPCAP); 3172 GUSBCFG_HNPCAP | GUSBCFG_USBTRDTIM_MASK);
3173 3173
3174 if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS && 3174 if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS &&
3175 (hsotg->params.speed == DWC2_SPEED_PARAM_FULL || 3175 (hsotg->params.speed == DWC2_SPEED_PARAM_FULL ||
@@ -3749,11 +3749,11 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
3749 __func__, epctrl, epctrl_reg); 3749 __func__, epctrl, epctrl_reg);
3750 3750
3751 /* Allocate DMA descriptor chain for non-ctrl endpoints */ 3751 /* Allocate DMA descriptor chain for non-ctrl endpoints */
3752 if (using_desc_dma(hsotg)) { 3752 if (using_desc_dma(hsotg) && !hs_ep->desc_list) {
3753 hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, 3753 hs_ep->desc_list = dmam_alloc_coherent(hsotg->dev,
3754 MAX_DMA_DESC_NUM_GENERIC * 3754 MAX_DMA_DESC_NUM_GENERIC *
3755 sizeof(struct dwc2_dma_desc), 3755 sizeof(struct dwc2_dma_desc),
3756 &hs_ep->desc_list_dma, GFP_KERNEL); 3756 &hs_ep->desc_list_dma, GFP_ATOMIC);
3757 if (!hs_ep->desc_list) { 3757 if (!hs_ep->desc_list) {
3758 ret = -ENOMEM; 3758 ret = -ENOMEM;
3759 goto error2; 3759 goto error2;
@@ -3872,7 +3872,7 @@ error1:
3872 3872
3873error2: 3873error2:
3874 if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) { 3874 if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) {
3875 dma_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC * 3875 dmam_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC *
3876 sizeof(struct dwc2_dma_desc), 3876 sizeof(struct dwc2_dma_desc),
3877 hs_ep->desc_list, hs_ep->desc_list_dma); 3877 hs_ep->desc_list, hs_ep->desc_list_dma);
3878 hs_ep->desc_list = NULL; 3878 hs_ep->desc_list = NULL;
@@ -3902,14 +3902,6 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)
3902 return -EINVAL; 3902 return -EINVAL;
3903 } 3903 }
3904 3904
3905 /* Remove DMA memory allocated for non-control Endpoints */
3906 if (using_desc_dma(hsotg)) {
3907 dma_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC *
3908 sizeof(struct dwc2_dma_desc),
3909 hs_ep->desc_list, hs_ep->desc_list_dma);
3910 hs_ep->desc_list = NULL;
3911 }
3912
3913 epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); 3905 epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index);
3914 3906
3915 spin_lock_irqsave(&hsotg->lock, flags); 3907 spin_lock_irqsave(&hsotg->lock, flags);
@@ -4131,7 +4123,7 @@ static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg)
4131 /* keep other bits untouched (so e.g. forced modes are not lost) */ 4123 /* keep other bits untouched (so e.g. forced modes are not lost) */
4132 usbcfg = dwc2_readl(hsotg->regs + GUSBCFG); 4124 usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
4133 usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP | 4125 usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
4134 GUSBCFG_HNPCAP); 4126 GUSBCFG_HNPCAP | GUSBCFG_USBTRDTIM_MASK);
4135 4127
4136 /* set the PLL on, remove the HNP/SRP and set the PHY */ 4128 /* set the PLL on, remove the HNP/SRP and set the PHY */
4137 trdtim = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5; 4129 trdtim = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 911c3b36ac06..46d0ad5105e4 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -4367,6 +4367,9 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
4367 if (!HCD_HW_ACCESSIBLE(hcd)) 4367 if (!HCD_HW_ACCESSIBLE(hcd))
4368 goto unlock; 4368 goto unlock;
4369 4369
4370 if (hsotg->op_state == OTG_STATE_B_PERIPHERAL)
4371 goto unlock;
4372
4370 if (!hsotg->params.hibernation) 4373 if (!hsotg->params.hibernation)
4371 goto skip_power_saving; 4374 goto skip_power_saving;
4372 4375
@@ -4489,8 +4492,8 @@ static void dwc2_dump_urb_info(struct usb_hcd *hcd, struct urb *urb,
4489{ 4492{
4490#ifdef VERBOSE_DEBUG 4493#ifdef VERBOSE_DEBUG
4491 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); 4494 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
4492 char *pipetype; 4495 char *pipetype = NULL;
4493 char *speed; 4496 char *speed = NULL;
4494 4497
4495 dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb); 4498 dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb);
4496 dev_vdbg(hsotg->dev, " Device address: %d\n", 4499 dev_vdbg(hsotg->dev, " Device address: %d\n",
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a786256535b6..bcd1e19b4076 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -247,8 +247,6 @@ MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
247static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, 247static void dwc2_get_device_property(struct dwc2_hsotg *hsotg,
248 char *property, u8 size, u64 *value) 248 char *property, u8 size, u64 *value)
249{ 249{
250 u8 val8;
251 u16 val16;
252 u32 val32; 250 u32 val32;
253 251
254 switch (size) { 252 switch (size) {
@@ -256,17 +254,7 @@ static void dwc2_get_device_property(struct dwc2_hsotg *hsotg,
256 *value = device_property_read_bool(hsotg->dev, property); 254 *value = device_property_read_bool(hsotg->dev, property);
257 break; 255 break;
258 case 1: 256 case 1:
259 if (device_property_read_u8(hsotg->dev, property, &val8))
260 return;
261
262 *value = val8;
263 break;
264 case 2: 257 case 2:
265 if (device_property_read_u16(hsotg->dev, property, &val16))
266 return;
267
268 *value = val16;
269 break;
270 case 4: 258 case 4:
271 if (device_property_read_u32(hsotg->dev, property, &val32)) 259 if (device_property_read_u32(hsotg->dev, property, &val32))
272 return; 260 return;
@@ -397,16 +385,16 @@ static void dwc2_set_param(struct dwc2_hsotg *hsotg, void *param,
397} 385}
398 386
399/** 387/**
400 * dwc2_set_param_u16() - Set a u16 parameter 388 * dwc2_set_param_u32() - Set a u32 parameter
401 * 389 *
402 * See dwc2_set_param(). 390 * See dwc2_set_param().
403 */ 391 */
404static void dwc2_set_param_u16(struct dwc2_hsotg *hsotg, u16 *param, 392static void dwc2_set_param_u32(struct dwc2_hsotg *hsotg, u32 *param,
405 bool lookup, char *property, u16 legacy, 393 bool lookup, char *property, u16 legacy,
406 u16 def, u16 min, u16 max) 394 u16 def, u16 min, u16 max)
407{ 395{
408 dwc2_set_param(hsotg, param, lookup, property, 396 dwc2_set_param(hsotg, param, lookup, property,
409 legacy, def, min, max, 2); 397 legacy, def, min, max, 4);
410} 398}
411 399
412/** 400/**
@@ -1100,13 +1088,13 @@ static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg)
1100 /* Buffer DMA */ 1088 /* Buffer DMA */
1101 dwc2_set_param_bool(hsotg, &p->g_dma, 1089 dwc2_set_param_bool(hsotg, &p->g_dma,
1102 false, "gadget-dma", 1090 false, "gadget-dma",
1103 true, false, 1091 dma_capable, false,
1104 dma_capable); 1092 dma_capable);
1105 1093
1106 /* DMA Descriptor */ 1094 /* DMA Descriptor */
1107 dwc2_set_param_bool(hsotg, &p->g_dma_desc, false, 1095 dwc2_set_param_bool(hsotg, &p->g_dma_desc, false,
1108 "gadget-dma-desc", 1096 "gadget-dma-desc",
1109 p->g_dma, false, 1097 !!hw->dma_desc_enable, false,
1110 !!hw->dma_desc_enable); 1098 !!hw->dma_desc_enable);
1111} 1099}
1112 1100
@@ -1130,8 +1118,14 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1130 1118
1131 dwc2_set_param_bool(hsotg, &p->host_dma, 1119 dwc2_set_param_bool(hsotg, &p->host_dma,
1132 false, "host-dma", 1120 false, "host-dma",
1133 true, false, 1121 dma_capable, false,
1134 dma_capable); 1122 dma_capable);
1123 dwc2_set_param_host_rx_fifo_size(hsotg,
1124 params->host_rx_fifo_size);
1125 dwc2_set_param_host_nperio_tx_fifo_size(hsotg,
1126 params->host_nperio_tx_fifo_size);
1127 dwc2_set_param_host_perio_tx_fifo_size(hsotg,
1128 params->host_perio_tx_fifo_size);
1135 } 1129 }
1136 dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable); 1130 dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable);
1137 dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable); 1131 dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable);
@@ -1140,12 +1134,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1140 params->host_support_fs_ls_low_power); 1134 params->host_support_fs_ls_low_power);
1141 dwc2_set_param_enable_dynamic_fifo(hsotg, 1135 dwc2_set_param_enable_dynamic_fifo(hsotg,
1142 params->enable_dynamic_fifo); 1136 params->enable_dynamic_fifo);
1143 dwc2_set_param_host_rx_fifo_size(hsotg,
1144 params->host_rx_fifo_size);
1145 dwc2_set_param_host_nperio_tx_fifo_size(hsotg,
1146 params->host_nperio_tx_fifo_size);
1147 dwc2_set_param_host_perio_tx_fifo_size(hsotg,
1148 params->host_perio_tx_fifo_size);
1149 dwc2_set_param_max_transfer_size(hsotg, 1137 dwc2_set_param_max_transfer_size(hsotg,
1150 params->max_transfer_size); 1138 params->max_transfer_size);
1151 dwc2_set_param_max_packet_count(hsotg, 1139 dwc2_set_param_max_packet_count(hsotg,
@@ -1190,12 +1178,12 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1190 * auto-detect if the hardware does not support the 1178 * auto-detect if the hardware does not support the
1191 * default. 1179 * default.
1192 */ 1180 */
1193 dwc2_set_param_u16(hsotg, &p->g_rx_fifo_size, 1181 dwc2_set_param_u32(hsotg, &p->g_rx_fifo_size,
1194 true, "g-rx-fifo-size", 2048, 1182 true, "g-rx-fifo-size", 2048,
1195 hw->rx_fifo_size, 1183 hw->rx_fifo_size,
1196 16, hw->rx_fifo_size); 1184 16, hw->rx_fifo_size);
1197 1185
1198 dwc2_set_param_u16(hsotg, &p->g_np_tx_fifo_size, 1186 dwc2_set_param_u32(hsotg, &p->g_np_tx_fifo_size,
1199 true, "g-np-tx-fifo-size", 1024, 1187 true, "g-np-tx-fifo-size", 1024,
1200 hw->dev_nperio_tx_fifo_size, 1188 hw->dev_nperio_tx_fifo_size,
1201 16, hw->dev_nperio_tx_fifo_size); 1189 16, hw->dev_nperio_tx_fifo_size);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index de5a8570be04..14b760209680 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -45,9 +45,7 @@
45#define DWC3_XHCI_RESOURCES_NUM 2 45#define DWC3_XHCI_RESOURCES_NUM 2
46 46
47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ 47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */
48#define DWC3_EVENT_SIZE 4 /* bytes */ 48#define DWC3_EVENT_BUFFERS_SIZE 4096
49#define DWC3_EVENT_MAX_NUM 64 /* 2 events/endpoint */
50#define DWC3_EVENT_BUFFERS_SIZE (DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM)
51#define DWC3_EVENT_TYPE_MASK 0xfe 49#define DWC3_EVENT_TYPE_MASK 0xfe
52 50
53#define DWC3_EVENT_TYPE_DEV 0 51#define DWC3_EVENT_TYPE_DEV 0
@@ -311,9 +309,8 @@
311#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ 309#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */
312#define DWC3_DCFG_SUPERSPEED (4 << 0) 310#define DWC3_DCFG_SUPERSPEED (4 << 0)
313#define DWC3_DCFG_HIGHSPEED (0 << 0) 311#define DWC3_DCFG_HIGHSPEED (0 << 0)
314#define DWC3_DCFG_FULLSPEED2 (1 << 0) 312#define DWC3_DCFG_FULLSPEED (1 << 0)
315#define DWC3_DCFG_LOWSPEED (2 << 0) 313#define DWC3_DCFG_LOWSPEED (2 << 0)
316#define DWC3_DCFG_FULLSPEED1 (3 << 0)
317 314
318#define DWC3_DCFG_NUMP_SHIFT 17 315#define DWC3_DCFG_NUMP_SHIFT 17
319#define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f) 316#define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f)
@@ -405,9 +402,8 @@
405#define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ 402#define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */
406#define DWC3_DSTS_SUPERSPEED (4 << 0) 403#define DWC3_DSTS_SUPERSPEED (4 << 0)
407#define DWC3_DSTS_HIGHSPEED (0 << 0) 404#define DWC3_DSTS_HIGHSPEED (0 << 0)
408#define DWC3_DSTS_FULLSPEED2 (1 << 0) 405#define DWC3_DSTS_FULLSPEED (1 << 0)
409#define DWC3_DSTS_LOWSPEED (2 << 0) 406#define DWC3_DSTS_LOWSPEED (2 << 0)
410#define DWC3_DSTS_FULLSPEED1 (3 << 0)
411 407
412/* Device Generic Command Register */ 408/* Device Generic Command Register */
413#define DWC3_DGCMD_SET_LMP 0x01 409#define DWC3_DGCMD_SET_LMP 0x01
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index e27899bb5706..e956306d9b0f 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -138,7 +138,8 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
138 exynos->axius_clk = devm_clk_get(dev, "usbdrd30_axius_clk"); 138 exynos->axius_clk = devm_clk_get(dev, "usbdrd30_axius_clk");
139 if (IS_ERR(exynos->axius_clk)) { 139 if (IS_ERR(exynos->axius_clk)) {
140 dev_err(dev, "no AXI UpScaler clk specified\n"); 140 dev_err(dev, "no AXI UpScaler clk specified\n");
141 return -ENODEV; 141 ret = -ENODEV;
142 goto axius_clk_err;
142 } 143 }
143 clk_prepare_enable(exynos->axius_clk); 144 clk_prepare_enable(exynos->axius_clk);
144 } else { 145 } else {
@@ -196,6 +197,7 @@ err3:
196 regulator_disable(exynos->vdd33); 197 regulator_disable(exynos->vdd33);
197err2: 198err2:
198 clk_disable_unprepare(exynos->axius_clk); 199 clk_disable_unprepare(exynos->axius_clk);
200axius_clk_err:
199 clk_disable_unprepare(exynos->susp_clk); 201 clk_disable_unprepare(exynos->susp_clk);
200 clk_disable_unprepare(exynos->clk); 202 clk_disable_unprepare(exynos->clk);
201 return ret; 203 return ret;
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 29e80cc9b634..eb1b9cb3f9d1 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/irq.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/platform_data/dwc3-omap.h> 25#include <linux/platform_data/dwc3-omap.h>
@@ -510,7 +511,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
510 511
511 /* check the DMA Status */ 512 /* check the DMA Status */
512 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); 513 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
513 514 irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
514 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, 515 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
515 dwc3_omap_interrupt_thread, IRQF_SHARED, 516 dwc3_omap_interrupt_thread, IRQF_SHARED,
516 "dwc3-omap", omap); 517 "dwc3-omap", omap);
@@ -531,7 +532,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
531 } 532 }
532 533
533 dwc3_omap_enable_irqs(omap); 534 dwc3_omap_enable_irqs(omap);
534 535 enable_irq(omap->irq);
535 return 0; 536 return 0;
536 537
537err2: 538err2:
@@ -552,6 +553,7 @@ static int dwc3_omap_remove(struct platform_device *pdev)
552 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); 553 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb);
553 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); 554 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb);
554 dwc3_omap_disable_irqs(omap); 555 dwc3_omap_disable_irqs(omap);
556 disable_irq(omap->irq);
555 of_platform_depopulate(omap->dev); 557 of_platform_depopulate(omap->dev);
556 pm_runtime_put_sync(&pdev->dev); 558 pm_runtime_put_sync(&pdev->dev);
557 pm_runtime_disable(&pdev->dev); 559 pm_runtime_disable(&pdev->dev);
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 2b73339f286b..cce0a220b6b0 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -38,6 +38,7 @@
38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa 38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa 39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
41#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
41 42
42#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 43#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
43#define PCI_INTEL_BXT_FUNC_PMU_PWR 4 44#define PCI_INTEL_BXT_FUNC_PMU_PWR 4
@@ -73,16 +74,6 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
73{ 74{
74 struct platform_device *dwc3 = dwc->dwc3; 75 struct platform_device *dwc3 = dwc->dwc3;
75 struct pci_dev *pdev = dwc->pci; 76 struct pci_dev *pdev = dwc->pci;
76 int ret;
77
78 struct property_entry sysdev_property[] = {
79 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
80 { },
81 };
82
83 ret = platform_device_add_properties(dwc3, sysdev_property);
84 if (ret)
85 return ret;
86 77
87 if (pdev->vendor == PCI_VENDOR_ID_AMD && 78 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
88 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { 79 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
@@ -105,6 +96,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
105 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"), 96 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"),
106 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"), 97 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"),
107 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"), 98 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
99 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
108 { }, 100 { },
109 }; 101 };
110 102
@@ -115,7 +107,8 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
115 int ret; 107 int ret;
116 108
117 struct property_entry properties[] = { 109 struct property_entry properties[] = {
118 PROPERTY_ENTRY_STRING("dr-mode", "peripheral"), 110 PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
111 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
119 { } 112 { }
120 }; 113 };
121 114
@@ -167,6 +160,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
167 PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"), 160 PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"),
168 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"), 161 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
169 PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"), 162 PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"),
163 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
170 { }, 164 { },
171 }; 165 };
172 166
@@ -274,6 +268,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
274 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, 268 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
275 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, 269 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
276 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, 270 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
271 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
277 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 272 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
278 { } /* Terminating Entry */ 273 { } /* Terminating Entry */
279}; 274};
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 4878d187c7d4..9bb1f8526f3e 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -39,18 +39,13 @@ static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep);
39static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, 39static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
40 struct dwc3_ep *dep, struct dwc3_request *req); 40 struct dwc3_ep *dep, struct dwc3_request *req);
41 41
42static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, 42static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum,
43 u32 len, u32 type, bool chain) 43 dma_addr_t buf_dma, u32 len, u32 type, bool chain)
44{ 44{
45 struct dwc3_gadget_ep_cmd_params params;
46 struct dwc3_trb *trb; 45 struct dwc3_trb *trb;
47 struct dwc3_ep *dep; 46 struct dwc3_ep *dep;
48 47
49 int ret;
50
51 dep = dwc->eps[epnum]; 48 dep = dwc->eps[epnum];
52 if (dep->flags & DWC3_EP_BUSY)
53 return 0;
54 49
55 trb = &dwc->ep0_trb[dep->trb_enqueue]; 50 trb = &dwc->ep0_trb[dep->trb_enqueue];
56 51
@@ -71,15 +66,23 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
71 trb->ctrl |= (DWC3_TRB_CTRL_IOC 66 trb->ctrl |= (DWC3_TRB_CTRL_IOC
72 | DWC3_TRB_CTRL_LST); 67 | DWC3_TRB_CTRL_LST);
73 68
74 if (chain) 69 trace_dwc3_prepare_trb(dep, trb);
70}
71
72static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum)
73{
74 struct dwc3_gadget_ep_cmd_params params;
75 struct dwc3_ep *dep;
76 int ret;
77
78 dep = dwc->eps[epnum];
79 if (dep->flags & DWC3_EP_BUSY)
75 return 0; 80 return 0;
76 81
77 memset(&params, 0, sizeof(params)); 82 memset(&params, 0, sizeof(params));
78 params.param0 = upper_32_bits(dwc->ep0_trb_addr); 83 params.param0 = upper_32_bits(dwc->ep0_trb_addr);
79 params.param1 = lower_32_bits(dwc->ep0_trb_addr); 84 params.param1 = lower_32_bits(dwc->ep0_trb_addr);
80 85
81 trace_dwc3_prepare_trb(dep, trb);
82
83 ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params); 86 ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params);
84 if (ret < 0) 87 if (ret < 0)
85 return ret; 88 return ret;
@@ -280,8 +283,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
280 283
281 complete(&dwc->ep0_in_setup); 284 complete(&dwc->ep0_in_setup);
282 285
283 ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, 286 dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8,
284 DWC3_TRBCTL_CONTROL_SETUP, false); 287 DWC3_TRBCTL_CONTROL_SETUP, false);
288 ret = dwc3_ep0_start_trans(dwc, 0);
285 WARN_ON(ret < 0); 289 WARN_ON(ret < 0);
286} 290}
287 291
@@ -912,9 +916,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
912 916
913 dwc->ep0_next_event = DWC3_EP0_COMPLETE; 917 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
914 918
915 ret = dwc3_ep0_start_trans(dwc, epnum, 919 dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr,
916 dwc->ctrl_req_addr, 0, 920 0, DWC3_TRBCTL_CONTROL_DATA, false);
917 DWC3_TRBCTL_CONTROL_DATA, false); 921 ret = dwc3_ep0_start_trans(dwc, epnum);
918 WARN_ON(ret < 0); 922 WARN_ON(ret < 0);
919 } 923 }
920 } 924 }
@@ -993,9 +997,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
993 req->direction = !!dep->number; 997 req->direction = !!dep->number;
994 998
995 if (req->request.length == 0) { 999 if (req->request.length == 0) {
996 ret = dwc3_ep0_start_trans(dwc, dep->number, 1000 dwc3_ep0_prepare_one_trb(dwc, dep->number,
997 dwc->ctrl_req_addr, 0, 1001 dwc->ctrl_req_addr, 0,
998 DWC3_TRBCTL_CONTROL_DATA, false); 1002 DWC3_TRBCTL_CONTROL_DATA, false);
1003 ret = dwc3_ep0_start_trans(dwc, dep->number);
999 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) 1004 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
1000 && (dep->number == 0)) { 1005 && (dep->number == 0)) {
1001 u32 transfer_size = 0; 1006 u32 transfer_size = 0;
@@ -1011,7 +1016,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1011 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { 1016 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
1012 transfer_size = ALIGN(req->request.length - maxpacket, 1017 transfer_size = ALIGN(req->request.length - maxpacket,
1013 maxpacket); 1018 maxpacket);
1014 ret = dwc3_ep0_start_trans(dwc, dep->number, 1019 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1015 req->request.dma, 1020 req->request.dma,
1016 transfer_size, 1021 transfer_size,
1017 DWC3_TRBCTL_CONTROL_DATA, 1022 DWC3_TRBCTL_CONTROL_DATA,
@@ -1023,18 +1028,20 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1023 1028
1024 dwc->ep0_bounced = true; 1029 dwc->ep0_bounced = true;
1025 1030
1026 ret = dwc3_ep0_start_trans(dwc, dep->number, 1031 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1027 dwc->ep0_bounce_addr, transfer_size, 1032 dwc->ep0_bounce_addr, transfer_size,
1028 DWC3_TRBCTL_CONTROL_DATA, false); 1033 DWC3_TRBCTL_CONTROL_DATA, false);
1034 ret = dwc3_ep0_start_trans(dwc, dep->number);
1029 } else { 1035 } else {
1030 ret = usb_gadget_map_request_by_dev(dwc->sysdev, 1036 ret = usb_gadget_map_request_by_dev(dwc->sysdev,
1031 &req->request, dep->number); 1037 &req->request, dep->number);
1032 if (ret) 1038 if (ret)
1033 return; 1039 return;
1034 1040
1035 ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, 1041 dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma,
1036 req->request.length, DWC3_TRBCTL_CONTROL_DATA, 1042 req->request.length, DWC3_TRBCTL_CONTROL_DATA,
1037 false); 1043 false);
1044 ret = dwc3_ep0_start_trans(dwc, dep->number);
1038 } 1045 }
1039 1046
1040 WARN_ON(ret < 0); 1047 WARN_ON(ret < 0);
@@ -1048,8 +1055,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
1048 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 1055 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
1049 : DWC3_TRBCTL_CONTROL_STATUS2; 1056 : DWC3_TRBCTL_CONTROL_STATUS2;
1050 1057
1051 return dwc3_ep0_start_trans(dwc, dep->number, 1058 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1052 dwc->ctrl_req_addr, 0, type, false); 1059 dwc->ctrl_req_addr, 0, type, false);
1060 return dwc3_ep0_start_trans(dwc, dep->number);
1053} 1061}
1054 1062
1055static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) 1063static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index efddaf5d11d1..204c754cc647 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -180,11 +180,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
180 if (req->request.status == -EINPROGRESS) 180 if (req->request.status == -EINPROGRESS)
181 req->request.status = status; 181 req->request.status = status;
182 182
183 if (dwc->ep0_bounced && dep->number == 0) 183 if (dwc->ep0_bounced && dep->number <= 1)
184 dwc->ep0_bounced = false; 184 dwc->ep0_bounced = false;
185 else 185
186 usb_gadget_unmap_request_by_dev(dwc->sysdev, 186 usb_gadget_unmap_request_by_dev(dwc->sysdev,
187 &req->request, req->direction); 187 &req->request, req->direction);
188 188
189 trace_dwc3_gadget_giveback(req); 189 trace_dwc3_gadget_giveback(req);
190 190
@@ -1720,7 +1720,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
1720 reg |= DWC3_DCFG_LOWSPEED; 1720 reg |= DWC3_DCFG_LOWSPEED;
1721 break; 1721 break;
1722 case USB_SPEED_FULL: 1722 case USB_SPEED_FULL:
1723 reg |= DWC3_DCFG_FULLSPEED1; 1723 reg |= DWC3_DCFG_FULLSPEED;
1724 break; 1724 break;
1725 case USB_SPEED_HIGH: 1725 case USB_SPEED_HIGH:
1726 reg |= DWC3_DCFG_HIGHSPEED; 1726 reg |= DWC3_DCFG_HIGHSPEED;
@@ -2232,9 +2232,14 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
2232 2232
2233 dep = dwc->eps[epnum]; 2233 dep = dwc->eps[epnum];
2234 2234
2235 if (!(dep->flags & DWC3_EP_ENABLED) && 2235 if (!(dep->flags & DWC3_EP_ENABLED)) {
2236 !(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 2236 if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
2237 return; 2237 return;
2238
2239 /* Handle only EPCMDCMPLT when EP disabled */
2240 if (event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT)
2241 return;
2242 }
2238 2243
2239 if (epnum == 0 || epnum == 1) { 2244 if (epnum == 0 || epnum == 1) {
2240 dwc3_ep0_interrupt(dwc, event); 2245 dwc3_ep0_interrupt(dwc, event);
@@ -2531,8 +2536,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
2531 dwc->gadget.ep0->maxpacket = 64; 2536 dwc->gadget.ep0->maxpacket = 64;
2532 dwc->gadget.speed = USB_SPEED_HIGH; 2537 dwc->gadget.speed = USB_SPEED_HIGH;
2533 break; 2538 break;
2534 case DWC3_DSTS_FULLSPEED2: 2539 case DWC3_DSTS_FULLSPEED:
2535 case DWC3_DSTS_FULLSPEED1:
2536 dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64); 2540 dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
2537 dwc->gadget.ep0->maxpacket = 64; 2541 dwc->gadget.ep0->maxpacket = 64;
2538 dwc->gadget.speed = USB_SPEED_FULL; 2542 dwc->gadget.speed = USB_SPEED_FULL;
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 41ab61f9b6e0..49d685ad0da9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1694,9 +1694,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1694 value = min(w_length, (u16) 1); 1694 value = min(w_length, (u16) 1);
1695 break; 1695 break;
1696 1696
1697 /* function drivers must handle get/set altsetting; if there's 1697 /* function drivers must handle get/set altsetting */
1698 * no get() method, we know only altsetting zero works.
1699 */
1700 case USB_REQ_SET_INTERFACE: 1698 case USB_REQ_SET_INTERFACE:
1701 if (ctrl->bRequestType != USB_RECIP_INTERFACE) 1699 if (ctrl->bRequestType != USB_RECIP_INTERFACE)
1702 goto unknown; 1700 goto unknown;
@@ -1705,7 +1703,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1705 f = cdev->config->interface[intf]; 1703 f = cdev->config->interface[intf];
1706 if (!f) 1704 if (!f)
1707 break; 1705 break;
1708 if (w_value && !f->set_alt) 1706
1707 /*
1708 * If there's no get_alt() method, we know only altsetting zero
1709 * works. There is no need to check if set_alt() is not NULL
1710 * as we check this in usb_add_function().
1711 */
1712 if (w_value && !f->get_alt)
1709 break; 1713 break;
1710 value = f->set_alt(f, w_index, w_value); 1714 value = f->set_alt(f, w_index, w_value);
1711 if (value == USB_GADGET_DELAYED_STATUS) { 1715 if (value == USB_GADGET_DELAYED_STATUS) {
@@ -2143,7 +2147,7 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
2143 cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL); 2147 cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
2144 if (!cdev->os_desc_req->buf) { 2148 if (!cdev->os_desc_req->buf) {
2145 ret = -ENOMEM; 2149 ret = -ENOMEM;
2146 kfree(cdev->os_desc_req); 2150 usb_ep_free_request(ep0, cdev->os_desc_req);
2147 goto end; 2151 goto end;
2148 } 2152 }
2149 cdev->os_desc_req->context = cdev; 2153 cdev->os_desc_req->context = cdev;
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index aab3fc1dbb94..5490fc51638e 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1806,7 +1806,7 @@ static void ffs_func_eps_disable(struct ffs_function *func)
1806 unsigned long flags; 1806 unsigned long flags;
1807 1807
1808 spin_lock_irqsave(&func->ffs->eps_lock, flags); 1808 spin_lock_irqsave(&func->ffs->eps_lock, flags);
1809 do { 1809 while (count--) {
1810 /* pending requests get nuked */ 1810 /* pending requests get nuked */
1811 if (likely(ep->ep)) 1811 if (likely(ep->ep))
1812 usb_ep_disable(ep->ep); 1812 usb_ep_disable(ep->ep);
@@ -1817,7 +1817,7 @@ static void ffs_func_eps_disable(struct ffs_function *func)
1817 __ffs_epfile_read_buffer_free(epfile); 1817 __ffs_epfile_read_buffer_free(epfile);
1818 ++epfile; 1818 ++epfile;
1819 } 1819 }
1820 } while (--count); 1820 }
1821 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); 1821 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
1822} 1822}
1823 1823
@@ -1831,7 +1831,7 @@ static int ffs_func_eps_enable(struct ffs_function *func)
1831 int ret = 0; 1831 int ret = 0;
1832 1832
1833 spin_lock_irqsave(&func->ffs->eps_lock, flags); 1833 spin_lock_irqsave(&func->ffs->eps_lock, flags);
1834 do { 1834 while(count--) {
1835 struct usb_endpoint_descriptor *ds; 1835 struct usb_endpoint_descriptor *ds;
1836 int desc_idx; 1836 int desc_idx;
1837 1837
@@ -1867,7 +1867,7 @@ static int ffs_func_eps_enable(struct ffs_function *func)
1867 1867
1868 ++ep; 1868 ++ep;
1869 ++epfile; 1869 ++epfile;
1870 } while (--count); 1870 }
1871 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); 1871 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
1872 1872
1873 return ret; 1873 return ret;
@@ -2091,8 +2091,8 @@ static int __ffs_data_do_entity(enum ffs_entity_type type,
2091 2091
2092 case FFS_STRING: 2092 case FFS_STRING:
2093 /* 2093 /*
2094 * Strings are indexed from 1 (0 is magic ;) reserved 2094 * Strings are indexed from 1 (0 is reserved
2095 * for languages list or some such) 2095 * for languages list)
2096 */ 2096 */
2097 if (*valuep > helper->ffs->strings_count) 2097 if (*valuep > helper->ffs->strings_count)
2098 helper->ffs->strings_count = *valuep; 2098 helper->ffs->strings_count = *valuep;
@@ -2252,7 +2252,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
2252 2252
2253 if (len < sizeof(*d) || 2253 if (len < sizeof(*d) ||
2254 d->bFirstInterfaceNumber >= ffs->interfaces_count || 2254 d->bFirstInterfaceNumber >= ffs->interfaces_count ||
2255 !d->Reserved1) 2255 d->Reserved1)
2256 return -EINVAL; 2256 return -EINVAL;
2257 for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i) 2257 for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
2258 if (d->Reserved2[i]) 2258 if (d->Reserved2[i])
@@ -3448,12 +3448,12 @@ static void ffs_func_unbind(struct usb_configuration *c,
3448 3448
3449 /* cleanup after autoconfig */ 3449 /* cleanup after autoconfig */
3450 spin_lock_irqsave(&func->ffs->eps_lock, flags); 3450 spin_lock_irqsave(&func->ffs->eps_lock, flags);
3451 do { 3451 while (count--) {
3452 if (ep->ep && ep->req) 3452 if (ep->ep && ep->req)
3453 usb_ep_free_request(ep->ep, ep->req); 3453 usb_ep_free_request(ep->ep, ep->req);
3454 ep->req = NULL; 3454 ep->req = NULL;
3455 ++ep; 3455 ++ep;
3456 } while (--count); 3456 }
3457 spin_unlock_irqrestore(&func->ffs->eps_lock, flags); 3457 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
3458 kfree(func->eps); 3458 kfree(func->eps);
3459 func->eps = NULL; 3459 func->eps = NULL;
@@ -3666,6 +3666,7 @@ static void ffs_closed(struct ffs_data *ffs)
3666{ 3666{
3667 struct ffs_dev *ffs_obj; 3667 struct ffs_dev *ffs_obj;
3668 struct f_fs_opts *opts; 3668 struct f_fs_opts *opts;
3669 struct config_item *ci;
3669 3670
3670 ENTER(); 3671 ENTER();
3671 ffs_dev_lock(); 3672 ffs_dev_lock();
@@ -3689,8 +3690,11 @@ static void ffs_closed(struct ffs_data *ffs)
3689 || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) 3690 || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount))
3690 goto done; 3691 goto done;
3691 3692
3692 unregister_gadget_item(ffs_obj->opts-> 3693 ci = opts->func_inst.group.cg_item.ci_parent->ci_parent;
3693 func_inst.group.cg_item.ci_parent->ci_parent); 3694 ffs_dev_unlock();
3695
3696 unregister_gadget_item(ci);
3697 return;
3694done: 3698done:
3695 ffs_dev_unlock(); 3699 ffs_dev_unlock();
3696} 3700}
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 3151d2a0fe59..5f8139b8e601 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -593,7 +593,7 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
593 } 593 }
594 status = usb_ep_enable(hidg->out_ep); 594 status = usb_ep_enable(hidg->out_ep);
595 if (status < 0) { 595 if (status < 0) {
596 ERROR(cdev, "Enable IN endpoint FAILED!\n"); 596 ERROR(cdev, "Enable OUT endpoint FAILED!\n");
597 goto fail; 597 goto fail;
598 } 598 }
599 hidg->out_ep->driver_data = hidg; 599 hidg->out_ep->driver_data = hidg;
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index e8f4102d19df..6bde4396927c 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1126,7 +1126,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1126 /* data and/or status stage for control request */ 1126 /* data and/or status stage for control request */
1127 } else if (dev->state == STATE_DEV_SETUP) { 1127 } else if (dev->state == STATE_DEV_SETUP) {
1128 1128
1129 /* IN DATA+STATUS caller makes len <= wLength */ 1129 len = min_t(size_t, len, dev->setup_wLength);
1130 if (dev->setup_in) { 1130 if (dev->setup_in) {
1131 retval = setup_req (dev->gadget->ep0, dev->req, len); 1131 retval = setup_req (dev->gadget->ep0, dev->req, len);
1132 if (retval == 0) { 1132 if (retval == 0) {
@@ -1734,10 +1734,12 @@ static struct usb_gadget_driver gadgetfs_driver = {
1734 * such as configuration notifications. 1734 * such as configuration notifications.
1735 */ 1735 */
1736 1736
1737static int is_valid_config (struct usb_config_descriptor *config) 1737static int is_valid_config(struct usb_config_descriptor *config,
1738 unsigned int total)
1738{ 1739{
1739 return config->bDescriptorType == USB_DT_CONFIG 1740 return config->bDescriptorType == USB_DT_CONFIG
1740 && config->bLength == USB_DT_CONFIG_SIZE 1741 && config->bLength == USB_DT_CONFIG_SIZE
1742 && total >= USB_DT_CONFIG_SIZE
1741 && config->bConfigurationValue != 0 1743 && config->bConfigurationValue != 0
1742 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0 1744 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0
1743 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0; 1745 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0;
@@ -1762,7 +1764,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1762 } 1764 }
1763 spin_unlock_irq(&dev->lock); 1765 spin_unlock_irq(&dev->lock);
1764 1766
1765 if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) 1767 if ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) ||
1768 (len > PAGE_SIZE * 4))
1766 return -EINVAL; 1769 return -EINVAL;
1767 1770
1768 /* we might need to change message format someday */ 1771 /* we might need to change message format someday */
@@ -1786,7 +1789,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1786 /* full or low speed config */ 1789 /* full or low speed config */
1787 dev->config = (void *) kbuf; 1790 dev->config = (void *) kbuf;
1788 total = le16_to_cpu(dev->config->wTotalLength); 1791 total = le16_to_cpu(dev->config->wTotalLength);
1789 if (!is_valid_config (dev->config) || total >= length) 1792 if (!is_valid_config(dev->config, total) ||
1793 total > length - USB_DT_DEVICE_SIZE)
1790 goto fail; 1794 goto fail;
1791 kbuf += total; 1795 kbuf += total;
1792 length -= total; 1796 length -= total;
@@ -1795,10 +1799,13 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1795 if (kbuf [1] == USB_DT_CONFIG) { 1799 if (kbuf [1] == USB_DT_CONFIG) {
1796 dev->hs_config = (void *) kbuf; 1800 dev->hs_config = (void *) kbuf;
1797 total = le16_to_cpu(dev->hs_config->wTotalLength); 1801 total = le16_to_cpu(dev->hs_config->wTotalLength);
1798 if (!is_valid_config (dev->hs_config) || total >= length) 1802 if (!is_valid_config(dev->hs_config, total) ||
1803 total > length - USB_DT_DEVICE_SIZE)
1799 goto fail; 1804 goto fail;
1800 kbuf += total; 1805 kbuf += total;
1801 length -= total; 1806 length -= total;
1807 } else {
1808 dev->hs_config = NULL;
1802 } 1809 }
1803 1810
1804 /* could support multiple configs, using another encoding! */ 1811 /* could support multiple configs, using another encoding! */
@@ -1811,7 +1818,6 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1811 || dev->dev->bDescriptorType != USB_DT_DEVICE 1818 || dev->dev->bDescriptorType != USB_DT_DEVICE
1812 || dev->dev->bNumConfigurations != 1) 1819 || dev->dev->bNumConfigurations != 1)
1813 goto fail; 1820 goto fail;
1814 dev->dev->bNumConfigurations = 1;
1815 dev->dev->bcdUSB = cpu_to_le16 (0x0200); 1821 dev->dev->bcdUSB = cpu_to_le16 (0x0200);
1816 1822
1817 /* triggers gadgetfs_bind(); then we can enumerate. */ 1823 /* triggers gadgetfs_bind(); then we can enumerate. */
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index f3212db9bc37..12c7687216e6 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1978,7 +1978,8 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
1978 dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); 1978 dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret);
1979 goto err; 1979 goto err;
1980 } 1980 }
1981 ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index); 1981 sprintf(ep->name, "ep%d", ep->index);
1982 ep->ep.name = ep->name;
1982 1983
1983 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); 1984 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
1984 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); 1985 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 3e1c9d589dfa..b03b2ebfc53a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -280,6 +280,7 @@ struct usba_ep {
280 void __iomem *ep_regs; 280 void __iomem *ep_regs;
281 void __iomem *dma_regs; 281 void __iomem *dma_regs;
282 void __iomem *fifo; 282 void __iomem *fifo;
283 char name[8];
283 struct usb_ep ep; 284 struct usb_ep ep;
284 struct usba_udc *udc; 285 struct usba_udc *udc;
285 286
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 9483489080f6..0402177f93cd 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1317,7 +1317,11 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
1317 if (!ret) 1317 if (!ret)
1318 break; 1318 break;
1319 } 1319 }
1320 if (!ret && !udc->driver) 1320 if (ret)
1321 ret = -ENODEV;
1322 else if (udc->driver)
1323 ret = -EBUSY;
1324 else
1321 goto found; 1325 goto found;
1322 } else { 1326 } else {
1323 list_for_each_entry(udc, &udc_list, list) { 1327 list_for_each_entry(udc, &udc_list, list) {
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 02b14e91ae6c..c60abe3a68f9 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, struct dummy_ep *ep)
330/* caller must hold lock */ 330/* caller must hold lock */
331static void stop_activity(struct dummy *dum) 331static void stop_activity(struct dummy *dum)
332{ 332{
333 struct dummy_ep *ep; 333 int i;
334 334
335 /* prevent any more requests */ 335 /* prevent any more requests */
336 dum->address = 0; 336 dum->address = 0;
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy *dum)
338 /* The timer is left running so that outstanding URBs can fail */ 338 /* The timer is left running so that outstanding URBs can fail */
339 339
340 /* nuke any pending requests first, so driver i/o is quiesced */ 340 /* nuke any pending requests first, so driver i/o is quiesced */
341 list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) 341 for (i = 0; i < DUMMY_ENDPOINTS; ++i)
342 nuke(dum, ep); 342 nuke(dum, &dum->ep[i]);
343 343
344 /* driver now does any non-usb quiescing necessary */ 344 /* driver now does any non-usb quiescing necessary */
345} 345}
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index be9e63836881..414e3c376dbb 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -43,7 +43,6 @@ struct at91_usbh_data {
43 struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; 43 struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS];
44 u8 ports; /* number of ports on root hub */ 44 u8 ports; /* number of ports on root hub */
45 u8 overcurrent_supported; 45 u8 overcurrent_supported;
46 u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
47 u8 overcurrent_status[AT91_MAX_USBH_PORTS]; 46 u8 overcurrent_status[AT91_MAX_USBH_PORTS];
48 u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; 47 u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
49}; 48};
@@ -266,8 +265,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
266 if (!valid_port(port)) 265 if (!valid_port(port))
267 return; 266 return;
268 267
269 gpiod_set_value(pdata->vbus_pin[port], 268 gpiod_set_value(pdata->vbus_pin[port], enable);
270 pdata->vbus_pin_active_low[port] ^ enable);
271} 269}
272 270
273static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 271static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
@@ -275,8 +273,7 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
275 if (!valid_port(port)) 273 if (!valid_port(port))
276 return -EINVAL; 274 return -EINVAL;
277 275
278 return gpiod_get_value(pdata->vbus_pin[port]) ^ 276 return gpiod_get_value(pdata->vbus_pin[port]);
279 pdata->vbus_pin_active_low[port];
280} 277}
281 278
282/* 279/*
@@ -533,18 +530,17 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
533 pdata->ports = ports; 530 pdata->ports = ports;
534 531
535 at91_for_each_port(i) { 532 at91_for_each_port(i) {
536 pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev, 533 if (i >= pdata->ports)
537 "atmel,vbus-gpio", 534 break;
538 GPIOD_IN); 535
536 pdata->vbus_pin[i] =
537 devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus",
538 i, GPIOD_OUT_HIGH);
539 if (IS_ERR(pdata->vbus_pin[i])) { 539 if (IS_ERR(pdata->vbus_pin[i])) {
540 err = PTR_ERR(pdata->vbus_pin[i]); 540 err = PTR_ERR(pdata->vbus_pin[i]);
541 dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); 541 dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err);
542 continue; 542 continue;
543 } 543 }
544
545 pdata->vbus_pin_active_low[i] = gpiod_get_value(pdata->vbus_pin[i]);
546
547 ohci_at91_usb_set_power(pdata, i, 1);
548 } 544 }
549 545
550 at91_for_each_port(i) { 546 at91_for_each_port(i) {
@@ -552,8 +548,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
552 break; 548 break;
553 549
554 pdata->overcurrent_pin[i] = 550 pdata->overcurrent_pin[i] =
555 devm_gpiod_get_optional(&pdev->dev, 551 devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
556 "atmel,oc-gpio", GPIOD_IN); 552 i, GPIOD_IN);
557 if (IS_ERR(pdata->overcurrent_pin[i])) { 553 if (IS_ERR(pdata->overcurrent_pin[i])) {
558 err = PTR_ERR(pdata->overcurrent_pin[i]); 554 err = PTR_ERR(pdata->overcurrent_pin[i]);
559 dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); 555 dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 321de2e0161b..8414ed2a02de 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -979,6 +979,40 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
979 xhci->devs[slot_id] = NULL; 979 xhci->devs[slot_id] = NULL;
980} 980}
981 981
982/*
983 * Free a virt_device structure.
984 * If the virt_device added a tt_info (a hub) and has children pointing to
985 * that tt_info, then free the child first. Recursive.
986 * We can't rely on udev at this point to find child-parent relationships.
987 */
988void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
989{
990 struct xhci_virt_device *vdev;
991 struct list_head *tt_list_head;
992 struct xhci_tt_bw_info *tt_info, *next;
993 int i;
994
995 vdev = xhci->devs[slot_id];
996 if (!vdev)
997 return;
998
999 tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
1000 list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
1001 /* is this a hub device that added a tt_info to the tts list */
1002 if (tt_info->slot_id == slot_id) {
1003 /* are any devices using this tt_info? */
1004 for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
1005 vdev = xhci->devs[i];
1006 if (vdev && (vdev->tt_info == tt_info))
1007 xhci_free_virt_devices_depth_first(
1008 xhci, i);
1009 }
1010 }
1011 }
1012 /* we are now at a leaf device */
1013 xhci_free_virt_device(xhci, slot_id);
1014}
1015
982int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, 1016int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
983 struct usb_device *udev, gfp_t flags) 1017 struct usb_device *udev, gfp_t flags)
984{ 1018{
@@ -1795,7 +1829,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1795 int size; 1829 int size;
1796 int i, j, num_ports; 1830 int i, j, num_ports;
1797 1831
1798 del_timer_sync(&xhci->cmd_timer); 1832 cancel_delayed_work_sync(&xhci->cmd_timer);
1799 1833
1800 /* Free the Event Ring Segment Table and the actual Event Ring */ 1834 /* Free the Event Ring Segment Table and the actual Event Ring */
1801 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1835 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -1828,8 +1862,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1828 } 1862 }
1829 } 1863 }
1830 1864
1831 for (i = 1; i < MAX_HC_SLOTS; ++i) 1865 for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--)
1832 xhci_free_virt_device(xhci, i); 1866 xhci_free_virt_devices_depth_first(xhci, i);
1833 1867
1834 dma_pool_destroy(xhci->segment_pool); 1868 dma_pool_destroy(xhci->segment_pool);
1835 xhci->segment_pool = NULL; 1869 xhci->segment_pool = NULL;
@@ -2342,9 +2376,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2342 2376
2343 INIT_LIST_HEAD(&xhci->cmd_list); 2377 INIT_LIST_HEAD(&xhci->cmd_list);
2344 2378
2345 /* init command timeout timer */ 2379 /* init command timeout work */
2346 setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout, 2380 INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
2347 (unsigned long)xhci); 2381 init_completion(&xhci->cmd_ring_stop_completion);
2348 2382
2349 page_size = readl(&xhci->op_regs->page_size); 2383 page_size = readl(&xhci->op_regs->page_size);
2350 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2384 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 1094ebd2838f..bac961cd24ad 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -579,8 +579,10 @@ static int xhci_mtk_probe(struct platform_device *pdev)
579 goto disable_ldos; 579 goto disable_ldos;
580 580
581 irq = platform_get_irq(pdev, 0); 581 irq = platform_get_irq(pdev, 0);
582 if (irq < 0) 582 if (irq < 0) {
583 ret = irq;
583 goto disable_clk; 584 goto disable_clk;
585 }
584 586
585 /* Initialize dma_mask and coherent_dma_mask to 32-bits */ 587 /* Initialize dma_mask and coherent_dma_mask to 32-bits */
586 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); 588 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index e96ae80d107e..954abfd5014d 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -165,7 +165,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
165 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || 165 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || 167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { 168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
169 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) {
169 xhci->quirks |= XHCI_PME_STUCK_QUIRK; 170 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
170 } 171 }
171 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 172 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ddfab301e366..e5834dd9bcde 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -165,7 +165,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
165 return -ENODEV; 165 return -ENODEV;
166 166
167 /* Try to set 64-bit DMA first */ 167 /* Try to set 64-bit DMA first */
168 if (WARN_ON(!pdev->dev.dma_mask)) 168 if (!pdev->dev.dma_mask)
169 /* Platform did not initialize dma_mask */ 169 /* Platform did not initialize dma_mask */
170 ret = dma_coerce_mask_and_coherent(&pdev->dev, 170 ret = dma_coerce_mask_and_coherent(&pdev->dev,
171 DMA_BIT_MASK(64)); 171 DMA_BIT_MASK(64));
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index bdf6b13d9b67..e32029a31ca4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -279,23 +279,76 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
279 readl(&xhci->dba->doorbell[0]); 279 readl(&xhci->dba->doorbell[0]);
280} 280}
281 281
282static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) 282static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay)
283{
284 return mod_delayed_work(system_wq, &xhci->cmd_timer, delay);
285}
286
287static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci)
288{
289 return list_first_entry_or_null(&xhci->cmd_list, struct xhci_command,
290 cmd_list);
291}
292
293/*
294 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
295 * If there are other commands waiting then restart the ring and kick the timer.
296 * This must be called with command ring stopped and xhci->lock held.
297 */
298static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
299 struct xhci_command *cur_cmd)
300{
301 struct xhci_command *i_cmd;
302 u32 cycle_state;
303
304 /* Turn all aborted commands in list to no-ops, then restart */
305 list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) {
306
307 if (i_cmd->status != COMP_CMD_ABORT)
308 continue;
309
310 i_cmd->status = COMP_CMD_STOP;
311
312 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
313 i_cmd->command_trb);
314 /* get cycle state from the original cmd trb */
315 cycle_state = le32_to_cpu(
316 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
317 /* modify the command trb to no-op command */
318 i_cmd->command_trb->generic.field[0] = 0;
319 i_cmd->command_trb->generic.field[1] = 0;
320 i_cmd->command_trb->generic.field[2] = 0;
321 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
322 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
323
324 /*
325 * caller waiting for completion is called when command
326 * completion event is received for these no-op commands
327 */
328 }
329
330 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
331
332 /* ring command ring doorbell to restart the command ring */
333 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
334 !(xhci->xhc_state & XHCI_STATE_DYING)) {
335 xhci->current_cmd = cur_cmd;
336 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
337 xhci_ring_cmd_db(xhci);
338 }
339}
340
341/* Must be called with xhci->lock held, releases and aquires lock back */
342static int xhci_abort_cmd_ring(struct xhci_hcd *xhci, unsigned long flags)
283{ 343{
284 u64 temp_64; 344 u64 temp_64;
285 int ret; 345 int ret;
286 346
287 xhci_dbg(xhci, "Abort command ring\n"); 347 xhci_dbg(xhci, "Abort command ring\n");
288 348
289 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 349 reinit_completion(&xhci->cmd_ring_stop_completion);
290 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
291 350
292 /* 351 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
293 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
294 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
295 * but the completion event in never sent. Use the cmd timeout timer to
296 * handle those cases. Use twice the time to cover the bit polling retry
297 */
298 mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT));
299 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, 352 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
300 &xhci->op_regs->cmd_ring); 353 &xhci->op_regs->cmd_ring);
301 354
@@ -315,17 +368,30 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
315 udelay(1000); 368 udelay(1000);
316 ret = xhci_handshake(&xhci->op_regs->cmd_ring, 369 ret = xhci_handshake(&xhci->op_regs->cmd_ring,
317 CMD_RING_RUNNING, 0, 3 * 1000 * 1000); 370 CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
318 if (ret == 0) 371 if (ret < 0) {
319 return 0; 372 xhci_err(xhci, "Stopped the command ring failed, "
320 373 "maybe the host is dead\n");
321 xhci_err(xhci, "Stopped the command ring failed, " 374 xhci->xhc_state |= XHCI_STATE_DYING;
322 "maybe the host is dead\n"); 375 xhci_halt(xhci);
323 del_timer(&xhci->cmd_timer); 376 return -ESHUTDOWN;
324 xhci->xhc_state |= XHCI_STATE_DYING; 377 }
325 xhci_halt(xhci); 378 }
326 return -ESHUTDOWN; 379 /*
380 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
381 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
382 * but the completion event in never sent. Wait 2 secs (arbitrary
383 * number) to handle those cases after negation of CMD_RING_RUNNING.
384 */
385 spin_unlock_irqrestore(&xhci->lock, flags);
386 ret = wait_for_completion_timeout(&xhci->cmd_ring_stop_completion,
387 msecs_to_jiffies(2000));
388 spin_lock_irqsave(&xhci->lock, flags);
389 if (!ret) {
390 xhci_dbg(xhci, "No stop event for abort, ring start fail?\n");
391 xhci_cleanup_command_queue(xhci);
392 } else {
393 xhci_handle_stopped_cmd_ring(xhci, xhci_next_queued_cmd(xhci));
327 } 394 }
328
329 return 0; 395 return 0;
330} 396}
331 397
@@ -847,17 +913,6 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
847 spin_lock_irqsave(&xhci->lock, flags); 913 spin_lock_irqsave(&xhci->lock, flags);
848 914
849 ep->stop_cmds_pending--; 915 ep->stop_cmds_pending--;
850 if (xhci->xhc_state & XHCI_STATE_REMOVING) {
851 spin_unlock_irqrestore(&xhci->lock, flags);
852 return;
853 }
854 if (xhci->xhc_state & XHCI_STATE_DYING) {
855 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
856 "Stop EP timer ran, but another timer marked "
857 "xHCI as DYING, exiting.");
858 spin_unlock_irqrestore(&xhci->lock, flags);
859 return;
860 }
861 if (!(ep->stop_cmds_pending == 0 && (ep->ep_state & EP_HALT_PENDING))) { 916 if (!(ep->stop_cmds_pending == 0 && (ep->ep_state & EP_HALT_PENDING))) {
862 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 917 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
863 "Stop EP timer ran, but no command pending, " 918 "Stop EP timer ran, but no command pending, "
@@ -1207,101 +1262,62 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
1207 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT); 1262 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT);
1208} 1263}
1209 1264
1210/* 1265void xhci_handle_command_timeout(struct work_struct *work)
1211 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
1212 * If there are other commands waiting then restart the ring and kick the timer.
1213 * This must be called with command ring stopped and xhci->lock held.
1214 */
1215static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
1216 struct xhci_command *cur_cmd)
1217{
1218 struct xhci_command *i_cmd, *tmp_cmd;
1219 u32 cycle_state;
1220
1221 /* Turn all aborted commands in list to no-ops, then restart */
1222 list_for_each_entry_safe(i_cmd, tmp_cmd, &xhci->cmd_list,
1223 cmd_list) {
1224
1225 if (i_cmd->status != COMP_CMD_ABORT)
1226 continue;
1227
1228 i_cmd->status = COMP_CMD_STOP;
1229
1230 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
1231 i_cmd->command_trb);
1232 /* get cycle state from the original cmd trb */
1233 cycle_state = le32_to_cpu(
1234 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
1235 /* modify the command trb to no-op command */
1236 i_cmd->command_trb->generic.field[0] = 0;
1237 i_cmd->command_trb->generic.field[1] = 0;
1238 i_cmd->command_trb->generic.field[2] = 0;
1239 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
1240 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
1241
1242 /*
1243 * caller waiting for completion is called when command
1244 * completion event is received for these no-op commands
1245 */
1246 }
1247
1248 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
1249
1250 /* ring command ring doorbell to restart the command ring */
1251 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
1252 !(xhci->xhc_state & XHCI_STATE_DYING)) {
1253 xhci->current_cmd = cur_cmd;
1254 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
1255 xhci_ring_cmd_db(xhci);
1256 }
1257 return;
1258}
1259
1260
1261void xhci_handle_command_timeout(unsigned long data)
1262{ 1266{
1263 struct xhci_hcd *xhci; 1267 struct xhci_hcd *xhci;
1264 int ret; 1268 int ret;
1265 unsigned long flags; 1269 unsigned long flags;
1266 u64 hw_ring_state; 1270 u64 hw_ring_state;
1267 bool second_timeout = false;
1268 xhci = (struct xhci_hcd *) data;
1269 1271
1270 /* mark this command to be cancelled */ 1272 xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
1273
1271 spin_lock_irqsave(&xhci->lock, flags); 1274 spin_lock_irqsave(&xhci->lock, flags);
1272 if (xhci->current_cmd) { 1275
1273 if (xhci->current_cmd->status == COMP_CMD_ABORT) 1276 /*
1274 second_timeout = true; 1277 * If timeout work is pending, or current_cmd is NULL, it means we
1275 xhci->current_cmd->status = COMP_CMD_ABORT; 1278 * raced with command completion. Command is handled so just return.
1279 */
1280 if (!xhci->current_cmd || delayed_work_pending(&xhci->cmd_timer)) {
1281 spin_unlock_irqrestore(&xhci->lock, flags);
1282 return;
1276 } 1283 }
1284 /* mark this command to be cancelled */
1285 xhci->current_cmd->status = COMP_CMD_ABORT;
1277 1286
1278 /* Make sure command ring is running before aborting it */ 1287 /* Make sure command ring is running before aborting it */
1279 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 1288 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
1280 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && 1289 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
1281 (hw_ring_state & CMD_RING_RUNNING)) { 1290 (hw_ring_state & CMD_RING_RUNNING)) {
1282 spin_unlock_irqrestore(&xhci->lock, flags); 1291 /* Prevent new doorbell, and start command abort */
1292 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
1283 xhci_dbg(xhci, "Command timeout\n"); 1293 xhci_dbg(xhci, "Command timeout\n");
1284 ret = xhci_abort_cmd_ring(xhci); 1294 ret = xhci_abort_cmd_ring(xhci, flags);
1285 if (unlikely(ret == -ESHUTDOWN)) { 1295 if (unlikely(ret == -ESHUTDOWN)) {
1286 xhci_err(xhci, "Abort command ring failed\n"); 1296 xhci_err(xhci, "Abort command ring failed\n");
1287 xhci_cleanup_command_queue(xhci); 1297 xhci_cleanup_command_queue(xhci);
1298 spin_unlock_irqrestore(&xhci->lock, flags);
1288 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); 1299 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
1289 xhci_dbg(xhci, "xHCI host controller is dead.\n"); 1300 xhci_dbg(xhci, "xHCI host controller is dead.\n");
1301
1302 return;
1290 } 1303 }
1291 return; 1304
1305 goto time_out_completed;
1292 } 1306 }
1293 1307
1294 /* command ring failed to restart, or host removed. Bail out */ 1308 /* host removed. Bail out */
1295 if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) { 1309 if (xhci->xhc_state & XHCI_STATE_REMOVING) {
1296 spin_unlock_irqrestore(&xhci->lock, flags); 1310 xhci_dbg(xhci, "host removed, ring start fail?\n");
1297 xhci_dbg(xhci, "command timed out twice, ring start fail?\n");
1298 xhci_cleanup_command_queue(xhci); 1311 xhci_cleanup_command_queue(xhci);
1299 return; 1312
1313 goto time_out_completed;
1300 } 1314 }
1301 1315
1302 /* command timeout on stopped ring, ring can't be aborted */ 1316 /* command timeout on stopped ring, ring can't be aborted */
1303 xhci_dbg(xhci, "Command timeout on stopped ring\n"); 1317 xhci_dbg(xhci, "Command timeout on stopped ring\n");
1304 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); 1318 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd);
1319
1320time_out_completed:
1305 spin_unlock_irqrestore(&xhci->lock, flags); 1321 spin_unlock_irqrestore(&xhci->lock, flags);
1306 return; 1322 return;
1307} 1323}
@@ -1333,7 +1349,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1333 1349
1334 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); 1350 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
1335 1351
1336 del_timer(&xhci->cmd_timer); 1352 cancel_delayed_work(&xhci->cmd_timer);
1337 1353
1338 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); 1354 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
1339 1355
@@ -1341,7 +1357,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1341 1357
1342 /* If CMD ring stopped we own the trbs between enqueue and dequeue */ 1358 /* If CMD ring stopped we own the trbs between enqueue and dequeue */
1343 if (cmd_comp_code == COMP_CMD_STOP) { 1359 if (cmd_comp_code == COMP_CMD_STOP) {
1344 xhci_handle_stopped_cmd_ring(xhci, cmd); 1360 complete_all(&xhci->cmd_ring_stop_completion);
1345 return; 1361 return;
1346 } 1362 }
1347 1363
@@ -1359,8 +1375,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1359 */ 1375 */
1360 if (cmd_comp_code == COMP_CMD_ABORT) { 1376 if (cmd_comp_code == COMP_CMD_ABORT) {
1361 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 1377 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
1362 if (cmd->status == COMP_CMD_ABORT) 1378 if (cmd->status == COMP_CMD_ABORT) {
1379 if (xhci->current_cmd == cmd)
1380 xhci->current_cmd = NULL;
1363 goto event_handled; 1381 goto event_handled;
1382 }
1364 } 1383 }
1365 1384
1366 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); 1385 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3]));
@@ -1421,7 +1440,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1421 if (cmd->cmd_list.next != &xhci->cmd_list) { 1440 if (cmd->cmd_list.next != &xhci->cmd_list) {
1422 xhci->current_cmd = list_entry(cmd->cmd_list.next, 1441 xhci->current_cmd = list_entry(cmd->cmd_list.next,
1423 struct xhci_command, cmd_list); 1442 struct xhci_command, cmd_list);
1424 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 1443 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
1444 } else if (xhci->current_cmd == cmd) {
1445 xhci->current_cmd = NULL;
1425 } 1446 }
1426 1447
1427event_handled: 1448event_handled:
@@ -1939,8 +1960,9 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1939 struct xhci_ep_ctx *ep_ctx; 1960 struct xhci_ep_ctx *ep_ctx;
1940 u32 trb_comp_code; 1961 u32 trb_comp_code;
1941 u32 remaining, requested; 1962 u32 remaining, requested;
1942 bool on_data_stage; 1963 u32 trb_type;
1943 1964
1965 trb_type = TRB_FIELD_TO_TYPE(le32_to_cpu(ep_trb->generic.field[3]));
1944 slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); 1966 slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
1945 xdev = xhci->devs[slot_id]; 1967 xdev = xhci->devs[slot_id];
1946 ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; 1968 ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1;
@@ -1950,14 +1972,11 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1950 requested = td->urb->transfer_buffer_length; 1972 requested = td->urb->transfer_buffer_length;
1951 remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); 1973 remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
1952 1974
1953 /* not setup (dequeue), or status stage means we are at data stage */
1954 on_data_stage = (ep_trb != ep_ring->dequeue && ep_trb != td->last_trb);
1955
1956 switch (trb_comp_code) { 1975 switch (trb_comp_code) {
1957 case COMP_SUCCESS: 1976 case COMP_SUCCESS:
1958 if (ep_trb != td->last_trb) { 1977 if (trb_type != TRB_STATUS) {
1959 xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n", 1978 xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n",
1960 on_data_stage ? "data" : "setup"); 1979 (trb_type == TRB_DATA) ? "data" : "setup");
1961 *status = -ESHUTDOWN; 1980 *status = -ESHUTDOWN;
1962 break; 1981 break;
1963 } 1982 }
@@ -1967,15 +1986,25 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1967 *status = 0; 1986 *status = 0;
1968 break; 1987 break;
1969 case COMP_STOP_SHORT: 1988 case COMP_STOP_SHORT:
1970 if (on_data_stage) 1989 if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
1971 td->urb->actual_length = remaining; 1990 td->urb->actual_length = remaining;
1972 else 1991 else
1973 xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n"); 1992 xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
1974 goto finish_td; 1993 goto finish_td;
1975 case COMP_STOP: 1994 case COMP_STOP:
1976 if (on_data_stage) 1995 switch (trb_type) {
1996 case TRB_SETUP:
1997 td->urb->actual_length = 0;
1998 goto finish_td;
1999 case TRB_DATA:
2000 case TRB_NORMAL:
1977 td->urb->actual_length = requested - remaining; 2001 td->urb->actual_length = requested - remaining;
1978 goto finish_td; 2002 goto finish_td;
2003 default:
2004 xhci_warn(xhci, "WARN: unexpected TRB Type %d\n",
2005 trb_type);
2006 goto finish_td;
2007 }
1979 case COMP_STOP_INVAL: 2008 case COMP_STOP_INVAL:
1980 goto finish_td; 2009 goto finish_td;
1981 default: 2010 default:
@@ -1987,7 +2016,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1987 /* else fall through */ 2016 /* else fall through */
1988 case COMP_STALL: 2017 case COMP_STALL:
1989 /* Did we transfer part of the data (middle) phase? */ 2018 /* Did we transfer part of the data (middle) phase? */
1990 if (on_data_stage) 2019 if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
1991 td->urb->actual_length = requested - remaining; 2020 td->urb->actual_length = requested - remaining;
1992 else if (!td->urb_length_set) 2021 else if (!td->urb_length_set)
1993 td->urb->actual_length = 0; 2022 td->urb->actual_length = 0;
@@ -1995,14 +2024,15 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1995 } 2024 }
1996 2025
1997 /* stopped at setup stage, no data transferred */ 2026 /* stopped at setup stage, no data transferred */
1998 if (ep_trb == ep_ring->dequeue) 2027 if (trb_type == TRB_SETUP)
1999 goto finish_td; 2028 goto finish_td;
2000 2029
2001 /* 2030 /*
2002 * if on data stage then update the actual_length of the URB and flag it 2031 * if on data stage then update the actual_length of the URB and flag it
2003 * as set, so it won't be overwritten in the event for the last TRB. 2032 * as set, so it won't be overwritten in the event for the last TRB.
2004 */ 2033 */
2005 if (on_data_stage) { 2034 if (trb_type == TRB_DATA ||
2035 trb_type == TRB_NORMAL) {
2006 td->urb_length_set = true; 2036 td->urb_length_set = true;
2007 td->urb->actual_length = requested - remaining; 2037 td->urb->actual_length = requested - remaining;
2008 xhci_dbg(xhci, "Waiting for status stage event\n"); 2038 xhci_dbg(xhci, "Waiting for status stage event\n");
@@ -3790,9 +3820,9 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
3790 3820
3791 /* if there are no other commands queued we start the timeout timer */ 3821 /* if there are no other commands queued we start the timeout timer */
3792 if (xhci->cmd_list.next == &cmd->cmd_list && 3822 if (xhci->cmd_list.next == &cmd->cmd_list &&
3793 !timer_pending(&xhci->cmd_timer)) { 3823 !delayed_work_pending(&xhci->cmd_timer)) {
3794 xhci->current_cmd = cmd; 3824 xhci->current_cmd = cmd;
3795 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 3825 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
3796 } 3826 }
3797 3827
3798 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 3828 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1cd56417cbec..9a0ec116654a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1534,19 +1534,6 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1534 xhci_urb_free_priv(urb_priv); 1534 xhci_urb_free_priv(urb_priv);
1535 return ret; 1535 return ret;
1536 } 1536 }
1537 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
1538 (xhci->xhc_state & XHCI_STATE_HALTED)) {
1539 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
1540 "Ep 0x%x: URB %p to be canceled on "
1541 "non-responsive xHCI host.",
1542 urb->ep->desc.bEndpointAddress, urb);
1543 /* Let the stop endpoint command watchdog timer (which set this
1544 * state) finish cleaning up the endpoint TD lists. We must
1545 * have caught it in the middle of dropping a lock and giving
1546 * back an URB.
1547 */
1548 goto done;
1549 }
1550 1537
1551 ep_index = xhci_get_endpoint_index(&urb->ep->desc); 1538 ep_index = xhci_get_endpoint_index(&urb->ep->desc);
1552 ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; 1539 ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index];
@@ -3787,8 +3774,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3787 3774
3788 mutex_lock(&xhci->mutex); 3775 mutex_lock(&xhci->mutex);
3789 3776
3790 if (xhci->xhc_state) /* dying, removing or halted */ 3777 if (xhci->xhc_state) { /* dying, removing or halted */
3778 ret = -ESHUTDOWN;
3791 goto out; 3779 goto out;
3780 }
3792 3781
3793 if (!udev->slot_id) { 3782 if (!udev->slot_id) {
3794 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3783 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 8ccc11a974b8..2d7b6374b58d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1568,7 +1568,8 @@ struct xhci_hcd {
1568#define CMD_RING_STATE_STOPPED (1 << 2) 1568#define CMD_RING_STATE_STOPPED (1 << 2)
1569 struct list_head cmd_list; 1569 struct list_head cmd_list;
1570 unsigned int cmd_ring_reserved_trbs; 1570 unsigned int cmd_ring_reserved_trbs;
1571 struct timer_list cmd_timer; 1571 struct delayed_work cmd_timer;
1572 struct completion cmd_ring_stop_completion;
1572 struct xhci_command *current_cmd; 1573 struct xhci_command *current_cmd;
1573 struct xhci_ring *event_ring; 1574 struct xhci_ring *event_ring;
1574 struct xhci_erst erst; 1575 struct xhci_erst erst;
@@ -1934,7 +1935,7 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci,
1934 unsigned int slot_id, unsigned int ep_index, 1935 unsigned int slot_id, unsigned int ep_index,
1935 struct xhci_dequeue_state *deq_state); 1936 struct xhci_dequeue_state *deq_state);
1936void xhci_stop_endpoint_command_watchdog(unsigned long arg); 1937void xhci_stop_endpoint_command_watchdog(unsigned long arg);
1937void xhci_handle_command_timeout(unsigned long data); 1938void xhci_handle_command_timeout(struct work_struct *work);
1938 1939
1939void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 1940void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
1940 unsigned int ep_index, unsigned int stream_id); 1941 unsigned int ep_index, unsigned int stream_id);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 310238c6b5cd..896798071817 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -469,6 +469,7 @@ static const struct musb_platform_ops bfin_ops = {
469 .init = bfin_musb_init, 469 .init = bfin_musb_init,
470 .exit = bfin_musb_exit, 470 .exit = bfin_musb_exit,
471 471
472 .fifo_offset = bfin_fifo_offset,
472 .readb = bfin_readb, 473 .readb = bfin_readb,
473 .writeb = bfin_writeb, 474 .writeb = bfin_writeb,
474 .readw = bfin_readw, 475 .readw = bfin_readw,
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9e226468a13e..fca288bbc800 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2050,6 +2050,7 @@ struct musb_pending_work {
2050 struct list_head node; 2050 struct list_head node;
2051}; 2051};
2052 2052
2053#ifdef CONFIG_PM
2053/* 2054/*
2054 * Called from musb_runtime_resume(), musb_resume(), and 2055 * Called from musb_runtime_resume(), musb_resume(), and
2055 * musb_queue_resume_work(). Callers must take musb->lock. 2056 * musb_queue_resume_work(). Callers must take musb->lock.
@@ -2077,6 +2078,7 @@ static int musb_run_resume_work(struct musb *musb)
2077 2078
2078 return error; 2079 return error;
2079} 2080}
2081#endif
2080 2082
2081/* 2083/*
2082 * Called to run work if device is active or else queue the work to happen 2084 * Called to run work if device is active or else queue the work to happen
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a611e2f67bdc..ade902ea1221 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -216,6 +216,7 @@ struct musb_platform_ops {
216 void (*pre_root_reset_end)(struct musb *musb); 216 void (*pre_root_reset_end)(struct musb *musb);
217 void (*post_root_reset_end)(struct musb *musb); 217 void (*post_root_reset_end)(struct musb *musb);
218 int (*phy_callback)(enum musb_vbus_id_status status); 218 int (*phy_callback)(enum musb_vbus_id_status status);
219 void (*clear_ep_rxintr)(struct musb *musb, int epnum);
219}; 220};
220 221
221/* 222/*
@@ -626,6 +627,12 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb)
626 musb->ops->post_root_reset_end(musb); 627 musb->ops->post_root_reset_end(musb);
627} 628}
628 629
630static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum)
631{
632 if (musb->ops->clear_ep_rxintr)
633 musb->ops->clear_ep_rxintr(musb, epnum);
634}
635
629/* 636/*
630 * gets the "dr_mode" property from DT and converts it into musb_mode 637 * gets the "dr_mode" property from DT and converts it into musb_mode
631 * if the property is not found or not recognized returns MUSB_OTG 638 * if the property is not found or not recognized returns MUSB_OTG
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 4fef50e5c8c1..dd70c88419d2 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -114,6 +114,7 @@ static int musb_regdump_show(struct seq_file *s, void *unused)
114 unsigned i; 114 unsigned i;
115 115
116 seq_printf(s, "MUSB (M)HDRC Register Dump\n"); 116 seq_printf(s, "MUSB (M)HDRC Register Dump\n");
117 pm_runtime_get_sync(musb->controller);
117 118
118 for (i = 0; i < ARRAY_SIZE(musb_regmap); i++) { 119 for (i = 0; i < ARRAY_SIZE(musb_regmap); i++) {
119 switch (musb_regmap[i].size) { 120 switch (musb_regmap[i].size) {
@@ -132,6 +133,8 @@ static int musb_regdump_show(struct seq_file *s, void *unused)
132 } 133 }
133 } 134 }
134 135
136 pm_runtime_mark_last_busy(musb->controller);
137 pm_runtime_put_autosuspend(musb->controller);
135 return 0; 138 return 0;
136} 139}
137 140
@@ -145,7 +148,10 @@ static int musb_test_mode_show(struct seq_file *s, void *unused)
145 struct musb *musb = s->private; 148 struct musb *musb = s->private;
146 unsigned test; 149 unsigned test;
147 150
151 pm_runtime_get_sync(musb->controller);
148 test = musb_readb(musb->mregs, MUSB_TESTMODE); 152 test = musb_readb(musb->mregs, MUSB_TESTMODE);
153 pm_runtime_mark_last_busy(musb->controller);
154 pm_runtime_put_autosuspend(musb->controller);
149 155
150 if (test & MUSB_TEST_FORCE_HOST) 156 if (test & MUSB_TEST_FORCE_HOST)
151 seq_printf(s, "force host\n"); 157 seq_printf(s, "force host\n");
@@ -194,11 +200,12 @@ static ssize_t musb_test_mode_write(struct file *file,
194 u8 test; 200 u8 test;
195 char buf[18]; 201 char buf[18];
196 202
203 pm_runtime_get_sync(musb->controller);
197 test = musb_readb(musb->mregs, MUSB_TESTMODE); 204 test = musb_readb(musb->mregs, MUSB_TESTMODE);
198 if (test) { 205 if (test) {
199 dev_err(musb->controller, "Error: test mode is already set. " 206 dev_err(musb->controller, "Error: test mode is already set. "
200 "Please do USB Bus Reset to start a new test.\n"); 207 "Please do USB Bus Reset to start a new test.\n");
201 return count; 208 goto ret;
202 } 209 }
203 210
204 memset(buf, 0x00, sizeof(buf)); 211 memset(buf, 0x00, sizeof(buf));
@@ -234,6 +241,9 @@ static ssize_t musb_test_mode_write(struct file *file,
234 241
235 musb_writeb(musb->mregs, MUSB_TESTMODE, test); 242 musb_writeb(musb->mregs, MUSB_TESTMODE, test);
236 243
244ret:
245 pm_runtime_mark_last_busy(musb->controller);
246 pm_runtime_put_autosuspend(musb->controller);
237 return count; 247 return count;
238} 248}
239 249
@@ -254,8 +264,13 @@ static int musb_softconnect_show(struct seq_file *s, void *unused)
254 switch (musb->xceiv->otg->state) { 264 switch (musb->xceiv->otg->state) {
255 case OTG_STATE_A_HOST: 265 case OTG_STATE_A_HOST:
256 case OTG_STATE_A_WAIT_BCON: 266 case OTG_STATE_A_WAIT_BCON:
267 pm_runtime_get_sync(musb->controller);
268
257 reg = musb_readb(musb->mregs, MUSB_DEVCTL); 269 reg = musb_readb(musb->mregs, MUSB_DEVCTL);
258 connect = reg & MUSB_DEVCTL_SESSION ? 1 : 0; 270 connect = reg & MUSB_DEVCTL_SESSION ? 1 : 0;
271
272 pm_runtime_mark_last_busy(musb->controller);
273 pm_runtime_put_autosuspend(musb->controller);
259 break; 274 break;
260 default: 275 default:
261 connect = -1; 276 connect = -1;
@@ -284,6 +299,7 @@ static ssize_t musb_softconnect_write(struct file *file,
284 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 299 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
285 return -EFAULT; 300 return -EFAULT;
286 301
302 pm_runtime_get_sync(musb->controller);
287 if (!strncmp(buf, "0", 1)) { 303 if (!strncmp(buf, "0", 1)) {
288 switch (musb->xceiv->otg->state) { 304 switch (musb->xceiv->otg->state) {
289 case OTG_STATE_A_HOST: 305 case OTG_STATE_A_HOST:
@@ -314,6 +330,8 @@ static ssize_t musb_softconnect_write(struct file *file,
314 } 330 }
315 } 331 }
316 332
333 pm_runtime_mark_last_busy(musb->controller);
334 pm_runtime_put_autosuspend(musb->controller);
317 return count; 335 return count;
318} 336}
319 337
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index feae1561b9ab..9f125e179acd 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -267,6 +267,17 @@ static void otg_timer(unsigned long _musb)
267 pm_runtime_put_autosuspend(dev); 267 pm_runtime_put_autosuspend(dev);
268} 268}
269 269
270void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum)
271{
272 u32 epintr;
273 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
274 const struct dsps_musb_wrapper *wrp = glue->wrp;
275
276 /* musb->lock might already been held */
277 epintr = (1 << epnum) << wrp->rxep_shift;
278 musb_writel(musb->ctrl_base, wrp->epintr_status, epintr);
279}
280
270static irqreturn_t dsps_interrupt(int irq, void *hci) 281static irqreturn_t dsps_interrupt(int irq, void *hci)
271{ 282{
272 struct musb *musb = hci; 283 struct musb *musb = hci;
@@ -622,6 +633,7 @@ static struct musb_platform_ops dsps_ops = {
622 633
623 .set_mode = dsps_musb_set_mode, 634 .set_mode = dsps_musb_set_mode,
624 .recover = dsps_musb_recover, 635 .recover = dsps_musb_recover,
636 .clear_ep_rxintr = dsps_musb_clear_ep_rxintr,
625}; 637};
626 638
627static u64 musb_dmamask = DMA_BIT_MASK(32); 639static u64 musb_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index f6cdbad00dac..ac3a4952abb4 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2374,12 +2374,11 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2374 int is_in = usb_pipein(urb->pipe); 2374 int is_in = usb_pipein(urb->pipe);
2375 int status = 0; 2375 int status = 0;
2376 u16 csr; 2376 u16 csr;
2377 struct dma_channel *dma = NULL;
2377 2378
2378 musb_ep_select(regs, hw_end); 2379 musb_ep_select(regs, hw_end);
2379 2380
2380 if (is_dma_capable()) { 2381 if (is_dma_capable()) {
2381 struct dma_channel *dma;
2382
2383 dma = is_in ? ep->rx_channel : ep->tx_channel; 2382 dma = is_in ? ep->rx_channel : ep->tx_channel;
2384 if (dma) { 2383 if (dma) {
2385 status = ep->musb->dma_controller->channel_abort(dma); 2384 status = ep->musb->dma_controller->channel_abort(dma);
@@ -2395,10 +2394,9 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2395 /* giveback saves bulk toggle */ 2394 /* giveback saves bulk toggle */
2396 csr = musb_h_flush_rxfifo(ep, 0); 2395 csr = musb_h_flush_rxfifo(ep, 0);
2397 2396
2398 /* REVISIT we still get an irq; should likely clear the 2397 /* clear the endpoint's irq status here to avoid bogus irqs */
2399 * endpoint's irq status here to avoid bogus irqs. 2398 if (is_dma_capable() && dma)
2400 * clearing that status is platform-specific... 2399 musb_platform_clear_ep_rxintr(musb, ep->epnum);
2401 */
2402 } else if (ep->epnum) { 2400 } else if (ep->epnum) {
2403 musb_h_tx_flush_fifo(ep); 2401 musb_h_tx_flush_fifo(ep);
2404 csr = musb_readw(epio, MUSB_TXCSR); 2402 csr = musb_readw(epio, MUSB_TXCSR);
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
index f7b13fd25257..a3dcbd55e436 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -157,5 +157,5 @@ struct musb_dma_controller {
157 void __iomem *base; 157 void __iomem *base;
158 u8 channel_count; 158 u8 channel_count;
159 u8 used_channels; 159 u8 used_channels;
160 u8 irq; 160 int irq;
161}; 161};
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 2597b83a8ae2..95aa5233726c 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -95,6 +95,7 @@ struct ch341_private {
95 unsigned baud_rate; /* set baud rate */ 95 unsigned baud_rate; /* set baud rate */
96 u8 line_control; /* set line control value RTS/DTR */ 96 u8 line_control; /* set line control value RTS/DTR */
97 u8 line_status; /* active status of modem control inputs */ 97 u8 line_status; /* active status of modem control inputs */
98 u8 lcr;
98}; 99};
99 100
100static void ch341_set_termios(struct tty_struct *tty, 101static void ch341_set_termios(struct tty_struct *tty,
@@ -112,6 +113,8 @@ static int ch341_control_out(struct usb_device *dev, u8 request,
112 r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, 113 r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
113 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 114 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
114 value, index, NULL, 0, DEFAULT_TIMEOUT); 115 value, index, NULL, 0, DEFAULT_TIMEOUT);
116 if (r < 0)
117 dev_err(&dev->dev, "failed to send control message: %d\n", r);
115 118
116 return r; 119 return r;
117} 120}
@@ -129,11 +132,24 @@ static int ch341_control_in(struct usb_device *dev,
129 r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, 132 r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
130 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 133 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
131 value, index, buf, bufsize, DEFAULT_TIMEOUT); 134 value, index, buf, bufsize, DEFAULT_TIMEOUT);
132 return r; 135 if (r < bufsize) {
136 if (r >= 0) {
137 dev_err(&dev->dev,
138 "short control message received (%d < %u)\n",
139 r, bufsize);
140 r = -EIO;
141 }
142
143 dev_err(&dev->dev, "failed to receive control message: %d\n",
144 r);
145 return r;
146 }
147
148 return 0;
133} 149}
134 150
135static int ch341_init_set_baudrate(struct usb_device *dev, 151static int ch341_set_baudrate_lcr(struct usb_device *dev,
136 struct ch341_private *priv, unsigned ctrl) 152 struct ch341_private *priv, u8 lcr)
137{ 153{
138 short a; 154 short a;
139 int r; 155 int r;
@@ -156,9 +172,19 @@ static int ch341_init_set_baudrate(struct usb_device *dev,
156 factor = 0x10000 - factor; 172 factor = 0x10000 - factor;
157 a = (factor & 0xff00) | divisor; 173 a = (factor & 0xff00) | divisor;
158 174
159 /* 0x9c is "enable SFR_UART Control register and timer" */ 175 /*
160 r = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 176 * CH341A buffers data until a full endpoint-size packet (32 bytes)
161 0x9c | (ctrl << 8), a | 0x80); 177 * has been received unless bit 7 is set.
178 */
179 a |= BIT(7);
180
181 r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, a);
182 if (r)
183 return r;
184
185 r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr);
186 if (r)
187 return r;
162 188
163 return r; 189 return r;
164} 190}
@@ -170,9 +196,9 @@ static int ch341_set_handshake(struct usb_device *dev, u8 control)
170 196
171static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv) 197static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)
172{ 198{
199 const unsigned int size = 2;
173 char *buffer; 200 char *buffer;
174 int r; 201 int r;
175 const unsigned size = 8;
176 unsigned long flags; 202 unsigned long flags;
177 203
178 buffer = kmalloc(size, GFP_KERNEL); 204 buffer = kmalloc(size, GFP_KERNEL);
@@ -183,14 +209,9 @@ static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)
183 if (r < 0) 209 if (r < 0)
184 goto out; 210 goto out;
185 211
186 /* setup the private status if available */ 212 spin_lock_irqsave(&priv->lock, flags);
187 if (r == 2) { 213 priv->line_status = (~(*buffer)) & CH341_BITS_MODEM_STAT;
188 r = 0; 214 spin_unlock_irqrestore(&priv->lock, flags);
189 spin_lock_irqsave(&priv->lock, flags);
190 priv->line_status = (~(*buffer)) & CH341_BITS_MODEM_STAT;
191 spin_unlock_irqrestore(&priv->lock, flags);
192 } else
193 r = -EPROTO;
194 215
195out: kfree(buffer); 216out: kfree(buffer);
196 return r; 217 return r;
@@ -200,9 +221,9 @@ out: kfree(buffer);
200 221
201static int ch341_configure(struct usb_device *dev, struct ch341_private *priv) 222static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
202{ 223{
224 const unsigned int size = 2;
203 char *buffer; 225 char *buffer;
204 int r; 226 int r;
205 const unsigned size = 8;
206 227
207 buffer = kmalloc(size, GFP_KERNEL); 228 buffer = kmalloc(size, GFP_KERNEL);
208 if (!buffer) 229 if (!buffer)
@@ -232,7 +253,7 @@ static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
232 if (r < 0) 253 if (r < 0)
233 goto out; 254 goto out;
234 255
235 r = ch341_init_set_baudrate(dev, priv, 0); 256 r = ch341_set_baudrate_lcr(dev, priv, priv->lcr);
236 if (r < 0) 257 if (r < 0)
237 goto out; 258 goto out;
238 259
@@ -258,7 +279,6 @@ static int ch341_port_probe(struct usb_serial_port *port)
258 279
259 spin_lock_init(&priv->lock); 280 spin_lock_init(&priv->lock);
260 priv->baud_rate = DEFAULT_BAUD_RATE; 281 priv->baud_rate = DEFAULT_BAUD_RATE;
261 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
262 282
263 r = ch341_configure(port->serial->dev, priv); 283 r = ch341_configure(port->serial->dev, priv);
264 if (r < 0) 284 if (r < 0)
@@ -320,7 +340,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
320 340
321 r = ch341_configure(serial->dev, priv); 341 r = ch341_configure(serial->dev, priv);
322 if (r) 342 if (r)
323 goto out; 343 return r;
324 344
325 if (tty) 345 if (tty)
326 ch341_set_termios(tty, port, NULL); 346 ch341_set_termios(tty, port, NULL);
@@ -330,12 +350,19 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
330 if (r) { 350 if (r) {
331 dev_err(&port->dev, "%s - failed to submit interrupt urb: %d\n", 351 dev_err(&port->dev, "%s - failed to submit interrupt urb: %d\n",
332 __func__, r); 352 __func__, r);
333 goto out; 353 return r;
334 } 354 }
335 355
336 r = usb_serial_generic_open(tty, port); 356 r = usb_serial_generic_open(tty, port);
357 if (r)
358 goto err_kill_interrupt_urb;
359
360 return 0;
361
362err_kill_interrupt_urb:
363 usb_kill_urb(port->interrupt_in_urb);
337 364
338out: return r; 365 return r;
339} 366}
340 367
341/* Old_termios contains the original termios settings and 368/* Old_termios contains the original termios settings and
@@ -356,7 +383,6 @@ static void ch341_set_termios(struct tty_struct *tty,
356 383
357 baud_rate = tty_get_baud_rate(tty); 384 baud_rate = tty_get_baud_rate(tty);
358 385
359 priv->baud_rate = baud_rate;
360 ctrl = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX; 386 ctrl = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX;
361 387
362 switch (C_CSIZE(tty)) { 388 switch (C_CSIZE(tty)) {
@@ -386,22 +412,25 @@ static void ch341_set_termios(struct tty_struct *tty,
386 ctrl |= CH341_LCR_STOP_BITS_2; 412 ctrl |= CH341_LCR_STOP_BITS_2;
387 413
388 if (baud_rate) { 414 if (baud_rate) {
389 spin_lock_irqsave(&priv->lock, flags); 415 priv->baud_rate = baud_rate;
390 priv->line_control |= (CH341_BIT_DTR | CH341_BIT_RTS); 416
391 spin_unlock_irqrestore(&priv->lock, flags); 417 r = ch341_set_baudrate_lcr(port->serial->dev, priv, ctrl);
392 r = ch341_init_set_baudrate(port->serial->dev, priv, ctrl);
393 if (r < 0 && old_termios) { 418 if (r < 0 && old_termios) {
394 priv->baud_rate = tty_termios_baud_rate(old_termios); 419 priv->baud_rate = tty_termios_baud_rate(old_termios);
395 tty_termios_copy_hw(&tty->termios, old_termios); 420 tty_termios_copy_hw(&tty->termios, old_termios);
421 } else if (r == 0) {
422 priv->lcr = ctrl;
396 } 423 }
397 } else {
398 spin_lock_irqsave(&priv->lock, flags);
399 priv->line_control &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
400 spin_unlock_irqrestore(&priv->lock, flags);
401 } 424 }
402 425
403 ch341_set_handshake(port->serial->dev, priv->line_control); 426 spin_lock_irqsave(&priv->lock, flags);
427 if (C_BAUD(tty) == B0)
428 priv->line_control &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
429 else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
430 priv->line_control |= (CH341_BIT_DTR | CH341_BIT_RTS);
431 spin_unlock_irqrestore(&priv->lock, flags);
404 432
433 ch341_set_handshake(port->serial->dev, priv->line_control);
405} 434}
406 435
407static void ch341_break_ctl(struct tty_struct *tty, int break_state) 436static void ch341_break_ctl(struct tty_struct *tty, int break_state)
@@ -576,14 +605,23 @@ static int ch341_tiocmget(struct tty_struct *tty)
576 605
577static int ch341_reset_resume(struct usb_serial *serial) 606static int ch341_reset_resume(struct usb_serial *serial)
578{ 607{
579 struct ch341_private *priv; 608 struct usb_serial_port *port = serial->port[0];
580 609 struct ch341_private *priv = usb_get_serial_port_data(port);
581 priv = usb_get_serial_port_data(serial->port[0]); 610 int ret;
582 611
583 /* reconfigure ch341 serial port after bus-reset */ 612 /* reconfigure ch341 serial port after bus-reset */
584 ch341_configure(serial->dev, priv); 613 ch341_configure(serial->dev, priv);
585 614
586 return 0; 615 if (tty_port_initialized(&port->port)) {
616 ret = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
617 if (ret) {
618 dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
619 ret);
620 return ret;
621 }
622 }
623
624 return usb_serial_generic_resume(serial);
587} 625}
588 626
589static struct usb_serial_driver ch341_device = { 627static struct usb_serial_driver ch341_device = {
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 5f17a3b9916d..80260b08398b 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -50,6 +50,7 @@
50#define CYBERJACK_PRODUCT_ID 0x0100 50#define CYBERJACK_PRODUCT_ID 0x0100
51 51
52/* Function prototypes */ 52/* Function prototypes */
53static int cyberjack_attach(struct usb_serial *serial);
53static int cyberjack_port_probe(struct usb_serial_port *port); 54static int cyberjack_port_probe(struct usb_serial_port *port);
54static int cyberjack_port_remove(struct usb_serial_port *port); 55static int cyberjack_port_remove(struct usb_serial_port *port);
55static int cyberjack_open(struct tty_struct *tty, 56static int cyberjack_open(struct tty_struct *tty,
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjack_device = {
77 .description = "Reiner SCT Cyberjack USB card reader", 78 .description = "Reiner SCT Cyberjack USB card reader",
78 .id_table = id_table, 79 .id_table = id_table,
79 .num_ports = 1, 80 .num_ports = 1,
81 .attach = cyberjack_attach,
80 .port_probe = cyberjack_port_probe, 82 .port_probe = cyberjack_port_probe,
81 .port_remove = cyberjack_port_remove, 83 .port_remove = cyberjack_port_remove,
82 .open = cyberjack_open, 84 .open = cyberjack_open,
@@ -100,6 +102,14 @@ struct cyberjack_private {
100 short wrsent; /* Data already sent */ 102 short wrsent; /* Data already sent */
101}; 103};
102 104
105static int cyberjack_attach(struct usb_serial *serial)
106{
107 if (serial->num_bulk_out < serial->num_ports)
108 return -ENODEV;
109
110 return 0;
111}
112
103static int cyberjack_port_probe(struct usb_serial_port *port) 113static int cyberjack_port_probe(struct usb_serial_port *port)
104{ 114{
105 struct cyberjack_private *priv; 115 struct cyberjack_private *priv;
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 8282a6a18fee..22f23a429a95 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1237,6 +1237,7 @@ static int f81534_attach(struct usb_serial *serial)
1237static int f81534_port_probe(struct usb_serial_port *port) 1237static int f81534_port_probe(struct usb_serial_port *port)
1238{ 1238{
1239 struct f81534_port_private *port_priv; 1239 struct f81534_port_private *port_priv;
1240 int ret;
1240 1241
1241 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); 1242 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL);
1242 if (!port_priv) 1243 if (!port_priv)
@@ -1246,10 +1247,11 @@ static int f81534_port_probe(struct usb_serial_port *port)
1246 mutex_init(&port_priv->mcr_mutex); 1247 mutex_init(&port_priv->mcr_mutex);
1247 1248
1248 /* Assign logic-to-phy mapping */ 1249 /* Assign logic-to-phy mapping */
1249 port_priv->phy_num = f81534_logic_to_phy_port(port->serial, port); 1250 ret = f81534_logic_to_phy_port(port->serial, port);
1250 if (port_priv->phy_num < 0 || port_priv->phy_num >= F81534_NUM_PORT) 1251 if (ret < 0)
1251 return -ENODEV; 1252 return ret;
1252 1253
1254 port_priv->phy_num = ret;
1253 usb_set_serial_port_data(port, port_priv); 1255 usb_set_serial_port_data(port, port_priv);
1254 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, 1256 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__,
1255 port->port_number, port_priv->phy_num); 1257 port->port_number, port_priv->phy_num);
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 97cabf803c2f..b2f2e87aed94 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1043,6 +1043,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1043 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 1043 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
1044 __func__, status); 1044 __func__, status);
1045 count = status; 1045 count = status;
1046 kfree(buffer);
1046 } 1047 }
1047 1048
1048 /* we are done with this urb, so let the host driver 1049 /* we are done with this urb, so let the host driver
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index dcc0c58aaad5..d50e5773483f 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2751,6 +2751,11 @@ static int edge_startup(struct usb_serial *serial)
2751 EDGE_COMPATIBILITY_MASK1, 2751 EDGE_COMPATIBILITY_MASK1,
2752 EDGE_COMPATIBILITY_MASK2 }; 2752 EDGE_COMPATIBILITY_MASK2 };
2753 2753
2754 if (serial->num_bulk_in < 1 || serial->num_interrupt_in < 1) {
2755 dev_err(&serial->interface->dev, "missing endpoints\n");
2756 return -ENODEV;
2757 }
2758
2754 dev = serial->dev; 2759 dev = serial->dev;
2755 2760
2756 /* create our private serial structure */ 2761 /* create our private serial structure */
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index c339163698eb..9a0db2965fbb 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_serial *serial,
1499 1499
1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); 1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
1501 1501
1502 /* return an error on purpose */ 1502 return 1;
1503 return -ENODEV;
1504 } 1503 }
1505 1504
1506stayinbootmode: 1505stayinbootmode:
@@ -1508,7 +1507,7 @@ stayinbootmode:
1508 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); 1507 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
1509 serial->product_info.TiMode = TI_MODE_BOOT; 1508 serial->product_info.TiMode = TI_MODE_BOOT;
1510 1509
1511 return 0; 1510 return 1;
1512} 1511}
1513 1512
1514static int ti_do_config(struct edgeport_port *port, int feature, int on) 1513static int ti_do_config(struct edgeport_port *port, int feature, int on)
@@ -2546,6 +2545,13 @@ static int edge_startup(struct usb_serial *serial)
2546 int status; 2545 int status;
2547 u16 product_id; 2546 u16 product_id;
2548 2547
2548 /* Make sure we have the required endpoints when in download mode. */
2549 if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) {
2550 if (serial->num_bulk_in < serial->num_ports ||
2551 serial->num_bulk_out < serial->num_ports)
2552 return -ENODEV;
2553 }
2554
2549 /* create our private serial structure */ 2555 /* create our private serial structure */
2550 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2556 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2551 if (!edge_serial) 2557 if (!edge_serial)
@@ -2553,14 +2559,18 @@ static int edge_startup(struct usb_serial *serial)
2553 2559
2554 mutex_init(&edge_serial->es_lock); 2560 mutex_init(&edge_serial->es_lock);
2555 edge_serial->serial = serial; 2561 edge_serial->serial = serial;
2562 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2556 usb_set_serial_data(serial, edge_serial); 2563 usb_set_serial_data(serial, edge_serial);
2557 2564
2558 status = download_fw(edge_serial); 2565 status = download_fw(edge_serial);
2559 if (status) { 2566 if (status < 0) {
2560 kfree(edge_serial); 2567 kfree(edge_serial);
2561 return status; 2568 return status;
2562 } 2569 }
2563 2570
2571 if (status > 0)
2572 return 1; /* bind but do not register any ports */
2573
2564 product_id = le16_to_cpu( 2574 product_id = le16_to_cpu(
2565 edge_serial->serial->dev->descriptor.idProduct); 2575 edge_serial->serial->dev->descriptor.idProduct);
2566 2576
@@ -2572,7 +2582,6 @@ static int edge_startup(struct usb_serial *serial)
2572 } 2582 }
2573 } 2583 }
2574 2584
2575 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2576 edge_heartbeat_schedule(edge_serial); 2585 edge_heartbeat_schedule(edge_serial);
2577 2586
2578 return 0; 2587 return 0;
@@ -2580,6 +2589,9 @@ static int edge_startup(struct usb_serial *serial)
2580 2589
2581static void edge_disconnect(struct usb_serial *serial) 2590static void edge_disconnect(struct usb_serial *serial)
2582{ 2591{
2592 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2593
2594 cancel_delayed_work_sync(&edge_serial->heartbeat_work);
2583} 2595}
2584 2596
2585static void edge_release(struct usb_serial *serial) 2597static void edge_release(struct usb_serial *serial)
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 344b4eea4bd5..d57fb5199218 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -68,6 +68,16 @@ struct iuu_private {
68 u32 clk; 68 u32 clk;
69}; 69};
70 70
71static int iuu_attach(struct usb_serial *serial)
72{
73 unsigned char num_ports = serial->num_ports;
74
75 if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
76 return -ENODEV;
77
78 return 0;
79}
80
71static int iuu_port_probe(struct usb_serial_port *port) 81static int iuu_port_probe(struct usb_serial_port *port)
72{ 82{
73 struct iuu_private *priv; 83 struct iuu_private *priv;
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_device = {
1196 .tiocmset = iuu_tiocmset, 1206 .tiocmset = iuu_tiocmset,
1197 .set_termios = iuu_set_termios, 1207 .set_termios = iuu_set_termios,
1198 .init_termios = iuu_init_termios, 1208 .init_termios = iuu_init_termios,
1209 .attach = iuu_attach,
1199 .port_probe = iuu_port_probe, 1210 .port_probe = iuu_port_probe,
1200 .port_remove = iuu_port_remove, 1211 .port_remove = iuu_port_remove,
1201}; 1212};
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index e49ad0c63ad8..83523fcf6fb9 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
700#endif 700#endif
701 701
702static int keyspan_pda_attach(struct usb_serial *serial)
703{
704 unsigned char num_ports = serial->num_ports;
705
706 if (serial->num_bulk_out < num_ports ||
707 serial->num_interrupt_in < num_ports) {
708 dev_err(&serial->interface->dev, "missing endpoints\n");
709 return -ENODEV;
710 }
711
712 return 0;
713}
714
702static int keyspan_pda_port_probe(struct usb_serial_port *port) 715static int keyspan_pda_port_probe(struct usb_serial_port *port)
703{ 716{
704 717
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_pda_device = {
776 .break_ctl = keyspan_pda_break_ctl, 789 .break_ctl = keyspan_pda_break_ctl,
777 .tiocmget = keyspan_pda_tiocmget, 790 .tiocmget = keyspan_pda_tiocmget,
778 .tiocmset = keyspan_pda_tiocmset, 791 .tiocmset = keyspan_pda_tiocmset,
792 .attach = keyspan_pda_attach,
779 .port_probe = keyspan_pda_port_probe, 793 .port_probe = keyspan_pda_port_probe,
780 .port_remove = keyspan_pda_port_remove, 794 .port_remove = keyspan_pda_port_remove,
781}; 795};
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 0ee190fc1bf8..6cb45757818f 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -192,10 +192,11 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
192 status_buf, KLSI_STATUSBUF_LEN, 192 status_buf, KLSI_STATUSBUF_LEN,
193 10000 193 10000
194 ); 194 );
195 if (rc < 0) 195 if (rc != KLSI_STATUSBUF_LEN) {
196 dev_err(&port->dev, "Reading line status failed (error = %d)\n", 196 dev_err(&port->dev, "reading line status failed: %d\n", rc);
197 rc); 197 if (rc >= 0)
198 else { 198 rc = -EIO;
199 } else {
199 status = get_unaligned_le16(status_buf); 200 status = get_unaligned_le16(status_buf);
200 201
201 dev_info(&port->serial->dev->dev, "read status %x %x\n", 202 dev_info(&port->serial->dev->dev, "read status %x %x\n",
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 2363654cafc9..813035f51fe7 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -51,6 +51,7 @@
51 51
52 52
53/* Function prototypes */ 53/* Function prototypes */
54static int kobil_attach(struct usb_serial *serial);
54static int kobil_port_probe(struct usb_serial_port *probe); 55static int kobil_port_probe(struct usb_serial_port *probe);
55static int kobil_port_remove(struct usb_serial_port *probe); 56static int kobil_port_remove(struct usb_serial_port *probe);
56static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); 57static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_device = {
86 .description = "KOBIL USB smart card terminal", 87 .description = "KOBIL USB smart card terminal",
87 .id_table = id_table, 88 .id_table = id_table,
88 .num_ports = 1, 89 .num_ports = 1,
90 .attach = kobil_attach,
89 .port_probe = kobil_port_probe, 91 .port_probe = kobil_port_probe,
90 .port_remove = kobil_port_remove, 92 .port_remove = kobil_port_remove,
91 .ioctl = kobil_ioctl, 93 .ioctl = kobil_ioctl,
@@ -113,6 +115,16 @@ struct kobil_private {
113}; 115};
114 116
115 117
118static int kobil_attach(struct usb_serial *serial)
119{
120 if (serial->num_interrupt_out < serial->num_ports) {
121 dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n");
122 return -ENODEV;
123 }
124
125 return 0;
126}
127
116static int kobil_port_probe(struct usb_serial_port *port) 128static int kobil_port_probe(struct usb_serial_port *port)
117{ 129{
118 struct usb_serial *serial = port->serial; 130 struct usb_serial *serial = port->serial;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index d52caa03679c..91bc170b408a 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -65,8 +65,6 @@ struct moschip_port {
65 struct urb *write_urb_pool[NUM_URBS]; 65 struct urb *write_urb_pool[NUM_URBS];
66}; 66};
67 67
68static struct usb_serial_driver moschip7720_2port_driver;
69
70#define USB_VENDOR_ID_MOSCHIP 0x9710 68#define USB_VENDOR_ID_MOSCHIP 0x9710
71#define MOSCHIP_DEVICE_ID_7720 0x7720 69#define MOSCHIP_DEVICE_ID_7720 0x7720
72#define MOSCHIP_DEVICE_ID_7715 0x7715 70#define MOSCHIP_DEVICE_ID_7715 0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
970 tty_port_tty_wakeup(&mos7720_port->port->port); 968 tty_port_tty_wakeup(&mos7720_port->port->port);
971} 969}
972 970
973/*
974 * mos77xx_probe
975 * this function installs the appropriate read interrupt endpoint callback
976 * depending on whether the device is a 7720 or 7715, thus avoiding costly
977 * run-time checks in the high-frequency callback routine itself.
978 */
979static int mos77xx_probe(struct usb_serial *serial,
980 const struct usb_device_id *id)
981{
982 if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
983 moschip7720_2port_driver.read_int_callback =
984 mos7715_interrupt_callback;
985 else
986 moschip7720_2port_driver.read_int_callback =
987 mos7720_interrupt_callback;
988
989 return 0;
990}
991
992static int mos77xx_calc_num_ports(struct usb_serial *serial) 971static int mos77xx_calc_num_ports(struct usb_serial *serial)
993{ 972{
994 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 973 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
@@ -1917,6 +1896,11 @@ static int mos7720_startup(struct usb_serial *serial)
1917 u16 product; 1896 u16 product;
1918 int ret_val; 1897 int ret_val;
1919 1898
1899 if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) {
1900 dev_err(&serial->interface->dev, "missing bulk endpoints\n");
1901 return -ENODEV;
1902 }
1903
1920 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1904 product = le16_to_cpu(serial->dev->descriptor.idProduct);
1921 dev = serial->dev; 1905 dev = serial->dev;
1922 1906
@@ -1941,19 +1925,18 @@ static int mos7720_startup(struct usb_serial *serial)
1941 tmp->interrupt_in_endpointAddress; 1925 tmp->interrupt_in_endpointAddress;
1942 serial->port[1]->interrupt_in_urb = NULL; 1926 serial->port[1]->interrupt_in_urb = NULL;
1943 serial->port[1]->interrupt_in_buffer = NULL; 1927 serial->port[1]->interrupt_in_buffer = NULL;
1928
1929 if (serial->port[0]->interrupt_in_urb) {
1930 struct urb *urb = serial->port[0]->interrupt_in_urb;
1931
1932 urb->complete = mos7715_interrupt_callback;
1933 }
1944 } 1934 }
1945 1935
1946 /* setting configuration feature to one */ 1936 /* setting configuration feature to one */
1947 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1937 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1948 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); 1938 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
1949 1939
1950 /* start the interrupt urb */
1951 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1952 if (ret_val)
1953 dev_err(&dev->dev,
1954 "%s - Error %d submitting control urb\n",
1955 __func__, ret_val);
1956
1957#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1940#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1958 if (product == MOSCHIP_DEVICE_ID_7715) { 1941 if (product == MOSCHIP_DEVICE_ID_7715) {
1959 ret_val = mos7715_parport_init(serial); 1942 ret_val = mos7715_parport_init(serial);
@@ -1961,6 +1944,13 @@ static int mos7720_startup(struct usb_serial *serial)
1961 return ret_val; 1944 return ret_val;
1962 } 1945 }
1963#endif 1946#endif
1947 /* start the interrupt urb */
1948 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1949 if (ret_val) {
1950 dev_err(&dev->dev, "failed to submit interrupt urb: %d\n",
1951 ret_val);
1952 }
1953
1964 /* LSR For Port 1 */ 1954 /* LSR For Port 1 */
1965 read_mos_reg(serial, 0, MOS7720_LSR, &data); 1955 read_mos_reg(serial, 0, MOS7720_LSR, &data);
1966 dev_dbg(&dev->dev, "LSR:%x\n", data); 1956 dev_dbg(&dev->dev, "LSR:%x\n", data);
@@ -1970,6 +1960,8 @@ static int mos7720_startup(struct usb_serial *serial)
1970 1960
1971static void mos7720_release(struct usb_serial *serial) 1961static void mos7720_release(struct usb_serial *serial)
1972{ 1962{
1963 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1964
1973#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1965#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1974 /* close the parallel port */ 1966 /* close the parallel port */
1975 1967
@@ -2019,11 +2011,6 @@ static int mos7720_port_probe(struct usb_serial_port *port)
2019 if (!mos7720_port) 2011 if (!mos7720_port)
2020 return -ENOMEM; 2012 return -ENOMEM;
2021 2013
2022 /* Initialize all port interrupt end point to port 0 int endpoint.
2023 * Our device has only one interrupt endpoint common to all ports.
2024 */
2025 port->interrupt_in_endpointAddress =
2026 port->serial->port[0]->interrupt_in_endpointAddress;
2027 mos7720_port->port = port; 2014 mos7720_port->port = port;
2028 2015
2029 usb_set_serial_port_data(port, mos7720_port); 2016 usb_set_serial_port_data(port, mos7720_port);
@@ -2053,7 +2040,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2053 .close = mos7720_close, 2040 .close = mos7720_close,
2054 .throttle = mos7720_throttle, 2041 .throttle = mos7720_throttle,
2055 .unthrottle = mos7720_unthrottle, 2042 .unthrottle = mos7720_unthrottle,
2056 .probe = mos77xx_probe,
2057 .attach = mos7720_startup, 2043 .attach = mos7720_startup,
2058 .release = mos7720_release, 2044 .release = mos7720_release,
2059 .port_probe = mos7720_port_probe, 2045 .port_probe = mos7720_port_probe,
@@ -2067,7 +2053,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2067 .chars_in_buffer = mos7720_chars_in_buffer, 2053 .chars_in_buffer = mos7720_chars_in_buffer,
2068 .break_ctl = mos7720_break, 2054 .break_ctl = mos7720_break,
2069 .read_bulk_callback = mos7720_bulk_in_callback, 2055 .read_bulk_callback = mos7720_bulk_in_callback,
2070 .read_int_callback = NULL /* dynamically assigned in probe() */ 2056 .read_int_callback = mos7720_interrupt_callback,
2071}; 2057};
2072 2058
2073static struct usb_serial_driver * const serial_drivers[] = { 2059static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 9a220b8e810f..ea27fb23967a 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -214,7 +214,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
214 214
215struct moschip_port { 215struct moschip_port {
216 int port_num; /*Actual port number in the device(1,2,etc) */ 216 int port_num; /*Actual port number in the device(1,2,etc) */
217 struct urb *write_urb; /* write URB for this port */
218 struct urb *read_urb; /* read URB for this port */ 217 struct urb *read_urb; /* read URB for this port */
219 __u8 shadowLCR; /* last LCR value received */ 218 __u8 shadowLCR; /* last LCR value received */
220 __u8 shadowMCR; /* last MCR value received */ 219 __u8 shadowMCR; /* last MCR value received */
@@ -1037,9 +1036,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1037 serial, 1036 serial,
1038 serial->port[0]->interrupt_in_urb->interval); 1037 serial->port[0]->interrupt_in_urb->interval);
1039 1038
1040 /* start interrupt read for mos7840 * 1039 /* start interrupt read for mos7840 */
1041 * will continue as long as mos7840 is connected */
1042
1043 response = 1040 response =
1044 usb_submit_urb(serial->port[0]->interrupt_in_urb, 1041 usb_submit_urb(serial->port[0]->interrupt_in_urb,
1045 GFP_KERNEL); 1042 GFP_KERNEL);
@@ -1186,7 +1183,6 @@ static void mos7840_close(struct usb_serial_port *port)
1186 } 1183 }
1187 } 1184 }
1188 1185
1189 usb_kill_urb(mos7840_port->write_urb);
1190 usb_kill_urb(mos7840_port->read_urb); 1186 usb_kill_urb(mos7840_port->read_urb);
1191 mos7840_port->read_urb_busy = false; 1187 mos7840_port->read_urb_busy = false;
1192 1188
@@ -1199,12 +1195,6 @@ static void mos7840_close(struct usb_serial_port *port)
1199 } 1195 }
1200 } 1196 }
1201 1197
1202 if (mos7840_port->write_urb) {
1203 /* if this urb had a transfer buffer already (old tx) free it */
1204 kfree(mos7840_port->write_urb->transfer_buffer);
1205 usb_free_urb(mos7840_port->write_urb);
1206 }
1207
1208 Data = 0x0; 1198 Data = 0x0;
1209 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); 1199 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
1210 1200
@@ -2113,6 +2103,17 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
2113 return mos7840_num_ports; 2103 return mos7840_num_ports;
2114} 2104}
2115 2105
2106static int mos7840_attach(struct usb_serial *serial)
2107{
2108 if (serial->num_bulk_in < serial->num_ports ||
2109 serial->num_bulk_out < serial->num_ports) {
2110 dev_err(&serial->interface->dev, "missing endpoints\n");
2111 return -ENODEV;
2112 }
2113
2114 return 0;
2115}
2116
2116static int mos7840_port_probe(struct usb_serial_port *port) 2117static int mos7840_port_probe(struct usb_serial_port *port)
2117{ 2118{
2118 struct usb_serial *serial = port->serial; 2119 struct usb_serial *serial = port->serial;
@@ -2388,6 +2389,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
2388 .tiocmset = mos7840_tiocmset, 2389 .tiocmset = mos7840_tiocmset,
2389 .tiocmiwait = usb_serial_generic_tiocmiwait, 2390 .tiocmiwait = usb_serial_generic_tiocmiwait,
2390 .get_icount = usb_serial_generic_get_icount, 2391 .get_icount = usb_serial_generic_get_icount,
2392 .attach = mos7840_attach,
2391 .port_probe = mos7840_port_probe, 2393 .port_probe = mos7840_port_probe,
2392 .port_remove = mos7840_port_remove, 2394 .port_remove = mos7840_port_remove,
2393 .read_bulk_callback = mos7840_bulk_in_callback, 2395 .read_bulk_callback = mos7840_bulk_in_callback,
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index f6c6900bccf0..a180b17d2432 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -38,6 +38,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
38 const unsigned char *buf, int count); 38 const unsigned char *buf, int count);
39static int omninet_write_room(struct tty_struct *tty); 39static int omninet_write_room(struct tty_struct *tty);
40static void omninet_disconnect(struct usb_serial *serial); 40static void omninet_disconnect(struct usb_serial *serial);
41static int omninet_attach(struct usb_serial *serial);
41static int omninet_port_probe(struct usb_serial_port *port); 42static int omninet_port_probe(struct usb_serial_port *port);
42static int omninet_port_remove(struct usb_serial_port *port); 43static int omninet_port_remove(struct usb_serial_port *port);
43 44
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_omninet_device = {
56 .description = "ZyXEL - omni.net lcd plus usb", 57 .description = "ZyXEL - omni.net lcd plus usb",
57 .id_table = id_table, 58 .id_table = id_table,
58 .num_ports = 1, 59 .num_ports = 1,
60 .attach = omninet_attach,
59 .port_probe = omninet_port_probe, 61 .port_probe = omninet_port_probe,
60 .port_remove = omninet_port_remove, 62 .port_remove = omninet_port_remove,
61 .open = omninet_open, 63 .open = omninet_open,
@@ -104,6 +106,17 @@ struct omninet_data {
104 __u8 od_outseq; /* Sequence number for bulk_out URBs */ 106 __u8 od_outseq; /* Sequence number for bulk_out URBs */
105}; 107};
106 108
109static int omninet_attach(struct usb_serial *serial)
110{
111 /* The second bulk-out endpoint is used for writing. */
112 if (serial->num_bulk_out < 2) {
113 dev_err(&serial->interface->dev, "missing endpoints\n");
114 return -ENODEV;
115 }
116
117 return 0;
118}
119
107static int omninet_port_probe(struct usb_serial_port *port) 120static int omninet_port_probe(struct usb_serial_port *port)
108{ 121{
109 struct omninet_data *od; 122 struct omninet_data *od;
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index a4b88bc038b6..b8bf52bf7a94 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
134static int oti6858_tiocmget(struct tty_struct *tty); 134static int oti6858_tiocmget(struct tty_struct *tty);
135static int oti6858_tiocmset(struct tty_struct *tty, 135static int oti6858_tiocmset(struct tty_struct *tty,
136 unsigned int set, unsigned int clear); 136 unsigned int set, unsigned int clear);
137static int oti6858_attach(struct usb_serial *serial);
137static int oti6858_port_probe(struct usb_serial_port *port); 138static int oti6858_port_probe(struct usb_serial_port *port);
138static int oti6858_port_remove(struct usb_serial_port *port); 139static int oti6858_port_remove(struct usb_serial_port *port);
139 140
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_device = {
158 .write_bulk_callback = oti6858_write_bulk_callback, 159 .write_bulk_callback = oti6858_write_bulk_callback,
159 .write_room = oti6858_write_room, 160 .write_room = oti6858_write_room,
160 .chars_in_buffer = oti6858_chars_in_buffer, 161 .chars_in_buffer = oti6858_chars_in_buffer,
162 .attach = oti6858_attach,
161 .port_probe = oti6858_port_probe, 163 .port_probe = oti6858_port_probe,
162 .port_remove = oti6858_port_remove, 164 .port_remove = oti6858_port_remove,
163}; 165};
@@ -324,6 +326,20 @@ static void send_data(struct work_struct *work)
324 usb_serial_port_softint(port); 326 usb_serial_port_softint(port);
325} 327}
326 328
329static int oti6858_attach(struct usb_serial *serial)
330{
331 unsigned char num_ports = serial->num_ports;
332
333 if (serial->num_bulk_in < num_ports ||
334 serial->num_bulk_out < num_ports ||
335 serial->num_interrupt_in < num_ports) {
336 dev_err(&serial->interface->dev, "missing endpoints\n");
337 return -ENODEV;
338 }
339
340 return 0;
341}
342
327static int oti6858_port_probe(struct usb_serial_port *port) 343static int oti6858_port_probe(struct usb_serial_port *port)
328{ 344{
329 struct oti6858_private *priv; 345 struct oti6858_private *priv;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ae682e4eeaef..46fca6b75846 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_serial *serial,
220static int pl2303_startup(struct usb_serial *serial) 220static int pl2303_startup(struct usb_serial *serial)
221{ 221{
222 struct pl2303_serial_private *spriv; 222 struct pl2303_serial_private *spriv;
223 unsigned char num_ports = serial->num_ports;
223 enum pl2303_type type = TYPE_01; 224 enum pl2303_type type = TYPE_01;
224 unsigned char *buf; 225 unsigned char *buf;
225 226
227 if (serial->num_bulk_in < num_ports ||
228 serial->num_bulk_out < num_ports ||
229 serial->num_interrupt_in < num_ports) {
230 dev_err(&serial->interface->dev, "missing endpoints\n");
231 return -ENODEV;
232 }
233
226 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 234 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
227 if (!spriv) 235 if (!spriv)
228 return -ENOMEM; 236 return -ENOMEM;
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 659cb8606bd9..5709cc93b083 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_port *port)
408{ 408{
409 struct usb_serial *serial; 409 struct usb_serial *serial;
410 struct qt2_port_private *port_priv; 410 struct qt2_port_private *port_priv;
411 unsigned long flags;
412 int i; 411 int i;
413 412
414 serial = port->serial; 413 serial = port->serial;
415 port_priv = usb_get_serial_port_data(port); 414 port_priv = usb_get_serial_port_data(port);
416 415
417 spin_lock_irqsave(&port_priv->urb_lock, flags);
418 usb_kill_urb(port_priv->write_urb); 416 usb_kill_urb(port_priv->write_urb);
419 port_priv->urb_in_use = false;
420 spin_unlock_irqrestore(&port_priv->urb_lock, flags);
421 417
422 /* flush the port transmit buffer */ 418 /* flush the port transmit buffer */
423 i = usb_control_msg(serial->dev, 419 i = usb_control_msg(serial->dev,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index ef0dbf0703c5..475e6c31b266 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial,
154 return 0; 154 return 0;
155} 155}
156 156
157static int spcp8x5_attach(struct usb_serial *serial)
158{
159 unsigned char num_ports = serial->num_ports;
160
161 if (serial->num_bulk_in < num_ports ||
162 serial->num_bulk_out < num_ports) {
163 dev_err(&serial->interface->dev, "missing endpoints\n");
164 return -ENODEV;
165 }
166
167 return 0;
168}
169
157static int spcp8x5_port_probe(struct usb_serial_port *port) 170static int spcp8x5_port_probe(struct usb_serial_port *port)
158{ 171{
159 const struct usb_device_id *id = usb_get_serial_data(port->serial); 172 const struct usb_device_id *id = usb_get_serial_data(port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = {
477 .tiocmget = spcp8x5_tiocmget, 490 .tiocmget = spcp8x5_tiocmget,
478 .tiocmset = spcp8x5_tiocmset, 491 .tiocmset = spcp8x5_tiocmset,
479 .probe = spcp8x5_probe, 492 .probe = spcp8x5_probe,
493 .attach = spcp8x5_attach,
480 .port_probe = spcp8x5_port_probe, 494 .port_probe = spcp8x5_port_probe,
481 .port_remove = spcp8x5_port_remove, 495 .port_remove = spcp8x5_port_remove,
482}; 496};
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 8db9d071d940..64b85b8dedf3 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -579,6 +579,13 @@ static int ti_startup(struct usb_serial *serial)
579 goto free_tdev; 579 goto free_tdev;
580 } 580 }
581 581
582 if (serial->num_bulk_in < serial->num_ports ||
583 serial->num_bulk_out < serial->num_ports) {
584 dev_err(&serial->interface->dev, "missing endpoints\n");
585 status = -ENODEV;
586 goto free_tdev;
587 }
588
582 return 0; 589 return 0;
583 590
584free_tdev: 591free_tdev:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index af3c7eecff91..16cc18369111 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2109,6 +2109,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114,
2109 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2109 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2110 US_FL_BROKEN_FUA ), 2110 US_FL_BROKEN_FUA ),
2111 2111
2112/* Reported-by George Cherian <george.cherian@cavium.com> */
2113UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
2114 "JMicron",
2115 "JMS56x",
2116 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2117 US_FL_NO_REPORT_OPCODES),
2118
2112/* 2119/*
2113 * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) 2120 * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
2114 * and Mac USB Dock USB-SCSI */ 2121 * and Mac USB Dock USB-SCSI */
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c
index 79451f7ef1b7..062c205f0046 100644
--- a/drivers/usb/wusbcore/crypto.c
+++ b/drivers/usb/wusbcore/crypto.c
@@ -216,7 +216,6 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
216 struct scatterlist sg[4], sg_dst; 216 struct scatterlist sg[4], sg_dst;
217 void *dst_buf; 217 void *dst_buf;
218 size_t dst_size; 218 size_t dst_size;
219 const u8 bzero[16] = { 0 };
220 u8 iv[crypto_skcipher_ivsize(tfm_cbc)]; 219 u8 iv[crypto_skcipher_ivsize(tfm_cbc)];
221 size_t zero_padding; 220 size_t zero_padding;
222 221
@@ -261,7 +260,7 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
261 sg_set_buf(&sg[1], &scratch->b1, sizeof(scratch->b1)); 260 sg_set_buf(&sg[1], &scratch->b1, sizeof(scratch->b1));
262 sg_set_buf(&sg[2], b, blen); 261 sg_set_buf(&sg[2], b, blen);
263 /* 0 if well behaved :) */ 262 /* 0 if well behaved :) */
264 sg_set_buf(&sg[3], bzero, zero_padding); 263 sg_set_page(&sg[3], ZERO_PAGE(0), zero_padding, 0);
265 sg_init_one(&sg_dst, dst_buf, dst_size); 264 sg_init_one(&sg_dst, dst_buf, dst_size);
266 265
267 skcipher_request_set_tfm(req, tfm_cbc); 266 skcipher_request_set_tfm(req, tfm_cbc);
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index be1ee89ee917..36d75c367d22 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -27,6 +27,45 @@ static LIST_HEAD(parent_list);
27static DEFINE_MUTEX(parent_list_lock); 27static DEFINE_MUTEX(parent_list_lock);
28static struct class_compat *mdev_bus_compat_class; 28static struct class_compat *mdev_bus_compat_class;
29 29
30static LIST_HEAD(mdev_list);
31static DEFINE_MUTEX(mdev_list_lock);
32
33struct device *mdev_parent_dev(struct mdev_device *mdev)
34{
35 return mdev->parent->dev;
36}
37EXPORT_SYMBOL(mdev_parent_dev);
38
39void *mdev_get_drvdata(struct mdev_device *mdev)
40{
41 return mdev->driver_data;
42}
43EXPORT_SYMBOL(mdev_get_drvdata);
44
45void mdev_set_drvdata(struct mdev_device *mdev, void *data)
46{
47 mdev->driver_data = data;
48}
49EXPORT_SYMBOL(mdev_set_drvdata);
50
51struct device *mdev_dev(struct mdev_device *mdev)
52{
53 return &mdev->dev;
54}
55EXPORT_SYMBOL(mdev_dev);
56
57struct mdev_device *mdev_from_dev(struct device *dev)
58{
59 return dev_is_mdev(dev) ? to_mdev_device(dev) : NULL;
60}
61EXPORT_SYMBOL(mdev_from_dev);
62
63uuid_le mdev_uuid(struct mdev_device *mdev)
64{
65 return mdev->uuid;
66}
67EXPORT_SYMBOL(mdev_uuid);
68
30static int _find_mdev_device(struct device *dev, void *data) 69static int _find_mdev_device(struct device *dev, void *data)
31{ 70{
32 struct mdev_device *mdev; 71 struct mdev_device *mdev;
@@ -42,7 +81,7 @@ static int _find_mdev_device(struct device *dev, void *data)
42 return 0; 81 return 0;
43} 82}
44 83
45static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid) 84static bool mdev_device_exist(struct mdev_parent *parent, uuid_le uuid)
46{ 85{
47 struct device *dev; 86 struct device *dev;
48 87
@@ -56,9 +95,9 @@ static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid)
56} 95}
57 96
58/* Should be called holding parent_list_lock */ 97/* Should be called holding parent_list_lock */
59static struct parent_device *__find_parent_device(struct device *dev) 98static struct mdev_parent *__find_parent_device(struct device *dev)
60{ 99{
61 struct parent_device *parent; 100 struct mdev_parent *parent;
62 101
63 list_for_each_entry(parent, &parent_list, next) { 102 list_for_each_entry(parent, &parent_list, next) {
64 if (parent->dev == dev) 103 if (parent->dev == dev)
@@ -69,8 +108,8 @@ static struct parent_device *__find_parent_device(struct device *dev)
69 108
70static void mdev_release_parent(struct kref *kref) 109static void mdev_release_parent(struct kref *kref)
71{ 110{
72 struct parent_device *parent = container_of(kref, struct parent_device, 111 struct mdev_parent *parent = container_of(kref, struct mdev_parent,
73 ref); 112 ref);
74 struct device *dev = parent->dev; 113 struct device *dev = parent->dev;
75 114
76 kfree(parent); 115 kfree(parent);
@@ -78,7 +117,7 @@ static void mdev_release_parent(struct kref *kref)
78} 117}
79 118
80static 119static
81inline struct parent_device *mdev_get_parent(struct parent_device *parent) 120inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
82{ 121{
83 if (parent) 122 if (parent)
84 kref_get(&parent->ref); 123 kref_get(&parent->ref);
@@ -86,7 +125,7 @@ inline struct parent_device *mdev_get_parent(struct parent_device *parent)
86 return parent; 125 return parent;
87} 126}
88 127
89static inline void mdev_put_parent(struct parent_device *parent) 128static inline void mdev_put_parent(struct mdev_parent *parent)
90{ 129{
91 if (parent) 130 if (parent)
92 kref_put(&parent->ref, mdev_release_parent); 131 kref_put(&parent->ref, mdev_release_parent);
@@ -95,7 +134,7 @@ static inline void mdev_put_parent(struct parent_device *parent)
95static int mdev_device_create_ops(struct kobject *kobj, 134static int mdev_device_create_ops(struct kobject *kobj,
96 struct mdev_device *mdev) 135 struct mdev_device *mdev)
97{ 136{
98 struct parent_device *parent = mdev->parent; 137 struct mdev_parent *parent = mdev->parent;
99 int ret; 138 int ret;
100 139
101 ret = parent->ops->create(kobj, mdev); 140 ret = parent->ops->create(kobj, mdev);
@@ -122,7 +161,7 @@ static int mdev_device_create_ops(struct kobject *kobj,
122 */ 161 */
123static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove) 162static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)
124{ 163{
125 struct parent_device *parent = mdev->parent; 164 struct mdev_parent *parent = mdev->parent;
126 int ret; 165 int ret;
127 166
128 /* 167 /*
@@ -153,10 +192,10 @@ static int mdev_device_remove_cb(struct device *dev, void *data)
153 * Add device to list of registered parent devices. 192 * Add device to list of registered parent devices.
154 * Returns a negative value on error, otherwise 0. 193 * Returns a negative value on error, otherwise 0.
155 */ 194 */
156int mdev_register_device(struct device *dev, const struct parent_ops *ops) 195int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
157{ 196{
158 int ret; 197 int ret;
159 struct parent_device *parent; 198 struct mdev_parent *parent;
160 199
161 /* check for mandatory ops */ 200 /* check for mandatory ops */
162 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) 201 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
@@ -229,7 +268,7 @@ EXPORT_SYMBOL(mdev_register_device);
229 268
230void mdev_unregister_device(struct device *dev) 269void mdev_unregister_device(struct device *dev)
231{ 270{
232 struct parent_device *parent; 271 struct mdev_parent *parent;
233 bool force_remove = true; 272 bool force_remove = true;
234 273
235 mutex_lock(&parent_list_lock); 274 mutex_lock(&parent_list_lock);
@@ -266,7 +305,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
266{ 305{
267 int ret; 306 int ret;
268 struct mdev_device *mdev; 307 struct mdev_device *mdev;
269 struct parent_device *parent; 308 struct mdev_parent *parent;
270 struct mdev_type *type = to_mdev_type(kobj); 309 struct mdev_type *type = to_mdev_type(kobj);
271 310
272 parent = mdev_get_parent(type->parent); 311 parent = mdev_get_parent(type->parent);
@@ -316,6 +355,11 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
316 dev_dbg(&mdev->dev, "MDEV: created\n"); 355 dev_dbg(&mdev->dev, "MDEV: created\n");
317 356
318 mutex_unlock(&parent->lock); 357 mutex_unlock(&parent->lock);
358
359 mutex_lock(&mdev_list_lock);
360 list_add(&mdev->next, &mdev_list);
361 mutex_unlock(&mdev_list_lock);
362
319 return ret; 363 return ret;
320 364
321create_failed: 365create_failed:
@@ -329,12 +373,30 @@ create_err:
329 373
330int mdev_device_remove(struct device *dev, bool force_remove) 374int mdev_device_remove(struct device *dev, bool force_remove)
331{ 375{
332 struct mdev_device *mdev; 376 struct mdev_device *mdev, *tmp;
333 struct parent_device *parent; 377 struct mdev_parent *parent;
334 struct mdev_type *type; 378 struct mdev_type *type;
335 int ret; 379 int ret;
380 bool found = false;
336 381
337 mdev = to_mdev_device(dev); 382 mdev = to_mdev_device(dev);
383
384 mutex_lock(&mdev_list_lock);
385 list_for_each_entry(tmp, &mdev_list, next) {
386 if (tmp == mdev) {
387 found = true;
388 break;
389 }
390 }
391
392 if (found)
393 list_del(&mdev->next);
394
395 mutex_unlock(&mdev_list_lock);
396
397 if (!found)
398 return -ENODEV;
399
338 type = to_mdev_type(mdev->type_kobj); 400 type = to_mdev_type(mdev->type_kobj);
339 parent = mdev->parent; 401 parent = mdev->parent;
340 mutex_lock(&parent->lock); 402 mutex_lock(&parent->lock);
@@ -342,6 +404,11 @@ int mdev_device_remove(struct device *dev, bool force_remove)
342 ret = mdev_device_remove_ops(mdev, force_remove); 404 ret = mdev_device_remove_ops(mdev, force_remove);
343 if (ret) { 405 if (ret) {
344 mutex_unlock(&parent->lock); 406 mutex_unlock(&parent->lock);
407
408 mutex_lock(&mdev_list_lock);
409 list_add(&mdev->next, &mdev_list);
410 mutex_unlock(&mdev_list_lock);
411
345 return ret; 412 return ret;
346 } 413 }
347 414
@@ -349,7 +416,8 @@ int mdev_device_remove(struct device *dev, bool force_remove)
349 device_unregister(dev); 416 device_unregister(dev);
350 mutex_unlock(&parent->lock); 417 mutex_unlock(&parent->lock);
351 mdev_put_parent(parent); 418 mdev_put_parent(parent);
352 return ret; 419
420 return 0;
353} 421}
354 422
355static int __init mdev_init(void) 423static int __init mdev_init(void)
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index d35097cbf3d7..a9cefd70a705 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -16,10 +16,33 @@
16int mdev_bus_register(void); 16int mdev_bus_register(void);
17void mdev_bus_unregister(void); 17void mdev_bus_unregister(void);
18 18
19struct mdev_parent {
20 struct device *dev;
21 const struct mdev_parent_ops *ops;
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
29struct mdev_device {
30 struct device dev;
31 struct mdev_parent *parent;
32 uuid_le uuid;
33 void *driver_data;
34 struct kref ref;
35 struct list_head next;
36 struct kobject *type_kobj;
37};
38
39#define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
40#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
41
19struct mdev_type { 42struct mdev_type {
20 struct kobject kobj; 43 struct kobject kobj;
21 struct kobject *devices_kobj; 44 struct kobject *devices_kobj;
22 struct parent_device *parent; 45 struct mdev_parent *parent;
23 struct list_head next; 46 struct list_head next;
24 struct attribute_group *group; 47 struct attribute_group *group;
25}; 48};
@@ -29,8 +52,8 @@ struct mdev_type {
29#define to_mdev_type(_kobj) \ 52#define to_mdev_type(_kobj) \
30 container_of(_kobj, struct mdev_type, kobj) 53 container_of(_kobj, struct mdev_type, kobj)
31 54
32int parent_create_sysfs_files(struct parent_device *parent); 55int parent_create_sysfs_files(struct mdev_parent *parent);
33void parent_remove_sysfs_files(struct parent_device *parent); 56void parent_remove_sysfs_files(struct mdev_parent *parent);
34 57
35int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type); 58int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
36void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type); 59void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 1a53deb2ee10..802df210929b 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -92,7 +92,7 @@ static struct kobj_type mdev_type_ktype = {
92 .release = mdev_type_release, 92 .release = mdev_type_release,
93}; 93};
94 94
95struct mdev_type *add_mdev_supported_type(struct parent_device *parent, 95struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
96 struct attribute_group *group) 96 struct attribute_group *group)
97{ 97{
98 struct mdev_type *type; 98 struct mdev_type *type;
@@ -158,7 +158,7 @@ static void remove_mdev_supported_type(struct mdev_type *type)
158 kobject_put(&type->kobj); 158 kobject_put(&type->kobj);
159} 159}
160 160
161static int add_mdev_supported_type_groups(struct parent_device *parent) 161static int add_mdev_supported_type_groups(struct mdev_parent *parent)
162{ 162{
163 int i; 163 int i;
164 164
@@ -183,7 +183,7 @@ static int add_mdev_supported_type_groups(struct parent_device *parent)
183} 183}
184 184
185/* mdev sysfs functions */ 185/* mdev sysfs functions */
186void parent_remove_sysfs_files(struct parent_device *parent) 186void parent_remove_sysfs_files(struct mdev_parent *parent)
187{ 187{
188 struct mdev_type *type, *tmp; 188 struct mdev_type *type, *tmp;
189 189
@@ -196,7 +196,7 @@ void parent_remove_sysfs_files(struct parent_device *parent)
196 kset_unregister(parent->mdev_types_kset); 196 kset_unregister(parent->mdev_types_kset);
197} 197}
198 198
199int parent_create_sysfs_files(struct parent_device *parent) 199int parent_create_sysfs_files(struct mdev_parent *parent)
200{ 200{
201 int ret; 201 int ret;
202 202
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
index ffc36758cb84..fa848a701b8b 100644
--- a/drivers/vfio/mdev/vfio_mdev.c
+++ b/drivers/vfio/mdev/vfio_mdev.c
@@ -27,7 +27,7 @@
27static int vfio_mdev_open(void *device_data) 27static int vfio_mdev_open(void *device_data)
28{ 28{
29 struct mdev_device *mdev = device_data; 29 struct mdev_device *mdev = device_data;
30 struct parent_device *parent = mdev->parent; 30 struct mdev_parent *parent = mdev->parent;
31 int ret; 31 int ret;
32 32
33 if (unlikely(!parent->ops->open)) 33 if (unlikely(!parent->ops->open))
@@ -46,7 +46,7 @@ static int vfio_mdev_open(void *device_data)
46static void vfio_mdev_release(void *device_data) 46static void vfio_mdev_release(void *device_data)
47{ 47{
48 struct mdev_device *mdev = device_data; 48 struct mdev_device *mdev = device_data;
49 struct parent_device *parent = mdev->parent; 49 struct mdev_parent *parent = mdev->parent;
50 50
51 if (likely(parent->ops->release)) 51 if (likely(parent->ops->release))
52 parent->ops->release(mdev); 52 parent->ops->release(mdev);
@@ -58,7 +58,7 @@ static long vfio_mdev_unlocked_ioctl(void *device_data,
58 unsigned int cmd, unsigned long arg) 58 unsigned int cmd, unsigned long arg)
59{ 59{
60 struct mdev_device *mdev = device_data; 60 struct mdev_device *mdev = device_data;
61 struct parent_device *parent = mdev->parent; 61 struct mdev_parent *parent = mdev->parent;
62 62
63 if (unlikely(!parent->ops->ioctl)) 63 if (unlikely(!parent->ops->ioctl))
64 return -EINVAL; 64 return -EINVAL;
@@ -70,7 +70,7 @@ static ssize_t vfio_mdev_read(void *device_data, char __user *buf,
70 size_t count, loff_t *ppos) 70 size_t count, loff_t *ppos)
71{ 71{
72 struct mdev_device *mdev = device_data; 72 struct mdev_device *mdev = device_data;
73 struct parent_device *parent = mdev->parent; 73 struct mdev_parent *parent = mdev->parent;
74 74
75 if (unlikely(!parent->ops->read)) 75 if (unlikely(!parent->ops->read))
76 return -EINVAL; 76 return -EINVAL;
@@ -82,7 +82,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
82 size_t count, loff_t *ppos) 82 size_t count, loff_t *ppos)
83{ 83{
84 struct mdev_device *mdev = device_data; 84 struct mdev_device *mdev = device_data;
85 struct parent_device *parent = mdev->parent; 85 struct mdev_parent *parent = mdev->parent;
86 86
87 if (unlikely(!parent->ops->write)) 87 if (unlikely(!parent->ops->write))
88 return -EINVAL; 88 return -EINVAL;
@@ -93,7 +93,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma) 93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma)
94{ 94{
95 struct mdev_device *mdev = device_data; 95 struct mdev_device *mdev = device_data;
96 struct parent_device *parent = mdev->parent; 96 struct mdev_parent *parent = mdev->parent;
97 97
98 if (unlikely(!parent->ops->mmap)) 98 if (unlikely(!parent->ops->mmap))
99 return -EINVAL; 99 return -EINVAL;
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index dcd7c2a99618..324c52e3a1a4 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1142,6 +1142,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
1142 return ret; 1142 return ret;
1143 1143
1144 vdev->barmap[index] = pci_iomap(pdev, index, 0); 1144 vdev->barmap[index] = pci_iomap(pdev, index, 0);
1145 if (!vdev->barmap[index]) {
1146 pci_release_selected_regions(pdev, 1 << index);
1147 return -ENOMEM;
1148 }
1145 } 1149 }
1146 1150
1147 vma->vm_private_data = vdev; 1151 vma->vm_private_data = vdev;
diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
index 5ffd1d9ad4bd..357243d76f10 100644
--- a/drivers/vfio/pci/vfio_pci_rdwr.c
+++ b/drivers/vfio/pci/vfio_pci_rdwr.c
@@ -193,7 +193,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
193 if (!vdev->has_vga) 193 if (!vdev->has_vga)
194 return -EINVAL; 194 return -EINVAL;
195 195
196 switch (pos) { 196 if (pos > 0xbfffful)
197 return -EINVAL;
198
199 switch ((u32)pos) {
197 case 0xa0000 ... 0xbffff: 200 case 0xa0000 ... 0xbffff:
198 count = min(count, (size_t)(0xc0000 - pos)); 201 count = min(count, (size_t)(0xc0000 - pos));
199 iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1); 202 iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index f3726ba12aa6..b3cc33fa6d26 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -36,7 +36,6 @@
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37#include <linux/vfio.h> 37#include <linux/vfio.h>
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/pid_namespace.h>
40#include <linux/mdev.h> 39#include <linux/mdev.h>
41#include <linux/notifier.h> 40#include <linux/notifier.h>
42 41
@@ -268,28 +267,38 @@ static void vfio_lock_acct(struct task_struct *task, long npage)
268{ 267{
269 struct vwork *vwork; 268 struct vwork *vwork;
270 struct mm_struct *mm; 269 struct mm_struct *mm;
270 bool is_current;
271 271
272 if (!npage) 272 if (!npage)
273 return; 273 return;
274 274
275 mm = get_task_mm(task); 275 is_current = (task->mm == current->mm);
276
277 mm = is_current ? task->mm : get_task_mm(task);
276 if (!mm) 278 if (!mm)
277 return; /* process exited or nothing to do */ 279 return; /* process exited */
278 280
279 if (down_write_trylock(&mm->mmap_sem)) { 281 if (down_write_trylock(&mm->mmap_sem)) {
280 mm->locked_vm += npage; 282 mm->locked_vm += npage;
281 up_write(&mm->mmap_sem); 283 up_write(&mm->mmap_sem);
282 mmput(mm); 284 if (!is_current)
285 mmput(mm);
283 return; 286 return;
284 } 287 }
285 288
289 if (is_current) {
290 mm = get_task_mm(task);
291 if (!mm)
292 return;
293 }
294
286 /* 295 /*
287 * Couldn't get mmap_sem lock, so must setup to update 296 * Couldn't get mmap_sem lock, so must setup to update
288 * mm->locked_vm later. If locked_vm were atomic, we 297 * mm->locked_vm later. If locked_vm were atomic, we
289 * wouldn't need this silliness 298 * wouldn't need this silliness
290 */ 299 */
291 vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL); 300 vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL);
292 if (!vwork) { 301 if (WARN_ON(!vwork)) {
293 mmput(mm); 302 mmput(mm);
294 return; 303 return;
295 } 304 }
@@ -393,77 +402,71 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
393static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr, 402static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
394 long npage, unsigned long *pfn_base) 403 long npage, unsigned long *pfn_base)
395{ 404{
396 unsigned long limit; 405 unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
397 bool lock_cap = ns_capable(task_active_pid_ns(dma->task)->user_ns, 406 bool lock_cap = capable(CAP_IPC_LOCK);
398 CAP_IPC_LOCK); 407 long ret, pinned = 0, lock_acct = 0;
399 struct mm_struct *mm;
400 long ret, i = 0, lock_acct = 0;
401 bool rsvd; 408 bool rsvd;
402 dma_addr_t iova = vaddr - dma->vaddr + dma->iova; 409 dma_addr_t iova = vaddr - dma->vaddr + dma->iova;
403 410
404 mm = get_task_mm(dma->task); 411 /* This code path is only user initiated */
405 if (!mm) 412 if (!current->mm)
406 return -ENODEV; 413 return -ENODEV;
407 414
408 ret = vaddr_get_pfn(mm, vaddr, dma->prot, pfn_base); 415 ret = vaddr_get_pfn(current->mm, vaddr, dma->prot, pfn_base);
409 if (ret) 416 if (ret)
410 goto pin_pg_remote_exit; 417 return ret;
411 418
419 pinned++;
412 rsvd = is_invalid_reserved_pfn(*pfn_base); 420 rsvd = is_invalid_reserved_pfn(*pfn_base);
413 limit = task_rlimit(dma->task, RLIMIT_MEMLOCK) >> PAGE_SHIFT;
414 421
415 /* 422 /*
416 * Reserved pages aren't counted against the user, externally pinned 423 * Reserved pages aren't counted against the user, externally pinned
417 * pages are already counted against the user. 424 * pages are already counted against the user.
418 */ 425 */
419 if (!rsvd && !vfio_find_vpfn(dma, iova)) { 426 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
420 if (!lock_cap && mm->locked_vm + 1 > limit) { 427 if (!lock_cap && current->mm->locked_vm + 1 > limit) {
421 put_pfn(*pfn_base, dma->prot); 428 put_pfn(*pfn_base, dma->prot);
422 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__, 429 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
423 limit << PAGE_SHIFT); 430 limit << PAGE_SHIFT);
424 ret = -ENOMEM; 431 return -ENOMEM;
425 goto pin_pg_remote_exit;
426 } 432 }
427 lock_acct++; 433 lock_acct++;
428 } 434 }
429 435
430 i++; 436 if (unlikely(disable_hugepages))
431 if (likely(!disable_hugepages)) { 437 goto out;
432 /* Lock all the consecutive pages from pfn_base */
433 for (vaddr += PAGE_SIZE, iova += PAGE_SIZE; i < npage;
434 i++, vaddr += PAGE_SIZE, iova += PAGE_SIZE) {
435 unsigned long pfn = 0;
436 438
437 ret = vaddr_get_pfn(mm, vaddr, dma->prot, &pfn); 439 /* Lock all the consecutive pages from pfn_base */
438 if (ret) 440 for (vaddr += PAGE_SIZE, iova += PAGE_SIZE; pinned < npage;
439 break; 441 pinned++, vaddr += PAGE_SIZE, iova += PAGE_SIZE) {
442 unsigned long pfn = 0;
440 443
441 if (pfn != *pfn_base + i || 444 ret = vaddr_get_pfn(current->mm, vaddr, dma->prot, &pfn);
442 rsvd != is_invalid_reserved_pfn(pfn)) { 445 if (ret)
446 break;
447
448 if (pfn != *pfn_base + pinned ||
449 rsvd != is_invalid_reserved_pfn(pfn)) {
450 put_pfn(pfn, dma->prot);
451 break;
452 }
453
454 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
455 if (!lock_cap &&
456 current->mm->locked_vm + lock_acct + 1 > limit) {
443 put_pfn(pfn, dma->prot); 457 put_pfn(pfn, dma->prot);
458 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n",
459 __func__, limit << PAGE_SHIFT);
444 break; 460 break;
445 } 461 }
446 462 lock_acct++;
447 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
448 if (!lock_cap &&
449 mm->locked_vm + lock_acct + 1 > limit) {
450 put_pfn(pfn, dma->prot);
451 pr_warn("%s: RLIMIT_MEMLOCK (%ld) "
452 "exceeded\n", __func__,
453 limit << PAGE_SHIFT);
454 break;
455 }
456 lock_acct++;
457 }
458 } 463 }
459 } 464 }
460 465
461 vfio_lock_acct(dma->task, lock_acct); 466out:
462 ret = i; 467 vfio_lock_acct(current, lock_acct);
463 468
464pin_pg_remote_exit: 469 return pinned;
465 mmput(mm);
466 return ret;
467} 470}
468 471
469static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova, 472static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
@@ -473,10 +476,10 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
473 long unlocked = 0, locked = 0; 476 long unlocked = 0, locked = 0;
474 long i; 477 long i;
475 478
476 for (i = 0; i < npage; i++) { 479 for (i = 0; i < npage; i++, iova += PAGE_SIZE) {
477 if (put_pfn(pfn++, dma->prot)) { 480 if (put_pfn(pfn++, dma->prot)) {
478 unlocked++; 481 unlocked++;
479 if (vfio_find_vpfn(dma, iova + (i << PAGE_SHIFT))) 482 if (vfio_find_vpfn(dma, iova))
480 locked++; 483 locked++;
481 } 484 }
482 } 485 }
@@ -491,8 +494,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
491 unsigned long *pfn_base, bool do_accounting) 494 unsigned long *pfn_base, bool do_accounting)
492{ 495{
493 unsigned long limit; 496 unsigned long limit;
494 bool lock_cap = ns_capable(task_active_pid_ns(dma->task)->user_ns, 497 bool lock_cap = has_capability(dma->task, CAP_IPC_LOCK);
495 CAP_IPC_LOCK);
496 struct mm_struct *mm; 498 struct mm_struct *mm;
497 int ret; 499 int ret;
498 bool rsvd; 500 bool rsvd;
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 253310cdaaca..fd6c8b66f06f 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -843,7 +843,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
843 struct iov_iter out_iter, in_iter, prot_iter, data_iter; 843 struct iov_iter out_iter, in_iter, prot_iter, data_iter;
844 u64 tag; 844 u64 tag;
845 u32 exp_data_len, data_direction; 845 u32 exp_data_len, data_direction;
846 unsigned out, in; 846 unsigned int out = 0, in = 0;
847 int head, ret, prot_bytes; 847 int head, ret, prot_bytes;
848 size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp); 848 size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp);
849 size_t out_size, in_size; 849 size_t out_size, in_size;
@@ -2087,7 +2087,7 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
2087 NULL, 2087 NULL,
2088}; 2088};
2089 2089
2090static struct target_core_fabric_ops vhost_scsi_ops = { 2090static const struct target_core_fabric_ops vhost_scsi_ops = {
2091 .module = THIS_MODULE, 2091 .module = THIS_MODULE,
2092 .name = "vhost", 2092 .name = "vhost",
2093 .get_fabric_name = vhost_scsi_get_fabric_name, 2093 .get_fabric_name = vhost_scsi_get_fabric_name,
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 2d3b691f3fc4..038ac6934fe9 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -308,6 +308,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
308 info->screen_size = resource_size(res); 308 info->screen_size = resource_size(res);
309 info->screen_base = devm_ioremap(&dev->dev, res->start, 309 info->screen_base = devm_ioremap(&dev->dev, res->start,
310 info->screen_size); 310 info->screen_size);
311 if (!info->screen_base) {
312 framebuffer_release(info);
313 return -ENOMEM;
314 }
315
311 info->fbops = &cobalt_lcd_fbops; 316 info->fbops = &cobalt_lcd_fbops;
312 info->fix = cobalt_lcdfb_fix; 317 info->fix = cobalt_lcdfb_fix;
313 info->fix.smem_start = res->start; 318 info->fix.smem_start = res->start;
diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c
index 6b5ee896af63..7cc51223db1c 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -464,7 +464,7 @@ static int ca91cx42_slave_get(struct vme_slave_resource *image, int *enabled,
464 vme_bound = ioread32(bridge->base + CA91CX42_VSI_BD[i]); 464 vme_bound = ioread32(bridge->base + CA91CX42_VSI_BD[i]);
465 pci_offset = ioread32(bridge->base + CA91CX42_VSI_TO[i]); 465 pci_offset = ioread32(bridge->base + CA91CX42_VSI_TO[i]);
466 466
467 *pci_base = (dma_addr_t)vme_base + pci_offset; 467 *pci_base = (dma_addr_t)*vme_base + pci_offset;
468 *size = (unsigned long long)((vme_bound - *vme_base) + granularity); 468 *size = (unsigned long long)((vme_bound - *vme_base) + granularity);
469 469
470 *enabled = 0; 470 *enabled = 0;
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 778acf80aacb..85dd20e05726 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
58 xen_pfn_t *gpfns; 58 xen_pfn_t *gpfns;
59 xen_ulong_t *idxs; 59 xen_ulong_t *idxs;
60 int *errs; 60 int *errs;
61 struct xen_add_to_physmap_range xatp;
62 61
63 for (i = 0; i < count; i++) { 62 for (i = 0; i < count; i++) {
63 struct xen_add_to_physmap_range xatp = {
64 .domid = DOMID_SELF,
65 .space = XENMAPSPACE_dev_mmio
66 };
67
64 r = &resources[i]; 68 r = &resources[i];
65 nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE); 69 nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
66 if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) 70 if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
87 idxs[j] = XEN_PFN_DOWN(r->start) + j; 91 idxs[j] = XEN_PFN_DOWN(r->start) + j;
88 } 92 }
89 93
90 xatp.domid = DOMID_SELF;
91 xatp.size = nr; 94 xatp.size = nr;
92 xatp.space = XENMAPSPACE_dev_mmio;
93 95
94 set_xen_guest_handle(xatp.gpfns, gpfns); 96 set_xen_guest_handle(xatp.gpfns, gpfns);
95 set_xen_guest_handle(xatp.idxs, idxs); 97 set_xen_guest_handle(xatp.idxs, idxs);
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index c03f9c86c7e3..3c41470c7fc4 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -369,8 +369,7 @@ static void evtchn_fifo_resume(void)
369 } 369 }
370 370
371 ret = init_control_block(cpu, control_block); 371 ret = init_control_block(cpu, control_block);
372 if (ret < 0) 372 BUG_ON(ret < 0);
373 BUG();
374 } 373 }
375 374
376 /* 375 /*
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index e8c7f09d01be..6890897a6f30 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -125,7 +125,7 @@ static int add_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
125 while (*new) { 125 while (*new) {
126 struct user_evtchn *this; 126 struct user_evtchn *this;
127 127
128 this = container_of(*new, struct user_evtchn, node); 128 this = rb_entry(*new, struct user_evtchn, node);
129 129
130 parent = *new; 130 parent = *new;
131 if (this->port < evtchn->port) 131 if (this->port < evtchn->port)
@@ -157,7 +157,7 @@ static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
157 while (node) { 157 while (node) {
158 struct user_evtchn *evtchn; 158 struct user_evtchn *evtchn;
159 159
160 evtchn = container_of(node, struct user_evtchn, node); 160 evtchn = rb_entry(node, struct user_evtchn, node);
161 161
162 if (evtchn->port < port) 162 if (evtchn->port < port)
163 node = node->rb_left; 163 node = node->rb_left;
diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c
index 112ce422dc22..2a165cc8a43c 100644
--- a/drivers/xen/platform-pci.c
+++ b/drivers/xen/platform-pci.c
@@ -42,6 +42,7 @@
42static unsigned long platform_mmio; 42static unsigned long platform_mmio;
43static unsigned long platform_mmio_alloc; 43static unsigned long platform_mmio_alloc;
44static unsigned long platform_mmiolen; 44static unsigned long platform_mmiolen;
45static uint64_t callback_via;
45 46
46static unsigned long alloc_xen_mmio(unsigned long len) 47static unsigned long alloc_xen_mmio(unsigned long len)
47{ 48{
@@ -54,6 +55,51 @@ static unsigned long alloc_xen_mmio(unsigned long len)
54 return addr; 55 return addr;
55} 56}
56 57
58static uint64_t get_callback_via(struct pci_dev *pdev)
59{
60 u8 pin;
61 int irq;
62
63 irq = pdev->irq;
64 if (irq < 16)
65 return irq; /* ISA IRQ */
66
67 pin = pdev->pin;
68
69 /* We don't know the GSI. Specify the PCI INTx line instead. */
70 return ((uint64_t)0x01 << HVM_CALLBACK_VIA_TYPE_SHIFT) | /* PCI INTx identifier */
71 ((uint64_t)pci_domain_nr(pdev->bus) << 32) |
72 ((uint64_t)pdev->bus->number << 16) |
73 ((uint64_t)(pdev->devfn & 0xff) << 8) |
74 ((uint64_t)(pin - 1) & 3);
75}
76
77static irqreturn_t do_hvm_evtchn_intr(int irq, void *dev_id)
78{
79 xen_hvm_evtchn_do_upcall();
80 return IRQ_HANDLED;
81}
82
83static int xen_allocate_irq(struct pci_dev *pdev)
84{
85 return request_irq(pdev->irq, do_hvm_evtchn_intr,
86 IRQF_NOBALANCING | IRQF_TRIGGER_RISING,
87 "xen-platform-pci", pdev);
88}
89
90static int platform_pci_resume(struct pci_dev *pdev)
91{
92 int err;
93 if (!xen_pv_domain())
94 return 0;
95 err = xen_set_callback_via(callback_via);
96 if (err) {
97 dev_err(&pdev->dev, "platform_pci_resume failure!\n");
98 return err;
99 }
100 return 0;
101}
102
57static int platform_pci_probe(struct pci_dev *pdev, 103static int platform_pci_probe(struct pci_dev *pdev,
58 const struct pci_device_id *ent) 104 const struct pci_device_id *ent)
59{ 105{
@@ -92,6 +138,28 @@ static int platform_pci_probe(struct pci_dev *pdev,
92 platform_mmio = mmio_addr; 138 platform_mmio = mmio_addr;
93 platform_mmiolen = mmio_len; 139 platform_mmiolen = mmio_len;
94 140
141 /*
142 * Xen HVM guests always use the vector callback mechanism.
143 * L1 Dom0 in a nested Xen environment is a PV guest inside in an
144 * HVM environment. It needs the platform-pci driver to get
145 * notifications from L0 Xen, but it cannot use the vector callback
146 * as it is not exported by L1 Xen.
147 */
148 if (xen_pv_domain()) {
149 ret = xen_allocate_irq(pdev);
150 if (ret) {
151 dev_warn(&pdev->dev, "request_irq failed err=%d\n", ret);
152 goto out;
153 }
154 callback_via = get_callback_via(pdev);
155 ret = xen_set_callback_via(callback_via);
156 if (ret) {
157 dev_warn(&pdev->dev, "Unable to set the evtchn callback "
158 "err=%d\n", ret);
159 goto out;
160 }
161 }
162
95 max_nr_gframes = gnttab_max_grant_frames(); 163 max_nr_gframes = gnttab_max_grant_frames();
96 grant_frames = alloc_xen_mmio(PAGE_SIZE * max_nr_gframes); 164 grant_frames = alloc_xen_mmio(PAGE_SIZE * max_nr_gframes);
97 ret = gnttab_setup_auto_xlat_frames(grant_frames); 165 ret = gnttab_setup_auto_xlat_frames(grant_frames);
@@ -123,6 +191,9 @@ static struct pci_driver platform_driver = {
123 .name = DRV_NAME, 191 .name = DRV_NAME,
124 .probe = platform_pci_probe, 192 .probe = platform_pci_probe,
125 .id_table = platform_pci_tbl, 193 .id_table = platform_pci_tbl,
194#ifdef CONFIG_PM
195 .resume_early = platform_pci_resume,
196#endif
126}; 197};
127 198
128builtin_pci_driver(platform_driver); 199builtin_pci_driver(platform_driver);
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 478fb91e3df2..f905d6eeb048 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -275,6 +275,10 @@ retry:
275 rc = 0; 275 rc = 0;
276 } else 276 } else
277 rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs); 277 rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
278
279 if (!rc)
280 swiotlb_set_max_segment(PAGE_SIZE);
281
278 return rc; 282 return rc;
279error: 283error:
280 if (repeat--) { 284 if (repeat--) {
@@ -392,7 +396,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
392 if (dma_capable(dev, dev_addr, size) && 396 if (dma_capable(dev, dev_addr, size) &&
393 !range_straddles_page_boundary(phys, size) && 397 !range_straddles_page_boundary(phys, size) &&
394 !xen_arch_need_swiotlb(dev, phys, dev_addr) && 398 !xen_arch_need_swiotlb(dev, phys, dev_addr) &&
395 !swiotlb_force) { 399 (swiotlb_force != SWIOTLB_FORCE)) {
396 /* we are not interested in the dma_addr returned by 400 /* we are not interested in the dma_addr returned by
397 * xen_dma_map_page, only in the potential cache flushes executed 401 * xen_dma_map_page, only in the potential cache flushes executed
398 * by the function. */ 402 * by the function. */
@@ -552,7 +556,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
552 phys_addr_t paddr = sg_phys(sg); 556 phys_addr_t paddr = sg_phys(sg);
553 dma_addr_t dev_addr = xen_phys_to_bus(paddr); 557 dma_addr_t dev_addr = xen_phys_to_bus(paddr);
554 558
555 if (swiotlb_force || 559 if (swiotlb_force == SWIOTLB_FORCE ||
556 xen_arch_need_swiotlb(hwdev, paddr, dev_addr) || 560 xen_arch_need_swiotlb(hwdev, paddr, dev_addr) ||
557 !dma_capable(hwdev, dev_addr, sg->length) || 561 !dma_capable(hwdev, dev_addr, sg->length) ||
558 range_straddles_page_boundary(paddr, sg->length)) { 562 range_straddles_page_boundary(paddr, sg->length)) {
diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h
index e74f9c1fbd80..867a2e425208 100644
--- a/drivers/xen/xenbus/xenbus_comms.h
+++ b/drivers/xen/xenbus/xenbus_comms.h
@@ -42,7 +42,6 @@ int xb_write(const void *data, unsigned len);
42int xb_read(void *data, unsigned len); 42int xb_read(void *data, unsigned len);
43int xb_data_to_read(void); 43int xb_data_to_read(void);
44int xb_wait_for_data_to_read(void); 44int xb_wait_for_data_to_read(void);
45int xs_input_avail(void);
46extern struct xenstore_domain_interface *xen_store_interface; 45extern struct xenstore_domain_interface *xen_store_interface;
47extern int xen_store_evtchn; 46extern int xen_store_evtchn;
48extern enum xenstore_init xen_store_domain_type; 47extern enum xenstore_init xen_store_domain_type;
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 6c0ead4be784..79130b310247 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -302,6 +302,29 @@ static void watch_fired(struct xenbus_watch *watch,
302 mutex_unlock(&adap->dev_data->reply_mutex); 302 mutex_unlock(&adap->dev_data->reply_mutex);
303} 303}
304 304
305static int xenbus_command_reply(struct xenbus_file_priv *u,
306 unsigned int msg_type, const char *reply)
307{
308 struct {
309 struct xsd_sockmsg hdr;
310 const char body[16];
311 } msg;
312 int rc;
313
314 msg.hdr = u->u.msg;
315 msg.hdr.type = msg_type;
316 msg.hdr.len = strlen(reply) + 1;
317 if (msg.hdr.len > sizeof(msg.body))
318 return -E2BIG;
319
320 mutex_lock(&u->reply_mutex);
321 rc = queue_reply(&u->read_buffers, &msg, sizeof(msg.hdr) + msg.hdr.len);
322 wake_up(&u->read_waitq);
323 mutex_unlock(&u->reply_mutex);
324
325 return rc;
326}
327
305static int xenbus_write_transaction(unsigned msg_type, 328static int xenbus_write_transaction(unsigned msg_type,
306 struct xenbus_file_priv *u) 329 struct xenbus_file_priv *u)
307{ 330{
@@ -316,12 +339,12 @@ static int xenbus_write_transaction(unsigned msg_type,
316 rc = -ENOMEM; 339 rc = -ENOMEM;
317 goto out; 340 goto out;
318 } 341 }
319 } else if (msg_type == XS_TRANSACTION_END) { 342 } else if (u->u.msg.tx_id != 0) {
320 list_for_each_entry(trans, &u->transactions, list) 343 list_for_each_entry(trans, &u->transactions, list)
321 if (trans->handle.id == u->u.msg.tx_id) 344 if (trans->handle.id == u->u.msg.tx_id)
322 break; 345 break;
323 if (&trans->list == &u->transactions) 346 if (&trans->list == &u->transactions)
324 return -ESRCH; 347 return xenbus_command_reply(u, XS_ERROR, "ENOENT");
325 } 348 }
326 349
327 reply = xenbus_dev_request_and_reply(&u->u.msg); 350 reply = xenbus_dev_request_and_reply(&u->u.msg);
@@ -372,12 +395,12 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
372 path = u->u.buffer + sizeof(u->u.msg); 395 path = u->u.buffer + sizeof(u->u.msg);
373 token = memchr(path, 0, u->u.msg.len); 396 token = memchr(path, 0, u->u.msg.len);
374 if (token == NULL) { 397 if (token == NULL) {
375 rc = -EILSEQ; 398 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL");
376 goto out; 399 goto out;
377 } 400 }
378 token++; 401 token++;
379 if (memchr(token, 0, u->u.msg.len - (token - path)) == NULL) { 402 if (memchr(token, 0, u->u.msg.len - (token - path)) == NULL) {
380 rc = -EILSEQ; 403 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL");
381 goto out; 404 goto out;
382 } 405 }
383 406
@@ -411,23 +434,7 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
411 } 434 }
412 435
413 /* Success. Synthesize a reply to say all is OK. */ 436 /* Success. Synthesize a reply to say all is OK. */
414 { 437 rc = xenbus_command_reply(u, msg_type, "OK");
415 struct {
416 struct xsd_sockmsg hdr;
417 char body[3];
418 } __packed reply = {
419 {
420 .type = msg_type,
421 .len = sizeof(reply.body)
422 },
423 "OK"
424 };
425
426 mutex_lock(&u->reply_mutex);
427 rc = queue_reply(&u->read_buffers, &reply, sizeof(reply));
428 wake_up(&u->read_waitq);
429 mutex_unlock(&u->reply_mutex);
430 }
431 438
432out: 439out:
433 return rc; 440 return rc;
diff --git a/fs/aio.c b/fs/aio.c
index 4ab67e8cb776..873b4ca82ccb 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1085,7 +1085,8 @@ static void aio_complete(struct kiocb *kiocb, long res, long res2)
1085 * Tell lockdep we inherited freeze protection from submission 1085 * Tell lockdep we inherited freeze protection from submission
1086 * thread. 1086 * thread.
1087 */ 1087 */
1088 __sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE); 1088 if (S_ISREG(file_inode(file)->i_mode))
1089 __sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE);
1089 file_end_write(file); 1090 file_end_write(file);
1090 } 1091 }
1091 1092
@@ -1525,7 +1526,8 @@ static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored,
1525 * by telling it the lock got released so that it doesn't 1526 * by telling it the lock got released so that it doesn't
1526 * complain about held lock when we return to userspace. 1527 * complain about held lock when we return to userspace.
1527 */ 1528 */
1528 __sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE); 1529 if (S_ISREG(file_inode(file)->i_mode))
1530 __sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE);
1529 } 1531 }
1530 kfree(iovec); 1532 kfree(iovec);
1531 return ret; 1533 return ret;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 29a02daf08a9..422370293cfd 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -2298,6 +2298,7 @@ static int elf_core_dump(struct coredump_params *cprm)
2298 goto end_coredump; 2298 goto end_coredump;
2299 } 2299 }
2300 } 2300 }
2301 dump_truncate(cprm);
2301 2302
2302 if (!elf_core_write_extra_data(cprm)) 2303 if (!elf_core_write_extra_data(cprm))
2303 goto end_coredump; 2304 goto end_coredump;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6254cee8f8f3..5db5d1340d69 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -328,6 +328,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
328 struct file *file = iocb->ki_filp; 328 struct file *file = iocb->ki_filp;
329 struct inode *inode = bdev_file_inode(file); 329 struct inode *inode = bdev_file_inode(file);
330 struct block_device *bdev = I_BDEV(inode); 330 struct block_device *bdev = I_BDEV(inode);
331 struct blk_plug plug;
331 struct blkdev_dio *dio; 332 struct blkdev_dio *dio;
332 struct bio *bio; 333 struct bio *bio;
333 bool is_read = (iov_iter_rw(iter) == READ); 334 bool is_read = (iov_iter_rw(iter) == READ);
@@ -353,6 +354,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
353 dio->multi_bio = false; 354 dio->multi_bio = false;
354 dio->should_dirty = is_read && (iter->type == ITER_IOVEC); 355 dio->should_dirty = is_read && (iter->type == ITER_IOVEC);
355 356
357 blk_start_plug(&plug);
356 for (;;) { 358 for (;;) {
357 bio->bi_bdev = bdev; 359 bio->bi_bdev = bdev;
358 bio->bi_iter.bi_sector = pos >> 9; 360 bio->bi_iter.bi_sector = pos >> 9;
@@ -394,6 +396,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
394 submit_bio(bio); 396 submit_bio(bio);
395 bio = bio_alloc(GFP_KERNEL, nr_pages); 397 bio = bio_alloc(GFP_KERNEL, nr_pages);
396 } 398 }
399 blk_finish_plug(&plug);
397 400
398 if (!dio->is_sync) 401 if (!dio->is_sync)
399 return -EIOCBQUEUED; 402 return -EIOCBQUEUED;
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 63d197724519..ff0b0be92d61 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -273,6 +273,8 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
273 unsigned long flags; 273 unsigned long flags;
274 274
275 while (1) { 275 while (1) {
276 void *wtag;
277
276 spin_lock_irqsave(lock, flags); 278 spin_lock_irqsave(lock, flags);
277 if (list_empty(list)) 279 if (list_empty(list))
278 break; 280 break;
@@ -299,11 +301,13 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
299 spin_unlock_irqrestore(lock, flags); 301 spin_unlock_irqrestore(lock, flags);
300 302
301 /* 303 /*
302 * we don't want to call the ordered free functions 304 * We don't want to call the ordered free functions with the
303 * with the lock held though 305 * lock held though. Save the work as tag for the trace event,
306 * because the callback could free the structure.
304 */ 307 */
308 wtag = work;
305 work->ordered_free(work); 309 work->ordered_free(work);
306 trace_btrfs_all_work_done(work); 310 trace_btrfs_all_work_done(wq->fs_info, wtag);
307 } 311 }
308 spin_unlock_irqrestore(lock, flags); 312 spin_unlock_irqrestore(lock, flags);
309} 313}
@@ -311,6 +315,7 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
311static void normal_work_helper(struct btrfs_work *work) 315static void normal_work_helper(struct btrfs_work *work)
312{ 316{
313 struct __btrfs_workqueue *wq; 317 struct __btrfs_workqueue *wq;
318 void *wtag;
314 int need_order = 0; 319 int need_order = 0;
315 320
316 /* 321 /*
@@ -324,6 +329,8 @@ static void normal_work_helper(struct btrfs_work *work)
324 if (work->ordered_func) 329 if (work->ordered_func)
325 need_order = 1; 330 need_order = 1;
326 wq = work->wq; 331 wq = work->wq;
332 /* Safe for tracepoints in case work gets freed by the callback */
333 wtag = work;
327 334
328 trace_btrfs_work_sched(work); 335 trace_btrfs_work_sched(work);
329 thresh_exec_hook(wq); 336 thresh_exec_hook(wq);
@@ -333,7 +340,7 @@ static void normal_work_helper(struct btrfs_work *work)
333 run_ordered_work(wq); 340 run_ordered_work(wq);
334 } 341 }
335 if (!need_order) 342 if (!need_order)
336 trace_btrfs_all_work_done(work); 343 trace_btrfs_all_work_done(wq->fs_info, wtag);
337} 344}
338 345
339void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func, 346void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e97302f437a1..dcd2e798767e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2522,11 +2522,11 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2522 if (ref && ref->seq && 2522 if (ref && ref->seq &&
2523 btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) { 2523 btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) {
2524 spin_unlock(&locked_ref->lock); 2524 spin_unlock(&locked_ref->lock);
2525 btrfs_delayed_ref_unlock(locked_ref);
2526 spin_lock(&delayed_refs->lock); 2525 spin_lock(&delayed_refs->lock);
2527 locked_ref->processing = 0; 2526 locked_ref->processing = 0;
2528 delayed_refs->num_heads_ready++; 2527 delayed_refs->num_heads_ready++;
2529 spin_unlock(&delayed_refs->lock); 2528 spin_unlock(&delayed_refs->lock);
2529 btrfs_delayed_ref_unlock(locked_ref);
2530 locked_ref = NULL; 2530 locked_ref = NULL;
2531 cond_resched(); 2531 cond_resched();
2532 count++; 2532 count++;
@@ -2572,7 +2572,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2572 */ 2572 */
2573 if (must_insert_reserved) 2573 if (must_insert_reserved)
2574 locked_ref->must_insert_reserved = 1; 2574 locked_ref->must_insert_reserved = 1;
2575 spin_lock(&delayed_refs->lock);
2575 locked_ref->processing = 0; 2576 locked_ref->processing = 0;
2577 delayed_refs->num_heads_ready++;
2578 spin_unlock(&delayed_refs->lock);
2576 btrfs_debug(fs_info, 2579 btrfs_debug(fs_info,
2577 "run_delayed_extent_op returned %d", 2580 "run_delayed_extent_op returned %d",
2578 ret); 2581 ret);
@@ -7384,7 +7387,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
7384 7387
7385 spin_unlock(&cluster->refill_lock); 7388 spin_unlock(&cluster->refill_lock);
7386 7389
7387 down_read(&used_bg->data_rwsem); 7390 /* We should only have one-level nested. */
7391 down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
7388 7392
7389 spin_lock(&cluster->refill_lock); 7393 spin_lock(&cluster->refill_lock);
7390 if (used_bg == cluster->block_group) 7394 if (used_bg == cluster->block_group)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f2b281ad7af6..4e024260ad71 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7059,7 +7059,7 @@ insert:
7059 write_unlock(&em_tree->lock); 7059 write_unlock(&em_tree->lock);
7060out: 7060out:
7061 7061
7062 trace_btrfs_get_extent(root, em); 7062 trace_btrfs_get_extent(root, inode, em);
7063 7063
7064 btrfs_free_path(path); 7064 btrfs_free_path(path);
7065 if (trans) { 7065 if (trans) {
@@ -7623,11 +7623,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
7623 * within our reservation, otherwise we need to adjust our inode 7623 * within our reservation, otherwise we need to adjust our inode
7624 * counter appropriately. 7624 * counter appropriately.
7625 */ 7625 */
7626 if (dio_data->outstanding_extents) { 7626 if (dio_data->outstanding_extents >= num_extents) {
7627 dio_data->outstanding_extents -= num_extents; 7627 dio_data->outstanding_extents -= num_extents;
7628 } else { 7628 } else {
7629 /*
7630 * If dio write length has been split due to no large enough
7631 * contiguous space, we need to compensate our inode counter
7632 * appropriately.
7633 */
7634 u64 num_needed = num_extents - dio_data->outstanding_extents;
7635
7629 spin_lock(&BTRFS_I(inode)->lock); 7636 spin_lock(&BTRFS_I(inode)->lock);
7630 BTRFS_I(inode)->outstanding_extents += num_extents; 7637 BTRFS_I(inode)->outstanding_extents += num_needed;
7631 spin_unlock(&BTRFS_I(inode)->lock); 7638 spin_unlock(&BTRFS_I(inode)->lock);
7632 } 7639 }
7633} 7640}
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f10bf5213ed8..eeffff84f280 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -37,6 +37,7 @@
37 */ 37 */
38#define LOG_INODE_ALL 0 38#define LOG_INODE_ALL 0
39#define LOG_INODE_EXISTS 1 39#define LOG_INODE_EXISTS 1
40#define LOG_OTHER_INODE 2
40 41
41/* 42/*
42 * directory trouble cases 43 * directory trouble cases
@@ -4641,7 +4642,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4641 if (S_ISDIR(inode->i_mode) || 4642 if (S_ISDIR(inode->i_mode) ||
4642 (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, 4643 (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
4643 &BTRFS_I(inode)->runtime_flags) && 4644 &BTRFS_I(inode)->runtime_flags) &&
4644 inode_only == LOG_INODE_EXISTS)) 4645 inode_only >= LOG_INODE_EXISTS))
4645 max_key.type = BTRFS_XATTR_ITEM_KEY; 4646 max_key.type = BTRFS_XATTR_ITEM_KEY;
4646 else 4647 else
4647 max_key.type = (u8)-1; 4648 max_key.type = (u8)-1;
@@ -4665,7 +4666,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4665 return ret; 4666 return ret;
4666 } 4667 }
4667 4668
4668 mutex_lock(&BTRFS_I(inode)->log_mutex); 4669 if (inode_only == LOG_OTHER_INODE) {
4670 inode_only = LOG_INODE_EXISTS;
4671 mutex_lock_nested(&BTRFS_I(inode)->log_mutex,
4672 SINGLE_DEPTH_NESTING);
4673 } else {
4674 mutex_lock(&BTRFS_I(inode)->log_mutex);
4675 }
4669 4676
4670 /* 4677 /*
4671 * a brute force approach to making sure we get the most uptodate 4678 * a brute force approach to making sure we get the most uptodate
@@ -4817,7 +4824,7 @@ again:
4817 * unpin it. 4824 * unpin it.
4818 */ 4825 */
4819 err = btrfs_log_inode(trans, root, other_inode, 4826 err = btrfs_log_inode(trans, root, other_inode,
4820 LOG_INODE_EXISTS, 4827 LOG_OTHER_INODE,
4821 0, LLONG_MAX, ctx); 4828 0, LLONG_MAX, ctx);
4822 iput(other_inode); 4829 iput(other_inode);
4823 if (err) 4830 if (err)
diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 161342b73ce5..726f928238d0 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -352,7 +352,5 @@ skip:
352 352
353out: 353out:
354 btrfs_free_path(path); 354 btrfs_free_path(path);
355 if (ret) 355 return ret;
356 btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
357 return 0;
358} 356}
diff --git a/fs/buffer.c b/fs/buffer.c
index d21771fcf7d3..0e87401cf335 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1660,7 +1660,7 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len)
1660 head = page_buffers(page); 1660 head = page_buffers(page);
1661 bh = head; 1661 bh = head;
1662 do { 1662 do {
1663 if (!buffer_mapped(bh)) 1663 if (!buffer_mapped(bh) || (bh->b_blocknr < block))
1664 goto next; 1664 goto next;
1665 if (bh->b_blocknr >= block + len) 1665 if (bh->b_blocknr >= block + len)
1666 break; 1666 break;
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 9cd0c0ea7cdb..e4b066cd912a 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -502,9 +502,9 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
502 dout(" head snapc %p has %d dirty pages\n", 502 dout(" head snapc %p has %d dirty pages\n",
503 snapc, ci->i_wrbuffer_ref_head); 503 snapc, ci->i_wrbuffer_ref_head);
504 if (truncate_size) 504 if (truncate_size)
505 *truncate_size = capsnap->truncate_size; 505 *truncate_size = ci->i_truncate_size;
506 if (truncate_seq) 506 if (truncate_seq)
507 *truncate_seq = capsnap->truncate_seq; 507 *truncate_seq = ci->i_truncate_seq;
508 } 508 }
509 spin_unlock(&ci->i_ceph_lock); 509 spin_unlock(&ci->i_ceph_lock);
510 return snapc; 510 return snapc;
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index baea866a6751..94fd76d04683 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2591,8 +2591,13 @@ int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
2591 add_wait_queue(&ci->i_cap_wq, &wait); 2591 add_wait_queue(&ci->i_cap_wq, &wait);
2592 2592
2593 while (!try_get_cap_refs(ci, need, want, endoff, 2593 while (!try_get_cap_refs(ci, need, want, endoff,
2594 true, &_got, &err)) 2594 true, &_got, &err)) {
2595 if (signal_pending(current)) {
2596 ret = -ERESTARTSYS;
2597 break;
2598 }
2595 wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); 2599 wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
2600 }
2596 2601
2597 remove_wait_queue(&ci->i_cap_wq, &wait); 2602 remove_wait_queue(&ci->i_cap_wq, &wait);
2598 2603
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index d7a93696663b..8ab1fdf0bd49 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1230,7 +1230,8 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
1230 struct ceph_mds_client *mdsc = 1230 struct ceph_mds_client *mdsc =
1231 ceph_sb_to_client(dir->i_sb)->mdsc; 1231 ceph_sb_to_client(dir->i_sb)->mdsc;
1232 struct ceph_mds_request *req; 1232 struct ceph_mds_request *req;
1233 int op, mask, err; 1233 int op, err;
1234 u32 mask;
1234 1235
1235 if (flags & LOOKUP_RCU) 1236 if (flags & LOOKUP_RCU)
1236 return -ECHILD; 1237 return -ECHILD;
@@ -1245,7 +1246,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
1245 mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED; 1246 mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
1246 if (ceph_security_xattr_wanted(dir)) 1247 if (ceph_security_xattr_wanted(dir))
1247 mask |= CEPH_CAP_XATTR_SHARED; 1248 mask |= CEPH_CAP_XATTR_SHARED;
1248 req->r_args.getattr.mask = mask; 1249 req->r_args.getattr.mask = cpu_to_le32(mask);
1249 1250
1250 err = ceph_mdsc_do_request(mdsc, NULL, req); 1251 err = ceph_mdsc_do_request(mdsc, NULL, req);
1251 switch (err) { 1252 switch (err) {
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 398e5328b309..5e659d054b40 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -305,7 +305,8 @@ static int frag_tree_split_cmp(const void *l, const void *r)
305{ 305{
306 struct ceph_frag_tree_split *ls = (struct ceph_frag_tree_split*)l; 306 struct ceph_frag_tree_split *ls = (struct ceph_frag_tree_split*)l;
307 struct ceph_frag_tree_split *rs = (struct ceph_frag_tree_split*)r; 307 struct ceph_frag_tree_split *rs = (struct ceph_frag_tree_split*)r;
308 return ceph_frag_compare(ls->frag, rs->frag); 308 return ceph_frag_compare(le32_to_cpu(ls->frag),
309 le32_to_cpu(rs->frag));
309} 310}
310 311
311static bool is_frag_child(u32 f, struct ceph_inode_frag *frag) 312static bool is_frag_child(u32 f, struct ceph_inode_frag *frag)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 4f49253387a0..c9d2e553a6c4 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -288,12 +288,13 @@ static int parse_reply_info_extra(void **p, void *end,
288 struct ceph_mds_reply_info_parsed *info, 288 struct ceph_mds_reply_info_parsed *info,
289 u64 features) 289 u64 features)
290{ 290{
291 if (info->head->op == CEPH_MDS_OP_GETFILELOCK) 291 u32 op = le32_to_cpu(info->head->op);
292
293 if (op == CEPH_MDS_OP_GETFILELOCK)
292 return parse_reply_info_filelock(p, end, info, features); 294 return parse_reply_info_filelock(p, end, info, features);
293 else if (info->head->op == CEPH_MDS_OP_READDIR || 295 else if (op == CEPH_MDS_OP_READDIR || op == CEPH_MDS_OP_LSSNAP)
294 info->head->op == CEPH_MDS_OP_LSSNAP)
295 return parse_reply_info_dir(p, end, info, features); 296 return parse_reply_info_dir(p, end, info, features);
296 else if (info->head->op == CEPH_MDS_OP_CREATE) 297 else if (op == CEPH_MDS_OP_CREATE)
297 return parse_reply_info_create(p, end, info, features); 298 return parse_reply_info_create(p, end, info, features);
298 else 299 else
299 return -EIO; 300 return -EIO;
@@ -2106,6 +2107,11 @@ static int __do_request(struct ceph_mds_client *mdsc,
2106 dout("do_request mdsmap err %d\n", err); 2107 dout("do_request mdsmap err %d\n", err);
2107 goto finish; 2108 goto finish;
2108 } 2109 }
2110 if (mdsc->mdsmap->m_epoch == 0) {
2111 dout("do_request no mdsmap, waiting for map\n");
2112 list_add(&req->r_wait, &mdsc->waiting_for_map);
2113 goto finish;
2114 }
2109 if (!(mdsc->fsc->mount_options->flags & 2115 if (!(mdsc->fsc->mount_options->flags &
2110 CEPH_MOUNT_OPT_MOUNTWAIT) && 2116 CEPH_MOUNT_OPT_MOUNTWAIT) &&
2111 !ceph_mdsmap_is_cluster_available(mdsc->mdsmap)) { 2117 !ceph_mdsmap_is_cluster_available(mdsc->mdsmap)) {
diff --git a/fs/coredump.c b/fs/coredump.c
index e525b6017cdf..ae6b05629ca1 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -833,3 +833,21 @@ int dump_align(struct coredump_params *cprm, int align)
833 return mod ? dump_skip(cprm, align - mod) : 1; 833 return mod ? dump_skip(cprm, align - mod) : 1;
834} 834}
835EXPORT_SYMBOL(dump_align); 835EXPORT_SYMBOL(dump_align);
836
837/*
838 * Ensures that file size is big enough to contain the current file
839 * postion. This prevents gdb from complaining about a truncated file
840 * if the last "write" to the file was dump_skip.
841 */
842void dump_truncate(struct coredump_params *cprm)
843{
844 struct file *file = cprm->file;
845 loff_t offset;
846
847 if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
848 offset = file->f_op->llseek(file, 0, SEEK_CUR);
849 if (i_size_read(file->f_mapping->host) < offset)
850 do_truncate(file->f_path.dentry, offset, 0, file);
851 }
852}
853EXPORT_SYMBOL(dump_truncate);
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 6eeea1dcba41..95cd4c3b06c3 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -248,7 +248,8 @@ retry:
248 goto out; 248 goto out;
249 249
250 if (fscrypt_dummy_context_enabled(inode)) { 250 if (fscrypt_dummy_context_enabled(inode)) {
251 memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE); 251 memset(raw_key, 0x42, keysize/2);
252 memset(raw_key+keysize/2, 0x24, keysize - (keysize/2));
252 goto got_key; 253 goto got_key;
253 } 254 }
254 255
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 6ed7c2eebeec..d6cd7ea4851d 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -179,6 +179,11 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
179 BUG_ON(1); 179 BUG_ON(1);
180 } 180 }
181 181
182 /* No restrictions on file types which are never encrypted */
183 if (!S_ISREG(child->i_mode) && !S_ISDIR(child->i_mode) &&
184 !S_ISLNK(child->i_mode))
185 return 1;
186
182 /* no restrictions if the parent directory is not encrypted */ 187 /* no restrictions if the parent directory is not encrypted */
183 if (!parent->i_sb->s_cop->is_encrypted(parent)) 188 if (!parent->i_sb->s_cop->is_encrypted(parent))
184 return 1; 189 return 1;
diff --git a/fs/dax.c b/fs/dax.c
index 5c74f60d0a50..ddcddfeaa03b 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -691,8 +691,8 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,
691 pgoff_t index, unsigned long pfn) 691 pgoff_t index, unsigned long pfn)
692{ 692{
693 struct vm_area_struct *vma; 693 struct vm_area_struct *vma;
694 pte_t *ptep; 694 pte_t pte, *ptep = NULL;
695 pte_t pte; 695 pmd_t *pmdp = NULL;
696 spinlock_t *ptl; 696 spinlock_t *ptl;
697 bool changed; 697 bool changed;
698 698
@@ -707,21 +707,42 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,
707 707
708 address = pgoff_address(index, vma); 708 address = pgoff_address(index, vma);
709 changed = false; 709 changed = false;
710 if (follow_pte(vma->vm_mm, address, &ptep, &ptl)) 710 if (follow_pte_pmd(vma->vm_mm, address, &ptep, &pmdp, &ptl))
711 continue; 711 continue;
712 if (pfn != pte_pfn(*ptep))
713 goto unlock;
714 if (!pte_dirty(*ptep) && !pte_write(*ptep))
715 goto unlock;
716 712
717 flush_cache_page(vma, address, pfn); 713 if (pmdp) {
718 pte = ptep_clear_flush(vma, address, ptep); 714#ifdef CONFIG_FS_DAX_PMD
719 pte = pte_wrprotect(pte); 715 pmd_t pmd;
720 pte = pte_mkclean(pte); 716
721 set_pte_at(vma->vm_mm, address, ptep, pte); 717 if (pfn != pmd_pfn(*pmdp))
722 changed = true; 718 goto unlock_pmd;
723unlock: 719 if (!pmd_dirty(*pmdp) && !pmd_write(*pmdp))
724 pte_unmap_unlock(ptep, ptl); 720 goto unlock_pmd;
721
722 flush_cache_page(vma, address, pfn);
723 pmd = pmdp_huge_clear_flush(vma, address, pmdp);
724 pmd = pmd_wrprotect(pmd);
725 pmd = pmd_mkclean(pmd);
726 set_pmd_at(vma->vm_mm, address, pmdp, pmd);
727 changed = true;
728unlock_pmd:
729 spin_unlock(ptl);
730#endif
731 } else {
732 if (pfn != pte_pfn(*ptep))
733 goto unlock_pte;
734 if (!pte_dirty(*ptep) && !pte_write(*ptep))
735 goto unlock_pte;
736
737 flush_cache_page(vma, address, pfn);
738 pte = ptep_clear_flush(vma, address, ptep);
739 pte = pte_wrprotect(pte);
740 pte = pte_mkclean(pte);
741 set_pte_at(vma->vm_mm, address, ptep, pte);
742 changed = true;
743unlock_pte:
744 pte_unmap_unlock(ptep, ptl);
745 }
725 746
726 if (changed) 747 if (changed)
727 mmu_notifier_invalidate_page(vma->vm_mm, address); 748 mmu_notifier_invalidate_page(vma->vm_mm, address);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index aeae8c063451..c87bae4376b8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -906,6 +906,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
906 struct buffer_head *map_bh) 906 struct buffer_head *map_bh)
907{ 907{
908 const unsigned blkbits = sdio->blkbits; 908 const unsigned blkbits = sdio->blkbits;
909 const unsigned i_blkbits = blkbits + sdio->blkfactor;
909 int ret = 0; 910 int ret = 0;
910 911
911 while (sdio->block_in_file < sdio->final_block_in_request) { 912 while (sdio->block_in_file < sdio->final_block_in_request) {
@@ -949,7 +950,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
949 clean_bdev_aliases( 950 clean_bdev_aliases(
950 map_bh->b_bdev, 951 map_bh->b_bdev,
951 map_bh->b_blocknr, 952 map_bh->b_blocknr,
952 map_bh->b_size >> blkbits); 953 map_bh->b_size >> i_blkbits);
953 } 954 }
954 955
955 if (!sdio->blkfactor) 956 if (!sdio->blkfactor)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0738f48293cc..0d8802453758 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -713,8 +713,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
713 } 713 }
714 sector = SECTOR_FROM_BLOCK(blkstart); 714 sector = SECTOR_FROM_BLOCK(blkstart);
715 715
716 if (sector & (bdev_zone_size(bdev) - 1) || 716 if (sector & (bdev_zone_sectors(bdev) - 1) ||
717 nr_sects != bdev_zone_size(bdev)) { 717 nr_sects != bdev_zone_sectors(bdev)) {
718 f2fs_msg(sbi->sb, KERN_INFO, 718 f2fs_msg(sbi->sb, KERN_INFO,
719 "(%d) %s: Unaligned discard attempted (block %x + %x)", 719 "(%d) %s: Unaligned discard attempted (block %x + %x)",
720 devi, sbi->s_ndevs ? FDEV(devi).path: "", 720 devi, sbi->s_ndevs ? FDEV(devi).path: "",
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 702638e21c76..46fd30d8af77 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1553,16 +1553,16 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
1553 return 0; 1553 return 0;
1554 1554
1555 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz != 1555 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
1556 SECTOR_TO_BLOCK(bdev_zone_size(bdev))) 1556 SECTOR_TO_BLOCK(bdev_zone_sectors(bdev)))
1557 return -EINVAL; 1557 return -EINVAL;
1558 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_size(bdev)); 1558 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_sectors(bdev));
1559 if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz != 1559 if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
1560 __ilog2_u32(sbi->blocks_per_blkz)) 1560 __ilog2_u32(sbi->blocks_per_blkz))
1561 return -EINVAL; 1561 return -EINVAL;
1562 sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz); 1562 sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
1563 FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >> 1563 FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
1564 sbi->log_blocks_per_blkz; 1564 sbi->log_blocks_per_blkz;
1565 if (nr_sectors & (bdev_zone_size(bdev) - 1)) 1565 if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
1566 FDEV(devi).nr_blkz++; 1566 FDEV(devi).nr_blkz++;
1567 1567
1568 FDEV(devi).blkz_type = kmalloc(FDEV(devi).nr_blkz, GFP_KERNEL); 1568 FDEV(devi).blkz_type = kmalloc(FDEV(devi).nr_blkz, GFP_KERNEL);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 70ea57c7b6bb..4e06a27ed7f8 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2025,7 +2025,6 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head)
2025 struct fuse_req *req; 2025 struct fuse_req *req;
2026 req = list_entry(head->next, struct fuse_req, list); 2026 req = list_entry(head->next, struct fuse_req, list);
2027 req->out.h.error = -ECONNABORTED; 2027 req->out.h.error = -ECONNABORTED;
2028 clear_bit(FR_PENDING, &req->flags);
2029 clear_bit(FR_SENT, &req->flags); 2028 clear_bit(FR_SENT, &req->flags);
2030 list_del_init(&req->list); 2029 list_del_init(&req->list);
2031 request_end(fc, req); 2030 request_end(fc, req);
@@ -2103,6 +2102,8 @@ void fuse_abort_conn(struct fuse_conn *fc)
2103 spin_lock(&fiq->waitq.lock); 2102 spin_lock(&fiq->waitq.lock);
2104 fiq->connected = 0; 2103 fiq->connected = 0;
2105 list_splice_init(&fiq->pending, &to_end2); 2104 list_splice_init(&fiq->pending, &to_end2);
2105 list_for_each_entry(req, &to_end2, list)
2106 clear_bit(FR_PENDING, &req->flags);
2106 while (forget_pending(fiq)) 2107 while (forget_pending(fiq))
2107 kfree(dequeue_forget(fiq, 1, NULL)); 2108 kfree(dequeue_forget(fiq, 1, NULL));
2108 wake_up_all_locked(&fiq->waitq); 2109 wake_up_all_locked(&fiq->waitq);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 1f7c732f32b0..811fd8929a18 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -68,7 +68,7 @@ static u64 time_to_jiffies(u64 sec, u32 nsec)
68 if (sec || nsec) { 68 if (sec || nsec) {
69 struct timespec64 ts = { 69 struct timespec64 ts = {
70 sec, 70 sec,
71 max_t(u32, nsec, NSEC_PER_SEC - 1) 71 min_t(u32, nsec, NSEC_PER_SEC - 1)
72 }; 72 };
73 73
74 return get_jiffies_64() + timespec64_to_jiffies(&ts); 74 return get_jiffies_64() + timespec64_to_jiffies(&ts);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6dcbc5defb7a..ecc151697fd4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -38,7 +38,6 @@
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/file.h>
42#include <linux/string.h> 41#include <linux/string.h>
43#include <linux/ratelimit.h> 42#include <linux/ratelimit.h>
44#include <linux/printk.h> 43#include <linux/printk.h>
@@ -1083,7 +1082,8 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
1083 return nfs4_call_sync_sequence(clnt, server, msg, args, res); 1082 return nfs4_call_sync_sequence(clnt, server, msg, args, res);
1084} 1083}
1085 1084
1086static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) 1085static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo,
1086 unsigned long timestamp)
1087{ 1087{
1088 struct nfs_inode *nfsi = NFS_I(dir); 1088 struct nfs_inode *nfsi = NFS_I(dir);
1089 1089
@@ -1099,6 +1099,7 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
1099 NFS_INO_INVALID_ACL; 1099 NFS_INO_INVALID_ACL;
1100 } 1100 }
1101 dir->i_version = cinfo->after; 1101 dir->i_version = cinfo->after;
1102 nfsi->read_cache_jiffies = timestamp;
1102 nfsi->attr_gencount = nfs_inc_attr_generation_counter(); 1103 nfsi->attr_gencount = nfs_inc_attr_generation_counter();
1103 nfs_fscache_invalidate(dir); 1104 nfs_fscache_invalidate(dir);
1104 spin_unlock(&dir->i_lock); 1105 spin_unlock(&dir->i_lock);
@@ -2391,11 +2392,13 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
2391 nfs_fattr_map_and_free_names(server, &data->f_attr); 2392 nfs_fattr_map_and_free_names(server, &data->f_attr);
2392 2393
2393 if (o_arg->open_flags & O_CREAT) { 2394 if (o_arg->open_flags & O_CREAT) {
2394 update_changeattr(dir, &o_res->cinfo);
2395 if (o_arg->open_flags & O_EXCL) 2395 if (o_arg->open_flags & O_EXCL)
2396 data->file_created = 1; 2396 data->file_created = 1;
2397 else if (o_res->cinfo.before != o_res->cinfo.after) 2397 else if (o_res->cinfo.before != o_res->cinfo.after)
2398 data->file_created = 1; 2398 data->file_created = 1;
2399 if (data->file_created || dir->i_version != o_res->cinfo.after)
2400 update_changeattr(dir, &o_res->cinfo,
2401 o_res->f_attr->time_start);
2399 } 2402 }
2400 if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) 2403 if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0)
2401 server->caps &= ~NFS_CAP_POSIX_LOCK; 2404 server->caps &= ~NFS_CAP_POSIX_LOCK;
@@ -4073,11 +4076,12 @@ static int _nfs4_proc_remove(struct inode *dir, const struct qstr *name)
4073 .rpc_argp = &args, 4076 .rpc_argp = &args,
4074 .rpc_resp = &res, 4077 .rpc_resp = &res,
4075 }; 4078 };
4079 unsigned long timestamp = jiffies;
4076 int status; 4080 int status;
4077 4081
4078 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1); 4082 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1);
4079 if (status == 0) 4083 if (status == 0)
4080 update_changeattr(dir, &res.cinfo); 4084 update_changeattr(dir, &res.cinfo, timestamp);
4081 return status; 4085 return status;
4082} 4086}
4083 4087
@@ -4125,7 +4129,8 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
4125 if (nfs4_async_handle_error(task, res->server, NULL, 4129 if (nfs4_async_handle_error(task, res->server, NULL,
4126 &data->timeout) == -EAGAIN) 4130 &data->timeout) == -EAGAIN)
4127 return 0; 4131 return 0;
4128 update_changeattr(dir, &res->cinfo); 4132 if (task->tk_status == 0)
4133 update_changeattr(dir, &res->cinfo, res->dir_attr->time_start);
4129 return 1; 4134 return 1;
4130} 4135}
4131 4136
@@ -4159,8 +4164,11 @@ static int nfs4_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
4159 if (nfs4_async_handle_error(task, res->server, NULL, &data->timeout) == -EAGAIN) 4164 if (nfs4_async_handle_error(task, res->server, NULL, &data->timeout) == -EAGAIN)
4160 return 0; 4165 return 0;
4161 4166
4162 update_changeattr(old_dir, &res->old_cinfo); 4167 if (task->tk_status == 0) {
4163 update_changeattr(new_dir, &res->new_cinfo); 4168 update_changeattr(old_dir, &res->old_cinfo, res->old_fattr->time_start);
4169 if (new_dir != old_dir)
4170 update_changeattr(new_dir, &res->new_cinfo, res->new_fattr->time_start);
4171 }
4164 return 1; 4172 return 1;
4165} 4173}
4166 4174
@@ -4197,7 +4205,7 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct
4197 4205
4198 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); 4206 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
4199 if (!status) { 4207 if (!status) {
4200 update_changeattr(dir, &res.cinfo); 4208 update_changeattr(dir, &res.cinfo, res.fattr->time_start);
4201 status = nfs_post_op_update_inode(inode, res.fattr); 4209 status = nfs_post_op_update_inode(inode, res.fattr);
4202 if (!status) 4210 if (!status)
4203 nfs_setsecurity(inode, res.fattr, res.label); 4211 nfs_setsecurity(inode, res.fattr, res.label);
@@ -4272,7 +4280,8 @@ static int nfs4_do_create(struct inode *dir, struct dentry *dentry, struct nfs4_
4272 int status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &data->msg, 4280 int status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &data->msg,
4273 &data->arg.seq_args, &data->res.seq_res, 1); 4281 &data->arg.seq_args, &data->res.seq_res, 1);
4274 if (status == 0) { 4282 if (status == 0) {
4275 update_changeattr(dir, &data->res.dir_cinfo); 4283 update_changeattr(dir, &data->res.dir_cinfo,
4284 data->res.fattr->time_start);
4276 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, data->res.label); 4285 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, data->res.label);
4277 } 4286 }
4278 return status; 4287 return status;
@@ -6127,7 +6136,6 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
6127 p->server = server; 6136 p->server = server;
6128 atomic_inc(&lsp->ls_count); 6137 atomic_inc(&lsp->ls_count);
6129 p->ctx = get_nfs_open_context(ctx); 6138 p->ctx = get_nfs_open_context(ctx);
6130 get_file(fl->fl_file);
6131 memcpy(&p->fl, fl, sizeof(p->fl)); 6139 memcpy(&p->fl, fl, sizeof(p->fl));
6132 return p; 6140 return p;
6133out_free_seqid: 6141out_free_seqid:
@@ -6240,7 +6248,6 @@ static void nfs4_lock_release(void *calldata)
6240 nfs_free_seqid(data->arg.lock_seqid); 6248 nfs_free_seqid(data->arg.lock_seqid);
6241 nfs4_put_lock_state(data->lsp); 6249 nfs4_put_lock_state(data->lsp);
6242 put_nfs_open_context(data->ctx); 6250 put_nfs_open_context(data->ctx);
6243 fput(data->fl.fl_file);
6244 kfree(data); 6251 kfree(data);
6245 dprintk("%s: done!\n", __func__); 6252 dprintk("%s: done!\n", __func__);
6246} 6253}
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 1d152f4470cd..90e6193ce6be 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1729,7 +1729,6 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1729 break; 1729 break;
1730 case -NFS4ERR_STALE_CLIENTID: 1730 case -NFS4ERR_STALE_CLIENTID:
1731 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1731 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1732 nfs4_state_clear_reclaim_reboot(clp);
1733 nfs4_state_start_reclaim_reboot(clp); 1732 nfs4_state_start_reclaim_reboot(clp);
1734 break; 1733 break;
1735 case -NFS4ERR_EXPIRED: 1734 case -NFS4ERR_EXPIRED:
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 7ecf16be4a44..8fae53ce21d1 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2440,7 +2440,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
2440 p++; /* to be backfilled later */ 2440 p++; /* to be backfilled later */
2441 2441
2442 if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { 2442 if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
2443 u32 *supp = nfsd_suppattrs[minorversion]; 2443 u32 supp[3];
2444
2445 memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp));
2444 2446
2445 if (!IS_POSIXACL(dentry->d_inode)) 2447 if (!IS_POSIXACL(dentry->d_inode))
2446 supp[0] &= ~FATTR4_WORD0_ACL; 2448 supp[0] &= ~FATTR4_WORD0_ACL;
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index d3fea0bd89e2..6043306e8e21 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -510,18 +510,6 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group)
510 } 510 }
511} 511}
512 512
513void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old)
514{
515 assert_spin_locked(&old->lock);
516 new->inode = old->inode;
517 new->mnt = old->mnt;
518 if (old->group)
519 fsnotify_get_group(old->group);
520 new->group = old->group;
521 new->mask = old->mask;
522 new->free_mark = old->free_mark;
523}
524
525/* 513/*
526 * Nothing fancy, just initialize lists and locks and counters. 514 * Nothing fancy, just initialize lists and locks and counters.
527 */ 515 */
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 83d576f6a287..77d1632e905d 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3303,6 +3303,16 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
3303 mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, 3303 mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name,
3304 lockres->l_level, new_level); 3304 lockres->l_level, new_level);
3305 3305
3306 /*
3307 * On DLM_LKF_VALBLK, fsdlm behaves differently with o2cb. It always
3308 * expects DLM_LKF_VALBLK being set if the LKB has LVB, so that
3309 * we can recover correctly from node failure. Otherwise, we may get
3310 * invalid LVB in LKB, but without DLM_SBF_VALNOTVALID being set.
3311 */
3312 if (!ocfs2_is_o2cb_active() &&
3313 lockres->l_ops->flags & LOCK_TYPE_USES_LVB)
3314 lvb = 1;
3315
3306 if (lvb) 3316 if (lvb)
3307 dlm_flags |= DLM_LKF_VALBLK; 3317 dlm_flags |= DLM_LKF_VALBLK;
3308 3318
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 52c07346bea3..820359096c7a 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -48,6 +48,12 @@ static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
48 */ 48 */
49static struct ocfs2_stack_plugin *active_stack; 49static struct ocfs2_stack_plugin *active_stack;
50 50
51inline int ocfs2_is_o2cb_active(void)
52{
53 return !strcmp(active_stack->sp_name, OCFS2_STACK_PLUGIN_O2CB);
54}
55EXPORT_SYMBOL_GPL(ocfs2_is_o2cb_active);
56
51static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name) 57static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name)
52{ 58{
53 struct ocfs2_stack_plugin *p; 59 struct ocfs2_stack_plugin *p;
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index f2dce10fae54..e3036e1790e8 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -298,6 +298,9 @@ void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_p
298int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); 298int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
299void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin); 299void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
300 300
301/* In ocfs2_downconvert_lock(), we need to know which stack we are using */
302int ocfs2_is_o2cb_active(void);
303
301extern struct kset *ocfs2_kset; 304extern struct kset *ocfs2_kset;
302 305
303#endif /* STACKGLUE_H */ 306#endif /* STACKGLUE_H */
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 9ad48d9202a9..023bb0b03352 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -154,29 +154,38 @@ out_err:
154static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, 154static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d,
155 struct dentry **ret) 155 struct dentry **ret)
156{ 156{
157 const char *s = d->name.name; 157 /* Counting down from the end, since the prefix can change */
158 size_t rem = d->name.len - 1;
158 struct dentry *dentry = NULL; 159 struct dentry *dentry = NULL;
159 int err; 160 int err;
160 161
161 if (*s != '/') 162 if (d->name.name[0] != '/')
162 return ovl_lookup_single(base, d, d->name.name, d->name.len, 163 return ovl_lookup_single(base, d, d->name.name, d->name.len,
163 0, "", ret); 164 0, "", ret);
164 165
165 while (*s++ == '/' && !IS_ERR_OR_NULL(base) && d_can_lookup(base)) { 166 while (!IS_ERR_OR_NULL(base) && d_can_lookup(base)) {
167 const char *s = d->name.name + d->name.len - rem;
166 const char *next = strchrnul(s, '/'); 168 const char *next = strchrnul(s, '/');
167 size_t slen = strlen(s); 169 size_t thislen = next - s;
170 bool end = !next[0];
168 171
169 if (WARN_ON(slen > d->name.len) || 172 /* Verify we did not go off the rails */
170 WARN_ON(strcmp(d->name.name + d->name.len - slen, s))) 173 if (WARN_ON(s[-1] != '/'))
171 return -EIO; 174 return -EIO;
172 175
173 err = ovl_lookup_single(base, d, s, next - s, 176 err = ovl_lookup_single(base, d, s, thislen,
174 d->name.len - slen, next, &base); 177 d->name.len - rem, next, &base);
175 dput(dentry); 178 dput(dentry);
176 if (err) 179 if (err)
177 return err; 180 return err;
178 dentry = base; 181 dentry = base;
179 s = next; 182 if (end)
183 break;
184
185 rem -= thislen + 1;
186
187 if (WARN_ON(rem >= d->name.len))
188 return -EIO;
180 } 189 }
181 *ret = dentry; 190 *ret = dentry;
182 return 0; 191 return 0;
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 595522022aca..c9d48dc78495 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -922,11 +922,10 @@ int simple_set_acl(struct inode *inode, struct posix_acl *acl, int type)
922 int error; 922 int error;
923 923
924 if (type == ACL_TYPE_ACCESS) { 924 if (type == ACL_TYPE_ACCESS) {
925 error = posix_acl_equiv_mode(acl, &inode->i_mode); 925 error = posix_acl_update_mode(inode,
926 if (error < 0) 926 &inode->i_mode, &acl);
927 return 0; 927 if (error)
928 if (error == 0) 928 return error;
929 acl = NULL;
930 } 929 }
931 930
932 inode->i_ctime = current_time(inode); 931 inode->i_ctime = current_time(inode);
diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
index 0a908ae7af13..b0d0623c83ed 100644
--- a/fs/ubifs/Kconfig
+++ b/fs/ubifs/Kconfig
@@ -53,7 +53,7 @@ config UBIFS_ATIME_SUPPORT
53 53
54config UBIFS_FS_ENCRYPTION 54config UBIFS_FS_ENCRYPTION
55 bool "UBIFS Encryption" 55 bool "UBIFS Encryption"
56 depends on UBIFS_FS 56 depends on UBIFS_FS && BLOCK
57 select FS_ENCRYPTION 57 select FS_ENCRYPTION
58 default n 58 default n
59 help 59 help
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 1c5331ac9614..528369f3e472 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -390,16 +390,6 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
390 dbg_gen("dent '%pd', mode %#hx in dir ino %lu", 390 dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
391 dentry, mode, dir->i_ino); 391 dentry, mode, dir->i_ino);
392 392
393 if (ubifs_crypt_is_encrypted(dir)) {
394 err = fscrypt_get_encryption_info(dir);
395 if (err)
396 return err;
397
398 if (!fscrypt_has_encryption_key(dir)) {
399 return -EPERM;
400 }
401 }
402
403 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); 393 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
404 if (err) 394 if (err)
405 return err; 395 return err;
@@ -741,17 +731,9 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
741 ubifs_assert(inode_is_locked(dir)); 731 ubifs_assert(inode_is_locked(dir));
742 ubifs_assert(inode_is_locked(inode)); 732 ubifs_assert(inode_is_locked(inode));
743 733
744 if (ubifs_crypt_is_encrypted(dir)) { 734 if (ubifs_crypt_is_encrypted(dir) &&
745 if (!fscrypt_has_permitted_context(dir, inode)) 735 !fscrypt_has_permitted_context(dir, inode))
746 return -EPERM; 736 return -EPERM;
747
748 err = fscrypt_get_encryption_info(inode);
749 if (err)
750 return err;
751
752 if (!fscrypt_has_encryption_key(inode))
753 return -EPERM;
754 }
755 737
756 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); 738 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
757 if (err) 739 if (err)
@@ -1000,17 +982,6 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1000 if (err) 982 if (err)
1001 return err; 983 return err;
1002 984
1003 if (ubifs_crypt_is_encrypted(dir)) {
1004 err = fscrypt_get_encryption_info(dir);
1005 if (err)
1006 goto out_budg;
1007
1008 if (!fscrypt_has_encryption_key(dir)) {
1009 err = -EPERM;
1010 goto out_budg;
1011 }
1012 }
1013
1014 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); 985 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1015 if (err) 986 if (err)
1016 goto out_budg; 987 goto out_budg;
@@ -1096,17 +1067,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
1096 return err; 1067 return err;
1097 } 1068 }
1098 1069
1099 if (ubifs_crypt_is_encrypted(dir)) {
1100 err = fscrypt_get_encryption_info(dir);
1101 if (err)
1102 goto out_budg;
1103
1104 if (!fscrypt_has_encryption_key(dir)) {
1105 err = -EPERM;
1106 goto out_budg;
1107 }
1108 }
1109
1110 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); 1070 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1111 if (err) 1071 if (err)
1112 goto out_budg; 1072 goto out_budg;
@@ -1231,18 +1191,6 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
1231 goto out_inode; 1191 goto out_inode;
1232 } 1192 }
1233 1193
1234 err = fscrypt_get_encryption_info(inode);
1235 if (err) {
1236 kfree(sd);
1237 goto out_inode;
1238 }
1239
1240 if (!fscrypt_has_encryption_key(inode)) {
1241 kfree(sd);
1242 err = -EPERM;
1243 goto out_inode;
1244 }
1245
1246 ostr.name = sd->encrypted_path; 1194 ostr.name = sd->encrypted_path;
1247 ostr.len = disk_link.len; 1195 ostr.len = disk_link.len;
1248 1196
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 78d713644df3..da519ba205f6 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -217,6 +217,9 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
217 case FS_IOC32_SETFLAGS: 217 case FS_IOC32_SETFLAGS:
218 cmd = FS_IOC_SETFLAGS; 218 cmd = FS_IOC_SETFLAGS;
219 break; 219 break;
220 case FS_IOC_SET_ENCRYPTION_POLICY:
221 case FS_IOC_GET_ENCRYPTION_POLICY:
222 break;
220 default: 223 default:
221 return -ENOIOCTLCMD; 224 return -ENOIOCTLCMD;
222 } 225 }
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index a459211a1c21..294519b98874 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -744,6 +744,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
744 744
745 } else { 745 } else {
746 data->compr_size = 0; 746 data->compr_size = 0;
747 out_len = compr_len;
747 } 748 }
748 749
749 dlen = UBIFS_DATA_NODE_SZ + out_len; 750 dlen = UBIFS_DATA_NODE_SZ + out_len;
@@ -1319,6 +1320,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
1319 dn->compr_type = cpu_to_le16(compr_type); 1320 dn->compr_type = cpu_to_le16(compr_type);
1320 dn->size = cpu_to_le32(*new_len); 1321 dn->size = cpu_to_le32(*new_len);
1321 *new_len = UBIFS_DATA_NODE_SZ + out_len; 1322 *new_len = UBIFS_DATA_NODE_SZ + out_len;
1323 err = 0;
1322out: 1324out:
1323 kfree(buf); 1325 kfree(buf);
1324 return err; 1326 return err;
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 74ae2de949df..709aa098dd46 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -34,6 +34,11 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include "ubifs.h" 35#include "ubifs.h"
36 36
37static int try_read_node(const struct ubifs_info *c, void *buf, int type,
38 int len, int lnum, int offs);
39static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
40 struct ubifs_zbranch *zbr, void *node);
41
37/* 42/*
38 * Returned codes of 'matches_name()' and 'fallible_matches_name()' functions. 43 * Returned codes of 'matches_name()' and 'fallible_matches_name()' functions.
39 * @NAME_LESS: name corresponding to the first argument is less than second 44 * @NAME_LESS: name corresponding to the first argument is less than second
@@ -402,7 +407,19 @@ static int tnc_read_hashed_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
402 return 0; 407 return 0;
403 } 408 }
404 409
405 err = ubifs_tnc_read_node(c, zbr, node); 410 if (c->replaying) {
411 err = fallible_read_node(c, &zbr->key, zbr, node);
412 /*
413 * When the node was not found, return -ENOENT, 0 otherwise.
414 * Negative return codes stay as-is.
415 */
416 if (err == 0)
417 err = -ENOENT;
418 else if (err == 1)
419 err = 0;
420 } else {
421 err = ubifs_tnc_read_node(c, zbr, node);
422 }
406 if (err) 423 if (err)
407 return err; 424 return err;
408 425
@@ -2857,7 +2874,11 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
2857 if (fname_len(nm) > 0) { 2874 if (fname_len(nm) > 0) {
2858 if (err) { 2875 if (err) {
2859 /* Handle collisions */ 2876 /* Handle collisions */
2860 err = resolve_collision(c, key, &znode, &n, nm); 2877 if (c->replaying)
2878 err = fallible_resolve_collision(c, key, &znode, &n,
2879 nm, 0);
2880 else
2881 err = resolve_collision(c, key, &znode, &n, nm);
2861 dbg_tnc("rc returned %d, znode %p, n %d", 2882 dbg_tnc("rc returned %d, znode %p, n %d",
2862 err, znode, n); 2883 err, znode, n);
2863 if (unlikely(err < 0)) 2884 if (unlikely(err < 0))
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index e5ebc3770460..d346d42c54d1 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -256,6 +256,9 @@ xfs_ag_resv_init(
256 goto out; 256 goto out;
257 } 257 }
258 258
259 ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved +
260 xfs_perag_resv(pag, XFS_AG_RESV_AGFL)->ar_reserved <=
261 pag->pagf_freeblks + pag->pagf_flcount);
259out: 262out:
260 return error; 263 return error;
261} 264}
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 5050056a0b06..9f06a211e157 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -95,10 +95,7 @@ unsigned int
95xfs_alloc_set_aside( 95xfs_alloc_set_aside(
96 struct xfs_mount *mp) 96 struct xfs_mount *mp)
97{ 97{
98 unsigned int blocks; 98 return mp->m_sb.sb_agcount * (XFS_ALLOC_AGFL_RESERVE + 4);
99
100 blocks = 4 + (mp->m_sb.sb_agcount * XFS_ALLOC_AGFL_RESERVE);
101 return blocks;
102} 99}
103 100
104/* 101/*
@@ -365,36 +362,12 @@ xfs_alloc_fix_len(
365 return; 362 return;
366 ASSERT(rlen >= args->minlen && rlen <= args->maxlen); 363 ASSERT(rlen >= args->minlen && rlen <= args->maxlen);
367 ASSERT(rlen % args->prod == args->mod); 364 ASSERT(rlen % args->prod == args->mod);
365 ASSERT(args->pag->pagf_freeblks + args->pag->pagf_flcount >=
366 rlen + args->minleft);
368 args->len = rlen; 367 args->len = rlen;
369} 368}
370 369
371/* 370/*
372 * Fix up length if there is too little space left in the a.g.
373 * Return 1 if ok, 0 if too little, should give up.
374 */
375STATIC int
376xfs_alloc_fix_minleft(
377 xfs_alloc_arg_t *args) /* allocation argument structure */
378{
379 xfs_agf_t *agf; /* a.g. freelist header */
380 int diff; /* free space difference */
381
382 if (args->minleft == 0)
383 return 1;
384 agf = XFS_BUF_TO_AGF(args->agbp);
385 diff = be32_to_cpu(agf->agf_freeblks)
386 - args->len - args->minleft;
387 if (diff >= 0)
388 return 1;
389 args->len += diff; /* shrink the allocated space */
390 /* casts to (int) catch length underflows */
391 if ((int)args->len >= (int)args->minlen)
392 return 1;
393 args->agbno = NULLAGBLOCK;
394 return 0;
395}
396
397/*
398 * Update the two btrees, logically removing from freespace the extent 371 * Update the two btrees, logically removing from freespace the extent
399 * starting at rbno, rlen blocks. The extent is contained within the 372 * starting at rbno, rlen blocks. The extent is contained within the
400 * actual (current) free extent fbno for flen blocks. 373 * actual (current) free extent fbno for flen blocks.
@@ -689,8 +662,6 @@ xfs_alloc_ag_vextent(
689 xfs_alloc_arg_t *args) /* argument structure for allocation */ 662 xfs_alloc_arg_t *args) /* argument structure for allocation */
690{ 663{
691 int error=0; 664 int error=0;
692 xfs_extlen_t reservation;
693 xfs_extlen_t oldmax;
694 665
695 ASSERT(args->minlen > 0); 666 ASSERT(args->minlen > 0);
696 ASSERT(args->maxlen > 0); 667 ASSERT(args->maxlen > 0);
@@ -699,20 +670,6 @@ xfs_alloc_ag_vextent(
699 ASSERT(args->alignment > 0); 670 ASSERT(args->alignment > 0);
700 671
701 /* 672 /*
702 * Clamp maxlen to the amount of free space minus any reservations
703 * that have been made.
704 */
705 oldmax = args->maxlen;
706 reservation = xfs_ag_resv_needed(args->pag, args->resv);
707 if (args->maxlen > args->pag->pagf_freeblks - reservation)
708 args->maxlen = args->pag->pagf_freeblks - reservation;
709 if (args->maxlen == 0) {
710 args->agbno = NULLAGBLOCK;
711 args->maxlen = oldmax;
712 return 0;
713 }
714
715 /*
716 * Branch to correct routine based on the type. 673 * Branch to correct routine based on the type.
717 */ 674 */
718 args->wasfromfl = 0; 675 args->wasfromfl = 0;
@@ -731,8 +688,6 @@ xfs_alloc_ag_vextent(
731 /* NOTREACHED */ 688 /* NOTREACHED */
732 } 689 }
733 690
734 args->maxlen = oldmax;
735
736 if (error || args->agbno == NULLAGBLOCK) 691 if (error || args->agbno == NULLAGBLOCK)
737 return error; 692 return error;
738 693
@@ -841,9 +796,6 @@ xfs_alloc_ag_vextent_exact(
841 args->len = XFS_AGBLOCK_MIN(tend, args->agbno + args->maxlen) 796 args->len = XFS_AGBLOCK_MIN(tend, args->agbno + args->maxlen)
842 - args->agbno; 797 - args->agbno;
843 xfs_alloc_fix_len(args); 798 xfs_alloc_fix_len(args);
844 if (!xfs_alloc_fix_minleft(args))
845 goto not_found;
846
847 ASSERT(args->agbno + args->len <= tend); 799 ASSERT(args->agbno + args->len <= tend);
848 800
849 /* 801 /*
@@ -1149,12 +1101,7 @@ restart:
1149 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0); 1101 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1150 ASSERT(ltbno + ltlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); 1102 ASSERT(ltbno + ltlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
1151 args->len = blen; 1103 args->len = blen;
1152 if (!xfs_alloc_fix_minleft(args)) { 1104
1153 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
1154 trace_xfs_alloc_near_nominleft(args);
1155 return 0;
1156 }
1157 blen = args->len;
1158 /* 1105 /*
1159 * We are allocating starting at bnew for blen blocks. 1106 * We are allocating starting at bnew for blen blocks.
1160 */ 1107 */
@@ -1346,12 +1293,6 @@ restart:
1346 */ 1293 */
1347 args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); 1294 args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen);
1348 xfs_alloc_fix_len(args); 1295 xfs_alloc_fix_len(args);
1349 if (!xfs_alloc_fix_minleft(args)) {
1350 trace_xfs_alloc_near_nominleft(args);
1351 xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR);
1352 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
1353 return 0;
1354 }
1355 rlen = args->len; 1296 rlen = args->len;
1356 (void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment, 1297 (void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment,
1357 args->datatype, ltbnoa, ltlena, &ltnew); 1298 args->datatype, ltbnoa, ltlena, &ltnew);
@@ -1553,8 +1494,6 @@ restart:
1553 } 1494 }
1554 xfs_alloc_fix_len(args); 1495 xfs_alloc_fix_len(args);
1555 1496
1556 if (!xfs_alloc_fix_minleft(args))
1557 goto out_nominleft;
1558 rlen = args->len; 1497 rlen = args->len;
1559 XFS_WANT_CORRUPTED_GOTO(args->mp, rlen <= flen, error0); 1498 XFS_WANT_CORRUPTED_GOTO(args->mp, rlen <= flen, error0);
1560 /* 1499 /*
@@ -2056,7 +1995,7 @@ xfs_alloc_space_available(
2056 int flags) 1995 int flags)
2057{ 1996{
2058 struct xfs_perag *pag = args->pag; 1997 struct xfs_perag *pag = args->pag;
2059 xfs_extlen_t longest; 1998 xfs_extlen_t alloc_len, longest;
2060 xfs_extlen_t reservation; /* blocks that are still reserved */ 1999 xfs_extlen_t reservation; /* blocks that are still reserved */
2061 int available; 2000 int available;
2062 2001
@@ -2066,17 +2005,28 @@ xfs_alloc_space_available(
2066 reservation = xfs_ag_resv_needed(pag, args->resv); 2005 reservation = xfs_ag_resv_needed(pag, args->resv);
2067 2006
2068 /* do we have enough contiguous free space for the allocation? */ 2007 /* do we have enough contiguous free space for the allocation? */
2008 alloc_len = args->minlen + (args->alignment - 1) + args->minalignslop;
2069 longest = xfs_alloc_longest_free_extent(args->mp, pag, min_free, 2009 longest = xfs_alloc_longest_free_extent(args->mp, pag, min_free,
2070 reservation); 2010 reservation);
2071 if ((args->minlen + args->alignment + args->minalignslop - 1) > longest) 2011 if (longest < alloc_len)
2072 return false; 2012 return false;
2073 2013
2074 /* do we have enough free space remaining for the allocation? */ 2014 /* do we have enough free space remaining for the allocation? */
2075 available = (int)(pag->pagf_freeblks + pag->pagf_flcount - 2015 available = (int)(pag->pagf_freeblks + pag->pagf_flcount -
2076 reservation - min_free - args->total); 2016 reservation - min_free - args->minleft);
2077 if (available < (int)args->minleft || available <= 0) 2017 if (available < (int)max(args->total, alloc_len))
2078 return false; 2018 return false;
2079 2019
2020 /*
2021 * Clamp maxlen to the amount of free space available for the actual
2022 * extent allocation.
2023 */
2024 if (available < (int)args->maxlen && !(flags & XFS_ALLOC_FLAG_CHECK)) {
2025 args->maxlen = available;
2026 ASSERT(args->maxlen > 0);
2027 ASSERT(args->maxlen >= args->minlen);
2028 }
2029
2080 return true; 2030 return true;
2081} 2031}
2082 2032
@@ -2122,7 +2072,8 @@ xfs_alloc_fix_freelist(
2122 } 2072 }
2123 2073
2124 need = xfs_alloc_min_freelist(mp, pag); 2074 need = xfs_alloc_min_freelist(mp, pag);
2125 if (!xfs_alloc_space_available(args, need, flags)) 2075 if (!xfs_alloc_space_available(args, need, flags |
2076 XFS_ALLOC_FLAG_CHECK))
2126 goto out_agbp_relse; 2077 goto out_agbp_relse;
2127 2078
2128 /* 2079 /*
@@ -2638,12 +2589,10 @@ xfs_alloc_vextent(
2638 xfs_agblock_t agsize; /* allocation group size */ 2589 xfs_agblock_t agsize; /* allocation group size */
2639 int error; 2590 int error;
2640 int flags; /* XFS_ALLOC_FLAG_... locking flags */ 2591 int flags; /* XFS_ALLOC_FLAG_... locking flags */
2641 xfs_extlen_t minleft;/* minimum left value, temp copy */
2642 xfs_mount_t *mp; /* mount structure pointer */ 2592 xfs_mount_t *mp; /* mount structure pointer */
2643 xfs_agnumber_t sagno; /* starting allocation group number */ 2593 xfs_agnumber_t sagno; /* starting allocation group number */
2644 xfs_alloctype_t type; /* input allocation type */ 2594 xfs_alloctype_t type; /* input allocation type */
2645 int bump_rotor = 0; 2595 int bump_rotor = 0;
2646 int no_min = 0;
2647 xfs_agnumber_t rotorstep = xfs_rotorstep; /* inode32 agf stepper */ 2596 xfs_agnumber_t rotorstep = xfs_rotorstep; /* inode32 agf stepper */
2648 2597
2649 mp = args->mp; 2598 mp = args->mp;
@@ -2672,7 +2621,6 @@ xfs_alloc_vextent(
2672 trace_xfs_alloc_vextent_badargs(args); 2621 trace_xfs_alloc_vextent_badargs(args);
2673 return 0; 2622 return 0;
2674 } 2623 }
2675 minleft = args->minleft;
2676 2624
2677 switch (type) { 2625 switch (type) {
2678 case XFS_ALLOCTYPE_THIS_AG: 2626 case XFS_ALLOCTYPE_THIS_AG:
@@ -2683,9 +2631,7 @@ xfs_alloc_vextent(
2683 */ 2631 */
2684 args->agno = XFS_FSB_TO_AGNO(mp, args->fsbno); 2632 args->agno = XFS_FSB_TO_AGNO(mp, args->fsbno);
2685 args->pag = xfs_perag_get(mp, args->agno); 2633 args->pag = xfs_perag_get(mp, args->agno);
2686 args->minleft = 0;
2687 error = xfs_alloc_fix_freelist(args, 0); 2634 error = xfs_alloc_fix_freelist(args, 0);
2688 args->minleft = minleft;
2689 if (error) { 2635 if (error) {
2690 trace_xfs_alloc_vextent_nofix(args); 2636 trace_xfs_alloc_vextent_nofix(args);
2691 goto error0; 2637 goto error0;
@@ -2750,9 +2696,7 @@ xfs_alloc_vextent(
2750 */ 2696 */
2751 for (;;) { 2697 for (;;) {
2752 args->pag = xfs_perag_get(mp, args->agno); 2698 args->pag = xfs_perag_get(mp, args->agno);
2753 if (no_min) args->minleft = 0;
2754 error = xfs_alloc_fix_freelist(args, flags); 2699 error = xfs_alloc_fix_freelist(args, flags);
2755 args->minleft = minleft;
2756 if (error) { 2700 if (error) {
2757 trace_xfs_alloc_vextent_nofix(args); 2701 trace_xfs_alloc_vextent_nofix(args);
2758 goto error0; 2702 goto error0;
@@ -2792,20 +2736,17 @@ xfs_alloc_vextent(
2792 * or switch to non-trylock mode. 2736 * or switch to non-trylock mode.
2793 */ 2737 */
2794 if (args->agno == sagno) { 2738 if (args->agno == sagno) {
2795 if (no_min == 1) { 2739 if (flags == 0) {
2796 args->agbno = NULLAGBLOCK; 2740 args->agbno = NULLAGBLOCK;
2797 trace_xfs_alloc_vextent_allfailed(args); 2741 trace_xfs_alloc_vextent_allfailed(args);
2798 break; 2742 break;
2799 } 2743 }
2800 if (flags == 0) { 2744
2801 no_min = 1; 2745 flags = 0;
2802 } else { 2746 if (type == XFS_ALLOCTYPE_START_BNO) {
2803 flags = 0; 2747 args->agbno = XFS_FSB_TO_AGBNO(mp,
2804 if (type == XFS_ALLOCTYPE_START_BNO) { 2748 args->fsbno);
2805 args->agbno = XFS_FSB_TO_AGBNO(mp, 2749 args->type = XFS_ALLOCTYPE_NEAR_BNO;
2806 args->fsbno);
2807 args->type = XFS_ALLOCTYPE_NEAR_BNO;
2808 }
2809 } 2750 }
2810 } 2751 }
2811 xfs_perag_put(args->pag); 2752 xfs_perag_put(args->pag);
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index 7c404a6b0ae3..1d0f48a501a3 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -56,7 +56,7 @@ typedef unsigned int xfs_alloctype_t;
56#define XFS_ALLOC_FLAG_FREEING 0x00000002 /* indicate caller is freeing extents*/ 56#define XFS_ALLOC_FLAG_FREEING 0x00000002 /* indicate caller is freeing extents*/
57#define XFS_ALLOC_FLAG_NORMAP 0x00000004 /* don't modify the rmapbt */ 57#define XFS_ALLOC_FLAG_NORMAP 0x00000004 /* don't modify the rmapbt */
58#define XFS_ALLOC_FLAG_NOSHRINK 0x00000008 /* don't shrink the freelist */ 58#define XFS_ALLOC_FLAG_NOSHRINK 0x00000008 /* don't shrink the freelist */
59 59#define XFS_ALLOC_FLAG_CHECK 0x00000010 /* test only, don't modify args */
60 60
61/* 61/*
62 * Argument structure for xfs_alloc routines. 62 * Argument structure for xfs_alloc routines.
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 2760bc3b2536..44773c9eb957 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3812,7 +3812,6 @@ xfs_bmap_btalloc(
3812 args.fsbno = 0; 3812 args.fsbno = 0;
3813 args.type = XFS_ALLOCTYPE_FIRST_AG; 3813 args.type = XFS_ALLOCTYPE_FIRST_AG;
3814 args.total = ap->minlen; 3814 args.total = ap->minlen;
3815 args.minleft = 0;
3816 if ((error = xfs_alloc_vextent(&args))) 3815 if ((error = xfs_alloc_vextent(&args)))
3817 return error; 3816 return error;
3818 ap->dfops->dop_low = true; 3817 ap->dfops->dop_low = true;
@@ -4344,8 +4343,6 @@ xfs_bmapi_allocate(
4344 if (error) 4343 if (error)
4345 return error; 4344 return error;
4346 4345
4347 if (bma->dfops->dop_low)
4348 bma->minleft = 0;
4349 if (bma->cur) 4346 if (bma->cur)
4350 bma->cur->bc_private.b.firstblock = *bma->firstblock; 4347 bma->cur->bc_private.b.firstblock = *bma->firstblock;
4351 if (bma->blkno == NULLFSBLOCK) 4348 if (bma->blkno == NULLFSBLOCK)
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index d6330c297ca0..d9be241fc86f 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -502,12 +502,11 @@ try_another_ag:
502 if (args.fsbno == NULLFSBLOCK && args.minleft) { 502 if (args.fsbno == NULLFSBLOCK && args.minleft) {
503 /* 503 /*
504 * Could not find an AG with enough free space to satisfy 504 * Could not find an AG with enough free space to satisfy
505 * a full btree split. Try again without minleft and if 505 * a full btree split. Try again and if
506 * successful activate the lowspace algorithm. 506 * successful activate the lowspace algorithm.
507 */ 507 */
508 args.fsbno = 0; 508 args.fsbno = 0;
509 args.type = XFS_ALLOCTYPE_FIRST_AG; 509 args.type = XFS_ALLOCTYPE_FIRST_AG;
510 args.minleft = 0;
511 error = xfs_alloc_vextent(&args); 510 error = xfs_alloc_vextent(&args);
512 if (error) 511 if (error)
513 goto error0; 512 goto error0;
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index c58d72c220f5..2f389d366e93 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -36,21 +36,29 @@
36struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; 36struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
37 37
38/* 38/*
39 * @mode, if set, indicates that the type field needs to be set up. 39 * Convert inode mode to directory entry filetype
40 * This uses the transformation from file mode to DT_* as defined in linux/fs.h
41 * for file type specification. This will be propagated into the directory
42 * structure if appropriate for the given operation and filesystem config.
43 */ 40 */
44const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { 41unsigned char xfs_mode_to_ftype(int mode)
45 [0] = XFS_DIR3_FT_UNKNOWN, 42{
46 [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, 43 switch (mode & S_IFMT) {
47 [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, 44 case S_IFREG:
48 [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, 45 return XFS_DIR3_FT_REG_FILE;
49 [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, 46 case S_IFDIR:
50 [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, 47 return XFS_DIR3_FT_DIR;
51 [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, 48 case S_IFCHR:
52 [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, 49 return XFS_DIR3_FT_CHRDEV;
53}; 50 case S_IFBLK:
51 return XFS_DIR3_FT_BLKDEV;
52 case S_IFIFO:
53 return XFS_DIR3_FT_FIFO;
54 case S_IFSOCK:
55 return XFS_DIR3_FT_SOCK;
56 case S_IFLNK:
57 return XFS_DIR3_FT_SYMLINK;
58 default:
59 return XFS_DIR3_FT_UNKNOWN;
60 }
61}
54 62
55/* 63/*
56 * ASCII case-insensitive (ie. A-Z) support for directories that was 64 * ASCII case-insensitive (ie. A-Z) support for directories that was
@@ -631,7 +639,8 @@ xfs_dir2_isblock(
631 if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK))) 639 if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
632 return rval; 640 return rval;
633 rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize; 641 rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
634 ASSERT(rval == 0 || args->dp->i_d.di_size == args->geo->blksize); 642 if (rval != 0 && args->dp->i_d.di_size != args->geo->blksize)
643 return -EFSCORRUPTED;
635 *vp = rval; 644 *vp = rval;
636 return 0; 645 return 0;
637} 646}
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index 0197590fa7d7..d6e6d9d16f6c 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -18,6 +18,9 @@
18#ifndef __XFS_DIR2_H__ 18#ifndef __XFS_DIR2_H__
19#define __XFS_DIR2_H__ 19#define __XFS_DIR2_H__
20 20
21#include "xfs_da_format.h"
22#include "xfs_da_btree.h"
23
21struct xfs_defer_ops; 24struct xfs_defer_ops;
22struct xfs_da_args; 25struct xfs_da_args;
23struct xfs_inode; 26struct xfs_inode;
@@ -32,10 +35,9 @@ struct xfs_dir2_data_unused;
32extern struct xfs_name xfs_name_dotdot; 35extern struct xfs_name xfs_name_dotdot;
33 36
34/* 37/*
35 * directory filetype conversion tables. 38 * Convert inode mode to directory entry filetype
36 */ 39 */
37#define S_SHIFT 12 40extern unsigned char xfs_mode_to_ftype(int mode);
38extern const unsigned char xfs_mode_to_ftype[];
39 41
40/* 42/*
41 * directory operations vector for encode/decode routines 43 * directory operations vector for encode/decode routines
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index dd483e2767f7..d93f9d918cfc 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -29,6 +29,7 @@
29#include "xfs_icache.h" 29#include "xfs_icache.h"
30#include "xfs_trans.h" 30#include "xfs_trans.h"
31#include "xfs_ialloc.h" 31#include "xfs_ialloc.h"
32#include "xfs_dir2.h"
32 33
33/* 34/*
34 * Check that none of the inode's in the buffer have a next 35 * Check that none of the inode's in the buffer have a next
@@ -386,6 +387,7 @@ xfs_dinode_verify(
386 xfs_ino_t ino, 387 xfs_ino_t ino,
387 struct xfs_dinode *dip) 388 struct xfs_dinode *dip)
388{ 389{
390 uint16_t mode;
389 uint16_t flags; 391 uint16_t flags;
390 uint64_t flags2; 392 uint64_t flags2;
391 393
@@ -396,8 +398,12 @@ xfs_dinode_verify(
396 if (be64_to_cpu(dip->di_size) & (1ULL << 63)) 398 if (be64_to_cpu(dip->di_size) & (1ULL << 63))
397 return false; 399 return false;
398 400
399 /* No zero-length symlinks. */ 401 mode = be16_to_cpu(dip->di_mode);
400 if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0) 402 if (mode && xfs_mode_to_ftype(mode) == XFS_DIR3_FT_UNKNOWN)
403 return false;
404
405 /* No zero-length symlinks/dirs. */
406 if ((S_ISLNK(mode) || S_ISDIR(mode)) && dip->di_size == 0)
401 return false; 407 return false;
402 408
403 /* only version 3 or greater inodes are extensively verified here */ 409 /* only version 3 or greater inodes are extensively verified here */
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 6fb2215f8ff7..50add5272807 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -409,13 +409,14 @@ xfs_refcountbt_calc_size(
409 */ 409 */
410xfs_extlen_t 410xfs_extlen_t
411xfs_refcountbt_max_size( 411xfs_refcountbt_max_size(
412 struct xfs_mount *mp) 412 struct xfs_mount *mp,
413 xfs_agblock_t agblocks)
413{ 414{
414 /* Bail out if we're uninitialized, which can happen in mkfs. */ 415 /* Bail out if we're uninitialized, which can happen in mkfs. */
415 if (mp->m_refc_mxr[0] == 0) 416 if (mp->m_refc_mxr[0] == 0)
416 return 0; 417 return 0;
417 418
418 return xfs_refcountbt_calc_size(mp, mp->m_sb.sb_agblocks); 419 return xfs_refcountbt_calc_size(mp, agblocks);
419} 420}
420 421
421/* 422/*
@@ -430,22 +431,24 @@ xfs_refcountbt_calc_reserves(
430{ 431{
431 struct xfs_buf *agbp; 432 struct xfs_buf *agbp;
432 struct xfs_agf *agf; 433 struct xfs_agf *agf;
434 xfs_agblock_t agblocks;
433 xfs_extlen_t tree_len; 435 xfs_extlen_t tree_len;
434 int error; 436 int error;
435 437
436 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 438 if (!xfs_sb_version_hasreflink(&mp->m_sb))
437 return 0; 439 return 0;
438 440
439 *ask += xfs_refcountbt_max_size(mp);
440 441
441 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 442 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
442 if (error) 443 if (error)
443 return error; 444 return error;
444 445
445 agf = XFS_BUF_TO_AGF(agbp); 446 agf = XFS_BUF_TO_AGF(agbp);
447 agblocks = be32_to_cpu(agf->agf_length);
446 tree_len = be32_to_cpu(agf->agf_refcount_blocks); 448 tree_len = be32_to_cpu(agf->agf_refcount_blocks);
447 xfs_buf_relse(agbp); 449 xfs_buf_relse(agbp);
448 450
451 *ask += xfs_refcountbt_max_size(mp, agblocks);
449 *used += tree_len; 452 *used += tree_len;
450 453
451 return error; 454 return error;
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.h b/fs/xfs/libxfs/xfs_refcount_btree.h
index 3be7768bd51a..9db008b955b7 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.h
+++ b/fs/xfs/libxfs/xfs_refcount_btree.h
@@ -66,7 +66,8 @@ extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
66 66
67extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp, 67extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
68 unsigned long long len); 68 unsigned long long len);
69extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp); 69extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
70 xfs_agblock_t agblocks);
70 71
71extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp, 72extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
72 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 73 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index de25771764ba..74e5a54bc428 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -550,13 +550,14 @@ xfs_rmapbt_calc_size(
550 */ 550 */
551xfs_extlen_t 551xfs_extlen_t
552xfs_rmapbt_max_size( 552xfs_rmapbt_max_size(
553 struct xfs_mount *mp) 553 struct xfs_mount *mp,
554 xfs_agblock_t agblocks)
554{ 555{
555 /* Bail out if we're uninitialized, which can happen in mkfs. */ 556 /* Bail out if we're uninitialized, which can happen in mkfs. */
556 if (mp->m_rmap_mxr[0] == 0) 557 if (mp->m_rmap_mxr[0] == 0)
557 return 0; 558 return 0;
558 559
559 return xfs_rmapbt_calc_size(mp, mp->m_sb.sb_agblocks); 560 return xfs_rmapbt_calc_size(mp, agblocks);
560} 561}
561 562
562/* 563/*
@@ -571,25 +572,24 @@ xfs_rmapbt_calc_reserves(
571{ 572{
572 struct xfs_buf *agbp; 573 struct xfs_buf *agbp;
573 struct xfs_agf *agf; 574 struct xfs_agf *agf;
574 xfs_extlen_t pool_len; 575 xfs_agblock_t agblocks;
575 xfs_extlen_t tree_len; 576 xfs_extlen_t tree_len;
576 int error; 577 int error;
577 578
578 if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) 579 if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
579 return 0; 580 return 0;
580 581
581 /* Reserve 1% of the AG or enough for 1 block per record. */
582 pool_len = max(mp->m_sb.sb_agblocks / 100, xfs_rmapbt_max_size(mp));
583 *ask += pool_len;
584
585 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 582 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
586 if (error) 583 if (error)
587 return error; 584 return error;
588 585
589 agf = XFS_BUF_TO_AGF(agbp); 586 agf = XFS_BUF_TO_AGF(agbp);
587 agblocks = be32_to_cpu(agf->agf_length);
590 tree_len = be32_to_cpu(agf->agf_rmap_blocks); 588 tree_len = be32_to_cpu(agf->agf_rmap_blocks);
591 xfs_buf_relse(agbp); 589 xfs_buf_relse(agbp);
592 590
591 /* Reserve 1% of the AG or enough for 1 block per record. */
592 *ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
593 *used += tree_len; 593 *used += tree_len;
594 594
595 return error; 595 return error;
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.h b/fs/xfs/libxfs/xfs_rmap_btree.h
index 2a9ac472fb15..19c08e933049 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.h
+++ b/fs/xfs/libxfs/xfs_rmap_btree.h
@@ -60,7 +60,8 @@ extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
60 60
61extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp, 61extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
62 unsigned long long len); 62 unsigned long long len);
63extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp); 63extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
64 xfs_agblock_t agblocks);
64 65
65extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp, 66extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
66 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 67 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 0f56fcd3a5d5..631e7c0e0a29 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1152,19 +1152,22 @@ xfs_vm_releasepage(
1152 * block_invalidatepage() can send pages that are still marked dirty 1152 * block_invalidatepage() can send pages that are still marked dirty
1153 * but otherwise have invalidated buffers. 1153 * but otherwise have invalidated buffers.
1154 * 1154 *
1155 * We've historically freed buffers on the latter. Instead, quietly 1155 * We want to release the latter to avoid unnecessary buildup of the
1156 * filter out all dirty pages to avoid spurious buffer state warnings. 1156 * LRU, skip the former and warn if we've left any lingering
1157 * This can likely be removed once shrink_active_list() is fixed. 1157 * delalloc/unwritten buffers on clean pages. Skip pages with delalloc
1158 * or unwritten buffers and warn if the page is not dirty. Otherwise
1159 * try to release the buffers.
1158 */ 1160 */
1159 if (PageDirty(page))
1160 return 0;
1161
1162 xfs_count_page_state(page, &delalloc, &unwritten); 1161 xfs_count_page_state(page, &delalloc, &unwritten);
1163 1162
1164 if (WARN_ON_ONCE(delalloc)) 1163 if (delalloc) {
1164 WARN_ON_ONCE(!PageDirty(page));
1165 return 0; 1165 return 0;
1166 if (WARN_ON_ONCE(unwritten)) 1166 }
1167 if (unwritten) {
1168 WARN_ON_ONCE(!PageDirty(page));
1167 return 0; 1169 return 0;
1170 }
1168 1171
1169 return try_to_free_buffers(page); 1172 return try_to_free_buffers(page);
1170} 1173}
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 7a30b8f11db7..9d06cc30e875 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -710,6 +710,10 @@ xfs_dq_get_next_id(
710 /* Simple advance */ 710 /* Simple advance */
711 next_id = *id + 1; 711 next_id = *id + 1;
712 712
713 /* If we'd wrap past the max ID, stop */
714 if (next_id < *id)
715 return -ENOENT;
716
713 /* If new ID is within the current chunk, advancing it sufficed */ 717 /* If new ID is within the current chunk, advancing it sufficed */
714 if (next_id % mp->m_quotainfo->qi_dqperchunk) { 718 if (next_id % mp->m_quotainfo->qi_dqperchunk) {
715 *id = next_id; 719 *id = next_id;
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 93d12fa2670d..242e8091296d 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -631,6 +631,20 @@ xfs_growfs_data_private(
631 xfs_set_low_space_thresholds(mp); 631 xfs_set_low_space_thresholds(mp);
632 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); 632 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
633 633
634 /*
635 * If we expanded the last AG, free the per-AG reservation
636 * so we can reinitialize it with the new size.
637 */
638 if (new) {
639 struct xfs_perag *pag;
640
641 pag = xfs_perag_get(mp, agno);
642 error = xfs_ag_resv_free(pag);
643 xfs_perag_put(pag);
644 if (error)
645 goto out;
646 }
647
634 /* Reserve AG metadata blocks. */ 648 /* Reserve AG metadata blocks. */
635 error = xfs_fs_reserve_ag_blocks(mp); 649 error = xfs_fs_reserve_ag_blocks(mp);
636 if (error && error != -ENOSPC) 650 if (error && error != -ENOSPC)
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index ff4d6311c7f4..70ca4f608321 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1597,7 +1597,8 @@ xfs_inode_free_cowblocks(
1597 * If the mapping is dirty or under writeback we cannot touch the 1597 * If the mapping is dirty or under writeback we cannot touch the
1598 * CoW fork. Leave it alone if we're in the midst of a directio. 1598 * CoW fork. Leave it alone if we're in the midst of a directio.
1599 */ 1599 */
1600 if (mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) || 1600 if ((VFS_I(ip)->i_state & I_DIRTY_PAGES) ||
1601 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
1601 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) || 1602 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) ||
1602 atomic_read(&VFS_I(ip)->i_dio_count)) 1603 atomic_read(&VFS_I(ip)->i_dio_count))
1603 return 0; 1604 return 0;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 308bebb6dfd2..22c16155f1b4 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -98,12 +98,27 @@ xfs_init_security(
98static void 98static void
99xfs_dentry_to_name( 99xfs_dentry_to_name(
100 struct xfs_name *namep, 100 struct xfs_name *namep,
101 struct dentry *dentry)
102{
103 namep->name = dentry->d_name.name;
104 namep->len = dentry->d_name.len;
105 namep->type = XFS_DIR3_FT_UNKNOWN;
106}
107
108static int
109xfs_dentry_mode_to_name(
110 struct xfs_name *namep,
101 struct dentry *dentry, 111 struct dentry *dentry,
102 int mode) 112 int mode)
103{ 113{
104 namep->name = dentry->d_name.name; 114 namep->name = dentry->d_name.name;
105 namep->len = dentry->d_name.len; 115 namep->len = dentry->d_name.len;
106 namep->type = xfs_mode_to_ftype[(mode & S_IFMT) >> S_SHIFT]; 116 namep->type = xfs_mode_to_ftype(mode);
117
118 if (unlikely(namep->type == XFS_DIR3_FT_UNKNOWN))
119 return -EFSCORRUPTED;
120
121 return 0;
107} 122}
108 123
109STATIC void 124STATIC void
@@ -119,7 +134,7 @@ xfs_cleanup_inode(
119 * xfs_init_security we must back out. 134 * xfs_init_security we must back out.
120 * ENOSPC can hit here, among other things. 135 * ENOSPC can hit here, among other things.
121 */ 136 */
122 xfs_dentry_to_name(&teardown, dentry, 0); 137 xfs_dentry_to_name(&teardown, dentry);
123 138
124 xfs_remove(XFS_I(dir), &teardown, XFS_I(inode)); 139 xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
125} 140}
@@ -154,8 +169,12 @@ xfs_generic_create(
154 if (error) 169 if (error)
155 return error; 170 return error;
156 171
172 /* Verify mode is valid also for tmpfile case */
173 error = xfs_dentry_mode_to_name(&name, dentry, mode);
174 if (unlikely(error))
175 goto out_free_acl;
176
157 if (!tmpfile) { 177 if (!tmpfile) {
158 xfs_dentry_to_name(&name, dentry, mode);
159 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip); 178 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
160 } else { 179 } else {
161 error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip); 180 error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip);
@@ -248,7 +267,7 @@ xfs_vn_lookup(
248 if (dentry->d_name.len >= MAXNAMELEN) 267 if (dentry->d_name.len >= MAXNAMELEN)
249 return ERR_PTR(-ENAMETOOLONG); 268 return ERR_PTR(-ENAMETOOLONG);
250 269
251 xfs_dentry_to_name(&name, dentry, 0); 270 xfs_dentry_to_name(&name, dentry);
252 error = xfs_lookup(XFS_I(dir), &name, &cip, NULL); 271 error = xfs_lookup(XFS_I(dir), &name, &cip, NULL);
253 if (unlikely(error)) { 272 if (unlikely(error)) {
254 if (unlikely(error != -ENOENT)) 273 if (unlikely(error != -ENOENT))
@@ -275,7 +294,7 @@ xfs_vn_ci_lookup(
275 if (dentry->d_name.len >= MAXNAMELEN) 294 if (dentry->d_name.len >= MAXNAMELEN)
276 return ERR_PTR(-ENAMETOOLONG); 295 return ERR_PTR(-ENAMETOOLONG);
277 296
278 xfs_dentry_to_name(&xname, dentry, 0); 297 xfs_dentry_to_name(&xname, dentry);
279 error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name); 298 error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name);
280 if (unlikely(error)) { 299 if (unlikely(error)) {
281 if (unlikely(error != -ENOENT)) 300 if (unlikely(error != -ENOENT))
@@ -310,7 +329,9 @@ xfs_vn_link(
310 struct xfs_name name; 329 struct xfs_name name;
311 int error; 330 int error;
312 331
313 xfs_dentry_to_name(&name, dentry, inode->i_mode); 332 error = xfs_dentry_mode_to_name(&name, dentry, inode->i_mode);
333 if (unlikely(error))
334 return error;
314 335
315 error = xfs_link(XFS_I(dir), XFS_I(inode), &name); 336 error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
316 if (unlikely(error)) 337 if (unlikely(error))
@@ -329,7 +350,7 @@ xfs_vn_unlink(
329 struct xfs_name name; 350 struct xfs_name name;
330 int error; 351 int error;
331 352
332 xfs_dentry_to_name(&name, dentry, 0); 353 xfs_dentry_to_name(&name, dentry);
333 354
334 error = xfs_remove(XFS_I(dir), &name, XFS_I(d_inode(dentry))); 355 error = xfs_remove(XFS_I(dir), &name, XFS_I(d_inode(dentry)));
335 if (error) 356 if (error)
@@ -359,7 +380,9 @@ xfs_vn_symlink(
359 380
360 mode = S_IFLNK | 381 mode = S_IFLNK |
361 (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO); 382 (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
362 xfs_dentry_to_name(&name, dentry, mode); 383 error = xfs_dentry_mode_to_name(&name, dentry, mode);
384 if (unlikely(error))
385 goto out;
363 386
364 error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip); 387 error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip);
365 if (unlikely(error)) 388 if (unlikely(error))
@@ -395,6 +418,7 @@ xfs_vn_rename(
395{ 418{
396 struct inode *new_inode = d_inode(ndentry); 419 struct inode *new_inode = d_inode(ndentry);
397 int omode = 0; 420 int omode = 0;
421 int error;
398 struct xfs_name oname; 422 struct xfs_name oname;
399 struct xfs_name nname; 423 struct xfs_name nname;
400 424
@@ -405,8 +429,14 @@ xfs_vn_rename(
405 if (flags & RENAME_EXCHANGE) 429 if (flags & RENAME_EXCHANGE)
406 omode = d_inode(ndentry)->i_mode; 430 omode = d_inode(ndentry)->i_mode;
407 431
408 xfs_dentry_to_name(&oname, odentry, omode); 432 error = xfs_dentry_mode_to_name(&oname, odentry, omode);
409 xfs_dentry_to_name(&nname, ndentry, d_inode(odentry)->i_mode); 433 if (omode && unlikely(error))
434 return error;
435
436 error = xfs_dentry_mode_to_name(&nname, ndentry,
437 d_inode(odentry)->i_mode);
438 if (unlikely(error))
439 return error;
410 440
411 return xfs_rename(XFS_I(odir), &oname, XFS_I(d_inode(odentry)), 441 return xfs_rename(XFS_I(odir), &oname, XFS_I(d_inode(odentry)),
412 XFS_I(ndir), &nname, 442 XFS_I(ndir), &nname,
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index e467218c0098..7a989de224f4 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -331,11 +331,11 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
331} 331}
332 332
333#define ASSERT_ALWAYS(expr) \ 333#define ASSERT_ALWAYS(expr) \
334 (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) 334 (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
335 335
336#ifdef DEBUG 336#ifdef DEBUG
337#define ASSERT(expr) \ 337#define ASSERT(expr) \
338 (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) 338 (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
339 339
340#ifndef STATIC 340#ifndef STATIC
341# define STATIC noinline 341# define STATIC noinline
@@ -346,7 +346,7 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
346#ifdef XFS_WARN 346#ifdef XFS_WARN
347 347
348#define ASSERT(expr) \ 348#define ASSERT(expr) \
349 (unlikely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__)) 349 (likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__))
350 350
351#ifndef STATIC 351#ifndef STATIC
352# define STATIC static noinline 352# define STATIC static noinline
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index c39ac14ff540..b1469f0a91a6 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3317,12 +3317,8 @@ xfs_log_force(
3317 xfs_mount_t *mp, 3317 xfs_mount_t *mp,
3318 uint flags) 3318 uint flags)
3319{ 3319{
3320 int error;
3321
3322 trace_xfs_log_force(mp, 0, _RET_IP_); 3320 trace_xfs_log_force(mp, 0, _RET_IP_);
3323 error = _xfs_log_force(mp, flags, NULL); 3321 _xfs_log_force(mp, flags, NULL);
3324 if (error)
3325 xfs_warn(mp, "%s: error %d returned.", __func__, error);
3326} 3322}
3327 3323
3328/* 3324/*
@@ -3466,12 +3462,8 @@ xfs_log_force_lsn(
3466 xfs_lsn_t lsn, 3462 xfs_lsn_t lsn,
3467 uint flags) 3463 uint flags)
3468{ 3464{
3469 int error;
3470
3471 trace_xfs_log_force(mp, lsn, _RET_IP_); 3465 trace_xfs_log_force(mp, lsn, _RET_IP_);
3472 error = _xfs_log_force_lsn(mp, lsn, flags, NULL); 3466 _xfs_log_force_lsn(mp, lsn, flags, NULL);
3473 if (error)
3474 xfs_warn(mp, "%s: error %d returned.", __func__, error);
3475} 3467}
3476 3468
3477/* 3469/*
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index fe86a668a57e..6e4c7446c3d4 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -526,13 +526,14 @@ xfs_cui_recover(
526 xfs_refcount_finish_one_cleanup(tp, rcur, error); 526 xfs_refcount_finish_one_cleanup(tp, rcur, error);
527 error = xfs_defer_finish(&tp, &dfops, NULL); 527 error = xfs_defer_finish(&tp, &dfops, NULL);
528 if (error) 528 if (error)
529 goto abort_error; 529 goto abort_defer;
530 set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags); 530 set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags);
531 error = xfs_trans_commit(tp); 531 error = xfs_trans_commit(tp);
532 return error; 532 return error;
533 533
534abort_error: 534abort_error:
535 xfs_refcount_finish_one_cleanup(tp, rcur, error); 535 xfs_refcount_finish_one_cleanup(tp, rcur, error);
536abort_defer:
536 xfs_defer_cancel(&dfops); 537 xfs_defer_cancel(&dfops);
537 xfs_trans_cancel(tp); 538 xfs_trans_cancel(tp);
538 return error; 539 return error;
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 276d3023d60f..de6195e38910 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -396,7 +396,7 @@ max_retries_show(
396 int retries; 396 int retries;
397 struct xfs_error_cfg *cfg = to_error_cfg(kobject); 397 struct xfs_error_cfg *cfg = to_error_cfg(kobject);
398 398
399 if (cfg->retry_timeout == XFS_ERR_RETRY_FOREVER) 399 if (cfg->max_retries == XFS_ERR_RETRY_FOREVER)
400 retries = -1; 400 retries = -1;
401 else 401 else
402 retries = cfg->max_retries; 402 retries = cfg->max_retries;
@@ -422,7 +422,7 @@ max_retries_store(
422 return -EINVAL; 422 return -EINVAL;
423 423
424 if (val == -1) 424 if (val == -1)
425 cfg->retry_timeout = XFS_ERR_RETRY_FOREVER; 425 cfg->max_retries = XFS_ERR_RETRY_FOREVER;
426 else 426 else
427 cfg->max_retries = val; 427 cfg->max_retries = val;
428 return count; 428 return count;
diff --git a/include/asm-generic/asm-prototypes.h b/include/asm-generic/asm-prototypes.h
index df13637e4017..939869c772b1 100644
--- a/include/asm-generic/asm-prototypes.h
+++ b/include/asm-generic/asm-prototypes.h
@@ -1,7 +1,13 @@
1#include <linux/bitops.h> 1#include <linux/bitops.h>
2#undef __memset
2extern void *__memset(void *, int, __kernel_size_t); 3extern void *__memset(void *, int, __kernel_size_t);
4#undef __memcpy
3extern void *__memcpy(void *, const void *, __kernel_size_t); 5extern void *__memcpy(void *, const void *, __kernel_size_t);
6#undef __memmove
4extern void *__memmove(void *, const void *, __kernel_size_t); 7extern void *__memmove(void *, const void *, __kernel_size_t);
8#undef memset
5extern void *memset(void *, int, __kernel_size_t); 9extern void *memset(void *, int, __kernel_size_t);
10#undef memcpy
6extern void *memcpy(void *, const void *, __kernel_size_t); 11extern void *memcpy(void *, const void *, __kernel_size_t);
12#undef memmove
7extern void *memmove(void *, const void *, __kernel_size_t); 13extern void *memmove(void *, const void *, __kernel_size_t);
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 982c299e435a..d026f5017c33 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -73,6 +73,5 @@ extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
73 73
74extern void drm_kms_helper_poll_disable(struct drm_device *dev); 74extern void drm_kms_helper_poll_disable(struct drm_device *dev);
75extern void drm_kms_helper_poll_enable(struct drm_device *dev); 75extern void drm_kms_helper_poll_enable(struct drm_device *dev);
76extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev);
77 76
78#endif 77#endif
diff --git a/include/dt-bindings/mfd/tps65217.h b/include/dt-bindings/mfd/tps65217.h
deleted file mode 100644
index cafb9e60cf12..000000000000
--- a/include/dt-bindings/mfd/tps65217.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * This header provides macros for TI TPS65217 DT bindings.
3 *
4 * Copyright (C) 2016 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __DT_BINDINGS_TPS65217_H__
20#define __DT_BINDINGS_TPS65217_H__
21
22#define TPS65217_IRQ_USB 0
23#define TPS65217_IRQ_AC 1
24#define TPS65217_IRQ_PB 2
25
26#endif
diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
index b717ed9d2b75..5c970ce67949 100644
--- a/include/kvm/arm_arch_timer.h
+++ b/include/kvm/arm_arch_timer.h
@@ -76,4 +76,5 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu);
76 76
77void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu); 77void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu);
78 78
79void kvm_timer_init_vhe(void);
79#endif 80#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 83695641bd5e..1ca8e8fd1078 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -739,7 +739,7 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
739 } 739 }
740} 740}
741 741
742static inline unsigned int blk_queue_zone_size(struct request_queue *q) 742static inline unsigned int blk_queue_zone_sectors(struct request_queue *q)
743{ 743{
744 return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0; 744 return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
745} 745}
@@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
1000 return blk_rq_cur_bytes(rq) >> 9; 1000 return blk_rq_cur_bytes(rq) >> 9;
1001} 1001}
1002 1002
1003/*
1004 * Some commands like WRITE SAME have a payload or data transfer size which
1005 * is different from the size of the request. Any driver that supports such
1006 * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to
1007 * calculate the data transfer size.
1008 */
1009static inline unsigned int blk_rq_payload_bytes(struct request *rq)
1010{
1011 if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
1012 return rq->special_vec.bv_len;
1013 return blk_rq_bytes(rq);
1014}
1015
1003static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, 1016static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
1004 int op) 1017 int op)
1005{ 1018{
@@ -1536,12 +1549,12 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
1536 return false; 1549 return false;
1537} 1550}
1538 1551
1539static inline unsigned int bdev_zone_size(struct block_device *bdev) 1552static inline unsigned int bdev_zone_sectors(struct block_device *bdev)
1540{ 1553{
1541 struct request_queue *q = bdev_get_queue(bdev); 1554 struct request_queue *q = bdev_get_queue(bdev);
1542 1555
1543 if (q) 1556 if (q)
1544 return blk_queue_zone_size(q); 1557 return blk_queue_zone_sectors(q);
1545 1558
1546 return 0; 1559 return 0;
1547} 1560}
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index f74ae68086dc..05cf951df3fe 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -216,7 +216,7 @@ u64 bpf_tail_call(u64 ctx, u64 r2, u64 index, u64 r4, u64 r5);
216u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); 216u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
217 217
218bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp); 218bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp);
219int bpf_prog_calc_digest(struct bpf_prog *fp); 219int bpf_prog_calc_tag(struct bpf_prog *fp);
220 220
221const struct bpf_func_proto *bpf_get_trace_printk_proto(void); 221const struct bpf_func_proto *bpf_get_trace_printk_proto(void);
222 222
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index d016a121a8c4..28ffa94aed6b 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -14,6 +14,7 @@ struct coredump_params;
14extern int dump_skip(struct coredump_params *cprm, size_t nr); 14extern int dump_skip(struct coredump_params *cprm, size_t nr);
15extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr); 15extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
16extern int dump_align(struct coredump_params *cprm, int align); 16extern int dump_align(struct coredump_params *cprm, int align);
17extern void dump_truncate(struct coredump_params *cprm);
17#ifdef CONFIG_COREDUMP 18#ifdef CONFIG_COREDUMP
18extern void do_coredump(const siginfo_t *siginfo); 19extern void do_coredump(const siginfo_t *siginfo);
19#else 20#else
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 20bfefbe7594..d936a0021839 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -74,6 +74,8 @@ enum cpuhp_state {
74 CPUHP_ZCOMP_PREPARE, 74 CPUHP_ZCOMP_PREPARE,
75 CPUHP_TIMERS_DEAD, 75 CPUHP_TIMERS_DEAD,
76 CPUHP_MIPS_SOC_PREPARE, 76 CPUHP_MIPS_SOC_PREPARE,
77 CPUHP_BP_PREPARE_DYN,
78 CPUHP_BP_PREPARE_DYN_END = CPUHP_BP_PREPARE_DYN + 20,
77 CPUHP_BRINGUP_CPU, 79 CPUHP_BRINGUP_CPU,
78 CPUHP_AP_IDLE_DEAD, 80 CPUHP_AP_IDLE_DEAD,
79 CPUHP_AP_OFFLINE, 81 CPUHP_AP_OFFLINE,
diff --git a/include/linux/efi.h b/include/linux/efi.h
index a07a476178cd..5b1af30ece55 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -103,6 +103,7 @@ typedef struct {
103 103
104#define EFI_PAGE_SHIFT 12 104#define EFI_PAGE_SHIFT 12
105#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) 105#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
106#define EFI_PAGES_MAX (U64_MAX >> EFI_PAGE_SHIFT)
106 107
107typedef struct { 108typedef struct {
108 u32 type; 109 u32 type;
@@ -950,6 +951,7 @@ static inline efi_status_t efi_query_variable_store(u32 attributes,
950#endif 951#endif
951extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); 952extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr);
952 953
954extern phys_addr_t __init efi_memmap_alloc(unsigned int num_entries);
953extern int __init efi_memmap_init_early(struct efi_memory_map_data *data); 955extern int __init efi_memmap_init_early(struct efi_memory_map_data *data);
954extern int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size); 956extern int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size);
955extern void __init efi_memmap_unmap(void); 957extern void __init efi_memmap_unmap(void);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index a0934e6c9bab..e4eb2546339a 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -57,6 +57,8 @@ struct bpf_prog_aux;
57/* BPF program can access up to 512 bytes of stack space. */ 57/* BPF program can access up to 512 bytes of stack space. */
58#define MAX_BPF_STACK 512 58#define MAX_BPF_STACK 512
59 59
60#define BPF_TAG_SIZE 8
61
60/* Helper macros for filter block array initializers. */ 62/* Helper macros for filter block array initializers. */
61 63
62/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ 64/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
@@ -408,7 +410,7 @@ struct bpf_prog {
408 kmemcheck_bitfield_end(meta); 410 kmemcheck_bitfield_end(meta);
409 enum bpf_prog_type type; /* Type of BPF program */ 411 enum bpf_prog_type type; /* Type of BPF program */
410 u32 len; /* Number of filter blocks */ 412 u32 len; /* Number of filter blocks */
411 u32 digest[SHA_DIGEST_WORDS]; /* Program digest */ 413 u8 tag[BPF_TAG_SIZE];
412 struct bpf_prog_aux *aux; /* Auxiliary fields */ 414 struct bpf_prog_aux *aux; /* Auxiliary fields */
413 struct sock_fprog_kern *orig_prog; /* Original BPF program */ 415 struct sock_fprog_kern *orig_prog; /* Original BPF program */
414 unsigned int (*bpf_func)(const void *ctx, 416 unsigned int (*bpf_func)(const void *ctx,
@@ -519,7 +521,7 @@ static inline u32 bpf_prog_insn_size(const struct bpf_prog *prog)
519 return prog->len * sizeof(struct bpf_insn); 521 return prog->len * sizeof(struct bpf_insn);
520} 522}
521 523
522static inline u32 bpf_prog_digest_scratch_size(const struct bpf_prog *prog) 524static inline u32 bpf_prog_tag_scratch_size(const struct bpf_prog *prog)
523{ 525{
524 return round_up(bpf_prog_insn_size(prog) + 526 return round_up(bpf_prog_insn_size(prog) +
525 sizeof(__be64) + 1, SHA_MESSAGE_BYTES); 527 sizeof(__be64) + 1, SHA_MESSAGE_BYTES);
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 0cf34d6cc253..487246546ebe 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -323,8 +323,6 @@ extern void fsnotify_init_mark(struct fsnotify_mark *mark, void (*free_mark)(str
323extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode); 323extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode);
324/* find (and take a reference) to a mark associated with group and vfsmount */ 324/* find (and take a reference) to a mark associated with group and vfsmount */
325extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt); 325extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt);
326/* copy the values from old into new */
327extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);
328/* set the ignored_mask of a mark */ 326/* set the ignored_mask of a mark */
329extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask); 327extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask);
330/* set the mask of a mark (might pin the object into memory */ 328/* set the mask of a mark (might pin the object into memory */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e0341af6950e..76f39754e7b0 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -146,15 +146,6 @@ enum {
146 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */ 146 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
147}; 147};
148 148
149#define BLK_SCSI_MAX_CMDS (256)
150#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
151
152struct blk_scsi_cmd_filter {
153 unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
154 unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
155 struct kobject kobj;
156};
157
158struct disk_part_tbl { 149struct disk_part_tbl {
159 struct rcu_head rcu_head; 150 struct rcu_head rcu_head;
160 int len; 151 int len;
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 4175dca4ac39..0fe0b6295ab5 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -38,9 +38,8 @@ struct vm_area_struct;
38#define ___GFP_ACCOUNT 0x100000u 38#define ___GFP_ACCOUNT 0x100000u
39#define ___GFP_NOTRACK 0x200000u 39#define ___GFP_NOTRACK 0x200000u
40#define ___GFP_DIRECT_RECLAIM 0x400000u 40#define ___GFP_DIRECT_RECLAIM 0x400000u
41#define ___GFP_OTHER_NODE 0x800000u 41#define ___GFP_WRITE 0x800000u
42#define ___GFP_WRITE 0x1000000u 42#define ___GFP_KSWAPD_RECLAIM 0x1000000u
43#define ___GFP_KSWAPD_RECLAIM 0x2000000u
44/* If the above are modified, __GFP_BITS_SHIFT may need updating */ 43/* If the above are modified, __GFP_BITS_SHIFT may need updating */
45 44
46/* 45/*
@@ -172,11 +171,6 @@ struct vm_area_struct;
172 * __GFP_NOTRACK_FALSE_POSITIVE is an alias of __GFP_NOTRACK. It's a means of 171 * __GFP_NOTRACK_FALSE_POSITIVE is an alias of __GFP_NOTRACK. It's a means of
173 * distinguishing in the source between false positives and allocations that 172 * distinguishing in the source between false positives and allocations that
174 * cannot be supported (e.g. page tables). 173 * cannot be supported (e.g. page tables).
175 *
176 * __GFP_OTHER_NODE is for allocations that are on a remote node but that
177 * should not be accounted for as a remote allocation in vmstat. A
178 * typical user would be khugepaged collapsing a huge page on a remote
179 * node.
180 */ 174 */
181#define __GFP_COLD ((__force gfp_t)___GFP_COLD) 175#define __GFP_COLD ((__force gfp_t)___GFP_COLD)
182#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) 176#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN)
@@ -184,10 +178,9 @@ struct vm_area_struct;
184#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) 178#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO)
185#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) 179#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK)
186#define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK) 180#define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
187#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE)
188 181
189/* Room for N __GFP_FOO bits */ 182/* Room for N __GFP_FOO bits */
190#define __GFP_BITS_SHIFT 26 183#define __GFP_BITS_SHIFT 25
191#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) 184#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
192 185
193/* 186/*
@@ -506,11 +499,10 @@ extern void free_hot_cold_page(struct page *page, bool cold);
506extern void free_hot_cold_page_list(struct list_head *list, bool cold); 499extern void free_hot_cold_page_list(struct list_head *list, bool cold);
507 500
508struct page_frag_cache; 501struct page_frag_cache;
509extern void __page_frag_drain(struct page *page, unsigned int order, 502extern void __page_frag_cache_drain(struct page *page, unsigned int count);
510 unsigned int count); 503extern void *page_frag_alloc(struct page_frag_cache *nc,
511extern void *__alloc_page_frag(struct page_frag_cache *nc, 504 unsigned int fragsz, gfp_t gfp_mask);
512 unsigned int fragsz, gfp_t gfp_mask); 505extern void page_frag_free(void *addr);
513extern void __free_page_frag(void *addr);
514 506
515#define __free_page(page) __free_pages((page), 0) 507#define __free_page(page) __free_pages((page), 0)
516#define free_page(addr) free_pages((addr), 0) 508#define free_page(addr) free_pages((addr), 0)
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index c2748accea71..e973faba69dc 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -274,37 +274,67 @@ void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip,
274 struct irq_chip *irqchip, 274 struct irq_chip *irqchip,
275 int parent_irq); 275 int parent_irq);
276 276
277int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, 277int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
278 struct irq_chip *irqchip,
279 unsigned int first_irq,
280 irq_flow_handler_t handler,
281 unsigned int type,
282 bool nested,
283 struct lock_class_key *lock_key);
284
285#ifdef CONFIG_LOCKDEP
286
287/*
288 * Lockdep requires that each irqchip instance be created with a
289 * unique key so as to avoid unnecessary warnings. This upfront
290 * boilerplate static inlines provides such a key for each
291 * unique instance.
292 */
293static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
294 struct irq_chip *irqchip,
295 unsigned int first_irq,
296 irq_flow_handler_t handler,
297 unsigned int type)
298{
299 static struct lock_class_key key;
300
301 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
302 handler, type, false, &key);
303}
304
305static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
278 struct irq_chip *irqchip, 306 struct irq_chip *irqchip,
279 unsigned int first_irq, 307 unsigned int first_irq,
280 irq_flow_handler_t handler, 308 irq_flow_handler_t handler,
281 unsigned int type, 309 unsigned int type)
282 bool nested, 310{
283 struct lock_class_key *lock_key); 311
312 static struct lock_class_key key;
313
314 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
315 handler, type, true, &key);
316}
317#else
318static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
319 struct irq_chip *irqchip,
320 unsigned int first_irq,
321 irq_flow_handler_t handler,
322 unsigned int type)
323{
324 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
325 handler, type, false, NULL);
326}
284 327
285/* FIXME: I assume threaded IRQchips do not have the lockdep problem */
286static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, 328static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
287 struct irq_chip *irqchip, 329 struct irq_chip *irqchip,
288 unsigned int first_irq, 330 unsigned int first_irq,
289 irq_flow_handler_t handler, 331 irq_flow_handler_t handler,
290 unsigned int type) 332 unsigned int type)
291{ 333{
292 return _gpiochip_irqchip_add(gpiochip, irqchip, first_irq, 334 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
293 handler, type, true, NULL); 335 handler, type, true, NULL);
294} 336}
295 337#endif /* CONFIG_LOCKDEP */
296#ifdef CONFIG_LOCKDEP
297#define gpiochip_irqchip_add(...) \
298( \
299 ({ \
300 static struct lock_class_key _key; \
301 _gpiochip_irqchip_add(__VA_ARGS__, false, &_key); \
302 }) \
303)
304#else
305#define gpiochip_irqchip_add(...) \
306 _gpiochip_irqchip_add(__VA_ARGS__, false, NULL)
307#endif
308 338
309#endif /* CONFIG_GPIOLIB_IRQCHIP */ 339#endif /* CONFIG_GPIOLIB_IRQCHIP */
310 340
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index b2109c522dec..4b45ec46161f 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -665,6 +665,7 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
665#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */ 665#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
666 /* Must equal I2C_M_TEN below */ 666 /* Must equal I2C_M_TEN below */
667#define I2C_CLIENT_SLAVE 0x20 /* we are the slave */ 667#define I2C_CLIENT_SLAVE 0x20 /* we are the slave */
668#define I2C_CLIENT_HOST_NOTIFY 0x40 /* We want to use I2C host notify */
668#define I2C_CLIENT_WAKE 0x80 /* for board_info; true iff can wake */ 669#define I2C_CLIENT_WAKE 0x80 /* for board_info; true iff can wake */
669#define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */ 670#define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */
670 /* Must match I2C_M_STOP|IGNORE_NAK */ 671 /* Must match I2C_M_STOP|IGNORE_NAK */
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 228bd44efa4c..497f2b3a5a62 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -116,6 +116,16 @@ struct st_sensor_bdu {
116}; 116};
117 117
118/** 118/**
119 * struct st_sensor_das - ST sensor device data alignment selection
120 * @addr: address of the register.
121 * @mask: mask to write the das flag for left alignment.
122 */
123struct st_sensor_das {
124 u8 addr;
125 u8 mask;
126};
127
128/**
119 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt 129 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
120 * @addr: address of the register. 130 * @addr: address of the register.
121 * @mask_int1: mask to enable/disable IRQ on INT1 pin. 131 * @mask_int1: mask to enable/disable IRQ on INT1 pin.
@@ -185,6 +195,7 @@ struct st_sensor_transfer_function {
185 * @enable_axis: Enable one or more axis of the sensor. 195 * @enable_axis: Enable one or more axis of the sensor.
186 * @fs: Full scale register and full scale list available. 196 * @fs: Full scale register and full scale list available.
187 * @bdu: Block data update register. 197 * @bdu: Block data update register.
198 * @das: Data Alignment Selection register.
188 * @drdy_irq: Data ready register of the sensor. 199 * @drdy_irq: Data ready register of the sensor.
189 * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. 200 * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read.
190 * @bootime: samples to discard when sensor passing from power-down to power-up. 201 * @bootime: samples to discard when sensor passing from power-down to power-up.
@@ -200,6 +211,7 @@ struct st_sensor_settings {
200 struct st_sensor_axis enable_axis; 211 struct st_sensor_axis enable_axis;
201 struct st_sensor_fullscale fs; 212 struct st_sensor_fullscale fs;
202 struct st_sensor_bdu bdu; 213 struct st_sensor_bdu bdu;
214 struct st_sensor_das das;
203 struct st_sensor_data_ready_irq drdy_irq; 215 struct st_sensor_data_ready_irq drdy_irq;
204 bool multi_read_bit; 216 bool multi_read_bit;
205 unsigned int bootime; 217 unsigned int bootime;
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
index 089f70f83e97..23da3af459fe 100644
--- a/include/linux/jump_label_ratelimit.h
+++ b/include/linux/jump_label_ratelimit.h
@@ -14,6 +14,7 @@ struct static_key_deferred {
14 14
15#ifdef HAVE_JUMP_LABEL 15#ifdef HAVE_JUMP_LABEL
16extern void static_key_slow_dec_deferred(struct static_key_deferred *key); 16extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
17extern void static_key_deferred_flush(struct static_key_deferred *key);
17extern void 18extern void
18jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl); 19jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
19 20
@@ -26,6 +27,10 @@ static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
26 STATIC_KEY_CHECK_USE(); 27 STATIC_KEY_CHECK_USE();
27 static_key_slow_dec(&key->key); 28 static_key_slow_dec(&key->key);
28} 29}
30static inline void static_key_deferred_flush(struct static_key_deferred *key)
31{
32 STATIC_KEY_CHECK_USE();
33}
29static inline void 34static inline void
30jump_label_rate_limit(struct static_key_deferred *key, 35jump_label_rate_limit(struct static_key_deferred *key,
31 unsigned long rl) 36 unsigned long rl)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 56aec84237ad..cb09238f6d32 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -514,8 +514,8 @@ extern enum system_states {
514#define TAINT_FLAGS_COUNT 16 514#define TAINT_FLAGS_COUNT 16
515 515
516struct taint_flag { 516struct taint_flag {
517 char true; /* character printed when tainted */ 517 char c_true; /* character printed when tainted */
518 char false; /* character printed when not tainted */ 518 char c_false; /* character printed when not tainted */
519 bool module; /* also show as a per-module taint flag */ 519 bool module; /* also show as a per-module taint flag */
520}; 520};
521 521
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index ec819e9a115a..b6e048e1045f 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -13,34 +13,10 @@
13#ifndef MDEV_H 13#ifndef MDEV_H
14#define MDEV_H 14#define MDEV_H
15 15
16/* Parent device */ 16struct mdev_device;
17struct parent_device {
18 struct device *dev;
19 const struct parent_ops *ops;
20
21 /* internal */
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
29/* Mediated device */
30struct mdev_device {
31 struct device dev;
32 struct parent_device *parent;
33 uuid_le uuid;
34 void *driver_data;
35
36 /* internal */
37 struct kref ref;
38 struct list_head next;
39 struct kobject *type_kobj;
40};
41 17
42/** 18/**
43 * struct parent_ops - Structure to be registered for each parent device to 19 * struct mdev_parent_ops - Structure to be registered for each parent device to
44 * register the device to mdev module. 20 * register the device to mdev module.
45 * 21 *
46 * @owner: The module owner. 22 * @owner: The module owner.
@@ -86,10 +62,9 @@ struct mdev_device {
86 * @mdev: mediated device structure 62 * @mdev: mediated device structure
87 * @vma: vma structure 63 * @vma: vma structure
88 * Parent device that support mediated device should be registered with mdev 64 * Parent device that support mediated device should be registered with mdev
89 * module with parent_ops structure. 65 * module with mdev_parent_ops structure.
90 **/ 66 **/
91 67struct mdev_parent_ops {
92struct parent_ops {
93 struct module *owner; 68 struct module *owner;
94 const struct attribute_group **dev_attr_groups; 69 const struct attribute_group **dev_attr_groups;
95 const struct attribute_group **mdev_attr_groups; 70 const struct attribute_group **mdev_attr_groups;
@@ -103,7 +78,7 @@ struct parent_ops {
103 size_t count, loff_t *ppos); 78 size_t count, loff_t *ppos);
104 ssize_t (*write)(struct mdev_device *mdev, const char __user *buf, 79 ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
105 size_t count, loff_t *ppos); 80 size_t count, loff_t *ppos);
106 ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd, 81 long (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
107 unsigned long arg); 82 unsigned long arg);
108 int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma); 83 int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
109}; 84};
@@ -142,27 +117,22 @@ struct mdev_driver {
142}; 117};
143 118
144#define to_mdev_driver(drv) container_of(drv, struct mdev_driver, driver) 119#define to_mdev_driver(drv) container_of(drv, struct mdev_driver, driver)
145#define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
146
147static inline void *mdev_get_drvdata(struct mdev_device *mdev)
148{
149 return mdev->driver_data;
150}
151 120
152static inline void mdev_set_drvdata(struct mdev_device *mdev, void *data) 121extern void *mdev_get_drvdata(struct mdev_device *mdev);
153{ 122extern void mdev_set_drvdata(struct mdev_device *mdev, void *data);
154 mdev->driver_data = data; 123extern uuid_le mdev_uuid(struct mdev_device *mdev);
155}
156 124
157extern struct bus_type mdev_bus_type; 125extern struct bus_type mdev_bus_type;
158 126
159#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
160
161extern int mdev_register_device(struct device *dev, 127extern int mdev_register_device(struct device *dev,
162 const struct parent_ops *ops); 128 const struct mdev_parent_ops *ops);
163extern void mdev_unregister_device(struct device *dev); 129extern void mdev_unregister_device(struct device *dev);
164 130
165extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner); 131extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
166extern void mdev_unregister_driver(struct mdev_driver *drv); 132extern void mdev_unregister_driver(struct mdev_driver *drv);
167 133
134extern struct device *mdev_parent_dev(struct mdev_device *mdev);
135extern struct device *mdev_dev(struct mdev_device *mdev);
136extern struct mdev_device *mdev_from_dev(struct device *dev);
137
168#endif /* MDEV_H */ 138#endif /* MDEV_H */
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 61d20c17f3b7..254698856b8f 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -120,7 +120,7 @@ struct mem_cgroup_reclaim_iter {
120 */ 120 */
121struct mem_cgroup_per_node { 121struct mem_cgroup_per_node {
122 struct lruvec lruvec; 122 struct lruvec lruvec;
123 unsigned long lru_size[NR_LRU_LISTS]; 123 unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
124 124
125 struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1]; 125 struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1];
126 126
@@ -432,7 +432,7 @@ static inline bool mem_cgroup_online(struct mem_cgroup *memcg)
432int mem_cgroup_select_victim_node(struct mem_cgroup *memcg); 432int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
433 433
434void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, 434void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
435 int nr_pages); 435 int zid, int nr_pages);
436 436
437unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, 437unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
438 int nid, unsigned int lru_mask); 438 int nid, unsigned int lru_mask);
@@ -441,9 +441,23 @@ static inline
441unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru) 441unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
442{ 442{
443 struct mem_cgroup_per_node *mz; 443 struct mem_cgroup_per_node *mz;
444 unsigned long nr_pages = 0;
445 int zid;
444 446
445 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec); 447 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
446 return mz->lru_size[lru]; 448 for (zid = 0; zid < MAX_NR_ZONES; zid++)
449 nr_pages += mz->lru_zone_size[zid][lru];
450 return nr_pages;
451}
452
453static inline
454unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
455 enum lru_list lru, int zone_idx)
456{
457 struct mem_cgroup_per_node *mz;
458
459 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
460 return mz->lru_zone_size[zone_idx][lru];
447} 461}
448 462
449void mem_cgroup_handle_over_high(void); 463void mem_cgroup_handle_over_high(void);
@@ -671,6 +685,12 @@ mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
671{ 685{
672 return 0; 686 return 0;
673} 687}
688static inline
689unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
690 enum lru_list lru, int zone_idx)
691{
692 return 0;
693}
674 694
675static inline unsigned long 695static inline unsigned long
676mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, 696mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 93bdb3485192..6533c16e27ad 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -1384,6 +1384,8 @@ int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
1384int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv); 1384int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
1385int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port, 1385int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
1386 bool *vlan_offload_disabled); 1386 bool *vlan_offload_disabled);
1387void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
1388 struct _rule_hw *eth_header);
1387int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx); 1389int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
1388int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 1390int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
1389int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 1391int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 9f489365b3d3..52b437431c6a 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -1071,11 +1071,6 @@ enum {
1071 MLX5_INFINIBAND_PORT_COUNTERS_GROUP = 0x20, 1071 MLX5_INFINIBAND_PORT_COUNTERS_GROUP = 0x20,
1072}; 1072};
1073 1073
1074enum {
1075 MLX5_PCIE_PERFORMANCE_COUNTERS_GROUP = 0x0,
1076 MLX5_PCIE_TIMERS_AND_STATES_COUNTERS_GROUP = 0x2,
1077};
1078
1079static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz) 1074static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
1080{ 1075{
1081 if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE) 1076 if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 0ae55361e674..735b36335f29 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -123,7 +123,6 @@ enum {
123 MLX5_REG_HOST_ENDIANNESS = 0x7004, 123 MLX5_REG_HOST_ENDIANNESS = 0x7004,
124 MLX5_REG_MCIA = 0x9014, 124 MLX5_REG_MCIA = 0x9014,
125 MLX5_REG_MLCR = 0x902b, 125 MLX5_REG_MLCR = 0x902b,
126 MLX5_REG_MPCNT = 0x9051,
127}; 126};
128 127
129enum mlx5_dcbx_oper_mode { 128enum mlx5_dcbx_oper_mode {
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 57bec544e20a..a852e9db6f0d 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1757,80 +1757,6 @@ struct mlx5_ifc_eth_802_3_cntrs_grp_data_layout_bits {
1757 u8 reserved_at_4c0[0x300]; 1757 u8 reserved_at_4c0[0x300];
1758}; 1758};
1759 1759
1760struct mlx5_ifc_pcie_perf_cntrs_grp_data_layout_bits {
1761 u8 life_time_counter_high[0x20];
1762
1763 u8 life_time_counter_low[0x20];
1764
1765 u8 rx_errors[0x20];
1766
1767 u8 tx_errors[0x20];
1768
1769 u8 l0_to_recovery_eieos[0x20];
1770
1771 u8 l0_to_recovery_ts[0x20];
1772
1773 u8 l0_to_recovery_framing[0x20];
1774
1775 u8 l0_to_recovery_retrain[0x20];
1776
1777 u8 crc_error_dllp[0x20];
1778
1779 u8 crc_error_tlp[0x20];
1780
1781 u8 reserved_at_140[0x680];
1782};
1783
1784struct mlx5_ifc_pcie_tas_cntrs_grp_data_layout_bits {
1785 u8 life_time_counter_high[0x20];
1786
1787 u8 life_time_counter_low[0x20];
1788
1789 u8 time_to_boot_image_start[0x20];
1790
1791 u8 time_to_link_image[0x20];
1792
1793 u8 calibration_time[0x20];
1794
1795 u8 time_to_first_perst[0x20];
1796
1797 u8 time_to_detect_state[0x20];
1798
1799 u8 time_to_l0[0x20];
1800
1801 u8 time_to_crs_en[0x20];
1802
1803 u8 time_to_plastic_image_start[0x20];
1804
1805 u8 time_to_iron_image_start[0x20];
1806
1807 u8 perst_handler[0x20];
1808
1809 u8 times_in_l1[0x20];
1810
1811 u8 times_in_l23[0x20];
1812
1813 u8 dl_down[0x20];
1814
1815 u8 config_cycle1usec[0x20];
1816
1817 u8 config_cycle2to7usec[0x20];
1818
1819 u8 config_cycle_8to15usec[0x20];
1820
1821 u8 config_cycle_16_to_63usec[0x20];
1822
1823 u8 config_cycle_64usec[0x20];
1824
1825 u8 correctable_err_msg_sent[0x20];
1826
1827 u8 non_fatal_err_msg_sent[0x20];
1828
1829 u8 fatal_err_msg_sent[0x20];
1830
1831 u8 reserved_at_2e0[0x4e0];
1832};
1833
1834struct mlx5_ifc_cmd_inter_comp_event_bits { 1760struct mlx5_ifc_cmd_inter_comp_event_bits {
1835 u8 command_completion_vector[0x20]; 1761 u8 command_completion_vector[0x20];
1836 1762
@@ -2995,12 +2921,6 @@ union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits {
2995 u8 reserved_at_0[0x7c0]; 2921 u8 reserved_at_0[0x7c0];
2996}; 2922};
2997 2923
2998union mlx5_ifc_pcie_cntrs_grp_data_layout_auto_bits {
2999 struct mlx5_ifc_pcie_perf_cntrs_grp_data_layout_bits pcie_perf_cntrs_grp_data_layout;
3000 struct mlx5_ifc_pcie_tas_cntrs_grp_data_layout_bits pcie_tas_cntrs_grp_data_layout;
3001 u8 reserved_at_0[0x7c0];
3002};
3003
3004union mlx5_ifc_event_auto_bits { 2924union mlx5_ifc_event_auto_bits {
3005 struct mlx5_ifc_comp_event_bits comp_event; 2925 struct mlx5_ifc_comp_event_bits comp_event;
3006 struct mlx5_ifc_dct_events_bits dct_events; 2926 struct mlx5_ifc_dct_events_bits dct_events;
@@ -7320,18 +7240,6 @@ struct mlx5_ifc_ppcnt_reg_bits {
7320 union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits counter_set; 7240 union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits counter_set;
7321}; 7241};
7322 7242
7323struct mlx5_ifc_mpcnt_reg_bits {
7324 u8 reserved_at_0[0x8];
7325 u8 pcie_index[0x8];
7326 u8 reserved_at_10[0xa];
7327 u8 grp[0x6];
7328
7329 u8 clr[0x1];
7330 u8 reserved_at_21[0x1f];
7331
7332 union mlx5_ifc_pcie_cntrs_grp_data_layout_auto_bits counter_set;
7333};
7334
7335struct mlx5_ifc_ppad_reg_bits { 7243struct mlx5_ifc_ppad_reg_bits {
7336 u8 reserved_at_0[0x3]; 7244 u8 reserved_at_0[0x3];
7337 u8 single_mac[0x1]; 7245 u8 single_mac[0x1];
@@ -7937,7 +7845,6 @@ union mlx5_ifc_ports_control_registers_document_bits {
7937 struct mlx5_ifc_pmtu_reg_bits pmtu_reg; 7845 struct mlx5_ifc_pmtu_reg_bits pmtu_reg;
7938 struct mlx5_ifc_ppad_reg_bits ppad_reg; 7846 struct mlx5_ifc_ppad_reg_bits ppad_reg;
7939 struct mlx5_ifc_ppcnt_reg_bits ppcnt_reg; 7847 struct mlx5_ifc_ppcnt_reg_bits ppcnt_reg;
7940 struct mlx5_ifc_mpcnt_reg_bits mpcnt_reg;
7941 struct mlx5_ifc_pplm_reg_bits pplm_reg; 7848 struct mlx5_ifc_pplm_reg_bits pplm_reg;
7942 struct mlx5_ifc_pplr_reg_bits pplr_reg; 7849 struct mlx5_ifc_pplr_reg_bits pplr_reg;
7943 struct mlx5_ifc_ppsc_reg_bits ppsc_reg; 7850 struct mlx5_ifc_ppsc_reg_bits ppsc_reg;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fe6b4036664a..b84615b0f64c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1210,8 +1210,8 @@ int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
1210 struct vm_area_struct *vma); 1210 struct vm_area_struct *vma);
1211void unmap_mapping_range(struct address_space *mapping, 1211void unmap_mapping_range(struct address_space *mapping,
1212 loff_t const holebegin, loff_t const holelen, int even_cows); 1212 loff_t const holebegin, loff_t const holelen, int even_cows);
1213int follow_pte(struct mm_struct *mm, unsigned long address, pte_t **ptepp, 1213int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
1214 spinlock_t **ptlp); 1214 pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
1215int follow_pfn(struct vm_area_struct *vma, unsigned long address, 1215int follow_pfn(struct vm_area_struct *vma, unsigned long address,
1216 unsigned long *pfn); 1216 unsigned long *pfn);
1217int follow_phys(struct vm_area_struct *vma, unsigned long address, 1217int follow_phys(struct vm_area_struct *vma, unsigned long address,
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 71613e8a720f..41d376e7116d 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -39,7 +39,7 @@ static __always_inline void update_lru_size(struct lruvec *lruvec,
39{ 39{
40 __update_lru_size(lruvec, lru, zid, nr_pages); 40 __update_lru_size(lruvec, lru, zid, nr_pages);
41#ifdef CONFIG_MEMCG 41#ifdef CONFIG_MEMCG
42 mem_cgroup_update_lru_size(lruvec, lru, nr_pages); 42 mem_cgroup_update_lru_size(lruvec, lru, zid, nr_pages);
43#endif 43#endif
44} 44}
45 45
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 994f7423a74b..9bde9558b596 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2477,14 +2477,19 @@ static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen)
2477 return NAPI_GRO_CB(skb)->frag0_len < hlen; 2477 return NAPI_GRO_CB(skb)->frag0_len < hlen;
2478} 2478}
2479 2479
2480static inline void skb_gro_frag0_invalidate(struct sk_buff *skb)
2481{
2482 NAPI_GRO_CB(skb)->frag0 = NULL;
2483 NAPI_GRO_CB(skb)->frag0_len = 0;
2484}
2485
2480static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen, 2486static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
2481 unsigned int offset) 2487 unsigned int offset)
2482{ 2488{
2483 if (!pskb_may_pull(skb, hlen)) 2489 if (!pskb_may_pull(skb, hlen))
2484 return NULL; 2490 return NULL;
2485 2491
2486 NAPI_GRO_CB(skb)->frag0 = NULL; 2492 skb_gro_frag0_invalidate(skb);
2487 NAPI_GRO_CB(skb)->frag0_len = 0;
2488 return skb->data + offset; 2493 return skb->data + offset;
2489} 2494}
2490 2495
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 4741ecdb9817..78ed8105e64d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1259,6 +1259,7 @@ extern void perf_event_disable(struct perf_event *event);
1259extern void perf_event_disable_local(struct perf_event *event); 1259extern void perf_event_disable_local(struct perf_event *event);
1260extern void perf_event_disable_inatomic(struct perf_event *event); 1260extern void perf_event_disable_inatomic(struct perf_event *event);
1261extern void perf_event_task_tick(void); 1261extern void perf_event_task_tick(void);
1262extern int perf_event_account_interrupt(struct perf_event *event);
1262#else /* !CONFIG_PERF_EVENTS: */ 1263#else /* !CONFIG_PERF_EVENTS: */
1263static inline void * 1264static inline void *
1264perf_aux_output_begin(struct perf_output_handle *handle, 1265perf_aux_output_begin(struct perf_output_handle *handle,
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 5dea8f6440e4..52bda854593b 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -306,7 +306,9 @@ void radix_tree_iter_replace(struct radix_tree_root *,
306void radix_tree_replace_slot(struct radix_tree_root *root, 306void radix_tree_replace_slot(struct radix_tree_root *root,
307 void **slot, void *item); 307 void **slot, void *item);
308void __radix_tree_delete_node(struct radix_tree_root *root, 308void __radix_tree_delete_node(struct radix_tree_root *root,
309 struct radix_tree_node *node); 309 struct radix_tree_node *node,
310 radix_tree_update_node_t update_node,
311 void *private);
310void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *); 312void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *);
311void *radix_tree_delete(struct radix_tree_root *, unsigned long); 313void *radix_tree_delete(struct radix_tree_root *, unsigned long);
312void radix_tree_clear_tags(struct radix_tree_root *root, 314void radix_tree_clear_tags(struct radix_tree_root *root,
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 321f9ed552a9..01f71e1d2e94 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -444,6 +444,10 @@ bool __rcu_is_watching(void);
444#error "Unknown RCU implementation specified to kernel configuration" 444#error "Unknown RCU implementation specified to kernel configuration"
445#endif 445#endif
446 446
447#define RCU_SCHEDULER_INACTIVE 0
448#define RCU_SCHEDULER_INIT 1
449#define RCU_SCHEDULER_RUNNING 2
450
447/* 451/*
448 * init_rcu_head_on_stack()/destroy_rcu_head_on_stack() are needed for dynamic 452 * init_rcu_head_on_stack()/destroy_rcu_head_on_stack() are needed for dynamic
449 * initialization and destruction of rcu_head on the stack. rcu_head structures 453 * initialization and destruction of rcu_head on the stack. rcu_head structures
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index e2f3a3281d8f..8265d351c9f0 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -408,7 +408,8 @@ enum rproc_crash_type {
408 * @crash_comp: completion used to sync crash handler and the rproc reload 408 * @crash_comp: completion used to sync crash handler and the rproc reload
409 * @recovery_disabled: flag that state if recovery was disabled 409 * @recovery_disabled: flag that state if recovery was disabled
410 * @max_notifyid: largest allocated notify id. 410 * @max_notifyid: largest allocated notify id.
411 * @table_ptr: our copy of the resource table 411 * @table_ptr: pointer to the resource table in effect
412 * @cached_table: copy of the resource table
412 * @has_iommu: flag to indicate if remote processor is behind an MMU 413 * @has_iommu: flag to indicate if remote processor is behind an MMU
413 */ 414 */
414struct rproc { 415struct rproc {
@@ -440,6 +441,7 @@ struct rproc {
440 bool recovery_disabled; 441 bool recovery_disabled;
441 int max_notifyid; 442 int max_notifyid;
442 struct resource_table *table_ptr; 443 struct resource_table *table_ptr;
444 struct resource_table *cached_table;
443 bool has_iommu; 445 bool has_iommu;
444 bool auto_boot; 446 bool auto_boot;
445}; 447};
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4d1905245c7a..ad3ec9ec61f7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -854,6 +854,16 @@ struct signal_struct {
854 854
855#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */ 855#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
856 856
857#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
858 SIGNAL_STOP_CONTINUED)
859
860static inline void signal_set_stop_flags(struct signal_struct *sig,
861 unsigned int flags)
862{
863 WARN_ON(sig->flags & (SIGNAL_GROUP_EXIT|SIGNAL_GROUP_COREDUMP));
864 sig->flags = (sig->flags & ~SIGNAL_STOP_MASK) | flags;
865}
866
857/* If true, all threads except ->group_exit_task have pending SIGKILL */ 867/* If true, all threads except ->group_exit_task have pending SIGKILL */
858static inline int signal_group_exit(const struct signal_struct *sig) 868static inline int signal_group_exit(const struct signal_struct *sig)
859{ 869{
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..a410715bbef8 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2480,7 +2480,7 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
2480 2480
2481static inline void skb_free_frag(void *addr) 2481static inline void skb_free_frag(void *addr)
2482{ 2482{
2483 __free_page_frag(addr); 2483 page_frag_free(addr);
2484} 2484}
2485 2485
2486void *napi_alloc_frag(unsigned int fragsz); 2486void *napi_alloc_frag(unsigned int fragsz);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 084b12bad198..4c5363566815 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -226,7 +226,7 @@ static inline const char *__check_heap_object(const void *ptr,
226 * (PAGE_SIZE*2). Larger requests are passed to the page allocator. 226 * (PAGE_SIZE*2). Larger requests are passed to the page allocator.
227 */ 227 */
228#define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) 228#define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1)
229#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT) 229#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1)
230#ifndef KMALLOC_SHIFT_LOW 230#ifndef KMALLOC_SHIFT_LOW
231#define KMALLOC_SHIFT_LOW 3 231#define KMALLOC_SHIFT_LOW 3
232#endif 232#endif
@@ -239,7 +239,7 @@ static inline const char *__check_heap_object(const void *ptr,
239 * be allocated from the same page. 239 * be allocated from the same page.
240 */ 240 */
241#define KMALLOC_SHIFT_HIGH PAGE_SHIFT 241#define KMALLOC_SHIFT_HIGH PAGE_SHIFT
242#define KMALLOC_SHIFT_MAX 30 242#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1)
243#ifndef KMALLOC_SHIFT_LOW 243#ifndef KMALLOC_SHIFT_LOW
244#define KMALLOC_SHIFT_LOW 3 244#define KMALLOC_SHIFT_LOW 3
245#endif 245#endif
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index e5d193440374..7440290f64ac 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -66,6 +66,7 @@ struct svc_xprt {
66#define XPT_LISTENER 10 /* listening endpoint */ 66#define XPT_LISTENER 10 /* listening endpoint */
67#define XPT_CACHE_AUTH 11 /* cache auth info */ 67#define XPT_CACHE_AUTH 11 /* cache auth info */
68#define XPT_LOCAL 12 /* connection from loopback interface */ 68#define XPT_LOCAL 12 /* connection from loopback interface */
69#define XPT_KILL_TEMP 13 /* call xpo_kill_temp_xprt before closing */
69 70
70 struct svc_serv *xpt_server; /* service for transport */ 71 struct svc_serv *xpt_server; /* service for transport */
71 atomic_t xpt_reserved; /* space on outq that is rsvd */ 72 atomic_t xpt_reserved; /* space on outq that is rsvd */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 09f4be179ff3..7f47b7098b1b 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -150,8 +150,9 @@ enum {
150 SWP_FILE = (1 << 7), /* set after swap_activate success */ 150 SWP_FILE = (1 << 7), /* set after swap_activate success */
151 SWP_AREA_DISCARD = (1 << 8), /* single-time swap area discards */ 151 SWP_AREA_DISCARD = (1 << 8), /* single-time swap area discards */
152 SWP_PAGE_DISCARD = (1 << 9), /* freed swap page-cluster discards */ 152 SWP_PAGE_DISCARD = (1 << 9), /* freed swap page-cluster discards */
153 SWP_STABLE_WRITES = (1 << 10), /* no overwrite PG_writeback pages */
153 /* add others here before... */ 154 /* add others here before... */
154 SWP_SCANNING = (1 << 10), /* refcount in scan_swap_map */ 155 SWP_SCANNING = (1 << 11), /* refcount in scan_swap_map */
155}; 156};
156 157
157#define SWAP_CLUSTER_MAX 32UL 158#define SWAP_CLUSTER_MAX 32UL
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 183f37c8a5e1..4ee479f2f355 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -9,7 +9,13 @@ struct device;
9struct page; 9struct page;
10struct scatterlist; 10struct scatterlist;
11 11
12extern int swiotlb_force; 12enum swiotlb_force {
13 SWIOTLB_NORMAL, /* Default - depending on HW DMA mask etc. */
14 SWIOTLB_FORCE, /* swiotlb=force */
15 SWIOTLB_NO_FORCE, /* swiotlb=noforce */
16};
17
18extern enum swiotlb_force swiotlb_force;
13 19
14/* 20/*
15 * Maximum allowable number of contiguous slabs to map, 21 * Maximum allowable number of contiguous slabs to map,
@@ -108,11 +114,14 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask);
108 114
109#ifdef CONFIG_SWIOTLB 115#ifdef CONFIG_SWIOTLB
110extern void __init swiotlb_free(void); 116extern void __init swiotlb_free(void);
117unsigned int swiotlb_max_segment(void);
111#else 118#else
112static inline void swiotlb_free(void) { } 119static inline void swiotlb_free(void) { }
120static inline unsigned int swiotlb_max_segment(void) { return 0; }
113#endif 121#endif
114 122
115extern void swiotlb_print_info(void); 123extern void swiotlb_print_info(void);
116extern int is_swiotlb_buffer(phys_addr_t paddr); 124extern int is_swiotlb_buffer(phys_addr_t paddr);
125extern void swiotlb_set_max_segment(unsigned int);
117 126
118#endif /* __LINUX_SWIOTLB_H */ 127#endif /* __LINUX_SWIOTLB_H */
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index fc5848dad7a4..c93f4b3a59cb 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -62,8 +62,13 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb)
62 62
63/* TCP Fast Open Cookie as stored in memory */ 63/* TCP Fast Open Cookie as stored in memory */
64struct tcp_fastopen_cookie { 64struct tcp_fastopen_cookie {
65 union {
66 u8 val[TCP_FASTOPEN_COOKIE_MAX];
67#if IS_ENABLED(CONFIG_IPV6)
68 struct in6_addr addr;
69#endif
70 };
65 s8 len; 71 s8 len;
66 u8 val[TCP_FASTOPEN_COOKIE_MAX];
67 bool exp; /* In RFC6994 experimental option format */ 72 bool exp; /* In RFC6994 experimental option format */
68}; 73};
69 74
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index bd36ce431e32..bab0b1ad0613 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -8,23 +8,7 @@
8#ifndef _LINUX_TIMERFD_H 8#ifndef _LINUX_TIMERFD_H
9#define _LINUX_TIMERFD_H 9#define _LINUX_TIMERFD_H
10 10
11/* For O_CLOEXEC and O_NONBLOCK */ 11#include <uapi/linux/timerfd.h>
12#include <linux/fcntl.h>
13
14/* For _IO helpers */
15#include <linux/ioctl.h>
16
17/*
18 * CAREFUL: Check include/asm-generic/fcntl.h when defining
19 * new flags, since they might collide with O_* ones. We want
20 * to re-use O_* flags that couldn't possibly have a meaning
21 * from eventfd, in order to leave a free define-space for
22 * shared O_* flags.
23 */
24#define TFD_TIMER_ABSTIME (1 << 0)
25#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
26#define TFD_CLOEXEC O_CLOEXEC
27#define TFD_NONBLOCK O_NONBLOCK
28 12
29#define TFD_SHARED_FCNTL_FLAGS (TFD_CLOEXEC | TFD_NONBLOCK) 13#define TFD_SHARED_FCNTL_FLAGS (TFD_CLOEXEC | TFD_NONBLOCK)
30/* Flags for timerfd_create. */ 14/* Flags for timerfd_create. */
@@ -32,6 +16,4 @@
32/* Flags for timerfd_settime. */ 16/* Flags for timerfd_settime. */
33#define TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET) 17#define TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET)
34 18
35#define TFD_IOC_SET_TICKS _IOW('T', 0, u64)
36
37#endif /* _LINUX_TIMERFD_H */ 19#endif /* _LINUX_TIMERFD_H */
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 96dd0b3f70d7..da5033dd8cbc 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -809,11 +809,11 @@ static inline void fc_set_wwnn(struct fc_lport *lport, u64 wwnn)
809/** 809/**
810 * fc_set_wwpn() - Set the World Wide Port Name of a local port 810 * fc_set_wwpn() - Set the World Wide Port Name of a local port
811 * @lport: The local port whose WWPN is to be set 811 * @lport: The local port whose WWPN is to be set
812 * @wwnn: The new WWPN 812 * @wwpn: The new WWPN
813 */ 813 */
814static inline void fc_set_wwpn(struct fc_lport *lport, u64 wwnn) 814static inline void fc_set_wwpn(struct fc_lport *lport, u64 wwpn)
815{ 815{
816 lport->wwpn = wwnn; 816 lport->wwpn = wwpn;
817} 817}
818 818
819/** 819/**
diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 530c57bdefa0..915c4357945c 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -36,10 +36,10 @@ struct hdmi_codec_daifmt {
36 HDMI_AC97, 36 HDMI_AC97,
37 HDMI_SPDIF, 37 HDMI_SPDIF,
38 } fmt; 38 } fmt;
39 int bit_clk_inv:1; 39 unsigned int bit_clk_inv:1;
40 int frame_clk_inv:1; 40 unsigned int frame_clk_inv:1;
41 int bit_clk_master:1; 41 unsigned int bit_clk_master:1;
42 int frame_clk_master:1; 42 unsigned int frame_clk_master:1;
43}; 43};
44 44
45/* 45/*
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2b502f6cc6d0..b86168a21d56 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -813,6 +813,7 @@ struct snd_soc_component {
813 unsigned int suspended:1; /* is in suspend PM state */ 813 unsigned int suspended:1; /* is in suspend PM state */
814 814
815 struct list_head list; 815 struct list_head list;
816 struct list_head card_aux_list; /* for auxiliary bound components */
816 struct list_head card_list; 817 struct list_head card_list;
817 818
818 struct snd_soc_dai_driver *dai_drv; 819 struct snd_soc_dai_driver *dai_drv;
@@ -1152,6 +1153,7 @@ struct snd_soc_card {
1152 */ 1153 */
1153 struct snd_soc_aux_dev *aux_dev; 1154 struct snd_soc_aux_dev *aux_dev;
1154 int num_aux_devs; 1155 int num_aux_devs;
1156 struct list_head aux_comp_list;
1155 1157
1156 const struct snd_kcontrol_new *controls; 1158 const struct snd_kcontrol_new *controls;
1157 int num_controls; 1159 int num_controls;
@@ -1547,6 +1549,7 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
1547 INIT_LIST_HEAD(&card->widgets); 1549 INIT_LIST_HEAD(&card->widgets);
1548 INIT_LIST_HEAD(&card->paths); 1550 INIT_LIST_HEAD(&card->paths);
1549 INIT_LIST_HEAD(&card->dapm_list); 1551 INIT_LIST_HEAD(&card->dapm_list);
1552 INIT_LIST_HEAD(&card->aux_comp_list);
1550 INIT_LIST_HEAD(&card->component_dev_list); 1553 INIT_LIST_HEAD(&card->component_dev_list);
1551} 1554}
1552 1555
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 29e6858bb164..43edf82e54ff 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -174,6 +174,10 @@ enum tcm_sense_reason_table {
174 TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = R(0x16), 174 TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = R(0x16),
175 TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = R(0x17), 175 TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = R(0x17),
176 TCM_COPY_TARGET_DEVICE_NOT_REACHABLE = R(0x18), 176 TCM_COPY_TARGET_DEVICE_NOT_REACHABLE = R(0x18),
177 TCM_TOO_MANY_TARGET_DESCS = R(0x19),
178 TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE = R(0x1a),
179 TCM_TOO_MANY_SEGMENT_DESCS = R(0x1b),
180 TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c),
177#undef R 181#undef R
178}; 182};
179 183
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c14bed4ab097..88d18a8ceb59 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -130,8 +130,8 @@ DECLARE_EVENT_CLASS(btrfs__inode,
130 BTRFS_I(inode)->root->root_key.objectid; 130 BTRFS_I(inode)->root->root_key.objectid;
131 ), 131 ),
132 132
133 TP_printk_btrfs("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, " 133 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
134 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu", 134 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
135 show_root_type(__entry->root_objectid), 135 show_root_type(__entry->root_objectid),
136 (unsigned long long)__entry->generation, 136 (unsigned long long)__entry->generation,
137 (unsigned long)__entry->ino, 137 (unsigned long)__entry->ino,
@@ -184,14 +184,16 @@ DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
184 184
185TRACE_EVENT_CONDITION(btrfs_get_extent, 185TRACE_EVENT_CONDITION(btrfs_get_extent,
186 186
187 TP_PROTO(struct btrfs_root *root, struct extent_map *map), 187 TP_PROTO(struct btrfs_root *root, struct inode *inode,
188 struct extent_map *map),
188 189
189 TP_ARGS(root, map), 190 TP_ARGS(root, inode, map),
190 191
191 TP_CONDITION(map), 192 TP_CONDITION(map),
192 193
193 TP_STRUCT__entry_btrfs( 194 TP_STRUCT__entry_btrfs(
194 __field( u64, root_objectid ) 195 __field( u64, root_objectid )
196 __field( u64, ino )
195 __field( u64, start ) 197 __field( u64, start )
196 __field( u64, len ) 198 __field( u64, len )
197 __field( u64, orig_start ) 199 __field( u64, orig_start )
@@ -204,7 +206,8 @@ TRACE_EVENT_CONDITION(btrfs_get_extent,
204 206
205 TP_fast_assign_btrfs(root->fs_info, 207 TP_fast_assign_btrfs(root->fs_info,
206 __entry->root_objectid = root->root_key.objectid; 208 __entry->root_objectid = root->root_key.objectid;
207 __entry->start = map->start; 209 __entry->ino = btrfs_ino(inode);
210 __entry->start = map->start;
208 __entry->len = map->len; 211 __entry->len = map->len;
209 __entry->orig_start = map->orig_start; 212 __entry->orig_start = map->orig_start;
210 __entry->block_start = map->block_start; 213 __entry->block_start = map->block_start;
@@ -214,11 +217,12 @@ TRACE_EVENT_CONDITION(btrfs_get_extent,
214 __entry->compress_type = map->compress_type; 217 __entry->compress_type = map->compress_type;
215 ), 218 ),
216 219
217 TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu, " 220 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
218 "orig_start = %llu, block_start = %llu(%s), " 221 "orig_start=%llu block_start=%llu(%s) "
219 "block_len = %llu, flags = %s, refs = %u, " 222 "block_len=%llu flags=%s refs=%u "
220 "compress_type = %u", 223 "compress_type=%u",
221 show_root_type(__entry->root_objectid), 224 show_root_type(__entry->root_objectid),
225 (unsigned long long)__entry->ino,
222 (unsigned long long)__entry->start, 226 (unsigned long long)__entry->start,
223 (unsigned long long)__entry->len, 227 (unsigned long long)__entry->len,
224 (unsigned long long)__entry->orig_start, 228 (unsigned long long)__entry->orig_start,
@@ -259,6 +263,7 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
259 __field( int, compress_type ) 263 __field( int, compress_type )
260 __field( int, refs ) 264 __field( int, refs )
261 __field( u64, root_objectid ) 265 __field( u64, root_objectid )
266 __field( u64, truncated_len )
262 ), 267 ),
263 268
264 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 269 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
@@ -273,18 +278,21 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
273 __entry->refs = atomic_read(&ordered->refs); 278 __entry->refs = atomic_read(&ordered->refs);
274 __entry->root_objectid = 279 __entry->root_objectid =
275 BTRFS_I(inode)->root->root_key.objectid; 280 BTRFS_I(inode)->root->root_key.objectid;
281 __entry->truncated_len = ordered->truncated_len;
276 ), 282 ),
277 283
278 TP_printk_btrfs("root = %llu(%s), ino = %llu, file_offset = %llu, " 284 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
279 "start = %llu, len = %llu, disk_len = %llu, " 285 "start=%llu len=%llu disk_len=%llu "
280 "bytes_left = %llu, flags = %s, compress_type = %d, " 286 "truncated_len=%llu "
281 "refs = %d", 287 "bytes_left=%llu flags=%s compress_type=%d "
288 "refs=%d",
282 show_root_type(__entry->root_objectid), 289 show_root_type(__entry->root_objectid),
283 (unsigned long long)__entry->ino, 290 (unsigned long long)__entry->ino,
284 (unsigned long long)__entry->file_offset, 291 (unsigned long long)__entry->file_offset,
285 (unsigned long long)__entry->start, 292 (unsigned long long)__entry->start,
286 (unsigned long long)__entry->len, 293 (unsigned long long)__entry->len,
287 (unsigned long long)__entry->disk_len, 294 (unsigned long long)__entry->disk_len,
295 (unsigned long long)__entry->truncated_len,
288 (unsigned long long)__entry->bytes_left, 296 (unsigned long long)__entry->bytes_left,
289 show_ordered_flags(__entry->flags), 297 show_ordered_flags(__entry->flags),
290 __entry->compress_type, __entry->refs) 298 __entry->compress_type, __entry->refs)
@@ -354,10 +362,10 @@ DECLARE_EVENT_CLASS(btrfs__writepage,
354 BTRFS_I(inode)->root->root_key.objectid; 362 BTRFS_I(inode)->root->root_key.objectid;
355 ), 363 ),
356 364
357 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, " 365 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
358 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, " 366 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
359 "range_end = %llu, for_kupdate = %d, " 367 "range_end=%llu for_kupdate=%d "
360 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu", 368 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
361 show_root_type(__entry->root_objectid), 369 show_root_type(__entry->root_objectid),
362 (unsigned long)__entry->ino, __entry->index, 370 (unsigned long)__entry->ino, __entry->index,
363 __entry->nr_to_write, __entry->pages_skipped, 371 __entry->nr_to_write, __entry->pages_skipped,
@@ -400,8 +408,8 @@ TRACE_EVENT(btrfs_writepage_end_io_hook,
400 BTRFS_I(page->mapping->host)->root->root_key.objectid; 408 BTRFS_I(page->mapping->host)->root->root_key.objectid;
401 ), 409 ),
402 410
403 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, " 411 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
404 "end = %llu, uptodate = %d", 412 "end=%llu uptodate=%d",
405 show_root_type(__entry->root_objectid), 413 show_root_type(__entry->root_objectid),
406 (unsigned long)__entry->ino, (unsigned long)__entry->index, 414 (unsigned long)__entry->ino, (unsigned long)__entry->index,
407 (unsigned long long)__entry->start, 415 (unsigned long long)__entry->start,
@@ -433,7 +441,7 @@ TRACE_EVENT(btrfs_sync_file,
433 BTRFS_I(inode)->root->root_key.objectid; 441 BTRFS_I(inode)->root->root_key.objectid;
434 ), 442 ),
435 443
436 TP_printk_btrfs("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d", 444 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
437 show_root_type(__entry->root_objectid), 445 show_root_type(__entry->root_objectid),
438 (unsigned long)__entry->ino, (unsigned long)__entry->parent, 446 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
439 __entry->datasync) 447 __entry->datasync)
@@ -484,9 +492,9 @@ TRACE_EVENT(btrfs_add_block_group,
484 __entry->create = create; 492 __entry->create = create;
485 ), 493 ),
486 494
487 TP_printk("%pU: block_group offset = %llu, size = %llu, " 495 TP_printk("%pU: block_group offset=%llu size=%llu "
488 "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, " 496 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
489 "create = %d", __entry->fsid, 497 "create=%d", __entry->fsid,
490 (unsigned long long)__entry->offset, 498 (unsigned long long)__entry->offset,
491 (unsigned long long)__entry->size, 499 (unsigned long long)__entry->size,
492 (unsigned long long)__entry->flags, 500 (unsigned long long)__entry->flags,
@@ -535,9 +543,9 @@ DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
535 __entry->seq = ref->seq; 543 __entry->seq = ref->seq;
536 ), 544 ),
537 545
538 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, " 546 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
539 "parent = %llu(%s), ref_root = %llu(%s), level = %d, " 547 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
540 "type = %s, seq = %llu", 548 "type=%s seq=%llu",
541 (unsigned long long)__entry->bytenr, 549 (unsigned long long)__entry->bytenr,
542 (unsigned long long)__entry->num_bytes, 550 (unsigned long long)__entry->num_bytes,
543 show_ref_action(__entry->action), 551 show_ref_action(__entry->action),
@@ -600,9 +608,9 @@ DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
600 __entry->seq = ref->seq; 608 __entry->seq = ref->seq;
601 ), 609 ),
602 610
603 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, " 611 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
604 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, " 612 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
605 "offset = %llu, type = %s, seq = %llu", 613 "offset=%llu type=%s seq=%llu",
606 (unsigned long long)__entry->bytenr, 614 (unsigned long long)__entry->bytenr,
607 (unsigned long long)__entry->num_bytes, 615 (unsigned long long)__entry->num_bytes,
608 show_ref_action(__entry->action), 616 show_ref_action(__entry->action),
@@ -657,7 +665,7 @@ DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
657 __entry->is_data = head_ref->is_data; 665 __entry->is_data = head_ref->is_data;
658 ), 666 ),
659 667
660 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d", 668 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
661 (unsigned long long)__entry->bytenr, 669 (unsigned long long)__entry->bytenr,
662 (unsigned long long)__entry->num_bytes, 670 (unsigned long long)__entry->num_bytes,
663 show_ref_action(__entry->action), 671 show_ref_action(__entry->action),
@@ -721,8 +729,8 @@ DECLARE_EVENT_CLASS(btrfs__chunk,
721 __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 729 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
722 ), 730 ),
723 731
724 TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, " 732 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
725 "num_stripes = %d, sub_stripes = %d, type = %s", 733 "num_stripes=%d sub_stripes=%d type=%s",
726 show_root_type(__entry->root_objectid), 734 show_root_type(__entry->root_objectid),
727 (unsigned long long)__entry->offset, 735 (unsigned long long)__entry->offset,
728 (unsigned long long)__entry->size, 736 (unsigned long long)__entry->size,
@@ -771,8 +779,8 @@ TRACE_EVENT(btrfs_cow_block,
771 __entry->cow_level = btrfs_header_level(cow); 779 __entry->cow_level = btrfs_header_level(cow);
772 ), 780 ),
773 781
774 TP_printk_btrfs("root = %llu(%s), refs = %d, orig_buf = %llu " 782 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
775 "(orig_level = %d), cow_buf = %llu (cow_level = %d)", 783 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
776 show_root_type(__entry->root_objectid), 784 show_root_type(__entry->root_objectid),
777 __entry->refs, 785 __entry->refs,
778 (unsigned long long)__entry->buf_start, 786 (unsigned long long)__entry->buf_start,
@@ -836,7 +844,7 @@ TRACE_EVENT(btrfs_trigger_flush,
836 __assign_str(reason, reason) 844 __assign_str(reason, reason)
837 ), 845 ),
838 846
839 TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu", 847 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
840 __entry->fsid, __get_str(reason), __entry->flush, 848 __entry->fsid, __get_str(reason), __entry->flush,
841 show_flush_action(__entry->flush), 849 show_flush_action(__entry->flush),
842 (unsigned long long)__entry->flags, 850 (unsigned long long)__entry->flags,
@@ -879,8 +887,8 @@ TRACE_EVENT(btrfs_flush_space,
879 __entry->ret = ret; 887 __entry->ret = ret;
880 ), 888 ),
881 889
882 TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, " 890 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu "
883 "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state, 891 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state,
884 show_flush_state(__entry->state), 892 show_flush_state(__entry->state),
885 (unsigned long long)__entry->flags, 893 (unsigned long long)__entry->flags,
886 __print_flags((unsigned long)__entry->flags, "|", 894 __print_flags((unsigned long)__entry->flags, "|",
@@ -905,7 +913,7 @@ DECLARE_EVENT_CLASS(btrfs__reserved_extent,
905 __entry->len = len; 913 __entry->len = len;
906 ), 914 ),
907 915
908 TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu", 916 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
909 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 917 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
910 (unsigned long long)__entry->start, 918 (unsigned long long)__entry->start,
911 (unsigned long long)__entry->len) 919 (unsigned long long)__entry->len)
@@ -944,7 +952,7 @@ TRACE_EVENT(find_free_extent,
944 __entry->data = data; 952 __entry->data = data;
945 ), 953 ),
946 954
947 TP_printk_btrfs("root = %Lu(%s), len = %Lu, empty_size = %Lu, flags = %Lu(%s)", 955 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
948 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 956 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
949 __entry->num_bytes, __entry->empty_size, __entry->data, 957 __entry->num_bytes, __entry->empty_size, __entry->data,
950 __print_flags((unsigned long)__entry->data, "|", 958 __print_flags((unsigned long)__entry->data, "|",
@@ -973,8 +981,8 @@ DECLARE_EVENT_CLASS(btrfs__reserve_extent,
973 __entry->len = len; 981 __entry->len = len;
974 ), 982 ),
975 983
976 TP_printk_btrfs("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), " 984 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
977 "start = %Lu, len = %Lu", 985 "start=%Lu len=%Lu",
978 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 986 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
979 __entry->bg_objectid, 987 __entry->bg_objectid,
980 __entry->flags, __print_flags((unsigned long)__entry->flags, 988 __entry->flags, __print_flags((unsigned long)__entry->flags,
@@ -1025,8 +1033,8 @@ TRACE_EVENT(btrfs_find_cluster,
1025 __entry->min_bytes = min_bytes; 1033 __entry->min_bytes = min_bytes;
1026 ), 1034 ),
1027 1035
1028 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu," 1036 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1029 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid, 1037 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
1030 __entry->flags, 1038 __entry->flags,
1031 __print_flags((unsigned long)__entry->flags, "|", 1039 __print_flags((unsigned long)__entry->flags, "|",
1032 BTRFS_GROUP_FLAGS), __entry->start, 1040 BTRFS_GROUP_FLAGS), __entry->start,
@@ -1047,7 +1055,7 @@ TRACE_EVENT(btrfs_failed_cluster_setup,
1047 __entry->bg_objectid = block_group->key.objectid; 1055 __entry->bg_objectid = block_group->key.objectid;
1048 ), 1056 ),
1049 1057
1050 TP_printk_btrfs("block_group = %Lu", __entry->bg_objectid) 1058 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
1051); 1059);
1052 1060
1053TRACE_EVENT(btrfs_setup_cluster, 1061TRACE_EVENT(btrfs_setup_cluster,
@@ -1075,8 +1083,8 @@ TRACE_EVENT(btrfs_setup_cluster,
1075 __entry->bitmap = bitmap; 1083 __entry->bitmap = bitmap;
1076 ), 1084 ),
1077 1085
1078 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, " 1086 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1079 "size = %Lu, max_size = %Lu, bitmap = %d", 1087 "size=%Lu max_size=%Lu bitmap=%d",
1080 __entry->bg_objectid, 1088 __entry->bg_objectid,
1081 __entry->flags, 1089 __entry->flags,
1082 __print_flags((unsigned long)__entry->flags, "|", 1090 __print_flags((unsigned long)__entry->flags, "|",
@@ -1103,7 +1111,7 @@ TRACE_EVENT(alloc_extent_state,
1103 __entry->ip = IP 1111 __entry->ip = IP
1104 ), 1112 ),
1105 1113
1106 TP_printk("state=%p; mask = %s; caller = %pS", __entry->state, 1114 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
1107 show_gfp_flags(__entry->mask), (void *)__entry->ip) 1115 show_gfp_flags(__entry->mask), (void *)__entry->ip)
1108); 1116);
1109 1117
@@ -1123,7 +1131,7 @@ TRACE_EVENT(free_extent_state,
1123 __entry->ip = IP 1131 __entry->ip = IP
1124 ), 1132 ),
1125 1133
1126 TP_printk(" state=%p; caller = %pS", __entry->state, 1134 TP_printk("state=%p caller=%pS", __entry->state,
1127 (void *)__entry->ip) 1135 (void *)__entry->ip)
1128); 1136);
1129 1137
@@ -1151,28 +1159,32 @@ DECLARE_EVENT_CLASS(btrfs__work,
1151 __entry->normal_work = &work->normal_work; 1159 __entry->normal_work = &work->normal_work;
1152 ), 1160 ),
1153 1161
1154 TP_printk_btrfs("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p," 1162 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1155 " ordered_free=%p", 1163 "ordered_free=%p",
1156 __entry->work, __entry->normal_work, __entry->wq, 1164 __entry->work, __entry->normal_work, __entry->wq,
1157 __entry->func, __entry->ordered_func, __entry->ordered_free) 1165 __entry->func, __entry->ordered_func, __entry->ordered_free)
1158); 1166);
1159 1167
1160/* For situiations that the work is freed */ 1168/*
1169 * For situiations when the work is freed, we pass fs_info and a tag that that
1170 * matches address of the work structure so it can be paired with the
1171 * scheduling event.
1172 */
1161DECLARE_EVENT_CLASS(btrfs__work__done, 1173DECLARE_EVENT_CLASS(btrfs__work__done,
1162 1174
1163 TP_PROTO(struct btrfs_work *work), 1175 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1164 1176
1165 TP_ARGS(work), 1177 TP_ARGS(fs_info, wtag),
1166 1178
1167 TP_STRUCT__entry_btrfs( 1179 TP_STRUCT__entry_btrfs(
1168 __field( void *, work ) 1180 __field( void *, wtag )
1169 ), 1181 ),
1170 1182
1171 TP_fast_assign_btrfs(btrfs_work_owner(work), 1183 TP_fast_assign_btrfs(fs_info,
1172 __entry->work = work; 1184 __entry->wtag = wtag;
1173 ), 1185 ),
1174 1186
1175 TP_printk_btrfs("work->%p", __entry->work) 1187 TP_printk_btrfs("work->%p", __entry->wtag)
1176); 1188);
1177 1189
1178DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1190DEFINE_EVENT(btrfs__work, btrfs_work_queued,
@@ -1191,9 +1203,9 @@ DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1191 1203
1192DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1204DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1193 1205
1194 TP_PROTO(struct btrfs_work *work), 1206 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1195 1207
1196 TP_ARGS(work) 1208 TP_ARGS(fs_info, wtag)
1197); 1209);
1198 1210
1199DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1211DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
@@ -1221,7 +1233,7 @@ DECLARE_EVENT_CLASS(btrfs__workqueue,
1221 __entry->high = high; 1233 __entry->high = high;
1222 ), 1234 ),
1223 1235
1224 TP_printk_btrfs("name=%s%s, wq=%p", __get_str(name), 1236 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1225 __print_flags(__entry->high, "", 1237 __print_flags(__entry->high, "",
1226 {(WQ_HIGHPRI), "-high"}), 1238 {(WQ_HIGHPRI), "-high"}),
1227 __entry->wq) 1239 __entry->wq)
@@ -1276,7 +1288,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1276 __entry->free_reserved = free_reserved; 1288 __entry->free_reserved = free_reserved;
1277 ), 1289 ),
1278 1290
1279 TP_printk_btrfs("rootid=%llu, ino=%lu, free_reserved=%llu", 1291 TP_printk_btrfs("rootid=%llu ino=%lu free_reserved=%llu",
1280 __entry->rootid, __entry->ino, __entry->free_reserved) 1292 __entry->rootid, __entry->ino, __entry->free_reserved)
1281); 1293);
1282 1294
@@ -1323,7 +1335,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1323 __entry->op = op; 1335 __entry->op = op;
1324 ), 1336 ),
1325 1337
1326 TP_printk_btrfs("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s", 1338 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
1327 __entry->rootid, __entry->ino, __entry->start, __entry->len, 1339 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1328 __entry->reserved, 1340 __entry->reserved,
1329 __print_flags((unsigned long)__entry->op, "", 1341 __print_flags((unsigned long)__entry->op, "",
@@ -1361,7 +1373,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1361 __entry->reserved = reserved; 1373 __entry->reserved = reserved;
1362 ), 1374 ),
1363 1375
1364 TP_printk_btrfs("root=%llu, reserved=%llu, op=free", 1376 TP_printk_btrfs("root=%llu reserved=%llu op=free",
1365 __entry->ref_root, __entry->reserved) 1377 __entry->ref_root, __entry->reserved)
1366); 1378);
1367 1379
@@ -1388,7 +1400,7 @@ DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1388 __entry->num_bytes = rec->num_bytes; 1400 __entry->num_bytes = rec->num_bytes;
1389 ), 1401 ),
1390 1402
1391 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu", 1403 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
1392 (unsigned long long)__entry->bytenr, 1404 (unsigned long long)__entry->bytenr,
1393 (unsigned long long)__entry->num_bytes) 1405 (unsigned long long)__entry->num_bytes)
1394); 1406);
@@ -1430,8 +1442,8 @@ TRACE_EVENT(btrfs_qgroup_account_extent,
1430 __entry->nr_new_roots = nr_new_roots; 1442 __entry->nr_new_roots = nr_new_roots;
1431 ), 1443 ),
1432 1444
1433 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, " 1445 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1434 "nr_new_roots = %llu", 1446 "nr_new_roots=%llu",
1435 __entry->bytenr, 1447 __entry->bytenr,
1436 __entry->num_bytes, 1448 __entry->num_bytes,
1437 __entry->nr_old_roots, 1449 __entry->nr_old_roots,
@@ -1457,7 +1469,7 @@ TRACE_EVENT(qgroup_update_counters,
1457 __entry->cur_new_count = cur_new_count; 1469 __entry->cur_new_count = cur_new_count;
1458 ), 1470 ),
1459 1471
1460 TP_printk_btrfs("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu", 1472 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
1461 __entry->qgid, 1473 __entry->qgid,
1462 __entry->cur_old_count, 1474 __entry->cur_old_count,
1463 __entry->cur_new_count) 1475 __entry->cur_new_count)
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 9e687ca9a307..15bf875d0e4a 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -47,8 +47,7 @@
47 {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \ 47 {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \
48 {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \ 48 {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \
49 {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\ 49 {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\
50 {(unsigned long)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"},\ 50 {(unsigned long)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"}\
51 {(unsigned long)__GFP_OTHER_NODE, "__GFP_OTHER_NODE"} \
52 51
53#define show_gfp_flags(flags) \ 52#define show_gfp_flags(flags) \
54 (flags) ? __print_flags(flags, "|", \ 53 (flags) ? __print_flags(flags, "|", \
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
index 7ea4c5e7c448..288c0c54a2b4 100644
--- a/include/trace/events/swiotlb.h
+++ b/include/trace/events/swiotlb.h
@@ -11,16 +11,16 @@ TRACE_EVENT(swiotlb_bounced,
11 TP_PROTO(struct device *dev, 11 TP_PROTO(struct device *dev,
12 dma_addr_t dev_addr, 12 dma_addr_t dev_addr,
13 size_t size, 13 size_t size,
14 int swiotlb_force), 14 enum swiotlb_force swiotlb_force),
15 15
16 TP_ARGS(dev, dev_addr, size, swiotlb_force), 16 TP_ARGS(dev, dev_addr, size, swiotlb_force),
17 17
18 TP_STRUCT__entry( 18 TP_STRUCT__entry(
19 __string( dev_name, dev_name(dev) ) 19 __string( dev_name, dev_name(dev) )
20 __field( u64, dma_mask ) 20 __field( u64, dma_mask )
21 __field( dma_addr_t, dev_addr ) 21 __field( dma_addr_t, dev_addr )
22 __field( size_t, size ) 22 __field( size_t, size )
23 __field( int, swiotlb_force ) 23 __field( enum swiotlb_force, swiotlb_force )
24 ), 24 ),
25 25
26 TP_fast_assign( 26 TP_fast_assign(
@@ -37,7 +37,10 @@ TRACE_EVENT(swiotlb_bounced,
37 __entry->dma_mask, 37 __entry->dma_mask,
38 (unsigned long long)__entry->dev_addr, 38 (unsigned long long)__entry->dev_addr,
39 __entry->size, 39 __entry->size,
40 __entry->swiotlb_force ? "swiotlb_force" : "" ) 40 __print_symbolic(__entry->swiotlb_force,
41 { SWIOTLB_NORMAL, "NORMAL" },
42 { SWIOTLB_FORCE, "FORCE" },
43 { SWIOTLB_NO_FORCE, "NO_FORCE" }))
41); 44);
42 45
43#endif /* _TRACE_SWIOTLB_H */ 46#endif /* _TRACE_SWIOTLB_H */
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index a8b93e685239..f330ba4547cf 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -414,6 +414,7 @@ header-y += telephony.h
414header-y += termios.h 414header-y += termios.h
415header-y += thermal.h 415header-y += thermal.h
416header-y += time.h 416header-y += time.h
417header-y += timerfd.h
417header-y += times.h 418header-y += times.h
418header-y += timex.h 419header-y += timex.h
419header-y += tiocl.h 420header-y += tiocl.h
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 6b76e3b0c18e..bea982af9cfb 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1772,7 +1772,9 @@ enum nl80211_commands {
1772 * 1772 *
1773 * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode 1773 * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode
1774 * Notification Element based on association request when used with 1774 * Notification Element based on association request when used with
1775 * %NL80211_CMD_NEW_STATION; u8 attribute. 1775 * %NL80211_CMD_NEW_STATION or %NL80211_CMD_SET_STATION (only when
1776 * %NL80211_FEATURE_FULL_AP_CLIENT_STATE is supported, or with TDLS);
1777 * u8 attribute.
1776 * 1778 *
1777 * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if 1779 * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if
1778 * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet) 1780 * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet)
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index cb4bcdc58543..a4dcd88ec271 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -397,7 +397,7 @@ enum {
397 TCA_BPF_NAME, 397 TCA_BPF_NAME,
398 TCA_BPF_FLAGS, 398 TCA_BPF_FLAGS,
399 TCA_BPF_FLAGS_GEN, 399 TCA_BPF_FLAGS_GEN,
400 TCA_BPF_DIGEST, 400 TCA_BPF_TAG,
401 __TCA_BPF_MAX, 401 __TCA_BPF_MAX,
402}; 402};
403 403
diff --git a/include/uapi/linux/tc_act/tc_bpf.h b/include/uapi/linux/tc_act/tc_bpf.h
index a6b88a6f7f71..975b50dc8d1d 100644
--- a/include/uapi/linux/tc_act/tc_bpf.h
+++ b/include/uapi/linux/tc_act/tc_bpf.h
@@ -27,7 +27,7 @@ enum {
27 TCA_ACT_BPF_FD, 27 TCA_ACT_BPF_FD,
28 TCA_ACT_BPF_NAME, 28 TCA_ACT_BPF_NAME,
29 TCA_ACT_BPF_PAD, 29 TCA_ACT_BPF_PAD,
30 TCA_ACT_BPF_DIGEST, 30 TCA_ACT_BPF_TAG,
31 __TCA_ACT_BPF_MAX, 31 __TCA_ACT_BPF_MAX,
32}; 32};
33#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1) 33#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
diff --git a/include/uapi/linux/timerfd.h b/include/uapi/linux/timerfd.h
new file mode 100644
index 000000000000..6fcfaa8da173
--- /dev/null
+++ b/include/uapi/linux/timerfd.h
@@ -0,0 +1,36 @@
1/*
2 * include/linux/timerfd.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#ifndef _UAPI_LINUX_TIMERFD_H
9#define _UAPI_LINUX_TIMERFD_H
10
11#include <linux/types.h>
12
13/* For O_CLOEXEC and O_NONBLOCK */
14#include <linux/fcntl.h>
15
16/* For _IO helpers */
17#include <linux/ioctl.h>
18
19/*
20 * CAREFUL: Check include/asm-generic/fcntl.h when defining
21 * new flags, since they might collide with O_* ones. We want
22 * to re-use O_* flags that couldn't possibly have a meaning
23 * from eventfd, in order to leave a free define-space for
24 * shared O_* flags.
25 *
26 * Also make sure to update the masks in include/linux/timerfd.h
27 * when adding new flags.
28 */
29#define TFD_TIMER_ABSTIME (1 << 0)
30#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
31#define TFD_CLOEXEC O_CLOEXEC
32#define TFD_NONBLOCK O_NONBLOCK
33
34#define TFD_IOC_SET_TICKS _IOW('T', 0, __u64)
35
36#endif /* _UAPI_LINUX_TIMERFD_H */
diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
index acc63697a0cc..b2a31a55a612 100644
--- a/include/uapi/linux/usb/functionfs.h
+++ b/include/uapi/linux/usb/functionfs.h
@@ -93,6 +93,7 @@ struct usb_ext_prop_desc {
93 * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 | 93 * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 |
94 * | 4 | length | LE32 | length of the whole data chunk | 94 * | 4 | length | LE32 | length of the whole data chunk |
95 * | 8 | flags | LE32 | combination of functionfs_flags | 95 * | 8 | flags | LE32 | combination of functionfs_flags |
96 * | | eventfd | LE32 | eventfd file descriptor |
96 * | | fs_count | LE32 | number of full-speed descriptors | 97 * | | fs_count | LE32 | number of full-speed descriptors |
97 * | | hs_count | LE32 | number of high-speed descriptors | 98 * | | hs_count | LE32 | number of high-speed descriptors |
98 * | | ss_count | LE32 | number of super-speed descriptors | 99 * | | ss_count | LE32 | number of super-speed descriptors |
diff --git a/init/Kconfig b/init/Kconfig
index 223b734abccd..e1a937348a3e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1176,6 +1176,10 @@ config CGROUP_DEBUG
1176 1176
1177 Say N. 1177 Say N.
1178 1178
1179config SOCK_CGROUP_DATA
1180 bool
1181 default n
1182
1179endif # CGROUPS 1183endif # CGROUPS
1180 1184
1181config CHECKPOINT_RESTORE 1185config CHECKPOINT_RESTORE
diff --git a/ipc/sem.c b/ipc/sem.c
index e08b94851922..3ec5742b5640 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1977,7 +1977,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1977 } 1977 }
1978 1978
1979 rcu_read_lock(); 1979 rcu_read_lock();
1980 sem_lock(sma, sops, nsops); 1980 locknum = sem_lock(sma, sops, nsops);
1981 1981
1982 if (!ipc_valid_object(&sma->sem_perm)) 1982 if (!ipc_valid_object(&sma->sem_perm))
1983 goto out_unlock_free; 1983 goto out_unlock_free;
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 8b1dde96a0fa..7b44195da81b 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -231,9 +231,11 @@ static void untag_chunk(struct node *p)
231 if (size) 231 if (size)
232 new = alloc_chunk(size); 232 new = alloc_chunk(size);
233 233
234 mutex_lock(&entry->group->mark_mutex);
234 spin_lock(&entry->lock); 235 spin_lock(&entry->lock);
235 if (chunk->dead || !entry->inode) { 236 if (chunk->dead || !entry->inode) {
236 spin_unlock(&entry->lock); 237 spin_unlock(&entry->lock);
238 mutex_unlock(&entry->group->mark_mutex);
237 if (new) 239 if (new)
238 free_chunk(new); 240 free_chunk(new);
239 goto out; 241 goto out;
@@ -251,6 +253,7 @@ static void untag_chunk(struct node *p)
251 list_del_rcu(&chunk->hash); 253 list_del_rcu(&chunk->hash);
252 spin_unlock(&hash_lock); 254 spin_unlock(&hash_lock);
253 spin_unlock(&entry->lock); 255 spin_unlock(&entry->lock);
256 mutex_unlock(&entry->group->mark_mutex);
254 fsnotify_destroy_mark(entry, audit_tree_group); 257 fsnotify_destroy_mark(entry, audit_tree_group);
255 goto out; 258 goto out;
256 } 259 }
@@ -258,8 +261,8 @@ static void untag_chunk(struct node *p)
258 if (!new) 261 if (!new)
259 goto Fallback; 262 goto Fallback;
260 263
261 fsnotify_duplicate_mark(&new->mark, entry); 264 if (fsnotify_add_mark_locked(&new->mark, entry->group, entry->inode,
262 if (fsnotify_add_mark(&new->mark, new->mark.group, new->mark.inode, NULL, 1)) { 265 NULL, 1)) {
263 fsnotify_put_mark(&new->mark); 266 fsnotify_put_mark(&new->mark);
264 goto Fallback; 267 goto Fallback;
265 } 268 }
@@ -293,6 +296,7 @@ static void untag_chunk(struct node *p)
293 owner->root = new; 296 owner->root = new;
294 spin_unlock(&hash_lock); 297 spin_unlock(&hash_lock);
295 spin_unlock(&entry->lock); 298 spin_unlock(&entry->lock);
299 mutex_unlock(&entry->group->mark_mutex);
296 fsnotify_destroy_mark(entry, audit_tree_group); 300 fsnotify_destroy_mark(entry, audit_tree_group);
297 fsnotify_put_mark(&new->mark); /* drop initial reference */ 301 fsnotify_put_mark(&new->mark); /* drop initial reference */
298 goto out; 302 goto out;
@@ -309,6 +313,7 @@ Fallback:
309 put_tree(owner); 313 put_tree(owner);
310 spin_unlock(&hash_lock); 314 spin_unlock(&hash_lock);
311 spin_unlock(&entry->lock); 315 spin_unlock(&entry->lock);
316 mutex_unlock(&entry->group->mark_mutex);
312out: 317out:
313 fsnotify_put_mark(entry); 318 fsnotify_put_mark(entry);
314 spin_lock(&hash_lock); 319 spin_lock(&hash_lock);
@@ -386,18 +391,21 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
386 391
387 chunk_entry = &chunk->mark; 392 chunk_entry = &chunk->mark;
388 393
394 mutex_lock(&old_entry->group->mark_mutex);
389 spin_lock(&old_entry->lock); 395 spin_lock(&old_entry->lock);
390 if (!old_entry->inode) { 396 if (!old_entry->inode) {
391 /* old_entry is being shot, lets just lie */ 397 /* old_entry is being shot, lets just lie */
392 spin_unlock(&old_entry->lock); 398 spin_unlock(&old_entry->lock);
399 mutex_unlock(&old_entry->group->mark_mutex);
393 fsnotify_put_mark(old_entry); 400 fsnotify_put_mark(old_entry);
394 free_chunk(chunk); 401 free_chunk(chunk);
395 return -ENOENT; 402 return -ENOENT;
396 } 403 }
397 404
398 fsnotify_duplicate_mark(chunk_entry, old_entry); 405 if (fsnotify_add_mark_locked(chunk_entry, old_entry->group,
399 if (fsnotify_add_mark(chunk_entry, chunk_entry->group, chunk_entry->inode, NULL, 1)) { 406 old_entry->inode, NULL, 1)) {
400 spin_unlock(&old_entry->lock); 407 spin_unlock(&old_entry->lock);
408 mutex_unlock(&old_entry->group->mark_mutex);
401 fsnotify_put_mark(chunk_entry); 409 fsnotify_put_mark(chunk_entry);
402 fsnotify_put_mark(old_entry); 410 fsnotify_put_mark(old_entry);
403 return -ENOSPC; 411 return -ENOSPC;
@@ -413,6 +421,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
413 chunk->dead = 1; 421 chunk->dead = 1;
414 spin_unlock(&chunk_entry->lock); 422 spin_unlock(&chunk_entry->lock);
415 spin_unlock(&old_entry->lock); 423 spin_unlock(&old_entry->lock);
424 mutex_unlock(&old_entry->group->mark_mutex);
416 425
417 fsnotify_destroy_mark(chunk_entry, audit_tree_group); 426 fsnotify_destroy_mark(chunk_entry, audit_tree_group);
418 427
@@ -445,6 +454,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
445 spin_unlock(&hash_lock); 454 spin_unlock(&hash_lock);
446 spin_unlock(&chunk_entry->lock); 455 spin_unlock(&chunk_entry->lock);
447 spin_unlock(&old_entry->lock); 456 spin_unlock(&old_entry->lock);
457 mutex_unlock(&old_entry->group->mark_mutex);
448 fsnotify_destroy_mark(old_entry, audit_tree_group); 458 fsnotify_destroy_mark(old_entry, audit_tree_group);
449 fsnotify_put_mark(chunk_entry); /* drop initial reference */ 459 fsnotify_put_mark(chunk_entry); /* drop initial reference */
450 fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */ 460 fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index a2ac051c342f..229a5d5df977 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -56,7 +56,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
56 attr->value_size == 0 || attr->map_flags) 56 attr->value_size == 0 || attr->map_flags)
57 return ERR_PTR(-EINVAL); 57 return ERR_PTR(-EINVAL);
58 58
59 if (attr->value_size >= 1 << (KMALLOC_SHIFT_MAX - 1)) 59 if (attr->value_size > KMALLOC_MAX_SIZE)
60 /* if value_size is bigger, the user space won't be able to 60 /* if value_size is bigger, the user space won't be able to
61 * access the elements. 61 * access the elements.
62 */ 62 */
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 1eb4f1303756..503d4211988a 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -146,10 +146,11 @@ void __bpf_prog_free(struct bpf_prog *fp)
146 vfree(fp); 146 vfree(fp);
147} 147}
148 148
149int bpf_prog_calc_digest(struct bpf_prog *fp) 149int bpf_prog_calc_tag(struct bpf_prog *fp)
150{ 150{
151 const u32 bits_offset = SHA_MESSAGE_BYTES - sizeof(__be64); 151 const u32 bits_offset = SHA_MESSAGE_BYTES - sizeof(__be64);
152 u32 raw_size = bpf_prog_digest_scratch_size(fp); 152 u32 raw_size = bpf_prog_tag_scratch_size(fp);
153 u32 digest[SHA_DIGEST_WORDS];
153 u32 ws[SHA_WORKSPACE_WORDS]; 154 u32 ws[SHA_WORKSPACE_WORDS];
154 u32 i, bsize, psize, blocks; 155 u32 i, bsize, psize, blocks;
155 struct bpf_insn *dst; 156 struct bpf_insn *dst;
@@ -162,7 +163,7 @@ int bpf_prog_calc_digest(struct bpf_prog *fp)
162 if (!raw) 163 if (!raw)
163 return -ENOMEM; 164 return -ENOMEM;
164 165
165 sha_init(fp->digest); 166 sha_init(digest);
166 memset(ws, 0, sizeof(ws)); 167 memset(ws, 0, sizeof(ws));
167 168
168 /* We need to take out the map fd for the digest calculation 169 /* We need to take out the map fd for the digest calculation
@@ -204,13 +205,14 @@ int bpf_prog_calc_digest(struct bpf_prog *fp)
204 *bits = cpu_to_be64((psize - 1) << 3); 205 *bits = cpu_to_be64((psize - 1) << 3);
205 206
206 while (blocks--) { 207 while (blocks--) {
207 sha_transform(fp->digest, todo, ws); 208 sha_transform(digest, todo, ws);
208 todo += SHA_MESSAGE_BYTES; 209 todo += SHA_MESSAGE_BYTES;
209 } 210 }
210 211
211 result = (__force __be32 *)fp->digest; 212 result = (__force __be32 *)digest;
212 for (i = 0; i < SHA_DIGEST_WORDS; i++) 213 for (i = 0; i < SHA_DIGEST_WORDS; i++)
213 result[i] = cpu_to_be32(fp->digest[i]); 214 result[i] = cpu_to_be32(digest[i]);
215 memcpy(fp->tag, result, sizeof(fp->tag));
214 216
215 vfree(raw); 217 vfree(raw);
216 return 0; 218 return 0;
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 34debc1a9641..3f2bb58952d8 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -274,7 +274,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
274 */ 274 */
275 goto free_htab; 275 goto free_htab;
276 276
277 if (htab->map.value_size >= (1 << (KMALLOC_SHIFT_MAX - 1)) - 277 if (htab->map.value_size >= KMALLOC_MAX_SIZE -
278 MAX_BPF_STACK - sizeof(struct htab_elem)) 278 MAX_BPF_STACK - sizeof(struct htab_elem))
279 /* if value_size is bigger, the user space won't be able to 279 /* if value_size is bigger, the user space won't be able to
280 * access the elements via bpf syscall. This check also makes 280 * access the elements via bpf syscall. This check also makes
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e89acea22ecf..1d6b29e4e2c3 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -688,17 +688,17 @@ static int bpf_prog_release(struct inode *inode, struct file *filp)
688static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp) 688static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
689{ 689{
690 const struct bpf_prog *prog = filp->private_data; 690 const struct bpf_prog *prog = filp->private_data;
691 char prog_digest[sizeof(prog->digest) * 2 + 1] = { }; 691 char prog_tag[sizeof(prog->tag) * 2 + 1] = { };
692 692
693 bin2hex(prog_digest, prog->digest, sizeof(prog->digest)); 693 bin2hex(prog_tag, prog->tag, sizeof(prog->tag));
694 seq_printf(m, 694 seq_printf(m,
695 "prog_type:\t%u\n" 695 "prog_type:\t%u\n"
696 "prog_jited:\t%u\n" 696 "prog_jited:\t%u\n"
697 "prog_digest:\t%s\n" 697 "prog_tag:\t%s\n"
698 "memlock:\t%llu\n", 698 "memlock:\t%llu\n",
699 prog->type, 699 prog->type,
700 prog->jited, 700 prog->jited,
701 prog_digest, 701 prog_tag,
702 prog->pages * 1ULL << PAGE_SHIFT); 702 prog->pages * 1ULL << PAGE_SHIFT);
703} 703}
704#endif 704#endif
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 83ed2f8f6f22..cdc43b899f28 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2936,7 +2936,7 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
2936 int insn_cnt = env->prog->len; 2936 int insn_cnt = env->prog->len;
2937 int i, j, err; 2937 int i, j, err;
2938 2938
2939 err = bpf_prog_calc_digest(env->prog); 2939 err = bpf_prog_calc_tag(env->prog);
2940 if (err) 2940 if (err)
2941 return err; 2941 return err;
2942 2942
diff --git a/kernel/capability.c b/kernel/capability.c
index a98e814f216f..f97fe77ceb88 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -318,6 +318,7 @@ bool has_capability(struct task_struct *t, int cap)
318{ 318{
319 return has_ns_capability(t, &init_user_ns, cap); 319 return has_ns_capability(t, &init_user_ns, cap);
320} 320}
321EXPORT_SYMBOL(has_capability);
321 322
322/** 323/**
323 * has_ns_capability_noaudit - Does a task have a capability (unaudited) 324 * has_ns_capability_noaudit - Does a task have a capability (unaudited)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f75c4d031eeb..0a5f630f5c54 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -764,7 +764,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
764{ 764{
765 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); 765 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
766 int prev_state, ret = 0; 766 int prev_state, ret = 0;
767 bool hasdied = false;
768 767
769 if (num_online_cpus() == 1) 768 if (num_online_cpus() == 1)
770 return -EBUSY; 769 return -EBUSY;
@@ -809,7 +808,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
809 cpuhp_kick_ap_work(cpu); 808 cpuhp_kick_ap_work(cpu);
810 } 809 }
811 810
812 hasdied = prev_state != st->state && st->state == CPUHP_OFFLINE;
813out: 811out:
814 cpu_hotplug_done(); 812 cpu_hotplug_done();
815 return ret; 813 return ret;
@@ -1302,10 +1300,24 @@ static int cpuhp_cb_check(enum cpuhp_state state)
1302 */ 1300 */
1303static int cpuhp_reserve_state(enum cpuhp_state state) 1301static int cpuhp_reserve_state(enum cpuhp_state state)
1304{ 1302{
1305 enum cpuhp_state i; 1303 enum cpuhp_state i, end;
1304 struct cpuhp_step *step;
1306 1305
1307 for (i = CPUHP_AP_ONLINE_DYN; i <= CPUHP_AP_ONLINE_DYN_END; i++) { 1306 switch (state) {
1308 if (!cpuhp_ap_states[i].name) 1307 case CPUHP_AP_ONLINE_DYN:
1308 step = cpuhp_ap_states + CPUHP_AP_ONLINE_DYN;
1309 end = CPUHP_AP_ONLINE_DYN_END;
1310 break;
1311 case CPUHP_BP_PREPARE_DYN:
1312 step = cpuhp_bp_states + CPUHP_BP_PREPARE_DYN;
1313 end = CPUHP_BP_PREPARE_DYN_END;
1314 break;
1315 default:
1316 return -EINVAL;
1317 }
1318
1319 for (i = state; i <= end; i++, step++) {
1320 if (!step->name)
1309 return i; 1321 return i;
1310 } 1322 }
1311 WARN(1, "No more dynamic states available for CPU hotplug\n"); 1323 WARN(1, "No more dynamic states available for CPU hotplug\n");
@@ -1323,7 +1335,7 @@ static int cpuhp_store_callbacks(enum cpuhp_state state, const char *name,
1323 1335
1324 mutex_lock(&cpuhp_state_mutex); 1336 mutex_lock(&cpuhp_state_mutex);
1325 1337
1326 if (state == CPUHP_AP_ONLINE_DYN) { 1338 if (state == CPUHP_AP_ONLINE_DYN || state == CPUHP_BP_PREPARE_DYN) {
1327 ret = cpuhp_reserve_state(state); 1339 ret = cpuhp_reserve_state(state);
1328 if (ret < 0) 1340 if (ret < 0)
1329 goto out; 1341 goto out;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index ab15509fab8c..110b38a58493 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2249,7 +2249,7 @@ static int __perf_install_in_context(void *info)
2249 struct perf_event_context *ctx = event->ctx; 2249 struct perf_event_context *ctx = event->ctx;
2250 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); 2250 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
2251 struct perf_event_context *task_ctx = cpuctx->task_ctx; 2251 struct perf_event_context *task_ctx = cpuctx->task_ctx;
2252 bool activate = true; 2252 bool reprogram = true;
2253 int ret = 0; 2253 int ret = 0;
2254 2254
2255 raw_spin_lock(&cpuctx->ctx.lock); 2255 raw_spin_lock(&cpuctx->ctx.lock);
@@ -2257,27 +2257,26 @@ static int __perf_install_in_context(void *info)
2257 raw_spin_lock(&ctx->lock); 2257 raw_spin_lock(&ctx->lock);
2258 task_ctx = ctx; 2258 task_ctx = ctx;
2259 2259
2260 /* If we're on the wrong CPU, try again */ 2260 reprogram = (ctx->task == current);
2261 if (task_cpu(ctx->task) != smp_processor_id()) {
2262 ret = -ESRCH;
2263 goto unlock;
2264 }
2265 2261
2266 /* 2262 /*
2267 * If we're on the right CPU, see if the task we target is 2263 * If the task is running, it must be running on this CPU,
2268 * current, if not we don't have to activate the ctx, a future 2264 * otherwise we cannot reprogram things.
2269 * context switch will do that for us. 2265 *
2266 * If its not running, we don't care, ctx->lock will
2267 * serialize against it becoming runnable.
2270 */ 2268 */
2271 if (ctx->task != current) 2269 if (task_curr(ctx->task) && !reprogram) {
2272 activate = false; 2270 ret = -ESRCH;
2273 else 2271 goto unlock;
2274 WARN_ON_ONCE(cpuctx->task_ctx && cpuctx->task_ctx != ctx); 2272 }
2275 2273
2274 WARN_ON_ONCE(reprogram && cpuctx->task_ctx && cpuctx->task_ctx != ctx);
2276 } else if (task_ctx) { 2275 } else if (task_ctx) {
2277 raw_spin_lock(&task_ctx->lock); 2276 raw_spin_lock(&task_ctx->lock);
2278 } 2277 }
2279 2278
2280 if (activate) { 2279 if (reprogram) {
2281 ctx_sched_out(ctx, cpuctx, EVENT_TIME); 2280 ctx_sched_out(ctx, cpuctx, EVENT_TIME);
2282 add_event_to_ctx(event, ctx); 2281 add_event_to_ctx(event, ctx);
2283 ctx_resched(cpuctx, task_ctx); 2282 ctx_resched(cpuctx, task_ctx);
@@ -2328,13 +2327,36 @@ perf_install_in_context(struct perf_event_context *ctx,
2328 /* 2327 /*
2329 * Installing events is tricky because we cannot rely on ctx->is_active 2328 * Installing events is tricky because we cannot rely on ctx->is_active
2330 * to be set in case this is the nr_events 0 -> 1 transition. 2329 * to be set in case this is the nr_events 0 -> 1 transition.
2330 *
2331 * Instead we use task_curr(), which tells us if the task is running.
2332 * However, since we use task_curr() outside of rq::lock, we can race
2333 * against the actual state. This means the result can be wrong.
2334 *
2335 * If we get a false positive, we retry, this is harmless.
2336 *
2337 * If we get a false negative, things are complicated. If we are after
2338 * perf_event_context_sched_in() ctx::lock will serialize us, and the
2339 * value must be correct. If we're before, it doesn't matter since
2340 * perf_event_context_sched_in() will program the counter.
2341 *
2342 * However, this hinges on the remote context switch having observed
2343 * our task->perf_event_ctxp[] store, such that it will in fact take
2344 * ctx::lock in perf_event_context_sched_in().
2345 *
2346 * We do this by task_function_call(), if the IPI fails to hit the task
2347 * we know any future context switch of task must see the
2348 * perf_event_ctpx[] store.
2331 */ 2349 */
2332again: 2350
2333 /* 2351 /*
2334 * Cannot use task_function_call() because we need to run on the task's 2352 * This smp_mb() orders the task->perf_event_ctxp[] store with the
2335 * CPU regardless of whether its current or not. 2353 * task_cpu() load, such that if the IPI then does not find the task
2354 * running, a future context switch of that task must observe the
2355 * store.
2336 */ 2356 */
2337 if (!cpu_function_call(task_cpu(task), __perf_install_in_context, event)) 2357 smp_mb();
2358again:
2359 if (!task_function_call(task, __perf_install_in_context, event))
2338 return; 2360 return;
2339 2361
2340 raw_spin_lock_irq(&ctx->lock); 2362 raw_spin_lock_irq(&ctx->lock);
@@ -2348,12 +2370,16 @@ again:
2348 raw_spin_unlock_irq(&ctx->lock); 2370 raw_spin_unlock_irq(&ctx->lock);
2349 return; 2371 return;
2350 } 2372 }
2351 raw_spin_unlock_irq(&ctx->lock);
2352 /* 2373 /*
2353 * Since !ctx->is_active doesn't mean anything, we must IPI 2374 * If the task is not running, ctx->lock will avoid it becoming so,
2354 * unconditionally. 2375 * thus we can safely install the event.
2355 */ 2376 */
2356 goto again; 2377 if (task_curr(task)) {
2378 raw_spin_unlock_irq(&ctx->lock);
2379 goto again;
2380 }
2381 add_event_to_ctx(event, ctx);
2382 raw_spin_unlock_irq(&ctx->lock);
2357} 2383}
2358 2384
2359/* 2385/*
@@ -7034,25 +7060,12 @@ static void perf_log_itrace_start(struct perf_event *event)
7034 perf_output_end(&handle); 7060 perf_output_end(&handle);
7035} 7061}
7036 7062
7037/* 7063static int
7038 * Generic event overflow handling, sampling. 7064__perf_event_account_interrupt(struct perf_event *event, int throttle)
7039 */
7040
7041static int __perf_event_overflow(struct perf_event *event,
7042 int throttle, struct perf_sample_data *data,
7043 struct pt_regs *regs)
7044{ 7065{
7045 int events = atomic_read(&event->event_limit);
7046 struct hw_perf_event *hwc = &event->hw; 7066 struct hw_perf_event *hwc = &event->hw;
7047 u64 seq;
7048 int ret = 0; 7067 int ret = 0;
7049 7068 u64 seq;
7050 /*
7051 * Non-sampling counters might still use the PMI to fold short
7052 * hardware counters, ignore those.
7053 */
7054 if (unlikely(!is_sampling_event(event)))
7055 return 0;
7056 7069
7057 seq = __this_cpu_read(perf_throttled_seq); 7070 seq = __this_cpu_read(perf_throttled_seq);
7058 if (seq != hwc->interrupts_seq) { 7071 if (seq != hwc->interrupts_seq) {
@@ -7080,6 +7093,34 @@ static int __perf_event_overflow(struct perf_event *event,
7080 perf_adjust_period(event, delta, hwc->last_period, true); 7093 perf_adjust_period(event, delta, hwc->last_period, true);
7081 } 7094 }
7082 7095
7096 return ret;
7097}
7098
7099int perf_event_account_interrupt(struct perf_event *event)
7100{
7101 return __perf_event_account_interrupt(event, 1);
7102}
7103
7104/*
7105 * Generic event overflow handling, sampling.
7106 */
7107
7108static int __perf_event_overflow(struct perf_event *event,
7109 int throttle, struct perf_sample_data *data,
7110 struct pt_regs *regs)
7111{
7112 int events = atomic_read(&event->event_limit);
7113 int ret = 0;
7114
7115 /*
7116 * Non-sampling counters might still use the PMI to fold short
7117 * hardware counters, ignore those.
7118 */
7119 if (unlikely(!is_sampling_event(event)))
7120 return 0;
7121
7122 ret = __perf_event_account_interrupt(event, throttle);
7123
7083 /* 7124 /*
7084 * XXX event_limit might not quite work as expected on inherited 7125 * XXX event_limit might not quite work as expected on inherited
7085 * events 7126 * events
@@ -9503,6 +9544,37 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)
9503 return 0; 9544 return 0;
9504} 9545}
9505 9546
9547/*
9548 * Variation on perf_event_ctx_lock_nested(), except we take two context
9549 * mutexes.
9550 */
9551static struct perf_event_context *
9552__perf_event_ctx_lock_double(struct perf_event *group_leader,
9553 struct perf_event_context *ctx)
9554{
9555 struct perf_event_context *gctx;
9556
9557again:
9558 rcu_read_lock();
9559 gctx = READ_ONCE(group_leader->ctx);
9560 if (!atomic_inc_not_zero(&gctx->refcount)) {
9561 rcu_read_unlock();
9562 goto again;
9563 }
9564 rcu_read_unlock();
9565
9566 mutex_lock_double(&gctx->mutex, &ctx->mutex);
9567
9568 if (group_leader->ctx != gctx) {
9569 mutex_unlock(&ctx->mutex);
9570 mutex_unlock(&gctx->mutex);
9571 put_ctx(gctx);
9572 goto again;
9573 }
9574
9575 return gctx;
9576}
9577
9506/** 9578/**
9507 * sys_perf_event_open - open a performance event, associate it to a task/cpu 9579 * sys_perf_event_open - open a performance event, associate it to a task/cpu
9508 * 9580 *
@@ -9746,12 +9818,31 @@ SYSCALL_DEFINE5(perf_event_open,
9746 } 9818 }
9747 9819
9748 if (move_group) { 9820 if (move_group) {
9749 gctx = group_leader->ctx; 9821 gctx = __perf_event_ctx_lock_double(group_leader, ctx);
9750 mutex_lock_double(&gctx->mutex, &ctx->mutex); 9822
9751 if (gctx->task == TASK_TOMBSTONE) { 9823 if (gctx->task == TASK_TOMBSTONE) {
9752 err = -ESRCH; 9824 err = -ESRCH;
9753 goto err_locked; 9825 goto err_locked;
9754 } 9826 }
9827
9828 /*
9829 * Check if we raced against another sys_perf_event_open() call
9830 * moving the software group underneath us.
9831 */
9832 if (!(group_leader->group_caps & PERF_EV_CAP_SOFTWARE)) {
9833 /*
9834 * If someone moved the group out from under us, check
9835 * if this new event wound up on the same ctx, if so
9836 * its the regular !move_group case, otherwise fail.
9837 */
9838 if (gctx != ctx) {
9839 err = -EINVAL;
9840 goto err_locked;
9841 } else {
9842 perf_event_ctx_unlock(group_leader, gctx);
9843 move_group = 0;
9844 }
9845 }
9755 } else { 9846 } else {
9756 mutex_lock(&ctx->mutex); 9847 mutex_lock(&ctx->mutex);
9757 } 9848 }
@@ -9853,7 +9944,7 @@ SYSCALL_DEFINE5(perf_event_open,
9853 perf_unpin_context(ctx); 9944 perf_unpin_context(ctx);
9854 9945
9855 if (move_group) 9946 if (move_group)
9856 mutex_unlock(&gctx->mutex); 9947 perf_event_ctx_unlock(group_leader, gctx);
9857 mutex_unlock(&ctx->mutex); 9948 mutex_unlock(&ctx->mutex);
9858 9949
9859 if (task) { 9950 if (task) {
@@ -9879,7 +9970,7 @@ SYSCALL_DEFINE5(perf_event_open,
9879 9970
9880err_locked: 9971err_locked:
9881 if (move_group) 9972 if (move_group)
9882 mutex_unlock(&gctx->mutex); 9973 perf_event_ctx_unlock(group_leader, gctx);
9883 mutex_unlock(&ctx->mutex); 9974 mutex_unlock(&ctx->mutex);
9884/* err_file: */ 9975/* err_file: */
9885 fput(event_file); 9976 fput(event_file);
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 93ad6c1fb9b6..a9b8cf500591 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -182,6 +182,13 @@ void static_key_slow_dec_deferred(struct static_key_deferred *key)
182} 182}
183EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred); 183EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
184 184
185void static_key_deferred_flush(struct static_key_deferred *key)
186{
187 STATIC_KEY_CHECK_USE();
188 flush_delayed_work(&key->work);
189}
190EXPORT_SYMBOL_GPL(static_key_deferred_flush);
191
185void jump_label_rate_limit(struct static_key_deferred *key, 192void jump_label_rate_limit(struct static_key_deferred *key,
186 unsigned long rl) 193 unsigned long rl)
187{ 194{
diff --git a/kernel/memremap.c b/kernel/memremap.c
index b501e390bb34..9ecedc28b928 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -246,7 +246,9 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
246 /* pages are dead and unused, undo the arch mapping */ 246 /* pages are dead and unused, undo the arch mapping */
247 align_start = res->start & ~(SECTION_SIZE - 1); 247 align_start = res->start & ~(SECTION_SIZE - 1);
248 align_size = ALIGN(resource_size(res), SECTION_SIZE); 248 align_size = ALIGN(resource_size(res), SECTION_SIZE);
249 mem_hotplug_begin();
249 arch_remove_memory(align_start, align_size); 250 arch_remove_memory(align_start, align_size);
251 mem_hotplug_done();
250 untrack_pfn(NULL, PHYS_PFN(align_start), align_size); 252 untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
251 pgmap_radix_release(res); 253 pgmap_radix_release(res);
252 dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, 254 dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc,
@@ -358,7 +360,9 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
358 if (error) 360 if (error)
359 goto err_pfn_remap; 361 goto err_pfn_remap;
360 362
363 mem_hotplug_begin();
361 error = arch_add_memory(nid, align_start, align_size, true); 364 error = arch_add_memory(nid, align_start, align_size, true);
365 mem_hotplug_done();
362 if (error) 366 if (error)
363 goto err_add_memory; 367 goto err_add_memory;
364 368
diff --git a/kernel/module.c b/kernel/module.c
index 5088784c0cf9..38d4270925d4 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1145,7 +1145,7 @@ static size_t module_flags_taint(struct module *mod, char *buf)
1145 1145
1146 for (i = 0; i < TAINT_FLAGS_COUNT; i++) { 1146 for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
1147 if (taint_flags[i].module && test_bit(i, &mod->taints)) 1147 if (taint_flags[i].module && test_bit(i, &mod->taints))
1148 buf[l++] = taint_flags[i].true; 1148 buf[l++] = taint_flags[i].c_true;
1149 } 1149 }
1150 1150
1151 return l; 1151 return l;
diff --git a/kernel/panic.c b/kernel/panic.c
index c51edaa04fce..901c4fb46002 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -355,7 +355,7 @@ const char *print_tainted(void)
355 for (i = 0; i < TAINT_FLAGS_COUNT; i++) { 355 for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
356 const struct taint_flag *t = &taint_flags[i]; 356 const struct taint_flag *t = &taint_flags[i];
357 *s++ = test_bit(i, &tainted_mask) ? 357 *s++ = test_bit(i, &tainted_mask) ?
358 t->true : t->false; 358 t->c_true : t->c_false;
359 } 359 }
360 *s = 0; 360 *s = 0;
361 } else 361 } else
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 80adef7d4c3d..0d6ff3e471be 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -136,6 +136,7 @@ int rcu_jiffies_till_stall_check(void);
136#define TPS(x) tracepoint_string(x) 136#define TPS(x) tracepoint_string(x)
137 137
138void rcu_early_boot_tests(void); 138void rcu_early_boot_tests(void);
139void rcu_test_sync_prims(void);
139 140
140/* 141/*
141 * This function really isn't for public consumption, but RCU is special in 142 * This function really isn't for public consumption, but RCU is special in
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index 1898559e6b60..b23a4d076f3d 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -185,9 +185,6 @@ static __latent_entropy void rcu_process_callbacks(struct softirq_action *unused
185 * benefits of doing might_sleep() to reduce latency.) 185 * benefits of doing might_sleep() to reduce latency.)
186 * 186 *
187 * Cool, huh? (Due to Josh Triplett.) 187 * Cool, huh? (Due to Josh Triplett.)
188 *
189 * But we want to make this a static inline later. The cond_resched()
190 * currently makes this problematic.
191 */ 188 */
192void synchronize_sched(void) 189void synchronize_sched(void)
193{ 190{
@@ -195,7 +192,6 @@ void synchronize_sched(void)
195 lock_is_held(&rcu_lock_map) || 192 lock_is_held(&rcu_lock_map) ||
196 lock_is_held(&rcu_sched_lock_map), 193 lock_is_held(&rcu_sched_lock_map),
197 "Illegal synchronize_sched() in RCU read-side critical section"); 194 "Illegal synchronize_sched() in RCU read-side critical section");
198 cond_resched();
199} 195}
200EXPORT_SYMBOL_GPL(synchronize_sched); 196EXPORT_SYMBOL_GPL(synchronize_sched);
201 197
diff --git a/kernel/rcu/tiny_plugin.h b/kernel/rcu/tiny_plugin.h
index 196f0302e2f4..c64b827ecbca 100644
--- a/kernel/rcu/tiny_plugin.h
+++ b/kernel/rcu/tiny_plugin.h
@@ -60,12 +60,17 @@ EXPORT_SYMBOL_GPL(rcu_scheduler_active);
60 60
61/* 61/*
62 * During boot, we forgive RCU lockdep issues. After this function is 62 * During boot, we forgive RCU lockdep issues. After this function is
63 * invoked, we start taking RCU lockdep issues seriously. 63 * invoked, we start taking RCU lockdep issues seriously. Note that unlike
64 * Tree RCU, Tiny RCU transitions directly from RCU_SCHEDULER_INACTIVE
65 * to RCU_SCHEDULER_RUNNING, skipping the RCU_SCHEDULER_INIT stage.
66 * The reason for this is that Tiny RCU does not need kthreads, so does
67 * not have to care about the fact that the scheduler is half-initialized
68 * at a certain phase of the boot process.
64 */ 69 */
65void __init rcu_scheduler_starting(void) 70void __init rcu_scheduler_starting(void)
66{ 71{
67 WARN_ON(nr_context_switches() > 0); 72 WARN_ON(nr_context_switches() > 0);
68 rcu_scheduler_active = 1; 73 rcu_scheduler_active = RCU_SCHEDULER_RUNNING;
69} 74}
70 75
71#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ 76#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 96c52e43f7ca..cb4e2056ccf3 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -127,13 +127,16 @@ int rcu_num_nodes __read_mostly = NUM_RCU_NODES; /* Total # rcu_nodes in use. */
127int sysctl_panic_on_rcu_stall __read_mostly; 127int sysctl_panic_on_rcu_stall __read_mostly;
128 128
129/* 129/*
130 * The rcu_scheduler_active variable transitions from zero to one just 130 * The rcu_scheduler_active variable is initialized to the value
131 * before the first task is spawned. So when this variable is zero, RCU 131 * RCU_SCHEDULER_INACTIVE and transitions RCU_SCHEDULER_INIT just before the
132 * can assume that there is but one task, allowing RCU to (for example) 132 * first task is spawned. So when this variable is RCU_SCHEDULER_INACTIVE,
133 * RCU can assume that there is but one task, allowing RCU to (for example)
133 * optimize synchronize_rcu() to a simple barrier(). When this variable 134 * optimize synchronize_rcu() to a simple barrier(). When this variable
134 * is one, RCU must actually do all the hard work required to detect real 135 * is RCU_SCHEDULER_INIT, RCU must actually do all the hard work required
135 * grace periods. This variable is also used to suppress boot-time false 136 * to detect real grace periods. This variable is also used to suppress
136 * positives from lockdep-RCU error checking. 137 * boot-time false positives from lockdep-RCU error checking. Finally, it
138 * transitions from RCU_SCHEDULER_INIT to RCU_SCHEDULER_RUNNING after RCU
139 * is fully initialized, including all of its kthreads having been spawned.
137 */ 140 */
138int rcu_scheduler_active __read_mostly; 141int rcu_scheduler_active __read_mostly;
139EXPORT_SYMBOL_GPL(rcu_scheduler_active); 142EXPORT_SYMBOL_GPL(rcu_scheduler_active);
@@ -3980,18 +3983,22 @@ static int __init rcu_spawn_gp_kthread(void)
3980early_initcall(rcu_spawn_gp_kthread); 3983early_initcall(rcu_spawn_gp_kthread);
3981 3984
3982/* 3985/*
3983 * This function is invoked towards the end of the scheduler's initialization 3986 * This function is invoked towards the end of the scheduler's
3984 * process. Before this is called, the idle task might contain 3987 * initialization process. Before this is called, the idle task might
3985 * RCU read-side critical sections (during which time, this idle 3988 * contain synchronous grace-period primitives (during which time, this idle
3986 * task is booting the system). After this function is called, the 3989 * task is booting the system, and such primitives are no-ops). After this
3987 * idle tasks are prohibited from containing RCU read-side critical 3990 * function is called, any synchronous grace-period primitives are run as
3988 * sections. This function also enables RCU lockdep checking. 3991 * expedited, with the requesting task driving the grace period forward.
3992 * A later core_initcall() rcu_exp_runtime_mode() will switch to full
3993 * runtime RCU functionality.
3989 */ 3994 */
3990void rcu_scheduler_starting(void) 3995void rcu_scheduler_starting(void)
3991{ 3996{
3992 WARN_ON(num_online_cpus() != 1); 3997 WARN_ON(num_online_cpus() != 1);
3993 WARN_ON(nr_context_switches() > 0); 3998 WARN_ON(nr_context_switches() > 0);
3994 rcu_scheduler_active = 1; 3999 rcu_test_sync_prims();
4000 rcu_scheduler_active = RCU_SCHEDULER_INIT;
4001 rcu_test_sync_prims();
3995} 4002}
3996 4003
3997/* 4004/*
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index d3053e99fdb6..e59e1849b89a 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -532,18 +532,28 @@ struct rcu_exp_work {
532}; 532};
533 533
534/* 534/*
535 * Common code to drive an expedited grace period forward, used by
536 * workqueues and mid-boot-time tasks.
537 */
538static void rcu_exp_sel_wait_wake(struct rcu_state *rsp,
539 smp_call_func_t func, unsigned long s)
540{
541 /* Initialize the rcu_node tree in preparation for the wait. */
542 sync_rcu_exp_select_cpus(rsp, func);
543
544 /* Wait and clean up, including waking everyone. */
545 rcu_exp_wait_wake(rsp, s);
546}
547
548/*
535 * Work-queue handler to drive an expedited grace period forward. 549 * Work-queue handler to drive an expedited grace period forward.
536 */ 550 */
537static void wait_rcu_exp_gp(struct work_struct *wp) 551static void wait_rcu_exp_gp(struct work_struct *wp)
538{ 552{
539 struct rcu_exp_work *rewp; 553 struct rcu_exp_work *rewp;
540 554
541 /* Initialize the rcu_node tree in preparation for the wait. */
542 rewp = container_of(wp, struct rcu_exp_work, rew_work); 555 rewp = container_of(wp, struct rcu_exp_work, rew_work);
543 sync_rcu_exp_select_cpus(rewp->rew_rsp, rewp->rew_func); 556 rcu_exp_sel_wait_wake(rewp->rew_rsp, rewp->rew_func, rewp->rew_s);
544
545 /* Wait and clean up, including waking everyone. */
546 rcu_exp_wait_wake(rewp->rew_rsp, rewp->rew_s);
547} 557}
548 558
549/* 559/*
@@ -569,12 +579,18 @@ static void _synchronize_rcu_expedited(struct rcu_state *rsp,
569 if (exp_funnel_lock(rsp, s)) 579 if (exp_funnel_lock(rsp, s))
570 return; /* Someone else did our work for us. */ 580 return; /* Someone else did our work for us. */
571 581
572 /* Marshall arguments and schedule the expedited grace period. */ 582 /* Ensure that load happens before action based on it. */
573 rew.rew_func = func; 583 if (unlikely(rcu_scheduler_active == RCU_SCHEDULER_INIT)) {
574 rew.rew_rsp = rsp; 584 /* Direct call during scheduler init and early_initcalls(). */
575 rew.rew_s = s; 585 rcu_exp_sel_wait_wake(rsp, func, s);
576 INIT_WORK_ONSTACK(&rew.rew_work, wait_rcu_exp_gp); 586 } else {
577 schedule_work(&rew.rew_work); 587 /* Marshall arguments & schedule the expedited grace period. */
588 rew.rew_func = func;
589 rew.rew_rsp = rsp;
590 rew.rew_s = s;
591 INIT_WORK_ONSTACK(&rew.rew_work, wait_rcu_exp_gp);
592 schedule_work(&rew.rew_work);
593 }
578 594
579 /* Wait for expedited grace period to complete. */ 595 /* Wait for expedited grace period to complete. */
580 rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id()); 596 rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id());
@@ -676,6 +692,8 @@ void synchronize_rcu_expedited(void)
676{ 692{
677 struct rcu_state *rsp = rcu_state_p; 693 struct rcu_state *rsp = rcu_state_p;
678 694
695 if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
696 return;
679 _synchronize_rcu_expedited(rsp, sync_rcu_exp_handler); 697 _synchronize_rcu_expedited(rsp, sync_rcu_exp_handler);
680} 698}
681EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); 699EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
@@ -693,3 +711,15 @@ void synchronize_rcu_expedited(void)
693EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); 711EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
694 712
695#endif /* #else #ifdef CONFIG_PREEMPT_RCU */ 713#endif /* #else #ifdef CONFIG_PREEMPT_RCU */
714
715/*
716 * Switch to run-time mode once Tree RCU has fully initialized.
717 */
718static int __init rcu_exp_runtime_mode(void)
719{
720 rcu_test_sync_prims();
721 rcu_scheduler_active = RCU_SCHEDULER_RUNNING;
722 rcu_test_sync_prims();
723 return 0;
724}
725core_initcall(rcu_exp_runtime_mode);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 85c5a883c6e3..56583e764ebf 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -670,7 +670,7 @@ void synchronize_rcu(void)
670 lock_is_held(&rcu_lock_map) || 670 lock_is_held(&rcu_lock_map) ||
671 lock_is_held(&rcu_sched_lock_map), 671 lock_is_held(&rcu_sched_lock_map),
672 "Illegal synchronize_rcu() in RCU read-side critical section"); 672 "Illegal synchronize_rcu() in RCU read-side critical section");
673 if (!rcu_scheduler_active) 673 if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
674 return; 674 return;
675 if (rcu_gp_is_expedited()) 675 if (rcu_gp_is_expedited())
676 synchronize_rcu_expedited(); 676 synchronize_rcu_expedited();
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index f19271dce0a9..4f6db7e6a117 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -121,11 +121,14 @@ EXPORT_SYMBOL(rcu_read_lock_sched_held);
121 * Should expedited grace-period primitives always fall back to their 121 * Should expedited grace-period primitives always fall back to their
122 * non-expedited counterparts? Intended for use within RCU. Note 122 * non-expedited counterparts? Intended for use within RCU. Note
123 * that if the user specifies both rcu_expedited and rcu_normal, then 123 * that if the user specifies both rcu_expedited and rcu_normal, then
124 * rcu_normal wins. 124 * rcu_normal wins. (Except during the time period during boot from
125 * when the first task is spawned until the rcu_exp_runtime_mode()
126 * core_initcall() is invoked, at which point everything is expedited.)
125 */ 127 */
126bool rcu_gp_is_normal(void) 128bool rcu_gp_is_normal(void)
127{ 129{
128 return READ_ONCE(rcu_normal); 130 return READ_ONCE(rcu_normal) &&
131 rcu_scheduler_active != RCU_SCHEDULER_INIT;
129} 132}
130EXPORT_SYMBOL_GPL(rcu_gp_is_normal); 133EXPORT_SYMBOL_GPL(rcu_gp_is_normal);
131 134
@@ -135,13 +138,14 @@ static atomic_t rcu_expedited_nesting =
135/* 138/*
136 * Should normal grace-period primitives be expedited? Intended for 139 * Should normal grace-period primitives be expedited? Intended for
137 * use within RCU. Note that this function takes the rcu_expedited 140 * use within RCU. Note that this function takes the rcu_expedited
138 * sysfs/boot variable into account as well as the rcu_expedite_gp() 141 * sysfs/boot variable and rcu_scheduler_active into account as well
139 * nesting. So looping on rcu_unexpedite_gp() until rcu_gp_is_expedited() 142 * as the rcu_expedite_gp() nesting. So looping on rcu_unexpedite_gp()
140 * returns false is a -really- bad idea. 143 * until rcu_gp_is_expedited() returns false is a -really- bad idea.
141 */ 144 */
142bool rcu_gp_is_expedited(void) 145bool rcu_gp_is_expedited(void)
143{ 146{
144 return rcu_expedited || atomic_read(&rcu_expedited_nesting); 147 return rcu_expedited || atomic_read(&rcu_expedited_nesting) ||
148 rcu_scheduler_active == RCU_SCHEDULER_INIT;
145} 149}
146EXPORT_SYMBOL_GPL(rcu_gp_is_expedited); 150EXPORT_SYMBOL_GPL(rcu_gp_is_expedited);
147 151
@@ -257,7 +261,7 @@ EXPORT_SYMBOL_GPL(rcu_callback_map);
257 261
258int notrace debug_lockdep_rcu_enabled(void) 262int notrace debug_lockdep_rcu_enabled(void)
259{ 263{
260 return rcu_scheduler_active && debug_locks && 264 return rcu_scheduler_active != RCU_SCHEDULER_INACTIVE && debug_locks &&
261 current->lockdep_recursion == 0; 265 current->lockdep_recursion == 0;
262} 266}
263EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled); 267EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
@@ -591,7 +595,7 @@ EXPORT_SYMBOL_GPL(call_rcu_tasks);
591void synchronize_rcu_tasks(void) 595void synchronize_rcu_tasks(void)
592{ 596{
593 /* Complain if the scheduler has not started. */ 597 /* Complain if the scheduler has not started. */
594 RCU_LOCKDEP_WARN(!rcu_scheduler_active, 598 RCU_LOCKDEP_WARN(rcu_scheduler_active == RCU_SCHEDULER_INACTIVE,
595 "synchronize_rcu_tasks called too soon"); 599 "synchronize_rcu_tasks called too soon");
596 600
597 /* Wait for the grace period. */ 601 /* Wait for the grace period. */
@@ -813,6 +817,23 @@ static void rcu_spawn_tasks_kthread(void)
813 817
814#endif /* #ifdef CONFIG_TASKS_RCU */ 818#endif /* #ifdef CONFIG_TASKS_RCU */
815 819
820/*
821 * Test each non-SRCU synchronous grace-period wait API. This is
822 * useful just after a change in mode for these primitives, and
823 * during early boot.
824 */
825void rcu_test_sync_prims(void)
826{
827 if (!IS_ENABLED(CONFIG_PROVE_RCU))
828 return;
829 synchronize_rcu();
830 synchronize_rcu_bh();
831 synchronize_sched();
832 synchronize_rcu_expedited();
833 synchronize_rcu_bh_expedited();
834 synchronize_sched_expedited();
835}
836
816#ifdef CONFIG_PROVE_RCU 837#ifdef CONFIG_PROVE_RCU
817 838
818/* 839/*
@@ -865,6 +886,7 @@ void rcu_early_boot_tests(void)
865 early_boot_test_call_rcu_bh(); 886 early_boot_test_call_rcu_bh();
866 if (rcu_self_test_sched) 887 if (rcu_self_test_sched)
867 early_boot_test_call_rcu_sched(); 888 early_boot_test_call_rcu_sched();
889 rcu_test_sync_prims();
868} 890}
869 891
870static int rcu_verify_early_boot_tests(void) 892static int rcu_verify_early_boot_tests(void)
diff --git a/kernel/signal.c b/kernel/signal.c
index ff046b73ff2d..3603d93a1968 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -346,7 +346,7 @@ static bool task_participate_group_stop(struct task_struct *task)
346 * fresh group stop. Read comment in do_signal_stop() for details. 346 * fresh group stop. Read comment in do_signal_stop() for details.
347 */ 347 */
348 if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) { 348 if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) {
349 sig->flags = SIGNAL_STOP_STOPPED; 349 signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED);
350 return true; 350 return true;
351 } 351 }
352 return false; 352 return false;
@@ -843,7 +843,7 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force)
843 * will take ->siglock, notice SIGNAL_CLD_MASK, and 843 * will take ->siglock, notice SIGNAL_CLD_MASK, and
844 * notify its parent. See get_signal_to_deliver(). 844 * notify its parent. See get_signal_to_deliver().
845 */ 845 */
846 signal->flags = why | SIGNAL_STOP_CONTINUED; 846 signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED);
847 signal->group_stop_count = 0; 847 signal->group_stop_count = 0;
848 signal->group_exit_code = 0; 848 signal->group_exit_code = 0;
849 } 849 }
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 2c115fdab397..74e0388cc88d 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -767,7 +767,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
767 tick = expires; 767 tick = expires;
768 768
769 /* Skip reprogram of event if its not changed */ 769 /* Skip reprogram of event if its not changed */
770 if (ts->tick_stopped && (expires == dev->next_event)) 770 if (ts->tick_stopped && (expires == ts->next_tick))
771 goto out; 771 goto out;
772 772
773 /* 773 /*
@@ -787,6 +787,8 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
787 trace_tick_stop(1, TICK_DEP_MASK_NONE); 787 trace_tick_stop(1, TICK_DEP_MASK_NONE);
788 } 788 }
789 789
790 ts->next_tick = tick;
791
790 /* 792 /*
791 * If the expiration time == KTIME_MAX, then we simply stop 793 * If the expiration time == KTIME_MAX, then we simply stop
792 * the tick timer. 794 * the tick timer.
@@ -802,7 +804,10 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
802 else 804 else
803 tick_program_event(tick, 1); 805 tick_program_event(tick, 1);
804out: 806out:
805 /* Update the estimated sleep length */ 807 /*
808 * Update the estimated sleep length until the next timer
809 * (not only the tick).
810 */
806 ts->sleep_length = ktime_sub(dev->next_event, now); 811 ts->sleep_length = ktime_sub(dev->next_event, now);
807 return tick; 812 return tick;
808} 813}
diff --git a/kernel/time/tick-sched.h b/kernel/time/tick-sched.h
index bf38226e5c17..075444e3d48e 100644
--- a/kernel/time/tick-sched.h
+++ b/kernel/time/tick-sched.h
@@ -27,6 +27,7 @@ enum tick_nohz_mode {
27 * timer is modified for nohz sleeps. This is necessary 27 * timer is modified for nohz sleeps. This is necessary
28 * to resume the tick timer operation in the timeline 28 * to resume the tick timer operation in the timeline
29 * when the CPU returns from nohz sleep. 29 * when the CPU returns from nohz sleep.
30 * @next_tick: Next tick to be fired when in dynticks mode.
30 * @tick_stopped: Indicator that the idle tick has been stopped 31 * @tick_stopped: Indicator that the idle tick has been stopped
31 * @idle_jiffies: jiffies at the entry to idle for idle time accounting 32 * @idle_jiffies: jiffies at the entry to idle for idle time accounting
32 * @idle_calls: Total number of idle calls 33 * @idle_calls: Total number of idle calls
@@ -44,6 +45,7 @@ struct tick_sched {
44 unsigned long check_clocks; 45 unsigned long check_clocks;
45 enum tick_nohz_mode nohz_mode; 46 enum tick_nohz_mode nohz_mode;
46 ktime_t last_tick; 47 ktime_t last_tick;
48 ktime_t next_tick;
47 int inidle; 49 int inidle;
48 int tick_stopped; 50 int tick_stopped;
49 unsigned long idle_jiffies; 51 unsigned long idle_jiffies;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b06848a104e6..eb9e9a7870fa 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -164,7 +164,7 @@ config DEBUG_INFO_REDUCED
164 164
165config DEBUG_INFO_SPLIT 165config DEBUG_INFO_SPLIT
166 bool "Produce split debuginfo in .dwo files" 166 bool "Produce split debuginfo in .dwo files"
167 depends on DEBUG_INFO 167 depends on DEBUG_INFO && !FRV
168 help 168 help
169 Generate debug info into separate .dwo files. This significantly 169 Generate debug info into separate .dwo files. This significantly
170 reduces the build directory size for builds with DEBUG_INFO, 170 reduces the build directory size for builds with DEBUG_INFO,
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 25f572303801..e68604ae3ced 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -730,43 +730,50 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
730} 730}
731EXPORT_SYMBOL(iov_iter_copy_from_user_atomic); 731EXPORT_SYMBOL(iov_iter_copy_from_user_atomic);
732 732
733static inline void pipe_truncate(struct iov_iter *i)
734{
735 struct pipe_inode_info *pipe = i->pipe;
736 if (pipe->nrbufs) {
737 size_t off = i->iov_offset;
738 int idx = i->idx;
739 int nrbufs = (idx - pipe->curbuf) & (pipe->buffers - 1);
740 if (off) {
741 pipe->bufs[idx].len = off - pipe->bufs[idx].offset;
742 idx = next_idx(idx, pipe);
743 nrbufs++;
744 }
745 while (pipe->nrbufs > nrbufs) {
746 pipe_buf_release(pipe, &pipe->bufs[idx]);
747 idx = next_idx(idx, pipe);
748 pipe->nrbufs--;
749 }
750 }
751}
752
733static void pipe_advance(struct iov_iter *i, size_t size) 753static void pipe_advance(struct iov_iter *i, size_t size)
734{ 754{
735 struct pipe_inode_info *pipe = i->pipe; 755 struct pipe_inode_info *pipe = i->pipe;
736 struct pipe_buffer *buf;
737 int idx = i->idx;
738 size_t off = i->iov_offset, orig_sz;
739
740 if (unlikely(i->count < size)) 756 if (unlikely(i->count < size))
741 size = i->count; 757 size = i->count;
742 orig_sz = size;
743
744 if (size) { 758 if (size) {
759 struct pipe_buffer *buf;
760 size_t off = i->iov_offset, left = size;
761 int idx = i->idx;
745 if (off) /* make it relative to the beginning of buffer */ 762 if (off) /* make it relative to the beginning of buffer */
746 size += off - pipe->bufs[idx].offset; 763 left += off - pipe->bufs[idx].offset;
747 while (1) { 764 while (1) {
748 buf = &pipe->bufs[idx]; 765 buf = &pipe->bufs[idx];
749 if (size <= buf->len) 766 if (left <= buf->len)
750 break; 767 break;
751 size -= buf->len; 768 left -= buf->len;
752 idx = next_idx(idx, pipe); 769 idx = next_idx(idx, pipe);
753 } 770 }
754 buf->len = size;
755 i->idx = idx; 771 i->idx = idx;
756 off = i->iov_offset = buf->offset + size; 772 i->iov_offset = buf->offset + left;
757 }
758 if (off)
759 idx = next_idx(idx, pipe);
760 if (pipe->nrbufs) {
761 int unused = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1);
762 /* [curbuf,unused) is in use. Free [idx,unused) */
763 while (idx != unused) {
764 pipe_buf_release(pipe, &pipe->bufs[idx]);
765 idx = next_idx(idx, pipe);
766 pipe->nrbufs--;
767 }
768 } 773 }
769 i->count -= orig_sz; 774 i->count -= size;
775 /* ... and discard everything past that point */
776 pipe_truncate(i);
770} 777}
771 778
772void iov_iter_advance(struct iov_iter *i, size_t size) 779void iov_iter_advance(struct iov_iter *i, size_t size)
@@ -826,6 +833,7 @@ void iov_iter_pipe(struct iov_iter *i, int direction,
826 size_t count) 833 size_t count)
827{ 834{
828 BUG_ON(direction != ITER_PIPE); 835 BUG_ON(direction != ITER_PIPE);
836 WARN_ON(pipe->nrbufs == pipe->buffers);
829 i->type = direction; 837 i->type = direction;
830 i->pipe = pipe; 838 i->pipe = pipe;
831 i->idx = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1); 839 i->idx = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1);
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 6f382e07de77..0b92d605fb69 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -640,6 +640,7 @@ static inline void radix_tree_shrink(struct radix_tree_root *root,
640 update_node(node, private); 640 update_node(node, private);
641 } 641 }
642 642
643 WARN_ON_ONCE(!list_empty(&node->private_list));
643 radix_tree_node_free(node); 644 radix_tree_node_free(node);
644 } 645 }
645} 646}
@@ -666,6 +667,7 @@ static void delete_node(struct radix_tree_root *root,
666 root->rnode = NULL; 667 root->rnode = NULL;
667 } 668 }
668 669
670 WARN_ON_ONCE(!list_empty(&node->private_list));
669 radix_tree_node_free(node); 671 radix_tree_node_free(node);
670 672
671 node = parent; 673 node = parent;
@@ -767,6 +769,7 @@ static void radix_tree_free_nodes(struct radix_tree_node *node)
767 struct radix_tree_node *old = child; 769 struct radix_tree_node *old = child;
768 offset = child->offset + 1; 770 offset = child->offset + 1;
769 child = child->parent; 771 child = child->parent;
772 WARN_ON_ONCE(!list_empty(&node->private_list));
770 radix_tree_node_free(old); 773 radix_tree_node_free(old);
771 if (old == entry_to_node(node)) 774 if (old == entry_to_node(node))
772 return; 775 return;
@@ -1824,15 +1827,19 @@ EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot);
1824 * __radix_tree_delete_node - try to free node after clearing a slot 1827 * __radix_tree_delete_node - try to free node after clearing a slot
1825 * @root: radix tree root 1828 * @root: radix tree root
1826 * @node: node containing @index 1829 * @node: node containing @index
1830 * @update_node: callback for changing leaf nodes
1831 * @private: private data to pass to @update_node
1827 * 1832 *
1828 * After clearing the slot at @index in @node from radix tree 1833 * After clearing the slot at @index in @node from radix tree
1829 * rooted at @root, call this function to attempt freeing the 1834 * rooted at @root, call this function to attempt freeing the
1830 * node and shrinking the tree. 1835 * node and shrinking the tree.
1831 */ 1836 */
1832void __radix_tree_delete_node(struct radix_tree_root *root, 1837void __radix_tree_delete_node(struct radix_tree_root *root,
1833 struct radix_tree_node *node) 1838 struct radix_tree_node *node,
1839 radix_tree_update_node_t update_node,
1840 void *private)
1834{ 1841{
1835 delete_node(root, node, NULL, NULL); 1842 delete_node(root, node, update_node, private);
1836} 1843}
1837 1844
1838/** 1845/**
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index cb1b54ee8527..a8d74a733a38 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -53,7 +53,7 @@
53 */ 53 */
54#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) 54#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
55 55
56int swiotlb_force; 56enum swiotlb_force swiotlb_force;
57 57
58/* 58/*
59 * Used to do a quick range check in swiotlb_tbl_unmap_single and 59 * Used to do a quick range check in swiotlb_tbl_unmap_single and
@@ -83,6 +83,12 @@ static unsigned int *io_tlb_list;
83static unsigned int io_tlb_index; 83static unsigned int io_tlb_index;
84 84
85/* 85/*
86 * Max segment that we can provide which (if pages are contingous) will
87 * not be bounced (unless SWIOTLB_FORCE is set).
88 */
89unsigned int max_segment;
90
91/*
86 * We need to save away the original address corresponding to a mapped entry 92 * We need to save away the original address corresponding to a mapped entry
87 * for the sync operations. 93 * for the sync operations.
88 */ 94 */
@@ -106,8 +112,12 @@ setup_io_tlb_npages(char *str)
106 } 112 }
107 if (*str == ',') 113 if (*str == ',')
108 ++str; 114 ++str;
109 if (!strcmp(str, "force")) 115 if (!strcmp(str, "force")) {
110 swiotlb_force = 1; 116 swiotlb_force = SWIOTLB_FORCE;
117 } else if (!strcmp(str, "noforce")) {
118 swiotlb_force = SWIOTLB_NO_FORCE;
119 io_tlb_nslabs = 1;
120 }
111 121
112 return 0; 122 return 0;
113} 123}
@@ -120,6 +130,20 @@ unsigned long swiotlb_nr_tbl(void)
120} 130}
121EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); 131EXPORT_SYMBOL_GPL(swiotlb_nr_tbl);
122 132
133unsigned int swiotlb_max_segment(void)
134{
135 return max_segment;
136}
137EXPORT_SYMBOL_GPL(swiotlb_max_segment);
138
139void swiotlb_set_max_segment(unsigned int val)
140{
141 if (swiotlb_force == SWIOTLB_FORCE)
142 max_segment = 1;
143 else
144 max_segment = rounddown(val, PAGE_SIZE);
145}
146
123/* default to 64MB */ 147/* default to 64MB */
124#define IO_TLB_DEFAULT_SIZE (64UL<<20) 148#define IO_TLB_DEFAULT_SIZE (64UL<<20)
125unsigned long swiotlb_size_or_default(void) 149unsigned long swiotlb_size_or_default(void)
@@ -201,6 +225,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
201 if (verbose) 225 if (verbose)
202 swiotlb_print_info(); 226 swiotlb_print_info();
203 227
228 swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT);
204 return 0; 229 return 0;
205} 230}
206 231
@@ -279,6 +304,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
279 rc = swiotlb_late_init_with_tbl(vstart, io_tlb_nslabs); 304 rc = swiotlb_late_init_with_tbl(vstart, io_tlb_nslabs);
280 if (rc) 305 if (rc)
281 free_pages((unsigned long)vstart, order); 306 free_pages((unsigned long)vstart, order);
307
282 return rc; 308 return rc;
283} 309}
284 310
@@ -333,6 +359,8 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
333 359
334 late_alloc = 1; 360 late_alloc = 1;
335 361
362 swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT);
363
336 return 0; 364 return 0;
337 365
338cleanup4: 366cleanup4:
@@ -347,6 +375,7 @@ cleanup2:
347 io_tlb_end = 0; 375 io_tlb_end = 0;
348 io_tlb_start = 0; 376 io_tlb_start = 0;
349 io_tlb_nslabs = 0; 377 io_tlb_nslabs = 0;
378 max_segment = 0;
350 return -ENOMEM; 379 return -ENOMEM;
351} 380}
352 381
@@ -375,6 +404,7 @@ void __init swiotlb_free(void)
375 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); 404 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
376 } 405 }
377 io_tlb_nslabs = 0; 406 io_tlb_nslabs = 0;
407 max_segment = 0;
378} 408}
379 409
380int is_swiotlb_buffer(phys_addr_t paddr) 410int is_swiotlb_buffer(phys_addr_t paddr)
@@ -453,11 +483,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
453 : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT); 483 : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
454 484
455 /* 485 /*
456 * For mappings greater than a page, we limit the stride (and 486 * For mappings greater than or equal to a page, we limit the stride
457 * hence alignment) to a page size. 487 * (and hence alignment) to a page size.
458 */ 488 */
459 nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; 489 nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
460 if (size > PAGE_SIZE) 490 if (size >= PAGE_SIZE)
461 stride = (1 << (PAGE_SHIFT - IO_TLB_SHIFT)); 491 stride = (1 << (PAGE_SHIFT - IO_TLB_SHIFT));
462 else 492 else
463 stride = 1; 493 stride = 1;
@@ -543,8 +573,15 @@ static phys_addr_t
543map_single(struct device *hwdev, phys_addr_t phys, size_t size, 573map_single(struct device *hwdev, phys_addr_t phys, size_t size,
544 enum dma_data_direction dir, unsigned long attrs) 574 enum dma_data_direction dir, unsigned long attrs)
545{ 575{
546 dma_addr_t start_dma_addr = phys_to_dma(hwdev, io_tlb_start); 576 dma_addr_t start_dma_addr;
547 577
578 if (swiotlb_force == SWIOTLB_NO_FORCE) {
579 dev_warn_ratelimited(hwdev, "Cannot do DMA to address %pa\n",
580 &phys);
581 return SWIOTLB_MAP_ERROR;
582 }
583
584 start_dma_addr = phys_to_dma(hwdev, io_tlb_start);
548 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, 585 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size,
549 dir, attrs); 586 dir, attrs);
550} 587}
@@ -721,6 +758,9 @@ static void
721swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, 758swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
722 int do_panic) 759 int do_panic)
723{ 760{
761 if (swiotlb_force == SWIOTLB_NO_FORCE)
762 return;
763
724 /* 764 /*
725 * Ran out of IOMMU space for this operation. This is very bad. 765 * Ran out of IOMMU space for this operation. This is very bad.
726 * Unfortunately the drivers cannot handle this operation properly. 766 * Unfortunately the drivers cannot handle this operation properly.
@@ -763,7 +803,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
763 * we can safely return the device addr and not worry about bounce 803 * we can safely return the device addr and not worry about bounce
764 * buffering it. 804 * buffering it.
765 */ 805 */
766 if (dma_capable(dev, dev_addr, size) && !swiotlb_force) 806 if (dma_capable(dev, dev_addr, size) && swiotlb_force != SWIOTLB_FORCE)
767 return dev_addr; 807 return dev_addr;
768 808
769 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force); 809 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
@@ -904,7 +944,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
904 phys_addr_t paddr = sg_phys(sg); 944 phys_addr_t paddr = sg_phys(sg);
905 dma_addr_t dev_addr = phys_to_dma(hwdev, paddr); 945 dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
906 946
907 if (swiotlb_force || 947 if (swiotlb_force == SWIOTLB_FORCE ||
908 !dma_capable(hwdev, dev_addr, sg->length)) { 948 !dma_capable(hwdev, dev_addr, sg->length)) {
909 phys_addr_t map = map_single(hwdev, sg_phys(sg), 949 phys_addr_t map = map_single(hwdev, sg_phys(sg),
910 sg->length, dir, attrs); 950 sg->length, dir, attrs);
diff --git a/mm/filemap.c b/mm/filemap.c
index d0e4d1002059..b772a33ef640 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -138,7 +138,7 @@ static int page_cache_tree_insert(struct address_space *mapping,
138 dax_radix_locked_entry(0, RADIX_DAX_EMPTY)); 138 dax_radix_locked_entry(0, RADIX_DAX_EMPTY));
139 /* Wakeup waiters for exceptional entry lock */ 139 /* Wakeup waiters for exceptional entry lock */
140 dax_wake_mapping_entry_waiter(mapping, page->index, p, 140 dax_wake_mapping_entry_waiter(mapping, page->index, p,
141 false); 141 true);
142 } 142 }
143 } 143 }
144 __radix_tree_replace(&mapping->page_tree, node, slot, page, 144 __radix_tree_replace(&mapping->page_tree, node, slot, page,
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 10eedbf14421..9a6bd6c8d55a 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -883,15 +883,17 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd)
883{ 883{
884 pmd_t entry; 884 pmd_t entry;
885 unsigned long haddr; 885 unsigned long haddr;
886 bool write = vmf->flags & FAULT_FLAG_WRITE;
886 887
887 vmf->ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); 888 vmf->ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd);
888 if (unlikely(!pmd_same(*vmf->pmd, orig_pmd))) 889 if (unlikely(!pmd_same(*vmf->pmd, orig_pmd)))
889 goto unlock; 890 goto unlock;
890 891
891 entry = pmd_mkyoung(orig_pmd); 892 entry = pmd_mkyoung(orig_pmd);
893 if (write)
894 entry = pmd_mkdirty(entry);
892 haddr = vmf->address & HPAGE_PMD_MASK; 895 haddr = vmf->address & HPAGE_PMD_MASK;
893 if (pmdp_set_access_flags(vmf->vma, haddr, vmf->pmd, entry, 896 if (pmdp_set_access_flags(vmf->vma, haddr, vmf->pmd, entry, write))
894 vmf->flags & FAULT_FLAG_WRITE))
895 update_mmu_cache_pmd(vmf->vma, vmf->address, vmf->pmd); 897 update_mmu_cache_pmd(vmf->vma, vmf->address, vmf->pmd);
896 898
897unlock: 899unlock:
@@ -919,8 +921,7 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd,
919 } 921 }
920 922
921 for (i = 0; i < HPAGE_PMD_NR; i++) { 923 for (i = 0; i < HPAGE_PMD_NR; i++) {
922 pages[i] = alloc_page_vma_node(GFP_HIGHUSER_MOVABLE | 924 pages[i] = alloc_page_vma_node(GFP_HIGHUSER_MOVABLE, vma,
923 __GFP_OTHER_NODE, vma,
924 vmf->address, page_to_nid(page)); 925 vmf->address, page_to_nid(page));
925 if (unlikely(!pages[i] || 926 if (unlikely(!pages[i] ||
926 mem_cgroup_try_charge(pages[i], vma->vm_mm, 927 mem_cgroup_try_charge(pages[i], vma->vm_mm,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 3edb759c5c7d..c7025c132670 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1773,23 +1773,32 @@ free:
1773} 1773}
1774 1774
1775/* 1775/*
1776 * When releasing a hugetlb pool reservation, any surplus pages that were 1776 * This routine has two main purposes:
1777 * allocated to satisfy the reservation must be explicitly freed if they were 1777 * 1) Decrement the reservation count (resv_huge_pages) by the value passed
1778 * never used. 1778 * in unused_resv_pages. This corresponds to the prior adjustments made
1779 * Called with hugetlb_lock held. 1779 * to the associated reservation map.
1780 * 2) Free any unused surplus pages that may have been allocated to satisfy
1781 * the reservation. As many as unused_resv_pages may be freed.
1782 *
1783 * Called with hugetlb_lock held. However, the lock could be dropped (and
1784 * reacquired) during calls to cond_resched_lock. Whenever dropping the lock,
1785 * we must make sure nobody else can claim pages we are in the process of
1786 * freeing. Do this by ensuring resv_huge_page always is greater than the
1787 * number of huge pages we plan to free when dropping the lock.
1780 */ 1788 */
1781static void return_unused_surplus_pages(struct hstate *h, 1789static void return_unused_surplus_pages(struct hstate *h,
1782 unsigned long unused_resv_pages) 1790 unsigned long unused_resv_pages)
1783{ 1791{
1784 unsigned long nr_pages; 1792 unsigned long nr_pages;
1785 1793
1786 /* Uncommit the reservation */
1787 h->resv_huge_pages -= unused_resv_pages;
1788
1789 /* Cannot return gigantic pages currently */ 1794 /* Cannot return gigantic pages currently */
1790 if (hstate_is_gigantic(h)) 1795 if (hstate_is_gigantic(h))
1791 return; 1796 goto out;
1792 1797
1798 /*
1799 * Part (or even all) of the reservation could have been backed
1800 * by pre-allocated pages. Only free surplus pages.
1801 */
1793 nr_pages = min(unused_resv_pages, h->surplus_huge_pages); 1802 nr_pages = min(unused_resv_pages, h->surplus_huge_pages);
1794 1803
1795 /* 1804 /*
@@ -1799,12 +1808,22 @@ static void return_unused_surplus_pages(struct hstate *h,
1799 * when the nodes with surplus pages have no free pages. 1808 * when the nodes with surplus pages have no free pages.
1800 * free_pool_huge_page() will balance the the freed pages across the 1809 * free_pool_huge_page() will balance the the freed pages across the
1801 * on-line nodes with memory and will handle the hstate accounting. 1810 * on-line nodes with memory and will handle the hstate accounting.
1811 *
1812 * Note that we decrement resv_huge_pages as we free the pages. If
1813 * we drop the lock, resv_huge_pages will still be sufficiently large
1814 * to cover subsequent pages we may free.
1802 */ 1815 */
1803 while (nr_pages--) { 1816 while (nr_pages--) {
1817 h->resv_huge_pages--;
1818 unused_resv_pages--;
1804 if (!free_pool_huge_page(h, &node_states[N_MEMORY], 1)) 1819 if (!free_pool_huge_page(h, &node_states[N_MEMORY], 1))
1805 break; 1820 goto out;
1806 cond_resched_lock(&hugetlb_lock); 1821 cond_resched_lock(&hugetlb_lock);
1807 } 1822 }
1823
1824out:
1825 /* Fully uncommit the reservation */
1826 h->resv_huge_pages -= unused_resv_pages;
1808} 1827}
1809 1828
1810 1829
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index e32389a97030..77ae3239c3de 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -943,7 +943,7 @@ static void collapse_huge_page(struct mm_struct *mm,
943 VM_BUG_ON(address & ~HPAGE_PMD_MASK); 943 VM_BUG_ON(address & ~HPAGE_PMD_MASK);
944 944
945 /* Only allocate from the target node */ 945 /* Only allocate from the target node */
946 gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_OTHER_NODE | __GFP_THISNODE; 946 gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE;
947 947
948 /* 948 /*
949 * Before allocating the hugepage, release the mmap_sem read lock. 949 * Before allocating the hugepage, release the mmap_sem read lock.
@@ -1242,7 +1242,6 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
1242 struct vm_area_struct *vma; 1242 struct vm_area_struct *vma;
1243 unsigned long addr; 1243 unsigned long addr;
1244 pmd_t *pmd, _pmd; 1244 pmd_t *pmd, _pmd;
1245 bool deposited = false;
1246 1245
1247 i_mmap_lock_write(mapping); 1246 i_mmap_lock_write(mapping);
1248 vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { 1247 vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
@@ -1267,26 +1266,10 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
1267 spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd); 1266 spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd);
1268 /* assume page table is clear */ 1267 /* assume page table is clear */
1269 _pmd = pmdp_collapse_flush(vma, addr, pmd); 1268 _pmd = pmdp_collapse_flush(vma, addr, pmd);
1270 /*
1271 * now deposit the pgtable for arch that need it
1272 * otherwise free it.
1273 */
1274 if (arch_needs_pgtable_deposit()) {
1275 /*
1276 * The deposit should be visibile only after
1277 * collapse is seen by others.
1278 */
1279 smp_wmb();
1280 pgtable_trans_huge_deposit(vma->vm_mm, pmd,
1281 pmd_pgtable(_pmd));
1282 deposited = true;
1283 }
1284 spin_unlock(ptl); 1269 spin_unlock(ptl);
1285 up_write(&vma->vm_mm->mmap_sem); 1270 up_write(&vma->vm_mm->mmap_sem);
1286 if (!deposited) { 1271 atomic_long_dec(&vma->vm_mm->nr_ptes);
1287 atomic_long_dec(&vma->vm_mm->nr_ptes); 1272 pte_free(vma->vm_mm, pmd_pgtable(_pmd));
1288 pte_free(vma->vm_mm, pmd_pgtable(_pmd));
1289 }
1290 } 1273 }
1291 } 1274 }
1292 i_mmap_unlock_write(mapping); 1275 i_mmap_unlock_write(mapping);
@@ -1326,8 +1309,7 @@ static void collapse_shmem(struct mm_struct *mm,
1326 VM_BUG_ON(start & (HPAGE_PMD_NR - 1)); 1309 VM_BUG_ON(start & (HPAGE_PMD_NR - 1));
1327 1310
1328 /* Only allocate from the target node */ 1311 /* Only allocate from the target node */
1329 gfp = alloc_hugepage_khugepaged_gfpmask() | 1312 gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE;
1330 __GFP_OTHER_NODE | __GFP_THISNODE;
1331 1313
1332 new_page = khugepaged_alloc_page(hpage, gfp, node); 1314 new_page = khugepaged_alloc_page(hpage, gfp, node);
1333 if (!new_page) { 1315 if (!new_page) {
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4048897e7b01..a63a8f832664 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -625,8 +625,8 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
625unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, 625unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
626 int nid, unsigned int lru_mask) 626 int nid, unsigned int lru_mask)
627{ 627{
628 struct lruvec *lruvec = mem_cgroup_lruvec(NODE_DATA(nid), memcg);
628 unsigned long nr = 0; 629 unsigned long nr = 0;
629 struct mem_cgroup_per_node *mz;
630 enum lru_list lru; 630 enum lru_list lru;
631 631
632 VM_BUG_ON((unsigned)nid >= nr_node_ids); 632 VM_BUG_ON((unsigned)nid >= nr_node_ids);
@@ -634,8 +634,7 @@ unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
634 for_each_lru(lru) { 634 for_each_lru(lru) {
635 if (!(BIT(lru) & lru_mask)) 635 if (!(BIT(lru) & lru_mask))
636 continue; 636 continue;
637 mz = mem_cgroup_nodeinfo(memcg, nid); 637 nr += mem_cgroup_get_lru_size(lruvec, lru);
638 nr += mz->lru_size[lru];
639 } 638 }
640 return nr; 639 return nr;
641} 640}
@@ -1002,6 +1001,7 @@ out:
1002 * mem_cgroup_update_lru_size - account for adding or removing an lru page 1001 * mem_cgroup_update_lru_size - account for adding or removing an lru page
1003 * @lruvec: mem_cgroup per zone lru vector 1002 * @lruvec: mem_cgroup per zone lru vector
1004 * @lru: index of lru list the page is sitting on 1003 * @lru: index of lru list the page is sitting on
1004 * @zid: zone id of the accounted pages
1005 * @nr_pages: positive when adding or negative when removing 1005 * @nr_pages: positive when adding or negative when removing
1006 * 1006 *
1007 * This function must be called under lru_lock, just before a page is added 1007 * This function must be called under lru_lock, just before a page is added
@@ -1009,27 +1009,25 @@ out:
1009 * so as to allow it to check that lru_size 0 is consistent with list_empty). 1009 * so as to allow it to check that lru_size 0 is consistent with list_empty).
1010 */ 1010 */
1011void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, 1011void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
1012 int nr_pages) 1012 int zid, int nr_pages)
1013{ 1013{
1014 struct mem_cgroup_per_node *mz; 1014 struct mem_cgroup_per_node *mz;
1015 unsigned long *lru_size; 1015 unsigned long *lru_size;
1016 long size; 1016 long size;
1017 bool empty;
1018 1017
1019 if (mem_cgroup_disabled()) 1018 if (mem_cgroup_disabled())
1020 return; 1019 return;
1021 1020
1022 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec); 1021 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
1023 lru_size = mz->lru_size + lru; 1022 lru_size = &mz->lru_zone_size[zid][lru];
1024 empty = list_empty(lruvec->lists + lru);
1025 1023
1026 if (nr_pages < 0) 1024 if (nr_pages < 0)
1027 *lru_size += nr_pages; 1025 *lru_size += nr_pages;
1028 1026
1029 size = *lru_size; 1027 size = *lru_size;
1030 if (WARN_ONCE(size < 0 || empty != !size, 1028 if (WARN_ONCE(size < 0,
1031 "%s(%p, %d, %d): lru_size %ld but %sempty\n", 1029 "%s(%p, %d, %d): lru_size %ld\n",
1032 __func__, lruvec, lru, nr_pages, size, empty ? "" : "not ")) { 1030 __func__, lruvec, lru, nr_pages, size)) {
1033 VM_BUG_ON(1); 1031 VM_BUG_ON(1);
1034 *lru_size = 0; 1032 *lru_size = 0;
1035 } 1033 }
diff --git a/mm/memory.c b/mm/memory.c
index 7d23b5050248..6bf2b471e30c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3008,13 +3008,6 @@ static int do_set_pmd(struct vm_fault *vmf, struct page *page)
3008 ret = 0; 3008 ret = 0;
3009 count_vm_event(THP_FILE_MAPPED); 3009 count_vm_event(THP_FILE_MAPPED);
3010out: 3010out:
3011 /*
3012 * If we are going to fallback to pte mapping, do a
3013 * withdraw with pmd lock held.
3014 */
3015 if (arch_needs_pgtable_deposit() && ret == VM_FAULT_FALLBACK)
3016 vmf->prealloc_pte = pgtable_trans_huge_withdraw(vma->vm_mm,
3017 vmf->pmd);
3018 spin_unlock(vmf->ptl); 3011 spin_unlock(vmf->ptl);
3019 return ret; 3012 return ret;
3020} 3013}
@@ -3055,20 +3048,18 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
3055 3048
3056 ret = do_set_pmd(vmf, page); 3049 ret = do_set_pmd(vmf, page);
3057 if (ret != VM_FAULT_FALLBACK) 3050 if (ret != VM_FAULT_FALLBACK)
3058 goto fault_handled; 3051 return ret;
3059 } 3052 }
3060 3053
3061 if (!vmf->pte) { 3054 if (!vmf->pte) {
3062 ret = pte_alloc_one_map(vmf); 3055 ret = pte_alloc_one_map(vmf);
3063 if (ret) 3056 if (ret)
3064 goto fault_handled; 3057 return ret;
3065 } 3058 }
3066 3059
3067 /* Re-check under ptl */ 3060 /* Re-check under ptl */
3068 if (unlikely(!pte_none(*vmf->pte))) { 3061 if (unlikely(!pte_none(*vmf->pte)))
3069 ret = VM_FAULT_NOPAGE; 3062 return VM_FAULT_NOPAGE;
3070 goto fault_handled;
3071 }
3072 3063
3073 flush_icache_page(vma, page); 3064 flush_icache_page(vma, page);
3074 entry = mk_pte(page, vma->vm_page_prot); 3065 entry = mk_pte(page, vma->vm_page_prot);
@@ -3088,15 +3079,8 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
3088 3079
3089 /* no need to invalidate: a not-present page won't be cached */ 3080 /* no need to invalidate: a not-present page won't be cached */
3090 update_mmu_cache(vma, vmf->address, vmf->pte); 3081 update_mmu_cache(vma, vmf->address, vmf->pte);
3091 ret = 0;
3092 3082
3093fault_handled: 3083 return 0;
3094 /* preallocated pagetable is unused: free it */
3095 if (vmf->prealloc_pte) {
3096 pte_free(vmf->vma->vm_mm, vmf->prealloc_pte);
3097 vmf->prealloc_pte = 0;
3098 }
3099 return ret;
3100} 3084}
3101 3085
3102 3086
@@ -3360,15 +3344,24 @@ static int do_shared_fault(struct vm_fault *vmf)
3360static int do_fault(struct vm_fault *vmf) 3344static int do_fault(struct vm_fault *vmf)
3361{ 3345{
3362 struct vm_area_struct *vma = vmf->vma; 3346 struct vm_area_struct *vma = vmf->vma;
3347 int ret;
3363 3348
3364 /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */ 3349 /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */
3365 if (!vma->vm_ops->fault) 3350 if (!vma->vm_ops->fault)
3366 return VM_FAULT_SIGBUS; 3351 ret = VM_FAULT_SIGBUS;
3367 if (!(vmf->flags & FAULT_FLAG_WRITE)) 3352 else if (!(vmf->flags & FAULT_FLAG_WRITE))
3368 return do_read_fault(vmf); 3353 ret = do_read_fault(vmf);
3369 if (!(vma->vm_flags & VM_SHARED)) 3354 else if (!(vma->vm_flags & VM_SHARED))
3370 return do_cow_fault(vmf); 3355 ret = do_cow_fault(vmf);
3371 return do_shared_fault(vmf); 3356 else
3357 ret = do_shared_fault(vmf);
3358
3359 /* preallocated pagetable is unused: free it */
3360 if (vmf->prealloc_pte) {
3361 pte_free(vma->vm_mm, vmf->prealloc_pte);
3362 vmf->prealloc_pte = 0;
3363 }
3364 return ret;
3372} 3365}
3373 3366
3374static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, 3367static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
@@ -3779,8 +3772,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
3779} 3772}
3780#endif /* __PAGETABLE_PMD_FOLDED */ 3773#endif /* __PAGETABLE_PMD_FOLDED */
3781 3774
3782static int __follow_pte(struct mm_struct *mm, unsigned long address, 3775static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
3783 pte_t **ptepp, spinlock_t **ptlp) 3776 pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
3784{ 3777{
3785 pgd_t *pgd; 3778 pgd_t *pgd;
3786 pud_t *pud; 3779 pud_t *pud;
@@ -3797,11 +3790,20 @@ static int __follow_pte(struct mm_struct *mm, unsigned long address,
3797 3790
3798 pmd = pmd_offset(pud, address); 3791 pmd = pmd_offset(pud, address);
3799 VM_BUG_ON(pmd_trans_huge(*pmd)); 3792 VM_BUG_ON(pmd_trans_huge(*pmd));
3800 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
3801 goto out;
3802 3793
3803 /* We cannot handle huge page PFN maps. Luckily they don't exist. */ 3794 if (pmd_huge(*pmd)) {
3804 if (pmd_huge(*pmd)) 3795 if (!pmdpp)
3796 goto out;
3797
3798 *ptlp = pmd_lock(mm, pmd);
3799 if (pmd_huge(*pmd)) {
3800 *pmdpp = pmd;
3801 return 0;
3802 }
3803 spin_unlock(*ptlp);
3804 }
3805
3806 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
3805 goto out; 3807 goto out;
3806 3808
3807 ptep = pte_offset_map_lock(mm, pmd, address, ptlp); 3809 ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
@@ -3817,16 +3819,30 @@ out:
3817 return -EINVAL; 3819 return -EINVAL;
3818} 3820}
3819 3821
3820int follow_pte(struct mm_struct *mm, unsigned long address, pte_t **ptepp, 3822static inline int follow_pte(struct mm_struct *mm, unsigned long address,
3821 spinlock_t **ptlp) 3823 pte_t **ptepp, spinlock_t **ptlp)
3824{
3825 int res;
3826
3827 /* (void) is needed to make gcc happy */
3828 (void) __cond_lock(*ptlp,
3829 !(res = __follow_pte_pmd(mm, address, ptepp, NULL,
3830 ptlp)));
3831 return res;
3832}
3833
3834int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
3835 pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
3822{ 3836{
3823 int res; 3837 int res;
3824 3838
3825 /* (void) is needed to make gcc happy */ 3839 /* (void) is needed to make gcc happy */
3826 (void) __cond_lock(*ptlp, 3840 (void) __cond_lock(*ptlp,
3827 !(res = __follow_pte(mm, address, ptepp, ptlp))); 3841 !(res = __follow_pte_pmd(mm, address, ptepp, pmdpp,
3842 ptlp)));
3828 return res; 3843 return res;
3829} 3844}
3845EXPORT_SYMBOL(follow_pte_pmd);
3830 3846
3831/** 3847/**
3832 * follow_pfn - look up PFN at a user virtual address 3848 * follow_pfn - look up PFN at a user virtual address
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2c6d5f64feca..d604d2596b7b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1864,14 +1864,14 @@ int move_freepages(struct zone *zone,
1864#endif 1864#endif
1865 1865
1866 for (page = start_page; page <= end_page;) { 1866 for (page = start_page; page <= end_page;) {
1867 /* Make sure we are not inadvertently changing nodes */
1868 VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
1869
1870 if (!pfn_valid_within(page_to_pfn(page))) { 1867 if (!pfn_valid_within(page_to_pfn(page))) {
1871 page++; 1868 page++;
1872 continue; 1869 continue;
1873 } 1870 }
1874 1871
1872 /* Make sure we are not inadvertently changing nodes */
1873 VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
1874
1875 if (!PageBuddy(page)) { 1875 if (!PageBuddy(page)) {
1876 page++; 1876 page++;
1877 continue; 1877 continue;
@@ -2583,30 +2583,22 @@ int __isolate_free_page(struct page *page, unsigned int order)
2583 * Update NUMA hit/miss statistics 2583 * Update NUMA hit/miss statistics
2584 * 2584 *
2585 * Must be called with interrupts disabled. 2585 * Must be called with interrupts disabled.
2586 *
2587 * When __GFP_OTHER_NODE is set assume the node of the preferred
2588 * zone is the local node. This is useful for daemons who allocate
2589 * memory on behalf of other processes.
2590 */ 2586 */
2591static inline void zone_statistics(struct zone *preferred_zone, struct zone *z, 2587static inline void zone_statistics(struct zone *preferred_zone, struct zone *z)
2592 gfp_t flags)
2593{ 2588{
2594#ifdef CONFIG_NUMA 2589#ifdef CONFIG_NUMA
2595 int local_nid = numa_node_id();
2596 enum zone_stat_item local_stat = NUMA_LOCAL; 2590 enum zone_stat_item local_stat = NUMA_LOCAL;
2597 2591
2598 if (unlikely(flags & __GFP_OTHER_NODE)) { 2592 if (z->node != numa_node_id())
2599 local_stat = NUMA_OTHER; 2593 local_stat = NUMA_OTHER;
2600 local_nid = preferred_zone->node;
2601 }
2602 2594
2603 if (z->node == local_nid) { 2595 if (z->node == preferred_zone->node)
2604 __inc_zone_state(z, NUMA_HIT); 2596 __inc_zone_state(z, NUMA_HIT);
2605 __inc_zone_state(z, local_stat); 2597 else {
2606 } else {
2607 __inc_zone_state(z, NUMA_MISS); 2598 __inc_zone_state(z, NUMA_MISS);
2608 __inc_zone_state(preferred_zone, NUMA_FOREIGN); 2599 __inc_zone_state(preferred_zone, NUMA_FOREIGN);
2609 } 2600 }
2601 __inc_zone_state(z, local_stat);
2610#endif 2602#endif
2611} 2603}
2612 2604
@@ -2674,7 +2666,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
2674 } 2666 }
2675 2667
2676 __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); 2668 __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order);
2677 zone_statistics(preferred_zone, zone, gfp_flags); 2669 zone_statistics(preferred_zone, zone);
2678 local_irq_restore(flags); 2670 local_irq_restore(flags);
2679 2671
2680 VM_BUG_ON_PAGE(bad_range(zone, page), page); 2672 VM_BUG_ON_PAGE(bad_range(zone, page), page);
@@ -3904,8 +3896,8 @@ EXPORT_SYMBOL(free_pages);
3904 * drivers to provide a backing region of memory for use as either an 3896 * drivers to provide a backing region of memory for use as either an
3905 * sk_buff->head, or to be used in the "frags" portion of skb_shared_info. 3897 * sk_buff->head, or to be used in the "frags" portion of skb_shared_info.
3906 */ 3898 */
3907static struct page *__page_frag_refill(struct page_frag_cache *nc, 3899static struct page *__page_frag_cache_refill(struct page_frag_cache *nc,
3908 gfp_t gfp_mask) 3900 gfp_t gfp_mask)
3909{ 3901{
3910 struct page *page = NULL; 3902 struct page *page = NULL;
3911 gfp_t gfp = gfp_mask; 3903 gfp_t gfp = gfp_mask;
@@ -3925,22 +3917,23 @@ static struct page *__page_frag_refill(struct page_frag_cache *nc,
3925 return page; 3917 return page;
3926} 3918}
3927 3919
3928void __page_frag_drain(struct page *page, unsigned int order, 3920void __page_frag_cache_drain(struct page *page, unsigned int count)
3929 unsigned int count)
3930{ 3921{
3931 VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); 3922 VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
3932 3923
3933 if (page_ref_sub_and_test(page, count)) { 3924 if (page_ref_sub_and_test(page, count)) {
3925 unsigned int order = compound_order(page);
3926
3934 if (order == 0) 3927 if (order == 0)
3935 free_hot_cold_page(page, false); 3928 free_hot_cold_page(page, false);
3936 else 3929 else
3937 __free_pages_ok(page, order); 3930 __free_pages_ok(page, order);
3938 } 3931 }
3939} 3932}
3940EXPORT_SYMBOL(__page_frag_drain); 3933EXPORT_SYMBOL(__page_frag_cache_drain);
3941 3934
3942void *__alloc_page_frag(struct page_frag_cache *nc, 3935void *page_frag_alloc(struct page_frag_cache *nc,
3943 unsigned int fragsz, gfp_t gfp_mask) 3936 unsigned int fragsz, gfp_t gfp_mask)
3944{ 3937{
3945 unsigned int size = PAGE_SIZE; 3938 unsigned int size = PAGE_SIZE;
3946 struct page *page; 3939 struct page *page;
@@ -3948,7 +3941,7 @@ void *__alloc_page_frag(struct page_frag_cache *nc,
3948 3941
3949 if (unlikely(!nc->va)) { 3942 if (unlikely(!nc->va)) {
3950refill: 3943refill:
3951 page = __page_frag_refill(nc, gfp_mask); 3944 page = __page_frag_cache_refill(nc, gfp_mask);
3952 if (!page) 3945 if (!page)
3953 return NULL; 3946 return NULL;
3954 3947
@@ -3991,19 +3984,19 @@ refill:
3991 3984
3992 return nc->va + offset; 3985 return nc->va + offset;
3993} 3986}
3994EXPORT_SYMBOL(__alloc_page_frag); 3987EXPORT_SYMBOL(page_frag_alloc);
3995 3988
3996/* 3989/*
3997 * Frees a page fragment allocated out of either a compound or order 0 page. 3990 * Frees a page fragment allocated out of either a compound or order 0 page.
3998 */ 3991 */
3999void __free_page_frag(void *addr) 3992void page_frag_free(void *addr)
4000{ 3993{
4001 struct page *page = virt_to_head_page(addr); 3994 struct page *page = virt_to_head_page(addr);
4002 3995
4003 if (unlikely(put_page_testzero(page))) 3996 if (unlikely(put_page_testzero(page)))
4004 __free_pages_ok(page, compound_order(page)); 3997 __free_pages_ok(page, compound_order(page));
4005} 3998}
4006EXPORT_SYMBOL(__free_page_frag); 3999EXPORT_SYMBOL(page_frag_free);
4007 4000
4008static void *make_alloc_exact(unsigned long addr, unsigned int order, 4001static void *make_alloc_exact(unsigned long addr, unsigned int order,
4009 size_t size) 4002 size_t size)
diff --git a/mm/slab.c b/mm/slab.c
index 29bc6c0dedd0..4f2ec6bb46eb 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2457,7 +2457,6 @@ union freelist_init_state {
2457 unsigned int pos; 2457 unsigned int pos;
2458 unsigned int *list; 2458 unsigned int *list;
2459 unsigned int count; 2459 unsigned int count;
2460 unsigned int rand;
2461 }; 2460 };
2462 struct rnd_state rnd_state; 2461 struct rnd_state rnd_state;
2463}; 2462};
@@ -2483,8 +2482,7 @@ static bool freelist_state_initialize(union freelist_init_state *state,
2483 } else { 2482 } else {
2484 state->list = cachep->random_seq; 2483 state->list = cachep->random_seq;
2485 state->count = count; 2484 state->count = count;
2486 state->pos = 0; 2485 state->pos = rand % count;
2487 state->rand = rand;
2488 ret = true; 2486 ret = true;
2489 } 2487 }
2490 return ret; 2488 return ret;
@@ -2493,7 +2491,9 @@ static bool freelist_state_initialize(union freelist_init_state *state,
2493/* Get the next entry on the list and randomize it using a random shift */ 2491/* Get the next entry on the list and randomize it using a random shift */
2494static freelist_idx_t next_random_slot(union freelist_init_state *state) 2492static freelist_idx_t next_random_slot(union freelist_init_state *state)
2495{ 2493{
2496 return (state->list[state->pos++] + state->rand) % state->count; 2494 if (state->pos >= state->count)
2495 state->pos = 0;
2496 return state->list[state->pos++];
2497} 2497}
2498 2498
2499/* Swap two freelist entries */ 2499/* Swap two freelist entries */
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 1c6e0321205d..4761701d1721 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -943,11 +943,25 @@ bool reuse_swap_page(struct page *page, int *total_mapcount)
943 count = page_trans_huge_mapcount(page, total_mapcount); 943 count = page_trans_huge_mapcount(page, total_mapcount);
944 if (count <= 1 && PageSwapCache(page)) { 944 if (count <= 1 && PageSwapCache(page)) {
945 count += page_swapcount(page); 945 count += page_swapcount(page);
946 if (count == 1 && !PageWriteback(page)) { 946 if (count != 1)
947 goto out;
948 if (!PageWriteback(page)) {
947 delete_from_swap_cache(page); 949 delete_from_swap_cache(page);
948 SetPageDirty(page); 950 SetPageDirty(page);
951 } else {
952 swp_entry_t entry;
953 struct swap_info_struct *p;
954
955 entry.val = page_private(page);
956 p = swap_info_get(entry);
957 if (p->flags & SWP_STABLE_WRITES) {
958 spin_unlock(&p->lock);
959 return false;
960 }
961 spin_unlock(&p->lock);
949 } 962 }
950 } 963 }
964out:
951 return count <= 1; 965 return count <= 1;
952} 966}
953 967
@@ -2448,6 +2462,10 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2448 error = -ENOMEM; 2462 error = -ENOMEM;
2449 goto bad_swap; 2463 goto bad_swap;
2450 } 2464 }
2465
2466 if (bdi_cap_stable_pages_required(inode_to_bdi(inode)))
2467 p->flags |= SWP_STABLE_WRITES;
2468
2451 if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) { 2469 if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
2452 int cpu; 2470 int cpu;
2453 2471
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6aa5b01d3e75..532a2a750952 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -242,6 +242,16 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru)
242 return node_page_state(lruvec_pgdat(lruvec), NR_LRU_BASE + lru); 242 return node_page_state(lruvec_pgdat(lruvec), NR_LRU_BASE + lru);
243} 243}
244 244
245unsigned long lruvec_zone_lru_size(struct lruvec *lruvec, enum lru_list lru,
246 int zone_idx)
247{
248 if (!mem_cgroup_disabled())
249 return mem_cgroup_get_zone_lru_size(lruvec, lru, zone_idx);
250
251 return zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zone_idx],
252 NR_ZONE_LRU_BASE + lru);
253}
254
245/* 255/*
246 * Add a shrinker callback to be called from the vm. 256 * Add a shrinker callback to be called from the vm.
247 */ 257 */
@@ -1382,8 +1392,7 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode)
1382 * be complete before mem_cgroup_update_lru_size due to a santity check. 1392 * be complete before mem_cgroup_update_lru_size due to a santity check.
1383 */ 1393 */
1384static __always_inline void update_lru_sizes(struct lruvec *lruvec, 1394static __always_inline void update_lru_sizes(struct lruvec *lruvec,
1385 enum lru_list lru, unsigned long *nr_zone_taken, 1395 enum lru_list lru, unsigned long *nr_zone_taken)
1386 unsigned long nr_taken)
1387{ 1396{
1388 int zid; 1397 int zid;
1389 1398
@@ -1392,11 +1401,11 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec,
1392 continue; 1401 continue;
1393 1402
1394 __update_lru_size(lruvec, lru, zid, -nr_zone_taken[zid]); 1403 __update_lru_size(lruvec, lru, zid, -nr_zone_taken[zid]);
1395 }
1396
1397#ifdef CONFIG_MEMCG 1404#ifdef CONFIG_MEMCG
1398 mem_cgroup_update_lru_size(lruvec, lru, -nr_taken); 1405 mem_cgroup_update_lru_size(lruvec, lru, zid, -nr_zone_taken[zid]);
1399#endif 1406#endif
1407 }
1408
1400} 1409}
1401 1410
1402/* 1411/*
@@ -1501,7 +1510,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1501 *nr_scanned = scan; 1510 *nr_scanned = scan;
1502 trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan, scan, 1511 trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan, scan,
1503 nr_taken, mode, is_file_lru(lru)); 1512 nr_taken, mode, is_file_lru(lru));
1504 update_lru_sizes(lruvec, lru, nr_zone_taken, nr_taken); 1513 update_lru_sizes(lruvec, lru, nr_zone_taken);
1505 return nr_taken; 1514 return nr_taken;
1506} 1515}
1507 1516
@@ -2047,10 +2056,8 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,
2047 if (!managed_zone(zone)) 2056 if (!managed_zone(zone))
2048 continue; 2057 continue;
2049 2058
2050 inactive_zone = zone_page_state(zone, 2059 inactive_zone = lruvec_zone_lru_size(lruvec, file * LRU_FILE, zid);
2051 NR_ZONE_LRU_BASE + (file * LRU_FILE)); 2060 active_zone = lruvec_zone_lru_size(lruvec, (file * LRU_FILE) + LRU_ACTIVE, zid);
2052 active_zone = zone_page_state(zone,
2053 NR_ZONE_LRU_BASE + (file * LRU_FILE) + LRU_ACTIVE);
2054 2061
2055 inactive -= min(inactive, inactive_zone); 2062 inactive -= min(inactive, inactive_zone);
2056 active -= min(active, active_zone); 2063 active -= min(active, active_zone);
diff --git a/mm/workingset.c b/mm/workingset.c
index 241fa5d6b3b2..abb58ffa3c64 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -473,7 +473,8 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
473 if (WARN_ON_ONCE(node->exceptional)) 473 if (WARN_ON_ONCE(node->exceptional))
474 goto out_invalid; 474 goto out_invalid;
475 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM); 475 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM);
476 __radix_tree_delete_node(&mapping->page_tree, node); 476 __radix_tree_delete_node(&mapping->page_tree, node,
477 workingset_update_node, mapping);
477 478
478out_invalid: 479out_invalid:
479 spin_unlock(&mapping->tree_lock); 480 spin_unlock(&mapping->tree_lock);
diff --git a/net/Kconfig b/net/Kconfig
index a1005007224c..a29bb4b41c50 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -258,10 +258,6 @@ config XPS
258config HWBM 258config HWBM
259 bool 259 bool
260 260
261config SOCK_CGROUP_DATA
262 bool
263 default n
264
265config CGROUP_NET_PRIO 261config CGROUP_NET_PRIO
266 bool "Network priority cgroup" 262 bool "Network priority cgroup"
267 depends on CGROUPS 263 depends on CGROUPS
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 019557d0a11d..09cfe87f0a44 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1059,7 +1059,9 @@ static void __exit lane_module_cleanup(void)
1059{ 1059{
1060 int i; 1060 int i;
1061 1061
1062#ifdef CONFIG_PROC_FS
1062 remove_proc_entry("lec", atm_proc_root); 1063 remove_proc_entry("lec", atm_proc_root);
1064#endif
1063 1065
1064 deregister_atm_ioctl(&lane_ioctl_ops); 1066 deregister_atm_ioctl(&lane_ioctl_ops);
1065 1067
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 4855d18a8511..038b109b2be7 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -264,7 +264,7 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
264{ 264{
265 ax25_clear_queues(ax25); 265 ax25_clear_queues(ax25);
266 266
267 if (!sock_flag(ax25->sk, SOCK_DESTROY)) 267 if (!ax25->sk || !sock_flag(ax25->sk, SOCK_DESTROY))
268 ax25_stop_heartbeat(ax25); 268 ax25_stop_heartbeat(ax25);
269 ax25_stop_t1timer(ax25); 269 ax25_stop_t1timer(ax25);
270 ax25_stop_t2timer(ax25); 270 ax25_stop_t2timer(ax25);
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 8ca6a929bf12..95087e6e8258 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -399,7 +399,7 @@ bridged_dnat:
399 br_nf_hook_thresh(NF_BR_PRE_ROUTING, 399 br_nf_hook_thresh(NF_BR_PRE_ROUTING,
400 net, sk, skb, skb->dev, 400 net, sk, skb, skb->dev,
401 NULL, 401 NULL,
402 br_nf_pre_routing_finish); 402 br_nf_pre_routing_finish_bridge);
403 return 0; 403 return 0;
404 } 404 }
405 ether_addr_copy(eth_hdr(skb)->h_dest, dev->dev_addr); 405 ether_addr_copy(eth_hdr(skb)->h_dest, dev->dev_addr);
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index 3949ce70be07..292e33bd916e 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -214,7 +214,7 @@ static int ceph_aes_crypt(const struct ceph_crypto_key *key, bool encrypt,
214 SKCIPHER_REQUEST_ON_STACK(req, key->tfm); 214 SKCIPHER_REQUEST_ON_STACK(req, key->tfm);
215 struct sg_table sgt; 215 struct sg_table sgt;
216 struct scatterlist prealloc_sg; 216 struct scatterlist prealloc_sg;
217 char iv[AES_BLOCK_SIZE]; 217 char iv[AES_BLOCK_SIZE] __aligned(8);
218 int pad_byte = AES_BLOCK_SIZE - (in_len & (AES_BLOCK_SIZE - 1)); 218 int pad_byte = AES_BLOCK_SIZE - (in_len & (AES_BLOCK_SIZE - 1));
219 int crypt_len = encrypt ? in_len + pad_byte : in_len; 219 int crypt_len = encrypt ? in_len + pad_byte : in_len;
220 int ret; 220 int ret;
diff --git a/net/core/dev.c b/net/core/dev.c
index 8db5a0b4b520..07b307b0b414 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4441,7 +4441,9 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
4441 pinfo->nr_frags && 4441 pinfo->nr_frags &&
4442 !PageHighMem(skb_frag_page(frag0))) { 4442 !PageHighMem(skb_frag_page(frag0))) {
4443 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0); 4443 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
4444 NAPI_GRO_CB(skb)->frag0_len = skb_frag_size(frag0); 4444 NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int,
4445 skb_frag_size(frag0),
4446 skb->end - skb->tail);
4445 } 4447 }
4446} 4448}
4447 4449
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 8e0c0635ee97..fb55327dcfea 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
75 struct nlattr *nla; 75 struct nlattr *nla;
76 struct sk_buff *skb; 76 struct sk_buff *skb;
77 unsigned long flags; 77 unsigned long flags;
78 void *msg_header;
78 79
79 al = sizeof(struct net_dm_alert_msg); 80 al = sizeof(struct net_dm_alert_msg);
80 al += dm_hit_limit * sizeof(struct net_dm_drop_point); 81 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
@@ -82,21 +83,41 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
82 83
83 skb = genlmsg_new(al, GFP_KERNEL); 84 skb = genlmsg_new(al, GFP_KERNEL);
84 85
85 if (skb) { 86 if (!skb)
86 genlmsg_put(skb, 0, 0, &net_drop_monitor_family, 87 goto err;
87 0, NET_DM_CMD_ALERT); 88
88 nla = nla_reserve(skb, NLA_UNSPEC, 89 msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
89 sizeof(struct net_dm_alert_msg)); 90 0, NET_DM_CMD_ALERT);
90 msg = nla_data(nla); 91 if (!msg_header) {
91 memset(msg, 0, al); 92 nlmsg_free(skb);
92 } else { 93 skb = NULL;
93 mod_timer(&data->send_timer, jiffies + HZ / 10); 94 goto err;
95 }
96 nla = nla_reserve(skb, NLA_UNSPEC,
97 sizeof(struct net_dm_alert_msg));
98 if (!nla) {
99 nlmsg_free(skb);
100 skb = NULL;
101 goto err;
94 } 102 }
103 msg = nla_data(nla);
104 memset(msg, 0, al);
105 goto out;
95 106
107err:
108 mod_timer(&data->send_timer, jiffies + HZ / 10);
109out:
96 spin_lock_irqsave(&data->lock, flags); 110 spin_lock_irqsave(&data->lock, flags);
97 swap(data->skb, skb); 111 swap(data->skb, skb);
98 spin_unlock_irqrestore(&data->lock, flags); 112 spin_unlock_irqrestore(&data->lock, flags);
99 113
114 if (skb) {
115 struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
116 struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
117
118 genlmsg_end(skb, genlmsg_data(gnlh));
119 }
120
100 return skb; 121 return skb;
101} 122}
102 123
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index d6447dc10371..1b7673aac59d 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -67,8 +67,8 @@ EXPORT_SYMBOL(skb_flow_dissector_init);
67 * The function will try to retrieve a be32 entity at 67 * The function will try to retrieve a be32 entity at
68 * offset poff 68 * offset poff
69 */ 69 */
70__be16 skb_flow_get_be16(const struct sk_buff *skb, int poff, void *data, 70static __be16 skb_flow_get_be16(const struct sk_buff *skb, int poff,
71 int hlen) 71 void *data, int hlen)
72{ 72{
73 __be16 *u, _u; 73 __be16 *u, _u;
74 74
@@ -468,8 +468,9 @@ ip_proto_again:
468 if (hdr->flags & GRE_ACK) 468 if (hdr->flags & GRE_ACK)
469 offset += sizeof(((struct pptp_gre_header *)0)->ack); 469 offset += sizeof(((struct pptp_gre_header *)0)->ack);
470 470
471 ppp_hdr = skb_header_pointer(skb, nhoff + offset, 471 ppp_hdr = __skb_header_pointer(skb, nhoff + offset,
472 sizeof(_ppp_hdr), _ppp_hdr); 472 sizeof(_ppp_hdr),
473 data, hlen, _ppp_hdr);
473 if (!ppp_hdr) 474 if (!ppp_hdr)
474 goto out_bad; 475 goto out_bad;
475 476
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 18b5aae99bec..75e3ea7bda08 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3898,6 +3898,9 @@ static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
3898 u32 filter_mask; 3898 u32 filter_mask;
3899 int err; 3899 int err;
3900 3900
3901 if (nlmsg_len(nlh) < sizeof(*ifsm))
3902 return -EINVAL;
3903
3901 ifsm = nlmsg_data(nlh); 3904 ifsm = nlmsg_data(nlh);
3902 if (ifsm->ifindex > 0) 3905 if (ifsm->ifindex > 0)
3903 dev = __dev_get_by_index(net, ifsm->ifindex); 3906 dev = __dev_get_by_index(net, ifsm->ifindex);
@@ -3947,6 +3950,9 @@ static int rtnl_stats_dump(struct sk_buff *skb, struct netlink_callback *cb)
3947 3950
3948 cb->seq = net->dev_base_seq; 3951 cb->seq = net->dev_base_seq;
3949 3952
3953 if (nlmsg_len(cb->nlh) < sizeof(*ifsm))
3954 return -EINVAL;
3955
3950 ifsm = nlmsg_data(cb->nlh); 3956 ifsm = nlmsg_data(cb->nlh);
3951 filter_mask = ifsm->filter_mask; 3957 filter_mask = ifsm->filter_mask;
3952 if (!filter_mask) 3958 if (!filter_mask)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5a03730fbc1a..734c71468b01 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -369,7 +369,7 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
369 369
370 local_irq_save(flags); 370 local_irq_save(flags);
371 nc = this_cpu_ptr(&netdev_alloc_cache); 371 nc = this_cpu_ptr(&netdev_alloc_cache);
372 data = __alloc_page_frag(nc, fragsz, gfp_mask); 372 data = page_frag_alloc(nc, fragsz, gfp_mask);
373 local_irq_restore(flags); 373 local_irq_restore(flags);
374 return data; 374 return data;
375} 375}
@@ -391,7 +391,7 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
391{ 391{
392 struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); 392 struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
393 393
394 return __alloc_page_frag(&nc->page, fragsz, gfp_mask); 394 return page_frag_alloc(&nc->page, fragsz, gfp_mask);
395} 395}
396 396
397void *napi_alloc_frag(unsigned int fragsz) 397void *napi_alloc_frag(unsigned int fragsz)
@@ -441,7 +441,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len,
441 local_irq_save(flags); 441 local_irq_save(flags);
442 442
443 nc = this_cpu_ptr(&netdev_alloc_cache); 443 nc = this_cpu_ptr(&netdev_alloc_cache);
444 data = __alloc_page_frag(nc, len, gfp_mask); 444 data = page_frag_alloc(nc, len, gfp_mask);
445 pfmemalloc = nc->pfmemalloc; 445 pfmemalloc = nc->pfmemalloc;
446 446
447 local_irq_restore(flags); 447 local_irq_restore(flags);
@@ -505,7 +505,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len,
505 if (sk_memalloc_socks()) 505 if (sk_memalloc_socks())
506 gfp_mask |= __GFP_MEMALLOC; 506 gfp_mask |= __GFP_MEMALLOC;
507 507
508 data = __alloc_page_frag(&nc->page, len, gfp_mask); 508 data = page_frag_alloc(&nc->page, len, gfp_mask);
509 if (unlikely(!data)) 509 if (unlikely(!data))
510 return NULL; 510 return NULL;
511 511
diff --git a/net/core/sock.c b/net/core/sock.c
index f560e0826009..4eca27dc5c94 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -222,7 +222,7 @@ static const char *const af_family_key_strings[AF_MAX+1] = {
222 "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN" , "sk_lock-AF_PHONET" , 222 "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN" , "sk_lock-AF_PHONET" ,
223 "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG" , 223 "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG" ,
224 "sk_lock-AF_NFC" , "sk_lock-AF_VSOCK" , "sk_lock-AF_KCM" , 224 "sk_lock-AF_NFC" , "sk_lock-AF_VSOCK" , "sk_lock-AF_KCM" ,
225 "sk_lock-AF_MAX" 225 "sk_lock-AF_QIPCRTR", "sk_lock-AF_MAX"
226}; 226};
227static const char *const af_family_slock_key_strings[AF_MAX+1] = { 227static const char *const af_family_slock_key_strings[AF_MAX+1] = {
228 "slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" , 228 "slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" ,
@@ -239,7 +239,7 @@ static const char *const af_family_slock_key_strings[AF_MAX+1] = {
239 "slock-AF_RXRPC" , "slock-AF_ISDN" , "slock-AF_PHONET" , 239 "slock-AF_RXRPC" , "slock-AF_ISDN" , "slock-AF_PHONET" ,
240 "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG" , 240 "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG" ,
241 "slock-AF_NFC" , "slock-AF_VSOCK" ,"slock-AF_KCM" , 241 "slock-AF_NFC" , "slock-AF_VSOCK" ,"slock-AF_KCM" ,
242 "slock-AF_MAX" 242 "slock-AF_QIPCRTR", "slock-AF_MAX"
243}; 243};
244static const char *const af_family_clock_key_strings[AF_MAX+1] = { 244static const char *const af_family_clock_key_strings[AF_MAX+1] = {
245 "clock-AF_UNSPEC", "clock-AF_UNIX" , "clock-AF_INET" , 245 "clock-AF_UNSPEC", "clock-AF_UNIX" , "clock-AF_INET" ,
@@ -256,7 +256,7 @@ static const char *const af_family_clock_key_strings[AF_MAX+1] = {
256 "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , 256 "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" ,
257 "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG" , 257 "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG" ,
258 "clock-AF_NFC" , "clock-AF_VSOCK" , "clock-AF_KCM" , 258 "clock-AF_NFC" , "clock-AF_VSOCK" , "clock-AF_KCM" ,
259 "clock-AF_MAX" 259 "clock-AF_QIPCRTR", "clock-AF_MAX"
260}; 260};
261 261
262/* 262/*
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 5fff951a0a49..da3862124545 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -394,9 +394,11 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
394 return err; 394 return err;
395 } 395 }
396 396
397 err = dsa_cpu_port_ethtool_setup(dst->ds[0]); 397 if (dst->ds[0]) {
398 if (err) 398 err = dsa_cpu_port_ethtool_setup(dst->ds[0]);
399 return err; 399 if (err)
400 return err;
401 }
400 402
401 /* If we use a tagging format that doesn't have an ethertype 403 /* If we use a tagging format that doesn't have an ethertype
402 * field, make sure that all packets from this point on get 404 * field, make sure that all packets from this point on get
@@ -433,7 +435,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
433 dsa_ds_unapply(dst, ds); 435 dsa_ds_unapply(dst, ds);
434 } 436 }
435 437
436 dsa_cpu_port_ethtool_restore(dst->ds[0]); 438 if (dst->ds[0])
439 dsa_cpu_port_ethtool_restore(dst->ds[0]);
437 440
438 pr_info("DSA: tree %d unapplied\n", dst->tree); 441 pr_info("DSA: tree %d unapplied\n", dst->tree);
439 dst->applied = false; 442 dst->applied = false;
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 3ff8938893ec..eae0332b0e8c 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -85,7 +85,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
85 if (tb) 85 if (tb)
86 return tb; 86 return tb;
87 87
88 if (id == RT_TABLE_LOCAL) 88 if (id == RT_TABLE_LOCAL && !net->ipv4.fib_has_custom_rules)
89 alias = fib_new_table(net, RT_TABLE_MAIN); 89 alias = fib_new_table(net, RT_TABLE_MAIN);
90 90
91 tb = fib_trie_table(id, alias); 91 tb = fib_trie_table(id, alias);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 7a5b4c7d9a87..9a375b908d01 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1279,8 +1279,9 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
1279 nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid)) 1279 nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid))
1280 goto nla_put_failure; 1280 goto nla_put_failure;
1281#endif 1281#endif
1282 if (fi->fib_nh->nh_lwtstate) 1282 if (fi->fib_nh->nh_lwtstate &&
1283 lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate); 1283 lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate) < 0)
1284 goto nla_put_failure;
1284 } 1285 }
1285#ifdef CONFIG_IP_ROUTE_MULTIPATH 1286#ifdef CONFIG_IP_ROUTE_MULTIPATH
1286 if (fi->fib_nhs > 1) { 1287 if (fi->fib_nhs > 1) {
@@ -1316,8 +1317,10 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
1316 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) 1317 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
1317 goto nla_put_failure; 1318 goto nla_put_failure;
1318#endif 1319#endif
1319 if (nh->nh_lwtstate) 1320 if (nh->nh_lwtstate &&
1320 lwtunnel_fill_encap(skb, nh->nh_lwtstate); 1321 lwtunnel_fill_encap(skb, nh->nh_lwtstate) < 0)
1322 goto nla_put_failure;
1323
1321 /* length of rtnetlink header + attributes */ 1324 /* length of rtnetlink header + attributes */
1322 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh; 1325 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh;
1323 } endfor_nexthops(fi); 1326 } endfor_nexthops(fi);
@@ -1618,8 +1621,13 @@ void fib_select_multipath(struct fib_result *res, int hash)
1618void fib_select_path(struct net *net, struct fib_result *res, 1621void fib_select_path(struct net *net, struct fib_result *res,
1619 struct flowi4 *fl4, int mp_hash) 1622 struct flowi4 *fl4, int mp_hash)
1620{ 1623{
1624 bool oif_check;
1625
1626 oif_check = (fl4->flowi4_oif == 0 ||
1627 fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
1628
1621#ifdef CONFIG_IP_ROUTE_MULTIPATH 1629#ifdef CONFIG_IP_ROUTE_MULTIPATH
1622 if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) { 1630 if (res->fi->fib_nhs > 1 && oif_check) {
1623 if (mp_hash < 0) 1631 if (mp_hash < 0)
1624 mp_hash = get_hash_from_flowi4(fl4) >> 1; 1632 mp_hash = get_hash_from_flowi4(fl4) >> 1;
1625 1633
@@ -1629,7 +1637,7 @@ void fib_select_path(struct net *net, struct fib_result *res,
1629#endif 1637#endif
1630 if (!res->prefixlen && 1638 if (!res->prefixlen &&
1631 res->table->tb_num_default > 1 && 1639 res->table->tb_num_default > 1 &&
1632 res->type == RTN_UNICAST && !fl4->flowi4_oif) 1640 res->type == RTN_UNICAST && oif_check)
1633 fib_select_default(fl4, res); 1641 fib_select_default(fl4, res);
1634 1642
1635 if (!fl4->saddr) 1643 if (!fl4->saddr)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 68d622133f53..5b15459955f8 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -219,9 +219,14 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
219static void igmp_gq_start_timer(struct in_device *in_dev) 219static void igmp_gq_start_timer(struct in_device *in_dev)
220{ 220{
221 int tv = prandom_u32() % in_dev->mr_maxdelay; 221 int tv = prandom_u32() % in_dev->mr_maxdelay;
222 unsigned long exp = jiffies + tv + 2;
223
224 if (in_dev->mr_gq_running &&
225 time_after_eq(exp, (in_dev->mr_gq_timer).expires))
226 return;
222 227
223 in_dev->mr_gq_running = 1; 228 in_dev->mr_gq_running = 1;
224 if (!mod_timer(&in_dev->mr_gq_timer, jiffies+tv+2)) 229 if (!mod_timer(&in_dev->mr_gq_timer, exp))
225 in_dev_hold(in_dev); 230 in_dev_hold(in_dev);
226} 231}
227 232
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 57e1405e8282..53ae0c6315ad 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1225,8 +1225,14 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1225 * which has interface index (iif) as the first member of the 1225 * which has interface index (iif) as the first member of the
1226 * underlying inet{6}_skb_parm struct. This code then overlays 1226 * underlying inet{6}_skb_parm struct. This code then overlays
1227 * PKTINFO_SKB_CB and in_pktinfo also has iif as the first 1227 * PKTINFO_SKB_CB and in_pktinfo also has iif as the first
1228 * element so the iif is picked up from the prior IPCB 1228 * element so the iif is picked up from the prior IPCB. If iif
1229 * is the loopback interface, then return the sending interface
1230 * (e.g., process binds socket to eth0 for Tx which is
1231 * redirected to loopback in the rtable/dst).
1229 */ 1232 */
1233 if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
1234 pktinfo->ipi_ifindex = inet_iif(skb);
1235
1230 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); 1236 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1231 } else { 1237 } else {
1232 pktinfo->ipi_ifindex = 0; 1238 pktinfo->ipi_ifindex = 0;
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 21db00d0362b..a6b8c1a4102b 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -144,7 +144,7 @@ clusterip_config_find_get(struct net *net, __be32 clusterip, int entry)
144 rcu_read_lock_bh(); 144 rcu_read_lock_bh();
145 c = __clusterip_config_find(net, clusterip); 145 c = __clusterip_config_find(net, clusterip);
146 if (c) { 146 if (c) {
147 if (unlikely(!atomic_inc_not_zero(&c->refcount))) 147 if (!c->pde || unlikely(!atomic_inc_not_zero(&c->refcount)))
148 c = NULL; 148 c = NULL;
149 else if (entry) 149 else if (entry)
150 atomic_inc(&c->entries); 150 atomic_inc(&c->entries);
@@ -166,14 +166,15 @@ clusterip_config_init_nodelist(struct clusterip_config *c,
166 166
167static struct clusterip_config * 167static struct clusterip_config *
168clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip, 168clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
169 struct net_device *dev) 169 struct net_device *dev)
170{ 170{
171 struct net *net = dev_net(dev);
171 struct clusterip_config *c; 172 struct clusterip_config *c;
172 struct clusterip_net *cn = net_generic(dev_net(dev), clusterip_net_id); 173 struct clusterip_net *cn = net_generic(net, clusterip_net_id);
173 174
174 c = kzalloc(sizeof(*c), GFP_ATOMIC); 175 c = kzalloc(sizeof(*c), GFP_ATOMIC);
175 if (!c) 176 if (!c)
176 return NULL; 177 return ERR_PTR(-ENOMEM);
177 178
178 c->dev = dev; 179 c->dev = dev;
179 c->clusterip = ip; 180 c->clusterip = ip;
@@ -185,6 +186,17 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
185 atomic_set(&c->refcount, 1); 186 atomic_set(&c->refcount, 1);
186 atomic_set(&c->entries, 1); 187 atomic_set(&c->entries, 1);
187 188
189 spin_lock_bh(&cn->lock);
190 if (__clusterip_config_find(net, ip)) {
191 spin_unlock_bh(&cn->lock);
192 kfree(c);
193
194 return ERR_PTR(-EBUSY);
195 }
196
197 list_add_rcu(&c->list, &cn->configs);
198 spin_unlock_bh(&cn->lock);
199
188#ifdef CONFIG_PROC_FS 200#ifdef CONFIG_PROC_FS
189 { 201 {
190 char buffer[16]; 202 char buffer[16];
@@ -195,16 +207,16 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
195 cn->procdir, 207 cn->procdir,
196 &clusterip_proc_fops, c); 208 &clusterip_proc_fops, c);
197 if (!c->pde) { 209 if (!c->pde) {
210 spin_lock_bh(&cn->lock);
211 list_del_rcu(&c->list);
212 spin_unlock_bh(&cn->lock);
198 kfree(c); 213 kfree(c);
199 return NULL; 214
215 return ERR_PTR(-ENOMEM);
200 } 216 }
201 } 217 }
202#endif 218#endif
203 219
204 spin_lock_bh(&cn->lock);
205 list_add_rcu(&c->list, &cn->configs);
206 spin_unlock_bh(&cn->lock);
207
208 return c; 220 return c;
209} 221}
210 222
@@ -410,9 +422,9 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par)
410 422
411 config = clusterip_config_init(cipinfo, 423 config = clusterip_config_init(cipinfo,
412 e->ip.dst.s_addr, dev); 424 e->ip.dst.s_addr, dev);
413 if (!config) { 425 if (IS_ERR(config)) {
414 dev_put(dev); 426 dev_put(dev);
415 return -ENOMEM; 427 return PTR_ERR(config);
416 } 428 }
417 dev_mc_add(config->dev, config->clustermac); 429 dev_mc_add(config->dev, config->clustermac);
418 } 430 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a82a11747b3f..709ffe67d1de 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1914,7 +1914,8 @@ local_input:
1914 } 1914 }
1915 } 1915 }
1916 1916
1917 rth = rt_dst_alloc(net->loopback_dev, flags | RTCF_LOCAL, res.type, 1917 rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,
1918 flags | RTCF_LOCAL, res.type,
1918 IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache); 1919 IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache);
1919 if (!rth) 1920 if (!rth)
1920 goto e_nobufs; 1921 goto e_nobufs;
@@ -2471,7 +2472,7 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, u32 table_id,
2471 r->rtm_dst_len = 32; 2472 r->rtm_dst_len = 32;
2472 r->rtm_src_len = 0; 2473 r->rtm_src_len = 0;
2473 r->rtm_tos = fl4->flowi4_tos; 2474 r->rtm_tos = fl4->flowi4_tos;
2474 r->rtm_table = table_id; 2475 r->rtm_table = table_id < 256 ? table_id : RT_TABLE_COMPAT;
2475 if (nla_put_u32(skb, RTA_TABLE, table_id)) 2476 if (nla_put_u32(skb, RTA_TABLE, table_id))
2476 goto nla_put_failure; 2477 goto nla_put_failure;
2477 r->rtm_type = rt->rt_type; 2478 r->rtm_type = rt->rt_type;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 22cbd61079b5..b2fa498b15d1 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -951,7 +951,7 @@ static struct ctl_table ipv4_net_table[] = {
951 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, 951 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
952 .maxlen = sizeof(unsigned int), 952 .maxlen = sizeof(unsigned int),
953 .mode = 0644, 953 .mode = 0644,
954 .proc_handler = proc_dointvec, 954 .proc_handler = proc_douintvec,
955 }, 955 },
956 { 956 {
957 .procname = "tcp_tw_reuse", 957 .procname = "tcp_tw_reuse",
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 4e777a3243f9..f51919535ca7 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -113,7 +113,7 @@ static bool tcp_fastopen_cookie_gen(struct request_sock *req,
113 struct tcp_fastopen_cookie tmp; 113 struct tcp_fastopen_cookie tmp;
114 114
115 if (__tcp_fastopen_cookie_gen(&ip6h->saddr, &tmp)) { 115 if (__tcp_fastopen_cookie_gen(&ip6h->saddr, &tmp)) {
116 struct in6_addr *buf = (struct in6_addr *) tmp.val; 116 struct in6_addr *buf = &tmp.addr;
117 int i; 117 int i;
118 118
119 for (i = 0; i < 4; i++) 119 for (i = 0; i < 4; i++)
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index d46f4d5b1c62..ba8f02d0f283 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -606,7 +606,6 @@ bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst,
606 606
607 return ret; 607 return ret;
608} 608}
609EXPORT_SYMBOL_GPL(tcp_peer_is_proven);
610 609
611void tcp_fetch_timewait_stamp(struct sock *sk, struct dst_entry *dst) 610void tcp_fetch_timewait_stamp(struct sock *sk, struct dst_entry *dst)
612{ 611{
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 89c59e656f44..fc7b4017ba24 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -191,6 +191,7 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
191 ops = rcu_dereference(inet6_offloads[proto]); 191 ops = rcu_dereference(inet6_offloads[proto]);
192 if (!ops || !ops->callbacks.gro_receive) { 192 if (!ops || !ops->callbacks.gro_receive) {
193 __pskb_pull(skb, skb_gro_offset(skb)); 193 __pskb_pull(skb, skb_gro_offset(skb));
194 skb_gro_frag0_invalidate(skb);
194 proto = ipv6_gso_pull_exthdrs(skb, proto); 195 proto = ipv6_gso_pull_exthdrs(skb, proto);
195 skb_gro_pull(skb, -skb_transport_offset(skb)); 196 skb_gro_pull(skb, -skb_transport_offset(skb));
196 skb_reset_transport_header(skb); 197 skb_reset_transport_header(skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 70d0de404197..38122d04fadc 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1373,7 +1373,7 @@ emsgsize:
1373 */ 1373 */
1374 1374
1375 cork->length += length; 1375 cork->length += length;
1376 if (((length > mtu) || 1376 if ((((length + fragheaderlen) > mtu) ||
1377 (skb && skb_is_gso(skb))) && 1377 (skb && skb_is_gso(skb))) &&
1378 (sk->sk_protocol == IPPROTO_UDP) && 1378 (sk->sk_protocol == IPPROTO_UDP) &&
1379 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && 1379 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 36d292180942..753d6d0860fb 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1108,7 +1108,7 @@ route_lookup:
1108 t->parms.name); 1108 t->parms.name);
1109 goto tx_err_dst_release; 1109 goto tx_err_dst_release;
1110 } 1110 }
1111 mtu = dst_mtu(dst) - psh_hlen; 1111 mtu = dst_mtu(dst) - psh_hlen - t->tun_hlen;
1112 if (encap_limit >= 0) { 1112 if (encap_limit >= 0) {
1113 max_headroom += 8; 1113 max_headroom += 8;
1114 mtu -= 8; 1114 mtu -= 8;
@@ -1117,7 +1117,7 @@ route_lookup:
1117 mtu = IPV6_MIN_MTU; 1117 mtu = IPV6_MIN_MTU;
1118 if (skb_dst(skb) && !t->parms.collect_md) 1118 if (skb_dst(skb) && !t->parms.collect_md)
1119 skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu); 1119 skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
1120 if (skb->len > mtu && !skb_is_gso(skb)) { 1120 if (skb->len - t->tun_hlen > mtu && !skb_is_gso(skb)) {
1121 *pmtu = mtu; 1121 *pmtu = mtu;
1122 err = -EMSGSIZE; 1122 err = -EMSGSIZE;
1123 goto tx_err_dst_release; 1123 goto tx_err_dst_release;
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index f4b4a4a5f4ba..d82042c8d8fd 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -189,12 +189,12 @@ static int vti6_tnl_create2(struct net_device *dev)
189 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 189 struct vti6_net *ip6n = net_generic(net, vti6_net_id);
190 int err; 190 int err;
191 191
192 dev->rtnl_link_ops = &vti6_link_ops;
192 err = register_netdevice(dev); 193 err = register_netdevice(dev);
193 if (err < 0) 194 if (err < 0)
194 goto out; 195 goto out;
195 196
196 strcpy(t->parms.name, dev->name); 197 strcpy(t->parms.name, dev->name);
197 dev->rtnl_link_ops = &vti6_link_ops;
198 198
199 dev_hold(dev); 199 dev_hold(dev);
200 vti6_tnl_link(ip6n, t); 200 vti6_tnl_link(ip6n, t);
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 14a3903f1c82..7139fffd61b6 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -81,7 +81,7 @@ static void mld_gq_timer_expire(unsigned long data);
81static void mld_ifc_timer_expire(unsigned long data); 81static void mld_ifc_timer_expire(unsigned long data);
82static void mld_ifc_event(struct inet6_dev *idev); 82static void mld_ifc_event(struct inet6_dev *idev);
83static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc); 83static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
84static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *addr); 84static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
85static void mld_clear_delrec(struct inet6_dev *idev); 85static void mld_clear_delrec(struct inet6_dev *idev);
86static bool mld_in_v1_mode(const struct inet6_dev *idev); 86static bool mld_in_v1_mode(const struct inet6_dev *idev);
87static int sf_setstate(struct ifmcaddr6 *pmc); 87static int sf_setstate(struct ifmcaddr6 *pmc);
@@ -692,9 +692,9 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
692 dev_mc_del(dev, buf); 692 dev_mc_del(dev, buf);
693 } 693 }
694 694
695 if (mc->mca_flags & MAF_NOREPORT)
696 goto done;
697 spin_unlock_bh(&mc->mca_lock); 695 spin_unlock_bh(&mc->mca_lock);
696 if (mc->mca_flags & MAF_NOREPORT)
697 return;
698 698
699 if (!mc->idev->dead) 699 if (!mc->idev->dead)
700 igmp6_leave_group(mc); 700 igmp6_leave_group(mc);
@@ -702,8 +702,6 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
702 spin_lock_bh(&mc->mca_lock); 702 spin_lock_bh(&mc->mca_lock);
703 if (del_timer(&mc->mca_timer)) 703 if (del_timer(&mc->mca_timer))
704 atomic_dec(&mc->mca_refcnt); 704 atomic_dec(&mc->mca_refcnt);
705done:
706 ip6_mc_clear_src(mc);
707 spin_unlock_bh(&mc->mca_lock); 705 spin_unlock_bh(&mc->mca_lock);
708} 706}
709 707
@@ -748,10 +746,11 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
748 spin_unlock_bh(&idev->mc_lock); 746 spin_unlock_bh(&idev->mc_lock);
749} 747}
750 748
751static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *pmca) 749static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
752{ 750{
753 struct ifmcaddr6 *pmc, *pmc_prev; 751 struct ifmcaddr6 *pmc, *pmc_prev;
754 struct ip6_sf_list *psf, *psf_next; 752 struct ip6_sf_list *psf;
753 struct in6_addr *pmca = &im->mca_addr;
755 754
756 spin_lock_bh(&idev->mc_lock); 755 spin_lock_bh(&idev->mc_lock);
757 pmc_prev = NULL; 756 pmc_prev = NULL;
@@ -768,14 +767,20 @@ static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *pmca)
768 } 767 }
769 spin_unlock_bh(&idev->mc_lock); 768 spin_unlock_bh(&idev->mc_lock);
770 769
770 spin_lock_bh(&im->mca_lock);
771 if (pmc) { 771 if (pmc) {
772 for (psf = pmc->mca_tomb; psf; psf = psf_next) { 772 im->idev = pmc->idev;
773 psf_next = psf->sf_next; 773 im->mca_crcount = idev->mc_qrv;
774 kfree(psf); 774 im->mca_sfmode = pmc->mca_sfmode;
775 if (pmc->mca_sfmode == MCAST_INCLUDE) {
776 im->mca_tomb = pmc->mca_tomb;
777 im->mca_sources = pmc->mca_sources;
778 for (psf = im->mca_sources; psf; psf = psf->sf_next)
779 psf->sf_crcount = im->mca_crcount;
775 } 780 }
776 in6_dev_put(pmc->idev); 781 in6_dev_put(pmc->idev);
777 kfree(pmc);
778 } 782 }
783 spin_unlock_bh(&im->mca_lock);
779} 784}
780 785
781static void mld_clear_delrec(struct inet6_dev *idev) 786static void mld_clear_delrec(struct inet6_dev *idev)
@@ -904,7 +909,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
904 mca_get(mc); 909 mca_get(mc);
905 write_unlock_bh(&idev->lock); 910 write_unlock_bh(&idev->lock);
906 911
907 mld_del_delrec(idev, &mc->mca_addr); 912 mld_del_delrec(idev, mc);
908 igmp6_group_added(mc); 913 igmp6_group_added(mc);
909 ma_put(mc); 914 ma_put(mc);
910 return 0; 915 return 0;
@@ -927,6 +932,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
927 write_unlock_bh(&idev->lock); 932 write_unlock_bh(&idev->lock);
928 933
929 igmp6_group_dropped(ma); 934 igmp6_group_dropped(ma);
935 ip6_mc_clear_src(ma);
930 936
931 ma_put(ma); 937 ma_put(ma);
932 return 0; 938 return 0;
@@ -2501,15 +2507,17 @@ void ipv6_mc_down(struct inet6_dev *idev)
2501 /* Withdraw multicast list */ 2507 /* Withdraw multicast list */
2502 2508
2503 read_lock_bh(&idev->lock); 2509 read_lock_bh(&idev->lock);
2504 mld_ifc_stop_timer(idev);
2505 mld_gq_stop_timer(idev);
2506 mld_dad_stop_timer(idev);
2507 2510
2508 for (i = idev->mc_list; i; i = i->next) 2511 for (i = idev->mc_list; i; i = i->next)
2509 igmp6_group_dropped(i); 2512 igmp6_group_dropped(i);
2510 read_unlock_bh(&idev->lock);
2511 2513
2512 mld_clear_delrec(idev); 2514 /* Should stop timer after group drop. or we will
2515 * start timer again in mld_ifc_event()
2516 */
2517 mld_ifc_stop_timer(idev);
2518 mld_gq_stop_timer(idev);
2519 mld_dad_stop_timer(idev);
2520 read_unlock_bh(&idev->lock);
2513} 2521}
2514 2522
2515static void ipv6_mc_reset(struct inet6_dev *idev) 2523static void ipv6_mc_reset(struct inet6_dev *idev)
@@ -2531,8 +2539,10 @@ void ipv6_mc_up(struct inet6_dev *idev)
2531 2539
2532 read_lock_bh(&idev->lock); 2540 read_lock_bh(&idev->lock);
2533 ipv6_mc_reset(idev); 2541 ipv6_mc_reset(idev);
2534 for (i = idev->mc_list; i; i = i->next) 2542 for (i = idev->mc_list; i; i = i->next) {
2543 mld_del_delrec(idev, i);
2535 igmp6_group_added(i); 2544 igmp6_group_added(i);
2545 }
2536 read_unlock_bh(&idev->lock); 2546 read_unlock_bh(&idev->lock);
2537} 2547}
2538 2548
@@ -2565,6 +2575,7 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
2565 2575
2566 /* Deactivate timers */ 2576 /* Deactivate timers */
2567 ipv6_mc_down(idev); 2577 ipv6_mc_down(idev);
2578 mld_clear_delrec(idev);
2568 2579
2569 /* Delete all-nodes address. */ 2580 /* Delete all-nodes address. */
2570 /* We cannot call ipv6_dev_mc_dec() directly, our caller in 2581 /* We cannot call ipv6_dev_mc_dec() directly, our caller in
@@ -2579,11 +2590,9 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
2579 write_lock_bh(&idev->lock); 2590 write_lock_bh(&idev->lock);
2580 while ((i = idev->mc_list) != NULL) { 2591 while ((i = idev->mc_list) != NULL) {
2581 idev->mc_list = i->next; 2592 idev->mc_list = i->next;
2582 write_unlock_bh(&idev->lock);
2583 2593
2584 igmp6_group_dropped(i); 2594 write_unlock_bh(&idev->lock);
2585 ma_put(i); 2595 ma_put(i);
2586
2587 write_lock_bh(&idev->lock); 2596 write_lock_bh(&idev->lock);
2588 } 2597 }
2589 write_unlock_bh(&idev->lock); 2598 write_unlock_bh(&idev->lock);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8417c41d8ec8..4f6b067c8753 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1464,7 +1464,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
1464 struct fib6_node *fn; 1464 struct fib6_node *fn;
1465 1465
1466 /* Get the "current" route for this destination and 1466 /* Get the "current" route for this destination and
1467 * check if the redirect has come from approriate router. 1467 * check if the redirect has come from appropriate router.
1468 * 1468 *
1469 * RFC 4861 specifies that redirects should only be 1469 * RFC 4861 specifies that redirects should only be
1470 * accepted if they come from the nexthop to the target. 1470 * accepted if they come from the nexthop to the target.
@@ -2768,7 +2768,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
2768 old MTU is the lowest MTU in the path, update the route PMTU 2768 old MTU is the lowest MTU in the path, update the route PMTU
2769 to reflect the increase. In this case if the other nodes' MTU 2769 to reflect the increase. In this case if the other nodes' MTU
2770 also have the lowest MTU, TOO BIG MESSAGE will be lead to 2770 also have the lowest MTU, TOO BIG MESSAGE will be lead to
2771 PMTU discouvery. 2771 PMTU discovery.
2772 */ 2772 */
2773 if (rt->dst.dev == arg->dev && 2773 if (rt->dst.dev == arg->dev &&
2774 dst_metric_raw(&rt->dst, RTAX_MTU) && 2774 dst_metric_raw(&rt->dst, RTAX_MTU) &&
@@ -3317,7 +3317,8 @@ static int rt6_fill_node(struct net *net,
3317 if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags))) 3317 if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags)))
3318 goto nla_put_failure; 3318 goto nla_put_failure;
3319 3319
3320 lwtunnel_fill_encap(skb, rt->dst.lwtstate); 3320 if (lwtunnel_fill_encap(skb, rt->dst.lwtstate) < 0)
3321 goto nla_put_failure;
3321 3322
3322 nlmsg_end(skb, nlh); 3323 nlmsg_end(skb, nlh);
3323 return 0; 3324 return 0;
diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index ef1c8a46e7ac..03a064803626 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -400,7 +400,7 @@ static int seg6_hmac_init_algo(void)
400 *p_tfm = tfm; 400 *p_tfm = tfm;
401 } 401 }
402 402
403 p_tfm = this_cpu_ptr(algo->tfms); 403 p_tfm = raw_cpu_ptr(algo->tfms);
404 tfm = *p_tfm; 404 tfm = *p_tfm;
405 405
406 shsize = sizeof(*shash) + crypto_shash_descsize(tfm); 406 shsize = sizeof(*shash) + crypto_shash_descsize(tfm);
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index bbfca22c34ae..1d60cb132835 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -265,7 +265,9 @@ int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
265 slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate); 265 slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate);
266 266
267#ifdef CONFIG_DST_CACHE 267#ifdef CONFIG_DST_CACHE
268 preempt_disable();
268 dst = dst_cache_get(&slwt->cache); 269 dst = dst_cache_get(&slwt->cache);
270 preempt_enable();
269#endif 271#endif
270 272
271 if (unlikely(!dst)) { 273 if (unlikely(!dst)) {
@@ -286,7 +288,9 @@ int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
286 } 288 }
287 289
288#ifdef CONFIG_DST_CACHE 290#ifdef CONFIG_DST_CACHE
291 preempt_disable();
289 dst_cache_set_ip6(&slwt->cache, dst, &fl6.saddr); 292 dst_cache_set_ip6(&slwt->cache, dst, &fl6.saddr);
293 preempt_enable();
290#endif 294#endif
291 } 295 }
292 296
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index cfb9e5f4e28f..13190b38f22e 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1044,7 +1044,8 @@ static int iucv_sock_sendmsg(struct socket *sock, struct msghdr *msg,
1044{ 1044{
1045 struct sock *sk = sock->sk; 1045 struct sock *sk = sock->sk;
1046 struct iucv_sock *iucv = iucv_sk(sk); 1046 struct iucv_sock *iucv = iucv_sk(sk);
1047 size_t headroom, linear; 1047 size_t headroom = 0;
1048 size_t linear;
1048 struct sk_buff *skb; 1049 struct sk_buff *skb;
1049 struct iucv_message txmsg = {0}; 1050 struct iucv_message txmsg = {0};
1050 struct cmsghdr *cmsg; 1051 struct cmsghdr *cmsg;
@@ -1122,18 +1123,20 @@ static int iucv_sock_sendmsg(struct socket *sock, struct msghdr *msg,
1122 * this is fine for SOCK_SEQPACKET (unless we want to support 1123 * this is fine for SOCK_SEQPACKET (unless we want to support
1123 * segmented records using the MSG_EOR flag), but 1124 * segmented records using the MSG_EOR flag), but
1124 * for SOCK_STREAM we might want to improve it in future */ 1125 * for SOCK_STREAM we might want to improve it in future */
1125 headroom = (iucv->transport == AF_IUCV_TRANS_HIPER) 1126 if (iucv->transport == AF_IUCV_TRANS_HIPER) {
1126 ? sizeof(struct af_iucv_trans_hdr) + ETH_HLEN : 0; 1127 headroom = sizeof(struct af_iucv_trans_hdr) + ETH_HLEN;
1127 if (headroom + len < PAGE_SIZE) {
1128 linear = len; 1128 linear = len;
1129 } else { 1129 } else {
1130 /* In nonlinear "classic" iucv skb, 1130 if (len < PAGE_SIZE) {
1131 * reserve space for iucv_array 1131 linear = len;
1132 */ 1132 } else {
1133 if (iucv->transport != AF_IUCV_TRANS_HIPER) 1133 /* In nonlinear "classic" iucv skb,
1134 headroom += sizeof(struct iucv_array) * 1134 * reserve space for iucv_array
1135 (MAX_SKB_FRAGS + 1); 1135 */
1136 linear = PAGE_SIZE - headroom; 1136 headroom = sizeof(struct iucv_array) *
1137 (MAX_SKB_FRAGS + 1);
1138 linear = PAGE_SIZE - headroom;
1139 }
1137 } 1140 }
1138 skb = sock_alloc_send_pskb(sk, headroom + linear, len - linear, 1141 skb = sock_alloc_send_pskb(sk, headroom + linear, len - linear,
1139 noblock, &err, 0); 1142 noblock, &err, 0);
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 8938b6ba57a0..3d73278b86ca 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -47,7 +47,8 @@ static inline struct l2tp_ip_sock *l2tp_ip_sk(const struct sock *sk)
47 return (struct l2tp_ip_sock *)sk; 47 return (struct l2tp_ip_sock *)sk;
48} 48}
49 49
50static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id) 50static struct sock *__l2tp_ip_bind_lookup(const struct net *net, __be32 laddr,
51 __be32 raddr, int dif, u32 tunnel_id)
51{ 52{
52 struct sock *sk; 53 struct sock *sk;
53 54
@@ -61,6 +62,7 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif
61 if ((l2tp->conn_id == tunnel_id) && 62 if ((l2tp->conn_id == tunnel_id) &&
62 net_eq(sock_net(sk), net) && 63 net_eq(sock_net(sk), net) &&
63 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && 64 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
65 (!inet->inet_daddr || !raddr || inet->inet_daddr == raddr) &&
64 (!sk->sk_bound_dev_if || !dif || 66 (!sk->sk_bound_dev_if || !dif ||
65 sk->sk_bound_dev_if == dif)) 67 sk->sk_bound_dev_if == dif))
66 goto found; 68 goto found;
@@ -71,15 +73,6 @@ found:
71 return sk; 73 return sk;
72} 74}
73 75
74static inline struct sock *l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id)
75{
76 struct sock *sk = __l2tp_ip_bind_lookup(net, laddr, dif, tunnel_id);
77 if (sk)
78 sock_hold(sk);
79
80 return sk;
81}
82
83/* When processing receive frames, there are two cases to 76/* When processing receive frames, there are two cases to
84 * consider. Data frames consist of a non-zero session-id and an 77 * consider. Data frames consist of a non-zero session-id and an
85 * optional cookie. Control frames consist of a regular L2TP header 78 * optional cookie. Control frames consist of a regular L2TP header
@@ -183,8 +176,8 @@ pass_up:
183 struct iphdr *iph = (struct iphdr *) skb_network_header(skb); 176 struct iphdr *iph = (struct iphdr *) skb_network_header(skb);
184 177
185 read_lock_bh(&l2tp_ip_lock); 178 read_lock_bh(&l2tp_ip_lock);
186 sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb), 179 sk = __l2tp_ip_bind_lookup(net, iph->daddr, iph->saddr,
187 tunnel_id); 180 inet_iif(skb), tunnel_id);
188 if (!sk) { 181 if (!sk) {
189 read_unlock_bh(&l2tp_ip_lock); 182 read_unlock_bh(&l2tp_ip_lock);
190 goto discard; 183 goto discard;
@@ -280,7 +273,7 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
280 inet->inet_saddr = 0; /* Use device */ 273 inet->inet_saddr = 0; /* Use device */
281 274
282 write_lock_bh(&l2tp_ip_lock); 275 write_lock_bh(&l2tp_ip_lock);
283 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, 276 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, 0,
284 sk->sk_bound_dev_if, addr->l2tp_conn_id)) { 277 sk->sk_bound_dev_if, addr->l2tp_conn_id)) {
285 write_unlock_bh(&l2tp_ip_lock); 278 write_unlock_bh(&l2tp_ip_lock);
286 ret = -EADDRINUSE; 279 ret = -EADDRINUSE;
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index f092ac441fdd..331ccf5a7bad 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -59,12 +59,14 @@ static inline struct l2tp_ip6_sock *l2tp_ip6_sk(const struct sock *sk)
59 59
60static struct sock *__l2tp_ip6_bind_lookup(struct net *net, 60static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
61 struct in6_addr *laddr, 61 struct in6_addr *laddr,
62 const struct in6_addr *raddr,
62 int dif, u32 tunnel_id) 63 int dif, u32 tunnel_id)
63{ 64{
64 struct sock *sk; 65 struct sock *sk;
65 66
66 sk_for_each_bound(sk, &l2tp_ip6_bind_table) { 67 sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
67 const struct in6_addr *addr = inet6_rcv_saddr(sk); 68 const struct in6_addr *sk_laddr = inet6_rcv_saddr(sk);
69 const struct in6_addr *sk_raddr = &sk->sk_v6_daddr;
68 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk); 70 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);
69 71
70 if (l2tp == NULL) 72 if (l2tp == NULL)
@@ -72,7 +74,8 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
72 74
73 if ((l2tp->conn_id == tunnel_id) && 75 if ((l2tp->conn_id == tunnel_id) &&
74 net_eq(sock_net(sk), net) && 76 net_eq(sock_net(sk), net) &&
75 (!addr || ipv6_addr_equal(addr, laddr)) && 77 (!sk_laddr || ipv6_addr_any(sk_laddr) || ipv6_addr_equal(sk_laddr, laddr)) &&
78 (!raddr || ipv6_addr_any(sk_raddr) || ipv6_addr_equal(sk_raddr, raddr)) &&
76 (!sk->sk_bound_dev_if || !dif || 79 (!sk->sk_bound_dev_if || !dif ||
77 sk->sk_bound_dev_if == dif)) 80 sk->sk_bound_dev_if == dif))
78 goto found; 81 goto found;
@@ -83,17 +86,6 @@ found:
83 return sk; 86 return sk;
84} 87}
85 88
86static inline struct sock *l2tp_ip6_bind_lookup(struct net *net,
87 struct in6_addr *laddr,
88 int dif, u32 tunnel_id)
89{
90 struct sock *sk = __l2tp_ip6_bind_lookup(net, laddr, dif, tunnel_id);
91 if (sk)
92 sock_hold(sk);
93
94 return sk;
95}
96
97/* When processing receive frames, there are two cases to 89/* When processing receive frames, there are two cases to
98 * consider. Data frames consist of a non-zero session-id and an 90 * consider. Data frames consist of a non-zero session-id and an
99 * optional cookie. Control frames consist of a regular L2TP header 91 * optional cookie. Control frames consist of a regular L2TP header
@@ -197,8 +189,8 @@ pass_up:
197 struct ipv6hdr *iph = ipv6_hdr(skb); 189 struct ipv6hdr *iph = ipv6_hdr(skb);
198 190
199 read_lock_bh(&l2tp_ip6_lock); 191 read_lock_bh(&l2tp_ip6_lock);
200 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb), 192 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
201 tunnel_id); 193 inet6_iif(skb), tunnel_id);
202 if (!sk) { 194 if (!sk) {
203 read_unlock_bh(&l2tp_ip6_lock); 195 read_unlock_bh(&l2tp_ip6_lock);
204 goto discard; 196 goto discard;
@@ -330,7 +322,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
330 rcu_read_unlock(); 322 rcu_read_unlock();
331 323
332 write_lock_bh(&l2tp_ip6_lock); 324 write_lock_bh(&l2tp_ip6_lock);
333 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if, 325 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, NULL, bound_dev_if,
334 addr->l2tp_conn_id)) { 326 addr->l2tp_conn_id)) {
335 write_unlock_bh(&l2tp_ip6_lock); 327 write_unlock_bh(&l2tp_ip6_lock);
336 err = -EADDRINUSE; 328 err = -EADDRINUSE;
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index e75cbf6ecc26..a0d901d8992e 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -231,9 +231,6 @@ ieee80211_get_max_required_bw(struct ieee80211_sub_if_data *sdata)
231 !(sta->sdata->bss && sta->sdata->bss == sdata->bss)) 231 !(sta->sdata->bss && sta->sdata->bss == sdata->bss))
232 continue; 232 continue;
233 233
234 if (!sta->uploaded || !test_sta_flag(sta, WLAN_STA_ASSOC))
235 continue;
236
237 max_bw = max(max_bw, ieee80211_get_sta_bw(&sta->sta)); 234 max_bw = max(max_bw, ieee80211_get_sta_bw(&sta->sta));
238 } 235 }
239 rcu_read_unlock(); 236 rcu_read_unlock();
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 41497b670e2b..d37ae7dc114b 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -6,6 +6,7 @@
6 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> 6 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> 7 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
8 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 * Copyright 2013-2014 Intel Mobile Communications GmbH
9 * Copyright (c) 2016 Intel Deutschland GmbH
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -1295,6 +1296,26 @@ static void ieee80211_iface_work(struct work_struct *work)
1295 } else if (ieee80211_is_action(mgmt->frame_control) && 1296 } else if (ieee80211_is_action(mgmt->frame_control) &&
1296 mgmt->u.action.category == WLAN_CATEGORY_VHT) { 1297 mgmt->u.action.category == WLAN_CATEGORY_VHT) {
1297 switch (mgmt->u.action.u.vht_group_notif.action_code) { 1298 switch (mgmt->u.action.u.vht_group_notif.action_code) {
1299 case WLAN_VHT_ACTION_OPMODE_NOTIF: {
1300 struct ieee80211_rx_status *status;
1301 enum nl80211_band band;
1302 u8 opmode;
1303
1304 status = IEEE80211_SKB_RXCB(skb);
1305 band = status->band;
1306 opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode;
1307
1308 mutex_lock(&local->sta_mtx);
1309 sta = sta_info_get_bss(sdata, mgmt->sa);
1310
1311 if (sta)
1312 ieee80211_vht_handle_opmode(sdata, sta,
1313 opmode,
1314 band);
1315
1316 mutex_unlock(&local->sta_mtx);
1317 break;
1318 }
1298 case WLAN_VHT_ACTION_GROUPID_MGMT: 1319 case WLAN_VHT_ACTION_GROUPID_MGMT:
1299 ieee80211_process_mu_groups(sdata, mgmt); 1320 ieee80211_process_mu_groups(sdata, mgmt);
1300 break; 1321 break;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 1822c77f2b1c..56fb47953b72 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -913,12 +913,17 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
913 supp_ht = supp_ht || sband->ht_cap.ht_supported; 913 supp_ht = supp_ht || sband->ht_cap.ht_supported;
914 supp_vht = supp_vht || sband->vht_cap.vht_supported; 914 supp_vht = supp_vht || sband->vht_cap.vht_supported;
915 915
916 if (sband->ht_cap.ht_supported) 916 if (!sband->ht_cap.ht_supported)
917 local->rx_chains = 917 continue;
918 max(ieee80211_mcs_to_chains(&sband->ht_cap.mcs),
919 local->rx_chains);
920 918
921 /* TODO: consider VHT for RX chains, hopefully it's the same */ 919 /* TODO: consider VHT for RX chains, hopefully it's the same */
920 local->rx_chains =
921 max(ieee80211_mcs_to_chains(&sband->ht_cap.mcs),
922 local->rx_chains);
923
924 /* no need to mask, SM_PS_DISABLED has all bits set */
925 sband->ht_cap.cap |= WLAN_HT_CAP_SM_PS_DISABLED <<
926 IEEE80211_HT_CAP_SM_PS_SHIFT;
922 } 927 }
923 928
924 /* if low-level driver supports AP, we also support VLAN */ 929 /* if low-level driver supports AP, we also support VLAN */
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 206698bc93f4..9e2641d45587 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -40,6 +40,8 @@ void rate_control_rate_init(struct sta_info *sta)
40 40
41 ieee80211_sta_set_rx_nss(sta); 41 ieee80211_sta_set_rx_nss(sta);
42 42
43 ieee80211_recalc_min_chandef(sta->sdata);
44
43 if (!ref) 45 if (!ref)
44 return; 46 return;
45 47
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 3e289a64ed43..3090dd4342f6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2472,7 +2472,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
2472 if (!ifmsh->mshcfg.dot11MeshForwarding) 2472 if (!ifmsh->mshcfg.dot11MeshForwarding)
2473 goto out; 2473 goto out;
2474 2474
2475 fwd_skb = skb_copy_expand(skb, local->tx_headroom, 0, GFP_ATOMIC); 2475 fwd_skb = skb_copy_expand(skb, local->tx_headroom +
2476 sdata->encrypt_headroom, 0, GFP_ATOMIC);
2476 if (!fwd_skb) { 2477 if (!fwd_skb) {
2477 net_info_ratelimited("%s: failed to clone mesh frame\n", 2478 net_info_ratelimited("%s: failed to clone mesh frame\n",
2478 sdata->name); 2479 sdata->name);
@@ -2880,17 +2881,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2880 2881
2881 switch (mgmt->u.action.u.vht_opmode_notif.action_code) { 2882 switch (mgmt->u.action.u.vht_opmode_notif.action_code) {
2882 case WLAN_VHT_ACTION_OPMODE_NOTIF: { 2883 case WLAN_VHT_ACTION_OPMODE_NOTIF: {
2883 u8 opmode;
2884
2885 /* verify opmode is present */ 2884 /* verify opmode is present */
2886 if (len < IEEE80211_MIN_ACTION_SIZE + 2) 2885 if (len < IEEE80211_MIN_ACTION_SIZE + 2)
2887 goto invalid; 2886 goto invalid;
2888 2887 goto queue;
2889 opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode;
2890
2891 ieee80211_vht_handle_opmode(rx->sdata, rx->sta,
2892 opmode, status->band);
2893 goto handled;
2894 } 2888 }
2895 case WLAN_VHT_ACTION_GROUPID_MGMT: { 2889 case WLAN_VHT_ACTION_GROUPID_MGMT: {
2896 if (len < IEEE80211_MIN_ACTION_SIZE + 25) 2890 if (len < IEEE80211_MIN_ACTION_SIZE + 25)
@@ -3942,21 +3936,31 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
3942 u64_stats_update_end(&stats->syncp); 3936 u64_stats_update_end(&stats->syncp);
3943 3937
3944 if (fast_rx->internal_forward) { 3938 if (fast_rx->internal_forward) {
3945 struct sta_info *dsta = sta_info_get(rx->sdata, skb->data); 3939 struct sk_buff *xmit_skb = NULL;
3940 bool multicast = is_multicast_ether_addr(skb->data);
3941
3942 if (multicast) {
3943 xmit_skb = skb_copy(skb, GFP_ATOMIC);
3944 } else if (sta_info_get(rx->sdata, skb->data)) {
3945 xmit_skb = skb;
3946 skb = NULL;
3947 }
3946 3948
3947 if (dsta) { 3949 if (xmit_skb) {
3948 /* 3950 /*
3949 * Send to wireless media and increase priority by 256 3951 * Send to wireless media and increase priority by 256
3950 * to keep the received priority instead of 3952 * to keep the received priority instead of
3951 * reclassifying the frame (see cfg80211_classify8021d). 3953 * reclassifying the frame (see cfg80211_classify8021d).
3952 */ 3954 */
3953 skb->priority += 256; 3955 xmit_skb->priority += 256;
3954 skb->protocol = htons(ETH_P_802_3); 3956 xmit_skb->protocol = htons(ETH_P_802_3);
3955 skb_reset_network_header(skb); 3957 skb_reset_network_header(xmit_skb);
3956 skb_reset_mac_header(skb); 3958 skb_reset_mac_header(xmit_skb);
3957 dev_queue_xmit(skb); 3959 dev_queue_xmit(xmit_skb);
3958 return true;
3959 } 3960 }
3961
3962 if (!skb)
3963 return true;
3960 } 3964 }
3961 3965
3962 /* deliver to local stack */ 3966 /* deliver to local stack */
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index b6cfcf038c11..50c309094c37 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1501,8 +1501,8 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1501 1501
1502 /* This will evaluate to 1, 3, 5 or 7. */ 1502 /* This will evaluate to 1, 3, 5 or 7. */
1503 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) 1503 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++)
1504 if (ignored_acs & BIT(ac)) 1504 if (!(ignored_acs & ieee80211_ac_to_qos_mask[ac]))
1505 continue; 1505 break;
1506 tid = 7 - 2 * ac; 1506 tid = 7 - 2 * ac;
1507 1507
1508 ieee80211_send_null_response(sta, tid, reason, true, false); 1508 ieee80211_send_null_response(sta, tid, reason, true, false);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2c21b7039136..797e847cbc49 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1243,7 +1243,7 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
1243 1243
1244static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local, 1244static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
1245 struct ieee80211_vif *vif, 1245 struct ieee80211_vif *vif,
1246 struct ieee80211_sta *pubsta, 1246 struct sta_info *sta,
1247 struct sk_buff *skb) 1247 struct sk_buff *skb)
1248{ 1248{
1249 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1249 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -1257,10 +1257,13 @@ static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
1257 if (!ieee80211_is_data(hdr->frame_control)) 1257 if (!ieee80211_is_data(hdr->frame_control))
1258 return NULL; 1258 return NULL;
1259 1259
1260 if (pubsta) { 1260 if (sta) {
1261 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; 1261 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
1262 1262
1263 txq = pubsta->txq[tid]; 1263 if (!sta->uploaded)
1264 return NULL;
1265
1266 txq = sta->sta.txq[tid];
1264 } else if (vif) { 1267 } else if (vif) {
1265 txq = vif->txq; 1268 txq = vif->txq;
1266 } 1269 }
@@ -1503,23 +1506,17 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local,
1503 struct fq *fq = &local->fq; 1506 struct fq *fq = &local->fq;
1504 struct ieee80211_vif *vif; 1507 struct ieee80211_vif *vif;
1505 struct txq_info *txqi; 1508 struct txq_info *txqi;
1506 struct ieee80211_sta *pubsta;
1507 1509
1508 if (!local->ops->wake_tx_queue || 1510 if (!local->ops->wake_tx_queue ||
1509 sdata->vif.type == NL80211_IFTYPE_MONITOR) 1511 sdata->vif.type == NL80211_IFTYPE_MONITOR)
1510 return false; 1512 return false;
1511 1513
1512 if (sta && sta->uploaded)
1513 pubsta = &sta->sta;
1514 else
1515 pubsta = NULL;
1516
1517 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 1514 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1518 sdata = container_of(sdata->bss, 1515 sdata = container_of(sdata->bss,
1519 struct ieee80211_sub_if_data, u.ap); 1516 struct ieee80211_sub_if_data, u.ap);
1520 1517
1521 vif = &sdata->vif; 1518 vif = &sdata->vif;
1522 txqi = ieee80211_get_txq(local, vif, pubsta, skb); 1519 txqi = ieee80211_get_txq(local, vif, sta, skb);
1523 1520
1524 if (!txqi) 1521 if (!txqi)
1525 return false; 1522 return false;
@@ -3287,7 +3284,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
3287 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); 3284 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
3288 int hw_headroom = sdata->local->hw.extra_tx_headroom; 3285 int hw_headroom = sdata->local->hw.extra_tx_headroom;
3289 struct ethhdr eth; 3286 struct ethhdr eth;
3290 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 3287 struct ieee80211_tx_info *info;
3291 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; 3288 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
3292 struct ieee80211_tx_data tx; 3289 struct ieee80211_tx_data tx;
3293 ieee80211_tx_result r; 3290 ieee80211_tx_result r;
@@ -3351,6 +3348,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
3351 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); 3348 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN);
3352 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); 3349 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN);
3353 3350
3351 info = IEEE80211_SKB_CB(skb);
3354 memset(info, 0, sizeof(*info)); 3352 memset(info, 0, sizeof(*info));
3355 info->band = fast_tx->band; 3353 info->band = fast_tx->band;
3356 info->control.vif = &sdata->vif; 3354 info->control.vif = &sdata->vif;
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c
index 6832bf6ab69f..43e45bb660bc 100644
--- a/net/mac80211/vht.c
+++ b/net/mac80211/vht.c
@@ -527,8 +527,10 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
527 527
528 u32 changed = __ieee80211_vht_handle_opmode(sdata, sta, opmode, band); 528 u32 changed = __ieee80211_vht_handle_opmode(sdata, sta, opmode, band);
529 529
530 if (changed > 0) 530 if (changed > 0) {
531 ieee80211_recalc_min_chandef(sdata);
531 rate_control_rate_update(local, sband, sta, changed); 532 rate_control_rate_update(local, sband, sta, changed);
533 }
532} 534}
533 535
534void ieee80211_get_vht_mask_from_cap(__le16 vht_cap, 536void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a019a87e58ee..0db5f9782265 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2115,7 +2115,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
2115 * is called on error from nf_tables_newrule(). 2115 * is called on error from nf_tables_newrule().
2116 */ 2116 */
2117 expr = nft_expr_first(rule); 2117 expr = nft_expr_first(rule);
2118 while (expr->ops && expr != nft_expr_last(rule)) { 2118 while (expr != nft_expr_last(rule) && expr->ops) {
2119 nf_tables_expr_destroy(ctx, expr); 2119 nf_tables_expr_destroy(ctx, expr);
2120 expr = nft_expr_next(expr); 2120 expr = nft_expr_next(expr);
2121 } 2121 }
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 36d2b1096546..7d699bbd45b0 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -250,6 +250,22 @@ static int nft_payload_l4csum_update(const struct nft_pktinfo *pkt,
250 return 0; 250 return 0;
251} 251}
252 252
253static int nft_payload_csum_inet(struct sk_buff *skb, const u32 *src,
254 __wsum fsum, __wsum tsum, int csum_offset)
255{
256 __sum16 sum;
257
258 if (skb_copy_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
259 return -1;
260
261 nft_csum_replace(&sum, fsum, tsum);
262 if (!skb_make_writable(skb, csum_offset + sizeof(sum)) ||
263 skb_store_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
264 return -1;
265
266 return 0;
267}
268
253static void nft_payload_set_eval(const struct nft_expr *expr, 269static void nft_payload_set_eval(const struct nft_expr *expr,
254 struct nft_regs *regs, 270 struct nft_regs *regs,
255 const struct nft_pktinfo *pkt) 271 const struct nft_pktinfo *pkt)
@@ -259,7 +275,6 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
259 const u32 *src = &regs->data[priv->sreg]; 275 const u32 *src = &regs->data[priv->sreg];
260 int offset, csum_offset; 276 int offset, csum_offset;
261 __wsum fsum, tsum; 277 __wsum fsum, tsum;
262 __sum16 sum;
263 278
264 switch (priv->base) { 279 switch (priv->base) {
265 case NFT_PAYLOAD_LL_HEADER: 280 case NFT_PAYLOAD_LL_HEADER:
@@ -282,18 +297,14 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
282 csum_offset = offset + priv->csum_offset; 297 csum_offset = offset + priv->csum_offset;
283 offset += priv->offset; 298 offset += priv->offset;
284 299
285 if (priv->csum_type == NFT_PAYLOAD_CSUM_INET && 300 if ((priv->csum_type == NFT_PAYLOAD_CSUM_INET || priv->csum_flags) &&
286 (priv->base != NFT_PAYLOAD_TRANSPORT_HEADER || 301 (priv->base != NFT_PAYLOAD_TRANSPORT_HEADER ||
287 skb->ip_summed != CHECKSUM_PARTIAL)) { 302 skb->ip_summed != CHECKSUM_PARTIAL)) {
288 if (skb_copy_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
289 goto err;
290
291 fsum = skb_checksum(skb, offset, priv->len, 0); 303 fsum = skb_checksum(skb, offset, priv->len, 0);
292 tsum = csum_partial(src, priv->len, 0); 304 tsum = csum_partial(src, priv->len, 0);
293 nft_csum_replace(&sum, fsum, tsum);
294 305
295 if (!skb_make_writable(skb, csum_offset + sizeof(sum)) || 306 if (priv->csum_type == NFT_PAYLOAD_CSUM_INET &&
296 skb_store_bits(skb, csum_offset, &sum, sizeof(sum)) < 0) 307 nft_payload_csum_inet(skb, src, fsum, tsum, csum_offset))
297 goto err; 308 goto err;
298 309
299 if (priv->csum_flags && 310 if (priv->csum_flags &&
diff --git a/net/netfilter/nft_queue.c b/net/netfilter/nft_queue.c
index 3e19fa1230dc..dbb6aaff67ec 100644
--- a/net/netfilter/nft_queue.c
+++ b/net/netfilter/nft_queue.c
@@ -38,7 +38,7 @@ static void nft_queue_eval(const struct nft_expr *expr,
38 38
39 if (priv->queues_total > 1) { 39 if (priv->queues_total > 1) {
40 if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) { 40 if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) {
41 int cpu = smp_processor_id(); 41 int cpu = raw_smp_processor_id();
42 42
43 queue = priv->queuenum + cpu % priv->queues_total; 43 queue = priv->queuenum + cpu % priv->queues_total;
44 } else { 44 } else {
diff --git a/net/netfilter/nft_quota.c b/net/netfilter/nft_quota.c
index bd6efc53f26d..2d6fe3559912 100644
--- a/net/netfilter/nft_quota.c
+++ b/net/netfilter/nft_quota.c
@@ -110,30 +110,32 @@ static int nft_quota_obj_init(const struct nlattr * const tb[],
110static int nft_quota_do_dump(struct sk_buff *skb, struct nft_quota *priv, 110static int nft_quota_do_dump(struct sk_buff *skb, struct nft_quota *priv,
111 bool reset) 111 bool reset)
112{ 112{
113 u64 consumed, consumed_cap;
113 u32 flags = priv->flags; 114 u32 flags = priv->flags;
114 u64 consumed;
115
116 if (reset) {
117 consumed = atomic64_xchg(&priv->consumed, 0);
118 if (test_and_clear_bit(NFT_QUOTA_DEPLETED_BIT, &priv->flags))
119 flags |= NFT_QUOTA_F_DEPLETED;
120 } else {
121 consumed = atomic64_read(&priv->consumed);
122 }
123 115
124 /* Since we inconditionally increment consumed quota for each packet 116 /* Since we inconditionally increment consumed quota for each packet
125 * that we see, don't go over the quota boundary in what we send to 117 * that we see, don't go over the quota boundary in what we send to
126 * userspace. 118 * userspace.
127 */ 119 */
128 if (consumed > priv->quota) 120 consumed = atomic64_read(&priv->consumed);
129 consumed = priv->quota; 121 if (consumed >= priv->quota) {
122 consumed_cap = priv->quota;
123 flags |= NFT_QUOTA_F_DEPLETED;
124 } else {
125 consumed_cap = consumed;
126 }
130 127
131 if (nla_put_be64(skb, NFTA_QUOTA_BYTES, cpu_to_be64(priv->quota), 128 if (nla_put_be64(skb, NFTA_QUOTA_BYTES, cpu_to_be64(priv->quota),
132 NFTA_QUOTA_PAD) || 129 NFTA_QUOTA_PAD) ||
133 nla_put_be64(skb, NFTA_QUOTA_CONSUMED, cpu_to_be64(consumed), 130 nla_put_be64(skb, NFTA_QUOTA_CONSUMED, cpu_to_be64(consumed_cap),
134 NFTA_QUOTA_PAD) || 131 NFTA_QUOTA_PAD) ||
135 nla_put_be32(skb, NFTA_QUOTA_FLAGS, htonl(flags))) 132 nla_put_be32(skb, NFTA_QUOTA_FLAGS, htonl(flags)))
136 goto nla_put_failure; 133 goto nla_put_failure;
134
135 if (reset) {
136 atomic64_sub(consumed, &priv->consumed);
137 clear_bit(NFT_QUOTA_DEPLETED_BIT, &priv->flags);
138 }
137 return 0; 139 return 0;
138 140
139nla_put_failure: 141nla_put_failure:
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 28c56b95fb7f..ea7c67050792 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -1502,10 +1502,7 @@ static int __init netlbl_init(void)
1502 printk(KERN_INFO "NetLabel: Initializing\n"); 1502 printk(KERN_INFO "NetLabel: Initializing\n");
1503 printk(KERN_INFO "NetLabel: domain hash size = %u\n", 1503 printk(KERN_INFO "NetLabel: domain hash size = %u\n",
1504 (1 << NETLBL_DOMHSH_BITSIZE)); 1504 (1 << NETLBL_DOMHSH_BITSIZE));
1505 printk(KERN_INFO "NetLabel: protocols =" 1505 printk(KERN_INFO "NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO\n");
1506 " UNLABELED"
1507 " CIPSOv4"
1508 "\n");
1509 1506
1510 ret_val = netlbl_domhsh_init(NETLBL_DOMHSH_BITSIZE); 1507 ret_val = netlbl_domhsh_init(NETLBL_DOMHSH_BITSIZE);
1511 if (ret_val != 0) 1508 if (ret_val != 0)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 6b78bab27755..54253ea5976e 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -514,7 +514,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
514 int hooknum, nh_off, err = NF_ACCEPT; 514 int hooknum, nh_off, err = NF_ACCEPT;
515 515
516 nh_off = skb_network_offset(skb); 516 nh_off = skb_network_offset(skb);
517 skb_pull(skb, nh_off); 517 skb_pull_rcsum(skb, nh_off);
518 518
519 /* See HOOK2MANIP(). */ 519 /* See HOOK2MANIP(). */
520 if (maniptype == NF_NAT_MANIP_SRC) 520 if (maniptype == NF_NAT_MANIP_SRC)
@@ -579,6 +579,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
579 err = nf_nat_packet(ct, ctinfo, hooknum, skb); 579 err = nf_nat_packet(ct, ctinfo, hooknum, skb);
580push: 580push:
581 skb_push(skb, nh_off); 581 skb_push(skb, nh_off);
582 skb_postpush_rcsum(skb, skb->data, nh_off);
582 583
583 return err; 584 return err;
584} 585}
@@ -886,7 +887,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
886 887
887 /* The conntrack module expects to be working at L3. */ 888 /* The conntrack module expects to be working at L3. */
888 nh_ofs = skb_network_offset(skb); 889 nh_ofs = skb_network_offset(skb);
889 skb_pull(skb, nh_ofs); 890 skb_pull_rcsum(skb, nh_ofs);
890 891
891 if (key->ip.frag != OVS_FRAG_TYPE_NONE) { 892 if (key->ip.frag != OVS_FRAG_TYPE_NONE) {
892 err = handle_fragments(net, key, info->zone.id, skb); 893 err = handle_fragments(net, key, info->zone.id, skb);
@@ -900,6 +901,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
900 err = ovs_ct_lookup(net, key, info, skb); 901 err = ovs_ct_lookup(net, key, info, skb);
901 902
902 skb_push(skb, nh_ofs); 903 skb_push(skb, nh_ofs);
904 skb_postpush_rcsum(skb, skb->data, nh_ofs);
903 if (err) 905 if (err)
904 kfree_skb(skb); 906 kfree_skb(skb);
905 return err; 907 return err;
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index c985ecbe9bd6..ae5ac175b2be 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -252,7 +252,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node,
252 const int pkt_len = 20; 252 const int pkt_len = 20;
253 struct qrtr_hdr *hdr; 253 struct qrtr_hdr *hdr;
254 struct sk_buff *skb; 254 struct sk_buff *skb;
255 u32 *buf; 255 __le32 *buf;
256 256
257 skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); 257 skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL);
258 if (!skb) 258 if (!skb)
@@ -269,7 +269,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node,
269 hdr->dst_node_id = cpu_to_le32(dst_node); 269 hdr->dst_node_id = cpu_to_le32(dst_node);
270 hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); 270 hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL);
271 271
272 buf = (u32 *)skb_put(skb, pkt_len); 272 buf = (__le32 *)skb_put(skb, pkt_len);
273 memset(buf, 0, pkt_len); 273 memset(buf, 0, pkt_len);
274 buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); 274 buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX);
275 buf[1] = cpu_to_le32(src_node); 275 buf[1] = cpu_to_le32(src_node);
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 2095c83ce773..e10456ef6f7a 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -900,8 +900,6 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
900 goto err; 900 goto err;
901 } 901 }
902 act->order = i; 902 act->order = i;
903 if (event == RTM_GETACTION)
904 act->tcfa_refcnt++;
905 list_add_tail(&act->list, &actions); 903 list_add_tail(&act->list, &actions);
906 } 904 }
907 905
@@ -914,7 +912,8 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
914 return ret; 912 return ret;
915 } 913 }
916err: 914err:
917 tcf_action_destroy(&actions, 0); 915 if (event != RTM_GETACTION)
916 tcf_action_destroy(&actions, 0);
918 return ret; 917 return ret;
919} 918}
920 919
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index 1c60317f0121..520baa41cba3 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -123,12 +123,11 @@ static int tcf_bpf_dump_ebpf_info(const struct tcf_bpf *prog,
123 nla_put_string(skb, TCA_ACT_BPF_NAME, prog->bpf_name)) 123 nla_put_string(skb, TCA_ACT_BPF_NAME, prog->bpf_name))
124 return -EMSGSIZE; 124 return -EMSGSIZE;
125 125
126 nla = nla_reserve(skb, TCA_ACT_BPF_DIGEST, 126 nla = nla_reserve(skb, TCA_ACT_BPF_TAG, sizeof(prog->filter->tag));
127 sizeof(prog->filter->digest));
128 if (nla == NULL) 127 if (nla == NULL)
129 return -EMSGSIZE; 128 return -EMSGSIZE;
130 129
131 memcpy(nla_data(nla), prog->filter->digest, nla_len(nla)); 130 memcpy(nla_data(nla), prog->filter->tag, nla_len(nla));
132 131
133 return 0; 132 return 0;
134} 133}
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index adc776048d1a..d9c97018317d 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -555,11 +555,11 @@ static int cls_bpf_dump_ebpf_info(const struct cls_bpf_prog *prog,
555 nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name)) 555 nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name))
556 return -EMSGSIZE; 556 return -EMSGSIZE;
557 557
558 nla = nla_reserve(skb, TCA_BPF_DIGEST, sizeof(prog->filter->digest)); 558 nla = nla_reserve(skb, TCA_BPF_TAG, sizeof(prog->filter->tag));
559 if (nla == NULL) 559 if (nla == NULL)
560 return -EMSGSIZE; 560 return -EMSGSIZE;
561 561
562 memcpy(nla_data(nla), prog->filter->digest, nla_len(nla)); 562 memcpy(nla_data(nla), prog->filter->tag, nla_len(nla));
563 563
564 return 0; 564 return 0;
565} 565}
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 333f8e268431..970db7a41684 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -153,10 +153,14 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
153 153
154 switch (ip_tunnel_info_af(info)) { 154 switch (ip_tunnel_info_af(info)) {
155 case AF_INET: 155 case AF_INET:
156 skb_key.enc_control.addr_type =
157 FLOW_DISSECTOR_KEY_IPV4_ADDRS;
156 skb_key.enc_ipv4.src = key->u.ipv4.src; 158 skb_key.enc_ipv4.src = key->u.ipv4.src;
157 skb_key.enc_ipv4.dst = key->u.ipv4.dst; 159 skb_key.enc_ipv4.dst = key->u.ipv4.dst;
158 break; 160 break;
159 case AF_INET6: 161 case AF_INET6:
162 skb_key.enc_control.addr_type =
163 FLOW_DISSECTOR_KEY_IPV6_ADDRS;
160 skb_key.enc_ipv6.src = key->u.ipv6.src; 164 skb_key.enc_ipv6.src = key->u.ipv6.src;
161 skb_key.enc_ipv6.dst = key->u.ipv6.dst; 165 skb_key.enc_ipv6.dst = key->u.ipv6.dst;
162 break; 166 break;
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index e54082699520..34efaa4ef2f6 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -1048,7 +1048,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp)
1048 (new_transport->state == SCTP_PF))) 1048 (new_transport->state == SCTP_PF)))
1049 new_transport = asoc->peer.active_path; 1049 new_transport = asoc->peer.active_path;
1050 if (new_transport->state == SCTP_UNCONFIRMED) { 1050 if (new_transport->state == SCTP_UNCONFIRMED) {
1051 WARN_ONCE(1, "Atempt to send packet on unconfirmed path."); 1051 WARN_ONCE(1, "Attempt to send packet on unconfirmed path.");
1052 sctp_chunk_fail(chunk, 0); 1052 sctp_chunk_fail(chunk, 0);
1053 sctp_chunk_free(chunk); 1053 sctp_chunk_free(chunk);
1054 continue; 1054 continue;
diff --git a/net/socket.c b/net/socket.c
index 8487bf136e5c..0758e13754e2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -533,11 +533,11 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,
533 return used; 533 return used;
534} 534}
535 535
536int sockfs_setattr(struct dentry *dentry, struct iattr *iattr) 536static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)
537{ 537{
538 int err = simple_setattr(dentry, iattr); 538 int err = simple_setattr(dentry, iattr);
539 539
540 if (!err) { 540 if (!err && (iattr->ia_valid & ATTR_UID)) {
541 struct socket *sock = SOCKET_I(d_inode(dentry)); 541 struct socket *sock = SOCKET_I(d_inode(dentry));
542 542
543 sock->sk->sk_uid = iattr->ia_uid; 543 sock->sk->sk_uid = iattr->ia_uid;
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 886e9d381771..153082598522 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -1489,7 +1489,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
1489 case RPC_GSS_PROC_DESTROY: 1489 case RPC_GSS_PROC_DESTROY:
1490 if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq)) 1490 if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq))
1491 goto auth_err; 1491 goto auth_err;
1492 rsci->h.expiry_time = get_seconds(); 1492 rsci->h.expiry_time = seconds_since_boot();
1493 set_bit(CACHE_NEGATIVE, &rsci->h.flags); 1493 set_bit(CACHE_NEGATIVE, &rsci->h.flags);
1494 if (resv->iov_len + 4 > PAGE_SIZE) 1494 if (resv->iov_len + 4 > PAGE_SIZE)
1495 goto drop; 1495 goto drop;
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 3bc1d61694cb..9c9db55a0c1e 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -799,6 +799,8 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
799 799
800 if (test_bit(XPT_CLOSE, &xprt->xpt_flags)) { 800 if (test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
801 dprintk("svc_recv: found XPT_CLOSE\n"); 801 dprintk("svc_recv: found XPT_CLOSE\n");
802 if (test_and_clear_bit(XPT_KILL_TEMP, &xprt->xpt_flags))
803 xprt->xpt_ops->xpo_kill_temp_xprt(xprt);
802 svc_delete_xprt(xprt); 804 svc_delete_xprt(xprt);
803 /* Leave XPT_BUSY set on the dead xprt: */ 805 /* Leave XPT_BUSY set on the dead xprt: */
804 goto out; 806 goto out;
@@ -1020,9 +1022,11 @@ void svc_age_temp_xprts_now(struct svc_serv *serv, struct sockaddr *server_addr)
1020 le = to_be_closed.next; 1022 le = to_be_closed.next;
1021 list_del_init(le); 1023 list_del_init(le);
1022 xprt = list_entry(le, struct svc_xprt, xpt_list); 1024 xprt = list_entry(le, struct svc_xprt, xpt_list);
1023 dprintk("svc_age_temp_xprts_now: closing %p\n", xprt); 1025 set_bit(XPT_CLOSE, &xprt->xpt_flags);
1024 xprt->xpt_ops->xpo_kill_temp_xprt(xprt); 1026 set_bit(XPT_KILL_TEMP, &xprt->xpt_flags);
1025 svc_close_xprt(xprt); 1027 dprintk("svc_age_temp_xprts_now: queuing xprt %p for closing\n",
1028 xprt);
1029 svc_xprt_enqueue(xprt);
1026 } 1030 }
1027} 1031}
1028EXPORT_SYMBOL_GPL(svc_age_temp_xprts_now); 1032EXPORT_SYMBOL_GPL(svc_age_temp_xprts_now);
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index 57d35fbb1c28..172b537f8cfc 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -347,8 +347,6 @@ int rdma_read_chunk_frmr(struct svcxprt_rdma *xprt,
347 atomic_inc(&rdma_stat_read); 347 atomic_inc(&rdma_stat_read);
348 return ret; 348 return ret;
349 err: 349 err:
350 ib_dma_unmap_sg(xprt->sc_cm_id->device,
351 frmr->sg, frmr->sg_nents, frmr->direction);
352 svc_rdma_put_context(ctxt, 0); 350 svc_rdma_put_context(ctxt, 0);
353 svc_rdma_put_frmr(xprt, frmr); 351 svc_rdma_put_frmr(xprt, frmr);
354 return ret; 352 return ret;
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 6b109a808d4c..02462d67d191 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -169,7 +169,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
169 169
170 /* Send response, if necessary */ 170 /* Send response, if necessary */
171 if (respond && (mtyp == DSC_REQ_MSG)) { 171 if (respond && (mtyp == DSC_REQ_MSG)) {
172 rskb = tipc_buf_acquire(MAX_H_SIZE); 172 rskb = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
173 if (!rskb) 173 if (!rskb)
174 return; 174 return;
175 tipc_disc_init_msg(net, rskb, DSC_RESP_MSG, bearer); 175 tipc_disc_init_msg(net, rskb, DSC_RESP_MSG, bearer);
@@ -278,7 +278,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,
278 req = kmalloc(sizeof(*req), GFP_ATOMIC); 278 req = kmalloc(sizeof(*req), GFP_ATOMIC);
279 if (!req) 279 if (!req)
280 return -ENOMEM; 280 return -ENOMEM;
281 req->buf = tipc_buf_acquire(MAX_H_SIZE); 281 req->buf = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
282 if (!req->buf) { 282 if (!req->buf) {
283 kfree(req); 283 kfree(req);
284 return -ENOMEM; 284 return -ENOMEM;
diff --git a/net/tipc/link.c b/net/tipc/link.c
index bda89bf9f4ff..4e8647aef01c 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1395,7 +1395,7 @@ tnl:
1395 msg_set_seqno(hdr, seqno++); 1395 msg_set_seqno(hdr, seqno++);
1396 pktlen = msg_size(hdr); 1396 pktlen = msg_size(hdr);
1397 msg_set_size(&tnlhdr, pktlen + INT_H_SIZE); 1397 msg_set_size(&tnlhdr, pktlen + INT_H_SIZE);
1398 tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE); 1398 tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE, GFP_ATOMIC);
1399 if (!tnlskb) { 1399 if (!tnlskb) {
1400 pr_warn("%sunable to send packet\n", link_co_err); 1400 pr_warn("%sunable to send packet\n", link_co_err);
1401 return; 1401 return;
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index a22be502f1bd..ab02d0742476 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -58,12 +58,12 @@ static unsigned int align(unsigned int i)
58 * NOTE: Headroom is reserved to allow prepending of a data link header. 58 * NOTE: Headroom is reserved to allow prepending of a data link header.
59 * There may also be unrequested tailroom present at the buffer's end. 59 * There may also be unrequested tailroom present at the buffer's end.
60 */ 60 */
61struct sk_buff *tipc_buf_acquire(u32 size) 61struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp)
62{ 62{
63 struct sk_buff *skb; 63 struct sk_buff *skb;
64 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; 64 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
65 65
66 skb = alloc_skb_fclone(buf_size, GFP_ATOMIC); 66 skb = alloc_skb_fclone(buf_size, gfp);
67 if (skb) { 67 if (skb) {
68 skb_reserve(skb, BUF_HEADROOM); 68 skb_reserve(skb, BUF_HEADROOM);
69 skb_put(skb, size); 69 skb_put(skb, size);
@@ -95,7 +95,7 @@ struct sk_buff *tipc_msg_create(uint user, uint type,
95 struct tipc_msg *msg; 95 struct tipc_msg *msg;
96 struct sk_buff *buf; 96 struct sk_buff *buf;
97 97
98 buf = tipc_buf_acquire(hdr_sz + data_sz); 98 buf = tipc_buf_acquire(hdr_sz + data_sz, GFP_ATOMIC);
99 if (unlikely(!buf)) 99 if (unlikely(!buf))
100 return NULL; 100 return NULL;
101 101
@@ -261,7 +261,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
261 261
262 /* No fragmentation needed? */ 262 /* No fragmentation needed? */
263 if (likely(msz <= pktmax)) { 263 if (likely(msz <= pktmax)) {
264 skb = tipc_buf_acquire(msz); 264 skb = tipc_buf_acquire(msz, GFP_KERNEL);
265 if (unlikely(!skb)) 265 if (unlikely(!skb))
266 return -ENOMEM; 266 return -ENOMEM;
267 skb_orphan(skb); 267 skb_orphan(skb);
@@ -282,7 +282,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
282 msg_set_importance(&pkthdr, msg_importance(mhdr)); 282 msg_set_importance(&pkthdr, msg_importance(mhdr));
283 283
284 /* Prepare first fragment */ 284 /* Prepare first fragment */
285 skb = tipc_buf_acquire(pktmax); 285 skb = tipc_buf_acquire(pktmax, GFP_KERNEL);
286 if (!skb) 286 if (!skb)
287 return -ENOMEM; 287 return -ENOMEM;
288 skb_orphan(skb); 288 skb_orphan(skb);
@@ -313,7 +313,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
313 pktsz = drem + INT_H_SIZE; 313 pktsz = drem + INT_H_SIZE;
314 else 314 else
315 pktsz = pktmax; 315 pktsz = pktmax;
316 skb = tipc_buf_acquire(pktsz); 316 skb = tipc_buf_acquire(pktsz, GFP_KERNEL);
317 if (!skb) { 317 if (!skb) {
318 rc = -ENOMEM; 318 rc = -ENOMEM;
319 goto error; 319 goto error;
@@ -448,7 +448,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
448 if (msz > (max / 2)) 448 if (msz > (max / 2))
449 return false; 449 return false;
450 450
451 _skb = tipc_buf_acquire(max); 451 _skb = tipc_buf_acquire(max, GFP_ATOMIC);
452 if (!_skb) 452 if (!_skb)
453 return false; 453 return false;
454 454
@@ -496,7 +496,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
496 496
497 /* Never return SHORT header; expand by replacing buffer if necessary */ 497 /* Never return SHORT header; expand by replacing buffer if necessary */
498 if (msg_short(hdr)) { 498 if (msg_short(hdr)) {
499 *skb = tipc_buf_acquire(BASIC_H_SIZE + dlen); 499 *skb = tipc_buf_acquire(BASIC_H_SIZE + dlen, GFP_ATOMIC);
500 if (!*skb) 500 if (!*skb)
501 goto exit; 501 goto exit;
502 memcpy((*skb)->data + BASIC_H_SIZE, msg_data(hdr), dlen); 502 memcpy((*skb)->data + BASIC_H_SIZE, msg_data(hdr), dlen);
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 8d408612ffa4..2c3dc38abf9c 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -820,7 +820,7 @@ static inline bool msg_is_reset(struct tipc_msg *hdr)
820 return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG); 820 return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG);
821} 821}
822 822
823struct sk_buff *tipc_buf_acquire(u32 size); 823struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp);
824bool tipc_msg_validate(struct sk_buff *skb); 824bool tipc_msg_validate(struct sk_buff *skb);
825bool tipc_msg_reverse(u32 own_addr, struct sk_buff **skb, int err); 825bool tipc_msg_reverse(u32 own_addr, struct sk_buff **skb, int err);
826void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type, 826void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type,
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index c1cfd92de17a..23f8899e0f8c 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -69,7 +69,7 @@ static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,
69 u32 dest) 69 u32 dest)
70{ 70{
71 struct tipc_net *tn = net_generic(net, tipc_net_id); 71 struct tipc_net *tn = net_generic(net, tipc_net_id);
72 struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); 72 struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size, GFP_ATOMIC);
73 struct tipc_msg *msg; 73 struct tipc_msg *msg;
74 74
75 if (buf != NULL) { 75 if (buf != NULL) {
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3df85a751a85..5c1b267e22be 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4615,6 +4615,15 @@ int cfg80211_check_station_change(struct wiphy *wiphy,
4615 break; 4615 break;
4616 } 4616 }
4617 4617
4618 /*
4619 * Older kernel versions ignored this attribute entirely, so don't
4620 * reject attempts to update it but mark it as unused instead so the
4621 * driver won't look at the data.
4622 */
4623 if (statype != CFG80211_STA_AP_CLIENT_UNASSOC &&
4624 statype != CFG80211_STA_TDLS_PEER_SETUP)
4625 params->opmode_notif_used = false;
4626
4618 return 0; 4627 return 0;
4619} 4628}
4620EXPORT_SYMBOL(cfg80211_check_station_change); 4629EXPORT_SYMBOL(cfg80211_check_station_change);
@@ -4854,6 +4863,12 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
4854 params.local_pm = pm; 4863 params.local_pm = pm;
4855 } 4864 }
4856 4865
4866 if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) {
4867 params.opmode_notif_used = true;
4868 params.opmode_notif =
4869 nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]);
4870 }
4871
4857 /* Include parameters for TDLS peer (will check later) */ 4872 /* Include parameters for TDLS peer (will check later) */
4858 err = nl80211_set_station_tdls(info, &params); 4873 err = nl80211_set_station_tdls(info, &params);
4859 if (err) 4874 if (err)
@@ -14502,13 +14517,17 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
14502 14517
14503 list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { 14518 list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) {
14504 bool schedule_destroy_work = false; 14519 bool schedule_destroy_work = false;
14505 bool schedule_scan_stop = false;
14506 struct cfg80211_sched_scan_request *sched_scan_req = 14520 struct cfg80211_sched_scan_request *sched_scan_req =
14507 rcu_dereference(rdev->sched_scan_req); 14521 rcu_dereference(rdev->sched_scan_req);
14508 14522
14509 if (sched_scan_req && notify->portid && 14523 if (sched_scan_req && notify->portid &&
14510 sched_scan_req->owner_nlportid == notify->portid) 14524 sched_scan_req->owner_nlportid == notify->portid) {
14511 schedule_scan_stop = true; 14525 sched_scan_req->owner_nlportid = 0;
14526
14527 if (rdev->ops->sched_scan_stop &&
14528 rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN)
14529 schedule_work(&rdev->sched_scan_stop_wk);
14530 }
14512 14531
14513 list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) { 14532 list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) {
14514 cfg80211_mlme_unregister_socket(wdev, notify->portid); 14533 cfg80211_mlme_unregister_socket(wdev, notify->portid);
@@ -14539,12 +14558,6 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
14539 spin_unlock(&rdev->destroy_list_lock); 14558 spin_unlock(&rdev->destroy_list_lock);
14540 schedule_work(&rdev->destroy_work); 14559 schedule_work(&rdev->destroy_work);
14541 } 14560 }
14542 } else if (schedule_scan_stop) {
14543 sched_scan_req->owner_nlportid = 0;
14544
14545 if (rdev->ops->sched_scan_stop &&
14546 rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN)
14547 schedule_work(&rdev->sched_scan_stop_wk);
14548 } 14561 }
14549 } 14562 }
14550 14563
diff --git a/samples/Kconfig b/samples/Kconfig
index a6d2a43bbf2e..b124f62ed6cb 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -105,4 +105,11 @@ config SAMPLE_BLACKFIN_GPTIMERS
105 help 105 help
106 Build samples of blackfin gptimers sample module. 106 Build samples of blackfin gptimers sample module.
107 107
108config SAMPLE_VFIO_MDEV_MTTY
109 tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
110 depends on VFIO_MDEV_DEVICE && m
111 help
112 Build a virtual tty sample driver for use as a VFIO
113 mediated device
114
108endif # SAMPLES 115endif # SAMPLES
diff --git a/samples/Makefile b/samples/Makefile
index e17d66d77f09..86a137e451d9 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -2,4 +2,5 @@
2 2
3obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \ 3obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \
4 hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \ 4 hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
5 configfs/ connector/ v4l/ trace_printk/ blackfin/ 5 configfs/ connector/ v4l/ trace_printk/ blackfin/ \
6 vfio-mdev/
diff --git a/samples/bpf/sock_example.h b/samples/bpf/sock_example.h
index 09f7fe7e5fd7..d8014065d479 100644
--- a/samples/bpf/sock_example.h
+++ b/samples/bpf/sock_example.h
@@ -4,7 +4,7 @@
4#include <unistd.h> 4#include <unistd.h>
5#include <string.h> 5#include <string.h>
6#include <errno.h> 6#include <errno.h>
7#include <net/ethernet.h> 7#include <linux/if_ether.h>
8#include <net/if.h> 8#include <net/if.h>
9#include <linux/if_packet.h> 9#include <linux/if_packet.h>
10#include <arpa/inet.h> 10#include <arpa/inet.h>
diff --git a/samples/bpf/trace_output_user.c b/samples/bpf/trace_output_user.c
index f4fa6af22def..ccca1e348017 100644
--- a/samples/bpf/trace_output_user.c
+++ b/samples/bpf/trace_output_user.c
@@ -9,7 +9,6 @@
9#include <string.h> 9#include <string.h>
10#include <fcntl.h> 10#include <fcntl.h>
11#include <poll.h> 11#include <poll.h>
12#include <sys/ioctl.h>
13#include <linux/perf_event.h> 12#include <linux/perf_event.h>
14#include <linux/bpf.h> 13#include <linux/bpf.h>
15#include <errno.h> 14#include <errno.h>
diff --git a/samples/vfio-mdev/Makefile b/samples/vfio-mdev/Makefile
index a932edbe38eb..cbbd868a50a8 100644
--- a/samples/vfio-mdev/Makefile
+++ b/samples/vfio-mdev/Makefile
@@ -1,13 +1 @@
1# obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o
2# Makefile for mtty.c file
3#
4KERNEL_DIR:=/lib/modules/$(shell uname -r)/build
5
6obj-m:=mtty.o
7
8modules clean modules_install:
9 $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) $@
10
11default: modules
12
13module: modules
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 6b633a4ea333..ca495686b9c3 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -164,7 +164,7 @@ static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid)
164 struct mdev_state *mds; 164 struct mdev_state *mds;
165 165
166 list_for_each_entry(mds, &mdev_devices_list, next) { 166 list_for_each_entry(mds, &mdev_devices_list, next) {
167 if (uuid_le_cmp(mds->mdev->uuid, uuid) == 0) 167 if (uuid_le_cmp(mdev_uuid(mds->mdev), uuid) == 0)
168 return mds; 168 return mds;
169 } 169 }
170 170
@@ -341,7 +341,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
341 pr_err("Serial port %d: Fifo level trigger\n", 341 pr_err("Serial port %d: Fifo level trigger\n",
342 index); 342 index);
343#endif 343#endif
344 mtty_trigger_interrupt(mdev_state->mdev->uuid); 344 mtty_trigger_interrupt(
345 mdev_uuid(mdev_state->mdev));
345 } 346 }
346 } else { 347 } else {
347#if defined(DEBUG_INTR) 348#if defined(DEBUG_INTR)
@@ -355,7 +356,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
355 */ 356 */
356 if (mdev_state->s[index].uart_reg[UART_IER] & 357 if (mdev_state->s[index].uart_reg[UART_IER] &
357 UART_IER_RLSI) 358 UART_IER_RLSI)
358 mtty_trigger_interrupt(mdev_state->mdev->uuid); 359 mtty_trigger_interrupt(
360 mdev_uuid(mdev_state->mdev));
359 } 361 }
360 mutex_unlock(&mdev_state->rxtx_lock); 362 mutex_unlock(&mdev_state->rxtx_lock);
361 break; 363 break;
@@ -374,7 +376,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
374 pr_err("Serial port %d: IER_THRI write\n", 376 pr_err("Serial port %d: IER_THRI write\n",
375 index); 377 index);
376#endif 378#endif
377 mtty_trigger_interrupt(mdev_state->mdev->uuid); 379 mtty_trigger_interrupt(
380 mdev_uuid(mdev_state->mdev));
378 } 381 }
379 382
380 mutex_unlock(&mdev_state->rxtx_lock); 383 mutex_unlock(&mdev_state->rxtx_lock);
@@ -445,7 +448,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
445#if defined(DEBUG_INTR) 448#if defined(DEBUG_INTR)
446 pr_err("Serial port %d: MCR_OUT2 write\n", index); 449 pr_err("Serial port %d: MCR_OUT2 write\n", index);
447#endif 450#endif
448 mtty_trigger_interrupt(mdev_state->mdev->uuid); 451 mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev));
449 } 452 }
450 453
451 if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) && 454 if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) &&
@@ -453,7 +456,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
453#if defined(DEBUG_INTR) 456#if defined(DEBUG_INTR)
454 pr_err("Serial port %d: MCR RTS/DTR write\n", index); 457 pr_err("Serial port %d: MCR RTS/DTR write\n", index);
455#endif 458#endif
456 mtty_trigger_interrupt(mdev_state->mdev->uuid); 459 mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev));
457 } 460 }
458 break; 461 break;
459 462
@@ -504,7 +507,8 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
504#endif 507#endif
505 if (mdev_state->s[index].uart_reg[UART_IER] & 508 if (mdev_state->s[index].uart_reg[UART_IER] &
506 UART_IER_THRI) 509 UART_IER_THRI)
507 mtty_trigger_interrupt(mdev_state->mdev->uuid); 510 mtty_trigger_interrupt(
511 mdev_uuid(mdev_state->mdev));
508 } 512 }
509 mutex_unlock(&mdev_state->rxtx_lock); 513 mutex_unlock(&mdev_state->rxtx_lock);
510 514
@@ -734,7 +738,7 @@ int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
734 738
735 for (i = 0; i < 2; i++) { 739 for (i = 0; i < 2; i++) {
736 snprintf(name, MTTY_STRING_LEN, "%s-%d", 740 snprintf(name, MTTY_STRING_LEN, "%s-%d",
737 dev_driver_string(mdev->parent->dev), i + 1); 741 dev_driver_string(mdev_parent_dev(mdev)), i + 1);
738 if (!strcmp(kobj->name, name)) { 742 if (!strcmp(kobj->name, name)) {
739 nr_ports = i + 1; 743 nr_ports = i + 1;
740 break; 744 break;
@@ -1069,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
1069{ 1073{
1070 unsigned int size = 0; 1074 unsigned int size = 0;
1071 struct mdev_state *mdev_state; 1075 struct mdev_state *mdev_state;
1072 int bar_index; 1076 u32 bar_index;
1073 1077
1074 if (!mdev) 1078 if (!mdev)
1075 return -EINVAL; 1079 return -EINVAL;
@@ -1078,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
1078 if (!mdev_state) 1082 if (!mdev_state)
1079 return -EINVAL; 1083 return -EINVAL;
1080 1084
1081 mutex_lock(&mdev_state->ops_lock);
1082 bar_index = region_info->index; 1085 bar_index = region_info->index;
1086 if (bar_index >= VFIO_PCI_NUM_REGIONS)
1087 return -EINVAL;
1088
1089 mutex_lock(&mdev_state->ops_lock);
1083 1090
1084 switch (bar_index) { 1091 switch (bar_index) {
1085 case VFIO_PCI_CONFIG_REGION_INDEX: 1092 case VFIO_PCI_CONFIG_REGION_INDEX:
@@ -1176,7 +1183,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1176 1183
1177 memcpy(&mdev_state->dev_info, &info, sizeof(info)); 1184 memcpy(&mdev_state->dev_info, &info, sizeof(info));
1178 1185
1179 return copy_to_user((void __user *)arg, &info, minsz); 1186 if (copy_to_user((void __user *)arg, &info, minsz))
1187 return -EFAULT;
1188
1189 return 0;
1180 } 1190 }
1181 case VFIO_DEVICE_GET_REGION_INFO: 1191 case VFIO_DEVICE_GET_REGION_INFO:
1182 { 1192 {
@@ -1197,7 +1207,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1197 if (ret) 1207 if (ret)
1198 return ret; 1208 return ret;
1199 1209
1200 return copy_to_user((void __user *)arg, &info, minsz); 1210 if (copy_to_user((void __user *)arg, &info, minsz))
1211 return -EFAULT;
1212
1213 return 0;
1201 } 1214 }
1202 1215
1203 case VFIO_DEVICE_GET_IRQ_INFO: 1216 case VFIO_DEVICE_GET_IRQ_INFO:
@@ -1217,10 +1230,10 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
1217 if (ret) 1230 if (ret)
1218 return ret; 1231 return ret;
1219 1232
1220 if (info.count == -1) 1233 if (copy_to_user((void __user *)arg, &info, minsz))
1221 return -EINVAL; 1234 return -EFAULT;
1222 1235
1223 return copy_to_user((void __user *)arg, &info, minsz); 1236 return 0;
1224 } 1237 }
1225 case VFIO_DEVICE_SET_IRQS: 1238 case VFIO_DEVICE_SET_IRQS:
1226 { 1239 {
@@ -1298,10 +1311,8 @@ static ssize_t
1298sample_mdev_dev_show(struct device *dev, struct device_attribute *attr, 1311sample_mdev_dev_show(struct device *dev, struct device_attribute *attr,
1299 char *buf) 1312 char *buf)
1300{ 1313{
1301 struct mdev_device *mdev = to_mdev_device(dev); 1314 if (mdev_from_dev(dev))
1302 1315 return sprintf(buf, "This is MDEV %s\n", dev_name(dev));
1303 if (mdev)
1304 return sprintf(buf, "This is MDEV %s\n", dev_name(&mdev->dev));
1305 1316
1306 return sprintf(buf, "\n"); 1317 return sprintf(buf, "\n");
1307} 1318}
@@ -1402,7 +1413,7 @@ struct attribute_group *mdev_type_groups[] = {
1402 NULL, 1413 NULL,
1403}; 1414};
1404 1415
1405struct parent_ops mdev_fops = { 1416struct mdev_parent_ops mdev_fops = {
1406 .owner = THIS_MODULE, 1417 .owner = THIS_MODULE,
1407 .dev_attr_groups = mtty_dev_groups, 1418 .dev_attr_groups = mtty_dev_groups,
1408 .mdev_attr_groups = mdev_dev_groups, 1419 .mdev_attr_groups = mdev_dev_groups,
@@ -1447,6 +1458,7 @@ static int __init mtty_dev_init(void)
1447 1458
1448 if (IS_ERR(mtty_dev.vd_class)) { 1459 if (IS_ERR(mtty_dev.vd_class)) {
1449 pr_err("Error: failed to register mtty_dev class\n"); 1460 pr_err("Error: failed to register mtty_dev class\n");
1461 ret = PTR_ERR(mtty_dev.vd_class);
1450 goto failed1; 1462 goto failed1;
1451 } 1463 }
1452 1464
@@ -1458,7 +1470,8 @@ static int __init mtty_dev_init(void)
1458 if (ret) 1470 if (ret)
1459 goto failed2; 1471 goto failed2;
1460 1472
1461 if (mdev_register_device(&mtty_dev.dev, &mdev_fops) != 0) 1473 ret = mdev_register_device(&mtty_dev.dev, &mdev_fops);
1474 if (ret)
1462 goto failed3; 1475 goto failed3;
1463 1476
1464 mutex_init(&mdev_list_lock); 1477 mutex_init(&mdev_list_lock);
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 950fd2e64bb7..12262c0cc691 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -39,6 +39,9 @@
39#include "hash-map.h" 39#include "hash-map.h"
40#endif 40#endif
41 41
42#if BUILDING_GCC_VERSION >= 7000
43#include "memmodel.h"
44#endif
42#include "emit-rtl.h" 45#include "emit-rtl.h"
43#include "debug.h" 46#include "debug.h"
44#include "target.h" 47#include "target.h"
@@ -91,6 +94,9 @@
91#include "tree-ssa-alias.h" 94#include "tree-ssa-alias.h"
92#include "tree-ssa.h" 95#include "tree-ssa.h"
93#include "stringpool.h" 96#include "stringpool.h"
97#if BUILDING_GCC_VERSION >= 7000
98#include "tree-vrp.h"
99#endif
94#include "tree-ssanames.h" 100#include "tree-ssanames.h"
95#include "print-tree.h" 101#include "print-tree.h"
96#include "tree-eh.h" 102#include "tree-eh.h"
@@ -287,6 +293,22 @@ static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct c
287 return NULL; 293 return NULL;
288} 294}
289 295
296static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
297{
298 cgraph_node_ptr alias;
299
300 if (callback(node, data))
301 return true;
302
303 for (alias = node->same_body; alias; alias = alias->next) {
304 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
305 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
306 return true;
307 }
308
309 return false;
310}
311
290#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ 312#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
291 for ((node) = cgraph_first_function_with_gimple_body(); (node); \ 313 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
292 (node) = cgraph_next_function_with_gimple_body(node)) 314 (node) = cgraph_next_function_with_gimple_body(node))
@@ -399,6 +421,7 @@ typedef union gimple_statement_d gassign;
399typedef union gimple_statement_d gcall; 421typedef union gimple_statement_d gcall;
400typedef union gimple_statement_d gcond; 422typedef union gimple_statement_d gcond;
401typedef union gimple_statement_d gdebug; 423typedef union gimple_statement_d gdebug;
424typedef union gimple_statement_d ggoto;
402typedef union gimple_statement_d gphi; 425typedef union gimple_statement_d gphi;
403typedef union gimple_statement_d greturn; 426typedef union gimple_statement_d greturn;
404 427
@@ -452,6 +475,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
452 return stmt; 475 return stmt;
453} 476}
454 477
478static inline ggoto *as_a_ggoto(gimple stmt)
479{
480 return stmt;
481}
482
483static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
484{
485 return stmt;
486}
487
455static inline gphi *as_a_gphi(gimple stmt) 488static inline gphi *as_a_gphi(gimple stmt)
456{ 489{
457 return stmt; 490 return stmt;
@@ -496,6 +529,14 @@ static inline const greturn *as_a_const_greturn(const_gimple stmt)
496 529
497typedef struct rtx_def rtx_insn; 530typedef struct rtx_def rtx_insn;
498 531
532static inline const char *get_decl_section_name(const_tree decl)
533{
534 if (DECL_SECTION_NAME(decl) == NULL_TREE)
535 return NULL;
536
537 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
538}
539
499static inline void set_decl_section_name(tree node, const char *value) 540static inline void set_decl_section_name(tree node, const char *value)
500{ 541{
501 if (value) 542 if (value)
@@ -511,6 +552,7 @@ typedef struct gimple_statement_base gassign;
511typedef struct gimple_statement_call gcall; 552typedef struct gimple_statement_call gcall;
512typedef struct gimple_statement_base gcond; 553typedef struct gimple_statement_base gcond;
513typedef struct gimple_statement_base gdebug; 554typedef struct gimple_statement_base gdebug;
555typedef struct gimple_statement_base ggoto;
514typedef struct gimple_statement_phi gphi; 556typedef struct gimple_statement_phi gphi;
515typedef struct gimple_statement_base greturn; 557typedef struct gimple_statement_base greturn;
516 558
@@ -564,6 +606,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
564 return stmt; 606 return stmt;
565} 607}
566 608
609static inline ggoto *as_a_ggoto(gimple stmt)
610{
611 return stmt;
612}
613
614static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
615{
616 return stmt;
617}
618
567static inline gphi *as_a_gphi(gimple stmt) 619static inline gphi *as_a_gphi(gimple stmt)
568{ 620{
569 return as_a<gphi>(stmt); 621 return as_a<gphi>(stmt);
@@ -611,6 +663,11 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
611 663
612#define INSN_DELETED_P(insn) (insn)->deleted() 664#define INSN_DELETED_P(insn) (insn)->deleted()
613 665
666static inline const char *get_decl_section_name(const_tree decl)
667{
668 return DECL_SECTION_NAME(decl);
669}
670
614/* symtab/cgraph related */ 671/* symtab/cgraph related */
615#define debug_cgraph_node(node) (node)->debug() 672#define debug_cgraph_node(node) (node)->debug()
616#define cgraph_get_node(decl) cgraph_node::get(decl) 673#define cgraph_get_node(decl) cgraph_node::get(decl)
@@ -619,6 +676,7 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
619#define cgraph_n_nodes symtab->cgraph_count 676#define cgraph_n_nodes symtab->cgraph_count
620#define cgraph_max_uid symtab->cgraph_max_uid 677#define cgraph_max_uid symtab->cgraph_max_uid
621#define varpool_get_node(decl) varpool_node::get(decl) 678#define varpool_get_node(decl) varpool_node::get(decl)
679#define dump_varpool_node(file, node) (node)->dump(file)
622 680
623#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ 681#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
624 (caller)->create_edge((callee), (call_stmt), (count), (freq)) 682 (caller)->create_edge((callee), (call_stmt), (count), (freq))
@@ -674,6 +732,11 @@ static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
674 return node->get_alias_target(); 732 return node->get_alias_target();
675} 733}
676 734
735static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
736{
737 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
738}
739
677static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) 740static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
678{ 741{
679 return symtab->add_cgraph_insertion_hook(hook, data); 742 return symtab->add_cgraph_insertion_hook(hook, data);
@@ -731,6 +794,13 @@ static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree l
731 794
732template <> 795template <>
733template <> 796template <>
797inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
798{
799 return gs->code == GIMPLE_GOTO;
800}
801
802template <>
803template <>
734inline bool is_a_helper<const greturn *>::test(const_gimple gs) 804inline bool is_a_helper<const greturn *>::test(const_gimple gs)
735{ 805{
736 return gs->code == GIMPLE_RETURN; 806 return gs->code == GIMPLE_RETURN;
@@ -766,6 +836,16 @@ static inline const gcall *as_a_const_gcall(const_gimple stmt)
766 return as_a<const gcall *>(stmt); 836 return as_a<const gcall *>(stmt);
767} 837}
768 838
839static inline ggoto *as_a_ggoto(gimple stmt)
840{
841 return as_a<ggoto *>(stmt);
842}
843
844static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
845{
846 return as_a<const ggoto *>(stmt);
847}
848
769static inline gphi *as_a_gphi(gimple stmt) 849static inline gphi *as_a_gphi(gimple stmt)
770{ 850{
771 return as_a<gphi *>(stmt); 851 return as_a<gphi *>(stmt);
@@ -828,4 +908,9 @@ static inline void debug_gimple_stmt(const_gimple s)
828#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) 908#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
829#endif 909#endif
830 910
911#if BUILDING_GCC_VERSION >= 7000
912#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
913 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
914#endif
915
831#endif 916#endif
diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c
index 12541126575b..8ff203ad4809 100644
--- a/scripts/gcc-plugins/latent_entropy_plugin.c
+++ b/scripts/gcc-plugins/latent_entropy_plugin.c
@@ -328,9 +328,9 @@ static enum tree_code get_op(tree *rhs)
328 op = LROTATE_EXPR; 328 op = LROTATE_EXPR;
329 /* 329 /*
330 * This code limits the value of random_const to 330 * This code limits the value of random_const to
331 * the size of a wide int for the rotation 331 * the size of a long for the rotation
332 */ 332 */
333 random_const &= HOST_BITS_PER_WIDE_INT - 1; 333 random_const %= TYPE_PRECISION(long_unsigned_type_node);
334 break; 334 break;
335 } 335 }
336 336
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c
index ee47924aef0d..827161bc269c 100644
--- a/sound/firewire/fireworks/fireworks_stream.c
+++ b/sound/firewire/fireworks/fireworks_stream.c
@@ -117,7 +117,7 @@ destroy_stream(struct snd_efw *efw, struct amdtp_stream *stream)
117 conn = &efw->in_conn; 117 conn = &efw->in_conn;
118 118
119 amdtp_stream_destroy(stream); 119 amdtp_stream_destroy(stream);
120 cmp_connection_destroy(&efw->out_conn); 120 cmp_connection_destroy(conn);
121} 121}
122 122
123static int 123static int
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
index 4ad3bd7fd445..f1657a4e0621 100644
--- a/sound/firewire/tascam/tascam-stream.c
+++ b/sound/firewire/tascam/tascam-stream.c
@@ -343,7 +343,7 @@ int snd_tscm_stream_init_duplex(struct snd_tscm *tscm)
343 if (err < 0) 343 if (err < 0)
344 amdtp_stream_destroy(&tscm->rx_stream); 344 amdtp_stream_destroy(&tscm->rx_stream);
345 345
346 return 0; 346 return err;
347} 347}
348 348
349/* At bus reset, streaming is stopped and some registers are clear. */ 349/* At bus reset, streaming is stopped and some registers are clear. */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 9448daff9d8b..7d660ee1d5e8 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2230,6 +2230,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2230 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), 2230 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2231 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), 2231 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2232 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), 2232 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2233 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2233 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), 2234 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2234 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), 2235 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2235 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), 2236 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
@@ -6983,6 +6984,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6983 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16), 6984 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6984 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51), 6985 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
6985 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51), 6986 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
6987 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
6986 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16), 6988 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
6987 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 6989 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
6988 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 6990 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index efe3a44658d5..4576f987a4a5 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -561,9 +561,9 @@ static void nau8825_xtalk_prepare(struct nau8825 *nau8825)
561 nau8825_xtalk_backup(nau8825); 561 nau8825_xtalk_backup(nau8825);
562 /* Config IIS as master to output signal by codec */ 562 /* Config IIS as master to output signal by codec */
563 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 563 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
564 NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK | 564 NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
565 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER | 565 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER |
566 (0x2 << NAU8825_I2S_DRV_SFT) | 0x1); 566 (0x2 << NAU8825_I2S_LRC_DIV_SFT) | 0x1);
567 /* Ramp up headphone volume to 0dB to get better performance and 567 /* Ramp up headphone volume to 0dB to get better performance and
568 * avoid pop noise in headphone. 568 * avoid pop noise in headphone.
569 */ 569 */
@@ -657,7 +657,7 @@ static void nau8825_xtalk_clean(struct nau8825 *nau8825)
657 NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN); 657 NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN);
658 /* Recover default value for IIS */ 658 /* Recover default value for IIS */
659 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 659 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
660 NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK | 660 NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
661 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE); 661 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE);
662 /* Restore value of specific register for cross talk */ 662 /* Restore value of specific register for cross talk */
663 nau8825_xtalk_restore(nau8825); 663 nau8825_xtalk_restore(nau8825);
@@ -2006,7 +2006,8 @@ static void nau8825_fll_apply(struct nau8825 *nau8825,
2006 NAU8825_FLL_INTEGER_MASK, fll_param->fll_int); 2006 NAU8825_FLL_INTEGER_MASK, fll_param->fll_int);
2007 /* FLL pre-scaler */ 2007 /* FLL pre-scaler */
2008 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4, 2008 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4,
2009 NAU8825_FLL_REF_DIV_MASK, fll_param->clk_ref_div); 2009 NAU8825_FLL_REF_DIV_MASK,
2010 fll_param->clk_ref_div << NAU8825_FLL_REF_DIV_SFT);
2010 /* select divided VCO input */ 2011 /* select divided VCO input */
2011 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5, 2012 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,
2012 NAU8825_FLL_CLK_SW_MASK, NAU8825_FLL_CLK_SW_REF); 2013 NAU8825_FLL_CLK_SW_MASK, NAU8825_FLL_CLK_SW_REF);
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 5d1704e73241..514fd13c2f46 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -137,7 +137,8 @@
137#define NAU8825_FLL_CLK_SRC_FS (0x3 << NAU8825_FLL_CLK_SRC_SFT) 137#define NAU8825_FLL_CLK_SRC_FS (0x3 << NAU8825_FLL_CLK_SRC_SFT)
138 138
139/* FLL4 (0x07) */ 139/* FLL4 (0x07) */
140#define NAU8825_FLL_REF_DIV_MASK (0x3 << 10) 140#define NAU8825_FLL_REF_DIV_SFT 10
141#define NAU8825_FLL_REF_DIV_MASK (0x3 << NAU8825_FLL_REF_DIV_SFT)
141 142
142/* FLL5 (0x08) */ 143/* FLL5 (0x08) */
143#define NAU8825_FLL_PDB_DAC_EN (0x1 << 15) 144#define NAU8825_FLL_PDB_DAC_EN (0x1 << 15)
@@ -247,8 +248,8 @@
247 248
248/* I2S_PCM_CTRL2 (0x1d) */ 249/* I2S_PCM_CTRL2 (0x1d) */
249#define NAU8825_I2S_TRISTATE (1 << 15) /* 0 - normal mode, 1 - Hi-Z output */ 250#define NAU8825_I2S_TRISTATE (1 << 15) /* 0 - normal mode, 1 - Hi-Z output */
250#define NAU8825_I2S_DRV_SFT 12 251#define NAU8825_I2S_LRC_DIV_SFT 12
251#define NAU8825_I2S_DRV_MASK (0x3 << NAU8825_I2S_DRV_SFT) 252#define NAU8825_I2S_LRC_DIV_MASK (0x3 << NAU8825_I2S_LRC_DIV_SFT)
252#define NAU8825_I2S_MS_SFT 3 253#define NAU8825_I2S_MS_SFT 3
253#define NAU8825_I2S_MS_MASK (1 << NAU8825_I2S_MS_SFT) 254#define NAU8825_I2S_MS_MASK (1 << NAU8825_I2S_MS_SFT)
254#define NAU8825_I2S_MS_MASTER (1 << NAU8825_I2S_MS_SFT) 255#define NAU8825_I2S_MS_MASTER (1 << NAU8825_I2S_MS_SFT)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 10c2a564a715..1ac96ef9ee20 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3833,6 +3833,9 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3833 } 3833 }
3834 } 3834 }
3835 3835
3836 regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
3837 RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
3838
3836 if (rt5645->pdata.jd_invert) { 3839 if (rt5645->pdata.jd_invert) {
3837 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, 3840 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
3838 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); 3841 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 8877b74b0510..bb94d50052d7 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -126,6 +126,16 @@ static const struct reg_default aic3x_reg[] = {
126 { 108, 0x00 }, { 109, 0x00 }, 126 { 108, 0x00 }, { 109, 0x00 },
127}; 127};
128 128
129static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
130{
131 switch (reg) {
132 case AIC3X_RESET:
133 return true;
134 default:
135 return false;
136 }
137}
138
129static const struct regmap_config aic3x_regmap = { 139static const struct regmap_config aic3x_regmap = {
130 .reg_bits = 8, 140 .reg_bits = 8,
131 .val_bits = 8, 141 .val_bits = 8,
@@ -133,6 +143,9 @@ static const struct regmap_config aic3x_regmap = {
133 .max_register = DAC_ICC_ADJ, 143 .max_register = DAC_ICC_ADJ,
134 .reg_defaults = aic3x_reg, 144 .reg_defaults = aic3x_reg,
135 .num_reg_defaults = ARRAY_SIZE(aic3x_reg), 145 .num_reg_defaults = ARRAY_SIZE(aic3x_reg),
146
147 .volatile_reg = aic3x_volatile_reg,
148
136 .cache_type = REGCACHE_RBTREE, 149 .cache_type = REGCACHE_RBTREE,
137}; 150};
138 151
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 593b7d1aed46..d72ccef9e238 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1551,7 +1551,7 @@ static int wm_adsp_load(struct wm_adsp *dsp)
1551 const struct wmfw_region *region; 1551 const struct wmfw_region *region;
1552 const struct wm_adsp_region *mem; 1552 const struct wm_adsp_region *mem;
1553 const char *region_name; 1553 const char *region_name;
1554 char *file, *text; 1554 char *file, *text = NULL;
1555 struct wm_adsp_buf *buf; 1555 struct wm_adsp_buf *buf;
1556 unsigned int reg; 1556 unsigned int reg;
1557 int regions = 0; 1557 int regions = 0;
@@ -1700,10 +1700,21 @@ static int wm_adsp_load(struct wm_adsp *dsp)
1700 regions, le32_to_cpu(region->len), offset, 1700 regions, le32_to_cpu(region->len), offset,
1701 region_name); 1701 region_name);
1702 1702
1703 if ((pos + le32_to_cpu(region->len) + sizeof(*region)) >
1704 firmware->size) {
1705 adsp_err(dsp,
1706 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
1707 file, regions, region_name,
1708 le32_to_cpu(region->len), firmware->size);
1709 ret = -EINVAL;
1710 goto out_fw;
1711 }
1712
1703 if (text) { 1713 if (text) {
1704 memcpy(text, region->data, le32_to_cpu(region->len)); 1714 memcpy(text, region->data, le32_to_cpu(region->len));
1705 adsp_info(dsp, "%s: %s\n", file, text); 1715 adsp_info(dsp, "%s: %s\n", file, text);
1706 kfree(text); 1716 kfree(text);
1717 text = NULL;
1707 } 1718 }
1708 1719
1709 if (reg) { 1720 if (reg) {
@@ -1748,6 +1759,7 @@ out_fw:
1748 regmap_async_complete(regmap); 1759 regmap_async_complete(regmap);
1749 wm_adsp_buf_free(&buf_list); 1760 wm_adsp_buf_free(&buf_list);
1750 release_firmware(firmware); 1761 release_firmware(firmware);
1762 kfree(text);
1751out: 1763out:
1752 kfree(file); 1764 kfree(file);
1753 1765
@@ -2233,6 +2245,17 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
2233 } 2245 }
2234 2246
2235 if (reg) { 2247 if (reg) {
2248 if ((pos + le32_to_cpu(blk->len) + sizeof(*blk)) >
2249 firmware->size) {
2250 adsp_err(dsp,
2251 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
2252 file, blocks, region_name,
2253 le32_to_cpu(blk->len),
2254 firmware->size);
2255 ret = -EINVAL;
2256 goto out_fw;
2257 }
2258
2236 buf = wm_adsp_buf_alloc(blk->data, 2259 buf = wm_adsp_buf_alloc(blk->data,
2237 le32_to_cpu(blk->len), 2260 le32_to_cpu(blk->len),
2238 &buf_list); 2261 &buf_list);
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 2998954a1c74..bdf8398cbc81 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -681,22 +681,19 @@ static int dw_i2s_probe(struct platform_device *pdev)
681 } 681 }
682 682
683 if (!pdata) { 683 if (!pdata) {
684 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 684 if (irq >= 0) {
685 if (ret == -EPROBE_DEFER) {
686 dev_err(&pdev->dev,
687 "failed to register PCM, deferring probe\n");
688 return ret;
689 } else if (ret) {
690 dev_err(&pdev->dev,
691 "Could not register DMA PCM: %d\n"
692 "falling back to PIO mode\n", ret);
693 ret = dw_pcm_register(pdev); 685 ret = dw_pcm_register(pdev);
694 if (ret) { 686 dev->use_pio = true;
695 dev_err(&pdev->dev, 687 } else {
696 "Could not register PIO PCM: %d\n", 688 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
689 0);
690 dev->use_pio = false;
691 }
692
693 if (ret) {
694 dev_err(&pdev->dev, "could not register pcm: %d\n",
697 ret); 695 ret);
698 goto err_clk_disable; 696 goto err_clk_disable;
699 }
700 } 697 }
701 } 698 }
702 699
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 50349437d961..fde08660b63b 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -224,6 +224,12 @@ struct fsl_ssi_soc_data {
224 * @dbg_stats: Debugging statistics 224 * @dbg_stats: Debugging statistics
225 * 225 *
226 * @soc: SoC specific data 226 * @soc: SoC specific data
227 *
228 * @fifo_watermark: the FIFO watermark setting. Notifies DMA when
229 * there are @fifo_watermark or fewer words in TX fifo or
230 * @fifo_watermark or more empty words in RX fifo.
231 * @dma_maxburst: max number of words to transfer in one go. So far,
232 * this is always the same as fifo_watermark.
227 */ 233 */
228struct fsl_ssi_private { 234struct fsl_ssi_private {
229 struct regmap *regs; 235 struct regmap *regs;
@@ -263,6 +269,9 @@ struct fsl_ssi_private {
263 269
264 const struct fsl_ssi_soc_data *soc; 270 const struct fsl_ssi_soc_data *soc;
265 struct device *dev; 271 struct device *dev;
272
273 u32 fifo_watermark;
274 u32 dma_maxburst;
266}; 275};
267 276
268/* 277/*
@@ -1051,21 +1060,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
1051 regmap_write(regs, CCSR_SSI_SRCR, srcr); 1060 regmap_write(regs, CCSR_SSI_SRCR, srcr);
1052 regmap_write(regs, CCSR_SSI_SCR, scr); 1061 regmap_write(regs, CCSR_SSI_SCR, scr);
1053 1062
1054 /* 1063 wm = ssi_private->fifo_watermark;
1055 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
1056 * use FIFO 1. We program the transmit water to signal a DMA transfer
1057 * if there are only two (or fewer) elements left in the FIFO. Two
1058 * elements equals one frame (left channel, right channel). This value,
1059 * however, depends on the depth of the transmit buffer.
1060 *
1061 * We set the watermark on the same level as the DMA burstsize. For
1062 * fiq it is probably better to use the biggest possible watermark
1063 * size.
1064 */
1065 if (ssi_private->use_dma)
1066 wm = ssi_private->fifo_depth - 2;
1067 else
1068 wm = ssi_private->fifo_depth;
1069 1064
1070 regmap_write(regs, CCSR_SSI_SFCSR, 1065 regmap_write(regs, CCSR_SSI_SFCSR,
1071 CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | 1066 CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
@@ -1373,12 +1368,8 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
1373 dev_dbg(&pdev->dev, "could not get baud clock: %ld\n", 1368 dev_dbg(&pdev->dev, "could not get baud clock: %ld\n",
1374 PTR_ERR(ssi_private->baudclk)); 1369 PTR_ERR(ssi_private->baudclk));
1375 1370
1376 /* 1371 ssi_private->dma_params_tx.maxburst = ssi_private->dma_maxburst;
1377 * We have burstsize be "fifo_depth - 2" to match the SSI 1372 ssi_private->dma_params_rx.maxburst = ssi_private->dma_maxburst;
1378 * watermark setting in fsl_ssi_startup().
1379 */
1380 ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2;
1381 ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2;
1382 ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0; 1373 ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0;
1383 ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0; 1374 ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0;
1384 1375
@@ -1543,6 +1534,47 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1543 /* Older 8610 DTs didn't have the fifo-depth property */ 1534 /* Older 8610 DTs didn't have the fifo-depth property */
1544 ssi_private->fifo_depth = 8; 1535 ssi_private->fifo_depth = 8;
1545 1536
1537 /*
1538 * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
1539 * use FIFO 1 but set the watermark appropriately nontheless.
1540 * We program the transmit water to signal a DMA transfer
1541 * if there are N elements left in the FIFO. For chips with 15-deep
1542 * FIFOs, set watermark to 8. This allows the SSI to operate at a
1543 * high data rate without channel slipping. Behavior is unchanged
1544 * for the older chips with a fifo depth of only 8. A value of 4
1545 * might be appropriate for the older chips, but is left at
1546 * fifo_depth-2 until sombody has a chance to test.
1547 *
1548 * We set the watermark on the same level as the DMA burstsize. For
1549 * fiq it is probably better to use the biggest possible watermark
1550 * size.
1551 */
1552 switch (ssi_private->fifo_depth) {
1553 case 15:
1554 /*
1555 * 2 samples is not enough when running at high data
1556 * rates (like 48kHz @ 16 bits/channel, 16 channels)
1557 * 8 seems to split things evenly and leave enough time
1558 * for the DMA to fill the FIFO before it's over/under
1559 * run.
1560 */
1561 ssi_private->fifo_watermark = 8;
1562 ssi_private->dma_maxburst = 8;
1563 break;
1564 case 8:
1565 default:
1566 /*
1567 * maintain old behavior for older chips.
1568 * Keeping it the same because I don't have an older
1569 * board to test with.
1570 * I suspect this could be changed to be something to
1571 * leave some more space in the fifo.
1572 */
1573 ssi_private->fifo_watermark = ssi_private->fifo_depth - 2;
1574 ssi_private->dma_maxburst = ssi_private->fifo_depth - 2;
1575 break;
1576 }
1577
1546 dev_set_drvdata(&pdev->dev, ssi_private); 1578 dev_set_drvdata(&pdev->dev, ssi_private);
1547 1579
1548 if (ssi_private->soc->imx) { 1580 if (ssi_private->soc->imx) {
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 507a86a5eafe..8d2fb2d6f532 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -142,7 +142,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
142 * for Jack detection and button press 142 * for Jack detection and button press
143 */ 143 */
144 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK, 144 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK,
145 0, 145 48000 * 512,
146 SND_SOC_CLOCK_IN); 146 SND_SOC_CLOCK_IN);
147 if (!ret) { 147 if (!ret) {
148 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk) 148 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk)
@@ -825,10 +825,20 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
825 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && (is_valleyview())) { 825 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && (is_valleyview())) {
826 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 826 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
827 if (IS_ERR(priv->mclk)) { 827 if (IS_ERR(priv->mclk)) {
828 ret_val = PTR_ERR(priv->mclk);
829
828 dev_err(&pdev->dev, 830 dev_err(&pdev->dev,
829 "Failed to get MCLK from pmc_plt_clk_3: %ld\n", 831 "Failed to get MCLK from pmc_plt_clk_3: %d\n",
830 PTR_ERR(priv->mclk)); 832 ret_val);
831 return PTR_ERR(priv->mclk); 833
834 /*
835 * Fall back to bit clock usage for -ENOENT (clock not
836 * available likely due to missing dependencies), bail
837 * for all other errors, including -EPROBE_DEFER
838 */
839 if (ret_val != -ENOENT)
840 return ret_val;
841 byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
832 } 842 }
833 } 843 }
834 844
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 84b5101e6ca6..6c6b63a6b338 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -180,6 +180,9 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
180 snd_pcm_set_sync(substream); 180 snd_pcm_set_sync(substream);
181 181
182 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream); 182 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
183 if (!mconfig)
184 return -EINVAL;
185
183 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps); 186 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
184 187
185 return 0; 188 return 0;
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 8fc3178bc79c..b30bd384c8d3 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -515,6 +515,9 @@ EXPORT_SYMBOL_GPL(skl_sst_init_fw);
515 515
516void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) 516void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
517{ 517{
518
519 if (ctx->dsp->fw)
520 release_firmware(ctx->dsp->fw);
518 skl_clear_module_table(ctx->dsp); 521 skl_clear_module_table(ctx->dsp);
519 skl_freeup_uuid_list(ctx); 522 skl_freeup_uuid_list(ctx);
520 skl_ipc_free(&ctx->ipc); 523 skl_ipc_free(&ctx->ipc);
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 4bd68de76130..99b5b0835c1e 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1030,10 +1030,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
1030 return -ENOMEM; 1030 return -ENOMEM;
1031 1031
1032 ret = snd_ctl_add(card, kctrl); 1032 ret = snd_ctl_add(card, kctrl);
1033 if (ret < 0) { 1033 if (ret < 0)
1034 snd_ctl_free_one(kctrl);
1035 return ret; 1034 return ret;
1036 }
1037 1035
1038 cfg->update = update; 1036 cfg->update = update;
1039 cfg->card = card; 1037 cfg->card = card;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f1901bb1466e..baa1afa41e3d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1748,6 +1748,7 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1748 1748
1749 component->init = aux_dev->init; 1749 component->init = aux_dev->init;
1750 component->auxiliary = 1; 1750 component->auxiliary = 1;
1751 list_add(&component->card_aux_list, &card->aux_comp_list);
1751 1752
1752 return 0; 1753 return 0;
1753 1754
@@ -1758,16 +1759,14 @@ err_defer:
1758 1759
1759static int soc_probe_aux_devices(struct snd_soc_card *card) 1760static int soc_probe_aux_devices(struct snd_soc_card *card)
1760{ 1761{
1761 struct snd_soc_component *comp; 1762 struct snd_soc_component *comp, *tmp;
1762 int order; 1763 int order;
1763 int ret; 1764 int ret;
1764 1765
1765 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 1766 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1766 order++) { 1767 order++) {
1767 list_for_each_entry(comp, &card->component_dev_list, card_list) { 1768 list_for_each_entry_safe(comp, tmp, &card->aux_comp_list,
1768 if (!comp->auxiliary) 1769 card_aux_list) {
1769 continue;
1770
1771 if (comp->driver->probe_order == order) { 1770 if (comp->driver->probe_order == order) {
1772 ret = soc_probe_component(card, comp); 1771 ret = soc_probe_component(card, comp);
1773 if (ret < 0) { 1772 if (ret < 0) {
@@ -1776,6 +1775,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)
1776 comp->name, ret); 1775 comp->name, ret);
1777 return ret; 1776 return ret;
1778 } 1777 }
1778 list_del(&comp->card_aux_list);
1779 } 1779 }
1780 } 1780 }
1781 } 1781 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e7a1eaa2772f..6aba14009c92 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2184,9 +2184,11 @@ static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
2184 break; 2184 break;
2185 case SNDRV_PCM_TRIGGER_STOP: 2185 case SNDRV_PCM_TRIGGER_STOP:
2186 case SNDRV_PCM_TRIGGER_SUSPEND: 2186 case SNDRV_PCM_TRIGGER_SUSPEND:
2187 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2188 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; 2187 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
2189 break; 2188 break;
2189 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2190 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
2191 break;
2190 } 2192 }
2191 2193
2192out: 2194out:
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 65670b2b408c..fbfb1fab88d5 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -514,13 +514,12 @@ static void remove_widget(struct snd_soc_component *comp,
514 == SND_SOC_TPLG_TYPE_MIXER) 514 == SND_SOC_TPLG_TYPE_MIXER)
515 kfree(kcontrol->tlv.p); 515 kfree(kcontrol->tlv.p);
516 516
517 snd_ctl_remove(card, kcontrol);
518
519 /* Private value is used as struct soc_mixer_control 517 /* Private value is used as struct soc_mixer_control
520 * for volume mixers or soc_bytes_ext for bytes 518 * for volume mixers or soc_bytes_ext for bytes
521 * controls. 519 * controls.
522 */ 520 */
523 kfree((void *)kcontrol->private_value); 521 kfree((void *)kcontrol->private_value);
522 snd_ctl_remove(card, kcontrol);
524 } 523 }
525 kfree(w->kcontrol_news); 524 kfree(w->kcontrol_news);
526 } 525 }
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 15d1d5c63c3c..c90607ebe155 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -384,6 +384,9 @@ static void snd_complete_urb(struct urb *urb)
384 if (unlikely(atomic_read(&ep->chip->shutdown))) 384 if (unlikely(atomic_read(&ep->chip->shutdown)))
385 goto exit_clear; 385 goto exit_clear;
386 386
387 if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags)))
388 goto exit_clear;
389
387 if (usb_pipeout(ep->pipe)) { 390 if (usb_pipeout(ep->pipe)) {
388 retire_outbound_urb(ep, ctx); 391 retire_outbound_urb(ep, ctx);
389 /* can be stopped during retire callback */ 392 /* can be stopped during retire callback */
@@ -534,6 +537,11 @@ static int wait_clear_urbs(struct snd_usb_endpoint *ep)
534 alive, ep->ep_num); 537 alive, ep->ep_num);
535 clear_bit(EP_FLAG_STOPPING, &ep->flags); 538 clear_bit(EP_FLAG_STOPPING, &ep->flags);
536 539
540 ep->data_subs = NULL;
541 ep->sync_slave = NULL;
542 ep->retire_data_urb = NULL;
543 ep->prepare_data_urb = NULL;
544
537 return 0; 545 return 0;
538} 546}
539 547
@@ -912,9 +920,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
912/** 920/**
913 * snd_usb_endpoint_start: start an snd_usb_endpoint 921 * snd_usb_endpoint_start: start an snd_usb_endpoint
914 * 922 *
915 * @ep: the endpoint to start 923 * @ep: the endpoint to start
916 * @can_sleep: flag indicating whether the operation is executed in
917 * non-atomic context
918 * 924 *
919 * A call to this function will increment the use count of the endpoint. 925 * A call to this function will increment the use count of the endpoint.
920 * In case it is not already running, the URBs for this endpoint will be 926 * In case it is not already running, the URBs for this endpoint will be
@@ -924,7 +930,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
924 * 930 *
925 * Returns an error if the URB submission failed, 0 in all other cases. 931 * Returns an error if the URB submission failed, 0 in all other cases.
926 */ 932 */
927int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) 933int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
928{ 934{
929 int err; 935 int err;
930 unsigned int i; 936 unsigned int i;
@@ -938,8 +944,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
938 944
939 /* just to be sure */ 945 /* just to be sure */
940 deactivate_urbs(ep, false); 946 deactivate_urbs(ep, false);
941 if (can_sleep)
942 wait_clear_urbs(ep);
943 947
944 ep->active_mask = 0; 948 ep->active_mask = 0;
945 ep->unlink_mask = 0; 949 ep->unlink_mask = 0;
@@ -1020,10 +1024,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep)
1020 1024
1021 if (--ep->use_count == 0) { 1025 if (--ep->use_count == 0) {
1022 deactivate_urbs(ep, false); 1026 deactivate_urbs(ep, false);
1023 ep->data_subs = NULL;
1024 ep->sync_slave = NULL;
1025 ep->retire_data_urb = NULL;
1026 ep->prepare_data_urb = NULL;
1027 set_bit(EP_FLAG_STOPPING, &ep->flags); 1027 set_bit(EP_FLAG_STOPPING, &ep->flags);
1028 } 1028 }
1029} 1029}
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h
index 6428392d8f62..584f295d7c77 100644
--- a/sound/usb/endpoint.h
+++ b/sound/usb/endpoint.h
@@ -18,7 +18,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
18 struct audioformat *fmt, 18 struct audioformat *fmt,
19 struct snd_usb_endpoint *sync_ep); 19 struct snd_usb_endpoint *sync_ep);
20 20
21int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep); 21int snd_usb_endpoint_start(struct snd_usb_endpoint *ep);
22void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep); 22void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
23void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); 23void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
24int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); 24int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 34c6d4f2c0b6..9aa5b1855481 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -218,7 +218,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
218 } 218 }
219} 219}
220 220
221static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) 221static int start_endpoints(struct snd_usb_substream *subs)
222{ 222{
223 int err; 223 int err;
224 224
@@ -231,7 +231,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
231 dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep); 231 dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep);
232 232
233 ep->data_subs = subs; 233 ep->data_subs = subs;
234 err = snd_usb_endpoint_start(ep, can_sleep); 234 err = snd_usb_endpoint_start(ep);
235 if (err < 0) { 235 if (err < 0) {
236 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); 236 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags);
237 return err; 237 return err;
@@ -260,7 +260,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
260 dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep); 260 dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
261 261
262 ep->sync_slave = subs->data_endpoint; 262 ep->sync_slave = subs->data_endpoint;
263 err = snd_usb_endpoint_start(ep, can_sleep); 263 err = snd_usb_endpoint_start(ep);
264 if (err < 0) { 264 if (err < 0) {
265 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); 265 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
266 return err; 266 return err;
@@ -850,7 +850,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
850 /* for playback, submit the URBs now; otherwise, the first hwptr_done 850 /* for playback, submit the URBs now; otherwise, the first hwptr_done
851 * updates for all URBs would happen at the same time when starting */ 851 * updates for all URBs would happen at the same time when starting */
852 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) 852 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
853 ret = start_endpoints(subs, true); 853 ret = start_endpoints(subs);
854 854
855 unlock: 855 unlock:
856 snd_usb_unlock_shutdown(subs->stream->chip); 856 snd_usb_unlock_shutdown(subs->stream->chip);
@@ -1666,7 +1666,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
1666 1666
1667 switch (cmd) { 1667 switch (cmd) {
1668 case SNDRV_PCM_TRIGGER_START: 1668 case SNDRV_PCM_TRIGGER_START:
1669 err = start_endpoints(subs, false); 1669 err = start_endpoints(subs);
1670 if (err < 0) 1670 if (err < 0)
1671 return err; 1671 return err;
1672 1672
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index b3fd2382fdd9..eb4b9f7a571e 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1135,6 +1135,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1135 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */ 1135 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
1136 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */ 1136 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
1137 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ 1137 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
1138 case USB_ID(0x047F, 0x02F7): /* Plantronics BT-600 */
1138 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */ 1139 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */
1139 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */ 1140 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
1140 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ 1141 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 3284bb14ae78..8aad81151d50 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -213,6 +213,9 @@ static int get_value(struct parse_opt_ctx_t *p,
213 else 213 else
214 err = get_arg(p, opt, flags, (const char **)opt->value); 214 err = get_arg(p, opt, flags, (const char **)opt->value);
215 215
216 if (opt->set)
217 *(bool *)opt->set = true;
218
216 /* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */ 219 /* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */
217 if (opt->flags & PARSE_OPT_NOEMPTY) { 220 if (opt->flags & PARSE_OPT_NOEMPTY) {
218 const char *val = *(const char **)opt->value; 221 const char *val = *(const char **)opt->value;
diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 8866ac438b34..11c3be3bcce7 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -137,6 +137,11 @@ struct option {
137 { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \ 137 { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
138 .value = check_vtype(v, const char **), (a), .help = (h), \ 138 .value = check_vtype(v, const char **), (a), .help = (h), \
139 .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) } 139 .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
140#define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
141 { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
142 .value = check_vtype(v, const char **), (a), .help = (h), \
143 .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
144 .set = check_vtype(os, bool *)}
140#define OPT_STRING_NOEMPTY(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h), .flags = PARSE_OPT_NOEMPTY} 145#define OPT_STRING_NOEMPTY(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
141#define OPT_DATE(s, l, v, h) \ 146#define OPT_DATE(s, l, v, h) \
142 { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } 147 { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
index f1ce60065258..ec30c2fcbac0 100644
--- a/tools/lib/traceevent/plugin_sched_switch.c
+++ b/tools/lib/traceevent/plugin_sched_switch.c
@@ -111,7 +111,7 @@ static int sched_switch_handler(struct trace_seq *s,
111 trace_seq_printf(s, "%lld ", val); 111 trace_seq_printf(s, "%lld ", val);
112 112
113 if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0) 113 if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
114 trace_seq_printf(s, "[%lld] ", val); 114 trace_seq_printf(s, "[%d] ", (int) val);
115 115
116 if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0) 116 if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
117 write_state(s, val); 117 write_state(s, val);
@@ -129,7 +129,7 @@ static int sched_switch_handler(struct trace_seq *s,
129 trace_seq_printf(s, "%lld", val); 129 trace_seq_printf(s, "%lld", val);
130 130
131 if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0) 131 if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
132 trace_seq_printf(s, " [%lld]", val); 132 trace_seq_printf(s, " [%d]", (int) val);
133 133
134 return 0; 134 return 0;
135} 135}
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 27fc3617c6a4..5054d9147f0f 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -430,6 +430,10 @@ that gets then processed, possibly via a perf script, to decide if that
430particular perf.data snapshot should be kept or not. 430particular perf.data snapshot should be kept or not.
431 431
432Implies --timestamp-filename, --no-buildid and --no-buildid-cache. 432Implies --timestamp-filename, --no-buildid and --no-buildid-cache.
433The reason for the latter two is to reduce the data file switching
434overhead. You can still switch them on with:
435
436 --switch-output --no-no-buildid --no-no-buildid-cache
433 437
434--dry-run:: 438--dry-run::
435Parse options then exit. --dry-run can be used to detect errors in cmdline 439Parse options then exit. --dry-run can be used to detect errors in cmdline
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 8fc24824705e..8bb16aa9d661 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -704,9 +704,9 @@ install-tests: all install-gtk
704 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \ 704 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
705 $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' 705 $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
706 706
707install-bin: install-tools install-tests 707install-bin: install-tools install-tests install-traceevent-plugins
708 708
709install: install-bin try-install-man install-traceevent-plugins 709install: install-bin try-install-man
710 710
711install-python_ext: 711install-python_ext:
712 $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' 712 $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 35a02f8e5a4a..915869e00d86 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -655,7 +655,6 @@ static const struct {
655 { "__GFP_RECLAIM", "R" }, 655 { "__GFP_RECLAIM", "R" },
656 { "__GFP_DIRECT_RECLAIM", "DR" }, 656 { "__GFP_DIRECT_RECLAIM", "DR" },
657 { "__GFP_KSWAPD_RECLAIM", "KR" }, 657 { "__GFP_KSWAPD_RECLAIM", "KR" },
658 { "__GFP_OTHER_NODE", "ON" },
659}; 658};
660 659
661static size_t max_gfp_len; 660static size_t max_gfp_len;
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 74d6a035133a..4ec10e9427d9 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1405,7 +1405,7 @@ static bool dry_run;
1405 * perf_evlist__prepare_workload, etc instead of fork+exec'in 'perf record', 1405 * perf_evlist__prepare_workload, etc instead of fork+exec'in 'perf record',
1406 * using pipes, etc. 1406 * using pipes, etc.
1407 */ 1407 */
1408struct option __record_options[] = { 1408static struct option __record_options[] = {
1409 OPT_CALLBACK('e', "event", &record.evlist, "event", 1409 OPT_CALLBACK('e', "event", &record.evlist, "event",
1410 "event selector. use 'perf list' to list available events", 1410 "event selector. use 'perf list' to list available events",
1411 parse_events_option), 1411 parse_events_option),
@@ -1636,7 +1636,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
1636 * overhead. Still generate buildid if they are required 1636 * overhead. Still generate buildid if they are required
1637 * explicitly using 1637 * explicitly using
1638 * 1638 *
1639 * perf record --signal-trigger --no-no-buildid \ 1639 * perf record --switch-output --no-no-buildid \
1640 * --no-no-buildid-cache 1640 * --no-no-buildid-cache
1641 * 1641 *
1642 * Following code equals to: 1642 * Following code equals to:
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index d53e706a6f17..5b134b0d1ff3 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -209,6 +209,7 @@ struct perf_sched {
209 u64 skipped_samples; 209 u64 skipped_samples;
210 const char *time_str; 210 const char *time_str;
211 struct perf_time_interval ptime; 211 struct perf_time_interval ptime;
212 struct perf_time_interval hist_time;
212}; 213};
213 214
214/* per thread run time data */ 215/* per thread run time data */
@@ -2460,6 +2461,11 @@ static int timehist_sched_change_event(struct perf_tool *tool,
2460 timehist_print_sample(sched, sample, &al, thread, t); 2461 timehist_print_sample(sched, sample, &al, thread, t);
2461 2462
2462out: 2463out:
2464 if (sched->hist_time.start == 0 && t >= ptime->start)
2465 sched->hist_time.start = t;
2466 if (ptime->end == 0 || t <= ptime->end)
2467 sched->hist_time.end = t;
2468
2463 if (tr) { 2469 if (tr) {
2464 /* time of this sched_switch event becomes last time task seen */ 2470 /* time of this sched_switch event becomes last time task seen */
2465 tr->last_time = sample->time; 2471 tr->last_time = sample->time;
@@ -2624,6 +2630,7 @@ static void timehist_print_summary(struct perf_sched *sched,
2624 struct thread *t; 2630 struct thread *t;
2625 struct thread_runtime *r; 2631 struct thread_runtime *r;
2626 int i; 2632 int i;
2633 u64 hist_time = sched->hist_time.end - sched->hist_time.start;
2627 2634
2628 memset(&totals, 0, sizeof(totals)); 2635 memset(&totals, 0, sizeof(totals));
2629 2636
@@ -2665,7 +2672,7 @@ static void timehist_print_summary(struct perf_sched *sched,
2665 totals.sched_count += r->run_stats.n; 2672 totals.sched_count += r->run_stats.n;
2666 printf(" CPU %2d idle for ", i); 2673 printf(" CPU %2d idle for ", i);
2667 print_sched_time(r->total_run_time, 6); 2674 print_sched_time(r->total_run_time, 6);
2668 printf(" msec\n"); 2675 printf(" msec (%6.2f%%)\n", 100.0 * r->total_run_time / hist_time);
2669 } else 2676 } else
2670 printf(" CPU %2d idle entire time window\n", i); 2677 printf(" CPU %2d idle entire time window\n", i);
2671 } 2678 }
@@ -2701,12 +2708,16 @@ static void timehist_print_summary(struct perf_sched *sched,
2701 2708
2702 printf("\n" 2709 printf("\n"
2703 " Total number of unique tasks: %" PRIu64 "\n" 2710 " Total number of unique tasks: %" PRIu64 "\n"
2704 "Total number of context switches: %" PRIu64 "\n" 2711 "Total number of context switches: %" PRIu64 "\n",
2705 " Total run time (msec): ",
2706 totals.task_count, totals.sched_count); 2712 totals.task_count, totals.sched_count);
2707 2713
2714 printf(" Total run time (msec): ");
2708 print_sched_time(totals.total_run_time, 2); 2715 print_sched_time(totals.total_run_time, 2);
2709 printf("\n"); 2716 printf("\n");
2717
2718 printf(" Total scheduling time (msec): ");
2719 print_sched_time(hist_time, 2);
2720 printf(" (x %d)\n", sched->max_cpu);
2710} 2721}
2711 2722
2712typedef int (*sched_handler)(struct perf_tool *tool, 2723typedef int (*sched_handler)(struct perf_tool *tool,
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d281ae2b54e8..6a6f44dd594b 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -163,7 +163,7 @@ static struct map *kernel_get_module_map(const char *module)
163 163
164 /* A file path -- this is an offline module */ 164 /* A file path -- this is an offline module */
165 if (module && strchr(module, '/')) 165 if (module && strchr(module, '/'))
166 return machine__findnew_module_map(host_machine, 0, module); 166 return dso__new_map(module);
167 167
168 if (!module) 168 if (!module)
169 module = "kernel"; 169 module = "kernel";
@@ -173,6 +173,7 @@ static struct map *kernel_get_module_map(const char *module)
173 if (strncmp(pos->dso->short_name + 1, module, 173 if (strncmp(pos->dso->short_name + 1, module,
174 pos->dso->short_name_len - 2) == 0 && 174 pos->dso->short_name_len - 2) == 0 &&
175 module[pos->dso->short_name_len - 2] == '\0') { 175 module[pos->dso->short_name_len - 2] == '\0') {
176 map__get(pos);
176 return pos; 177 return pos;
177 } 178 }
178 } 179 }
@@ -188,15 +189,6 @@ struct map *get_target_map(const char *target, bool user)
188 return kernel_get_module_map(target); 189 return kernel_get_module_map(target);
189} 190}
190 191
191static void put_target_map(struct map *map, bool user)
192{
193 if (map && user) {
194 /* Only the user map needs to be released */
195 map__put(map);
196 }
197}
198
199
200static int convert_exec_to_group(const char *exec, char **result) 192static int convert_exec_to_group(const char *exec, char **result)
201{ 193{
202 char *ptr1, *ptr2, *exec_copy; 194 char *ptr1, *ptr2, *exec_copy;
@@ -268,21 +260,6 @@ static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
268} 260}
269 261
270/* 262/*
271 * NOTE:
272 * '.gnu.linkonce.this_module' section of kernel module elf directly
273 * maps to 'struct module' from linux/module.h. This section contains
274 * actual module name which will be used by kernel after loading it.
275 * But, we cannot use 'struct module' here since linux/module.h is not
276 * exposed to user-space. Offset of 'name' has remained same from long
277 * time, so hardcoding it here.
278 */
279#ifdef __LP64__
280#define MOD_NAME_OFFSET 24
281#else
282#define MOD_NAME_OFFSET 12
283#endif
284
285/*
286 * @module can be module name of module file path. In case of path, 263 * @module can be module name of module file path. In case of path,
287 * inspect elf and find out what is actual module name. 264 * inspect elf and find out what is actual module name.
288 * Caller has to free mod_name after using it. 265 * Caller has to free mod_name after using it.
@@ -296,6 +273,7 @@ static char *find_module_name(const char *module)
296 Elf_Data *data; 273 Elf_Data *data;
297 Elf_Scn *sec; 274 Elf_Scn *sec;
298 char *mod_name = NULL; 275 char *mod_name = NULL;
276 int name_offset;
299 277
300 fd = open(module, O_RDONLY); 278 fd = open(module, O_RDONLY);
301 if (fd < 0) 279 if (fd < 0)
@@ -317,7 +295,21 @@ static char *find_module_name(const char *module)
317 if (!data || !data->d_buf) 295 if (!data || !data->d_buf)
318 goto ret_err; 296 goto ret_err;
319 297
320 mod_name = strdup((char *)data->d_buf + MOD_NAME_OFFSET); 298 /*
299 * NOTE:
300 * '.gnu.linkonce.this_module' section of kernel module elf directly
301 * maps to 'struct module' from linux/module.h. This section contains
302 * actual module name which will be used by kernel after loading it.
303 * But, we cannot use 'struct module' here since linux/module.h is not
304 * exposed to user-space. Offset of 'name' has remained same from long
305 * time, so hardcoding it here.
306 */
307 if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
308 name_offset = 12;
309 else /* expect ELFCLASS64 by default */
310 name_offset = 24;
311
312 mod_name = strdup((char *)data->d_buf + name_offset);
321 313
322ret_err: 314ret_err:
323 elf_end(elf); 315 elf_end(elf);
@@ -412,7 +404,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
412 } 404 }
413 405
414out: 406out:
415 put_target_map(map, uprobes); 407 map__put(map);
416 return ret; 408 return ret;
417 409
418} 410}
@@ -618,6 +610,67 @@ error:
618 return ret ? : -ENOENT; 610 return ret ? : -ENOENT;
619} 611}
620 612
613/* Adjust symbol name and address */
614static int post_process_probe_trace_point(struct probe_trace_point *tp,
615 struct map *map, unsigned long offs)
616{
617 struct symbol *sym;
618 u64 addr = tp->address + tp->offset - offs;
619
620 sym = map__find_symbol(map, addr);
621 if (!sym)
622 return -ENOENT;
623
624 if (strcmp(sym->name, tp->symbol)) {
625 /* If we have no realname, use symbol for it */
626 if (!tp->realname)
627 tp->realname = tp->symbol;
628 else
629 free(tp->symbol);
630 tp->symbol = strdup(sym->name);
631 if (!tp->symbol)
632 return -ENOMEM;
633 }
634 tp->offset = addr - sym->start;
635 tp->address -= offs;
636
637 return 0;
638}
639
640/*
641 * Rename DWARF symbols to ELF symbols -- gcc sometimes optimizes functions
642 * and generate new symbols with suffixes such as .constprop.N or .isra.N
643 * etc. Since those symbols are not recorded in DWARF, we have to find
644 * correct generated symbols from offline ELF binary.
645 * For online kernel or uprobes we don't need this because those are
646 * rebased on _text, or already a section relative address.
647 */
648static int
649post_process_offline_probe_trace_events(struct probe_trace_event *tevs,
650 int ntevs, const char *pathname)
651{
652 struct map *map;
653 unsigned long stext = 0;
654 int i, ret = 0;
655
656 /* Prepare a map for offline binary */
657 map = dso__new_map(pathname);
658 if (!map || get_text_start_address(pathname, &stext) < 0) {
659 pr_warning("Failed to get ELF symbols for %s\n", pathname);
660 return -EINVAL;
661 }
662
663 for (i = 0; i < ntevs; i++) {
664 ret = post_process_probe_trace_point(&tevs[i].point,
665 map, stext);
666 if (ret < 0)
667 break;
668 }
669 map__put(map);
670
671 return ret;
672}
673
621static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs, 674static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
622 int ntevs, const char *exec) 675 int ntevs, const char *exec)
623{ 676{
@@ -645,18 +698,31 @@ static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
645 return ret; 698 return ret;
646} 699}
647 700
648static int add_module_to_probe_trace_events(struct probe_trace_event *tevs, 701static int
649 int ntevs, const char *module) 702post_process_module_probe_trace_events(struct probe_trace_event *tevs,
703 int ntevs, const char *module,
704 struct debuginfo *dinfo)
650{ 705{
706 Dwarf_Addr text_offs = 0;
651 int i, ret = 0; 707 int i, ret = 0;
652 char *mod_name = NULL; 708 char *mod_name = NULL;
709 struct map *map;
653 710
654 if (!module) 711 if (!module)
655 return 0; 712 return 0;
656 713
657 mod_name = find_module_name(module); 714 map = get_target_map(module, false);
715 if (!map || debuginfo__get_text_offset(dinfo, &text_offs, true) < 0) {
716 pr_warning("Failed to get ELF symbols for %s\n", module);
717 return -EINVAL;
718 }
658 719
720 mod_name = find_module_name(module);
659 for (i = 0; i < ntevs; i++) { 721 for (i = 0; i < ntevs; i++) {
722 ret = post_process_probe_trace_point(&tevs[i].point,
723 map, (unsigned long)text_offs);
724 if (ret < 0)
725 break;
660 tevs[i].point.module = 726 tevs[i].point.module =
661 strdup(mod_name ? mod_name : module); 727 strdup(mod_name ? mod_name : module);
662 if (!tevs[i].point.module) { 728 if (!tevs[i].point.module) {
@@ -666,6 +732,8 @@ static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
666 } 732 }
667 733
668 free(mod_name); 734 free(mod_name);
735 map__put(map);
736
669 return ret; 737 return ret;
670} 738}
671 739
@@ -679,7 +747,8 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,
679 747
680 /* Skip post process if the target is an offline kernel */ 748 /* Skip post process if the target is an offline kernel */
681 if (symbol_conf.ignore_vmlinux_buildid) 749 if (symbol_conf.ignore_vmlinux_buildid)
682 return 0; 750 return post_process_offline_probe_trace_events(tevs, ntevs,
751 symbol_conf.vmlinux_name);
683 752
684 reloc_sym = kernel_get_ref_reloc_sym(); 753 reloc_sym = kernel_get_ref_reloc_sym();
685 if (!reloc_sym) { 754 if (!reloc_sym) {
@@ -722,7 +791,7 @@ arch__post_process_probe_trace_events(struct perf_probe_event *pev __maybe_unuse
722static int post_process_probe_trace_events(struct perf_probe_event *pev, 791static int post_process_probe_trace_events(struct perf_probe_event *pev,
723 struct probe_trace_event *tevs, 792 struct probe_trace_event *tevs,
724 int ntevs, const char *module, 793 int ntevs, const char *module,
725 bool uprobe) 794 bool uprobe, struct debuginfo *dinfo)
726{ 795{
727 int ret; 796 int ret;
728 797
@@ -730,7 +799,8 @@ static int post_process_probe_trace_events(struct perf_probe_event *pev,
730 ret = add_exec_to_probe_trace_events(tevs, ntevs, module); 799 ret = add_exec_to_probe_trace_events(tevs, ntevs, module);
731 else if (module) 800 else if (module)
732 /* Currently ref_reloc_sym based probe is not for drivers */ 801 /* Currently ref_reloc_sym based probe is not for drivers */
733 ret = add_module_to_probe_trace_events(tevs, ntevs, module); 802 ret = post_process_module_probe_trace_events(tevs, ntevs,
803 module, dinfo);
734 else 804 else
735 ret = post_process_kernel_probe_trace_events(tevs, ntevs); 805 ret = post_process_kernel_probe_trace_events(tevs, ntevs);
736 806
@@ -774,30 +844,27 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
774 } 844 }
775 } 845 }
776 846
777 debuginfo__delete(dinfo);
778
779 if (ntevs > 0) { /* Succeeded to find trace events */ 847 if (ntevs > 0) { /* Succeeded to find trace events */
780 pr_debug("Found %d probe_trace_events.\n", ntevs); 848 pr_debug("Found %d probe_trace_events.\n", ntevs);
781 ret = post_process_probe_trace_events(pev, *tevs, ntevs, 849 ret = post_process_probe_trace_events(pev, *tevs, ntevs,
782 pev->target, pev->uprobes); 850 pev->target, pev->uprobes, dinfo);
783 if (ret < 0 || ret == ntevs) { 851 if (ret < 0 || ret == ntevs) {
852 pr_debug("Post processing failed or all events are skipped. (%d)\n", ret);
784 clear_probe_trace_events(*tevs, ntevs); 853 clear_probe_trace_events(*tevs, ntevs);
785 zfree(tevs); 854 zfree(tevs);
855 ntevs = 0;
786 } 856 }
787 if (ret != ntevs)
788 return ret < 0 ? ret : ntevs;
789 ntevs = 0;
790 /* Fall through */
791 } 857 }
792 858
859 debuginfo__delete(dinfo);
860
793 if (ntevs == 0) { /* No error but failed to find probe point. */ 861 if (ntevs == 0) { /* No error but failed to find probe point. */
794 pr_warning("Probe point '%s' not found.\n", 862 pr_warning("Probe point '%s' not found.\n",
795 synthesize_perf_probe_point(&pev->point)); 863 synthesize_perf_probe_point(&pev->point));
796 return -ENOENT; 864 return -ENOENT;
797 } 865 } else if (ntevs < 0) {
798 /* Error path : ntevs < 0 */ 866 /* Error path : ntevs < 0 */
799 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs); 867 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
800 if (ntevs < 0) {
801 if (ntevs == -EBADF) 868 if (ntevs == -EBADF)
802 pr_warning("Warning: No dwarf info found in the vmlinux - " 869 pr_warning("Warning: No dwarf info found in the vmlinux - "
803 "please rebuild kernel with CONFIG_DEBUG_INFO=y.\n"); 870 "please rebuild kernel with CONFIG_DEBUG_INFO=y.\n");
@@ -2869,7 +2936,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
2869 } 2936 }
2870 2937
2871out: 2938out:
2872 put_target_map(map, pev->uprobes); 2939 map__put(map);
2873 free(syms); 2940 free(syms);
2874 return ret; 2941 return ret;
2875 2942
@@ -3362,10 +3429,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
3362 return ret; 3429 return ret;
3363 3430
3364 /* Get a symbol map */ 3431 /* Get a symbol map */
3365 if (user) 3432 map = get_target_map(target, user);
3366 map = dso__new_map(target);
3367 else
3368 map = kernel_get_module_map(target);
3369 if (!map) { 3433 if (!map) {
3370 pr_err("Failed to get a map for %s\n", (target) ? : "kernel"); 3434 pr_err("Failed to get a map for %s\n", (target) ? : "kernel");
3371 return -EINVAL; 3435 return -EINVAL;
@@ -3397,9 +3461,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
3397 } 3461 }
3398 3462
3399end: 3463end:
3400 if (user) { 3464 map__put(map);
3401 map__put(map);
3402 }
3403 exit_probe_symbol_maps(); 3465 exit_probe_symbol_maps();
3404 3466
3405 return ret; 3467 return ret;
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index df4debe564da..0d9d6e0803b8 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1501,7 +1501,8 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg,
1501} 1501}
1502 1502
1503/* For the kernel module, we need a special code to get a DIE */ 1503/* For the kernel module, we need a special code to get a DIE */
1504static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs) 1504int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
1505 bool adjust_offset)
1505{ 1506{
1506 int n, i; 1507 int n, i;
1507 Elf32_Word shndx; 1508 Elf32_Word shndx;
@@ -1530,6 +1531,8 @@ static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs)
1530 if (!shdr) 1531 if (!shdr)
1531 return -ENOENT; 1532 return -ENOENT;
1532 *offs = shdr->sh_addr; 1533 *offs = shdr->sh_addr;
1534 if (adjust_offset)
1535 *offs -= shdr->sh_offset;
1533 } 1536 }
1534 } 1537 }
1535 return 0; 1538 return 0;
@@ -1543,16 +1546,12 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
1543 Dwarf_Addr _addr = 0, baseaddr = 0; 1546 Dwarf_Addr _addr = 0, baseaddr = 0;
1544 const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp; 1547 const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
1545 int baseline = 0, lineno = 0, ret = 0; 1548 int baseline = 0, lineno = 0, ret = 0;
1546 bool reloc = false;
1547 1549
1548retry: 1550 /* We always need to relocate the address for aranges */
1551 if (debuginfo__get_text_offset(dbg, &baseaddr, false) == 0)
1552 addr += baseaddr;
1549 /* Find cu die */ 1553 /* Find cu die */
1550 if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) { 1554 if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
1551 if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
1552 addr += baseaddr;
1553 reloc = true;
1554 goto retry;
1555 }
1556 pr_warning("Failed to find debug information for address %lx\n", 1555 pr_warning("Failed to find debug information for address %lx\n",
1557 addr); 1556 addr);
1558 ret = -EINVAL; 1557 ret = -EINVAL;
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index f1d8558f498e..2956c5198652 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -46,6 +46,9 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
46int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr, 46int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
47 struct perf_probe_point *ppt); 47 struct perf_probe_point *ppt);
48 48
49int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
50 bool adjust_offset);
51
49/* Find a line range */ 52/* Find a line range */
50int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr); 53int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr);
51 54
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 99400b0e8f2a..adbc6c02c3aa 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -537,6 +537,12 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
537 break; 537 break;
538 } else { 538 } else {
539 int n = namesz + descsz; 539 int n = namesz + descsz;
540
541 if (n > (int)sizeof(bf)) {
542 n = sizeof(bf);
543 pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
544 __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
545 }
540 if (read(fd, bf, n) != n) 546 if (read(fd, bf, n) != n)
541 break; 547 break;
542 } 548 }
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 71b05891a6a1..831022b12848 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -90,7 +90,7 @@ ifdef INSTALL_PATH
90 done; 90 done;
91 91
92 @# Ask all targets to emit their test scripts 92 @# Ask all targets to emit their test scripts
93 echo "#!/bin/bash" > $(ALL_SCRIPT) 93 echo "#!/bin/sh" > $(ALL_SCRIPT)
94 echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT) 94 echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
95 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) 95 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
96 96
diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
index 92e627adf354..6d58cca8e235 100755
--- a/tools/testing/selftests/bpf/test_kmod.sh
+++ b/tools/testing/selftests/bpf/test_kmod.sh
@@ -1,4 +1,4 @@
1#!/bin/bash 1#!/bin/sh
2 2
3SRC_TREE=../../../../ 3SRC_TREE=../../../../
4 4
diff --git a/tools/testing/selftests/net/run_netsocktests b/tools/testing/selftests/net/run_netsocktests
index c09a682df56a..16058bbea7a8 100755
--- a/tools/testing/selftests/net/run_netsocktests
+++ b/tools/testing/selftests/net/run_netsocktests
@@ -1,4 +1,4 @@
1#!/bin/bash 1#!/bin/sh
2 2
3echo "--------------------" 3echo "--------------------"
4echo "running socket test" 4echo "running socket test"
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
index c22860ab9733..30e1ac62e8cb 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
@@ -66,7 +66,7 @@ int pmc56_overflow(void)
66 66
67 FAIL_IF(ebb_event_enable(&event)); 67 FAIL_IF(ebb_event_enable(&event));
68 68
69 mtspr(SPRN_PMC1, pmc_sample_period(sample_period)); 69 mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
70 mtspr(SPRN_PMC5, 0); 70 mtspr(SPRN_PMC5, 0);
71 mtspr(SPRN_PMC6, 0); 71 mtspr(SPRN_PMC6, 0);
72 72
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
index bdd58c78902e..df9e0a0cdf29 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -1367,7 +1367,7 @@ void run_tests_once(void)
1367 tracing_off(); 1367 tracing_off();
1368 close_test_fds(); 1368 close_test_fds();
1369 1369
1370 printf("test %2d PASSED (itertation %d)\n", test_nr, iteration_nr); 1370 printf("test %2d PASSED (iteration %d)\n", test_nr, iteration_nr);
1371 dprintf1("======================\n\n"); 1371 dprintf1("======================\n\n");
1372 } 1372 }
1373 iteration_nr++; 1373 iteration_nr++;
diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index 34e63cc4c572..14142faf040b 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -26,6 +26,16 @@ static inline void wait_cycles(unsigned long long cycles)
26#define VMEXIT_CYCLES 500 26#define VMEXIT_CYCLES 500
27#define VMENTRY_CYCLES 500 27#define VMENTRY_CYCLES 500
28 28
29#elif defined(__s390x__)
30static inline void wait_cycles(unsigned long long cycles)
31{
32 asm volatile("0: brctg %0,0b" : : "d" (cycles));
33}
34
35/* tweak me */
36#define VMEXIT_CYCLES 200
37#define VMENTRY_CYCLES 200
38
29#else 39#else
30static inline void wait_cycles(unsigned long long cycles) 40static inline void wait_cycles(unsigned long long cycles)
31{ 41{
@@ -81,6 +91,8 @@ extern unsigned ring_size;
81/* Is there a portable way to do this? */ 91/* Is there a portable way to do this? */
82#if defined(__x86_64__) || defined(__i386__) 92#if defined(__x86_64__) || defined(__i386__)
83#define cpu_relax() asm ("rep; nop" ::: "memory") 93#define cpu_relax() asm ("rep; nop" ::: "memory")
94#elif defined(__s390x__)
95#define cpu_relax() barrier()
84#else 96#else
85#define cpu_relax() assert(0) 97#define cpu_relax() assert(0)
86#endif 98#endif
diff --git a/tools/virtio/ringtest/run-on-all.sh b/tools/virtio/ringtest/run-on-all.sh
index 2e69ca812b4c..29b0d3920bfc 100755
--- a/tools/virtio/ringtest/run-on-all.sh
+++ b/tools/virtio/ringtest/run-on-all.sh
@@ -1,12 +1,13 @@
1#!/bin/sh 1#!/bin/sh
2 2
3CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
3#use last CPU for host. Why not the first? 4#use last CPU for host. Why not the first?
4#many devices tend to use cpu0 by default so 5#many devices tend to use cpu0 by default so
5#it tends to be busier 6#it tends to be busier
6HOST_AFFINITY=$(lscpu -p=cpu | tail -1) 7HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
7 8
8#run command on all cpus 9#run command on all cpus
9for cpu in $(seq 0 $HOST_AFFINITY) 10for cpu in $CPUS_ONLINE
10do 11do
11 #Don't run guest and host on same CPU 12 #Don't run guest and host on same CPU
12 #It actually works ok if using signalling 13 #It actually works ok if using signalling
diff --git a/usr/Makefile b/usr/Makefile
index 17a513268325..0b87e71c00fc 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -5,8 +5,10 @@
5klibcdirs:; 5klibcdirs:;
6PHONY += klibcdirs 6PHONY += klibcdirs
7 7
8suffix_y = $(CONFIG_INITRAMFS_COMPRESSION) 8suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
9AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)" 9datafile_y = initramfs_data.cpio$(suffix_y)
10AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
11
10 12
11# Generate builtin.o based on initramfs_data.o 13# Generate builtin.o based on initramfs_data.o
12obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o 14obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
@@ -14,7 +16,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
14# initramfs_data.o contains the compressed initramfs_data.cpio image. 16# initramfs_data.o contains the compressed initramfs_data.cpio image.
15# The image is included using .incbin, a dependency which is not 17# The image is included using .incbin, a dependency which is not
16# tracked automatically. 18# tracked automatically.
17$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE 19$(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
18 20
19##### 21#####
20# Generate the initramfs cpio archive 22# Generate the initramfs cpio archive
@@ -38,10 +40,8 @@ endif
38quiet_cmd_initfs = GEN $@ 40quiet_cmd_initfs = GEN $@
39 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) 41 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
40 42
41targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \ 43targets := $(datafile_y)
42 initramfs_data.cpio.lzma initramfs_data.cpio.xz \ 44
43 initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
44 initramfs_data.cpio
45# do not try to update files included in initramfs 45# do not try to update files included in initramfs
46$(deps_initramfs): ; 46$(deps_initramfs): ;
47 47
@@ -51,6 +51,6 @@ $(deps_initramfs): klibcdirs
51# 2) There are changes in which files are included (added or deleted) 51# 2) There are changes in which files are included (added or deleted)
52# 3) If gen_init_cpio are newer than initramfs_data.cpio 52# 3) If gen_init_cpio are newer than initramfs_data.cpio
53# 4) arguments to gen_initramfs.sh changes 53# 4) arguments to gen_initramfs.sh changes
54$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs 54$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
55 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d 55 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
56 $(call if_changed,initfs) 56 $(call if_changed,initfs)
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index a2dbbccbb6a3..6a084cd57b88 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -24,6 +24,7 @@
24 24
25#include <clocksource/arm_arch_timer.h> 25#include <clocksource/arm_arch_timer.h>
26#include <asm/arch_timer.h> 26#include <asm/arch_timer.h>
27#include <asm/kvm_hyp.h>
27 28
28#include <kvm/arm_vgic.h> 29#include <kvm/arm_vgic.h>
29#include <kvm/arm_arch_timer.h> 30#include <kvm/arm_arch_timer.h>
@@ -89,9 +90,6 @@ static void kvm_timer_inject_irq_work(struct work_struct *work)
89 struct kvm_vcpu *vcpu; 90 struct kvm_vcpu *vcpu;
90 91
91 vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired); 92 vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired);
92 vcpu->arch.timer_cpu.armed = false;
93
94 WARN_ON(!kvm_timer_should_fire(vcpu));
95 93
96 /* 94 /*
97 * If the vcpu is blocked we want to wake it up so that it will see 95 * If the vcpu is blocked we want to wake it up so that it will see
@@ -512,3 +510,25 @@ void kvm_timer_init(struct kvm *kvm)
512{ 510{
513 kvm->arch.timer.cntvoff = kvm_phys_timer_read(); 511 kvm->arch.timer.cntvoff = kvm_phys_timer_read();
514} 512}
513
514/*
515 * On VHE system, we only need to configure trap on physical timer and counter
516 * accesses in EL0 and EL1 once, not for every world switch.
517 * The host kernel runs at EL2 with HCR_EL2.TGE == 1,
518 * and this makes those bits have no effect for the host kernel execution.
519 */
520void kvm_timer_init_vhe(void)
521{
522 /* When HCR_EL2.E2H ==1, EL1PCEN and EL1PCTEN are shifted by 10 */
523 u32 cnthctl_shift = 10;
524 u64 val;
525
526 /*
527 * Disallow physical timer access for the guest.
528 * Physical counter access is allowed.
529 */
530 val = read_sysreg(cnthctl_el2);
531 val &= ~(CNTHCTL_EL1PCEN << cnthctl_shift);
532 val |= (CNTHCTL_EL1PCTEN << cnthctl_shift);
533 write_sysreg(val, cnthctl_el2);
534}
diff --git a/virt/kvm/arm/hyp/timer-sr.c b/virt/kvm/arm/hyp/timer-sr.c
index 798866a8d875..63e28dd18bb0 100644
--- a/virt/kvm/arm/hyp/timer-sr.c
+++ b/virt/kvm/arm/hyp/timer-sr.c
@@ -35,10 +35,16 @@ void __hyp_text __timer_save_state(struct kvm_vcpu *vcpu)
35 /* Disable the virtual timer */ 35 /* Disable the virtual timer */
36 write_sysreg_el0(0, cntv_ctl); 36 write_sysreg_el0(0, cntv_ctl);
37 37
38 /* Allow physical timer/counter access for the host */ 38 /*
39 val = read_sysreg(cnthctl_el2); 39 * We don't need to do this for VHE since the host kernel runs in EL2
40 val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN; 40 * with HCR_EL2.TGE ==1, which makes those bits have no impact.
41 write_sysreg(val, cnthctl_el2); 41 */
42 if (!has_vhe()) {
43 /* Allow physical timer/counter access for the host */
44 val = read_sysreg(cnthctl_el2);
45 val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN;
46 write_sysreg(val, cnthctl_el2);
47 }
42 48
43 /* Clear cntvoff for the host */ 49 /* Clear cntvoff for the host */
44 write_sysreg(0, cntvoff_el2); 50 write_sysreg(0, cntvoff_el2);
@@ -50,14 +56,17 @@ void __hyp_text __timer_restore_state(struct kvm_vcpu *vcpu)
50 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; 56 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
51 u64 val; 57 u64 val;
52 58
53 /* 59 /* Those bits are already configured at boot on VHE-system */
54 * Disallow physical timer access for the guest 60 if (!has_vhe()) {
55 * Physical counter access is allowed 61 /*
56 */ 62 * Disallow physical timer access for the guest
57 val = read_sysreg(cnthctl_el2); 63 * Physical counter access is allowed
58 val &= ~CNTHCTL_EL1PCEN; 64 */
59 val |= CNTHCTL_EL1PCTEN; 65 val = read_sysreg(cnthctl_el2);
60 write_sysreg(val, cnthctl_el2); 66 val &= ~CNTHCTL_EL1PCEN;
67 val |= CNTHCTL_EL1PCTEN;
68 write_sysreg(val, cnthctl_el2);
69 }
61 70
62 if (timer->enabled) { 71 if (timer->enabled) {
63 write_sysreg(kvm->arch.timer.cntvoff, cntvoff_el2); 72 write_sysreg(kvm->arch.timer.cntvoff, cntvoff_el2);
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index 5114391b7e5a..c737ea0a310a 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -268,15 +268,11 @@ static void kvm_vgic_dist_destroy(struct kvm *kvm)
268{ 268{
269 struct vgic_dist *dist = &kvm->arch.vgic; 269 struct vgic_dist *dist = &kvm->arch.vgic;
270 270
271 mutex_lock(&kvm->lock);
272
273 dist->ready = false; 271 dist->ready = false;
274 dist->initialized = false; 272 dist->initialized = false;
275 273
276 kfree(dist->spis); 274 kfree(dist->spis);
277 dist->nr_spis = 0; 275 dist->nr_spis = 0;
278
279 mutex_unlock(&kvm->lock);
280} 276}
281 277
282void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) 278void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
@@ -286,7 +282,8 @@ void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
286 INIT_LIST_HEAD(&vgic_cpu->ap_list_head); 282 INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
287} 283}
288 284
289void kvm_vgic_destroy(struct kvm *kvm) 285/* To be called with kvm->lock held */
286static void __kvm_vgic_destroy(struct kvm *kvm)
290{ 287{
291 struct kvm_vcpu *vcpu; 288 struct kvm_vcpu *vcpu;
292 int i; 289 int i;
@@ -297,6 +294,13 @@ void kvm_vgic_destroy(struct kvm *kvm)
297 kvm_vgic_vcpu_destroy(vcpu); 294 kvm_vgic_vcpu_destroy(vcpu);
298} 295}
299 296
297void kvm_vgic_destroy(struct kvm *kvm)
298{
299 mutex_lock(&kvm->lock);
300 __kvm_vgic_destroy(kvm);
301 mutex_unlock(&kvm->lock);
302}
303
300/** 304/**
301 * vgic_lazy_init: Lazy init is only allowed if the GIC exposed to the guest 305 * vgic_lazy_init: Lazy init is only allowed if the GIC exposed to the guest
302 * is a GICv2. A GICv3 must be explicitly initialized by the guest using the 306 * is a GICv2. A GICv3 must be explicitly initialized by the guest using the
@@ -348,6 +352,10 @@ int kvm_vgic_map_resources(struct kvm *kvm)
348 ret = vgic_v2_map_resources(kvm); 352 ret = vgic_v2_map_resources(kvm);
349 else 353 else
350 ret = vgic_v3_map_resources(kvm); 354 ret = vgic_v3_map_resources(kvm);
355
356 if (ret)
357 __kvm_vgic_destroy(kvm);
358
351out: 359out:
352 mutex_unlock(&kvm->lock); 360 mutex_unlock(&kvm->lock);
353 return ret; 361 return ret;
diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
index 9bab86757fa4..834137e7b83f 100644
--- a/virt/kvm/arm/vgic/vgic-v2.c
+++ b/virt/kvm/arm/vgic/vgic-v2.c
@@ -293,8 +293,6 @@ int vgic_v2_map_resources(struct kvm *kvm)
293 dist->ready = true; 293 dist->ready = true;
294 294
295out: 295out:
296 if (ret)
297 kvm_vgic_destroy(kvm);
298 return ret; 296 return ret;
299} 297}
300 298
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 5c9f9745e6ca..e6b03fd8c374 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -302,8 +302,6 @@ int vgic_v3_map_resources(struct kvm *kvm)
302 dist->ready = true; 302 dist->ready = true;
303 303
304out: 304out:
305 if (ret)
306 kvm_vgic_destroy(kvm);
307 return ret; 305 return ret;
308} 306}
309 307
diff --git a/virt/lib/irqbypass.c b/virt/lib/irqbypass.c
index 52abac4bb6a2..6d2fcd6fcb25 100644
--- a/virt/lib/irqbypass.c
+++ b/virt/lib/irqbypass.c
@@ -195,7 +195,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)
195 mutex_lock(&lock); 195 mutex_lock(&lock);
196 196
197 list_for_each_entry(tmp, &consumers, node) { 197 list_for_each_entry(tmp, &consumers, node) {
198 if (tmp->token == consumer->token) { 198 if (tmp->token == consumer->token || tmp == consumer) {
199 mutex_unlock(&lock); 199 mutex_unlock(&lock);
200 module_put(THIS_MODULE); 200 module_put(THIS_MODULE);
201 return -EBUSY; 201 return -EBUSY;
@@ -245,7 +245,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)
245 mutex_lock(&lock); 245 mutex_lock(&lock);
246 246
247 list_for_each_entry(tmp, &consumers, node) { 247 list_for_each_entry(tmp, &consumers, node) {
248 if (tmp->token != consumer->token) 248 if (tmp != consumer)
249 continue; 249 continue;
250 250
251 list_for_each_entry(producer, &producers, node) { 251 list_for_each_entry(producer, &producers, node) {