aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-11-01 02:41:06 -0400
committerIngo Molnar <mingo@kernel.org>2016-11-01 02:41:06 -0400
commit05b93c19d50af2bd0d30fc000d817418ae8d33f1 (patch)
treedbfbd3f3bc13789e6450112c2013d7a2b042bdb9
parent24d86f59093b0bcb3756cdf47f2db10ff4e90dbb (diff)
parent0c183d92b20b5c84ca655b45ef57b3318b83eb9e (diff)
Merge branch 'linus' into x86/asm, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--CREDITS5
-rw-r--r--Documentation/ABI/testing/sysfs-class-cxl7
-rw-r--r--Documentation/device-mapper/dm-raid.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/uniphier-clock.txt16
-rw-r--r--Documentation/devicetree/bindings/ipmi/aspeed,ast2400-bt-bmc.txt23
-rw-r--r--Documentation/devicetree/bindings/ipmi/ipmi-smic.txt (renamed from Documentation/devicetree/bindings/ipmi.txt)0
-rw-r--r--Documentation/devicetree/bindings/net/marvell-orion-net.txt1
-rw-r--r--Documentation/devicetree/bindings/reset/uniphier-reset.txt62
-rw-r--r--Documentation/devicetree/bindings/serial/cdns,uart.txt4
-rw-r--r--Documentation/devicetree/bindings/serial/renesas,sci-serial.txt8
-rw-r--r--Documentation/devicetree/bindings/timer/jcore,pit.txt24
-rw-r--r--Documentation/devicetree/bindings/usb/dwc2.txt5
-rw-r--r--Documentation/filesystems/proc.txt26
-rw-r--r--Documentation/gpio/board.txt11
-rw-r--r--Documentation/networking/netdev-FAQ.txt8
-rw-r--r--Documentation/networking/nf_conntrack-sysctl.txt18
-rw-r--r--MAINTAINERS56
-rw-r--r--Makefile2
-rw-r--r--arch/arc/Kconfig27
-rw-r--r--arch/arc/Makefile3
-rw-r--r--arch/arc/boot/Makefile16
-rw-r--r--arch/arc/include/asm/arcregs.h3
-rw-r--r--arch/arc/include/asm/cache.h2
-rw-r--r--arch/arc/include/asm/elf.h2
-rw-r--r--arch/arc/include/asm/mcip.h16
-rw-r--r--arch/arc/include/asm/module.h1
-rw-r--r--arch/arc/include/asm/setup.h6
-rw-r--r--arch/arc/include/asm/syscalls.h1
-rw-r--r--arch/arc/include/uapi/asm/unistd.h9
-rw-r--r--arch/arc/kernel/mcip.c31
-rw-r--r--arch/arc/kernel/module.c53
-rw-r--r--arch/arc/kernel/process.c33
-rw-r--r--arch/arc/kernel/setup.c113
-rw-r--r--arch/arc/kernel/troubleshoot.c110
-rw-r--r--arch/arc/mm/cache.c19
-rw-r--r--arch/arc/mm/dma.c4
-rw-r--r--arch/arc/mm/tlb.c6
-rw-r--r--arch/arc/mm/tlbex.S21
-rw-r--r--arch/arm/boot/dts/ste-snowball.dts15
-rw-r--r--arch/arm/boot/dts/uniphier-pro5.dtsi4
-rw-r--r--arch/arm/boot/dts/uniphier-pxs2.dtsi4
-rw-r--r--arch/arm/boot/dts/vf500.dtsi2
-rw-r--r--arch/arm/configs/multi_v7_defconfig1
-rw-r--r--arch/arm/include/asm/unistd.h2
-rw-r--r--arch/arm/include/uapi/asm/unistd.h3
-rw-r--r--arch/arm/kernel/calls.S3
-rw-r--r--arch/arm/kvm/arm.c7
-rw-r--r--arch/arm/mach-imx/gpc.c15
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c2
-rw-r--r--arch/arm/mach-mvebu/Kconfig4
-rw-r--r--arch/arm/mach-uniphier/Kconfig1
-rw-r--r--arch/arm/mm/abort-lv4t.S34
-rw-r--r--arch/arm64/Kconfig2
-rw-r--r--arch/arm64/Kconfig.platforms1
-rw-r--r--arch/arm64/Makefile2
-rw-r--r--arch/arm64/boot/dts/broadcom/ns2-svk.dts2
-rw-r--r--arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi1
-rw-r--r--arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi1
-rw-r--r--arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi2
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts3
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3368-orion-r68-meta.dts4
-rw-r--r--arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi12
-rw-r--r--arch/arm64/include/asm/cpufeature.h2
-rw-r--r--arch/arm64/include/asm/exec.h3
-rw-r--r--arch/arm64/include/asm/kvm_emulate.h11
-rw-r--r--arch/arm64/include/asm/memory.h2
-rw-r--r--arch/arm64/include/asm/module.h5
-rw-r--r--arch/arm64/include/asm/percpu.h120
-rw-r--r--arch/arm64/include/asm/processor.h6
-rw-r--r--arch/arm64/include/asm/sysreg.h2
-rw-r--r--arch/arm64/include/asm/uaccess.h8
-rw-r--r--arch/arm64/kernel/armv8_deprecated.c36
-rw-r--r--arch/arm64/kernel/cpu_errata.c3
-rw-r--r--arch/arm64/kernel/cpufeature.c10
-rw-r--r--arch/arm64/kernel/head.S3
-rw-r--r--arch/arm64/kernel/process.c18
-rw-r--r--arch/arm64/kernel/smp.c1
-rw-r--r--arch/arm64/kernel/suspend.c11
-rw-r--r--arch/arm64/kernel/traps.c30
-rw-r--r--arch/arm64/mm/fault.c15
-rw-r--r--arch/arm64/mm/init.c26
-rw-r--r--arch/arm64/mm/numa.c9
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c2
-rw-r--r--arch/h8300/include/asm/thread_info.h4
-rw-r--r--arch/h8300/kernel/signal.c2
-rw-r--r--arch/mips/kvm/mips.c1
-rw-r--r--arch/powerpc/boot/main.c18
-rw-r--r--arch/powerpc/include/asm/checksum.h12
-rw-r--r--arch/powerpc/include/asm/cpuidle.h2
-rw-r--r--arch/powerpc/include/asm/exception-64s.h16
-rw-r--r--arch/powerpc/include/asm/tlb.h12
-rw-r--r--arch/powerpc/include/asm/unistd.h4
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S50
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c2
-rw-r--r--arch/powerpc/kernel/idle_book3s.S35
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kvm/book3s_hv_rm_xics.c1
-rw-r--r--arch/powerpc/mm/copro_fault.c2
-rw-r--r--arch/powerpc/mm/numa.c46
-rw-r--r--arch/powerpc/mm/tlb-radix.c8
-rw-r--r--arch/s390/include/asm/ftrace.h4
-rw-r--r--arch/s390/include/asm/processor.h2
-rw-r--r--arch/s390/include/asm/unistd.h3
-rw-r--r--arch/s390/kernel/dis.c4
-rw-r--r--arch/s390/kernel/dumpstack.c63
-rw-r--r--arch/s390/kernel/perf_event.c2
-rw-r--r--arch/s390/kernel/stacktrace.c4
-rw-r--r--arch/s390/kvm/intercept.c9
-rw-r--r--arch/s390/mm/hugetlbpage.c1
-rw-r--r--arch/s390/mm/init.c38
-rw-r--r--arch/s390/oprofile/init.c2
-rw-r--r--arch/sparc/include/asm/cpudata_64.h5
-rw-r--r--arch/sparc/include/asm/spinlock_32.h2
-rw-r--r--arch/sparc/include/asm/spinlock_64.h12
-rw-r--r--arch/sparc/include/asm/topology_64.h8
-rw-r--r--arch/sparc/include/asm/uaccess_64.h28
-rw-r--r--arch/sparc/kernel/head_64.S37
-rw-r--r--arch/sparc/kernel/jump_label.c23
-rw-r--r--arch/sparc/kernel/mdesc.c46
-rw-r--r--arch/sparc/kernel/smp_64.c8
-rw-r--r--arch/sparc/lib/GENcopy_from_user.S4
-rw-r--r--arch/sparc/lib/GENcopy_to_user.S4
-rw-r--r--arch/sparc/lib/GENmemcpy.S48
-rw-r--r--arch/sparc/lib/Makefile2
-rw-r--r--arch/sparc/lib/NG2copy_from_user.S8
-rw-r--r--arch/sparc/lib/NG2copy_to_user.S8
-rw-r--r--arch/sparc/lib/NG2memcpy.S228
-rw-r--r--arch/sparc/lib/NG4copy_from_user.S8
-rw-r--r--arch/sparc/lib/NG4copy_to_user.S8
-rw-r--r--arch/sparc/lib/NG4memcpy.S294
-rw-r--r--arch/sparc/lib/NGcopy_from_user.S4
-rw-r--r--arch/sparc/lib/NGcopy_to_user.S4
-rw-r--r--arch/sparc/lib/NGmemcpy.S233
-rw-r--r--arch/sparc/lib/U1copy_from_user.S8
-rw-r--r--arch/sparc/lib/U1copy_to_user.S8
-rw-r--r--arch/sparc/lib/U1memcpy.S345
-rw-r--r--arch/sparc/lib/U3copy_from_user.S8
-rw-r--r--arch/sparc/lib/U3copy_to_user.S8
-rw-r--r--arch/sparc/lib/U3memcpy.S227
-rw-r--r--arch/sparc/lib/copy_in_user.S35
-rw-r--r--arch/sparc/lib/user_fixup.c71
-rw-r--r--arch/sparc/mm/tsb.c17
-rw-r--r--arch/sparc/mm/ultra.S374
-rw-r--r--arch/x86/entry/Makefile4
-rw-r--r--arch/x86/events/intel/core.c10
-rw-r--r--arch/x86/events/intel/cstate.c30
-rw-r--r--arch/x86/include/asm/cpufeatures.h2
-rw-r--r--arch/x86/include/asm/io.h6
-rw-r--r--arch/x86/include/asm/thread_info.h9
-rw-r--r--arch/x86/kernel/acpi/boot.c1
-rw-r--r--arch/x86/kernel/cpu/microcode/amd.c2
-rw-r--r--arch/x86/kernel/cpu/scattered.c2
-rw-r--r--arch/x86/kernel/cpu/vmware.c5
-rw-r--r--arch/x86/kernel/fpu/xstate.c2
-rw-r--r--arch/x86/kernel/mcount_64.S3
-rw-r--r--arch/x86/kernel/quirks.c3
-rw-r--r--arch/x86/kernel/setup.c7
-rw-r--r--arch/x86/kernel/signal_compat.c3
-rw-r--r--arch/x86/kernel/smpboot.c16
-rw-r--r--arch/x86/kernel/unwind_guess.c9
-rw-r--r--arch/x86/kvm/ioapic.c2
-rw-r--r--arch/x86/kvm/x86.c4
-rw-r--r--arch/x86/mm/kaslr.c6
-rw-r--r--arch/x86/mm/pat.c14
-rw-r--r--arch/x86/platform/uv/bios_uv.c10
-rw-r--r--arch/x86/xen/enlighten.c2
-rw-r--r--block/badblocks.c29
-rw-r--r--block/blk-flush.c28
-rw-r--r--block/blk-mq.c6
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/acpica/dsinit.c11
-rw-r--r--drivers/acpi/acpica/dsmethod.c50
-rw-r--r--drivers/acpi/acpica/dswload2.c2
-rw-r--r--drivers/acpi/acpica/evrgnini.c3
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/apei/ghes.c2
-rw-r--r--drivers/acpi/pci_link.c38
-rw-r--r--drivers/android/binder.c35
-rw-r--r--drivers/ata/ahci.c41
-rw-r--r--drivers/base/Kconfig6
-rw-r--r--drivers/block/DAC960.c4
-rw-r--r--drivers/block/nbd.c2
-rw-r--r--drivers/block/rbd.c50
-rw-r--r--drivers/bluetooth/btwilink.c2
-rw-r--r--drivers/bluetooth/hci_bcm.c8
-rw-r--r--drivers/bus/Kconfig1
-rw-r--r--drivers/char/hw_random/core.c6
-rw-r--r--drivers/char/ipmi/Kconfig8
-rw-r--r--drivers/char/ipmi/Makefile1
-rw-r--r--drivers/char/ipmi/bt-bmc.c505
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c7
-rw-r--r--drivers/char/tpm/tpm-interface.c3
-rw-r--r--drivers/clk/at91/clk-programmable.c2
-rw-r--r--drivers/clk/bcm/clk-bcm2835.c11
-rw-r--r--drivers/clk/clk-max77686.c1
-rw-r--r--drivers/clk/hisilicon/clk-hi6220.c4
-rw-r--r--drivers/clk/mediatek/Kconfig2
-rw-r--r--drivers/clk/mvebu/armada-37xx-periph.c11
-rw-r--r--drivers/clk/samsung/clk-exynos-audss.c1
-rw-r--r--drivers/clk/uniphier/clk-uniphier-core.c20
-rw-r--r--drivers/clk/uniphier/clk-uniphier-mio.c2
-rw-r--r--drivers/clk/uniphier/clk-uniphier-mux.c2
-rw-r--r--drivers/clk/uniphier/clk-uniphier.h2
-rw-r--r--drivers/clocksource/Kconfig10
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/jcore-pit.c249
-rw-r--r--drivers/clocksource/timer-sun5i.c16
-rw-r--r--drivers/cpufreq/intel_pstate.c38
-rw-r--r--drivers/dax/Kconfig2
-rw-r--r--drivers/dax/pmem.c2
-rw-r--r--drivers/extcon/extcon-qcom-spmi-misc.c2
-rw-r--r--drivers/firmware/efi/libstub/Makefile5
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/gpio-ath79.c1
-rw-r--r--drivers/gpio/gpio-mpc8xxx.c2
-rw-r--r--drivers/gpio/gpio-mxs.c8
-rw-r--r--drivers/gpio/gpio-stmpe.c2
-rw-r--r--drivers/gpio/gpio-ts4800.c1
-rw-r--r--drivers/gpio/gpiolib-acpi.c7
-rw-r--r--drivers/gpio/gpiolib.c42
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c5
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c18
-rw-r--r--drivers/gpu/drm/ast/ast_ttm.c6
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_ttm.c7
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_buffer.c24
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_mmu.c3
-rw-r--r--drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c4
-rw-r--r--drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c23
-rw-r--r--drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c5
-rw-r--r--drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c39
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_ttm.c7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ttm.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c145
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_surface.c56
-rw-r--r--drivers/hv/hv_util.c10
-rw-r--r--drivers/hwmon/adm9240.c6
-rw-r--r--drivers/hwmon/max31790.c4
-rw-r--r--drivers/i2c/busses/Kconfig12
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c17
-rw-r--r--drivers/i2c/busses/i2c-digicolor.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c16
-rw-r--r--drivers/i2c/busses/i2c-imx.c11
-rw-r--r--drivers/i2c/busses/i2c-jz4780.c1
-rw-r--r--drivers/i2c/busses/i2c-rk3x.c2
-rw-r--r--drivers/i2c/busses/i2c-xgene-slimpro.c2
-rw-r--r--drivers/i2c/busses/i2c-xlp9xx.c1
-rw-r--r--drivers/i2c/busses/i2c-xlr.c1
-rw-r--r--drivers/i2c/i2c-core.c11
-rw-r--r--drivers/iio/adc/Kconfig2
-rw-r--r--drivers/iio/chemical/atlas-ph-sensor.c7
-rw-r--r--drivers/iio/temperature/maxim_thermocouple.c16
-rw-r--r--drivers/infiniband/hw/mlx5/main.c2
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c1
-rw-r--r--drivers/infiniband/hw/qedr/Kconfig1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h20
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c15
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c12
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c54
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c6
-rw-r--r--drivers/ipack/ipack.c2
-rw-r--r--drivers/irqchip/Kconfig4
-rw-r--r--drivers/irqchip/irq-eznps.c2
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c10
-rw-r--r--drivers/irqchip/irq-gic.c2
-rw-r--r--drivers/md/dm-raid.c15
-rw-r--r--drivers/md/dm-raid1.c22
-rw-r--r--drivers/md/dm-rq.c7
-rw-r--r--drivers/md/dm-table.c24
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/memstick/host/rtsx_usb_ms.c6
-rw-r--r--drivers/misc/cxl/api.c11
-rw-r--r--drivers/misc/cxl/context.c3
-rw-r--r--drivers/misc/cxl/cxl.h24
-rw-r--r--drivers/misc/cxl/file.c15
-rw-r--r--drivers/misc/cxl/guest.c3
-rw-r--r--drivers/misc/cxl/main.c42
-rw-r--r--drivers/misc/cxl/pci.c2
-rw-r--r--drivers/misc/cxl/sysfs.c27
-rw-r--r--drivers/misc/genwqe/card_utils.c12
-rw-r--r--drivers/misc/mei/hw-txe.c6
-rw-r--r--drivers/misc/sgi-gru/grumain.c2
-rw-r--r--drivers/misc/vmw_vmci/vmci_doorbell.c8
-rw-r--r--drivers/misc/vmw_vmci/vmci_driver.c2
-rw-r--r--drivers/mmc/card/block.c3
-rw-r--r--drivers/mmc/card/queue.h2
-rw-r--r--drivers/mmc/core/mmc.c12
-rw-r--r--drivers/mmc/host/rtsx_usb_sdmmc.c7
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c23
-rw-r--r--drivers/mmc/host/sdhci-of-arasan.c26
-rw-r--r--drivers/mmc/host/sdhci-pci-core.c54
-rw-r--r--drivers/mmc/host/sdhci-pci.h2
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c2
-rw-r--r--drivers/mmc/host/sdhci.c42
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/ubi/eba.c1
-rw-r--r--drivers/mtd/ubi/fastmap.c12
-rw-r--r--drivers/net/dsa/b53/b53_mmap.c1
-rw-r--r--drivers/net/dsa/bcm_sf2.c16
-rw-r--r--drivers/net/ethernet/aurora/nb8800.c1
-rw-r--r--drivers/net/ethernet/broadcom/bcm63xx_enet.c3
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c17
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c40
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sched.c4
-rw-r--r--drivers/net/ethernet/cisco/enic/vnic_rq.c32
-rw-r--r--drivers/net/ethernet/ezchip/nps_enet.c1
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c6
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c1
-rw-r--r--drivers/net/ethernet/hisilicon/hns_mdio.c1
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c45
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.h3
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c34
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c12
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c23
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_clock.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_cq.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_port.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_selftest.c26
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c62
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/port.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/alloc.c31
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c21
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c50
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c76
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c39
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c26
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/pci.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c21
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/switchx2.c1
-rw-r--r--drivers/net/ethernet/qlogic/Kconfig3
-rw-r--r--drivers/net/ethernet/qlogic/qed/Makefile2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_cxt.c15
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_dcbx.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_debug.c53
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_dev.c19
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.c27
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.h20
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_main.c31
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_roce.c216
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_roce.h95
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_sp.h1
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_spq.c4
-rw-r--r--drivers/net/ethernet/qlogic/qede/Makefile2
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede.h3
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede_ethtool.c99
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede_main.c15
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-mac.c8
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c3
-rw-r--r--drivers/net/ethernet/rocker/rocker_main.c2
-rw-r--r--drivers/net/ethernet/rocker/rocker_ofdpa.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c7
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c13
-rw-r--r--drivers/net/ethernet/synopsys/dwc_eth_qos.c4
-rw-r--r--drivers/net/geneve.c47
-rw-r--r--drivers/net/hyperv/netvsc_drv.c25
-rw-r--r--drivers/net/macsec.c26
-rw-r--r--drivers/net/phy/at803x.c65
-rw-r--r--drivers/net/phy/dp83848.c3
-rw-r--r--drivers/net/usb/asix_common.c8
-rw-r--r--drivers/net/usb/kalmia.c2
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c17
-rw-r--r--drivers/net/vrf.c2
-rw-r--r--drivers/net/vxlan.c82
-rw-r--r--drivers/net/wan/Kconfig2
-rw-r--r--drivers/net/wan/slic_ds26522.c8
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h1
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c75
-rw-r--r--drivers/net/wireless/ath/ath6kl/sdio.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c2
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h4
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c8
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c4
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c11
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c8
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c13
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c6
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c8
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c9
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c6
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c18
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/wifi.h2
-rw-r--r--drivers/net/wireless/ti/wlcore/sdio.c1
-rw-r--r--drivers/nvdimm/Kconfig2
-rw-r--r--drivers/nvdimm/namespace_devs.c14
-rw-r--r--drivers/nvdimm/pmem.c8
-rw-r--r--drivers/nvme/host/core.c14
-rw-r--r--drivers/nvme/host/pci.c77
-rw-r--r--drivers/nvme/host/scsi.c4
-rw-r--r--drivers/nvme/target/admin-cmd.c8
-rw-r--r--drivers/nvme/target/core.c2
-rw-r--r--drivers/nvme/target/discovery.c4
-rw-r--r--drivers/pci/host/pci-layerscape.c2
-rw-r--r--drivers/pci/host/pcie-designware-plat.c2
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--drivers/perf/xgene_pmu.c2
-rw-r--r--drivers/regulator/core.c2
-rw-r--r--drivers/reset/reset-uniphier.c16
-rw-r--r--drivers/s390/block/dasd_eckd.c4
-rw-r--r--drivers/s390/cio/chp.c6
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c2
-rw-r--r--drivers/scsi/NCR5380.c6
-rw-r--r--drivers/scsi/be2iscsi/be_main.c37
-rw-r--r--drivers/scsi/ipr.c3
-rw-r--r--drivers/scsi/libiscsi.c4
-rw-r--r--drivers/scsi/scsi_dh.c6
-rw-r--r--drivers/scsi/scsi_scan.c6
-rw-r--r--drivers/spi/spi-fsl-dspi.c7
-rw-r--r--drivers/spi/spi-fsl-espi.c2
-rw-r--r--drivers/spi/spi.c5
-rw-r--r--drivers/staging/android/ion/ion.c6
-rw-r--r--drivers/staging/android/ion/ion_of.c2
-rw-r--r--drivers/staging/greybus/arche-platform.c1
-rw-r--r--drivers/staging/greybus/es2.c3
-rw-r--r--drivers/staging/greybus/gpio.c6
-rw-r--r--drivers/staging/greybus/module.c2
-rw-r--r--drivers/staging/greybus/uart.c2
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/lproc_llite.c34
-rw-r--r--drivers/staging/wilc1000/host_interface.c1
-rw-r--r--drivers/target/iscsi/iscsi_target.c6
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c4
-rw-r--r--drivers/target/target_core_transport.c39
-rw-r--r--drivers/target/target_core_user.c50
-rw-r--r--drivers/target/target_core_xcopy.c34
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c4
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c42
-rw-r--r--drivers/thermal/intel_pch_thermal.c60
-rw-r--r--drivers/thermal/intel_powerclamp.c14
-rw-r--r--drivers/tty/serial/8250/8250_lpss.c2
-rw-r--r--drivers/tty/serial/8250/8250_port.c3
-rw-r--r--drivers/tty/serial/8250/8250_uniphier.c4
-rw-r--r--drivers/tty/serial/Kconfig1
-rw-r--r--drivers/tty/serial/atmel_serial.c26
-rw-r--r--drivers/tty/serial/fsl_lpuart.c3
-rw-r--r--drivers/tty/serial/pch_uart.c1
-rw-r--r--drivers/tty/serial/sc16is7xx.c8
-rw-r--r--drivers/tty/serial/serial_core.c8
-rw-r--r--drivers/tty/serial/stm32-usart.h2
-rw-r--r--drivers/tty/serial/xilinx_uartps.c2
-rw-r--r--drivers/tty/vt/vt.c7
-rw-r--r--drivers/usb/chipidea/host.c2
-rw-r--r--drivers/usb/dwc2/core.c11
-rw-r--r--drivers/usb/dwc2/core.h7
-rw-r--r--drivers/usb/dwc2/gadget.c53
-rw-r--r--drivers/usb/dwc3/gadget.c26
-rw-r--r--drivers/usb/gadget/function/f_fs.c107
-rw-r--r--drivers/usb/gadget/function/u_ether.c5
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c2
-rw-r--r--drivers/usb/host/ehci-platform.c2
-rw-r--r--drivers/usb/host/ohci-at91.c9
-rw-r--r--drivers/usb/host/ohci-hcd.c2
-rw-r--r--drivers/usb/host/xhci-hub.c41
-rw-r--r--drivers/usb/host/xhci-pci.c10
-rw-r--r--drivers/usb/host/xhci.h3
-rw-r--r--drivers/usb/musb/musb_gadget.c4
-rw-r--r--drivers/usb/musb/omap2430.c7
-rw-r--r--drivers/usb/renesas_usbhs/rcar3.c8
-rw-r--r--drivers/usb/serial/cp210x.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h5
-rw-r--r--drivers/usb/serial/usb-serial.c3
-rw-r--r--drivers/usb/wusbcore/crypto.c61
-rw-r--r--drivers/vme/vme.c4
-rw-r--r--drivers/watchdog/wdat_wdt.c4
-rw-r--r--drivers/xen/manage.c45
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c4
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c4
-rw-r--r--fs/afs/cmservice.c6
-rw-r--r--fs/afs/fsclient.c4
-rw-r--r--fs/afs/internal.h2
-rw-r--r--fs/afs/rxrpc.c3
-rw-r--r--fs/btrfs/send.c58
-rw-r--r--fs/btrfs/tree-log.c20
-rw-r--r--fs/ceph/file.c3
-rw-r--r--fs/ceph/inode.c3
-rw-r--r--fs/ceph/super.c2
-rw-r--r--fs/ceph/xattr.c4
-rw-r--r--fs/crypto/crypto.c15
-rw-r--r--fs/crypto/policy.c4
-rw-r--r--fs/exofs/dir.c2
-rw-r--r--fs/ext2/inode.c7
-rw-r--r--fs/ext4/block_validity.c4
-rw-r--r--fs/ext4/mballoc.h17
-rw-r--r--fs/ext4/namei.c18
-rw-r--r--fs/ext4/super.c21
-rw-r--r--fs/ext4/sysfs.c4
-rw-r--r--fs/ext4/xattr.c20
-rw-r--r--fs/iomap.c5
-rw-r--r--fs/isofs/inode.c8
-rw-r--r--fs/jbd2/transaction.c3
-rw-r--r--fs/kernfs/file.c1
-rw-r--r--fs/nfs/blocklayout/blocklayout.c3
-rw-r--r--fs/nfs/nfs4proc.c2
-rw-r--r--fs/orangefs/dcache.c5
-rw-r--r--fs/orangefs/file.c14
-rw-r--r--fs/orangefs/namei.c8
-rw-r--r--fs/orangefs/orangefs-kernel.h7
-rw-r--r--fs/proc/array.c9
-rw-r--r--fs/proc/base.c21
-rw-r--r--fs/proc/task_mmu.c29
-rw-r--r--fs/proc/task_nommu.c28
-rw-r--r--fs/ubifs/dir.c28
-rw-r--r--fs/ubifs/xattr.c2
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c418
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h8
-rw-r--r--fs/xfs/libxfs/xfs_btree.c2
-rw-r--r--fs/xfs/libxfs/xfs_dquot_buf.c3
-rw-r--r--fs/xfs/libxfs/xfs_format.h1
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c13
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.h2
-rw-r--r--fs/xfs/xfs_file.c232
-rw-r--r--fs/xfs/xfs_icache.c8
-rw-r--r--fs/xfs/xfs_iomap.c57
-rw-r--r--fs/xfs/xfs_mount.c1
-rw-r--r--fs/xfs/xfs_reflink.c499
-rw-r--r--fs/xfs/xfs_reflink.h11
-rw-r--r--fs/xfs/xfs_sysfs.c4
-rw-r--r--fs/xfs/xfs_trace.h4
-rw-r--r--include/acpi/pcc.h2
-rw-r--r--include/asm-generic/export.h2
-rw-r--r--include/linux/acpi.h1
-rw-r--r--include/linux/clk-provider.h2
-rw-r--r--include/linux/cpufreq.h4
-rw-r--r--include/linux/cpuhotplug.h1
-rw-r--r--include/linux/hyperv.h7
-rw-r--r--include/linux/io.h22
-rw-r--r--include/linux/iomap.h17
-rw-r--r--include/linux/ipv6.h17
-rw-r--r--include/linux/irqchip/arm-gic-v3.h2
-rw-r--r--include/linux/kconfig.h5
-rw-r--r--include/linux/mlx4/device.h3
-rw-r--r--include/linux/mlx5/driver.h16
-rw-r--r--include/linux/mm.h6
-rw-r--r--include/linux/mmzone.h30
-rw-r--r--include/linux/netdevice.h41
-rw-r--r--include/linux/nvme.h49
-rw-r--r--include/linux/perf_event.h1
-rw-r--r--include/linux/qed/qed_if.h1
-rw-r--r--include/linux/qed/qede_roce.h2
-rw-r--r--include/linux/regmap.h11
-rw-r--r--include/linux/skbuff.h1
-rw-r--r--include/linux/thread_info.h11
-rw-r--r--include/net/addrconf.h1
-rw-r--r--include/net/cfg80211.h32
-rw-r--r--include/net/if_inet6.h2
-rw-r--r--include/net/ip.h12
-rw-r--r--include/net/ip6_fib.h2
-rw-r--r--include/net/ip6_route.h1
-rw-r--r--include/net/mac80211.h21
-rw-r--r--include/net/sock.h4
-rw-r--r--include/net/tcp.h13
-rw-r--r--include/net/udp.h1
-rw-r--r--include/net/vxlan.h4
-rw-r--r--include/target/target_core_base.h1
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/bt-bmc.h18
-rw-r--r--include/uapi/linux/ethtool.h3
-rw-r--r--include/uapi/linux/rtnetlink.h2
-rw-r--r--ipc/msgutil.c4
-rw-r--r--kernel/events/core.c23
-rw-r--r--kernel/irq/manage.c1
-rw-r--r--kernel/kcov.c9
-rw-r--r--kernel/power/suspend.c4
-rw-r--r--kernel/sched/core.c16
-rw-r--r--kernel/sched/fair.c3
-rw-r--r--kernel/sched/wait.c10
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/time/timer.c74
-rw-r--r--lib/Kconfig.debug1
-rw-r--r--lib/genalloc.c3
-rw-r--r--lib/stackdepot.c2
-rw-r--r--lib/test_bpf.c2
-rw-r--r--mm/Kconfig2
-rw-r--r--mm/filemap.c4
-rw-r--r--mm/gup.c3
-rw-r--r--mm/kmemleak.c7
-rw-r--r--mm/list_lru.c2
-rw-r--r--mm/memcontrol.c9
-rw-r--r--mm/memory_hotplug.c29
-rw-r--r--mm/mprotect.c1
-rw-r--r--mm/nommu.c2
-rw-r--r--mm/page_alloc.c131
-rw-r--r--mm/slab.c45
-rw-r--r--mm/slab.h1
-rw-r--r--mm/util.c4
-rw-r--r--mm/vmscan.c2
-rw-r--r--net/8021q/vlan.c2
-rw-r--r--net/batman-adv/hard-interface.c1
-rw-r--r--net/batman-adv/log.h2
-rw-r--r--net/batman-adv/originator.c2
-rw-r--r--net/bluetooth/hci_request.c49
-rw-r--r--net/bluetooth/hci_request.h2
-rw-r--r--net/bluetooth/mgmt.c26
-rw-r--r--net/bridge/br_multicast.c23
-rw-r--r--net/core/dev.c12
-rw-r--r--net/core/flow_dissector.c12
-rw-r--r--net/core/net_namespace.c35
-rw-r--r--net/core/pktgen.c17
-rw-r--r--net/core/sock_reuseport.c1
-rw-r--r--net/ethernet/eth.c2
-rw-r--r--net/hsr/hsr_forward.c4
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/fou.c4
-rw-r--r--net/ipv4/gre_offload.c2
-rw-r--r--net/ipv4/inet_hashtables.c8
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv4/ip_sockglue.c11
-rw-r--r--net/ipv4/ping.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/sysctl_net_ipv4.c8
-rw-r--r--net/ipv4/tcp_ipv4.c3
-rw-r--r--net/ipv4/udp.c15
-rw-r--r--net/ipv4/udp_offload.c2
-rw-r--r--net/ipv6/addrconf.c101
-rw-r--r--net/ipv6/inet6_hashtables.c13
-rw-r--r--net/ipv6/ip6_offload.c2
-rw-r--r--net/ipv6/ip6_tunnel.c3
-rw-r--r--net/ipv6/ipv6_sockglue.c3
-rw-r--r--net/ipv6/mcast.c17
-rw-r--r--net/ipv6/ping.c2
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/ipv6/reassembly.c3
-rw-r--r--net/ipv6/route.c74
-rw-r--r--net/ipv6/udp.c3
-rw-r--r--net/l2tp/l2tp_ip.c2
-rw-r--r--net/l2tp/l2tp_ip6.c2
-rw-r--r--net/mac80211/aes_ccm.c46
-rw-r--r--net/mac80211/aes_ccm.h8
-rw-r--r--net/mac80211/aes_gcm.c43
-rw-r--r--net/mac80211/aes_gcm.h6
-rw-r--r--net/mac80211/aes_gmac.c26
-rw-r--r--net/mac80211/aes_gmac.h4
-rw-r--r--net/mac80211/offchannel.c2
-rw-r--r--net/mac80211/rx.c51
-rw-r--r--net/mac80211/wpa.c22
-rw-r--r--net/ncsi/internal.h2
-rw-r--r--net/ncsi/ncsi-aen.c18
-rw-r--r--net/ncsi/ncsi-manage.c126
-rw-r--r--net/netfilter/core.c13
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_internals.h2
-rw-r--r--net/netfilter/nf_queue.c48
-rw-r--r--net/netfilter/nf_tables_api.c2
-rw-r--r--net/netfilter/nft_dynset.c6
-rw-r--r--net/netfilter/nft_exthdr.c3
-rw-r--r--net/netfilter/nft_hash.c1
-rw-r--r--net/netfilter/nft_range.c26
-rw-r--r--net/netfilter/x_tables.c2
-rw-r--r--net/netfilter/xt_NFLOG.c1
-rw-r--r--net/netfilter/xt_hashlimit.c4
-rw-r--r--net/netfilter/xt_ipcomp.c2
-rw-r--r--net/packet/af_packet.c9
-rw-r--r--net/rds/Makefile2
-rw-r--r--net/rds/rds.h2
-rw-r--r--net/rxrpc/call_object.c2
-rw-r--r--net/rxrpc/peer_object.c4
-rw-r--r--net/sched/act_api.c3
-rw-r--r--net/sched/act_mirred.c5
-rw-r--r--net/sched/cls_api.c3
-rw-r--r--net/sctp/output.c8
-rw-r--r--net/sctp/sm_statefuns.c12
-rw-r--r--net/sctp/socket.c5
-rw-r--r--net/switchdev/switchdev.c9
-rw-r--r--net/tipc/bcast.c14
-rw-r--r--net/tipc/bcast.h3
-rw-r--r--net/tipc/link.c2
-rw-r--r--net/tipc/msg.h17
-rw-r--r--net/tipc/name_distr.c1
-rw-r--r--net/tipc/node.c2
-rw-r--r--net/wireless/sysfs.c5
-rw-r--r--net/wireless/util.c34
-rw-r--r--samples/bpf/parse_ldabs.c1
-rw-r--r--samples/bpf/parse_simple.c1
-rw-r--r--samples/bpf/parse_varlen.c1
-rw-r--r--samples/bpf/tcbpf1_kern.c1
-rw-r--r--samples/bpf/tcbpf2_kern.c1
-rw-r--r--samples/bpf/test_cgrp2_tc_kern.c1
-rw-r--r--security/keys/Kconfig2
-rw-r--r--security/keys/big_key.c59
-rw-r--r--security/keys/proc.c2
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--sound/core/seq/seq_timer.c4
-rw-r--r--sound/pci/asihpi/hpioctl.c2
-rw-r--r--sound/pci/hda/hda_intel.c7
-rw-r--r--sound/pci/hda/patch_realtek.c30
-rw-r--r--sound/usb/quirks-table.h17
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/objtool/builtin-check.c2
-rw-r--r--virt/kvm/kvm_main.c10
715 files changed, 8023 insertions, 4744 deletions
diff --git a/CREDITS b/CREDITS
index 513aaa3546bf..837367624e45 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1864,10 +1864,11 @@ S: The Netherlands
1864 1864
1865N: Martin Kepplinger 1865N: Martin Kepplinger
1866E: martink@posteo.de 1866E: martink@posteo.de
1867E: martin.kepplinger@theobroma-systems.com 1867E: martin.kepplinger@ginzinger.com
1868W: http://www.martinkepplinger.com 1868W: http://www.martinkepplinger.com
1869D: mma8452 accelerators iio driver 1869D: mma8452 accelerators iio driver
1870D: Kernel cleanups 1870D: pegasus_notetaker input driver
1871D: Kernel fixes and cleanups
1871S: Garnisonstraße 26 1872S: Garnisonstraße 26
1872S: 4020 Linz 1873S: 4020 Linz
1873S: Austria 1874S: Austria
diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl
index 4ba0a2a61926..640f65e79ef1 100644
--- a/Documentation/ABI/testing/sysfs-class-cxl
+++ b/Documentation/ABI/testing/sysfs-class-cxl
@@ -220,8 +220,11 @@ What: /sys/class/cxl/<card>/reset
220Date: October 2014 220Date: October 2014
221Contact: linuxppc-dev@lists.ozlabs.org 221Contact: linuxppc-dev@lists.ozlabs.org
222Description: write only 222Description: write only
223 Writing 1 will issue a PERST to card which may cause the card 223 Writing 1 will issue a PERST to card provided there are no
224 to reload the FPGA depending on load_image_on_perst. 224 contexts active on any one of the card AFUs. This may cause
225 the card to reload the FPGA depending on load_image_on_perst.
226 Writing -1 will do a force PERST irrespective of any active
227 contexts on the card AFUs.
225Users: https://github.com/ibm-capi/libcxl 228Users: https://github.com/ibm-capi/libcxl
226 229
227What: /sys/class/cxl/<card>/perst_reloads_same_image (not in a guest) 230What: /sys/class/cxl/<card>/perst_reloads_same_image (not in a guest)
diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt
index e5b6497116f4..c75b64a85859 100644
--- a/Documentation/device-mapper/dm-raid.txt
+++ b/Documentation/device-mapper/dm-raid.txt
@@ -309,3 +309,4 @@ Version History
309 with a reshape in progress. 309 with a reshape in progress.
3101.9.0 Add support for RAID level takeover/reshape/region size 3101.9.0 Add support for RAID level takeover/reshape/region size
311 and set size reduction. 311 and set size reduction.
3121.9.1 Fix activation of existing RAID 4/10 mapped devices
diff --git a/Documentation/devicetree/bindings/clock/uniphier-clock.txt b/Documentation/devicetree/bindings/clock/uniphier-clock.txt
index c7179d3b5c33..812163060fa3 100644
--- a/Documentation/devicetree/bindings/clock/uniphier-clock.txt
+++ b/Documentation/devicetree/bindings/clock/uniphier-clock.txt
@@ -24,7 +24,7 @@ Example:
24 reg = <0x61840000 0x4000>; 24 reg = <0x61840000 0x4000>;
25 25
26 clock { 26 clock {
27 compatible = "socionext,uniphier-ld20-clock"; 27 compatible = "socionext,uniphier-ld11-clock";
28 #clock-cells = <1>; 28 #clock-cells = <1>;
29 }; 29 };
30 30
@@ -43,8 +43,8 @@ Provided clocks:
4321: USB3 ch1 PHY1 4321: USB3 ch1 PHY1
44 44
45 45
46Media I/O (MIO) clock 46Media I/O (MIO) clock, SD clock
47--------------------- 47-------------------------------
48 48
49Required properties: 49Required properties:
50- compatible: should be one of the following: 50- compatible: should be one of the following:
@@ -52,10 +52,10 @@ Required properties:
52 "socionext,uniphier-ld4-mio-clock" - for LD4 SoC. 52 "socionext,uniphier-ld4-mio-clock" - for LD4 SoC.
53 "socionext,uniphier-pro4-mio-clock" - for Pro4 SoC. 53 "socionext,uniphier-pro4-mio-clock" - for Pro4 SoC.
54 "socionext,uniphier-sld8-mio-clock" - for sLD8 SoC. 54 "socionext,uniphier-sld8-mio-clock" - for sLD8 SoC.
55 "socionext,uniphier-pro5-mio-clock" - for Pro5 SoC. 55 "socionext,uniphier-pro5-sd-clock" - for Pro5 SoC.
56 "socionext,uniphier-pxs2-mio-clock" - for PXs2/LD6b SoC. 56 "socionext,uniphier-pxs2-sd-clock" - for PXs2/LD6b SoC.
57 "socionext,uniphier-ld11-mio-clock" - for LD11 SoC. 57 "socionext,uniphier-ld11-mio-clock" - for LD11 SoC.
58 "socionext,uniphier-ld20-mio-clock" - for LD20 SoC. 58 "socionext,uniphier-ld20-sd-clock" - for LD20 SoC.
59- #clock-cells: should be 1. 59- #clock-cells: should be 1.
60 60
61Example: 61Example:
@@ -66,7 +66,7 @@ Example:
66 reg = <0x59810000 0x800>; 66 reg = <0x59810000 0x800>;
67 67
68 clock { 68 clock {
69 compatible = "socionext,uniphier-ld20-mio-clock"; 69 compatible = "socionext,uniphier-ld11-mio-clock";
70 #clock-cells = <1>; 70 #clock-cells = <1>;
71 }; 71 };
72 72
@@ -112,7 +112,7 @@ Example:
112 reg = <0x59820000 0x200>; 112 reg = <0x59820000 0x200>;
113 113
114 clock { 114 clock {
115 compatible = "socionext,uniphier-ld20-peri-clock"; 115 compatible = "socionext,uniphier-ld11-peri-clock";
116 #clock-cells = <1>; 116 #clock-cells = <1>;
117 }; 117 };
118 118
diff --git a/Documentation/devicetree/bindings/ipmi/aspeed,ast2400-bt-bmc.txt b/Documentation/devicetree/bindings/ipmi/aspeed,ast2400-bt-bmc.txt
new file mode 100644
index 000000000000..fbbacd958240
--- /dev/null
+++ b/Documentation/devicetree/bindings/ipmi/aspeed,ast2400-bt-bmc.txt
@@ -0,0 +1,23 @@
1* Aspeed BT (Block Transfer) IPMI interface
2
3The Aspeed SOCs (AST2400 and AST2500) are commonly used as BMCs
4(BaseBoard Management Controllers) and the BT interface can be used to
5perform in-band IPMI communication with their host.
6
7Required properties:
8
9- compatible : should be "aspeed,ast2400-bt-bmc"
10- reg: physical address and size of the registers
11
12Optional properties:
13
14- interrupts: interrupt generated by the BT interface. without an
15 interrupt, the driver will operate in poll mode.
16
17Example:
18
19 ibt@1e789140 {
20 compatible = "aspeed,ast2400-bt-bmc";
21 reg = <0x1e789140 0x18>;
22 interrupts = <8>;
23 };
diff --git a/Documentation/devicetree/bindings/ipmi.txt b/Documentation/devicetree/bindings/ipmi/ipmi-smic.txt
index d5f1a877ed3e..d5f1a877ed3e 100644
--- a/Documentation/devicetree/bindings/ipmi.txt
+++ b/Documentation/devicetree/bindings/ipmi/ipmi-smic.txt
diff --git a/Documentation/devicetree/bindings/net/marvell-orion-net.txt b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
index bce52b2ec55e..6fd988c84c4f 100644
--- a/Documentation/devicetree/bindings/net/marvell-orion-net.txt
+++ b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
@@ -49,6 +49,7 @@ Optional port properties:
49and 49and
50 50
51 - phy-handle: See ethernet.txt file in the same directory. 51 - phy-handle: See ethernet.txt file in the same directory.
52 - phy-mode: See ethernet.txt file in the same directory.
52 53
53or 54or
54 55
diff --git a/Documentation/devicetree/bindings/reset/uniphier-reset.txt b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
index e6bbfccd56c3..5020524cddeb 100644
--- a/Documentation/devicetree/bindings/reset/uniphier-reset.txt
+++ b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
@@ -6,25 +6,25 @@ System reset
6 6
7Required properties: 7Required properties:
8- compatible: should be one of the following: 8- compatible: should be one of the following:
9 "socionext,uniphier-sld3-reset" - for PH1-sLD3 SoC. 9 "socionext,uniphier-sld3-reset" - for sLD3 SoC.
10 "socionext,uniphier-ld4-reset" - for PH1-LD4 SoC. 10 "socionext,uniphier-ld4-reset" - for LD4 SoC.
11 "socionext,uniphier-pro4-reset" - for PH1-Pro4 SoC. 11 "socionext,uniphier-pro4-reset" - for Pro4 SoC.
12 "socionext,uniphier-sld8-reset" - for PH1-sLD8 SoC. 12 "socionext,uniphier-sld8-reset" - for sLD8 SoC.
13 "socionext,uniphier-pro5-reset" - for PH1-Pro5 SoC. 13 "socionext,uniphier-pro5-reset" - for Pro5 SoC.
14 "socionext,uniphier-pxs2-reset" - for ProXstream2/PH1-LD6b SoC. 14 "socionext,uniphier-pxs2-reset" - for PXs2/LD6b SoC.
15 "socionext,uniphier-ld11-reset" - for PH1-LD11 SoC. 15 "socionext,uniphier-ld11-reset" - for LD11 SoC.
16 "socionext,uniphier-ld20-reset" - for PH1-LD20 SoC. 16 "socionext,uniphier-ld20-reset" - for LD20 SoC.
17- #reset-cells: should be 1. 17- #reset-cells: should be 1.
18 18
19Example: 19Example:
20 20
21 sysctrl@61840000 { 21 sysctrl@61840000 {
22 compatible = "socionext,uniphier-ld20-sysctrl", 22 compatible = "socionext,uniphier-ld11-sysctrl",
23 "simple-mfd", "syscon"; 23 "simple-mfd", "syscon";
24 reg = <0x61840000 0x4000>; 24 reg = <0x61840000 0x4000>;
25 25
26 reset { 26 reset {
27 compatible = "socionext,uniphier-ld20-reset"; 27 compatible = "socionext,uniphier-ld11-reset";
28 #reset-cells = <1>; 28 #reset-cells = <1>;
29 }; 29 };
30 30
@@ -32,30 +32,30 @@ Example:
32 }; 32 };
33 33
34 34
35Media I/O (MIO) reset 35Media I/O (MIO) reset, SD reset
36--------------------- 36-------------------------------
37 37
38Required properties: 38Required properties:
39- compatible: should be one of the following: 39- compatible: should be one of the following:
40 "socionext,uniphier-sld3-mio-reset" - for PH1-sLD3 SoC. 40 "socionext,uniphier-sld3-mio-reset" - for sLD3 SoC.
41 "socionext,uniphier-ld4-mio-reset" - for PH1-LD4 SoC. 41 "socionext,uniphier-ld4-mio-reset" - for LD4 SoC.
42 "socionext,uniphier-pro4-mio-reset" - for PH1-Pro4 SoC. 42 "socionext,uniphier-pro4-mio-reset" - for Pro4 SoC.
43 "socionext,uniphier-sld8-mio-reset" - for PH1-sLD8 SoC. 43 "socionext,uniphier-sld8-mio-reset" - for sLD8 SoC.
44 "socionext,uniphier-pro5-mio-reset" - for PH1-Pro5 SoC. 44 "socionext,uniphier-pro5-sd-reset" - for Pro5 SoC.
45 "socionext,uniphier-pxs2-mio-reset" - for ProXstream2/PH1-LD6b SoC. 45 "socionext,uniphier-pxs2-sd-reset" - for PXs2/LD6b SoC.
46 "socionext,uniphier-ld11-mio-reset" - for PH1-LD11 SoC. 46 "socionext,uniphier-ld11-mio-reset" - for LD11 SoC.
47 "socionext,uniphier-ld20-mio-reset" - for PH1-LD20 SoC. 47 "socionext,uniphier-ld20-sd-reset" - for LD20 SoC.
48- #reset-cells: should be 1. 48- #reset-cells: should be 1.
49 49
50Example: 50Example:
51 51
52 mioctrl@59810000 { 52 mioctrl@59810000 {
53 compatible = "socionext,uniphier-ld20-mioctrl", 53 compatible = "socionext,uniphier-ld11-mioctrl",
54 "simple-mfd", "syscon"; 54 "simple-mfd", "syscon";
55 reg = <0x59810000 0x800>; 55 reg = <0x59810000 0x800>;
56 56
57 reset { 57 reset {
58 compatible = "socionext,uniphier-ld20-mio-reset"; 58 compatible = "socionext,uniphier-ld11-mio-reset";
59 #reset-cells = <1>; 59 #reset-cells = <1>;
60 }; 60 };
61 61
@@ -68,24 +68,24 @@ Peripheral reset
68 68
69Required properties: 69Required properties:
70- compatible: should be one of the following: 70- compatible: should be one of the following:
71 "socionext,uniphier-ld4-peri-reset" - for PH1-LD4 SoC. 71 "socionext,uniphier-ld4-peri-reset" - for LD4 SoC.
72 "socionext,uniphier-pro4-peri-reset" - for PH1-Pro4 SoC. 72 "socionext,uniphier-pro4-peri-reset" - for Pro4 SoC.
73 "socionext,uniphier-sld8-peri-reset" - for PH1-sLD8 SoC. 73 "socionext,uniphier-sld8-peri-reset" - for sLD8 SoC.
74 "socionext,uniphier-pro5-peri-reset" - for PH1-Pro5 SoC. 74 "socionext,uniphier-pro5-peri-reset" - for Pro5 SoC.
75 "socionext,uniphier-pxs2-peri-reset" - for ProXstream2/PH1-LD6b SoC. 75 "socionext,uniphier-pxs2-peri-reset" - for PXs2/LD6b SoC.
76 "socionext,uniphier-ld11-peri-reset" - for PH1-LD11 SoC. 76 "socionext,uniphier-ld11-peri-reset" - for LD11 SoC.
77 "socionext,uniphier-ld20-peri-reset" - for PH1-LD20 SoC. 77 "socionext,uniphier-ld20-peri-reset" - for LD20 SoC.
78- #reset-cells: should be 1. 78- #reset-cells: should be 1.
79 79
80Example: 80Example:
81 81
82 perictrl@59820000 { 82 perictrl@59820000 {
83 compatible = "socionext,uniphier-ld20-perictrl", 83 compatible = "socionext,uniphier-ld11-perictrl",
84 "simple-mfd", "syscon"; 84 "simple-mfd", "syscon";
85 reg = <0x59820000 0x200>; 85 reg = <0x59820000 0x200>;
86 86
87 reset { 87 reset {
88 compatible = "socionext,uniphier-ld20-peri-reset"; 88 compatible = "socionext,uniphier-ld11-peri-reset";
89 #reset-cells = <1>; 89 #reset-cells = <1>;
90 }; 90 };
91 91
diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.txt b/Documentation/devicetree/bindings/serial/cdns,uart.txt
index a3eb154c32ca..227bb770b027 100644
--- a/Documentation/devicetree/bindings/serial/cdns,uart.txt
+++ b/Documentation/devicetree/bindings/serial/cdns,uart.txt
@@ -1,7 +1,9 @@
1Binding for Cadence UART Controller 1Binding for Cadence UART Controller
2 2
3Required properties: 3Required properties:
4- compatible : should be "cdns,uart-r1p8", or "xlnx,xuartps" 4- compatible :
5 Use "xlnx,xuartps","cdns,uart-r1p8" for Zynq-7xxx SoC.
6 Use "xlnx,zynqmp-uart","cdns,uart-r1p12" for Zynq Ultrascale+ MPSoC.
5- reg: Should contain UART controller registers location and length. 7- reg: Should contain UART controller registers location and length.
6- interrupts: Should contain UART controller interrupts. 8- interrupts: Should contain UART controller interrupts.
7- clocks: Must contain phandles to the UART clocks 9- clocks: Must contain phandles to the UART clocks
diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
index 1e4000d83aee..8d27d1a603e7 100644
--- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
+++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
@@ -9,6 +9,14 @@ Required properties:
9 - "renesas,scifb-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFB compatible UART. 9 - "renesas,scifb-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFB compatible UART.
10 - "renesas,scifa-r8a7740" for R8A7740 (R-Mobile A1) SCIFA compatible UART. 10 - "renesas,scifa-r8a7740" for R8A7740 (R-Mobile A1) SCIFA compatible UART.
11 - "renesas,scifb-r8a7740" for R8A7740 (R-Mobile A1) SCIFB compatible UART. 11 - "renesas,scifb-r8a7740" for R8A7740 (R-Mobile A1) SCIFB compatible UART.
12 - "renesas,scif-r8a7743" for R8A7743 (RZ/G1M) SCIF compatible UART.
13 - "renesas,scifa-r8a7743" for R8A7743 (RZ/G1M) SCIFA compatible UART.
14 - "renesas,scifb-r8a7743" for R8A7743 (RZ/G1M) SCIFB compatible UART.
15 - "renesas,hscif-r8a7743" for R8A7743 (RZ/G1M) HSCIF compatible UART.
16 - "renesas,scif-r8a7745" for R8A7745 (RZ/G1E) SCIF compatible UART.
17 - "renesas,scifa-r8a7745" for R8A7745 (RZ/G1E) SCIFA compatible UART.
18 - "renesas,scifb-r8a7745" for R8A7745 (RZ/G1E) SCIFB compatible UART.
19 - "renesas,hscif-r8a7745" for R8A7745 (RZ/G1E) HSCIF compatible UART.
12 - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART. 20 - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART.
13 - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART. 21 - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART.
14 - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART. 22 - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART.
diff --git a/Documentation/devicetree/bindings/timer/jcore,pit.txt b/Documentation/devicetree/bindings/timer/jcore,pit.txt
new file mode 100644
index 000000000000..af5dd35469d7
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/jcore,pit.txt
@@ -0,0 +1,24 @@
1J-Core Programmable Interval Timer and Clocksource
2
3Required properties:
4
5- compatible: Must be "jcore,pit".
6
7- reg: Memory region(s) for timer/clocksource registers. For SMP,
8 there should be one region per cpu, indexed by the sequential,
9 zero-based hardware cpu number.
10
11- interrupts: An interrupt to assign for the timer. The actual pit
12 core is integrated with the aic and allows the timer interrupt
13 assignment to be programmed by software, but this property is
14 required in order to reserve an interrupt number that doesn't
15 conflict with other devices.
16
17
18Example:
19
20timer@200 {
21 compatible = "jcore,pit";
22 reg = < 0x200 0x30 0x500 0x30 >;
23 interrupts = < 0x48 >;
24};
diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
index 455f2c310a1b..2c30a5479069 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -28,10 +28,7 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties
28- g-use-dma: enable dma usage in gadget driver. 28- g-use-dma: enable dma usage in gadget driver.
29- g-rx-fifo-size: size of rx fifo size in gadget mode. 29- g-rx-fifo-size: size of rx fifo size in gadget mode.
30- g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. 30- g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
31 31- g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode.
32Deprecated properties:
33- g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0)
34 in gadget mode.
35 32
36Example: 33Example:
37 34
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 219ffd41a911..74329fd0add2 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -395,32 +395,6 @@ is not associated with a file:
395 395
396 or if empty, the mapping is anonymous. 396 or if empty, the mapping is anonymous.
397 397
398The /proc/PID/task/TID/maps is a view of the virtual memory from the viewpoint
399of the individual tasks of a process. In this file you will see a mapping marked
400as [stack] if that task sees it as a stack. Hence, for the example above, the
401task-level map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this:
402
40308048000-08049000 r-xp 00000000 03:00 8312 /opt/test
40408049000-0804a000 rw-p 00001000 03:00 8312 /opt/test
4050804a000-0806b000 rw-p 00000000 00:00 0 [heap]
406a7cb1000-a7cb2000 ---p 00000000 00:00 0
407a7cb2000-a7eb2000 rw-p 00000000 00:00 0
408a7eb2000-a7eb3000 ---p 00000000 00:00 0
409a7eb3000-a7ed5000 rw-p 00000000 00:00 0 [stack]
410a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6
411a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6
412a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6
413a800b000-a800e000 rw-p 00000000 00:00 0
414a800e000-a8022000 r-xp 00000000 03:00 14462 /lib/libpthread.so.0
415a8022000-a8023000 r--p 00013000 03:00 14462 /lib/libpthread.so.0
416a8023000-a8024000 rw-p 00014000 03:00 14462 /lib/libpthread.so.0
417a8024000-a8027000 rw-p 00000000 00:00 0
418a8027000-a8043000 r-xp 00000000 03:00 8317 /lib/ld-linux.so.2
419a8043000-a8044000 r--p 0001b000 03:00 8317 /lib/ld-linux.so.2
420a8044000-a8045000 rw-p 0001c000 03:00 8317 /lib/ld-linux.so.2
421aff35000-aff4a000 rw-p 00000000 00:00 0
422ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
423
424The /proc/PID/smaps is an extension based on maps, showing the memory 398The /proc/PID/smaps is an extension based on maps, showing the memory
425consumption for each of the process's mappings. For each of mappings there 399consumption for each of the process's mappings. For each of mappings there
426is a series of lines such as the following: 400is a series of lines such as the following:
diff --git a/Documentation/gpio/board.txt b/Documentation/gpio/board.txt
index 40884c4fe40c..a0f61898d493 100644
--- a/Documentation/gpio/board.txt
+++ b/Documentation/gpio/board.txt
@@ -6,7 +6,7 @@ Note that it only applies to the new descriptor-based interface. For a
6description of the deprecated integer-based GPIO interface please refer to 6description of the deprecated integer-based GPIO interface please refer to
7gpio-legacy.txt (actually, there is no real mapping possible with the old 7gpio-legacy.txt (actually, there is no real mapping possible with the old
8interface; you just fetch an integer from somewhere and request the 8interface; you just fetch an integer from somewhere and request the
9corresponding GPIO. 9corresponding GPIO).
10 10
11All platforms can enable the GPIO library, but if the platform strictly 11All platforms can enable the GPIO library, but if the platform strictly
12requires GPIO functionality to be present, it needs to select GPIOLIB from its 12requires GPIO functionality to be present, it needs to select GPIOLIB from its
@@ -162,6 +162,9 @@ The driver controlling "foo.0" will then be able to obtain its GPIOs as follows:
162 162
163Since the "led" GPIOs are mapped as active-high, this example will switch their 163Since the "led" GPIOs are mapped as active-high, this example will switch their
164signals to 1, i.e. enabling the LEDs. And for the "power" GPIO, which is mapped 164signals to 1, i.e. enabling the LEDs. And for the "power" GPIO, which is mapped
165as active-low, its actual signal will be 0 after this code. Contrary to the legacy 165as active-low, its actual signal will be 0 after this code. Contrary to the
166integer GPIO interface, the active-low property is handled during mapping and is 166legacy integer GPIO interface, the active-low property is handled during
167thus transparent to GPIO consumers. 167mapping and is thus transparent to GPIO consumers.
168
169A set of functions such as gpiod_set_value() is available to work with
170the new descriptor-oriented interface.
diff --git a/Documentation/networking/netdev-FAQ.txt b/Documentation/networking/netdev-FAQ.txt
index 0fe1c6e0dbcd..a20b2fae942b 100644
--- a/Documentation/networking/netdev-FAQ.txt
+++ b/Documentation/networking/netdev-FAQ.txt
@@ -29,8 +29,8 @@ A: There are always two trees (git repositories) in play. Both are driven
29 Linus, and net-next is where the new code goes for the future release. 29 Linus, and net-next is where the new code goes for the future release.
30 You can find the trees here: 30 You can find the trees here:
31 31
32 http://git.kernel.org/?p=linux/kernel/git/davem/net.git 32 https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
33 http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git 33 https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
34 34
35Q: How often do changes from these trees make it to the mainline Linus tree? 35Q: How often do changes from these trees make it to the mainline Linus tree?
36 36
@@ -76,7 +76,7 @@ Q: So where are we now in this cycle?
76 76
77A: Load the mainline (Linus) page here: 77A: Load the mainline (Linus) page here:
78 78
79 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git 79 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
80 80
81 and note the top of the "tags" section. If it is rc1, it is early 81 and note the top of the "tags" section. If it is rc1, it is early
82 in the dev cycle. If it was tagged rc7 a week ago, then a release 82 in the dev cycle. If it was tagged rc7 a week ago, then a release
@@ -123,7 +123,7 @@ A: Normally Greg Kroah-Hartman collects stable commits himself, but
123 123
124 It contains the patches which Dave has selected, but not yet handed 124 It contains the patches which Dave has selected, but not yet handed
125 off to Greg. If Greg already has the patch, then it will be here: 125 off to Greg. If Greg already has the patch, then it will be here:
126 http://git.kernel.org/cgit/linux/kernel/git/stable/stable-queue.git 126 https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git
127 127
128 A quick way to find whether the patch is in this stable-queue is 128 A quick way to find whether the patch is in this stable-queue is
129 to simply clone the repo, and then git grep the mainline commit ID, e.g. 129 to simply clone the repo, and then git grep the mainline commit ID, e.g.
diff --git a/Documentation/networking/nf_conntrack-sysctl.txt b/Documentation/networking/nf_conntrack-sysctl.txt
index 4fb51d32fccc..399e4e866a9c 100644
--- a/Documentation/networking/nf_conntrack-sysctl.txt
+++ b/Documentation/networking/nf_conntrack-sysctl.txt
@@ -33,24 +33,6 @@ nf_conntrack_events - BOOLEAN
33 If this option is enabled, the connection tracking code will 33 If this option is enabled, the connection tracking code will
34 provide userspace with connection tracking events via ctnetlink. 34 provide userspace with connection tracking events via ctnetlink.
35 35
36nf_conntrack_events_retry_timeout - INTEGER (seconds)
37 default 15
38
39 This option is only relevant when "reliable connection tracking
40 events" are used. Normally, ctnetlink is "lossy", that is,
41 events are normally dropped when userspace listeners can't keep up.
42
43 Userspace can request "reliable event mode". When this mode is
44 active, the conntrack will only be destroyed after the event was
45 delivered. If event delivery fails, the kernel periodically
46 re-tries to send the event to userspace.
47
48 This is the maximum interval the kernel should use when re-trying
49 to deliver the destroy event.
50
51 A higher number means there will be fewer delivery retries and it
52 will take longer for a backlog to be processed.
53
54nf_conntrack_expect_max - INTEGER 36nf_conntrack_expect_max - INTEGER
55 Maximum size of expectation table. Default value is 37 Maximum size of expectation table. Default value is
56 nf_conntrack_buckets / 256. Minimum is 1. 38 nf_conntrack_buckets / 256. Minimum is 1.
diff --git a/MAINTAINERS b/MAINTAINERS
index 1cd38a7e0064..4012c2f98617 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1442,6 +1442,7 @@ F: drivers/cpufreq/mvebu-cpufreq.c
1442F: arch/arm/configs/mvebu_*_defconfig 1442F: arch/arm/configs/mvebu_*_defconfig
1443 1443
1444ARM/Marvell Berlin SoC support 1444ARM/Marvell Berlin SoC support
1445M: Jisheng Zhang <jszhang@marvell.com>
1445M: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> 1446M: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
1446L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1447L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1447S: Maintained 1448S: Maintained
@@ -2551,15 +2552,18 @@ S: Supported
2551F: drivers/net/ethernet/broadcom/genet/ 2552F: drivers/net/ethernet/broadcom/genet/
2552 2553
2553BROADCOM BNX2 GIGABIT ETHERNET DRIVER 2554BROADCOM BNX2 GIGABIT ETHERNET DRIVER
2554M: Sony Chacko <sony.chacko@qlogic.com> 2555M: Rasesh Mody <rasesh.mody@cavium.com>
2555M: Dept-HSGLinuxNICDev@qlogic.com 2556M: Harish Patil <harish.patil@cavium.com>
2557M: Dept-GELinuxNICDev@cavium.com
2556L: netdev@vger.kernel.org 2558L: netdev@vger.kernel.org
2557S: Supported 2559S: Supported
2558F: drivers/net/ethernet/broadcom/bnx2.* 2560F: drivers/net/ethernet/broadcom/bnx2.*
2559F: drivers/net/ethernet/broadcom/bnx2_* 2561F: drivers/net/ethernet/broadcom/bnx2_*
2560 2562
2561BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER 2563BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER
2562M: Ariel Elior <ariel.elior@qlogic.com> 2564M: Yuval Mintz <Yuval.Mintz@cavium.com>
2565M: Ariel Elior <ariel.elior@cavium.com>
2566M: everest-linux-l2@cavium.com
2563L: netdev@vger.kernel.org 2567L: netdev@vger.kernel.org
2564S: Supported 2568S: Supported
2565F: drivers/net/ethernet/broadcom/bnx2x/ 2569F: drivers/net/ethernet/broadcom/bnx2x/
@@ -2766,7 +2770,9 @@ S: Supported
2766F: drivers/scsi/bfa/ 2770F: drivers/scsi/bfa/
2767 2771
2768BROCADE BNA 10 GIGABIT ETHERNET DRIVER 2772BROCADE BNA 10 GIGABIT ETHERNET DRIVER
2769M: Rasesh Mody <rasesh.mody@qlogic.com> 2773M: Rasesh Mody <rasesh.mody@cavium.com>
2774M: Sudarsana Kalluru <sudarsana.kalluru@cavium.com>
2775M: Dept-GELinuxNICDev@cavium.com
2770L: netdev@vger.kernel.org 2776L: netdev@vger.kernel.org
2771S: Supported 2777S: Supported
2772F: drivers/net/ethernet/brocade/bna/ 2778F: drivers/net/ethernet/brocade/bna/
@@ -4620,8 +4626,9 @@ F: sound/usb/misc/ua101.c
4620 4626
4621EXTENSIBLE FIRMWARE INTERFACE (EFI) 4627EXTENSIBLE FIRMWARE INTERFACE (EFI)
4622M: Matt Fleming <matt@codeblueprint.co.uk> 4628M: Matt Fleming <matt@codeblueprint.co.uk>
4629M: Ard Biesheuvel <ard.biesheuvel@linaro.org>
4623L: linux-efi@vger.kernel.org 4630L: linux-efi@vger.kernel.org
4624T: git git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git 4631T: git git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git
4625S: Maintained 4632S: Maintained
4626F: Documentation/efi-stub.txt 4633F: Documentation/efi-stub.txt
4627F: arch/ia64/kernel/efi.c 4634F: arch/ia64/kernel/efi.c
@@ -5286,6 +5293,12 @@ M: Joe Perches <joe@perches.com>
5286S: Maintained 5293S: Maintained
5287F: scripts/get_maintainer.pl 5294F: scripts/get_maintainer.pl
5288 5295
5296GENWQE (IBM Generic Workqueue Card)
5297M: Frank Haverkamp <haver@linux.vnet.ibm.com>
5298M: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
5299S: Supported
5300F: drivers/misc/genwqe/
5301
5289GFS2 FILE SYSTEM 5302GFS2 FILE SYSTEM
5290M: Steven Whitehouse <swhiteho@redhat.com> 5303M: Steven Whitehouse <swhiteho@redhat.com>
5291M: Bob Peterson <rpeterso@redhat.com> 5304M: Bob Peterson <rpeterso@redhat.com>
@@ -8099,6 +8112,7 @@ S: Maintained
8099F: drivers/media/dvb-frontends/mn88473* 8112F: drivers/media/dvb-frontends/mn88473*
8100 8113
8101MODULE SUPPORT 8114MODULE SUPPORT
8115M: Jessica Yu <jeyu@redhat.com>
8102M: Rusty Russell <rusty@rustcorp.com.au> 8116M: Rusty Russell <rusty@rustcorp.com.au>
8103S: Maintained 8117S: Maintained
8104F: include/linux/module.h 8118F: include/linux/module.h
@@ -8212,7 +8226,7 @@ F: include/linux/mfd/
8212MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM 8226MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM
8213M: Ulf Hansson <ulf.hansson@linaro.org> 8227M: Ulf Hansson <ulf.hansson@linaro.org>
8214L: linux-mmc@vger.kernel.org 8228L: linux-mmc@vger.kernel.org
8215T: git git://git.linaro.org/people/ulf.hansson/mmc.git 8229T: git git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git
8216S: Maintained 8230S: Maintained
8217F: Documentation/devicetree/bindings/mmc/ 8231F: Documentation/devicetree/bindings/mmc/
8218F: drivers/mmc/ 8232F: drivers/mmc/
@@ -8508,11 +8522,10 @@ F: Documentation/devicetree/bindings/net/wireless/
8508F: drivers/net/wireless/ 8522F: drivers/net/wireless/
8509 8523
8510NETXEN (1/10) GbE SUPPORT 8524NETXEN (1/10) GbE SUPPORT
8511M: Manish Chopra <manish.chopra@qlogic.com> 8525M: Manish Chopra <manish.chopra@cavium.com>
8512M: Sony Chacko <sony.chacko@qlogic.com> 8526M: Rahul Verma <rahul.verma@cavium.com>
8513M: Rajesh Borundia <rajesh.borundia@qlogic.com> 8527M: Dept-GELinuxNICDev@cavium.com
8514L: netdev@vger.kernel.org 8528L: netdev@vger.kernel.org
8515W: http://www.qlogic.com
8516S: Supported 8529S: Supported
8517F: drivers/net/ethernet/qlogic/netxen/ 8530F: drivers/net/ethernet/qlogic/netxen/
8518 8531
@@ -9299,7 +9312,7 @@ S: Maintained
9299F: drivers/pci/host/*designware* 9312F: drivers/pci/host/*designware*
9300 9313
9301PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE 9314PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE
9302M: Joao Pinto <jpinto@synopsys.com> 9315M: Jose Abreu <Jose.Abreu@synopsys.com>
9303L: linux-pci@vger.kernel.org 9316L: linux-pci@vger.kernel.org
9304S: Maintained 9317S: Maintained
9305F: Documentation/devicetree/bindings/pci/designware-pcie.txt 9318F: Documentation/devicetree/bindings/pci/designware-pcie.txt
@@ -9888,33 +9901,32 @@ F: Documentation/scsi/LICENSE.qla4xxx
9888F: drivers/scsi/qla4xxx/ 9901F: drivers/scsi/qla4xxx/
9889 9902
9890QLOGIC QLA3XXX NETWORK DRIVER 9903QLOGIC QLA3XXX NETWORK DRIVER
9891M: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com> 9904M: Dept-GELinuxNICDev@cavium.com
9892M: Ron Mercer <ron.mercer@qlogic.com>
9893M: linux-driver@qlogic.com
9894L: netdev@vger.kernel.org 9905L: netdev@vger.kernel.org
9895S: Supported 9906S: Supported
9896F: Documentation/networking/LICENSE.qla3xxx 9907F: Documentation/networking/LICENSE.qla3xxx
9897F: drivers/net/ethernet/qlogic/qla3xxx.* 9908F: drivers/net/ethernet/qlogic/qla3xxx.*
9898 9909
9899QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER 9910QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER
9900M: Dept-GELinuxNICDev@qlogic.com 9911M: Harish Patil <harish.patil@cavium.com>
9912M: Manish Chopra <manish.chopra@cavium.com>
9913M: Dept-GELinuxNICDev@cavium.com
9901L: netdev@vger.kernel.org 9914L: netdev@vger.kernel.org
9902S: Supported 9915S: Supported
9903F: drivers/net/ethernet/qlogic/qlcnic/ 9916F: drivers/net/ethernet/qlogic/qlcnic/
9904 9917
9905QLOGIC QLGE 10Gb ETHERNET DRIVER 9918QLOGIC QLGE 10Gb ETHERNET DRIVER
9906M: Harish Patil <harish.patil@qlogic.com> 9919M: Harish Patil <harish.patil@cavium.com>
9907M: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com> 9920M: Manish Chopra <manish.chopra@cavium.com>
9908M: Dept-GELinuxNICDev@qlogic.com 9921M: Dept-GELinuxNICDev@cavium.com
9909M: linux-driver@qlogic.com
9910L: netdev@vger.kernel.org 9922L: netdev@vger.kernel.org
9911S: Supported 9923S: Supported
9912F: drivers/net/ethernet/qlogic/qlge/ 9924F: drivers/net/ethernet/qlogic/qlge/
9913 9925
9914QLOGIC QL4xxx ETHERNET DRIVER 9926QLOGIC QL4xxx ETHERNET DRIVER
9915M: Yuval Mintz <Yuval.Mintz@qlogic.com> 9927M: Yuval Mintz <Yuval.Mintz@cavium.com>
9916M: Ariel Elior <Ariel.Elior@qlogic.com> 9928M: Ariel Elior <Ariel.Elior@cavium.com>
9917M: everest-linux-l2@qlogic.com 9929M: everest-linux-l2@cavium.com
9918L: netdev@vger.kernel.org 9930L: netdev@vger.kernel.org
9919S: Supported 9931S: Supported
9920F: drivers/net/ethernet/qlogic/qed/ 9932F: drivers/net/ethernet/qlogic/qed/
diff --git a/Makefile b/Makefile
index 512e47a53e9a..a2650f9c6a25 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 9 2PATCHLEVEL = 9
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc3
5NAME = Psychotic Stoned Sheep 5NAME = Psychotic Stoned Sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ecd12379e2cd..bd204bfa29ed 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -41,6 +41,8 @@ config ARC
41 select PERF_USE_VMALLOC 41 select PERF_USE_VMALLOC
42 select HAVE_DEBUG_STACKOVERFLOW 42 select HAVE_DEBUG_STACKOVERFLOW
43 select HAVE_GENERIC_DMA_COHERENT 43 select HAVE_GENERIC_DMA_COHERENT
44 select HAVE_KERNEL_GZIP
45 select HAVE_KERNEL_LZMA
44 46
45config MIGHT_HAVE_PCI 47config MIGHT_HAVE_PCI
46 bool 48 bool
@@ -186,14 +188,6 @@ if SMP
186config ARC_HAS_COH_CACHES 188config ARC_HAS_COH_CACHES
187 def_bool n 189 def_bool n
188 190
189config ARC_MCIP
190 bool "ARConnect Multicore IP (MCIP) Support "
191 depends on ISA_ARCV2
192 help
193 This IP block enables SMP in ARC-HS38 cores.
194 It provides for cross-core interrupts, multi-core debug
195 hardware semaphores, shared memory,....
196
197config NR_CPUS 191config NR_CPUS
198 int "Maximum number of CPUs (2-4096)" 192 int "Maximum number of CPUs (2-4096)"
199 range 2 4096 193 range 2 4096
@@ -211,6 +205,15 @@ config ARC_SMP_HALT_ON_RESET
211 205
212endif #SMP 206endif #SMP
213 207
208config ARC_MCIP
209 bool "ARConnect Multicore IP (MCIP) Support "
210 depends on ISA_ARCV2
211 default y if SMP
212 help
213 This IP block enables SMP in ARC-HS38 cores.
214 It provides for cross-core interrupts, multi-core debug
215 hardware semaphores, shared memory,....
216
214menuconfig ARC_CACHE 217menuconfig ARC_CACHE
215 bool "Enable Cache Support" 218 bool "Enable Cache Support"
216 default y 219 default y
@@ -537,14 +540,6 @@ config ARC_DBG_TLB_PARANOIA
537 bool "Paranoia Checks in Low Level TLB Handlers" 540 bool "Paranoia Checks in Low Level TLB Handlers"
538 default n 541 default n
539 542
540config ARC_DBG_TLB_MISS_COUNT
541 bool "Profile TLB Misses"
542 default n
543 select DEBUG_FS
544 help
545 Counts number of I and D TLB Misses and exports them via Debugfs
546 The counters can be cleared via Debugfs as well
547
548endif 543endif
549 544
550config ARC_UBOOT_SUPPORT 545config ARC_UBOOT_SUPPORT
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index aa82d13d4213..864adad52280 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -50,9 +50,6 @@ atleast_gcc44 := $(call cc-ifversion, -ge, 0404, y)
50 50
51cflags-$(atleast_gcc44) += -fsection-anchors 51cflags-$(atleast_gcc44) += -fsection-anchors
52 52
53cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
54cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
55
56ifdef CONFIG_ISA_ARCV2 53ifdef CONFIG_ISA_ARCV2
57 54
58ifndef CONFIG_ARC_HAS_LL64 55ifndef CONFIG_ARC_HAS_LL64
diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index e597cb34c16a..f94cf151e06a 100644
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -14,9 +14,15 @@ UIMAGE_ENTRYADDR = $(LINUX_START_TEXT)
14 14
15suffix-y := bin 15suffix-y := bin
16suffix-$(CONFIG_KERNEL_GZIP) := gz 16suffix-$(CONFIG_KERNEL_GZIP) := gz
17suffix-$(CONFIG_KERNEL_LZMA) := lzma
17 18
18targets += uImage uImage.bin uImage.gz 19targets += uImage
19extra-y += vmlinux.bin vmlinux.bin.gz 20targets += uImage.bin
21targets += uImage.gz
22targets += uImage.lzma
23extra-y += vmlinux.bin
24extra-y += vmlinux.bin.gz
25extra-y += vmlinux.bin.lzma
20 26
21$(obj)/vmlinux.bin: vmlinux FORCE 27$(obj)/vmlinux.bin: vmlinux FORCE
22 $(call if_changed,objcopy) 28 $(call if_changed,objcopy)
@@ -24,12 +30,18 @@ $(obj)/vmlinux.bin: vmlinux FORCE
24$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 30$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
25 $(call if_changed,gzip) 31 $(call if_changed,gzip)
26 32
33$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
34 $(call if_changed,lzma)
35
27$(obj)/uImage.bin: $(obj)/vmlinux.bin FORCE 36$(obj)/uImage.bin: $(obj)/vmlinux.bin FORCE
28 $(call if_changed,uimage,none) 37 $(call if_changed,uimage,none)
29 38
30$(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE 39$(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
31 $(call if_changed,uimage,gzip) 40 $(call if_changed,uimage,gzip)
32 41
42$(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
43 $(call if_changed,uimage,lzma)
44
33$(obj)/uImage: $(obj)/uImage.$(suffix-y) 45$(obj)/uImage: $(obj)/uImage.$(suffix-y)
34 @ln -sf $(notdir $<) $@ 46 @ln -sf $(notdir $<) $@
35 @echo ' Image $@ is ready' 47 @echo ' Image $@ is ready'
diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index db25c65155cb..7f3f9f63708c 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -349,10 +349,11 @@ struct cpuinfo_arc {
349 struct cpuinfo_arc_bpu bpu; 349 struct cpuinfo_arc_bpu bpu;
350 struct bcr_identity core; 350 struct bcr_identity core;
351 struct bcr_isa isa; 351 struct bcr_isa isa;
352 const char *details, *name;
352 unsigned int vec_base; 353 unsigned int vec_base;
353 struct cpuinfo_arc_ccm iccm, dccm; 354 struct cpuinfo_arc_ccm iccm, dccm;
354 struct { 355 struct {
355 unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, pad1:3, 356 unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2,
356 fpu_sp:1, fpu_dp:1, pad2:6, 357 fpu_sp:1, fpu_dp:1, pad2:6,
357 debug:1, ap:1, smart:1, rtt:1, pad3:4, 358 debug:1, ap:1, smart:1, rtt:1, pad3:4,
358 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4; 359 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index fb781e34f322..b3410ff6a62d 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -53,7 +53,7 @@ extern void arc_cache_init(void);
53extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len); 53extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
54extern void read_decode_cache_bcr(void); 54extern void read_decode_cache_bcr(void);
55 55
56extern int ioc_exists; 56extern int ioc_enable;
57extern unsigned long perip_base, perip_end; 57extern unsigned long perip_base, perip_end;
58 58
59#endif /* !__ASSEMBLY__ */ 59#endif /* !__ASSEMBLY__ */
diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
index 7096f97a1434..aa2d6da9d187 100644
--- a/arch/arc/include/asm/elf.h
+++ b/arch/arc/include/asm/elf.h
@@ -54,7 +54,7 @@ extern int elf_check_arch(const struct elf32_hdr *);
54 * the loader. We need to make sure that it is out of the way of the program 54 * the loader. We need to make sure that it is out of the way of the program
55 * that it will "exec", and that there is sufficient room for the brk. 55 * that it will "exec", and that there is sufficient room for the brk.
56 */ 56 */
57#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) 57#define ELF_ET_DYN_BASE (2UL * TASK_SIZE / 3)
58 58
59/* 59/*
60 * When the program starts, a1 contains a pointer to a function to be 60 * When the program starts, a1 contains a pointer to a function to be
diff --git a/arch/arc/include/asm/mcip.h b/arch/arc/include/asm/mcip.h
index 847e3bbe387f..c8fbe4114bad 100644
--- a/arch/arc/include/asm/mcip.h
+++ b/arch/arc/include/asm/mcip.h
@@ -55,6 +55,22 @@ struct mcip_cmd {
55#define IDU_M_DISTRI_DEST 0x2 55#define IDU_M_DISTRI_DEST 0x2
56}; 56};
57 57
58struct mcip_bcr {
59#ifdef CONFIG_CPU_BIG_ENDIAN
60 unsigned int pad3:8,
61 idu:1, llm:1, num_cores:6,
62 iocoh:1, gfrc:1, dbg:1, pad2:1,
63 msg:1, sem:1, ipi:1, pad:1,
64 ver:8;
65#else
66 unsigned int ver:8,
67 pad:1, ipi:1, sem:1, msg:1,
68 pad2:1, dbg:1, gfrc:1, iocoh:1,
69 num_cores:6, llm:1, idu:1,
70 pad3:8;
71#endif
72};
73
58/* 74/*
59 * MCIP programming model 75 * MCIP programming model
60 * 76 *
diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h
index 518222bb3f8e..6e91d8b339c3 100644
--- a/arch/arc/include/asm/module.h
+++ b/arch/arc/include/asm/module.h
@@ -18,6 +18,7 @@
18struct mod_arch_specific { 18struct mod_arch_specific {
19 void *unw_info; 19 void *unw_info;
20 int unw_sec_idx; 20 int unw_sec_idx;
21 const char *secstr;
21}; 22};
22#endif 23#endif
23 24
diff --git a/arch/arc/include/asm/setup.h b/arch/arc/include/asm/setup.h
index 48b37c693db3..cb954cdab070 100644
--- a/arch/arc/include/asm/setup.h
+++ b/arch/arc/include/asm/setup.h
@@ -27,11 +27,6 @@ struct id_to_str {
27 const char *str; 27 const char *str;
28}; 28};
29 29
30struct cpuinfo_data {
31 struct id_to_str info;
32 int up_range;
33};
34
35extern int root_mountflags, end_mem; 30extern int root_mountflags, end_mem;
36 31
37void setup_processor(void); 32void setup_processor(void);
@@ -43,5 +38,6 @@ void __init setup_arch_memory(void);
43#define IS_USED_RUN(v) ((v) ? "" : "(not used) ") 38#define IS_USED_RUN(v) ((v) ? "" : "(not used) ")
44#define IS_USED_CFG(cfg) IS_USED_RUN(IS_ENABLED(cfg)) 39#define IS_USED_CFG(cfg) IS_USED_RUN(IS_ENABLED(cfg))
45#define IS_AVAIL2(v, s, cfg) IS_AVAIL1(v, s), IS_AVAIL1(v, IS_USED_CFG(cfg)) 40#define IS_AVAIL2(v, s, cfg) IS_AVAIL1(v, s), IS_AVAIL1(v, IS_USED_CFG(cfg))
41#define IS_AVAIL3(v, v2, s) IS_AVAIL1(v, s), IS_AVAIL1(v, IS_DISABLED_RUN(v2))
46 42
47#endif /* __ASMARC_SETUP_H */ 43#endif /* __ASMARC_SETUP_H */
diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
index e56f9fcc5581..772b67ca56e7 100644
--- a/arch/arc/include/asm/syscalls.h
+++ b/arch/arc/include/asm/syscalls.h
@@ -17,6 +17,7 @@ int sys_clone_wrapper(int, int, int, int, int);
17int sys_cacheflush(uint32_t, uint32_t uint32_t); 17int sys_cacheflush(uint32_t, uint32_t uint32_t);
18int sys_arc_settls(void *); 18int sys_arc_settls(void *);
19int sys_arc_gettls(void); 19int sys_arc_gettls(void);
20int sys_arc_usr_cmpxchg(int *, int, int);
20 21
21#include <asm-generic/syscalls.h> 22#include <asm-generic/syscalls.h>
22 23
diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h
index 41fa2ec9e02c..9a34136d84b2 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -27,18 +27,19 @@
27 27
28#define NR_syscalls __NR_syscalls 28#define NR_syscalls __NR_syscalls
29 29
30/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
31#define __NR_sysfs (__NR_arch_specific_syscall + 3)
32
30/* ARC specific syscall */ 33/* ARC specific syscall */
31#define __NR_cacheflush (__NR_arch_specific_syscall + 0) 34#define __NR_cacheflush (__NR_arch_specific_syscall + 0)
32#define __NR_arc_settls (__NR_arch_specific_syscall + 1) 35#define __NR_arc_settls (__NR_arch_specific_syscall + 1)
33#define __NR_arc_gettls (__NR_arch_specific_syscall + 2) 36#define __NR_arc_gettls (__NR_arch_specific_syscall + 2)
37#define __NR_arc_usr_cmpxchg (__NR_arch_specific_syscall + 4)
34 38
35__SYSCALL(__NR_cacheflush, sys_cacheflush) 39__SYSCALL(__NR_cacheflush, sys_cacheflush)
36__SYSCALL(__NR_arc_settls, sys_arc_settls) 40__SYSCALL(__NR_arc_settls, sys_arc_settls)
37__SYSCALL(__NR_arc_gettls, sys_arc_gettls) 41__SYSCALL(__NR_arc_gettls, sys_arc_gettls)
38 42__SYSCALL(__NR_arc_usr_cmpxchg, sys_arc_usr_cmpxchg)
39
40/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
41#define __NR_sysfs (__NR_arch_specific_syscall + 3)
42__SYSCALL(__NR_sysfs, sys_sysfs) 43__SYSCALL(__NR_sysfs, sys_sysfs)
43 44
44#undef __SYSCALL 45#undef __SYSCALL
diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c
index 72f9179b1a24..c424d5abc318 100644
--- a/arch/arc/kernel/mcip.c
+++ b/arch/arc/kernel/mcip.c
@@ -15,11 +15,12 @@
15#include <asm/mcip.h> 15#include <asm/mcip.h>
16#include <asm/setup.h> 16#include <asm/setup.h>
17 17
18static char smp_cpuinfo_buf[128];
19static int idu_detected;
20
21static DEFINE_RAW_SPINLOCK(mcip_lock); 18static DEFINE_RAW_SPINLOCK(mcip_lock);
22 19
20#ifdef CONFIG_SMP
21
22static char smp_cpuinfo_buf[128];
23
23static void mcip_setup_per_cpu(int cpu) 24static void mcip_setup_per_cpu(int cpu)
24{ 25{
25 smp_ipi_irq_setup(cpu, IPI_IRQ); 26 smp_ipi_irq_setup(cpu, IPI_IRQ);
@@ -86,21 +87,7 @@ static void mcip_ipi_clear(int irq)
86 87
87static void mcip_probe_n_setup(void) 88static void mcip_probe_n_setup(void)
88{ 89{
89 struct mcip_bcr { 90 struct mcip_bcr mp;
90#ifdef CONFIG_CPU_BIG_ENDIAN
91 unsigned int pad3:8,
92 idu:1, llm:1, num_cores:6,
93 iocoh:1, gfrc:1, dbg:1, pad2:1,
94 msg:1, sem:1, ipi:1, pad:1,
95 ver:8;
96#else
97 unsigned int ver:8,
98 pad:1, ipi:1, sem:1, msg:1,
99 pad2:1, dbg:1, gfrc:1, iocoh:1,
100 num_cores:6, llm:1, idu:1,
101 pad3:8;
102#endif
103 } mp;
104 91
105 READ_BCR(ARC_REG_MCIP_BCR, mp); 92 READ_BCR(ARC_REG_MCIP_BCR, mp);
106 93
@@ -114,7 +101,6 @@ static void mcip_probe_n_setup(void)
114 IS_AVAIL1(mp.gfrc, "GFRC")); 101 IS_AVAIL1(mp.gfrc, "GFRC"));
115 102
116 cpuinfo_arc700[0].extn.gfrc = mp.gfrc; 103 cpuinfo_arc700[0].extn.gfrc = mp.gfrc;
117 idu_detected = mp.idu;
118 104
119 if (mp.dbg) { 105 if (mp.dbg) {
120 __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf); 106 __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf);
@@ -130,6 +116,8 @@ struct plat_smp_ops plat_smp_ops = {
130 .ipi_clear = mcip_ipi_clear, 116 .ipi_clear = mcip_ipi_clear,
131}; 117};
132 118
119#endif
120
133/*************************************************************************** 121/***************************************************************************
134 * ARCv2 Interrupt Distribution Unit (IDU) 122 * ARCv2 Interrupt Distribution Unit (IDU)
135 * 123 *
@@ -295,8 +283,11 @@ idu_of_init(struct device_node *intc, struct device_node *parent)
295 /* Read IDU BCR to confirm nr_irqs */ 283 /* Read IDU BCR to confirm nr_irqs */
296 int nr_irqs = of_irq_count(intc); 284 int nr_irqs = of_irq_count(intc);
297 int i, irq; 285 int i, irq;
286 struct mcip_bcr mp;
287
288 READ_BCR(ARC_REG_MCIP_BCR, mp);
298 289
299 if (!idu_detected) 290 if (!mp.idu)
300 panic("IDU not detected, but DeviceTree using it"); 291 panic("IDU not detected, but DeviceTree using it");
301 292
302 pr_info("MCIP: IDU referenced from Devicetree %d irqs\n", nr_irqs); 293 pr_info("MCIP: IDU referenced from Devicetree %d irqs\n", nr_irqs);
diff --git a/arch/arc/kernel/module.c b/arch/arc/kernel/module.c
index 9a2849756022..42e964db2967 100644
--- a/arch/arc/kernel/module.c
+++ b/arch/arc/kernel/module.c
@@ -30,17 +30,9 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
30 char *secstr, struct module *mod) 30 char *secstr, struct module *mod)
31{ 31{
32#ifdef CONFIG_ARC_DW2_UNWIND 32#ifdef CONFIG_ARC_DW2_UNWIND
33 int i;
34
35 mod->arch.unw_sec_idx = 0; 33 mod->arch.unw_sec_idx = 0;
36 mod->arch.unw_info = NULL; 34 mod->arch.unw_info = NULL;
37 35 mod->arch.secstr = secstr;
38 for (i = 1; i < hdr->e_shnum; i++) {
39 if (strcmp(secstr+sechdrs[i].sh_name, ".eh_frame") == 0) {
40 mod->arch.unw_sec_idx = i;
41 break;
42 }
43 }
44#endif 36#endif
45 return 0; 37 return 0;
46} 38}
@@ -59,29 +51,33 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
59 unsigned int relsec, /* sec index for relo sec */ 51 unsigned int relsec, /* sec index for relo sec */
60 struct module *module) 52 struct module *module)
61{ 53{
62 int i, n; 54 int i, n, relo_type;
63 Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr; 55 Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr;
64 Elf32_Sym *sym_entry, *sym_sec; 56 Elf32_Sym *sym_entry, *sym_sec;
65 Elf32_Addr relocation; 57 Elf32_Addr relocation, location, tgt_addr;
66 Elf32_Addr location; 58 unsigned int tgtsec;
67 Elf32_Addr sec_to_patch; 59
68 int relo_type; 60 /*
69 61 * @relsec has relocations e.g. .rela.init.text
70 sec_to_patch = sechdrs[sechdrs[relsec].sh_info].sh_addr; 62 * @tgtsec is section to patch e.g. .init.text
63 */
64 tgtsec = sechdrs[relsec].sh_info;
65 tgt_addr = sechdrs[tgtsec].sh_addr;
71 sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr; 66 sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr;
72 n = sechdrs[relsec].sh_size / sizeof(*rel_entry); 67 n = sechdrs[relsec].sh_size / sizeof(*rel_entry);
73 68
74 pr_debug("\n========== Module Sym reloc ===========================\n"); 69 pr_debug("\nSection to fixup %s @%x\n",
75 pr_debug("Section to fixup %x\n", sec_to_patch); 70 module->arch.secstr + sechdrs[tgtsec].sh_name, tgt_addr);
76 pr_debug("=========================================================\n"); 71 pr_debug("=========================================================\n");
77 pr_debug("rela->r_off | rela->addend | sym->st_value | ADDR | VALUE\n"); 72 pr_debug("r_off\tr_add\tst_value ADDRESS VALUE\n");
78 pr_debug("=========================================================\n"); 73 pr_debug("=========================================================\n");
79 74
80 /* Loop thru entries in relocation section */ 75 /* Loop thru entries in relocation section */
81 for (i = 0; i < n; i++) { 76 for (i = 0; i < n; i++) {
77 const char *s;
82 78
83 /* This is where to make the change */ 79 /* This is where to make the change */
84 location = sec_to_patch + rel_entry[i].r_offset; 80 location = tgt_addr + rel_entry[i].r_offset;
85 81
86 /* This is the symbol it is referring to. Note that all 82 /* This is the symbol it is referring to. Note that all
87 undefined symbols have been resolved. */ 83 undefined symbols have been resolved. */
@@ -89,10 +85,15 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
89 85
90 relocation = sym_entry->st_value + rel_entry[i].r_addend; 86 relocation = sym_entry->st_value + rel_entry[i].r_addend;
91 87
92 pr_debug("\t%x\t\t%x\t\t%x %x %x [%s]\n", 88 if (sym_entry->st_name == 0 && ELF_ST_TYPE (sym_entry->st_info) == STT_SECTION) {
93 rel_entry[i].r_offset, rel_entry[i].r_addend, 89 s = module->arch.secstr + sechdrs[sym_entry->st_shndx].sh_name;
94 sym_entry->st_value, location, relocation, 90 } else {
95 strtab + sym_entry->st_name); 91 s = strtab + sym_entry->st_name;
92 }
93
94 pr_debug(" %x\t%x\t%x %x %x [%s]\n",
95 rel_entry[i].r_offset, rel_entry[i].r_addend,
96 sym_entry->st_value, location, relocation, s);
96 97
97 /* This assumes modules are built with -mlong-calls 98 /* This assumes modules are built with -mlong-calls
98 * so any branches/jumps are absolute 32 bit jmps 99 * so any branches/jumps are absolute 32 bit jmps
@@ -111,6 +112,10 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
111 goto relo_err; 112 goto relo_err;
112 113
113 } 114 }
115
116 if (strcmp(module->arch.secstr+sechdrs[tgtsec].sh_name, ".eh_frame") == 0)
117 module->arch.unw_sec_idx = tgtsec;
118
114 return 0; 119 return 0;
115 120
116relo_err: 121relo_err:
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index be1972bd2729..59aa43cb146e 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -41,6 +41,39 @@ SYSCALL_DEFINE0(arc_gettls)
41 return task_thread_info(current)->thr_ptr; 41 return task_thread_info(current)->thr_ptr;
42} 42}
43 43
44SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
45{
46 int uval;
47 int ret;
48
49 /*
50 * This is only for old cores lacking LLOCK/SCOND, which by defintion
51 * can't possibly be SMP. Thus doesn't need to be SMP safe.
52 * And this also helps reduce the overhead for serializing in
53 * the UP case
54 */
55 WARN_ON_ONCE(IS_ENABLED(CONFIG_SMP));
56
57 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
58 return -EFAULT;
59
60 preempt_disable();
61
62 ret = __get_user(uval, uaddr);
63 if (ret)
64 goto done;
65
66 if (uval != expected)
67 ret = -EAGAIN;
68 else
69 ret = __put_user(new, uaddr);
70
71done:
72 preempt_enable();
73
74 return ret;
75}
76
44void arch_cpu_idle(void) 77void arch_cpu_idle(void)
45{ 78{
46 /* sleep, but enable all interrupts before committing */ 79 /* sleep, but enable all interrupts before committing */
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 3df7f9c72f42..0385df77a697 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -40,6 +40,29 @@ struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
40 40
41struct cpuinfo_arc cpuinfo_arc700[NR_CPUS]; 41struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
42 42
43static const struct id_to_str arc_cpu_rel[] = {
44#ifdef CONFIG_ISA_ARCOMPACT
45 { 0x34, "R4.10"},
46 { 0x35, "R4.11"},
47#else
48 { 0x51, "R2.0" },
49 { 0x52, "R2.1" },
50 { 0x53, "R3.0" },
51#endif
52 { 0x00, NULL }
53};
54
55static const struct id_to_str arc_cpu_nm[] = {
56#ifdef CONFIG_ISA_ARCOMPACT
57 { 0x20, "ARC 600" },
58 { 0x30, "ARC 770" }, /* 750 identified seperately */
59#else
60 { 0x40, "ARC EM" },
61 { 0x50, "ARC HS38" },
62#endif
63 { 0x00, "Unknown" }
64};
65
43static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu) 66static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu)
44{ 67{
45 if (is_isa_arcompact()) { 68 if (is_isa_arcompact()) {
@@ -92,11 +115,26 @@ static void read_arc_build_cfg_regs(void)
92 struct bcr_timer timer; 115 struct bcr_timer timer;
93 struct bcr_generic bcr; 116 struct bcr_generic bcr;
94 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; 117 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
118 const struct id_to_str *tbl;
119
95 FIX_PTR(cpu); 120 FIX_PTR(cpu);
96 121
97 READ_BCR(AUX_IDENTITY, cpu->core); 122 READ_BCR(AUX_IDENTITY, cpu->core);
98 READ_BCR(ARC_REG_ISA_CFG_BCR, cpu->isa); 123 READ_BCR(ARC_REG_ISA_CFG_BCR, cpu->isa);
99 124
125 for (tbl = &arc_cpu_rel[0]; tbl->id != 0; tbl++) {
126 if (cpu->core.family == tbl->id) {
127 cpu->details = tbl->str;
128 break;
129 }
130 }
131
132 for (tbl = &arc_cpu_nm[0]; tbl->id != 0; tbl++) {
133 if ((cpu->core.family & 0xF0) == tbl->id)
134 break;
135 }
136 cpu->name = tbl->str;
137
100 READ_BCR(ARC_REG_TIMERS_BCR, timer); 138 READ_BCR(ARC_REG_TIMERS_BCR, timer);
101 cpu->extn.timer0 = timer.t0; 139 cpu->extn.timer0 = timer.t0;
102 cpu->extn.timer1 = timer.t1; 140 cpu->extn.timer1 = timer.t1;
@@ -111,6 +149,9 @@ static void read_arc_build_cfg_regs(void)
111 cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0; /* 1,3 */ 149 cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0; /* 1,3 */
112 cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0; 150 cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0;
113 cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */ 151 cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */
152 cpu->extn.swape = (cpu->core.family >= 0x34) ? 1 :
153 IS_ENABLED(CONFIG_ARC_HAS_SWAPE);
154
114 READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem); 155 READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem);
115 156
116 /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */ 157 /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
@@ -160,64 +201,38 @@ static void read_arc_build_cfg_regs(void)
160 cpu->extn.rtt = bcr.ver ? 1 : 0; 201 cpu->extn.rtt = bcr.ver ? 1 : 0;
161 202
162 cpu->extn.debug = cpu->extn.ap | cpu->extn.smart | cpu->extn.rtt; 203 cpu->extn.debug = cpu->extn.ap | cpu->extn.smart | cpu->extn.rtt;
163}
164 204
165static const struct cpuinfo_data arc_cpu_tbl[] = { 205 /* some hacks for lack of feature BCR info in old ARC700 cores */
166#ifdef CONFIG_ISA_ARCOMPACT 206 if (is_isa_arcompact()) {
167 { {0x20, "ARC 600" }, 0x2F}, 207 if (!cpu->isa.ver) /* ISA BCR absent, use Kconfig info */
168 { {0x30, "ARC 700" }, 0x33}, 208 cpu->isa.atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
169 { {0x34, "ARC 700 R4.10"}, 0x34}, 209 else
170 { {0x35, "ARC 700 R4.11"}, 0x35}, 210 cpu->isa.atomic = cpu->isa.atomic1;
171#else
172 { {0x50, "ARC HS38 R2.0"}, 0x51},
173 { {0x52, "ARC HS38 R2.1"}, 0x52},
174 { {0x53, "ARC HS38 R3.0"}, 0x53},
175#endif
176 { {0x00, NULL } }
177};
178 211
212 cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
213
214 /* there's no direct way to distinguish 750 vs. 770 */
215 if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
216 cpu->name = "ARC750";
217 }
218}
179 219
180static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len) 220static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
181{ 221{
182 struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id]; 222 struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
183 struct bcr_identity *core = &cpu->core; 223 struct bcr_identity *core = &cpu->core;
184 const struct cpuinfo_data *tbl; 224 int i, n = 0;
185 char *isa_nm;
186 int i, be, atomic;
187 int n = 0;
188 225
189 FIX_PTR(cpu); 226 FIX_PTR(cpu);
190 227
191 if (is_isa_arcompact()) {
192 isa_nm = "ARCompact";
193 be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
194
195 atomic = cpu->isa.atomic1;
196 if (!cpu->isa.ver) /* ISA BCR absent, use Kconfig info */
197 atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
198 } else {
199 isa_nm = "ARCv2";
200 be = cpu->isa.be;
201 atomic = cpu->isa.atomic;
202 }
203
204 n += scnprintf(buf + n, len - n, 228 n += scnprintf(buf + n, len - n,
205 "\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n", 229 "\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n",
206 core->family, core->cpu_id, core->chip_id); 230 core->family, core->cpu_id, core->chip_id);
207 231
208 for (tbl = &arc_cpu_tbl[0]; tbl->info.id != 0; tbl++) { 232 n += scnprintf(buf + n, len - n, "processor [%d]\t: %s %s (%s ISA) %s\n",
209 if ((core->family >= tbl->info.id) && 233 cpu_id, cpu->name, cpu->details,
210 (core->family <= tbl->up_range)) { 234 is_isa_arcompact() ? "ARCompact" : "ARCv2",
211 n += scnprintf(buf + n, len - n, 235 IS_AVAIL1(cpu->isa.be, "[Big-Endian]"));
212 "processor [%d]\t: %s (%s ISA) %s\n",
213 cpu_id, tbl->info.str, isa_nm,
214 IS_AVAIL1(be, "[Big-Endian]"));
215 break;
216 }
217 }
218
219 if (tbl->info.id == 0)
220 n += scnprintf(buf + n, len - n, "UNKNOWN ARC Processor\n");
221 236
222 n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ", 237 n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
223 IS_AVAIL1(cpu->extn.timer0, "Timer0 "), 238 IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
@@ -226,7 +241,7 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
226 CONFIG_ARC_HAS_RTC)); 241 CONFIG_ARC_HAS_RTC));
227 242
228 n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s", 243 n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
229 IS_AVAIL2(atomic, "atomic ", CONFIG_ARC_HAS_LLSC), 244 IS_AVAIL2(cpu->isa.atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
230 IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64), 245 IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64),
231 IS_AVAIL1(cpu->isa.unalign, "unalign (not used)")); 246 IS_AVAIL1(cpu->isa.unalign, "unalign (not used)"));
232 247
@@ -253,7 +268,7 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
253 IS_AVAIL1(cpu->extn.swap, "swap "), 268 IS_AVAIL1(cpu->extn.swap, "swap "),
254 IS_AVAIL1(cpu->extn.minmax, "minmax "), 269 IS_AVAIL1(cpu->extn.minmax, "minmax "),
255 IS_AVAIL1(cpu->extn.crc, "crc "), 270 IS_AVAIL1(cpu->extn.crc, "crc "),
256 IS_AVAIL2(1, "swape", CONFIG_ARC_HAS_SWAPE)); 271 IS_AVAIL2(cpu->extn.swape, "swape", CONFIG_ARC_HAS_SWAPE));
257 272
258 if (cpu->bpu.ver) 273 if (cpu->bpu.ver)
259 n += scnprintf(buf + n, len - n, 274 n += scnprintf(buf + n, len - n,
@@ -272,9 +287,7 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
272 287
273 FIX_PTR(cpu); 288 FIX_PTR(cpu);
274 289
275 n += scnprintf(buf + n, len - n, 290 n += scnprintf(buf + n, len - n, "Vector Table\t: %#x\n", cpu->vec_base);
276 "Vector Table\t: %#x\nPeripherals\t: %#lx:%#lx\n",
277 cpu->vec_base, perip_base, perip_end);
278 291
279 if (cpu->extn.fpu_sp || cpu->extn.fpu_dp) 292 if (cpu->extn.fpu_sp || cpu->extn.fpu_dp)
280 n += scnprintf(buf + n, len - n, "FPU\t\t: %s%s\n", 293 n += scnprintf(buf + n, len - n, "FPU\t\t: %s%s\n",
@@ -507,7 +520,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
507 * way to pass it w/o having to kmalloc/free a 2 byte string. 520 * way to pass it w/o having to kmalloc/free a 2 byte string.
508 * Encode cpu-id as 0xFFcccc, which is decoded by show routine. 521 * Encode cpu-id as 0xFFcccc, which is decoded by show routine.
509 */ 522 */
510 return *pos < num_possible_cpus() ? cpu_to_ptr(*pos) : NULL; 523 return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
511} 524}
512 525
513static void *c_next(struct seq_file *m, void *v, loff_t *pos) 526static void *c_next(struct seq_file *m, void *v, loff_t *pos)
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 934150e7ac48..82f9bc819f4a 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -237,113 +237,3 @@ void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
237 if (!user_mode(regs)) 237 if (!user_mode(regs))
238 show_stacktrace(current, regs); 238 show_stacktrace(current, regs);
239} 239}
240
241#ifdef CONFIG_DEBUG_FS
242
243#include <linux/module.h>
244#include <linux/fs.h>
245#include <linux/mount.h>
246#include <linux/pagemap.h>
247#include <linux/init.h>
248#include <linux/namei.h>
249#include <linux/debugfs.h>
250
251static struct dentry *test_dentry;
252static struct dentry *test_dir;
253static struct dentry *test_u32_dentry;
254
255static u32 clr_on_read = 1;
256
257#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
258u32 numitlb, numdtlb, num_pte_not_present;
259
260static int fill_display_data(char *kbuf)
261{
262 size_t num = 0;
263 num += sprintf(kbuf + num, "I-TLB Miss %x\n", numitlb);
264 num += sprintf(kbuf + num, "D-TLB Miss %x\n", numdtlb);
265 num += sprintf(kbuf + num, "PTE not present %x\n", num_pte_not_present);
266
267 if (clr_on_read)
268 numitlb = numdtlb = num_pte_not_present = 0;
269
270 return num;
271}
272
273static int tlb_stats_open(struct inode *inode, struct file *file)
274{
275 file->private_data = (void *)__get_free_page(GFP_KERNEL);
276 return 0;
277}
278
279/* called on user read(): display the counters */
280static ssize_t tlb_stats_output(struct file *file, /* file descriptor */
281 char __user *user_buf, /* user buffer */
282 size_t len, /* length of buffer */
283 loff_t *offset) /* offset in the file */
284{
285 size_t num;
286 char *kbuf = (char *)file->private_data;
287
288 /* All of the data can he shoved in one iteration */
289 if (*offset != 0)
290 return 0;
291
292 num = fill_display_data(kbuf);
293
294 /* simple_read_from_buffer() is helper for copy to user space
295 It copies up to @2 (num) bytes from kernel buffer @4 (kbuf) at offset
296 @3 (offset) into the user space address starting at @1 (user_buf).
297 @5 (len) is max size of user buffer
298 */
299 return simple_read_from_buffer(user_buf, num, offset, kbuf, len);
300}
301
302/* called on user write : clears the counters */
303static ssize_t tlb_stats_clear(struct file *file, const char __user *user_buf,
304 size_t length, loff_t *offset)
305{
306 numitlb = numdtlb = num_pte_not_present = 0;
307 return length;
308}
309
310static int tlb_stats_close(struct inode *inode, struct file *file)
311{
312 free_page((unsigned long)(file->private_data));
313 return 0;
314}
315
316static const struct file_operations tlb_stats_file_ops = {
317 .read = tlb_stats_output,
318 .write = tlb_stats_clear,
319 .open = tlb_stats_open,
320 .release = tlb_stats_close
321};
322#endif
323
324static int __init arc_debugfs_init(void)
325{
326 test_dir = debugfs_create_dir("arc", NULL);
327
328#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
329 test_dentry = debugfs_create_file("tlb_stats", 0444, test_dir, NULL,
330 &tlb_stats_file_ops);
331#endif
332
333 test_u32_dentry =
334 debugfs_create_u32("clr_on_read", 0444, test_dir, &clr_on_read);
335
336 return 0;
337}
338
339module_init(arc_debugfs_init);
340
341static void __exit arc_debugfs_exit(void)
342{
343 debugfs_remove(test_u32_dentry);
344 debugfs_remove(test_dentry);
345 debugfs_remove(test_dir);
346}
347module_exit(arc_debugfs_exit);
348
349#endif
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 97dddbefb86a..2b96cfc3be75 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -22,8 +22,8 @@
22#include <asm/setup.h> 22#include <asm/setup.h>
23 23
24static int l2_line_sz; 24static int l2_line_sz;
25int ioc_exists; 25static int ioc_exists;
26volatile int slc_enable = 1, ioc_enable = 1; 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
@@ -53,18 +53,15 @@ char *arc_cache_mumbojumbo(int c, char *buf, int len)
53 PR_CACHE(&cpuinfo_arc700[c].icache, CONFIG_ARC_HAS_ICACHE, "I-Cache"); 53 PR_CACHE(&cpuinfo_arc700[c].icache, CONFIG_ARC_HAS_ICACHE, "I-Cache");
54 PR_CACHE(&cpuinfo_arc700[c].dcache, CONFIG_ARC_HAS_DCACHE, "D-Cache"); 54 PR_CACHE(&cpuinfo_arc700[c].dcache, CONFIG_ARC_HAS_DCACHE, "D-Cache");
55 55
56 if (!is_isa_arcv2())
57 return buf;
58
59 p = &cpuinfo_arc700[c].slc; 56 p = &cpuinfo_arc700[c].slc;
60 if (p->ver) 57 if (p->ver)
61 n += scnprintf(buf + n, len - n, 58 n += scnprintf(buf + n, len - n,
62 "SLC\t\t: %uK, %uB Line%s\n", 59 "SLC\t\t: %uK, %uB Line%s\n",
63 p->sz_k, p->line_len, IS_USED_RUN(slc_enable)); 60 p->sz_k, p->line_len, IS_USED_RUN(slc_enable));
64 61
65 if (ioc_exists) 62 n += scnprintf(buf + n, len - n, "Peripherals\t: %#lx%s%s\n",
66 n += scnprintf(buf + n, len - n, "IOC\t\t:%s\n", 63 perip_base,
67 IS_DISABLED_RUN(ioc_enable)); 64 IS_AVAIL3(ioc_exists, ioc_enable, ", IO-Coherency "));
68 65
69 return buf; 66 return buf;
70} 67}
@@ -113,8 +110,10 @@ static void read_decode_cache_bcr_arcv2(int cpu)
113 } 110 }
114 111
115 READ_BCR(ARC_REG_CLUSTER_BCR, cbcr); 112 READ_BCR(ARC_REG_CLUSTER_BCR, cbcr);
116 if (cbcr.c && ioc_enable) 113 if (cbcr.c)
117 ioc_exists = 1; 114 ioc_exists = 1;
115 else
116 ioc_enable = 0;
118 117
119 /* HS 2.0 didn't have AUX_VOL */ 118 /* HS 2.0 didn't have AUX_VOL */
120 if (cpuinfo_arc700[cpu].core.family > 0x51) { 119 if (cpuinfo_arc700[cpu].core.family > 0x51) {
@@ -1002,7 +1001,7 @@ void arc_cache_init(void)
1002 read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_DISABLE); 1001 read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_DISABLE);
1003 } 1002 }
1004 1003
1005 if (is_isa_arcv2() && ioc_exists) { 1004 if (is_isa_arcv2() && ioc_enable) {
1006 /* IO coherency base - 0x8z */ 1005 /* IO coherency base - 0x8z */
1007 write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000); 1006 write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000);
1008 /* IO coherency aperture size - 512Mb: 0x8z-0xAz */ 1007 /* IO coherency aperture size - 512Mb: 0x8z-0xAz */
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 20afc65e22dc..60aab5a7522b 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -45,7 +45,7 @@ static void *arc_dma_alloc(struct device *dev, size_t size,
45 * -For coherent data, Read/Write to buffers terminate early in cache 45 * -For coherent data, Read/Write to buffers terminate early in cache
46 * (vs. always going to memory - thus are faster) 46 * (vs. always going to memory - thus are faster)
47 */ 47 */
48 if ((is_isa_arcv2() && ioc_exists) || 48 if ((is_isa_arcv2() && ioc_enable) ||
49 (attrs & DMA_ATTR_NON_CONSISTENT)) 49 (attrs & DMA_ATTR_NON_CONSISTENT))
50 need_coh = 0; 50 need_coh = 0;
51 51
@@ -97,7 +97,7 @@ static void arc_dma_free(struct device *dev, size_t size, void *vaddr,
97 int is_non_coh = 1; 97 int is_non_coh = 1;
98 98
99 is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT) || 99 is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT) ||
100 (is_isa_arcv2() && ioc_exists); 100 (is_isa_arcv2() && ioc_enable);
101 101
102 if (PageHighMem(page) || !is_non_coh) 102 if (PageHighMem(page) || !is_non_coh)
103 iounmap((void __force __iomem *)vaddr); 103 iounmap((void __force __iomem *)vaddr);
diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c
index ec868a9081a1..bdb295e09160 100644
--- a/arch/arc/mm/tlb.c
+++ b/arch/arc/mm/tlb.c
@@ -793,16 +793,16 @@ char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len)
793 char super_pg[64] = ""; 793 char super_pg[64] = "";
794 794
795 if (p_mmu->s_pg_sz_m) 795 if (p_mmu->s_pg_sz_m)
796 scnprintf(super_pg, 64, "%dM Super Page%s, ", 796 scnprintf(super_pg, 64, "%dM Super Page %s",
797 p_mmu->s_pg_sz_m, 797 p_mmu->s_pg_sz_m,
798 IS_USED_CFG(CONFIG_TRANSPARENT_HUGEPAGE)); 798 IS_USED_CFG(CONFIG_TRANSPARENT_HUGEPAGE));
799 799
800 n += scnprintf(buf + n, len - n, 800 n += scnprintf(buf + n, len - n,
801 "MMU [v%x]\t: %dk PAGE, %sJTLB %d (%dx%d), uDTLB %d, uITLB %d %s%s\n", 801 "MMU [v%x]\t: %dk PAGE, %sJTLB %d (%dx%d), uDTLB %d, uITLB %d%s%s\n",
802 p_mmu->ver, p_mmu->pg_sz_k, super_pg, 802 p_mmu->ver, p_mmu->pg_sz_k, super_pg,
803 p_mmu->sets * p_mmu->ways, p_mmu->sets, p_mmu->ways, 803 p_mmu->sets * p_mmu->ways, p_mmu->sets, p_mmu->ways,
804 p_mmu->u_dtlb, p_mmu->u_itlb, 804 p_mmu->u_dtlb, p_mmu->u_itlb,
805 IS_AVAIL2(p_mmu->pae, "PAE40 ", CONFIG_ARC_HAS_PAE40)); 805 IS_AVAIL2(p_mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));
806 806
807 return buf; 807 return buf;
808} 808}
diff --git a/arch/arc/mm/tlbex.S b/arch/arc/mm/tlbex.S
index f1967eeb32e7..b30e4e36bb00 100644
--- a/arch/arc/mm/tlbex.S
+++ b/arch/arc/mm/tlbex.S
@@ -237,15 +237,6 @@ ex_saved_reg1:
237 237
2382: 2382:
239 239
240#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
241 and.f 0, r0, _PAGE_PRESENT
242 bz 1f
243 ld r3, [num_pte_not_present]
244 add r3, r3, 1
245 st r3, [num_pte_not_present]
2461:
247#endif
248
249.endm 240.endm
250 241
251;----------------------------------------------------------------- 242;-----------------------------------------------------------------
@@ -309,12 +300,6 @@ ENTRY(EV_TLBMissI)
309 300
310 TLBMISS_FREEUP_REGS 301 TLBMISS_FREEUP_REGS
311 302
312#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
313 ld r0, [@numitlb]
314 add r0, r0, 1
315 st r0, [@numitlb]
316#endif
317
318 ;---------------------------------------------------------------- 303 ;----------------------------------------------------------------
319 ; Get the PTE corresponding to V-addr accessed, r2 is setup with EFA 304 ; Get the PTE corresponding to V-addr accessed, r2 is setup with EFA
320 LOAD_FAULT_PTE 305 LOAD_FAULT_PTE
@@ -349,12 +334,6 @@ ENTRY(EV_TLBMissD)
349 334
350 TLBMISS_FREEUP_REGS 335 TLBMISS_FREEUP_REGS
351 336
352#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
353 ld r0, [@numdtlb]
354 add r0, r0, 1
355 st r0, [@numdtlb]
356#endif
357
358 ;---------------------------------------------------------------- 337 ;----------------------------------------------------------------
359 ; Get the PTE corresponding to V-addr accessed 338 ; Get the PTE corresponding to V-addr accessed
360 ; If PTE exists, it will setup, r0 = PTE, r1 = Ptr to PTE, r2 = EFA 339 ; If PTE exists, it will setup, r0 = PTE, r1 = Ptr to PTE, r2 = EFA
diff --git a/arch/arm/boot/dts/ste-snowball.dts b/arch/arm/boot/dts/ste-snowball.dts
index b3df1c60d465..386eee6de232 100644
--- a/arch/arm/boot/dts/ste-snowball.dts
+++ b/arch/arm/boot/dts/ste-snowball.dts
@@ -239,14 +239,25 @@
239 arm,primecell-periphid = <0x10480180>; 239 arm,primecell-periphid = <0x10480180>;
240 max-frequency = <100000000>; 240 max-frequency = <100000000>;
241 bus-width = <4>; 241 bus-width = <4>;
242 cap-sd-highspeed;
242 cap-mmc-highspeed; 243 cap-mmc-highspeed;
244 sd-uhs-sdr12;
245 sd-uhs-sdr25;
246 /* All direction control is used */
247 st,sig-dir-cmd;
248 st,sig-dir-dat0;
249 st,sig-dir-dat2;
250 st,sig-dir-dat31;
251 st,sig-pin-fbclk;
252 full-pwr-cycle;
243 vmmc-supply = <&ab8500_ldo_aux3_reg>; 253 vmmc-supply = <&ab8500_ldo_aux3_reg>;
244 vqmmc-supply = <&vmmci>; 254 vqmmc-supply = <&vmmci>;
245 pinctrl-names = "default", "sleep"; 255 pinctrl-names = "default", "sleep";
246 pinctrl-0 = <&sdi0_default_mode>; 256 pinctrl-0 = <&sdi0_default_mode>;
247 pinctrl-1 = <&sdi0_sleep_mode>; 257 pinctrl-1 = <&sdi0_sleep_mode>;
248 258
249 cd-gpios = <&gpio6 26 GPIO_ACTIVE_LOW>; // 218 259 /* GPIO218 MMC_CD */
260 cd-gpios = <&gpio6 26 GPIO_ACTIVE_LOW>;
250 261
251 status = "okay"; 262 status = "okay";
252 }; 263 };
@@ -549,7 +560,7 @@
549 /* VMMCI level-shifter enable */ 560 /* VMMCI level-shifter enable */
550 snowball_cfg3 { 561 snowball_cfg3 {
551 pins = "GPIO217_AH12"; 562 pins = "GPIO217_AH12";
552 ste,config = <&gpio_out_lo>; 563 ste,config = <&gpio_out_hi>;
553 }; 564 };
554 /* VMMCI level-shifter voltage select */ 565 /* VMMCI level-shifter voltage select */
555 snowball_cfg4 { 566 snowball_cfg4 {
diff --git a/arch/arm/boot/dts/uniphier-pro5.dtsi b/arch/arm/boot/dts/uniphier-pro5.dtsi
index 2c49c3614bda..5357ea9c14b1 100644
--- a/arch/arm/boot/dts/uniphier-pro5.dtsi
+++ b/arch/arm/boot/dts/uniphier-pro5.dtsi
@@ -184,11 +184,11 @@
184}; 184};
185 185
186&mio_clk { 186&mio_clk {
187 compatible = "socionext,uniphier-pro5-mio-clock"; 187 compatible = "socionext,uniphier-pro5-sd-clock";
188}; 188};
189 189
190&mio_rst { 190&mio_rst {
191 compatible = "socionext,uniphier-pro5-mio-reset"; 191 compatible = "socionext,uniphier-pro5-sd-reset";
192}; 192};
193 193
194&peri_clk { 194&peri_clk {
diff --git a/arch/arm/boot/dts/uniphier-pxs2.dtsi b/arch/arm/boot/dts/uniphier-pxs2.dtsi
index 8789cd518933..950f07ba0337 100644
--- a/arch/arm/boot/dts/uniphier-pxs2.dtsi
+++ b/arch/arm/boot/dts/uniphier-pxs2.dtsi
@@ -197,11 +197,11 @@
197}; 197};
198 198
199&mio_clk { 199&mio_clk {
200 compatible = "socionext,uniphier-pxs2-mio-clock"; 200 compatible = "socionext,uniphier-pxs2-sd-clock";
201}; 201};
202 202
203&mio_rst { 203&mio_rst {
204 compatible = "socionext,uniphier-pxs2-mio-reset"; 204 compatible = "socionext,uniphier-pxs2-sd-reset";
205}; 205};
206 206
207&peri_clk { 207&peri_clk {
diff --git a/arch/arm/boot/dts/vf500.dtsi b/arch/arm/boot/dts/vf500.dtsi
index a3824e61bd72..d7fdb2a7d97b 100644
--- a/arch/arm/boot/dts/vf500.dtsi
+++ b/arch/arm/boot/dts/vf500.dtsi
@@ -70,7 +70,7 @@
70 global_timer: timer@40002200 { 70 global_timer: timer@40002200 {
71 compatible = "arm,cortex-a9-global-timer"; 71 compatible = "arm,cortex-a9-global-timer";
72 reg = <0x40002200 0x20>; 72 reg = <0x40002200 0x20>;
73 interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; 73 interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>;
74 interrupt-parent = <&intc>; 74 interrupt-parent = <&intc>;
75 clocks = <&clks VF610_CLK_PLATFORM_BUS>; 75 clocks = <&clks VF610_CLK_PLATFORM_BUS>;
76 }; 76 };
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 437d0740dec6..11f37ed1dbff 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -850,6 +850,7 @@ CONFIG_PWM_SUN4I=y
850CONFIG_PWM_TEGRA=y 850CONFIG_PWM_TEGRA=y
851CONFIG_PWM_VT8500=y 851CONFIG_PWM_VT8500=y
852CONFIG_PHY_HIX5HD2_SATA=y 852CONFIG_PHY_HIX5HD2_SATA=y
853CONFIG_E1000E=y
853CONFIG_PWM_STI=y 854CONFIG_PWM_STI=y
854CONFIG_PWM_BCM2835=y 855CONFIG_PWM_BCM2835=y
855CONFIG_PWM_BRCMSTB=m 856CONFIG_PWM_BRCMSTB=m
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index 194b69923389..ada0d29a660f 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -19,7 +19,7 @@
19 * This may need to be greater than __NR_last_syscall+1 in order to 19 * This may need to be greater than __NR_last_syscall+1 in order to
20 * account for the padding in the syscall table 20 * account for the padding in the syscall table
21 */ 21 */
22#define __NR_syscalls (396) 22#define __NR_syscalls (400)
23 23
24#define __ARCH_WANT_STAT64 24#define __ARCH_WANT_STAT64
25#define __ARCH_WANT_SYS_GETHOSTNAME 25#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index 2cb9dc770e1d..314100a06ccb 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -420,6 +420,9 @@
420#define __NR_copy_file_range (__NR_SYSCALL_BASE+391) 420#define __NR_copy_file_range (__NR_SYSCALL_BASE+391)
421#define __NR_preadv2 (__NR_SYSCALL_BASE+392) 421#define __NR_preadv2 (__NR_SYSCALL_BASE+392)
422#define __NR_pwritev2 (__NR_SYSCALL_BASE+393) 422#define __NR_pwritev2 (__NR_SYSCALL_BASE+393)
423#define __NR_pkey_mprotect (__NR_SYSCALL_BASE+394)
424#define __NR_pkey_alloc (__NR_SYSCALL_BASE+395)
425#define __NR_pkey_free (__NR_SYSCALL_BASE+396)
423 426
424/* 427/*
425 * The following SWIs are ARM private. 428 * The following SWIs are ARM private.
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 703fa0f3cd8f..08030b18f10a 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -403,6 +403,9 @@
403 CALL(sys_copy_file_range) 403 CALL(sys_copy_file_range)
404 CALL(sys_preadv2) 404 CALL(sys_preadv2)
405 CALL(sys_pwritev2) 405 CALL(sys_pwritev2)
406 CALL(sys_pkey_mprotect)
407/* 395 */ CALL(sys_pkey_alloc)
408 CALL(sys_pkey_free)
406#ifndef syscalls_counted 409#ifndef syscalls_counted
407.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 410.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
408#define syscalls_counted 411#define syscalls_counted
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 03e9273f1876..08bb84f2ad58 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -1312,6 +1312,13 @@ static int init_hyp_mode(void)
1312 goto out_err; 1312 goto out_err;
1313 } 1313 }
1314 1314
1315 err = create_hyp_mappings(kvm_ksym_ref(__bss_start),
1316 kvm_ksym_ref(__bss_stop), PAGE_HYP_RO);
1317 if (err) {
1318 kvm_err("Cannot map bss section\n");
1319 goto out_err;
1320 }
1321
1315 /* 1322 /*
1316 * Map the Hyp stack pages 1323 * Map the Hyp stack pages
1317 */ 1324 */
diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c
index 0df062d8b2c9..b54db47f6f32 100644
--- a/arch/arm/mach-imx/gpc.c
+++ b/arch/arm/mach-imx/gpc.c
@@ -408,7 +408,7 @@ static struct genpd_onecell_data imx_gpc_onecell_data = {
408static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg) 408static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg)
409{ 409{
410 struct clk *clk; 410 struct clk *clk;
411 int i; 411 int i, ret;
412 412
413 imx6q_pu_domain.reg = pu_reg; 413 imx6q_pu_domain.reg = pu_reg;
414 414
@@ -430,13 +430,22 @@ static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg)
430 if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) 430 if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS))
431 return 0; 431 return 0;
432 432
433 pm_genpd_init(&imx6q_pu_domain.base, NULL, false); 433 for (i = 0; i < ARRAY_SIZE(imx_gpc_domains); i++)
434 return of_genpd_add_provider_onecell(dev->of_node, 434 pm_genpd_init(imx_gpc_domains[i], NULL, false);
435
436 ret = of_genpd_add_provider_onecell(dev->of_node,
435 &imx_gpc_onecell_data); 437 &imx_gpc_onecell_data);
438 if (ret)
439 goto power_off;
440
441 return 0;
436 442
443power_off:
444 imx6q_pm_pu_power_off(&imx6q_pu_domain.base);
437clk_err: 445clk_err:
438 while (i--) 446 while (i--)
439 clk_put(imx6q_pu_domain.clk[i]); 447 clk_put(imx6q_pu_domain.clk[i]);
448 imx6q_pu_domain.reg = NULL;
440 return -EINVAL; 449 return -EINVAL;
441} 450}
442 451
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 97fd25105e2c..45801b27ee5c 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -173,7 +173,7 @@ static void __init imx6q_enet_phy_init(void)
173 ksz9021rn_phy_fixup); 173 ksz9021rn_phy_fixup);
174 phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK, 174 phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK,
175 ksz9031rn_phy_fixup); 175 ksz9031rn_phy_fixup);
176 phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff, 176 phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffef,
177 ar8031_phy_fixup); 177 ar8031_phy_fixup);
178 phy_register_fixup_for_uid(PHY_ID_AR8035, 0xffffffef, 178 phy_register_fixup_for_uid(PHY_ID_AR8035, 0xffffffef,
179 ar8035_phy_fixup); 179 ar8035_phy_fixup);
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index f9b6bd306cfe..541647f57192 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -23,6 +23,7 @@ config MACH_MVEBU_V7
23 select CACHE_L2X0 23 select CACHE_L2X0
24 select ARM_CPU_SUSPEND 24 select ARM_CPU_SUSPEND
25 select MACH_MVEBU_ANY 25 select MACH_MVEBU_ANY
26 select MVEBU_CLK_COREDIV
26 27
27config MACH_ARMADA_370 28config MACH_ARMADA_370
28 bool "Marvell Armada 370 boards" 29 bool "Marvell Armada 370 boards"
@@ -32,7 +33,6 @@ config MACH_ARMADA_370
32 select CPU_PJ4B 33 select CPU_PJ4B
33 select MACH_MVEBU_V7 34 select MACH_MVEBU_V7
34 select PINCTRL_ARMADA_370 35 select PINCTRL_ARMADA_370
35 select MVEBU_CLK_COREDIV
36 help 36 help
37 Say 'Y' here if you want your kernel to support boards based 37 Say 'Y' here if you want your kernel to support boards based
38 on the Marvell Armada 370 SoC with device tree. 38 on the Marvell Armada 370 SoC with device tree.
@@ -50,7 +50,6 @@ config MACH_ARMADA_375
50 select HAVE_SMP 50 select HAVE_SMP
51 select MACH_MVEBU_V7 51 select MACH_MVEBU_V7
52 select PINCTRL_ARMADA_375 52 select PINCTRL_ARMADA_375
53 select MVEBU_CLK_COREDIV
54 help 53 help
55 Say 'Y' here if you want your kernel to support boards based 54 Say 'Y' here if you want your kernel to support boards based
56 on the Marvell Armada 375 SoC with device tree. 55 on the Marvell Armada 375 SoC with device tree.
@@ -68,7 +67,6 @@ config MACH_ARMADA_38X
68 select HAVE_SMP 67 select HAVE_SMP
69 select MACH_MVEBU_V7 68 select MACH_MVEBU_V7
70 select PINCTRL_ARMADA_38X 69 select PINCTRL_ARMADA_38X
71 select MVEBU_CLK_COREDIV
72 help 70 help
73 Say 'Y' here if you want your kernel to support boards based 71 Say 'Y' here if you want your kernel to support boards based
74 on the Marvell Armada 380/385 SoC with device tree. 72 on the Marvell Armada 380/385 SoC with device tree.
diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig
index 82dddee3a469..3930fbba30b4 100644
--- a/arch/arm/mach-uniphier/Kconfig
+++ b/arch/arm/mach-uniphier/Kconfig
@@ -1,6 +1,7 @@
1config ARCH_UNIPHIER 1config ARCH_UNIPHIER
2 bool "Socionext UniPhier SoCs" 2 bool "Socionext UniPhier SoCs"
3 depends on ARCH_MULTI_V7 3 depends on ARCH_MULTI_V7
4 select ARCH_HAS_RESET_CONTROLLER
4 select ARM_AMBA 5 select ARM_AMBA
5 select ARM_GLOBAL_TIMER 6 select ARM_GLOBAL_TIMER
6 select ARM_GIC 7 select ARM_GIC
diff --git a/arch/arm/mm/abort-lv4t.S b/arch/arm/mm/abort-lv4t.S
index 6d8e8e3365d1..4cdfab31a0b6 100644
--- a/arch/arm/mm/abort-lv4t.S
+++ b/arch/arm/mm/abort-lv4t.S
@@ -7,7 +7,7 @@
7 * : r4 = aborted context pc 7 * : r4 = aborted context pc
8 * : r5 = aborted context psr 8 * : r5 = aborted context psr
9 * 9 *
10 * Returns : r4-r5, r10-r11, r13 preserved 10 * Returns : r4-r5, r9-r11, r13 preserved
11 * 11 *
12 * Purpose : obtain information about current aborted instruction. 12 * Purpose : obtain information about current aborted instruction.
13 * Note: we read user space. This means we might cause a data 13 * Note: we read user space. This means we might cause a data
@@ -48,7 +48,10 @@ ENTRY(v4t_late_abort)
48/* c */ b do_DataAbort @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m 48/* c */ b do_DataAbort @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
49/* d */ b do_DataAbort @ ldc rd, [rn, #m] 49/* d */ b do_DataAbort @ ldc rd, [rn, #m]
50/* e */ b .data_unknown 50/* e */ b .data_unknown
51/* f */ 51/* f */ b .data_unknown
52
53.data_unknown_r9:
54 ldr r9, [sp], #4
52.data_unknown: @ Part of jumptable 55.data_unknown: @ Part of jumptable
53 mov r0, r4 56 mov r0, r4
54 mov r1, r8 57 mov r1, r8
@@ -57,6 +60,7 @@ ENTRY(v4t_late_abort)
57.data_arm_ldmstm: 60.data_arm_ldmstm:
58 tst r8, #1 << 21 @ check writeback bit 61 tst r8, #1 << 21 @ check writeback bit
59 beq do_DataAbort @ no writeback -> no fixup 62 beq do_DataAbort @ no writeback -> no fixup
63 str r9, [sp, #-4]!
60 mov r7, #0x11 64 mov r7, #0x11
61 orr r7, r7, #0x1100 65 orr r7, r7, #0x1100
62 and r6, r8, r7 66 and r6, r8, r7
@@ -75,12 +79,14 @@ ENTRY(v4t_late_abort)
75 subne r7, r7, r6, lsl #2 @ Undo increment 79 subne r7, r7, r6, lsl #2 @ Undo increment
76 addeq r7, r7, r6, lsl #2 @ Undo decrement 80 addeq r7, r7, r6, lsl #2 @ Undo decrement
77 str r7, [r2, r9, lsr #14] @ Put register 'Rn' 81 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
82 ldr r9, [sp], #4
78 b do_DataAbort 83 b do_DataAbort
79 84
80.data_arm_lateldrhpre: 85.data_arm_lateldrhpre:
81 tst r8, #1 << 21 @ Check writeback bit 86 tst r8, #1 << 21 @ Check writeback bit
82 beq do_DataAbort @ No writeback -> no fixup 87 beq do_DataAbort @ No writeback -> no fixup
83.data_arm_lateldrhpost: 88.data_arm_lateldrhpost:
89 str r9, [sp, #-4]!
84 and r9, r8, #0x00f @ get Rm / low nibble of immediate value 90 and r9, r8, #0x00f @ get Rm / low nibble of immediate value
85 tst r8, #1 << 22 @ if (immediate offset) 91 tst r8, #1 << 22 @ if (immediate offset)
86 andne r6, r8, #0xf00 @ { immediate high nibble 92 andne r6, r8, #0xf00 @ { immediate high nibble
@@ -93,6 +99,7 @@ ENTRY(v4t_late_abort)
93 subne r7, r7, r6 @ Undo incrmenet 99 subne r7, r7, r6 @ Undo incrmenet
94 addeq r7, r7, r6 @ Undo decrement 100 addeq r7, r7, r6 @ Undo decrement
95 str r7, [r2, r9, lsr #14] @ Put register 'Rn' 101 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
102 ldr r9, [sp], #4
96 b do_DataAbort 103 b do_DataAbort
97 104
98.data_arm_lateldrpreconst: 105.data_arm_lateldrpreconst:
@@ -101,12 +108,14 @@ ENTRY(v4t_late_abort)
101.data_arm_lateldrpostconst: 108.data_arm_lateldrpostconst:
102 movs r6, r8, lsl #20 @ Get offset 109 movs r6, r8, lsl #20 @ Get offset
103 beq do_DataAbort @ zero -> no fixup 110 beq do_DataAbort @ zero -> no fixup
111 str r9, [sp, #-4]!
104 and r9, r8, #15 << 16 @ Extract 'n' from instruction 112 and r9, r8, #15 << 16 @ Extract 'n' from instruction
105 ldr r7, [r2, r9, lsr #14] @ Get register 'Rn' 113 ldr r7, [r2, r9, lsr #14] @ Get register 'Rn'
106 tst r8, #1 << 23 @ Check U bit 114 tst r8, #1 << 23 @ Check U bit
107 subne r7, r7, r6, lsr #20 @ Undo increment 115 subne r7, r7, r6, lsr #20 @ Undo increment
108 addeq r7, r7, r6, lsr #20 @ Undo decrement 116 addeq r7, r7, r6, lsr #20 @ Undo decrement
109 str r7, [r2, r9, lsr #14] @ Put register 'Rn' 117 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
118 ldr r9, [sp], #4
110 b do_DataAbort 119 b do_DataAbort
111 120
112.data_arm_lateldrprereg: 121.data_arm_lateldrprereg:
@@ -115,6 +124,7 @@ ENTRY(v4t_late_abort)
115.data_arm_lateldrpostreg: 124.data_arm_lateldrpostreg:
116 and r7, r8, #15 @ Extract 'm' from instruction 125 and r7, r8, #15 @ Extract 'm' from instruction
117 ldr r6, [r2, r7, lsl #2] @ Get register 'Rm' 126 ldr r6, [r2, r7, lsl #2] @ Get register 'Rm'
127 str r9, [sp, #-4]!
118 mov r9, r8, lsr #7 @ get shift count 128 mov r9, r8, lsr #7 @ get shift count
119 ands r9, r9, #31 129 ands r9, r9, #31
120 and r7, r8, #0x70 @ get shift type 130 and r7, r8, #0x70 @ get shift type
@@ -126,33 +136,33 @@ ENTRY(v4t_late_abort)
126 b .data_arm_apply_r6_and_rn 136 b .data_arm_apply_r6_and_rn
127 b .data_arm_apply_r6_and_rn @ 1: LSL #0 137 b .data_arm_apply_r6_and_rn @ 1: LSL #0
128 nop 138 nop
129 b .data_unknown @ 2: MUL? 139 b .data_unknown_r9 @ 2: MUL?
130 nop 140 nop
131 b .data_unknown @ 3: MUL? 141 b .data_unknown_r9 @ 3: MUL?
132 nop 142 nop
133 mov r6, r6, lsr r9 @ 4: LSR #!0 143 mov r6, r6, lsr r9 @ 4: LSR #!0
134 b .data_arm_apply_r6_and_rn 144 b .data_arm_apply_r6_and_rn
135 mov r6, r6, lsr #32 @ 5: LSR #32 145 mov r6, r6, lsr #32 @ 5: LSR #32
136 b .data_arm_apply_r6_and_rn 146 b .data_arm_apply_r6_and_rn
137 b .data_unknown @ 6: MUL? 147 b .data_unknown_r9 @ 6: MUL?
138 nop 148 nop
139 b .data_unknown @ 7: MUL? 149 b .data_unknown_r9 @ 7: MUL?
140 nop 150 nop
141 mov r6, r6, asr r9 @ 8: ASR #!0 151 mov r6, r6, asr r9 @ 8: ASR #!0
142 b .data_arm_apply_r6_and_rn 152 b .data_arm_apply_r6_and_rn
143 mov r6, r6, asr #32 @ 9: ASR #32 153 mov r6, r6, asr #32 @ 9: ASR #32
144 b .data_arm_apply_r6_and_rn 154 b .data_arm_apply_r6_and_rn
145 b .data_unknown @ A: MUL? 155 b .data_unknown_r9 @ A: MUL?
146 nop 156 nop
147 b .data_unknown @ B: MUL? 157 b .data_unknown_r9 @ B: MUL?
148 nop 158 nop
149 mov r6, r6, ror r9 @ C: ROR #!0 159 mov r6, r6, ror r9 @ C: ROR #!0
150 b .data_arm_apply_r6_and_rn 160 b .data_arm_apply_r6_and_rn
151 mov r6, r6, rrx @ D: RRX 161 mov r6, r6, rrx @ D: RRX
152 b .data_arm_apply_r6_and_rn 162 b .data_arm_apply_r6_and_rn
153 b .data_unknown @ E: MUL? 163 b .data_unknown_r9 @ E: MUL?
154 nop 164 nop
155 b .data_unknown @ F: MUL? 165 b .data_unknown_r9 @ F: MUL?
156 166
157.data_thumb_abort: 167.data_thumb_abort:
158 ldrh r8, [r4] @ read instruction 168 ldrh r8, [r4] @ read instruction
@@ -190,6 +200,7 @@ ENTRY(v4t_late_abort)
190.data_thumb_pushpop: 200.data_thumb_pushpop:
191 tst r8, #1 << 10 201 tst r8, #1 << 10
192 beq .data_unknown 202 beq .data_unknown
203 str r9, [sp, #-4]!
193 and r6, r8, #0x55 @ hweight8(r8) + R bit 204 and r6, r8, #0x55 @ hweight8(r8) + R bit
194 and r9, r8, #0xaa 205 and r9, r8, #0xaa
195 add r6, r6, r9, lsr #1 206 add r6, r6, r9, lsr #1
@@ -204,9 +215,11 @@ ENTRY(v4t_late_abort)
204 addeq r7, r7, r6, lsl #2 @ increment SP if PUSH 215 addeq r7, r7, r6, lsl #2 @ increment SP if PUSH
205 subne r7, r7, r6, lsl #2 @ decrement SP if POP 216 subne r7, r7, r6, lsl #2 @ decrement SP if POP
206 str r7, [r2, #13 << 2] 217 str r7, [r2, #13 << 2]
218 ldr r9, [sp], #4
207 b do_DataAbort 219 b do_DataAbort
208 220
209.data_thumb_ldmstm: 221.data_thumb_ldmstm:
222 str r9, [sp, #-4]!
210 and r6, r8, #0x55 @ hweight8(r8) 223 and r6, r8, #0x55 @ hweight8(r8)
211 and r9, r8, #0xaa 224 and r9, r8, #0xaa
212 add r6, r6, r9, lsr #1 225 add r6, r6, r9, lsr #1
@@ -219,4 +232,5 @@ ENTRY(v4t_late_abort)
219 and r6, r6, #15 @ number of regs to transfer 232 and r6, r6, #15 @ number of regs to transfer
220 sub r7, r7, r6, lsl #2 @ always decrement 233 sub r7, r7, r6, lsl #2 @ always decrement
221 str r7, [r2, r9, lsr #6] 234 str r7, [r2, r9, lsr #6]
235 ldr r9, [sp], #4
222 b do_DataAbort 236 b do_DataAbort
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 30398dbc940a..969ef880d234 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -915,7 +915,7 @@ config RANDOMIZE_BASE
915 915
916config RANDOMIZE_MODULE_REGION_FULL 916config RANDOMIZE_MODULE_REGION_FULL
917 bool "Randomize the module region independently from the core kernel" 917 bool "Randomize the module region independently from the core kernel"
918 depends on RANDOMIZE_BASE 918 depends on RANDOMIZE_BASE && !DYNAMIC_FTRACE
919 default y 919 default y
920 help 920 help
921 Randomizes the location of the module region without considering the 921 Randomizes the location of the module region without considering the
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index cfbdf02ef566..101794f5ce10 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -190,6 +190,7 @@ config ARCH_THUNDER
190 190
191config ARCH_UNIPHIER 191config ARCH_UNIPHIER
192 bool "Socionext UniPhier SoC Family" 192 bool "Socionext UniPhier SoC Family"
193 select ARCH_HAS_RESET_CONTROLLER
193 select PINCTRL 194 select PINCTRL
194 help 195 help
195 This enables support for Socionext UniPhier SoC family. 196 This enables support for Socionext UniPhier SoC family.
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index ab51aed6b6c1..3635b8662724 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -15,7 +15,7 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
15GZFLAGS :=-9 15GZFLAGS :=-9
16 16
17ifneq ($(CONFIG_RELOCATABLE),) 17ifneq ($(CONFIG_RELOCATABLE),)
18LDFLAGS_vmlinux += -pie -Bsymbolic 18LDFLAGS_vmlinux += -pie -shared -Bsymbolic
19endif 19endif
20 20
21ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) 21ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index 2d7872a36b91..b09f3bc5c6c1 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -164,6 +164,8 @@
164 nand-ecc-mode = "hw"; 164 nand-ecc-mode = "hw";
165 nand-ecc-strength = <8>; 165 nand-ecc-strength = <8>;
166 nand-ecc-step-size = <512>; 166 nand-ecc-step-size = <512>;
167 nand-bus-width = <16>;
168 brcm,nand-oob-sector-size = <16>;
167 #address-cells = <1>; 169 #address-cells = <1>;
168 #size-cells = <1>; 170 #size-cells = <1>;
169 }; 171 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
index 220ac7057d12..97d331ec2500 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
@@ -123,6 +123,7 @@
123 <1 14 0xf08>, /* Physical Non-Secure PPI */ 123 <1 14 0xf08>, /* Physical Non-Secure PPI */
124 <1 11 0xf08>, /* Virtual PPI */ 124 <1 11 0xf08>, /* Virtual PPI */
125 <1 10 0xf08>; /* Hypervisor PPI */ 125 <1 10 0xf08>; /* Hypervisor PPI */
126 fsl,erratum-a008585;
126 }; 127 };
127 128
128 pmu { 129 pmu {
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
index 337da90bd7da..7f0dc13b4087 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
@@ -195,6 +195,7 @@
195 <1 14 4>, /* Physical Non-Secure PPI, active-low */ 195 <1 14 4>, /* Physical Non-Secure PPI, active-low */
196 <1 11 4>, /* Virtual PPI, active-low */ 196 <1 11 4>, /* Virtual PPI, active-low */
197 <1 10 4>; /* Hypervisor PPI, active-low */ 197 <1 10 4>; /* Hypervisor PPI, active-low */
198 fsl,erratum-a008585;
198 }; 199 };
199 200
200 pmu { 201 pmu {
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
index e5e3ed678b6f..602e2c2e9a4d 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
@@ -131,7 +131,7 @@
131 #address-cells = <0x1>; 131 #address-cells = <0x1>;
132 #size-cells = <0x0>; 132 #size-cells = <0x0>;
133 cell-index = <1>; 133 cell-index = <1>;
134 clocks = <&cpm_syscon0 0 3>; 134 clocks = <&cpm_syscon0 1 21>;
135 status = "disabled"; 135 status = "disabled";
136 }; 136 };
137 137
diff --git a/arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts b/arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts
index 46cdddfcea6c..e5eeca2c2456 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts
@@ -116,7 +116,6 @@
116 cap-mmc-highspeed; 116 cap-mmc-highspeed;
117 clock-frequency = <150000000>; 117 clock-frequency = <150000000>;
118 disable-wp; 118 disable-wp;
119 keep-power-in-suspend;
120 non-removable; 119 non-removable;
121 num-slots = <1>; 120 num-slots = <1>;
122 vmmc-supply = <&vcc_io>; 121 vmmc-supply = <&vcc_io>;
@@ -258,8 +257,6 @@
258 }; 257 };
259 258
260 vcc_sd: SWITCH_REG1 { 259 vcc_sd: SWITCH_REG1 {
261 regulator-always-on;
262 regulator-boot-on;
263 regulator-name = "vcc_sd"; 260 regulator-name = "vcc_sd";
264 }; 261 };
265 262
diff --git a/arch/arm64/boot/dts/rockchip/rk3368-orion-r68-meta.dts b/arch/arm64/boot/dts/rockchip/rk3368-orion-r68-meta.dts
index 5797933ef80e..ea0a8eceefd4 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368-orion-r68-meta.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3368-orion-r68-meta.dts
@@ -152,8 +152,6 @@
152 gpio = <&gpio3 11 GPIO_ACTIVE_LOW>; 152 gpio = <&gpio3 11 GPIO_ACTIVE_LOW>;
153 regulator-min-microvolt = <1800000>; 153 regulator-min-microvolt = <1800000>;
154 regulator-max-microvolt = <3300000>; 154 regulator-max-microvolt = <3300000>;
155 regulator-always-on;
156 regulator-boot-on;
157 vin-supply = <&vcc_io>; 155 vin-supply = <&vcc_io>;
158 }; 156 };
159 157
@@ -201,7 +199,6 @@
201 bus-width = <8>; 199 bus-width = <8>;
202 cap-mmc-highspeed; 200 cap-mmc-highspeed;
203 disable-wp; 201 disable-wp;
204 keep-power-in-suspend;
205 mmc-pwrseq = <&emmc_pwrseq>; 202 mmc-pwrseq = <&emmc_pwrseq>;
206 mmc-hs200-1_2v; 203 mmc-hs200-1_2v;
207 mmc-hs200-1_8v; 204 mmc-hs200-1_8v;
@@ -350,7 +347,6 @@
350 clock-freq-min-max = <400000 50000000>; 347 clock-freq-min-max = <400000 50000000>;
351 cap-sd-highspeed; 348 cap-sd-highspeed;
352 card-detect-delay = <200>; 349 card-detect-delay = <200>;
353 keep-power-in-suspend;
354 num-slots = <1>; 350 num-slots = <1>;
355 pinctrl-names = "default"; 351 pinctrl-names = "default";
356 pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>; 352 pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
diff --git a/arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi b/arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi
index 08fd7cf7769c..56a1b2e92cf3 100644
--- a/arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi
+++ b/arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi
@@ -257,18 +257,18 @@
257 reg = <0x59801000 0x400>; 257 reg = <0x59801000 0x400>;
258 }; 258 };
259 259
260 mioctrl@59810000 { 260 sdctrl@59810000 {
261 compatible = "socionext,uniphier-mioctrl", 261 compatible = "socionext,uniphier-ld20-sdctrl",
262 "simple-mfd", "syscon"; 262 "simple-mfd", "syscon";
263 reg = <0x59810000 0x800>; 263 reg = <0x59810000 0x800>;
264 264
265 mio_clk: clock { 265 sd_clk: clock {
266 compatible = "socionext,uniphier-ld20-mio-clock"; 266 compatible = "socionext,uniphier-ld20-sd-clock";
267 #clock-cells = <1>; 267 #clock-cells = <1>;
268 }; 268 };
269 269
270 mio_rst: reset { 270 sd_rst: reset {
271 compatible = "socionext,uniphier-ld20-mio-reset"; 271 compatible = "socionext,uniphier-ld20-sd-reset";
272 #reset-cells = <1>; 272 #reset-cells = <1>;
273 }; 273 };
274 }; 274 };
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 758d74fedfad..a27c3245ba21 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -94,7 +94,7 @@ struct arm64_cpu_capabilities {
94 u16 capability; 94 u16 capability;
95 int def_scope; /* default scope */ 95 int def_scope; /* default scope */
96 bool (*matches)(const struct arm64_cpu_capabilities *caps, int scope); 96 bool (*matches)(const struct arm64_cpu_capabilities *caps, int scope);
97 void (*enable)(void *); /* Called on all active CPUs */ 97 int (*enable)(void *); /* Called on all active CPUs */
98 union { 98 union {
99 struct { /* To be used for erratum handling only */ 99 struct { /* To be used for erratum handling only */
100 u32 midr_model; 100 u32 midr_model;
diff --git a/arch/arm64/include/asm/exec.h b/arch/arm64/include/asm/exec.h
index db0563c23482..f7865dd9d868 100644
--- a/arch/arm64/include/asm/exec.h
+++ b/arch/arm64/include/asm/exec.h
@@ -18,6 +18,9 @@
18#ifndef __ASM_EXEC_H 18#ifndef __ASM_EXEC_H
19#define __ASM_EXEC_H 19#define __ASM_EXEC_H
20 20
21#include <linux/sched.h>
22
21extern unsigned long arch_align_stack(unsigned long sp); 23extern unsigned long arch_align_stack(unsigned long sp);
24void uao_thread_switch(struct task_struct *next);
22 25
23#endif /* __ASM_EXEC_H */ 26#endif /* __ASM_EXEC_H */
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index fd9d5fd788f5..f5ea0ba70f07 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -178,11 +178,6 @@ static inline bool kvm_vcpu_dabt_isvalid(const struct kvm_vcpu *vcpu)
178 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_ISV); 178 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_ISV);
179} 179}
180 180
181static inline bool kvm_vcpu_dabt_iswrite(const struct kvm_vcpu *vcpu)
182{
183 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WNR);
184}
185
186static inline bool kvm_vcpu_dabt_issext(const struct kvm_vcpu *vcpu) 181static inline bool kvm_vcpu_dabt_issext(const struct kvm_vcpu *vcpu)
187{ 182{
188 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SSE); 183 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SSE);
@@ -203,6 +198,12 @@ static inline bool kvm_vcpu_dabt_iss1tw(const struct kvm_vcpu *vcpu)
203 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_S1PTW); 198 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_S1PTW);
204} 199}
205 200
201static inline bool kvm_vcpu_dabt_iswrite(const struct kvm_vcpu *vcpu)
202{
203 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WNR) ||
204 kvm_vcpu_dabt_iss1tw(vcpu); /* AF/DBM update */
205}
206
206static inline bool kvm_vcpu_dabt_is_cm(const struct kvm_vcpu *vcpu) 207static inline bool kvm_vcpu_dabt_is_cm(const struct kvm_vcpu *vcpu)
207{ 208{
208 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_CM); 209 return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_CM);
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index ba62df8c6e35..b71086d25195 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -217,7 +217,7 @@ static inline void *phys_to_virt(phys_addr_t x)
217#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 217#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
218#else 218#else
219#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page)) 219#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page))
220#define __page_to_voff(kaddr) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page)) 220#define __page_to_voff(page) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
221 221
222#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET)) 222#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET))
223#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START)) 223#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
diff --git a/arch/arm64/include/asm/module.h b/arch/arm64/include/asm/module.h
index e12af6754634..06ff7fd9e81f 100644
--- a/arch/arm64/include/asm/module.h
+++ b/arch/arm64/include/asm/module.h
@@ -17,6 +17,7 @@
17#define __ASM_MODULE_H 17#define __ASM_MODULE_H
18 18
19#include <asm-generic/module.h> 19#include <asm-generic/module.h>
20#include <asm/memory.h>
20 21
21#define MODULE_ARCH_VERMAGIC "aarch64" 22#define MODULE_ARCH_VERMAGIC "aarch64"
22 23
@@ -32,6 +33,10 @@ u64 module_emit_plt_entry(struct module *mod, const Elf64_Rela *rela,
32 Elf64_Sym *sym); 33 Elf64_Sym *sym);
33 34
34#ifdef CONFIG_RANDOMIZE_BASE 35#ifdef CONFIG_RANDOMIZE_BASE
36#ifdef CONFIG_MODVERSIONS
37#define ARCH_RELOCATES_KCRCTAB
38#define reloc_start (kimage_vaddr - KIMAGE_VADDR)
39#endif
35extern u64 module_alloc_base; 40extern u64 module_alloc_base;
36#else 41#else
37#define module_alloc_base ((u64)_etext - MODULES_VSIZE) 42#define module_alloc_base ((u64)_etext - MODULES_VSIZE)
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index 2fee2f59288c..5394c8405e66 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -44,48 +44,44 @@ static inline unsigned long __percpu_##op(void *ptr, \
44 \ 44 \
45 switch (size) { \ 45 switch (size) { \
46 case 1: \ 46 case 1: \
47 do { \ 47 asm ("//__per_cpu_" #op "_1\n" \
48 asm ("//__per_cpu_" #op "_1\n" \ 48 "1: ldxrb %w[ret], %[ptr]\n" \
49 "ldxrb %w[ret], %[ptr]\n" \
50 #asm_op " %w[ret], %w[ret], %w[val]\n" \ 49 #asm_op " %w[ret], %w[ret], %w[val]\n" \
51 "stxrb %w[loop], %w[ret], %[ptr]\n" \ 50 " stxrb %w[loop], %w[ret], %[ptr]\n" \
52 : [loop] "=&r" (loop), [ret] "=&r" (ret), \ 51 " cbnz %w[loop], 1b" \
53 [ptr] "+Q"(*(u8 *)ptr) \ 52 : [loop] "=&r" (loop), [ret] "=&r" (ret), \
54 : [val] "Ir" (val)); \ 53 [ptr] "+Q"(*(u8 *)ptr) \
55 } while (loop); \ 54 : [val] "Ir" (val)); \
56 break; \ 55 break; \
57 case 2: \ 56 case 2: \
58 do { \ 57 asm ("//__per_cpu_" #op "_2\n" \
59 asm ("//__per_cpu_" #op "_2\n" \ 58 "1: ldxrh %w[ret], %[ptr]\n" \
60 "ldxrh %w[ret], %[ptr]\n" \
61 #asm_op " %w[ret], %w[ret], %w[val]\n" \ 59 #asm_op " %w[ret], %w[ret], %w[val]\n" \
62 "stxrh %w[loop], %w[ret], %[ptr]\n" \ 60 " stxrh %w[loop], %w[ret], %[ptr]\n" \
63 : [loop] "=&r" (loop), [ret] "=&r" (ret), \ 61 " cbnz %w[loop], 1b" \
64 [ptr] "+Q"(*(u16 *)ptr) \ 62 : [loop] "=&r" (loop), [ret] "=&r" (ret), \
65 : [val] "Ir" (val)); \ 63 [ptr] "+Q"(*(u16 *)ptr) \
66 } while (loop); \ 64 : [val] "Ir" (val)); \
67 break; \ 65 break; \
68 case 4: \ 66 case 4: \
69 do { \ 67 asm ("//__per_cpu_" #op "_4\n" \
70 asm ("//__per_cpu_" #op "_4\n" \ 68 "1: ldxr %w[ret], %[ptr]\n" \
71 "ldxr %w[ret], %[ptr]\n" \
72 #asm_op " %w[ret], %w[ret], %w[val]\n" \ 69 #asm_op " %w[ret], %w[ret], %w[val]\n" \
73 "stxr %w[loop], %w[ret], %[ptr]\n" \ 70 " stxr %w[loop], %w[ret], %[ptr]\n" \
74 : [loop] "=&r" (loop), [ret] "=&r" (ret), \ 71 " cbnz %w[loop], 1b" \
75 [ptr] "+Q"(*(u32 *)ptr) \ 72 : [loop] "=&r" (loop), [ret] "=&r" (ret), \
76 : [val] "Ir" (val)); \ 73 [ptr] "+Q"(*(u32 *)ptr) \
77 } while (loop); \ 74 : [val] "Ir" (val)); \
78 break; \ 75 break; \
79 case 8: \ 76 case 8: \
80 do { \ 77 asm ("//__per_cpu_" #op "_8\n" \
81 asm ("//__per_cpu_" #op "_8\n" \ 78 "1: ldxr %[ret], %[ptr]\n" \
82 "ldxr %[ret], %[ptr]\n" \
83 #asm_op " %[ret], %[ret], %[val]\n" \ 79 #asm_op " %[ret], %[ret], %[val]\n" \
84 "stxr %w[loop], %[ret], %[ptr]\n" \ 80 " stxr %w[loop], %[ret], %[ptr]\n" \
85 : [loop] "=&r" (loop), [ret] "=&r" (ret), \ 81 " cbnz %w[loop], 1b" \
86 [ptr] "+Q"(*(u64 *)ptr) \ 82 : [loop] "=&r" (loop), [ret] "=&r" (ret), \
87 : [val] "Ir" (val)); \ 83 [ptr] "+Q"(*(u64 *)ptr) \
88 } while (loop); \ 84 : [val] "Ir" (val)); \
89 break; \ 85 break; \
90 default: \ 86 default: \
91 BUILD_BUG(); \ 87 BUILD_BUG(); \
@@ -150,44 +146,40 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val,
150 146
151 switch (size) { 147 switch (size) {
152 case 1: 148 case 1:
153 do { 149 asm ("//__percpu_xchg_1\n"
154 asm ("//__percpu_xchg_1\n" 150 "1: ldxrb %w[ret], %[ptr]\n"
155 "ldxrb %w[ret], %[ptr]\n" 151 " stxrb %w[loop], %w[val], %[ptr]\n"
156 "stxrb %w[loop], %w[val], %[ptr]\n" 152 " cbnz %w[loop], 1b"
157 : [loop] "=&r"(loop), [ret] "=&r"(ret), 153 : [loop] "=&r"(loop), [ret] "=&r"(ret),
158 [ptr] "+Q"(*(u8 *)ptr) 154 [ptr] "+Q"(*(u8 *)ptr)
159 : [val] "r" (val)); 155 : [val] "r" (val));
160 } while (loop);
161 break; 156 break;
162 case 2: 157 case 2:
163 do { 158 asm ("//__percpu_xchg_2\n"
164 asm ("//__percpu_xchg_2\n" 159 "1: ldxrh %w[ret], %[ptr]\n"
165 "ldxrh %w[ret], %[ptr]\n" 160 " stxrh %w[loop], %w[val], %[ptr]\n"
166 "stxrh %w[loop], %w[val], %[ptr]\n" 161 " cbnz %w[loop], 1b"
167 : [loop] "=&r"(loop), [ret] "=&r"(ret), 162 : [loop] "=&r"(loop), [ret] "=&r"(ret),
168 [ptr] "+Q"(*(u16 *)ptr) 163 [ptr] "+Q"(*(u16 *)ptr)
169 : [val] "r" (val)); 164 : [val] "r" (val));
170 } while (loop);
171 break; 165 break;
172 case 4: 166 case 4:
173 do { 167 asm ("//__percpu_xchg_4\n"
174 asm ("//__percpu_xchg_4\n" 168 "1: ldxr %w[ret], %[ptr]\n"
175 "ldxr %w[ret], %[ptr]\n" 169 " stxr %w[loop], %w[val], %[ptr]\n"
176 "stxr %w[loop], %w[val], %[ptr]\n" 170 " cbnz %w[loop], 1b"
177 : [loop] "=&r"(loop), [ret] "=&r"(ret), 171 : [loop] "=&r"(loop), [ret] "=&r"(ret),
178 [ptr] "+Q"(*(u32 *)ptr) 172 [ptr] "+Q"(*(u32 *)ptr)
179 : [val] "r" (val)); 173 : [val] "r" (val));
180 } while (loop);
181 break; 174 break;
182 case 8: 175 case 8:
183 do { 176 asm ("//__percpu_xchg_8\n"
184 asm ("//__percpu_xchg_8\n" 177 "1: ldxr %[ret], %[ptr]\n"
185 "ldxr %[ret], %[ptr]\n" 178 " stxr %w[loop], %[val], %[ptr]\n"
186 "stxr %w[loop], %[val], %[ptr]\n" 179 " cbnz %w[loop], 1b"
187 : [loop] "=&r"(loop), [ret] "=&r"(ret), 180 : [loop] "=&r"(loop), [ret] "=&r"(ret),
188 [ptr] "+Q"(*(u64 *)ptr) 181 [ptr] "+Q"(*(u64 *)ptr)
189 : [val] "r" (val)); 182 : [val] "r" (val));
190 } while (loop);
191 break; 183 break;
192 default: 184 default:
193 BUILD_BUG(); 185 BUILD_BUG();
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index df2e53d3a969..60e34824e18c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -188,8 +188,8 @@ static inline void spin_lock_prefetch(const void *ptr)
188 188
189#endif 189#endif
190 190
191void cpu_enable_pan(void *__unused); 191int cpu_enable_pan(void *__unused);
192void cpu_enable_uao(void *__unused); 192int cpu_enable_uao(void *__unused);
193void cpu_enable_cache_maint_trap(void *__unused); 193int cpu_enable_cache_maint_trap(void *__unused);
194 194
195#endif /* __ASM_PROCESSOR_H */ 195#endif /* __ASM_PROCESSOR_H */
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index e8d46e8e6079..6c80b3699cb8 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -286,7 +286,7 @@ asm(
286 286
287#define write_sysreg_s(v, r) do { \ 287#define write_sysreg_s(v, r) do { \
288 u64 __val = (u64)v; \ 288 u64 __val = (u64)v; \
289 asm volatile("msr_s " __stringify(r) ", %0" : : "rZ" (__val)); \ 289 asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val)); \
290} while (0) 290} while (0)
291 291
292static inline void config_sctlr_el1(u32 clear, u32 set) 292static inline void config_sctlr_el1(u32 clear, u32 set)
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index bcaf6fba1b65..55d0adbf6509 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -21,6 +21,7 @@
21/* 21/*
22 * User space memory access functions 22 * User space memory access functions
23 */ 23 */
24#include <linux/bitops.h>
24#include <linux/kasan-checks.h> 25#include <linux/kasan-checks.h>
25#include <linux/string.h> 26#include <linux/string.h>
26#include <linux/thread_info.h> 27#include <linux/thread_info.h>
@@ -102,6 +103,13 @@ static inline void set_fs(mm_segment_t fs)
102 flag; \ 103 flag; \
103}) 104})
104 105
106/*
107 * When dealing with data aborts or instruction traps we may end up with
108 * a tagged userland pointer. Clear the tag to get a sane pointer to pass
109 * on to access_ok(), for instance.
110 */
111#define untagged_addr(addr) sign_extend64(addr, 55)
112
105#define access_ok(type, addr, size) __range_ok(addr, size) 113#define access_ok(type, addr, size) __range_ok(addr, size)
106#define user_addr_max get_fs 114#define user_addr_max get_fs
107 115
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index 42ffdb54e162..b0988bb1bf64 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -280,35 +280,43 @@ static void __init register_insn_emulation_sysctl(struct ctl_table *table)
280/* 280/*
281 * Error-checking SWP macros implemented using ldxr{b}/stxr{b} 281 * Error-checking SWP macros implemented using ldxr{b}/stxr{b}
282 */ 282 */
283#define __user_swpX_asm(data, addr, res, temp, B) \ 283
284/* Arbitrary constant to ensure forward-progress of the LL/SC loop */
285#define __SWP_LL_SC_LOOPS 4
286
287#define __user_swpX_asm(data, addr, res, temp, temp2, B) \
284 __asm__ __volatile__( \ 288 __asm__ __volatile__( \
289 " mov %w3, %w7\n" \
285 ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN, \ 290 ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN, \
286 CONFIG_ARM64_PAN) \ 291 CONFIG_ARM64_PAN) \
287 "0: ldxr"B" %w2, [%3]\n" \ 292 "0: ldxr"B" %w2, [%4]\n" \
288 "1: stxr"B" %w0, %w1, [%3]\n" \ 293 "1: stxr"B" %w0, %w1, [%4]\n" \
289 " cbz %w0, 2f\n" \ 294 " cbz %w0, 2f\n" \
290 " mov %w0, %w4\n" \ 295 " sub %w3, %w3, #1\n" \
296 " cbnz %w3, 0b\n" \
297 " mov %w0, %w5\n" \
291 " b 3f\n" \ 298 " b 3f\n" \
292 "2:\n" \ 299 "2:\n" \
293 " mov %w1, %w2\n" \ 300 " mov %w1, %w2\n" \
294 "3:\n" \ 301 "3:\n" \
295 " .pushsection .fixup,\"ax\"\n" \ 302 " .pushsection .fixup,\"ax\"\n" \
296 " .align 2\n" \ 303 " .align 2\n" \
297 "4: mov %w0, %w5\n" \ 304 "4: mov %w0, %w6\n" \
298 " b 3b\n" \ 305 " b 3b\n" \
299 " .popsection" \ 306 " .popsection" \
300 _ASM_EXTABLE(0b, 4b) \ 307 _ASM_EXTABLE(0b, 4b) \
301 _ASM_EXTABLE(1b, 4b) \ 308 _ASM_EXTABLE(1b, 4b) \
302 ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, \ 309 ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, \
303 CONFIG_ARM64_PAN) \ 310 CONFIG_ARM64_PAN) \
304 : "=&r" (res), "+r" (data), "=&r" (temp) \ 311 : "=&r" (res), "+r" (data), "=&r" (temp), "=&r" (temp2) \
305 : "r" (addr), "i" (-EAGAIN), "i" (-EFAULT) \ 312 : "r" (addr), "i" (-EAGAIN), "i" (-EFAULT), \
313 "i" (__SWP_LL_SC_LOOPS) \
306 : "memory") 314 : "memory")
307 315
308#define __user_swp_asm(data, addr, res, temp) \ 316#define __user_swp_asm(data, addr, res, temp, temp2) \
309 __user_swpX_asm(data, addr, res, temp, "") 317 __user_swpX_asm(data, addr, res, temp, temp2, "")
310#define __user_swpb_asm(data, addr, res, temp) \ 318#define __user_swpb_asm(data, addr, res, temp, temp2) \
311 __user_swpX_asm(data, addr, res, temp, "b") 319 __user_swpX_asm(data, addr, res, temp, temp2, "b")
312 320
313/* 321/*
314 * Bit 22 of the instruction encoding distinguishes between 322 * Bit 22 of the instruction encoding distinguishes between
@@ -328,12 +336,12 @@ static int emulate_swpX(unsigned int address, unsigned int *data,
328 } 336 }
329 337
330 while (1) { 338 while (1) {
331 unsigned long temp; 339 unsigned long temp, temp2;
332 340
333 if (type == TYPE_SWPB) 341 if (type == TYPE_SWPB)
334 __user_swpb_asm(*data, address, res, temp); 342 __user_swpb_asm(*data, address, res, temp, temp2);
335 else 343 else
336 __user_swp_asm(*data, address, res, temp); 344 __user_swp_asm(*data, address, res, temp, temp2);
337 345
338 if (likely(res != -EAGAIN) || signal_pending(current)) 346 if (likely(res != -EAGAIN) || signal_pending(current))
339 break; 347 break;
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 0150394f4cab..b75e917aac46 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -39,10 +39,11 @@ has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry,
39 (arm64_ftr_reg_ctrel0.sys_val & arm64_ftr_reg_ctrel0.strict_mask); 39 (arm64_ftr_reg_ctrel0.sys_val & arm64_ftr_reg_ctrel0.strict_mask);
40} 40}
41 41
42static void cpu_enable_trap_ctr_access(void *__unused) 42static int cpu_enable_trap_ctr_access(void *__unused)
43{ 43{
44 /* Clear SCTLR_EL1.UCT */ 44 /* Clear SCTLR_EL1.UCT */
45 config_sctlr_el1(SCTLR_EL1_UCT, 0); 45 config_sctlr_el1(SCTLR_EL1_UCT, 0);
46 return 0;
46} 47}
47 48
48#define MIDR_RANGE(model, min, max) \ 49#define MIDR_RANGE(model, min, max) \
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index d577f263cc4a..c02504ea304b 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -19,7 +19,9 @@
19#define pr_fmt(fmt) "CPU features: " fmt 19#define pr_fmt(fmt) "CPU features: " fmt
20 20
21#include <linux/bsearch.h> 21#include <linux/bsearch.h>
22#include <linux/cpumask.h>
22#include <linux/sort.h> 23#include <linux/sort.h>
24#include <linux/stop_machine.h>
23#include <linux/types.h> 25#include <linux/types.h>
24#include <asm/cpu.h> 26#include <asm/cpu.h>
25#include <asm/cpufeature.h> 27#include <asm/cpufeature.h>
@@ -941,7 +943,13 @@ void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps)
941{ 943{
942 for (; caps->matches; caps++) 944 for (; caps->matches; caps++)
943 if (caps->enable && cpus_have_cap(caps->capability)) 945 if (caps->enable && cpus_have_cap(caps->capability))
944 on_each_cpu(caps->enable, NULL, true); 946 /*
947 * Use stop_machine() as it schedules the work allowing
948 * us to modify PSTATE, instead of on_each_cpu() which
949 * uses an IPI, giving us a PSTATE that disappears when
950 * we return.
951 */
952 stop_machine(caps->enable, NULL, cpu_online_mask);
945} 953}
946 954
947/* 955/*
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 427f6d3f084c..332e33193ccf 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -586,8 +586,9 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems
586 b.lt 4f // Skip if no PMU present 586 b.lt 4f // Skip if no PMU present
587 mrs x0, pmcr_el0 // Disable debug access traps 587 mrs x0, pmcr_el0 // Disable debug access traps
588 ubfx x0, x0, #11, #5 // to EL2 and allow access to 588 ubfx x0, x0, #11, #5 // to EL2 and allow access to
589 msr mdcr_el2, x0 // all PMU counters from EL1
5904: 5894:
590 csel x0, xzr, x0, lt // all PMU counters from EL1
591 msr mdcr_el2, x0 // (if they exist)
591 592
592 /* Stage-2 translation */ 593 /* Stage-2 translation */
593 msr vttbr_el2, xzr 594 msr vttbr_el2, xzr
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 27b2f1387df4..01753cd7d3f0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -49,6 +49,7 @@
49#include <asm/alternative.h> 49#include <asm/alternative.h>
50#include <asm/compat.h> 50#include <asm/compat.h>
51#include <asm/cacheflush.h> 51#include <asm/cacheflush.h>
52#include <asm/exec.h>
52#include <asm/fpsimd.h> 53#include <asm/fpsimd.h>
53#include <asm/mmu_context.h> 54#include <asm/mmu_context.h>
54#include <asm/processor.h> 55#include <asm/processor.h>
@@ -186,10 +187,19 @@ void __show_regs(struct pt_regs *regs)
186 printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n", 187 printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n",
187 regs->pc, lr, regs->pstate); 188 regs->pc, lr, regs->pstate);
188 printk("sp : %016llx\n", sp); 189 printk("sp : %016llx\n", sp);
189 for (i = top_reg; i >= 0; i--) { 190
191 i = top_reg;
192
193 while (i >= 0) {
190 printk("x%-2d: %016llx ", i, regs->regs[i]); 194 printk("x%-2d: %016llx ", i, regs->regs[i]);
191 if (i % 2 == 0) 195 i--;
192 printk("\n"); 196
197 if (i % 2 == 0) {
198 pr_cont("x%-2d: %016llx ", i, regs->regs[i]);
199 i--;
200 }
201
202 pr_cont("\n");
193 } 203 }
194 printk("\n"); 204 printk("\n");
195} 205}
@@ -301,7 +311,7 @@ static void tls_thread_switch(struct task_struct *next)
301} 311}
302 312
303/* Restore the UAO state depending on next's addr_limit */ 313/* Restore the UAO state depending on next's addr_limit */
304static void uao_thread_switch(struct task_struct *next) 314void uao_thread_switch(struct task_struct *next)
305{ 315{
306 if (IS_ENABLED(CONFIG_ARM64_UAO)) { 316 if (IS_ENABLED(CONFIG_ARM64_UAO)) {
307 if (task_thread_info(next)->addr_limit == KERNEL_DS) 317 if (task_thread_info(next)->addr_limit == KERNEL_DS)
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index d3f151cfd4a1..8507703dabe4 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -544,6 +544,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
544 return; 544 return;
545 } 545 }
546 bootcpu_valid = true; 546 bootcpu_valid = true;
547 early_map_cpu_to_node(0, acpi_numa_get_nid(0, hwid));
547 return; 548 return;
548 } 549 }
549 550
diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index ad734142070d..bb0cd787a9d3 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -1,8 +1,11 @@
1#include <linux/ftrace.h> 1#include <linux/ftrace.h>
2#include <linux/percpu.h> 2#include <linux/percpu.h>
3#include <linux/slab.h> 3#include <linux/slab.h>
4#include <asm/alternative.h>
4#include <asm/cacheflush.h> 5#include <asm/cacheflush.h>
6#include <asm/cpufeature.h>
5#include <asm/debug-monitors.h> 7#include <asm/debug-monitors.h>
8#include <asm/exec.h>
6#include <asm/pgtable.h> 9#include <asm/pgtable.h>
7#include <asm/memory.h> 10#include <asm/memory.h>
8#include <asm/mmu_context.h> 11#include <asm/mmu_context.h>
@@ -50,6 +53,14 @@ void notrace __cpu_suspend_exit(void)
50 set_my_cpu_offset(per_cpu_offset(cpu)); 53 set_my_cpu_offset(per_cpu_offset(cpu));
51 54
52 /* 55 /*
56 * PSTATE was not saved over suspend/resume, re-enable any detected
57 * features that might not have been set correctly.
58 */
59 asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
60 CONFIG_ARM64_PAN));
61 uao_thread_switch(current);
62
63 /*
53 * Restore HW breakpoint registers to sane values 64 * Restore HW breakpoint registers to sane values
54 * before debug exceptions are possibly reenabled 65 * before debug exceptions are possibly reenabled
55 * through local_dbg_restore. 66 * through local_dbg_restore.
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 5ff020f8fb7f..c9986b3e0a96 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -428,24 +428,28 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
428 force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0); 428 force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
429} 429}
430 430
431void cpu_enable_cache_maint_trap(void *__unused) 431int cpu_enable_cache_maint_trap(void *__unused)
432{ 432{
433 config_sctlr_el1(SCTLR_EL1_UCI, 0); 433 config_sctlr_el1(SCTLR_EL1_UCI, 0);
434 return 0;
434} 435}
435 436
436#define __user_cache_maint(insn, address, res) \ 437#define __user_cache_maint(insn, address, res) \
437 asm volatile ( \ 438 if (untagged_addr(address) >= user_addr_max()) \
438 "1: " insn ", %1\n" \ 439 res = -EFAULT; \
439 " mov %w0, #0\n" \ 440 else \
440 "2:\n" \ 441 asm volatile ( \
441 " .pushsection .fixup,\"ax\"\n" \ 442 "1: " insn ", %1\n" \
442 " .align 2\n" \ 443 " mov %w0, #0\n" \
443 "3: mov %w0, %w2\n" \ 444 "2:\n" \
444 " b 2b\n" \ 445 " .pushsection .fixup,\"ax\"\n" \
445 " .popsection\n" \ 446 " .align 2\n" \
446 _ASM_EXTABLE(1b, 3b) \ 447 "3: mov %w0, %w2\n" \
447 : "=r" (res) \ 448 " b 2b\n" \
448 : "r" (address), "i" (-EFAULT) ) 449 " .popsection\n" \
450 _ASM_EXTABLE(1b, 3b) \
451 : "=r" (res) \
452 : "r" (address), "i" (-EFAULT) )
449 453
450static void user_cache_maint_handler(unsigned int esr, struct pt_regs *regs) 454static void user_cache_maint_handler(unsigned int esr, struct pt_regs *regs)
451{ 455{
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 53d9159662fe..0f8788374815 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -29,7 +29,9 @@
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/perf_event.h> 31#include <linux/perf_event.h>
32#include <linux/preempt.h>
32 33
34#include <asm/bug.h>
33#include <asm/cpufeature.h> 35#include <asm/cpufeature.h>
34#include <asm/exception.h> 36#include <asm/exception.h>
35#include <asm/debug-monitors.h> 37#include <asm/debug-monitors.h>
@@ -670,9 +672,17 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
670NOKPROBE_SYMBOL(do_debug_exception); 672NOKPROBE_SYMBOL(do_debug_exception);
671 673
672#ifdef CONFIG_ARM64_PAN 674#ifdef CONFIG_ARM64_PAN
673void cpu_enable_pan(void *__unused) 675int cpu_enable_pan(void *__unused)
674{ 676{
677 /*
678 * We modify PSTATE. This won't work from irq context as the PSTATE
679 * is discarded once we return from the exception.
680 */
681 WARN_ON_ONCE(in_interrupt());
682
675 config_sctlr_el1(SCTLR_EL1_SPAN, 0); 683 config_sctlr_el1(SCTLR_EL1_SPAN, 0);
684 asm(SET_PSTATE_PAN(1));
685 return 0;
676} 686}
677#endif /* CONFIG_ARM64_PAN */ 687#endif /* CONFIG_ARM64_PAN */
678 688
@@ -683,8 +693,9 @@ void cpu_enable_pan(void *__unused)
683 * We need to enable the feature at runtime (instead of adding it to 693 * We need to enable the feature at runtime (instead of adding it to
684 * PSR_MODE_EL1h) as the feature may not be implemented by the cpu. 694 * PSR_MODE_EL1h) as the feature may not be implemented by the cpu.
685 */ 695 */
686void cpu_enable_uao(void *__unused) 696int cpu_enable_uao(void *__unused)
687{ 697{
688 asm(SET_PSTATE_UAO(1)); 698 asm(SET_PSTATE_UAO(1));
699 return 0;
689} 700}
690#endif /* CONFIG_ARM64_UAO */ 701#endif /* CONFIG_ARM64_UAO */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 21c489bdeb4e..212c4d1e2f26 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -421,35 +421,35 @@ void __init mem_init(void)
421 421
422 pr_notice("Virtual kernel memory layout:\n"); 422 pr_notice("Virtual kernel memory layout:\n");
423#ifdef CONFIG_KASAN 423#ifdef CONFIG_KASAN
424 pr_cont(" kasan : 0x%16lx - 0x%16lx (%6ld GB)\n", 424 pr_notice(" kasan : 0x%16lx - 0x%16lx (%6ld GB)\n",
425 MLG(KASAN_SHADOW_START, KASAN_SHADOW_END)); 425 MLG(KASAN_SHADOW_START, KASAN_SHADOW_END));
426#endif 426#endif
427 pr_cont(" modules : 0x%16lx - 0x%16lx (%6ld MB)\n", 427 pr_notice(" modules : 0x%16lx - 0x%16lx (%6ld MB)\n",
428 MLM(MODULES_VADDR, MODULES_END)); 428 MLM(MODULES_VADDR, MODULES_END));
429 pr_cont(" vmalloc : 0x%16lx - 0x%16lx (%6ld GB)\n", 429 pr_notice(" vmalloc : 0x%16lx - 0x%16lx (%6ld GB)\n",
430 MLG(VMALLOC_START, VMALLOC_END)); 430 MLG(VMALLOC_START, VMALLOC_END));
431 pr_cont(" .text : 0x%p" " - 0x%p" " (%6ld KB)\n", 431 pr_notice(" .text : 0x%p" " - 0x%p" " (%6ld KB)\n",
432 MLK_ROUNDUP(_text, _etext)); 432 MLK_ROUNDUP(_text, _etext));
433 pr_cont(" .rodata : 0x%p" " - 0x%p" " (%6ld KB)\n", 433 pr_notice(" .rodata : 0x%p" " - 0x%p" " (%6ld KB)\n",
434 MLK_ROUNDUP(__start_rodata, __init_begin)); 434 MLK_ROUNDUP(__start_rodata, __init_begin));
435 pr_cont(" .init : 0x%p" " - 0x%p" " (%6ld KB)\n", 435 pr_notice(" .init : 0x%p" " - 0x%p" " (%6ld KB)\n",
436 MLK_ROUNDUP(__init_begin, __init_end)); 436 MLK_ROUNDUP(__init_begin, __init_end));
437 pr_cont(" .data : 0x%p" " - 0x%p" " (%6ld KB)\n", 437 pr_notice(" .data : 0x%p" " - 0x%p" " (%6ld KB)\n",
438 MLK_ROUNDUP(_sdata, _edata)); 438 MLK_ROUNDUP(_sdata, _edata));
439 pr_cont(" .bss : 0x%p" " - 0x%p" " (%6ld KB)\n", 439 pr_notice(" .bss : 0x%p" " - 0x%p" " (%6ld KB)\n",
440 MLK_ROUNDUP(__bss_start, __bss_stop)); 440 MLK_ROUNDUP(__bss_start, __bss_stop));
441 pr_cont(" fixed : 0x%16lx - 0x%16lx (%6ld KB)\n", 441 pr_notice(" fixed : 0x%16lx - 0x%16lx (%6ld KB)\n",
442 MLK(FIXADDR_START, FIXADDR_TOP)); 442 MLK(FIXADDR_START, FIXADDR_TOP));
443 pr_cont(" PCI I/O : 0x%16lx - 0x%16lx (%6ld MB)\n", 443 pr_notice(" PCI I/O : 0x%16lx - 0x%16lx (%6ld MB)\n",
444 MLM(PCI_IO_START, PCI_IO_END)); 444 MLM(PCI_IO_START, PCI_IO_END));
445#ifdef CONFIG_SPARSEMEM_VMEMMAP 445#ifdef CONFIG_SPARSEMEM_VMEMMAP
446 pr_cont(" vmemmap : 0x%16lx - 0x%16lx (%6ld GB maximum)\n", 446 pr_notice(" vmemmap : 0x%16lx - 0x%16lx (%6ld GB maximum)\n",
447 MLG(VMEMMAP_START, VMEMMAP_START + VMEMMAP_SIZE)); 447 MLG(VMEMMAP_START, VMEMMAP_START + VMEMMAP_SIZE));
448 pr_cont(" 0x%16lx - 0x%16lx (%6ld MB actual)\n", 448 pr_notice(" 0x%16lx - 0x%16lx (%6ld MB actual)\n",
449 MLM((unsigned long)phys_to_page(memblock_start_of_DRAM()), 449 MLM((unsigned long)phys_to_page(memblock_start_of_DRAM()),
450 (unsigned long)virt_to_page(high_memory))); 450 (unsigned long)virt_to_page(high_memory)));
451#endif 451#endif
452 pr_cont(" memory : 0x%16lx - 0x%16lx (%6ld MB)\n", 452 pr_notice(" memory : 0x%16lx - 0x%16lx (%6ld MB)\n",
453 MLM(__phys_to_virt(memblock_start_of_DRAM()), 453 MLM(__phys_to_virt(memblock_start_of_DRAM()),
454 (unsigned long)high_memory)); 454 (unsigned long)high_memory));
455 455
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index 778a985c8a70..4b32168cf91a 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -147,7 +147,7 @@ static int __init early_cpu_to_node(int cpu)
147 147
148static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) 148static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
149{ 149{
150 return node_distance(from, to); 150 return node_distance(early_cpu_to_node(from), early_cpu_to_node(to));
151} 151}
152 152
153static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, 153static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,
@@ -223,8 +223,11 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)
223 void *nd; 223 void *nd;
224 int tnid; 224 int tnid;
225 225
226 pr_info("Initmem setup node %d [mem %#010Lx-%#010Lx]\n", 226 if (start_pfn < end_pfn)
227 nid, start_pfn << PAGE_SHIFT, (end_pfn << PAGE_SHIFT) - 1); 227 pr_info("Initmem setup node %d [mem %#010Lx-%#010Lx]\n", nid,
228 start_pfn << PAGE_SHIFT, (end_pfn << PAGE_SHIFT) - 1);
229 else
230 pr_info("Initmem setup node %d [<memory-less node>]\n", nid);
228 231
229 nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); 232 nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid);
230 nd = __va(nd_pa); 233 nd = __va(nd_pa);
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 099e170a93ee..0068fd411a84 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -3149,7 +3149,7 @@ static void print_dma_descriptors(struct cryptocop_int_operation *iop)
3149 printk("print_dma_descriptors start\n"); 3149 printk("print_dma_descriptors start\n");
3150 3150
3151 printk("iop:\n"); 3151 printk("iop:\n");
3152 printk("\tsid: 0x%lld\n", iop->sid); 3152 printk("\tsid: 0x%llx\n", iop->sid);
3153 3153
3154 printk("\tcdesc_out: 0x%p\n", iop->cdesc_out); 3154 printk("\tcdesc_out: 0x%p\n", iop->cdesc_out);
3155 printk("\tcdesc_in: 0x%p\n", iop->cdesc_in); 3155 printk("\tcdesc_in: 0x%p\n", iop->cdesc_in);
diff --git a/arch/h8300/include/asm/thread_info.h b/arch/h8300/include/asm/thread_info.h
index b408fe660cf8..3cef06875f5c 100644
--- a/arch/h8300/include/asm/thread_info.h
+++ b/arch/h8300/include/asm/thread_info.h
@@ -31,7 +31,6 @@ struct thread_info {
31 int cpu; /* cpu we're on */ 31 int cpu; /* cpu we're on */
32 int preempt_count; /* 0 => preemptable, <0 => BUG */ 32 int preempt_count; /* 0 => preemptable, <0 => BUG */
33 mm_segment_t addr_limit; 33 mm_segment_t addr_limit;
34 struct restart_block restart_block;
35}; 34};
36 35
37/* 36/*
@@ -44,9 +43,6 @@ struct thread_info {
44 .cpu = 0, \ 43 .cpu = 0, \
45 .preempt_count = INIT_PREEMPT_COUNT, \ 44 .preempt_count = INIT_PREEMPT_COUNT, \
46 .addr_limit = KERNEL_DS, \ 45 .addr_limit = KERNEL_DS, \
47 .restart_block = { \
48 .fn = do_no_restart_syscall, \
49 }, \
50} 46}
51 47
52#define init_thread_info (init_thread_union.thread_info) 48#define init_thread_info (init_thread_union.thread_info)
diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index ad1f81f574e5..7138303cbbf2 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -79,7 +79,7 @@ restore_sigcontext(struct sigcontext *usc, int *pd0)
79 unsigned int er0; 79 unsigned int er0;
80 80
81 /* Always make any pending restarted system calls return -EINTR */ 81 /* Always make any pending restarted system calls return -EINTR */
82 current_thread_info()->restart_block.fn = do_no_restart_syscall; 82 current->restart_block.fn = do_no_restart_syscall;
83 83
84 /* restore passed registers */ 84 /* restore passed registers */
85#define COPY(r) do { err |= get_user(regs->r, &usc->sc_##r); } while (0) 85#define COPY(r) do { err |= get_user(regs->r, &usc->sc_##r); } while (0)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index ce961495b5e1..622037d851a3 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -14,6 +14,7 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/kdebug.h> 15#include <linux/kdebug.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/uaccess.h>
17#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
18#include <linux/fs.h> 19#include <linux/fs.h>
19#include <linux/bootmem.h> 20#include <linux/bootmem.h>
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index f7a184b6c35b..57d42d129033 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -32,9 +32,16 @@ static struct addr_range prep_kernel(void)
32 void *addr = 0; 32 void *addr = 0;
33 struct elf_info ei; 33 struct elf_info ei;
34 long len; 34 long len;
35 int uncompressed_image = 0;
35 36
36 partial_decompress(vmlinuz_addr, vmlinuz_size, 37 len = partial_decompress(vmlinuz_addr, vmlinuz_size,
37 elfheader, sizeof(elfheader), 0); 38 elfheader, sizeof(elfheader), 0);
39 /* assume uncompressed data if -1 is returned */
40 if (len == -1) {
41 uncompressed_image = 1;
42 memcpy(elfheader, vmlinuz_addr, sizeof(elfheader));
43 printf("No valid compressed data found, assume uncompressed data\n\r");
44 }
38 45
39 if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei)) 46 if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei))
40 fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r"); 47 fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
@@ -67,6 +74,13 @@ static struct addr_range prep_kernel(void)
67 "device tree\n\r"); 74 "device tree\n\r");
68 } 75 }
69 76
77 if (uncompressed_image) {
78 memcpy(addr, vmlinuz_addr + ei.elfoffset, ei.loadsize);
79 printf("0x%lx bytes of uncompressed data copied\n\r",
80 ei.loadsize);
81 goto out;
82 }
83
70 /* Finally, decompress the kernel */ 84 /* Finally, decompress the kernel */
71 printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr, 85 printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr,
72 vmlinuz_addr, vmlinuz_addr+vmlinuz_size); 86 vmlinuz_addr, vmlinuz_addr+vmlinuz_size);
@@ -82,7 +96,7 @@ static struct addr_range prep_kernel(void)
82 len, ei.loadsize); 96 len, ei.loadsize);
83 97
84 printf("Done! Decompressed 0x%lx bytes\n\r", len); 98 printf("Done! Decompressed 0x%lx bytes\n\r", len);
85 99out:
86 flush_cache(addr, ei.loadsize); 100 flush_cache(addr, ei.loadsize);
87 101
88 return (struct addr_range){addr, ei.memsize}; 102 return (struct addr_range){addr, ei.memsize};
diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h
index ee655ed1ff1b..1e8fceb308a5 100644
--- a/arch/powerpc/include/asm/checksum.h
+++ b/arch/powerpc/include/asm/checksum.h
@@ -53,10 +53,8 @@ static inline __sum16 csum_fold(__wsum sum)
53 return (__force __sum16)(~((__force u32)sum + tmp) >> 16); 53 return (__force __sum16)(~((__force u32)sum + tmp) >> 16);
54} 54}
55 55
56static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, 56static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
57 unsigned short len, 57 __u8 proto, __wsum sum)
58 unsigned short proto,
59 __wsum sum)
60{ 58{
61#ifdef __powerpc64__ 59#ifdef __powerpc64__
62 unsigned long s = (__force u32)sum; 60 unsigned long s = (__force u32)sum;
@@ -83,10 +81,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
83 * computes the checksum of the TCP/UDP pseudo-header 81 * computes the checksum of the TCP/UDP pseudo-header
84 * returns a 16-bit checksum, already complemented 82 * returns a 16-bit checksum, already complemented
85 */ 83 */
86static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, 84static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
87 unsigned short len, 85 __u8 proto, __wsum sum)
88 unsigned short proto,
89 __wsum sum)
90{ 86{
91 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); 87 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
92} 88}
diff --git a/arch/powerpc/include/asm/cpuidle.h b/arch/powerpc/include/asm/cpuidle.h
index 01b8a13f0224..3919332965af 100644
--- a/arch/powerpc/include/asm/cpuidle.h
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -26,7 +26,7 @@ extern u64 pnv_first_deep_stop_state;
26 std r0,0(r1); \ 26 std r0,0(r1); \
27 ptesync; \ 27 ptesync; \
28 ld r0,0(r1); \ 28 ld r0,0(r1); \
291: cmp cr0,r0,r0; \ 291: cmpd cr0,r0,r0; \
30 bne 1b; \ 30 bne 1b; \
31 IDLE_INST; \ 31 IDLE_INST; \
32 b . 32 b .
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 2e4e7d878c8e..84d49b197c32 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -93,6 +93,10 @@
93 ld reg,PACAKBASE(r13); /* get high part of &label */ \ 93 ld reg,PACAKBASE(r13); /* get high part of &label */ \
94 ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l; 94 ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l;
95 95
96#define __LOAD_HANDLER(reg, label) \
97 ld reg,PACAKBASE(r13); \
98 ori reg,reg,(ABS_ADDR(label))@l;
99
96/* Exception register prefixes */ 100/* Exception register prefixes */
97#define EXC_HV H 101#define EXC_HV H
98#define EXC_STD 102#define EXC_STD
@@ -208,6 +212,18 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
208#define kvmppc_interrupt kvmppc_interrupt_pr 212#define kvmppc_interrupt kvmppc_interrupt_pr
209#endif 213#endif
210 214
215#ifdef CONFIG_RELOCATABLE
216#define BRANCH_TO_COMMON(reg, label) \
217 __LOAD_HANDLER(reg, label); \
218 mtctr reg; \
219 bctr
220
221#else
222#define BRANCH_TO_COMMON(reg, label) \
223 b label
224
225#endif
226
211#define __KVM_HANDLER_PROLOG(area, n) \ 227#define __KVM_HANDLER_PROLOG(area, n) \
212 BEGIN_FTR_SECTION_NESTED(947) \ 228 BEGIN_FTR_SECTION_NESTED(947) \
213 ld r10,area+EX_CFAR(r13); \ 229 ld r10,area+EX_CFAR(r13); \
diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h
index f6f68f73e858..99e1397b71da 100644
--- a/arch/powerpc/include/asm/tlb.h
+++ b/arch/powerpc/include/asm/tlb.h
@@ -52,11 +52,23 @@ static inline int mm_is_core_local(struct mm_struct *mm)
52 return cpumask_subset(mm_cpumask(mm), 52 return cpumask_subset(mm_cpumask(mm),
53 topology_sibling_cpumask(smp_processor_id())); 53 topology_sibling_cpumask(smp_processor_id()));
54} 54}
55
56static inline int mm_is_thread_local(struct mm_struct *mm)
57{
58 return cpumask_equal(mm_cpumask(mm),
59 cpumask_of(smp_processor_id()));
60}
61
55#else 62#else
56static inline int mm_is_core_local(struct mm_struct *mm) 63static inline int mm_is_core_local(struct mm_struct *mm)
57{ 64{
58 return 1; 65 return 1;
59} 66}
67
68static inline int mm_is_thread_local(struct mm_struct *mm)
69{
70 return 1;
71}
60#endif 72#endif
61 73
62#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index cf12c580f6b2..e8cdfec8d512 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -16,6 +16,10 @@
16 16
17#define __NR__exit __NR_exit 17#define __NR__exit __NR_exit
18 18
19#define __IGNORE_pkey_mprotect
20#define __IGNORE_pkey_alloc
21#define __IGNORE_pkey_free
22
19#ifndef __ASSEMBLY__ 23#ifndef __ASSEMBLY__
20 24
21#include <linux/types.h> 25#include <linux/types.h>
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index f129408c6022..08ba447a4b3d 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -95,19 +95,35 @@ __start_interrupts:
95/* No virt vectors corresponding with 0x0..0x100 */ 95/* No virt vectors corresponding with 0x0..0x100 */
96EXC_VIRT_NONE(0x4000, 0x4100) 96EXC_VIRT_NONE(0x4000, 0x4100)
97 97
98EXC_REAL_BEGIN(system_reset, 0x100, 0x200) 98
99 SET_SCRATCH0(r13)
100#ifdef CONFIG_PPC_P7_NAP 99#ifdef CONFIG_PPC_P7_NAP
101BEGIN_FTR_SECTION 100 /*
102 /* Running native on arch 2.06 or later, check if we are 101 * If running native on arch 2.06 or later, check if we are waking up
103 * waking up from nap/sleep/winkle. 102 * from nap/sleep/winkle, and branch to idle handler.
104 */ 103 */
105 mfspr r13,SPRN_SRR1 104#define IDLETEST(n) \
106 rlwinm. r13,r13,47-31,30,31 105 BEGIN_FTR_SECTION ; \
107 beq 9f 106 mfspr r10,SPRN_SRR1 ; \
107 rlwinm. r10,r10,47-31,30,31 ; \
108 beq- 1f ; \
109 cmpwi cr3,r10,2 ; \
110 BRANCH_TO_COMMON(r10, system_reset_idle_common) ; \
1111: \
112 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
113#else
114#define IDLETEST NOTEST
115#endif
108 116
109 cmpwi cr3,r13,2 117EXC_REAL_BEGIN(system_reset, 0x100, 0x200)
110 GET_PACA(r13) 118 SET_SCRATCH0(r13)
119 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
120 IDLETEST, 0x100)
121
122EXC_REAL_END(system_reset, 0x100, 0x200)
123EXC_VIRT_NONE(0x4100, 0x4200)
124
125#ifdef CONFIG_PPC_P7_NAP
126EXC_COMMON_BEGIN(system_reset_idle_common)
111 bl pnv_restore_hyp_resource 127 bl pnv_restore_hyp_resource
112 128
113 li r0,PNV_THREAD_RUNNING 129 li r0,PNV_THREAD_RUNNING
@@ -130,14 +146,8 @@ BEGIN_FTR_SECTION
130 blt cr3,2f 146 blt cr3,2f
131 b pnv_wakeup_loss 147 b pnv_wakeup_loss
1322: b pnv_wakeup_noloss 1482: b pnv_wakeup_noloss
149#endif
133 150
1349:
135END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
136#endif /* CONFIG_PPC_P7_NAP */
137 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
138 NOTEST, 0x100)
139EXC_REAL_END(system_reset, 0x100, 0x200)
140EXC_VIRT_NONE(0x4100, 0x4200)
141EXC_COMMON(system_reset_common, 0x100, system_reset_exception) 151EXC_COMMON(system_reset_common, 0x100, system_reset_exception)
142 152
143#ifdef CONFIG_PPC_PSERIES 153#ifdef CONFIG_PPC_PSERIES
@@ -817,10 +827,8 @@ EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
817TRAMP_KVM(PACA_EXGEN, 0xb00) 827TRAMP_KVM(PACA_EXGEN, 0xb00)
818EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) 828EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
819 829
820 830#define LOAD_SYSCALL_HANDLER(reg) \
821#define LOAD_SYSCALL_HANDLER(reg) \ 831 __LOAD_HANDLER(reg, system_call_common)
822 ld reg,PACAKBASE(r13); \
823 ori reg,reg,(ABS_ADDR(system_call_common))@l;
824 832
825/* Syscall routine is used twice, in reloc-off and reloc-on paths */ 833/* Syscall routine is used twice, in reloc-off and reloc-on paths */
826#define SYSCALL_PSERIES_1 \ 834#define SYSCALL_PSERIES_1 \
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 9781c69eae57..03d089b3ed72 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -275,7 +275,7 @@ int hw_breakpoint_handler(struct die_args *args)
275 if (!stepped) { 275 if (!stepped) {
276 WARN(1, "Unable to handle hardware breakpoint. Breakpoint at " 276 WARN(1, "Unable to handle hardware breakpoint. Breakpoint at "
277 "0x%lx will be disabled.", info->address); 277 "0x%lx will be disabled.", info->address);
278 perf_event_disable(bp); 278 perf_event_disable_inatomic(bp);
279 goto out; 279 goto out;
280 } 280 }
281 /* 281 /*
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index bd739fed26e3..72dac0b58061 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -90,6 +90,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
90 * Threads will spin in HMT_LOW until the lock bit is cleared. 90 * Threads will spin in HMT_LOW until the lock bit is cleared.
91 * r14 - pointer to core_idle_state 91 * r14 - pointer to core_idle_state
92 * r15 - used to load contents of core_idle_state 92 * r15 - used to load contents of core_idle_state
93 * r9 - used as a temporary variable
93 */ 94 */
94 95
95core_idle_lock_held: 96core_idle_lock_held:
@@ -99,6 +100,8 @@ core_idle_lock_held:
99 bne 3b 100 bne 3b
100 HMT_MEDIUM 101 HMT_MEDIUM
101 lwarx r15,0,r14 102 lwarx r15,0,r14
103 andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT
104 bne core_idle_lock_held
102 blr 105 blr
103 106
104/* 107/*
@@ -163,12 +166,6 @@ _GLOBAL(pnv_powersave_common)
163 std r9,_MSR(r1) 166 std r9,_MSR(r1)
164 std r1,PACAR1(r13) 167 std r1,PACAR1(r13)
165 168
166#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
167 /* Tell KVM we're entering idle */
168 li r4,KVM_HWTHREAD_IN_IDLE
169 stb r4,HSTATE_HWTHREAD_STATE(r13)
170#endif
171
172 /* 169 /*
173 * Go to real mode to do the nap, as required by the architecture. 170 * Go to real mode to do the nap, as required by the architecture.
174 * Also, we need to be in real mode before setting hwthread_state, 171 * Also, we need to be in real mode before setting hwthread_state,
@@ -185,6 +182,26 @@ _GLOBAL(pnv_powersave_common)
185 182
186 .globl pnv_enter_arch207_idle_mode 183 .globl pnv_enter_arch207_idle_mode
187pnv_enter_arch207_idle_mode: 184pnv_enter_arch207_idle_mode:
185#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
186 /* Tell KVM we're entering idle */
187 li r4,KVM_HWTHREAD_IN_IDLE
188 /******************************************************/
189 /* N O T E W E L L ! ! ! N O T E W E L L */
190 /* The following store to HSTATE_HWTHREAD_STATE(r13) */
191 /* MUST occur in real mode, i.e. with the MMU off, */
192 /* and the MMU must stay off until we clear this flag */
193 /* and test HSTATE_HWTHREAD_REQ(r13) in the system */
194 /* reset interrupt vector in exceptions-64s.S. */
195 /* The reason is that another thread can switch the */
196 /* MMU to a guest context whenever this flag is set */
197 /* to KVM_HWTHREAD_IN_IDLE, and if the MMU was on, */
198 /* that would potentially cause this thread to start */
199 /* executing instructions from guest memory in */
200 /* hypervisor mode, leading to a host crash or data */
201 /* corruption, or worse. */
202 /******************************************************/
203 stb r4,HSTATE_HWTHREAD_STATE(r13)
204#endif
188 stb r3,PACA_THREAD_IDLE_STATE(r13) 205 stb r3,PACA_THREAD_IDLE_STATE(r13)
189 cmpwi cr3,r3,PNV_THREAD_SLEEP 206 cmpwi cr3,r3,PNV_THREAD_SLEEP
190 bge cr3,2f 207 bge cr3,2f
@@ -250,6 +267,12 @@ enter_winkle:
250 * r3 - requested stop state 267 * r3 - requested stop state
251 */ 268 */
252power_enter_stop: 269power_enter_stop:
270#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
271 /* Tell KVM we're entering idle */
272 li r4,KVM_HWTHREAD_IN_IDLE
273 /* DO THIS IN REAL MODE! See comment above. */
274 stb r4,HSTATE_HWTHREAD_STATE(r13)
275#endif
253/* 276/*
254 * Check if the requested state is a deep idle state. 277 * Check if the requested state is a deep idle state.
255 */ 278 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9e7c10fe205f..ce6dc61b15b2 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1012,7 +1012,7 @@ void restore_tm_state(struct pt_regs *regs)
1012 /* Ensure that restore_math() will restore */ 1012 /* Ensure that restore_math() will restore */
1013 if (msr_diff & MSR_FP) 1013 if (msr_diff & MSR_FP)
1014 current->thread.load_fp = 1; 1014 current->thread.load_fp = 1;
1015#ifdef CONFIG_ALIVEC 1015#ifdef CONFIG_ALTIVEC
1016 if (cpu_has_feature(CPU_FTR_ALTIVEC) && msr_diff & MSR_VEC) 1016 if (cpu_has_feature(CPU_FTR_ALTIVEC) && msr_diff & MSR_VEC)
1017 current->thread.load_vec = 1; 1017 current->thread.load_vec = 1;
1018#endif 1018#endif
diff --git a/arch/powerpc/kvm/book3s_hv_rm_xics.c b/arch/powerpc/kvm/book3s_hv_rm_xics.c
index 82ff5de8b1e7..a0ea63ac2b52 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_xics.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_xics.c
@@ -23,6 +23,7 @@
23#include <asm/ppc-opcode.h> 23#include <asm/ppc-opcode.h>
24#include <asm/pnv-pci.h> 24#include <asm/pnv-pci.h>
25#include <asm/opal.h> 25#include <asm/opal.h>
26#include <asm/smp.h>
26 27
27#include "book3s_xics.h" 28#include "book3s_xics.h"
28 29
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index bb0354222b11..362954f98029 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -106,6 +106,8 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
106 switch (REGION_ID(ea)) { 106 switch (REGION_ID(ea)) {
107 case USER_REGION_ID: 107 case USER_REGION_ID:
108 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); 108 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea);
109 if (mm == NULL)
110 return 1;
109 psize = get_slice_psize(mm, ea); 111 psize = get_slice_psize(mm, ea);
110 ssize = user_segment_size(ea); 112 ssize = user_segment_size(ea);
111 vsid = get_vsid(mm->context.id, ea, ssize); 113 vsid = get_vsid(mm->context.id, ea, ssize);
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 75b9cd6150cc..a51c188b81f3 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -845,7 +845,7 @@ void __init dump_numa_cpu_topology(void)
845 return; 845 return;
846 846
847 for_each_online_node(node) { 847 for_each_online_node(node) {
848 printk(KERN_DEBUG "Node %d CPUs:", node); 848 pr_info("Node %d CPUs:", node);
849 849
850 count = 0; 850 count = 0;
851 /* 851 /*
@@ -856,52 +856,18 @@ void __init dump_numa_cpu_topology(void)
856 if (cpumask_test_cpu(cpu, 856 if (cpumask_test_cpu(cpu,
857 node_to_cpumask_map[node])) { 857 node_to_cpumask_map[node])) {
858 if (count == 0) 858 if (count == 0)
859 printk(" %u", cpu); 859 pr_cont(" %u", cpu);
860 ++count; 860 ++count;
861 } else { 861 } else {
862 if (count > 1) 862 if (count > 1)
863 printk("-%u", cpu - 1); 863 pr_cont("-%u", cpu - 1);
864 count = 0; 864 count = 0;
865 } 865 }
866 } 866 }
867 867
868 if (count > 1) 868 if (count > 1)
869 printk("-%u", nr_cpu_ids - 1); 869 pr_cont("-%u", nr_cpu_ids - 1);
870 printk("\n"); 870 pr_cont("\n");
871 }
872}
873
874static void __init dump_numa_memory_topology(void)
875{
876 unsigned int node;
877 unsigned int count;
878
879 if (min_common_depth == -1 || !numa_enabled)
880 return;
881
882 for_each_online_node(node) {
883 unsigned long i;
884
885 printk(KERN_DEBUG "Node %d Memory:", node);
886
887 count = 0;
888
889 for (i = 0; i < memblock_end_of_DRAM();
890 i += (1 << SECTION_SIZE_BITS)) {
891 if (early_pfn_to_nid(i >> PAGE_SHIFT) == node) {
892 if (count == 0)
893 printk(" 0x%lx", i);
894 ++count;
895 } else {
896 if (count > 0)
897 printk("-0x%lx", i);
898 count = 0;
899 }
900 }
901
902 if (count > 0)
903 printk("-0x%lx", i);
904 printk("\n");
905 } 871 }
906} 872}
907 873
@@ -947,8 +913,6 @@ void __init initmem_init(void)
947 913
948 if (parse_numa_properties()) 914 if (parse_numa_properties())
949 setup_nonnuma(); 915 setup_nonnuma();
950 else
951 dump_numa_memory_topology();
952 916
953 memblock_dump_all(); 917 memblock_dump_all();
954 918
diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
index 0e49ec541ab5..bda8c43be78a 100644
--- a/arch/powerpc/mm/tlb-radix.c
+++ b/arch/powerpc/mm/tlb-radix.c
@@ -175,7 +175,7 @@ void radix__flush_tlb_mm(struct mm_struct *mm)
175 if (unlikely(pid == MMU_NO_CONTEXT)) 175 if (unlikely(pid == MMU_NO_CONTEXT))
176 goto no_context; 176 goto no_context;
177 177
178 if (!mm_is_core_local(mm)) { 178 if (!mm_is_thread_local(mm)) {
179 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 179 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
180 180
181 if (lock_tlbie) 181 if (lock_tlbie)
@@ -201,7 +201,7 @@ void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr)
201 if (unlikely(pid == MMU_NO_CONTEXT)) 201 if (unlikely(pid == MMU_NO_CONTEXT))
202 goto no_context; 202 goto no_context;
203 203
204 if (!mm_is_core_local(mm)) { 204 if (!mm_is_thread_local(mm)) {
205 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 205 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
206 206
207 if (lock_tlbie) 207 if (lock_tlbie)
@@ -226,7 +226,7 @@ void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
226 pid = mm ? mm->context.id : 0; 226 pid = mm ? mm->context.id : 0;
227 if (unlikely(pid == MMU_NO_CONTEXT)) 227 if (unlikely(pid == MMU_NO_CONTEXT))
228 goto bail; 228 goto bail;
229 if (!mm_is_core_local(mm)) { 229 if (!mm_is_thread_local(mm)) {
230 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 230 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
231 231
232 if (lock_tlbie) 232 if (lock_tlbie)
@@ -321,7 +321,7 @@ void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start,
321{ 321{
322 unsigned long pid; 322 unsigned long pid;
323 unsigned long addr; 323 unsigned long addr;
324 int local = mm_is_core_local(mm); 324 int local = mm_is_thread_local(mm);
325 unsigned long ap = mmu_get_ap(psize); 325 unsigned long ap = mmu_get_ap(psize);
326 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 326 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
327 unsigned long page_size = 1UL << mmu_psize_defs[psize].shift; 327 unsigned long page_size = 1UL << mmu_psize_defs[psize].shift;
diff --git a/arch/s390/include/asm/ftrace.h b/arch/s390/include/asm/ftrace.h
index 64053d9ac3f2..836c56290499 100644
--- a/arch/s390/include/asm/ftrace.h
+++ b/arch/s390/include/asm/ftrace.h
@@ -12,9 +12,7 @@
12 12
13#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
14 14
15unsigned long return_address(int depth); 15#define ftrace_return_address(n) __builtin_return_address(n)
16
17#define ftrace_return_address(n) return_address(n)
18 16
19void _mcount(void); 17void _mcount(void);
20void ftrace_caller(void); 18void ftrace_caller(void);
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 03323175de30..602af692efdc 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -192,7 +192,7 @@ struct task_struct;
192struct mm_struct; 192struct mm_struct;
193struct seq_file; 193struct seq_file;
194 194
195typedef int (*dump_trace_func_t)(void *data, unsigned long address); 195typedef int (*dump_trace_func_t)(void *data, unsigned long address, int reliable);
196void dump_trace(dump_trace_func_t func, void *data, 196void dump_trace(dump_trace_func_t func, void *data,
197 struct task_struct *task, unsigned long sp); 197 struct task_struct *task, unsigned long sp);
198 198
diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h
index 02613bad8bbb..3066031a73fe 100644
--- a/arch/s390/include/asm/unistd.h
+++ b/arch/s390/include/asm/unistd.h
@@ -9,6 +9,9 @@
9#include <uapi/asm/unistd.h> 9#include <uapi/asm/unistd.h>
10 10
11#define __IGNORE_time 11#define __IGNORE_time
12#define __IGNORE_pkey_mprotect
13#define __IGNORE_pkey_alloc
14#define __IGNORE_pkey_free
12 15
13#define __ARCH_WANT_OLD_READDIR 16#define __ARCH_WANT_OLD_READDIR
14#define __ARCH_WANT_SYS_ALARM 17#define __ARCH_WANT_SYS_ALARM
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
index 43446fa2a4e5..c74c59236f44 100644
--- a/arch/s390/kernel/dis.c
+++ b/arch/s390/kernel/dis.c
@@ -2014,12 +2014,12 @@ void show_code(struct pt_regs *regs)
2014 *ptr++ = '\t'; 2014 *ptr++ = '\t';
2015 ptr += print_insn(ptr, code + start, addr); 2015 ptr += print_insn(ptr, code + start, addr);
2016 start += opsize; 2016 start += opsize;
2017 printk("%s", buffer); 2017 pr_cont("%s", buffer);
2018 ptr = buffer; 2018 ptr = buffer;
2019 ptr += sprintf(ptr, "\n "); 2019 ptr += sprintf(ptr, "\n ");
2020 hops++; 2020 hops++;
2021 } 2021 }
2022 printk("\n"); 2022 pr_cont("\n");
2023} 2023}
2024 2024
2025void print_fn_code(unsigned char *code, unsigned long len) 2025void print_fn_code(unsigned char *code, unsigned long len)
diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
index 6693383bc01b..55d4fe174fd9 100644
--- a/arch/s390/kernel/dumpstack.c
+++ b/arch/s390/kernel/dumpstack.c
@@ -38,10 +38,10 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
38 if (sp < low || sp > high - sizeof(*sf)) 38 if (sp < low || sp > high - sizeof(*sf))
39 return sp; 39 return sp;
40 sf = (struct stack_frame *) sp; 40 sf = (struct stack_frame *) sp;
41 if (func(data, sf->gprs[8], 0))
42 return sp;
41 /* Follow the backchain. */ 43 /* Follow the backchain. */
42 while (1) { 44 while (1) {
43 if (func(data, sf->gprs[8]))
44 return sp;
45 low = sp; 45 low = sp;
46 sp = sf->back_chain; 46 sp = sf->back_chain;
47 if (!sp) 47 if (!sp)
@@ -49,6 +49,8 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
49 if (sp <= low || sp > high - sizeof(*sf)) 49 if (sp <= low || sp > high - sizeof(*sf))
50 return sp; 50 return sp;
51 sf = (struct stack_frame *) sp; 51 sf = (struct stack_frame *) sp;
52 if (func(data, sf->gprs[8], 1))
53 return sp;
52 } 54 }
53 /* Zero backchain detected, check for interrupt frame. */ 55 /* Zero backchain detected, check for interrupt frame. */
54 sp = (unsigned long) (sf + 1); 56 sp = (unsigned long) (sf + 1);
@@ -56,7 +58,7 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
56 return sp; 58 return sp;
57 regs = (struct pt_regs *) sp; 59 regs = (struct pt_regs *) sp;
58 if (!user_mode(regs)) { 60 if (!user_mode(regs)) {
59 if (func(data, regs->psw.addr)) 61 if (func(data, regs->psw.addr, 1))
60 return sp; 62 return sp;
61 } 63 }
62 low = sp; 64 low = sp;
@@ -85,33 +87,12 @@ void dump_trace(dump_trace_func_t func, void *data, struct task_struct *task,
85} 87}
86EXPORT_SYMBOL_GPL(dump_trace); 88EXPORT_SYMBOL_GPL(dump_trace);
87 89
88struct return_address_data { 90static int show_address(void *data, unsigned long address, int reliable)
89 unsigned long address;
90 int depth;
91};
92
93static int __return_address(void *data, unsigned long address)
94{
95 struct return_address_data *rd = data;
96
97 if (rd->depth--)
98 return 0;
99 rd->address = address;
100 return 1;
101}
102
103unsigned long return_address(int depth)
104{
105 struct return_address_data rd = { .depth = depth + 2 };
106
107 dump_trace(__return_address, &rd, NULL, current_stack_pointer());
108 return rd.address;
109}
110EXPORT_SYMBOL_GPL(return_address);
111
112static int show_address(void *data, unsigned long address)
113{ 91{
114 printk("([<%016lx>] %pSR)\n", address, (void *)address); 92 if (reliable)
93 printk(" [<%016lx>] %pSR \n", address, (void *)address);
94 else
95 printk("([<%016lx>] %pSR)\n", address, (void *)address);
115 return 0; 96 return 0;
116} 97}
117 98
@@ -138,14 +119,14 @@ void show_stack(struct task_struct *task, unsigned long *sp)
138 else 119 else
139 stack = (unsigned long *)task->thread.ksp; 120 stack = (unsigned long *)task->thread.ksp;
140 } 121 }
122 printk(KERN_DEFAULT "Stack:\n");
141 for (i = 0; i < 20; i++) { 123 for (i = 0; i < 20; i++) {
142 if (((addr_t) stack & (THREAD_SIZE-1)) == 0) 124 if (((addr_t) stack & (THREAD_SIZE-1)) == 0)
143 break; 125 break;
144 if ((i * sizeof(long) % 32) == 0) 126 if (i % 4 == 0)
145 printk("%s ", i == 0 ? "" : "\n"); 127 printk(KERN_DEFAULT " ");
146 printk("%016lx ", *stack++); 128 pr_cont("%016lx%c", *stack++, i % 4 == 3 ? '\n' : ' ');
147 } 129 }
148 printk("\n");
149 show_trace(task, (unsigned long)sp); 130 show_trace(task, (unsigned long)sp);
150} 131}
151 132
@@ -163,13 +144,13 @@ void show_registers(struct pt_regs *regs)
163 mode = user_mode(regs) ? "User" : "Krnl"; 144 mode = user_mode(regs) ? "User" : "Krnl";
164 printk("%s PSW : %p %p", mode, (void *)regs->psw.mask, (void *)regs->psw.addr); 145 printk("%s PSW : %p %p", mode, (void *)regs->psw.mask, (void *)regs->psw.addr);
165 if (!user_mode(regs)) 146 if (!user_mode(regs))
166 printk(" (%pSR)", (void *)regs->psw.addr); 147 pr_cont(" (%pSR)", (void *)regs->psw.addr);
167 printk("\n"); 148 pr_cont("\n");
168 printk(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x " 149 printk(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x "
169 "P:%x AS:%x CC:%x PM:%x", psw->r, psw->t, psw->i, psw->e, 150 "P:%x AS:%x CC:%x PM:%x", psw->r, psw->t, psw->i, psw->e,
170 psw->key, psw->m, psw->w, psw->p, psw->as, psw->cc, psw->pm); 151 psw->key, psw->m, psw->w, psw->p, psw->as, psw->cc, psw->pm);
171 printk(" RI:%x EA:%x", psw->ri, psw->eaba); 152 pr_cont(" RI:%x EA:%x\n", psw->ri, psw->eaba);
172 printk("\n%s GPRS: %016lx %016lx %016lx %016lx\n", mode, 153 printk("%s GPRS: %016lx %016lx %016lx %016lx\n", mode,
173 regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]); 154 regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]);
174 printk(" %016lx %016lx %016lx %016lx\n", 155 printk(" %016lx %016lx %016lx %016lx\n",
175 regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]); 156 regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]);
@@ -205,14 +186,14 @@ void die(struct pt_regs *regs, const char *str)
205 printk("%s: %04x ilc:%d [#%d] ", str, regs->int_code & 0xffff, 186 printk("%s: %04x ilc:%d [#%d] ", str, regs->int_code & 0xffff,
206 regs->int_code >> 17, ++die_counter); 187 regs->int_code >> 17, ++die_counter);
207#ifdef CONFIG_PREEMPT 188#ifdef CONFIG_PREEMPT
208 printk("PREEMPT "); 189 pr_cont("PREEMPT ");
209#endif 190#endif
210#ifdef CONFIG_SMP 191#ifdef CONFIG_SMP
211 printk("SMP "); 192 pr_cont("SMP ");
212#endif 193#endif
213 if (debug_pagealloc_enabled()) 194 if (debug_pagealloc_enabled())
214 printk("DEBUG_PAGEALLOC"); 195 pr_cont("DEBUG_PAGEALLOC");
215 printk("\n"); 196 pr_cont("\n");
216 notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV); 197 notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV);
217 print_modules(); 198 print_modules();
218 show_regs(regs); 199 show_regs(regs);
diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
index 17431f63de00..955a7b6fa0a4 100644
--- a/arch/s390/kernel/perf_event.c
+++ b/arch/s390/kernel/perf_event.c
@@ -222,7 +222,7 @@ static int __init service_level_perf_register(void)
222} 222}
223arch_initcall(service_level_perf_register); 223arch_initcall(service_level_perf_register);
224 224
225static int __perf_callchain_kernel(void *data, unsigned long address) 225static int __perf_callchain_kernel(void *data, unsigned long address, int reliable)
226{ 226{
227 struct perf_callchain_entry_ctx *entry = data; 227 struct perf_callchain_entry_ctx *entry = data;
228 228
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index 44f84b23d4e5..355db9db8210 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -27,12 +27,12 @@ static int __save_address(void *data, unsigned long address, int nosched)
27 return 1; 27 return 1;
28} 28}
29 29
30static int save_address(void *data, unsigned long address) 30static int save_address(void *data, unsigned long address, int reliable)
31{ 31{
32 return __save_address(data, address, 0); 32 return __save_address(data, address, 0);
33} 33}
34 34
35static int save_address_nosched(void *data, unsigned long address) 35static int save_address_nosched(void *data, unsigned long address, int reliable)
36{ 36{
37 return __save_address(data, address, 1); 37 return __save_address(data, address, 1);
38} 38}
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 1cab8a177d0e..7a27eebab28a 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -119,8 +119,13 @@ static int handle_validity(struct kvm_vcpu *vcpu)
119 119
120 vcpu->stat.exit_validity++; 120 vcpu->stat.exit_validity++;
121 trace_kvm_s390_intercept_validity(vcpu, viwhy); 121 trace_kvm_s390_intercept_validity(vcpu, viwhy);
122 WARN_ONCE(true, "kvm: unhandled validity intercept 0x%x\n", viwhy); 122 KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%pK)", viwhy,
123 return -EOPNOTSUPP; 123 current->pid, vcpu->kvm);
124
125 /* do not warn on invalid runtime instrumentation mode */
126 WARN_ONCE(viwhy != 0x44, "kvm: unhandled validity intercept 0x%x\n",
127 viwhy);
128 return -EINVAL;
124} 129}
125 130
126static int handle_instruction(struct kvm_vcpu *vcpu) 131static int handle_instruction(struct kvm_vcpu *vcpu)
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index cd404aa3931c..4a0c5bce3552 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -217,6 +217,7 @@ static __init int setup_hugepagesz(char *opt)
217 } else if (MACHINE_HAS_EDAT2 && size == PUD_SIZE) { 217 } else if (MACHINE_HAS_EDAT2 && size == PUD_SIZE) {
218 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); 218 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
219 } else { 219 } else {
220 hugetlb_bad_size();
220 pr_err("hugepagesz= specifies an unsupported page size %s\n", 221 pr_err("hugepagesz= specifies an unsupported page size %s\n",
221 string); 222 string);
222 return 0; 223 return 0;
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index f56a39bd8ba6..b3e9d18f2ec6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -151,36 +151,40 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
151#ifdef CONFIG_MEMORY_HOTPLUG 151#ifdef CONFIG_MEMORY_HOTPLUG
152int arch_add_memory(int nid, u64 start, u64 size, bool for_device) 152int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
153{ 153{
154 unsigned long normal_end_pfn = PFN_DOWN(memblock_end_of_DRAM()); 154 unsigned long zone_start_pfn, zone_end_pfn, nr_pages;
155 unsigned long dma_end_pfn = PFN_DOWN(MAX_DMA_ADDRESS);
156 unsigned long start_pfn = PFN_DOWN(start); 155 unsigned long start_pfn = PFN_DOWN(start);
157 unsigned long size_pages = PFN_DOWN(size); 156 unsigned long size_pages = PFN_DOWN(size);
158 unsigned long nr_pages; 157 pg_data_t *pgdat = NODE_DATA(nid);
159 int rc, zone_enum; 158 struct zone *zone;
159 int rc, i;
160 160
161 rc = vmem_add_mapping(start, size); 161 rc = vmem_add_mapping(start, size);
162 if (rc) 162 if (rc)
163 return rc; 163 return rc;
164 164
165 while (size_pages > 0) { 165 for (i = 0; i < MAX_NR_ZONES; i++) {
166 if (start_pfn < dma_end_pfn) { 166 zone = pgdat->node_zones + i;
167 nr_pages = (start_pfn + size_pages > dma_end_pfn) ? 167 if (zone_idx(zone) != ZONE_MOVABLE) {
168 dma_end_pfn - start_pfn : size_pages; 168 /* Add range within existing zone limits, if possible */
169 zone_enum = ZONE_DMA; 169 zone_start_pfn = zone->zone_start_pfn;
170 } else if (start_pfn < normal_end_pfn) { 170 zone_end_pfn = zone->zone_start_pfn +
171 nr_pages = (start_pfn + size_pages > normal_end_pfn) ? 171 zone->spanned_pages;
172 normal_end_pfn - start_pfn : size_pages;
173 zone_enum = ZONE_NORMAL;
174 } else { 172 } else {
175 nr_pages = size_pages; 173 /* Add remaining range to ZONE_MOVABLE */
176 zone_enum = ZONE_MOVABLE; 174 zone_start_pfn = start_pfn;
175 zone_end_pfn = start_pfn + size_pages;
177 } 176 }
178 rc = __add_pages(nid, NODE_DATA(nid)->node_zones + zone_enum, 177 if (start_pfn < zone_start_pfn || start_pfn >= zone_end_pfn)
179 start_pfn, size_pages); 178 continue;
179 nr_pages = (start_pfn + size_pages > zone_end_pfn) ?
180 zone_end_pfn - start_pfn : size_pages;
181 rc = __add_pages(nid, zone, start_pfn, nr_pages);
180 if (rc) 182 if (rc)
181 break; 183 break;
182 start_pfn += nr_pages; 184 start_pfn += nr_pages;
183 size_pages -= nr_pages; 185 size_pages -= nr_pages;
186 if (!size_pages)
187 break;
184 } 188 }
185 if (rc) 189 if (rc)
186 vmem_remove_mapping(start, size); 190 vmem_remove_mapping(start, size);
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index 16f4c3960b87..9a4de4599c7b 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <asm/processor.h> 14#include <asm/processor.h>
15 15
16static int __s390_backtrace(void *data, unsigned long address) 16static int __s390_backtrace(void *data, unsigned long address, int reliable)
17{ 17{
18 unsigned int *depth = data; 18 unsigned int *depth = data;
19 19
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index a6cfdabb6054..5b0ed48e5b0c 100644
--- a/arch/sparc/include/asm/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
@@ -24,9 +24,10 @@ typedef struct {
24 unsigned int icache_line_size; 24 unsigned int icache_line_size;
25 unsigned int ecache_size; 25 unsigned int ecache_size;
26 unsigned int ecache_line_size; 26 unsigned int ecache_line_size;
27 unsigned short sock_id; 27 unsigned short sock_id; /* physical package */
28 unsigned short core_id; 28 unsigned short core_id;
29 int proc_id; 29 unsigned short max_cache_id; /* groupings of highest shared cache */
30 unsigned short proc_id; /* strand (aka HW thread) id */
30} cpuinfo_sparc; 31} cpuinfo_sparc;
31 32
32DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data); 33DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
diff --git a/arch/sparc/include/asm/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h
index d9c5876c6121..8011e79f59c9 100644
--- a/arch/sparc/include/asm/spinlock_32.h
+++ b/arch/sparc/include/asm/spinlock_32.h
@@ -134,7 +134,7 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
134 *(volatile __u32 *)&lp->lock = ~0U; 134 *(volatile __u32 *)&lp->lock = ~0U;
135} 135}
136 136
137static void inline arch_write_unlock(arch_rwlock_t *lock) 137static inline void arch_write_unlock(arch_rwlock_t *lock)
138{ 138{
139 __asm__ __volatile__( 139 __asm__ __volatile__(
140" st %%g0, [%0]" 140" st %%g0, [%0]"
diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
index 87990b7c6b0d..07c9f2e9bf57 100644
--- a/arch/sparc/include/asm/spinlock_64.h
+++ b/arch/sparc/include/asm/spinlock_64.h
@@ -96,7 +96,7 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
96 96
97/* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */ 97/* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
98 98
99static void inline arch_read_lock(arch_rwlock_t *lock) 99static inline void arch_read_lock(arch_rwlock_t *lock)
100{ 100{
101 unsigned long tmp1, tmp2; 101 unsigned long tmp1, tmp2;
102 102
@@ -119,7 +119,7 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
119 : "memory"); 119 : "memory");
120} 120}
121 121
122static int inline arch_read_trylock(arch_rwlock_t *lock) 122static inline int arch_read_trylock(arch_rwlock_t *lock)
123{ 123{
124 int tmp1, tmp2; 124 int tmp1, tmp2;
125 125
@@ -140,7 +140,7 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
140 return tmp1; 140 return tmp1;
141} 141}
142 142
143static void inline arch_read_unlock(arch_rwlock_t *lock) 143static inline void arch_read_unlock(arch_rwlock_t *lock)
144{ 144{
145 unsigned long tmp1, tmp2; 145 unsigned long tmp1, tmp2;
146 146
@@ -156,7 +156,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
156 : "memory"); 156 : "memory");
157} 157}
158 158
159static void inline arch_write_lock(arch_rwlock_t *lock) 159static inline void arch_write_lock(arch_rwlock_t *lock)
160{ 160{
161 unsigned long mask, tmp1, tmp2; 161 unsigned long mask, tmp1, tmp2;
162 162
@@ -181,7 +181,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
181 : "memory"); 181 : "memory");
182} 182}
183 183
184static void inline arch_write_unlock(arch_rwlock_t *lock) 184static inline void arch_write_unlock(arch_rwlock_t *lock)
185{ 185{
186 __asm__ __volatile__( 186 __asm__ __volatile__(
187" stw %%g0, [%0]" 187" stw %%g0, [%0]"
@@ -190,7 +190,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
190 : "memory"); 190 : "memory");
191} 191}
192 192
193static int inline arch_write_trylock(arch_rwlock_t *lock) 193static inline int arch_write_trylock(arch_rwlock_t *lock)
194{ 194{
195 unsigned long mask, tmp1, tmp2, result; 195 unsigned long mask, tmp1, tmp2, result;
196 196
diff --git a/arch/sparc/include/asm/topology_64.h b/arch/sparc/include/asm/topology_64.h
index bec481aaca16..7b4898a36eee 100644
--- a/arch/sparc/include/asm/topology_64.h
+++ b/arch/sparc/include/asm/topology_64.h
@@ -44,14 +44,20 @@ int __node_distance(int, int);
44#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) 44#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id)
45#define topology_core_id(cpu) (cpu_data(cpu).core_id) 45#define topology_core_id(cpu) (cpu_data(cpu).core_id)
46#define topology_core_cpumask(cpu) (&cpu_core_sib_map[cpu]) 46#define topology_core_cpumask(cpu) (&cpu_core_sib_map[cpu])
47#define topology_core_cache_cpumask(cpu) (&cpu_core_sib_cache_map[cpu])
47#define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu)) 48#define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
48#endif /* CONFIG_SMP */ 49#endif /* CONFIG_SMP */
49 50
50extern cpumask_t cpu_core_map[NR_CPUS]; 51extern cpumask_t cpu_core_map[NR_CPUS];
51extern cpumask_t cpu_core_sib_map[NR_CPUS]; 52extern cpumask_t cpu_core_sib_map[NR_CPUS];
53extern cpumask_t cpu_core_sib_cache_map[NR_CPUS];
54
55/**
56 * Return cores that shares the last level cache.
57 */
52static inline const struct cpumask *cpu_coregroup_mask(int cpu) 58static inline const struct cpumask *cpu_coregroup_mask(int cpu)
53{ 59{
54 return &cpu_core_map[cpu]; 60 return &cpu_core_sib_cache_map[cpu];
55} 61}
56 62
57#endif /* _ASM_SPARC64_TOPOLOGY_H */ 63#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index b68acc563235..5373136c412b 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -82,7 +82,6 @@ static inline int access_ok(int type, const void __user * addr, unsigned long si
82 return 1; 82 return 1;
83} 83}
84 84
85void __ret_efault(void);
86void __retl_efault(void); 85void __retl_efault(void);
87 86
88/* Uh, these should become the main single-value transfer routines.. 87/* Uh, these should become the main single-value transfer routines..
@@ -189,55 +188,34 @@ int __get_user_bad(void);
189unsigned long __must_check ___copy_from_user(void *to, 188unsigned long __must_check ___copy_from_user(void *to,
190 const void __user *from, 189 const void __user *from,
191 unsigned long size); 190 unsigned long size);
192unsigned long copy_from_user_fixup(void *to, const void __user *from,
193 unsigned long size);
194static inline unsigned long __must_check 191static inline unsigned long __must_check
195copy_from_user(void *to, const void __user *from, unsigned long size) 192copy_from_user(void *to, const void __user *from, unsigned long size)
196{ 193{
197 unsigned long ret;
198
199 check_object_size(to, size, false); 194 check_object_size(to, size, false);
200 195
201 ret = ___copy_from_user(to, from, size); 196 return ___copy_from_user(to, from, size);
202 if (unlikely(ret))
203 ret = copy_from_user_fixup(to, from, size);
204
205 return ret;
206} 197}
207#define __copy_from_user copy_from_user 198#define __copy_from_user copy_from_user
208 199
209unsigned long __must_check ___copy_to_user(void __user *to, 200unsigned long __must_check ___copy_to_user(void __user *to,
210 const void *from, 201 const void *from,
211 unsigned long size); 202 unsigned long size);
212unsigned long copy_to_user_fixup(void __user *to, const void *from,
213 unsigned long size);
214static inline unsigned long __must_check 203static inline unsigned long __must_check
215copy_to_user(void __user *to, const void *from, unsigned long size) 204copy_to_user(void __user *to, const void *from, unsigned long size)
216{ 205{
217 unsigned long ret;
218
219 check_object_size(from, size, true); 206 check_object_size(from, size, true);
220 207
221 ret = ___copy_to_user(to, from, size); 208 return ___copy_to_user(to, from, size);
222 if (unlikely(ret))
223 ret = copy_to_user_fixup(to, from, size);
224 return ret;
225} 209}
226#define __copy_to_user copy_to_user 210#define __copy_to_user copy_to_user
227 211
228unsigned long __must_check ___copy_in_user(void __user *to, 212unsigned long __must_check ___copy_in_user(void __user *to,
229 const void __user *from, 213 const void __user *from,
230 unsigned long size); 214 unsigned long size);
231unsigned long copy_in_user_fixup(void __user *to, void __user *from,
232 unsigned long size);
233static inline unsigned long __must_check 215static inline unsigned long __must_check
234copy_in_user(void __user *to, void __user *from, unsigned long size) 216copy_in_user(void __user *to, void __user *from, unsigned long size)
235{ 217{
236 unsigned long ret = ___copy_in_user(to, from, size); 218 return ___copy_in_user(to, from, size);
237
238 if (unlikely(ret))
239 ret = copy_in_user_fixup(to, from, size);
240 return ret;
241} 219}
242#define __copy_in_user copy_in_user 220#define __copy_in_user copy_in_user
243 221
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
index beba6c11554c..6aa3da152c20 100644
--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -926,48 +926,11 @@ tlb_type: .word 0 /* Must NOT end up in BSS */
926EXPORT_SYMBOL(tlb_type) 926EXPORT_SYMBOL(tlb_type)
927 .section ".fixup",#alloc,#execinstr 927 .section ".fixup",#alloc,#execinstr
928 928
929 .globl __ret_efault, __retl_efault, __ret_one, __retl_one
930ENTRY(__ret_efault)
931 ret
932 restore %g0, -EFAULT, %o0
933ENDPROC(__ret_efault)
934EXPORT_SYMBOL(__ret_efault)
935
936ENTRY(__retl_efault) 929ENTRY(__retl_efault)
937 retl 930 retl
938 mov -EFAULT, %o0 931 mov -EFAULT, %o0
939ENDPROC(__retl_efault) 932ENDPROC(__retl_efault)
940 933
941ENTRY(__retl_one)
942 retl
943 mov 1, %o0
944ENDPROC(__retl_one)
945
946ENTRY(__retl_one_fp)
947 VISExitHalf
948 retl
949 mov 1, %o0
950ENDPROC(__retl_one_fp)
951
952ENTRY(__ret_one_asi)
953 wr %g0, ASI_AIUS, %asi
954 ret
955 restore %g0, 1, %o0
956ENDPROC(__ret_one_asi)
957
958ENTRY(__retl_one_asi)
959 wr %g0, ASI_AIUS, %asi
960 retl
961 mov 1, %o0
962ENDPROC(__retl_one_asi)
963
964ENTRY(__retl_one_asi_fp)
965 wr %g0, ASI_AIUS, %asi
966 VISExitHalf
967 retl
968 mov 1, %o0
969ENDPROC(__retl_one_asi_fp)
970
971ENTRY(__retl_o1) 934ENTRY(__retl_o1)
972 retl 935 retl
973 mov %o1, %o0 936 mov %o1, %o0
diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
index 59bbeff55024..07933b9e9ce0 100644
--- a/arch/sparc/kernel/jump_label.c
+++ b/arch/sparc/kernel/jump_label.c
@@ -13,19 +13,30 @@
13void arch_jump_label_transform(struct jump_entry *entry, 13void arch_jump_label_transform(struct jump_entry *entry,
14 enum jump_label_type type) 14 enum jump_label_type type)
15{ 15{
16 u32 val;
17 u32 *insn = (u32 *) (unsigned long) entry->code; 16 u32 *insn = (u32 *) (unsigned long) entry->code;
17 u32 val;
18 18
19 if (type == JUMP_LABEL_JMP) { 19 if (type == JUMP_LABEL_JMP) {
20 s32 off = (s32)entry->target - (s32)entry->code; 20 s32 off = (s32)entry->target - (s32)entry->code;
21 bool use_v9_branch = false;
22
23 BUG_ON(off & 3);
21 24
22#ifdef CONFIG_SPARC64 25#ifdef CONFIG_SPARC64
23 /* ba,pt %xcc, . + (off << 2) */ 26 if (off <= 0xfffff && off >= -0x100000)
24 val = 0x10680000 | ((u32) off >> 2); 27 use_v9_branch = true;
25#else
26 /* ba . + (off << 2) */
27 val = 0x10800000 | ((u32) off >> 2);
28#endif 28#endif
29 if (use_v9_branch) {
30 /* WDISP19 - target is . + immed << 2 */
31 /* ba,pt %xcc, . + off */
32 val = 0x10680000 | (((u32) off >> 2) & 0x7ffff);
33 } else {
34 /* WDISP22 - target is . + immed << 2 */
35 BUG_ON(off > 0x7fffff);
36 BUG_ON(off < -0x800000);
37 /* ba . + off */
38 val = 0x10800000 | (((u32) off >> 2) & 0x3fffff);
39 }
29 } else { 40 } else {
30 val = 0x01000000; 41 val = 0x01000000;
31 } 42 }
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 11228861d9b4..8a6982dfd733 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -645,13 +645,20 @@ static void __mark_core_id(struct mdesc_handle *hp, u64 node,
645 cpu_data(*id).core_id = core_id; 645 cpu_data(*id).core_id = core_id;
646} 646}
647 647
648static void __mark_sock_id(struct mdesc_handle *hp, u64 node, 648static void __mark_max_cache_id(struct mdesc_handle *hp, u64 node,
649 int sock_id) 649 int max_cache_id)
650{ 650{
651 const u64 *id = mdesc_get_property(hp, node, "id", NULL); 651 const u64 *id = mdesc_get_property(hp, node, "id", NULL);
652 652
653 if (*id < num_possible_cpus()) 653 if (*id < num_possible_cpus()) {
654 cpu_data(*id).sock_id = sock_id; 654 cpu_data(*id).max_cache_id = max_cache_id;
655
656 /**
657 * On systems without explicit socket descriptions socket
658 * is max_cache_id
659 */
660 cpu_data(*id).sock_id = max_cache_id;
661 }
655} 662}
656 663
657static void mark_core_ids(struct mdesc_handle *hp, u64 mp, 664static void mark_core_ids(struct mdesc_handle *hp, u64 mp,
@@ -660,10 +667,11 @@ static void mark_core_ids(struct mdesc_handle *hp, u64 mp,
660 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10); 667 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10);
661} 668}
662 669
663static void mark_sock_ids(struct mdesc_handle *hp, u64 mp, 670static void mark_max_cache_ids(struct mdesc_handle *hp, u64 mp,
664 int sock_id) 671 int max_cache_id)
665{ 672{
666 find_back_node_value(hp, mp, "cpu", __mark_sock_id, sock_id, 10); 673 find_back_node_value(hp, mp, "cpu", __mark_max_cache_id,
674 max_cache_id, 10);
667} 675}
668 676
669static void set_core_ids(struct mdesc_handle *hp) 677static void set_core_ids(struct mdesc_handle *hp)
@@ -694,14 +702,15 @@ static void set_core_ids(struct mdesc_handle *hp)
694 } 702 }
695} 703}
696 704
697static int set_sock_ids_by_cache(struct mdesc_handle *hp, int level) 705static int set_max_cache_ids_by_cache(struct mdesc_handle *hp, int level)
698{ 706{
699 u64 mp; 707 u64 mp;
700 int idx = 1; 708 int idx = 1;
701 int fnd = 0; 709 int fnd = 0;
702 710
703 /* Identify unique sockets by looking for cpus backpointed to by 711 /**
704 * shared level n caches. 712 * Identify unique highest level of shared cache by looking for cpus
713 * backpointed to by shared level N caches.
705 */ 714 */
706 mdesc_for_each_node_by_name(hp, mp, "cache") { 715 mdesc_for_each_node_by_name(hp, mp, "cache") {
707 const u64 *cur_lvl; 716 const u64 *cur_lvl;
@@ -709,8 +718,7 @@ static int set_sock_ids_by_cache(struct mdesc_handle *hp, int level)
709 cur_lvl = mdesc_get_property(hp, mp, "level", NULL); 718 cur_lvl = mdesc_get_property(hp, mp, "level", NULL);
710 if (*cur_lvl != level) 719 if (*cur_lvl != level)
711 continue; 720 continue;
712 721 mark_max_cache_ids(hp, mp, idx);
713 mark_sock_ids(hp, mp, idx);
714 idx++; 722 idx++;
715 fnd = 1; 723 fnd = 1;
716 } 724 }
@@ -745,15 +753,17 @@ static void set_sock_ids(struct mdesc_handle *hp)
745{ 753{
746 u64 mp; 754 u64 mp;
747 755
748 /* If machine description exposes sockets data use it. 756 /**
749 * Otherwise fallback to use shared L3 or L2 caches. 757 * Find the highest level of shared cache which pre-T7 is also
758 * the socket.
750 */ 759 */
760 if (!set_max_cache_ids_by_cache(hp, 3))
761 set_max_cache_ids_by_cache(hp, 2);
762
763 /* If machine description exposes sockets data use it.*/
751 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets"); 764 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets");
752 if (mp != MDESC_NODE_NULL) 765 if (mp != MDESC_NODE_NULL)
753 return set_sock_ids_by_socket(hp, mp); 766 set_sock_ids_by_socket(hp, mp);
754
755 if (!set_sock_ids_by_cache(hp, 3))
756 set_sock_ids_by_cache(hp, 2);
757} 767}
758 768
759static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) 769static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index d3035ba6cd31..8182f7caf5b1 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -63,9 +63,13 @@ cpumask_t cpu_core_map[NR_CPUS] __read_mostly =
63cpumask_t cpu_core_sib_map[NR_CPUS] __read_mostly = { 63cpumask_t cpu_core_sib_map[NR_CPUS] __read_mostly = {
64 [0 ... NR_CPUS-1] = CPU_MASK_NONE }; 64 [0 ... NR_CPUS-1] = CPU_MASK_NONE };
65 65
66cpumask_t cpu_core_sib_cache_map[NR_CPUS] __read_mostly = {
67 [0 ... NR_CPUS - 1] = CPU_MASK_NONE };
68
66EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); 69EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
67EXPORT_SYMBOL(cpu_core_map); 70EXPORT_SYMBOL(cpu_core_map);
68EXPORT_SYMBOL(cpu_core_sib_map); 71EXPORT_SYMBOL(cpu_core_sib_map);
72EXPORT_SYMBOL(cpu_core_sib_cache_map);
69 73
70static cpumask_t smp_commenced_mask; 74static cpumask_t smp_commenced_mask;
71 75
@@ -1265,6 +1269,10 @@ void smp_fill_in_sib_core_maps(void)
1265 unsigned int j; 1269 unsigned int j;
1266 1270
1267 for_each_present_cpu(j) { 1271 for_each_present_cpu(j) {
1272 if (cpu_data(i).max_cache_id ==
1273 cpu_data(j).max_cache_id)
1274 cpumask_set_cpu(j, &cpu_core_sib_cache_map[i]);
1275
1268 if (cpu_data(i).sock_id == cpu_data(j).sock_id) 1276 if (cpu_data(i).sock_id == cpu_data(j).sock_id)
1269 cpumask_set_cpu(j, &cpu_core_sib_map[i]); 1277 cpumask_set_cpu(j, &cpu_core_sib_map[i]);
1270 } 1278 }
diff --git a/arch/sparc/lib/GENcopy_from_user.S b/arch/sparc/lib/GENcopy_from_user.S
index b7d0bd6b1406..69a439fa2fc1 100644
--- a/arch/sparc/lib/GENcopy_from_user.S
+++ b/arch/sparc/lib/GENcopy_from_user.S
@@ -3,11 +3,11 @@
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
diff --git a/arch/sparc/lib/GENcopy_to_user.S b/arch/sparc/lib/GENcopy_to_user.S
index 780550e1afc7..9947427ce354 100644
--- a/arch/sparc/lib/GENcopy_to_user.S
+++ b/arch/sparc/lib/GENcopy_to_user.S
@@ -3,11 +3,11 @@
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
diff --git a/arch/sparc/lib/GENmemcpy.S b/arch/sparc/lib/GENmemcpy.S
index 89358ee94851..059ea24ad73d 100644
--- a/arch/sparc/lib/GENmemcpy.S
+++ b/arch/sparc/lib/GENmemcpy.S
@@ -4,21 +4,18 @@
4 */ 4 */
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/linkage.h>
7#define GLOBAL_SPARE %g7 8#define GLOBAL_SPARE %g7
8#else 9#else
9#define GLOBAL_SPARE %g5 10#define GLOBAL_SPARE %g5
10#endif 11#endif
11 12
12#ifndef EX_LD 13#ifndef EX_LD
13#define EX_LD(x) x 14#define EX_LD(x,y) x
14#endif 15#endif
15 16
16#ifndef EX_ST 17#ifndef EX_ST
17#define EX_ST(x) x 18#define EX_ST(x,y) x
18#endif
19
20#ifndef EX_RETVAL
21#define EX_RETVAL(x) x
22#endif 19#endif
23 20
24#ifndef LOAD 21#ifndef LOAD
@@ -45,6 +42,29 @@
45 .register %g3,#scratch 42 .register %g3,#scratch
46 43
47 .text 44 .text
45
46#ifndef EX_RETVAL
47#define EX_RETVAL(x) x
48ENTRY(GEN_retl_o4_1)
49 add %o4, %o2, %o4
50 retl
51 add %o4, 1, %o0
52ENDPROC(GEN_retl_o4_1)
53ENTRY(GEN_retl_g1_8)
54 add %g1, %o2, %g1
55 retl
56 add %g1, 8, %o0
57ENDPROC(GEN_retl_g1_8)
58ENTRY(GEN_retl_o2_4)
59 retl
60 add %o2, 4, %o0
61ENDPROC(GEN_retl_o2_4)
62ENTRY(GEN_retl_o2_1)
63 retl
64 add %o2, 1, %o0
65ENDPROC(GEN_retl_o2_1)
66#endif
67
48 .align 64 68 .align 64
49 69
50 .globl FUNC_NAME 70 .globl FUNC_NAME
@@ -73,8 +93,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
73 sub %g0, %o4, %o4 93 sub %g0, %o4, %o4
74 sub %o2, %o4, %o2 94 sub %o2, %o4, %o2
751: subcc %o4, 1, %o4 951: subcc %o4, 1, %o4
76 EX_LD(LOAD(ldub, %o1, %g1)) 96 EX_LD(LOAD(ldub, %o1, %g1),GEN_retl_o4_1)
77 EX_ST(STORE(stb, %g1, %o0)) 97 EX_ST(STORE(stb, %g1, %o0),GEN_retl_o4_1)
78 add %o1, 1, %o1 98 add %o1, 1, %o1
79 bne,pt %XCC, 1b 99 bne,pt %XCC, 1b
80 add %o0, 1, %o0 100 add %o0, 1, %o0
@@ -82,8 +102,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
82 andn %o2, 0x7, %g1 102 andn %o2, 0x7, %g1
83 sub %o2, %g1, %o2 103 sub %o2, %g1, %o2
841: subcc %g1, 0x8, %g1 1041: subcc %g1, 0x8, %g1
85 EX_LD(LOAD(ldx, %o1, %g2)) 105 EX_LD(LOAD(ldx, %o1, %g2),GEN_retl_g1_8)
86 EX_ST(STORE(stx, %g2, %o0)) 106 EX_ST(STORE(stx, %g2, %o0),GEN_retl_g1_8)
87 add %o1, 0x8, %o1 107 add %o1, 0x8, %o1
88 bne,pt %XCC, 1b 108 bne,pt %XCC, 1b
89 add %o0, 0x8, %o0 109 add %o0, 0x8, %o0
@@ -100,8 +120,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
100 120
1011: 1211:
102 subcc %o2, 4, %o2 122 subcc %o2, 4, %o2
103 EX_LD(LOAD(lduw, %o1, %g1)) 123 EX_LD(LOAD(lduw, %o1, %g1),GEN_retl_o2_4)
104 EX_ST(STORE(stw, %g1, %o1 + %o3)) 124 EX_ST(STORE(stw, %g1, %o1 + %o3),GEN_retl_o2_4)
105 bgu,pt %XCC, 1b 125 bgu,pt %XCC, 1b
106 add %o1, 4, %o1 126 add %o1, 4, %o1
107 127
@@ -111,8 +131,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
111 .align 32 131 .align 32
11290: 13290:
113 subcc %o2, 1, %o2 133 subcc %o2, 1, %o2
114 EX_LD(LOAD(ldub, %o1, %g1)) 134 EX_LD(LOAD(ldub, %o1, %g1),GEN_retl_o2_1)
115 EX_ST(STORE(stb, %g1, %o1 + %o3)) 135 EX_ST(STORE(stb, %g1, %o1 + %o3),GEN_retl_o2_1)
116 bgu,pt %XCC, 90b 136 bgu,pt %XCC, 90b
117 add %o1, 1, %o1 137 add %o1, 1, %o1
118 retl 138 retl
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index 885f00e81d1a..69912d2f8b54 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -38,7 +38,7 @@ lib-$(CONFIG_SPARC64) += NG4patch.o NG4copy_page.o NG4clear_page.o NG4memset.o
38lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o 38lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o
39lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o 39lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
40 40
41lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o 41lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o
42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o 42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
43 43
44obj-$(CONFIG_SPARC64) += iomap.o 44obj-$(CONFIG_SPARC64) += iomap.o
diff --git a/arch/sparc/lib/NG2copy_from_user.S b/arch/sparc/lib/NG2copy_from_user.S
index d5242b8c4f94..b79a6998d87c 100644
--- a/arch/sparc/lib/NG2copy_from_user.S
+++ b/arch/sparc/lib/NG2copy_from_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_LD_FP(x) \ 14#define EX_LD_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_asi_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/NG2copy_to_user.S b/arch/sparc/lib/NG2copy_to_user.S
index 4e962d993b10..dcec55f254ab 100644
--- a/arch/sparc/lib/NG2copy_to_user.S
+++ b/arch/sparc/lib/NG2copy_to_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_ST_FP(x) \ 14#define EX_ST_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_asi_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/NG2memcpy.S b/arch/sparc/lib/NG2memcpy.S
index d5f585df2f3f..c629dbd121b6 100644
--- a/arch/sparc/lib/NG2memcpy.S
+++ b/arch/sparc/lib/NG2memcpy.S
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/linkage.h>
7#include <asm/visasm.h> 8#include <asm/visasm.h>
8#include <asm/asi.h> 9#include <asm/asi.h>
9#define GLOBAL_SPARE %g7 10#define GLOBAL_SPARE %g7
@@ -32,21 +33,17 @@
32#endif 33#endif
33 34
34#ifndef EX_LD 35#ifndef EX_LD
35#define EX_LD(x) x 36#define EX_LD(x,y) x
36#endif 37#endif
37#ifndef EX_LD_FP 38#ifndef EX_LD_FP
38#define EX_LD_FP(x) x 39#define EX_LD_FP(x,y) x
39#endif 40#endif
40 41
41#ifndef EX_ST 42#ifndef EX_ST
42#define EX_ST(x) x 43#define EX_ST(x,y) x
43#endif 44#endif
44#ifndef EX_ST_FP 45#ifndef EX_ST_FP
45#define EX_ST_FP(x) x 46#define EX_ST_FP(x,y) x
46#endif
47
48#ifndef EX_RETVAL
49#define EX_RETVAL(x) x
50#endif 47#endif
51 48
52#ifndef LOAD 49#ifndef LOAD
@@ -140,45 +137,110 @@
140 fsrc2 %x6, %f12; \ 137 fsrc2 %x6, %f12; \
141 fsrc2 %x7, %f14; 138 fsrc2 %x7, %f14;
142#define FREG_LOAD_1(base, x0) \ 139#define FREG_LOAD_1(base, x0) \
143 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)) 140 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1)
144#define FREG_LOAD_2(base, x0, x1) \ 141#define FREG_LOAD_2(base, x0, x1) \
145 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 142 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
146 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); 143 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1);
147#define FREG_LOAD_3(base, x0, x1, x2) \ 144#define FREG_LOAD_3(base, x0, x1, x2) \
148 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 145 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
149 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ 146 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
150 EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); 147 EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1);
151#define FREG_LOAD_4(base, x0, x1, x2, x3) \ 148#define FREG_LOAD_4(base, x0, x1, x2, x3) \
152 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 149 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
153 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ 150 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
154 EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ 151 EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
155 EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); 152 EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1);
156#define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \ 153#define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \
157 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 154 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
158 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ 155 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
159 EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ 156 EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
160 EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ 157 EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
161 EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); 158 EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1);
162#define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \ 159#define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \
163 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 160 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
164 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ 161 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
165 EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ 162 EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
166 EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ 163 EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
167 EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \ 164 EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
168 EX_LD_FP(LOAD(ldd, base + 0x28, %x5)); 165 EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1);
169#define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \ 166#define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \
170 EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ 167 EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
171 EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ 168 EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
172 EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ 169 EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
173 EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ 170 EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
174 EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \ 171 EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
175 EX_LD_FP(LOAD(ldd, base + 0x28, %x5)); \ 172 EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1); \
176 EX_LD_FP(LOAD(ldd, base + 0x30, %x6)); 173 EX_LD_FP(LOAD(ldd, base + 0x30, %x6), NG2_retl_o2_plus_g1);
177 174
178 .register %g2,#scratch 175 .register %g2,#scratch
179 .register %g3,#scratch 176 .register %g3,#scratch
180 177
181 .text 178 .text
179#ifndef EX_RETVAL
180#define EX_RETVAL(x) x
181__restore_fp:
182 VISExitHalf
183__restore_asi:
184 retl
185 wr %g0, ASI_AIUS, %asi
186ENTRY(NG2_retl_o2)
187 ba,pt %xcc, __restore_asi
188 mov %o2, %o0
189ENDPROC(NG2_retl_o2)
190ENTRY(NG2_retl_o2_plus_1)
191 ba,pt %xcc, __restore_asi
192 add %o2, 1, %o0
193ENDPROC(NG2_retl_o2_plus_1)
194ENTRY(NG2_retl_o2_plus_4)
195 ba,pt %xcc, __restore_asi
196 add %o2, 4, %o0
197ENDPROC(NG2_retl_o2_plus_4)
198ENTRY(NG2_retl_o2_plus_8)
199 ba,pt %xcc, __restore_asi
200 add %o2, 8, %o0
201ENDPROC(NG2_retl_o2_plus_8)
202ENTRY(NG2_retl_o2_plus_o4_plus_1)
203 add %o4, 1, %o4
204 ba,pt %xcc, __restore_asi
205 add %o2, %o4, %o0
206ENDPROC(NG2_retl_o2_plus_o4_plus_1)
207ENTRY(NG2_retl_o2_plus_o4_plus_8)
208 add %o4, 8, %o4
209 ba,pt %xcc, __restore_asi
210 add %o2, %o4, %o0
211ENDPROC(NG2_retl_o2_plus_o4_plus_8)
212ENTRY(NG2_retl_o2_plus_o4_plus_16)
213 add %o4, 16, %o4
214 ba,pt %xcc, __restore_asi
215 add %o2, %o4, %o0
216ENDPROC(NG2_retl_o2_plus_o4_plus_16)
217ENTRY(NG2_retl_o2_plus_g1_fp)
218 ba,pt %xcc, __restore_fp
219 add %o2, %g1, %o0
220ENDPROC(NG2_retl_o2_plus_g1_fp)
221ENTRY(NG2_retl_o2_plus_g1_plus_64_fp)
222 add %g1, 64, %g1
223 ba,pt %xcc, __restore_fp
224 add %o2, %g1, %o0
225ENDPROC(NG2_retl_o2_plus_g1_plus_64_fp)
226ENTRY(NG2_retl_o2_plus_g1_plus_1)
227 add %g1, 1, %g1
228 ba,pt %xcc, __restore_asi
229 add %o2, %g1, %o0
230ENDPROC(NG2_retl_o2_plus_g1_plus_1)
231ENTRY(NG2_retl_o2_and_7_plus_o4)
232 and %o2, 7, %o2
233 ba,pt %xcc, __restore_asi
234 add %o2, %o4, %o0
235ENDPROC(NG2_retl_o2_and_7_plus_o4)
236ENTRY(NG2_retl_o2_and_7_plus_o4_plus_8)
237 and %o2, 7, %o2
238 add %o4, 8, %o4
239 ba,pt %xcc, __restore_asi
240 add %o2, %o4, %o0
241ENDPROC(NG2_retl_o2_and_7_plus_o4_plus_8)
242#endif
243
182 .align 64 244 .align 64
183 245
184 .globl FUNC_NAME 246 .globl FUNC_NAME
@@ -230,8 +292,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
230 sub %g0, %o4, %o4 ! bytes to align dst 292 sub %g0, %o4, %o4 ! bytes to align dst
231 sub %o2, %o4, %o2 293 sub %o2, %o4, %o2
2321: subcc %o4, 1, %o4 2941: subcc %o4, 1, %o4
233 EX_LD(LOAD(ldub, %o1, %g1)) 295 EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_o4_plus_1)
234 EX_ST(STORE(stb, %g1, %o0)) 296 EX_ST(STORE(stb, %g1, %o0), NG2_retl_o2_plus_o4_plus_1)
235 add %o1, 1, %o1 297 add %o1, 1, %o1
236 bne,pt %XCC, 1b 298 bne,pt %XCC, 1b
237 add %o0, 1, %o0 299 add %o0, 1, %o0
@@ -281,11 +343,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
281 nop 343 nop
282 /* fall through for 0 < low bits < 8 */ 344 /* fall through for 0 < low bits < 8 */
283110: sub %o4, 64, %g2 345110: sub %o4, 64, %g2
284 EX_LD_FP(LOAD_BLK(%g2, %f0)) 346 EX_LD_FP(LOAD_BLK(%g2, %f0), NG2_retl_o2_plus_g1)
2851: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 3471: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
286 EX_LD_FP(LOAD_BLK(%o4, %f16)) 348 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
287 FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16) 349 FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16)
288 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 350 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
289 FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30) 351 FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30)
290 subcc %g1, 64, %g1 352 subcc %g1, 64, %g1
291 add %o4, 64, %o4 353 add %o4, 64, %o4
@@ -296,10 +358,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
296 358
297120: sub %o4, 56, %g2 359120: sub %o4, 56, %g2
298 FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12) 360 FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12)
2991: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 3611: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
300 EX_LD_FP(LOAD_BLK(%o4, %f16)) 362 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
301 FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18) 363 FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18)
302 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 364 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
303 FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30) 365 FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30)
304 subcc %g1, 64, %g1 366 subcc %g1, 64, %g1
305 add %o4, 64, %o4 367 add %o4, 64, %o4
@@ -310,10 +372,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
310 372
311130: sub %o4, 48, %g2 373130: sub %o4, 48, %g2
312 FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10) 374 FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10)
3131: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 3751: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
314 EX_LD_FP(LOAD_BLK(%o4, %f16)) 376 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
315 FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20) 377 FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20)
316 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 378 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
317 FREG_MOVE_6(f20, f22, f24, f26, f28, f30) 379 FREG_MOVE_6(f20, f22, f24, f26, f28, f30)
318 subcc %g1, 64, %g1 380 subcc %g1, 64, %g1
319 add %o4, 64, %o4 381 add %o4, 64, %o4
@@ -324,10 +386,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
324 386
325140: sub %o4, 40, %g2 387140: sub %o4, 40, %g2
326 FREG_LOAD_5(%g2, f0, f2, f4, f6, f8) 388 FREG_LOAD_5(%g2, f0, f2, f4, f6, f8)
3271: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 3891: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
328 EX_LD_FP(LOAD_BLK(%o4, %f16)) 390 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
329 FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22) 391 FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22)
330 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 392 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
331 FREG_MOVE_5(f22, f24, f26, f28, f30) 393 FREG_MOVE_5(f22, f24, f26, f28, f30)
332 subcc %g1, 64, %g1 394 subcc %g1, 64, %g1
333 add %o4, 64, %o4 395 add %o4, 64, %o4
@@ -338,10 +400,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
338 400
339150: sub %o4, 32, %g2 401150: sub %o4, 32, %g2
340 FREG_LOAD_4(%g2, f0, f2, f4, f6) 402 FREG_LOAD_4(%g2, f0, f2, f4, f6)
3411: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 4031: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
342 EX_LD_FP(LOAD_BLK(%o4, %f16)) 404 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
343 FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24) 405 FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24)
344 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 406 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
345 FREG_MOVE_4(f24, f26, f28, f30) 407 FREG_MOVE_4(f24, f26, f28, f30)
346 subcc %g1, 64, %g1 408 subcc %g1, 64, %g1
347 add %o4, 64, %o4 409 add %o4, 64, %o4
@@ -352,10 +414,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
352 414
353160: sub %o4, 24, %g2 415160: sub %o4, 24, %g2
354 FREG_LOAD_3(%g2, f0, f2, f4) 416 FREG_LOAD_3(%g2, f0, f2, f4)
3551: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 4171: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
356 EX_LD_FP(LOAD_BLK(%o4, %f16)) 418 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
357 FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26) 419 FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26)
358 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 420 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
359 FREG_MOVE_3(f26, f28, f30) 421 FREG_MOVE_3(f26, f28, f30)
360 subcc %g1, 64, %g1 422 subcc %g1, 64, %g1
361 add %o4, 64, %o4 423 add %o4, 64, %o4
@@ -366,10 +428,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
366 428
367170: sub %o4, 16, %g2 429170: sub %o4, 16, %g2
368 FREG_LOAD_2(%g2, f0, f2) 430 FREG_LOAD_2(%g2, f0, f2)
3691: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 4311: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
370 EX_LD_FP(LOAD_BLK(%o4, %f16)) 432 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
371 FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28) 433 FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28)
372 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 434 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
373 FREG_MOVE_2(f28, f30) 435 FREG_MOVE_2(f28, f30)
374 subcc %g1, 64, %g1 436 subcc %g1, 64, %g1
375 add %o4, 64, %o4 437 add %o4, 64, %o4
@@ -380,10 +442,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
380 442
381180: sub %o4, 8, %g2 443180: sub %o4, 8, %g2
382 FREG_LOAD_1(%g2, f0) 444 FREG_LOAD_1(%g2, f0)
3831: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 4451: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
384 EX_LD_FP(LOAD_BLK(%o4, %f16)) 446 EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
385 FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30) 447 FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30)
386 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 448 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
387 FREG_MOVE_1(f30) 449 FREG_MOVE_1(f30)
388 subcc %g1, 64, %g1 450 subcc %g1, 64, %g1
389 add %o4, 64, %o4 451 add %o4, 64, %o4
@@ -393,10 +455,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
393 nop 455 nop
394 456
395190: 457190:
3961: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) 4581: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
397 subcc %g1, 64, %g1 459 subcc %g1, 64, %g1
398 EX_LD_FP(LOAD_BLK(%o4, %f0)) 460 EX_LD_FP(LOAD_BLK(%o4, %f0), NG2_retl_o2_plus_g1_plus_64)
399 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) 461 EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1_plus_64)
400 add %o4, 64, %o4 462 add %o4, 64, %o4
401 bne,pt %xcc, 1b 463 bne,pt %xcc, 1b
402 LOAD(prefetch, %o4 + 64, #one_read) 464 LOAD(prefetch, %o4 + 64, #one_read)
@@ -423,28 +485,28 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
423 andn %o2, 0xf, %o4 485 andn %o2, 0xf, %o4
424 and %o2, 0xf, %o2 486 and %o2, 0xf, %o2
4251: subcc %o4, 0x10, %o4 4871: subcc %o4, 0x10, %o4
426 EX_LD(LOAD(ldx, %o1, %o5)) 488 EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_o4_plus_16)
427 add %o1, 0x08, %o1 489 add %o1, 0x08, %o1
428 EX_LD(LOAD(ldx, %o1, %g1)) 490 EX_LD(LOAD(ldx, %o1, %g1), NG2_retl_o2_plus_o4_plus_16)
429 sub %o1, 0x08, %o1 491 sub %o1, 0x08, %o1
430 EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE)) 492 EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_16)
431 add %o1, 0x8, %o1 493 add %o1, 0x8, %o1
432 EX_ST(STORE(stx, %g1, %o1 + GLOBAL_SPARE)) 494 EX_ST(STORE(stx, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_8)
433 bgu,pt %XCC, 1b 495 bgu,pt %XCC, 1b
434 add %o1, 0x8, %o1 496 add %o1, 0x8, %o1
43573: andcc %o2, 0x8, %g0 49773: andcc %o2, 0x8, %g0
436 be,pt %XCC, 1f 498 be,pt %XCC, 1f
437 nop 499 nop
438 sub %o2, 0x8, %o2 500 sub %o2, 0x8, %o2
439 EX_LD(LOAD(ldx, %o1, %o5)) 501 EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_8)
440 EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE)) 502 EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_8)
441 add %o1, 0x8, %o1 503 add %o1, 0x8, %o1
4421: andcc %o2, 0x4, %g0 5041: andcc %o2, 0x4, %g0
443 be,pt %XCC, 1f 505 be,pt %XCC, 1f
444 nop 506 nop
445 sub %o2, 0x4, %o2 507 sub %o2, 0x4, %o2
446 EX_LD(LOAD(lduw, %o1, %o5)) 508 EX_LD(LOAD(lduw, %o1, %o5), NG2_retl_o2_plus_4)
447 EX_ST(STORE(stw, %o5, %o1 + GLOBAL_SPARE)) 509 EX_ST(STORE(stw, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
448 add %o1, 0x4, %o1 510 add %o1, 0x4, %o1
4491: cmp %o2, 0 5111: cmp %o2, 0
450 be,pt %XCC, 85f 512 be,pt %XCC, 85f
@@ -460,8 +522,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
460 sub %o2, %g1, %o2 522 sub %o2, %g1, %o2
461 523
4621: subcc %g1, 1, %g1 5241: subcc %g1, 1, %g1
463 EX_LD(LOAD(ldub, %o1, %o5)) 525 EX_LD(LOAD(ldub, %o1, %o5), NG2_retl_o2_plus_g1_plus_1)
464 EX_ST(STORE(stb, %o5, %o1 + GLOBAL_SPARE)) 526 EX_ST(STORE(stb, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_g1_plus_1)
465 bgu,pt %icc, 1b 527 bgu,pt %icc, 1b
466 add %o1, 1, %o1 528 add %o1, 1, %o1
467 529
@@ -477,16 +539,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
477 539
4788: mov 64, GLOBAL_SPARE 5408: mov 64, GLOBAL_SPARE
479 andn %o1, 0x7, %o1 541 andn %o1, 0x7, %o1
480 EX_LD(LOAD(ldx, %o1, %g2)) 542 EX_LD(LOAD(ldx, %o1, %g2), NG2_retl_o2)
481 sub GLOBAL_SPARE, %g1, GLOBAL_SPARE 543 sub GLOBAL_SPARE, %g1, GLOBAL_SPARE
482 andn %o2, 0x7, %o4 544 andn %o2, 0x7, %o4
483 sllx %g2, %g1, %g2 545 sllx %g2, %g1, %g2
4841: add %o1, 0x8, %o1 5461: add %o1, 0x8, %o1
485 EX_LD(LOAD(ldx, %o1, %g3)) 547 EX_LD(LOAD(ldx, %o1, %g3), NG2_retl_o2_and_7_plus_o4)
486 subcc %o4, 0x8, %o4 548 subcc %o4, 0x8, %o4
487 srlx %g3, GLOBAL_SPARE, %o5 549 srlx %g3, GLOBAL_SPARE, %o5
488 or %o5, %g2, %o5 550 or %o5, %g2, %o5
489 EX_ST(STORE(stx, %o5, %o0)) 551 EX_ST(STORE(stx, %o5, %o0), NG2_retl_o2_and_7_plus_o4_plus_8)
490 add %o0, 0x8, %o0 552 add %o0, 0x8, %o0
491 bgu,pt %icc, 1b 553 bgu,pt %icc, 1b
492 sllx %g3, %g1, %g2 554 sllx %g3, %g1, %g2
@@ -506,8 +568,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
506 568
5071: 5691:
508 subcc %o2, 4, %o2 570 subcc %o2, 4, %o2
509 EX_LD(LOAD(lduw, %o1, %g1)) 571 EX_LD(LOAD(lduw, %o1, %g1), NG2_retl_o2_plus_4)
510 EX_ST(STORE(stw, %g1, %o1 + GLOBAL_SPARE)) 572 EX_ST(STORE(stw, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
511 bgu,pt %XCC, 1b 573 bgu,pt %XCC, 1b
512 add %o1, 4, %o1 574 add %o1, 4, %o1
513 575
@@ -517,8 +579,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
517 .align 32 579 .align 32
51890: 58090:
519 subcc %o2, 1, %o2 581 subcc %o2, 1, %o2
520 EX_LD(LOAD(ldub, %o1, %g1)) 582 EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_1)
521 EX_ST(STORE(stb, %g1, %o1 + GLOBAL_SPARE)) 583 EX_ST(STORE(stb, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_1)
522 bgu,pt %XCC, 90b 584 bgu,pt %XCC, 90b
523 add %o1, 1, %o1 585 add %o1, 1, %o1
524 retl 586 retl
diff --git a/arch/sparc/lib/NG4copy_from_user.S b/arch/sparc/lib/NG4copy_from_user.S
index 2e8ee7ad07a9..16a286c1a528 100644
--- a/arch/sparc/lib/NG4copy_from_user.S
+++ b/arch/sparc/lib/NG4copy_from_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 2012 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2012 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x, y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_LD_FP(x) \ 14#define EX_LD_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_asi_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/NG4copy_to_user.S b/arch/sparc/lib/NG4copy_to_user.S
index be0bf4590df8..6b0276ffc858 100644
--- a/arch/sparc/lib/NG4copy_to_user.S
+++ b/arch/sparc/lib/NG4copy_to_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 2012 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2012 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_ST_FP(x) \ 14#define EX_ST_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_asi_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/NG4memcpy.S b/arch/sparc/lib/NG4memcpy.S
index 8e13ee1f4454..75bb93b1437f 100644
--- a/arch/sparc/lib/NG4memcpy.S
+++ b/arch/sparc/lib/NG4memcpy.S
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/linkage.h>
7#include <asm/visasm.h> 8#include <asm/visasm.h>
8#include <asm/asi.h> 9#include <asm/asi.h>
9#define GLOBAL_SPARE %g7 10#define GLOBAL_SPARE %g7
@@ -46,22 +47,19 @@
46#endif 47#endif
47 48
48#ifndef EX_LD 49#ifndef EX_LD
49#define EX_LD(x) x 50#define EX_LD(x,y) x
50#endif 51#endif
51#ifndef EX_LD_FP 52#ifndef EX_LD_FP
52#define EX_LD_FP(x) x 53#define EX_LD_FP(x,y) x
53#endif 54#endif
54 55
55#ifndef EX_ST 56#ifndef EX_ST
56#define EX_ST(x) x 57#define EX_ST(x,y) x
57#endif 58#endif
58#ifndef EX_ST_FP 59#ifndef EX_ST_FP
59#define EX_ST_FP(x) x 60#define EX_ST_FP(x,y) x
60#endif 61#endif
61 62
62#ifndef EX_RETVAL
63#define EX_RETVAL(x) x
64#endif
65 63
66#ifndef LOAD 64#ifndef LOAD
67#define LOAD(type,addr,dest) type [addr], dest 65#define LOAD(type,addr,dest) type [addr], dest
@@ -94,6 +92,158 @@
94 .register %g3,#scratch 92 .register %g3,#scratch
95 93
96 .text 94 .text
95#ifndef EX_RETVAL
96#define EX_RETVAL(x) x
97__restore_asi_fp:
98 VISExitHalf
99__restore_asi:
100 retl
101 wr %g0, ASI_AIUS, %asi
102
103ENTRY(NG4_retl_o2)
104 ba,pt %xcc, __restore_asi
105 mov %o2, %o0
106ENDPROC(NG4_retl_o2)
107ENTRY(NG4_retl_o2_plus_1)
108 ba,pt %xcc, __restore_asi
109 add %o2, 1, %o0
110ENDPROC(NG4_retl_o2_plus_1)
111ENTRY(NG4_retl_o2_plus_4)
112 ba,pt %xcc, __restore_asi
113 add %o2, 4, %o0
114ENDPROC(NG4_retl_o2_plus_4)
115ENTRY(NG4_retl_o2_plus_o5)
116 ba,pt %xcc, __restore_asi
117 add %o2, %o5, %o0
118ENDPROC(NG4_retl_o2_plus_o5)
119ENTRY(NG4_retl_o2_plus_o5_plus_4)
120 add %o5, 4, %o5
121 ba,pt %xcc, __restore_asi
122 add %o2, %o5, %o0
123ENDPROC(NG4_retl_o2_plus_o5_plus_4)
124ENTRY(NG4_retl_o2_plus_o5_plus_8)
125 add %o5, 8, %o5
126 ba,pt %xcc, __restore_asi
127 add %o2, %o5, %o0
128ENDPROC(NG4_retl_o2_plus_o5_plus_8)
129ENTRY(NG4_retl_o2_plus_o5_plus_16)
130 add %o5, 16, %o5
131 ba,pt %xcc, __restore_asi
132 add %o2, %o5, %o0
133ENDPROC(NG4_retl_o2_plus_o5_plus_16)
134ENTRY(NG4_retl_o2_plus_o5_plus_24)
135 add %o5, 24, %o5
136 ba,pt %xcc, __restore_asi
137 add %o2, %o5, %o0
138ENDPROC(NG4_retl_o2_plus_o5_plus_24)
139ENTRY(NG4_retl_o2_plus_o5_plus_32)
140 add %o5, 32, %o5
141 ba,pt %xcc, __restore_asi
142 add %o2, %o5, %o0
143ENDPROC(NG4_retl_o2_plus_o5_plus_32)
144ENTRY(NG4_retl_o2_plus_g1)
145 ba,pt %xcc, __restore_asi
146 add %o2, %g1, %o0
147ENDPROC(NG4_retl_o2_plus_g1)
148ENTRY(NG4_retl_o2_plus_g1_plus_1)
149 add %g1, 1, %g1
150 ba,pt %xcc, __restore_asi
151 add %o2, %g1, %o0
152ENDPROC(NG4_retl_o2_plus_g1_plus_1)
153ENTRY(NG4_retl_o2_plus_g1_plus_8)
154 add %g1, 8, %g1
155 ba,pt %xcc, __restore_asi
156 add %o2, %g1, %o0
157ENDPROC(NG4_retl_o2_plus_g1_plus_8)
158ENTRY(NG4_retl_o2_plus_o4)
159 ba,pt %xcc, __restore_asi
160 add %o2, %o4, %o0
161ENDPROC(NG4_retl_o2_plus_o4)
162ENTRY(NG4_retl_o2_plus_o4_plus_8)
163 add %o4, 8, %o4
164 ba,pt %xcc, __restore_asi
165 add %o2, %o4, %o0
166ENDPROC(NG4_retl_o2_plus_o4_plus_8)
167ENTRY(NG4_retl_o2_plus_o4_plus_16)
168 add %o4, 16, %o4
169 ba,pt %xcc, __restore_asi
170 add %o2, %o4, %o0
171ENDPROC(NG4_retl_o2_plus_o4_plus_16)
172ENTRY(NG4_retl_o2_plus_o4_plus_24)
173 add %o4, 24, %o4
174 ba,pt %xcc, __restore_asi
175 add %o2, %o4, %o0
176ENDPROC(NG4_retl_o2_plus_o4_plus_24)
177ENTRY(NG4_retl_o2_plus_o4_plus_32)
178 add %o4, 32, %o4
179 ba,pt %xcc, __restore_asi
180 add %o2, %o4, %o0
181ENDPROC(NG4_retl_o2_plus_o4_plus_32)
182ENTRY(NG4_retl_o2_plus_o4_plus_40)
183 add %o4, 40, %o4
184 ba,pt %xcc, __restore_asi
185 add %o2, %o4, %o0
186ENDPROC(NG4_retl_o2_plus_o4_plus_40)
187ENTRY(NG4_retl_o2_plus_o4_plus_48)
188 add %o4, 48, %o4
189 ba,pt %xcc, __restore_asi
190 add %o2, %o4, %o0
191ENDPROC(NG4_retl_o2_plus_o4_plus_48)
192ENTRY(NG4_retl_o2_plus_o4_plus_56)
193 add %o4, 56, %o4
194 ba,pt %xcc, __restore_asi
195 add %o2, %o4, %o0
196ENDPROC(NG4_retl_o2_plus_o4_plus_56)
197ENTRY(NG4_retl_o2_plus_o4_plus_64)
198 add %o4, 64, %o4
199 ba,pt %xcc, __restore_asi
200 add %o2, %o4, %o0
201ENDPROC(NG4_retl_o2_plus_o4_plus_64)
202ENTRY(NG4_retl_o2_plus_o4_fp)
203 ba,pt %xcc, __restore_asi_fp
204 add %o2, %o4, %o0
205ENDPROC(NG4_retl_o2_plus_o4_fp)
206ENTRY(NG4_retl_o2_plus_o4_plus_8_fp)
207 add %o4, 8, %o4
208 ba,pt %xcc, __restore_asi_fp
209 add %o2, %o4, %o0
210ENDPROC(NG4_retl_o2_plus_o4_plus_8_fp)
211ENTRY(NG4_retl_o2_plus_o4_plus_16_fp)
212 add %o4, 16, %o4
213 ba,pt %xcc, __restore_asi_fp
214 add %o2, %o4, %o0
215ENDPROC(NG4_retl_o2_plus_o4_plus_16_fp)
216ENTRY(NG4_retl_o2_plus_o4_plus_24_fp)
217 add %o4, 24, %o4
218 ba,pt %xcc, __restore_asi_fp
219 add %o2, %o4, %o0
220ENDPROC(NG4_retl_o2_plus_o4_plus_24_fp)
221ENTRY(NG4_retl_o2_plus_o4_plus_32_fp)
222 add %o4, 32, %o4
223 ba,pt %xcc, __restore_asi_fp
224 add %o2, %o4, %o0
225ENDPROC(NG4_retl_o2_plus_o4_plus_32_fp)
226ENTRY(NG4_retl_o2_plus_o4_plus_40_fp)
227 add %o4, 40, %o4
228 ba,pt %xcc, __restore_asi_fp
229 add %o2, %o4, %o0
230ENDPROC(NG4_retl_o2_plus_o4_plus_40_fp)
231ENTRY(NG4_retl_o2_plus_o4_plus_48_fp)
232 add %o4, 48, %o4
233 ba,pt %xcc, __restore_asi_fp
234 add %o2, %o4, %o0
235ENDPROC(NG4_retl_o2_plus_o4_plus_48_fp)
236ENTRY(NG4_retl_o2_plus_o4_plus_56_fp)
237 add %o4, 56, %o4
238 ba,pt %xcc, __restore_asi_fp
239 add %o2, %o4, %o0
240ENDPROC(NG4_retl_o2_plus_o4_plus_56_fp)
241ENTRY(NG4_retl_o2_plus_o4_plus_64_fp)
242 add %o4, 64, %o4
243 ba,pt %xcc, __restore_asi_fp
244 add %o2, %o4, %o0
245ENDPROC(NG4_retl_o2_plus_o4_plus_64_fp)
246#endif
97 .align 64 247 .align 64
98 248
99 .globl FUNC_NAME 249 .globl FUNC_NAME
@@ -124,12 +274,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
124 brz,pt %g1, 51f 274 brz,pt %g1, 51f
125 sub %o2, %g1, %o2 275 sub %o2, %g1, %o2
126 276
1271: EX_LD(LOAD(ldub, %o1 + 0x00, %g2)) 277
2781: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
128 add %o1, 1, %o1 279 add %o1, 1, %o1
129 subcc %g1, 1, %g1 280 subcc %g1, 1, %g1
130 add %o0, 1, %o0 281 add %o0, 1, %o0
131 bne,pt %icc, 1b 282 bne,pt %icc, 1b
132 EX_ST(STORE(stb, %g2, %o0 - 0x01)) 283 EX_ST(STORE(stb, %g2, %o0 - 0x01), NG4_retl_o2_plus_g1_plus_1)
133 284
13451: LOAD(prefetch, %o1 + 0x040, #n_reads_strong) 28551: LOAD(prefetch, %o1 + 0x040, #n_reads_strong)
135 LOAD(prefetch, %o1 + 0x080, #n_reads_strong) 286 LOAD(prefetch, %o1 + 0x080, #n_reads_strong)
@@ -154,43 +305,43 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
154 brz,pt %g1, .Llarge_aligned 305 brz,pt %g1, .Llarge_aligned
155 sub %o2, %g1, %o2 306 sub %o2, %g1, %o2
156 307
1571: EX_LD(LOAD(ldx, %o1 + 0x00, %g2)) 3081: EX_LD(LOAD(ldx, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
158 add %o1, 8, %o1 309 add %o1, 8, %o1
159 subcc %g1, 8, %g1 310 subcc %g1, 8, %g1
160 add %o0, 8, %o0 311 add %o0, 8, %o0
161 bne,pt %icc, 1b 312 bne,pt %icc, 1b
162 EX_ST(STORE(stx, %g2, %o0 - 0x08)) 313 EX_ST(STORE(stx, %g2, %o0 - 0x08), NG4_retl_o2_plus_g1_plus_8)
163 314
164.Llarge_aligned: 315.Llarge_aligned:
165 /* len >= 0x80 && src 8-byte aligned && dest 8-byte aligned */ 316 /* len >= 0x80 && src 8-byte aligned && dest 8-byte aligned */
166 andn %o2, 0x3f, %o4 317 andn %o2, 0x3f, %o4
167 sub %o2, %o4, %o2 318 sub %o2, %o4, %o2
168 319
1691: EX_LD(LOAD(ldx, %o1 + 0x00, %g1)) 3201: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o4)
170 add %o1, 0x40, %o1 321 add %o1, 0x40, %o1
171 EX_LD(LOAD(ldx, %o1 - 0x38, %g2)) 322 EX_LD(LOAD(ldx, %o1 - 0x38, %g2), NG4_retl_o2_plus_o4)
172 subcc %o4, 0x40, %o4 323 subcc %o4, 0x40, %o4
173 EX_LD(LOAD(ldx, %o1 - 0x30, %g3)) 324 EX_LD(LOAD(ldx, %o1 - 0x30, %g3), NG4_retl_o2_plus_o4_plus_64)
174 EX_LD(LOAD(ldx, %o1 - 0x28, GLOBAL_SPARE)) 325 EX_LD(LOAD(ldx, %o1 - 0x28, GLOBAL_SPARE), NG4_retl_o2_plus_o4_plus_64)
175 EX_LD(LOAD(ldx, %o1 - 0x20, %o5)) 326 EX_LD(LOAD(ldx, %o1 - 0x20, %o5), NG4_retl_o2_plus_o4_plus_64)
176 EX_ST(STORE_INIT(%g1, %o0)) 327 EX_ST(STORE_INIT(%g1, %o0), NG4_retl_o2_plus_o4_plus_64)
177 add %o0, 0x08, %o0 328 add %o0, 0x08, %o0
178 EX_ST(STORE_INIT(%g2, %o0)) 329 EX_ST(STORE_INIT(%g2, %o0), NG4_retl_o2_plus_o4_plus_56)
179 add %o0, 0x08, %o0 330 add %o0, 0x08, %o0
180 EX_LD(LOAD(ldx, %o1 - 0x18, %g2)) 331 EX_LD(LOAD(ldx, %o1 - 0x18, %g2), NG4_retl_o2_plus_o4_plus_48)
181 EX_ST(STORE_INIT(%g3, %o0)) 332 EX_ST(STORE_INIT(%g3, %o0), NG4_retl_o2_plus_o4_plus_48)
182 add %o0, 0x08, %o0 333 add %o0, 0x08, %o0
183 EX_LD(LOAD(ldx, %o1 - 0x10, %g3)) 334 EX_LD(LOAD(ldx, %o1 - 0x10, %g3), NG4_retl_o2_plus_o4_plus_40)
184 EX_ST(STORE_INIT(GLOBAL_SPARE, %o0)) 335 EX_ST(STORE_INIT(GLOBAL_SPARE, %o0), NG4_retl_o2_plus_o4_plus_40)
185 add %o0, 0x08, %o0 336 add %o0, 0x08, %o0
186 EX_LD(LOAD(ldx, %o1 - 0x08, GLOBAL_SPARE)) 337 EX_LD(LOAD(ldx, %o1 - 0x08, GLOBAL_SPARE), NG4_retl_o2_plus_o4_plus_32)
187 EX_ST(STORE_INIT(%o5, %o0)) 338 EX_ST(STORE_INIT(%o5, %o0), NG4_retl_o2_plus_o4_plus_32)
188 add %o0, 0x08, %o0 339 add %o0, 0x08, %o0
189 EX_ST(STORE_INIT(%g2, %o0)) 340 EX_ST(STORE_INIT(%g2, %o0), NG4_retl_o2_plus_o4_plus_24)
190 add %o0, 0x08, %o0 341 add %o0, 0x08, %o0
191 EX_ST(STORE_INIT(%g3, %o0)) 342 EX_ST(STORE_INIT(%g3, %o0), NG4_retl_o2_plus_o4_plus_16)
192 add %o0, 0x08, %o0 343 add %o0, 0x08, %o0
193 EX_ST(STORE_INIT(GLOBAL_SPARE, %o0)) 344 EX_ST(STORE_INIT(GLOBAL_SPARE, %o0), NG4_retl_o2_plus_o4_plus_8)
194 add %o0, 0x08, %o0 345 add %o0, 0x08, %o0
195 bne,pt %icc, 1b 346 bne,pt %icc, 1b
196 LOAD(prefetch, %o1 + 0x200, #n_reads_strong) 347 LOAD(prefetch, %o1 + 0x200, #n_reads_strong)
@@ -216,17 +367,17 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
216 sub %o2, %o4, %o2 367 sub %o2, %o4, %o2
217 alignaddr %o1, %g0, %g1 368 alignaddr %o1, %g0, %g1
218 add %o1, %o4, %o1 369 add %o1, %o4, %o1
219 EX_LD_FP(LOAD(ldd, %g1 + 0x00, %f0)) 370 EX_LD_FP(LOAD(ldd, %g1 + 0x00, %f0), NG4_retl_o2_plus_o4)
2201: EX_LD_FP(LOAD(ldd, %g1 + 0x08, %f2)) 3711: EX_LD_FP(LOAD(ldd, %g1 + 0x08, %f2), NG4_retl_o2_plus_o4)
221 subcc %o4, 0x40, %o4 372 subcc %o4, 0x40, %o4
222 EX_LD_FP(LOAD(ldd, %g1 + 0x10, %f4)) 373 EX_LD_FP(LOAD(ldd, %g1 + 0x10, %f4), NG4_retl_o2_plus_o4_plus_64)
223 EX_LD_FP(LOAD(ldd, %g1 + 0x18, %f6)) 374 EX_LD_FP(LOAD(ldd, %g1 + 0x18, %f6), NG4_retl_o2_plus_o4_plus_64)
224 EX_LD_FP(LOAD(ldd, %g1 + 0x20, %f8)) 375 EX_LD_FP(LOAD(ldd, %g1 + 0x20, %f8), NG4_retl_o2_plus_o4_plus_64)
225 EX_LD_FP(LOAD(ldd, %g1 + 0x28, %f10)) 376 EX_LD_FP(LOAD(ldd, %g1 + 0x28, %f10), NG4_retl_o2_plus_o4_plus_64)
226 EX_LD_FP(LOAD(ldd, %g1 + 0x30, %f12)) 377 EX_LD_FP(LOAD(ldd, %g1 + 0x30, %f12), NG4_retl_o2_plus_o4_plus_64)
227 EX_LD_FP(LOAD(ldd, %g1 + 0x38, %f14)) 378 EX_LD_FP(LOAD(ldd, %g1 + 0x38, %f14), NG4_retl_o2_plus_o4_plus_64)
228 faligndata %f0, %f2, %f16 379 faligndata %f0, %f2, %f16
229 EX_LD_FP(LOAD(ldd, %g1 + 0x40, %f0)) 380 EX_LD_FP(LOAD(ldd, %g1 + 0x40, %f0), NG4_retl_o2_plus_o4_plus_64)
230 faligndata %f2, %f4, %f18 381 faligndata %f2, %f4, %f18
231 add %g1, 0x40, %g1 382 add %g1, 0x40, %g1
232 faligndata %f4, %f6, %f20 383 faligndata %f4, %f6, %f20
@@ -235,14 +386,14 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
235 faligndata %f10, %f12, %f26 386 faligndata %f10, %f12, %f26
236 faligndata %f12, %f14, %f28 387 faligndata %f12, %f14, %f28
237 faligndata %f14, %f0, %f30 388 faligndata %f14, %f0, %f30
238 EX_ST_FP(STORE(std, %f16, %o0 + 0x00)) 389 EX_ST_FP(STORE(std, %f16, %o0 + 0x00), NG4_retl_o2_plus_o4_plus_64)
239 EX_ST_FP(STORE(std, %f18, %o0 + 0x08)) 390 EX_ST_FP(STORE(std, %f18, %o0 + 0x08), NG4_retl_o2_plus_o4_plus_56)
240 EX_ST_FP(STORE(std, %f20, %o0 + 0x10)) 391 EX_ST_FP(STORE(std, %f20, %o0 + 0x10), NG4_retl_o2_plus_o4_plus_48)
241 EX_ST_FP(STORE(std, %f22, %o0 + 0x18)) 392 EX_ST_FP(STORE(std, %f22, %o0 + 0x18), NG4_retl_o2_plus_o4_plus_40)
242 EX_ST_FP(STORE(std, %f24, %o0 + 0x20)) 393 EX_ST_FP(STORE(std, %f24, %o0 + 0x20), NG4_retl_o2_plus_o4_plus_32)
243 EX_ST_FP(STORE(std, %f26, %o0 + 0x28)) 394 EX_ST_FP(STORE(std, %f26, %o0 + 0x28), NG4_retl_o2_plus_o4_plus_24)
244 EX_ST_FP(STORE(std, %f28, %o0 + 0x30)) 395 EX_ST_FP(STORE(std, %f28, %o0 + 0x30), NG4_retl_o2_plus_o4_plus_16)
245 EX_ST_FP(STORE(std, %f30, %o0 + 0x38)) 396 EX_ST_FP(STORE(std, %f30, %o0 + 0x38), NG4_retl_o2_plus_o4_plus_8)
246 add %o0, 0x40, %o0 397 add %o0, 0x40, %o0
247 bne,pt %icc, 1b 398 bne,pt %icc, 1b
248 LOAD(prefetch, %g1 + 0x200, #n_reads_strong) 399 LOAD(prefetch, %g1 + 0x200, #n_reads_strong)
@@ -270,37 +421,38 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
270 andncc %o2, 0x20 - 1, %o5 421 andncc %o2, 0x20 - 1, %o5
271 be,pn %icc, 2f 422 be,pn %icc, 2f
272 sub %o2, %o5, %o2 423 sub %o2, %o5, %o2
2731: EX_LD(LOAD(ldx, %o1 + 0x00, %g1)) 4241: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
274 EX_LD(LOAD(ldx, %o1 + 0x08, %g2)) 425 EX_LD(LOAD(ldx, %o1 + 0x08, %g2), NG4_retl_o2_plus_o5)
275 EX_LD(LOAD(ldx, %o1 + 0x10, GLOBAL_SPARE)) 426 EX_LD(LOAD(ldx, %o1 + 0x10, GLOBAL_SPARE), NG4_retl_o2_plus_o5)
276 EX_LD(LOAD(ldx, %o1 + 0x18, %o4)) 427 EX_LD(LOAD(ldx, %o1 + 0x18, %o4), NG4_retl_o2_plus_o5)
277 add %o1, 0x20, %o1 428 add %o1, 0x20, %o1
278 subcc %o5, 0x20, %o5 429 subcc %o5, 0x20, %o5
279 EX_ST(STORE(stx, %g1, %o0 + 0x00)) 430 EX_ST(STORE(stx, %g1, %o0 + 0x00), NG4_retl_o2_plus_o5_plus_32)
280 EX_ST(STORE(stx, %g2, %o0 + 0x08)) 431 EX_ST(STORE(stx, %g2, %o0 + 0x08), NG4_retl_o2_plus_o5_plus_24)
281 EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10)) 432 EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10), NG4_retl_o2_plus_o5_plus_24)
282 EX_ST(STORE(stx, %o4, %o0 + 0x18)) 433 EX_ST(STORE(stx, %o4, %o0 + 0x18), NG4_retl_o2_plus_o5_plus_8)
283 bne,pt %icc, 1b 434 bne,pt %icc, 1b
284 add %o0, 0x20, %o0 435 add %o0, 0x20, %o0
2852: andcc %o2, 0x18, %o5 4362: andcc %o2, 0x18, %o5
286 be,pt %icc, 3f 437 be,pt %icc, 3f
287 sub %o2, %o5, %o2 438 sub %o2, %o5, %o2
2881: EX_LD(LOAD(ldx, %o1 + 0x00, %g1)) 439
4401: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
289 add %o1, 0x08, %o1 441 add %o1, 0x08, %o1
290 add %o0, 0x08, %o0 442 add %o0, 0x08, %o0
291 subcc %o5, 0x08, %o5 443 subcc %o5, 0x08, %o5
292 bne,pt %icc, 1b 444 bne,pt %icc, 1b
293 EX_ST(STORE(stx, %g1, %o0 - 0x08)) 445 EX_ST(STORE(stx, %g1, %o0 - 0x08), NG4_retl_o2_plus_o5_plus_8)
2943: brz,pt %o2, .Lexit 4463: brz,pt %o2, .Lexit
295 cmp %o2, 0x04 447 cmp %o2, 0x04
296 bl,pn %icc, .Ltiny 448 bl,pn %icc, .Ltiny
297 nop 449 nop
298 EX_LD(LOAD(lduw, %o1 + 0x00, %g1)) 450 EX_LD(LOAD(lduw, %o1 + 0x00, %g1), NG4_retl_o2)
299 add %o1, 0x04, %o1 451 add %o1, 0x04, %o1
300 add %o0, 0x04, %o0 452 add %o0, 0x04, %o0
301 subcc %o2, 0x04, %o2 453 subcc %o2, 0x04, %o2
302 bne,pn %icc, .Ltiny 454 bne,pn %icc, .Ltiny
303 EX_ST(STORE(stw, %g1, %o0 - 0x04)) 455 EX_ST(STORE(stw, %g1, %o0 - 0x04), NG4_retl_o2_plus_4)
304 ba,a,pt %icc, .Lexit 456 ba,a,pt %icc, .Lexit
305.Lmedium_unaligned: 457.Lmedium_unaligned:
306 /* First get dest 8 byte aligned. */ 458 /* First get dest 8 byte aligned. */
@@ -309,12 +461,12 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
309 brz,pt %g1, 2f 461 brz,pt %g1, 2f
310 sub %o2, %g1, %o2 462 sub %o2, %g1, %o2
311 463
3121: EX_LD(LOAD(ldub, %o1 + 0x00, %g2)) 4641: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
313 add %o1, 1, %o1 465 add %o1, 1, %o1
314 subcc %g1, 1, %g1 466 subcc %g1, 1, %g1
315 add %o0, 1, %o0 467 add %o0, 1, %o0
316 bne,pt %icc, 1b 468 bne,pt %icc, 1b
317 EX_ST(STORE(stb, %g2, %o0 - 0x01)) 469 EX_ST(STORE(stb, %g2, %o0 - 0x01), NG4_retl_o2_plus_g1_plus_1)
3182: 4702:
319 and %o1, 0x7, %g1 471 and %o1, 0x7, %g1
320 brz,pn %g1, .Lmedium_noprefetch 472 brz,pn %g1, .Lmedium_noprefetch
@@ -322,16 +474,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
322 mov 64, %g2 474 mov 64, %g2
323 sub %g2, %g1, %g2 475 sub %g2, %g1, %g2
324 andn %o1, 0x7, %o1 476 andn %o1, 0x7, %o1
325 EX_LD(LOAD(ldx, %o1 + 0x00, %o4)) 477 EX_LD(LOAD(ldx, %o1 + 0x00, %o4), NG4_retl_o2)
326 sllx %o4, %g1, %o4 478 sllx %o4, %g1, %o4
327 andn %o2, 0x08 - 1, %o5 479 andn %o2, 0x08 - 1, %o5
328 sub %o2, %o5, %o2 480 sub %o2, %o5, %o2
3291: EX_LD(LOAD(ldx, %o1 + 0x08, %g3)) 4811: EX_LD(LOAD(ldx, %o1 + 0x08, %g3), NG4_retl_o2_plus_o5)
330 add %o1, 0x08, %o1 482 add %o1, 0x08, %o1
331 subcc %o5, 0x08, %o5 483 subcc %o5, 0x08, %o5
332 srlx %g3, %g2, GLOBAL_SPARE 484 srlx %g3, %g2, GLOBAL_SPARE
333 or GLOBAL_SPARE, %o4, GLOBAL_SPARE 485 or GLOBAL_SPARE, %o4, GLOBAL_SPARE
334 EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x00)) 486 EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x00), NG4_retl_o2_plus_o5_plus_8)
335 add %o0, 0x08, %o0 487 add %o0, 0x08, %o0
336 bne,pt %icc, 1b 488 bne,pt %icc, 1b
337 sllx %g3, %g1, %o4 489 sllx %g3, %g1, %o4
@@ -342,17 +494,17 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
342 ba,pt %icc, .Lsmall_unaligned 494 ba,pt %icc, .Lsmall_unaligned
343 495
344.Ltiny: 496.Ltiny:
345 EX_LD(LOAD(ldub, %o1 + 0x00, %g1)) 497 EX_LD(LOAD(ldub, %o1 + 0x00, %g1), NG4_retl_o2)
346 subcc %o2, 1, %o2 498 subcc %o2, 1, %o2
347 be,pn %icc, .Lexit 499 be,pn %icc, .Lexit
348 EX_ST(STORE(stb, %g1, %o0 + 0x00)) 500 EX_ST(STORE(stb, %g1, %o0 + 0x00), NG4_retl_o2_plus_1)
349 EX_LD(LOAD(ldub, %o1 + 0x01, %g1)) 501 EX_LD(LOAD(ldub, %o1 + 0x01, %g1), NG4_retl_o2)
350 subcc %o2, 1, %o2 502 subcc %o2, 1, %o2
351 be,pn %icc, .Lexit 503 be,pn %icc, .Lexit
352 EX_ST(STORE(stb, %g1, %o0 + 0x01)) 504 EX_ST(STORE(stb, %g1, %o0 + 0x01), NG4_retl_o2_plus_1)
353 EX_LD(LOAD(ldub, %o1 + 0x02, %g1)) 505 EX_LD(LOAD(ldub, %o1 + 0x02, %g1), NG4_retl_o2)
354 ba,pt %icc, .Lexit 506 ba,pt %icc, .Lexit
355 EX_ST(STORE(stb, %g1, %o0 + 0x02)) 507 EX_ST(STORE(stb, %g1, %o0 + 0x02), NG4_retl_o2)
356 508
357.Lsmall: 509.Lsmall:
358 andcc %g2, 0x3, %g0 510 andcc %g2, 0x3, %g0
@@ -360,22 +512,22 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
360 andn %o2, 0x4 - 1, %o5 512 andn %o2, 0x4 - 1, %o5
361 sub %o2, %o5, %o2 513 sub %o2, %o5, %o2
3621: 5141:
363 EX_LD(LOAD(lduw, %o1 + 0x00, %g1)) 515 EX_LD(LOAD(lduw, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
364 add %o1, 0x04, %o1 516 add %o1, 0x04, %o1
365 subcc %o5, 0x04, %o5 517 subcc %o5, 0x04, %o5
366 add %o0, 0x04, %o0 518 add %o0, 0x04, %o0
367 bne,pt %icc, 1b 519 bne,pt %icc, 1b
368 EX_ST(STORE(stw, %g1, %o0 - 0x04)) 520 EX_ST(STORE(stw, %g1, %o0 - 0x04), NG4_retl_o2_plus_o5_plus_4)
369 brz,pt %o2, .Lexit 521 brz,pt %o2, .Lexit
370 nop 522 nop
371 ba,a,pt %icc, .Ltiny 523 ba,a,pt %icc, .Ltiny
372 524
373.Lsmall_unaligned: 525.Lsmall_unaligned:
3741: EX_LD(LOAD(ldub, %o1 + 0x00, %g1)) 5261: EX_LD(LOAD(ldub, %o1 + 0x00, %g1), NG4_retl_o2)
375 add %o1, 1, %o1 527 add %o1, 1, %o1
376 add %o0, 1, %o0 528 add %o0, 1, %o0
377 subcc %o2, 1, %o2 529 subcc %o2, 1, %o2
378 bne,pt %icc, 1b 530 bne,pt %icc, 1b
379 EX_ST(STORE(stb, %g1, %o0 - 0x01)) 531 EX_ST(STORE(stb, %g1, %o0 - 0x01), NG4_retl_o2_plus_1)
380 ba,a,pt %icc, .Lexit 532 ba,a,pt %icc, .Lexit
381 .size FUNC_NAME, .-FUNC_NAME 533 .size FUNC_NAME, .-FUNC_NAME
diff --git a/arch/sparc/lib/NGcopy_from_user.S b/arch/sparc/lib/NGcopy_from_user.S
index 5d1e4d1ac21e..9cd42fcbc781 100644
--- a/arch/sparc/lib/NGcopy_from_user.S
+++ b/arch/sparc/lib/NGcopy_from_user.S
@@ -3,11 +3,11 @@
3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __ret_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
diff --git a/arch/sparc/lib/NGcopy_to_user.S b/arch/sparc/lib/NGcopy_to_user.S
index ff630dcb273c..5c358afd464e 100644
--- a/arch/sparc/lib/NGcopy_to_user.S
+++ b/arch/sparc/lib/NGcopy_to_user.S
@@ -3,11 +3,11 @@
3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __ret_one_asi;\ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
diff --git a/arch/sparc/lib/NGmemcpy.S b/arch/sparc/lib/NGmemcpy.S
index 96a14caf6966..d88c4ed50a00 100644
--- a/arch/sparc/lib/NGmemcpy.S
+++ b/arch/sparc/lib/NGmemcpy.S
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/linkage.h>
7#include <asm/asi.h> 8#include <asm/asi.h>
8#include <asm/thread_info.h> 9#include <asm/thread_info.h>
9#define GLOBAL_SPARE %g7 10#define GLOBAL_SPARE %g7
@@ -27,15 +28,11 @@
27#endif 28#endif
28 29
29#ifndef EX_LD 30#ifndef EX_LD
30#define EX_LD(x) x 31#define EX_LD(x,y) x
31#endif 32#endif
32 33
33#ifndef EX_ST 34#ifndef EX_ST
34#define EX_ST(x) x 35#define EX_ST(x,y) x
35#endif
36
37#ifndef EX_RETVAL
38#define EX_RETVAL(x) x
39#endif 36#endif
40 37
41#ifndef LOAD 38#ifndef LOAD
@@ -79,6 +76,92 @@
79 .register %g3,#scratch 76 .register %g3,#scratch
80 77
81 .text 78 .text
79#ifndef EX_RETVAL
80#define EX_RETVAL(x) x
81__restore_asi:
82 ret
83 wr %g0, ASI_AIUS, %asi
84 restore
85ENTRY(NG_ret_i2_plus_i4_plus_1)
86 ba,pt %xcc, __restore_asi
87 add %i2, %i5, %i0
88ENDPROC(NG_ret_i2_plus_i4_plus_1)
89ENTRY(NG_ret_i2_plus_g1)
90 ba,pt %xcc, __restore_asi
91 add %i2, %g1, %i0
92ENDPROC(NG_ret_i2_plus_g1)
93ENTRY(NG_ret_i2_plus_g1_minus_8)
94 sub %g1, 8, %g1
95 ba,pt %xcc, __restore_asi
96 add %i2, %g1, %i0
97ENDPROC(NG_ret_i2_plus_g1_minus_8)
98ENTRY(NG_ret_i2_plus_g1_minus_16)
99 sub %g1, 16, %g1
100 ba,pt %xcc, __restore_asi
101 add %i2, %g1, %i0
102ENDPROC(NG_ret_i2_plus_g1_minus_16)
103ENTRY(NG_ret_i2_plus_g1_minus_24)
104 sub %g1, 24, %g1
105 ba,pt %xcc, __restore_asi
106 add %i2, %g1, %i0
107ENDPROC(NG_ret_i2_plus_g1_minus_24)
108ENTRY(NG_ret_i2_plus_g1_minus_32)
109 sub %g1, 32, %g1
110 ba,pt %xcc, __restore_asi
111 add %i2, %g1, %i0
112ENDPROC(NG_ret_i2_plus_g1_minus_32)
113ENTRY(NG_ret_i2_plus_g1_minus_40)
114 sub %g1, 40, %g1
115 ba,pt %xcc, __restore_asi
116 add %i2, %g1, %i0
117ENDPROC(NG_ret_i2_plus_g1_minus_40)
118ENTRY(NG_ret_i2_plus_g1_minus_48)
119 sub %g1, 48, %g1
120 ba,pt %xcc, __restore_asi
121 add %i2, %g1, %i0
122ENDPROC(NG_ret_i2_plus_g1_minus_48)
123ENTRY(NG_ret_i2_plus_g1_minus_56)
124 sub %g1, 56, %g1
125 ba,pt %xcc, __restore_asi
126 add %i2, %g1, %i0
127ENDPROC(NG_ret_i2_plus_g1_minus_56)
128ENTRY(NG_ret_i2_plus_i4)
129 ba,pt %xcc, __restore_asi
130 add %i2, %i4, %i0
131ENDPROC(NG_ret_i2_plus_i4)
132ENTRY(NG_ret_i2_plus_i4_minus_8)
133 sub %i4, 8, %i4
134 ba,pt %xcc, __restore_asi
135 add %i2, %i4, %i0
136ENDPROC(NG_ret_i2_plus_i4_minus_8)
137ENTRY(NG_ret_i2_plus_8)
138 ba,pt %xcc, __restore_asi
139 add %i2, 8, %i0
140ENDPROC(NG_ret_i2_plus_8)
141ENTRY(NG_ret_i2_plus_4)
142 ba,pt %xcc, __restore_asi
143 add %i2, 4, %i0
144ENDPROC(NG_ret_i2_plus_4)
145ENTRY(NG_ret_i2_plus_1)
146 ba,pt %xcc, __restore_asi
147 add %i2, 1, %i0
148ENDPROC(NG_ret_i2_plus_1)
149ENTRY(NG_ret_i2_plus_g1_plus_1)
150 add %g1, 1, %g1
151 ba,pt %xcc, __restore_asi
152 add %i2, %g1, %i0
153ENDPROC(NG_ret_i2_plus_g1_plus_1)
154ENTRY(NG_ret_i2)
155 ba,pt %xcc, __restore_asi
156 mov %i2, %i0
157ENDPROC(NG_ret_i2)
158ENTRY(NG_ret_i2_and_7_plus_i4)
159 and %i2, 7, %i2
160 ba,pt %xcc, __restore_asi
161 add %i2, %i4, %i0
162ENDPROC(NG_ret_i2_and_7_plus_i4)
163#endif
164
82 .align 64 165 .align 64
83 166
84 .globl FUNC_NAME 167 .globl FUNC_NAME
@@ -126,8 +209,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
126 sub %g0, %i4, %i4 ! bytes to align dst 209 sub %g0, %i4, %i4 ! bytes to align dst
127 sub %i2, %i4, %i2 210 sub %i2, %i4, %i2
1281: subcc %i4, 1, %i4 2111: subcc %i4, 1, %i4
129 EX_LD(LOAD(ldub, %i1, %g1)) 212 EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_i4_plus_1)
130 EX_ST(STORE(stb, %g1, %o0)) 213 EX_ST(STORE(stb, %g1, %o0), NG_ret_i2_plus_i4_plus_1)
131 add %i1, 1, %i1 214 add %i1, 1, %i1
132 bne,pt %XCC, 1b 215 bne,pt %XCC, 1b
133 add %o0, 1, %o0 216 add %o0, 1, %o0
@@ -160,7 +243,7 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
160 and %i4, 0x7, GLOBAL_SPARE 243 and %i4, 0x7, GLOBAL_SPARE
161 sll GLOBAL_SPARE, 3, GLOBAL_SPARE 244 sll GLOBAL_SPARE, 3, GLOBAL_SPARE
162 mov 64, %i5 245 mov 64, %i5
163 EX_LD(LOAD_TWIN(%i1, %g2, %g3)) 246 EX_LD(LOAD_TWIN(%i1, %g2, %g3), NG_ret_i2_plus_g1)
164 sub %i5, GLOBAL_SPARE, %i5 247 sub %i5, GLOBAL_SPARE, %i5
165 mov 16, %o4 248 mov 16, %o4
166 mov 32, %o5 249 mov 32, %o5
@@ -178,31 +261,31 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
178 srlx WORD3, PRE_SHIFT, TMP; \ 261 srlx WORD3, PRE_SHIFT, TMP; \
179 or WORD2, TMP, WORD2; 262 or WORD2, TMP, WORD2;
180 263
1818: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3)) 2648: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
182 MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1) 265 MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
183 LOAD(prefetch, %i1 + %i3, #one_read) 266 LOAD(prefetch, %i1 + %i3, #one_read)
184 267
185 EX_ST(STORE_INIT(%g2, %o0 + 0x00)) 268 EX_ST(STORE_INIT(%g2, %o0 + 0x00), NG_ret_i2_plus_g1)
186 EX_ST(STORE_INIT(%g3, %o0 + 0x08)) 269 EX_ST(STORE_INIT(%g3, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
187 270
188 EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3)) 271 EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
189 MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1) 272 MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
190 273
191 EX_ST(STORE_INIT(%o2, %o0 + 0x10)) 274 EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
192 EX_ST(STORE_INIT(%o3, %o0 + 0x18)) 275 EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
193 276
194 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3)) 277 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
195 MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1) 278 MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
196 279
197 EX_ST(STORE_INIT(%g2, %o0 + 0x20)) 280 EX_ST(STORE_INIT(%g2, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
198 EX_ST(STORE_INIT(%g3, %o0 + 0x28)) 281 EX_ST(STORE_INIT(%g3, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
199 282
200 EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3)) 283 EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
201 add %i1, 64, %i1 284 add %i1, 64, %i1
202 MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1) 285 MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
203 286
204 EX_ST(STORE_INIT(%o2, %o0 + 0x30)) 287 EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
205 EX_ST(STORE_INIT(%o3, %o0 + 0x38)) 288 EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
206 289
207 subcc %g1, 64, %g1 290 subcc %g1, 64, %g1
208 bne,pt %XCC, 8b 291 bne,pt %XCC, 8b
@@ -211,31 +294,31 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
211 ba,pt %XCC, 60f 294 ba,pt %XCC, 60f
212 add %i1, %i4, %i1 295 add %i1, %i4, %i1
213 296
2149: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3)) 2979: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
215 MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1) 298 MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
216 LOAD(prefetch, %i1 + %i3, #one_read) 299 LOAD(prefetch, %i1 + %i3, #one_read)
217 300
218 EX_ST(STORE_INIT(%g3, %o0 + 0x00)) 301 EX_ST(STORE_INIT(%g3, %o0 + 0x00), NG_ret_i2_plus_g1)
219 EX_ST(STORE_INIT(%o2, %o0 + 0x08)) 302 EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
220 303
221 EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3)) 304 EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
222 MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1) 305 MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
223 306
224 EX_ST(STORE_INIT(%o3, %o0 + 0x10)) 307 EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
225 EX_ST(STORE_INIT(%g2, %o0 + 0x18)) 308 EX_ST(STORE_INIT(%g2, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
226 309
227 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3)) 310 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
228 MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1) 311 MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
229 312
230 EX_ST(STORE_INIT(%g3, %o0 + 0x20)) 313 EX_ST(STORE_INIT(%g3, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
231 EX_ST(STORE_INIT(%o2, %o0 + 0x28)) 314 EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
232 315
233 EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3)) 316 EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
234 add %i1, 64, %i1 317 add %i1, 64, %i1
235 MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1) 318 MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
236 319
237 EX_ST(STORE_INIT(%o3, %o0 + 0x30)) 320 EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
238 EX_ST(STORE_INIT(%g2, %o0 + 0x38)) 321 EX_ST(STORE_INIT(%g2, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
239 322
240 subcc %g1, 64, %g1 323 subcc %g1, 64, %g1
241 bne,pt %XCC, 9b 324 bne,pt %XCC, 9b
@@ -249,25 +332,25 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
249 * one twin load ahead, then add 8 back into source when 332 * one twin load ahead, then add 8 back into source when
250 * we finish the loop. 333 * we finish the loop.
251 */ 334 */
252 EX_LD(LOAD_TWIN(%i1, %o4, %o5)) 335 EX_LD(LOAD_TWIN(%i1, %o4, %o5), NG_ret_i2_plus_g1)
253 mov 16, %o7 336 mov 16, %o7
254 mov 32, %g2 337 mov 32, %g2
255 mov 48, %g3 338 mov 48, %g3
256 mov 64, %o1 339 mov 64, %o1
2571: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3)) 3401: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
258 LOAD(prefetch, %i1 + %o1, #one_read) 341 LOAD(prefetch, %i1 + %o1, #one_read)
259 EX_ST(STORE_INIT(%o5, %o0 + 0x00)) ! initializes cache line 342 EX_ST(STORE_INIT(%o5, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
260 EX_ST(STORE_INIT(%o2, %o0 + 0x08)) 343 EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
261 EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5)) 344 EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
262 EX_ST(STORE_INIT(%o3, %o0 + 0x10)) 345 EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
263 EX_ST(STORE_INIT(%o4, %o0 + 0x18)) 346 EX_ST(STORE_INIT(%o4, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
264 EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3)) 347 EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
265 EX_ST(STORE_INIT(%o5, %o0 + 0x20)) 348 EX_ST(STORE_INIT(%o5, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
266 EX_ST(STORE_INIT(%o2, %o0 + 0x28)) 349 EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
267 EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5)) 350 EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5), NG_ret_i2_plus_g1_minus_48)
268 add %i1, 64, %i1 351 add %i1, 64, %i1
269 EX_ST(STORE_INIT(%o3, %o0 + 0x30)) 352 EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
270 EX_ST(STORE_INIT(%o4, %o0 + 0x38)) 353 EX_ST(STORE_INIT(%o4, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
271 subcc %g1, 64, %g1 354 subcc %g1, 64, %g1
272 bne,pt %XCC, 1b 355 bne,pt %XCC, 1b
273 add %o0, 64, %o0 356 add %o0, 64, %o0
@@ -282,20 +365,20 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
282 mov 32, %g2 365 mov 32, %g2
283 mov 48, %g3 366 mov 48, %g3
284 mov 64, %o1 367 mov 64, %o1
2851: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5)) 3681: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5), NG_ret_i2_plus_g1)
286 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3)) 369 EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
287 LOAD(prefetch, %i1 + %o1, #one_read) 370 LOAD(prefetch, %i1 + %o1, #one_read)
288 EX_ST(STORE_INIT(%o4, %o0 + 0x00)) ! initializes cache line 371 EX_ST(STORE_INIT(%o4, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
289 EX_ST(STORE_INIT(%o5, %o0 + 0x08)) 372 EX_ST(STORE_INIT(%o5, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
290 EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5)) 373 EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
291 EX_ST(STORE_INIT(%o2, %o0 + 0x10)) 374 EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
292 EX_ST(STORE_INIT(%o3, %o0 + 0x18)) 375 EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
293 EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3)) 376 EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
294 add %i1, 64, %i1 377 add %i1, 64, %i1
295 EX_ST(STORE_INIT(%o4, %o0 + 0x20)) 378 EX_ST(STORE_INIT(%o4, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
296 EX_ST(STORE_INIT(%o5, %o0 + 0x28)) 379 EX_ST(STORE_INIT(%o5, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
297 EX_ST(STORE_INIT(%o2, %o0 + 0x30)) 380 EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
298 EX_ST(STORE_INIT(%o3, %o0 + 0x38)) 381 EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
299 subcc %g1, 64, %g1 382 subcc %g1, 64, %g1
300 bne,pt %XCC, 1b 383 bne,pt %XCC, 1b
301 add %o0, 64, %o0 384 add %o0, 64, %o0
@@ -321,28 +404,28 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
321 andn %i2, 0xf, %i4 404 andn %i2, 0xf, %i4
322 and %i2, 0xf, %i2 405 and %i2, 0xf, %i2
3231: subcc %i4, 0x10, %i4 4061: subcc %i4, 0x10, %i4
324 EX_LD(LOAD(ldx, %i1, %o4)) 407 EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4)
325 add %i1, 0x08, %i1 408 add %i1, 0x08, %i1
326 EX_LD(LOAD(ldx, %i1, %g1)) 409 EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4)
327 sub %i1, 0x08, %i1 410 sub %i1, 0x08, %i1
328 EX_ST(STORE(stx, %o4, %i1 + %i3)) 411 EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4)
329 add %i1, 0x8, %i1 412 add %i1, 0x8, %i1
330 EX_ST(STORE(stx, %g1, %i1 + %i3)) 413 EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_minus_8)
331 bgu,pt %XCC, 1b 414 bgu,pt %XCC, 1b
332 add %i1, 0x8, %i1 415 add %i1, 0x8, %i1
33373: andcc %i2, 0x8, %g0 41673: andcc %i2, 0x8, %g0
334 be,pt %XCC, 1f 417 be,pt %XCC, 1f
335 nop 418 nop
336 sub %i2, 0x8, %i2 419 sub %i2, 0x8, %i2
337 EX_LD(LOAD(ldx, %i1, %o4)) 420 EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_8)
338 EX_ST(STORE(stx, %o4, %i1 + %i3)) 421 EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_8)
339 add %i1, 0x8, %i1 422 add %i1, 0x8, %i1
3401: andcc %i2, 0x4, %g0 4231: andcc %i2, 0x4, %g0
341 be,pt %XCC, 1f 424 be,pt %XCC, 1f
342 nop 425 nop
343 sub %i2, 0x4, %i2 426 sub %i2, 0x4, %i2
344 EX_LD(LOAD(lduw, %i1, %i5)) 427 EX_LD(LOAD(lduw, %i1, %i5), NG_ret_i2_plus_4)
345 EX_ST(STORE(stw, %i5, %i1 + %i3)) 428 EX_ST(STORE(stw, %i5, %i1 + %i3), NG_ret_i2_plus_4)
346 add %i1, 0x4, %i1 429 add %i1, 0x4, %i1
3471: cmp %i2, 0 4301: cmp %i2, 0
348 be,pt %XCC, 85f 431 be,pt %XCC, 85f
@@ -358,8 +441,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
358 sub %i2, %g1, %i2 441 sub %i2, %g1, %i2
359 442
3601: subcc %g1, 1, %g1 4431: subcc %g1, 1, %g1
361 EX_LD(LOAD(ldub, %i1, %i5)) 444 EX_LD(LOAD(ldub, %i1, %i5), NG_ret_i2_plus_g1_plus_1)
362 EX_ST(STORE(stb, %i5, %i1 + %i3)) 445 EX_ST(STORE(stb, %i5, %i1 + %i3), NG_ret_i2_plus_g1_plus_1)
363 bgu,pt %icc, 1b 446 bgu,pt %icc, 1b
364 add %i1, 1, %i1 447 add %i1, 1, %i1
365 448
@@ -375,16 +458,16 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
375 458
3768: mov 64, %i3 4598: mov 64, %i3
377 andn %i1, 0x7, %i1 460 andn %i1, 0x7, %i1
378 EX_LD(LOAD(ldx, %i1, %g2)) 461 EX_LD(LOAD(ldx, %i1, %g2), NG_ret_i2)
379 sub %i3, %g1, %i3 462 sub %i3, %g1, %i3
380 andn %i2, 0x7, %i4 463 andn %i2, 0x7, %i4
381 sllx %g2, %g1, %g2 464 sllx %g2, %g1, %g2
3821: add %i1, 0x8, %i1 4651: add %i1, 0x8, %i1
383 EX_LD(LOAD(ldx, %i1, %g3)) 466 EX_LD(LOAD(ldx, %i1, %g3), NG_ret_i2_and_7_plus_i4)
384 subcc %i4, 0x8, %i4 467 subcc %i4, 0x8, %i4
385 srlx %g3, %i3, %i5 468 srlx %g3, %i3, %i5
386 or %i5, %g2, %i5 469 or %i5, %g2, %i5
387 EX_ST(STORE(stx, %i5, %o0)) 470 EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4)
388 add %o0, 0x8, %o0 471 add %o0, 0x8, %o0
389 bgu,pt %icc, 1b 472 bgu,pt %icc, 1b
390 sllx %g3, %g1, %g2 473 sllx %g3, %g1, %g2
@@ -404,8 +487,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
404 487
4051: 4881:
406 subcc %i2, 4, %i2 489 subcc %i2, 4, %i2
407 EX_LD(LOAD(lduw, %i1, %g1)) 490 EX_LD(LOAD(lduw, %i1, %g1), NG_ret_i2_plus_4)
408 EX_ST(STORE(stw, %g1, %i1 + %i3)) 491 EX_ST(STORE(stw, %g1, %i1 + %i3), NG_ret_i2_plus_4)
409 bgu,pt %XCC, 1b 492 bgu,pt %XCC, 1b
410 add %i1, 4, %i1 493 add %i1, 4, %i1
411 494
@@ -415,8 +498,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
415 .align 32 498 .align 32
41690: 49990:
417 subcc %i2, 1, %i2 500 subcc %i2, 1, %i2
418 EX_LD(LOAD(ldub, %i1, %g1)) 501 EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_1)
419 EX_ST(STORE(stb, %g1, %i1 + %i3)) 502 EX_ST(STORE(stb, %g1, %i1 + %i3), NG_ret_i2_plus_1)
420 bgu,pt %XCC, 90b 503 bgu,pt %XCC, 90b
421 add %i1, 1, %i1 504 add %i1, 1, %i1
422 ret 505 ret
diff --git a/arch/sparc/lib/U1copy_from_user.S b/arch/sparc/lib/U1copy_from_user.S
index ecc5692fa2b4..bb6ff73229e3 100644
--- a/arch/sparc/lib/U1copy_from_user.S
+++ b/arch/sparc/lib/U1copy_from_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_LD_FP(x) \ 14#define EX_LD_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_fp;\ 18 .word 98b, y; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/U1copy_to_user.S b/arch/sparc/lib/U1copy_to_user.S
index 9eea392e44d4..ed92ce739558 100644
--- a/arch/sparc/lib/U1copy_to_user.S
+++ b/arch/sparc/lib/U1copy_to_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_ST_FP(x) \ 14#define EX_ST_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_fp;\ 18 .word 98b, y; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/U1memcpy.S b/arch/sparc/lib/U1memcpy.S
index 97e1b211090c..4f0d50b33a72 100644
--- a/arch/sparc/lib/U1memcpy.S
+++ b/arch/sparc/lib/U1memcpy.S
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#ifdef __KERNEL__ 7#ifdef __KERNEL__
8#include <linux/linkage.h>
8#include <asm/visasm.h> 9#include <asm/visasm.h>
9#include <asm/asi.h> 10#include <asm/asi.h>
10#include <asm/export.h> 11#include <asm/export.h>
@@ -24,21 +25,17 @@
24#endif 25#endif
25 26
26#ifndef EX_LD 27#ifndef EX_LD
27#define EX_LD(x) x 28#define EX_LD(x,y) x
28#endif 29#endif
29#ifndef EX_LD_FP 30#ifndef EX_LD_FP
30#define EX_LD_FP(x) x 31#define EX_LD_FP(x,y) x
31#endif 32#endif
32 33
33#ifndef EX_ST 34#ifndef EX_ST
34#define EX_ST(x) x 35#define EX_ST(x,y) x
35#endif 36#endif
36#ifndef EX_ST_FP 37#ifndef EX_ST_FP
37#define EX_ST_FP(x) x 38#define EX_ST_FP(x,y) x
38#endif
39
40#ifndef EX_RETVAL
41#define EX_RETVAL(x) x
42#endif 39#endif
43 40
44#ifndef LOAD 41#ifndef LOAD
@@ -79,53 +76,169 @@
79 faligndata %f7, %f8, %f60; \ 76 faligndata %f7, %f8, %f60; \
80 faligndata %f8, %f9, %f62; 77 faligndata %f8, %f9, %f62;
81 78
82#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \ 79#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, jmptgt) \
83 EX_LD_FP(LOAD_BLK(%src, %fdest)); \ 80 EX_LD_FP(LOAD_BLK(%src, %fdest), U1_gs_80_fp); \
84 EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ 81 EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_80_fp); \
85 add %src, 0x40, %src; \ 82 add %src, 0x40, %src; \
86 subcc %len, 0x40, %len; \ 83 subcc %GLOBAL_SPARE, 0x40, %GLOBAL_SPARE; \
87 be,pn %xcc, jmptgt; \ 84 be,pn %xcc, jmptgt; \
88 add %dest, 0x40, %dest; \ 85 add %dest, 0x40, %dest; \
89 86
90#define LOOP_CHUNK1(src, dest, len, branch_dest) \ 87#define LOOP_CHUNK1(src, dest, branch_dest) \
91 MAIN_LOOP_CHUNK(src, dest, f0, f48, len, branch_dest) 88 MAIN_LOOP_CHUNK(src, dest, f0, f48, branch_dest)
92#define LOOP_CHUNK2(src, dest, len, branch_dest) \ 89#define LOOP_CHUNK2(src, dest, branch_dest) \
93 MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest) 90 MAIN_LOOP_CHUNK(src, dest, f16, f48, branch_dest)
94#define LOOP_CHUNK3(src, dest, len, branch_dest) \ 91#define LOOP_CHUNK3(src, dest, branch_dest) \
95 MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest) 92 MAIN_LOOP_CHUNK(src, dest, f32, f48, branch_dest)
96 93
97#define DO_SYNC membar #Sync; 94#define DO_SYNC membar #Sync;
98#define STORE_SYNC(dest, fsrc) \ 95#define STORE_SYNC(dest, fsrc) \
99 EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ 96 EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_80_fp); \
100 add %dest, 0x40, %dest; \ 97 add %dest, 0x40, %dest; \
101 DO_SYNC 98 DO_SYNC
102 99
103#define STORE_JUMP(dest, fsrc, target) \ 100#define STORE_JUMP(dest, fsrc, target) \
104 EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ 101 EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_40_fp); \
105 add %dest, 0x40, %dest; \ 102 add %dest, 0x40, %dest; \
106 ba,pt %xcc, target; \ 103 ba,pt %xcc, target; \
107 nop; 104 nop;
108 105
109#define FINISH_VISCHUNK(dest, f0, f1, left) \ 106#define FINISH_VISCHUNK(dest, f0, f1) \
110 subcc %left, 8, %left;\ 107 subcc %g3, 8, %g3; \
111 bl,pn %xcc, 95f; \ 108 bl,pn %xcc, 95f; \
112 faligndata %f0, %f1, %f48; \ 109 faligndata %f0, %f1, %f48; \
113 EX_ST_FP(STORE(std, %f48, %dest)); \ 110 EX_ST_FP(STORE(std, %f48, %dest), U1_g3_8_fp); \
114 add %dest, 8, %dest; 111 add %dest, 8, %dest;
115 112
116#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \ 113#define UNEVEN_VISCHUNK_LAST(dest, f0, f1) \
117 subcc %left, 8, %left; \ 114 subcc %g3, 8, %g3; \
118 bl,pn %xcc, 95f; \ 115 bl,pn %xcc, 95f; \
119 fsrc2 %f0, %f1; 116 fsrc2 %f0, %f1;
120 117
121#define UNEVEN_VISCHUNK(dest, f0, f1, left) \ 118#define UNEVEN_VISCHUNK(dest, f0, f1) \
122 UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \ 119 UNEVEN_VISCHUNK_LAST(dest, f0, f1) \
123 ba,a,pt %xcc, 93f; 120 ba,a,pt %xcc, 93f;
124 121
125 .register %g2,#scratch 122 .register %g2,#scratch
126 .register %g3,#scratch 123 .register %g3,#scratch
127 124
128 .text 125 .text
126#ifndef EX_RETVAL
127#define EX_RETVAL(x) x
128ENTRY(U1_g1_1_fp)
129 VISExitHalf
130 add %g1, 1, %g1
131 add %g1, %g2, %g1
132 retl
133 add %g1, %o2, %o0
134ENDPROC(U1_g1_1_fp)
135ENTRY(U1_g2_0_fp)
136 VISExitHalf
137 retl
138 add %g2, %o2, %o0
139ENDPROC(U1_g2_0_fp)
140ENTRY(U1_g2_8_fp)
141 VISExitHalf
142 add %g2, 8, %g2
143 retl
144 add %g2, %o2, %o0
145ENDPROC(U1_g2_8_fp)
146ENTRY(U1_gs_0_fp)
147 VISExitHalf
148 add %GLOBAL_SPARE, %g3, %o0
149 retl
150 add %o0, %o2, %o0
151ENDPROC(U1_gs_0_fp)
152ENTRY(U1_gs_80_fp)
153 VISExitHalf
154 add %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE
155 add %GLOBAL_SPARE, %g3, %o0
156 retl
157 add %o0, %o2, %o0
158ENDPROC(U1_gs_80_fp)
159ENTRY(U1_gs_40_fp)
160 VISExitHalf
161 add %GLOBAL_SPARE, 0x40, %GLOBAL_SPARE
162 add %GLOBAL_SPARE, %g3, %o0
163 retl
164 add %o0, %o2, %o0
165ENDPROC(U1_gs_40_fp)
166ENTRY(U1_g3_0_fp)
167 VISExitHalf
168 retl
169 add %g3, %o2, %o0
170ENDPROC(U1_g3_0_fp)
171ENTRY(U1_g3_8_fp)
172 VISExitHalf
173 add %g3, 8, %g3
174 retl
175 add %g3, %o2, %o0
176ENDPROC(U1_g3_8_fp)
177ENTRY(U1_o2_0_fp)
178 VISExitHalf
179 retl
180 mov %o2, %o0
181ENDPROC(U1_o2_0_fp)
182ENTRY(U1_o2_1_fp)
183 VISExitHalf
184 retl
185 add %o2, 1, %o0
186ENDPROC(U1_o2_1_fp)
187ENTRY(U1_gs_0)
188 VISExitHalf
189 retl
190 add %GLOBAL_SPARE, %o2, %o0
191ENDPROC(U1_gs_0)
192ENTRY(U1_gs_8)
193 VISExitHalf
194 add %GLOBAL_SPARE, %o2, %GLOBAL_SPARE
195 retl
196 add %GLOBAL_SPARE, 0x8, %o0
197ENDPROC(U1_gs_8)
198ENTRY(U1_gs_10)
199 VISExitHalf
200 add %GLOBAL_SPARE, %o2, %GLOBAL_SPARE
201 retl
202 add %GLOBAL_SPARE, 0x10, %o0
203ENDPROC(U1_gs_10)
204ENTRY(U1_o2_0)
205 retl
206 mov %o2, %o0
207ENDPROC(U1_o2_0)
208ENTRY(U1_o2_8)
209 retl
210 add %o2, 8, %o0
211ENDPROC(U1_o2_8)
212ENTRY(U1_o2_4)
213 retl
214 add %o2, 4, %o0
215ENDPROC(U1_o2_4)
216ENTRY(U1_o2_1)
217 retl
218 add %o2, 1, %o0
219ENDPROC(U1_o2_1)
220ENTRY(U1_g1_0)
221 retl
222 add %g1, %o2, %o0
223ENDPROC(U1_g1_0)
224ENTRY(U1_g1_1)
225 add %g1, 1, %g1
226 retl
227 add %g1, %o2, %o0
228ENDPROC(U1_g1_1)
229ENTRY(U1_gs_0_o2_adj)
230 and %o2, 7, %o2
231 retl
232 add %GLOBAL_SPARE, %o2, %o0
233ENDPROC(U1_gs_0_o2_adj)
234ENTRY(U1_gs_8_o2_adj)
235 and %o2, 7, %o2
236 add %GLOBAL_SPARE, 8, %GLOBAL_SPARE
237 retl
238 add %GLOBAL_SPARE, %o2, %o0
239ENDPROC(U1_gs_8_o2_adj)
240#endif
241
129 .align 64 242 .align 64
130 243
131 .globl FUNC_NAME 244 .globl FUNC_NAME
@@ -167,8 +280,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
167 and %g2, 0x38, %g2 280 and %g2, 0x38, %g2
168 281
1691: subcc %g1, 0x1, %g1 2821: subcc %g1, 0x1, %g1
170 EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3)) 283 EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3), U1_g1_1_fp)
171 EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE)) 284 EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE), U1_g1_1_fp)
172 bgu,pt %XCC, 1b 285 bgu,pt %XCC, 1b
173 add %o1, 0x1, %o1 286 add %o1, 0x1, %o1
174 287
@@ -179,20 +292,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
179 be,pt %icc, 3f 292 be,pt %icc, 3f
180 alignaddr %o1, %g0, %o1 293 alignaddr %o1, %g0, %o1
181 294
182 EX_LD_FP(LOAD(ldd, %o1, %f4)) 295 EX_LD_FP(LOAD(ldd, %o1, %f4), U1_g2_0_fp)
1831: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6)) 2961: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6), U1_g2_0_fp)
184 add %o1, 0x8, %o1 297 add %o1, 0x8, %o1
185 subcc %g2, 0x8, %g2 298 subcc %g2, 0x8, %g2
186 faligndata %f4, %f6, %f0 299 faligndata %f4, %f6, %f0
187 EX_ST_FP(STORE(std, %f0, %o0)) 300 EX_ST_FP(STORE(std, %f0, %o0), U1_g2_8_fp)
188 be,pn %icc, 3f 301 be,pn %icc, 3f
189 add %o0, 0x8, %o0 302 add %o0, 0x8, %o0
190 303
191 EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4)) 304 EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4), U1_g2_0_fp)
192 add %o1, 0x8, %o1 305 add %o1, 0x8, %o1
193 subcc %g2, 0x8, %g2 306 subcc %g2, 0x8, %g2
194 faligndata %f6, %f4, %f0 307 faligndata %f6, %f4, %f0
195 EX_ST_FP(STORE(std, %f0, %o0)) 308 EX_ST_FP(STORE(std, %f0, %o0), U1_g2_8_fp)
196 bne,pt %icc, 1b 309 bne,pt %icc, 1b
197 add %o0, 0x8, %o0 310 add %o0, 0x8, %o0
198 311
@@ -215,13 +328,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
215 add %g1, %GLOBAL_SPARE, %g1 328 add %g1, %GLOBAL_SPARE, %g1
216 subcc %o2, %g3, %o2 329 subcc %o2, %g3, %o2
217 330
218 EX_LD_FP(LOAD_BLK(%o1, %f0)) 331 EX_LD_FP(LOAD_BLK(%o1, %f0), U1_gs_0_fp)
219 add %o1, 0x40, %o1 332 add %o1, 0x40, %o1
220 add %g1, %g3, %g1 333 add %g1, %g3, %g1
221 EX_LD_FP(LOAD_BLK(%o1, %f16)) 334 EX_LD_FP(LOAD_BLK(%o1, %f16), U1_gs_0_fp)
222 add %o1, 0x40, %o1 335 add %o1, 0x40, %o1
223 sub %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE 336 sub %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE
224 EX_LD_FP(LOAD_BLK(%o1, %f32)) 337 EX_LD_FP(LOAD_BLK(%o1, %f32), U1_gs_80_fp)
225 add %o1, 0x40, %o1 338 add %o1, 0x40, %o1
226 339
227 /* There are 8 instances of the unrolled loop, 340 /* There are 8 instances of the unrolled loop,
@@ -241,11 +354,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
241 354
242 .align 64 355 .align 64
2431: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) 3561: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16)
244 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 357 LOOP_CHUNK1(o1, o0, 1f)
245 FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) 358 FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
246 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 359 LOOP_CHUNK2(o1, o0, 2f)
247 FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) 360 FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0)
248 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 361 LOOP_CHUNK3(o1, o0, 3f)
249 ba,pt %xcc, 1b+4 362 ba,pt %xcc, 1b+4
250 faligndata %f0, %f2, %f48 363 faligndata %f0, %f2, %f48
2511: FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) 3641: FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
@@ -262,11 +375,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
262 STORE_JUMP(o0, f48, 56f) 375 STORE_JUMP(o0, f48, 56f)
263 376
2641: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) 3771: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18)
265 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 378 LOOP_CHUNK1(o1, o0, 1f)
266 FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) 379 FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
267 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 380 LOOP_CHUNK2(o1, o0, 2f)
268 FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) 381 FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2)
269 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 382 LOOP_CHUNK3(o1, o0, 3f)
270 ba,pt %xcc, 1b+4 383 ba,pt %xcc, 1b+4
271 faligndata %f2, %f4, %f48 384 faligndata %f2, %f4, %f48
2721: FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) 3851: FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
@@ -283,11 +396,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
283 STORE_JUMP(o0, f48, 57f) 396 STORE_JUMP(o0, f48, 57f)
284 397
2851: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) 3981: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20)
286 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 399 LOOP_CHUNK1(o1, o0, 1f)
287 FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) 400 FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
288 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 401 LOOP_CHUNK2(o1, o0, 2f)
289 FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) 402 FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4)
290 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 403 LOOP_CHUNK3(o1, o0, 3f)
291 ba,pt %xcc, 1b+4 404 ba,pt %xcc, 1b+4
292 faligndata %f4, %f6, %f48 405 faligndata %f4, %f6, %f48
2931: FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) 4061: FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
@@ -304,11 +417,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
304 STORE_JUMP(o0, f48, 58f) 417 STORE_JUMP(o0, f48, 58f)
305 418
3061: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) 4191: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22)
307 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 420 LOOP_CHUNK1(o1, o0, 1f)
308 FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) 421 FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
309 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 422 LOOP_CHUNK2(o1, o0, 2f)
310 FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) 423 FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6)
311 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 424 LOOP_CHUNK3(o1, o0, 3f)
312 ba,pt %xcc, 1b+4 425 ba,pt %xcc, 1b+4
313 faligndata %f6, %f8, %f48 426 faligndata %f6, %f8, %f48
3141: FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) 4271: FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
@@ -325,11 +438,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
325 STORE_JUMP(o0, f48, 59f) 438 STORE_JUMP(o0, f48, 59f)
326 439
3271: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) 4401: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24)
328 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 441 LOOP_CHUNK1(o1, o0, 1f)
329 FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) 442 FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
330 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 443 LOOP_CHUNK2(o1, o0, 2f)
331 FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) 444 FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8)
332 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 445 LOOP_CHUNK3(o1, o0, 3f)
333 ba,pt %xcc, 1b+4 446 ba,pt %xcc, 1b+4
334 faligndata %f8, %f10, %f48 447 faligndata %f8, %f10, %f48
3351: FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) 4481: FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
@@ -346,11 +459,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
346 STORE_JUMP(o0, f48, 60f) 459 STORE_JUMP(o0, f48, 60f)
347 460
3481: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) 4611: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26)
349 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 462 LOOP_CHUNK1(o1, o0, 1f)
350 FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) 463 FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
351 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 464 LOOP_CHUNK2(o1, o0, 2f)
352 FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) 465 FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10)
353 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 466 LOOP_CHUNK3(o1, o0, 3f)
354 ba,pt %xcc, 1b+4 467 ba,pt %xcc, 1b+4
355 faligndata %f10, %f12, %f48 468 faligndata %f10, %f12, %f48
3561: FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) 4691: FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
@@ -367,11 +480,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
367 STORE_JUMP(o0, f48, 61f) 480 STORE_JUMP(o0, f48, 61f)
368 481
3691: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) 4821: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28)
370 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 483 LOOP_CHUNK1(o1, o0, 1f)
371 FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) 484 FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
372 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 485 LOOP_CHUNK2(o1, o0, 2f)
373 FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) 486 FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12)
374 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 487 LOOP_CHUNK3(o1, o0, 3f)
375 ba,pt %xcc, 1b+4 488 ba,pt %xcc, 1b+4
376 faligndata %f12, %f14, %f48 489 faligndata %f12, %f14, %f48
3771: FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) 4901: FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
@@ -388,11 +501,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
388 STORE_JUMP(o0, f48, 62f) 501 STORE_JUMP(o0, f48, 62f)
389 502
3901: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) 5031: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30)
391 LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f) 504 LOOP_CHUNK1(o1, o0, 1f)
392 FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) 505 FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
393 LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f) 506 LOOP_CHUNK2(o1, o0, 2f)
394 FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) 507 FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14)
395 LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f) 508 LOOP_CHUNK3(o1, o0, 3f)
396 ba,pt %xcc, 1b+4 509 ba,pt %xcc, 1b+4
397 faligndata %f14, %f16, %f48 510 faligndata %f14, %f16, %f48
3981: FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) 5111: FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
@@ -408,53 +521,53 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
408 FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) 521 FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
409 STORE_JUMP(o0, f48, 63f) 522 STORE_JUMP(o0, f48, 63f)
410 523
41140: FINISH_VISCHUNK(o0, f0, f2, g3) 52440: FINISH_VISCHUNK(o0, f0, f2)
41241: FINISH_VISCHUNK(o0, f2, f4, g3) 52541: FINISH_VISCHUNK(o0, f2, f4)
41342: FINISH_VISCHUNK(o0, f4, f6, g3) 52642: FINISH_VISCHUNK(o0, f4, f6)
41443: FINISH_VISCHUNK(o0, f6, f8, g3) 52743: FINISH_VISCHUNK(o0, f6, f8)
41544: FINISH_VISCHUNK(o0, f8, f10, g3) 52844: FINISH_VISCHUNK(o0, f8, f10)
41645: FINISH_VISCHUNK(o0, f10, f12, g3) 52945: FINISH_VISCHUNK(o0, f10, f12)
41746: FINISH_VISCHUNK(o0, f12, f14, g3) 53046: FINISH_VISCHUNK(o0, f12, f14)
41847: UNEVEN_VISCHUNK(o0, f14, f0, g3) 53147: UNEVEN_VISCHUNK(o0, f14, f0)
41948: FINISH_VISCHUNK(o0, f16, f18, g3) 53248: FINISH_VISCHUNK(o0, f16, f18)
42049: FINISH_VISCHUNK(o0, f18, f20, g3) 53349: FINISH_VISCHUNK(o0, f18, f20)
42150: FINISH_VISCHUNK(o0, f20, f22, g3) 53450: FINISH_VISCHUNK(o0, f20, f22)
42251: FINISH_VISCHUNK(o0, f22, f24, g3) 53551: FINISH_VISCHUNK(o0, f22, f24)
42352: FINISH_VISCHUNK(o0, f24, f26, g3) 53652: FINISH_VISCHUNK(o0, f24, f26)
42453: FINISH_VISCHUNK(o0, f26, f28, g3) 53753: FINISH_VISCHUNK(o0, f26, f28)
42554: FINISH_VISCHUNK(o0, f28, f30, g3) 53854: FINISH_VISCHUNK(o0, f28, f30)
42655: UNEVEN_VISCHUNK(o0, f30, f0, g3) 53955: UNEVEN_VISCHUNK(o0, f30, f0)
42756: FINISH_VISCHUNK(o0, f32, f34, g3) 54056: FINISH_VISCHUNK(o0, f32, f34)
42857: FINISH_VISCHUNK(o0, f34, f36, g3) 54157: FINISH_VISCHUNK(o0, f34, f36)
42958: FINISH_VISCHUNK(o0, f36, f38, g3) 54258: FINISH_VISCHUNK(o0, f36, f38)
43059: FINISH_VISCHUNK(o0, f38, f40, g3) 54359: FINISH_VISCHUNK(o0, f38, f40)
43160: FINISH_VISCHUNK(o0, f40, f42, g3) 54460: FINISH_VISCHUNK(o0, f40, f42)
43261: FINISH_VISCHUNK(o0, f42, f44, g3) 54561: FINISH_VISCHUNK(o0, f42, f44)
43362: FINISH_VISCHUNK(o0, f44, f46, g3) 54662: FINISH_VISCHUNK(o0, f44, f46)
43463: UNEVEN_VISCHUNK_LAST(o0, f46, f0, g3) 54763: UNEVEN_VISCHUNK_LAST(o0, f46, f0)
435 548
43693: EX_LD_FP(LOAD(ldd, %o1, %f2)) 54993: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_0_fp)
437 add %o1, 8, %o1 550 add %o1, 8, %o1
438 subcc %g3, 8, %g3 551 subcc %g3, 8, %g3
439 faligndata %f0, %f2, %f8 552 faligndata %f0, %f2, %f8
440 EX_ST_FP(STORE(std, %f8, %o0)) 553 EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
441 bl,pn %xcc, 95f 554 bl,pn %xcc, 95f
442 add %o0, 8, %o0 555 add %o0, 8, %o0
443 EX_LD_FP(LOAD(ldd, %o1, %f0)) 556 EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_0_fp)
444 add %o1, 8, %o1 557 add %o1, 8, %o1
445 subcc %g3, 8, %g3 558 subcc %g3, 8, %g3
446 faligndata %f2, %f0, %f8 559 faligndata %f2, %f0, %f8
447 EX_ST_FP(STORE(std, %f8, %o0)) 560 EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
448 bge,pt %xcc, 93b 561 bge,pt %xcc, 93b
449 add %o0, 8, %o0 562 add %o0, 8, %o0
450 563
45195: brz,pt %o2, 2f 56495: brz,pt %o2, 2f
452 mov %g1, %o1 565 mov %g1, %o1
453 566
4541: EX_LD_FP(LOAD(ldub, %o1, %o3)) 5671: EX_LD_FP(LOAD(ldub, %o1, %o3), U1_o2_0_fp)
455 add %o1, 1, %o1 568 add %o1, 1, %o1
456 subcc %o2, 1, %o2 569 subcc %o2, 1, %o2
457 EX_ST_FP(STORE(stb, %o3, %o0)) 570 EX_ST_FP(STORE(stb, %o3, %o0), U1_o2_1_fp)
458 bne,pt %xcc, 1b 571 bne,pt %xcc, 1b
459 add %o0, 1, %o0 572 add %o0, 1, %o0
460 573
@@ -470,27 +583,27 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
470 583
47172: andn %o2, 0xf, %GLOBAL_SPARE 58472: andn %o2, 0xf, %GLOBAL_SPARE
472 and %o2, 0xf, %o2 585 and %o2, 0xf, %o2
4731: EX_LD(LOAD(ldx, %o1 + 0x00, %o5)) 5861: EX_LD(LOAD(ldx, %o1 + 0x00, %o5), U1_gs_0)
474 EX_LD(LOAD(ldx, %o1 + 0x08, %g1)) 587 EX_LD(LOAD(ldx, %o1 + 0x08, %g1), U1_gs_0)
475 subcc %GLOBAL_SPARE, 0x10, %GLOBAL_SPARE 588 subcc %GLOBAL_SPARE, 0x10, %GLOBAL_SPARE
476 EX_ST(STORE(stx, %o5, %o1 + %o3)) 589 EX_ST(STORE(stx, %o5, %o1 + %o3), U1_gs_10)
477 add %o1, 0x8, %o1 590 add %o1, 0x8, %o1
478 EX_ST(STORE(stx, %g1, %o1 + %o3)) 591 EX_ST(STORE(stx, %g1, %o1 + %o3), U1_gs_8)
479 bgu,pt %XCC, 1b 592 bgu,pt %XCC, 1b
480 add %o1, 0x8, %o1 593 add %o1, 0x8, %o1
48173: andcc %o2, 0x8, %g0 59473: andcc %o2, 0x8, %g0
482 be,pt %XCC, 1f 595 be,pt %XCC, 1f
483 nop 596 nop
484 EX_LD(LOAD(ldx, %o1, %o5)) 597 EX_LD(LOAD(ldx, %o1, %o5), U1_o2_0)
485 sub %o2, 0x8, %o2 598 sub %o2, 0x8, %o2
486 EX_ST(STORE(stx, %o5, %o1 + %o3)) 599 EX_ST(STORE(stx, %o5, %o1 + %o3), U1_o2_8)
487 add %o1, 0x8, %o1 600 add %o1, 0x8, %o1
4881: andcc %o2, 0x4, %g0 6011: andcc %o2, 0x4, %g0
489 be,pt %XCC, 1f 602 be,pt %XCC, 1f
490 nop 603 nop
491 EX_LD(LOAD(lduw, %o1, %o5)) 604 EX_LD(LOAD(lduw, %o1, %o5), U1_o2_0)
492 sub %o2, 0x4, %o2 605 sub %o2, 0x4, %o2
493 EX_ST(STORE(stw, %o5, %o1 + %o3)) 606 EX_ST(STORE(stw, %o5, %o1 + %o3), U1_o2_4)
494 add %o1, 0x4, %o1 607 add %o1, 0x4, %o1
4951: cmp %o2, 0 6081: cmp %o2, 0
496 be,pt %XCC, 85f 609 be,pt %XCC, 85f
@@ -504,9 +617,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
504 sub %g0, %g1, %g1 617 sub %g0, %g1, %g1
505 sub %o2, %g1, %o2 618 sub %o2, %g1, %o2
506 619
5071: EX_LD(LOAD(ldub, %o1, %o5)) 6201: EX_LD(LOAD(ldub, %o1, %o5), U1_g1_0)
508 subcc %g1, 1, %g1 621 subcc %g1, 1, %g1
509 EX_ST(STORE(stb, %o5, %o1 + %o3)) 622 EX_ST(STORE(stb, %o5, %o1 + %o3), U1_g1_1)
510 bgu,pt %icc, 1b 623 bgu,pt %icc, 1b
511 add %o1, 1, %o1 624 add %o1, 1, %o1
512 625
@@ -522,16 +635,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
522 635
5238: mov 64, %o3 6368: mov 64, %o3
524 andn %o1, 0x7, %o1 637 andn %o1, 0x7, %o1
525 EX_LD(LOAD(ldx, %o1, %g2)) 638 EX_LD(LOAD(ldx, %o1, %g2), U1_o2_0)
526 sub %o3, %g1, %o3 639 sub %o3, %g1, %o3
527 andn %o2, 0x7, %GLOBAL_SPARE 640 andn %o2, 0x7, %GLOBAL_SPARE
528 sllx %g2, %g1, %g2 641 sllx %g2, %g1, %g2
5291: EX_LD(LOAD(ldx, %o1 + 0x8, %g3)) 6421: EX_LD(LOAD(ldx, %o1 + 0x8, %g3), U1_gs_0_o2_adj)
530 subcc %GLOBAL_SPARE, 0x8, %GLOBAL_SPARE 643 subcc %GLOBAL_SPARE, 0x8, %GLOBAL_SPARE
531 add %o1, 0x8, %o1 644 add %o1, 0x8, %o1
532 srlx %g3, %o3, %o5 645 srlx %g3, %o3, %o5
533 or %o5, %g2, %o5 646 or %o5, %g2, %o5
534 EX_ST(STORE(stx, %o5, %o0)) 647 EX_ST(STORE(stx, %o5, %o0), U1_gs_8_o2_adj)
535 add %o0, 0x8, %o0 648 add %o0, 0x8, %o0
536 bgu,pt %icc, 1b 649 bgu,pt %icc, 1b
537 sllx %g3, %g1, %g2 650 sllx %g3, %g1, %g2
@@ -549,9 +662,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
549 bne,pn %XCC, 90f 662 bne,pn %XCC, 90f
550 sub %o0, %o1, %o3 663 sub %o0, %o1, %o3
551 664
5521: EX_LD(LOAD(lduw, %o1, %g1)) 6651: EX_LD(LOAD(lduw, %o1, %g1), U1_o2_0)
553 subcc %o2, 4, %o2 666 subcc %o2, 4, %o2
554 EX_ST(STORE(stw, %g1, %o1 + %o3)) 667 EX_ST(STORE(stw, %g1, %o1 + %o3), U1_o2_4)
555 bgu,pt %XCC, 1b 668 bgu,pt %XCC, 1b
556 add %o1, 4, %o1 669 add %o1, 4, %o1
557 670
@@ -559,9 +672,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
559 mov EX_RETVAL(%o4), %o0 672 mov EX_RETVAL(%o4), %o0
560 673
561 .align 32 674 .align 32
56290: EX_LD(LOAD(ldub, %o1, %g1)) 67590: EX_LD(LOAD(ldub, %o1, %g1), U1_o2_0)
563 subcc %o2, 1, %o2 676 subcc %o2, 1, %o2
564 EX_ST(STORE(stb, %g1, %o1 + %o3)) 677 EX_ST(STORE(stb, %g1, %o1 + %o3), U1_o2_1)
565 bgu,pt %XCC, 90b 678 bgu,pt %XCC, 90b
566 add %o1, 1, %o1 679 add %o1, 1, %o1
567 retl 680 retl
diff --git a/arch/sparc/lib/U3copy_from_user.S b/arch/sparc/lib/U3copy_from_user.S
index 88ad73d86fe4..db73010a1af8 100644
--- a/arch/sparc/lib/U3copy_from_user.S
+++ b/arch/sparc/lib/U3copy_from_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#define EX_LD(x) \ 6#define EX_LD(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_LD_FP(x) \ 14#define EX_LD_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/U3copy_to_user.S b/arch/sparc/lib/U3copy_to_user.S
index 845139d75537..c4ee858e352a 100644
--- a/arch/sparc/lib/U3copy_to_user.S
+++ b/arch/sparc/lib/U3copy_to_user.S
@@ -3,19 +3,19 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#define EX_ST(x) \ 6#define EX_ST(x,y) \
798: x; \ 798: x; \
8 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
9 .align 4; \ 9 .align 4; \
10 .word 98b, __retl_one; \ 10 .word 98b, y; \
11 .text; \ 11 .text; \
12 .align 4; 12 .align 4;
13 13
14#define EX_ST_FP(x) \ 14#define EX_ST_FP(x,y) \
1598: x; \ 1598: x; \
16 .section __ex_table,"a";\ 16 .section __ex_table,"a";\
17 .align 4; \ 17 .align 4; \
18 .word 98b, __retl_one_fp;\ 18 .word 98b, y##_fp; \
19 .text; \ 19 .text; \
20 .align 4; 20 .align 4;
21 21
diff --git a/arch/sparc/lib/U3memcpy.S b/arch/sparc/lib/U3memcpy.S
index 491ee69e4995..54f98706b03b 100644
--- a/arch/sparc/lib/U3memcpy.S
+++ b/arch/sparc/lib/U3memcpy.S
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/linkage.h>
7#include <asm/visasm.h> 8#include <asm/visasm.h>
8#include <asm/asi.h> 9#include <asm/asi.h>
9#define GLOBAL_SPARE %g7 10#define GLOBAL_SPARE %g7
@@ -22,21 +23,17 @@
22#endif 23#endif
23 24
24#ifndef EX_LD 25#ifndef EX_LD
25#define EX_LD(x) x 26#define EX_LD(x,y) x
26#endif 27#endif
27#ifndef EX_LD_FP 28#ifndef EX_LD_FP
28#define EX_LD_FP(x) x 29#define EX_LD_FP(x,y) x
29#endif 30#endif
30 31
31#ifndef EX_ST 32#ifndef EX_ST
32#define EX_ST(x) x 33#define EX_ST(x,y) x
33#endif 34#endif
34#ifndef EX_ST_FP 35#ifndef EX_ST_FP
35#define EX_ST_FP(x) x 36#define EX_ST_FP(x,y) x
36#endif
37
38#ifndef EX_RETVAL
39#define EX_RETVAL(x) x
40#endif 37#endif
41 38
42#ifndef LOAD 39#ifndef LOAD
@@ -77,6 +74,87 @@
77 */ 74 */
78 75
79 .text 76 .text
77#ifndef EX_RETVAL
78#define EX_RETVAL(x) x
79__restore_fp:
80 VISExitHalf
81 retl
82 nop
83ENTRY(U3_retl_o2_plus_g2_plus_g1_plus_1_fp)
84 add %g1, 1, %g1
85 add %g2, %g1, %g2
86 ba,pt %xcc, __restore_fp
87 add %o2, %g2, %o0
88ENDPROC(U3_retl_o2_plus_g2_plus_g1_plus_1_fp)
89ENTRY(U3_retl_o2_plus_g2_fp)
90 ba,pt %xcc, __restore_fp
91 add %o2, %g2, %o0
92ENDPROC(U3_retl_o2_plus_g2_fp)
93ENTRY(U3_retl_o2_plus_g2_plus_8_fp)
94 add %g2, 8, %g2
95 ba,pt %xcc, __restore_fp
96 add %o2, %g2, %o0
97ENDPROC(U3_retl_o2_plus_g2_plus_8_fp)
98ENTRY(U3_retl_o2)
99 retl
100 mov %o2, %o0
101ENDPROC(U3_retl_o2)
102ENTRY(U3_retl_o2_plus_1)
103 retl
104 add %o2, 1, %o0
105ENDPROC(U3_retl_o2_plus_1)
106ENTRY(U3_retl_o2_plus_4)
107 retl
108 add %o2, 4, %o0
109ENDPROC(U3_retl_o2_plus_4)
110ENTRY(U3_retl_o2_plus_8)
111 retl
112 add %o2, 8, %o0
113ENDPROC(U3_retl_o2_plus_8)
114ENTRY(U3_retl_o2_plus_g1_plus_1)
115 add %g1, 1, %g1
116 retl
117 add %o2, %g1, %o0
118ENDPROC(U3_retl_o2_plus_g1_plus_1)
119ENTRY(U3_retl_o2_fp)
120 ba,pt %xcc, __restore_fp
121 mov %o2, %o0
122ENDPROC(U3_retl_o2_fp)
123ENTRY(U3_retl_o2_plus_o3_sll_6_plus_0x80_fp)
124 sll %o3, 6, %o3
125 add %o3, 0x80, %o3
126 ba,pt %xcc, __restore_fp
127 add %o2, %o3, %o0
128ENDPROC(U3_retl_o2_plus_o3_sll_6_plus_0x80_fp)
129ENTRY(U3_retl_o2_plus_o3_sll_6_plus_0x40_fp)
130 sll %o3, 6, %o3
131 add %o3, 0x40, %o3
132 ba,pt %xcc, __restore_fp
133 add %o2, %o3, %o0
134ENDPROC(U3_retl_o2_plus_o3_sll_6_plus_0x40_fp)
135ENTRY(U3_retl_o2_plus_GS_plus_0x10)
136 add GLOBAL_SPARE, 0x10, GLOBAL_SPARE
137 retl
138 add %o2, GLOBAL_SPARE, %o0
139ENDPROC(U3_retl_o2_plus_GS_plus_0x10)
140ENTRY(U3_retl_o2_plus_GS_plus_0x08)
141 add GLOBAL_SPARE, 0x08, GLOBAL_SPARE
142 retl
143 add %o2, GLOBAL_SPARE, %o0
144ENDPROC(U3_retl_o2_plus_GS_plus_0x08)
145ENTRY(U3_retl_o2_and_7_plus_GS)
146 and %o2, 7, %o2
147 retl
148 add %o2, GLOBAL_SPARE, %o2
149ENDPROC(U3_retl_o2_and_7_plus_GS)
150ENTRY(U3_retl_o2_and_7_plus_GS_plus_8)
151 add GLOBAL_SPARE, 8, GLOBAL_SPARE
152 and %o2, 7, %o2
153 retl
154 add %o2, GLOBAL_SPARE, %o2
155ENDPROC(U3_retl_o2_and_7_plus_GS_plus_8)
156#endif
157
80 .align 64 158 .align 64
81 159
82 /* The cheetah's flexible spine, oversized liver, enlarged heart, 160 /* The cheetah's flexible spine, oversized liver, enlarged heart,
@@ -126,8 +204,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
126 and %g2, 0x38, %g2 204 and %g2, 0x38, %g2
127 205
1281: subcc %g1, 0x1, %g1 2061: subcc %g1, 0x1, %g1
129 EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3)) 207 EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3), U3_retl_o2_plus_g2_plus_g1_plus_1)
130 EX_ST_FP(STORE(stb, %o3, %o1 + GLOBAL_SPARE)) 208 EX_ST_FP(STORE(stb, %o3, %o1 + GLOBAL_SPARE), U3_retl_o2_plus_g2_plus_g1_plus_1)
131 bgu,pt %XCC, 1b 209 bgu,pt %XCC, 1b
132 add %o1, 0x1, %o1 210 add %o1, 0x1, %o1
133 211
@@ -138,20 +216,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
138 be,pt %icc, 3f 216 be,pt %icc, 3f
139 alignaddr %o1, %g0, %o1 217 alignaddr %o1, %g0, %o1
140 218
141 EX_LD_FP(LOAD(ldd, %o1, %f4)) 219 EX_LD_FP(LOAD(ldd, %o1, %f4), U3_retl_o2_plus_g2)
1421: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6)) 2201: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6), U3_retl_o2_plus_g2)
143 add %o1, 0x8, %o1 221 add %o1, 0x8, %o1
144 subcc %g2, 0x8, %g2 222 subcc %g2, 0x8, %g2
145 faligndata %f4, %f6, %f0 223 faligndata %f4, %f6, %f0
146 EX_ST_FP(STORE(std, %f0, %o0)) 224 EX_ST_FP(STORE(std, %f0, %o0), U3_retl_o2_plus_g2_plus_8)
147 be,pn %icc, 3f 225 be,pn %icc, 3f
148 add %o0, 0x8, %o0 226 add %o0, 0x8, %o0
149 227
150 EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4)) 228 EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4), U3_retl_o2_plus_g2)
151 add %o1, 0x8, %o1 229 add %o1, 0x8, %o1
152 subcc %g2, 0x8, %g2 230 subcc %g2, 0x8, %g2
153 faligndata %f6, %f4, %f2 231 faligndata %f6, %f4, %f2
154 EX_ST_FP(STORE(std, %f2, %o0)) 232 EX_ST_FP(STORE(std, %f2, %o0), U3_retl_o2_plus_g2_plus_8)
155 bne,pt %icc, 1b 233 bne,pt %icc, 1b
156 add %o0, 0x8, %o0 234 add %o0, 0x8, %o0
157 235
@@ -161,25 +239,25 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
161 LOAD(prefetch, %o1 + 0x080, #one_read) 239 LOAD(prefetch, %o1 + 0x080, #one_read)
162 LOAD(prefetch, %o1 + 0x0c0, #one_read) 240 LOAD(prefetch, %o1 + 0x0c0, #one_read)
163 LOAD(prefetch, %o1 + 0x100, #one_read) 241 LOAD(prefetch, %o1 + 0x100, #one_read)
164 EX_LD_FP(LOAD(ldd, %o1 + 0x000, %f0)) 242 EX_LD_FP(LOAD(ldd, %o1 + 0x000, %f0), U3_retl_o2)
165 LOAD(prefetch, %o1 + 0x140, #one_read) 243 LOAD(prefetch, %o1 + 0x140, #one_read)
166 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) 244 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2)
167 LOAD(prefetch, %o1 + 0x180, #one_read) 245 LOAD(prefetch, %o1 + 0x180, #one_read)
168 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) 246 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2)
169 LOAD(prefetch, %o1 + 0x1c0, #one_read) 247 LOAD(prefetch, %o1 + 0x1c0, #one_read)
170 faligndata %f0, %f2, %f16 248 faligndata %f0, %f2, %f16
171 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) 249 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2)
172 faligndata %f2, %f4, %f18 250 faligndata %f2, %f4, %f18
173 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) 251 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2)
174 faligndata %f4, %f6, %f20 252 faligndata %f4, %f6, %f20
175 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) 253 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2)
176 faligndata %f6, %f8, %f22 254 faligndata %f6, %f8, %f22
177 255
178 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) 256 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2)
179 faligndata %f8, %f10, %f24 257 faligndata %f8, %f10, %f24
180 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) 258 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2)
181 faligndata %f10, %f12, %f26 259 faligndata %f10, %f12, %f26
182 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) 260 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2)
183 261
184 subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE 262 subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE
185 add %o1, 0x40, %o1 263 add %o1, 0x40, %o1
@@ -190,26 +268,26 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
190 268
191 .align 64 269 .align 64
1921: 2701:
193 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) 271 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2_plus_o3_sll_6_plus_0x80)
194 faligndata %f12, %f14, %f28 272 faligndata %f12, %f14, %f28
195 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) 273 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2_plus_o3_sll_6_plus_0x80)
196 faligndata %f14, %f0, %f30 274 faligndata %f14, %f0, %f30
197 EX_ST_FP(STORE_BLK(%f16, %o0)) 275 EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
198 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) 276 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2_plus_o3_sll_6_plus_0x40)
199 faligndata %f0, %f2, %f16 277 faligndata %f0, %f2, %f16
200 add %o0, 0x40, %o0 278 add %o0, 0x40, %o0
201 279
202 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) 280 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2_plus_o3_sll_6_plus_0x40)
203 faligndata %f2, %f4, %f18 281 faligndata %f2, %f4, %f18
204 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) 282 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2_plus_o3_sll_6_plus_0x40)
205 faligndata %f4, %f6, %f20 283 faligndata %f4, %f6, %f20
206 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) 284 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2_plus_o3_sll_6_plus_0x40)
207 subcc %o3, 0x01, %o3 285 subcc %o3, 0x01, %o3
208 faligndata %f6, %f8, %f22 286 faligndata %f6, %f8, %f22
209 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) 287 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2_plus_o3_sll_6_plus_0x80)
210 288
211 faligndata %f8, %f10, %f24 289 faligndata %f8, %f10, %f24
212 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) 290 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
213 LOAD(prefetch, %o1 + 0x1c0, #one_read) 291 LOAD(prefetch, %o1 + 0x1c0, #one_read)
214 faligndata %f10, %f12, %f26 292 faligndata %f10, %f12, %f26
215 bg,pt %XCC, 1b 293 bg,pt %XCC, 1b
@@ -217,29 +295,29 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
217 295
218 /* Finally we copy the last full 64-byte block. */ 296 /* Finally we copy the last full 64-byte block. */
2192: 2972:
220 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) 298 EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2_plus_o3_sll_6_plus_0x80)
221 faligndata %f12, %f14, %f28 299 faligndata %f12, %f14, %f28
222 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) 300 EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2_plus_o3_sll_6_plus_0x80)
223 faligndata %f14, %f0, %f30 301 faligndata %f14, %f0, %f30
224 EX_ST_FP(STORE_BLK(%f16, %o0)) 302 EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
225 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) 303 EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2_plus_o3_sll_6_plus_0x40)
226 faligndata %f0, %f2, %f16 304 faligndata %f0, %f2, %f16
227 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) 305 EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2_plus_o3_sll_6_plus_0x40)
228 faligndata %f2, %f4, %f18 306 faligndata %f2, %f4, %f18
229 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) 307 EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2_plus_o3_sll_6_plus_0x40)
230 faligndata %f4, %f6, %f20 308 faligndata %f4, %f6, %f20
231 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) 309 EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2_plus_o3_sll_6_plus_0x40)
232 faligndata %f6, %f8, %f22 310 faligndata %f6, %f8, %f22
233 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) 311 EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2_plus_o3_sll_6_plus_0x40)
234 faligndata %f8, %f10, %f24 312 faligndata %f8, %f10, %f24
235 cmp %g1, 0 313 cmp %g1, 0
236 be,pt %XCC, 1f 314 be,pt %XCC, 1f
237 add %o0, 0x40, %o0 315 add %o0, 0x40, %o0
238 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) 316 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2_plus_o3_sll_6_plus_0x40)
2391: faligndata %f10, %f12, %f26 3171: faligndata %f10, %f12, %f26
240 faligndata %f12, %f14, %f28 318 faligndata %f12, %f14, %f28
241 faligndata %f14, %f0, %f30 319 faligndata %f14, %f0, %f30
242 EX_ST_FP(STORE_BLK(%f16, %o0)) 320 EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x40)
243 add %o0, 0x40, %o0 321 add %o0, 0x40, %o0
244 add %o1, 0x40, %o1 322 add %o1, 0x40, %o1
245 membar #Sync 323 membar #Sync
@@ -259,20 +337,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
259 337
260 sub %o2, %g2, %o2 338 sub %o2, %g2, %o2
261 be,a,pt %XCC, 1f 339 be,a,pt %XCC, 1f
262 EX_LD_FP(LOAD(ldd, %o1 + 0x00, %f0)) 340 EX_LD_FP(LOAD(ldd, %o1 + 0x00, %f0), U3_retl_o2_plus_g2)
263 341
2641: EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f2)) 3421: EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f2), U3_retl_o2_plus_g2)
265 add %o1, 0x8, %o1 343 add %o1, 0x8, %o1
266 subcc %g2, 0x8, %g2 344 subcc %g2, 0x8, %g2
267 faligndata %f0, %f2, %f8 345 faligndata %f0, %f2, %f8
268 EX_ST_FP(STORE(std, %f8, %o0)) 346 EX_ST_FP(STORE(std, %f8, %o0), U3_retl_o2_plus_g2_plus_8)
269 be,pn %XCC, 2f 347 be,pn %XCC, 2f
270 add %o0, 0x8, %o0 348 add %o0, 0x8, %o0
271 EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f0)) 349 EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f0), U3_retl_o2_plus_g2)
272 add %o1, 0x8, %o1 350 add %o1, 0x8, %o1
273 subcc %g2, 0x8, %g2 351 subcc %g2, 0x8, %g2
274 faligndata %f2, %f0, %f8 352 faligndata %f2, %f0, %f8
275 EX_ST_FP(STORE(std, %f8, %o0)) 353 EX_ST_FP(STORE(std, %f8, %o0), U3_retl_o2_plus_g2_plus_8)
276 bne,pn %XCC, 1b 354 bne,pn %XCC, 1b
277 add %o0, 0x8, %o0 355 add %o0, 0x8, %o0
278 356
@@ -292,30 +370,33 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
292 andcc %o2, 0x8, %g0 370 andcc %o2, 0x8, %g0
293 be,pt %icc, 1f 371 be,pt %icc, 1f
294 nop 372 nop
295 EX_LD(LOAD(ldx, %o1, %o5)) 373 EX_LD(LOAD(ldx, %o1, %o5), U3_retl_o2)
296 EX_ST(STORE(stx, %o5, %o1 + %o3)) 374 EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2)
297 add %o1, 0x8, %o1 375 add %o1, 0x8, %o1
376 sub %o2, 8, %o2
298 377
2991: andcc %o2, 0x4, %g0 3781: andcc %o2, 0x4, %g0
300 be,pt %icc, 1f 379 be,pt %icc, 1f
301 nop 380 nop
302 EX_LD(LOAD(lduw, %o1, %o5)) 381 EX_LD(LOAD(lduw, %o1, %o5), U3_retl_o2)
303 EX_ST(STORE(stw, %o5, %o1 + %o3)) 382 EX_ST(STORE(stw, %o5, %o1 + %o3), U3_retl_o2)
304 add %o1, 0x4, %o1 383 add %o1, 0x4, %o1
384 sub %o2, 4, %o2
305 385
3061: andcc %o2, 0x2, %g0 3861: andcc %o2, 0x2, %g0
307 be,pt %icc, 1f 387 be,pt %icc, 1f
308 nop 388 nop
309 EX_LD(LOAD(lduh, %o1, %o5)) 389 EX_LD(LOAD(lduh, %o1, %o5), U3_retl_o2)
310 EX_ST(STORE(sth, %o5, %o1 + %o3)) 390 EX_ST(STORE(sth, %o5, %o1 + %o3), U3_retl_o2)
311 add %o1, 0x2, %o1 391 add %o1, 0x2, %o1
392 sub %o2, 2, %o2
312 393
3131: andcc %o2, 0x1, %g0 3941: andcc %o2, 0x1, %g0
314 be,pt %icc, 85f 395 be,pt %icc, 85f
315 nop 396 nop
316 EX_LD(LOAD(ldub, %o1, %o5)) 397 EX_LD(LOAD(ldub, %o1, %o5), U3_retl_o2)
317 ba,pt %xcc, 85f 398 ba,pt %xcc, 85f
318 EX_ST(STORE(stb, %o5, %o1 + %o3)) 399 EX_ST(STORE(stb, %o5, %o1 + %o3), U3_retl_o2)
319 400
320 .align 64 401 .align 64
32170: /* 16 < len <= 64 */ 40270: /* 16 < len <= 64 */
@@ -326,26 +407,26 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
326 andn %o2, 0xf, GLOBAL_SPARE 407 andn %o2, 0xf, GLOBAL_SPARE
327 and %o2, 0xf, %o2 408 and %o2, 0xf, %o2
3281: subcc GLOBAL_SPARE, 0x10, GLOBAL_SPARE 4091: subcc GLOBAL_SPARE, 0x10, GLOBAL_SPARE
329 EX_LD(LOAD(ldx, %o1 + 0x00, %o5)) 410 EX_LD(LOAD(ldx, %o1 + 0x00, %o5), U3_retl_o2_plus_GS_plus_0x10)
330 EX_LD(LOAD(ldx, %o1 + 0x08, %g1)) 411 EX_LD(LOAD(ldx, %o1 + 0x08, %g1), U3_retl_o2_plus_GS_plus_0x10)
331 EX_ST(STORE(stx, %o5, %o1 + %o3)) 412 EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2_plus_GS_plus_0x10)
332 add %o1, 0x8, %o1 413 add %o1, 0x8, %o1
333 EX_ST(STORE(stx, %g1, %o1 + %o3)) 414 EX_ST(STORE(stx, %g1, %o1 + %o3), U3_retl_o2_plus_GS_plus_0x08)
334 bgu,pt %XCC, 1b 415 bgu,pt %XCC, 1b
335 add %o1, 0x8, %o1 416 add %o1, 0x8, %o1
33673: andcc %o2, 0x8, %g0 41773: andcc %o2, 0x8, %g0
337 be,pt %XCC, 1f 418 be,pt %XCC, 1f
338 nop 419 nop
339 sub %o2, 0x8, %o2 420 sub %o2, 0x8, %o2
340 EX_LD(LOAD(ldx, %o1, %o5)) 421 EX_LD(LOAD(ldx, %o1, %o5), U3_retl_o2_plus_8)
341 EX_ST(STORE(stx, %o5, %o1 + %o3)) 422 EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2_plus_8)
342 add %o1, 0x8, %o1 423 add %o1, 0x8, %o1
3431: andcc %o2, 0x4, %g0 4241: andcc %o2, 0x4, %g0
344 be,pt %XCC, 1f 425 be,pt %XCC, 1f
345 nop 426 nop
346 sub %o2, 0x4, %o2 427 sub %o2, 0x4, %o2
347 EX_LD(LOAD(lduw, %o1, %o5)) 428 EX_LD(LOAD(lduw, %o1, %o5), U3_retl_o2_plus_4)
348 EX_ST(STORE(stw, %o5, %o1 + %o3)) 429 EX_ST(STORE(stw, %o5, %o1 + %o3), U3_retl_o2_plus_4)
349 add %o1, 0x4, %o1 430 add %o1, 0x4, %o1
3501: cmp %o2, 0 4311: cmp %o2, 0
351 be,pt %XCC, 85f 432 be,pt %XCC, 85f
@@ -361,8 +442,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
361 sub %o2, %g1, %o2 442 sub %o2, %g1, %o2
362 443
3631: subcc %g1, 1, %g1 4441: subcc %g1, 1, %g1
364 EX_LD(LOAD(ldub, %o1, %o5)) 445 EX_LD(LOAD(ldub, %o1, %o5), U3_retl_o2_plus_g1_plus_1)
365 EX_ST(STORE(stb, %o5, %o1 + %o3)) 446 EX_ST(STORE(stb, %o5, %o1 + %o3), U3_retl_o2_plus_g1_plus_1)
366 bgu,pt %icc, 1b 447 bgu,pt %icc, 1b
367 add %o1, 1, %o1 448 add %o1, 1, %o1
368 449
@@ -378,16 +459,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
378 459
3798: mov 64, %o3 4608: mov 64, %o3
380 andn %o1, 0x7, %o1 461 andn %o1, 0x7, %o1
381 EX_LD(LOAD(ldx, %o1, %g2)) 462 EX_LD(LOAD(ldx, %o1, %g2), U3_retl_o2)
382 sub %o3, %g1, %o3 463 sub %o3, %g1, %o3
383 andn %o2, 0x7, GLOBAL_SPARE 464 andn %o2, 0x7, GLOBAL_SPARE
384 sllx %g2, %g1, %g2 465 sllx %g2, %g1, %g2
3851: EX_LD(LOAD(ldx, %o1 + 0x8, %g3)) 4661: EX_LD(LOAD(ldx, %o1 + 0x8, %g3), U3_retl_o2_and_7_plus_GS)
386 subcc GLOBAL_SPARE, 0x8, GLOBAL_SPARE 467 subcc GLOBAL_SPARE, 0x8, GLOBAL_SPARE
387 add %o1, 0x8, %o1 468 add %o1, 0x8, %o1
388 srlx %g3, %o3, %o5 469 srlx %g3, %o3, %o5
389 or %o5, %g2, %o5 470 or %o5, %g2, %o5
390 EX_ST(STORE(stx, %o5, %o0)) 471 EX_ST(STORE(stx, %o5, %o0), U3_retl_o2_and_7_plus_GS_plus_8)
391 add %o0, 0x8, %o0 472 add %o0, 0x8, %o0
392 bgu,pt %icc, 1b 473 bgu,pt %icc, 1b
393 sllx %g3, %g1, %g2 474 sllx %g3, %g1, %g2
@@ -407,8 +488,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
407 488
4081: 4891:
409 subcc %o2, 4, %o2 490 subcc %o2, 4, %o2
410 EX_LD(LOAD(lduw, %o1, %g1)) 491 EX_LD(LOAD(lduw, %o1, %g1), U3_retl_o2_plus_4)
411 EX_ST(STORE(stw, %g1, %o1 + %o3)) 492 EX_ST(STORE(stw, %g1, %o1 + %o3), U3_retl_o2_plus_4)
412 bgu,pt %XCC, 1b 493 bgu,pt %XCC, 1b
413 add %o1, 4, %o1 494 add %o1, 4, %o1
414 495
@@ -418,8 +499,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
418 .align 32 499 .align 32
41990: 50090:
420 subcc %o2, 1, %o2 501 subcc %o2, 1, %o2
421 EX_LD(LOAD(ldub, %o1, %g1)) 502 EX_LD(LOAD(ldub, %o1, %g1), U3_retl_o2_plus_1)
422 EX_ST(STORE(stb, %g1, %o1 + %o3)) 503 EX_ST(STORE(stb, %g1, %o1 + %o3), U3_retl_o2_plus_1)
423 bgu,pt %XCC, 90b 504 bgu,pt %XCC, 90b
424 add %o1, 1, %o1 505 add %o1, 1, %o1
425 retl 506 retl
diff --git a/arch/sparc/lib/copy_in_user.S b/arch/sparc/lib/copy_in_user.S
index 482de093bdae..0252b218de45 100644
--- a/arch/sparc/lib/copy_in_user.S
+++ b/arch/sparc/lib/copy_in_user.S
@@ -9,18 +9,33 @@
9 9
10#define XCC xcc 10#define XCC xcc
11 11
12#define EX(x,y) \ 12#define EX(x,y,z) \
1398: x,y; \ 1398: x,y; \
14 .section __ex_table,"a";\ 14 .section __ex_table,"a";\
15 .align 4; \ 15 .align 4; \
16 .word 98b, __retl_one; \ 16 .word 98b, z; \
17 .text; \ 17 .text; \
18 .align 4; 18 .align 4;
19 19
20#define EX_O4(x,y) EX(x,y,__retl_o4_plus_8)
21#define EX_O2_4(x,y) EX(x,y,__retl_o2_plus_4)
22#define EX_O2_1(x,y) EX(x,y,__retl_o2_plus_1)
23
20 .register %g2,#scratch 24 .register %g2,#scratch
21 .register %g3,#scratch 25 .register %g3,#scratch
22 26
23 .text 27 .text
28__retl_o4_plus_8:
29 add %o4, %o2, %o4
30 retl
31 add %o4, 8, %o0
32__retl_o2_plus_4:
33 retl
34 add %o2, 4, %o0
35__retl_o2_plus_1:
36 retl
37 add %o2, 1, %o0
38
24 .align 32 39 .align 32
25 40
26 /* Don't try to get too fancy here, just nice and 41 /* Don't try to get too fancy here, just nice and
@@ -45,8 +60,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
45 andn %o2, 0x7, %o4 60 andn %o2, 0x7, %o4
46 and %o2, 0x7, %o2 61 and %o2, 0x7, %o2
471: subcc %o4, 0x8, %o4 621: subcc %o4, 0x8, %o4
48 EX(ldxa [%o1] %asi, %o5) 63 EX_O4(ldxa [%o1] %asi, %o5)
49 EX(stxa %o5, [%o0] %asi) 64 EX_O4(stxa %o5, [%o0] %asi)
50 add %o1, 0x8, %o1 65 add %o1, 0x8, %o1
51 bgu,pt %XCC, 1b 66 bgu,pt %XCC, 1b
52 add %o0, 0x8, %o0 67 add %o0, 0x8, %o0
@@ -54,8 +69,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
54 be,pt %XCC, 1f 69 be,pt %XCC, 1f
55 nop 70 nop
56 sub %o2, 0x4, %o2 71 sub %o2, 0x4, %o2
57 EX(lduwa [%o1] %asi, %o5) 72 EX_O2_4(lduwa [%o1] %asi, %o5)
58 EX(stwa %o5, [%o0] %asi) 73 EX_O2_4(stwa %o5, [%o0] %asi)
59 add %o1, 0x4, %o1 74 add %o1, 0x4, %o1
60 add %o0, 0x4, %o0 75 add %o0, 0x4, %o0
611: cmp %o2, 0 761: cmp %o2, 0
@@ -71,8 +86,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
71 86
7282: 8782:
73 subcc %o2, 4, %o2 88 subcc %o2, 4, %o2
74 EX(lduwa [%o1] %asi, %g1) 89 EX_O2_4(lduwa [%o1] %asi, %g1)
75 EX(stwa %g1, [%o0] %asi) 90 EX_O2_4(stwa %g1, [%o0] %asi)
76 add %o1, 4, %o1 91 add %o1, 4, %o1
77 bgu,pt %XCC, 82b 92 bgu,pt %XCC, 82b
78 add %o0, 4, %o0 93 add %o0, 4, %o0
@@ -83,8 +98,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
83 .align 32 98 .align 32
8490: 9990:
85 subcc %o2, 1, %o2 100 subcc %o2, 1, %o2
86 EX(lduba [%o1] %asi, %g1) 101 EX_O2_1(lduba [%o1] %asi, %g1)
87 EX(stba %g1, [%o0] %asi) 102 EX_O2_1(stba %g1, [%o0] %asi)
88 add %o1, 1, %o1 103 add %o1, 1, %o1
89 bgu,pt %XCC, 90b 104 bgu,pt %XCC, 90b
90 add %o0, 1, %o0 105 add %o0, 1, %o0
diff --git a/arch/sparc/lib/user_fixup.c b/arch/sparc/lib/user_fixup.c
deleted file mode 100644
index ac96ae236709..000000000000
--- a/arch/sparc/lib/user_fixup.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/* user_fixup.c: Fix up user copy faults.
2 *
3 * Copyright (C) 2004 David S. Miller <davem@redhat.com>
4 */
5
6#include <linux/compiler.h>
7#include <linux/kernel.h>
8#include <linux/string.h>
9#include <linux/errno.h>
10#include <linux/module.h>
11
12#include <asm/uaccess.h>
13
14/* Calculating the exact fault address when using
15 * block loads and stores can be very complicated.
16 *
17 * Instead of trying to be clever and handling all
18 * of the cases, just fix things up simply here.
19 */
20
21static unsigned long compute_size(unsigned long start, unsigned long size, unsigned long *offset)
22{
23 unsigned long fault_addr = current_thread_info()->fault_address;
24 unsigned long end = start + size;
25
26 if (fault_addr < start || fault_addr >= end) {
27 *offset = 0;
28 } else {
29 *offset = fault_addr - start;
30 size = end - fault_addr;
31 }
32 return size;
33}
34
35unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
36{
37 unsigned long offset;
38
39 size = compute_size((unsigned long) from, size, &offset);
40 if (likely(size))
41 memset(to + offset, 0, size);
42
43 return size;
44}
45EXPORT_SYMBOL(copy_from_user_fixup);
46
47unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size)
48{
49 unsigned long offset;
50
51 return compute_size((unsigned long) to, size, &offset);
52}
53EXPORT_SYMBOL(copy_to_user_fixup);
54
55unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size)
56{
57 unsigned long fault_addr = current_thread_info()->fault_address;
58 unsigned long start = (unsigned long) to;
59 unsigned long end = start + size;
60
61 if (fault_addr >= start && fault_addr < end)
62 return end - fault_addr;
63
64 start = (unsigned long) from;
65 end = start + size;
66 if (fault_addr >= start && fault_addr < end)
67 return end - fault_addr;
68
69 return size;
70}
71EXPORT_SYMBOL(copy_in_user_fixup);
diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
index f2b77112e9d8..e20fbbafb0b0 100644
--- a/arch/sparc/mm/tsb.c
+++ b/arch/sparc/mm/tsb.c
@@ -27,6 +27,20 @@ static inline int tag_compare(unsigned long tag, unsigned long vaddr)
27 return (tag == (vaddr >> 22)); 27 return (tag == (vaddr >> 22));
28} 28}
29 29
30static void flush_tsb_kernel_range_scan(unsigned long start, unsigned long end)
31{
32 unsigned long idx;
33
34 for (idx = 0; idx < KERNEL_TSB_NENTRIES; idx++) {
35 struct tsb *ent = &swapper_tsb[idx];
36 unsigned long match = idx << 13;
37
38 match |= (ent->tag << 22);
39 if (match >= start && match < end)
40 ent->tag = (1UL << TSB_TAG_INVALID_BIT);
41 }
42}
43
30/* TSB flushes need only occur on the processor initiating the address 44/* TSB flushes need only occur on the processor initiating the address
31 * space modification, not on each cpu the address space has run on. 45 * space modification, not on each cpu the address space has run on.
32 * Only the TLB flush needs that treatment. 46 * Only the TLB flush needs that treatment.
@@ -36,6 +50,9 @@ void flush_tsb_kernel_range(unsigned long start, unsigned long end)
36{ 50{
37 unsigned long v; 51 unsigned long v;
38 52
53 if ((end - start) >> PAGE_SHIFT >= 2 * KERNEL_TSB_NENTRIES)
54 return flush_tsb_kernel_range_scan(start, end);
55
39 for (v = start; v < end; v += PAGE_SIZE) { 56 for (v = start; v < end; v += PAGE_SIZE) {
40 unsigned long hash = tsb_hash(v, PAGE_SHIFT, 57 unsigned long hash = tsb_hash(v, PAGE_SHIFT,
41 KERNEL_TSB_NENTRIES); 58 KERNEL_TSB_NENTRIES);
diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
index b4f4733abc6e..5d2fd6cd3189 100644
--- a/arch/sparc/mm/ultra.S
+++ b/arch/sparc/mm/ultra.S
@@ -30,7 +30,7 @@
30 .text 30 .text
31 .align 32 31 .align 32
32 .globl __flush_tlb_mm 32 .globl __flush_tlb_mm
33__flush_tlb_mm: /* 18 insns */ 33__flush_tlb_mm: /* 19 insns */
34 /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */ 34 /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
35 ldxa [%o1] ASI_DMMU, %g2 35 ldxa [%o1] ASI_DMMU, %g2
36 cmp %g2, %o0 36 cmp %g2, %o0
@@ -81,7 +81,7 @@ __flush_tlb_page: /* 22 insns */
81 81
82 .align 32 82 .align 32
83 .globl __flush_tlb_pending 83 .globl __flush_tlb_pending
84__flush_tlb_pending: /* 26 insns */ 84__flush_tlb_pending: /* 27 insns */
85 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */ 85 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
86 rdpr %pstate, %g7 86 rdpr %pstate, %g7
87 sllx %o1, 3, %o1 87 sllx %o1, 3, %o1
@@ -113,12 +113,14 @@ __flush_tlb_pending: /* 26 insns */
113 113
114 .align 32 114 .align 32
115 .globl __flush_tlb_kernel_range 115 .globl __flush_tlb_kernel_range
116__flush_tlb_kernel_range: /* 16 insns */ 116__flush_tlb_kernel_range: /* 31 insns */
117 /* %o0=start, %o1=end */ 117 /* %o0=start, %o1=end */
118 cmp %o0, %o1 118 cmp %o0, %o1
119 be,pn %xcc, 2f 119 be,pn %xcc, 2f
120 sub %o1, %o0, %o3
121 srlx %o3, 18, %o4
122 brnz,pn %o4, __spitfire_flush_tlb_kernel_range_slow
120 sethi %hi(PAGE_SIZE), %o4 123 sethi %hi(PAGE_SIZE), %o4
121 sub %o1, %o0, %o3
122 sub %o3, %o4, %o3 124 sub %o3, %o4, %o3
123 or %o0, 0x20, %o0 ! Nucleus 125 or %o0, 0x20, %o0 ! Nucleus
1241: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP 1261: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
@@ -131,6 +133,41 @@ __flush_tlb_kernel_range: /* 16 insns */
131 retl 133 retl
132 nop 134 nop
133 nop 135 nop
136 nop
137 nop
138 nop
139 nop
140 nop
141 nop
142 nop
143 nop
144 nop
145 nop
146 nop
147 nop
148 nop
149
150__spitfire_flush_tlb_kernel_range_slow:
151 mov 63 * 8, %o4
1521: ldxa [%o4] ASI_ITLB_DATA_ACCESS, %o3
153 andcc %o3, 0x40, %g0 /* _PAGE_L_4U */
154 bne,pn %xcc, 2f
155 mov TLB_TAG_ACCESS, %o3
156 stxa %g0, [%o3] ASI_IMMU
157 stxa %g0, [%o4] ASI_ITLB_DATA_ACCESS
158 membar #Sync
1592: ldxa [%o4] ASI_DTLB_DATA_ACCESS, %o3
160 andcc %o3, 0x40, %g0
161 bne,pn %xcc, 2f
162 mov TLB_TAG_ACCESS, %o3
163 stxa %g0, [%o3] ASI_DMMU
164 stxa %g0, [%o4] ASI_DTLB_DATA_ACCESS
165 membar #Sync
1662: sub %o4, 8, %o4
167 brgez,pt %o4, 1b
168 nop
169 retl
170 nop
134 171
135__spitfire_flush_tlb_mm_slow: 172__spitfire_flush_tlb_mm_slow:
136 rdpr %pstate, %g1 173 rdpr %pstate, %g1
@@ -285,6 +322,40 @@ __cheetah_flush_tlb_pending: /* 27 insns */
285 retl 322 retl
286 wrpr %g7, 0x0, %pstate 323 wrpr %g7, 0x0, %pstate
287 324
325__cheetah_flush_tlb_kernel_range: /* 31 insns */
326 /* %o0=start, %o1=end */
327 cmp %o0, %o1
328 be,pn %xcc, 2f
329 sub %o1, %o0, %o3
330 srlx %o3, 18, %o4
331 brnz,pn %o4, 3f
332 sethi %hi(PAGE_SIZE), %o4
333 sub %o3, %o4, %o3
334 or %o0, 0x20, %o0 ! Nucleus
3351: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
336 stxa %g0, [%o0 + %o3] ASI_IMMU_DEMAP
337 membar #Sync
338 brnz,pt %o3, 1b
339 sub %o3, %o4, %o3
3402: sethi %hi(KERNBASE), %o3
341 flush %o3
342 retl
343 nop
3443: mov 0x80, %o4
345 stxa %g0, [%o4] ASI_DMMU_DEMAP
346 membar #Sync
347 stxa %g0, [%o4] ASI_IMMU_DEMAP
348 membar #Sync
349 retl
350 nop
351 nop
352 nop
353 nop
354 nop
355 nop
356 nop
357 nop
358
288#ifdef DCACHE_ALIASING_POSSIBLE 359#ifdef DCACHE_ALIASING_POSSIBLE
289__cheetah_flush_dcache_page: /* 11 insns */ 360__cheetah_flush_dcache_page: /* 11 insns */
290 sethi %hi(PAGE_OFFSET), %g1 361 sethi %hi(PAGE_OFFSET), %g1
@@ -309,19 +380,28 @@ __hypervisor_tlb_tl0_error:
309 ret 380 ret
310 restore 381 restore
311 382
312__hypervisor_flush_tlb_mm: /* 10 insns */ 383__hypervisor_flush_tlb_mm: /* 19 insns */
313 mov %o0, %o2 /* ARG2: mmu context */ 384 mov %o0, %o2 /* ARG2: mmu context */
314 mov 0, %o0 /* ARG0: CPU lists unimplemented */ 385 mov 0, %o0 /* ARG0: CPU lists unimplemented */
315 mov 0, %o1 /* ARG1: CPU lists unimplemented */ 386 mov 0, %o1 /* ARG1: CPU lists unimplemented */
316 mov HV_MMU_ALL, %o3 /* ARG3: flags */ 387 mov HV_MMU_ALL, %o3 /* ARG3: flags */
317 mov HV_FAST_MMU_DEMAP_CTX, %o5 388 mov HV_FAST_MMU_DEMAP_CTX, %o5
318 ta HV_FAST_TRAP 389 ta HV_FAST_TRAP
319 brnz,pn %o0, __hypervisor_tlb_tl0_error 390 brnz,pn %o0, 1f
320 mov HV_FAST_MMU_DEMAP_CTX, %o1 391 mov HV_FAST_MMU_DEMAP_CTX, %o1
321 retl 392 retl
322 nop 393 nop
3941: sethi %hi(__hypervisor_tlb_tl0_error), %o5
395 jmpl %o5 + %lo(__hypervisor_tlb_tl0_error), %g0
396 nop
397 nop
398 nop
399 nop
400 nop
401 nop
402 nop
323 403
324__hypervisor_flush_tlb_page: /* 11 insns */ 404__hypervisor_flush_tlb_page: /* 22 insns */
325 /* %o0 = context, %o1 = vaddr */ 405 /* %o0 = context, %o1 = vaddr */
326 mov %o0, %g2 406 mov %o0, %g2
327 mov %o1, %o0 /* ARG0: vaddr + IMMU-bit */ 407 mov %o1, %o0 /* ARG0: vaddr + IMMU-bit */
@@ -330,12 +410,23 @@ __hypervisor_flush_tlb_page: /* 11 insns */
330 srlx %o0, PAGE_SHIFT, %o0 410 srlx %o0, PAGE_SHIFT, %o0
331 sllx %o0, PAGE_SHIFT, %o0 411 sllx %o0, PAGE_SHIFT, %o0
332 ta HV_MMU_UNMAP_ADDR_TRAP 412 ta HV_MMU_UNMAP_ADDR_TRAP
333 brnz,pn %o0, __hypervisor_tlb_tl0_error 413 brnz,pn %o0, 1f
334 mov HV_MMU_UNMAP_ADDR_TRAP, %o1 414 mov HV_MMU_UNMAP_ADDR_TRAP, %o1
335 retl 415 retl
336 nop 416 nop
4171: sethi %hi(__hypervisor_tlb_tl0_error), %o2
418 jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
419 nop
420 nop
421 nop
422 nop
423 nop
424 nop
425 nop
426 nop
427 nop
337 428
338__hypervisor_flush_tlb_pending: /* 16 insns */ 429__hypervisor_flush_tlb_pending: /* 27 insns */
339 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */ 430 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
340 sllx %o1, 3, %g1 431 sllx %o1, 3, %g1
341 mov %o2, %g2 432 mov %o2, %g2
@@ -347,31 +438,57 @@ __hypervisor_flush_tlb_pending: /* 16 insns */
347 srlx %o0, PAGE_SHIFT, %o0 438 srlx %o0, PAGE_SHIFT, %o0
348 sllx %o0, PAGE_SHIFT, %o0 439 sllx %o0, PAGE_SHIFT, %o0
349 ta HV_MMU_UNMAP_ADDR_TRAP 440 ta HV_MMU_UNMAP_ADDR_TRAP
350 brnz,pn %o0, __hypervisor_tlb_tl0_error 441 brnz,pn %o0, 1f
351 mov HV_MMU_UNMAP_ADDR_TRAP, %o1 442 mov HV_MMU_UNMAP_ADDR_TRAP, %o1
352 brnz,pt %g1, 1b 443 brnz,pt %g1, 1b
353 nop 444 nop
354 retl 445 retl
355 nop 446 nop
4471: sethi %hi(__hypervisor_tlb_tl0_error), %o2
448 jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
449 nop
450 nop
451 nop
452 nop
453 nop
454 nop
455 nop
456 nop
457 nop
356 458
357__hypervisor_flush_tlb_kernel_range: /* 16 insns */ 459__hypervisor_flush_tlb_kernel_range: /* 31 insns */
358 /* %o0=start, %o1=end */ 460 /* %o0=start, %o1=end */
359 cmp %o0, %o1 461 cmp %o0, %o1
360 be,pn %xcc, 2f 462 be,pn %xcc, 2f
361 sethi %hi(PAGE_SIZE), %g3 463 sub %o1, %o0, %g2
362 mov %o0, %g1 464 srlx %g2, 18, %g3
363 sub %o1, %g1, %g2 465 brnz,pn %g3, 4f
466 mov %o0, %g1
467 sethi %hi(PAGE_SIZE), %g3
364 sub %g2, %g3, %g2 468 sub %g2, %g3, %g2
3651: add %g1, %g2, %o0 /* ARG0: virtual address */ 4691: add %g1, %g2, %o0 /* ARG0: virtual address */
366 mov 0, %o1 /* ARG1: mmu context */ 470 mov 0, %o1 /* ARG1: mmu context */
367 mov HV_MMU_ALL, %o2 /* ARG2: flags */ 471 mov HV_MMU_ALL, %o2 /* ARG2: flags */
368 ta HV_MMU_UNMAP_ADDR_TRAP 472 ta HV_MMU_UNMAP_ADDR_TRAP
369 brnz,pn %o0, __hypervisor_tlb_tl0_error 473 brnz,pn %o0, 3f
370 mov HV_MMU_UNMAP_ADDR_TRAP, %o1 474 mov HV_MMU_UNMAP_ADDR_TRAP, %o1
371 brnz,pt %g2, 1b 475 brnz,pt %g2, 1b
372 sub %g2, %g3, %g2 476 sub %g2, %g3, %g2
3732: retl 4772: retl
374 nop 478 nop
4793: sethi %hi(__hypervisor_tlb_tl0_error), %o2
480 jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
481 nop
4824: mov 0, %o0 /* ARG0: CPU lists unimplemented */
483 mov 0, %o1 /* ARG1: CPU lists unimplemented */
484 mov 0, %o2 /* ARG2: mmu context == nucleus */
485 mov HV_MMU_ALL, %o3 /* ARG3: flags */
486 mov HV_FAST_MMU_DEMAP_CTX, %o5
487 ta HV_FAST_TRAP
488 brnz,pn %o0, 3b
489 mov HV_FAST_MMU_DEMAP_CTX, %o1
490 retl
491 nop
375 492
376#ifdef DCACHE_ALIASING_POSSIBLE 493#ifdef DCACHE_ALIASING_POSSIBLE
377 /* XXX Niagara and friends have an 8K cache, so no aliasing is 494 /* XXX Niagara and friends have an 8K cache, so no aliasing is
@@ -394,43 +511,6 @@ tlb_patch_one:
394 retl 511 retl
395 nop 512 nop
396 513
397 .globl cheetah_patch_cachetlbops
398cheetah_patch_cachetlbops:
399 save %sp, -128, %sp
400
401 sethi %hi(__flush_tlb_mm), %o0
402 or %o0, %lo(__flush_tlb_mm), %o0
403 sethi %hi(__cheetah_flush_tlb_mm), %o1
404 or %o1, %lo(__cheetah_flush_tlb_mm), %o1
405 call tlb_patch_one
406 mov 19, %o2
407
408 sethi %hi(__flush_tlb_page), %o0
409 or %o0, %lo(__flush_tlb_page), %o0
410 sethi %hi(__cheetah_flush_tlb_page), %o1
411 or %o1, %lo(__cheetah_flush_tlb_page), %o1
412 call tlb_patch_one
413 mov 22, %o2
414
415 sethi %hi(__flush_tlb_pending), %o0
416 or %o0, %lo(__flush_tlb_pending), %o0
417 sethi %hi(__cheetah_flush_tlb_pending), %o1
418 or %o1, %lo(__cheetah_flush_tlb_pending), %o1
419 call tlb_patch_one
420 mov 27, %o2
421
422#ifdef DCACHE_ALIASING_POSSIBLE
423 sethi %hi(__flush_dcache_page), %o0
424 or %o0, %lo(__flush_dcache_page), %o0
425 sethi %hi(__cheetah_flush_dcache_page), %o1
426 or %o1, %lo(__cheetah_flush_dcache_page), %o1
427 call tlb_patch_one
428 mov 11, %o2
429#endif /* DCACHE_ALIASING_POSSIBLE */
430
431 ret
432 restore
433
434#ifdef CONFIG_SMP 514#ifdef CONFIG_SMP
435 /* These are all called by the slaves of a cross call, at 515 /* These are all called by the slaves of a cross call, at
436 * trap level 1, with interrupts fully disabled. 516 * trap level 1, with interrupts fully disabled.
@@ -447,7 +527,7 @@ cheetah_patch_cachetlbops:
447 */ 527 */
448 .align 32 528 .align 32
449 .globl xcall_flush_tlb_mm 529 .globl xcall_flush_tlb_mm
450xcall_flush_tlb_mm: /* 21 insns */ 530xcall_flush_tlb_mm: /* 24 insns */
451 mov PRIMARY_CONTEXT, %g2 531 mov PRIMARY_CONTEXT, %g2
452 ldxa [%g2] ASI_DMMU, %g3 532 ldxa [%g2] ASI_DMMU, %g3
453 srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4 533 srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4
@@ -469,9 +549,12 @@ xcall_flush_tlb_mm: /* 21 insns */
469 nop 549 nop
470 nop 550 nop
471 nop 551 nop
552 nop
553 nop
554 nop
472 555
473 .globl xcall_flush_tlb_page 556 .globl xcall_flush_tlb_page
474xcall_flush_tlb_page: /* 17 insns */ 557xcall_flush_tlb_page: /* 20 insns */
475 /* %g5=context, %g1=vaddr */ 558 /* %g5=context, %g1=vaddr */
476 mov PRIMARY_CONTEXT, %g4 559 mov PRIMARY_CONTEXT, %g4
477 ldxa [%g4] ASI_DMMU, %g2 560 ldxa [%g4] ASI_DMMU, %g2
@@ -490,15 +573,20 @@ xcall_flush_tlb_page: /* 17 insns */
490 retry 573 retry
491 nop 574 nop
492 nop 575 nop
576 nop
577 nop
578 nop
493 579
494 .globl xcall_flush_tlb_kernel_range 580 .globl xcall_flush_tlb_kernel_range
495xcall_flush_tlb_kernel_range: /* 25 insns */ 581xcall_flush_tlb_kernel_range: /* 44 insns */
496 sethi %hi(PAGE_SIZE - 1), %g2 582 sethi %hi(PAGE_SIZE - 1), %g2
497 or %g2, %lo(PAGE_SIZE - 1), %g2 583 or %g2, %lo(PAGE_SIZE - 1), %g2
498 andn %g1, %g2, %g1 584 andn %g1, %g2, %g1
499 andn %g7, %g2, %g7 585 andn %g7, %g2, %g7
500 sub %g7, %g1, %g3 586 sub %g7, %g1, %g3
501 add %g2, 1, %g2 587 srlx %g3, 18, %g2
588 brnz,pn %g2, 2f
589 add %g2, 1, %g2
502 sub %g3, %g2, %g3 590 sub %g3, %g2, %g3
503 or %g1, 0x20, %g1 ! Nucleus 591 or %g1, 0x20, %g1 ! Nucleus
5041: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP 5921: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
@@ -507,8 +595,25 @@ xcall_flush_tlb_kernel_range: /* 25 insns */
507 brnz,pt %g3, 1b 595 brnz,pt %g3, 1b
508 sub %g3, %g2, %g3 596 sub %g3, %g2, %g3
509 retry 597 retry
510 nop 5982: mov 63 * 8, %g1
511 nop 5991: ldxa [%g1] ASI_ITLB_DATA_ACCESS, %g2
600 andcc %g2, 0x40, %g0 /* _PAGE_L_4U */
601 bne,pn %xcc, 2f
602 mov TLB_TAG_ACCESS, %g2
603 stxa %g0, [%g2] ASI_IMMU
604 stxa %g0, [%g1] ASI_ITLB_DATA_ACCESS
605 membar #Sync
6062: ldxa [%g1] ASI_DTLB_DATA_ACCESS, %g2
607 andcc %g2, 0x40, %g0
608 bne,pn %xcc, 2f
609 mov TLB_TAG_ACCESS, %g2
610 stxa %g0, [%g2] ASI_DMMU
611 stxa %g0, [%g1] ASI_DTLB_DATA_ACCESS
612 membar #Sync
6132: sub %g1, 8, %g1
614 brgez,pt %g1, 1b
615 nop
616 retry
512 nop 617 nop
513 nop 618 nop
514 nop 619 nop
@@ -637,6 +742,52 @@ xcall_fetch_glob_pmu_n4:
637 742
638 retry 743 retry
639 744
745__cheetah_xcall_flush_tlb_kernel_range: /* 44 insns */
746 sethi %hi(PAGE_SIZE - 1), %g2
747 or %g2, %lo(PAGE_SIZE - 1), %g2
748 andn %g1, %g2, %g1
749 andn %g7, %g2, %g7
750 sub %g7, %g1, %g3
751 srlx %g3, 18, %g2
752 brnz,pn %g2, 2f
753 add %g2, 1, %g2
754 sub %g3, %g2, %g3
755 or %g1, 0x20, %g1 ! Nucleus
7561: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
757 stxa %g0, [%g1 + %g3] ASI_IMMU_DEMAP
758 membar #Sync
759 brnz,pt %g3, 1b
760 sub %g3, %g2, %g3
761 retry
7622: mov 0x80, %g2
763 stxa %g0, [%g2] ASI_DMMU_DEMAP
764 membar #Sync
765 stxa %g0, [%g2] ASI_IMMU_DEMAP
766 membar #Sync
767 retry
768 nop
769 nop
770 nop
771 nop
772 nop
773 nop
774 nop
775 nop
776 nop
777 nop
778 nop
779 nop
780 nop
781 nop
782 nop
783 nop
784 nop
785 nop
786 nop
787 nop
788 nop
789 nop
790
640#ifdef DCACHE_ALIASING_POSSIBLE 791#ifdef DCACHE_ALIASING_POSSIBLE
641 .align 32 792 .align 32
642 .globl xcall_flush_dcache_page_cheetah 793 .globl xcall_flush_dcache_page_cheetah
@@ -700,7 +851,7 @@ __hypervisor_tlb_xcall_error:
700 ba,a,pt %xcc, rtrap 851 ba,a,pt %xcc, rtrap
701 852
702 .globl __hypervisor_xcall_flush_tlb_mm 853 .globl __hypervisor_xcall_flush_tlb_mm
703__hypervisor_xcall_flush_tlb_mm: /* 21 insns */ 854__hypervisor_xcall_flush_tlb_mm: /* 24 insns */
704 /* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */ 855 /* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
705 mov %o0, %g2 856 mov %o0, %g2
706 mov %o1, %g3 857 mov %o1, %g3
@@ -714,7 +865,7 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
714 mov HV_FAST_MMU_DEMAP_CTX, %o5 865 mov HV_FAST_MMU_DEMAP_CTX, %o5
715 ta HV_FAST_TRAP 866 ta HV_FAST_TRAP
716 mov HV_FAST_MMU_DEMAP_CTX, %g6 867 mov HV_FAST_MMU_DEMAP_CTX, %g6
717 brnz,pn %o0, __hypervisor_tlb_xcall_error 868 brnz,pn %o0, 1f
718 mov %o0, %g5 869 mov %o0, %g5
719 mov %g2, %o0 870 mov %g2, %o0
720 mov %g3, %o1 871 mov %g3, %o1
@@ -723,9 +874,12 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
723 mov %g7, %o5 874 mov %g7, %o5
724 membar #Sync 875 membar #Sync
725 retry 876 retry
8771: sethi %hi(__hypervisor_tlb_xcall_error), %g4
878 jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
879 nop
726 880
727 .globl __hypervisor_xcall_flush_tlb_page 881 .globl __hypervisor_xcall_flush_tlb_page
728__hypervisor_xcall_flush_tlb_page: /* 17 insns */ 882__hypervisor_xcall_flush_tlb_page: /* 20 insns */
729 /* %g5=ctx, %g1=vaddr */ 883 /* %g5=ctx, %g1=vaddr */
730 mov %o0, %g2 884 mov %o0, %g2
731 mov %o1, %g3 885 mov %o1, %g3
@@ -737,42 +891,64 @@ __hypervisor_xcall_flush_tlb_page: /* 17 insns */
737 sllx %o0, PAGE_SHIFT, %o0 891 sllx %o0, PAGE_SHIFT, %o0
738 ta HV_MMU_UNMAP_ADDR_TRAP 892 ta HV_MMU_UNMAP_ADDR_TRAP
739 mov HV_MMU_UNMAP_ADDR_TRAP, %g6 893 mov HV_MMU_UNMAP_ADDR_TRAP, %g6
740 brnz,a,pn %o0, __hypervisor_tlb_xcall_error 894 brnz,a,pn %o0, 1f
741 mov %o0, %g5 895 mov %o0, %g5
742 mov %g2, %o0 896 mov %g2, %o0
743 mov %g3, %o1 897 mov %g3, %o1
744 mov %g4, %o2 898 mov %g4, %o2
745 membar #Sync 899 membar #Sync
746 retry 900 retry
9011: sethi %hi(__hypervisor_tlb_xcall_error), %g4
902 jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
903 nop
747 904
748 .globl __hypervisor_xcall_flush_tlb_kernel_range 905 .globl __hypervisor_xcall_flush_tlb_kernel_range
749__hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */ 906__hypervisor_xcall_flush_tlb_kernel_range: /* 44 insns */
750 /* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */ 907 /* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
751 sethi %hi(PAGE_SIZE - 1), %g2 908 sethi %hi(PAGE_SIZE - 1), %g2
752 or %g2, %lo(PAGE_SIZE - 1), %g2 909 or %g2, %lo(PAGE_SIZE - 1), %g2
753 andn %g1, %g2, %g1 910 andn %g1, %g2, %g1
754 andn %g7, %g2, %g7 911 andn %g7, %g2, %g7
755 sub %g7, %g1, %g3 912 sub %g7, %g1, %g3
913 srlx %g3, 18, %g7
756 add %g2, 1, %g2 914 add %g2, 1, %g2
757 sub %g3, %g2, %g3 915 sub %g3, %g2, %g3
758 mov %o0, %g2 916 mov %o0, %g2
759 mov %o1, %g4 917 mov %o1, %g4
760 mov %o2, %g7 918 brnz,pn %g7, 2f
919 mov %o2, %g7
7611: add %g1, %g3, %o0 /* ARG0: virtual address */ 9201: add %g1, %g3, %o0 /* ARG0: virtual address */
762 mov 0, %o1 /* ARG1: mmu context */ 921 mov 0, %o1 /* ARG1: mmu context */
763 mov HV_MMU_ALL, %o2 /* ARG2: flags */ 922 mov HV_MMU_ALL, %o2 /* ARG2: flags */
764 ta HV_MMU_UNMAP_ADDR_TRAP 923 ta HV_MMU_UNMAP_ADDR_TRAP
765 mov HV_MMU_UNMAP_ADDR_TRAP, %g6 924 mov HV_MMU_UNMAP_ADDR_TRAP, %g6
766 brnz,pn %o0, __hypervisor_tlb_xcall_error 925 brnz,pn %o0, 1f
767 mov %o0, %g5 926 mov %o0, %g5
768 sethi %hi(PAGE_SIZE), %o2 927 sethi %hi(PAGE_SIZE), %o2
769 brnz,pt %g3, 1b 928 brnz,pt %g3, 1b
770 sub %g3, %o2, %g3 929 sub %g3, %o2, %g3
771 mov %g2, %o0 9305: mov %g2, %o0
772 mov %g4, %o1 931 mov %g4, %o1
773 mov %g7, %o2 932 mov %g7, %o2
774 membar #Sync 933 membar #Sync
775 retry 934 retry
9351: sethi %hi(__hypervisor_tlb_xcall_error), %g4
936 jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
937 nop
9382: mov %o3, %g1
939 mov %o5, %g3
940 mov 0, %o0 /* ARG0: CPU lists unimplemented */
941 mov 0, %o1 /* ARG1: CPU lists unimplemented */
942 mov 0, %o2 /* ARG2: mmu context == nucleus */
943 mov HV_MMU_ALL, %o3 /* ARG3: flags */
944 mov HV_FAST_MMU_DEMAP_CTX, %o5
945 ta HV_FAST_TRAP
946 mov %g1, %o3
947 brz,pt %o0, 5b
948 mov %g3, %o5
949 mov HV_FAST_MMU_DEMAP_CTX, %g6
950 ba,pt %xcc, 1b
951 clr %g5
776 952
777 /* These just get rescheduled to PIL vectors. */ 953 /* These just get rescheduled to PIL vectors. */
778 .globl xcall_call_function 954 .globl xcall_call_function
@@ -809,6 +985,58 @@ xcall_kgdb_capture:
809 985
810#endif /* CONFIG_SMP */ 986#endif /* CONFIG_SMP */
811 987
988 .globl cheetah_patch_cachetlbops
989cheetah_patch_cachetlbops:
990 save %sp, -128, %sp
991
992 sethi %hi(__flush_tlb_mm), %o0
993 or %o0, %lo(__flush_tlb_mm), %o0
994 sethi %hi(__cheetah_flush_tlb_mm), %o1
995 or %o1, %lo(__cheetah_flush_tlb_mm), %o1
996 call tlb_patch_one
997 mov 19, %o2
998
999 sethi %hi(__flush_tlb_page), %o0
1000 or %o0, %lo(__flush_tlb_page), %o0
1001 sethi %hi(__cheetah_flush_tlb_page), %o1
1002 or %o1, %lo(__cheetah_flush_tlb_page), %o1
1003 call tlb_patch_one
1004 mov 22, %o2
1005
1006 sethi %hi(__flush_tlb_pending), %o0
1007 or %o0, %lo(__flush_tlb_pending), %o0
1008 sethi %hi(__cheetah_flush_tlb_pending), %o1
1009 or %o1, %lo(__cheetah_flush_tlb_pending), %o1
1010 call tlb_patch_one
1011 mov 27, %o2
1012
1013 sethi %hi(__flush_tlb_kernel_range), %o0
1014 or %o0, %lo(__flush_tlb_kernel_range), %o0
1015 sethi %hi(__cheetah_flush_tlb_kernel_range), %o1
1016 or %o1, %lo(__cheetah_flush_tlb_kernel_range), %o1
1017 call tlb_patch_one
1018 mov 31, %o2
1019
1020#ifdef DCACHE_ALIASING_POSSIBLE
1021 sethi %hi(__flush_dcache_page), %o0
1022 or %o0, %lo(__flush_dcache_page), %o0
1023 sethi %hi(__cheetah_flush_dcache_page), %o1
1024 or %o1, %lo(__cheetah_flush_dcache_page), %o1
1025 call tlb_patch_one
1026 mov 11, %o2
1027#endif /* DCACHE_ALIASING_POSSIBLE */
1028
1029#ifdef CONFIG_SMP
1030 sethi %hi(xcall_flush_tlb_kernel_range), %o0
1031 or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
1032 sethi %hi(__cheetah_xcall_flush_tlb_kernel_range), %o1
1033 or %o1, %lo(__cheetah_xcall_flush_tlb_kernel_range), %o1
1034 call tlb_patch_one
1035 mov 44, %o2
1036#endif /* CONFIG_SMP */
1037
1038 ret
1039 restore
812 1040
813 .globl hypervisor_patch_cachetlbops 1041 .globl hypervisor_patch_cachetlbops
814hypervisor_patch_cachetlbops: 1042hypervisor_patch_cachetlbops:
@@ -819,28 +1047,28 @@ hypervisor_patch_cachetlbops:
819 sethi %hi(__hypervisor_flush_tlb_mm), %o1 1047 sethi %hi(__hypervisor_flush_tlb_mm), %o1
820 or %o1, %lo(__hypervisor_flush_tlb_mm), %o1 1048 or %o1, %lo(__hypervisor_flush_tlb_mm), %o1
821 call tlb_patch_one 1049 call tlb_patch_one
822 mov 10, %o2 1050 mov 19, %o2
823 1051
824 sethi %hi(__flush_tlb_page), %o0 1052 sethi %hi(__flush_tlb_page), %o0
825 or %o0, %lo(__flush_tlb_page), %o0 1053 or %o0, %lo(__flush_tlb_page), %o0
826 sethi %hi(__hypervisor_flush_tlb_page), %o1 1054 sethi %hi(__hypervisor_flush_tlb_page), %o1
827 or %o1, %lo(__hypervisor_flush_tlb_page), %o1 1055 or %o1, %lo(__hypervisor_flush_tlb_page), %o1
828 call tlb_patch_one 1056 call tlb_patch_one
829 mov 11, %o2 1057 mov 22, %o2
830 1058
831 sethi %hi(__flush_tlb_pending), %o0 1059 sethi %hi(__flush_tlb_pending), %o0
832 or %o0, %lo(__flush_tlb_pending), %o0 1060 or %o0, %lo(__flush_tlb_pending), %o0
833 sethi %hi(__hypervisor_flush_tlb_pending), %o1 1061 sethi %hi(__hypervisor_flush_tlb_pending), %o1
834 or %o1, %lo(__hypervisor_flush_tlb_pending), %o1 1062 or %o1, %lo(__hypervisor_flush_tlb_pending), %o1
835 call tlb_patch_one 1063 call tlb_patch_one
836 mov 16, %o2 1064 mov 27, %o2
837 1065
838 sethi %hi(__flush_tlb_kernel_range), %o0 1066 sethi %hi(__flush_tlb_kernel_range), %o0
839 or %o0, %lo(__flush_tlb_kernel_range), %o0 1067 or %o0, %lo(__flush_tlb_kernel_range), %o0
840 sethi %hi(__hypervisor_flush_tlb_kernel_range), %o1 1068 sethi %hi(__hypervisor_flush_tlb_kernel_range), %o1
841 or %o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1 1069 or %o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1
842 call tlb_patch_one 1070 call tlb_patch_one
843 mov 16, %o2 1071 mov 31, %o2
844 1072
845#ifdef DCACHE_ALIASING_POSSIBLE 1073#ifdef DCACHE_ALIASING_POSSIBLE
846 sethi %hi(__flush_dcache_page), %o0 1074 sethi %hi(__flush_dcache_page), %o0
@@ -857,21 +1085,21 @@ hypervisor_patch_cachetlbops:
857 sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1 1085 sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1
858 or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1 1086 or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
859 call tlb_patch_one 1087 call tlb_patch_one
860 mov 21, %o2 1088 mov 24, %o2
861 1089
862 sethi %hi(xcall_flush_tlb_page), %o0 1090 sethi %hi(xcall_flush_tlb_page), %o0
863 or %o0, %lo(xcall_flush_tlb_page), %o0 1091 or %o0, %lo(xcall_flush_tlb_page), %o0
864 sethi %hi(__hypervisor_xcall_flush_tlb_page), %o1 1092 sethi %hi(__hypervisor_xcall_flush_tlb_page), %o1
865 or %o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1 1093 or %o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1
866 call tlb_patch_one 1094 call tlb_patch_one
867 mov 17, %o2 1095 mov 20, %o2
868 1096
869 sethi %hi(xcall_flush_tlb_kernel_range), %o0 1097 sethi %hi(xcall_flush_tlb_kernel_range), %o0
870 or %o0, %lo(xcall_flush_tlb_kernel_range), %o0 1098 or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
871 sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1 1099 sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
872 or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1 1100 or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
873 call tlb_patch_one 1101 call tlb_patch_one
874 mov 25, %o2 1102 mov 44, %o2
875#endif /* CONFIG_SMP */ 1103#endif /* CONFIG_SMP */
876 1104
877 ret 1105 ret
diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile
index 77f28ce9c646..9976fcecd17e 100644
--- a/arch/x86/entry/Makefile
+++ b/arch/x86/entry/Makefile
@@ -5,8 +5,8 @@
5OBJECT_FILES_NON_STANDARD_entry_$(BITS).o := y 5OBJECT_FILES_NON_STANDARD_entry_$(BITS).o := y
6OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y 6OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y
7 7
8CFLAGS_syscall_64.o += -Wno-override-init 8CFLAGS_syscall_64.o += $(call cc-option,-Wno-override-init,)
9CFLAGS_syscall_32.o += -Wno-override-init 9CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,)
10obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o 10obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o
11obj-y += common.o 11obj-y += common.o
12 12
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index eab0915f5995..a74a2dbc0180 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3607,10 +3607,14 @@ __init int intel_pmu_init(void)
3607 3607
3608 /* 3608 /*
3609 * Quirk: v2 perfmon does not report fixed-purpose events, so 3609 * Quirk: v2 perfmon does not report fixed-purpose events, so
3610 * assume at least 3 events: 3610 * assume at least 3 events, when not running in a hypervisor:
3611 */ 3611 */
3612 if (version > 1) 3612 if (version > 1) {
3613 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3); 3613 int assume = 3 * !boot_cpu_has(X86_FEATURE_HYPERVISOR);
3614
3615 x86_pmu.num_counters_fixed =
3616 max((int)edx.split.num_counters_fixed, assume);
3617 }
3614 3618
3615 if (boot_cpu_has(X86_FEATURE_PDCM)) { 3619 if (boot_cpu_has(X86_FEATURE_PDCM)) {
3616 u64 capabilities; 3620 u64 capabilities;
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index 3ca87b5a8677..4f5ac726335f 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -48,7 +48,8 @@
48 * Scope: Core 48 * Scope: Core
49 * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter 49 * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter
50 * perf code: 0x02 50 * perf code: 0x02
51 * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW,SKL 51 * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW
52 * SKL,KNL
52 * Scope: Core 53 * Scope: Core
53 * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter 54 * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter
54 * perf code: 0x03 55 * perf code: 0x03
@@ -56,15 +57,16 @@
56 * Scope: Core 57 * Scope: Core
57 * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter. 58 * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter.
58 * perf code: 0x00 59 * perf code: 0x00
59 * Available model: SNB,IVB,HSW,BDW,SKL 60 * Available model: SNB,IVB,HSW,BDW,SKL,KNL
60 * Scope: Package (physical package) 61 * Scope: Package (physical package)
61 * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. 62 * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter.
62 * perf code: 0x01 63 * perf code: 0x01
63 * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL 64 * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,KNL
64 * Scope: Package (physical package) 65 * Scope: Package (physical package)
65 * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter. 66 * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter.
66 * perf code: 0x02 67 * perf code: 0x02
67 * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW,SKL 68 * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW
69 * SKL,KNL
68 * Scope: Package (physical package) 70 * Scope: Package (physical package)
69 * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter. 71 * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter.
70 * perf code: 0x03 72 * perf code: 0x03
@@ -118,6 +120,7 @@ struct cstate_model {
118 120
119/* Quirk flags */ 121/* Quirk flags */
120#define SLM_PKG_C6_USE_C7_MSR (1UL << 0) 122#define SLM_PKG_C6_USE_C7_MSR (1UL << 0)
123#define KNL_CORE_C6_MSR (1UL << 1)
121 124
122struct perf_cstate_msr { 125struct perf_cstate_msr {
123 u64 msr; 126 u64 msr;
@@ -488,6 +491,18 @@ static const struct cstate_model slm_cstates __initconst = {
488 .quirks = SLM_PKG_C6_USE_C7_MSR, 491 .quirks = SLM_PKG_C6_USE_C7_MSR,
489}; 492};
490 493
494
495static const struct cstate_model knl_cstates __initconst = {
496 .core_events = BIT(PERF_CSTATE_CORE_C6_RES),
497
498 .pkg_events = BIT(PERF_CSTATE_PKG_C2_RES) |
499 BIT(PERF_CSTATE_PKG_C3_RES) |
500 BIT(PERF_CSTATE_PKG_C6_RES),
501 .quirks = KNL_CORE_C6_MSR,
502};
503
504
505
491#define X86_CSTATES_MODEL(model, states) \ 506#define X86_CSTATES_MODEL(model, states) \
492 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long) &(states) } 507 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long) &(states) }
493 508
@@ -523,6 +538,8 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
523 538
524 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_MOBILE, snb_cstates), 539 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_MOBILE, snb_cstates),
525 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates), 540 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates),
541
542 X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNL, knl_cstates),
526 { }, 543 { },
527}; 544};
528MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match); 545MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match);
@@ -558,6 +575,11 @@ static int __init cstate_probe(const struct cstate_model *cm)
558 if (cm->quirks & SLM_PKG_C6_USE_C7_MSR) 575 if (cm->quirks & SLM_PKG_C6_USE_C7_MSR)
559 pkg_msr[PERF_CSTATE_PKG_C6_RES].msr = MSR_PKG_C7_RESIDENCY; 576 pkg_msr[PERF_CSTATE_PKG_C6_RES].msr = MSR_PKG_C7_RESIDENCY;
560 577
578 /* KNL has different MSR for CORE C6 */
579 if (cm->quirks & KNL_CORE_C6_MSR)
580 pkg_msr[PERF_CSTATE_CORE_C6_RES].msr = MSR_KNL_CORE_C6_RESIDENCY;
581
582
561 has_cstate_core = cstate_probe_msr(cm->core_events, 583 has_cstate_core = cstate_probe_msr(cm->core_events,
562 PERF_CSTATE_CORE_EVENT_MAX, 584 PERF_CSTATE_CORE_EVENT_MAX,
563 core_msr, core_events_attrs); 585 core_msr, core_events_attrs);
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 1188bc849ee3..a39629206864 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -194,6 +194,8 @@
194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
195 195
196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ 196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */
197#define X86_FEATURE_AVX512_4VNNIW (7*32+16) /* AVX-512 Neural Network Instructions */
198#define X86_FEATURE_AVX512_4FMAPS (7*32+17) /* AVX-512 Multiply Accumulation Single precision */
197 199
198/* Virtualization flags: Linux defined, word 8 */ 200/* Virtualization flags: Linux defined, word 8 */
199#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 201#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index de25aad07853..d34bd370074b 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -351,4 +351,10 @@ extern void arch_phys_wc_del(int handle);
351#define arch_phys_wc_add arch_phys_wc_add 351#define arch_phys_wc_add arch_phys_wc_add
352#endif 352#endif
353 353
354#ifdef CONFIG_X86_PAT
355extern int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size);
356extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size);
357#define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc
358#endif
359
354#endif /* _ASM_X86_IO_H */ 360#endif /* _ASM_X86_IO_H */
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index 2aaca53c0974..ad6f5eb07a95 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -52,6 +52,15 @@ struct task_struct;
52#include <asm/cpufeature.h> 52#include <asm/cpufeature.h>
53#include <linux/atomic.h> 53#include <linux/atomic.h>
54 54
55struct thread_info {
56 unsigned long flags; /* low level flags */
57};
58
59#define INIT_THREAD_INFO(tsk) \
60{ \
61 .flags = 0, \
62}
63
55#define init_stack (init_thread_union.stack) 64#define init_stack (init_thread_union.stack)
56 65
57#else /* !__ASSEMBLY__ */ 66#else /* !__ASSEMBLY__ */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 8a5abaa7d453..931ced8ca345 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -454,6 +454,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
454 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK; 454 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
455 455
456 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); 456 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
457 acpi_penalize_sci_irq(bus_irq, trigger, polarity);
457 458
458 /* 459 /*
459 * stash over-ride to indicate we've been here 460 * stash over-ride to indicate we've been here
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 620ab06bcf45..017bda12caae 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -429,7 +429,7 @@ int __init save_microcode_in_initrd_amd(void)
429 * We need the physical address of the container for both bitness since 429 * We need the physical address of the container for both bitness since
430 * boot_params.hdr.ramdisk_image is a physical address. 430 * boot_params.hdr.ramdisk_image is a physical address.
431 */ 431 */
432 cont = __pa(container); 432 cont = __pa_nodebug(container);
433 cont_va = container; 433 cont_va = container;
434#endif 434#endif
435 435
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index 8cb57df9398d..1db8dc490b66 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -32,6 +32,8 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
32 32
33 static const struct cpuid_bit cpuid_bits[] = { 33 static const struct cpuid_bit cpuid_bits[] = {
34 { X86_FEATURE_INTEL_PT, CR_EBX,25, 0x00000007, 0 }, 34 { X86_FEATURE_INTEL_PT, CR_EBX,25, 0x00000007, 0 },
35 { X86_FEATURE_AVX512_4VNNIW, CR_EDX, 2, 0x00000007, 0 },
36 { X86_FEATURE_AVX512_4FMAPS, CR_EDX, 3, 0x00000007, 0 },
35 { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, 37 { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 },
36 { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, 38 { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 },
37 { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, 39 { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 },
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 81160578b91a..5130985b758b 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -27,6 +27,7 @@
27#include <asm/div64.h> 27#include <asm/div64.h>
28#include <asm/x86_init.h> 28#include <asm/x86_init.h>
29#include <asm/hypervisor.h> 29#include <asm/hypervisor.h>
30#include <asm/timer.h>
30#include <asm/apic.h> 31#include <asm/apic.h>
31 32
32#define CPUID_VMWARE_INFO_LEAF 0x40000000 33#define CPUID_VMWARE_INFO_LEAF 0x40000000
@@ -94,6 +95,10 @@ static void __init vmware_platform_setup(void)
94 } else { 95 } else {
95 pr_warn("Failed to get TSC freq from the hypervisor\n"); 96 pr_warn("Failed to get TSC freq from the hypervisor\n");
96 } 97 }
98
99#ifdef CONFIG_X86_IO_APIC
100 no_timer_check = 1;
101#endif
97} 102}
98 103
99/* 104/*
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 124aa5c593f8..095ef7ddd6ae 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -74,6 +74,8 @@ void fpu__xstate_clear_all_cpu_caps(void)
74 setup_clear_cpu_cap(X86_FEATURE_MPX); 74 setup_clear_cpu_cap(X86_FEATURE_MPX);
75 setup_clear_cpu_cap(X86_FEATURE_XGETBV1); 75 setup_clear_cpu_cap(X86_FEATURE_XGETBV1);
76 setup_clear_cpu_cap(X86_FEATURE_PKU); 76 setup_clear_cpu_cap(X86_FEATURE_PKU);
77 setup_clear_cpu_cap(X86_FEATURE_AVX512_4VNNIW);
78 setup_clear_cpu_cap(X86_FEATURE_AVX512_4FMAPS);
77} 79}
78 80
79/* 81/*
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index efe73aacf966..7b0d3da52fb4 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -18,8 +18,10 @@
18 18
19#ifdef CC_USING_FENTRY 19#ifdef CC_USING_FENTRY
20# define function_hook __fentry__ 20# define function_hook __fentry__
21EXPORT_SYMBOL(__fentry__)
21#else 22#else
22# define function_hook mcount 23# define function_hook mcount
24EXPORT_SYMBOL(mcount)
23#endif 25#endif
24 26
25/* All cases save the original rbp (8 bytes) */ 27/* All cases save the original rbp (8 bytes) */
@@ -295,7 +297,6 @@ trace:
295 jmp fgraph_trace 297 jmp fgraph_trace
296END(function_hook) 298END(function_hook)
297#endif /* CONFIG_DYNAMIC_FTRACE */ 299#endif /* CONFIG_DYNAMIC_FTRACE */
298EXPORT_SYMBOL(function_hook)
299#endif /* CONFIG_FUNCTION_TRACER */ 300#endif /* CONFIG_FUNCTION_TRACER */
300 301
301#ifdef CONFIG_FUNCTION_GRAPH_TRACER 302#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 51402a7e4ca6..0bee04d41bed 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -625,8 +625,6 @@ static void amd_disable_seq_and_redirect_scrub(struct pci_dev *dev)
625DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3, 625DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3,
626 amd_disable_seq_and_redirect_scrub); 626 amd_disable_seq_and_redirect_scrub);
627 627
628#endif
629
630#if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE) 628#if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE)
631#include <linux/jump_label.h> 629#include <linux/jump_label.h>
632#include <asm/string_64.h> 630#include <asm/string_64.h>
@@ -657,3 +655,4 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, quirk_intel_brickland_xeon_
657DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, quirk_intel_brickland_xeon_ras_cap); 655DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, quirk_intel_brickland_xeon_ras_cap);
658DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras_cap); 656DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras_cap);
659#endif 657#endif
658#endif
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index bbfbca5fea0c..9c337b0e8ba7 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1221,11 +1221,16 @@ void __init setup_arch(char **cmdline_p)
1221 */ 1221 */
1222 get_smp_config(); 1222 get_smp_config();
1223 1223
1224 /*
1225 * Systems w/o ACPI and mptables might not have it mapped the local
1226 * APIC yet, but prefill_possible_map() might need to access it.
1227 */
1228 init_apic_mappings();
1229
1224 prefill_possible_map(); 1230 prefill_possible_map();
1225 1231
1226 init_cpu_to_node(); 1232 init_cpu_to_node();
1227 1233
1228 init_apic_mappings();
1229 io_apic_init_mappings(); 1234 io_apic_init_mappings();
1230 1235
1231 kvm_guest_init(); 1236 kvm_guest_init();
diff --git a/arch/x86/kernel/signal_compat.c b/arch/x86/kernel/signal_compat.c
index 40df33753bae..ec1f756f9dc9 100644
--- a/arch/x86/kernel/signal_compat.c
+++ b/arch/x86/kernel/signal_compat.c
@@ -105,9 +105,6 @@ void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
105 /* Don't let flags to be set from userspace */ 105 /* Don't let flags to be set from userspace */
106 act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI); 106 act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
107 107
108 if (user_64bit_mode(current_pt_regs()))
109 return;
110
111 if (in_ia32_syscall()) 108 if (in_ia32_syscall())
112 act->sa.sa_flags |= SA_IA32_ABI; 109 act->sa.sa_flags |= SA_IA32_ABI;
113 if (in_x32_syscall()) 110 if (in_x32_syscall())
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index dcbd45ad8db6..95d6fc549ad5 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1407,15 +1407,17 @@ __init void prefill_possible_map(void)
1407 1407
1408 /* No boot processor was found in mptable or ACPI MADT */ 1408 /* No boot processor was found in mptable or ACPI MADT */
1409 if (!num_processors) { 1409 if (!num_processors) {
1410 int apicid = boot_cpu_physical_apicid; 1410 if (boot_cpu_has(X86_FEATURE_APIC)) {
1411 int cpu = hard_smp_processor_id(); 1411 int apicid = boot_cpu_physical_apicid;
1412 int cpu = hard_smp_processor_id();
1412 1413
1413 pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu); 1414 pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu);
1414 1415
1415 /* Make sure boot cpu is enumerated */ 1416 /* Make sure boot cpu is enumerated */
1416 if (apic->cpu_present_to_apicid(0) == BAD_APICID && 1417 if (apic->cpu_present_to_apicid(0) == BAD_APICID &&
1417 apic->apic_id_valid(apicid)) 1418 apic->apic_id_valid(apicid))
1418 generic_processor_info(apicid, boot_cpu_apic_version); 1419 generic_processor_info(apicid, boot_cpu_apic_version);
1420 }
1419 1421
1420 if (!num_processors) 1422 if (!num_processors)
1421 num_processors = 1; 1423 num_processors = 1;
diff --git a/arch/x86/kernel/unwind_guess.c b/arch/x86/kernel/unwind_guess.c
index 9298993dc8b7..2d721e533cf4 100644
--- a/arch/x86/kernel/unwind_guess.c
+++ b/arch/x86/kernel/unwind_guess.c
@@ -47,7 +47,14 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
47 get_stack_info(first_frame, state->task, &state->stack_info, 47 get_stack_info(first_frame, state->task, &state->stack_info,
48 &state->stack_mask); 48 &state->stack_mask);
49 49
50 if (!__kernel_text_address(*first_frame)) 50 /*
51 * The caller can provide the address of the first frame directly
52 * (first_frame) or indirectly (regs->sp) to indicate which stack frame
53 * to start unwinding at. Skip ahead until we reach it.
54 */
55 if (!unwind_done(state) &&
56 (!on_stack(&state->stack_info, first_frame, sizeof(long)) ||
57 !__kernel_text_address(*first_frame)))
51 unwind_next_frame(state); 58 unwind_next_frame(state);
52} 59}
53EXPORT_SYMBOL_GPL(__unwind_start); 60EXPORT_SYMBOL_GPL(__unwind_start);
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index c7220ba94aa7..1a22de70f7f7 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -594,7 +594,7 @@ static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
594 ioapic->irr = 0; 594 ioapic->irr = 0;
595 ioapic->irr_delivered = 0; 595 ioapic->irr_delivered = 0;
596 ioapic->id = 0; 596 ioapic->id = 0;
597 memset(ioapic->irq_eoi, 0x00, IOAPIC_NUM_PINS); 597 memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
598 rtc_irq_eoi_tracking_reset(ioapic); 598 rtc_irq_eoi_tracking_reset(ioapic);
599} 599}
600 600
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6c633de84dd7..e375235d81c9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5733,13 +5733,13 @@ static int kvmclock_cpu_online(unsigned int cpu)
5733 5733
5734static void kvm_timer_init(void) 5734static void kvm_timer_init(void)
5735{ 5735{
5736 int cpu;
5737
5738 max_tsc_khz = tsc_khz; 5736 max_tsc_khz = tsc_khz;
5739 5737
5740 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) { 5738 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
5741#ifdef CONFIG_CPU_FREQ 5739#ifdef CONFIG_CPU_FREQ
5742 struct cpufreq_policy policy; 5740 struct cpufreq_policy policy;
5741 int cpu;
5742
5743 memset(&policy, 0, sizeof(policy)); 5743 memset(&policy, 0, sizeof(policy));
5744 cpu = get_cpu(); 5744 cpu = get_cpu();
5745 cpufreq_get_policy(&policy, cpu); 5745 cpufreq_get_policy(&policy, cpu);
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index ddd2661c4502..887e57182716 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -104,10 +104,10 @@ void __init kernel_randomize_memory(void)
104 * consistent with the vaddr_start/vaddr_end variables. 104 * consistent with the vaddr_start/vaddr_end variables.
105 */ 105 */
106 BUILD_BUG_ON(vaddr_start >= vaddr_end); 106 BUILD_BUG_ON(vaddr_start >= vaddr_end);
107 BUILD_BUG_ON(config_enabled(CONFIG_X86_ESPFIX64) && 107 BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) &&
108 vaddr_end >= EFI_VA_START); 108 vaddr_end >= EFI_VA_START);
109 BUILD_BUG_ON((config_enabled(CONFIG_X86_ESPFIX64) || 109 BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) ||
110 config_enabled(CONFIG_EFI)) && 110 IS_ENABLED(CONFIG_EFI)) &&
111 vaddr_end >= __START_KERNEL_map); 111 vaddr_end >= __START_KERNEL_map);
112 BUILD_BUG_ON(vaddr_end > __START_KERNEL_map); 112 BUILD_BUG_ON(vaddr_end > __START_KERNEL_map);
113 113
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 170cc4ff057b..83e701f160a9 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -730,6 +730,20 @@ void io_free_memtype(resource_size_t start, resource_size_t end)
730 free_memtype(start, end); 730 free_memtype(start, end);
731} 731}
732 732
733int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size)
734{
735 enum page_cache_mode type = _PAGE_CACHE_MODE_WC;
736
737 return io_reserve_memtype(start, start + size, &type);
738}
739EXPORT_SYMBOL(arch_io_reserve_memtype_wc);
740
741void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size)
742{
743 io_free_memtype(start, start + size);
744}
745EXPORT_SYMBOL(arch_io_free_memtype_wc);
746
733pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 747pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
734 unsigned long size, pgprot_t vma_prot) 748 unsigned long size, pgprot_t vma_prot)
735{ 749{
diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c
index b4d5e95fe4df..4a6a5a26c582 100644
--- a/arch/x86/platform/uv/bios_uv.c
+++ b/arch/x86/platform/uv/bios_uv.c
@@ -40,7 +40,15 @@ s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
40 */ 40 */
41 return BIOS_STATUS_UNIMPLEMENTED; 41 return BIOS_STATUS_UNIMPLEMENTED;
42 42
43 ret = efi_call_virt_pointer(tab, function, (u64)which, a1, a2, a3, a4, a5); 43 /*
44 * If EFI_OLD_MEMMAP is set, we need to fall back to using our old EFI
45 * callback method, which uses efi_call() directly, with the kernel page tables:
46 */
47 if (unlikely(test_bit(EFI_OLD_MEMMAP, &efi.flags)))
48 ret = efi_call((void *)__va(tab->function), (u64)which, a1, a2, a3, a4, a5);
49 else
50 ret = efi_call_virt_pointer(tab, function, (u64)which, a1, a2, a3, a4, a5);
51
44 return ret; 52 return ret;
45} 53}
46EXPORT_SYMBOL_GPL(uv_bios_call); 54EXPORT_SYMBOL_GPL(uv_bios_call);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index c0fdd57da7aa..bdd855685403 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1837,6 +1837,7 @@ static void __init init_hvm_pv_info(void)
1837 1837
1838 xen_domain_type = XEN_HVM_DOMAIN; 1838 xen_domain_type = XEN_HVM_DOMAIN;
1839} 1839}
1840#endif
1840 1841
1841static int xen_cpu_up_prepare(unsigned int cpu) 1842static int xen_cpu_up_prepare(unsigned int cpu)
1842{ 1843{
@@ -1887,6 +1888,7 @@ static int xen_cpu_up_online(unsigned int cpu)
1887 return 0; 1888 return 0;
1888} 1889}
1889 1890
1891#ifdef CONFIG_XEN_PVHVM
1890#ifdef CONFIG_KEXEC_CORE 1892#ifdef CONFIG_KEXEC_CORE
1891static void xen_hvm_shutdown(void) 1893static void xen_hvm_shutdown(void)
1892{ 1894{
diff --git a/block/badblocks.c b/block/badblocks.c
index 7be53cb1cc3c..6ebcef282314 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -133,6 +133,26 @@ retry:
133} 133}
134EXPORT_SYMBOL_GPL(badblocks_check); 134EXPORT_SYMBOL_GPL(badblocks_check);
135 135
136static void badblocks_update_acked(struct badblocks *bb)
137{
138 u64 *p = bb->page;
139 int i;
140 bool unacked = false;
141
142 if (!bb->unacked_exist)
143 return;
144
145 for (i = 0; i < bb->count ; i++) {
146 if (!BB_ACK(p[i])) {
147 unacked = true;
148 break;
149 }
150 }
151
152 if (!unacked)
153 bb->unacked_exist = 0;
154}
155
136/** 156/**
137 * badblocks_set() - Add a range of bad blocks to the table. 157 * badblocks_set() - Add a range of bad blocks to the table.
138 * @bb: the badblocks structure that holds all badblock information 158 * @bb: the badblocks structure that holds all badblock information
@@ -294,6 +314,8 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
294 bb->changed = 1; 314 bb->changed = 1;
295 if (!acknowledged) 315 if (!acknowledged)
296 bb->unacked_exist = 1; 316 bb->unacked_exist = 1;
317 else
318 badblocks_update_acked(bb);
297 write_sequnlock_irqrestore(&bb->lock, flags); 319 write_sequnlock_irqrestore(&bb->lock, flags);
298 320
299 return rv; 321 return rv;
@@ -354,7 +376,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
354 * current range. Earlier ranges could also overlap, 376 * current range. Earlier ranges could also overlap,
355 * but only this one can overlap the end of the range. 377 * but only this one can overlap the end of the range.
356 */ 378 */
357 if (BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > target) { 379 if ((BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > target) &&
380 (BB_OFFSET(p[lo]) < target)) {
358 /* Partial overlap, leave the tail of this range */ 381 /* Partial overlap, leave the tail of this range */
359 int ack = BB_ACK(p[lo]); 382 int ack = BB_ACK(p[lo]);
360 sector_t a = BB_OFFSET(p[lo]); 383 sector_t a = BB_OFFSET(p[lo]);
@@ -377,7 +400,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
377 lo--; 400 lo--;
378 } 401 }
379 while (lo >= 0 && 402 while (lo >= 0 &&
380 BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > s) { 403 (BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > s) &&
404 (BB_OFFSET(p[lo]) < target)) {
381 /* This range does overlap */ 405 /* This range does overlap */
382 if (BB_OFFSET(p[lo]) < s) { 406 if (BB_OFFSET(p[lo]) < s) {
383 /* Keep the early parts of this range. */ 407 /* Keep the early parts of this range. */
@@ -399,6 +423,7 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
399 } 423 }
400 } 424 }
401 425
426 badblocks_update_acked(bb);
402 bb->changed = 1; 427 bb->changed = 1;
403out: 428out:
404 write_sequnlock_irq(&bb->lock); 429 write_sequnlock_irq(&bb->lock);
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 6a14b68b9135..3c882cbc7541 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -343,6 +343,34 @@ static void flush_data_end_io(struct request *rq, int error)
343 struct blk_flush_queue *fq = blk_get_flush_queue(q, NULL); 343 struct blk_flush_queue *fq = blk_get_flush_queue(q, NULL);
344 344
345 /* 345 /*
346 * Updating q->in_flight[] here for making this tag usable
347 * early. Because in blk_queue_start_tag(),
348 * q->in_flight[BLK_RW_ASYNC] is used to limit async I/O and
349 * reserve tags for sync I/O.
350 *
351 * More importantly this way can avoid the following I/O
352 * deadlock:
353 *
354 * - suppose there are 40 fua requests comming to flush queue
355 * and queue depth is 31
356 * - 30 rqs are scheduled then blk_queue_start_tag() can't alloc
357 * tag for async I/O any more
358 * - all the 30 rqs are completed before FLUSH_PENDING_TIMEOUT
359 * and flush_data_end_io() is called
360 * - the other rqs still can't go ahead if not updating
361 * q->in_flight[BLK_RW_ASYNC] here, meantime these rqs
362 * are held in flush data queue and make no progress of
363 * handling post flush rq
364 * - only after the post flush rq is handled, all these rqs
365 * can be completed
366 */
367
368 elv_completed_request(q, rq);
369
370 /* for avoiding double accounting */
371 rq->cmd_flags &= ~REQ_STARTED;
372
373 /*
346 * After populating an empty queue, kick it to avoid stall. Read 374 * After populating an empty queue, kick it to avoid stall. Read
347 * the comment in flush_end_io(). 375 * the comment in flush_end_io().
348 */ 376 */
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ddc2eed64771..f3d27a6dee09 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1217,9 +1217,9 @@ static struct request *blk_mq_map_request(struct request_queue *q,
1217 blk_mq_set_alloc_data(&alloc_data, q, 0, ctx, hctx); 1217 blk_mq_set_alloc_data(&alloc_data, q, 0, ctx, hctx);
1218 rq = __blk_mq_alloc_request(&alloc_data, op, op_flags); 1218 rq = __blk_mq_alloc_request(&alloc_data, op, op_flags);
1219 1219
1220 hctx->queued++; 1220 data->hctx = alloc_data.hctx;
1221 data->hctx = hctx; 1221 data->ctx = alloc_data.ctx;
1222 data->ctx = ctx; 1222 data->hctx->queued++;
1223 return rq; 1223 return rq;
1224} 1224}
1225 1225
diff --git a/drivers/Makefile b/drivers/Makefile
index f0afdfb3c7df..194d20bee7dc 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -21,7 +21,7 @@ obj-y += video/
21obj-y += idle/ 21obj-y += idle/
22 22
23# IPMI must come before ACPI in order to provide IPMI opregion support 23# IPMI must come before ACPI in order to provide IPMI opregion support
24obj-$(CONFIG_IPMI_HANDLER) += char/ipmi/ 24obj-y += char/ipmi/
25 25
26obj-$(CONFIG_ACPI) += acpi/ 26obj-$(CONFIG_ACPI) += acpi/
27obj-$(CONFIG_SFI) += sfi/ 27obj-$(CONFIG_SFI) += sfi/
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index f1e6dcc7a827..54d48b90de2c 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -46,6 +46,7 @@
46#include "acdispat.h" 46#include "acdispat.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "actables.h" 48#include "actables.h"
49#include "acinterp.h"
49 50
50#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
51ACPI_MODULE_NAME("dsinit") 52ACPI_MODULE_NAME("dsinit")
@@ -214,23 +215,17 @@ acpi_ds_initialize_objects(u32 table_index,
214 215
215 /* Walk entire namespace from the supplied root */ 216 /* Walk entire namespace from the supplied root */
216 217
217 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
218 if (ACPI_FAILURE(status)) {
219 return_ACPI_STATUS(status);
220 }
221
222 /* 218 /*
223 * We don't use acpi_walk_namespace since we do not want to acquire 219 * We don't use acpi_walk_namespace since we do not want to acquire
224 * the namespace reader lock. 220 * the namespace reader lock.
225 */ 221 */
226 status = 222 status =
227 acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 223 acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
228 ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object, 224 0, acpi_ds_init_one_object, NULL, &info,
229 NULL, &info, NULL); 225 NULL);
230 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
231 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); 227 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
232 } 228 }
233 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
234 229
235 status = acpi_get_table_by_index(table_index, &table); 230 status = acpi_get_table_by_index(table_index, &table);
236 if (ACPI_FAILURE(status)) { 231 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 32e9ddc0cf2b..2b3210f42a46 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -99,14 +99,11 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node,
99 "Method auto-serialization parse [%4.4s] %p\n", 99 "Method auto-serialization parse [%4.4s] %p\n",
100 acpi_ut_get_node_name(node), node)); 100 acpi_ut_get_node_name(node), node));
101 101
102 acpi_ex_enter_interpreter();
103
104 /* Create/Init a root op for the method parse tree */ 102 /* Create/Init a root op for the method parse tree */
105 103
106 op = acpi_ps_alloc_op(AML_METHOD_OP, obj_desc->method.aml_start); 104 op = acpi_ps_alloc_op(AML_METHOD_OP, obj_desc->method.aml_start);
107 if (!op) { 105 if (!op) {
108 status = AE_NO_MEMORY; 106 return_ACPI_STATUS(AE_NO_MEMORY);
109 goto unlock;
110 } 107 }
111 108
112 acpi_ps_set_name(op, node->name.integer); 109 acpi_ps_set_name(op, node->name.integer);
@@ -118,8 +115,7 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node,
118 acpi_ds_create_walk_state(node->owner_id, NULL, NULL, NULL); 115 acpi_ds_create_walk_state(node->owner_id, NULL, NULL, NULL);
119 if (!walk_state) { 116 if (!walk_state) {
120 acpi_ps_free_op(op); 117 acpi_ps_free_op(op);
121 status = AE_NO_MEMORY; 118 return_ACPI_STATUS(AE_NO_MEMORY);
122 goto unlock;
123 } 119 }
124 120
125 status = acpi_ds_init_aml_walk(walk_state, op, node, 121 status = acpi_ds_init_aml_walk(walk_state, op, node,
@@ -138,8 +134,6 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node,
138 status = acpi_ps_parse_aml(walk_state); 134 status = acpi_ps_parse_aml(walk_state);
139 135
140 acpi_ps_delete_parse_tree(op); 136 acpi_ps_delete_parse_tree(op);
141unlock:
142 acpi_ex_exit_interpreter();
143 return_ACPI_STATUS(status); 137 return_ACPI_STATUS(status);
144} 138}
145 139
@@ -731,26 +725,6 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
731 acpi_ds_method_data_delete_all(walk_state); 725 acpi_ds_method_data_delete_all(walk_state);
732 726
733 /* 727 /*
734 * If method is serialized, release the mutex and restore the
735 * current sync level for this thread
736 */
737 if (method_desc->method.mutex) {
738
739 /* Acquisition Depth handles recursive calls */
740
741 method_desc->method.mutex->mutex.acquisition_depth--;
742 if (!method_desc->method.mutex->mutex.acquisition_depth) {
743 walk_state->thread->current_sync_level =
744 method_desc->method.mutex->mutex.
745 original_sync_level;
746
747 acpi_os_release_mutex(method_desc->method.
748 mutex->mutex.os_mutex);
749 method_desc->method.mutex->mutex.thread_id = 0;
750 }
751 }
752
753 /*
754 * Delete any namespace objects created anywhere within the 728 * Delete any namespace objects created anywhere within the
755 * namespace by the execution of this method. Unless: 729 * namespace by the execution of this method. Unless:
756 * 1) This method is a module-level executable code method, in which 730 * 1) This method is a module-level executable code method, in which
@@ -786,6 +760,26 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
786 ~ACPI_METHOD_MODIFIED_NAMESPACE; 760 ~ACPI_METHOD_MODIFIED_NAMESPACE;
787 } 761 }
788 } 762 }
763
764 /*
765 * If method is serialized, release the mutex and restore the
766 * current sync level for this thread
767 */
768 if (method_desc->method.mutex) {
769
770 /* Acquisition Depth handles recursive calls */
771
772 method_desc->method.mutex->mutex.acquisition_depth--;
773 if (!method_desc->method.mutex->mutex.acquisition_depth) {
774 walk_state->thread->current_sync_level =
775 method_desc->method.mutex->mutex.
776 original_sync_level;
777
778 acpi_os_release_mutex(method_desc->method.
779 mutex->mutex.os_mutex);
780 method_desc->method.mutex->mutex.thread_id = 0;
781 }
782 }
789 } 783 }
790 784
791 /* Decrement the thread count on the method */ 785 /* Decrement the thread count on the method */
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 028b22a3154e..e36218206bb0 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -607,11 +607,9 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
607 } 607 }
608 } 608 }
609 609
610 acpi_ex_exit_interpreter();
611 status = 610 status =
612 acpi_ev_initialize_region 611 acpi_ev_initialize_region
613 (acpi_ns_get_attached_object(node), FALSE); 612 (acpi_ns_get_attached_object(node), FALSE);
614 acpi_ex_enter_interpreter();
615 613
616 if (ACPI_FAILURE(status)) { 614 if (ACPI_FAILURE(status)) {
617 /* 615 /*
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 3843f1fc5dbb..75ddd160a716 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -45,6 +45,7 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acevents.h" 46#include "acevents.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evrgnini") 51ACPI_MODULE_NAME("evrgnini")
@@ -597,9 +598,11 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
597 } 598 }
598 } 599 }
599 600
601 acpi_ex_exit_interpreter();
600 status = 602 status =
601 acpi_ev_execute_reg_method(region_obj, 603 acpi_ev_execute_reg_method(region_obj,
602 ACPI_REG_CONNECT); 604 ACPI_REG_CONNECT);
605 acpi_ex_enter_interpreter();
603 606
604 if (acpi_ns_locked) { 607 if (acpi_ns_locked) {
605 status = 608 status =
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index 334d3c5ba617..d1f20143bb11 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -137,7 +137,9 @@ unlock:
137 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 137 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
138 "**** Begin Table Object Initialization\n")); 138 "**** Begin Table Object Initialization\n"));
139 139
140 acpi_ex_enter_interpreter();
140 status = acpi_ds_initialize_objects(table_index, node); 141 status = acpi_ds_initialize_objects(table_index, node);
142 acpi_ex_exit_interpreter();
141 143
142 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 144 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
143 "**** Completed Table Object Initialization\n")); 145 "**** Completed Table Object Initialization\n"));
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index f0a029e68d3e..0d099a24f776 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -662,7 +662,7 @@ static int ghes_proc(struct ghes *ghes)
662 ghes_do_proc(ghes, ghes->estatus); 662 ghes_do_proc(ghes, ghes->estatus);
663out: 663out:
664 ghes_clear_estatus(ghes); 664 ghes_clear_estatus(ghes);
665 return 0; 665 return rc;
666} 666}
667 667
668static void ghes_add_timer(struct ghes *ghes) 668static void ghes_add_timer(struct ghes *ghes)
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index c983bf733ad3..bc3d914dfc3e 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -87,6 +87,7 @@ struct acpi_pci_link {
87 87
88static LIST_HEAD(acpi_link_list); 88static LIST_HEAD(acpi_link_list);
89static DEFINE_MUTEX(acpi_link_lock); 89static DEFINE_MUTEX(acpi_link_lock);
90static int sci_irq = -1, sci_penalty;
90 91
91/* -------------------------------------------------------------------------- 92/* --------------------------------------------------------------------------
92 PCI Link Device Management 93 PCI Link Device Management
@@ -496,25 +497,13 @@ static int acpi_irq_get_penalty(int irq)
496{ 497{
497 int penalty = 0; 498 int penalty = 0;
498 499
499 /* 500 if (irq == sci_irq)
500 * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict 501 penalty += sci_penalty;
501 * with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
502 * use for PCI IRQs.
503 */
504 if (irq == acpi_gbl_FADT.sci_interrupt) {
505 u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
506
507 if (type != IRQ_TYPE_LEVEL_LOW)
508 penalty += PIRQ_PENALTY_ISA_ALWAYS;
509 else
510 penalty += PIRQ_PENALTY_PCI_USING;
511 }
512 502
513 if (irq < ACPI_MAX_ISA_IRQS) 503 if (irq < ACPI_MAX_ISA_IRQS)
514 return penalty + acpi_isa_irq_penalty[irq]; 504 return penalty + acpi_isa_irq_penalty[irq];
515 505
516 penalty += acpi_irq_pci_sharing_penalty(irq); 506 return penalty + acpi_irq_pci_sharing_penalty(irq);
517 return penalty;
518} 507}
519 508
520int __init acpi_irq_penalty_init(void) 509int __init acpi_irq_penalty_init(void)
@@ -619,6 +608,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
619 acpi_device_bid(link->device)); 608 acpi_device_bid(link->device));
620 return -ENODEV; 609 return -ENODEV;
621 } else { 610 } else {
611 if (link->irq.active < ACPI_MAX_ISA_IRQS)
612 acpi_isa_irq_penalty[link->irq.active] +=
613 PIRQ_PENALTY_PCI_USING;
614
622 printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n", 615 printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
623 acpi_device_name(link->device), 616 acpi_device_name(link->device),
624 acpi_device_bid(link->device), link->irq.active); 617 acpi_device_bid(link->device), link->irq.active);
@@ -849,7 +842,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)
849 continue; 842 continue;
850 843
851 if (used) 844 if (used)
852 new_penalty = acpi_irq_get_penalty(irq) + 845 new_penalty = acpi_isa_irq_penalty[irq] +
853 PIRQ_PENALTY_ISA_USED; 846 PIRQ_PENALTY_ISA_USED;
854 else 847 else
855 new_penalty = 0; 848 new_penalty = 0;
@@ -871,7 +864,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)
871void acpi_penalize_isa_irq(int irq, int active) 864void acpi_penalize_isa_irq(int irq, int active)
872{ 865{
873 if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty))) 866 if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
874 acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) + 867 acpi_isa_irq_penalty[irq] +=
875 (active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING); 868 (active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
876} 869}
877 870
@@ -881,6 +874,17 @@ bool acpi_isa_irq_available(int irq)
881 acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS); 874 acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
882} 875}
883 876
877void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
878{
879 sci_irq = irq;
880
881 if (trigger == ACPI_MADT_TRIGGER_LEVEL &&
882 polarity == ACPI_MADT_POLARITY_ACTIVE_LOW)
883 sci_penalty = PIRQ_PENALTY_PCI_USING;
884 else
885 sci_penalty = PIRQ_PENALTY_ISA_ALWAYS;
886}
887
884/* 888/*
885 * Over-ride default table to reserve additional IRQs for use by ISA 889 * Over-ride default table to reserve additional IRQs for use by ISA
886 * e.g. acpi_irq_isa=5 890 * e.g. acpi_irq_isa=5
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 562af94bec35..3c71b982bf2a 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1002,7 +1002,7 @@ static int binder_dec_node(struct binder_node *node, int strong, int internal)
1002 1002
1003 1003
1004static struct binder_ref *binder_get_ref(struct binder_proc *proc, 1004static struct binder_ref *binder_get_ref(struct binder_proc *proc,
1005 uint32_t desc) 1005 u32 desc, bool need_strong_ref)
1006{ 1006{
1007 struct rb_node *n = proc->refs_by_desc.rb_node; 1007 struct rb_node *n = proc->refs_by_desc.rb_node;
1008 struct binder_ref *ref; 1008 struct binder_ref *ref;
@@ -1010,12 +1010,16 @@ static struct binder_ref *binder_get_ref(struct binder_proc *proc,
1010 while (n) { 1010 while (n) {
1011 ref = rb_entry(n, struct binder_ref, rb_node_desc); 1011 ref = rb_entry(n, struct binder_ref, rb_node_desc);
1012 1012
1013 if (desc < ref->desc) 1013 if (desc < ref->desc) {
1014 n = n->rb_left; 1014 n = n->rb_left;
1015 else if (desc > ref->desc) 1015 } else if (desc > ref->desc) {
1016 n = n->rb_right; 1016 n = n->rb_right;
1017 else 1017 } else if (need_strong_ref && !ref->strong) {
1018 binder_user_error("tried to use weak ref as strong ref\n");
1019 return NULL;
1020 } else {
1018 return ref; 1021 return ref;
1022 }
1019 } 1023 }
1020 return NULL; 1024 return NULL;
1021} 1025}
@@ -1285,7 +1289,10 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
1285 } break; 1289 } break;
1286 case BINDER_TYPE_HANDLE: 1290 case BINDER_TYPE_HANDLE:
1287 case BINDER_TYPE_WEAK_HANDLE: { 1291 case BINDER_TYPE_WEAK_HANDLE: {
1288 struct binder_ref *ref = binder_get_ref(proc, fp->handle); 1292 struct binder_ref *ref;
1293
1294 ref = binder_get_ref(proc, fp->handle,
1295 fp->type == BINDER_TYPE_HANDLE);
1289 1296
1290 if (ref == NULL) { 1297 if (ref == NULL) {
1291 pr_err("transaction release %d bad handle %d\n", 1298 pr_err("transaction release %d bad handle %d\n",
@@ -1380,7 +1387,7 @@ static void binder_transaction(struct binder_proc *proc,
1380 if (tr->target.handle) { 1387 if (tr->target.handle) {
1381 struct binder_ref *ref; 1388 struct binder_ref *ref;
1382 1389
1383 ref = binder_get_ref(proc, tr->target.handle); 1390 ref = binder_get_ref(proc, tr->target.handle, true);
1384 if (ref == NULL) { 1391 if (ref == NULL) {
1385 binder_user_error("%d:%d got transaction to invalid handle\n", 1392 binder_user_error("%d:%d got transaction to invalid handle\n",
1386 proc->pid, thread->pid); 1393 proc->pid, thread->pid);
@@ -1577,7 +1584,9 @@ static void binder_transaction(struct binder_proc *proc,
1577 fp->type = BINDER_TYPE_HANDLE; 1584 fp->type = BINDER_TYPE_HANDLE;
1578 else 1585 else
1579 fp->type = BINDER_TYPE_WEAK_HANDLE; 1586 fp->type = BINDER_TYPE_WEAK_HANDLE;
1587 fp->binder = 0;
1580 fp->handle = ref->desc; 1588 fp->handle = ref->desc;
1589 fp->cookie = 0;
1581 binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, 1590 binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE,
1582 &thread->todo); 1591 &thread->todo);
1583 1592
@@ -1589,7 +1598,10 @@ static void binder_transaction(struct binder_proc *proc,
1589 } break; 1598 } break;
1590 case BINDER_TYPE_HANDLE: 1599 case BINDER_TYPE_HANDLE:
1591 case BINDER_TYPE_WEAK_HANDLE: { 1600 case BINDER_TYPE_WEAK_HANDLE: {
1592 struct binder_ref *ref = binder_get_ref(proc, fp->handle); 1601 struct binder_ref *ref;
1602
1603 ref = binder_get_ref(proc, fp->handle,
1604 fp->type == BINDER_TYPE_HANDLE);
1593 1605
1594 if (ref == NULL) { 1606 if (ref == NULL) {
1595 binder_user_error("%d:%d got transaction with invalid handle, %d\n", 1607 binder_user_error("%d:%d got transaction with invalid handle, %d\n",
@@ -1624,7 +1636,9 @@ static void binder_transaction(struct binder_proc *proc,
1624 return_error = BR_FAILED_REPLY; 1636 return_error = BR_FAILED_REPLY;
1625 goto err_binder_get_ref_for_node_failed; 1637 goto err_binder_get_ref_for_node_failed;
1626 } 1638 }
1639 fp->binder = 0;
1627 fp->handle = new_ref->desc; 1640 fp->handle = new_ref->desc;
1641 fp->cookie = 0;
1628 binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); 1642 binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL);
1629 trace_binder_transaction_ref_to_ref(t, ref, 1643 trace_binder_transaction_ref_to_ref(t, ref,
1630 new_ref); 1644 new_ref);
@@ -1678,6 +1692,7 @@ static void binder_transaction(struct binder_proc *proc,
1678 binder_debug(BINDER_DEBUG_TRANSACTION, 1692 binder_debug(BINDER_DEBUG_TRANSACTION,
1679 " fd %d -> %d\n", fp->handle, target_fd); 1693 " fd %d -> %d\n", fp->handle, target_fd);
1680 /* TODO: fput? */ 1694 /* TODO: fput? */
1695 fp->binder = 0;
1681 fp->handle = target_fd; 1696 fp->handle = target_fd;
1682 } break; 1697 } break;
1683 1698
@@ -1800,7 +1815,9 @@ static int binder_thread_write(struct binder_proc *proc,
1800 ref->desc); 1815 ref->desc);
1801 } 1816 }
1802 } else 1817 } else
1803 ref = binder_get_ref(proc, target); 1818 ref = binder_get_ref(proc, target,
1819 cmd == BC_ACQUIRE ||
1820 cmd == BC_RELEASE);
1804 if (ref == NULL) { 1821 if (ref == NULL) {
1805 binder_user_error("%d:%d refcount change on invalid ref %d\n", 1822 binder_user_error("%d:%d refcount change on invalid ref %d\n",
1806 proc->pid, thread->pid, target); 1823 proc->pid, thread->pid, target);
@@ -1996,7 +2013,7 @@ static int binder_thread_write(struct binder_proc *proc,
1996 if (get_user(cookie, (binder_uintptr_t __user *)ptr)) 2013 if (get_user(cookie, (binder_uintptr_t __user *)ptr))
1997 return -EFAULT; 2014 return -EFAULT;
1998 ptr += sizeof(binder_uintptr_t); 2015 ptr += sizeof(binder_uintptr_t);
1999 ref = binder_get_ref(proc, target); 2016 ref = binder_get_ref(proc, target, false);
2000 if (ref == NULL) { 2017 if (ref == NULL) {
2001 binder_user_error("%d:%d %s invalid ref %d\n", 2018 binder_user_error("%d:%d %s invalid ref %d\n",
2002 proc->pid, thread->pid, 2019 proc->pid, thread->pid,
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index ba5f11cebee2..9669fc7c19df 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1418,31 +1418,34 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
1418 * Message mode could be enforced. In this case assume that advantage 1418 * Message mode could be enforced. In this case assume that advantage
1419 * of multipe MSIs is negated and use single MSI mode instead. 1419 * of multipe MSIs is negated and use single MSI mode instead.
1420 */ 1420 */
1421 nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX, 1421 if (n_ports > 1) {
1422 PCI_IRQ_MSIX | PCI_IRQ_MSI); 1422 nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX,
1423 if (nvec > 0) { 1423 PCI_IRQ_MSIX | PCI_IRQ_MSI);
1424 if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) { 1424 if (nvec > 0) {
1425 hpriv->get_irq_vector = ahci_get_irq_vector; 1425 if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
1426 hpriv->flags |= AHCI_HFLAG_MULTI_MSI; 1426 hpriv->get_irq_vector = ahci_get_irq_vector;
1427 return nvec; 1427 hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1428 return nvec;
1429 }
1430
1431 /*
1432 * Fallback to single MSI mode if the controller
1433 * enforced MRSM mode.
1434 */
1435 printk(KERN_INFO
1436 "ahci: MRSM is on, fallback to single MSI\n");
1437 pci_free_irq_vectors(pdev);
1428 } 1438 }
1429 1439
1430 /* 1440 /*
1431 * Fallback to single MSI mode if the controller enforced MRSM 1441 * -ENOSPC indicated we don't have enough vectors. Don't bother
1432 * mode. 1442 * trying a single vectors for any other error:
1433 */ 1443 */
1434 printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n"); 1444 if (nvec < 0 && nvec != -ENOSPC)
1435 pci_free_irq_vectors(pdev); 1445 return nvec;
1436 } 1446 }
1437 1447
1438 /* 1448 /*
1439 * -ENOSPC indicated we don't have enough vectors. Don't bother trying
1440 * a single vectors for any other error:
1441 */
1442 if (nvec < 0 && nvec != -ENOSPC)
1443 return nvec;
1444
1445 /*
1446 * If the host is not capable of supporting per-port vectors, fall 1449 * If the host is not capable of supporting per-port vectors, fall
1447 * back to single MSI before finally attempting single MSI-X. 1450 * back to single MSI before finally attempting single MSI-X.
1448 */ 1451 */
@@ -1617,7 +1620,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1617 /* legacy intx interrupts */ 1620 /* legacy intx interrupts */
1618 pci_intx(pdev, 1); 1621 pci_intx(pdev, 1);
1619 } 1622 }
1620 hpriv->irq = pdev->irq; 1623 hpriv->irq = pci_irq_vector(pdev, 0);
1621 1624
1622 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) 1625 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
1623 host->flags |= ATA_HOST_PARALLEL_SCAN; 1626 host->flags |= ATA_HOST_PARALLEL_SCAN;
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index fdf44cac08e6..d02e7c0f5bfd 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -213,14 +213,16 @@ config DEBUG_DEVRES
213 If you are unsure about this, Say N here. 213 If you are unsure about this, Say N here.
214 214
215config DEBUG_TEST_DRIVER_REMOVE 215config DEBUG_TEST_DRIVER_REMOVE
216 bool "Test driver remove calls during probe" 216 bool "Test driver remove calls during probe (UNSTABLE)"
217 depends on DEBUG_KERNEL 217 depends on DEBUG_KERNEL
218 help 218 help
219 Say Y here if you want the Driver core to test driver remove functions 219 Say Y here if you want the Driver core to test driver remove functions
220 by calling probe, remove, probe. This tests the remove path without 220 by calling probe, remove, probe. This tests the remove path without
221 having to unbind the driver or unload the driver module. 221 having to unbind the driver or unload the driver module.
222 222
223 If you are unsure about this, say N here. 223 This option is expected to find errors and may render your system
224 unusable. You should say N here unless you are explicitly looking to
225 test this functionality.
224 226
225config SYS_HYPERVISOR 227config SYS_HYPERVISOR
226 bool 228 bool
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 811e11c82f32..0809cda93cc0 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -2954,7 +2954,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2954 case DAC960_PD_Controller: 2954 case DAC960_PD_Controller:
2955 if (!request_region(Controller->IO_Address, 0x80, 2955 if (!request_region(Controller->IO_Address, 0x80,
2956 Controller->FullModelName)) { 2956 Controller->FullModelName)) {
2957 DAC960_Error("IO port 0x%d busy for Controller at\n", 2957 DAC960_Error("IO port 0x%lx busy for Controller at\n",
2958 Controller, Controller->IO_Address); 2958 Controller, Controller->IO_Address);
2959 goto Failure; 2959 goto Failure;
2960 } 2960 }
@@ -2990,7 +2990,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2990 case DAC960_P_Controller: 2990 case DAC960_P_Controller:
2991 if (!request_region(Controller->IO_Address, 0x80, 2991 if (!request_region(Controller->IO_Address, 0x80,
2992 Controller->FullModelName)){ 2992 Controller->FullModelName)){
2993 DAC960_Error("IO port 0x%d busy for Controller at\n", 2993 DAC960_Error("IO port 0x%lx busy for Controller at\n",
2994 Controller, Controller->IO_Address); 2994 Controller, Controller->IO_Address);
2995 goto Failure; 2995 goto Failure;
2996 } 2996 }
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index ba405b55329f..19a16b2dbb91 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -164,7 +164,7 @@ static void sock_shutdown(struct nbd_device *nbd)
164 spin_lock(&nbd->sock_lock); 164 spin_lock(&nbd->sock_lock);
165 165
166 if (!nbd->sock) { 166 if (!nbd->sock) {
167 spin_unlock_irq(&nbd->sock_lock); 167 spin_unlock(&nbd->sock_lock);
168 return; 168 return;
169 } 169 }
170 170
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index abb71628ab61..7b274ff4632c 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -415,15 +415,15 @@ struct rbd_device {
415}; 415};
416 416
417/* 417/*
418 * Flag bits for rbd_dev->flags. If atomicity is required, 418 * Flag bits for rbd_dev->flags:
419 * rbd_dev->lock is used to protect access. 419 * - REMOVING (which is coupled with rbd_dev->open_count) is protected
420 * 420 * by rbd_dev->lock
421 * Currently, only the "removing" flag (which is coupled with the 421 * - BLACKLISTED is protected by rbd_dev->lock_rwsem
422 * "open_count" field) requires atomic access.
423 */ 422 */
424enum rbd_dev_flags { 423enum rbd_dev_flags {
425 RBD_DEV_FLAG_EXISTS, /* mapped snapshot has not been deleted */ 424 RBD_DEV_FLAG_EXISTS, /* mapped snapshot has not been deleted */
426 RBD_DEV_FLAG_REMOVING, /* this mapping is being removed */ 425 RBD_DEV_FLAG_REMOVING, /* this mapping is being removed */
426 RBD_DEV_FLAG_BLACKLISTED, /* our ceph_client is blacklisted */
427}; 427};
428 428
429static DEFINE_MUTEX(client_mutex); /* Serialize client creation */ 429static DEFINE_MUTEX(client_mutex); /* Serialize client creation */
@@ -3926,6 +3926,7 @@ static void rbd_reregister_watch(struct work_struct *work)
3926 struct rbd_device *rbd_dev = container_of(to_delayed_work(work), 3926 struct rbd_device *rbd_dev = container_of(to_delayed_work(work),
3927 struct rbd_device, watch_dwork); 3927 struct rbd_device, watch_dwork);
3928 bool was_lock_owner = false; 3928 bool was_lock_owner = false;
3929 bool need_to_wake = false;
3929 int ret; 3930 int ret;
3930 3931
3931 dout("%s rbd_dev %p\n", __func__, rbd_dev); 3932 dout("%s rbd_dev %p\n", __func__, rbd_dev);
@@ -3935,19 +3936,27 @@ static void rbd_reregister_watch(struct work_struct *work)
3935 was_lock_owner = rbd_release_lock(rbd_dev); 3936 was_lock_owner = rbd_release_lock(rbd_dev);
3936 3937
3937 mutex_lock(&rbd_dev->watch_mutex); 3938 mutex_lock(&rbd_dev->watch_mutex);
3938 if (rbd_dev->watch_state != RBD_WATCH_STATE_ERROR) 3939 if (rbd_dev->watch_state != RBD_WATCH_STATE_ERROR) {
3939 goto fail_unlock; 3940 mutex_unlock(&rbd_dev->watch_mutex);
3941 goto out;
3942 }
3940 3943
3941 ret = __rbd_register_watch(rbd_dev); 3944 ret = __rbd_register_watch(rbd_dev);
3942 if (ret) { 3945 if (ret) {
3943 rbd_warn(rbd_dev, "failed to reregister watch: %d", ret); 3946 rbd_warn(rbd_dev, "failed to reregister watch: %d", ret);
3944 if (ret != -EBLACKLISTED) 3947 if (ret == -EBLACKLISTED || ret == -ENOENT) {
3948 set_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags);
3949 need_to_wake = true;
3950 } else {
3945 queue_delayed_work(rbd_dev->task_wq, 3951 queue_delayed_work(rbd_dev->task_wq,
3946 &rbd_dev->watch_dwork, 3952 &rbd_dev->watch_dwork,
3947 RBD_RETRY_DELAY); 3953 RBD_RETRY_DELAY);
3948 goto fail_unlock; 3954 }
3955 mutex_unlock(&rbd_dev->watch_mutex);
3956 goto out;
3949 } 3957 }
3950 3958
3959 need_to_wake = true;
3951 rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED; 3960 rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED;
3952 rbd_dev->watch_cookie = rbd_dev->watch_handle->linger_id; 3961 rbd_dev->watch_cookie = rbd_dev->watch_handle->linger_id;
3953 mutex_unlock(&rbd_dev->watch_mutex); 3962 mutex_unlock(&rbd_dev->watch_mutex);
@@ -3963,13 +3972,10 @@ static void rbd_reregister_watch(struct work_struct *work)
3963 ret); 3972 ret);
3964 } 3973 }
3965 3974
3975out:
3966 up_write(&rbd_dev->lock_rwsem); 3976 up_write(&rbd_dev->lock_rwsem);
3967 wake_requests(rbd_dev, true); 3977 if (need_to_wake)
3968 return; 3978 wake_requests(rbd_dev, true);
3969
3970fail_unlock:
3971 mutex_unlock(&rbd_dev->watch_mutex);
3972 up_write(&rbd_dev->lock_rwsem);
3973} 3979}
3974 3980
3975/* 3981/*
@@ -4074,7 +4080,9 @@ static void rbd_wait_state_locked(struct rbd_device *rbd_dev)
4074 up_read(&rbd_dev->lock_rwsem); 4080 up_read(&rbd_dev->lock_rwsem);
4075 schedule(); 4081 schedule();
4076 down_read(&rbd_dev->lock_rwsem); 4082 down_read(&rbd_dev->lock_rwsem);
4077 } while (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED); 4083 } while (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED &&
4084 !test_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags));
4085
4078 finish_wait(&rbd_dev->lock_waitq, &wait); 4086 finish_wait(&rbd_dev->lock_waitq, &wait);
4079} 4087}
4080 4088
@@ -4166,8 +4174,16 @@ static void rbd_queue_workfn(struct work_struct *work)
4166 4174
4167 if (must_be_locked) { 4175 if (must_be_locked) {
4168 down_read(&rbd_dev->lock_rwsem); 4176 down_read(&rbd_dev->lock_rwsem);
4169 if (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED) 4177 if (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED &&
4178 !test_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags))
4170 rbd_wait_state_locked(rbd_dev); 4179 rbd_wait_state_locked(rbd_dev);
4180
4181 WARN_ON((rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED) ^
4182 !test_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags));
4183 if (test_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags)) {
4184 result = -EBLACKLISTED;
4185 goto err_unlock;
4186 }
4171 } 4187 }
4172 4188
4173 img_request = rbd_img_request_create(rbd_dev, offset, length, op_type, 4189 img_request = rbd_img_request_create(rbd_dev, offset, length, op_type,
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index ef51c9c864c5..b6bb58c41df5 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -310,7 +310,7 @@ static int bt_ti_probe(struct platform_device *pdev)
310 BT_DBG("HCI device registered (hdev %p)", hdev); 310 BT_DBG("HCI device registered (hdev %p)", hdev);
311 311
312 dev_set_drvdata(&pdev->dev, hst); 312 dev_set_drvdata(&pdev->dev, hst);
313 return err; 313 return 0;
314} 314}
315 315
316static int bt_ti_remove(struct platform_device *pdev) 316static int bt_ti_remove(struct platform_device *pdev)
diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 5ccb90ef0146..8f6c23c20c52 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -643,6 +643,14 @@ static const struct dmi_system_id bcm_wrong_irq_dmi_table[] = {
643 }, 643 },
644 .driver_data = &acpi_active_low, 644 .driver_data = &acpi_active_low,
645 }, 645 },
646 { /* Handle ThinkPad 8 tablets with BCM2E55 chipset ACPI ID */
647 .ident = "Lenovo ThinkPad 8",
648 .matches = {
649 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
650 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 8"),
651 },
652 .driver_data = &acpi_active_low,
653 },
646 { } 654 { }
647}; 655};
648 656
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index 7010dcac9328..78751057164a 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -111,6 +111,7 @@ config OMAP_OCP2SCP
111config QCOM_EBI2 111config QCOM_EBI2
112 bool "Qualcomm External Bus Interface 2 (EBI2)" 112 bool "Qualcomm External Bus Interface 2 (EBI2)"
113 depends on HAS_IOMEM 113 depends on HAS_IOMEM
114 depends on ARCH_QCOM || COMPILE_TEST
114 help 115 help
115 Say y here to enable support for the Qualcomm External Bus 116 Say y here to enable support for the Qualcomm External Bus
116 Interface 2, which can be used to connect things like NAND Flash, 117 Interface 2, which can be used to connect things like NAND Flash,
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 482794526e8c..d2d2c89de5b4 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -84,14 +84,14 @@ static size_t rng_buffer_size(void)
84 84
85static void add_early_randomness(struct hwrng *rng) 85static void add_early_randomness(struct hwrng *rng)
86{ 86{
87 unsigned char bytes[16];
88 int bytes_read; 87 int bytes_read;
88 size_t size = min_t(size_t, 16, rng_buffer_size());
89 89
90 mutex_lock(&reading_mutex); 90 mutex_lock(&reading_mutex);
91 bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); 91 bytes_read = rng_get_data(rng, rng_buffer, size, 1);
92 mutex_unlock(&reading_mutex); 92 mutex_unlock(&reading_mutex);
93 if (bytes_read > 0) 93 if (bytes_read > 0)
94 add_device_randomness(bytes, bytes_read); 94 add_device_randomness(rng_buffer, bytes_read);
95} 95}
96 96
97static inline void cleanup_rng(struct kref *kref) 97static inline void cleanup_rng(struct kref *kref)
diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig
index 5a9350b1069a..7f816655cbbf 100644
--- a/drivers/char/ipmi/Kconfig
+++ b/drivers/char/ipmi/Kconfig
@@ -76,3 +76,11 @@ config IPMI_POWEROFF
76 the IPMI management controller is capable of this. 76 the IPMI management controller is capable of this.
77 77
78endif # IPMI_HANDLER 78endif # IPMI_HANDLER
79
80config ASPEED_BT_IPMI_BMC
81 depends on ARCH_ASPEED
82 tristate "BT IPMI bmc driver"
83 help
84 Provides a driver for the BT (Block Transfer) IPMI interface
85 found on Aspeed SOCs (AST2400 and AST2500). The driver
86 implements the BMC side of the BT interface.
diff --git a/drivers/char/ipmi/Makefile b/drivers/char/ipmi/Makefile
index f3ffde1f5f1f..0d98cd91def1 100644
--- a/drivers/char/ipmi/Makefile
+++ b/drivers/char/ipmi/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_IPMI_SSIF) += ipmi_ssif.o
11obj-$(CONFIG_IPMI_POWERNV) += ipmi_powernv.o 11obj-$(CONFIG_IPMI_POWERNV) += ipmi_powernv.o
12obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o 12obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o
13obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o 13obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o
14obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += bt-bmc.o
diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
new file mode 100644
index 000000000000..b49e61320952
--- /dev/null
+++ b/drivers/char/ipmi/bt-bmc.c
@@ -0,0 +1,505 @@
1/*
2 * Copyright (c) 2015-2016, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#include <linux/atomic.h>
11#include <linux/bt-bmc.h>
12#include <linux/errno.h>
13#include <linux/interrupt.h>
14#include <linux/io.h>
15#include <linux/miscdevice.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18#include <linux/poll.h>
19#include <linux/sched.h>
20#include <linux/timer.h>
21
22/*
23 * This is a BMC device used to communicate to the host
24 */
25#define DEVICE_NAME "ipmi-bt-host"
26
27#define BT_IO_BASE 0xe4
28#define BT_IRQ 10
29
30#define BT_CR0 0x0
31#define BT_CR0_IO_BASE 16
32#define BT_CR0_IRQ 12
33#define BT_CR0_EN_CLR_SLV_RDP 0x8
34#define BT_CR0_EN_CLR_SLV_WRP 0x4
35#define BT_CR0_ENABLE_IBT 0x1
36#define BT_CR1 0x4
37#define BT_CR1_IRQ_H2B 0x01
38#define BT_CR1_IRQ_HBUSY 0x40
39#define BT_CR2 0x8
40#define BT_CR2_IRQ_H2B 0x01
41#define BT_CR2_IRQ_HBUSY 0x40
42#define BT_CR3 0xc
43#define BT_CTRL 0x10
44#define BT_CTRL_B_BUSY 0x80
45#define BT_CTRL_H_BUSY 0x40
46#define BT_CTRL_OEM0 0x20
47#define BT_CTRL_SMS_ATN 0x10
48#define BT_CTRL_B2H_ATN 0x08
49#define BT_CTRL_H2B_ATN 0x04
50#define BT_CTRL_CLR_RD_PTR 0x02
51#define BT_CTRL_CLR_WR_PTR 0x01
52#define BT_BMC2HOST 0x14
53#define BT_INTMASK 0x18
54#define BT_INTMASK_B2H_IRQEN 0x01
55#define BT_INTMASK_B2H_IRQ 0x02
56#define BT_INTMASK_BMC_HWRST 0x80
57
58#define BT_BMC_BUFFER_SIZE 256
59
60struct bt_bmc {
61 struct device dev;
62 struct miscdevice miscdev;
63 void __iomem *base;
64 int irq;
65 wait_queue_head_t queue;
66 struct timer_list poll_timer;
67 struct mutex mutex;
68};
69
70static atomic_t open_count = ATOMIC_INIT(0);
71
72static u8 bt_inb(struct bt_bmc *bt_bmc, int reg)
73{
74 return ioread8(bt_bmc->base + reg);
75}
76
77static void bt_outb(struct bt_bmc *bt_bmc, u8 data, int reg)
78{
79 iowrite8(data, bt_bmc->base + reg);
80}
81
82static void clr_rd_ptr(struct bt_bmc *bt_bmc)
83{
84 bt_outb(bt_bmc, BT_CTRL_CLR_RD_PTR, BT_CTRL);
85}
86
87static void clr_wr_ptr(struct bt_bmc *bt_bmc)
88{
89 bt_outb(bt_bmc, BT_CTRL_CLR_WR_PTR, BT_CTRL);
90}
91
92static void clr_h2b_atn(struct bt_bmc *bt_bmc)
93{
94 bt_outb(bt_bmc, BT_CTRL_H2B_ATN, BT_CTRL);
95}
96
97static void set_b_busy(struct bt_bmc *bt_bmc)
98{
99 if (!(bt_inb(bt_bmc, BT_CTRL) & BT_CTRL_B_BUSY))
100 bt_outb(bt_bmc, BT_CTRL_B_BUSY, BT_CTRL);
101}
102
103static void clr_b_busy(struct bt_bmc *bt_bmc)
104{
105 if (bt_inb(bt_bmc, BT_CTRL) & BT_CTRL_B_BUSY)
106 bt_outb(bt_bmc, BT_CTRL_B_BUSY, BT_CTRL);
107}
108
109static void set_b2h_atn(struct bt_bmc *bt_bmc)
110{
111 bt_outb(bt_bmc, BT_CTRL_B2H_ATN, BT_CTRL);
112}
113
114static u8 bt_read(struct bt_bmc *bt_bmc)
115{
116 return bt_inb(bt_bmc, BT_BMC2HOST);
117}
118
119static ssize_t bt_readn(struct bt_bmc *bt_bmc, u8 *buf, size_t n)
120{
121 int i;
122
123 for (i = 0; i < n; i++)
124 buf[i] = bt_read(bt_bmc);
125 return n;
126}
127
128static void bt_write(struct bt_bmc *bt_bmc, u8 c)
129{
130 bt_outb(bt_bmc, c, BT_BMC2HOST);
131}
132
133static ssize_t bt_writen(struct bt_bmc *bt_bmc, u8 *buf, size_t n)
134{
135 int i;
136
137 for (i = 0; i < n; i++)
138 bt_write(bt_bmc, buf[i]);
139 return n;
140}
141
142static void set_sms_atn(struct bt_bmc *bt_bmc)
143{
144 bt_outb(bt_bmc, BT_CTRL_SMS_ATN, BT_CTRL);
145}
146
147static struct bt_bmc *file_bt_bmc(struct file *file)
148{
149 return container_of(file->private_data, struct bt_bmc, miscdev);
150}
151
152static int bt_bmc_open(struct inode *inode, struct file *file)
153{
154 struct bt_bmc *bt_bmc = file_bt_bmc(file);
155
156 if (atomic_inc_return(&open_count) == 1) {
157 clr_b_busy(bt_bmc);
158 return 0;
159 }
160
161 atomic_dec(&open_count);
162 return -EBUSY;
163}
164
165/*
166 * The BT (Block Transfer) interface means that entire messages are
167 * buffered by the host before a notification is sent to the BMC that
168 * there is data to be read. The first byte is the length and the
169 * message data follows. The read operation just tries to capture the
170 * whole before returning it to userspace.
171 *
172 * BT Message format :
173 *
174 * Byte 1 Byte 2 Byte 3 Byte 4 Byte 5:N
175 * Length NetFn/LUN Seq Cmd Data
176 *
177 */
178static ssize_t bt_bmc_read(struct file *file, char __user *buf,
179 size_t count, loff_t *ppos)
180{
181 struct bt_bmc *bt_bmc = file_bt_bmc(file);
182 u8 len;
183 int len_byte = 1;
184 u8 kbuffer[BT_BMC_BUFFER_SIZE];
185 ssize_t ret = 0;
186 ssize_t nread;
187
188 if (!access_ok(VERIFY_WRITE, buf, count))
189 return -EFAULT;
190
191 WARN_ON(*ppos);
192
193 if (wait_event_interruptible(bt_bmc->queue,
194 bt_inb(bt_bmc, BT_CTRL) & BT_CTRL_H2B_ATN))
195 return -ERESTARTSYS;
196
197 mutex_lock(&bt_bmc->mutex);
198
199 if (unlikely(!(bt_inb(bt_bmc, BT_CTRL) & BT_CTRL_H2B_ATN))) {
200 ret = -EIO;
201 goto out_unlock;
202 }
203
204 set_b_busy(bt_bmc);
205 clr_h2b_atn(bt_bmc);
206 clr_rd_ptr(bt_bmc);
207
208 /*
209 * The BT frames start with the message length, which does not
210 * include the length byte.
211 */
212 kbuffer[0] = bt_read(bt_bmc);
213 len = kbuffer[0];
214
215 /* We pass the length back to userspace as well */
216 if (len + 1 > count)
217 len = count - 1;
218
219 while (len) {
220 nread = min_t(ssize_t, len, sizeof(kbuffer) - len_byte);
221
222 bt_readn(bt_bmc, kbuffer + len_byte, nread);
223
224 if (copy_to_user(buf, kbuffer, nread + len_byte)) {
225 ret = -EFAULT;
226 break;
227 }
228 len -= nread;
229 buf += nread + len_byte;
230 ret += nread + len_byte;
231 len_byte = 0;
232 }
233
234 clr_b_busy(bt_bmc);
235
236out_unlock:
237 mutex_unlock(&bt_bmc->mutex);
238 return ret;
239}
240
241/*
242 * BT Message response format :
243 *
244 * Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6:N
245 * Length NetFn/LUN Seq Cmd Code Data
246 */
247static ssize_t bt_bmc_write(struct file *file, const char __user *buf,
248 size_t count, loff_t *ppos)
249{
250 struct bt_bmc *bt_bmc = file_bt_bmc(file);
251 u8 kbuffer[BT_BMC_BUFFER_SIZE];
252 ssize_t ret = 0;
253 ssize_t nwritten;
254
255 /*
256 * send a minimum response size
257 */
258 if (count < 5)
259 return -EINVAL;
260
261 if (!access_ok(VERIFY_READ, buf, count))
262 return -EFAULT;
263
264 WARN_ON(*ppos);
265
266 /*
267 * There's no interrupt for clearing bmc busy so we have to
268 * poll
269 */
270 if (wait_event_interruptible(bt_bmc->queue,
271 !(bt_inb(bt_bmc, BT_CTRL) &
272 (BT_CTRL_H_BUSY | BT_CTRL_B2H_ATN))))
273 return -ERESTARTSYS;
274
275 mutex_lock(&bt_bmc->mutex);
276
277 if (unlikely(bt_inb(bt_bmc, BT_CTRL) &
278 (BT_CTRL_H_BUSY | BT_CTRL_B2H_ATN))) {
279 ret = -EIO;
280 goto out_unlock;
281 }
282
283 clr_wr_ptr(bt_bmc);
284
285 while (count) {
286 nwritten = min_t(ssize_t, count, sizeof(kbuffer));
287 if (copy_from_user(&kbuffer, buf, nwritten)) {
288 ret = -EFAULT;
289 break;
290 }
291
292 bt_writen(bt_bmc, kbuffer, nwritten);
293
294 count -= nwritten;
295 buf += nwritten;
296 ret += nwritten;
297 }
298
299 set_b2h_atn(bt_bmc);
300
301out_unlock:
302 mutex_unlock(&bt_bmc->mutex);
303 return ret;
304}
305
306static long bt_bmc_ioctl(struct file *file, unsigned int cmd,
307 unsigned long param)
308{
309 struct bt_bmc *bt_bmc = file_bt_bmc(file);
310
311 switch (cmd) {
312 case BT_BMC_IOCTL_SMS_ATN:
313 set_sms_atn(bt_bmc);
314 return 0;
315 }
316 return -EINVAL;
317}
318
319static int bt_bmc_release(struct inode *inode, struct file *file)
320{
321 struct bt_bmc *bt_bmc = file_bt_bmc(file);
322
323 atomic_dec(&open_count);
324 set_b_busy(bt_bmc);
325 return 0;
326}
327
328static unsigned int bt_bmc_poll(struct file *file, poll_table *wait)
329{
330 struct bt_bmc *bt_bmc = file_bt_bmc(file);
331 unsigned int mask = 0;
332 u8 ctrl;
333
334 poll_wait(file, &bt_bmc->queue, wait);
335
336 ctrl = bt_inb(bt_bmc, BT_CTRL);
337
338 if (ctrl & BT_CTRL_H2B_ATN)
339 mask |= POLLIN;
340
341 if (!(ctrl & (BT_CTRL_H_BUSY | BT_CTRL_B2H_ATN)))
342 mask |= POLLOUT;
343
344 return mask;
345}
346
347static const struct file_operations bt_bmc_fops = {
348 .owner = THIS_MODULE,
349 .open = bt_bmc_open,
350 .read = bt_bmc_read,
351 .write = bt_bmc_write,
352 .release = bt_bmc_release,
353 .poll = bt_bmc_poll,
354 .unlocked_ioctl = bt_bmc_ioctl,
355};
356
357static void poll_timer(unsigned long data)
358{
359 struct bt_bmc *bt_bmc = (void *)data;
360
361 bt_bmc->poll_timer.expires += msecs_to_jiffies(500);
362 wake_up(&bt_bmc->queue);
363 add_timer(&bt_bmc->poll_timer);
364}
365
366static irqreturn_t bt_bmc_irq(int irq, void *arg)
367{
368 struct bt_bmc *bt_bmc = arg;
369 u32 reg;
370
371 reg = ioread32(bt_bmc->base + BT_CR2);
372 reg &= BT_CR2_IRQ_H2B | BT_CR2_IRQ_HBUSY;
373 if (!reg)
374 return IRQ_NONE;
375
376 /* ack pending IRQs */
377 iowrite32(reg, bt_bmc->base + BT_CR2);
378
379 wake_up(&bt_bmc->queue);
380 return IRQ_HANDLED;
381}
382
383static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
384 struct platform_device *pdev)
385{
386 struct device *dev = &pdev->dev;
387 u32 reg;
388 int rc;
389
390 bt_bmc->irq = platform_get_irq(pdev, 0);
391 if (!bt_bmc->irq)
392 return -ENODEV;
393
394 rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
395 DEVICE_NAME, bt_bmc);
396 if (rc < 0) {
397 dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
398 bt_bmc->irq = 0;
399 return rc;
400 }
401
402 /*
403 * Configure IRQs on the bmc clearing the H2B and HBUSY bits;
404 * H2B will be asserted when the bmc has data for us; HBUSY
405 * will be cleared (along with B2H) when we can write the next
406 * message to the BT buffer
407 */
408 reg = ioread32(bt_bmc->base + BT_CR1);
409 reg |= BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY;
410 iowrite32(reg, bt_bmc->base + BT_CR1);
411
412 return 0;
413}
414
415static int bt_bmc_probe(struct platform_device *pdev)
416{
417 struct bt_bmc *bt_bmc;
418 struct device *dev;
419 struct resource *res;
420 int rc;
421
422 if (!pdev || !pdev->dev.of_node)
423 return -ENODEV;
424
425 dev = &pdev->dev;
426 dev_info(dev, "Found bt bmc device\n");
427
428 bt_bmc = devm_kzalloc(dev, sizeof(*bt_bmc), GFP_KERNEL);
429 if (!bt_bmc)
430 return -ENOMEM;
431
432 dev_set_drvdata(&pdev->dev, bt_bmc);
433
434 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
435 bt_bmc->base = devm_ioremap_resource(&pdev->dev, res);
436 if (IS_ERR(bt_bmc->base))
437 return PTR_ERR(bt_bmc->base);
438
439 mutex_init(&bt_bmc->mutex);
440 init_waitqueue_head(&bt_bmc->queue);
441
442 bt_bmc->miscdev.minor = MISC_DYNAMIC_MINOR,
443 bt_bmc->miscdev.name = DEVICE_NAME,
444 bt_bmc->miscdev.fops = &bt_bmc_fops,
445 bt_bmc->miscdev.parent = dev;
446 rc = misc_register(&bt_bmc->miscdev);
447 if (rc) {
448 dev_err(dev, "Unable to register misc device\n");
449 return rc;
450 }
451
452 bt_bmc_config_irq(bt_bmc, pdev);
453
454 if (bt_bmc->irq) {
455 dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
456 } else {
457 dev_info(dev, "No IRQ; using timer\n");
458 setup_timer(&bt_bmc->poll_timer, poll_timer,
459 (unsigned long)bt_bmc);
460 bt_bmc->poll_timer.expires = jiffies + msecs_to_jiffies(10);
461 add_timer(&bt_bmc->poll_timer);
462 }
463
464 iowrite32((BT_IO_BASE << BT_CR0_IO_BASE) |
465 (BT_IRQ << BT_CR0_IRQ) |
466 BT_CR0_EN_CLR_SLV_RDP |
467 BT_CR0_EN_CLR_SLV_WRP |
468 BT_CR0_ENABLE_IBT,
469 bt_bmc->base + BT_CR0);
470
471 clr_b_busy(bt_bmc);
472
473 return 0;
474}
475
476static int bt_bmc_remove(struct platform_device *pdev)
477{
478 struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev);
479
480 misc_deregister(&bt_bmc->miscdev);
481 if (!bt_bmc->irq)
482 del_timer_sync(&bt_bmc->poll_timer);
483 return 0;
484}
485
486static const struct of_device_id bt_bmc_match[] = {
487 { .compatible = "aspeed,ast2400-bt-bmc" },
488 { },
489};
490
491static struct platform_driver bt_bmc_driver = {
492 .driver = {
493 .name = DEVICE_NAME,
494 .of_match_table = bt_bmc_match,
495 },
496 .probe = bt_bmc_probe,
497 .remove = bt_bmc_remove,
498};
499
500module_platform_driver(bt_bmc_driver);
501
502MODULE_DEVICE_TABLE(of, bt_bmc_match);
503MODULE_LICENSE("GPL");
504MODULE_AUTHOR("Alistair Popple <alistair@popple.id.au>");
505MODULE_DESCRIPTION("Linux device interface to the BT interface");
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d8619998cfb5..fcdd886819f5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2891,11 +2891,11 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
2891 intf->curr_channel = IPMI_MAX_CHANNELS; 2891 intf->curr_channel = IPMI_MAX_CHANNELS;
2892 } 2892 }
2893 2893
2894 rv = ipmi_bmc_register(intf, i);
2895
2894 if (rv == 0) 2896 if (rv == 0)
2895 rv = add_proc_entries(intf, i); 2897 rv = add_proc_entries(intf, i);
2896 2898
2897 rv = ipmi_bmc_register(intf, i);
2898
2899 out: 2899 out:
2900 if (rv) { 2900 if (rv) {
2901 if (intf->proc_dir) 2901 if (intf->proc_dir)
@@ -2982,8 +2982,6 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
2982 int intf_num = intf->intf_num; 2982 int intf_num = intf->intf_num;
2983 ipmi_user_t user; 2983 ipmi_user_t user;
2984 2984
2985 ipmi_bmc_unregister(intf);
2986
2987 mutex_lock(&smi_watchers_mutex); 2985 mutex_lock(&smi_watchers_mutex);
2988 mutex_lock(&ipmi_interfaces_mutex); 2986 mutex_lock(&ipmi_interfaces_mutex);
2989 intf->intf_num = -1; 2987 intf->intf_num = -1;
@@ -3007,6 +3005,7 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
3007 mutex_unlock(&ipmi_interfaces_mutex); 3005 mutex_unlock(&ipmi_interfaces_mutex);
3008 3006
3009 remove_proc_entries(intf); 3007 remove_proc_entries(intf);
3008 ipmi_bmc_unregister(intf);
3010 3009
3011 /* 3010 /*
3012 * Call all the watcher interfaces to tell them that 3011 * Call all the watcher interfaces to tell them that
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 8de61876f633..3a9149cf0110 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -813,9 +813,6 @@ int tpm_do_selftest(struct tpm_chip *chip)
813 continue; 813 continue;
814 } 814 }
815 815
816 if (rc < TPM_HEADER_SIZE)
817 return -EFAULT;
818
819 if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) { 816 if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
820 dev_info(&chip->dev, 817 dev_info(&chip->dev,
821 "TPM is disabled/deactivated (0x%X)\n", rc); 818 "TPM is disabled/deactivated (0x%X)\n", rc);
diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
index 190122e64a3a..85a449cf61e3 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -203,7 +203,7 @@ at91_clk_register_programmable(struct regmap *regmap,
203 ret = clk_hw_register(NULL, &prog->hw); 203 ret = clk_hw_register(NULL, &prog->hw);
204 if (ret) { 204 if (ret) {
205 kfree(prog); 205 kfree(prog);
206 hw = &prog->hw; 206 hw = ERR_PTR(ret);
207 } 207 }
208 208
209 return hw; 209 return hw;
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index b68bf573dcfb..8c7763fd9efc 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -502,8 +502,12 @@ static long bcm2835_pll_rate_from_divisors(unsigned long parent_rate,
502static long bcm2835_pll_round_rate(struct clk_hw *hw, unsigned long rate, 502static long bcm2835_pll_round_rate(struct clk_hw *hw, unsigned long rate,
503 unsigned long *parent_rate) 503 unsigned long *parent_rate)
504{ 504{
505 struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
506 const struct bcm2835_pll_data *data = pll->data;
505 u32 ndiv, fdiv; 507 u32 ndiv, fdiv;
506 508
509 rate = clamp(rate, data->min_rate, data->max_rate);
510
507 bcm2835_pll_choose_ndiv_and_fdiv(rate, *parent_rate, &ndiv, &fdiv); 511 bcm2835_pll_choose_ndiv_and_fdiv(rate, *parent_rate, &ndiv, &fdiv);
508 512
509 return bcm2835_pll_rate_from_divisors(*parent_rate, ndiv, fdiv, 1); 513 return bcm2835_pll_rate_from_divisors(*parent_rate, ndiv, fdiv, 1);
@@ -608,13 +612,6 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
608 u32 ana[4]; 612 u32 ana[4];
609 int i; 613 int i;
610 614
611 if (rate < data->min_rate || rate > data->max_rate) {
612 dev_err(cprman->dev, "%s: rate out of spec: %lu vs (%lu, %lu)\n",
613 clk_hw_get_name(hw), rate,
614 data->min_rate, data->max_rate);
615 return -EINVAL;
616 }
617
618 if (rate > data->max_fb_rate) { 615 if (rate > data->max_fb_rate) {
619 use_fb_prediv = true; 616 use_fb_prediv = true;
620 rate /= 2; 617 rate /= 2;
diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c
index b637f5979023..eb953d3b0b69 100644
--- a/drivers/clk/clk-max77686.c
+++ b/drivers/clk/clk-max77686.c
@@ -216,6 +216,7 @@ static int max77686_clk_probe(struct platform_device *pdev)
216 return -EINVAL; 216 return -EINVAL;
217 } 217 }
218 218
219 drv_data->num_clks = num_clks;
219 drv_data->max_clk_data = devm_kcalloc(dev, num_clks, 220 drv_data->max_clk_data = devm_kcalloc(dev, num_clks,
220 sizeof(*drv_data->max_clk_data), 221 sizeof(*drv_data->max_clk_data),
221 GFP_KERNEL); 222 GFP_KERNEL);
diff --git a/drivers/clk/hisilicon/clk-hi6220.c b/drivers/clk/hisilicon/clk-hi6220.c
index fe364e63f8de..c0e8e1f196aa 100644
--- a/drivers/clk/hisilicon/clk-hi6220.c
+++ b/drivers/clk/hisilicon/clk-hi6220.c
@@ -195,7 +195,7 @@ static void __init hi6220_clk_sys_init(struct device_node *np)
195 hi6220_clk_register_divider(hi6220_div_clks_sys, 195 hi6220_clk_register_divider(hi6220_div_clks_sys,
196 ARRAY_SIZE(hi6220_div_clks_sys), clk_data); 196 ARRAY_SIZE(hi6220_div_clks_sys), clk_data);
197} 197}
198CLK_OF_DECLARE(hi6220_clk_sys, "hisilicon,hi6220-sysctrl", hi6220_clk_sys_init); 198CLK_OF_DECLARE_DRIVER(hi6220_clk_sys, "hisilicon,hi6220-sysctrl", hi6220_clk_sys_init);
199 199
200 200
201/* clocks in media controller */ 201/* clocks in media controller */
@@ -252,7 +252,7 @@ static void __init hi6220_clk_media_init(struct device_node *np)
252 hi6220_clk_register_divider(hi6220_div_clks_media, 252 hi6220_clk_register_divider(hi6220_div_clks_media,
253 ARRAY_SIZE(hi6220_div_clks_media), clk_data); 253 ARRAY_SIZE(hi6220_div_clks_media), clk_data);
254} 254}
255CLK_OF_DECLARE(hi6220_clk_media, "hisilicon,hi6220-mediactrl", hi6220_clk_media_init); 255CLK_OF_DECLARE_DRIVER(hi6220_clk_media, "hisilicon,hi6220-mediactrl", hi6220_clk_media_init);
256 256
257 257
258/* clocks in pmctrl */ 258/* clocks in pmctrl */
diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 380c372d528e..f042bd2a6a99 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -8,6 +8,7 @@ config COMMON_CLK_MEDIATEK
8 8
9config COMMON_CLK_MT8135 9config COMMON_CLK_MT8135
10 bool "Clock driver for Mediatek MT8135" 10 bool "Clock driver for Mediatek MT8135"
11 depends on ARCH_MEDIATEK || COMPILE_TEST
11 select COMMON_CLK_MEDIATEK 12 select COMMON_CLK_MEDIATEK
12 default ARCH_MEDIATEK 13 default ARCH_MEDIATEK
13 ---help--- 14 ---help---
@@ -15,6 +16,7 @@ config COMMON_CLK_MT8135
15 16
16config COMMON_CLK_MT8173 17config COMMON_CLK_MT8173
17 bool "Clock driver for Mediatek MT8173" 18 bool "Clock driver for Mediatek MT8173"
19 depends on ARCH_MEDIATEK || COMPILE_TEST
18 select COMMON_CLK_MEDIATEK 20 select COMMON_CLK_MEDIATEK
19 default ARCH_MEDIATEK 21 default ARCH_MEDIATEK
20 ---help--- 22 ---help---
diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c
index 45905fc0d75b..cecb0fdfaef6 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -305,7 +305,7 @@ static const struct of_device_id armada_3700_periph_clock_of_match[] = {
305}; 305};
306static int armada_3700_add_composite_clk(const struct clk_periph_data *data, 306static int armada_3700_add_composite_clk(const struct clk_periph_data *data,
307 void __iomem *reg, spinlock_t *lock, 307 void __iomem *reg, spinlock_t *lock,
308 struct device *dev, struct clk_hw *hw) 308 struct device *dev, struct clk_hw **hw)
309{ 309{
310 const struct clk_ops *mux_ops = NULL, *gate_ops = NULL, 310 const struct clk_ops *mux_ops = NULL, *gate_ops = NULL,
311 *rate_ops = NULL; 311 *rate_ops = NULL;
@@ -329,6 +329,7 @@ static int armada_3700_add_composite_clk(const struct clk_periph_data *data,
329 gate->lock = lock; 329 gate->lock = lock;
330 gate_ops = gate_hw->init->ops; 330 gate_ops = gate_hw->init->ops;
331 gate->reg = reg + (u64)gate->reg; 331 gate->reg = reg + (u64)gate->reg;
332 gate->flags = CLK_GATE_SET_TO_DISABLE;
332 } 333 }
333 334
334 if (data->rate_hw) { 335 if (data->rate_hw) {
@@ -353,13 +354,13 @@ static int armada_3700_add_composite_clk(const struct clk_periph_data *data,
353 } 354 }
354 } 355 }
355 356
356 hw = clk_hw_register_composite(dev, data->name, data->parent_names, 357 *hw = clk_hw_register_composite(dev, data->name, data->parent_names,
357 data->num_parents, mux_hw, 358 data->num_parents, mux_hw,
358 mux_ops, rate_hw, rate_ops, 359 mux_ops, rate_hw, rate_ops,
359 gate_hw, gate_ops, CLK_IGNORE_UNUSED); 360 gate_hw, gate_ops, CLK_IGNORE_UNUSED);
360 361
361 if (IS_ERR(hw)) 362 if (IS_ERR(*hw))
362 return PTR_ERR(hw); 363 return PTR_ERR(*hw);
363 364
364 return 0; 365 return 0;
365} 366}
@@ -400,7 +401,7 @@ static int armada_3700_periph_clock_probe(struct platform_device *pdev)
400 spin_lock_init(&driver_data->lock); 401 spin_lock_init(&driver_data->lock);
401 402
402 for (i = 0; i < num_periph; i++) { 403 for (i = 0; i < num_periph; i++) {
403 struct clk_hw *hw = driver_data->hw_data->hws[i]; 404 struct clk_hw **hw = &driver_data->hw_data->hws[i];
404 405
405 if (armada_3700_add_composite_clk(&data[i], reg, 406 if (armada_3700_add_composite_clk(&data[i], reg,
406 &driver_data->lock, dev, hw)) 407 &driver_data->lock, dev, hw))
diff --git a/drivers/clk/samsung/clk-exynos-audss.c b/drivers/clk/samsung/clk-exynos-audss.c
index 51d152f735cc..17e68a724945 100644
--- a/drivers/clk/samsung/clk-exynos-audss.c
+++ b/drivers/clk/samsung/clk-exynos-audss.c
@@ -106,6 +106,7 @@ static const struct of_device_id exynos_audss_clk_of_match[] = {
106 }, 106 },
107 { }, 107 { },
108}; 108};
109MODULE_DEVICE_TABLE(of, exynos_audss_clk_of_match);
109 110
110static void exynos_audss_clk_teardown(void) 111static void exynos_audss_clk_teardown(void)
111{ 112{
diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c
index 5ffb898d0839..26c53f7963a4 100644
--- a/drivers/clk/uniphier/clk-uniphier-core.c
+++ b/drivers/clk/uniphier/clk-uniphier-core.c
@@ -79,7 +79,7 @@ static int uniphier_clk_probe(struct platform_device *pdev)
79 hw_data->num = clk_num; 79 hw_data->num = clk_num;
80 80
81 /* avoid returning NULL for unused idx */ 81 /* avoid returning NULL for unused idx */
82 for (; clk_num >= 0; clk_num--) 82 while (--clk_num >= 0)
83 hw_data->hws[clk_num] = ERR_PTR(-EINVAL); 83 hw_data->hws[clk_num] = ERR_PTR(-EINVAL);
84 84
85 for (p = data; p->name; p++) { 85 for (p = data; p->name; p++) {
@@ -111,6 +111,10 @@ static int uniphier_clk_remove(struct platform_device *pdev)
111static const struct of_device_id uniphier_clk_match[] = { 111static const struct of_device_id uniphier_clk_match[] = {
112 /* System clock */ 112 /* System clock */
113 { 113 {
114 .compatible = "socionext,uniphier-sld3-clock",
115 .data = uniphier_sld3_sys_clk_data,
116 },
117 {
114 .compatible = "socionext,uniphier-ld4-clock", 118 .compatible = "socionext,uniphier-ld4-clock",
115 .data = uniphier_ld4_sys_clk_data, 119 .data = uniphier_ld4_sys_clk_data,
116 }, 120 },
@@ -138,7 +142,7 @@ static const struct of_device_id uniphier_clk_match[] = {
138 .compatible = "socionext,uniphier-ld20-clock", 142 .compatible = "socionext,uniphier-ld20-clock",
139 .data = uniphier_ld20_sys_clk_data, 143 .data = uniphier_ld20_sys_clk_data,
140 }, 144 },
141 /* Media I/O clock */ 145 /* Media I/O clock, SD clock */
142 { 146 {
143 .compatible = "socionext,uniphier-sld3-mio-clock", 147 .compatible = "socionext,uniphier-sld3-mio-clock",
144 .data = uniphier_sld3_mio_clk_data, 148 .data = uniphier_sld3_mio_clk_data,
@@ -156,20 +160,20 @@ static const struct of_device_id uniphier_clk_match[] = {
156 .data = uniphier_sld3_mio_clk_data, 160 .data = uniphier_sld3_mio_clk_data,
157 }, 161 },
158 { 162 {
159 .compatible = "socionext,uniphier-pro5-mio-clock", 163 .compatible = "socionext,uniphier-pro5-sd-clock",
160 .data = uniphier_pro5_mio_clk_data, 164 .data = uniphier_pro5_sd_clk_data,
161 }, 165 },
162 { 166 {
163 .compatible = "socionext,uniphier-pxs2-mio-clock", 167 .compatible = "socionext,uniphier-pxs2-sd-clock",
164 .data = uniphier_pro5_mio_clk_data, 168 .data = uniphier_pro5_sd_clk_data,
165 }, 169 },
166 { 170 {
167 .compatible = "socionext,uniphier-ld11-mio-clock", 171 .compatible = "socionext,uniphier-ld11-mio-clock",
168 .data = uniphier_sld3_mio_clk_data, 172 .data = uniphier_sld3_mio_clk_data,
169 }, 173 },
170 { 174 {
171 .compatible = "socionext,uniphier-ld20-mio-clock", 175 .compatible = "socionext,uniphier-ld20-sd-clock",
172 .data = uniphier_pro5_mio_clk_data, 176 .data = uniphier_pro5_sd_clk_data,
173 }, 177 },
174 /* Peripheral clock */ 178 /* Peripheral clock */
175 { 179 {
diff --git a/drivers/clk/uniphier/clk-uniphier-mio.c b/drivers/clk/uniphier/clk-uniphier-mio.c
index 6aa7ec768d0b..218d20f099ce 100644
--- a/drivers/clk/uniphier/clk-uniphier-mio.c
+++ b/drivers/clk/uniphier/clk-uniphier-mio.c
@@ -93,7 +93,7 @@ const struct uniphier_clk_data uniphier_sld3_mio_clk_data[] = {
93 { /* sentinel */ } 93 { /* sentinel */ }
94}; 94};
95 95
96const struct uniphier_clk_data uniphier_pro5_mio_clk_data[] = { 96const struct uniphier_clk_data uniphier_pro5_sd_clk_data[] = {
97 UNIPHIER_MIO_CLK_SD_FIXED, 97 UNIPHIER_MIO_CLK_SD_FIXED,
98 UNIPHIER_MIO_CLK_SD(0, 0), 98 UNIPHIER_MIO_CLK_SD(0, 0),
99 UNIPHIER_MIO_CLK_SD(1, 1), 99 UNIPHIER_MIO_CLK_SD(1, 1),
diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c b/drivers/clk/uniphier/clk-uniphier-mux.c
index 15a2f2cbe0d9..2c243a894f3b 100644
--- a/drivers/clk/uniphier/clk-uniphier-mux.c
+++ b/drivers/clk/uniphier/clk-uniphier-mux.c
@@ -42,7 +42,7 @@ static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)
42 struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw); 42 struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw);
43 int num_parents = clk_hw_get_num_parents(hw); 43 int num_parents = clk_hw_get_num_parents(hw);
44 int ret; 44 int ret;
45 u32 val; 45 unsigned int val;
46 u8 i; 46 u8 i;
47 47
48 ret = regmap_read(mux->regmap, mux->reg, &val); 48 ret = regmap_read(mux->regmap, mux->reg, &val);
diff --git a/drivers/clk/uniphier/clk-uniphier.h b/drivers/clk/uniphier/clk-uniphier.h
index 3ae184062388..0244dba1f4cf 100644
--- a/drivers/clk/uniphier/clk-uniphier.h
+++ b/drivers/clk/uniphier/clk-uniphier.h
@@ -115,7 +115,7 @@ extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[];
115extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data[]; 115extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data[];
116extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[]; 116extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[];
117extern const struct uniphier_clk_data uniphier_sld3_mio_clk_data[]; 117extern const struct uniphier_clk_data uniphier_sld3_mio_clk_data[];
118extern const struct uniphier_clk_data uniphier_pro5_mio_clk_data[]; 118extern const struct uniphier_clk_data uniphier_pro5_sd_clk_data[];
119extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data[]; 119extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data[];
120extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data[]; 120extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data[];
121 121
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 245190839359..e2c6e43cf8ca 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -417,6 +417,16 @@ config SYS_SUPPORTS_SH_TMU
417config SYS_SUPPORTS_EM_STI 417config SYS_SUPPORTS_EM_STI
418 bool 418 bool
419 419
420config CLKSRC_JCORE_PIT
421 bool "J-Core PIT timer driver" if COMPILE_TEST
422 depends on OF
423 depends on GENERIC_CLOCKEVENTS
424 depends on HAS_IOMEM
425 select CLKSRC_MMIO
426 help
427 This enables build of clocksource and clockevent driver for
428 the integrated PIT in the J-Core synthesizable, open source SoC.
429
420config SH_TIMER_CMT 430config SH_TIMER_CMT
421 bool "Renesas CMT timer driver" if COMPILE_TEST 431 bool "Renesas CMT timer driver" if COMPILE_TEST
422 depends on GENERIC_CLOCKEVENTS 432 depends on GENERIC_CLOCKEVENTS
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index fd9d6df0bbc0..cf87f407f1ad 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
5obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o 5obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
6obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o 6obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
7obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o 7obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o
8obj-$(CONFIG_CLKSRC_JCORE_PIT) += jcore-pit.o
8obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o 9obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
9obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o 10obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
10obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o 11obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
diff --git a/drivers/clocksource/jcore-pit.c b/drivers/clocksource/jcore-pit.c
new file mode 100644
index 000000000000..54e1665aa03c
--- /dev/null
+++ b/drivers/clocksource/jcore-pit.c
@@ -0,0 +1,249 @@
1/*
2 * J-Core SoC PIT/clocksource driver
3 *
4 * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/kernel.h>
12#include <linux/slab.h>
13#include <linux/interrupt.h>
14#include <linux/clockchips.h>
15#include <linux/clocksource.h>
16#include <linux/sched_clock.h>
17#include <linux/cpu.h>
18#include <linux/cpuhotplug.h>
19#include <linux/of_address.h>
20#include <linux/of_irq.h>
21
22#define PIT_IRQ_SHIFT 12
23#define PIT_PRIO_SHIFT 20
24#define PIT_ENABLE_SHIFT 26
25#define PIT_PRIO_MASK 0xf
26
27#define REG_PITEN 0x00
28#define REG_THROT 0x10
29#define REG_COUNT 0x14
30#define REG_BUSPD 0x18
31#define REG_SECHI 0x20
32#define REG_SECLO 0x24
33#define REG_NSEC 0x28
34
35struct jcore_pit {
36 struct clock_event_device ced;
37 void __iomem *base;
38 unsigned long periodic_delta;
39 u32 enable_val;
40};
41
42static void __iomem *jcore_pit_base;
43static struct jcore_pit __percpu *jcore_pit_percpu;
44
45static notrace u64 jcore_sched_clock_read(void)
46{
47 u32 seclo, nsec, seclo0;
48 __iomem void *base = jcore_pit_base;
49
50 seclo = readl(base + REG_SECLO);
51 do {
52 seclo0 = seclo;
53 nsec = readl(base + REG_NSEC);
54 seclo = readl(base + REG_SECLO);
55 } while (seclo0 != seclo);
56
57 return seclo * NSEC_PER_SEC + nsec;
58}
59
60static cycle_t jcore_clocksource_read(struct clocksource *cs)
61{
62 return jcore_sched_clock_read();
63}
64
65static int jcore_pit_disable(struct jcore_pit *pit)
66{
67 writel(0, pit->base + REG_PITEN);
68 return 0;
69}
70
71static int jcore_pit_set(unsigned long delta, struct jcore_pit *pit)
72{
73 jcore_pit_disable(pit);
74 writel(delta, pit->base + REG_THROT);
75 writel(pit->enable_val, pit->base + REG_PITEN);
76 return 0;
77}
78
79static int jcore_pit_set_state_shutdown(struct clock_event_device *ced)
80{
81 struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
82
83 return jcore_pit_disable(pit);
84}
85
86static int jcore_pit_set_state_oneshot(struct clock_event_device *ced)
87{
88 struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
89
90 return jcore_pit_disable(pit);
91}
92
93static int jcore_pit_set_state_periodic(struct clock_event_device *ced)
94{
95 struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
96
97 return jcore_pit_set(pit->periodic_delta, pit);
98}
99
100static int jcore_pit_set_next_event(unsigned long delta,
101 struct clock_event_device *ced)
102{
103 struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
104
105 return jcore_pit_set(delta, pit);
106}
107
108static int jcore_pit_local_init(unsigned cpu)
109{
110 struct jcore_pit *pit = this_cpu_ptr(jcore_pit_percpu);
111 unsigned buspd, freq;
112
113 pr_info("Local J-Core PIT init on cpu %u\n", cpu);
114
115 buspd = readl(pit->base + REG_BUSPD);
116 freq = DIV_ROUND_CLOSEST(NSEC_PER_SEC, buspd);
117 pit->periodic_delta = DIV_ROUND_CLOSEST(NSEC_PER_SEC, HZ * buspd);
118
119 clockevents_config_and_register(&pit->ced, freq, 1, ULONG_MAX);
120
121 return 0;
122}
123
124static irqreturn_t jcore_timer_interrupt(int irq, void *dev_id)
125{
126 struct jcore_pit *pit = this_cpu_ptr(dev_id);
127
128 if (clockevent_state_oneshot(&pit->ced))
129 jcore_pit_disable(pit);
130
131 pit->ced.event_handler(&pit->ced);
132
133 return IRQ_HANDLED;
134}
135
136static int __init jcore_pit_init(struct device_node *node)
137{
138 int err;
139 unsigned pit_irq, cpu;
140 unsigned long hwirq;
141 u32 irqprio, enable_val;
142
143 jcore_pit_base = of_iomap(node, 0);
144 if (!jcore_pit_base) {
145 pr_err("Error: Cannot map base address for J-Core PIT\n");
146 return -ENXIO;
147 }
148
149 pit_irq = irq_of_parse_and_map(node, 0);
150 if (!pit_irq) {
151 pr_err("Error: J-Core PIT has no IRQ\n");
152 return -ENXIO;
153 }
154
155 pr_info("Initializing J-Core PIT at %p IRQ %d\n",
156 jcore_pit_base, pit_irq);
157
158 err = clocksource_mmio_init(jcore_pit_base, "jcore_pit_cs",
159 NSEC_PER_SEC, 400, 32,
160 jcore_clocksource_read);
161 if (err) {
162 pr_err("Error registering clocksource device: %d\n", err);
163 return err;
164 }
165
166 sched_clock_register(jcore_sched_clock_read, 32, NSEC_PER_SEC);
167
168 jcore_pit_percpu = alloc_percpu(struct jcore_pit);
169 if (!jcore_pit_percpu) {
170 pr_err("Failed to allocate memory for clock event device\n");
171 return -ENOMEM;
172 }
173
174 err = request_irq(pit_irq, jcore_timer_interrupt,
175 IRQF_TIMER | IRQF_PERCPU,
176 "jcore_pit", jcore_pit_percpu);
177 if (err) {
178 pr_err("pit irq request failed: %d\n", err);
179 free_percpu(jcore_pit_percpu);
180 return err;
181 }
182
183 /*
184 * The J-Core PIT is not hard-wired to a particular IRQ, but
185 * integrated with the interrupt controller such that the IRQ it
186 * generates is programmable, as follows:
187 *
188 * The bit layout of the PIT enable register is:
189 *
190 * .....e..ppppiiiiiiii............
191 *
192 * where the .'s indicate unrelated/unused bits, e is enable,
193 * p is priority, and i is hard irq number.
194 *
195 * For the PIT included in AIC1 (obsolete but still in use),
196 * any hard irq (trap number) can be programmed via the 8
197 * iiiiiiii bits, and a priority (0-15) is programmable
198 * separately in the pppp bits.
199 *
200 * For the PIT included in AIC2 (current), the programming
201 * interface is equivalent modulo interrupt mapping. This is
202 * why a different compatible tag was not used. However only
203 * traps 64-127 (the ones actually intended to be used for
204 * interrupts, rather than syscalls/exceptions/etc.) can be
205 * programmed (the high 2 bits of i are ignored) and the
206 * priority pppp is <<2'd and or'd onto the irq number. This
207 * choice seems to have been made on the hardware engineering
208 * side under an assumption that preserving old AIC1 priority
209 * mappings was important. Future models will likely ignore
210 * the pppp field.
211 */
212 hwirq = irq_get_irq_data(pit_irq)->hwirq;
213 irqprio = (hwirq >> 2) & PIT_PRIO_MASK;
214 enable_val = (1U << PIT_ENABLE_SHIFT)
215 | (hwirq << PIT_IRQ_SHIFT)
216 | (irqprio << PIT_PRIO_SHIFT);
217
218 for_each_present_cpu(cpu) {
219 struct jcore_pit *pit = per_cpu_ptr(jcore_pit_percpu, cpu);
220
221 pit->base = of_iomap(node, cpu);
222 if (!pit->base) {
223 pr_err("Unable to map PIT for cpu %u\n", cpu);
224 continue;
225 }
226
227 pit->ced.name = "jcore_pit";
228 pit->ced.features = CLOCK_EVT_FEAT_PERIODIC
229 | CLOCK_EVT_FEAT_ONESHOT
230 | CLOCK_EVT_FEAT_PERCPU;
231 pit->ced.cpumask = cpumask_of(cpu);
232 pit->ced.rating = 400;
233 pit->ced.irq = pit_irq;
234 pit->ced.set_state_shutdown = jcore_pit_set_state_shutdown;
235 pit->ced.set_state_periodic = jcore_pit_set_state_periodic;
236 pit->ced.set_state_oneshot = jcore_pit_set_state_oneshot;
237 pit->ced.set_next_event = jcore_pit_set_next_event;
238
239 pit->enable_val = enable_val;
240 }
241
242 cpuhp_setup_state(CPUHP_AP_JCORE_TIMER_STARTING,
243 "AP_JCORE_TIMER_STARTING",
244 jcore_pit_local_init, NULL);
245
246 return 0;
247}
248
249CLOCKSOURCE_OF_DECLARE(jcore_pit, "jcore,pit", jcore_pit_init);
diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index c184eb84101e..4f87f3e76d83 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -152,6 +152,13 @@ static irqreturn_t sun5i_timer_interrupt(int irq, void *dev_id)
152 return IRQ_HANDLED; 152 return IRQ_HANDLED;
153} 153}
154 154
155static cycle_t sun5i_clksrc_read(struct clocksource *clksrc)
156{
157 struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc);
158
159 return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1));
160}
161
155static int sun5i_rate_cb_clksrc(struct notifier_block *nb, 162static int sun5i_rate_cb_clksrc(struct notifier_block *nb,
156 unsigned long event, void *data) 163 unsigned long event, void *data)
157{ 164{
@@ -210,8 +217,13 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
210 writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD, 217 writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
211 base + TIMER_CTL_REG(1)); 218 base + TIMER_CTL_REG(1));
212 219
213 ret = clocksource_mmio_init(base + TIMER_CNTVAL_LO_REG(1), node->name, 220 cs->clksrc.name = node->name;
214 rate, 340, 32, clocksource_mmio_readl_down); 221 cs->clksrc.rating = 340;
222 cs->clksrc.read = sun5i_clksrc_read;
223 cs->clksrc.mask = CLOCKSOURCE_MASK(32);
224 cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
225
226 ret = clocksource_register_hz(&cs->clksrc, rate);
215 if (ret) { 227 if (ret) {
216 pr_err("Couldn't register clock source.\n"); 228 pr_err("Couldn't register clock source.\n");
217 goto err_remove_notifier; 229 goto err_remove_notifier;
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index f535f8123258..4737520ec823 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -179,6 +179,7 @@ struct _pid {
179/** 179/**
180 * struct cpudata - Per CPU instance data storage 180 * struct cpudata - Per CPU instance data storage
181 * @cpu: CPU number for this instance data 181 * @cpu: CPU number for this instance data
182 * @policy: CPUFreq policy value
182 * @update_util: CPUFreq utility callback information 183 * @update_util: CPUFreq utility callback information
183 * @update_util_set: CPUFreq utility callback is set 184 * @update_util_set: CPUFreq utility callback is set
184 * @iowait_boost: iowait-related boost fraction 185 * @iowait_boost: iowait-related boost fraction
@@ -201,6 +202,7 @@ struct _pid {
201struct cpudata { 202struct cpudata {
202 int cpu; 203 int cpu;
203 204
205 unsigned int policy;
204 struct update_util_data update_util; 206 struct update_util_data update_util;
205 bool update_util_set; 207 bool update_util_set;
206 208
@@ -1142,10 +1144,8 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
1142 *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf); 1144 *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
1143} 1145}
1144 1146
1145static void intel_pstate_set_min_pstate(struct cpudata *cpu) 1147static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
1146{ 1148{
1147 int pstate = cpu->pstate.min_pstate;
1148
1149 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); 1149 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
1150 cpu->pstate.current_pstate = pstate; 1150 cpu->pstate.current_pstate = pstate;
1151 /* 1151 /*
@@ -1157,6 +1157,20 @@ static void intel_pstate_set_min_pstate(struct cpudata *cpu)
1157 pstate_funcs.get_val(cpu, pstate)); 1157 pstate_funcs.get_val(cpu, pstate));
1158} 1158}
1159 1159
1160static void intel_pstate_set_min_pstate(struct cpudata *cpu)
1161{
1162 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
1163}
1164
1165static void intel_pstate_max_within_limits(struct cpudata *cpu)
1166{
1167 int min_pstate, max_pstate;
1168
1169 update_turbo_state();
1170 intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate);
1171 intel_pstate_set_pstate(cpu, max_pstate);
1172}
1173
1160static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) 1174static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
1161{ 1175{
1162 cpu->pstate.min_pstate = pstate_funcs.get_min(); 1176 cpu->pstate.min_pstate = pstate_funcs.get_min();
@@ -1325,7 +1339,8 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
1325 1339
1326 from = cpu->pstate.current_pstate; 1340 from = cpu->pstate.current_pstate;
1327 1341
1328 target_pstate = pstate_funcs.get_target_pstate(cpu); 1342 target_pstate = cpu->policy == CPUFREQ_POLICY_PERFORMANCE ?
1343 cpu->pstate.turbo_pstate : pstate_funcs.get_target_pstate(cpu);
1329 1344
1330 intel_pstate_update_pstate(cpu, target_pstate); 1345 intel_pstate_update_pstate(cpu, target_pstate);
1331 1346
@@ -1491,7 +1506,9 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
1491 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", 1506 pr_debug("set_policy cpuinfo.max %u policy->max %u\n",
1492 policy->cpuinfo.max_freq, policy->max); 1507 policy->cpuinfo.max_freq, policy->max);
1493 1508
1494 cpu = all_cpu_data[0]; 1509 cpu = all_cpu_data[policy->cpu];
1510 cpu->policy = policy->policy;
1511
1495 if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && 1512 if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
1496 policy->max < policy->cpuinfo.max_freq && 1513 policy->max < policy->cpuinfo.max_freq &&
1497 policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) { 1514 policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) {
@@ -1499,7 +1516,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
1499 policy->max = policy->cpuinfo.max_freq; 1516 policy->max = policy->cpuinfo.max_freq;
1500 } 1517 }
1501 1518
1502 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { 1519 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) {
1503 limits = &performance_limits; 1520 limits = &performance_limits;
1504 if (policy->max >= policy->cpuinfo.max_freq) { 1521 if (policy->max >= policy->cpuinfo.max_freq) {
1505 pr_debug("set performance\n"); 1522 pr_debug("set performance\n");
@@ -1535,6 +1552,15 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
1535 limits->max_perf = round_up(limits->max_perf, FRAC_BITS); 1552 limits->max_perf = round_up(limits->max_perf, FRAC_BITS);
1536 1553
1537 out: 1554 out:
1555 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) {
1556 /*
1557 * NOHZ_FULL CPUs need this as the governor callback may not
1558 * be invoked on them.
1559 */
1560 intel_pstate_clear_update_util_hook(policy->cpu);
1561 intel_pstate_max_within_limits(cpu);
1562 }
1563
1538 intel_pstate_set_update_util_hook(policy->cpu); 1564 intel_pstate_set_update_util_hook(policy->cpu);
1539 1565
1540 intel_pstate_hwp_set_policy(policy); 1566 intel_pstate_hwp_set_policy(policy);
diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig
index daadd20aa936..3e2ab3b14eea 100644
--- a/drivers/dax/Kconfig
+++ b/drivers/dax/Kconfig
@@ -14,7 +14,7 @@ if DEV_DAX
14 14
15config DEV_DAX_PMEM 15config DEV_DAX_PMEM
16 tristate "PMEM DAX: direct access to persistent memory" 16 tristate "PMEM DAX: direct access to persistent memory"
17 depends on NVDIMM_DAX 17 depends on LIBNVDIMM && NVDIMM_DAX
18 default DEV_DAX 18 default DEV_DAX
19 help 19 help
20 Support raw access to persistent memory. Note that this 20 Support raw access to persistent memory. Note that this
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 9630d8837ba9..4a15fa5df98b 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -44,7 +44,6 @@ static void dax_pmem_percpu_exit(void *data)
44 44
45 dev_dbg(dax_pmem->dev, "%s\n", __func__); 45 dev_dbg(dax_pmem->dev, "%s\n", __func__);
46 percpu_ref_exit(ref); 46 percpu_ref_exit(ref);
47 wait_for_completion(&dax_pmem->cmp);
48} 47}
49 48
50static void dax_pmem_percpu_kill(void *data) 49static void dax_pmem_percpu_kill(void *data)
@@ -54,6 +53,7 @@ static void dax_pmem_percpu_kill(void *data)
54 53
55 dev_dbg(dax_pmem->dev, "%s\n", __func__); 54 dev_dbg(dax_pmem->dev, "%s\n", __func__);
56 percpu_ref_kill(ref); 55 percpu_ref_kill(ref);
56 wait_for_completion(&dax_pmem->cmp);
57} 57}
58 58
59static int dax_pmem_probe(struct device *dev) 59static int dax_pmem_probe(struct device *dev)
diff --git a/drivers/extcon/extcon-qcom-spmi-misc.c b/drivers/extcon/extcon-qcom-spmi-misc.c
index ca957a5f4291..b8cde096a808 100644
--- a/drivers/extcon/extcon-qcom-spmi-misc.c
+++ b/drivers/extcon/extcon-qcom-spmi-misc.c
@@ -51,7 +51,7 @@ static void qcom_usb_extcon_detect_cable(struct work_struct *work)
51 if (ret) 51 if (ret)
52 return; 52 return;
53 53
54 extcon_set_state(info->edev, EXTCON_USB_HOST, !id); 54 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, !id);
55} 55}
56 56
57static irqreturn_t qcom_usb_irq_handler(int irq, void *dev_id) 57static irqreturn_t qcom_usb_irq_handler(int irq, void *dev_id)
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index c06945160a41..5e23e2d305e7 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -11,7 +11,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
11 -mno-mmx -mno-sse 11 -mno-mmx -mno-sse
12 12
13cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) 13cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS))
14cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ 14cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) -g0 \
15 -fno-builtin -fpic -mno-single-pic-base 15 -fno-builtin -fpic -mno-single-pic-base
16 16
17cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt 17cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
@@ -79,5 +79,6 @@ quiet_cmd_stubcopy = STUBCPY $@
79# decompressor. So move our .data to .data.efistub, which is preserved 79# decompressor. So move our .data to .data.efistub, which is preserved
80# explicitly by the decompressor linker script. 80# explicitly by the decompressor linker script.
81# 81#
82STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub 82STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
83 -R ___ksymtab+sort -R ___kcrctab+sort
83STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS 84STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 26ee00f6bd58..d011cb89d25e 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -284,7 +284,7 @@ config GPIO_MM_LANTIQ
284 284
285config GPIO_MOCKUP 285config GPIO_MOCKUP
286 tristate "GPIO Testing Driver" 286 tristate "GPIO Testing Driver"
287 depends on GPIOLIB 287 depends on GPIOLIB && SYSFS
288 select GPIO_SYSFS 288 select GPIO_SYSFS
289 help 289 help
290 This enables GPIO Testing driver, which provides a way to test GPIO 290 This enables GPIO Testing driver, which provides a way to test GPIO
diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index 9457e2022bf6..dc37dbe4b46d 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -219,6 +219,7 @@ static const struct of_device_id ath79_gpio_of_match[] = {
219 { .compatible = "qca,ar9340-gpio" }, 219 { .compatible = "qca,ar9340-gpio" },
220 {}, 220 {},
221}; 221};
222MODULE_DEVICE_TABLE(of, ath79_gpio_of_match);
222 223
223static int ath79_gpio_probe(struct platform_device *pdev) 224static int ath79_gpio_probe(struct platform_device *pdev)
224{ 225{
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 425501c39527..793518a30afe 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -239,7 +239,7 @@ static int mpc8xxx_gpio_irq_map(struct irq_domain *h, unsigned int irq,
239 irq_hw_number_t hwirq) 239 irq_hw_number_t hwirq)
240{ 240{
241 irq_set_chip_data(irq, h->host_data); 241 irq_set_chip_data(irq, h->host_data);
242 irq_set_chip_and_handler(irq, &mpc8xxx_irq_chip, handle_level_irq); 242 irq_set_chip_and_handler(irq, &mpc8xxx_irq_chip, handle_edge_irq);
243 243
244 return 0; 244 return 0;
245} 245}
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index b9daa0bf32a4..ee1724806f46 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -308,8 +308,10 @@ static int mxs_gpio_probe(struct platform_device *pdev)
308 writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR); 308 writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR);
309 309
310 irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id()); 310 irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
311 if (irq_base < 0) 311 if (irq_base < 0) {
312 return irq_base; 312 err = irq_base;
313 goto out_iounmap;
314 }
313 315
314 port->domain = irq_domain_add_legacy(np, 32, irq_base, 0, 316 port->domain = irq_domain_add_legacy(np, 32, irq_base, 0,
315 &irq_domain_simple_ops, NULL); 317 &irq_domain_simple_ops, NULL);
@@ -349,6 +351,8 @@ out_irqdomain_remove:
349 irq_domain_remove(port->domain); 351 irq_domain_remove(port->domain);
350out_irqdesc_free: 352out_irqdesc_free:
351 irq_free_descs(irq_base, 32); 353 irq_free_descs(irq_base, 32);
354out_iounmap:
355 iounmap(port->base);
352 return err; 356 return err;
353} 357}
354 358
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index e7d422a6b90b..5b0042776ec7 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -409,7 +409,7 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev)
409 * 801/1801/1600, bits are cleared when read. 409 * 801/1801/1600, bits are cleared when read.
410 * Edge detect register is not present on 801/1600/1801 410 * Edge detect register is not present on 801/1600/1801
411 */ 411 */
412 if (stmpe->partnum != STMPE801 || stmpe->partnum != STMPE1600 || 412 if (stmpe->partnum != STMPE801 && stmpe->partnum != STMPE1600 &&
413 stmpe->partnum != STMPE1801) { 413 stmpe->partnum != STMPE1801) {
414 stmpe_reg_write(stmpe, statmsbreg + i, status[i]); 414 stmpe_reg_write(stmpe, statmsbreg + i, status[i]);
415 stmpe_reg_write(stmpe, 415 stmpe_reg_write(stmpe,
diff --git a/drivers/gpio/gpio-ts4800.c b/drivers/gpio/gpio-ts4800.c
index 99256115bea5..c2a80b4cbf32 100644
--- a/drivers/gpio/gpio-ts4800.c
+++ b/drivers/gpio/gpio-ts4800.c
@@ -66,6 +66,7 @@ static const struct of_device_id ts4800_gpio_of_match[] = {
66 { .compatible = "technologic,ts4800-gpio", }, 66 { .compatible = "technologic,ts4800-gpio", },
67 {}, 67 {},
68}; 68};
69MODULE_DEVICE_TABLE(of, ts4800_gpio_of_match);
69 70
70static struct platform_driver ts4800_gpio_driver = { 71static struct platform_driver ts4800_gpio_driver = {
71 .driver = { 72 .driver = {
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 58ece201b8e6..72a4b326fd0d 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -653,14 +653,17 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
653{ 653{
654 int idx, i; 654 int idx, i;
655 unsigned int irq_flags; 655 unsigned int irq_flags;
656 int ret = -ENOENT;
656 657
657 for (i = 0, idx = 0; idx <= index; i++) { 658 for (i = 0, idx = 0; idx <= index; i++) {
658 struct acpi_gpio_info info; 659 struct acpi_gpio_info info;
659 struct gpio_desc *desc; 660 struct gpio_desc *desc;
660 661
661 desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); 662 desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
662 if (IS_ERR(desc)) 663 if (IS_ERR(desc)) {
664 ret = PTR_ERR(desc);
663 break; 665 break;
666 }
664 if (info.gpioint && idx++ == index) { 667 if (info.gpioint && idx++ == index) {
665 int irq = gpiod_to_irq(desc); 668 int irq = gpiod_to_irq(desc);
666 669
@@ -679,7 +682,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
679 } 682 }
680 683
681 } 684 }
682 return -ENOENT; 685 return ret;
683} 686}
684EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get); 687EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);
685 688
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f0fc3a0d37c8..20e09b7c2de3 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -333,6 +333,13 @@ struct linehandle_state {
333 u32 numdescs; 333 u32 numdescs;
334}; 334};
335 335
336#define GPIOHANDLE_REQUEST_VALID_FLAGS \
337 (GPIOHANDLE_REQUEST_INPUT | \
338 GPIOHANDLE_REQUEST_OUTPUT | \
339 GPIOHANDLE_REQUEST_ACTIVE_LOW | \
340 GPIOHANDLE_REQUEST_OPEN_DRAIN | \
341 GPIOHANDLE_REQUEST_OPEN_SOURCE)
342
336static long linehandle_ioctl(struct file *filep, unsigned int cmd, 343static long linehandle_ioctl(struct file *filep, unsigned int cmd,
337 unsigned long arg) 344 unsigned long arg)
338{ 345{
@@ -344,6 +351,8 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd,
344 if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { 351 if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) {
345 int val; 352 int val;
346 353
354 memset(&ghd, 0, sizeof(ghd));
355
347 /* TODO: check if descriptors are really input */ 356 /* TODO: check if descriptors are really input */
348 for (i = 0; i < lh->numdescs; i++) { 357 for (i = 0; i < lh->numdescs; i++) {
349 val = gpiod_get_value_cansleep(lh->descs[i]); 358 val = gpiod_get_value_cansleep(lh->descs[i]);
@@ -444,6 +453,17 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
444 u32 lflags = handlereq.flags; 453 u32 lflags = handlereq.flags;
445 struct gpio_desc *desc; 454 struct gpio_desc *desc;
446 455
456 if (offset >= gdev->ngpio) {
457 ret = -EINVAL;
458 goto out_free_descs;
459 }
460
461 /* Return an error if a unknown flag is set */
462 if (lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) {
463 ret = -EINVAL;
464 goto out_free_descs;
465 }
466
447 desc = &gdev->descs[offset]; 467 desc = &gdev->descs[offset];
448 ret = gpiod_request(desc, lh->label); 468 ret = gpiod_request(desc, lh->label);
449 if (ret) 469 if (ret)
@@ -536,6 +556,10 @@ struct lineevent_state {
536 struct mutex read_lock; 556 struct mutex read_lock;
537}; 557};
538 558
559#define GPIOEVENT_REQUEST_VALID_FLAGS \
560 (GPIOEVENT_REQUEST_RISING_EDGE | \
561 GPIOEVENT_REQUEST_FALLING_EDGE)
562
539static unsigned int lineevent_poll(struct file *filep, 563static unsigned int lineevent_poll(struct file *filep,
540 struct poll_table_struct *wait) 564 struct poll_table_struct *wait)
541{ 565{
@@ -623,6 +647,8 @@ static long lineevent_ioctl(struct file *filep, unsigned int cmd,
623 if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { 647 if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) {
624 int val; 648 int val;
625 649
650 memset(&ghd, 0, sizeof(ghd));
651
626 val = gpiod_get_value_cansleep(le->desc); 652 val = gpiod_get_value_cansleep(le->desc);
627 if (val < 0) 653 if (val < 0)
628 return val; 654 return val;
@@ -726,6 +752,18 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
726 lflags = eventreq.handleflags; 752 lflags = eventreq.handleflags;
727 eflags = eventreq.eventflags; 753 eflags = eventreq.eventflags;
728 754
755 if (offset >= gdev->ngpio) {
756 ret = -EINVAL;
757 goto out_free_label;
758 }
759
760 /* Return an error if a unknown flag is set */
761 if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
762 (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS)) {
763 ret = -EINVAL;
764 goto out_free_label;
765 }
766
729 /* This is just wrong: we don't look for events on output lines */ 767 /* This is just wrong: we don't look for events on output lines */
730 if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { 768 if (lflags & GPIOHANDLE_REQUEST_OUTPUT) {
731 ret = -EINVAL; 769 ret = -EINVAL;
@@ -823,6 +861,8 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
823 if (cmd == GPIO_GET_CHIPINFO_IOCTL) { 861 if (cmd == GPIO_GET_CHIPINFO_IOCTL) {
824 struct gpiochip_info chipinfo; 862 struct gpiochip_info chipinfo;
825 863
864 memset(&chipinfo, 0, sizeof(chipinfo));
865
826 strncpy(chipinfo.name, dev_name(&gdev->dev), 866 strncpy(chipinfo.name, dev_name(&gdev->dev),
827 sizeof(chipinfo.name)); 867 sizeof(chipinfo.name));
828 chipinfo.name[sizeof(chipinfo.name)-1] = '\0'; 868 chipinfo.name[sizeof(chipinfo.name)-1] = '\0';
@@ -839,7 +879,7 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
839 879
840 if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) 880 if (copy_from_user(&lineinfo, ip, sizeof(lineinfo)))
841 return -EFAULT; 881 return -EFAULT;
842 if (lineinfo.line_offset > gdev->ngpio) 882 if (lineinfo.line_offset >= gdev->ngpio)
843 return -EINVAL; 883 return -EINVAL;
844 884
845 desc = &gdev->descs[lineinfo.line_offset]; 885 desc = &gdev->descs[lineinfo.line_offset];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index aa074fac0c7f..f3efb1c5dae9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -754,6 +754,10 @@ static const char *amdgpu_vram_names[] = {
754 754
755int amdgpu_bo_init(struct amdgpu_device *adev) 755int amdgpu_bo_init(struct amdgpu_device *adev)
756{ 756{
757 /* reserve PAT memory space to WC for VRAM */
758 arch_io_reserve_memtype_wc(adev->mc.aper_base,
759 adev->mc.aper_size);
760
757 /* Add an MTRR for the VRAM */ 761 /* Add an MTRR for the VRAM */
758 adev->mc.vram_mtrr = arch_phys_wc_add(adev->mc.aper_base, 762 adev->mc.vram_mtrr = arch_phys_wc_add(adev->mc.aper_base,
759 adev->mc.aper_size); 763 adev->mc.aper_size);
@@ -769,6 +773,7 @@ void amdgpu_bo_fini(struct amdgpu_device *adev)
769{ 773{
770 amdgpu_ttm_fini(adev); 774 amdgpu_ttm_fini(adev);
771 arch_phys_wc_del(adev->mc.vram_mtrr); 775 arch_phys_wc_del(adev->mc.vram_mtrr);
776 arch_io_free_memtype_wc(adev->mc.aper_base, adev->mc.aper_size);
772} 777}
773 778
774int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo, 779int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 2f58e9e2a59c..a51f8cbcfe26 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -332,17 +332,19 @@ static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
332{ 332{
333 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); 333 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
334 334
335 if (dcrtc->dpms != dpms) { 335 if (dpms_blanked(dcrtc->dpms) != dpms_blanked(dpms)) {
336 dcrtc->dpms = dpms;
337 if (!IS_ERR(dcrtc->clk) && !dpms_blanked(dpms))
338 WARN_ON(clk_prepare_enable(dcrtc->clk));
339 armada_drm_crtc_update(dcrtc);
340 if (!IS_ERR(dcrtc->clk) && dpms_blanked(dpms))
341 clk_disable_unprepare(dcrtc->clk);
342 if (dpms_blanked(dpms)) 336 if (dpms_blanked(dpms))
343 armada_drm_vblank_off(dcrtc); 337 armada_drm_vblank_off(dcrtc);
344 else 338 else if (!IS_ERR(dcrtc->clk))
339 WARN_ON(clk_prepare_enable(dcrtc->clk));
340 dcrtc->dpms = dpms;
341 armada_drm_crtc_update(dcrtc);
342 if (!dpms_blanked(dpms))
345 drm_crtc_vblank_on(&dcrtc->crtc); 343 drm_crtc_vblank_on(&dcrtc->crtc);
344 else if (!IS_ERR(dcrtc->clk))
345 clk_disable_unprepare(dcrtc->clk);
346 } else if (dcrtc->dpms != dpms) {
347 dcrtc->dpms = dpms;
346 } 348 }
347} 349}
348 350
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 608df4c90520..0743e65cb240 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -267,6 +267,8 @@ int ast_mm_init(struct ast_private *ast)
267 return ret; 267 return ret;
268 } 268 }
269 269
270 arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
271 pci_resource_len(dev->pdev, 0));
270 ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 272 ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
271 pci_resource_len(dev->pdev, 0)); 273 pci_resource_len(dev->pdev, 0));
272 274
@@ -275,11 +277,15 @@ int ast_mm_init(struct ast_private *ast)
275 277
276void ast_mm_fini(struct ast_private *ast) 278void ast_mm_fini(struct ast_private *ast)
277{ 279{
280 struct drm_device *dev = ast->dev;
281
278 ttm_bo_device_release(&ast->ttm.bdev); 282 ttm_bo_device_release(&ast->ttm.bdev);
279 283
280 ast_ttm_global_release(ast); 284 ast_ttm_global_release(ast);
281 285
282 arch_phys_wc_del(ast->fb_mtrr); 286 arch_phys_wc_del(ast->fb_mtrr);
287 arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
288 pci_resource_len(dev->pdev, 0));
283} 289}
284 290
285void ast_ttm_placement(struct ast_bo *bo, int domain) 291void ast_ttm_placement(struct ast_bo *bo, int domain)
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index bb2438dd8733..5e7e63ce7bce 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -267,6 +267,9 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
267 return ret; 267 return ret;
268 } 268 }
269 269
270 arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
271 pci_resource_len(dev->pdev, 0));
272
270 cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 273 cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
271 pci_resource_len(dev->pdev, 0)); 274 pci_resource_len(dev->pdev, 0));
272 275
@@ -276,6 +279,8 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
276 279
277void cirrus_mm_fini(struct cirrus_device *cirrus) 280void cirrus_mm_fini(struct cirrus_device *cirrus)
278{ 281{
282 struct drm_device *dev = cirrus->dev;
283
279 if (!cirrus->mm_inited) 284 if (!cirrus->mm_inited)
280 return; 285 return;
281 286
@@ -285,6 +290,8 @@ void cirrus_mm_fini(struct cirrus_device *cirrus)
285 290
286 arch_phys_wc_del(cirrus->fb_mtrr); 291 arch_phys_wc_del(cirrus->fb_mtrr);
287 cirrus->fb_mtrr = 0; 292 cirrus->fb_mtrr = 0;
293 arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
294 pci_resource_len(dev->pdev, 0));
288} 295}
289 296
290void cirrus_ttm_placement(struct cirrus_bo *bo, int domain) 297void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
index cb86c7e5495c..d9230132dfbc 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
@@ -329,20 +329,34 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event,
329 /* 329 /*
330 * Append a LINK to the submitted command buffer to return to 330 * Append a LINK to the submitted command buffer to return to
331 * the ring buffer. return_target is the ring target address. 331 * the ring buffer. return_target is the ring target address.
332 * We need three dwords: event, wait, link. 332 * We need at most 7 dwords in the return target: 2 cache flush +
333 * 2 semaphore stall + 1 event + 1 wait + 1 link.
333 */ 334 */
334 return_dwords = 3; 335 return_dwords = 7;
335 return_target = etnaviv_buffer_reserve(gpu, buffer, return_dwords); 336 return_target = etnaviv_buffer_reserve(gpu, buffer, return_dwords);
336 CMD_LINK(cmdbuf, return_dwords, return_target); 337 CMD_LINK(cmdbuf, return_dwords, return_target);
337 338
338 /* 339 /*
339 * Append event, wait and link pointing back to the wait 340 * Append a cache flush, stall, event, wait and link pointing back to
340 * command to the ring buffer. 341 * the wait command to the ring buffer.
341 */ 342 */
343 if (gpu->exec_state == ETNA_PIPE_2D) {
344 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE,
345 VIVS_GL_FLUSH_CACHE_PE2D);
346 } else {
347 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE,
348 VIVS_GL_FLUSH_CACHE_DEPTH |
349 VIVS_GL_FLUSH_CACHE_COLOR);
350 CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
351 VIVS_TS_FLUSH_CACHE_FLUSH);
352 }
353 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
354 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
342 CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) | 355 CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) |
343 VIVS_GL_EVENT_FROM_PE); 356 VIVS_GL_EVENT_FROM_PE);
344 CMD_WAIT(buffer); 357 CMD_WAIT(buffer);
345 CMD_LINK(buffer, 2, return_target + 8); 358 CMD_LINK(buffer, 2, etnaviv_iommu_get_cmdbuf_va(gpu, buffer) +
359 buffer->user_size - 4);
346 360
347 if (drm_debug & DRM_UT_DRIVER) 361 if (drm_debug & DRM_UT_DRIVER)
348 pr_info("stream link to 0x%08x @ 0x%08x %p\n", 362 pr_info("stream link to 0x%08x @ 0x%08x %p\n",
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
index d3796ed8d8c5..169ac96e8f08 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
@@ -330,7 +330,8 @@ u32 etnaviv_iommu_get_cmdbuf_va(struct etnaviv_gpu *gpu,
330 return (u32)buf->vram_node.start; 330 return (u32)buf->vram_node.start;
331 331
332 mutex_lock(&mmu->lock); 332 mutex_lock(&mmu->lock);
333 ret = etnaviv_iommu_find_iova(mmu, &buf->vram_node, buf->size); 333 ret = etnaviv_iommu_find_iova(mmu, &buf->vram_node,
334 buf->size + SZ_64K);
334 if (ret < 0) { 335 if (ret < 0) {
335 mutex_unlock(&mmu->lock); 336 mutex_unlock(&mmu->lock);
336 return 0; 337 return 0;
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index 3371635cd4d7..b2d5e188b1b8 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -51,6 +51,7 @@ static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc)
51 DCU_MODE_DCU_MODE(DCU_MODE_OFF)); 51 DCU_MODE_DCU_MODE(DCU_MODE_OFF));
52 regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, 52 regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
53 DCU_UPDATE_MODE_READREG); 53 DCU_UPDATE_MODE_READREG);
54 clk_disable_unprepare(fsl_dev->pix_clk);
54} 55}
55 56
56static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc) 57static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc)
@@ -58,6 +59,7 @@ static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc)
58 struct drm_device *dev = crtc->dev; 59 struct drm_device *dev = crtc->dev;
59 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; 60 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
60 61
62 clk_prepare_enable(fsl_dev->pix_clk);
61 regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, 63 regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
62 DCU_MODE_DCU_MODE_MASK, 64 DCU_MODE_DCU_MODE_MASK,
63 DCU_MODE_DCU_MODE(DCU_MODE_NORMAL)); 65 DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
@@ -116,8 +118,6 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
116 DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) | 118 DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
117 DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) | 119 DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
118 DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL)); 120 DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
119 regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
120 DCU_UPDATE_MODE_READREG);
121 return; 121 return;
122} 122}
123 123
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 0884c45aefe8..e04efbed1a54 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -267,12 +267,8 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
267 return ret; 267 return ret;
268 } 268 }
269 269
270 ret = clk_prepare_enable(fsl_dev->pix_clk); 270 if (fsl_dev->tcon)
271 if (ret < 0) { 271 fsl_tcon_bypass_enable(fsl_dev->tcon);
272 dev_err(dev, "failed to enable pix clk\n");
273 goto disable_dcu_clk;
274 }
275
276 fsl_dcu_drm_init_planes(fsl_dev->drm); 272 fsl_dcu_drm_init_planes(fsl_dev->drm);
277 drm_atomic_helper_resume(fsl_dev->drm, fsl_dev->state); 273 drm_atomic_helper_resume(fsl_dev->drm, fsl_dev->state);
278 274
@@ -284,10 +280,6 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
284 enable_irq(fsl_dev->irq); 280 enable_irq(fsl_dev->irq);
285 281
286 return 0; 282 return 0;
287
288disable_dcu_clk:
289 clk_disable_unprepare(fsl_dev->clk);
290 return ret;
291} 283}
292#endif 284#endif
293 285
@@ -401,18 +393,12 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
401 goto disable_clk; 393 goto disable_clk;
402 } 394 }
403 395
404 ret = clk_prepare_enable(fsl_dev->pix_clk);
405 if (ret < 0) {
406 dev_err(dev, "failed to enable pix clk\n");
407 goto unregister_pix_clk;
408 }
409
410 fsl_dev->tcon = fsl_tcon_init(dev); 396 fsl_dev->tcon = fsl_tcon_init(dev);
411 397
412 drm = drm_dev_alloc(driver, dev); 398 drm = drm_dev_alloc(driver, dev);
413 if (IS_ERR(drm)) { 399 if (IS_ERR(drm)) {
414 ret = PTR_ERR(drm); 400 ret = PTR_ERR(drm);
415 goto disable_pix_clk; 401 goto unregister_pix_clk;
416 } 402 }
417 403
418 fsl_dev->dev = dev; 404 fsl_dev->dev = dev;
@@ -433,8 +419,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
433 419
434unref: 420unref:
435 drm_dev_unref(drm); 421 drm_dev_unref(drm);
436disable_pix_clk:
437 clk_disable_unprepare(fsl_dev->pix_clk);
438unregister_pix_clk: 422unregister_pix_clk:
439 clk_unregister(fsl_dev->pix_clk); 423 clk_unregister(fsl_dev->pix_clk);
440disable_clk: 424disable_clk:
@@ -447,7 +431,6 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
447 struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev); 431 struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
448 432
449 clk_disable_unprepare(fsl_dev->clk); 433 clk_disable_unprepare(fsl_dev->clk);
450 clk_disable_unprepare(fsl_dev->pix_clk);
451 clk_unregister(fsl_dev->pix_clk); 434 clk_unregister(fsl_dev->pix_clk);
452 drm_put_dev(fsl_dev->drm); 435 drm_put_dev(fsl_dev->drm);
453 436
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index a7e5486bd1e9..9e6f7d8112b3 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -211,11 +211,6 @@ void fsl_dcu_drm_init_planes(struct drm_device *dev)
211 for (j = 1; j <= fsl_dev->soc->layer_regs; j++) 211 for (j = 1; j <= fsl_dev->soc->layer_regs; j++)
212 regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(i, j), 0); 212 regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(i, j), 0);
213 } 213 }
214 regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
215 DCU_MODE_DCU_MODE_MASK,
216 DCU_MODE_DCU_MODE(DCU_MODE_OFF));
217 regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
218 DCU_UPDATE_MODE_READREG);
219} 214}
220 215
221struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev) 216struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 26edcc899712..e1dd75b18118 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -20,38 +20,6 @@
20#include "fsl_dcu_drm_drv.h" 20#include "fsl_dcu_drm_drv.h"
21#include "fsl_tcon.h" 21#include "fsl_tcon.h"
22 22
23static int
24fsl_dcu_drm_encoder_atomic_check(struct drm_encoder *encoder,
25 struct drm_crtc_state *crtc_state,
26 struct drm_connector_state *conn_state)
27{
28 return 0;
29}
30
31static void fsl_dcu_drm_encoder_disable(struct drm_encoder *encoder)
32{
33 struct drm_device *dev = encoder->dev;
34 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
35
36 if (fsl_dev->tcon)
37 fsl_tcon_bypass_disable(fsl_dev->tcon);
38}
39
40static void fsl_dcu_drm_encoder_enable(struct drm_encoder *encoder)
41{
42 struct drm_device *dev = encoder->dev;
43 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
44
45 if (fsl_dev->tcon)
46 fsl_tcon_bypass_enable(fsl_dev->tcon);
47}
48
49static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
50 .atomic_check = fsl_dcu_drm_encoder_atomic_check,
51 .disable = fsl_dcu_drm_encoder_disable,
52 .enable = fsl_dcu_drm_encoder_enable,
53};
54
55static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder) 23static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
56{ 24{
57 drm_encoder_cleanup(encoder); 25 drm_encoder_cleanup(encoder);
@@ -68,13 +36,16 @@ int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
68 int ret; 36 int ret;
69 37
70 encoder->possible_crtcs = 1; 38 encoder->possible_crtcs = 1;
39
40 /* Use bypass mode for parallel RGB/LVDS encoder */
41 if (fsl_dev->tcon)
42 fsl_tcon_bypass_enable(fsl_dev->tcon);
43
71 ret = drm_encoder_init(fsl_dev->drm, encoder, &encoder_funcs, 44 ret = drm_encoder_init(fsl_dev->drm, encoder, &encoder_funcs,
72 DRM_MODE_ENCODER_LVDS, NULL); 45 DRM_MODE_ENCODER_LVDS, NULL);
73 if (ret < 0) 46 if (ret < 0)
74 return ret; 47 return ret;
75 48
76 drm_encoder_helper_add(encoder, &encoder_helper_funcs);
77
78 return 0; 49 return 0;
79} 50}
80 51
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 919b35f2ad24..dcf7d11ac380 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -266,6 +266,9 @@ int mgag200_mm_init(struct mga_device *mdev)
266 return ret; 266 return ret;
267 } 267 }
268 268
269 arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
270 pci_resource_len(dev->pdev, 0));
271
269 mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 272 mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
270 pci_resource_len(dev->pdev, 0)); 273 pci_resource_len(dev->pdev, 0));
271 274
@@ -274,10 +277,14 @@ int mgag200_mm_init(struct mga_device *mdev)
274 277
275void mgag200_mm_fini(struct mga_device *mdev) 278void mgag200_mm_fini(struct mga_device *mdev)
276{ 279{
280 struct drm_device *dev = mdev->dev;
281
277 ttm_bo_device_release(&mdev->ttm.bdev); 282 ttm_bo_device_release(&mdev->ttm.bdev);
278 283
279 mgag200_ttm_global_release(mdev); 284 mgag200_ttm_global_release(mdev);
280 285
286 arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
287 pci_resource_len(dev->pdev, 0));
281 arch_phys_wc_del(mdev->fb_mtrr); 288 arch_phys_wc_del(mdev->fb_mtrr);
282 mdev->fb_mtrr = 0; 289 mdev->fb_mtrr = 0;
283} 290}
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 1825dbc33192..a6dbe8258040 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -398,6 +398,9 @@ nouveau_ttm_init(struct nouveau_drm *drm)
398 /* VRAM init */ 398 /* VRAM init */
399 drm->gem.vram_available = drm->device.info.ram_user; 399 drm->gem.vram_available = drm->device.info.ram_user;
400 400
401 arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1),
402 device->func->resource_size(device, 1));
403
401 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, 404 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
402 drm->gem.vram_available >> PAGE_SHIFT); 405 drm->gem.vram_available >> PAGE_SHIFT);
403 if (ret) { 406 if (ret) {
@@ -430,6 +433,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
430void 433void
431nouveau_ttm_fini(struct nouveau_drm *drm) 434nouveau_ttm_fini(struct nouveau_drm *drm)
432{ 435{
436 struct nvkm_device *device = nvxx_device(&drm->device);
437
433 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM); 438 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM);
434 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT); 439 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT);
435 440
@@ -439,4 +444,7 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
439 444
440 arch_phys_wc_del(drm->ttm.mtrr); 445 arch_phys_wc_del(drm->ttm.mtrr);
441 drm->ttm.mtrr = 0; 446 drm->ttm.mtrr = 0;
447 arch_io_free_memtype_wc(device->func->resource_addr(device, 1),
448 device->func->resource_size(device, 1));
449
442} 450}
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index be30861afae9..41b72ce6613f 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -446,6 +446,10 @@ void radeon_bo_force_delete(struct radeon_device *rdev)
446 446
447int radeon_bo_init(struct radeon_device *rdev) 447int radeon_bo_init(struct radeon_device *rdev)
448{ 448{
449 /* reserve PAT memory space to WC for VRAM */
450 arch_io_reserve_memtype_wc(rdev->mc.aper_base,
451 rdev->mc.aper_size);
452
449 /* Add an MTRR for the VRAM */ 453 /* Add an MTRR for the VRAM */
450 if (!rdev->fastfb_working) { 454 if (!rdev->fastfb_working) {
451 rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base, 455 rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base,
@@ -463,6 +467,7 @@ void radeon_bo_fini(struct radeon_device *rdev)
463{ 467{
464 radeon_ttm_fini(rdev); 468 radeon_ttm_fini(rdev);
465 arch_phys_wc_del(rdev->mc.vram_mtrr); 469 arch_phys_wc_del(rdev->mc.vram_mtrr);
470 arch_io_free_memtype_wc(rdev->mc.aper_base, rdev->mc.aper_size);
466} 471}
467 472
468/* Returns how many bytes TTM can move per IB. 473/* Returns how many bytes TTM can move per IB.
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index e8ae3dc476d1..18061a4bc2f2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -241,15 +241,15 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
241 void *ptr); 241 void *ptr);
242 242
243MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev"); 243MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
244module_param_named(enable_fbdev, enable_fbdev, int, 0600); 244module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
245MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages"); 245MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
246module_param_named(force_dma_api, vmw_force_iommu, int, 0600); 246module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
247MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages"); 247MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
248module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600); 248module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | S_IWUSR);
249MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages"); 249MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
250module_param_named(force_coherent, vmw_force_coherent, int, 0600); 250module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | S_IWUSR);
251MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU"); 251MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU");
252module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600); 252module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR | S_IWUSR);
253MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes"); 253MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
254module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600); 254module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);
255 255
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 070d750af16d..1e59a486bba8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -43,7 +43,7 @@
43 43
44#define VMWGFX_DRIVER_DATE "20160210" 44#define VMWGFX_DRIVER_DATE "20160210"
45#define VMWGFX_DRIVER_MAJOR 2 45#define VMWGFX_DRIVER_MAJOR 2
46#define VMWGFX_DRIVER_MINOR 10 46#define VMWGFX_DRIVER_MINOR 11
47#define VMWGFX_DRIVER_PATCHLEVEL 0 47#define VMWGFX_DRIVER_PATCHLEVEL 0
48#define VMWGFX_FILE_PAGE_OFFSET 0x00100000 48#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
49#define VMWGFX_FIFO_STATIC_SIZE (1024*1024) 49#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index dc5beff2b4aa..c7b53d987f06 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -35,17 +35,37 @@
35#define VMW_RES_HT_ORDER 12 35#define VMW_RES_HT_ORDER 12
36 36
37/** 37/**
38 * enum vmw_resource_relocation_type - Relocation type for resources
39 *
40 * @vmw_res_rel_normal: Traditional relocation. The resource id in the
41 * command stream is replaced with the actual id after validation.
42 * @vmw_res_rel_nop: NOP relocation. The command is unconditionally replaced
43 * with a NOP.
44 * @vmw_res_rel_cond_nop: Conditional NOP relocation. If the resource id
45 * after validation is -1, the command is replaced with a NOP. Otherwise no
46 * action.
47 */
48enum vmw_resource_relocation_type {
49 vmw_res_rel_normal,
50 vmw_res_rel_nop,
51 vmw_res_rel_cond_nop,
52 vmw_res_rel_max
53};
54
55/**
38 * struct vmw_resource_relocation - Relocation info for resources 56 * struct vmw_resource_relocation - Relocation info for resources
39 * 57 *
40 * @head: List head for the software context's relocation list. 58 * @head: List head for the software context's relocation list.
41 * @res: Non-ref-counted pointer to the resource. 59 * @res: Non-ref-counted pointer to the resource.
42 * @offset: Offset of 4 byte entries into the command buffer where the 60 * @offset: Offset of single byte entries into the command buffer where the
43 * id that needs fixup is located. 61 * id that needs fixup is located.
62 * @rel_type: Type of relocation.
44 */ 63 */
45struct vmw_resource_relocation { 64struct vmw_resource_relocation {
46 struct list_head head; 65 struct list_head head;
47 const struct vmw_resource *res; 66 const struct vmw_resource *res;
48 unsigned long offset; 67 u32 offset:29;
68 enum vmw_resource_relocation_type rel_type:3;
49}; 69};
50 70
51/** 71/**
@@ -109,7 +129,18 @@ static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context,
109 struct vmw_dma_buffer *vbo, 129 struct vmw_dma_buffer *vbo,
110 bool validate_as_mob, 130 bool validate_as_mob,
111 uint32_t *p_val_node); 131 uint32_t *p_val_node);
112 132/**
133 * vmw_ptr_diff - Compute the offset from a to b in bytes
134 *
135 * @a: A starting pointer.
136 * @b: A pointer offset in the same address space.
137 *
138 * Returns: The offset in bytes between the two pointers.
139 */
140static size_t vmw_ptr_diff(void *a, void *b)
141{
142 return (unsigned long) b - (unsigned long) a;
143}
113 144
114/** 145/**
115 * vmw_resources_unreserve - unreserve resources previously reserved for 146 * vmw_resources_unreserve - unreserve resources previously reserved for
@@ -409,11 +440,14 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,
409 * @list: Pointer to head of relocation list. 440 * @list: Pointer to head of relocation list.
410 * @res: The resource. 441 * @res: The resource.
411 * @offset: Offset into the command buffer currently being parsed where the 442 * @offset: Offset into the command buffer currently being parsed where the
412 * id that needs fixup is located. Granularity is 4 bytes. 443 * id that needs fixup is located. Granularity is one byte.
444 * @rel_type: Relocation type.
413 */ 445 */
414static int vmw_resource_relocation_add(struct list_head *list, 446static int vmw_resource_relocation_add(struct list_head *list,
415 const struct vmw_resource *res, 447 const struct vmw_resource *res,
416 unsigned long offset) 448 unsigned long offset,
449 enum vmw_resource_relocation_type
450 rel_type)
417{ 451{
418 struct vmw_resource_relocation *rel; 452 struct vmw_resource_relocation *rel;
419 453
@@ -425,6 +459,7 @@ static int vmw_resource_relocation_add(struct list_head *list,
425 459
426 rel->res = res; 460 rel->res = res;
427 rel->offset = offset; 461 rel->offset = offset;
462 rel->rel_type = rel_type;
428 list_add_tail(&rel->head, list); 463 list_add_tail(&rel->head, list);
429 464
430 return 0; 465 return 0;
@@ -459,11 +494,24 @@ static void vmw_resource_relocations_apply(uint32_t *cb,
459{ 494{
460 struct vmw_resource_relocation *rel; 495 struct vmw_resource_relocation *rel;
461 496
497 /* Validate the struct vmw_resource_relocation member size */
498 BUILD_BUG_ON(SVGA_CB_MAX_SIZE >= (1 << 29));
499 BUILD_BUG_ON(vmw_res_rel_max >= (1 << 3));
500
462 list_for_each_entry(rel, list, head) { 501 list_for_each_entry(rel, list, head) {
463 if (likely(rel->res != NULL)) 502 u32 *addr = (u32 *)((unsigned long) cb + rel->offset);
464 cb[rel->offset] = rel->res->id; 503 switch (rel->rel_type) {
465 else 504 case vmw_res_rel_normal:
466 cb[rel->offset] = SVGA_3D_CMD_NOP; 505 *addr = rel->res->id;
506 break;
507 case vmw_res_rel_nop:
508 *addr = SVGA_3D_CMD_NOP;
509 break;
510 default:
511 if (rel->res->id == -1)
512 *addr = SVGA_3D_CMD_NOP;
513 break;
514 }
467 } 515 }
468} 516}
469 517
@@ -655,7 +703,9 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv,
655 *p_val = NULL; 703 *p_val = NULL;
656 ret = vmw_resource_relocation_add(&sw_context->res_relocations, 704 ret = vmw_resource_relocation_add(&sw_context->res_relocations,
657 res, 705 res,
658 id_loc - sw_context->buf_start); 706 vmw_ptr_diff(sw_context->buf_start,
707 id_loc),
708 vmw_res_rel_normal);
659 if (unlikely(ret != 0)) 709 if (unlikely(ret != 0))
660 return ret; 710 return ret;
661 711
@@ -721,7 +771,8 @@ vmw_cmd_res_check(struct vmw_private *dev_priv,
721 771
722 return vmw_resource_relocation_add 772 return vmw_resource_relocation_add
723 (&sw_context->res_relocations, res, 773 (&sw_context->res_relocations, res,
724 id_loc - sw_context->buf_start); 774 vmw_ptr_diff(sw_context->buf_start, id_loc),
775 vmw_res_rel_normal);
725 } 776 }
726 777
727 ret = vmw_user_resource_lookup_handle(dev_priv, 778 ret = vmw_user_resource_lookup_handle(dev_priv,
@@ -2143,10 +2194,10 @@ static int vmw_cmd_shader_define(struct vmw_private *dev_priv,
2143 return ret; 2194 return ret;
2144 2195
2145 return vmw_resource_relocation_add(&sw_context->res_relocations, 2196 return vmw_resource_relocation_add(&sw_context->res_relocations,
2146 NULL, &cmd->header.id - 2197 NULL,
2147 sw_context->buf_start); 2198 vmw_ptr_diff(sw_context->buf_start,
2148 2199 &cmd->header.id),
2149 return 0; 2200 vmw_res_rel_nop);
2150} 2201}
2151 2202
2152/** 2203/**
@@ -2188,10 +2239,10 @@ static int vmw_cmd_shader_destroy(struct vmw_private *dev_priv,
2188 return ret; 2239 return ret;
2189 2240
2190 return vmw_resource_relocation_add(&sw_context->res_relocations, 2241 return vmw_resource_relocation_add(&sw_context->res_relocations,
2191 NULL, &cmd->header.id - 2242 NULL,
2192 sw_context->buf_start); 2243 vmw_ptr_diff(sw_context->buf_start,
2193 2244 &cmd->header.id),
2194 return 0; 2245 vmw_res_rel_nop);
2195} 2246}
2196 2247
2197/** 2248/**
@@ -2848,8 +2899,7 @@ static int vmw_cmd_dx_cid_check(struct vmw_private *dev_priv,
2848 * @header: Pointer to the command header in the command stream. 2899 * @header: Pointer to the command header in the command stream.
2849 * 2900 *
2850 * Check that the view exists, and if it was not created using this 2901 * Check that the view exists, and if it was not created using this
2851 * command batch, make sure it's validated (present in the device) so that 2902 * command batch, conditionally make this command a NOP.
2852 * the remove command will not confuse the device.
2853 */ 2903 */
2854static int vmw_cmd_dx_view_remove(struct vmw_private *dev_priv, 2904static int vmw_cmd_dx_view_remove(struct vmw_private *dev_priv,
2855 struct vmw_sw_context *sw_context, 2905 struct vmw_sw_context *sw_context,
@@ -2877,10 +2927,16 @@ static int vmw_cmd_dx_view_remove(struct vmw_private *dev_priv,
2877 return ret; 2927 return ret;
2878 2928
2879 /* 2929 /*
2880 * Add view to the validate list iff it was not created using this 2930 * If the view wasn't created during this command batch, it might
2881 * command batch. 2931 * have been removed due to a context swapout, so add a
2932 * relocation to conditionally make this command a NOP to avoid
2933 * device errors.
2882 */ 2934 */
2883 return vmw_view_res_val_add(sw_context, view); 2935 return vmw_resource_relocation_add(&sw_context->res_relocations,
2936 view,
2937 vmw_ptr_diff(sw_context->buf_start,
2938 &cmd->header.id),
2939 vmw_res_rel_cond_nop);
2884} 2940}
2885 2941
2886/** 2942/**
@@ -3029,6 +3085,35 @@ static int vmw_cmd_dx_genmips(struct vmw_private *dev_priv,
3029 cmd->body.shaderResourceViewId); 3085 cmd->body.shaderResourceViewId);
3030} 3086}
3031 3087
3088/**
3089 * vmw_cmd_dx_transfer_from_buffer -
3090 * Validate an SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER command
3091 *
3092 * @dev_priv: Pointer to a device private struct.
3093 * @sw_context: The software context being used for this batch.
3094 * @header: Pointer to the command header in the command stream.
3095 */
3096static int vmw_cmd_dx_transfer_from_buffer(struct vmw_private *dev_priv,
3097 struct vmw_sw_context *sw_context,
3098 SVGA3dCmdHeader *header)
3099{
3100 struct {
3101 SVGA3dCmdHeader header;
3102 SVGA3dCmdDXTransferFromBuffer body;
3103 } *cmd = container_of(header, typeof(*cmd), header);
3104 int ret;
3105
3106 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
3107 user_surface_converter,
3108 &cmd->body.srcSid, NULL);
3109 if (ret != 0)
3110 return ret;
3111
3112 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
3113 user_surface_converter,
3114 &cmd->body.destSid, NULL);
3115}
3116
3032static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv, 3117static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
3033 struct vmw_sw_context *sw_context, 3118 struct vmw_sw_context *sw_context,
3034 void *buf, uint32_t *size) 3119 void *buf, uint32_t *size)
@@ -3379,6 +3464,9 @@ static const struct vmw_cmd_entry vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
3379 &vmw_cmd_buffer_copy_check, true, false, true), 3464 &vmw_cmd_buffer_copy_check, true, false, true),
3380 VMW_CMD_DEF(SVGA_3D_CMD_DX_PRED_COPY_REGION, 3465 VMW_CMD_DEF(SVGA_3D_CMD_DX_PRED_COPY_REGION,
3381 &vmw_cmd_pred_copy_check, true, false, true), 3466 &vmw_cmd_pred_copy_check, true, false, true),
3467 VMW_CMD_DEF(SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER,
3468 &vmw_cmd_dx_transfer_from_buffer,
3469 true, false, true),
3382}; 3470};
3383 3471
3384static int vmw_cmd_check(struct vmw_private *dev_priv, 3472static int vmw_cmd_check(struct vmw_private *dev_priv,
@@ -3848,14 +3936,14 @@ static void *vmw_execbuf_cmdbuf(struct vmw_private *dev_priv,
3848 int ret; 3936 int ret;
3849 3937
3850 *header = NULL; 3938 *header = NULL;
3851 if (!dev_priv->cman || kernel_commands)
3852 return kernel_commands;
3853
3854 if (command_size > SVGA_CB_MAX_SIZE) { 3939 if (command_size > SVGA_CB_MAX_SIZE) {
3855 DRM_ERROR("Command buffer is too large.\n"); 3940 DRM_ERROR("Command buffer is too large.\n");
3856 return ERR_PTR(-EINVAL); 3941 return ERR_PTR(-EINVAL);
3857 } 3942 }
3858 3943
3944 if (!dev_priv->cman || kernel_commands)
3945 return kernel_commands;
3946
3859 /* If possible, add a little space for fencing. */ 3947 /* If possible, add a little space for fencing. */
3860 cmdbuf_size = command_size + 512; 3948 cmdbuf_size = command_size + 512;
3861 cmdbuf_size = min_t(size_t, cmdbuf_size, SVGA_CB_MAX_SIZE); 3949 cmdbuf_size = min_t(size_t, cmdbuf_size, SVGA_CB_MAX_SIZE);
@@ -4232,9 +4320,6 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,
4232 ttm_bo_unref(&query_val.bo); 4320 ttm_bo_unref(&query_val.bo);
4233 ttm_bo_unref(&pinned_val.bo); 4321 ttm_bo_unref(&pinned_val.bo);
4234 vmw_dmabuf_unreference(&dev_priv->pinned_bo); 4322 vmw_dmabuf_unreference(&dev_priv->pinned_bo);
4235 DRM_INFO("Dummy query bo pin count: %d\n",
4236 dev_priv->dummy_query_bo->pin_count);
4237
4238out_unlock: 4323out_unlock:
4239 return; 4324 return;
4240 4325
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 6a328d507a28..52ca1c9d070e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -574,10 +574,8 @@ static int vmw_user_dmabuf_synccpu_grab(struct vmw_user_dma_buffer *user_bo,
574 bool nonblock = !!(flags & drm_vmw_synccpu_dontblock); 574 bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);
575 long lret; 575 long lret;
576 576
577 if (nonblock) 577 lret = reservation_object_wait_timeout_rcu(bo->resv, true, true,
578 return reservation_object_test_signaled_rcu(bo->resv, true) ? 0 : -EBUSY; 578 nonblock ? 0 : MAX_SCHEDULE_TIMEOUT);
579
580 lret = reservation_object_wait_timeout_rcu(bo->resv, true, true, MAX_SCHEDULE_TIMEOUT);
581 if (!lret) 579 if (!lret)
582 return -EBUSY; 580 return -EBUSY;
583 else if (lret < 0) 581 else if (lret < 0)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index c2a721a8cef9..b445ce9b9757 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -324,7 +324,7 @@ static void vmw_hw_surface_destroy(struct vmw_resource *res)
324 if (res->id != -1) { 324 if (res->id != -1) {
325 325
326 cmd = vmw_fifo_reserve(dev_priv, vmw_surface_destroy_size()); 326 cmd = vmw_fifo_reserve(dev_priv, vmw_surface_destroy_size());
327 if (unlikely(cmd == NULL)) { 327 if (unlikely(!cmd)) {
328 DRM_ERROR("Failed reserving FIFO space for surface " 328 DRM_ERROR("Failed reserving FIFO space for surface "
329 "destruction.\n"); 329 "destruction.\n");
330 return; 330 return;
@@ -397,7 +397,7 @@ static int vmw_legacy_srf_create(struct vmw_resource *res)
397 397
398 submit_size = vmw_surface_define_size(srf); 398 submit_size = vmw_surface_define_size(srf);
399 cmd = vmw_fifo_reserve(dev_priv, submit_size); 399 cmd = vmw_fifo_reserve(dev_priv, submit_size);
400 if (unlikely(cmd == NULL)) { 400 if (unlikely(!cmd)) {
401 DRM_ERROR("Failed reserving FIFO space for surface " 401 DRM_ERROR("Failed reserving FIFO space for surface "
402 "creation.\n"); 402 "creation.\n");
403 ret = -ENOMEM; 403 ret = -ENOMEM;
@@ -446,11 +446,10 @@ static int vmw_legacy_srf_dma(struct vmw_resource *res,
446 uint8_t *cmd; 446 uint8_t *cmd;
447 struct vmw_private *dev_priv = res->dev_priv; 447 struct vmw_private *dev_priv = res->dev_priv;
448 448
449 BUG_ON(val_buf->bo == NULL); 449 BUG_ON(!val_buf->bo);
450
451 submit_size = vmw_surface_dma_size(srf); 450 submit_size = vmw_surface_dma_size(srf);
452 cmd = vmw_fifo_reserve(dev_priv, submit_size); 451 cmd = vmw_fifo_reserve(dev_priv, submit_size);
453 if (unlikely(cmd == NULL)) { 452 if (unlikely(!cmd)) {
454 DRM_ERROR("Failed reserving FIFO space for surface " 453 DRM_ERROR("Failed reserving FIFO space for surface "
455 "DMA.\n"); 454 "DMA.\n");
456 return -ENOMEM; 455 return -ENOMEM;
@@ -538,7 +537,7 @@ static int vmw_legacy_srf_destroy(struct vmw_resource *res)
538 537
539 submit_size = vmw_surface_destroy_size(); 538 submit_size = vmw_surface_destroy_size();
540 cmd = vmw_fifo_reserve(dev_priv, submit_size); 539 cmd = vmw_fifo_reserve(dev_priv, submit_size);
541 if (unlikely(cmd == NULL)) { 540 if (unlikely(!cmd)) {
542 DRM_ERROR("Failed reserving FIFO space for surface " 541 DRM_ERROR("Failed reserving FIFO space for surface "
543 "eviction.\n"); 542 "eviction.\n");
544 return -ENOMEM; 543 return -ENOMEM;
@@ -578,7 +577,7 @@ static int vmw_surface_init(struct vmw_private *dev_priv,
578 int ret; 577 int ret;
579 struct vmw_resource *res = &srf->res; 578 struct vmw_resource *res = &srf->res;
580 579
581 BUG_ON(res_free == NULL); 580 BUG_ON(!res_free);
582 if (!dev_priv->has_mob) 581 if (!dev_priv->has_mob)
583 vmw_fifo_resource_inc(dev_priv); 582 vmw_fifo_resource_inc(dev_priv);
584 ret = vmw_resource_init(dev_priv, res, true, res_free, 583 ret = vmw_resource_init(dev_priv, res, true, res_free,
@@ -700,7 +699,6 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
700 struct drm_vmw_surface_create_req *req = &arg->req; 699 struct drm_vmw_surface_create_req *req = &arg->req;
701 struct drm_vmw_surface_arg *rep = &arg->rep; 700 struct drm_vmw_surface_arg *rep = &arg->rep;
702 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 701 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
703 struct drm_vmw_size __user *user_sizes;
704 int ret; 702 int ret;
705 int i, j; 703 int i, j;
706 uint32_t cur_bo_offset; 704 uint32_t cur_bo_offset;
@@ -748,7 +746,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
748 } 746 }
749 747
750 user_srf = kzalloc(sizeof(*user_srf), GFP_KERNEL); 748 user_srf = kzalloc(sizeof(*user_srf), GFP_KERNEL);
751 if (unlikely(user_srf == NULL)) { 749 if (unlikely(!user_srf)) {
752 ret = -ENOMEM; 750 ret = -ENOMEM;
753 goto out_no_user_srf; 751 goto out_no_user_srf;
754 } 752 }
@@ -763,29 +761,21 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
763 memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels)); 761 memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels));
764 srf->num_sizes = num_sizes; 762 srf->num_sizes = num_sizes;
765 user_srf->size = size; 763 user_srf->size = size;
766 764 srf->sizes = memdup_user((struct drm_vmw_size __user *)(unsigned long)
767 srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL); 765 req->size_addr,
768 if (unlikely(srf->sizes == NULL)) { 766 sizeof(*srf->sizes) * srf->num_sizes);
769 ret = -ENOMEM; 767 if (IS_ERR(srf->sizes)) {
768 ret = PTR_ERR(srf->sizes);
770 goto out_no_sizes; 769 goto out_no_sizes;
771 } 770 }
772 srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets), 771 srf->offsets = kmalloc_array(srf->num_sizes,
773 GFP_KERNEL); 772 sizeof(*srf->offsets),
774 if (unlikely(srf->offsets == NULL)) { 773 GFP_KERNEL);
774 if (unlikely(!srf->offsets)) {
775 ret = -ENOMEM; 775 ret = -ENOMEM;
776 goto out_no_offsets; 776 goto out_no_offsets;
777 } 777 }
778 778
779 user_sizes = (struct drm_vmw_size __user *)(unsigned long)
780 req->size_addr;
781
782 ret = copy_from_user(srf->sizes, user_sizes,
783 srf->num_sizes * sizeof(*srf->sizes));
784 if (unlikely(ret != 0)) {
785 ret = -EFAULT;
786 goto out_no_copy;
787 }
788
789 srf->base_size = *srf->sizes; 779 srf->base_size = *srf->sizes;
790 srf->autogen_filter = SVGA3D_TEX_FILTER_NONE; 780 srf->autogen_filter = SVGA3D_TEX_FILTER_NONE;
791 srf->multisample_count = 0; 781 srf->multisample_count = 0;
@@ -923,7 +913,7 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv,
923 913
924 ret = -EINVAL; 914 ret = -EINVAL;
925 base = ttm_base_object_lookup_for_ref(dev_priv->tdev, handle); 915 base = ttm_base_object_lookup_for_ref(dev_priv->tdev, handle);
926 if (unlikely(base == NULL)) { 916 if (unlikely(!base)) {
927 DRM_ERROR("Could not find surface to reference.\n"); 917 DRM_ERROR("Could not find surface to reference.\n");
928 goto out_no_lookup; 918 goto out_no_lookup;
929 } 919 }
@@ -1069,7 +1059,7 @@ static int vmw_gb_surface_create(struct vmw_resource *res)
1069 1059
1070 cmd = vmw_fifo_reserve(dev_priv, submit_len); 1060 cmd = vmw_fifo_reserve(dev_priv, submit_len);
1071 cmd2 = (typeof(cmd2))cmd; 1061 cmd2 = (typeof(cmd2))cmd;
1072 if (unlikely(cmd == NULL)) { 1062 if (unlikely(!cmd)) {
1073 DRM_ERROR("Failed reserving FIFO space for surface " 1063 DRM_ERROR("Failed reserving FIFO space for surface "
1074 "creation.\n"); 1064 "creation.\n");
1075 ret = -ENOMEM; 1065 ret = -ENOMEM;
@@ -1135,7 +1125,7 @@ static int vmw_gb_surface_bind(struct vmw_resource *res,
1135 submit_size = sizeof(*cmd1) + (res->backup_dirty ? sizeof(*cmd2) : 0); 1125 submit_size = sizeof(*cmd1) + (res->backup_dirty ? sizeof(*cmd2) : 0);
1136 1126
1137 cmd1 = vmw_fifo_reserve(dev_priv, submit_size); 1127 cmd1 = vmw_fifo_reserve(dev_priv, submit_size);
1138 if (unlikely(cmd1 == NULL)) { 1128 if (unlikely(!cmd1)) {
1139 DRM_ERROR("Failed reserving FIFO space for surface " 1129 DRM_ERROR("Failed reserving FIFO space for surface "
1140 "binding.\n"); 1130 "binding.\n");
1141 return -ENOMEM; 1131 return -ENOMEM;
@@ -1185,7 +1175,7 @@ static int vmw_gb_surface_unbind(struct vmw_resource *res,
1185 1175
1186 submit_size = sizeof(*cmd3) + (readback ? sizeof(*cmd1) : sizeof(*cmd2)); 1176 submit_size = sizeof(*cmd3) + (readback ? sizeof(*cmd1) : sizeof(*cmd2));
1187 cmd = vmw_fifo_reserve(dev_priv, submit_size); 1177 cmd = vmw_fifo_reserve(dev_priv, submit_size);
1188 if (unlikely(cmd == NULL)) { 1178 if (unlikely(!cmd)) {
1189 DRM_ERROR("Failed reserving FIFO space for surface " 1179 DRM_ERROR("Failed reserving FIFO space for surface "
1190 "unbinding.\n"); 1180 "unbinding.\n");
1191 return -ENOMEM; 1181 return -ENOMEM;
@@ -1244,7 +1234,7 @@ static int vmw_gb_surface_destroy(struct vmw_resource *res)
1244 vmw_binding_res_list_scrub(&res->binding_head); 1234 vmw_binding_res_list_scrub(&res->binding_head);
1245 1235
1246 cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd)); 1236 cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
1247 if (unlikely(cmd == NULL)) { 1237 if (unlikely(!cmd)) {
1248 DRM_ERROR("Failed reserving FIFO space for surface " 1238 DRM_ERROR("Failed reserving FIFO space for surface "
1249 "destruction.\n"); 1239 "destruction.\n");
1250 mutex_unlock(&dev_priv->binding_mutex); 1240 mutex_unlock(&dev_priv->binding_mutex);
@@ -1410,7 +1400,7 @@ int vmw_gb_surface_reference_ioctl(struct drm_device *dev, void *data,
1410 1400
1411 user_srf = container_of(base, struct vmw_user_surface, prime.base); 1401 user_srf = container_of(base, struct vmw_user_surface, prime.base);
1412 srf = &user_srf->srf; 1402 srf = &user_srf->srf;
1413 if (srf->res.backup == NULL) { 1403 if (!srf->res.backup) {
1414 DRM_ERROR("Shared GB surface is missing a backup buffer.\n"); 1404 DRM_ERROR("Shared GB surface is missing a backup buffer.\n");
1415 goto out_bad_resource; 1405 goto out_bad_resource;
1416 } 1406 }
@@ -1524,7 +1514,7 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
1524 } 1514 }
1525 1515
1526 user_srf = kzalloc(sizeof(*user_srf), GFP_KERNEL); 1516 user_srf = kzalloc(sizeof(*user_srf), GFP_KERNEL);
1527 if (unlikely(user_srf == NULL)) { 1517 if (unlikely(!user_srf)) {
1528 ret = -ENOMEM; 1518 ret = -ENOMEM;
1529 goto out_no_user_srf; 1519 goto out_no_user_srf;
1530 } 1520 }
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 4aa3cb63fd41..bcd06306f3e8 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -314,10 +314,14 @@ static void heartbeat_onchannelcallback(void *context)
314 u8 *hbeat_txf_buf = util_heartbeat.recv_buffer; 314 u8 *hbeat_txf_buf = util_heartbeat.recv_buffer;
315 struct icmsg_negotiate *negop = NULL; 315 struct icmsg_negotiate *negop = NULL;
316 316
317 vmbus_recvpacket(channel, hbeat_txf_buf, 317 while (1) {
318 PAGE_SIZE, &recvlen, &requestid); 318
319 vmbus_recvpacket(channel, hbeat_txf_buf,
320 PAGE_SIZE, &recvlen, &requestid);
321
322 if (!recvlen)
323 break;
319 324
320 if (recvlen > 0) {
321 icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[ 325 icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[
322 sizeof(struct vmbuspipe_hdr)]; 326 sizeof(struct vmbuspipe_hdr)];
323 327
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 98114cef1e43..2fe1828bd10b 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -194,10 +194,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
194 * 0.5'C per two measurement cycles thus ignore possible 194 * 0.5'C per two measurement cycles thus ignore possible
195 * but unlikely aliasing error on lsb reading. --Grant 195 * but unlikely aliasing error on lsb reading. --Grant
196 */ 196 */
197 data->temp = ((i2c_smbus_read_byte_data(client, 197 data->temp = (i2c_smbus_read_byte_data(client,
198 ADM9240_REG_TEMP) << 8) | 198 ADM9240_REG_TEMP) << 8) |
199 i2c_smbus_read_byte_data(client, 199 i2c_smbus_read_byte_data(client,
200 ADM9240_REG_TEMP_CONF)) / 128; 200 ADM9240_REG_TEMP_CONF);
201 201
202 for (i = 0; i < 2; i++) { /* read fans */ 202 for (i = 0; i < 2; i++) { /* read fans */
203 data->fan[i] = i2c_smbus_read_byte_data(client, 203 data->fan[i] = i2c_smbus_read_byte_data(client,
@@ -263,7 +263,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *dummy,
263 char *buf) 263 char *buf)
264{ 264{
265 struct adm9240_data *data = adm9240_update_device(dev); 265 struct adm9240_data *data = adm9240_update_device(dev);
266 return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ 266 return sprintf(buf, "%d\n", data->temp / 128 * 500); /* 9-bit value */
267} 267}
268 268
269static ssize_t show_max(struct device *dev, struct device_attribute *devattr, 269static ssize_t show_max(struct device *dev, struct device_attribute *devattr,
diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
index bef84e085973..c1b9275978f9 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
268 long *val) 268 long *val)
269{ 269{
270 struct max31790_data *data = max31790_update_device(dev); 270 struct max31790_data *data = max31790_update_device(dev);
271 u8 fan_config = data->fan_config[channel]; 271 u8 fan_config;
272 272
273 if (IS_ERR(data)) 273 if (IS_ERR(data))
274 return PTR_ERR(data); 274 return PTR_ERR(data);
275 275
276 fan_config = data->fan_config[channel];
277
276 switch (attr) { 278 switch (attr) {
277 case hwmon_pwm_input: 279 case hwmon_pwm_input:
278 *val = data->pwm[channel] >> 8; 280 *val = data->pwm[channel] >> 8;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 6d94e2ec5b4f..d252276feadf 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -79,12 +79,12 @@ config I2C_AMD8111
79 79
80config I2C_HIX5HD2 80config I2C_HIX5HD2
81 tristate "Hix5hd2 high-speed I2C driver" 81 tristate "Hix5hd2 high-speed I2C driver"
82 depends on ARCH_HIX5HD2 || COMPILE_TEST 82 depends on ARCH_HISI || ARCH_HIX5HD2 || COMPILE_TEST
83 help 83 help
84 Say Y here to include support for high-speed I2C controller in the 84 Say Y here to include support for the high-speed I2C controller
85 Hisilicon based hix5hd2 SoCs. 85 used in HiSilicon hix5hd2 SoCs.
86 86
87 This driver can also be built as a module. If so, the module 87 This driver can also be built as a module. If so, the module
88 will be called i2c-hix5hd2. 88 will be called i2c-hix5hd2.
89 89
90config I2C_I801 90config I2C_I801
@@ -589,10 +589,10 @@ config I2C_IMG
589 589
590config I2C_IMX 590config I2C_IMX
591 tristate "IMX I2C interface" 591 tristate "IMX I2C interface"
592 depends on ARCH_MXC || ARCH_LAYERSCAPE 592 depends on ARCH_MXC || ARCH_LAYERSCAPE || COLDFIRE
593 help 593 help
594 Say Y here if you want to use the IIC bus controller on 594 Say Y here if you want to use the IIC bus controller on
595 the Freescale i.MX/MXC or Layerscape processors. 595 the Freescale i.MX/MXC, Layerscape or ColdFire processors.
596 596
597 This driver can also be built as a module. If so, the module 597 This driver can also be built as a module. If so, the module
598 will be called i2c-imx. 598 will be called i2c-imx.
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 1fe93c43215c..11e866d05368 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -95,6 +95,9 @@
95#define DW_IC_STATUS_TFE BIT(2) 95#define DW_IC_STATUS_TFE BIT(2)
96#define DW_IC_STATUS_MST_ACTIVITY BIT(5) 96#define DW_IC_STATUS_MST_ACTIVITY BIT(5)
97 97
98#define DW_IC_SDA_HOLD_RX_SHIFT 16
99#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, DW_IC_SDA_HOLD_RX_SHIFT)
100
98#define DW_IC_ERR_TX_ABRT 0x1 101#define DW_IC_ERR_TX_ABRT 0x1
99 102
100#define DW_IC_TAR_10BITADDR_MASTER BIT(12) 103#define DW_IC_TAR_10BITADDR_MASTER BIT(12)
@@ -420,12 +423,20 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
420 /* Configure SDA Hold Time if required */ 423 /* Configure SDA Hold Time if required */
421 reg = dw_readl(dev, DW_IC_COMP_VERSION); 424 reg = dw_readl(dev, DW_IC_COMP_VERSION);
422 if (reg >= DW_IC_SDA_HOLD_MIN_VERS) { 425 if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
423 if (dev->sda_hold_time) { 426 if (!dev->sda_hold_time) {
424 dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
425 } else {
426 /* Keep previous hold time setting if no one set it */ 427 /* Keep previous hold time setting if no one set it */
427 dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD); 428 dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD);
428 } 429 }
430 /*
431 * Workaround for avoiding TX arbitration lost in case I2C
432 * slave pulls SDA down "too quickly" after falling egde of
433 * SCL by enabling non-zero SDA RX hold. Specification says it
434 * extends incoming SDA low to high transition while SCL is
435 * high but it apprears to help also above issue.
436 */
437 if (!(dev->sda_hold_time & DW_IC_SDA_HOLD_RX_MASK))
438 dev->sda_hold_time |= 1 << DW_IC_SDA_HOLD_RX_SHIFT;
439 dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
429 } else { 440 } else {
430 dev_warn(dev->dev, 441 dev_warn(dev->dev,
431 "Hardware too old to adjust SDA hold time.\n"); 442 "Hardware too old to adjust SDA hold time.\n");
diff --git a/drivers/i2c/busses/i2c-digicolor.c b/drivers/i2c/busses/i2c-digicolor.c
index 9604024e0eb0..49f2084f7bb5 100644
--- a/drivers/i2c/busses/i2c-digicolor.c
+++ b/drivers/i2c/busses/i2c-digicolor.c
@@ -368,6 +368,7 @@ static const struct of_device_id dc_i2c_match[] = {
368 { .compatible = "cnxt,cx92755-i2c" }, 368 { .compatible = "cnxt,cx92755-i2c" },
369 { }, 369 { },
370}; 370};
371MODULE_DEVICE_TABLE(of, dc_i2c_match);
371 372
372static struct platform_driver dc_i2c_driver = { 373static struct platform_driver dc_i2c_driver = {
373 .probe = dc_i2c_probe, 374 .probe = dc_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 08847e8b8998..eb3627f35d12 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -146,6 +146,7 @@
146#define SMBHSTCFG_HST_EN 1 146#define SMBHSTCFG_HST_EN 1
147#define SMBHSTCFG_SMB_SMI_EN 2 147#define SMBHSTCFG_SMB_SMI_EN 2
148#define SMBHSTCFG_I2C_EN 4 148#define SMBHSTCFG_I2C_EN 4
149#define SMBHSTCFG_SPD_WD 0x10
149 150
150/* TCO configuration bits for TCOCTL */ 151/* TCO configuration bits for TCOCTL */
151#define TCOCTL_EN 0x0100 152#define TCOCTL_EN 0x0100
@@ -865,9 +866,16 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
865 block = 1; 866 block = 1;
866 break; 867 break;
867 case I2C_SMBUS_I2C_BLOCK_DATA: 868 case I2C_SMBUS_I2C_BLOCK_DATA:
868 /* NB: page 240 of ICH5 datasheet shows that the R/#W 869 /*
869 * bit should be cleared here, even when reading */ 870 * NB: page 240 of ICH5 datasheet shows that the R/#W
870 outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); 871 * bit should be cleared here, even when reading.
872 * However if SPD Write Disable is set (Lynx Point and later),
873 * the read will fail if we don't set the R/#W bit.
874 */
875 outb_p(((addr & 0x7f) << 1) |
876 ((priv->original_hstcfg & SMBHSTCFG_SPD_WD) ?
877 (read_write & 0x01) : 0),
878 SMBHSTADD(priv));
871 if (read_write == I2C_SMBUS_READ) { 879 if (read_write == I2C_SMBUS_READ) {
872 /* NB: page 240 of ICH5 datasheet also shows 880 /* NB: page 240 of ICH5 datasheet also shows
873 * that DATA1 is the cmd field when reading */ 881 * that DATA1 is the cmd field when reading */
@@ -1573,6 +1581,8 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
1573 /* Disable SMBus interrupt feature if SMBus using SMI# */ 1581 /* Disable SMBus interrupt feature if SMBus using SMI# */
1574 priv->features &= ~FEATURE_IRQ; 1582 priv->features &= ~FEATURE_IRQ;
1575 } 1583 }
1584 if (temp & SMBHSTCFG_SPD_WD)
1585 dev_info(&dev->dev, "SPD Write Disable is set\n");
1576 1586
1577 /* Clear special mode bits */ 1587 /* Clear special mode bits */
1578 if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER)) 1588 if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER))
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 592a8f26a708..47fc1f1acff7 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -1009,10 +1009,13 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
1009 rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios", 0); 1009 rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios", 0);
1010 rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios", 0); 1010 rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios", 0);
1011 1011
1012 if (!gpio_is_valid(rinfo->sda_gpio) || 1012 if (rinfo->sda_gpio == -EPROBE_DEFER ||
1013 !gpio_is_valid(rinfo->scl_gpio) || 1013 rinfo->scl_gpio == -EPROBE_DEFER) {
1014 IS_ERR(i2c_imx->pinctrl_pins_default) || 1014 return -EPROBE_DEFER;
1015 IS_ERR(i2c_imx->pinctrl_pins_gpio)) { 1015 } else if (!gpio_is_valid(rinfo->sda_gpio) ||
1016 !gpio_is_valid(rinfo->scl_gpio) ||
1017 IS_ERR(i2c_imx->pinctrl_pins_default) ||
1018 IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
1016 dev_dbg(&pdev->dev, "recovery information incomplete\n"); 1019 dev_dbg(&pdev->dev, "recovery information incomplete\n");
1017 return 0; 1020 return 0;
1018 } 1021 }
diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
index b8ea62105f42..30132c3957cd 100644
--- a/drivers/i2c/busses/i2c-jz4780.c
+++ b/drivers/i2c/busses/i2c-jz4780.c
@@ -729,6 +729,7 @@ static const struct of_device_id jz4780_i2c_of_matches[] = {
729 { .compatible = "ingenic,jz4780-i2c", }, 729 { .compatible = "ingenic,jz4780-i2c", },
730 { /* sentinel */ } 730 { /* sentinel */ }
731}; 731};
732MODULE_DEVICE_TABLE(of, jz4780_i2c_of_matches);
732 733
733static int jz4780_i2c_probe(struct platform_device *pdev) 734static int jz4780_i2c_probe(struct platform_device *pdev)
734{ 735{
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index 50702c7bb244..df220666d627 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -694,6 +694,8 @@ static int rk3x_i2c_v0_calc_timings(unsigned long clk_rate,
694 t_calc->div_low--; 694 t_calc->div_low--;
695 t_calc->div_high--; 695 t_calc->div_high--;
696 696
697 /* Give the tuning value 0, that would not update con register */
698 t_calc->tuning = 0;
697 /* Maximum divider supported by hw is 0xffff */ 699 /* Maximum divider supported by hw is 0xffff */
698 if (t_calc->div_low > 0xffff) { 700 if (t_calc->div_low > 0xffff) {
699 t_calc->div_low = 0xffff; 701 t_calc->div_low = 0xffff;
diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c
index 263685c7a512..05cf192ef1ac 100644
--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -105,7 +105,7 @@ struct slimpro_i2c_dev {
105 struct mbox_chan *mbox_chan; 105 struct mbox_chan *mbox_chan;
106 struct mbox_client mbox_client; 106 struct mbox_client mbox_client;
107 struct completion rd_complete; 107 struct completion rd_complete;
108 u8 dma_buffer[I2C_SMBUS_BLOCK_MAX]; 108 u8 dma_buffer[I2C_SMBUS_BLOCK_MAX + 1]; /* dma_buffer[0] is used for length */
109 u32 *resp_msg; 109 u32 *resp_msg;
110}; 110};
111 111
diff --git a/drivers/i2c/busses/i2c-xlp9xx.c b/drivers/i2c/busses/i2c-xlp9xx.c
index 2a972ed7aa0d..e29ff37a43bd 100644
--- a/drivers/i2c/busses/i2c-xlp9xx.c
+++ b/drivers/i2c/busses/i2c-xlp9xx.c
@@ -426,6 +426,7 @@ static const struct of_device_id xlp9xx_i2c_of_match[] = {
426 { .compatible = "netlogic,xlp980-i2c", }, 426 { .compatible = "netlogic,xlp980-i2c", },
427 { /* sentinel */ }, 427 { /* sentinel */ },
428}; 428};
429MODULE_DEVICE_TABLE(of, xlp9xx_i2c_of_match);
429 430
430#ifdef CONFIG_ACPI 431#ifdef CONFIG_ACPI
431static const struct acpi_device_id xlp9xx_i2c_acpi_ids[] = { 432static const struct acpi_device_id xlp9xx_i2c_acpi_ids[] = {
diff --git a/drivers/i2c/busses/i2c-xlr.c b/drivers/i2c/busses/i2c-xlr.c
index 0968f59b6df5..ad17d88d8573 100644
--- a/drivers/i2c/busses/i2c-xlr.c
+++ b/drivers/i2c/busses/i2c-xlr.c
@@ -358,6 +358,7 @@ static const struct of_device_id xlr_i2c_dt_ids[] = {
358 }, 358 },
359 { } 359 { }
360}; 360};
361MODULE_DEVICE_TABLE(of, xlr_i2c_dt_ids);
361 362
362static int xlr_i2c_probe(struct platform_device *pdev) 363static int xlr_i2c_probe(struct platform_device *pdev)
363{ 364{
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 5ab67219f71e..1704fc84d647 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1681,6 +1681,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
1681static void of_i2c_register_devices(struct i2c_adapter *adap) 1681static void of_i2c_register_devices(struct i2c_adapter *adap)
1682{ 1682{
1683 struct device_node *bus, *node; 1683 struct device_node *bus, *node;
1684 struct i2c_client *client;
1684 1685
1685 /* Only register child devices if the adapter has a node pointer set */ 1686 /* Only register child devices if the adapter has a node pointer set */
1686 if (!adap->dev.of_node) 1687 if (!adap->dev.of_node)
@@ -1695,7 +1696,14 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
1695 for_each_available_child_of_node(bus, node) { 1696 for_each_available_child_of_node(bus, node) {
1696 if (of_node_test_and_set_flag(node, OF_POPULATED)) 1697 if (of_node_test_and_set_flag(node, OF_POPULATED))
1697 continue; 1698 continue;
1698 of_i2c_register_device(adap, node); 1699
1700 client = of_i2c_register_device(adap, node);
1701 if (IS_ERR(client)) {
1702 dev_warn(&adap->dev,
1703 "Failed to create I2C device for %s\n",
1704 node->full_name);
1705 of_node_clear_flag(node, OF_POPULATED);
1706 }
1699 } 1707 }
1700 1708
1701 of_node_put(bus); 1709 of_node_put(bus);
@@ -2299,6 +2307,7 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
2299 if (IS_ERR(client)) { 2307 if (IS_ERR(client)) {
2300 dev_err(&adap->dev, "failed to create client for '%s'\n", 2308 dev_err(&adap->dev, "failed to create client for '%s'\n",
2301 rd->dn->full_name); 2309 rd->dn->full_name);
2310 of_node_clear_flag(rd->dn, OF_POPULATED);
2302 return notifier_from_errno(PTR_ERR(client)); 2311 return notifier_from_errno(PTR_ERR(client));
2303 } 2312 }
2304 break; 2313 break;
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 7edcf3238620..99c051490eff 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -437,6 +437,8 @@ config STX104
437config TI_ADC081C 437config TI_ADC081C
438 tristate "Texas Instruments ADC081C/ADC101C/ADC121C family" 438 tristate "Texas Instruments ADC081C/ADC101C/ADC121C family"
439 depends on I2C 439 depends on I2C
440 select IIO_BUFFER
441 select IIO_TRIGGERED_BUFFER
440 help 442 help
441 If you say yes here you get support for Texas Instruments ADC081C, 443 If you say yes here you get support for Texas Instruments ADC081C,
442 ADC101C and ADC121C ADC chips. 444 ADC101C and ADC121C ADC chips.
diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c
index bd321b305a0a..ef761a508630 100644
--- a/drivers/iio/chemical/atlas-ph-sensor.c
+++ b/drivers/iio/chemical/atlas-ph-sensor.c
@@ -213,13 +213,14 @@ static int atlas_check_ec_calibration(struct atlas_data *data)
213 struct device *dev = &data->client->dev; 213 struct device *dev = &data->client->dev;
214 int ret; 214 int ret;
215 unsigned int val; 215 unsigned int val;
216 __be16 rval;
216 217
217 ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &val, 2); 218 ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &rval, 2);
218 if (ret) 219 if (ret)
219 return ret; 220 return ret;
220 221
221 dev_info(dev, "probe set to K = %d.%.2d", be16_to_cpu(val) / 100, 222 val = be16_to_cpu(rval);
222 be16_to_cpu(val) % 100); 223 dev_info(dev, "probe set to K = %d.%.2d", val / 100, val % 100);
223 224
224 ret = regmap_read(data->regmap, ATLAS_REG_EC_CALIB_STATUS, &val); 225 ret = regmap_read(data->regmap, ATLAS_REG_EC_CALIB_STATUS, &val);
225 if (ret) 226 if (ret)
diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c
index 39dd2026ccc9..066161a4bccd 100644
--- a/drivers/iio/temperature/maxim_thermocouple.c
+++ b/drivers/iio/temperature/maxim_thermocouple.c
@@ -123,22 +123,24 @@ static int maxim_thermocouple_read(struct maxim_thermocouple_data *data,
123{ 123{
124 unsigned int storage_bytes = data->chip->read_size; 124 unsigned int storage_bytes = data->chip->read_size;
125 unsigned int shift = chan->scan_type.shift + (chan->address * 8); 125 unsigned int shift = chan->scan_type.shift + (chan->address * 8);
126 unsigned int buf; 126 __be16 buf16;
127 __be32 buf32;
127 int ret; 128 int ret;
128 129
129 ret = spi_read(data->spi, (void *) &buf, storage_bytes);
130 if (ret)
131 return ret;
132
133 switch (storage_bytes) { 130 switch (storage_bytes) {
134 case 2: 131 case 2:
135 *val = be16_to_cpu(buf); 132 ret = spi_read(data->spi, (void *)&buf16, storage_bytes);
133 *val = be16_to_cpu(buf16);
136 break; 134 break;
137 case 4: 135 case 4:
138 *val = be32_to_cpu(buf); 136 ret = spi_read(data->spi, (void *)&buf32, storage_bytes);
137 *val = be32_to_cpu(buf32);
139 break; 138 break;
140 } 139 }
141 140
141 if (ret)
142 return ret;
143
142 /* check to be sure this is a valid reading */ 144 /* check to be sure this is a valid reading */
143 if (*val & data->chip->status_bit) 145 if (*val & data->chip->status_bit)
144 return -EINVAL; 146 return -EINVAL;
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 22174774dbb8..63036c731626 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1019,7 +1019,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
1019 resp.qp_tab_size = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp); 1019 resp.qp_tab_size = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp);
1020 if (mlx5_core_is_pf(dev->mdev) && MLX5_CAP_GEN(dev->mdev, bf)) 1020 if (mlx5_core_is_pf(dev->mdev) && MLX5_CAP_GEN(dev->mdev, bf))
1021 resp.bf_reg_size = 1 << MLX5_CAP_GEN(dev->mdev, log_bf_reg_size); 1021 resp.bf_reg_size = 1 << MLX5_CAP_GEN(dev->mdev, log_bf_reg_size);
1022 resp.cache_line_size = L1_CACHE_BYTES; 1022 resp.cache_line_size = cache_line_size();
1023 resp.max_sq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq); 1023 resp.max_sq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq);
1024 resp.max_rq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_rq); 1024 resp.max_rq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_rq);
1025 resp.max_send_wqebb = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz); 1025 resp.max_send_wqebb = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz);
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 41f4c2afbcdd..7ce97daf26c6 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -52,7 +52,6 @@ enum {
52 52
53enum { 53enum {
54 MLX5_IB_SQ_STRIDE = 6, 54 MLX5_IB_SQ_STRIDE = 6,
55 MLX5_IB_CACHE_LINE_SIZE = 64,
56}; 55};
57 56
58static const u32 mlx5_ib_opcode[] = { 57static const u32 mlx5_ib_opcode[] = {
diff --git a/drivers/infiniband/hw/qedr/Kconfig b/drivers/infiniband/hw/qedr/Kconfig
index 7c06d85568d4..6c9f3923e838 100644
--- a/drivers/infiniband/hw/qedr/Kconfig
+++ b/drivers/infiniband/hw/qedr/Kconfig
@@ -2,6 +2,7 @@ config INFINIBAND_QEDR
2 tristate "QLogic RoCE driver" 2 tristate "QLogic RoCE driver"
3 depends on 64BIT && QEDE 3 depends on 64BIT && QEDE
4 select QED_LL2 4 select QED_LL2
5 select QED_RDMA
5 ---help--- 6 ---help---
6 This driver provides low-level InfiniBand over Ethernet 7 This driver provides low-level InfiniBand over Ethernet
7 support for QLogic QED host channel adapters (HCAs). 8 support for QLogic QED host channel adapters (HCAs).
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 7b8d2d9e2263..da12717a3eb7 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -63,6 +63,8 @@ enum ipoib_flush_level {
63 63
64enum { 64enum {
65 IPOIB_ENCAP_LEN = 4, 65 IPOIB_ENCAP_LEN = 4,
66 IPOIB_PSEUDO_LEN = 20,
67 IPOIB_HARD_LEN = IPOIB_ENCAP_LEN + IPOIB_PSEUDO_LEN,
66 68
67 IPOIB_UD_HEAD_SIZE = IB_GRH_BYTES + IPOIB_ENCAP_LEN, 69 IPOIB_UD_HEAD_SIZE = IB_GRH_BYTES + IPOIB_ENCAP_LEN,
68 IPOIB_UD_RX_SG = 2, /* max buffer needed for 4K mtu */ 70 IPOIB_UD_RX_SG = 2, /* max buffer needed for 4K mtu */
@@ -134,15 +136,21 @@ struct ipoib_header {
134 u16 reserved; 136 u16 reserved;
135}; 137};
136 138
137struct ipoib_cb { 139struct ipoib_pseudo_header {
138 struct qdisc_skb_cb qdisc_cb; 140 u8 hwaddr[INFINIBAND_ALEN];
139 u8 hwaddr[INFINIBAND_ALEN];
140}; 141};
141 142
142static inline struct ipoib_cb *ipoib_skb_cb(const struct sk_buff *skb) 143static inline void skb_add_pseudo_hdr(struct sk_buff *skb)
143{ 144{
144 BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct ipoib_cb)); 145 char *data = skb_push(skb, IPOIB_PSEUDO_LEN);
145 return (struct ipoib_cb *)skb->cb; 146
147 /*
148 * only the ipoib header is present now, make room for a dummy
149 * pseudo header and set skb field accordingly
150 */
151 memset(data, 0, IPOIB_PSEUDO_LEN);
152 skb_reset_mac_header(skb);
153 skb_pull(skb, IPOIB_HARD_LEN);
146} 154}
147 155
148/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ 156/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 4ad297d3de89..339a1eecdfe3 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -63,6 +63,8 @@ MODULE_PARM_DESC(cm_data_debug_level,
63#define IPOIB_CM_RX_DELAY (3 * 256 * HZ) 63#define IPOIB_CM_RX_DELAY (3 * 256 * HZ)
64#define IPOIB_CM_RX_UPDATE_MASK (0x3) 64#define IPOIB_CM_RX_UPDATE_MASK (0x3)
65 65
66#define IPOIB_CM_RX_RESERVE (ALIGN(IPOIB_HARD_LEN, 16) - IPOIB_ENCAP_LEN)
67
66static struct ib_qp_attr ipoib_cm_err_attr = { 68static struct ib_qp_attr ipoib_cm_err_attr = {
67 .qp_state = IB_QPS_ERR 69 .qp_state = IB_QPS_ERR
68}; 70};
@@ -146,15 +148,15 @@ static struct sk_buff *ipoib_cm_alloc_rx_skb(struct net_device *dev,
146 struct sk_buff *skb; 148 struct sk_buff *skb;
147 int i; 149 int i;
148 150
149 skb = dev_alloc_skb(IPOIB_CM_HEAD_SIZE + 12); 151 skb = dev_alloc_skb(ALIGN(IPOIB_CM_HEAD_SIZE + IPOIB_PSEUDO_LEN, 16));
150 if (unlikely(!skb)) 152 if (unlikely(!skb))
151 return NULL; 153 return NULL;
152 154
153 /* 155 /*
154 * IPoIB adds a 4 byte header. So we need 12 more bytes to align the 156 * IPoIB adds a IPOIB_ENCAP_LEN byte header, this will align the
155 * IP header to a multiple of 16. 157 * IP header to a multiple of 16.
156 */ 158 */
157 skb_reserve(skb, 12); 159 skb_reserve(skb, IPOIB_CM_RX_RESERVE);
158 160
159 mapping[0] = ib_dma_map_single(priv->ca, skb->data, IPOIB_CM_HEAD_SIZE, 161 mapping[0] = ib_dma_map_single(priv->ca, skb->data, IPOIB_CM_HEAD_SIZE,
160 DMA_FROM_DEVICE); 162 DMA_FROM_DEVICE);
@@ -624,9 +626,9 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
624 if (wc->byte_len < IPOIB_CM_COPYBREAK) { 626 if (wc->byte_len < IPOIB_CM_COPYBREAK) {
625 int dlen = wc->byte_len; 627 int dlen = wc->byte_len;
626 628
627 small_skb = dev_alloc_skb(dlen + 12); 629 small_skb = dev_alloc_skb(dlen + IPOIB_CM_RX_RESERVE);
628 if (small_skb) { 630 if (small_skb) {
629 skb_reserve(small_skb, 12); 631 skb_reserve(small_skb, IPOIB_CM_RX_RESERVE);
630 ib_dma_sync_single_for_cpu(priv->ca, rx_ring[wr_id].mapping[0], 632 ib_dma_sync_single_for_cpu(priv->ca, rx_ring[wr_id].mapping[0],
631 dlen, DMA_FROM_DEVICE); 633 dlen, DMA_FROM_DEVICE);
632 skb_copy_from_linear_data(skb, small_skb->data, dlen); 634 skb_copy_from_linear_data(skb, small_skb->data, dlen);
@@ -663,8 +665,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
663 665
664copied: 666copied:
665 skb->protocol = ((struct ipoib_header *) skb->data)->proto; 667 skb->protocol = ((struct ipoib_header *) skb->data)->proto;
666 skb_reset_mac_header(skb); 668 skb_add_pseudo_hdr(skb);
667 skb_pull(skb, IPOIB_ENCAP_LEN);
668 669
669 ++dev->stats.rx_packets; 670 ++dev->stats.rx_packets;
670 dev->stats.rx_bytes += skb->len; 671 dev->stats.rx_bytes += skb->len;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index be11d5d5b8c1..830fecb6934c 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -128,16 +128,15 @@ static struct sk_buff *ipoib_alloc_rx_skb(struct net_device *dev, int id)
128 128
129 buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu); 129 buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu);
130 130
131 skb = dev_alloc_skb(buf_size + IPOIB_ENCAP_LEN); 131 skb = dev_alloc_skb(buf_size + IPOIB_HARD_LEN);
132 if (unlikely(!skb)) 132 if (unlikely(!skb))
133 return NULL; 133 return NULL;
134 134
135 /* 135 /*
136 * IB will leave a 40 byte gap for a GRH and IPoIB adds a 4 byte 136 * the IP header will be at IPOIP_HARD_LEN + IB_GRH_BYTES, that is
137 * header. So we need 4 more bytes to get to 48 and align the 137 * 64 bytes aligned
138 * IP header to a multiple of 16.
139 */ 138 */
140 skb_reserve(skb, 4); 139 skb_reserve(skb, sizeof(struct ipoib_pseudo_header));
141 140
142 mapping = priv->rx_ring[id].mapping; 141 mapping = priv->rx_ring[id].mapping;
143 mapping[0] = ib_dma_map_single(priv->ca, skb->data, buf_size, 142 mapping[0] = ib_dma_map_single(priv->ca, skb->data, buf_size,
@@ -253,8 +252,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
253 skb_pull(skb, IB_GRH_BYTES); 252 skb_pull(skb, IB_GRH_BYTES);
254 253
255 skb->protocol = ((struct ipoib_header *) skb->data)->proto; 254 skb->protocol = ((struct ipoib_header *) skb->data)->proto;
256 skb_reset_mac_header(skb); 255 skb_add_pseudo_hdr(skb);
257 skb_pull(skb, IPOIB_ENCAP_LEN);
258 256
259 ++dev->stats.rx_packets; 257 ++dev->stats.rx_packets;
260 dev->stats.rx_bytes += skb->len; 258 dev->stats.rx_bytes += skb->len;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 5636fc3da6b8..b58d9dca5c93 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -925,9 +925,12 @@ static void neigh_add_path(struct sk_buff *skb, u8 *daddr,
925 ipoib_neigh_free(neigh); 925 ipoib_neigh_free(neigh);
926 goto err_drop; 926 goto err_drop;
927 } 927 }
928 if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) 928 if (skb_queue_len(&neigh->queue) <
929 IPOIB_MAX_PATH_REC_QUEUE) {
930 /* put pseudoheader back on for next time */
931 skb_push(skb, IPOIB_PSEUDO_LEN);
929 __skb_queue_tail(&neigh->queue, skb); 932 __skb_queue_tail(&neigh->queue, skb);
930 else { 933 } else {
931 ipoib_warn(priv, "queue length limit %d. Packet drop.\n", 934 ipoib_warn(priv, "queue length limit %d. Packet drop.\n",
932 skb_queue_len(&neigh->queue)); 935 skb_queue_len(&neigh->queue));
933 goto err_drop; 936 goto err_drop;
@@ -964,7 +967,7 @@ err_drop:
964} 967}
965 968
966static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, 969static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
967 struct ipoib_cb *cb) 970 struct ipoib_pseudo_header *phdr)
968{ 971{
969 struct ipoib_dev_priv *priv = netdev_priv(dev); 972 struct ipoib_dev_priv *priv = netdev_priv(dev);
970 struct ipoib_path *path; 973 struct ipoib_path *path;
@@ -972,16 +975,18 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
972 975
973 spin_lock_irqsave(&priv->lock, flags); 976 spin_lock_irqsave(&priv->lock, flags);
974 977
975 path = __path_find(dev, cb->hwaddr + 4); 978 path = __path_find(dev, phdr->hwaddr + 4);
976 if (!path || !path->valid) { 979 if (!path || !path->valid) {
977 int new_path = 0; 980 int new_path = 0;
978 981
979 if (!path) { 982 if (!path) {
980 path = path_rec_create(dev, cb->hwaddr + 4); 983 path = path_rec_create(dev, phdr->hwaddr + 4);
981 new_path = 1; 984 new_path = 1;
982 } 985 }
983 if (path) { 986 if (path) {
984 if (skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 987 if (skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
988 /* put pseudoheader back on for next time */
989 skb_push(skb, IPOIB_PSEUDO_LEN);
985 __skb_queue_tail(&path->queue, skb); 990 __skb_queue_tail(&path->queue, skb);
986 } else { 991 } else {
987 ++dev->stats.tx_dropped; 992 ++dev->stats.tx_dropped;
@@ -1009,10 +1014,12 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
1009 be16_to_cpu(path->pathrec.dlid)); 1014 be16_to_cpu(path->pathrec.dlid));
1010 1015
1011 spin_unlock_irqrestore(&priv->lock, flags); 1016 spin_unlock_irqrestore(&priv->lock, flags);
1012 ipoib_send(dev, skb, path->ah, IPOIB_QPN(cb->hwaddr)); 1017 ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
1013 return; 1018 return;
1014 } else if ((path->query || !path_rec_start(dev, path)) && 1019 } else if ((path->query || !path_rec_start(dev, path)) &&
1015 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 1020 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
1021 /* put pseudoheader back on for next time */
1022 skb_push(skb, IPOIB_PSEUDO_LEN);
1016 __skb_queue_tail(&path->queue, skb); 1023 __skb_queue_tail(&path->queue, skb);
1017 } else { 1024 } else {
1018 ++dev->stats.tx_dropped; 1025 ++dev->stats.tx_dropped;
@@ -1026,13 +1033,15 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
1026{ 1033{
1027 struct ipoib_dev_priv *priv = netdev_priv(dev); 1034 struct ipoib_dev_priv *priv = netdev_priv(dev);
1028 struct ipoib_neigh *neigh; 1035 struct ipoib_neigh *neigh;
1029 struct ipoib_cb *cb = ipoib_skb_cb(skb); 1036 struct ipoib_pseudo_header *phdr;
1030 struct ipoib_header *header; 1037 struct ipoib_header *header;
1031 unsigned long flags; 1038 unsigned long flags;
1032 1039
1040 phdr = (struct ipoib_pseudo_header *) skb->data;
1041 skb_pull(skb, sizeof(*phdr));
1033 header = (struct ipoib_header *) skb->data; 1042 header = (struct ipoib_header *) skb->data;
1034 1043
1035 if (unlikely(cb->hwaddr[4] == 0xff)) { 1044 if (unlikely(phdr->hwaddr[4] == 0xff)) {
1036 /* multicast, arrange "if" according to probability */ 1045 /* multicast, arrange "if" according to probability */
1037 if ((header->proto != htons(ETH_P_IP)) && 1046 if ((header->proto != htons(ETH_P_IP)) &&
1038 (header->proto != htons(ETH_P_IPV6)) && 1047 (header->proto != htons(ETH_P_IPV6)) &&
@@ -1045,13 +1054,13 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
1045 return NETDEV_TX_OK; 1054 return NETDEV_TX_OK;
1046 } 1055 }
1047 /* Add in the P_Key for multicast*/ 1056 /* Add in the P_Key for multicast*/
1048 cb->hwaddr[8] = (priv->pkey >> 8) & 0xff; 1057 phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff;
1049 cb->hwaddr[9] = priv->pkey & 0xff; 1058 phdr->hwaddr[9] = priv->pkey & 0xff;
1050 1059
1051 neigh = ipoib_neigh_get(dev, cb->hwaddr); 1060 neigh = ipoib_neigh_get(dev, phdr->hwaddr);
1052 if (likely(neigh)) 1061 if (likely(neigh))
1053 goto send_using_neigh; 1062 goto send_using_neigh;
1054 ipoib_mcast_send(dev, cb->hwaddr, skb); 1063 ipoib_mcast_send(dev, phdr->hwaddr, skb);
1055 return NETDEV_TX_OK; 1064 return NETDEV_TX_OK;
1056 } 1065 }
1057 1066
@@ -1060,16 +1069,16 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
1060 case htons(ETH_P_IP): 1069 case htons(ETH_P_IP):
1061 case htons(ETH_P_IPV6): 1070 case htons(ETH_P_IPV6):
1062 case htons(ETH_P_TIPC): 1071 case htons(ETH_P_TIPC):
1063 neigh = ipoib_neigh_get(dev, cb->hwaddr); 1072 neigh = ipoib_neigh_get(dev, phdr->hwaddr);
1064 if (unlikely(!neigh)) { 1073 if (unlikely(!neigh)) {
1065 neigh_add_path(skb, cb->hwaddr, dev); 1074 neigh_add_path(skb, phdr->hwaddr, dev);
1066 return NETDEV_TX_OK; 1075 return NETDEV_TX_OK;
1067 } 1076 }
1068 break; 1077 break;
1069 case htons(ETH_P_ARP): 1078 case htons(ETH_P_ARP):
1070 case htons(ETH_P_RARP): 1079 case htons(ETH_P_RARP):
1071 /* for unicast ARP and RARP should always perform path find */ 1080 /* for unicast ARP and RARP should always perform path find */
1072 unicast_arp_send(skb, dev, cb); 1081 unicast_arp_send(skb, dev, phdr);
1073 return NETDEV_TX_OK; 1082 return NETDEV_TX_OK;
1074 default: 1083 default:
1075 /* ethertype not supported by IPoIB */ 1084 /* ethertype not supported by IPoIB */
@@ -1086,11 +1095,13 @@ send_using_neigh:
1086 goto unref; 1095 goto unref;
1087 } 1096 }
1088 } else if (neigh->ah) { 1097 } else if (neigh->ah) {
1089 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(cb->hwaddr)); 1098 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(phdr->hwaddr));
1090 goto unref; 1099 goto unref;
1091 } 1100 }
1092 1101
1093 if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 1102 if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
1103 /* put pseudoheader back on for next time */
1104 skb_push(skb, sizeof(*phdr));
1094 spin_lock_irqsave(&priv->lock, flags); 1105 spin_lock_irqsave(&priv->lock, flags);
1095 __skb_queue_tail(&neigh->queue, skb); 1106 __skb_queue_tail(&neigh->queue, skb);
1096 spin_unlock_irqrestore(&priv->lock, flags); 1107 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1122,8 +1133,8 @@ static int ipoib_hard_header(struct sk_buff *skb,
1122 unsigned short type, 1133 unsigned short type,
1123 const void *daddr, const void *saddr, unsigned len) 1134 const void *daddr, const void *saddr, unsigned len)
1124{ 1135{
1136 struct ipoib_pseudo_header *phdr;
1125 struct ipoib_header *header; 1137 struct ipoib_header *header;
1126 struct ipoib_cb *cb = ipoib_skb_cb(skb);
1127 1138
1128 header = (struct ipoib_header *) skb_push(skb, sizeof *header); 1139 header = (struct ipoib_header *) skb_push(skb, sizeof *header);
1129 1140
@@ -1132,12 +1143,13 @@ static int ipoib_hard_header(struct sk_buff *skb,
1132 1143
1133 /* 1144 /*
1134 * we don't rely on dst_entry structure, always stuff the 1145 * we don't rely on dst_entry structure, always stuff the
1135 * destination address into skb->cb so we can figure out where 1146 * destination address into skb hard header so we can figure out where
1136 * to send the packet later. 1147 * to send the packet later.
1137 */ 1148 */
1138 memcpy(cb->hwaddr, daddr, INFINIBAND_ALEN); 1149 phdr = (struct ipoib_pseudo_header *) skb_push(skb, sizeof(*phdr));
1150 memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN);
1139 1151
1140 return sizeof *header; 1152 return IPOIB_HARD_LEN;
1141} 1153}
1142 1154
1143static void ipoib_set_mcast_list(struct net_device *dev) 1155static void ipoib_set_mcast_list(struct net_device *dev)
@@ -1759,7 +1771,7 @@ void ipoib_setup(struct net_device *dev)
1759 1771
1760 dev->flags |= IFF_BROADCAST | IFF_MULTICAST; 1772 dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
1761 1773
1762 dev->hard_header_len = IPOIB_ENCAP_LEN; 1774 dev->hard_header_len = IPOIB_HARD_LEN;
1763 dev->addr_len = INFINIBAND_ALEN; 1775 dev->addr_len = INFINIBAND_ALEN;
1764 dev->type = ARPHRD_INFINIBAND; 1776 dev->type = ARPHRD_INFINIBAND;
1765 dev->tx_queue_len = ipoib_sendq_size * 2; 1777 dev->tx_queue_len = ipoib_sendq_size * 2;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d3394b6add24..1909dd252c94 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -796,9 +796,11 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)
796 __ipoib_mcast_add(dev, mcast); 796 __ipoib_mcast_add(dev, mcast);
797 list_add_tail(&mcast->list, &priv->multicast_list); 797 list_add_tail(&mcast->list, &priv->multicast_list);
798 } 798 }
799 if (skb_queue_len(&mcast->pkt_queue) < IPOIB_MAX_MCAST_QUEUE) 799 if (skb_queue_len(&mcast->pkt_queue) < IPOIB_MAX_MCAST_QUEUE) {
800 /* put pseudoheader back on for next time */
801 skb_push(skb, sizeof(struct ipoib_pseudo_header));
800 skb_queue_tail(&mcast->pkt_queue, skb); 802 skb_queue_tail(&mcast->pkt_queue, skb);
801 else { 803 } else {
802 ++dev->stats.tx_dropped; 804 ++dev->stats.tx_dropped;
803 dev_kfree_skb_any(skb); 805 dev_kfree_skb_any(skb);
804 } 806 }
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c
index c0e7b624ce54..12102448fddd 100644
--- a/drivers/ipack/ipack.c
+++ b/drivers/ipack/ipack.c
@@ -178,7 +178,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
178 idev->id_vendor, idev->id_device); 178 idev->id_vendor, idev->id_device);
179} 179}
180 180
181ipack_device_attr(id_format, "0x%hhu\n"); 181ipack_device_attr(id_format, "0x%hhx\n");
182 182
183static DEVICE_ATTR_RO(id); 183static DEVICE_ATTR_RO(id);
184static DEVICE_ATTR_RO(id_device); 184static DEVICE_ATTR_RO(id_device);
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 82b0b5daf3f5..bc0af3307bbf 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -158,8 +158,8 @@ config PIC32_EVIC
158 select IRQ_DOMAIN 158 select IRQ_DOMAIN
159 159
160config JCORE_AIC 160config JCORE_AIC
161 bool "J-Core integrated AIC" 161 bool "J-Core integrated AIC" if COMPILE_TEST
162 depends on OF && (SUPERH || COMPILE_TEST) 162 depends on OF
163 select IRQ_DOMAIN 163 select IRQ_DOMAIN
164 help 164 help
165 Support for the J-Core integrated AIC. 165 Support for the J-Core integrated AIC.
diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c
index ebc2b0b15f67..2a7a38830a8d 100644
--- a/drivers/irqchip/irq-eznps.c
+++ b/drivers/irqchip/irq-eznps.c
@@ -135,7 +135,7 @@ static const struct irq_domain_ops nps400_irq_ops = {
135static int __init nps400_of_init(struct device_node *node, 135static int __init nps400_of_init(struct device_node *node,
136 struct device_node *parent) 136 struct device_node *parent)
137{ 137{
138 static struct irq_domain *nps400_root_domain; 138 struct irq_domain *nps400_root_domain;
139 139
140 if (parent) { 140 if (parent) {
141 pr_err("DeviceTree incore ic not a root irq controller\n"); 141 pr_err("DeviceTree incore ic not a root irq controller\n");
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 003495d91f9c..c5dee300e8a3 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -1023,7 +1023,7 @@ static void its_free_tables(struct its_node *its)
1023 1023
1024static int its_alloc_tables(struct its_node *its) 1024static int its_alloc_tables(struct its_node *its)
1025{ 1025{
1026 u64 typer = readq_relaxed(its->base + GITS_TYPER); 1026 u64 typer = gic_read_typer(its->base + GITS_TYPER);
1027 u32 ids = GITS_TYPER_DEVBITS(typer); 1027 u32 ids = GITS_TYPER_DEVBITS(typer);
1028 u64 shr = GITS_BASER_InnerShareable; 1028 u64 shr = GITS_BASER_InnerShareable;
1029 u64 cache = GITS_BASER_WaWb; 1029 u64 cache = GITS_BASER_WaWb;
@@ -1198,7 +1198,7 @@ static void its_cpu_init_collection(void)
1198 * We now have to bind each collection to its target 1198 * We now have to bind each collection to its target
1199 * redistributor. 1199 * redistributor.
1200 */ 1200 */
1201 if (readq_relaxed(its->base + GITS_TYPER) & GITS_TYPER_PTA) { 1201 if (gic_read_typer(its->base + GITS_TYPER) & GITS_TYPER_PTA) {
1202 /* 1202 /*
1203 * This ITS wants the physical address of the 1203 * This ITS wants the physical address of the
1204 * redistributor. 1204 * redistributor.
@@ -1208,7 +1208,7 @@ static void its_cpu_init_collection(void)
1208 /* 1208 /*
1209 * This ITS wants a linear CPU number. 1209 * This ITS wants a linear CPU number.
1210 */ 1210 */
1211 target = readq_relaxed(gic_data_rdist_rd_base() + GICR_TYPER); 1211 target = gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER);
1212 target = GICR_TYPER_CPU_NUMBER(target) << 16; 1212 target = GICR_TYPER_CPU_NUMBER(target) << 16;
1213 } 1213 }
1214 1214
@@ -1691,7 +1691,7 @@ static int __init its_probe_one(struct resource *res,
1691 INIT_LIST_HEAD(&its->its_device_list); 1691 INIT_LIST_HEAD(&its->its_device_list);
1692 its->base = its_base; 1692 its->base = its_base;
1693 its->phys_base = res->start; 1693 its->phys_base = res->start;
1694 its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1; 1694 its->ite_size = ((gic_read_typer(its_base + GITS_TYPER) >> 4) & 0xf) + 1;
1695 its->numa_node = numa_node; 1695 its->numa_node = numa_node;
1696 1696
1697 its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL); 1697 its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL);
@@ -1763,7 +1763,7 @@ out_unmap:
1763 1763
1764static bool gic_rdists_supports_plpis(void) 1764static bool gic_rdists_supports_plpis(void)
1765{ 1765{
1766 return !!(readl_relaxed(gic_data_rdist_rd_base() + GICR_TYPER) & GICR_TYPER_PLPIS); 1766 return !!(gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER) & GICR_TYPER_PLPIS);
1767} 1767}
1768 1768
1769int its_cpu_init(void) 1769int its_cpu_init(void)
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 58e5b4e87056..d6c404b3584d 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -1279,7 +1279,7 @@ static bool gic_check_eoimode(struct device_node *node, void __iomem **base)
1279 */ 1279 */
1280 *base += 0xf000; 1280 *base += 0xf000;
1281 cpuif_res.start += 0xf000; 1281 cpuif_res.start += 0xf000;
1282 pr_warn("GIC: Adjusting CPU interface base to %pa", 1282 pr_warn("GIC: Adjusting CPU interface base to %pa\n",
1283 &cpuif_res.start); 1283 &cpuif_res.start);
1284 } 1284 }
1285 1285
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 8abde6b8cedc..6d53810963f7 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -266,7 +266,7 @@ static struct raid_type {
266 {"raid10_offset", "raid10 offset (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_OFFSET}, 266 {"raid10_offset", "raid10 offset (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_OFFSET},
267 {"raid10_near", "raid10 near (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_NEAR}, 267 {"raid10_near", "raid10 near (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_NEAR},
268 {"raid10", "raid10 (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_DEFAULT}, 268 {"raid10", "raid10 (striped mirrors)", 0, 2, 10, ALGORITHM_RAID10_DEFAULT},
269 {"raid4", "raid4 (dedicated last parity disk)", 1, 2, 4, ALGORITHM_PARITY_N}, /* raid4 layout = raid5_n */ 269 {"raid4", "raid4 (dedicated first parity disk)", 1, 2, 5, ALGORITHM_PARITY_0}, /* raid4 layout = raid5_0 */
270 {"raid5_n", "raid5 (dedicated last parity disk)", 1, 2, 5, ALGORITHM_PARITY_N}, 270 {"raid5_n", "raid5 (dedicated last parity disk)", 1, 2, 5, ALGORITHM_PARITY_N},
271 {"raid5_ls", "raid5 (left symmetric)", 1, 2, 5, ALGORITHM_LEFT_SYMMETRIC}, 271 {"raid5_ls", "raid5 (left symmetric)", 1, 2, 5, ALGORITHM_LEFT_SYMMETRIC},
272 {"raid5_rs", "raid5 (right symmetric)", 1, 2, 5, ALGORITHM_RIGHT_SYMMETRIC}, 272 {"raid5_rs", "raid5 (right symmetric)", 1, 2, 5, ALGORITHM_RIGHT_SYMMETRIC},
@@ -2087,11 +2087,11 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
2087 /* 2087 /*
2088 * No takeover/reshaping, because we don't have the extended v1.9.0 metadata 2088 * No takeover/reshaping, because we don't have the extended v1.9.0 metadata
2089 */ 2089 */
2090 if (le32_to_cpu(sb->level) != mddev->level) { 2090 if (le32_to_cpu(sb->level) != mddev->new_level) {
2091 DMERR("Reshaping/takeover raid sets not yet supported. (raid level/stripes/size change)"); 2091 DMERR("Reshaping/takeover raid sets not yet supported. (raid level/stripes/size change)");
2092 return -EINVAL; 2092 return -EINVAL;
2093 } 2093 }
2094 if (le32_to_cpu(sb->layout) != mddev->layout) { 2094 if (le32_to_cpu(sb->layout) != mddev->new_layout) {
2095 DMERR("Reshaping raid sets not yet supported. (raid layout change)"); 2095 DMERR("Reshaping raid sets not yet supported. (raid layout change)");
2096 DMERR(" 0x%X vs 0x%X", le32_to_cpu(sb->layout), mddev->layout); 2096 DMERR(" 0x%X vs 0x%X", le32_to_cpu(sb->layout), mddev->layout);
2097 DMERR(" Old layout: %s w/ %d copies", 2097 DMERR(" Old layout: %s w/ %d copies",
@@ -2102,7 +2102,7 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
2102 raid10_md_layout_to_copies(mddev->layout)); 2102 raid10_md_layout_to_copies(mddev->layout));
2103 return -EINVAL; 2103 return -EINVAL;
2104 } 2104 }
2105 if (le32_to_cpu(sb->stripe_sectors) != mddev->chunk_sectors) { 2105 if (le32_to_cpu(sb->stripe_sectors) != mddev->new_chunk_sectors) {
2106 DMERR("Reshaping raid sets not yet supported. (stripe sectors change)"); 2106 DMERR("Reshaping raid sets not yet supported. (stripe sectors change)");
2107 return -EINVAL; 2107 return -EINVAL;
2108 } 2108 }
@@ -2115,6 +2115,8 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
2115 return -EINVAL; 2115 return -EINVAL;
2116 } 2116 }
2117 2117
2118 DMINFO("Discovered old metadata format; upgrading to extended metadata format");
2119
2118 /* Table line is checked vs. authoritative superblock */ 2120 /* Table line is checked vs. authoritative superblock */
2119 rs_set_new(rs); 2121 rs_set_new(rs);
2120 } 2122 }
@@ -2258,7 +2260,8 @@ static int super_validate(struct raid_set *rs, struct md_rdev *rdev)
2258 if (!mddev->events && super_init_validation(rs, rdev)) 2260 if (!mddev->events && super_init_validation(rs, rdev))
2259 return -EINVAL; 2261 return -EINVAL;
2260 2262
2261 if (le32_to_cpu(sb->compat_features) != FEATURE_FLAG_SUPPORTS_V190) { 2263 if (le32_to_cpu(sb->compat_features) &&
2264 le32_to_cpu(sb->compat_features) != FEATURE_FLAG_SUPPORTS_V190) {
2262 rs->ti->error = "Unable to assemble array: Unknown flag(s) in compatible feature flags"; 2265 rs->ti->error = "Unable to assemble array: Unknown flag(s) in compatible feature flags";
2263 return -EINVAL; 2266 return -EINVAL;
2264 } 2267 }
@@ -3646,7 +3649,7 @@ static void raid_resume(struct dm_target *ti)
3646 3649
3647static struct target_type raid_target = { 3650static struct target_type raid_target = {
3648 .name = "raid", 3651 .name = "raid",
3649 .version = {1, 9, 0}, 3652 .version = {1, 9, 1},
3650 .module = THIS_MODULE, 3653 .module = THIS_MODULE,
3651 .ctr = raid_ctr, 3654 .ctr = raid_ctr,
3652 .dtr = raid_dtr, 3655 .dtr = raid_dtr,
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index bdf1606f67bc..9a8b71067c6e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -145,7 +145,6 @@ static void dispatch_bios(void *context, struct bio_list *bio_list)
145 145
146struct dm_raid1_bio_record { 146struct dm_raid1_bio_record {
147 struct mirror *m; 147 struct mirror *m;
148 /* if details->bi_bdev == NULL, details were not saved */
149 struct dm_bio_details details; 148 struct dm_bio_details details;
150 region_t write_region; 149 region_t write_region;
151}; 150};
@@ -1200,8 +1199,6 @@ static int mirror_map(struct dm_target *ti, struct bio *bio)
1200 struct dm_raid1_bio_record *bio_record = 1199 struct dm_raid1_bio_record *bio_record =
1201 dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record)); 1200 dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
1202 1201
1203 bio_record->details.bi_bdev = NULL;
1204
1205 if (rw == WRITE) { 1202 if (rw == WRITE) {
1206 /* Save region for mirror_end_io() handler */ 1203 /* Save region for mirror_end_io() handler */
1207 bio_record->write_region = dm_rh_bio_to_region(ms->rh, bio); 1204 bio_record->write_region = dm_rh_bio_to_region(ms->rh, bio);
@@ -1260,22 +1257,12 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
1260 } 1257 }
1261 1258
1262 if (error == -EOPNOTSUPP) 1259 if (error == -EOPNOTSUPP)
1263 goto out; 1260 return error;
1264 1261
1265 if ((error == -EWOULDBLOCK) && (bio->bi_opf & REQ_RAHEAD)) 1262 if ((error == -EWOULDBLOCK) && (bio->bi_opf & REQ_RAHEAD))
1266 goto out; 1263 return error;
1267 1264
1268 if (unlikely(error)) { 1265 if (unlikely(error)) {
1269 if (!bio_record->details.bi_bdev) {
1270 /*
1271 * There wasn't enough memory to record necessary
1272 * information for a retry or there was no other
1273 * mirror in-sync.
1274 */
1275 DMERR_LIMIT("Mirror read failed.");
1276 return -EIO;
1277 }
1278
1279 m = bio_record->m; 1266 m = bio_record->m;
1280 1267
1281 DMERR("Mirror read failed from %s. Trying alternative device.", 1268 DMERR("Mirror read failed from %s. Trying alternative device.",
@@ -1291,7 +1278,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
1291 bd = &bio_record->details; 1278 bd = &bio_record->details;
1292 1279
1293 dm_bio_restore(bd, bio); 1280 dm_bio_restore(bd, bio);
1294 bio_record->details.bi_bdev = NULL; 1281 bio->bi_error = 0;
1295 1282
1296 queue_bio(ms, bio, rw); 1283 queue_bio(ms, bio, rw);
1297 return DM_ENDIO_INCOMPLETE; 1284 return DM_ENDIO_INCOMPLETE;
@@ -1299,9 +1286,6 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
1299 DMERR("All replicated volumes dead, failing I/O"); 1286 DMERR("All replicated volumes dead, failing I/O");
1300 } 1287 }
1301 1288
1302out:
1303 bio_record->details.bi_bdev = NULL;
1304
1305 return error; 1289 return error;
1306} 1290}
1307 1291
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index dc75bea0d541..1d0d2adc050a 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -856,8 +856,11 @@ int dm_old_init_request_queue(struct mapped_device *md)
856 kthread_init_worker(&md->kworker); 856 kthread_init_worker(&md->kworker);
857 md->kworker_task = kthread_run(kthread_worker_fn, &md->kworker, 857 md->kworker_task = kthread_run(kthread_worker_fn, &md->kworker,
858 "kdmwork-%s", dm_device_name(md)); 858 "kdmwork-%s", dm_device_name(md));
859 if (IS_ERR(md->kworker_task)) 859 if (IS_ERR(md->kworker_task)) {
860 return PTR_ERR(md->kworker_task); 860 int error = PTR_ERR(md->kworker_task);
861 md->kworker_task = NULL;
862 return error;
863 }
861 864
862 elv_register_queue(md->queue); 865 elv_register_queue(md->queue);
863 866
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 3e407a9cde1f..c4b53b332607 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -695,37 +695,32 @@ int dm_table_add_target(struct dm_table *t, const char *type,
695 695
696 tgt->type = dm_get_target_type(type); 696 tgt->type = dm_get_target_type(type);
697 if (!tgt->type) { 697 if (!tgt->type) {
698 DMERR("%s: %s: unknown target type", dm_device_name(t->md), 698 DMERR("%s: %s: unknown target type", dm_device_name(t->md), type);
699 type);
700 return -EINVAL; 699 return -EINVAL;
701 } 700 }
702 701
703 if (dm_target_needs_singleton(tgt->type)) { 702 if (dm_target_needs_singleton(tgt->type)) {
704 if (t->num_targets) { 703 if (t->num_targets) {
705 DMERR("%s: target type %s must appear alone in table", 704 tgt->error = "singleton target type must appear alone in table";
706 dm_device_name(t->md), type); 705 goto bad;
707 return -EINVAL;
708 } 706 }
709 t->singleton = true; 707 t->singleton = true;
710 } 708 }
711 709
712 if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) { 710 if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) {
713 DMERR("%s: target type %s may not be included in read-only tables", 711 tgt->error = "target type may not be included in a read-only table";
714 dm_device_name(t->md), type); 712 goto bad;
715 return -EINVAL;
716 } 713 }
717 714
718 if (t->immutable_target_type) { 715 if (t->immutable_target_type) {
719 if (t->immutable_target_type != tgt->type) { 716 if (t->immutable_target_type != tgt->type) {
720 DMERR("%s: immutable target type %s cannot be mixed with other target types", 717 tgt->error = "immutable target type cannot be mixed with other target types";
721 dm_device_name(t->md), t->immutable_target_type->name); 718 goto bad;
722 return -EINVAL;
723 } 719 }
724 } else if (dm_target_is_immutable(tgt->type)) { 720 } else if (dm_target_is_immutable(tgt->type)) {
725 if (t->num_targets) { 721 if (t->num_targets) {
726 DMERR("%s: immutable target type %s cannot be mixed with other target types", 722 tgt->error = "immutable target type cannot be mixed with other target types";
727 dm_device_name(t->md), tgt->type->name); 723 goto bad;
728 return -EINVAL;
729 } 724 }
730 t->immutable_target_type = tgt->type; 725 t->immutable_target_type = tgt->type;
731 } 726 }
@@ -740,7 +735,6 @@ int dm_table_add_target(struct dm_table *t, const char *type,
740 */ 735 */
741 if (!adjoin(t, tgt)) { 736 if (!adjoin(t, tgt)) {
742 tgt->error = "Gap in table"; 737 tgt->error = "Gap in table";
743 r = -EINVAL;
744 goto bad; 738 goto bad;
745 } 739 }
746 740
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 147af9536d0c..ef7bf1dd6900 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1423,8 +1423,6 @@ static void cleanup_mapped_device(struct mapped_device *md)
1423 if (md->bs) 1423 if (md->bs)
1424 bioset_free(md->bs); 1424 bioset_free(md->bs);
1425 1425
1426 cleanup_srcu_struct(&md->io_barrier);
1427
1428 if (md->disk) { 1426 if (md->disk) {
1429 spin_lock(&_minor_lock); 1427 spin_lock(&_minor_lock);
1430 md->disk->private_data = NULL; 1428 md->disk->private_data = NULL;
@@ -1436,6 +1434,8 @@ static void cleanup_mapped_device(struct mapped_device *md)
1436 if (md->queue) 1434 if (md->queue)
1437 blk_cleanup_queue(md->queue); 1435 blk_cleanup_queue(md->queue);
1438 1436
1437 cleanup_srcu_struct(&md->io_barrier);
1438
1439 if (md->bdev) { 1439 if (md->bdev) {
1440 bdput(md->bdev); 1440 bdput(md->bdev);
1441 md->bdev = NULL; 1441 md->bdev = NULL;
diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index d34bc3530385..2e3cf012ef48 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -524,6 +524,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work)
524 int rc; 524 int rc;
525 525
526 if (!host->req) { 526 if (!host->req) {
527 pm_runtime_get_sync(ms_dev(host));
527 do { 528 do {
528 rc = memstick_next_req(msh, &host->req); 529 rc = memstick_next_req(msh, &host->req);
529 dev_dbg(ms_dev(host), "next req %d\n", rc); 530 dev_dbg(ms_dev(host), "next req %d\n", rc);
@@ -544,6 +545,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work)
544 host->req->error); 545 host->req->error);
545 } 546 }
546 } while (!rc); 547 } while (!rc);
548 pm_runtime_put(ms_dev(host));
547 } 549 }
548 550
549} 551}
@@ -570,6 +572,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh,
570 dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n", 572 dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n",
571 __func__, param, value); 573 __func__, param, value);
572 574
575 pm_runtime_get_sync(ms_dev(host));
573 mutex_lock(&ucr->dev_mutex); 576 mutex_lock(&ucr->dev_mutex);
574 577
575 err = rtsx_usb_card_exclusive_check(ucr, RTSX_USB_MS_CARD); 578 err = rtsx_usb_card_exclusive_check(ucr, RTSX_USB_MS_CARD);
@@ -635,6 +638,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh,
635 } 638 }
636out: 639out:
637 mutex_unlock(&ucr->dev_mutex); 640 mutex_unlock(&ucr->dev_mutex);
641 pm_runtime_put(ms_dev(host));
638 642
639 /* power-on delay */ 643 /* power-on delay */
640 if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) 644 if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON)
@@ -681,6 +685,7 @@ static int rtsx_usb_detect_ms_card(void *__host)
681 int err; 685 int err;
682 686
683 for (;;) { 687 for (;;) {
688 pm_runtime_get_sync(ms_dev(host));
684 mutex_lock(&ucr->dev_mutex); 689 mutex_lock(&ucr->dev_mutex);
685 690
686 /* Check pending MS card changes */ 691 /* Check pending MS card changes */
@@ -703,6 +708,7 @@ static int rtsx_usb_detect_ms_card(void *__host)
703 } 708 }
704 709
705poll_again: 710poll_again:
711 pm_runtime_put(ms_dev(host));
706 if (host->eject) 712 if (host->eject)
707 break; 713 break;
708 714
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index f3d34b941f85..2e5233b60971 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -229,6 +229,14 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
229 if (ctx->status == STARTED) 229 if (ctx->status == STARTED)
230 goto out; /* already started */ 230 goto out; /* already started */
231 231
232 /*
233 * Increment the mapped context count for adapter. This also checks
234 * if adapter_context_lock is taken.
235 */
236 rc = cxl_adapter_context_get(ctx->afu->adapter);
237 if (rc)
238 goto out;
239
232 if (task) { 240 if (task) {
233 ctx->pid = get_task_pid(task, PIDTYPE_PID); 241 ctx->pid = get_task_pid(task, PIDTYPE_PID);
234 ctx->glpid = get_task_pid(task->group_leader, PIDTYPE_PID); 242 ctx->glpid = get_task_pid(task->group_leader, PIDTYPE_PID);
@@ -239,7 +247,10 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
239 cxl_ctx_get(); 247 cxl_ctx_get();
240 248
241 if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { 249 if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {
250 put_pid(ctx->glpid);
242 put_pid(ctx->pid); 251 put_pid(ctx->pid);
252 ctx->glpid = ctx->pid = NULL;
253 cxl_adapter_context_put(ctx->afu->adapter);
243 cxl_ctx_put(); 254 cxl_ctx_put();
244 goto out; 255 goto out;
245 } 256 }
diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index c466ee2b0c97..5e506c19108a 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -238,6 +238,9 @@ int __detach_context(struct cxl_context *ctx)
238 put_pid(ctx->glpid); 238 put_pid(ctx->glpid);
239 239
240 cxl_ctx_put(); 240 cxl_ctx_put();
241
242 /* Decrease the attached context count on the adapter */
243 cxl_adapter_context_put(ctx->afu->adapter);
241 return 0; 244 return 0;
242} 245}
243 246
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 01d372aba131..a144073593fa 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -618,6 +618,14 @@ struct cxl {
618 bool perst_select_user; 618 bool perst_select_user;
619 bool perst_same_image; 619 bool perst_same_image;
620 bool psl_timebase_synced; 620 bool psl_timebase_synced;
621
622 /*
623 * number of contexts mapped on to this card. Possible values are:
624 * >0: Number of contexts mapped and new one can be mapped.
625 * 0: No active contexts and new ones can be mapped.
626 * -1: No contexts mapped and new ones cannot be mapped.
627 */
628 atomic_t contexts_num;
621}; 629};
622 630
623int cxl_pci_alloc_one_irq(struct cxl *adapter); 631int cxl_pci_alloc_one_irq(struct cxl *adapter);
@@ -944,4 +952,20 @@ bool cxl_pci_is_vphb_device(struct pci_dev *dev);
944 952
945/* decode AFU error bits in the PSL register PSL_SERR_An */ 953/* decode AFU error bits in the PSL register PSL_SERR_An */
946void cxl_afu_decode_psl_serr(struct cxl_afu *afu, u64 serr); 954void cxl_afu_decode_psl_serr(struct cxl_afu *afu, u64 serr);
955
956/*
957 * Increments the number of attached contexts on an adapter.
958 * In case an adapter_context_lock is taken the return -EBUSY.
959 */
960int cxl_adapter_context_get(struct cxl *adapter);
961
962/* Decrements the number of attached contexts on an adapter */
963void cxl_adapter_context_put(struct cxl *adapter);
964
965/* If no active contexts then prevents contexts from being attached */
966int cxl_adapter_context_lock(struct cxl *adapter);
967
968/* Unlock the contexts-lock if taken. Warn and force unlock otherwise */
969void cxl_adapter_context_unlock(struct cxl *adapter);
970
947#endif 971#endif
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index 5fb9894b157f..77080cc5fa0a 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -194,6 +194,16 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
194 ctx->mmio_err_ff = !!(work.flags & CXL_START_WORK_ERR_FF); 194 ctx->mmio_err_ff = !!(work.flags & CXL_START_WORK_ERR_FF);
195 195
196 /* 196 /*
197 * Increment the mapped context count for adapter. This also checks
198 * if adapter_context_lock is taken.
199 */
200 rc = cxl_adapter_context_get(ctx->afu->adapter);
201 if (rc) {
202 afu_release_irqs(ctx, ctx);
203 goto out;
204 }
205
206 /*
197 * We grab the PID here and not in the file open to allow for the case 207 * We grab the PID here and not in the file open to allow for the case
198 * where a process (master, some daemon, etc) has opened the chardev on 208 * where a process (master, some daemon, etc) has opened the chardev on
199 * behalf of another process, so the AFU's mm gets bound to the process 209 * behalf of another process, so the AFU's mm gets bound to the process
@@ -205,11 +215,16 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
205 ctx->pid = get_task_pid(current, PIDTYPE_PID); 215 ctx->pid = get_task_pid(current, PIDTYPE_PID);
206 ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); 216 ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID);
207 217
218
208 trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); 219 trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);
209 220
210 if ((rc = cxl_ops->attach_process(ctx, false, work.work_element_descriptor, 221 if ((rc = cxl_ops->attach_process(ctx, false, work.work_element_descriptor,
211 amr))) { 222 amr))) {
212 afu_release_irqs(ctx, ctx); 223 afu_release_irqs(ctx, ctx);
224 cxl_adapter_context_put(ctx->afu->adapter);
225 put_pid(ctx->glpid);
226 put_pid(ctx->pid);
227 ctx->glpid = ctx->pid = NULL;
213 goto out; 228 goto out;
214 } 229 }
215 230
diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
index 9aa58a77a24d..3e102cd6ed91 100644
--- a/drivers/misc/cxl/guest.c
+++ b/drivers/misc/cxl/guest.c
@@ -1152,6 +1152,9 @@ struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_devic
1152 if ((rc = cxl_sysfs_adapter_add(adapter))) 1152 if ((rc = cxl_sysfs_adapter_add(adapter)))
1153 goto err_put1; 1153 goto err_put1;
1154 1154
1155 /* release the context lock as the adapter is configured */
1156 cxl_adapter_context_unlock(adapter);
1157
1155 return adapter; 1158 return adapter;
1156 1159
1157err_put1: 1160err_put1:
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index d9be23b24aa3..62e0dfb5f15b 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -243,8 +243,10 @@ struct cxl *cxl_alloc_adapter(void)
243 if (dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)) 243 if (dev_set_name(&adapter->dev, "card%i", adapter->adapter_num))
244 goto err2; 244 goto err2;
245 245
246 return adapter; 246 /* start with context lock taken */
247 atomic_set(&adapter->contexts_num, -1);
247 248
249 return adapter;
248err2: 250err2:
249 cxl_remove_adapter_nr(adapter); 251 cxl_remove_adapter_nr(adapter);
250err1: 252err1:
@@ -286,6 +288,44 @@ int cxl_afu_select_best_mode(struct cxl_afu *afu)
286 return 0; 288 return 0;
287} 289}
288 290
291int cxl_adapter_context_get(struct cxl *adapter)
292{
293 int rc;
294
295 rc = atomic_inc_unless_negative(&adapter->contexts_num);
296 return rc >= 0 ? 0 : -EBUSY;
297}
298
299void cxl_adapter_context_put(struct cxl *adapter)
300{
301 atomic_dec_if_positive(&adapter->contexts_num);
302}
303
304int cxl_adapter_context_lock(struct cxl *adapter)
305{
306 int rc;
307 /* no active contexts -> contexts_num == 0 */
308 rc = atomic_cmpxchg(&adapter->contexts_num, 0, -1);
309 return rc ? -EBUSY : 0;
310}
311
312void cxl_adapter_context_unlock(struct cxl *adapter)
313{
314 int val = atomic_cmpxchg(&adapter->contexts_num, -1, 0);
315
316 /*
317 * contexts lock taken -> contexts_num == -1
318 * If not true then show a warning and force reset the lock.
319 * This will happen when context_unlock was requested without
320 * doing a context_lock.
321 */
322 if (val != -1) {
323 atomic_set(&adapter->contexts_num, 0);
324 WARN(1, "Adapter context unlocked with %d active contexts",
325 val);
326 }
327}
328
289static int __init init_cxl(void) 329static int __init init_cxl(void)
290{ 330{
291 int rc = 0; 331 int rc = 0;
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 7afad8477ad5..e96be9ca4e60 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1487,6 +1487,8 @@ static int cxl_configure_adapter(struct cxl *adapter, struct pci_dev *dev)
1487 if ((rc = cxl_native_register_psl_err_irq(adapter))) 1487 if ((rc = cxl_native_register_psl_err_irq(adapter)))
1488 goto err; 1488 goto err;
1489 1489
1490 /* Release the context lock as adapter is configured */
1491 cxl_adapter_context_unlock(adapter);
1490 return 0; 1492 return 0;
1491 1493
1492err: 1494err:
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index b043c20f158f..a8b6d6a635e9 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -75,12 +75,31 @@ static ssize_t reset_adapter_store(struct device *device,
75 int val; 75 int val;
76 76
77 rc = sscanf(buf, "%i", &val); 77 rc = sscanf(buf, "%i", &val);
78 if ((rc != 1) || (val != 1)) 78 if ((rc != 1) || (val != 1 && val != -1))
79 return -EINVAL; 79 return -EINVAL;
80 80
81 if ((rc = cxl_ops->adapter_reset(adapter))) 81 /*
82 return rc; 82 * See if we can lock the context mapping that's only allowed
83 return count; 83 * when there are no contexts attached to the adapter. Once
84 * taken this will also prevent any context from getting activated.
85 */
86 if (val == 1) {
87 rc = cxl_adapter_context_lock(adapter);
88 if (rc)
89 goto out;
90
91 rc = cxl_ops->adapter_reset(adapter);
92 /* In case reset failed release context lock */
93 if (rc)
94 cxl_adapter_context_unlock(adapter);
95
96 } else if (val == -1) {
97 /* Perform a forced adapter reset */
98 rc = cxl_ops->adapter_reset(adapter);
99 }
100
101out:
102 return rc ? rc : count;
84} 103}
85 104
86static ssize_t load_image_on_perst_show(struct device *device, 105static ssize_t load_image_on_perst_show(struct device *device,
diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c
index 8a679ecc8fd1..fc2794b513fa 100644
--- a/drivers/misc/genwqe/card_utils.c
+++ b/drivers/misc/genwqe/card_utils.c
@@ -352,17 +352,27 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,
352 if (copy_from_user(sgl->lpage, user_addr + user_size - 352 if (copy_from_user(sgl->lpage, user_addr + user_size -
353 sgl->lpage_size, sgl->lpage_size)) { 353 sgl->lpage_size, sgl->lpage_size)) {
354 rc = -EFAULT; 354 rc = -EFAULT;
355 goto err_out1; 355 goto err_out2;
356 } 356 }
357 } 357 }
358 return 0; 358 return 0;
359 359
360 err_out2:
361 __genwqe_free_consistent(cd, PAGE_SIZE, sgl->lpage,
362 sgl->lpage_dma_addr);
363 sgl->lpage = NULL;
364 sgl->lpage_dma_addr = 0;
360 err_out1: 365 err_out1:
361 __genwqe_free_consistent(cd, PAGE_SIZE, sgl->fpage, 366 __genwqe_free_consistent(cd, PAGE_SIZE, sgl->fpage,
362 sgl->fpage_dma_addr); 367 sgl->fpage_dma_addr);
368 sgl->fpage = NULL;
369 sgl->fpage_dma_addr = 0;
363 err_out: 370 err_out:
364 __genwqe_free_consistent(cd, sgl->sgl_size, sgl->sgl, 371 __genwqe_free_consistent(cd, sgl->sgl_size, sgl->sgl,
365 sgl->sgl_dma_addr); 372 sgl->sgl_dma_addr);
373 sgl->sgl = NULL;
374 sgl->sgl_dma_addr = 0;
375 sgl->sgl_size = 0;
366 return -ENOMEM; 376 return -ENOMEM;
367} 377}
368 378
diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c
index e6e5e55a12ed..60415a2bfcbd 100644
--- a/drivers/misc/mei/hw-txe.c
+++ b/drivers/misc/mei/hw-txe.c
@@ -981,11 +981,13 @@ static bool mei_txe_check_and_ack_intrs(struct mei_device *dev, bool do_ack)
981 hisr = mei_txe_br_reg_read(hw, HISR_REG); 981 hisr = mei_txe_br_reg_read(hw, HISR_REG);
982 982
983 aliveness = mei_txe_aliveness_get(dev); 983 aliveness = mei_txe_aliveness_get(dev);
984 if (hhisr & IPC_HHIER_SEC && aliveness) 984 if (hhisr & IPC_HHIER_SEC && aliveness) {
985 ipc_isr = mei_txe_sec_reg_read_silent(hw, 985 ipc_isr = mei_txe_sec_reg_read_silent(hw,
986 SEC_IPC_HOST_INT_STATUS_REG); 986 SEC_IPC_HOST_INT_STATUS_REG);
987 else 987 } else {
988 ipc_isr = 0; 988 ipc_isr = 0;
989 hhisr &= ~IPC_HHIER_SEC;
990 }
989 991
990 generated = generated || 992 generated = generated ||
991 (hisr & HISR_INT_STS_MSK) || 993 (hisr & HISR_INT_STS_MSK) ||
diff --git a/drivers/misc/sgi-gru/grumain.c b/drivers/misc/sgi-gru/grumain.c
index 1525870f460a..33741ad4a74a 100644
--- a/drivers/misc/sgi-gru/grumain.c
+++ b/drivers/misc/sgi-gru/grumain.c
@@ -283,7 +283,7 @@ static void gru_unload_mm_tracker(struct gru_state *gru,
283 spin_lock(&gru->gs_asid_lock); 283 spin_lock(&gru->gs_asid_lock);
284 BUG_ON((asids->mt_ctxbitmap & ctxbitmap) != ctxbitmap); 284 BUG_ON((asids->mt_ctxbitmap & ctxbitmap) != ctxbitmap);
285 asids->mt_ctxbitmap ^= ctxbitmap; 285 asids->mt_ctxbitmap ^= ctxbitmap;
286 gru_dbg(grudev, "gid %d, gts %p, gms %p, ctxnum 0x%d, asidmap 0x%lx\n", 286 gru_dbg(grudev, "gid %d, gts %p, gms %p, ctxnum %d, asidmap 0x%lx\n",
287 gru->gs_gid, gts, gms, gts->ts_ctxnum, gms->ms_asidmap[0]); 287 gru->gs_gid, gts, gms, gts->ts_ctxnum, gms->ms_asidmap[0]);
288 spin_unlock(&gru->gs_asid_lock); 288 spin_unlock(&gru->gs_asid_lock);
289 spin_unlock(&gms->ms_asid_lock); 289 spin_unlock(&gms->ms_asid_lock);
diff --git a/drivers/misc/vmw_vmci/vmci_doorbell.c b/drivers/misc/vmw_vmci/vmci_doorbell.c
index a8cee33ae8d2..b3fa738ae005 100644
--- a/drivers/misc/vmw_vmci/vmci_doorbell.c
+++ b/drivers/misc/vmw_vmci/vmci_doorbell.c
@@ -431,6 +431,12 @@ int vmci_doorbell_create(struct vmci_handle *handle,
431 if (vmci_handle_is_invalid(*handle)) { 431 if (vmci_handle_is_invalid(*handle)) {
432 u32 context_id = vmci_get_context_id(); 432 u32 context_id = vmci_get_context_id();
433 433
434 if (context_id == VMCI_INVALID_ID) {
435 pr_warn("Failed to get context ID\n");
436 result = VMCI_ERROR_NO_RESOURCES;
437 goto free_mem;
438 }
439
434 /* Let resource code allocate a free ID for us */ 440 /* Let resource code allocate a free ID for us */
435 new_handle = vmci_make_handle(context_id, VMCI_INVALID_ID); 441 new_handle = vmci_make_handle(context_id, VMCI_INVALID_ID);
436 } else { 442 } else {
@@ -525,7 +531,7 @@ int vmci_doorbell_destroy(struct vmci_handle handle)
525 531
526 entry = container_of(resource, struct dbell_entry, resource); 532 entry = container_of(resource, struct dbell_entry, resource);
527 533
528 if (vmci_guest_code_active()) { 534 if (!hlist_unhashed(&entry->node)) {
529 int result; 535 int result;
530 536
531 dbell_index_table_remove(entry); 537 dbell_index_table_remove(entry);
diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c
index 896be150e28f..d7eaf1eb11e7 100644
--- a/drivers/misc/vmw_vmci/vmci_driver.c
+++ b/drivers/misc/vmw_vmci/vmci_driver.c
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
113 113
114MODULE_AUTHOR("VMware, Inc."); 114MODULE_AUTHOR("VMware, Inc.");
115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface."); 115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
116MODULE_VERSION("1.1.4.0-k"); 116MODULE_VERSION("1.1.5.0-k");
117MODULE_LICENSE("GPL v2"); 117MODULE_LICENSE("GPL v2");
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index c3335112e68c..709a872ed484 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -46,6 +46,7 @@
46#include <asm/uaccess.h> 46#include <asm/uaccess.h>
47 47
48#include "queue.h" 48#include "queue.h"
49#include "block.h"
49 50
50MODULE_ALIAS("mmc:block"); 51MODULE_ALIAS("mmc:block");
51#ifdef MODULE_PARAM_PREFIX 52#ifdef MODULE_PARAM_PREFIX
@@ -1786,7 +1787,7 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq,
1786 struct mmc_blk_data *md = mq->data; 1787 struct mmc_blk_data *md = mq->data;
1787 struct mmc_packed *packed = mqrq->packed; 1788 struct mmc_packed *packed = mqrq->packed;
1788 bool do_rel_wr, do_data_tag; 1789 bool do_rel_wr, do_data_tag;
1789 u32 *packed_cmd_hdr; 1790 __le32 *packed_cmd_hdr;
1790 u8 hdr_blocks; 1791 u8 hdr_blocks;
1791 u8 i = 1; 1792 u8 i = 1;
1792 1793
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
index 3c15a75bae86..342f1e3f301e 100644
--- a/drivers/mmc/card/queue.h
+++ b/drivers/mmc/card/queue.h
@@ -31,7 +31,7 @@ enum mmc_packed_type {
31 31
32struct mmc_packed { 32struct mmc_packed {
33 struct list_head list; 33 struct list_head list;
34 u32 cmd_hdr[1024]; 34 __le32 cmd_hdr[1024];
35 unsigned int blocks; 35 unsigned int blocks;
36 u8 nr_entries; 36 u8 nr_entries;
37 u8 retries; 37 u8 retries;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 3486bc7fbb64..39fc5b2b96c5 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1263,6 +1263,16 @@ static int mmc_select_hs400es(struct mmc_card *card)
1263 goto out_err; 1263 goto out_err;
1264 } 1264 }
1265 1265
1266 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V)
1267 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);
1268
1269 if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_8V)
1270 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
1271
1272 /* If fails try again during next card power cycle */
1273 if (err)
1274 goto out_err;
1275
1266 err = mmc_select_bus_width(card); 1276 err = mmc_select_bus_width(card);
1267 if (err < 0) 1277 if (err < 0)
1268 goto out_err; 1278 goto out_err;
@@ -1272,6 +1282,8 @@ static int mmc_select_hs400es(struct mmc_card *card)
1272 if (err) 1282 if (err)
1273 goto out_err; 1283 goto out_err;
1274 1284
1285 mmc_set_clock(host, card->ext_csd.hs_max_dtr);
1286
1275 err = mmc_switch_status(card); 1287 err = mmc_switch_status(card);
1276 if (err) 1288 if (err)
1277 goto out_err; 1289 goto out_err;
diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 4106295527b9..6e9c0f8fddb1 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1138,11 +1138,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1138 dev_dbg(sdmmc_dev(host), "%s\n", __func__); 1138 dev_dbg(sdmmc_dev(host), "%s\n", __func__);
1139 mutex_lock(&ucr->dev_mutex); 1139 mutex_lock(&ucr->dev_mutex);
1140 1140
1141 if (rtsx_usb_card_exclusive_check(ucr, RTSX_USB_SD_CARD)) {
1142 mutex_unlock(&ucr->dev_mutex);
1143 return;
1144 }
1145
1146 sd_set_power_mode(host, ios->power_mode); 1141 sd_set_power_mode(host, ios->power_mode);
1147 sd_set_bus_width(host, ios->bus_width); 1142 sd_set_bus_width(host, ios->bus_width);
1148 sd_set_timing(host, ios->timing, &host->ddr_mode); 1143 sd_set_timing(host, ios->timing, &host->ddr_mode);
@@ -1314,6 +1309,7 @@ static void rtsx_usb_update_led(struct work_struct *work)
1314 container_of(work, struct rtsx_usb_sdmmc, led_work); 1309 container_of(work, struct rtsx_usb_sdmmc, led_work);
1315 struct rtsx_ucr *ucr = host->ucr; 1310 struct rtsx_ucr *ucr = host->ucr;
1316 1311
1312 pm_runtime_get_sync(sdmmc_dev(host));
1317 mutex_lock(&ucr->dev_mutex); 1313 mutex_lock(&ucr->dev_mutex);
1318 1314
1319 if (host->led.brightness == LED_OFF) 1315 if (host->led.brightness == LED_OFF)
@@ -1322,6 +1318,7 @@ static void rtsx_usb_update_led(struct work_struct *work)
1322 rtsx_usb_turn_on_led(ucr); 1318 rtsx_usb_turn_on_led(ucr);
1323 1319
1324 mutex_unlock(&ucr->dev_mutex); 1320 mutex_unlock(&ucr->dev_mutex);
1321 pm_runtime_put(sdmmc_dev(host));
1325} 1322}
1326#endif 1323#endif
1327 1324
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1f54fd8755c8..7123ef96ed18 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -346,7 +346,8 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
346 struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 346 struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
347 u32 data; 347 u32 data;
348 348
349 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) { 349 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE ||
350 reg == SDHCI_INT_STATUS)) {
350 if ((val & SDHCI_INT_CARD_INT) && !esdhc_is_usdhc(imx_data)) { 351 if ((val & SDHCI_INT_CARD_INT) && !esdhc_is_usdhc(imx_data)) {
351 /* 352 /*
352 * Clear and then set D3CD bit to avoid missing the 353 * Clear and then set D3CD bit to avoid missing the
@@ -555,6 +556,25 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
555 esdhc_clrset_le(host, 0xffff, val, reg); 556 esdhc_clrset_le(host, 0xffff, val, reg);
556} 557}
557 558
559static u8 esdhc_readb_le(struct sdhci_host *host, int reg)
560{
561 u8 ret;
562 u32 val;
563
564 switch (reg) {
565 case SDHCI_HOST_CONTROL:
566 val = readl(host->ioaddr + reg);
567
568 ret = val & SDHCI_CTRL_LED;
569 ret |= (val >> 5) & SDHCI_CTRL_DMA_MASK;
570 ret |= (val & ESDHC_CTRL_4BITBUS);
571 ret |= (val & ESDHC_CTRL_8BITBUS) << 3;
572 return ret;
573 }
574
575 return readb(host->ioaddr + reg);
576}
577
558static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg) 578static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
559{ 579{
560 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 580 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -947,6 +967,7 @@ static void esdhc_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
947static struct sdhci_ops sdhci_esdhc_ops = { 967static struct sdhci_ops sdhci_esdhc_ops = {
948 .read_l = esdhc_readl_le, 968 .read_l = esdhc_readl_le,
949 .read_w = esdhc_readw_le, 969 .read_w = esdhc_readw_le,
970 .read_b = esdhc_readb_le,
950 .write_l = esdhc_writel_le, 971 .write_l = esdhc_writel_le,
951 .write_w = esdhc_writew_le, 972 .write_w = esdhc_writew_le,
952 .write_b = esdhc_writeb_le, 973 .write_b = esdhc_writeb_le,
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index da8e40af6f85..410a55b1c25f 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -250,7 +250,7 @@ static void sdhci_arasan_hs400_enhanced_strobe(struct mmc_host *mmc,
250 writel(vendor, host->ioaddr + SDHCI_ARASAN_VENDOR_REGISTER); 250 writel(vendor, host->ioaddr + SDHCI_ARASAN_VENDOR_REGISTER);
251} 251}
252 252
253void sdhci_arasan_reset(struct sdhci_host *host, u8 mask) 253static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
254{ 254{
255 u8 ctrl; 255 u8 ctrl;
256 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 256 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -265,6 +265,28 @@ void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
265 } 265 }
266} 266}
267 267
268static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
269 struct mmc_ios *ios)
270{
271 switch (ios->signal_voltage) {
272 case MMC_SIGNAL_VOLTAGE_180:
273 /*
274 * Plese don't switch to 1V8 as arasan,5.1 doesn't
275 * actually refer to this setting to indicate the
276 * signal voltage and the state machine will be broken
277 * actually if we force to enable 1V8. That's something
278 * like broken quirk but we could work around here.
279 */
280 return 0;
281 case MMC_SIGNAL_VOLTAGE_330:
282 case MMC_SIGNAL_VOLTAGE_120:
283 /* We don't support 3V3 and 1V2 */
284 break;
285 }
286
287 return -EINVAL;
288}
289
268static struct sdhci_ops sdhci_arasan_ops = { 290static struct sdhci_ops sdhci_arasan_ops = {
269 .set_clock = sdhci_arasan_set_clock, 291 .set_clock = sdhci_arasan_set_clock,
270 .get_max_clock = sdhci_pltfm_clk_get_max_clock, 292 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
@@ -661,6 +683,8 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
661 683
662 host->mmc_host_ops.hs400_enhanced_strobe = 684 host->mmc_host_ops.hs400_enhanced_strobe =
663 sdhci_arasan_hs400_enhanced_strobe; 685 sdhci_arasan_hs400_enhanced_strobe;
686 host->mmc_host_ops.start_signal_voltage_switch =
687 sdhci_arasan_voltage_switch;
664 } 688 }
665 689
666 ret = sdhci_add_host(host); 690 ret = sdhci_add_host(host);
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 72a1f1f5180a..1d9e00a00e9f 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -32,6 +32,14 @@
32#include "sdhci-pci.h" 32#include "sdhci-pci.h"
33#include "sdhci-pci-o2micro.h" 33#include "sdhci-pci-o2micro.h"
34 34
35static int sdhci_pci_enable_dma(struct sdhci_host *host);
36static void sdhci_pci_set_bus_width(struct sdhci_host *host, int width);
37static void sdhci_pci_hw_reset(struct sdhci_host *host);
38static int sdhci_pci_select_drive_strength(struct sdhci_host *host,
39 struct mmc_card *card,
40 unsigned int max_dtr, int host_drv,
41 int card_drv, int *drv_type);
42
35/*****************************************************************************\ 43/*****************************************************************************\
36 * * 44 * *
37 * Hardware specific quirk handling * 45 * Hardware specific quirk handling *
@@ -390,6 +398,45 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
390 return 0; 398 return 0;
391} 399}
392 400
401#define SDHCI_INTEL_PWR_TIMEOUT_CNT 20
402#define SDHCI_INTEL_PWR_TIMEOUT_UDELAY 100
403
404static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
405 unsigned short vdd)
406{
407 int cntr;
408 u8 reg;
409
410 sdhci_set_power(host, mode, vdd);
411
412 if (mode == MMC_POWER_OFF)
413 return;
414
415 /*
416 * Bus power might not enable after D3 -> D0 transition due to the
417 * present state not yet having propagated. Retry for up to 2ms.
418 */
419 for (cntr = 0; cntr < SDHCI_INTEL_PWR_TIMEOUT_CNT; cntr++) {
420 reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
421 if (reg & SDHCI_POWER_ON)
422 break;
423 udelay(SDHCI_INTEL_PWR_TIMEOUT_UDELAY);
424 reg |= SDHCI_POWER_ON;
425 sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
426 }
427}
428
429static const struct sdhci_ops sdhci_intel_byt_ops = {
430 .set_clock = sdhci_set_clock,
431 .set_power = sdhci_intel_set_power,
432 .enable_dma = sdhci_pci_enable_dma,
433 .set_bus_width = sdhci_pci_set_bus_width,
434 .reset = sdhci_reset,
435 .set_uhs_signaling = sdhci_set_uhs_signaling,
436 .hw_reset = sdhci_pci_hw_reset,
437 .select_drive_strength = sdhci_pci_select_drive_strength,
438};
439
393static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { 440static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
394 .allow_runtime_pm = true, 441 .allow_runtime_pm = true,
395 .probe_slot = byt_emmc_probe_slot, 442 .probe_slot = byt_emmc_probe_slot,
@@ -397,6 +444,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
397 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 444 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
398 SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 | 445 SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 |
399 SDHCI_QUIRK2_STOP_WITH_TC, 446 SDHCI_QUIRK2_STOP_WITH_TC,
447 .ops = &sdhci_intel_byt_ops,
400}; 448};
401 449
402static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = { 450static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
@@ -405,6 +453,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
405 SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 453 SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
406 .allow_runtime_pm = true, 454 .allow_runtime_pm = true,
407 .probe_slot = byt_sdio_probe_slot, 455 .probe_slot = byt_sdio_probe_slot,
456 .ops = &sdhci_intel_byt_ops,
408}; 457};
409 458
410static const struct sdhci_pci_fixes sdhci_intel_byt_sd = { 459static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
@@ -415,6 +464,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
415 .allow_runtime_pm = true, 464 .allow_runtime_pm = true,
416 .own_cd_for_runtime_pm = true, 465 .own_cd_for_runtime_pm = true,
417 .probe_slot = byt_sd_probe_slot, 466 .probe_slot = byt_sd_probe_slot,
467 .ops = &sdhci_intel_byt_ops,
418}; 468};
419 469
420/* Define Host controllers for Intel Merrifield platform */ 470/* Define Host controllers for Intel Merrifield platform */
@@ -1648,7 +1698,9 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
1648 } 1698 }
1649 1699
1650 host->hw_name = "PCI"; 1700 host->hw_name = "PCI";
1651 host->ops = &sdhci_pci_ops; 1701 host->ops = chip->fixes && chip->fixes->ops ?
1702 chip->fixes->ops :
1703 &sdhci_pci_ops;
1652 host->quirks = chip->quirks; 1704 host->quirks = chip->quirks;
1653 host->quirks2 = chip->quirks2; 1705 host->quirks2 = chip->quirks2;
1654 1706
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 9c7c08b93223..6bccf56bc5ff 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -65,6 +65,8 @@ struct sdhci_pci_fixes {
65 65
66 int (*suspend) (struct sdhci_pci_chip *); 66 int (*suspend) (struct sdhci_pci_chip *);
67 int (*resume) (struct sdhci_pci_chip *); 67 int (*resume) (struct sdhci_pci_chip *);
68
69 const struct sdhci_ops *ops;
68}; 70};
69 71
70struct sdhci_pci_slot { 72struct sdhci_pci_slot {
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index dd1938d341f7..d0f5c05fbc19 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -315,7 +315,7 @@ static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
315 struct mmc_host *mmc = host->mmc; 315 struct mmc_host *mmc = host->mmc;
316 u8 pwr = host->pwr; 316 u8 pwr = host->pwr;
317 317
318 sdhci_set_power(host, mode, vdd); 318 sdhci_set_power_noreg(host, mode, vdd);
319 319
320 if (host->pwr == pwr) 320 if (host->pwr == pwr)
321 return; 321 return;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 48055666c655..71654b90227f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -687,7 +687,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
687 * host->clock is in Hz. target_timeout is in us. 687 * host->clock is in Hz. target_timeout is in us.
688 * Hence, us = 1000000 * cycles / Hz. Round up. 688 * Hence, us = 1000000 * cycles / Hz. Round up.
689 */ 689 */
690 val = 1000000 * data->timeout_clks; 690 val = 1000000ULL * data->timeout_clks;
691 if (do_div(val, host->clock)) 691 if (do_div(val, host->clock))
692 target_timeout++; 692 target_timeout++;
693 target_timeout += val; 693 target_timeout += val;
@@ -1077,6 +1077,10 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
1077 /* Initially, a command has no error */ 1077 /* Initially, a command has no error */
1078 cmd->error = 0; 1078 cmd->error = 0;
1079 1079
1080 if ((host->quirks2 & SDHCI_QUIRK2_STOP_WITH_TC) &&
1081 cmd->opcode == MMC_STOP_TRANSMISSION)
1082 cmd->flags |= MMC_RSP_BUSY;
1083
1080 /* Wait max 10 ms */ 1084 /* Wait max 10 ms */
1081 timeout = 10; 1085 timeout = 10;
1082 1086
@@ -1390,8 +1394,8 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
1390 sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); 1394 sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
1391} 1395}
1392 1396
1393void sdhci_set_power(struct sdhci_host *host, unsigned char mode, 1397void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
1394 unsigned short vdd) 1398 unsigned short vdd)
1395{ 1399{
1396 u8 pwr = 0; 1400 u8 pwr = 0;
1397 1401
@@ -1455,20 +1459,17 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
1455 mdelay(10); 1459 mdelay(10);
1456 } 1460 }
1457} 1461}
1458EXPORT_SYMBOL_GPL(sdhci_set_power); 1462EXPORT_SYMBOL_GPL(sdhci_set_power_noreg);
1459 1463
1460static void __sdhci_set_power(struct sdhci_host *host, unsigned char mode, 1464void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
1461 unsigned short vdd) 1465 unsigned short vdd)
1462{ 1466{
1463 struct mmc_host *mmc = host->mmc; 1467 if (IS_ERR(host->mmc->supply.vmmc))
1464 1468 sdhci_set_power_noreg(host, mode, vdd);
1465 if (host->ops->set_power)
1466 host->ops->set_power(host, mode, vdd);
1467 else if (!IS_ERR(mmc->supply.vmmc))
1468 sdhci_set_power_reg(host, mode, vdd);
1469 else 1469 else
1470 sdhci_set_power(host, mode, vdd); 1470 sdhci_set_power_reg(host, mode, vdd);
1471} 1471}
1472EXPORT_SYMBOL_GPL(sdhci_set_power);
1472 1473
1473/*****************************************************************************\ 1474/*****************************************************************************\
1474 * * 1475 * *
@@ -1609,7 +1610,10 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1609 } 1610 }
1610 } 1611 }
1611 1612
1612 __sdhci_set_power(host, ios->power_mode, ios->vdd); 1613 if (host->ops->set_power)
1614 host->ops->set_power(host, ios->power_mode, ios->vdd);
1615 else
1616 sdhci_set_power(host, ios->power_mode, ios->vdd);
1613 1617
1614 if (host->ops->platform_send_init_74_clocks) 1618 if (host->ops->platform_send_init_74_clocks)
1615 host->ops->platform_send_init_74_clocks(host, ios->power_mode); 1619 host->ops->platform_send_init_74_clocks(host, ios->power_mode);
@@ -2409,7 +2413,7 @@ static void sdhci_timeout_data_timer(unsigned long data)
2409 * * 2413 * *
2410\*****************************************************************************/ 2414\*****************************************************************************/
2411 2415
2412static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *mask) 2416static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
2413{ 2417{
2414 if (!host->cmd) { 2418 if (!host->cmd) {
2415 /* 2419 /*
@@ -2453,11 +2457,6 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *mask)
2453 return; 2457 return;
2454 } 2458 }
2455 2459
2456 if ((host->quirks2 & SDHCI_QUIRK2_STOP_WITH_TC) &&
2457 !(host->cmd->flags & MMC_RSP_BUSY) && !host->data &&
2458 host->cmd->opcode == MMC_STOP_TRANSMISSION)
2459 *mask &= ~SDHCI_INT_DATA_END;
2460
2461 if (intmask & SDHCI_INT_RESPONSE) 2460 if (intmask & SDHCI_INT_RESPONSE)
2462 sdhci_finish_command(host); 2461 sdhci_finish_command(host);
2463} 2462}
@@ -2680,8 +2679,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
2680 } 2679 }
2681 2680
2682 if (intmask & SDHCI_INT_CMD_MASK) 2681 if (intmask & SDHCI_INT_CMD_MASK)
2683 sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK, 2682 sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
2684 &intmask);
2685 2683
2686 if (intmask & SDHCI_INT_DATA_MASK) 2684 if (intmask & SDHCI_INT_DATA_MASK)
2687 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); 2685 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index c722cd23205c..766df17fb7eb 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -683,6 +683,8 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock,
683void sdhci_set_clock(struct sdhci_host *host, unsigned int clock); 683void sdhci_set_clock(struct sdhci_host *host, unsigned int clock);
684void sdhci_set_power(struct sdhci_host *host, unsigned char mode, 684void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
685 unsigned short vdd); 685 unsigned short vdd);
686void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
687 unsigned short vdd);
686void sdhci_set_bus_width(struct sdhci_host *host, int width); 688void sdhci_set_bus_width(struct sdhci_host *host, int width);
687void sdhci_reset(struct sdhci_host *host, u8 mask); 689void sdhci_reset(struct sdhci_host *host, u8 mask);
688void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing); 690void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 95c4048a371e..388e46be6ad9 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -741,6 +741,7 @@ static int try_recover_peb(struct ubi_volume *vol, int pnum, int lnum,
741 goto out_put; 741 goto out_put;
742 } 742 }
743 743
744 vid_hdr = ubi_get_vid_hdr(vidb);
744 ubi_assert(vid_hdr->vol_type == UBI_VID_DYNAMIC); 745 ubi_assert(vid_hdr->vol_type == UBI_VID_DYNAMIC);
745 746
746 mutex_lock(&ubi->buf_mutex); 747 mutex_lock(&ubi->buf_mutex);
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index d6384d965788..c1f5c29e458e 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -287,7 +287,7 @@ static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai,
287 287
288 /* new_aeb is newer */ 288 /* new_aeb is newer */
289 if (cmp_res & 1) { 289 if (cmp_res & 1) {
290 victim = ubi_alloc_aeb(ai, aeb->ec, aeb->pnum); 290 victim = ubi_alloc_aeb(ai, aeb->pnum, aeb->ec);
291 if (!victim) 291 if (!victim)
292 return -ENOMEM; 292 return -ENOMEM;
293 293
@@ -707,11 +707,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
707 fmvhdr->vol_type, 707 fmvhdr->vol_type,
708 be32_to_cpu(fmvhdr->last_eb_bytes)); 708 be32_to_cpu(fmvhdr->last_eb_bytes));
709 709
710 if (!av) 710 if (IS_ERR(av)) {
711 goto fail_bad; 711 if (PTR_ERR(av) == -EEXIST)
712 if (PTR_ERR(av) == -EINVAL) { 712 ubi_err(ubi, "volume (ID %i) already exists",
713 ubi_err(ubi, "volume (ID %i) already exists", 713 fmvhdr->vol_id);
714 fmvhdr->vol_id); 714
715 goto fail_bad; 715 goto fail_bad;
716 } 716 }
717 717
diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index 76fb8552c9d9..ef63d24fef81 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -256,6 +256,7 @@ static const struct of_device_id b53_mmap_of_table[] = {
256 { .compatible = "brcm,bcm63xx-switch" }, 256 { .compatible = "brcm,bcm63xx-switch" },
257 { /* sentinel */ }, 257 { /* sentinel */ },
258}; 258};
259MODULE_DEVICE_TABLE(of, b53_mmap_of_table);
259 260
260static struct platform_driver b53_mmap_driver = { 261static struct platform_driver b53_mmap_driver = {
261 .probe = b53_mmap_probe, 262 .probe = b53_mmap_probe,
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index e218887f18b7..e3ee27ce13dd 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1133,6 +1133,20 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
1133 return 0; 1133 return 0;
1134} 1134}
1135 1135
1136static void bcm_sf2_sw_shutdown(struct platform_device *pdev)
1137{
1138 struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
1139
1140 /* For a kernel about to be kexec'd we want to keep the GPHY on for a
1141 * successful MDIO bus scan to occur. If we did turn off the GPHY
1142 * before (e.g: port_disable), this will also power it back on.
1143 *
1144 * Do not rely on kexec_in_progress, just power the PHY on.
1145 */
1146 if (priv->hw_params.num_gphy == 1)
1147 bcm_sf2_gphy_enable_set(priv->dev->ds, true);
1148}
1149
1136#ifdef CONFIG_PM_SLEEP 1150#ifdef CONFIG_PM_SLEEP
1137static int bcm_sf2_suspend(struct device *dev) 1151static int bcm_sf2_suspend(struct device *dev)
1138{ 1152{
@@ -1158,10 +1172,12 @@ static const struct of_device_id bcm_sf2_of_match[] = {
1158 { .compatible = "brcm,bcm7445-switch-v4.0" }, 1172 { .compatible = "brcm,bcm7445-switch-v4.0" },
1159 { /* sentinel */ }, 1173 { /* sentinel */ },
1160}; 1174};
1175MODULE_DEVICE_TABLE(of, bcm_sf2_of_match);
1161 1176
1162static struct platform_driver bcm_sf2_driver = { 1177static struct platform_driver bcm_sf2_driver = {
1163 .probe = bcm_sf2_sw_probe, 1178 .probe = bcm_sf2_sw_probe,
1164 .remove = bcm_sf2_sw_remove, 1179 .remove = bcm_sf2_sw_remove,
1180 .shutdown = bcm_sf2_sw_shutdown,
1165 .driver = { 1181 .driver = {
1166 .name = "brcm-sf2", 1182 .name = "brcm-sf2",
1167 .of_match_table = bcm_sf2_of_match, 1183 .of_match_table = bcm_sf2_of_match,
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
index b047fd607b83..00c38bf151e6 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -1358,6 +1358,7 @@ static const struct of_device_id nb8800_dt_ids[] = {
1358 }, 1358 },
1359 { } 1359 { }
1360}; 1360};
1361MODULE_DEVICE_TABLE(of, nb8800_dt_ids);
1361 1362
1362static int nb8800_probe(struct platform_device *pdev) 1363static int nb8800_probe(struct platform_device *pdev)
1363{ 1364{
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index ae364c74baf3..537090952c45 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1126,7 +1126,8 @@ out_freeirq:
1126 free_irq(dev->irq, dev); 1126 free_irq(dev->irq, dev);
1127 1127
1128out_phy_disconnect: 1128out_phy_disconnect:
1129 phy_disconnect(phydev); 1129 if (priv->has_phy)
1130 phy_disconnect(phydev);
1130 1131
1131 return ret; 1132 return ret;
1132} 1133}
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 856379cbb402..31ca204b38d2 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1449,7 +1449,7 @@ static int bgmac_phy_connect(struct bgmac *bgmac)
1449 phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link, 1449 phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
1450 PHY_INTERFACE_MODE_MII); 1450 PHY_INTERFACE_MODE_MII);
1451 if (IS_ERR(phy_dev)) { 1451 if (IS_ERR(phy_dev)) {
1452 dev_err(bgmac->dev, "PHY connecton failed\n"); 1452 dev_err(bgmac->dev, "PHY connection failed\n");
1453 return PTR_ERR(phy_dev); 1453 return PTR_ERR(phy_dev);
1454 } 1454 }
1455 1455
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 27f11a5d5fe2..b3791b394715 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -271,22 +271,25 @@ static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
271static u32 271static u32
272bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset) 272bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
273{ 273{
274 unsigned long flags;
274 u32 val; 275 u32 val;
275 276
276 spin_lock_bh(&bp->indirect_lock); 277 spin_lock_irqsave(&bp->indirect_lock, flags);
277 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset); 278 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
278 val = BNX2_RD(bp, BNX2_PCICFG_REG_WINDOW); 279 val = BNX2_RD(bp, BNX2_PCICFG_REG_WINDOW);
279 spin_unlock_bh(&bp->indirect_lock); 280 spin_unlock_irqrestore(&bp->indirect_lock, flags);
280 return val; 281 return val;
281} 282}
282 283
283static void 284static void
284bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val) 285bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val)
285{ 286{
286 spin_lock_bh(&bp->indirect_lock); 287 unsigned long flags;
288
289 spin_lock_irqsave(&bp->indirect_lock, flags);
287 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset); 290 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
288 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW, val); 291 BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW, val);
289 spin_unlock_bh(&bp->indirect_lock); 292 spin_unlock_irqrestore(&bp->indirect_lock, flags);
290} 293}
291 294
292static void 295static void
@@ -304,8 +307,10 @@ bnx2_shmem_rd(struct bnx2 *bp, u32 offset)
304static void 307static void
305bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val) 308bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
306{ 309{
310 unsigned long flags;
311
307 offset += cid_addr; 312 offset += cid_addr;
308 spin_lock_bh(&bp->indirect_lock); 313 spin_lock_irqsave(&bp->indirect_lock, flags);
309 if (BNX2_CHIP(bp) == BNX2_CHIP_5709) { 314 if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
310 int i; 315 int i;
311 316
@@ -322,7 +327,7 @@ bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
322 BNX2_WR(bp, BNX2_CTX_DATA_ADR, offset); 327 BNX2_WR(bp, BNX2_CTX_DATA_ADR, offset);
323 BNX2_WR(bp, BNX2_CTX_DATA, val); 328 BNX2_WR(bp, BNX2_CTX_DATA, val);
324 } 329 }
325 spin_unlock_bh(&bp->indirect_lock); 330 spin_unlock_irqrestore(&bp->indirect_lock, flags);
326} 331}
327 332
328#ifdef BCM_CNIC 333#ifdef BCM_CNIC
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 20fe6a8c35c1..0cee4c0283f9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -15241,7 +15241,7 @@ static void bnx2x_init_cyclecounter(struct bnx2x *bp)
15241 memset(&bp->cyclecounter, 0, sizeof(bp->cyclecounter)); 15241 memset(&bp->cyclecounter, 0, sizeof(bp->cyclecounter));
15242 bp->cyclecounter.read = bnx2x_cyclecounter_read; 15242 bp->cyclecounter.read = bnx2x_cyclecounter_read;
15243 bp->cyclecounter.mask = CYCLECOUNTER_MASK(64); 15243 bp->cyclecounter.mask = CYCLECOUNTER_MASK(64);
15244 bp->cyclecounter.shift = 1; 15244 bp->cyclecounter.shift = 0;
15245 bp->cyclecounter.mult = 1; 15245 bp->cyclecounter.mult = 1;
15246} 15246}
15247 15247
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index f320497368f4..57eb4e1345cb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4057,7 +4057,7 @@ static void cfg_queues(struct adapter *adap)
4057 * capped by the number of available cores. 4057 * capped by the number of available cores.
4058 */ 4058 */
4059 if (n10g) { 4059 if (n10g) {
4060 i = num_online_cpus(); 4060 i = min_t(int, MAX_OFLD_QSETS, num_online_cpus());
4061 s->ofldqsets = roundup(i, adap->params.nports); 4061 s->ofldqsets = roundup(i, adap->params.nports);
4062 } else { 4062 } else {
4063 s->ofldqsets = adap->params.nports; 4063 s->ofldqsets = adap->params.nports;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index 0945fa49a5dd..2471ff465d5c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -135,15 +135,17 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
135} 135}
136 136
137static int alloc_uld_rxqs(struct adapter *adap, 137static int alloc_uld_rxqs(struct adapter *adap,
138 struct sge_uld_rxq_info *rxq_info, 138 struct sge_uld_rxq_info *rxq_info, bool lro)
139 unsigned int nq, unsigned int offset, bool lro)
140{ 139{
141 struct sge *s = &adap->sge; 140 struct sge *s = &adap->sge;
142 struct sge_ofld_rxq *q = rxq_info->uldrxq + offset; 141 unsigned int nq = rxq_info->nrxq + rxq_info->nciq;
143 unsigned short *ids = rxq_info->rspq_id + offset; 142 struct sge_ofld_rxq *q = rxq_info->uldrxq;
144 unsigned int per_chan = nq / adap->params.nports; 143 unsigned short *ids = rxq_info->rspq_id;
145 unsigned int bmap_idx = 0; 144 unsigned int bmap_idx = 0;
146 int i, err, msi_idx; 145 unsigned int per_chan;
146 int i, err, msi_idx, que_idx = 0;
147
148 per_chan = rxq_info->nrxq / adap->params.nports;
147 149
148 if (adap->flags & USING_MSIX) 150 if (adap->flags & USING_MSIX)
149 msi_idx = 1; 151 msi_idx = 1;
@@ -151,12 +153,18 @@ static int alloc_uld_rxqs(struct adapter *adap,
151 msi_idx = -((int)s->intrq.abs_id + 1); 153 msi_idx = -((int)s->intrq.abs_id + 1);
152 154
153 for (i = 0; i < nq; i++, q++) { 155 for (i = 0; i < nq; i++, q++) {
156 if (i == rxq_info->nrxq) {
157 /* start allocation of concentrator queues */
158 per_chan = rxq_info->nciq / adap->params.nports;
159 que_idx = 0;
160 }
161
154 if (msi_idx >= 0) { 162 if (msi_idx >= 0) {
155 bmap_idx = get_msix_idx_from_bmap(adap); 163 bmap_idx = get_msix_idx_from_bmap(adap);
156 msi_idx = adap->msix_info_ulds[bmap_idx].idx; 164 msi_idx = adap->msix_info_ulds[bmap_idx].idx;
157 } 165 }
158 err = t4_sge_alloc_rxq(adap, &q->rspq, false, 166 err = t4_sge_alloc_rxq(adap, &q->rspq, false,
159 adap->port[i / per_chan], 167 adap->port[que_idx++ / per_chan],
160 msi_idx, 168 msi_idx,
161 q->fl.size ? &q->fl : NULL, 169 q->fl.size ? &q->fl : NULL,
162 uldrx_handler, 170 uldrx_handler,
@@ -165,29 +173,19 @@ static int alloc_uld_rxqs(struct adapter *adap,
165 if (err) 173 if (err)
166 goto freeout; 174 goto freeout;
167 if (msi_idx >= 0) 175 if (msi_idx >= 0)
168 rxq_info->msix_tbl[i + offset] = bmap_idx; 176 rxq_info->msix_tbl[i] = bmap_idx;
169 memset(&q->stats, 0, sizeof(q->stats)); 177 memset(&q->stats, 0, sizeof(q->stats));
170 if (ids) 178 if (ids)
171 ids[i] = q->rspq.abs_id; 179 ids[i] = q->rspq.abs_id;
172 } 180 }
173 return 0; 181 return 0;
174freeout: 182freeout:
175 q = rxq_info->uldrxq + offset; 183 q = rxq_info->uldrxq;
176 for ( ; i; i--, q++) { 184 for ( ; i; i--, q++) {
177 if (q->rspq.desc) 185 if (q->rspq.desc)
178 free_rspq_fl(adap, &q->rspq, 186 free_rspq_fl(adap, &q->rspq,
179 q->fl.size ? &q->fl : NULL); 187 q->fl.size ? &q->fl : NULL);
180 } 188 }
181
182 /* We need to free rxq also in case of ciq allocation failure */
183 if (offset) {
184 q = rxq_info->uldrxq + offset;
185 for ( ; i; i--, q++) {
186 if (q->rspq.desc)
187 free_rspq_fl(adap, &q->rspq,
188 q->fl.size ? &q->fl : NULL);
189 }
190 }
191 return err; 189 return err;
192} 190}
193 191
@@ -205,9 +203,7 @@ setup_sge_queues_uld(struct adapter *adap, unsigned int uld_type, bool lro)
205 return -ENOMEM; 203 return -ENOMEM;
206 } 204 }
207 205
208 ret = !(!alloc_uld_rxqs(adap, rxq_info, rxq_info->nrxq, 0, lro) && 206 ret = !(!alloc_uld_rxqs(adap, rxq_info, lro));
209 !alloc_uld_rxqs(adap, rxq_info, rxq_info->nciq,
210 rxq_info->nrxq, lro));
211 207
212 /* Tell uP to route control queue completions to rdma rspq */ 208 /* Tell uP to route control queue completions to rdma rspq */
213 if (adap->flags & FULL_INIT_DONE && 209 if (adap->flags & FULL_INIT_DONE &&
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c b/drivers/net/ethernet/chelsio/cxgb4/sched.c
index 539de764bbd3..cbd68a8fe2e4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
@@ -210,8 +210,10 @@ static int t4_sched_queue_bind(struct port_info *pi, struct ch_sched_queue *p)
210 210
211 /* Unbind queue from any existing class */ 211 /* Unbind queue from any existing class */
212 err = t4_sched_queue_unbind(pi, p); 212 err = t4_sched_queue_unbind(pi, p);
213 if (err) 213 if (err) {
214 t4_free_mem(qe);
214 goto out; 215 goto out;
216 }
215 217
216 /* Bind queue to specified class */ 218 /* Bind queue to specified class */
217 memset(qe, 0, sizeof(*qe)); 219 memset(qe, 0, sizeof(*qe));
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c b/drivers/net/ethernet/cisco/enic/vnic_rq.c
index e572a527b18d..36bc2c71fba9 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c
@@ -169,19 +169,28 @@ int vnic_rq_disable(struct vnic_rq *rq)
169{ 169{
170 unsigned int wait; 170 unsigned int wait;
171 struct vnic_dev *vdev = rq->vdev; 171 struct vnic_dev *vdev = rq->vdev;
172 int i;
172 173
173 iowrite32(0, &rq->ctrl->enable); 174 /* Due to a race condition with clearing RQ "mini-cache" in hw, we need
175 * to disable the RQ twice to guarantee that stale descriptors are not
176 * used when this RQ is re-enabled.
177 */
178 for (i = 0; i < 2; i++) {
179 iowrite32(0, &rq->ctrl->enable);
174 180
175 /* Wait for HW to ACK disable request */ 181 /* Wait for HW to ACK disable request */
176 for (wait = 0; wait < 1000; wait++) { 182 for (wait = 20000; wait > 0; wait--)
177 if (!(ioread32(&rq->ctrl->running))) 183 if (!ioread32(&rq->ctrl->running))
178 return 0; 184 break;
179 udelay(10); 185 if (!wait) {
180 } 186 vdev_neterr(vdev, "Failed to disable RQ[%d]\n",
187 rq->index);
181 188
182 vdev_neterr(vdev, "Failed to disable RQ[%d]\n", rq->index); 189 return -ETIMEDOUT;
190 }
191 }
183 192
184 return -ETIMEDOUT; 193 return 0;
185} 194}
186 195
187void vnic_rq_clean(struct vnic_rq *rq, 196void vnic_rq_clean(struct vnic_rq *rq,
@@ -212,6 +221,11 @@ void vnic_rq_clean(struct vnic_rq *rq,
212 [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES(count)]; 221 [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES(count)];
213 iowrite32(fetch_index, &rq->ctrl->posted_index); 222 iowrite32(fetch_index, &rq->ctrl->posted_index);
214 223
224 /* Anytime we write fetch_index, we need to re-write 0 to rq->enable
225 * to re-sync internal VIC state.
226 */
227 iowrite32(0, &rq->ctrl->enable);
228
215 vnic_dev_clear_desc_ring(&rq->ring); 229 vnic_dev_clear_desc_ring(&rq->ring);
216} 230}
217 231
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index f928e6f79c89..223f35cc034c 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -669,6 +669,7 @@ static const struct of_device_id nps_enet_dt_ids[] = {
669 { .compatible = "ezchip,nps-mgt-enet" }, 669 { .compatible = "ezchip,nps-mgt-enet" },
670 { /* Sentinel */ } 670 { /* Sentinel */ }
671}; 671};
672MODULE_DEVICE_TABLE(of, nps_enet_dt_ids);
672 673
673static struct platform_driver nps_enet_driver = { 674static struct platform_driver nps_enet_driver = {
674 .probe = nps_enet_probe, 675 .probe = nps_enet_probe,
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 48a033e64423..5aa9d4ded214 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1430,14 +1430,14 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
1430 skb_put(skb, pkt_len - 4); 1430 skb_put(skb, pkt_len - 4);
1431 data = skb->data; 1431 data = skb->data;
1432 1432
1433 if (!is_copybreak && need_swap)
1434 swap_buffer(data, pkt_len);
1435
1433#if !defined(CONFIG_M5272) 1436#if !defined(CONFIG_M5272)
1434 if (fep->quirks & FEC_QUIRK_HAS_RACC) 1437 if (fep->quirks & FEC_QUIRK_HAS_RACC)
1435 data = skb_pull_inline(skb, 2); 1438 data = skb_pull_inline(skb, 2);
1436#endif 1439#endif
1437 1440
1438 if (!is_copybreak && need_swap)
1439 swap_buffer(data, pkt_len);
1440
1441 /* Extract the enhanced buffer descriptor */ 1441 /* Extract the enhanced buffer descriptor */
1442 ebdp = NULL; 1442 ebdp = NULL;
1443 if (fep->bufdesc_ex) 1443 if (fep->bufdesc_ex)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 8d70377f6624..8ea3d95fa483 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2751,6 +2751,7 @@ static const struct of_device_id g_dsaf_match[] = {
2751 {.compatible = "hisilicon,hns-dsaf-v2"}, 2751 {.compatible = "hisilicon,hns-dsaf-v2"},
2752 {} 2752 {}
2753}; 2753};
2754MODULE_DEVICE_TABLE(of, g_dsaf_match);
2754 2755
2755static struct platform_driver g_dsaf_driver = { 2756static struct platform_driver g_dsaf_driver = {
2756 .probe = hns_dsaf_probe, 2757 .probe = hns_dsaf_probe,
diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c b/drivers/net/ethernet/hisilicon/hns_mdio.c
index 33f4c483af0f..501eb2090ca6 100644
--- a/drivers/net/ethernet/hisilicon/hns_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
@@ -563,6 +563,7 @@ static const struct of_device_id hns_mdio_match[] = {
563 {.compatible = "hisilicon,hns-mdio"}, 563 {.compatible = "hisilicon,hns-mdio"},
564 {} 564 {}
565}; 565};
566MODULE_DEVICE_TABLE(of, hns_mdio_match);
566 567
567static const struct acpi_device_id hns_mdio_acpi_match[] = { 568static const struct acpi_device_id hns_mdio_acpi_match[] = {
568 { "HISI0141", 0 }, 569 { "HISI0141", 0 },
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index bfe17d9c022d..5f44c5520fbc 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1190,7 +1190,7 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
1190 if (!scrq) 1190 if (!scrq)
1191 return NULL; 1191 return NULL;
1192 1192
1193 scrq->msgs = (union sub_crq *)__get_free_pages(GFP_KERNEL, 2); 1193 scrq->msgs = (union sub_crq *)__get_free_pages(GFP_ATOMIC, 2);
1194 memset(scrq->msgs, 0, 4 * PAGE_SIZE); 1194 memset(scrq->msgs, 0, 4 * PAGE_SIZE);
1195 if (!scrq->msgs) { 1195 if (!scrq->msgs) {
1196 dev_warn(dev, "Couldn't allocate crq queue messages page\n"); 1196 dev_warn(dev, "Couldn't allocate crq queue messages page\n");
@@ -1461,14 +1461,16 @@ static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter)
1461 return rc; 1461 return rc;
1462 1462
1463req_rx_irq_failed: 1463req_rx_irq_failed:
1464 for (j = 0; j < i; j++) 1464 for (j = 0; j < i; j++) {
1465 free_irq(adapter->rx_scrq[j]->irq, adapter->rx_scrq[j]); 1465 free_irq(adapter->rx_scrq[j]->irq, adapter->rx_scrq[j]);
1466 irq_dispose_mapping(adapter->rx_scrq[j]->irq); 1466 irq_dispose_mapping(adapter->rx_scrq[j]->irq);
1467 }
1467 i = adapter->req_tx_queues; 1468 i = adapter->req_tx_queues;
1468req_tx_irq_failed: 1469req_tx_irq_failed:
1469 for (j = 0; j < i; j++) 1470 for (j = 0; j < i; j++) {
1470 free_irq(adapter->tx_scrq[j]->irq, adapter->tx_scrq[j]); 1471 free_irq(adapter->tx_scrq[j]->irq, adapter->tx_scrq[j]);
1471 irq_dispose_mapping(adapter->rx_scrq[j]->irq); 1472 irq_dispose_mapping(adapter->rx_scrq[j]->irq);
1473 }
1472 release_sub_crqs_no_irqs(adapter); 1474 release_sub_crqs_no_irqs(adapter);
1473 return rc; 1475 return rc;
1474} 1476}
@@ -3232,6 +3234,27 @@ static void ibmvnic_free_inflight(struct ibmvnic_adapter *adapter)
3232 spin_unlock_irqrestore(&adapter->inflight_lock, flags); 3234 spin_unlock_irqrestore(&adapter->inflight_lock, flags);
3233} 3235}
3234 3236
3237static void ibmvnic_xport_event(struct work_struct *work)
3238{
3239 struct ibmvnic_adapter *adapter = container_of(work,
3240 struct ibmvnic_adapter,
3241 ibmvnic_xport);
3242 struct device *dev = &adapter->vdev->dev;
3243 long rc;
3244
3245 ibmvnic_free_inflight(adapter);
3246 release_sub_crqs(adapter);
3247 if (adapter->migrated) {
3248 rc = ibmvnic_reenable_crq_queue(adapter);
3249 if (rc)
3250 dev_err(dev, "Error after enable rc=%ld\n", rc);
3251 adapter->migrated = false;
3252 rc = ibmvnic_send_crq_init(adapter);
3253 if (rc)
3254 dev_err(dev, "Error sending init rc=%ld\n", rc);
3255 }
3256}
3257
3235static void ibmvnic_handle_crq(union ibmvnic_crq *crq, 3258static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
3236 struct ibmvnic_adapter *adapter) 3259 struct ibmvnic_adapter *adapter)
3237{ 3260{
@@ -3267,15 +3290,7 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
3267 if (gen_crq->cmd == IBMVNIC_PARTITION_MIGRATED) { 3290 if (gen_crq->cmd == IBMVNIC_PARTITION_MIGRATED) {
3268 dev_info(dev, "Re-enabling adapter\n"); 3291 dev_info(dev, "Re-enabling adapter\n");
3269 adapter->migrated = true; 3292 adapter->migrated = true;
3270 ibmvnic_free_inflight(adapter); 3293 schedule_work(&adapter->ibmvnic_xport);
3271 release_sub_crqs(adapter);
3272 rc = ibmvnic_reenable_crq_queue(adapter);
3273 if (rc)
3274 dev_err(dev, "Error after enable rc=%ld\n", rc);
3275 adapter->migrated = false;
3276 rc = ibmvnic_send_crq_init(adapter);
3277 if (rc)
3278 dev_err(dev, "Error sending init rc=%ld\n", rc);
3279 } else if (gen_crq->cmd == IBMVNIC_DEVICE_FAILOVER) { 3294 } else if (gen_crq->cmd == IBMVNIC_DEVICE_FAILOVER) {
3280 dev_info(dev, "Backing device failover detected\n"); 3295 dev_info(dev, "Backing device failover detected\n");
3281 netif_carrier_off(netdev); 3296 netif_carrier_off(netdev);
@@ -3284,8 +3299,7 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
3284 /* The adapter lost the connection */ 3299 /* The adapter lost the connection */
3285 dev_err(dev, "Virtual Adapter failed (rc=%d)\n", 3300 dev_err(dev, "Virtual Adapter failed (rc=%d)\n",
3286 gen_crq->cmd); 3301 gen_crq->cmd);
3287 ibmvnic_free_inflight(adapter); 3302 schedule_work(&adapter->ibmvnic_xport);
3288 release_sub_crqs(adapter);
3289 } 3303 }
3290 return; 3304 return;
3291 case IBMVNIC_CRQ_CMD_RSP: 3305 case IBMVNIC_CRQ_CMD_RSP:
@@ -3654,6 +3668,7 @@ static void handle_crq_init_rsp(struct work_struct *work)
3654 goto task_failed; 3668 goto task_failed;
3655 3669
3656 netdev->real_num_tx_queues = adapter->req_tx_queues; 3670 netdev->real_num_tx_queues = adapter->req_tx_queues;
3671 netdev->mtu = adapter->req_mtu;
3657 3672
3658 if (adapter->failover) { 3673 if (adapter->failover) {
3659 adapter->failover = false; 3674 adapter->failover = false;
@@ -3725,6 +3740,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
3725 SET_NETDEV_DEV(netdev, &dev->dev); 3740 SET_NETDEV_DEV(netdev, &dev->dev);
3726 3741
3727 INIT_WORK(&adapter->vnic_crq_init, handle_crq_init_rsp); 3742 INIT_WORK(&adapter->vnic_crq_init, handle_crq_init_rsp);
3743 INIT_WORK(&adapter->ibmvnic_xport, ibmvnic_xport_event);
3728 3744
3729 spin_lock_init(&adapter->stats_lock); 3745 spin_lock_init(&adapter->stats_lock);
3730 3746
@@ -3792,6 +3808,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
3792 } 3808 }
3793 3809
3794 netdev->real_num_tx_queues = adapter->req_tx_queues; 3810 netdev->real_num_tx_queues = adapter->req_tx_queues;
3811 netdev->mtu = adapter->req_mtu;
3795 3812
3796 rc = register_netdev(netdev); 3813 rc = register_netdev(netdev);
3797 if (rc) { 3814 if (rc) {
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index bfc84c7d0e11..dd775d951b73 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -27,7 +27,7 @@
27/**************************************************************************/ 27/**************************************************************************/
28 28
29#define IBMVNIC_NAME "ibmvnic" 29#define IBMVNIC_NAME "ibmvnic"
30#define IBMVNIC_DRIVER_VERSION "1.0" 30#define IBMVNIC_DRIVER_VERSION "1.0.1"
31#define IBMVNIC_INVALID_MAP -1 31#define IBMVNIC_INVALID_MAP -1
32#define IBMVNIC_STATS_TIMEOUT 1 32#define IBMVNIC_STATS_TIMEOUT 1
33/* basic structures plus 100 2k buffers */ 33/* basic structures plus 100 2k buffers */
@@ -1048,5 +1048,6 @@ struct ibmvnic_adapter {
1048 u8 map_id; 1048 u8 map_id;
1049 1049
1050 struct work_struct vnic_crq_init; 1050 struct work_struct vnic_crq_init;
1051 struct work_struct ibmvnic_xport;
1051 bool failover; 1052 bool failover;
1052}; 1053};
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 2030d7c1dc94..6d61e443bdf8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -92,6 +92,7 @@
92#define I40E_AQ_LEN 256 92#define I40E_AQ_LEN 256
93#define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */ 93#define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */
94#define I40E_MAX_USER_PRIORITY 8 94#define I40E_MAX_USER_PRIORITY 8
95#define I40E_DEFAULT_TRAFFIC_CLASS BIT(0)
95#define I40E_DEFAULT_MSG_ENABLE 4 96#define I40E_DEFAULT_MSG_ENABLE 4
96#define I40E_QUEUE_WAIT_RETRY_LIMIT 10 97#define I40E_QUEUE_WAIT_RETRY_LIMIT 10
97#define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 16) 98#define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 16)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ac1faee2a5b8..31c97e3937a4 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -4641,29 +4641,6 @@ static u8 i40e_pf_get_num_tc(struct i40e_pf *pf)
4641} 4641}
4642 4642
4643/** 4643/**
4644 * i40e_pf_get_default_tc - Get bitmap for first enabled TC
4645 * @pf: PF being queried
4646 *
4647 * Return a bitmap for first enabled traffic class for this PF.
4648 **/
4649static u8 i40e_pf_get_default_tc(struct i40e_pf *pf)
4650{
4651 u8 enabled_tc = pf->hw.func_caps.enabled_tcmap;
4652 u8 i = 0;
4653
4654 if (!enabled_tc)
4655 return 0x1; /* TC0 */
4656
4657 /* Find the first enabled TC */
4658 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
4659 if (enabled_tc & BIT(i))
4660 break;
4661 }
4662
4663 return BIT(i);
4664}
4665
4666/**
4667 * i40e_pf_get_pf_tc_map - Get bitmap for enabled traffic classes 4644 * i40e_pf_get_pf_tc_map - Get bitmap for enabled traffic classes
4668 * @pf: PF being queried 4645 * @pf: PF being queried
4669 * 4646 *
@@ -4673,7 +4650,7 @@ static u8 i40e_pf_get_tc_map(struct i40e_pf *pf)
4673{ 4650{
4674 /* If DCB is not enabled for this PF then just return default TC */ 4651 /* If DCB is not enabled for this PF then just return default TC */
4675 if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) 4652 if (!(pf->flags & I40E_FLAG_DCB_ENABLED))
4676 return i40e_pf_get_default_tc(pf); 4653 return I40E_DEFAULT_TRAFFIC_CLASS;
4677 4654
4678 /* SFP mode we want PF to be enabled for all TCs */ 4655 /* SFP mode we want PF to be enabled for all TCs */
4679 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) 4656 if (!(pf->flags & I40E_FLAG_MFP_ENABLED))
@@ -4683,7 +4660,7 @@ static u8 i40e_pf_get_tc_map(struct i40e_pf *pf)
4683 if (pf->hw.func_caps.iscsi) 4660 if (pf->hw.func_caps.iscsi)
4684 return i40e_get_iscsi_tc_map(pf); 4661 return i40e_get_iscsi_tc_map(pf);
4685 else 4662 else
4686 return i40e_pf_get_default_tc(pf); 4663 return I40E_DEFAULT_TRAFFIC_CLASS;
4687} 4664}
4688 4665
4689/** 4666/**
@@ -5029,7 +5006,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
5029 if (v == pf->lan_vsi) 5006 if (v == pf->lan_vsi)
5030 tc_map = i40e_pf_get_tc_map(pf); 5007 tc_map = i40e_pf_get_tc_map(pf);
5031 else 5008 else
5032 tc_map = i40e_pf_get_default_tc(pf); 5009 tc_map = I40E_DEFAULT_TRAFFIC_CLASS;
5033#ifdef I40E_FCOE 5010#ifdef I40E_FCOE
5034 if (pf->vsi[v]->type == I40E_VSI_FCOE) 5011 if (pf->vsi[v]->type == I40E_VSI_FCOE)
5035 tc_map = i40e_get_fcoe_tc_map(pf); 5012 tc_map = i40e_get_fcoe_tc_map(pf);
@@ -5717,7 +5694,7 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
5717 u8 type; 5694 u8 type;
5718 5695
5719 /* Not DCB capable or capability disabled */ 5696 /* Not DCB capable or capability disabled */
5720 if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) 5697 if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
5721 return ret; 5698 return ret;
5722 5699
5723 /* Ignore if event is not for Nearest Bridge */ 5700 /* Ignore if event is not for Nearest Bridge */
@@ -7707,6 +7684,7 @@ static int i40e_init_msix(struct i40e_pf *pf)
7707 pf->flags &= ~I40E_FLAG_MSIX_ENABLED; 7684 pf->flags &= ~I40E_FLAG_MSIX_ENABLED;
7708 kfree(pf->msix_entries); 7685 kfree(pf->msix_entries);
7709 pf->msix_entries = NULL; 7686 pf->msix_entries = NULL;
7687 pci_disable_msix(pf->pdev);
7710 return -ENODEV; 7688 return -ENODEV;
7711 7689
7712 } else if (v_actual == I40E_MIN_MSIX) { 7690 } else if (v_actual == I40E_MIN_MSIX) {
@@ -9056,7 +9034,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
9056 return 0; 9034 return 0;
9057 9035
9058 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, veb->bridge_mode, 9036 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, veb->bridge_mode,
9059 nlflags, 0, 0, filter_mask, NULL); 9037 0, 0, nlflags, filter_mask, NULL);
9060} 9038}
9061 9039
9062/* Hardware supports L4 tunnel length of 128B (=2^7) which includes 9040/* Hardware supports L4 tunnel length of 128B (=2^7) which includes
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a244d9a67264..bd93d823cc25 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -9135,10 +9135,14 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
9135 goto fwd_add_err; 9135 goto fwd_add_err;
9136 fwd_adapter->pool = pool; 9136 fwd_adapter->pool = pool;
9137 fwd_adapter->real_adapter = adapter; 9137 fwd_adapter->real_adapter = adapter;
9138 err = ixgbe_fwd_ring_up(vdev, fwd_adapter); 9138
9139 if (err) 9139 if (netif_running(pdev)) {
9140 goto fwd_add_err; 9140 err = ixgbe_fwd_ring_up(vdev, fwd_adapter);
9141 netif_tx_start_all_queues(vdev); 9141 if (err)
9142 goto fwd_add_err;
9143 netif_tx_start_all_queues(vdev);
9144 }
9145
9142 return fwd_adapter; 9146 return fwd_adapter;
9143fwd_add_err: 9147fwd_add_err:
9144 /* unwind counter and free adapter struct */ 9148 /* unwind counter and free adapter struct */
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 55831188bc32..bf5cc55ba24c 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2968,6 +2968,22 @@ static void set_params(struct mv643xx_eth_private *mp,
2968 mp->txq_count = pd->tx_queue_count ? : 1; 2968 mp->txq_count = pd->tx_queue_count ? : 1;
2969} 2969}
2970 2970
2971static int get_phy_mode(struct mv643xx_eth_private *mp)
2972{
2973 struct device *dev = mp->dev->dev.parent;
2974 int iface = -1;
2975
2976 if (dev->of_node)
2977 iface = of_get_phy_mode(dev->of_node);
2978
2979 /* Historical default if unspecified. We could also read/write
2980 * the interface state in the PSC1
2981 */
2982 if (iface < 0)
2983 iface = PHY_INTERFACE_MODE_GMII;
2984 return iface;
2985}
2986
2971static struct phy_device *phy_scan(struct mv643xx_eth_private *mp, 2987static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
2972 int phy_addr) 2988 int phy_addr)
2973{ 2989{
@@ -2994,7 +3010,7 @@ static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
2994 "orion-mdio-mii", addr); 3010 "orion-mdio-mii", addr);
2995 3011
2996 phydev = phy_connect(mp->dev, phy_id, mv643xx_eth_adjust_link, 3012 phydev = phy_connect(mp->dev, phy_id, mv643xx_eth_adjust_link,
2997 PHY_INTERFACE_MODE_GMII); 3013 get_phy_mode(mp));
2998 if (!IS_ERR(phydev)) { 3014 if (!IS_ERR(phydev)) {
2999 phy_addr_set(mp, addr); 3015 phy_addr_set(mp, addr);
3000 break; 3016 break;
@@ -3090,6 +3106,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
3090 if (!dev) 3106 if (!dev)
3091 return -ENOMEM; 3107 return -ENOMEM;
3092 3108
3109 SET_NETDEV_DEV(dev, &pdev->dev);
3093 mp = netdev_priv(dev); 3110 mp = netdev_priv(dev);
3094 platform_set_drvdata(pdev, mp); 3111 platform_set_drvdata(pdev, mp);
3095 3112
@@ -3129,7 +3146,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
3129 if (pd->phy_node) { 3146 if (pd->phy_node) {
3130 mp->phy = of_phy_connect(mp->dev, pd->phy_node, 3147 mp->phy = of_phy_connect(mp->dev, pd->phy_node,
3131 mv643xx_eth_adjust_link, 0, 3148 mv643xx_eth_adjust_link, 0,
3132 PHY_INTERFACE_MODE_GMII); 3149 get_phy_mode(mp));
3133 if (!mp->phy) 3150 if (!mp->phy)
3134 err = -ENODEV; 3151 err = -ENODEV;
3135 else 3152 else
@@ -3187,8 +3204,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
3187 dev->priv_flags |= IFF_UNICAST_FLT; 3204 dev->priv_flags |= IFF_UNICAST_FLT;
3188 dev->gso_max_segs = MV643XX_MAX_TSO_SEGS; 3205 dev->gso_max_segs = MV643XX_MAX_TSO_SEGS;
3189 3206
3190 SET_NETDEV_DEV(dev, &pdev->dev);
3191
3192 if (mp->shared->win_protect) 3207 if (mp->shared->win_protect)
3193 wrl(mp, WINDOW_PROTECT(mp->port_num), mp->shared->win_protect); 3208 wrl(mp, WINDOW_PROTECT(mp->port_num), mp->shared->win_protect);
3194 3209
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index b1cef7a0f7ca..e36bebcab3f2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2469,6 +2469,7 @@ err_comm_admin:
2469 kfree(priv->mfunc.master.slave_state); 2469 kfree(priv->mfunc.master.slave_state);
2470err_comm: 2470err_comm:
2471 iounmap(priv->mfunc.comm); 2471 iounmap(priv->mfunc.comm);
2472 priv->mfunc.comm = NULL;
2472err_vhcr: 2473err_vhcr:
2473 dma_free_coherent(&dev->persist->pdev->dev, PAGE_SIZE, 2474 dma_free_coherent(&dev->persist->pdev->dev, PAGE_SIZE,
2474 priv->mfunc.vhcr, 2475 priv->mfunc.vhcr,
@@ -2537,6 +2538,13 @@ void mlx4_report_internal_err_comm_event(struct mlx4_dev *dev)
2537 int slave; 2538 int slave;
2538 u32 slave_read; 2539 u32 slave_read;
2539 2540
2541 /* If the comm channel has not yet been initialized,
2542 * skip reporting the internal error event to all
2543 * the communication channels.
2544 */
2545 if (!priv->mfunc.comm)
2546 return;
2547
2540 /* Report an internal error event to all 2548 /* Report an internal error event to all
2541 * communication channels. 2549 * communication channels.
2542 */ 2550 */
@@ -2571,6 +2579,7 @@ void mlx4_multi_func_cleanup(struct mlx4_dev *dev)
2571 } 2579 }
2572 2580
2573 iounmap(priv->mfunc.comm); 2581 iounmap(priv->mfunc.comm);
2582 priv->mfunc.comm = NULL;
2574} 2583}
2575 2584
2576void mlx4_cmd_cleanup(struct mlx4_dev *dev, int cleanup_mask) 2585void mlx4_cmd_cleanup(struct mlx4_dev *dev, int cleanup_mask)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 08fc5fc56d43..a5fc46bbcbe2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -245,8 +245,11 @@ 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 =
249 roundup_pow_of_two(max_val_cycles) > max_val_cycles ?
250 roundup_pow_of_two(max_val_cycles) - 1 : UINT_MAX;
248 u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ? 251 u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ?
249 max_val_cycles : roundup_pow_of_two(max_val_cycles) - 1; 252 max_val_cycles : tmp_rounded;
250 /* calculate max possible multiplier in order to fit in 64bit */ 253 /* calculate max possible multiplier in order to fit in 64bit */
251 u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded); 254 u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded);
252 255
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
index 132cea655920..e3be7e44ff51 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
@@ -127,7 +127,15 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
127 /* For TX we use the same irq per 127 /* For TX we use the same irq per
128 ring we assigned for the RX */ 128 ring we assigned for the RX */
129 struct mlx4_en_cq *rx_cq; 129 struct mlx4_en_cq *rx_cq;
130 130 int xdp_index;
131
132 /* The xdp tx irq must align with the rx ring that forwards to
133 * it, so reindex these from 0. This should only happen when
134 * tx_ring_num is not a multiple of rx_ring_num.
135 */
136 xdp_index = (priv->xdp_ring_num - priv->tx_ring_num) + cq_idx;
137 if (xdp_index >= 0)
138 cq_idx = xdp_index;
131 cq_idx = cq_idx % priv->rx_ring_num; 139 cq_idx = cq_idx % priv->rx_ring_num;
132 rx_cq = priv->rx_cq[cq_idx]; 140 rx_cq = priv->rx_cq[cq_idx];
133 cq->vector = rx_cq->vector; 141 cq->vector = rx_cq->vector;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 7e703bed7b82..12c99a2655f2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1733,6 +1733,13 @@ int mlx4_en_start_port(struct net_device *dev)
1733 udp_tunnel_get_rx_info(dev); 1733 udp_tunnel_get_rx_info(dev);
1734 1734
1735 priv->port_up = true; 1735 priv->port_up = true;
1736
1737 /* Process all completions if exist to prevent
1738 * the queues freezing if they are full
1739 */
1740 for (i = 0; i < priv->rx_ring_num; i++)
1741 napi_schedule(&priv->rx_cq[i]->napi);
1742
1736 netif_tx_start_all_queues(dev); 1743 netif_tx_start_all_queues(dev);
1737 netif_device_attach(dev); 1744 netif_device_attach(dev);
1738 1745
@@ -1910,8 +1917,9 @@ static void mlx4_en_clear_stats(struct net_device *dev)
1910 struct mlx4_en_dev *mdev = priv->mdev; 1917 struct mlx4_en_dev *mdev = priv->mdev;
1911 int i; 1918 int i;
1912 1919
1913 if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1)) 1920 if (!mlx4_is_slave(mdev->dev))
1914 en_dbg(HW, priv, "Failed dumping statistics\n"); 1921 if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1))
1922 en_dbg(HW, priv, "Failed dumping statistics\n");
1915 1923
1916 memset(&priv->pstats, 0, sizeof(priv->pstats)); 1924 memset(&priv->pstats, 0, sizeof(priv->pstats));
1917 memset(&priv->pkstats, 0, sizeof(priv->pkstats)); 1925 memset(&priv->pkstats, 0, sizeof(priv->pkstats));
@@ -2194,6 +2202,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2194 2202
2195 if (!shutdown) 2203 if (!shutdown)
2196 free_netdev(dev); 2204 free_netdev(dev);
2205 dev->ethtool_ops = NULL;
2197} 2206}
2198 2207
2199static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) 2208static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 5aa8b751f417..59473a0ebcdf 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -166,7 +166,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
166 return PTR_ERR(mailbox); 166 return PTR_ERR(mailbox);
167 err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, in_mod, 0, 167 err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, in_mod, 0,
168 MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B, 168 MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B,
169 MLX4_CMD_WRAPPED); 169 MLX4_CMD_NATIVE);
170 if (err) 170 if (err)
171 goto out; 171 goto out;
172 172
@@ -322,7 +322,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
322 err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, 322 err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma,
323 in_mod | MLX4_DUMP_ETH_STATS_FLOW_CONTROL, 323 in_mod | MLX4_DUMP_ETH_STATS_FLOW_CONTROL,
324 0, MLX4_CMD_DUMP_ETH_STATS, 324 0, MLX4_CMD_DUMP_ETH_STATS,
325 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); 325 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
326 if (err) 326 if (err)
327 goto out; 327 goto out;
328 } 328 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
index b66e03d9711f..c06346a82496 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
@@ -118,6 +118,29 @@ mlx4_en_test_loopback_exit:
118 return !loopback_ok; 118 return !loopback_ok;
119} 119}
120 120
121static int mlx4_en_test_interrupts(struct mlx4_en_priv *priv)
122{
123 struct mlx4_en_dev *mdev = priv->mdev;
124 int err = 0;
125 int i = 0;
126
127 err = mlx4_test_async(mdev->dev);
128 /* When not in MSI_X or slave, test only async */
129 if (!(mdev->dev->flags & MLX4_FLAG_MSI_X) || mlx4_is_slave(mdev->dev))
130 return err;
131
132 /* A loop over all completion vectors of current port,
133 * for each vector check whether it works by mapping command
134 * completions to that vector and performing a NOP command
135 */
136 for (i = 0; i < priv->rx_ring_num; i++) {
137 err = mlx4_test_interrupt(mdev->dev, priv->rx_cq[i]->vector);
138 if (err)
139 break;
140 }
141
142 return err;
143}
121 144
122static int mlx4_en_test_link(struct mlx4_en_priv *priv) 145static int mlx4_en_test_link(struct mlx4_en_priv *priv)
123{ 146{
@@ -151,7 +174,6 @@ static int mlx4_en_test_speed(struct mlx4_en_priv *priv)
151void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf) 174void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf)
152{ 175{
153 struct mlx4_en_priv *priv = netdev_priv(dev); 176 struct mlx4_en_priv *priv = netdev_priv(dev);
154 struct mlx4_en_dev *mdev = priv->mdev;
155 int i, carrier_ok; 177 int i, carrier_ok;
156 178
157 memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST); 179 memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST);
@@ -177,7 +199,7 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf)
177 netif_carrier_on(dev); 199 netif_carrier_on(dev);
178 200
179 } 201 }
180 buf[0] = mlx4_test_interrupts(mdev->dev); 202 buf[0] = mlx4_en_test_interrupts(priv);
181 buf[1] = mlx4_en_test_link(priv); 203 buf[1] = mlx4_en_test_link(priv);
182 buf[2] = mlx4_en_test_speed(priv); 204 buf[2] = mlx4_en_test_speed(priv);
183 205
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index cf8f8a72a801..cd3638e6fe25 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1361,53 +1361,49 @@ void mlx4_cleanup_eq_table(struct mlx4_dev *dev)
1361 kfree(priv->eq_table.uar_map); 1361 kfree(priv->eq_table.uar_map);
1362} 1362}
1363 1363
1364/* A test that verifies that we can accept interrupts on all 1364/* A test that verifies that we can accept interrupts
1365 * the irq vectors of the device. 1365 * on the vector allocated for asynchronous events
1366 */
1367int mlx4_test_async(struct mlx4_dev *dev)
1368{
1369 return mlx4_NOP(dev);
1370}
1371EXPORT_SYMBOL(mlx4_test_async);
1372
1373/* A test that verifies that we can accept interrupts
1374 * on the given irq vector of the tested port.
1366 * Interrupts are checked using the NOP command. 1375 * Interrupts are checked using the NOP command.
1367 */ 1376 */
1368int mlx4_test_interrupts(struct mlx4_dev *dev) 1377int mlx4_test_interrupt(struct mlx4_dev *dev, int vector)
1369{ 1378{
1370 struct mlx4_priv *priv = mlx4_priv(dev); 1379 struct mlx4_priv *priv = mlx4_priv(dev);
1371 int i;
1372 int err; 1380 int err;
1373 1381
1374 err = mlx4_NOP(dev); 1382 /* Temporary use polling for command completions */
1375 /* When not in MSI_X, there is only one irq to check */ 1383 mlx4_cmd_use_polling(dev);
1376 if (!(dev->flags & MLX4_FLAG_MSI_X) || mlx4_is_slave(dev))
1377 return err;
1378
1379 /* A loop over all completion vectors, for each vector we will check
1380 * whether it works by mapping command completions to that vector
1381 * and performing a NOP command
1382 */
1383 for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) {
1384 /* Make sure request_irq was called */
1385 if (!priv->eq_table.eq[i].have_irq)
1386 continue;
1387
1388 /* Temporary use polling for command completions */
1389 mlx4_cmd_use_polling(dev);
1390
1391 /* Map the new eq to handle all asynchronous events */
1392 err = mlx4_MAP_EQ(dev, get_async_ev_mask(dev), 0,
1393 priv->eq_table.eq[i].eqn);
1394 if (err) {
1395 mlx4_warn(dev, "Failed mapping eq for interrupt test\n");
1396 mlx4_cmd_use_events(dev);
1397 break;
1398 }
1399 1384
1400 /* Go back to using events */ 1385 /* Map the new eq to handle all asynchronous events */
1401 mlx4_cmd_use_events(dev); 1386 err = mlx4_MAP_EQ(dev, get_async_ev_mask(dev), 0,
1402 err = mlx4_NOP(dev); 1387 priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(vector)].eqn);
1388 if (err) {
1389 mlx4_warn(dev, "Failed mapping eq for interrupt test\n");
1390 goto out;
1403 } 1391 }
1404 1392
1393 /* Go back to using events */
1394 mlx4_cmd_use_events(dev);
1395 err = mlx4_NOP(dev);
1396
1405 /* Return to default */ 1397 /* Return to default */
1398 mlx4_cmd_use_polling(dev);
1399out:
1406 mlx4_MAP_EQ(dev, get_async_ev_mask(dev), 0, 1400 mlx4_MAP_EQ(dev, get_async_ev_mask(dev), 0,
1407 priv->eq_table.eq[MLX4_EQ_ASYNC].eqn); 1401 priv->eq_table.eq[MLX4_EQ_ASYNC].eqn);
1402 mlx4_cmd_use_events(dev);
1403
1408 return err; 1404 return err;
1409} 1405}
1410EXPORT_SYMBOL(mlx4_test_interrupts); 1406EXPORT_SYMBOL(mlx4_test_interrupt);
1411 1407
1412bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector) 1408bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector)
1413{ 1409{
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index c41ab31a39f8..84bab9f0732e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -49,9 +49,9 @@ enum {
49extern void __buggy_use_of_MLX4_GET(void); 49extern void __buggy_use_of_MLX4_GET(void);
50extern void __buggy_use_of_MLX4_PUT(void); 50extern void __buggy_use_of_MLX4_PUT(void);
51 51
52static bool enable_qos = true; 52static bool enable_qos;
53module_param(enable_qos, bool, 0444); 53module_param(enable_qos, bool, 0444);
54MODULE_PARM_DESC(enable_qos, "Enable Enhanced QoS support (default: on)"); 54MODULE_PARM_DESC(enable_qos, "Enable Enhanced QoS support (default: off)");
55 55
56#define MLX4_GET(dest, source, offset) \ 56#define MLX4_GET(dest, source, offset) \
57 do { \ 57 do { \
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 7183ac4135d2..6f4e67bc3538 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1102,6 +1102,14 @@ static int __set_port_type(struct mlx4_port_info *info,
1102 int i; 1102 int i;
1103 int err = 0; 1103 int err = 0;
1104 1104
1105 if ((port_type & mdev->caps.supported_type[info->port]) != port_type) {
1106 mlx4_err(mdev,
1107 "Requested port type for port %d is not supported on this HCA\n",
1108 info->port);
1109 err = -EINVAL;
1110 goto err_sup;
1111 }
1112
1105 mlx4_stop_sense(mdev); 1113 mlx4_stop_sense(mdev);
1106 mutex_lock(&priv->port_mutex); 1114 mutex_lock(&priv->port_mutex);
1107 info->tmp_type = port_type; 1115 info->tmp_type = port_type;
@@ -1147,7 +1155,7 @@ static int __set_port_type(struct mlx4_port_info *info,
1147out: 1155out:
1148 mlx4_start_sense(mdev); 1156 mlx4_start_sense(mdev);
1149 mutex_unlock(&priv->port_mutex); 1157 mutex_unlock(&priv->port_mutex);
1150 1158err_sup:
1151 return err; 1159 return err;
1152} 1160}
1153 1161
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index e4878f31e45d..88ee7d8a5923 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -145,9 +145,10 @@ enum mlx4_resource {
145 RES_MTT, 145 RES_MTT,
146 RES_MAC, 146 RES_MAC,
147 RES_VLAN, 147 RES_VLAN,
148 RES_EQ, 148 RES_NPORT_ID,
149 RES_COUNTER, 149 RES_COUNTER,
150 RES_FS_RULE, 150 RES_FS_RULE,
151 RES_EQ,
151 MLX4_NUM_OF_RESOURCE_TYPE 152 MLX4_NUM_OF_RESOURCE_TYPE
152}; 153};
153 154
@@ -1329,8 +1330,6 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
1329 struct mlx4_cmd_info *cmd); 1330 struct mlx4_cmd_info *cmd);
1330int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function, 1331int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
1331 int port, void *buf); 1332 int port, void *buf);
1332int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
1333 struct mlx4_cmd_mailbox *outbox);
1334int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, 1333int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
1335 struct mlx4_vhcr *vhcr, 1334 struct mlx4_vhcr *vhcr,
1336 struct mlx4_cmd_mailbox *inbox, 1335 struct mlx4_cmd_mailbox *inbox,
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index c5b2064297a1..b656dd5772e5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -1728,24 +1728,13 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
1728 return err; 1728 return err;
1729} 1729}
1730 1730
1731int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave,
1732 u32 in_mod, struct mlx4_cmd_mailbox *outbox)
1733{
1734 return mlx4_cmd_box(dev, 0, outbox->dma, in_mod, 0,
1735 MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B,
1736 MLX4_CMD_NATIVE);
1737}
1738
1739int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, 1731int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
1740 struct mlx4_vhcr *vhcr, 1732 struct mlx4_vhcr *vhcr,
1741 struct mlx4_cmd_mailbox *inbox, 1733 struct mlx4_cmd_mailbox *inbox,
1742 struct mlx4_cmd_mailbox *outbox, 1734 struct mlx4_cmd_mailbox *outbox,
1743 struct mlx4_cmd_info *cmd) 1735 struct mlx4_cmd_info *cmd)
1744{ 1736{
1745 if (slave != dev->caps.function) 1737 return 0;
1746 return 0;
1747 return mlx4_common_dump_eth_stats(dev, slave,
1748 vhcr->in_modifier, outbox);
1749} 1738}
1750 1739
1751int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, 1740int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid,
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 84d7857ccc27..c548beaaf910 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -1605,13 +1605,14 @@ static int eq_res_start_move_to(struct mlx4_dev *dev, int slave, int index,
1605 r->com.from_state = r->com.state; 1605 r->com.from_state = r->com.state;
1606 r->com.to_state = state; 1606 r->com.to_state = state;
1607 r->com.state = RES_EQ_BUSY; 1607 r->com.state = RES_EQ_BUSY;
1608 if (eq)
1609 *eq = r;
1610 } 1608 }
1611 } 1609 }
1612 1610
1613 spin_unlock_irq(mlx4_tlock(dev)); 1611 spin_unlock_irq(mlx4_tlock(dev));
1614 1612
1613 if (!err && eq)
1614 *eq = r;
1615
1615 return err; 1616 return err;
1616} 1617}
1617 1618
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
index 6cb38304669f..2c6e3c7b7417 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
@@ -41,6 +41,13 @@
41 41
42#include "mlx5_core.h" 42#include "mlx5_core.h"
43 43
44struct mlx5_db_pgdir {
45 struct list_head list;
46 unsigned long *bitmap;
47 __be32 *db_page;
48 dma_addr_t db_dma;
49};
50
44/* Handling for queue buffers -- we allocate a bunch of memory and 51/* Handling for queue buffers -- we allocate a bunch of memory and
45 * register it in a memory region at HCA virtual address 0. 52 * register it in a memory region at HCA virtual address 0.
46 */ 53 */
@@ -102,17 +109,28 @@ EXPORT_SYMBOL_GPL(mlx5_buf_free);
102static struct mlx5_db_pgdir *mlx5_alloc_db_pgdir(struct mlx5_core_dev *dev, 109static struct mlx5_db_pgdir *mlx5_alloc_db_pgdir(struct mlx5_core_dev *dev,
103 int node) 110 int node)
104{ 111{
112 u32 db_per_page = PAGE_SIZE / cache_line_size();
105 struct mlx5_db_pgdir *pgdir; 113 struct mlx5_db_pgdir *pgdir;
106 114
107 pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); 115 pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL);
108 if (!pgdir) 116 if (!pgdir)
109 return NULL; 117 return NULL;
110 118
111 bitmap_fill(pgdir->bitmap, MLX5_DB_PER_PAGE); 119 pgdir->bitmap = kcalloc(BITS_TO_LONGS(db_per_page),
120 sizeof(unsigned long),
121 GFP_KERNEL);
122
123 if (!pgdir->bitmap) {
124 kfree(pgdir);
125 return NULL;
126 }
127
128 bitmap_fill(pgdir->bitmap, db_per_page);
112 129
113 pgdir->db_page = mlx5_dma_zalloc_coherent_node(dev, PAGE_SIZE, 130 pgdir->db_page = mlx5_dma_zalloc_coherent_node(dev, PAGE_SIZE,
114 &pgdir->db_dma, node); 131 &pgdir->db_dma, node);
115 if (!pgdir->db_page) { 132 if (!pgdir->db_page) {
133 kfree(pgdir->bitmap);
116 kfree(pgdir); 134 kfree(pgdir);
117 return NULL; 135 return NULL;
118 } 136 }
@@ -123,18 +141,19 @@ static struct mlx5_db_pgdir *mlx5_alloc_db_pgdir(struct mlx5_core_dev *dev,
123static int mlx5_alloc_db_from_pgdir(struct mlx5_db_pgdir *pgdir, 141static int mlx5_alloc_db_from_pgdir(struct mlx5_db_pgdir *pgdir,
124 struct mlx5_db *db) 142 struct mlx5_db *db)
125{ 143{
144 u32 db_per_page = PAGE_SIZE / cache_line_size();
126 int offset; 145 int offset;
127 int i; 146 int i;
128 147
129 i = find_first_bit(pgdir->bitmap, MLX5_DB_PER_PAGE); 148 i = find_first_bit(pgdir->bitmap, db_per_page);
130 if (i >= MLX5_DB_PER_PAGE) 149 if (i >= db_per_page)
131 return -ENOMEM; 150 return -ENOMEM;
132 151
133 __clear_bit(i, pgdir->bitmap); 152 __clear_bit(i, pgdir->bitmap);
134 153
135 db->u.pgdir = pgdir; 154 db->u.pgdir = pgdir;
136 db->index = i; 155 db->index = i;
137 offset = db->index * L1_CACHE_BYTES; 156 offset = db->index * cache_line_size();
138 db->db = pgdir->db_page + offset / sizeof(*pgdir->db_page); 157 db->db = pgdir->db_page + offset / sizeof(*pgdir->db_page);
139 db->dma = pgdir->db_dma + offset; 158 db->dma = pgdir->db_dma + offset;
140 159
@@ -181,14 +200,16 @@ EXPORT_SYMBOL_GPL(mlx5_db_alloc);
181 200
182void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db) 201void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db)
183{ 202{
203 u32 db_per_page = PAGE_SIZE / cache_line_size();
184 mutex_lock(&dev->priv.pgdir_mutex); 204 mutex_lock(&dev->priv.pgdir_mutex);
185 205
186 __set_bit(db->index, db->u.pgdir->bitmap); 206 __set_bit(db->index, db->u.pgdir->bitmap);
187 207
188 if (bitmap_full(db->u.pgdir->bitmap, MLX5_DB_PER_PAGE)) { 208 if (bitmap_full(db->u.pgdir->bitmap, db_per_page)) {
189 dma_free_coherent(&(dev->pdev->dev), PAGE_SIZE, 209 dma_free_coherent(&(dev->pdev->dev), PAGE_SIZE,
190 db->u.pgdir->db_page, db->u.pgdir->db_dma); 210 db->u.pgdir->db_page, db->u.pgdir->db_dma);
191 list_del(&db->u.pgdir->list); 211 list_del(&db->u.pgdir->list);
212 kfree(db->u.pgdir->bitmap);
192 kfree(db->u.pgdir); 213 kfree(db->u.pgdir);
193 } 214 }
194 215
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 460363b66cb1..7a43502a89cc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -85,6 +85,9 @@
85#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) 85#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128)
86 86
87#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024) 87#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024)
88#define MLX5E_DEFAULT_LRO_TIMEOUT 32
89#define MLX5E_LRO_TIMEOUT_ARR_SIZE 4
90
88#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10 91#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10
89#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3 92#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3
90#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20 93#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20
@@ -221,6 +224,7 @@ struct mlx5e_params {
221 struct ieee_ets ets; 224 struct ieee_ets ets;
222#endif 225#endif
223 bool rx_am_enabled; 226 bool rx_am_enabled;
227 u32 lro_timeout;
224}; 228};
225 229
226struct mlx5e_tstamp { 230struct mlx5e_tstamp {
@@ -888,5 +892,6 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
888void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev); 892void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
889struct rtnl_link_stats64 * 893struct rtnl_link_stats64 *
890mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats); 894mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
895u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
891 896
892#endif /* __MLX5_EN_H__ */ 897#endif /* __MLX5_EN_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7eaf38020a8f..f4c687ce4c59 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1971,9 +1971,7 @@ static void mlx5e_build_tir_ctx_lro(void *tirc, struct mlx5e_priv *priv)
1971 MLX5_SET(tirc, tirc, lro_max_ip_payload_size, 1971 MLX5_SET(tirc, tirc, lro_max_ip_payload_size,
1972 (priv->params.lro_wqe_sz - 1972 (priv->params.lro_wqe_sz -
1973 ROUGH_MAX_L2_L3_HDR_SZ) >> 8); 1973 ROUGH_MAX_L2_L3_HDR_SZ) >> 8);
1974 MLX5_SET(tirc, tirc, lro_timeout_period_usecs, 1974 MLX5_SET(tirc, tirc, lro_timeout_period_usecs, priv->params.lro_timeout);
1975 MLX5_CAP_ETH(priv->mdev,
1976 lro_timer_supported_periods[2]));
1977} 1975}
1978 1976
1979void mlx5e_build_tir_ctx_hash(void *tirc, struct mlx5e_priv *priv) 1977void mlx5e_build_tir_ctx_hash(void *tirc, struct mlx5e_priv *priv)
@@ -3401,6 +3399,18 @@ static void mlx5e_query_min_inline(struct mlx5_core_dev *mdev,
3401 } 3399 }
3402} 3400}
3403 3401
3402u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
3403{
3404 int i;
3405
3406 /* The supported periods are organized in ascending order */
3407 for (i = 0; i < MLX5E_LRO_TIMEOUT_ARR_SIZE - 1; i++)
3408 if (MLX5_CAP_ETH(mdev, lro_timer_supported_periods[i]) >= wanted_timeout)
3409 break;
3410
3411 return MLX5_CAP_ETH(mdev, lro_timer_supported_periods[i]);
3412}
3413
3404static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev, 3414static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
3405 struct net_device *netdev, 3415 struct net_device *netdev,
3406 const struct mlx5e_profile *profile, 3416 const struct mlx5e_profile *profile,
@@ -3419,6 +3429,9 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
3419 priv->profile = profile; 3429 priv->profile = profile;
3420 priv->ppriv = ppriv; 3430 priv->ppriv = ppriv;
3421 3431
3432 priv->params.lro_timeout =
3433 mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
3434
3422 priv->params.log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE; 3435 priv->params.log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
3423 3436
3424 /* set CQE compression */ 3437 /* set CQE compression */
@@ -4035,7 +4048,6 @@ void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv)
4035 const struct mlx5e_profile *profile = priv->profile; 4048 const struct mlx5e_profile *profile = priv->profile;
4036 struct net_device *netdev = priv->netdev; 4049 struct net_device *netdev = priv->netdev;
4037 4050
4038 unregister_netdev(netdev);
4039 destroy_workqueue(priv->wq); 4051 destroy_workqueue(priv->wq);
4040 if (profile->cleanup) 4052 if (profile->cleanup)
4041 profile->cleanup(priv); 4053 profile->cleanup(priv);
@@ -4052,6 +4064,7 @@ static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv)
4052 for (vport = 1; vport < total_vfs; vport++) 4064 for (vport = 1; vport < total_vfs; vport++)
4053 mlx5_eswitch_unregister_vport_rep(esw, vport); 4065 mlx5_eswitch_unregister_vport_rep(esw, vport);
4054 4066
4067 unregister_netdev(priv->netdev);
4055 mlx5e_detach(mdev, vpriv); 4068 mlx5e_detach(mdev, vpriv);
4056 mlx5e_destroy_netdev(mdev, priv); 4069 mlx5e_destroy_netdev(mdev, priv);
4057} 4070}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 3c97da103d30..7fe6559e4ab3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -457,6 +457,7 @@ void mlx5e_vport_rep_unload(struct mlx5_eswitch *esw,
457 struct mlx5e_priv *priv = rep->priv_data; 457 struct mlx5e_priv *priv = rep->priv_data;
458 struct net_device *netdev = priv->netdev; 458 struct net_device *netdev = priv->netdev;
459 459
460 unregister_netdev(netdev);
460 mlx5e_detach_netdev(esw->dev, netdev); 461 mlx5e_detach_netdev(esw->dev, netdev);
461 mlx5e_destroy_netdev(esw->dev, priv); 462 mlx5e_destroy_netdev(esw->dev, priv);
462} 463}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index abbf2c369923..be1f7333ab7f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -931,8 +931,8 @@ static void esw_vport_change_handler(struct work_struct *work)
931 mutex_unlock(&esw->state_lock); 931 mutex_unlock(&esw->state_lock);
932} 932}
933 933
934static void esw_vport_enable_egress_acl(struct mlx5_eswitch *esw, 934static int esw_vport_enable_egress_acl(struct mlx5_eswitch *esw,
935 struct mlx5_vport *vport) 935 struct mlx5_vport *vport)
936{ 936{
937 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 937 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
938 struct mlx5_flow_group *vlan_grp = NULL; 938 struct mlx5_flow_group *vlan_grp = NULL;
@@ -949,9 +949,11 @@ static void esw_vport_enable_egress_acl(struct mlx5_eswitch *esw,
949 int table_size = 2; 949 int table_size = 2;
950 int err = 0; 950 int err = 0;
951 951
952 if (!MLX5_CAP_ESW_EGRESS_ACL(dev, ft_support) || 952 if (!MLX5_CAP_ESW_EGRESS_ACL(dev, ft_support))
953 !IS_ERR_OR_NULL(vport->egress.acl)) 953 return -EOPNOTSUPP;
954 return; 954
955 if (!IS_ERR_OR_NULL(vport->egress.acl))
956 return 0;
955 957
956 esw_debug(dev, "Create vport[%d] egress ACL log_max_size(%d)\n", 958 esw_debug(dev, "Create vport[%d] egress ACL log_max_size(%d)\n",
957 vport->vport, MLX5_CAP_ESW_EGRESS_ACL(dev, log_max_ft_size)); 959 vport->vport, MLX5_CAP_ESW_EGRESS_ACL(dev, log_max_ft_size));
@@ -959,12 +961,12 @@ static void esw_vport_enable_egress_acl(struct mlx5_eswitch *esw,
959 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_EGRESS); 961 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_EGRESS);
960 if (!root_ns) { 962 if (!root_ns) {
961 esw_warn(dev, "Failed to get E-Switch egress flow namespace\n"); 963 esw_warn(dev, "Failed to get E-Switch egress flow namespace\n");
962 return; 964 return -EIO;
963 } 965 }
964 966
965 flow_group_in = mlx5_vzalloc(inlen); 967 flow_group_in = mlx5_vzalloc(inlen);
966 if (!flow_group_in) 968 if (!flow_group_in)
967 return; 969 return -ENOMEM;
968 970
969 acl = mlx5_create_vport_flow_table(root_ns, 0, table_size, 0, vport->vport); 971 acl = mlx5_create_vport_flow_table(root_ns, 0, table_size, 0, vport->vport);
970 if (IS_ERR(acl)) { 972 if (IS_ERR(acl)) {
@@ -1009,6 +1011,7 @@ out:
1009 mlx5_destroy_flow_group(vlan_grp); 1011 mlx5_destroy_flow_group(vlan_grp);
1010 if (err && !IS_ERR_OR_NULL(acl)) 1012 if (err && !IS_ERR_OR_NULL(acl))
1011 mlx5_destroy_flow_table(acl); 1013 mlx5_destroy_flow_table(acl);
1014 return err;
1012} 1015}
1013 1016
1014static void esw_vport_cleanup_egress_rules(struct mlx5_eswitch *esw, 1017static void esw_vport_cleanup_egress_rules(struct mlx5_eswitch *esw,
@@ -1041,8 +1044,8 @@ static void esw_vport_disable_egress_acl(struct mlx5_eswitch *esw,
1041 vport->egress.acl = NULL; 1044 vport->egress.acl = NULL;
1042} 1045}
1043 1046
1044static void esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw, 1047static int esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw,
1045 struct mlx5_vport *vport) 1048 struct mlx5_vport *vport)
1046{ 1049{
1047 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 1050 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
1048 struct mlx5_core_dev *dev = esw->dev; 1051 struct mlx5_core_dev *dev = esw->dev;
@@ -1063,9 +1066,11 @@ static void esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw,
1063 int table_size = 4; 1066 int table_size = 4;
1064 int err = 0; 1067 int err = 0;
1065 1068
1066 if (!MLX5_CAP_ESW_INGRESS_ACL(dev, ft_support) || 1069 if (!MLX5_CAP_ESW_INGRESS_ACL(dev, ft_support))
1067 !IS_ERR_OR_NULL(vport->ingress.acl)) 1070 return -EOPNOTSUPP;
1068 return; 1071
1072 if (!IS_ERR_OR_NULL(vport->ingress.acl))
1073 return 0;
1069 1074
1070 esw_debug(dev, "Create vport[%d] ingress ACL log_max_size(%d)\n", 1075 esw_debug(dev, "Create vport[%d] ingress ACL log_max_size(%d)\n",
1071 vport->vport, MLX5_CAP_ESW_INGRESS_ACL(dev, log_max_ft_size)); 1076 vport->vport, MLX5_CAP_ESW_INGRESS_ACL(dev, log_max_ft_size));
@@ -1073,12 +1078,12 @@ static void esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw,
1073 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS); 1078 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS);
1074 if (!root_ns) { 1079 if (!root_ns) {
1075 esw_warn(dev, "Failed to get E-Switch ingress flow namespace\n"); 1080 esw_warn(dev, "Failed to get E-Switch ingress flow namespace\n");
1076 return; 1081 return -EIO;
1077 } 1082 }
1078 1083
1079 flow_group_in = mlx5_vzalloc(inlen); 1084 flow_group_in = mlx5_vzalloc(inlen);
1080 if (!flow_group_in) 1085 if (!flow_group_in)
1081 return; 1086 return -ENOMEM;
1082 1087
1083 acl = mlx5_create_vport_flow_table(root_ns, 0, table_size, 0, vport->vport); 1088 acl = mlx5_create_vport_flow_table(root_ns, 0, table_size, 0, vport->vport);
1084 if (IS_ERR(acl)) { 1089 if (IS_ERR(acl)) {
@@ -1167,6 +1172,7 @@ out:
1167 } 1172 }
1168 1173
1169 kvfree(flow_group_in); 1174 kvfree(flow_group_in);
1175 return err;
1170} 1176}
1171 1177
1172static void esw_vport_cleanup_ingress_rules(struct mlx5_eswitch *esw, 1178static void esw_vport_cleanup_ingress_rules(struct mlx5_eswitch *esw,
@@ -1225,7 +1231,13 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
1225 return 0; 1231 return 0;
1226 } 1232 }
1227 1233
1228 esw_vport_enable_ingress_acl(esw, vport); 1234 err = esw_vport_enable_ingress_acl(esw, vport);
1235 if (err) {
1236 mlx5_core_warn(esw->dev,
1237 "failed to enable ingress acl (%d) on vport[%d]\n",
1238 err, vport->vport);
1239 return err;
1240 }
1229 1241
1230 esw_debug(esw->dev, 1242 esw_debug(esw->dev,
1231 "vport[%d] configure ingress rules, vlan(%d) qos(%d)\n", 1243 "vport[%d] configure ingress rules, vlan(%d) qos(%d)\n",
@@ -1299,7 +1311,13 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
1299 return 0; 1311 return 0;
1300 } 1312 }
1301 1313
1302 esw_vport_enable_egress_acl(esw, vport); 1314 err = esw_vport_enable_egress_acl(esw, vport);
1315 if (err) {
1316 mlx5_core_warn(esw->dev,
1317 "failed to enable egress acl (%d) on vport[%d]\n",
1318 err, vport->vport);
1319 return err;
1320 }
1303 1321
1304 esw_debug(esw->dev, 1322 esw_debug(esw->dev,
1305 "vport[%d] configure egress rules, vlan(%d) qos(%d)\n", 1323 "vport[%d] configure egress rules, vlan(%d) qos(%d)\n",
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 5da2cc878582..89696048b045 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -436,6 +436,9 @@ static void del_flow_group(struct fs_node *node)
436 fs_get_obj(ft, fg->node.parent); 436 fs_get_obj(ft, fg->node.parent);
437 dev = get_dev(&ft->node); 437 dev = get_dev(&ft->node);
438 438
439 if (ft->autogroup.active)
440 ft->autogroup.num_groups--;
441
439 if (mlx5_cmd_destroy_flow_group(dev, ft, fg->id)) 442 if (mlx5_cmd_destroy_flow_group(dev, ft, fg->id))
440 mlx5_core_warn(dev, "flow steering can't destroy fg %d of ft %d\n", 443 mlx5_core_warn(dev, "flow steering can't destroy fg %d of ft %d\n",
441 fg->id, ft->id); 444 fg->id, ft->id);
@@ -879,7 +882,7 @@ static struct mlx5_flow_group *create_flow_group_common(struct mlx5_flow_table *
879 tree_init_node(&fg->node, !is_auto_fg, del_flow_group); 882 tree_init_node(&fg->node, !is_auto_fg, del_flow_group);
880 tree_add_node(&fg->node, &ft->node); 883 tree_add_node(&fg->node, &ft->node);
881 /* Add node to group list */ 884 /* Add node to group list */
882 list_add(&fg->node.list, ft->node.children.prev); 885 list_add(&fg->node.list, prev_fg);
883 886
884 return fg; 887 return fg;
885} 888}
@@ -893,7 +896,7 @@ struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft,
893 return ERR_PTR(-EPERM); 896 return ERR_PTR(-EPERM);
894 897
895 lock_ref_node(&ft->node); 898 lock_ref_node(&ft->node);
896 fg = create_flow_group_common(ft, fg_in, &ft->node.children, false); 899 fg = create_flow_group_common(ft, fg_in, ft->node.children.prev, false);
897 unlock_ref_node(&ft->node); 900 unlock_ref_node(&ft->node);
898 901
899 return fg; 902 return fg;
@@ -1012,7 +1015,7 @@ static struct mlx5_flow_group *create_autogroup(struct mlx5_flow_table *ft,
1012 u32 *match_criteria) 1015 u32 *match_criteria)
1013{ 1016{
1014 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 1017 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
1015 struct list_head *prev = &ft->node.children; 1018 struct list_head *prev = ft->node.children.prev;
1016 unsigned int candidate_index = 0; 1019 unsigned int candidate_index = 0;
1017 struct mlx5_flow_group *fg; 1020 struct mlx5_flow_group *fg;
1018 void *match_criteria_addr; 1021 void *match_criteria_addr;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
index 3a9195b4169d..3b026c151cf2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
@@ -218,6 +218,7 @@ struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging)
218 goto err_out; 218 goto err_out;
219 219
220 if (aging) { 220 if (aging) {
221 counter->cache.lastuse = jiffies;
221 counter->aging = true; 222 counter->aging = true;
222 223
223 spin_lock(&fc_stats->addlist_lock); 224 spin_lock(&fc_stats->addlist_lock);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 1a05fb965c8d..5bcf93422ee0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -61,10 +61,15 @@ enum {
61enum { 61enum {
62 MLX5_NIC_IFC_FULL = 0, 62 MLX5_NIC_IFC_FULL = 0,
63 MLX5_NIC_IFC_DISABLED = 1, 63 MLX5_NIC_IFC_DISABLED = 1,
64 MLX5_NIC_IFC_NO_DRAM_NIC = 2 64 MLX5_NIC_IFC_NO_DRAM_NIC = 2,
65 MLX5_NIC_IFC_INVALID = 3
65}; 66};
66 67
67static u8 get_nic_interface(struct mlx5_core_dev *dev) 68enum {
69 MLX5_DROP_NEW_HEALTH_WORK,
70};
71
72static u8 get_nic_state(struct mlx5_core_dev *dev)
68{ 73{
69 return (ioread32be(&dev->iseg->cmdq_addr_l_sz) >> 8) & 3; 74 return (ioread32be(&dev->iseg->cmdq_addr_l_sz) >> 8) & 3;
70} 75}
@@ -97,7 +102,7 @@ static int in_fatal(struct mlx5_core_dev *dev)
97 struct mlx5_core_health *health = &dev->priv.health; 102 struct mlx5_core_health *health = &dev->priv.health;
98 struct health_buffer __iomem *h = health->health; 103 struct health_buffer __iomem *h = health->health;
99 104
100 if (get_nic_interface(dev) == MLX5_NIC_IFC_DISABLED) 105 if (get_nic_state(dev) == MLX5_NIC_IFC_DISABLED)
101 return 1; 106 return 1;
102 107
103 if (ioread32be(&h->fw_ver) == 0xffffffff) 108 if (ioread32be(&h->fw_ver) == 0xffffffff)
@@ -127,7 +132,7 @@ unlock:
127 132
128static void mlx5_handle_bad_state(struct mlx5_core_dev *dev) 133static void mlx5_handle_bad_state(struct mlx5_core_dev *dev)
129{ 134{
130 u8 nic_interface = get_nic_interface(dev); 135 u8 nic_interface = get_nic_state(dev);
131 136
132 switch (nic_interface) { 137 switch (nic_interface) {
133 case MLX5_NIC_IFC_FULL: 138 case MLX5_NIC_IFC_FULL:
@@ -149,8 +154,34 @@ static void mlx5_handle_bad_state(struct mlx5_core_dev *dev)
149 mlx5_disable_device(dev); 154 mlx5_disable_device(dev);
150} 155}
151 156
157static void health_recover(struct work_struct *work)
158{
159 struct mlx5_core_health *health;
160 struct delayed_work *dwork;
161 struct mlx5_core_dev *dev;
162 struct mlx5_priv *priv;
163 u8 nic_state;
164
165 dwork = container_of(work, struct delayed_work, work);
166 health = container_of(dwork, struct mlx5_core_health, recover_work);
167 priv = container_of(health, struct mlx5_priv, health);
168 dev = container_of(priv, struct mlx5_core_dev, priv);
169
170 nic_state = get_nic_state(dev);
171 if (nic_state == MLX5_NIC_IFC_INVALID) {
172 dev_err(&dev->pdev->dev, "health recovery flow aborted since the nic state is invalid\n");
173 return;
174 }
175
176 dev_err(&dev->pdev->dev, "starting health recovery flow\n");
177 mlx5_recover_device(dev);
178}
179
180/* How much time to wait until health resetting the driver (in msecs) */
181#define MLX5_RECOVERY_DELAY_MSECS 60000
152static void health_care(struct work_struct *work) 182static void health_care(struct work_struct *work)
153{ 183{
184 unsigned long recover_delay = msecs_to_jiffies(MLX5_RECOVERY_DELAY_MSECS);
154 struct mlx5_core_health *health; 185 struct mlx5_core_health *health;
155 struct mlx5_core_dev *dev; 186 struct mlx5_core_dev *dev;
156 struct mlx5_priv *priv; 187 struct mlx5_priv *priv;
@@ -160,6 +191,14 @@ static void health_care(struct work_struct *work)
160 dev = container_of(priv, struct mlx5_core_dev, priv); 191 dev = container_of(priv, struct mlx5_core_dev, priv);
161 mlx5_core_warn(dev, "handling bad device here\n"); 192 mlx5_core_warn(dev, "handling bad device here\n");
162 mlx5_handle_bad_state(dev); 193 mlx5_handle_bad_state(dev);
194
195 spin_lock(&health->wq_lock);
196 if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
197 schedule_delayed_work(&health->recover_work, recover_delay);
198 else
199 dev_err(&dev->pdev->dev,
200 "new health works are not permitted at this stage\n");
201 spin_unlock(&health->wq_lock);
163} 202}
164 203
165static const char *hsynd_str(u8 synd) 204static const char *hsynd_str(u8 synd)
@@ -272,7 +311,13 @@ static void poll_health(unsigned long data)
272 if (in_fatal(dev) && !health->sick) { 311 if (in_fatal(dev) && !health->sick) {
273 health->sick = true; 312 health->sick = true;
274 print_health_info(dev); 313 print_health_info(dev);
275 schedule_work(&health->work); 314 spin_lock(&health->wq_lock);
315 if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
316 queue_work(health->wq, &health->work);
317 else
318 dev_err(&dev->pdev->dev,
319 "new health works are not permitted at this stage\n");
320 spin_unlock(&health->wq_lock);
276 } 321 }
277} 322}
278 323
@@ -281,6 +326,8 @@ void mlx5_start_health_poll(struct mlx5_core_dev *dev)
281 struct mlx5_core_health *health = &dev->priv.health; 326 struct mlx5_core_health *health = &dev->priv.health;
282 327
283 init_timer(&health->timer); 328 init_timer(&health->timer);
329 health->sick = 0;
330 clear_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
284 health->health = &dev->iseg->health; 331 health->health = &dev->iseg->health;
285 health->health_counter = &dev->iseg->health_counter; 332 health->health_counter = &dev->iseg->health_counter;
286 333
@@ -297,11 +344,22 @@ void mlx5_stop_health_poll(struct mlx5_core_dev *dev)
297 del_timer_sync(&health->timer); 344 del_timer_sync(&health->timer);
298} 345}
299 346
347void mlx5_drain_health_wq(struct mlx5_core_dev *dev)
348{
349 struct mlx5_core_health *health = &dev->priv.health;
350
351 spin_lock(&health->wq_lock);
352 set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
353 spin_unlock(&health->wq_lock);
354 cancel_delayed_work_sync(&health->recover_work);
355 cancel_work_sync(&health->work);
356}
357
300void mlx5_health_cleanup(struct mlx5_core_dev *dev) 358void mlx5_health_cleanup(struct mlx5_core_dev *dev)
301{ 359{
302 struct mlx5_core_health *health = &dev->priv.health; 360 struct mlx5_core_health *health = &dev->priv.health;
303 361
304 flush_work(&health->work); 362 destroy_workqueue(health->wq);
305} 363}
306 364
307int mlx5_health_init(struct mlx5_core_dev *dev) 365int mlx5_health_init(struct mlx5_core_dev *dev)
@@ -316,9 +374,13 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
316 374
317 strcpy(name, "mlx5_health"); 375 strcpy(name, "mlx5_health");
318 strcat(name, dev_name(&dev->pdev->dev)); 376 strcat(name, dev_name(&dev->pdev->dev));
377 health->wq = create_singlethread_workqueue(name);
319 kfree(name); 378 kfree(name);
320 379 if (!health->wq)
380 return -ENOMEM;
381 spin_lock_init(&health->wq_lock);
321 INIT_WORK(&health->work, health_care); 382 INIT_WORK(&health->work, health_care);
383 INIT_DELAYED_WORK(&health->recover_work, health_recover);
322 384
323 return 0; 385 return 0;
324} 386}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index d9c3c70b29e4..d5433c49b2b0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -844,12 +844,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
844 struct pci_dev *pdev = dev->pdev; 844 struct pci_dev *pdev = dev->pdev;
845 int err; 845 int err;
846 846
847 err = mlx5_query_hca_caps(dev);
848 if (err) {
849 dev_err(&pdev->dev, "query hca failed\n");
850 goto out;
851 }
852
853 err = mlx5_query_board_id(dev); 847 err = mlx5_query_board_id(dev);
854 if (err) { 848 if (err) {
855 dev_err(&pdev->dev, "query board id failed\n"); 849 dev_err(&pdev->dev, "query board id failed\n");
@@ -1023,6 +1017,12 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
1023 1017
1024 mlx5_start_health_poll(dev); 1018 mlx5_start_health_poll(dev);
1025 1019
1020 err = mlx5_query_hca_caps(dev);
1021 if (err) {
1022 dev_err(&pdev->dev, "query hca failed\n");
1023 goto err_stop_poll;
1024 }
1025
1026 if (boot && mlx5_init_once(dev, priv)) { 1026 if (boot && mlx5_init_once(dev, priv)) {
1027 dev_err(&pdev->dev, "sw objs init failed\n"); 1027 dev_err(&pdev->dev, "sw objs init failed\n");
1028 goto err_stop_poll; 1028 goto err_stop_poll;
@@ -1313,10 +1313,16 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
1313 struct mlx5_priv *priv = &dev->priv; 1313 struct mlx5_priv *priv = &dev->priv;
1314 1314
1315 dev_info(&pdev->dev, "%s was called\n", __func__); 1315 dev_info(&pdev->dev, "%s was called\n", __func__);
1316
1316 mlx5_enter_error_state(dev); 1317 mlx5_enter_error_state(dev);
1317 mlx5_unload_one(dev, priv, false); 1318 mlx5_unload_one(dev, priv, false);
1318 pci_save_state(pdev); 1319 /* In case of kernel call save the pci state and drain health wq */
1319 mlx5_pci_disable_device(dev); 1320 if (state) {
1321 pci_save_state(pdev);
1322 mlx5_drain_health_wq(dev);
1323 mlx5_pci_disable_device(dev);
1324 }
1325
1320 return state == pci_channel_io_perm_failure ? 1326 return state == pci_channel_io_perm_failure ?
1321 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; 1327 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
1322} 1328}
@@ -1373,11 +1379,6 @@ static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev)
1373 return PCI_ERS_RESULT_RECOVERED; 1379 return PCI_ERS_RESULT_RECOVERED;
1374} 1380}
1375 1381
1376void mlx5_disable_device(struct mlx5_core_dev *dev)
1377{
1378 mlx5_pci_err_detected(dev->pdev, 0);
1379}
1380
1381static void mlx5_pci_resume(struct pci_dev *pdev) 1382static void mlx5_pci_resume(struct pci_dev *pdev)
1382{ 1383{
1383 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); 1384 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
@@ -1427,6 +1428,18 @@ static const struct pci_device_id mlx5_core_pci_table[] = {
1427 1428
1428MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table); 1429MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table);
1429 1430
1431void mlx5_disable_device(struct mlx5_core_dev *dev)
1432{
1433 mlx5_pci_err_detected(dev->pdev, 0);
1434}
1435
1436void mlx5_recover_device(struct mlx5_core_dev *dev)
1437{
1438 mlx5_pci_disable_device(dev);
1439 if (mlx5_pci_slot_reset(dev->pdev) == PCI_ERS_RESULT_RECOVERED)
1440 mlx5_pci_resume(dev->pdev);
1441}
1442
1430static struct pci_driver mlx5_core_driver = { 1443static struct pci_driver mlx5_core_driver = {
1431 .name = DRIVER_NAME, 1444 .name = DRIVER_NAME,
1432 .id_table = mlx5_core_pci_table, 1445 .id_table = mlx5_core_pci_table,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 3d0cfb9f18f9..187662c8ea96 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -83,6 +83,7 @@ void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
83 unsigned long param); 83 unsigned long param);
84void mlx5_enter_error_state(struct mlx5_core_dev *dev); 84void mlx5_enter_error_state(struct mlx5_core_dev *dev);
85void mlx5_disable_device(struct mlx5_core_dev *dev); 85void mlx5_disable_device(struct mlx5_core_dev *dev);
86void mlx5_recover_device(struct mlx5_core_dev *dev);
86int mlx5_sriov_init(struct mlx5_core_dev *dev); 87int mlx5_sriov_init(struct mlx5_core_dev *dev);
87void mlx5_sriov_cleanup(struct mlx5_core_dev *dev); 88void mlx5_sriov_cleanup(struct mlx5_core_dev *dev);
88int mlx5_sriov_attach(struct mlx5_core_dev *dev); 89int mlx5_sriov_attach(struct mlx5_core_dev *dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index cc4fd61914d3..a57d5a81eb05 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -209,6 +209,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr)
209static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id) 209static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id)
210{ 210{
211 struct page *page; 211 struct page *page;
212 u64 zero_addr = 1;
212 u64 addr; 213 u64 addr;
213 int err; 214 int err;
214 int nid = dev_to_node(&dev->pdev->dev); 215 int nid = dev_to_node(&dev->pdev->dev);
@@ -218,26 +219,35 @@ static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id)
218 mlx5_core_warn(dev, "failed to allocate page\n"); 219 mlx5_core_warn(dev, "failed to allocate page\n");
219 return -ENOMEM; 220 return -ENOMEM;
220 } 221 }
222map:
221 addr = dma_map_page(&dev->pdev->dev, page, 0, 223 addr = dma_map_page(&dev->pdev->dev, page, 0,
222 PAGE_SIZE, DMA_BIDIRECTIONAL); 224 PAGE_SIZE, DMA_BIDIRECTIONAL);
223 if (dma_mapping_error(&dev->pdev->dev, addr)) { 225 if (dma_mapping_error(&dev->pdev->dev, addr)) {
224 mlx5_core_warn(dev, "failed dma mapping page\n"); 226 mlx5_core_warn(dev, "failed dma mapping page\n");
225 err = -ENOMEM; 227 err = -ENOMEM;
226 goto out_alloc; 228 goto err_mapping;
227 } 229 }
230
231 /* Firmware doesn't support page with physical address 0 */
232 if (addr == 0) {
233 zero_addr = addr;
234 goto map;
235 }
236
228 err = insert_page(dev, addr, page, func_id); 237 err = insert_page(dev, addr, page, func_id);
229 if (err) { 238 if (err) {
230 mlx5_core_err(dev, "failed to track allocated page\n"); 239 mlx5_core_err(dev, "failed to track allocated page\n");
231 goto out_mapping; 240 dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE,
241 DMA_BIDIRECTIONAL);
232 } 242 }
233 243
234 return 0; 244err_mapping:
235 245 if (err)
236out_mapping: 246 __free_page(page);
237 dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
238 247
239out_alloc: 248 if (zero_addr == 0)
240 __free_page(page); 249 dma_unmap_page(&dev->pdev->dev, zero_addr, PAGE_SIZE,
250 DMA_BIDIRECTIONAL);
241 251
242 return err; 252 return err;
243} 253}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index e742bd4e8894..912f71f84209 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -1838,11 +1838,17 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
1838 .cmd_exec = mlxsw_pci_cmd_exec, 1838 .cmd_exec = mlxsw_pci_cmd_exec,
1839}; 1839};
1840 1840
1841static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci) 1841static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci,
1842 const struct pci_device_id *id)
1842{ 1843{
1843 unsigned long end; 1844 unsigned long end;
1844 1845
1845 mlxsw_pci_write32(mlxsw_pci, SW_RESET, MLXSW_PCI_SW_RESET_RST_BIT); 1846 mlxsw_pci_write32(mlxsw_pci, SW_RESET, MLXSW_PCI_SW_RESET_RST_BIT);
1847 if (id->device == PCI_DEVICE_ID_MELLANOX_SWITCHX2) {
1848 msleep(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
1849 return 0;
1850 }
1851
1846 wmb(); /* reset needs to be written before we read control register */ 1852 wmb(); /* reset needs to be written before we read control register */
1847 end = jiffies + msecs_to_jiffies(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS); 1853 end = jiffies + msecs_to_jiffies(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
1848 do { 1854 do {
@@ -1909,7 +1915,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1909 mlxsw_pci->pdev = pdev; 1915 mlxsw_pci->pdev = pdev;
1910 pci_set_drvdata(pdev, mlxsw_pci); 1916 pci_set_drvdata(pdev, mlxsw_pci);
1911 1917
1912 err = mlxsw_pci_sw_reset(mlxsw_pci); 1918 err = mlxsw_pci_sw_reset(mlxsw_pci, id);
1913 if (err) { 1919 if (err) {
1914 dev_err(&pdev->dev, "Software reset failed\n"); 1920 dev_err(&pdev->dev, "Software reset failed\n");
1915 goto err_sw_reset; 1921 goto err_sw_reset;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 78fc557d6dd7..4573da2c5560 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -320,6 +320,8 @@ mlxsw_sp_lpm_tree_create(struct mlxsw_sp *mlxsw_sp,
320 lpm_tree); 320 lpm_tree);
321 if (err) 321 if (err)
322 goto err_left_struct_set; 322 goto err_left_struct_set;
323 memcpy(&lpm_tree->prefix_usage, prefix_usage,
324 sizeof(lpm_tree->prefix_usage));
323 return lpm_tree; 325 return lpm_tree;
324 326
325err_left_struct_set: 327err_left_struct_set:
@@ -343,7 +345,8 @@ mlxsw_sp_lpm_tree_get(struct mlxsw_sp *mlxsw_sp,
343 345
344 for (i = 0; i < MLXSW_SP_LPM_TREE_COUNT; i++) { 346 for (i = 0; i < MLXSW_SP_LPM_TREE_COUNT; i++) {
345 lpm_tree = &mlxsw_sp->router.lpm_trees[i]; 347 lpm_tree = &mlxsw_sp->router.lpm_trees[i];
346 if (lpm_tree->proto == proto && 348 if (lpm_tree->ref_count != 0 &&
349 lpm_tree->proto == proto &&
347 mlxsw_sp_prefix_usage_eq(&lpm_tree->prefix_usage, 350 mlxsw_sp_prefix_usage_eq(&lpm_tree->prefix_usage,
348 prefix_usage)) 351 prefix_usage))
349 goto inc_ref_count; 352 goto inc_ref_count;
@@ -1820,19 +1823,17 @@ err_fib_entry_insert:
1820 return err; 1823 return err;
1821} 1824}
1822 1825
1823static int mlxsw_sp_router_fib4_del(struct mlxsw_sp *mlxsw_sp, 1826static void mlxsw_sp_router_fib4_del(struct mlxsw_sp *mlxsw_sp,
1824 struct fib_entry_notifier_info *fen_info) 1827 struct fib_entry_notifier_info *fen_info)
1825{ 1828{
1826 struct mlxsw_sp_fib_entry *fib_entry; 1829 struct mlxsw_sp_fib_entry *fib_entry;
1827 1830
1828 if (mlxsw_sp->router.aborted) 1831 if (mlxsw_sp->router.aborted)
1829 return 0; 1832 return;
1830 1833
1831 fib_entry = mlxsw_sp_fib_entry_find(mlxsw_sp, fen_info); 1834 fib_entry = mlxsw_sp_fib_entry_find(mlxsw_sp, fen_info);
1832 if (!fib_entry) { 1835 if (!fib_entry)
1833 dev_warn(mlxsw_sp->bus_info->dev, "Failed to find FIB4 entry being removed.\n"); 1836 return;
1834 return -ENOENT;
1835 }
1836 1837
1837 if (fib_entry->ref_count == 1) { 1838 if (fib_entry->ref_count == 1) {
1838 mlxsw_sp_fib_entry_del(mlxsw_sp, fib_entry); 1839 mlxsw_sp_fib_entry_del(mlxsw_sp, fib_entry);
@@ -1840,7 +1841,6 @@ static int mlxsw_sp_router_fib4_del(struct mlxsw_sp *mlxsw_sp,
1840 } 1841 }
1841 1842
1842 mlxsw_sp_fib_entry_put(mlxsw_sp, fib_entry); 1843 mlxsw_sp_fib_entry_put(mlxsw_sp, fib_entry);
1843 return 0;
1844} 1844}
1845 1845
1846static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp) 1846static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp)
@@ -1862,7 +1862,8 @@ static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp)
1862 if (err) 1862 if (err)
1863 return err; 1863 return err;
1864 1864
1865 mlxsw_reg_raltb_pack(raltb_pl, 0, MLXSW_REG_RALXX_PROTOCOL_IPV4, 0); 1865 mlxsw_reg_raltb_pack(raltb_pl, 0, MLXSW_REG_RALXX_PROTOCOL_IPV4,
1866 MLXSW_SP_LPM_TREE_MIN);
1866 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raltb), raltb_pl); 1867 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raltb), raltb_pl);
1867 if (err) 1868 if (err)
1868 return err; 1869 return err;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index c0c23e2f3275..92bda8703f87 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -1088,6 +1088,7 @@ err_port_stp_state_set:
1088err_port_admin_status_set: 1088err_port_admin_status_set:
1089err_port_mtu_set: 1089err_port_mtu_set:
1090err_port_speed_set: 1090err_port_speed_set:
1091 mlxsw_sx_port_swid_set(mlxsw_sx_port, MLXSW_PORT_SWID_DISABLED_PORT);
1091err_port_swid_set: 1092err_port_swid_set:
1092err_port_system_port_mapping_set: 1093err_port_system_port_mapping_set:
1093port_not_usable: 1094port_not_usable:
diff --git a/drivers/net/ethernet/qlogic/Kconfig b/drivers/net/ethernet/qlogic/Kconfig
index 1e8339a67f6e..32f2a45f4ab2 100644
--- a/drivers/net/ethernet/qlogic/Kconfig
+++ b/drivers/net/ethernet/qlogic/Kconfig
@@ -107,4 +107,7 @@ config QEDE
107 ---help--- 107 ---help---
108 This enables the support for ... 108 This enables the support for ...
109 109
110config QED_RDMA
111 bool
112
110endif # NET_VENDOR_QLOGIC 113endif # NET_VENDOR_QLOGIC
diff --git a/drivers/net/ethernet/qlogic/qed/Makefile b/drivers/net/ethernet/qlogic/qed/Makefile
index cda0af7fbc20..967acf322c09 100644
--- a/drivers/net/ethernet/qlogic/qed/Makefile
+++ b/drivers/net/ethernet/qlogic/qed/Makefile
@@ -5,4 +5,4 @@ qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o \
5 qed_selftest.o qed_dcbx.o qed_debug.o 5 qed_selftest.o qed_dcbx.o qed_debug.o
6qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o 6qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o
7qed-$(CONFIG_QED_LL2) += qed_ll2.o 7qed-$(CONFIG_QED_LL2) += qed_ll2.o
8qed-$(CONFIG_INFINIBAND_QEDR) += qed_roce.o 8qed-$(CONFIG_QED_RDMA) += qed_roce.o
diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index 82370a1a59ad..0c42c240b5cf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -47,13 +47,8 @@
47#define TM_ALIGN BIT(TM_SHIFT) 47#define TM_ALIGN BIT(TM_SHIFT)
48#define TM_ELEM_SIZE 4 48#define TM_ELEM_SIZE 4
49 49
50/* ILT constants */
51#if IS_ENABLED(CONFIG_INFINIBAND_QEDR)
52/* For RoCE we configure to 64K to cover for RoCE max tasks 256K purpose. */ 50/* For RoCE we configure to 64K to cover for RoCE max tasks 256K purpose. */
53#define ILT_DEFAULT_HW_P_SIZE 4 51#define ILT_DEFAULT_HW_P_SIZE (IS_ENABLED(CONFIG_QED_RDMA) ? 4 : 3)
54#else
55#define ILT_DEFAULT_HW_P_SIZE 3
56#endif
57 52
58#define ILT_PAGE_IN_BYTES(hw_p_size) (1U << ((hw_p_size) + 12)) 53#define ILT_PAGE_IN_BYTES(hw_p_size) (1U << ((hw_p_size) + 12))
59#define ILT_CFG_REG(cli, reg) PSWRQ2_REG_ ## cli ## _ ## reg ## _RT_OFFSET 54#define ILT_CFG_REG(cli, reg) PSWRQ2_REG_ ## cli ## _ ## reg ## _RT_OFFSET
@@ -349,14 +344,14 @@ static struct qed_tid_seg *qed_cxt_tid_seg_info(struct qed_hwfn *p_hwfn,
349 return NULL; 344 return NULL;
350} 345}
351 346
352void qed_cxt_set_srq_count(struct qed_hwfn *p_hwfn, u32 num_srqs) 347static void qed_cxt_set_srq_count(struct qed_hwfn *p_hwfn, u32 num_srqs)
353{ 348{
354 struct qed_cxt_mngr *p_mgr = p_hwfn->p_cxt_mngr; 349 struct qed_cxt_mngr *p_mgr = p_hwfn->p_cxt_mngr;
355 350
356 p_mgr->srq_count = num_srqs; 351 p_mgr->srq_count = num_srqs;
357} 352}
358 353
359u32 qed_cxt_get_srq_count(struct qed_hwfn *p_hwfn) 354static u32 qed_cxt_get_srq_count(struct qed_hwfn *p_hwfn)
360{ 355{
361 struct qed_cxt_mngr *p_mgr = p_hwfn->p_cxt_mngr; 356 struct qed_cxt_mngr *p_mgr = p_hwfn->p_cxt_mngr;
362 357
@@ -1804,8 +1799,8 @@ int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn, struct qed_cxt_info *p_info)
1804 return 0; 1799 return 0;
1805} 1800}
1806 1801
1807void qed_rdma_set_pf_params(struct qed_hwfn *p_hwfn, 1802static void qed_rdma_set_pf_params(struct qed_hwfn *p_hwfn,
1808 struct qed_rdma_pf_params *p_params) 1803 struct qed_rdma_pf_params *p_params)
1809{ 1804{
1810 u32 num_cons, num_tasks, num_qps, num_mrs, num_srqs; 1805 u32 num_cons, num_tasks, num_qps, num_mrs, num_srqs;
1811 enum protocol_type proto; 1806 enum protocol_type proto;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 130da1c0490b..a4789a93b692 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -1190,6 +1190,7 @@ int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn,
1190 if (!dcbx_info) 1190 if (!dcbx_info)
1191 return -ENOMEM; 1191 return -ENOMEM;
1192 1192
1193 memset(dcbx_info, 0, sizeof(*dcbx_info));
1193 rc = qed_dcbx_query_params(p_hwfn, dcbx_info, QED_DCBX_OPERATIONAL_MIB); 1194 rc = qed_dcbx_query_params(p_hwfn, dcbx_info, QED_DCBX_OPERATIONAL_MIB);
1194 if (rc) { 1195 if (rc) {
1195 kfree(dcbx_info); 1196 kfree(dcbx_info);
@@ -1225,6 +1226,7 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
1225 if (!dcbx_info) 1226 if (!dcbx_info)
1226 return NULL; 1227 return NULL;
1227 1228
1229 memset(dcbx_info, 0, sizeof(*dcbx_info));
1228 if (qed_dcbx_query_params(hwfn, dcbx_info, type)) { 1230 if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
1229 kfree(dcbx_info); 1231 kfree(dcbx_info);
1230 return NULL; 1232 return NULL;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index 88e7d5bef909..68f19ca57f96 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -405,7 +405,7 @@ struct phy_defs {
405/***************************** Constant Arrays *******************************/ 405/***************************** Constant Arrays *******************************/
406 406
407/* Debug arrays */ 407/* Debug arrays */
408static struct dbg_array s_dbg_arrays[MAX_BIN_DBG_BUFFER_TYPE] = { {0} }; 408static struct dbg_array s_dbg_arrays[MAX_BIN_DBG_BUFFER_TYPE] = { {NULL} };
409 409
410/* Chip constant definitions array */ 410/* Chip constant definitions array */
411static struct chip_defs s_chip_defs[MAX_CHIP_IDS] = { 411static struct chip_defs s_chip_defs[MAX_CHIP_IDS] = {
@@ -4028,10 +4028,10 @@ static enum dbg_status qed_mcp_trace_read_meta(struct qed_hwfn *p_hwfn,
4028} 4028}
4029 4029
4030/* Dump MCP Trace */ 4030/* Dump MCP Trace */
4031enum dbg_status qed_mcp_trace_dump(struct qed_hwfn *p_hwfn, 4031static enum dbg_status qed_mcp_trace_dump(struct qed_hwfn *p_hwfn,
4032 struct qed_ptt *p_ptt, 4032 struct qed_ptt *p_ptt,
4033 u32 *dump_buf, 4033 u32 *dump_buf,
4034 bool dump, u32 *num_dumped_dwords) 4034 bool dump, u32 *num_dumped_dwords)
4035{ 4035{
4036 u32 trace_data_grc_addr, trace_data_size_bytes, trace_data_size_dwords; 4036 u32 trace_data_grc_addr, trace_data_size_bytes, trace_data_size_dwords;
4037 u32 trace_meta_size_dwords, running_bundle_id, offset = 0; 4037 u32 trace_meta_size_dwords, running_bundle_id, offset = 0;
@@ -4130,10 +4130,10 @@ enum dbg_status qed_mcp_trace_dump(struct qed_hwfn *p_hwfn,
4130} 4130}
4131 4131
4132/* Dump GRC FIFO */ 4132/* Dump GRC FIFO */
4133enum dbg_status qed_reg_fifo_dump(struct qed_hwfn *p_hwfn, 4133static enum dbg_status qed_reg_fifo_dump(struct qed_hwfn *p_hwfn,
4134 struct qed_ptt *p_ptt, 4134 struct qed_ptt *p_ptt,
4135 u32 *dump_buf, 4135 u32 *dump_buf,
4136 bool dump, u32 *num_dumped_dwords) 4136 bool dump, u32 *num_dumped_dwords)
4137{ 4137{
4138 u32 offset = 0, dwords_read, size_param_offset; 4138 u32 offset = 0, dwords_read, size_param_offset;
4139 bool fifo_has_data; 4139 bool fifo_has_data;
@@ -4192,10 +4192,10 @@ enum dbg_status qed_reg_fifo_dump(struct qed_hwfn *p_hwfn,
4192} 4192}
4193 4193
4194/* Dump IGU FIFO */ 4194/* Dump IGU FIFO */
4195enum dbg_status qed_igu_fifo_dump(struct qed_hwfn *p_hwfn, 4195static enum dbg_status qed_igu_fifo_dump(struct qed_hwfn *p_hwfn,
4196 struct qed_ptt *p_ptt, 4196 struct qed_ptt *p_ptt,
4197 u32 *dump_buf, 4197 u32 *dump_buf,
4198 bool dump, u32 *num_dumped_dwords) 4198 bool dump, u32 *num_dumped_dwords)
4199{ 4199{
4200 u32 offset = 0, dwords_read, size_param_offset; 4200 u32 offset = 0, dwords_read, size_param_offset;
4201 bool fifo_has_data; 4201 bool fifo_has_data;
@@ -4255,10 +4255,11 @@ enum dbg_status qed_igu_fifo_dump(struct qed_hwfn *p_hwfn,
4255} 4255}
4256 4256
4257/* Protection Override dump */ 4257/* Protection Override dump */
4258enum dbg_status qed_protection_override_dump(struct qed_hwfn *p_hwfn, 4258static enum dbg_status qed_protection_override_dump(struct qed_hwfn *p_hwfn,
4259 struct qed_ptt *p_ptt, 4259 struct qed_ptt *p_ptt,
4260 u32 *dump_buf, 4260 u32 *dump_buf,
4261 bool dump, u32 *num_dumped_dwords) 4261 bool dump,
4262 u32 *num_dumped_dwords)
4262{ 4263{
4263 u32 offset = 0, size_param_offset, override_window_dwords; 4264 u32 offset = 0, size_param_offset, override_window_dwords;
4264 4265
@@ -6339,10 +6340,11 @@ enum dbg_status qed_print_fw_asserts_results(struct qed_hwfn *p_hwfn,
6339} 6340}
6340 6341
6341/* Wrapper for unifying the idle_chk and mcp_trace api */ 6342/* Wrapper for unifying the idle_chk and mcp_trace api */
6342enum dbg_status qed_print_idle_chk_results_wrapper(struct qed_hwfn *p_hwfn, 6343static enum dbg_status
6343 u32 *dump_buf, 6344qed_print_idle_chk_results_wrapper(struct qed_hwfn *p_hwfn,
6344 u32 num_dumped_dwords, 6345 u32 *dump_buf,
6345 char *results_buf) 6346 u32 num_dumped_dwords,
6347 char *results_buf)
6346{ 6348{
6347 u32 num_errors, num_warnnings; 6349 u32 num_errors, num_warnnings;
6348 6350
@@ -6413,8 +6415,8 @@ static void qed_dbg_print_feature(u8 *p_text_buf, u32 text_size)
6413 6415
6414#define QED_RESULTS_BUF_MIN_SIZE 16 6416#define QED_RESULTS_BUF_MIN_SIZE 16
6415/* Generic function for decoding debug feature info */ 6417/* Generic function for decoding debug feature info */
6416enum dbg_status format_feature(struct qed_hwfn *p_hwfn, 6418static enum dbg_status format_feature(struct qed_hwfn *p_hwfn,
6417 enum qed_dbg_features feature_idx) 6419 enum qed_dbg_features feature_idx)
6418{ 6420{
6419 struct qed_dbg_feature *feature = 6421 struct qed_dbg_feature *feature =
6420 &p_hwfn->cdev->dbg_params.features[feature_idx]; 6422 &p_hwfn->cdev->dbg_params.features[feature_idx];
@@ -6480,8 +6482,9 @@ enum dbg_status format_feature(struct qed_hwfn *p_hwfn,
6480} 6482}
6481 6483
6482/* Generic function for performing the dump of a debug feature. */ 6484/* Generic function for performing the dump of a debug feature. */
6483enum dbg_status qed_dbg_dump(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, 6485static enum dbg_status qed_dbg_dump(struct qed_hwfn *p_hwfn,
6484 enum qed_dbg_features feature_idx) 6486 struct qed_ptt *p_ptt,
6487 enum qed_dbg_features feature_idx)
6485{ 6488{
6486 struct qed_dbg_feature *feature = 6489 struct qed_dbg_feature *feature =
6487 &p_hwfn->cdev->dbg_params.features[feature_idx]; 6490 &p_hwfn->cdev->dbg_params.features[feature_idx];
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 754f6a908858..edae5fc5fccd 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -497,12 +497,13 @@ int qed_resc_alloc(struct qed_dev *cdev)
497 if (p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE) { 497 if (p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE) {
498 num_cons = qed_cxt_get_proto_cid_count(p_hwfn, 498 num_cons = qed_cxt_get_proto_cid_count(p_hwfn,
499 PROTOCOLID_ROCE, 499 PROTOCOLID_ROCE,
500 0) * 2; 500 NULL) * 2;
501 n_eqes += num_cons + 2 * MAX_NUM_VFS_BB; 501 n_eqes += num_cons + 2 * MAX_NUM_VFS_BB;
502 } else if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { 502 } else if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) {
503 num_cons = 503 num_cons =
504 qed_cxt_get_proto_cid_count(p_hwfn, 504 qed_cxt_get_proto_cid_count(p_hwfn,
505 PROTOCOLID_ISCSI, 0); 505 PROTOCOLID_ISCSI,
506 NULL);
506 n_eqes += 2 * num_cons; 507 n_eqes += 2 * num_cons;
507 } 508 }
508 509
@@ -1422,19 +1423,19 @@ static void qed_hw_set_feat(struct qed_hwfn *p_hwfn)
1422 u32 *feat_num = p_hwfn->hw_info.feat_num; 1423 u32 *feat_num = p_hwfn->hw_info.feat_num;
1423 int num_features = 1; 1424 int num_features = 1;
1424 1425
1425#if IS_ENABLED(CONFIG_INFINIBAND_QEDR) 1426 if (IS_ENABLED(CONFIG_QED_RDMA) &&
1426 /* Roce CNQ each requires: 1 status block + 1 CNQ. We divide the 1427 p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE) {
1427 * status blocks equally between L2 / RoCE but with consideration as 1428 /* Roce CNQ each requires: 1 status block + 1 CNQ. We divide
1428 * to how many l2 queues / cnqs we have 1429 * the status blocks equally between L2 / RoCE but with
1429 */ 1430 * consideration as to how many l2 queues / cnqs we have.
1430 if (p_hwfn->hw_info.personality == QED_PCI_ETH_ROCE) { 1431 */
1431 num_features++; 1432 num_features++;
1432 1433
1433 feat_num[QED_RDMA_CNQ] = 1434 feat_num[QED_RDMA_CNQ] =
1434 min_t(u32, RESC_NUM(p_hwfn, QED_SB) / num_features, 1435 min_t(u32, RESC_NUM(p_hwfn, QED_SB) / num_features,
1435 RESC_NUM(p_hwfn, QED_RDMA_CNQ_RAM)); 1436 RESC_NUM(p_hwfn, QED_RDMA_CNQ_RAM));
1436 } 1437 }
1437#endif 1438
1438 feat_num[QED_PF_L2_QUE] = min_t(u32, RESC_NUM(p_hwfn, QED_SB) / 1439 feat_num[QED_PF_L2_QUE] = min_t(u32, RESC_NUM(p_hwfn, QED_SB) /
1439 num_features, 1440 num_features,
1440 RESC_NUM(p_hwfn, QED_L2_QUEUE)); 1441 RESC_NUM(p_hwfn, QED_L2_QUEUE));
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 02a8be2faed7..63e1a1b0ef8e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -38,6 +38,7 @@
38#include "qed_mcp.h" 38#include "qed_mcp.h"
39#include "qed_reg_addr.h" 39#include "qed_reg_addr.h"
40#include "qed_sp.h" 40#include "qed_sp.h"
41#include "qed_roce.h"
41 42
42#define QED_LL2_RX_REGISTERED(ll2) ((ll2)->rx_queue.b_cb_registred) 43#define QED_LL2_RX_REGISTERED(ll2) ((ll2)->rx_queue.b_cb_registred)
43#define QED_LL2_TX_REGISTERED(ll2) ((ll2)->tx_queue.b_cb_registred) 44#define QED_LL2_TX_REGISTERED(ll2) ((ll2)->tx_queue.b_cb_registred)
@@ -140,11 +141,11 @@ static void qed_ll2_kill_buffers(struct qed_dev *cdev)
140 qed_ll2_dealloc_buffer(cdev, buffer); 141 qed_ll2_dealloc_buffer(cdev, buffer);
141} 142}
142 143
143void qed_ll2b_complete_rx_packet(struct qed_hwfn *p_hwfn, 144static void qed_ll2b_complete_rx_packet(struct qed_hwfn *p_hwfn,
144 u8 connection_handle, 145 u8 connection_handle,
145 struct qed_ll2_rx_packet *p_pkt, 146 struct qed_ll2_rx_packet *p_pkt,
146 struct core_rx_fast_path_cqe *p_cqe, 147 struct core_rx_fast_path_cqe *p_cqe,
147 bool b_last_packet) 148 bool b_last_packet)
148{ 149{
149 u16 packet_length = le16_to_cpu(p_cqe->packet_length); 150 u16 packet_length = le16_to_cpu(p_cqe->packet_length);
150 struct qed_ll2_buffer *buffer = p_pkt->cookie; 151 struct qed_ll2_buffer *buffer = p_pkt->cookie;
@@ -515,7 +516,7 @@ static int qed_ll2_rxq_completion(struct qed_hwfn *p_hwfn, void *cookie)
515 return rc; 516 return rc;
516} 517}
517 518
518void qed_ll2_rxq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle) 519static void qed_ll2_rxq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle)
519{ 520{
520 struct qed_ll2_info *p_ll2_conn = NULL; 521 struct qed_ll2_info *p_ll2_conn = NULL;
521 struct qed_ll2_rx_packet *p_pkt = NULL; 522 struct qed_ll2_rx_packet *p_pkt = NULL;
@@ -537,8 +538,7 @@ void qed_ll2_rxq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle)
537 if (!p_pkt) 538 if (!p_pkt)
538 break; 539 break;
539 540
540 list_del(&p_pkt->list_entry); 541 list_move_tail(&p_pkt->list_entry, &p_rx->free_descq);
541 list_add_tail(&p_pkt->list_entry, &p_rx->free_descq);
542 542
543 rx_buf_addr = p_pkt->rx_buf_addr; 543 rx_buf_addr = p_pkt->rx_buf_addr;
544 cookie = p_pkt->cookie; 544 cookie = p_pkt->cookie;
@@ -992,9 +992,8 @@ static void qed_ll2_post_rx_buffer_notify_fw(struct qed_hwfn *p_hwfn,
992 p_posting_packet = list_first_entry(&p_rx->posting_descq, 992 p_posting_packet = list_first_entry(&p_rx->posting_descq,
993 struct qed_ll2_rx_packet, 993 struct qed_ll2_rx_packet,
994 list_entry); 994 list_entry);
995 list_del(&p_posting_packet->list_entry); 995 list_move_tail(&p_posting_packet->list_entry,
996 list_add_tail(&p_posting_packet->list_entry, 996 &p_rx->active_descq);
997 &p_rx->active_descq);
998 b_notify_fw = true; 997 b_notify_fw = true;
999 } 998 }
1000 999
@@ -1123,9 +1122,6 @@ static void qed_ll2_prepare_tx_packet_set_bd(struct qed_hwfn *p_hwfn,
1123 DMA_REGPAIR_LE(start_bd->addr, first_frag); 1122 DMA_REGPAIR_LE(start_bd->addr, first_frag);
1124 start_bd->nbytes = cpu_to_le16(first_frag_len); 1123 start_bd->nbytes = cpu_to_le16(first_frag_len);
1125 1124
1126 SET_FIELD(start_bd->bd_flags.as_bitfield, CORE_TX_BD_FLAGS_ROCE_FLAV,
1127 type);
1128
1129 DP_VERBOSE(p_hwfn, 1125 DP_VERBOSE(p_hwfn,
1130 (NETIF_MSG_TX_QUEUED | QED_MSG_LL2), 1126 (NETIF_MSG_TX_QUEUED | QED_MSG_LL2),
1131 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs buffer at %08x:%08x\n", 1127 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs buffer at %08x:%08x\n",
@@ -1188,8 +1184,7 @@ static void qed_ll2_tx_packet_notify(struct qed_hwfn *p_hwfn,
1188 if (!p_pkt) 1184 if (!p_pkt)
1189 break; 1185 break;
1190 1186
1191 list_del(&p_pkt->list_entry); 1187 list_move_tail(&p_pkt->list_entry, &p_tx->active_descq);
1192 list_add_tail(&p_pkt->list_entry, &p_tx->active_descq);
1193 } 1188 }
1194 1189
1195 SET_FIELD(db_msg.params, CORE_DB_DATA_DEST, DB_DEST_XCM); 1190 SET_FIELD(db_msg.params, CORE_DB_DATA_DEST, DB_DEST_XCM);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.h b/drivers/net/ethernet/qlogic/qed/qed_ll2.h
index 80a5dc2d652d..4e3d62a16cab 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.h
@@ -293,24 +293,4 @@ void qed_ll2_setup(struct qed_hwfn *p_hwfn,
293 */ 293 */
294void qed_ll2_free(struct qed_hwfn *p_hwfn, 294void qed_ll2_free(struct qed_hwfn *p_hwfn,
295 struct qed_ll2_info *p_ll2_connections); 295 struct qed_ll2_info *p_ll2_connections);
296void qed_ll2b_complete_rx_gsi_packet(struct qed_hwfn *p_hwfn,
297 u8 connection_handle,
298 void *cookie,
299 dma_addr_t rx_buf_addr,
300 u16 data_length,
301 u8 data_length_error,
302 u16 parse_flags,
303 u16 vlan,
304 u32 src_mac_addr_hi,
305 u16 src_mac_addr_lo, bool b_last_packet);
306void qed_ll2b_complete_tx_gsi_packet(struct qed_hwfn *p_hwfn,
307 u8 connection_handle,
308 void *cookie,
309 dma_addr_t first_frag_addr,
310 bool b_last_fragment, bool b_last_packet);
311void qed_ll2b_release_tx_gsi_packet(struct qed_hwfn *p_hwfn,
312 u8 connection_handle,
313 void *cookie,
314 dma_addr_t first_frag_addr,
315 bool b_last_fragment, bool b_last_packet);
316#endif 296#endif
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 4ee3151e80c2..c418360ba02a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -33,10 +33,8 @@
33#include "qed_hw.h" 33#include "qed_hw.h"
34#include "qed_selftest.h" 34#include "qed_selftest.h"
35 35
36#if IS_ENABLED(CONFIG_INFINIBAND_QEDR)
37#define QED_ROCE_QPS (8192) 36#define QED_ROCE_QPS (8192)
38#define QED_ROCE_DPIS (8) 37#define QED_ROCE_DPIS (8)
39#endif
40 38
41static char version[] = 39static char version[] =
42 "QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n"; 40 "QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n";
@@ -682,9 +680,7 @@ static int qed_slowpath_setup_int(struct qed_dev *cdev,
682 enum qed_int_mode int_mode) 680 enum qed_int_mode int_mode)
683{ 681{
684 struct qed_sb_cnt_info sb_cnt_info; 682 struct qed_sb_cnt_info sb_cnt_info;
685#if IS_ENABLED(CONFIG_INFINIBAND_QEDR) 683 int num_l2_queues = 0;
686 int num_l2_queues;
687#endif
688 int rc; 684 int rc;
689 int i; 685 int i;
690 686
@@ -715,8 +711,9 @@ static int qed_slowpath_setup_int(struct qed_dev *cdev,
715 cdev->int_params.fp_msix_cnt = cdev->int_params.out.num_vectors - 711 cdev->int_params.fp_msix_cnt = cdev->int_params.out.num_vectors -
716 cdev->num_hwfns; 712 cdev->num_hwfns;
717 713
718#if IS_ENABLED(CONFIG_INFINIBAND_QEDR) 714 if (!IS_ENABLED(CONFIG_QED_RDMA))
719 num_l2_queues = 0; 715 return 0;
716
720 for_each_hwfn(cdev, i) 717 for_each_hwfn(cdev, i)
721 num_l2_queues += FEAT_NUM(&cdev->hwfns[i], QED_PF_L2_QUE); 718 num_l2_queues += FEAT_NUM(&cdev->hwfns[i], QED_PF_L2_QUE);
722 719
@@ -738,7 +735,6 @@ static int qed_slowpath_setup_int(struct qed_dev *cdev,
738 DP_VERBOSE(cdev, QED_MSG_RDMA, "roce_msix_cnt=%d roce_msix_base=%d\n", 735 DP_VERBOSE(cdev, QED_MSG_RDMA, "roce_msix_cnt=%d roce_msix_base=%d\n",
739 cdev->int_params.rdma_msix_cnt, 736 cdev->int_params.rdma_msix_cnt,
740 cdev->int_params.rdma_msix_base); 737 cdev->int_params.rdma_msix_base);
741#endif
742 738
743 return 0; 739 return 0;
744} 740}
@@ -843,18 +839,20 @@ static void qed_update_pf_params(struct qed_dev *cdev,
843{ 839{
844 int i; 840 int i;
845 841
846#if IS_ENABLED(CONFIG_INFINIBAND_QEDR)
847 params->rdma_pf_params.num_qps = QED_ROCE_QPS;
848 params->rdma_pf_params.min_dpis = QED_ROCE_DPIS;
849 /* divide by 3 the MRs to avoid MF ILT overflow */
850 params->rdma_pf_params.num_mrs = RDMA_MAX_TIDS;
851 params->rdma_pf_params.gl_pi = QED_ROCE_PROTOCOL_INDEX;
852#endif
853 for (i = 0; i < cdev->num_hwfns; i++) { 842 for (i = 0; i < cdev->num_hwfns; i++) {
854 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; 843 struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
855 844
856 p_hwfn->pf_params = *params; 845 p_hwfn->pf_params = *params;
857 } 846 }
847
848 if (!IS_ENABLED(CONFIG_QED_RDMA))
849 return;
850
851 params->rdma_pf_params.num_qps = QED_ROCE_QPS;
852 params->rdma_pf_params.min_dpis = QED_ROCE_DPIS;
853 /* divide by 3 the MRs to avoid MF ILT overflow */
854 params->rdma_pf_params.num_mrs = RDMA_MAX_TIDS;
855 params->rdma_pf_params.gl_pi = QED_ROCE_PROTOCOL_INDEX;
858} 856}
859 857
860static int qed_slowpath_start(struct qed_dev *cdev, 858static int qed_slowpath_start(struct qed_dev *cdev,
@@ -880,6 +878,7 @@ static int qed_slowpath_start(struct qed_dev *cdev,
880 } 878 }
881 } 879 }
882 880
881 cdev->rx_coalesce_usecs = QED_DEFAULT_RX_USECS;
883 rc = qed_nic_setup(cdev); 882 rc = qed_nic_setup(cdev);
884 if (rc) 883 if (rc)
885 goto err; 884 goto err;
@@ -1432,7 +1431,7 @@ static int qed_set_led(struct qed_dev *cdev, enum qed_led_mode mode)
1432 return status; 1431 return status;
1433} 1432}
1434 1433
1435struct qed_selftest_ops qed_selftest_ops_pass = { 1434static struct qed_selftest_ops qed_selftest_ops_pass = {
1436 .selftest_memory = &qed_selftest_memory, 1435 .selftest_memory = &qed_selftest_memory,
1437 .selftest_interrupt = &qed_selftest_interrupt, 1436 .selftest_interrupt = &qed_selftest_interrupt,
1438 .selftest_register = &qed_selftest_register, 1437 .selftest_register = &qed_selftest_register,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
index 76831a398bed..f3a825a8f8d5 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
@@ -129,17 +129,12 @@ static void qed_bmap_release_id(struct qed_hwfn *p_hwfn,
129 } 129 }
130} 130}
131 131
132u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) 132static u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id)
133{ 133{
134 /* First sb id for RoCE is after all the l2 sb */ 134 /* First sb id for RoCE is after all the l2 sb */
135 return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id; 135 return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id;
136} 136}
137 137
138u32 qed_rdma_query_cau_timer_res(void *rdma_cxt)
139{
140 return QED_CAU_DEF_RX_TIMER_RES;
141}
142
143static int qed_rdma_alloc(struct qed_hwfn *p_hwfn, 138static int qed_rdma_alloc(struct qed_hwfn *p_hwfn,
144 struct qed_ptt *p_ptt, 139 struct qed_ptt *p_ptt,
145 struct qed_rdma_start_in_params *params) 140 struct qed_rdma_start_in_params *params)
@@ -162,7 +157,8 @@ static int qed_rdma_alloc(struct qed_hwfn *p_hwfn,
162 p_hwfn->p_rdma_info = p_rdma_info; 157 p_hwfn->p_rdma_info = p_rdma_info;
163 p_rdma_info->proto = PROTOCOLID_ROCE; 158 p_rdma_info->proto = PROTOCOLID_ROCE;
164 159
165 num_cons = qed_cxt_get_proto_cid_count(p_hwfn, p_rdma_info->proto, 0); 160 num_cons = qed_cxt_get_proto_cid_count(p_hwfn, p_rdma_info->proto,
161 NULL);
166 162
167 p_rdma_info->num_qps = num_cons / 2; 163 p_rdma_info->num_qps = num_cons / 2;
168 164
@@ -275,7 +271,7 @@ free_rdma_info:
275 return rc; 271 return rc;
276} 272}
277 273
278void qed_rdma_resc_free(struct qed_hwfn *p_hwfn) 274static void qed_rdma_resc_free(struct qed_hwfn *p_hwfn)
279{ 275{
280 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; 276 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info;
281 277
@@ -527,6 +523,26 @@ static int qed_rdma_start_fw(struct qed_hwfn *p_hwfn,
527 return qed_spq_post(p_hwfn, p_ent, NULL); 523 return qed_spq_post(p_hwfn, p_ent, NULL);
528} 524}
529 525
526static int qed_rdma_alloc_tid(void *rdma_cxt, u32 *itid)
527{
528 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
529 int rc;
530
531 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID\n");
532
533 spin_lock_bh(&p_hwfn->p_rdma_info->lock);
534 rc = qed_rdma_bmap_alloc_id(p_hwfn,
535 &p_hwfn->p_rdma_info->tid_map, itid);
536 spin_unlock_bh(&p_hwfn->p_rdma_info->lock);
537 if (rc)
538 goto out;
539
540 rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_TASK, *itid);
541out:
542 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID - done, rc = %d\n", rc);
543 return rc;
544}
545
530static int qed_rdma_reserve_lkey(struct qed_hwfn *p_hwfn) 546static int qed_rdma_reserve_lkey(struct qed_hwfn *p_hwfn)
531{ 547{
532 struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; 548 struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev;
@@ -573,7 +589,7 @@ static int qed_rdma_setup(struct qed_hwfn *p_hwfn,
573 return qed_rdma_start_fw(p_hwfn, params, p_ptt); 589 return qed_rdma_start_fw(p_hwfn, params, p_ptt);
574} 590}
575 591
576int qed_rdma_stop(void *rdma_cxt) 592static int qed_rdma_stop(void *rdma_cxt)
577{ 593{
578 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 594 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
579 struct rdma_close_func_ramrod_data *p_ramrod; 595 struct rdma_close_func_ramrod_data *p_ramrod;
@@ -629,8 +645,8 @@ out:
629 return rc; 645 return rc;
630} 646}
631 647
632int qed_rdma_add_user(void *rdma_cxt, 648static int qed_rdma_add_user(void *rdma_cxt,
633 struct qed_rdma_add_user_out_params *out_params) 649 struct qed_rdma_add_user_out_params *out_params)
634{ 650{
635 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 651 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
636 u32 dpi_start_offset; 652 u32 dpi_start_offset;
@@ -664,7 +680,7 @@ int qed_rdma_add_user(void *rdma_cxt,
664 return rc; 680 return rc;
665} 681}
666 682
667struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt) 683static struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt)
668{ 684{
669 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 685 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
670 struct qed_rdma_port *p_port = p_hwfn->p_rdma_info->port; 686 struct qed_rdma_port *p_port = p_hwfn->p_rdma_info->port;
@@ -680,7 +696,7 @@ struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt)
680 return p_port; 696 return p_port;
681} 697}
682 698
683struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt) 699static struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt)
684{ 700{
685 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 701 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
686 702
@@ -690,7 +706,7 @@ struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt)
690 return p_hwfn->p_rdma_info->dev; 706 return p_hwfn->p_rdma_info->dev;
691} 707}
692 708
693void qed_rdma_free_tid(void *rdma_cxt, u32 itid) 709static void qed_rdma_free_tid(void *rdma_cxt, u32 itid)
694{ 710{
695 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 711 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
696 712
@@ -701,27 +717,7 @@ void qed_rdma_free_tid(void *rdma_cxt, u32 itid)
701 spin_unlock_bh(&p_hwfn->p_rdma_info->lock); 717 spin_unlock_bh(&p_hwfn->p_rdma_info->lock);
702} 718}
703 719
704int qed_rdma_alloc_tid(void *rdma_cxt, u32 *itid) 720static void qed_rdma_cnq_prod_update(void *rdma_cxt, u8 qz_offset, u16 prod)
705{
706 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
707 int rc;
708
709 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID\n");
710
711 spin_lock_bh(&p_hwfn->p_rdma_info->lock);
712 rc = qed_rdma_bmap_alloc_id(p_hwfn,
713 &p_hwfn->p_rdma_info->tid_map, itid);
714 spin_unlock_bh(&p_hwfn->p_rdma_info->lock);
715 if (rc)
716 goto out;
717
718 rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_TASK, *itid);
719out:
720 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID - done, rc = %d\n", rc);
721 return rc;
722}
723
724void qed_rdma_cnq_prod_update(void *rdma_cxt, u8 qz_offset, u16 prod)
725{ 721{
726 struct qed_hwfn *p_hwfn; 722 struct qed_hwfn *p_hwfn;
727 u16 qz_num; 723 u16 qz_num;
@@ -816,7 +812,7 @@ static int qed_rdma_get_int(struct qed_dev *cdev, struct qed_int_info *info)
816 return 0; 812 return 0;
817} 813}
818 814
819int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd) 815static int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd)
820{ 816{
821 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 817 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
822 u32 returned_id; 818 u32 returned_id;
@@ -836,7 +832,7 @@ int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd)
836 return rc; 832 return rc;
837} 833}
838 834
839void qed_rdma_free_pd(void *rdma_cxt, u16 pd) 835static void qed_rdma_free_pd(void *rdma_cxt, u16 pd)
840{ 836{
841 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 837 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
842 838
@@ -873,8 +869,9 @@ qed_rdma_toggle_bit_create_resize_cq(struct qed_hwfn *p_hwfn, u16 icid)
873 return toggle_bit; 869 return toggle_bit;
874} 870}
875 871
876int qed_rdma_create_cq(void *rdma_cxt, 872static int qed_rdma_create_cq(void *rdma_cxt,
877 struct qed_rdma_create_cq_in_params *params, u16 *icid) 873 struct qed_rdma_create_cq_in_params *params,
874 u16 *icid)
878{ 875{
879 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 876 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
880 struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; 877 struct qed_rdma_info *p_info = p_hwfn->p_rdma_info;
@@ -957,98 +954,10 @@ err:
957 return rc; 954 return rc;
958} 955}
959 956
960int qed_rdma_resize_cq(void *rdma_cxt, 957static int
961 struct qed_rdma_resize_cq_in_params *in_params, 958qed_rdma_destroy_cq(void *rdma_cxt,
962 struct qed_rdma_resize_cq_out_params *out_params) 959 struct qed_rdma_destroy_cq_in_params *in_params,
963{ 960 struct qed_rdma_destroy_cq_out_params *out_params)
964 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
965 struct rdma_resize_cq_output_params *p_ramrod_res;
966 struct rdma_resize_cq_ramrod_data *p_ramrod;
967 enum qed_rdma_toggle_bit toggle_bit;
968 struct qed_sp_init_data init_data;
969 struct qed_spq_entry *p_ent;
970 dma_addr_t ramrod_res_phys;
971 u8 fw_return_code;
972 int rc = -ENOMEM;
973
974 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", in_params->icid);
975
976 p_ramrod_res =
977 (struct rdma_resize_cq_output_params *)
978 dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
979 sizeof(struct rdma_resize_cq_output_params),
980 &ramrod_res_phys, GFP_KERNEL);
981 if (!p_ramrod_res) {
982 DP_NOTICE(p_hwfn,
983 "qed resize cq failed: cannot allocate memory (ramrod)\n");
984 return rc;
985 }
986
987 /* Get SPQ entry */
988 memset(&init_data, 0, sizeof(init_data));
989 init_data.cid = in_params->icid;
990 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
991 init_data.comp_mode = QED_SPQ_MODE_EBLOCK;
992
993 rc = qed_sp_init_request(p_hwfn, &p_ent,
994 RDMA_RAMROD_RESIZE_CQ,
995 p_hwfn->p_rdma_info->proto, &init_data);
996 if (rc)
997 goto err;
998
999 p_ramrod = &p_ent->ramrod.rdma_resize_cq;
1000
1001 p_ramrod->flags = 0;
1002
1003 /* toggle the bit for every resize or create cq for a given icid */
1004 toggle_bit = qed_rdma_toggle_bit_create_resize_cq(p_hwfn,
1005 in_params->icid);
1006
1007 SET_FIELD(p_ramrod->flags,
1008 RDMA_RESIZE_CQ_RAMROD_DATA_TOGGLE_BIT, toggle_bit);
1009
1010 SET_FIELD(p_ramrod->flags,
1011 RDMA_RESIZE_CQ_RAMROD_DATA_IS_TWO_LEVEL_PBL,
1012 in_params->pbl_two_level);
1013
1014 p_ramrod->pbl_log_page_size = in_params->pbl_page_size_log - 12;
1015 p_ramrod->pbl_num_pages = cpu_to_le16(in_params->pbl_num_pages);
1016 p_ramrod->max_cqes = cpu_to_le32(in_params->cq_size);
1017 DMA_REGPAIR_LE(p_ramrod->pbl_addr, in_params->pbl_ptr);
1018 DMA_REGPAIR_LE(p_ramrod->output_params_addr, ramrod_res_phys);
1019
1020 rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code);
1021 if (rc)
1022 goto err;
1023
1024 if (fw_return_code != RDMA_RETURN_OK) {
1025 DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code);
1026 rc = -EINVAL;
1027 goto err;
1028 }
1029
1030 out_params->prod = le32_to_cpu(p_ramrod_res->old_cq_prod);
1031 out_params->cons = le32_to_cpu(p_ramrod_res->old_cq_cons);
1032
1033 dma_free_coherent(&p_hwfn->cdev->pdev->dev,
1034 sizeof(struct rdma_resize_cq_output_params),
1035 p_ramrod_res, ramrod_res_phys);
1036
1037 DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Resized CQ, rc = %d\n", rc);
1038
1039 return rc;
1040
1041err: dma_free_coherent(&p_hwfn->cdev->pdev->dev,
1042 sizeof(struct rdma_resize_cq_output_params),
1043 p_ramrod_res, ramrod_res_phys);
1044 DP_NOTICE(p_hwfn, "Resized CQ, Failed - rc = %d\n", rc);
1045
1046 return rc;
1047}
1048
1049int qed_rdma_destroy_cq(void *rdma_cxt,
1050 struct qed_rdma_destroy_cq_in_params *in_params,
1051 struct qed_rdma_destroy_cq_out_params *out_params)
1052{ 961{
1053 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 962 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
1054 struct rdma_destroy_cq_output_params *p_ramrod_res; 963 struct rdma_destroy_cq_output_params *p_ramrod_res;
@@ -1169,7 +1078,7 @@ static enum roce_flavor qed_roce_mode_to_flavor(enum roce_mode roce_mode)
1169 return flavor; 1078 return flavor;
1170} 1079}
1171 1080
1172int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid) 1081static int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid)
1173{ 1082{
1174 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; 1083 struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info;
1175 u32 responder_icid; 1084 u32 responder_icid;
@@ -1793,9 +1702,9 @@ err:
1793 return rc; 1702 return rc;
1794} 1703}
1795 1704
1796int qed_roce_query_qp(struct qed_hwfn *p_hwfn, 1705static int qed_roce_query_qp(struct qed_hwfn *p_hwfn,
1797 struct qed_rdma_qp *qp, 1706 struct qed_rdma_qp *qp,
1798 struct qed_rdma_query_qp_out_params *out_params) 1707 struct qed_rdma_query_qp_out_params *out_params)
1799{ 1708{
1800 struct roce_query_qp_resp_output_params *p_resp_ramrod_res; 1709 struct roce_query_qp_resp_output_params *p_resp_ramrod_res;
1801 struct roce_query_qp_req_output_params *p_req_ramrod_res; 1710 struct roce_query_qp_req_output_params *p_req_ramrod_res;
@@ -1936,7 +1845,7 @@ err_resp:
1936 return rc; 1845 return rc;
1937} 1846}
1938 1847
1939int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) 1848static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
1940{ 1849{
1941 u32 num_invalidated_mw = 0; 1850 u32 num_invalidated_mw = 0;
1942 u32 num_bound_mw = 0; 1851 u32 num_bound_mw = 0;
@@ -1985,9 +1894,9 @@ int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
1985 return 0; 1894 return 0;
1986} 1895}
1987 1896
1988int qed_rdma_query_qp(void *rdma_cxt, 1897static int qed_rdma_query_qp(void *rdma_cxt,
1989 struct qed_rdma_qp *qp, 1898 struct qed_rdma_qp *qp,
1990 struct qed_rdma_query_qp_out_params *out_params) 1899 struct qed_rdma_query_qp_out_params *out_params)
1991{ 1900{
1992 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 1901 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
1993 int rc; 1902 int rc;
@@ -2022,7 +1931,7 @@ int qed_rdma_query_qp(void *rdma_cxt,
2022 return rc; 1931 return rc;
2023} 1932}
2024 1933
2025int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp) 1934static int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp)
2026{ 1935{
2027 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 1936 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2028 int rc = 0; 1937 int rc = 0;
@@ -2038,7 +1947,7 @@ int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp)
2038 return rc; 1947 return rc;
2039} 1948}
2040 1949
2041struct qed_rdma_qp * 1950static struct qed_rdma_qp *
2042qed_rdma_create_qp(void *rdma_cxt, 1951qed_rdma_create_qp(void *rdma_cxt,
2043 struct qed_rdma_create_qp_in_params *in_params, 1952 struct qed_rdma_create_qp_in_params *in_params,
2044 struct qed_rdma_create_qp_out_params *out_params) 1953 struct qed_rdma_create_qp_out_params *out_params)
@@ -2215,9 +2124,9 @@ static int qed_roce_modify_qp(struct qed_hwfn *p_hwfn,
2215 return rc; 2124 return rc;
2216} 2125}
2217 2126
2218int qed_rdma_modify_qp(void *rdma_cxt, 2127static int qed_rdma_modify_qp(void *rdma_cxt,
2219 struct qed_rdma_qp *qp, 2128 struct qed_rdma_qp *qp,
2220 struct qed_rdma_modify_qp_in_params *params) 2129 struct qed_rdma_modify_qp_in_params *params)
2221{ 2130{
2222 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 2131 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2223 enum qed_roce_qp_state prev_state; 2132 enum qed_roce_qp_state prev_state;
@@ -2312,8 +2221,9 @@ int qed_rdma_modify_qp(void *rdma_cxt,
2312 return rc; 2221 return rc;
2313} 2222}
2314 2223
2315int qed_rdma_register_tid(void *rdma_cxt, 2224static int
2316 struct qed_rdma_register_tid_in_params *params) 2225qed_rdma_register_tid(void *rdma_cxt,
2226 struct qed_rdma_register_tid_in_params *params)
2317{ 2227{
2318 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 2228 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2319 struct rdma_register_tid_ramrod_data *p_ramrod; 2229 struct rdma_register_tid_ramrod_data *p_ramrod;
@@ -2450,7 +2360,7 @@ int qed_rdma_register_tid(void *rdma_cxt,
2450 return rc; 2360 return rc;
2451} 2361}
2452 2362
2453int qed_rdma_deregister_tid(void *rdma_cxt, u32 itid) 2363static int qed_rdma_deregister_tid(void *rdma_cxt, u32 itid)
2454{ 2364{
2455 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 2365 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2456 struct rdma_deregister_tid_ramrod_data *p_ramrod; 2366 struct rdma_deregister_tid_ramrod_data *p_ramrod;
@@ -2561,7 +2471,8 @@ void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
2561 qed_rdma_dpm_conf(p_hwfn, p_ptt); 2471 qed_rdma_dpm_conf(p_hwfn, p_ptt);
2562} 2472}
2563 2473
2564int qed_rdma_start(void *rdma_cxt, struct qed_rdma_start_in_params *params) 2474static int qed_rdma_start(void *rdma_cxt,
2475 struct qed_rdma_start_in_params *params)
2565{ 2476{
2566 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 2477 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2567 struct qed_ptt *p_ptt; 2478 struct qed_ptt *p_ptt;
@@ -2601,7 +2512,7 @@ static int qed_rdma_init(struct qed_dev *cdev,
2601 return qed_rdma_start(QED_LEADING_HWFN(cdev), params); 2512 return qed_rdma_start(QED_LEADING_HWFN(cdev), params);
2602} 2513}
2603 2514
2604void qed_rdma_remove_user(void *rdma_cxt, u16 dpi) 2515static void qed_rdma_remove_user(void *rdma_cxt, u16 dpi)
2605{ 2516{
2606 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; 2517 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt;
2607 2518
@@ -2809,11 +2720,6 @@ static int qed_roce_ll2_stop(struct qed_dev *cdev)
2809 struct qed_roce_ll2_info *roce_ll2 = hwfn->ll2; 2720 struct qed_roce_ll2_info *roce_ll2 = hwfn->ll2;
2810 int rc; 2721 int rc;
2811 2722
2812 if (!cdev) {
2813 DP_ERR(cdev, "qed roce ll2 stop: invalid cdev\n");
2814 return -EINVAL;
2815 }
2816
2817 if (roce_ll2->handle == QED_LL2_UNUSED_HANDLE) { 2723 if (roce_ll2->handle == QED_LL2_UNUSED_HANDLE) {
2818 DP_ERR(cdev, "qed roce ll2 stop: cannot stop an unused LL2\n"); 2724 DP_ERR(cdev, "qed roce ll2 stop: cannot stop an unused LL2\n");
2819 return -EINVAL; 2725 return -EINVAL;
@@ -2850,7 +2756,7 @@ static int qed_roce_ll2_tx(struct qed_dev *cdev,
2850 int rc; 2756 int rc;
2851 int i; 2757 int i;
2852 2758
2853 if (!cdev || !pkt || !params) { 2759 if (!pkt || !params) {
2854 DP_ERR(cdev, 2760 DP_ERR(cdev,
2855 "roce ll2 tx: failed tx because one of the following is NULL - drv=%p, pkt=%p, params=%p\n", 2761 "roce ll2 tx: failed tx because one of the following is NULL - drv=%p, pkt=%p, params=%p\n",
2856 cdev, pkt, params); 2762 cdev, pkt, params);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.h b/drivers/net/ethernet/qlogic/qed/qed_roce.h
index 2f091e8a0f40..279f342af8db 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_roce.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_roce.h
@@ -95,26 +95,6 @@ struct qed_rdma_info {
95 enum protocol_type proto; 95 enum protocol_type proto;
96}; 96};
97 97
98struct qed_rdma_resize_cq_in_params {
99 u16 icid;
100 u32 cq_size;
101 bool pbl_two_level;
102 u64 pbl_ptr;
103 u16 pbl_num_pages;
104 u8 pbl_page_size_log;
105};
106
107struct qed_rdma_resize_cq_out_params {
108 u32 prod;
109 u32 cons;
110};
111
112struct qed_rdma_resize_cnq_in_params {
113 u32 cnq_id;
114 u32 pbl_page_size_log;
115 u64 pbl_ptr;
116};
117
118struct qed_rdma_qp { 98struct qed_rdma_qp {
119 struct regpair qp_handle; 99 struct regpair qp_handle;
120 struct regpair qp_handle_async; 100 struct regpair qp_handle_async;
@@ -181,36 +161,55 @@ struct qed_rdma_qp {
181 dma_addr_t shared_queue_phys_addr; 161 dma_addr_t shared_queue_phys_addr;
182}; 162};
183 163
184int 164#if IS_ENABLED(CONFIG_QED_RDMA)
185qed_rdma_add_user(void *rdma_cxt, 165void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
186 struct qed_rdma_add_user_out_params *out_params);
187int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd);
188int qed_rdma_alloc_tid(void *rdma_cxt, u32 *tid);
189int qed_rdma_deregister_tid(void *rdma_cxt, u32 tid);
190void qed_rdma_free_tid(void *rdma_cxt, u32 tid);
191struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt);
192struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt);
193int
194qed_rdma_register_tid(void *rdma_cxt,
195 struct qed_rdma_register_tid_in_params *params);
196void qed_rdma_remove_user(void *rdma_cxt, u16 dpi);
197int qed_rdma_start(void *p_hwfn, struct qed_rdma_start_in_params *params);
198int qed_rdma_stop(void *rdma_cxt);
199u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id);
200u32 qed_rdma_query_cau_timer_res(void *p_hwfn);
201void qed_rdma_cnq_prod_update(void *rdma_cxt, u8 cnq_index, u16 prod);
202void qed_rdma_resc_free(struct qed_hwfn *p_hwfn);
203void qed_async_roce_event(struct qed_hwfn *p_hwfn, 166void qed_async_roce_event(struct qed_hwfn *p_hwfn,
204 struct event_ring_entry *p_eqe); 167 struct event_ring_entry *p_eqe);
205int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp); 168void qed_ll2b_complete_tx_gsi_packet(struct qed_hwfn *p_hwfn,
206int qed_rdma_modify_qp(void *rdma_cxt, struct qed_rdma_qp *qp, 169 u8 connection_handle,
207 struct qed_rdma_modify_qp_in_params *params); 170 void *cookie,
208int qed_rdma_query_qp(void *rdma_cxt, struct qed_rdma_qp *qp, 171 dma_addr_t first_frag_addr,
209 struct qed_rdma_query_qp_out_params *out_params); 172 bool b_last_fragment, bool b_last_packet);
210 173void qed_ll2b_release_tx_gsi_packet(struct qed_hwfn *p_hwfn,
211#if IS_ENABLED(CONFIG_INFINIBAND_QEDR) 174 u8 connection_handle,
212void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); 175 void *cookie,
176 dma_addr_t first_frag_addr,
177 bool b_last_fragment, bool b_last_packet);
178void qed_ll2b_complete_rx_gsi_packet(struct qed_hwfn *p_hwfn,
179 u8 connection_handle,
180 void *cookie,
181 dma_addr_t rx_buf_addr,
182 u16 data_length,
183 u8 data_length_error,
184 u16 parse_flags,
185 u16 vlan,
186 u32 src_mac_addr_hi,
187 u16 src_mac_addr_lo, bool b_last_packet);
213#else 188#else
214void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {} 189static inline void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {}
190static inline void qed_async_roce_event(struct qed_hwfn *p_hwfn, struct event_ring_entry *p_eqe) {}
191static inline void qed_ll2b_complete_tx_gsi_packet(struct qed_hwfn *p_hwfn,
192 u8 connection_handle,
193 void *cookie,
194 dma_addr_t first_frag_addr,
195 bool b_last_fragment,
196 bool b_last_packet) {}
197static inline void qed_ll2b_release_tx_gsi_packet(struct qed_hwfn *p_hwfn,
198 u8 connection_handle,
199 void *cookie,
200 dma_addr_t first_frag_addr,
201 bool b_last_fragment,
202 bool b_last_packet) {}
203static inline void qed_ll2b_complete_rx_gsi_packet(struct qed_hwfn *p_hwfn,
204 u8 connection_handle,
205 void *cookie,
206 dma_addr_t rx_buf_addr,
207 u16 data_length,
208 u8 data_length_error,
209 u16 parse_flags,
210 u16 vlan,
211 u32 src_mac_addr_hi,
212 u16 src_mac_addr_lo,
213 bool b_last_packet) {}
215#endif 214#endif
216#endif 215#endif
diff --git a/drivers/net/ethernet/qlogic/qed/qed_sp.h b/drivers/net/ethernet/qlogic/qed/qed_sp.h
index 652c90819758..b2c08e4d2a9b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_sp.h
@@ -80,7 +80,6 @@ union ramrod_data {
80 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp; 80 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp;
81 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req; 81 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req;
82 struct rdma_create_cq_ramrod_data rdma_create_cq; 82 struct rdma_create_cq_ramrod_data rdma_create_cq;
83 struct rdma_resize_cq_ramrod_data rdma_resize_cq;
84 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq; 83 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq;
85 struct rdma_srq_create_ramrod_data rdma_create_srq; 84 struct rdma_srq_create_ramrod_data rdma_create_srq;
86 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq; 85 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c
index caff41544898..9fbaf9429fd0 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_spq.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c
@@ -28,9 +28,7 @@
28#include "qed_reg_addr.h" 28#include "qed_reg_addr.h"
29#include "qed_sp.h" 29#include "qed_sp.h"
30#include "qed_sriov.h" 30#include "qed_sriov.h"
31#if IS_ENABLED(CONFIG_INFINIBAND_QEDR)
32#include "qed_roce.h" 31#include "qed_roce.h"
33#endif
34 32
35/*************************************************************************** 33/***************************************************************************
36* Structures & Definitions 34* Structures & Definitions
@@ -240,11 +238,9 @@ qed_async_event_completion(struct qed_hwfn *p_hwfn,
240 struct event_ring_entry *p_eqe) 238 struct event_ring_entry *p_eqe)
241{ 239{
242 switch (p_eqe->protocol_id) { 240 switch (p_eqe->protocol_id) {
243#if IS_ENABLED(CONFIG_INFINIBAND_QEDR)
244 case PROTOCOLID_ROCE: 241 case PROTOCOLID_ROCE:
245 qed_async_roce_event(p_hwfn, p_eqe); 242 qed_async_roce_event(p_hwfn, p_eqe);
246 return 0; 243 return 0;
247#endif
248 case PROTOCOLID_COMMON: 244 case PROTOCOLID_COMMON:
249 return qed_sriov_eqe_event(p_hwfn, 245 return qed_sriov_eqe_event(p_hwfn,
250 p_eqe->opcode, 246 p_eqe->opcode,
diff --git a/drivers/net/ethernet/qlogic/qede/Makefile b/drivers/net/ethernet/qlogic/qede/Makefile
index 28dc58919c85..048a230c3ce0 100644
--- a/drivers/net/ethernet/qlogic/qede/Makefile
+++ b/drivers/net/ethernet/qlogic/qede/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_QEDE) := qede.o
2 2
3qede-y := qede_main.o qede_ethtool.o 3qede-y := qede_main.o qede_ethtool.o
4qede-$(CONFIG_DCB) += qede_dcbnl.o 4qede-$(CONFIG_DCB) += qede_dcbnl.o
5qede-$(CONFIG_INFINIBAND_QEDR) += qede_roce.o 5qede-$(CONFIG_QED_RDMA) += qede_roce.o
diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h
index 28c0e9f42c9e..974689a13337 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -348,12 +348,13 @@ bool qede_has_rx_work(struct qede_rx_queue *rxq);
348int qede_txq_has_work(struct qede_tx_queue *txq); 348int qede_txq_has_work(struct qede_tx_queue *txq);
349void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, struct qede_dev *edev, 349void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, struct qede_dev *edev,
350 u8 count); 350 u8 count);
351void qede_update_rx_prod(struct qede_dev *edev, struct qede_rx_queue *rxq);
351 352
352#define RX_RING_SIZE_POW 13 353#define RX_RING_SIZE_POW 13
353#define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE_POW)) 354#define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE_POW))
354#define NUM_RX_BDS_MAX (RX_RING_SIZE - 1) 355#define NUM_RX_BDS_MAX (RX_RING_SIZE - 1)
355#define NUM_RX_BDS_MIN 128 356#define NUM_RX_BDS_MIN 128
356#define NUM_RX_BDS_DEF NUM_RX_BDS_MAX 357#define NUM_RX_BDS_DEF ((u16)BIT(10) - 1)
357 358
358#define TX_RING_SIZE_POW 13 359#define TX_RING_SIZE_POW 13
359#define TX_RING_SIZE ((u16)BIT(TX_RING_SIZE_POW)) 360#define TX_RING_SIZE ((u16)BIT(TX_RING_SIZE_POW))
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index 25a9b293ee8f..12251a1032d1 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -756,6 +756,8 @@ static void qede_get_channels(struct net_device *dev,
756 struct qede_dev *edev = netdev_priv(dev); 756 struct qede_dev *edev = netdev_priv(dev);
757 757
758 channels->max_combined = QEDE_MAX_RSS_CNT(edev); 758 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
759 channels->max_rx = QEDE_MAX_RSS_CNT(edev);
760 channels->max_tx = QEDE_MAX_RSS_CNT(edev);
759 channels->combined_count = QEDE_QUEUE_CNT(edev) - edev->fp_num_tx - 761 channels->combined_count = QEDE_QUEUE_CNT(edev) - edev->fp_num_tx -
760 edev->fp_num_rx; 762 edev->fp_num_rx;
761 channels->tx_count = edev->fp_num_tx; 763 channels->tx_count = edev->fp_num_tx;
@@ -820,6 +822,13 @@ static int qede_set_channels(struct net_device *dev,
820 edev->req_queues = count; 822 edev->req_queues = count;
821 edev->req_num_tx = channels->tx_count; 823 edev->req_num_tx = channels->tx_count;
822 edev->req_num_rx = channels->rx_count; 824 edev->req_num_rx = channels->rx_count;
825 /* Reset the indirection table if rx queue count is updated */
826 if ((edev->req_queues - edev->req_num_tx) != QEDE_RSS_COUNT(edev)) {
827 edev->rss_params_inited &= ~QEDE_RSS_INDIR_INITED;
828 memset(&edev->rss_params.rss_ind_table, 0,
829 sizeof(edev->rss_params.rss_ind_table));
830 }
831
823 if (netif_running(dev)) 832 if (netif_running(dev))
824 qede_reload(edev, NULL, NULL); 833 qede_reload(edev, NULL, NULL);
825 834
@@ -1053,6 +1062,12 @@ static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
1053 struct qede_dev *edev = netdev_priv(dev); 1062 struct qede_dev *edev = netdev_priv(dev);
1054 int i; 1063 int i;
1055 1064
1065 if (edev->dev_info.common.num_hwfns > 1) {
1066 DP_INFO(edev,
1067 "RSS configuration is not supported for 100G devices\n");
1068 return -EOPNOTSUPP;
1069 }
1070
1056 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) 1071 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1057 return -EOPNOTSUPP; 1072 return -EOPNOTSUPP;
1058 1073
@@ -1184,8 +1199,8 @@ static int qede_selftest_transmit_traffic(struct qede_dev *edev,
1184 } 1199 }
1185 1200
1186 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl); 1201 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl);
1187 dma_unmap_page(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd), 1202 dma_unmap_single(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
1188 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE); 1203 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE);
1189 txq->sw_tx_cons++; 1204 txq->sw_tx_cons++;
1190 txq->sw_tx_ring[idx].skb = NULL; 1205 txq->sw_tx_ring[idx].skb = NULL;
1191 1206
@@ -1199,8 +1214,8 @@ static int qede_selftest_receive_traffic(struct qede_dev *edev)
1199 struct qede_rx_queue *rxq = NULL; 1214 struct qede_rx_queue *rxq = NULL;
1200 struct sw_rx_data *sw_rx_data; 1215 struct sw_rx_data *sw_rx_data;
1201 union eth_rx_cqe *cqe; 1216 union eth_rx_cqe *cqe;
1217 int i, rc = 0;
1202 u8 *data_ptr; 1218 u8 *data_ptr;
1203 int i;
1204 1219
1205 for_each_queue(i) { 1220 for_each_queue(i) {
1206 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) { 1221 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
@@ -1219,46 +1234,60 @@ static int qede_selftest_receive_traffic(struct qede_dev *edev)
1219 * queue and that the loopback traffic is not IP. 1234 * queue and that the loopback traffic is not IP.
1220 */ 1235 */
1221 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) { 1236 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1222 if (qede_has_rx_work(rxq)) 1237 if (!qede_has_rx_work(rxq)) {
1238 usleep_range(100, 200);
1239 continue;
1240 }
1241
1242 hw_comp_cons = le16_to_cpu(*rxq->hw_cons_ptr);
1243 sw_comp_cons = qed_chain_get_cons_idx(&rxq->rx_comp_ring);
1244
1245 /* Memory barrier to prevent the CPU from doing speculative
1246 * reads of CQE/BD before reading hw_comp_cons. If the CQE is
1247 * read before it is written by FW, then FW writes CQE and SB,
1248 * and then the CPU reads the hw_comp_cons, it will use an old
1249 * CQE.
1250 */
1251 rmb();
1252
1253 /* Get the CQE from the completion ring */
1254 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1255
1256 /* Get the data from the SW ring */
1257 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1258 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1259 fp_cqe = &cqe->fast_path_regular;
1260 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1261 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1262 fp_cqe->placement_offset +
1263 sw_rx_data->page_offset);
1264 if (ether_addr_equal(data_ptr, edev->ndev->dev_addr) &&
1265 ether_addr_equal(data_ptr + ETH_ALEN,
1266 edev->ndev->dev_addr)) {
1267 for (i = ETH_HLEN; i < len; i++)
1268 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1269 rc = -1;
1270 break;
1271 }
1272
1273 qede_recycle_rx_bd_ring(rxq, edev, 1);
1274 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1223 break; 1275 break;
1224 usleep_range(100, 200); 1276 }
1277
1278 DP_INFO(edev, "Not the transmitted packet\n");
1279 qede_recycle_rx_bd_ring(rxq, edev, 1);
1280 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1225 } 1281 }
1226 1282
1227 if (!qede_has_rx_work(rxq)) { 1283 if (i == QEDE_SELFTEST_POLL_COUNT) {
1228 DP_NOTICE(edev, "Failed to receive the traffic\n"); 1284 DP_NOTICE(edev, "Failed to receive the traffic\n");
1229 return -1; 1285 return -1;
1230 } 1286 }
1231 1287
1232 hw_comp_cons = le16_to_cpu(*rxq->hw_cons_ptr); 1288 qede_update_rx_prod(edev, rxq);
1233 sw_comp_cons = qed_chain_get_cons_idx(&rxq->rx_comp_ring);
1234 1289
1235 /* Memory barrier to prevent the CPU from doing speculative reads of CQE 1290 return rc;
1236 * / BD before reading hw_comp_cons. If the CQE is read before it is
1237 * written by FW, then FW writes CQE and SB, and then the CPU reads the
1238 * hw_comp_cons, it will use an old CQE.
1239 */
1240 rmb();
1241
1242 /* Get the CQE from the completion ring */
1243 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1244
1245 /* Get the data from the SW ring */
1246 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1247 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1248 fp_cqe = &cqe->fast_path_regular;
1249 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1250 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1251 fp_cqe->placement_offset + sw_rx_data->page_offset);
1252 for (i = ETH_HLEN; i < len; i++)
1253 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1254 DP_NOTICE(edev, "Loopback test failed\n");
1255 qede_recycle_rx_bd_ring(rxq, edev, 1);
1256 return -1;
1257 }
1258
1259 qede_recycle_rx_bd_ring(rxq, edev, 1);
1260
1261 return 0;
1262} 1291}
1263 1292
1264static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode) 1293static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 343038ca047d..7def29aaf65c 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -313,8 +313,8 @@ static int qede_free_tx_pkt(struct qede_dev *edev,
313 split_bd_len = BD_UNMAP_LEN(split); 313 split_bd_len = BD_UNMAP_LEN(split);
314 bds_consumed++; 314 bds_consumed++;
315 } 315 }
316 dma_unmap_page(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd), 316 dma_unmap_single(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
317 BD_UNMAP_LEN(first_bd) + split_bd_len, DMA_TO_DEVICE); 317 BD_UNMAP_LEN(first_bd) + split_bd_len, DMA_TO_DEVICE);
318 318
319 /* Unmap the data of the skb frags */ 319 /* Unmap the data of the skb frags */
320 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, bds_consumed++) { 320 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, bds_consumed++) {
@@ -359,8 +359,8 @@ static void qede_free_failed_tx_pkt(struct qede_dev *edev,
359 nbd--; 359 nbd--;
360 } 360 }
361 361
362 dma_unmap_page(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd), 362 dma_unmap_single(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
363 BD_UNMAP_LEN(first_bd) + split_bd_len, DMA_TO_DEVICE); 363 BD_UNMAP_LEN(first_bd) + split_bd_len, DMA_TO_DEVICE);
364 364
365 /* Unmap the data of the skb frags */ 365 /* Unmap the data of the skb frags */
366 for (i = 0; i < nbd; i++) { 366 for (i = 0; i < nbd; i++) {
@@ -943,8 +943,7 @@ static inline int qede_realloc_rx_buffer(struct qede_dev *edev,
943 return 0; 943 return 0;
944} 944}
945 945
946static inline void qede_update_rx_prod(struct qede_dev *edev, 946void qede_update_rx_prod(struct qede_dev *edev, struct qede_rx_queue *rxq)
947 struct qede_rx_queue *rxq)
948{ 947{
949 u16 bd_prod = qed_chain_get_prod_idx(&rxq->rx_bd_ring); 948 u16 bd_prod = qed_chain_get_prod_idx(&rxq->rx_bd_ring);
950 u16 cqe_prod = qed_chain_get_prod_idx(&rxq->rx_comp_ring); 949 u16 cqe_prod = qed_chain_get_prod_idx(&rxq->rx_comp_ring);
@@ -2941,7 +2940,7 @@ static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
2941 txq->num_tx_buffers = edev->q_num_tx_buffers; 2940 txq->num_tx_buffers = edev->q_num_tx_buffers;
2942 2941
2943 /* Allocate the parallel driver ring for Tx buffers */ 2942 /* Allocate the parallel driver ring for Tx buffers */
2944 size = sizeof(*txq->sw_tx_ring) * NUM_TX_BDS_MAX; 2943 size = sizeof(*txq->sw_tx_ring) * TX_RING_SIZE;
2945 txq->sw_tx_ring = kzalloc(size, GFP_KERNEL); 2944 txq->sw_tx_ring = kzalloc(size, GFP_KERNEL);
2946 if (!txq->sw_tx_ring) { 2945 if (!txq->sw_tx_ring) {
2947 DP_NOTICE(edev, "Tx buffers ring allocation failed\n"); 2946 DP_NOTICE(edev, "Tx buffers ring allocation failed\n");
@@ -2952,7 +2951,7 @@ static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
2952 QED_CHAIN_USE_TO_CONSUME_PRODUCE, 2951 QED_CHAIN_USE_TO_CONSUME_PRODUCE,
2953 QED_CHAIN_MODE_PBL, 2952 QED_CHAIN_MODE_PBL,
2954 QED_CHAIN_CNT_TYPE_U16, 2953 QED_CHAIN_CNT_TYPE_U16,
2955 NUM_TX_BDS_MAX, 2954 TX_RING_SIZE,
2956 sizeof(*p_virt), &txq->tx_pbl); 2955 sizeof(*p_virt), &txq->tx_pbl);
2957 if (rc) 2956 if (rc)
2958 goto err; 2957 goto err;
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
index e97968ed4b8f..6fb3bee904d3 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
@@ -1021,14 +1021,18 @@ void emac_mac_down(struct emac_adapter *adpt)
1021 napi_disable(&adpt->rx_q.napi); 1021 napi_disable(&adpt->rx_q.napi);
1022 1022
1023 phy_stop(adpt->phydev); 1023 phy_stop(adpt->phydev);
1024 phy_disconnect(adpt->phydev);
1025 1024
1026 /* disable mac irq */ 1025 /* Interrupts must be disabled before the PHY is disconnected, to
1026 * avoid a race condition where adjust_link is null when we get
1027 * an interrupt.
1028 */
1027 writel(DIS_INT, adpt->base + EMAC_INT_STATUS); 1029 writel(DIS_INT, adpt->base + EMAC_INT_STATUS);
1028 writel(0, adpt->base + EMAC_INT_MASK); 1030 writel(0, adpt->base + EMAC_INT_MASK);
1029 synchronize_irq(adpt->irq.irq); 1031 synchronize_irq(adpt->irq.irq);
1030 free_irq(adpt->irq.irq, &adpt->irq); 1032 free_irq(adpt->irq.irq, &adpt->irq);
1031 1033
1034 phy_disconnect(adpt->phydev);
1035
1032 emac_mac_reset(adpt); 1036 emac_mac_reset(adpt);
1033 1037
1034 emac_tx_q_descs_free(adpt); 1038 emac_tx_q_descs_free(adpt);
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 9bf3b2b82e95..4fede4b86538 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -575,6 +575,7 @@ static const struct of_device_id emac_dt_match[] = {
575 }, 575 },
576 {} 576 {}
577}; 577};
578MODULE_DEVICE_TABLE(of, emac_dt_match);
578 579
579#if IS_ENABLED(CONFIG_ACPI) 580#if IS_ENABLED(CONFIG_ACPI)
580static const struct acpi_device_id emac_acpi_match[] = { 581static const struct acpi_device_id emac_acpi_match[] = {
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index e55638c7505a..bf000d819a21 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -8273,7 +8273,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8273 if ((sizeof(dma_addr_t) > 4) && 8273 if ((sizeof(dma_addr_t) > 4) &&
8274 (use_dac == 1 || (use_dac == -1 && pci_is_pcie(pdev) && 8274 (use_dac == 1 || (use_dac == -1 && pci_is_pcie(pdev) &&
8275 tp->mac_version >= RTL_GIGA_MAC_VER_18)) && 8275 tp->mac_version >= RTL_GIGA_MAC_VER_18)) &&
8276 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { 8276 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
8277 !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
8277 8278
8278 /* CPlusCmd Dual Access Cycle is only needed for non-PCIe */ 8279 /* CPlusCmd Dual Access Cycle is only needed for non-PCIe */
8279 if (!pci_is_pcie(pdev)) 8280 if (!pci_is_pcie(pdev))
diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index 5424fb341613..24b746406bc7 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1471,7 +1471,7 @@ static int rocker_world_check_init(struct rocker_port *rocker_port)
1471 if (rocker->wops) { 1471 if (rocker->wops) {
1472 if (rocker->wops->mode != mode) { 1472 if (rocker->wops->mode != mode) {
1473 dev_err(&rocker->pdev->dev, "hardware has ports in different worlds, which is not supported\n"); 1473 dev_err(&rocker->pdev->dev, "hardware has ports in different worlds, which is not supported\n");
1474 return err; 1474 return -EINVAL;
1475 } 1475 }
1476 return 0; 1476 return 0;
1477 } 1477 }
diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
index 431a60804272..4ca461322d60 100644
--- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
+++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
@@ -1493,8 +1493,6 @@ static int ofdpa_port_ipv4_nh(struct ofdpa_port *ofdpa_port,
1493 spin_lock_irqsave(&ofdpa->neigh_tbl_lock, lock_flags); 1493 spin_lock_irqsave(&ofdpa->neigh_tbl_lock, lock_flags);
1494 1494
1495 found = ofdpa_neigh_tbl_find(ofdpa, ip_addr); 1495 found = ofdpa_neigh_tbl_find(ofdpa, ip_addr);
1496 if (found)
1497 *index = found->index;
1498 1496
1499 updating = found && adding; 1497 updating = found && adding;
1500 removing = found && !adding; 1498 removing = found && !adding;
@@ -1508,9 +1506,11 @@ static int ofdpa_port_ipv4_nh(struct ofdpa_port *ofdpa_port,
1508 resolved = false; 1506 resolved = false;
1509 } else if (removing) { 1507 } else if (removing) {
1510 ofdpa_neigh_del(trans, found); 1508 ofdpa_neigh_del(trans, found);
1509 *index = found->index;
1511 } else if (updating) { 1510 } else if (updating) {
1512 ofdpa_neigh_update(found, trans, NULL, false); 1511 ofdpa_neigh_update(found, trans, NULL, false);
1513 resolved = !is_zero_ether_addr(found->eth_dst); 1512 resolved = !is_zero_ether_addr(found->eth_dst);
1513 *index = found->index;
1514 } else { 1514 } else {
1515 err = -ENOENT; 1515 err = -ENOENT;
1516 } 1516 }
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index 4ec7397e7fb3..a1b17cd7886b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -347,10 +347,9 @@ static void dwmac4_display_ring(void *head, unsigned int size, bool rx)
347 pr_info("%s descriptor ring:\n", rx ? "RX" : "TX"); 347 pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
348 348
349 for (i = 0; i < size; i++) { 349 for (i = 0; i < size; i++) {
350 if (p->des0) 350 pr_info("%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
351 pr_info("%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", 351 i, (unsigned int)virt_to_phys(p),
352 i, (unsigned int)virt_to_phys(p), 352 p->des0, p->des1, p->des2, p->des3);
353 p->des0, p->des1, p->des2, p->des3);
354 p++; 353 p++;
355 } 354 }
356} 355}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 8dc9056c1001..b15fc55f1b96 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -145,7 +145,7 @@ int stmmac_mdio_register(struct net_device *ndev);
145int stmmac_mdio_reset(struct mii_bus *mii); 145int stmmac_mdio_reset(struct mii_bus *mii);
146void stmmac_set_ethtool_ops(struct net_device *netdev); 146void stmmac_set_ethtool_ops(struct net_device *netdev);
147 147
148int stmmac_ptp_register(struct stmmac_priv *priv); 148void stmmac_ptp_register(struct stmmac_priv *priv);
149void stmmac_ptp_unregister(struct stmmac_priv *priv); 149void stmmac_ptp_unregister(struct stmmac_priv *priv);
150int stmmac_resume(struct device *dev); 150int stmmac_resume(struct device *dev);
151int stmmac_suspend(struct device *dev); 151int stmmac_suspend(struct device *dev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6c85b61aaa0b..48e71fad4210 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -676,7 +676,9 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
676 priv->hwts_tx_en = 0; 676 priv->hwts_tx_en = 0;
677 priv->hwts_rx_en = 0; 677 priv->hwts_rx_en = 0;
678 678
679 return stmmac_ptp_register(priv); 679 stmmac_ptp_register(priv);
680
681 return 0;
680} 682}
681 683
682static void stmmac_release_ptp(struct stmmac_priv *priv) 684static void stmmac_release_ptp(struct stmmac_priv *priv)
@@ -1710,7 +1712,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
1710 if (init_ptp) { 1712 if (init_ptp) {
1711 ret = stmmac_init_ptp(priv); 1713 ret = stmmac_init_ptp(priv);
1712 if (ret) 1714 if (ret)
1713 netdev_warn(priv->dev, "PTP support cannot init.\n"); 1715 netdev_warn(priv->dev, "fail to init PTP.\n");
1714 } 1716 }
1715 1717
1716#ifdef CONFIG_DEBUG_FS 1718#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 289d52725a6c..1477471f8d44 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -177,7 +177,7 @@ static struct ptp_clock_info stmmac_ptp_clock_ops = {
177 * Description: this function will register the ptp clock driver 177 * Description: this function will register the ptp clock driver
178 * to kernel. It also does some house keeping work. 178 * to kernel. It also does some house keeping work.
179 */ 179 */
180int stmmac_ptp_register(struct stmmac_priv *priv) 180void stmmac_ptp_register(struct stmmac_priv *priv)
181{ 181{
182 spin_lock_init(&priv->ptp_lock); 182 spin_lock_init(&priv->ptp_lock);
183 priv->ptp_clock_ops = stmmac_ptp_clock_ops; 183 priv->ptp_clock_ops = stmmac_ptp_clock_ops;
@@ -185,15 +185,10 @@ int stmmac_ptp_register(struct stmmac_priv *priv)
185 priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops, 185 priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops,
186 priv->device); 186 priv->device);
187 if (IS_ERR(priv->ptp_clock)) { 187 if (IS_ERR(priv->ptp_clock)) {
188 netdev_err(priv->dev, "ptp_clock_register failed\n");
188 priv->ptp_clock = NULL; 189 priv->ptp_clock = NULL;
189 return PTR_ERR(priv->ptp_clock); 190 } else if (priv->ptp_clock)
190 } 191 netdev_info(priv->dev, "registered PTP clock\n");
191
192 spin_lock_init(&priv->ptp_lock);
193
194 netdev_dbg(priv->dev, "Added PTP HW clock successfully\n");
195
196 return 0;
197} 192}
198 193
199/** 194/**
diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 0d0053128542..5eedac495077 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -982,11 +982,13 @@ static int dwceqos_mii_probe(struct net_device *ndev)
982 if (netif_msg_probe(lp)) 982 if (netif_msg_probe(lp))
983 phy_attached_info(phydev); 983 phy_attached_info(phydev);
984 984
985 phydev->supported &= PHY_GBIT_FEATURES; 985 phydev->supported &= PHY_GBIT_FEATURES | SUPPORTED_Pause |
986 SUPPORTED_Asym_Pause;
986 987
987 lp->link = 0; 988 lp->link = 0;
988 lp->speed = 0; 989 lp->speed = 0;
989 lp->duplex = DUPLEX_UNKNOWN; 990 lp->duplex = DUPLEX_UNKNOWN;
991 lp->flowcontrol.autoneg = AUTONEG_ENABLE;
990 992
991 return 0; 993 return 0;
992} 994}
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 3c20e87bb761..42edd7b7902f 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -58,9 +58,9 @@ struct geneve_dev {
58 struct hlist_node hlist; /* vni hash table */ 58 struct hlist_node hlist; /* vni hash table */
59 struct net *net; /* netns for packet i/o */ 59 struct net *net; /* netns for packet i/o */
60 struct net_device *dev; /* netdev for geneve tunnel */ 60 struct net_device *dev; /* netdev for geneve tunnel */
61 struct geneve_sock *sock4; /* IPv4 socket used for geneve tunnel */ 61 struct geneve_sock __rcu *sock4; /* IPv4 socket used for geneve tunnel */
62#if IS_ENABLED(CONFIG_IPV6) 62#if IS_ENABLED(CONFIG_IPV6)
63 struct geneve_sock *sock6; /* IPv6 socket used for geneve tunnel */ 63 struct geneve_sock __rcu *sock6; /* IPv6 socket used for geneve tunnel */
64#endif 64#endif
65 u8 vni[3]; /* virtual network ID for tunnel */ 65 u8 vni[3]; /* virtual network ID for tunnel */
66 u8 ttl; /* TTL override */ 66 u8 ttl; /* TTL override */
@@ -453,7 +453,7 @@ static struct sk_buff **geneve_gro_receive(struct sock *sk,
453 453
454 skb_gro_pull(skb, gh_len); 454 skb_gro_pull(skb, gh_len);
455 skb_gro_postpull_rcsum(skb, gh, gh_len); 455 skb_gro_postpull_rcsum(skb, gh, gh_len);
456 pp = ptype->callbacks.gro_receive(head, skb); 456 pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
457 flush = 0; 457 flush = 0;
458 458
459out_unlock: 459out_unlock:
@@ -543,9 +543,19 @@ static void __geneve_sock_release(struct geneve_sock *gs)
543 543
544static void geneve_sock_release(struct geneve_dev *geneve) 544static void geneve_sock_release(struct geneve_dev *geneve)
545{ 545{
546 __geneve_sock_release(geneve->sock4); 546 struct geneve_sock *gs4 = rtnl_dereference(geneve->sock4);
547#if IS_ENABLED(CONFIG_IPV6) 547#if IS_ENABLED(CONFIG_IPV6)
548 __geneve_sock_release(geneve->sock6); 548 struct geneve_sock *gs6 = rtnl_dereference(geneve->sock6);
549
550 rcu_assign_pointer(geneve->sock6, NULL);
551#endif
552
553 rcu_assign_pointer(geneve->sock4, NULL);
554 synchronize_net();
555
556 __geneve_sock_release(gs4);
557#if IS_ENABLED(CONFIG_IPV6)
558 __geneve_sock_release(gs6);
549#endif 559#endif
550} 560}
551 561
@@ -586,10 +596,10 @@ out:
586 gs->flags = geneve->flags; 596 gs->flags = geneve->flags;
587#if IS_ENABLED(CONFIG_IPV6) 597#if IS_ENABLED(CONFIG_IPV6)
588 if (ipv6) 598 if (ipv6)
589 geneve->sock6 = gs; 599 rcu_assign_pointer(geneve->sock6, gs);
590 else 600 else
591#endif 601#endif
592 geneve->sock4 = gs; 602 rcu_assign_pointer(geneve->sock4, gs);
593 603
594 hash = geneve_net_vni_hash(geneve->vni); 604 hash = geneve_net_vni_hash(geneve->vni);
595 hlist_add_head_rcu(&geneve->hlist, &gs->vni_list[hash]); 605 hlist_add_head_rcu(&geneve->hlist, &gs->vni_list[hash]);
@@ -603,9 +613,7 @@ static int geneve_open(struct net_device *dev)
603 bool metadata = geneve->collect_md; 613 bool metadata = geneve->collect_md;
604 int ret = 0; 614 int ret = 0;
605 615
606 geneve->sock4 = NULL;
607#if IS_ENABLED(CONFIG_IPV6) 616#if IS_ENABLED(CONFIG_IPV6)
608 geneve->sock6 = NULL;
609 if (ipv6 || metadata) 617 if (ipv6 || metadata)
610 ret = geneve_sock_add(geneve, true); 618 ret = geneve_sock_add(geneve, true);
611#endif 619#endif
@@ -720,6 +728,9 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,
720 struct rtable *rt = NULL; 728 struct rtable *rt = NULL;
721 __u8 tos; 729 __u8 tos;
722 730
731 if (!rcu_dereference(geneve->sock4))
732 return ERR_PTR(-EIO);
733
723 memset(fl4, 0, sizeof(*fl4)); 734 memset(fl4, 0, sizeof(*fl4));
724 fl4->flowi4_mark = skb->mark; 735 fl4->flowi4_mark = skb->mark;
725 fl4->flowi4_proto = IPPROTO_UDP; 736 fl4->flowi4_proto = IPPROTO_UDP;
@@ -772,11 +783,15 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
772{ 783{
773 bool use_cache = ip_tunnel_dst_cache_usable(skb, info); 784 bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
774 struct geneve_dev *geneve = netdev_priv(dev); 785 struct geneve_dev *geneve = netdev_priv(dev);
775 struct geneve_sock *gs6 = geneve->sock6;
776 struct dst_entry *dst = NULL; 786 struct dst_entry *dst = NULL;
777 struct dst_cache *dst_cache; 787 struct dst_cache *dst_cache;
788 struct geneve_sock *gs6;
778 __u8 prio; 789 __u8 prio;
779 790
791 gs6 = rcu_dereference(geneve->sock6);
792 if (!gs6)
793 return ERR_PTR(-EIO);
794
780 memset(fl6, 0, sizeof(*fl6)); 795 memset(fl6, 0, sizeof(*fl6));
781 fl6->flowi6_mark = skb->mark; 796 fl6->flowi6_mark = skb->mark;
782 fl6->flowi6_proto = IPPROTO_UDP; 797 fl6->flowi6_proto = IPPROTO_UDP;
@@ -842,7 +857,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
842 struct ip_tunnel_info *info) 857 struct ip_tunnel_info *info)
843{ 858{
844 struct geneve_dev *geneve = netdev_priv(dev); 859 struct geneve_dev *geneve = netdev_priv(dev);
845 struct geneve_sock *gs4 = geneve->sock4; 860 struct geneve_sock *gs4;
846 struct rtable *rt = NULL; 861 struct rtable *rt = NULL;
847 const struct iphdr *iip; /* interior IP header */ 862 const struct iphdr *iip; /* interior IP header */
848 int err = -EINVAL; 863 int err = -EINVAL;
@@ -853,6 +868,10 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
853 bool xnet = !net_eq(geneve->net, dev_net(geneve->dev)); 868 bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
854 u32 flags = geneve->flags; 869 u32 flags = geneve->flags;
855 870
871 gs4 = rcu_dereference(geneve->sock4);
872 if (!gs4)
873 goto tx_error;
874
856 if (geneve->collect_md) { 875 if (geneve->collect_md) {
857 if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) { 876 if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) {
858 netdev_dbg(dev, "no tunnel metadata\n"); 877 netdev_dbg(dev, "no tunnel metadata\n");
@@ -932,9 +951,9 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
932 struct ip_tunnel_info *info) 951 struct ip_tunnel_info *info)
933{ 952{
934 struct geneve_dev *geneve = netdev_priv(dev); 953 struct geneve_dev *geneve = netdev_priv(dev);
935 struct geneve_sock *gs6 = geneve->sock6;
936 struct dst_entry *dst = NULL; 954 struct dst_entry *dst = NULL;
937 const struct iphdr *iip; /* interior IP header */ 955 const struct iphdr *iip; /* interior IP header */
956 struct geneve_sock *gs6;
938 int err = -EINVAL; 957 int err = -EINVAL;
939 struct flowi6 fl6; 958 struct flowi6 fl6;
940 __u8 prio, ttl; 959 __u8 prio, ttl;
@@ -943,6 +962,10 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
943 bool xnet = !net_eq(geneve->net, dev_net(geneve->dev)); 962 bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
944 u32 flags = geneve->flags; 963 u32 flags = geneve->flags;
945 964
965 gs6 = rcu_dereference(geneve->sock6);
966 if (!gs6)
967 goto tx_error;
968
946 if (geneve->collect_md) { 969 if (geneve->collect_md) {
947 if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) { 970 if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) {
948 netdev_dbg(dev, "no tunnel metadata\n"); 971 netdev_dbg(dev, "no tunnel metadata\n");
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f0919bd3a563..f6382150b16a 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -447,7 +447,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
447 * Setup the sendside checksum offload only if this is not a 447 * Setup the sendside checksum offload only if this is not a
448 * GSO packet. 448 * GSO packet.
449 */ 449 */
450 if (skb_is_gso(skb)) { 450 if ((net_trans_info & (INFO_TCP | INFO_UDP)) && skb_is_gso(skb)) {
451 struct ndis_tcp_lso_info *lso_info; 451 struct ndis_tcp_lso_info *lso_info;
452 452
453 rndis_msg_size += NDIS_LSO_PPI_SIZE; 453 rndis_msg_size += NDIS_LSO_PPI_SIZE;
@@ -607,15 +607,18 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net,
607 packet->total_data_buflen); 607 packet->total_data_buflen);
608 608
609 skb->protocol = eth_type_trans(skb, net); 609 skb->protocol = eth_type_trans(skb, net);
610 if (csum_info) { 610
611 /* We only look at the IP checksum here. 611 /* skb is already created with CHECKSUM_NONE */
612 * Should we be dropping the packet if checksum 612 skb_checksum_none_assert(skb);
613 * failed? How do we deal with other checksums - TCP/UDP? 613
614 */ 614 /*
615 if (csum_info->receive.ip_checksum_succeeded) 615 * In Linux, the IP checksum is always checked.
616 * Do L4 checksum offload if enabled and present.
617 */
618 if (csum_info && (net->features & NETIF_F_RXCSUM)) {
619 if (csum_info->receive.tcp_checksum_succeeded ||
620 csum_info->receive.udp_checksum_succeeded)
616 skb->ip_summed = CHECKSUM_UNNECESSARY; 621 skb->ip_summed = CHECKSUM_UNNECESSARY;
617 else
618 skb->ip_summed = CHECKSUM_NONE;
619 } 622 }
620 623
621 if (vlan_tci & VLAN_TAG_PRESENT) 624 if (vlan_tci & VLAN_TAG_PRESENT)
@@ -696,12 +699,8 @@ int netvsc_recv_callback(struct hv_device *device_obj,
696static void netvsc_get_drvinfo(struct net_device *net, 699static void netvsc_get_drvinfo(struct net_device *net,
697 struct ethtool_drvinfo *info) 700 struct ethtool_drvinfo *info)
698{ 701{
699 struct net_device_context *net_device_ctx = netdev_priv(net);
700 struct hv_device *dev = net_device_ctx->device_ctx;
701
702 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); 702 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
703 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); 703 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
704 strlcpy(info->bus_info, vmbus_dev_name(dev), sizeof(info->bus_info));
705} 704}
706 705
707static void netvsc_get_channels(struct net_device *net, 706static void netvsc_get_channels(struct net_device *net,
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 3ea47f28e143..d2e61e002926 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -397,6 +397,14 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
397#define DEFAULT_ENCRYPT false 397#define DEFAULT_ENCRYPT false
398#define DEFAULT_ENCODING_SA 0 398#define DEFAULT_ENCODING_SA 0
399 399
400static bool send_sci(const struct macsec_secy *secy)
401{
402 const struct macsec_tx_sc *tx_sc = &secy->tx_sc;
403
404 return tx_sc->send_sci ||
405 (secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb);
406}
407
400static sci_t make_sci(u8 *addr, __be16 port) 408static sci_t make_sci(u8 *addr, __be16 port)
401{ 409{
402 sci_t sci; 410 sci_t sci;
@@ -437,15 +445,15 @@ static unsigned int macsec_extra_len(bool sci_present)
437 445
438/* Fill SecTAG according to IEEE 802.1AE-2006 10.5.3 */ 446/* Fill SecTAG according to IEEE 802.1AE-2006 10.5.3 */
439static void macsec_fill_sectag(struct macsec_eth_header *h, 447static void macsec_fill_sectag(struct macsec_eth_header *h,
440 const struct macsec_secy *secy, u32 pn) 448 const struct macsec_secy *secy, u32 pn,
449 bool sci_present)
441{ 450{
442 const struct macsec_tx_sc *tx_sc = &secy->tx_sc; 451 const struct macsec_tx_sc *tx_sc = &secy->tx_sc;
443 452
444 memset(&h->tci_an, 0, macsec_sectag_len(tx_sc->send_sci)); 453 memset(&h->tci_an, 0, macsec_sectag_len(sci_present));
445 h->eth.h_proto = htons(ETH_P_MACSEC); 454 h->eth.h_proto = htons(ETH_P_MACSEC);
446 455
447 if (tx_sc->send_sci || 456 if (sci_present) {
448 (secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb)) {
449 h->tci_an |= MACSEC_TCI_SC; 457 h->tci_an |= MACSEC_TCI_SC;
450 memcpy(&h->secure_channel_id, &secy->sci, 458 memcpy(&h->secure_channel_id, &secy->sci,
451 sizeof(h->secure_channel_id)); 459 sizeof(h->secure_channel_id));
@@ -650,6 +658,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
650 struct macsec_tx_sc *tx_sc; 658 struct macsec_tx_sc *tx_sc;
651 struct macsec_tx_sa *tx_sa; 659 struct macsec_tx_sa *tx_sa;
652 struct macsec_dev *macsec = macsec_priv(dev); 660 struct macsec_dev *macsec = macsec_priv(dev);
661 bool sci_present;
653 u32 pn; 662 u32 pn;
654 663
655 secy = &macsec->secy; 664 secy = &macsec->secy;
@@ -687,7 +696,8 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
687 696
688 unprotected_len = skb->len; 697 unprotected_len = skb->len;
689 eth = eth_hdr(skb); 698 eth = eth_hdr(skb);
690 hh = (struct macsec_eth_header *)skb_push(skb, macsec_extra_len(tx_sc->send_sci)); 699 sci_present = send_sci(secy);
700 hh = (struct macsec_eth_header *)skb_push(skb, macsec_extra_len(sci_present));
691 memmove(hh, eth, 2 * ETH_ALEN); 701 memmove(hh, eth, 2 * ETH_ALEN);
692 702
693 pn = tx_sa_update_pn(tx_sa, secy); 703 pn = tx_sa_update_pn(tx_sa, secy);
@@ -696,7 +706,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
696 kfree_skb(skb); 706 kfree_skb(skb);
697 return ERR_PTR(-ENOLINK); 707 return ERR_PTR(-ENOLINK);
698 } 708 }
699 macsec_fill_sectag(hh, secy, pn); 709 macsec_fill_sectag(hh, secy, pn, sci_present);
700 macsec_set_shortlen(hh, unprotected_len - 2 * ETH_ALEN); 710 macsec_set_shortlen(hh, unprotected_len - 2 * ETH_ALEN);
701 711
702 skb_put(skb, secy->icv_len); 712 skb_put(skb, secy->icv_len);
@@ -726,10 +736,10 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
726 skb_to_sgvec(skb, sg, 0, skb->len); 736 skb_to_sgvec(skb, sg, 0, skb->len);
727 737
728 if (tx_sc->encrypt) { 738 if (tx_sc->encrypt) {
729 int len = skb->len - macsec_hdr_len(tx_sc->send_sci) - 739 int len = skb->len - macsec_hdr_len(sci_present) -
730 secy->icv_len; 740 secy->icv_len;
731 aead_request_set_crypt(req, sg, sg, len, iv); 741 aead_request_set_crypt(req, sg, sg, len, iv);
732 aead_request_set_ad(req, macsec_hdr_len(tx_sc->send_sci)); 742 aead_request_set_ad(req, macsec_hdr_len(sci_present));
733 } else { 743 } else {
734 aead_request_set_crypt(req, sg, sg, 0, iv); 744 aead_request_set_crypt(req, sg, sg, 0, iv);
735 aead_request_set_ad(req, skb->len - secy->icv_len); 745 aead_request_set_ad(req, skb->len - secy->icv_len);
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index f279a897a5c7..a52b560e428b 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -42,19 +42,24 @@
42#define AT803X_MMD_ACCESS_CONTROL 0x0D 42#define AT803X_MMD_ACCESS_CONTROL 0x0D
43#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E 43#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E
44#define AT803X_FUNC_DATA 0x4003 44#define AT803X_FUNC_DATA 0x4003
45#define AT803X_REG_CHIP_CONFIG 0x1f
46#define AT803X_BT_BX_REG_SEL 0x8000
45 47
46#define AT803X_DEBUG_ADDR 0x1D 48#define AT803X_DEBUG_ADDR 0x1D
47#define AT803X_DEBUG_DATA 0x1E 49#define AT803X_DEBUG_DATA 0x1E
48 50
51#define AT803X_MODE_CFG_MASK 0x0F
52#define AT803X_MODE_CFG_SGMII 0x01
53
54#define AT803X_PSSR 0x11 /*PHY-Specific Status Register*/
55#define AT803X_PSSR_MR_AN_COMPLETE 0x0200
56
49#define AT803X_DEBUG_REG_0 0x00 57#define AT803X_DEBUG_REG_0 0x00
50#define AT803X_DEBUG_RX_CLK_DLY_EN BIT(15) 58#define AT803X_DEBUG_RX_CLK_DLY_EN BIT(15)
51 59
52#define AT803X_DEBUG_REG_5 0x05 60#define AT803X_DEBUG_REG_5 0x05
53#define AT803X_DEBUG_TX_CLK_DLY_EN BIT(8) 61#define AT803X_DEBUG_TX_CLK_DLY_EN BIT(8)
54 62
55#define AT803X_REG_CHIP_CONFIG 0x1f
56#define AT803X_BT_BX_REG_SEL 0x8000
57
58#define ATH8030_PHY_ID 0x004dd076 63#define ATH8030_PHY_ID 0x004dd076
59#define ATH8031_PHY_ID 0x004dd074 64#define ATH8031_PHY_ID 0x004dd074
60#define ATH8035_PHY_ID 0x004dd072 65#define ATH8035_PHY_ID 0x004dd072
@@ -209,7 +214,6 @@ static int at803x_suspend(struct phy_device *phydev)
209{ 214{
210 int value; 215 int value;
211 int wol_enabled; 216 int wol_enabled;
212 int ccr;
213 217
214 mutex_lock(&phydev->lock); 218 mutex_lock(&phydev->lock);
215 219
@@ -225,16 +229,6 @@ static int at803x_suspend(struct phy_device *phydev)
225 229
226 phy_write(phydev, MII_BMCR, value); 230 phy_write(phydev, MII_BMCR, value);
227 231
228 if (phydev->interface != PHY_INTERFACE_MODE_SGMII)
229 goto done;
230
231 /* also power-down SGMII interface */
232 ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
233 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr & ~AT803X_BT_BX_REG_SEL);
234 phy_write(phydev, MII_BMCR, phy_read(phydev, MII_BMCR) | BMCR_PDOWN);
235 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL);
236
237done:
238 mutex_unlock(&phydev->lock); 232 mutex_unlock(&phydev->lock);
239 233
240 return 0; 234 return 0;
@@ -243,7 +237,6 @@ done:
243static int at803x_resume(struct phy_device *phydev) 237static int at803x_resume(struct phy_device *phydev)
244{ 238{
245 int value; 239 int value;
246 int ccr;
247 240
248 mutex_lock(&phydev->lock); 241 mutex_lock(&phydev->lock);
249 242
@@ -251,17 +244,6 @@ static int at803x_resume(struct phy_device *phydev)
251 value &= ~(BMCR_PDOWN | BMCR_ISOLATE); 244 value &= ~(BMCR_PDOWN | BMCR_ISOLATE);
252 phy_write(phydev, MII_BMCR, value); 245 phy_write(phydev, MII_BMCR, value);
253 246
254 if (phydev->interface != PHY_INTERFACE_MODE_SGMII)
255 goto done;
256
257 /* also power-up SGMII interface */
258 ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
259 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr & ~AT803X_BT_BX_REG_SEL);
260 value = phy_read(phydev, MII_BMCR) & ~(BMCR_PDOWN | BMCR_ISOLATE);
261 phy_write(phydev, MII_BMCR, value);
262 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL);
263
264done:
265 mutex_unlock(&phydev->lock); 247 mutex_unlock(&phydev->lock);
266 248
267 return 0; 249 return 0;
@@ -381,6 +363,36 @@ static void at803x_link_change_notify(struct phy_device *phydev)
381 } 363 }
382} 364}
383 365
366static int at803x_aneg_done(struct phy_device *phydev)
367{
368 int ccr;
369
370 int aneg_done = genphy_aneg_done(phydev);
371 if (aneg_done != BMSR_ANEGCOMPLETE)
372 return aneg_done;
373
374 /*
375 * in SGMII mode, if copper side autoneg is successful,
376 * also check SGMII side autoneg result
377 */
378 ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
379 if ((ccr & AT803X_MODE_CFG_MASK) != AT803X_MODE_CFG_SGMII)
380 return aneg_done;
381
382 /* switch to SGMII/fiber page */
383 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr & ~AT803X_BT_BX_REG_SEL);
384
385 /* check if the SGMII link is OK. */
386 if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) {
387 pr_warn("803x_aneg_done: SGMII link is not ok\n");
388 aneg_done = 0;
389 }
390 /* switch back to copper page */
391 phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL);
392
393 return aneg_done;
394}
395
384static struct phy_driver at803x_driver[] = { 396static struct phy_driver at803x_driver[] = {
385{ 397{
386 /* ATHEROS 8035 */ 398 /* ATHEROS 8035 */
@@ -432,6 +444,7 @@ static struct phy_driver at803x_driver[] = {
432 .flags = PHY_HAS_INTERRUPT, 444 .flags = PHY_HAS_INTERRUPT,
433 .config_aneg = genphy_config_aneg, 445 .config_aneg = genphy_config_aneg,
434 .read_status = genphy_read_status, 446 .read_status = genphy_read_status,
447 .aneg_done = at803x_aneg_done,
435 .ack_interrupt = &at803x_ack_interrupt, 448 .ack_interrupt = &at803x_ack_interrupt,
436 .config_intr = &at803x_config_intr, 449 .config_intr = &at803x_config_intr,
437} }; 450} };
diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 03d54c4adc88..800b39f06279 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -19,6 +19,7 @@
19#define TI_DP83848C_PHY_ID 0x20005ca0 19#define TI_DP83848C_PHY_ID 0x20005ca0
20#define NS_DP83848C_PHY_ID 0x20005c90 20#define NS_DP83848C_PHY_ID 0x20005c90
21#define TLK10X_PHY_ID 0x2000a210 21#define TLK10X_PHY_ID 0x2000a210
22#define TI_DP83822_PHY_ID 0x2000a240
22 23
23/* Registers */ 24/* Registers */
24#define DP83848_MICR 0x11 /* MII Interrupt Control Register */ 25#define DP83848_MICR 0x11 /* MII Interrupt Control Register */
@@ -77,6 +78,7 @@ static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
77 { TI_DP83848C_PHY_ID, 0xfffffff0 }, 78 { TI_DP83848C_PHY_ID, 0xfffffff0 },
78 { NS_DP83848C_PHY_ID, 0xfffffff0 }, 79 { NS_DP83848C_PHY_ID, 0xfffffff0 },
79 { TLK10X_PHY_ID, 0xfffffff0 }, 80 { TLK10X_PHY_ID, 0xfffffff0 },
81 { TI_DP83822_PHY_ID, 0xfffffff0 },
80 { } 82 { }
81}; 83};
82MODULE_DEVICE_TABLE(mdio, dp83848_tbl); 84MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
@@ -105,6 +107,7 @@ static struct phy_driver dp83848_driver[] = {
105 DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"), 107 DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
106 DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"), 108 DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"),
107 DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"), 109 DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"),
110 DP83848_PHY_DRIVER(TI_DP83822_PHY_ID, "TI DP83822 10/100 Mbps PHY"),
108}; 111};
109module_phy_driver(dp83848_driver); 112module_phy_driver(dp83848_driver);
110 113
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index f79eb12c326a..125cff57c759 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -433,13 +433,13 @@ int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
433 mutex_lock(&dev->phy_mutex); 433 mutex_lock(&dev->phy_mutex);
434 do { 434 do {
435 ret = asix_set_sw_mii(dev, 0); 435 ret = asix_set_sw_mii(dev, 0);
436 if (ret == -ENODEV) 436 if (ret == -ENODEV || ret == -ETIMEDOUT)
437 break; 437 break;
438 usleep_range(1000, 1100); 438 usleep_range(1000, 1100);
439 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 439 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG,
440 0, 0, 1, &smsr, 0); 440 0, 0, 1, &smsr, 0);
441 } while (!(smsr & AX_HOST_EN) && (i++ < 30) && (ret != -ENODEV)); 441 } while (!(smsr & AX_HOST_EN) && (i++ < 30) && (ret != -ENODEV));
442 if (ret == -ENODEV) { 442 if (ret == -ENODEV || ret == -ETIMEDOUT) {
443 mutex_unlock(&dev->phy_mutex); 443 mutex_unlock(&dev->phy_mutex);
444 return ret; 444 return ret;
445 } 445 }
@@ -497,13 +497,13 @@ int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc)
497 mutex_lock(&dev->phy_mutex); 497 mutex_lock(&dev->phy_mutex);
498 do { 498 do {
499 ret = asix_set_sw_mii(dev, 1); 499 ret = asix_set_sw_mii(dev, 1);
500 if (ret == -ENODEV) 500 if (ret == -ENODEV || ret == -ETIMEDOUT)
501 break; 501 break;
502 usleep_range(1000, 1100); 502 usleep_range(1000, 1100);
503 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 503 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG,
504 0, 0, 1, &smsr, 1); 504 0, 0, 1, &smsr, 1);
505 } while (!(smsr & AX_HOST_EN) && (i++ < 30) && (ret != -ENODEV)); 505 } while (!(smsr & AX_HOST_EN) && (i++ < 30) && (ret != -ENODEV));
506 if (ret == -ENODEV) { 506 if (ret == -ENODEV || ret == -ETIMEDOUT) {
507 mutex_unlock(&dev->phy_mutex); 507 mutex_unlock(&dev->phy_mutex);
508 return ret; 508 return ret;
509 } 509 }
diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index 5662babf0583..3e37724d30ae 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c
@@ -151,7 +151,7 @@ kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
151 151
152 status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr); 152 status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr);
153 153
154 if (status < 0) { 154 if (status) {
155 usb_set_intfdata(intf, NULL); 155 usb_set_intfdata(intf, NULL);
156 usb_driver_release_interface(driver_of(intf), intf); 156 usb_driver_release_interface(driver_of(intf), intf);
157 return status; 157 return status;
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index b5554f2ebee4..ef83ae3b0a44 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2279,6 +2279,7 @@ vmxnet3_set_mc(struct net_device *netdev)
2279 &adapter->shared->devRead.rxFilterConf; 2279 &adapter->shared->devRead.rxFilterConf;
2280 u8 *new_table = NULL; 2280 u8 *new_table = NULL;
2281 dma_addr_t new_table_pa = 0; 2281 dma_addr_t new_table_pa = 0;
2282 bool new_table_pa_valid = false;
2282 u32 new_mode = VMXNET3_RXM_UCAST; 2283 u32 new_mode = VMXNET3_RXM_UCAST;
2283 2284
2284 if (netdev->flags & IFF_PROMISC) { 2285 if (netdev->flags & IFF_PROMISC) {
@@ -2307,13 +2308,15 @@ vmxnet3_set_mc(struct net_device *netdev)
2307 new_table, 2308 new_table,
2308 sz, 2309 sz,
2309 PCI_DMA_TODEVICE); 2310 PCI_DMA_TODEVICE);
2311 if (!dma_mapping_error(&adapter->pdev->dev,
2312 new_table_pa)) {
2313 new_mode |= VMXNET3_RXM_MCAST;
2314 new_table_pa_valid = true;
2315 rxConf->mfTablePA = cpu_to_le64(
2316 new_table_pa);
2317 }
2310 } 2318 }
2311 2319 if (!new_table_pa_valid) {
2312 if (!dma_mapping_error(&adapter->pdev->dev,
2313 new_table_pa)) {
2314 new_mode |= VMXNET3_RXM_MCAST;
2315 rxConf->mfTablePA = cpu_to_le64(new_table_pa);
2316 } else {
2317 netdev_info(netdev, 2320 netdev_info(netdev,
2318 "failed to copy mcast list, setting ALL_MULTI\n"); 2321 "failed to copy mcast list, setting ALL_MULTI\n");
2319 new_mode |= VMXNET3_RXM_ALL_MULTI; 2322 new_mode |= VMXNET3_RXM_ALL_MULTI;
@@ -2338,7 +2341,7 @@ vmxnet3_set_mc(struct net_device *netdev)
2338 VMXNET3_CMD_UPDATE_MAC_FILTERS); 2341 VMXNET3_CMD_UPDATE_MAC_FILTERS);
2339 spin_unlock_irqrestore(&adapter->cmd_lock, flags); 2342 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2340 2343
2341 if (new_table_pa) 2344 if (new_table_pa_valid)
2342 dma_unmap_single(&adapter->pdev->dev, new_table_pa, 2345 dma_unmap_single(&adapter->pdev->dev, new_table_pa,
2343 rxConf->mfTableLen, PCI_DMA_TODEVICE); 2346 rxConf->mfTableLen, PCI_DMA_TODEVICE);
2344 kfree(new_table); 2347 kfree(new_table);
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 85c271c70d42..820de6a9ddde 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -956,6 +956,7 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
956 if (skb->pkt_type == PACKET_LOOPBACK) { 956 if (skb->pkt_type == PACKET_LOOPBACK) {
957 skb->dev = vrf_dev; 957 skb->dev = vrf_dev;
958 skb->skb_iif = vrf_dev->ifindex; 958 skb->skb_iif = vrf_dev->ifindex;
959 IP6CB(skb)->flags |= IP6SKB_L3SLAVE;
959 skb->pkt_type = PACKET_HOST; 960 skb->pkt_type = PACKET_HOST;
960 goto out; 961 goto out;
961 } 962 }
@@ -996,6 +997,7 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev,
996{ 997{
997 skb->dev = vrf_dev; 998 skb->dev = vrf_dev;
998 skb->skb_iif = vrf_dev->ifindex; 999 skb->skb_iif = vrf_dev->ifindex;
1000 IPCB(skb)->flags |= IPSKB_L3SLAVE;
999 1001
1000 /* loopback traffic; do not push through packet taps again. 1002 /* loopback traffic; do not push through packet taps again.
1001 * Reset pkt_type for upper layers to process skb 1003 * Reset pkt_type for upper layers to process skb
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index e7d16687538b..f3c2fa3ab0d5 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -583,7 +583,7 @@ static struct sk_buff **vxlan_gro_receive(struct sock *sk,
583 } 583 }
584 } 584 }
585 585
586 pp = eth_gro_receive(head, skb); 586 pp = call_gro_receive(eth_gro_receive, head, skb);
587 flush = 0; 587 flush = 0;
588 588
589out: 589out:
@@ -943,17 +943,20 @@ static bool vxlan_snoop(struct net_device *dev,
943static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev) 943static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
944{ 944{
945 struct vxlan_dev *vxlan; 945 struct vxlan_dev *vxlan;
946 struct vxlan_sock *sock4;
947 struct vxlan_sock *sock6 = NULL;
946 unsigned short family = dev->default_dst.remote_ip.sa.sa_family; 948 unsigned short family = dev->default_dst.remote_ip.sa.sa_family;
947 949
950 sock4 = rtnl_dereference(dev->vn4_sock);
951
948 /* The vxlan_sock is only used by dev, leaving group has 952 /* The vxlan_sock is only used by dev, leaving group has
949 * no effect on other vxlan devices. 953 * no effect on other vxlan devices.
950 */ 954 */
951 if (family == AF_INET && dev->vn4_sock && 955 if (family == AF_INET && sock4 && atomic_read(&sock4->refcnt) == 1)
952 atomic_read(&dev->vn4_sock->refcnt) == 1)
953 return false; 956 return false;
954#if IS_ENABLED(CONFIG_IPV6) 957#if IS_ENABLED(CONFIG_IPV6)
955 if (family == AF_INET6 && dev->vn6_sock && 958 sock6 = rtnl_dereference(dev->vn6_sock);
956 atomic_read(&dev->vn6_sock->refcnt) == 1) 959 if (family == AF_INET6 && sock6 && atomic_read(&sock6->refcnt) == 1)
957 return false; 960 return false;
958#endif 961#endif
959 962
@@ -961,10 +964,12 @@ static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
961 if (!netif_running(vxlan->dev) || vxlan == dev) 964 if (!netif_running(vxlan->dev) || vxlan == dev)
962 continue; 965 continue;
963 966
964 if (family == AF_INET && vxlan->vn4_sock != dev->vn4_sock) 967 if (family == AF_INET &&
968 rtnl_dereference(vxlan->vn4_sock) != sock4)
965 continue; 969 continue;
966#if IS_ENABLED(CONFIG_IPV6) 970#if IS_ENABLED(CONFIG_IPV6)
967 if (family == AF_INET6 && vxlan->vn6_sock != dev->vn6_sock) 971 if (family == AF_INET6 &&
972 rtnl_dereference(vxlan->vn6_sock) != sock6)
968 continue; 973 continue;
969#endif 974#endif
970 975
@@ -1005,22 +1010,25 @@ static bool __vxlan_sock_release_prep(struct vxlan_sock *vs)
1005 1010
1006static void vxlan_sock_release(struct vxlan_dev *vxlan) 1011static void vxlan_sock_release(struct vxlan_dev *vxlan)
1007{ 1012{
1008 bool ipv4 = __vxlan_sock_release_prep(vxlan->vn4_sock); 1013 struct vxlan_sock *sock4 = rtnl_dereference(vxlan->vn4_sock);
1009#if IS_ENABLED(CONFIG_IPV6) 1014#if IS_ENABLED(CONFIG_IPV6)
1010 bool ipv6 = __vxlan_sock_release_prep(vxlan->vn6_sock); 1015 struct vxlan_sock *sock6 = rtnl_dereference(vxlan->vn6_sock);
1016
1017 rcu_assign_pointer(vxlan->vn6_sock, NULL);
1011#endif 1018#endif
1012 1019
1020 rcu_assign_pointer(vxlan->vn4_sock, NULL);
1013 synchronize_net(); 1021 synchronize_net();
1014 1022
1015 if (ipv4) { 1023 if (__vxlan_sock_release_prep(sock4)) {
1016 udp_tunnel_sock_release(vxlan->vn4_sock->sock); 1024 udp_tunnel_sock_release(sock4->sock);
1017 kfree(vxlan->vn4_sock); 1025 kfree(sock4);
1018 } 1026 }
1019 1027
1020#if IS_ENABLED(CONFIG_IPV6) 1028#if IS_ENABLED(CONFIG_IPV6)
1021 if (ipv6) { 1029 if (__vxlan_sock_release_prep(sock6)) {
1022 udp_tunnel_sock_release(vxlan->vn6_sock->sock); 1030 udp_tunnel_sock_release(sock6->sock);
1023 kfree(vxlan->vn6_sock); 1031 kfree(sock6);
1024 } 1032 }
1025#endif 1033#endif
1026} 1034}
@@ -1036,18 +1044,21 @@ static int vxlan_igmp_join(struct vxlan_dev *vxlan)
1036 int ret = -EINVAL; 1044 int ret = -EINVAL;
1037 1045
1038 if (ip->sa.sa_family == AF_INET) { 1046 if (ip->sa.sa_family == AF_INET) {
1047 struct vxlan_sock *sock4 = rtnl_dereference(vxlan->vn4_sock);
1039 struct ip_mreqn mreq = { 1048 struct ip_mreqn mreq = {
1040 .imr_multiaddr.s_addr = ip->sin.sin_addr.s_addr, 1049 .imr_multiaddr.s_addr = ip->sin.sin_addr.s_addr,
1041 .imr_ifindex = ifindex, 1050 .imr_ifindex = ifindex,
1042 }; 1051 };
1043 1052
1044 sk = vxlan->vn4_sock->sock->sk; 1053 sk = sock4->sock->sk;
1045 lock_sock(sk); 1054 lock_sock(sk);
1046 ret = ip_mc_join_group(sk, &mreq); 1055 ret = ip_mc_join_group(sk, &mreq);
1047 release_sock(sk); 1056 release_sock(sk);
1048#if IS_ENABLED(CONFIG_IPV6) 1057#if IS_ENABLED(CONFIG_IPV6)
1049 } else { 1058 } else {
1050 sk = vxlan->vn6_sock->sock->sk; 1059 struct vxlan_sock *sock6 = rtnl_dereference(vxlan->vn6_sock);
1060
1061 sk = sock6->sock->sk;
1051 lock_sock(sk); 1062 lock_sock(sk);
1052 ret = ipv6_stub->ipv6_sock_mc_join(sk, ifindex, 1063 ret = ipv6_stub->ipv6_sock_mc_join(sk, ifindex,
1053 &ip->sin6.sin6_addr); 1064 &ip->sin6.sin6_addr);
@@ -1067,18 +1078,21 @@ static int vxlan_igmp_leave(struct vxlan_dev *vxlan)
1067 int ret = -EINVAL; 1078 int ret = -EINVAL;
1068 1079
1069 if (ip->sa.sa_family == AF_INET) { 1080 if (ip->sa.sa_family == AF_INET) {
1081 struct vxlan_sock *sock4 = rtnl_dereference(vxlan->vn4_sock);
1070 struct ip_mreqn mreq = { 1082 struct ip_mreqn mreq = {
1071 .imr_multiaddr.s_addr = ip->sin.sin_addr.s_addr, 1083 .imr_multiaddr.s_addr = ip->sin.sin_addr.s_addr,
1072 .imr_ifindex = ifindex, 1084 .imr_ifindex = ifindex,
1073 }; 1085 };
1074 1086
1075 sk = vxlan->vn4_sock->sock->sk; 1087 sk = sock4->sock->sk;
1076 lock_sock(sk); 1088 lock_sock(sk);
1077 ret = ip_mc_leave_group(sk, &mreq); 1089 ret = ip_mc_leave_group(sk, &mreq);
1078 release_sock(sk); 1090 release_sock(sk);
1079#if IS_ENABLED(CONFIG_IPV6) 1091#if IS_ENABLED(CONFIG_IPV6)
1080 } else { 1092 } else {
1081 sk = vxlan->vn6_sock->sock->sk; 1093 struct vxlan_sock *sock6 = rtnl_dereference(vxlan->vn6_sock);
1094
1095 sk = sock6->sock->sk;
1082 lock_sock(sk); 1096 lock_sock(sk);
1083 ret = ipv6_stub->ipv6_sock_mc_drop(sk, ifindex, 1097 ret = ipv6_stub->ipv6_sock_mc_drop(sk, ifindex,
1084 &ip->sin6.sin6_addr); 1098 &ip->sin6.sin6_addr);
@@ -1828,11 +1842,15 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
1828 struct dst_cache *dst_cache, 1842 struct dst_cache *dst_cache,
1829 const struct ip_tunnel_info *info) 1843 const struct ip_tunnel_info *info)
1830{ 1844{
1845 struct vxlan_sock *sock6 = rcu_dereference(vxlan->vn6_sock);
1831 bool use_cache = ip_tunnel_dst_cache_usable(skb, info); 1846 bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
1832 struct dst_entry *ndst; 1847 struct dst_entry *ndst;
1833 struct flowi6 fl6; 1848 struct flowi6 fl6;
1834 int err; 1849 int err;
1835 1850
1851 if (!sock6)
1852 return ERR_PTR(-EIO);
1853
1836 if (tos && !info) 1854 if (tos && !info)
1837 use_cache = false; 1855 use_cache = false;
1838 if (use_cache) { 1856 if (use_cache) {
@@ -1850,7 +1868,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
1850 fl6.flowi6_proto = IPPROTO_UDP; 1868 fl6.flowi6_proto = IPPROTO_UDP;
1851 1869
1852 err = ipv6_stub->ipv6_dst_lookup(vxlan->net, 1870 err = ipv6_stub->ipv6_dst_lookup(vxlan->net,
1853 vxlan->vn6_sock->sock->sk, 1871 sock6->sock->sk,
1854 &ndst, &fl6); 1872 &ndst, &fl6);
1855 if (err < 0) 1873 if (err < 0)
1856 return ERR_PTR(err); 1874 return ERR_PTR(err);
@@ -1995,9 +2013,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1995 } 2013 }
1996 2014
1997 if (dst->sa.sa_family == AF_INET) { 2015 if (dst->sa.sa_family == AF_INET) {
1998 if (!vxlan->vn4_sock) 2016 struct vxlan_sock *sock4 = rcu_dereference(vxlan->vn4_sock);
2017
2018 if (!sock4)
1999 goto drop; 2019 goto drop;
2000 sk = vxlan->vn4_sock->sock->sk; 2020 sk = sock4->sock->sk;
2001 2021
2002 rt = vxlan_get_route(vxlan, skb, 2022 rt = vxlan_get_route(vxlan, skb,
2003 rdst ? rdst->remote_ifindex : 0, tos, 2023 rdst ? rdst->remote_ifindex : 0, tos,
@@ -2050,12 +2070,13 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2050 src_port, dst_port, xnet, !udp_sum); 2070 src_port, dst_port, xnet, !udp_sum);
2051#if IS_ENABLED(CONFIG_IPV6) 2071#if IS_ENABLED(CONFIG_IPV6)
2052 } else { 2072 } else {
2073 struct vxlan_sock *sock6 = rcu_dereference(vxlan->vn6_sock);
2053 struct dst_entry *ndst; 2074 struct dst_entry *ndst;
2054 u32 rt6i_flags; 2075 u32 rt6i_flags;
2055 2076
2056 if (!vxlan->vn6_sock) 2077 if (!sock6)
2057 goto drop; 2078 goto drop;
2058 sk = vxlan->vn6_sock->sock->sk; 2079 sk = sock6->sock->sk;
2059 2080
2060 ndst = vxlan6_get_route(vxlan, skb, 2081 ndst = vxlan6_get_route(vxlan, skb,
2061 rdst ? rdst->remote_ifindex : 0, tos, 2082 rdst ? rdst->remote_ifindex : 0, tos,
@@ -2415,9 +2436,10 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2415 dport = info->key.tp_dst ? : vxlan->cfg.dst_port; 2436 dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
2416 2437
2417 if (ip_tunnel_info_af(info) == AF_INET) { 2438 if (ip_tunnel_info_af(info) == AF_INET) {
2439 struct vxlan_sock *sock4 = rcu_dereference(vxlan->vn4_sock);
2418 struct rtable *rt; 2440 struct rtable *rt;
2419 2441
2420 if (!vxlan->vn4_sock) 2442 if (!sock4)
2421 return -EINVAL; 2443 return -EINVAL;
2422 rt = vxlan_get_route(vxlan, skb, 0, info->key.tos, 2444 rt = vxlan_get_route(vxlan, skb, 0, info->key.tos,
2423 info->key.u.ipv4.dst, 2445 info->key.u.ipv4.dst,
@@ -2429,8 +2451,6 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2429#if IS_ENABLED(CONFIG_IPV6) 2451#if IS_ENABLED(CONFIG_IPV6)
2430 struct dst_entry *ndst; 2452 struct dst_entry *ndst;
2431 2453
2432 if (!vxlan->vn6_sock)
2433 return -EINVAL;
2434 ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos, 2454 ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos,
2435 info->key.label, &info->key.u.ipv6.dst, 2455 info->key.label, &info->key.u.ipv6.dst,
2436 &info->key.u.ipv6.src, NULL, info); 2456 &info->key.u.ipv6.src, NULL, info);
@@ -2740,10 +2760,10 @@ static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6)
2740 return PTR_ERR(vs); 2760 return PTR_ERR(vs);
2741#if IS_ENABLED(CONFIG_IPV6) 2761#if IS_ENABLED(CONFIG_IPV6)
2742 if (ipv6) 2762 if (ipv6)
2743 vxlan->vn6_sock = vs; 2763 rcu_assign_pointer(vxlan->vn6_sock, vs);
2744 else 2764 else
2745#endif 2765#endif
2746 vxlan->vn4_sock = vs; 2766 rcu_assign_pointer(vxlan->vn4_sock, vs);
2747 vxlan_vs_add_dev(vs, vxlan); 2767 vxlan_vs_add_dev(vs, vxlan);
2748 return 0; 2768 return 0;
2749} 2769}
@@ -2754,9 +2774,9 @@ static int vxlan_sock_add(struct vxlan_dev *vxlan)
2754 bool metadata = vxlan->flags & VXLAN_F_COLLECT_METADATA; 2774 bool metadata = vxlan->flags & VXLAN_F_COLLECT_METADATA;
2755 int ret = 0; 2775 int ret = 0;
2756 2776
2757 vxlan->vn4_sock = NULL; 2777 RCU_INIT_POINTER(vxlan->vn4_sock, NULL);
2758#if IS_ENABLED(CONFIG_IPV6) 2778#if IS_ENABLED(CONFIG_IPV6)
2759 vxlan->vn6_sock = NULL; 2779 RCU_INIT_POINTER(vxlan->vn6_sock, NULL);
2760 if (ipv6 || metadata) 2780 if (ipv6 || metadata)
2761 ret = __vxlan_sock_add(vxlan, true); 2781 ret = __vxlan_sock_add(vxlan, true);
2762#endif 2782#endif
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 33ab3345d333..4e9fe75d7067 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -294,7 +294,7 @@ config FSL_UCC_HDLC
294config SLIC_DS26522 294config SLIC_DS26522
295 tristate "Slic Maxim ds26522 card support" 295 tristate "Slic Maxim ds26522 card support"
296 depends on SPI 296 depends on SPI
297 depends on FSL_SOC || ARCH_MXC || ARCH_LAYERSCAPE 297 depends on FSL_SOC || ARCH_MXC || ARCH_LAYERSCAPE || COMPILE_TEST
298 help 298 help
299 This module initializes and configures the slic maxim card 299 This module initializes and configures the slic maxim card
300 in T1 or E1 mode. 300 in T1 or E1 mode.
diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index d06a887a2352..b776a0ab106c 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -223,12 +223,19 @@ static int slic_ds26522_probe(struct spi_device *spi)
223 return ret; 223 return ret;
224} 224}
225 225
226static const struct spi_device_id slic_ds26522_id[] = {
227 { .name = "ds26522" },
228 { /* sentinel */ },
229};
230MODULE_DEVICE_TABLE(spi, slic_ds26522_id);
231
226static const struct of_device_id slic_ds26522_match[] = { 232static const struct of_device_id slic_ds26522_match[] = {
227 { 233 {
228 .compatible = "maxim,ds26522", 234 .compatible = "maxim,ds26522",
229 }, 235 },
230 {}, 236 {},
231}; 237};
238MODULE_DEVICE_TABLE(of, slic_ds26522_match);
232 239
233static struct spi_driver slic_ds26522_driver = { 240static struct spi_driver slic_ds26522_driver = {
234 .driver = { 241 .driver = {
@@ -239,6 +246,7 @@ static struct spi_driver slic_ds26522_driver = {
239 }, 246 },
240 .probe = slic_ds26522_probe, 247 .probe = slic_ds26522_probe,
241 .remove = slic_ds26522_remove, 248 .remove = slic_ds26522_remove,
249 .id_table = slic_ds26522_id,
242}; 250};
243 251
244static int __init slic_ds26522_init(void) 252static int __init slic_ds26522_init(void)
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index dda49af1eb74..521f1c55c19e 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -450,6 +450,7 @@ struct ath10k_debug {
450 u32 pktlog_filter; 450 u32 pktlog_filter;
451 u32 reg_addr; 451 u32 reg_addr;
452 u32 nf_cal_period; 452 u32 nf_cal_period;
453 void *cal_data;
453 454
454 struct ath10k_fw_crash_data *fw_crash_data; 455 struct ath10k_fw_crash_data *fw_crash_data;
455}; 456};
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 832da6ed9f13..82a4c67f3672 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -30,6 +30,8 @@
30/* ms */ 30/* ms */
31#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 31#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
32 32
33#define ATH10K_DEBUG_CAL_DATA_LEN 12064
34
33#define ATH10K_FW_CRASH_DUMP_VERSION 1 35#define ATH10K_FW_CRASH_DUMP_VERSION 1
34 36
35/** 37/**
@@ -1451,56 +1453,51 @@ static const struct file_operations fops_fw_dbglog = {
1451 .llseek = default_llseek, 1453 .llseek = default_llseek,
1452}; 1454};
1453 1455
1454static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file) 1456static int ath10k_debug_cal_data_fetch(struct ath10k *ar)
1455{ 1457{
1456 struct ath10k *ar = inode->i_private;
1457 void *buf;
1458 u32 hi_addr; 1458 u32 hi_addr;
1459 __le32 addr; 1459 __le32 addr;
1460 int ret; 1460 int ret;
1461 1461
1462 mutex_lock(&ar->conf_mutex); 1462 lockdep_assert_held(&ar->conf_mutex);
1463
1464 if (ar->state != ATH10K_STATE_ON &&
1465 ar->state != ATH10K_STATE_UTF) {
1466 ret = -ENETDOWN;
1467 goto err;
1468 }
1469 1463
1470 buf = vmalloc(ar->hw_params.cal_data_len); 1464 if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN))
1471 if (!buf) { 1465 return -EINVAL;
1472 ret = -ENOMEM;
1473 goto err;
1474 }
1475 1466
1476 hi_addr = host_interest_item_address(HI_ITEM(hi_board_data)); 1467 hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
1477 1468
1478 ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr)); 1469 ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
1479 if (ret) { 1470 if (ret) {
1480 ath10k_warn(ar, "failed to read hi_board_data address: %d\n", ret); 1471 ath10k_warn(ar, "failed to read hi_board_data address: %d\n",
1481 goto err_vfree; 1472 ret);
1473 return ret;
1482 } 1474 }
1483 1475
1484 ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf, 1476 ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), ar->debug.cal_data,
1485 ar->hw_params.cal_data_len); 1477 ar->hw_params.cal_data_len);
1486 if (ret) { 1478 if (ret) {
1487 ath10k_warn(ar, "failed to read calibration data: %d\n", ret); 1479 ath10k_warn(ar, "failed to read calibration data: %d\n", ret);
1488 goto err_vfree; 1480 return ret;
1489 } 1481 }
1490 1482
1491 file->private_data = buf; 1483 return 0;
1484}
1492 1485
1493 mutex_unlock(&ar->conf_mutex); 1486static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
1487{
1488 struct ath10k *ar = inode->i_private;
1494 1489
1495 return 0; 1490 mutex_lock(&ar->conf_mutex);
1496 1491
1497err_vfree: 1492 if (ar->state == ATH10K_STATE_ON ||
1498 vfree(buf); 1493 ar->state == ATH10K_STATE_UTF) {
1494 ath10k_debug_cal_data_fetch(ar);
1495 }
1499 1496
1500err: 1497 file->private_data = ar;
1501 mutex_unlock(&ar->conf_mutex); 1498 mutex_unlock(&ar->conf_mutex);
1502 1499
1503 return ret; 1500 return 0;
1504} 1501}
1505 1502
1506static ssize_t ath10k_debug_cal_data_read(struct file *file, 1503static ssize_t ath10k_debug_cal_data_read(struct file *file,
@@ -1508,18 +1505,16 @@ static ssize_t ath10k_debug_cal_data_read(struct file *file,
1508 size_t count, loff_t *ppos) 1505 size_t count, loff_t *ppos)
1509{ 1506{
1510 struct ath10k *ar = file->private_data; 1507 struct ath10k *ar = file->private_data;
1511 void *buf = file->private_data;
1512 1508
1513 return simple_read_from_buffer(user_buf, count, ppos, 1509 mutex_lock(&ar->conf_mutex);
1514 buf, ar->hw_params.cal_data_len);
1515}
1516 1510
1517static int ath10k_debug_cal_data_release(struct inode *inode, 1511 count = simple_read_from_buffer(user_buf, count, ppos,
1518 struct file *file) 1512 ar->debug.cal_data,
1519{ 1513 ar->hw_params.cal_data_len);
1520 vfree(file->private_data);
1521 1514
1522 return 0; 1515 mutex_unlock(&ar->conf_mutex);
1516
1517 return count;
1523} 1518}
1524 1519
1525static ssize_t ath10k_write_ani_enable(struct file *file, 1520static ssize_t ath10k_write_ani_enable(struct file *file,
@@ -1580,7 +1575,6 @@ static const struct file_operations fops_ani_enable = {
1580static const struct file_operations fops_cal_data = { 1575static const struct file_operations fops_cal_data = {
1581 .open = ath10k_debug_cal_data_open, 1576 .open = ath10k_debug_cal_data_open,
1582 .read = ath10k_debug_cal_data_read, 1577 .read = ath10k_debug_cal_data_read,
1583 .release = ath10k_debug_cal_data_release,
1584 .owner = THIS_MODULE, 1578 .owner = THIS_MODULE,
1585 .llseek = default_llseek, 1579 .llseek = default_llseek,
1586}; 1580};
@@ -1932,6 +1926,8 @@ void ath10k_debug_stop(struct ath10k *ar)
1932{ 1926{
1933 lockdep_assert_held(&ar->conf_mutex); 1927 lockdep_assert_held(&ar->conf_mutex);
1934 1928
1929 ath10k_debug_cal_data_fetch(ar);
1930
1935 /* Must not use _sync to avoid deadlock, we do that in 1931 /* Must not use _sync to avoid deadlock, we do that in
1936 * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid 1932 * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid
1937 * warning from del_timer(). */ 1933 * warning from del_timer(). */
@@ -2344,6 +2340,10 @@ int ath10k_debug_create(struct ath10k *ar)
2344 if (!ar->debug.fw_crash_data) 2340 if (!ar->debug.fw_crash_data)
2345 return -ENOMEM; 2341 return -ENOMEM;
2346 2342
2343 ar->debug.cal_data = vzalloc(ATH10K_DEBUG_CAL_DATA_LEN);
2344 if (!ar->debug.cal_data)
2345 return -ENOMEM;
2346
2347 INIT_LIST_HEAD(&ar->debug.fw_stats.pdevs); 2347 INIT_LIST_HEAD(&ar->debug.fw_stats.pdevs);
2348 INIT_LIST_HEAD(&ar->debug.fw_stats.vdevs); 2348 INIT_LIST_HEAD(&ar->debug.fw_stats.vdevs);
2349 INIT_LIST_HEAD(&ar->debug.fw_stats.peers); 2349 INIT_LIST_HEAD(&ar->debug.fw_stats.peers);
@@ -2357,6 +2357,9 @@ void ath10k_debug_destroy(struct ath10k *ar)
2357 vfree(ar->debug.fw_crash_data); 2357 vfree(ar->debug.fw_crash_data);
2358 ar->debug.fw_crash_data = NULL; 2358 ar->debug.fw_crash_data = NULL;
2359 2359
2360 vfree(ar->debug.cal_data);
2361 ar->debug.cal_data = NULL;
2362
2360 ath10k_debug_fw_stats_reset(ar); 2363 ath10k_debug_fw_stats_reset(ar);
2361 2364
2362 kfree(ar->debug.tpc_stats); 2365 kfree(ar->debug.tpc_stats);
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index eab0ab976af2..76eb33679d4b 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -1401,6 +1401,7 @@ static const struct sdio_device_id ath6kl_sdio_devices[] = {
1401 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))}, 1401 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))},
1402 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))}, 1402 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))},
1403 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x2))}, 1403 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x2))},
1404 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x18))},
1404 {}, 1405 {},
1405}; 1406};
1406 1407
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index b6f064a8d264..7e27a06e5df1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -33,7 +33,6 @@ struct coeff {
33 33
34enum ar9003_cal_types { 34enum ar9003_cal_types {
35 IQ_MISMATCH_CAL = BIT(0), 35 IQ_MISMATCH_CAL = BIT(0),
36 TEMP_COMP_CAL = BIT(1),
37}; 36};
38 37
39static void ar9003_hw_setup_calibration(struct ath_hw *ah, 38static void ar9003_hw_setup_calibration(struct ath_hw *ah,
@@ -59,12 +58,6 @@ static void ar9003_hw_setup_calibration(struct ath_hw *ah,
59 /* Kick-off cal */ 58 /* Kick-off cal */
60 REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL); 59 REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
61 break; 60 break;
62 case TEMP_COMP_CAL:
63 ath_dbg(common, CALIBRATE,
64 "starting Temperature Compensation Calibration\n");
65 REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL);
66 REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START);
67 break;
68 default: 61 default:
69 ath_err(common, "Invalid calibration type\n"); 62 ath_err(common, "Invalid calibration type\n");
70 break; 63 break;
@@ -93,8 +86,7 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
93 /* 86 /*
94 * Accumulate cal measures for active chains 87 * Accumulate cal measures for active chains
95 */ 88 */
96 if (cur_caldata->calCollect) 89 cur_caldata->calCollect(ah);
97 cur_caldata->calCollect(ah);
98 ah->cal_samples++; 90 ah->cal_samples++;
99 91
100 if (ah->cal_samples >= cur_caldata->calNumSamples) { 92 if (ah->cal_samples >= cur_caldata->calNumSamples) {
@@ -107,8 +99,7 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
107 /* 99 /*
108 * Process accumulated data 100 * Process accumulated data
109 */ 101 */
110 if (cur_caldata->calPostProc) 102 cur_caldata->calPostProc(ah, numChains);
111 cur_caldata->calPostProc(ah, numChains);
112 103
113 /* Calibration has finished. */ 104 /* Calibration has finished. */
114 caldata->CalValid |= cur_caldata->calType; 105 caldata->CalValid |= cur_caldata->calType;
@@ -323,16 +314,9 @@ static const struct ath9k_percal_data iq_cal_single_sample = {
323 ar9003_hw_iqcalibrate 314 ar9003_hw_iqcalibrate
324}; 315};
325 316
326static const struct ath9k_percal_data temp_cal_single_sample = {
327 TEMP_COMP_CAL,
328 MIN_CAL_SAMPLES,
329 PER_MAX_LOG_COUNT,
330};
331
332static void ar9003_hw_init_cal_settings(struct ath_hw *ah) 317static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
333{ 318{
334 ah->iq_caldata.calData = &iq_cal_single_sample; 319 ah->iq_caldata.calData = &iq_cal_single_sample;
335 ah->temp_caldata.calData = &temp_cal_single_sample;
336 320
337 if (AR_SREV_9300_20_OR_LATER(ah)) { 321 if (AR_SREV_9300_20_OR_LATER(ah)) {
338 ah->enabled_cals |= TX_IQ_CAL; 322 ah->enabled_cals |= TX_IQ_CAL;
@@ -340,7 +324,7 @@ static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
340 ah->enabled_cals |= TX_IQ_ON_AGC_CAL; 324 ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
341 } 325 }
342 326
343 ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL; 327 ah->supp_cals = IQ_MISMATCH_CAL;
344} 328}
345 329
346#define OFF_UPPER_LT 24 330#define OFF_UPPER_LT 24
@@ -1399,9 +1383,6 @@ static void ar9003_hw_init_cal_common(struct ath_hw *ah)
1399 INIT_CAL(&ah->iq_caldata); 1383 INIT_CAL(&ah->iq_caldata);
1400 INSERT_CAL(ah, &ah->iq_caldata); 1384 INSERT_CAL(ah, &ah->iq_caldata);
1401 1385
1402 INIT_CAL(&ah->temp_caldata);
1403 INSERT_CAL(ah, &ah->temp_caldata);
1404
1405 /* Initialize current pointer to first element in list */ 1386 /* Initialize current pointer to first element in list */
1406 ah->cal_list_curr = ah->cal_list; 1387 ah->cal_list_curr = ah->cal_list;
1407 1388
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 2a5d3ad1169c..9cbca1229bac 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -830,7 +830,6 @@ struct ath_hw {
830 /* Calibration */ 830 /* Calibration */
831 u32 supp_cals; 831 u32 supp_cals;
832 struct ath9k_cal_list iq_caldata; 832 struct ath9k_cal_list iq_caldata;
833 struct ath9k_cal_list temp_caldata;
834 struct ath9k_cal_list adcgain_caldata; 833 struct ath9k_cal_list adcgain_caldata;
835 struct ath9k_cal_list adcdc_caldata; 834 struct ath9k_cal_list adcdc_caldata;
836 struct ath9k_cal_list *cal_list; 835 struct ath9k_cal_list *cal_list;
diff --git a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
index 94480123efa3..274dd5a1574a 100644
--- a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
@@ -45,7 +45,7 @@ static int mwifiex_11n_dispatch_amsdu_pkt(struct mwifiex_private *priv,
45 skb_trim(skb, le16_to_cpu(local_rx_pd->rx_pkt_length)); 45 skb_trim(skb, le16_to_cpu(local_rx_pd->rx_pkt_length));
46 46
47 ieee80211_amsdu_to_8023s(skb, &list, priv->curr_addr, 47 ieee80211_amsdu_to_8023s(skb, &list, priv->curr_addr,
48 priv->wdev.iftype, 0, false); 48 priv->wdev.iftype, 0, NULL, NULL);
49 49
50 while (!skb_queue_empty(&list)) { 50 while (!skb_queue_empty(&list)) {
51 struct rx_packet_hdr *rx_hdr; 51 struct rx_packet_hdr *rx_hdr;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 1016628926d2..08d587a342d3 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -238,7 +238,7 @@ struct rtl8xxxu_rxdesc16 {
238 u32 pattern1match:1; 238 u32 pattern1match:1;
239 u32 pattern0match:1; 239 u32 pattern0match:1;
240#endif 240#endif
241 __le32 tsfl; 241 u32 tsfl;
242#if 0 242#if 0
243 u32 bassn:12; 243 u32 bassn:12;
244 u32 bavld:1; 244 u32 bavld:1;
@@ -368,7 +368,7 @@ struct rtl8xxxu_rxdesc24 {
368 u32 ldcp:1; 368 u32 ldcp:1;
369 u32 splcp:1; 369 u32 splcp:1;
370#endif 370#endif
371 __le32 tsfl; 371 u32 tsfl;
372}; 372};
373 373
374struct rtl8xxxu_txdesc32 { 374struct rtl8xxxu_txdesc32 {
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index df54d27e7851..a793fedc3654 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -1461,7 +1461,9 @@ static int rtl8192eu_active_to_emu(struct rtl8xxxu_priv *priv)
1461 int count, ret = 0; 1461 int count, ret = 0;
1462 1462
1463 /* Turn off RF */ 1463 /* Turn off RF */
1464 rtl8xxxu_write8(priv, REG_RF_CTRL, 0); 1464 val8 = rtl8xxxu_read8(priv, REG_RF_CTRL);
1465 val8 &= ~RF_ENABLE;
1466 rtl8xxxu_write8(priv, REG_RF_CTRL, val8);
1465 1467
1466 /* Switch DPDT_SEL_P output from register 0x65[2] */ 1468 /* Switch DPDT_SEL_P output from register 0x65[2] */
1467 val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 1469 val8 = rtl8xxxu_read8(priv, REG_LEDCFG2);
@@ -1593,6 +1595,10 @@ static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv)
1593 u32 val32; 1595 u32 val32;
1594 u8 val8; 1596 u8 val8;
1595 1597
1598 val32 = rtl8xxxu_read32(priv, REG_RX_WAIT_CCA);
1599 val32 |= (BIT(22) | BIT(23));
1600 rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32);
1601
1596 val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 1602 val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG);
1597 val8 |= BIT(5); 1603 val8 |= BIT(5);
1598 rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 1604 rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 6c086b5657e9..02b8ddd98a95 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -1498,6 +1498,10 @@ static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv)
1498 u32 val32; 1498 u32 val32;
1499 u8 val8; 1499 u8 val8;
1500 1500
1501 val32 = rtl8xxxu_read32(priv, REG_RX_WAIT_CCA);
1502 val32 |= (BIT(22) | BIT(23));
1503 rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32);
1504
1501 /* 1505 /*
1502 * No indication anywhere as to what 0x0790 does. The 2 antenna 1506 * No indication anywhere as to what 0x0790 does. The 2 antenna
1503 * vendor code preserves bits 6-7 here. 1507 * vendor code preserves bits 6-7 here.
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index b2d7f6e69667..a5e6ec2152bf 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5197,7 +5197,12 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb)
5197 pkt_offset = roundup(pkt_len + drvinfo_sz + desc_shift + 5197 pkt_offset = roundup(pkt_len + drvinfo_sz + desc_shift +
5198 sizeof(struct rtl8xxxu_rxdesc16), 128); 5198 sizeof(struct rtl8xxxu_rxdesc16), 128);
5199 5199
5200 if (pkt_cnt > 1) 5200 /*
5201 * Only clone the skb if there's enough data at the end to
5202 * at least cover the rx descriptor
5203 */
5204 if (pkt_cnt > 1 &&
5205 urb_len > (pkt_offset + sizeof(struct rtl8xxxu_rxdesc16)))
5201 next_skb = skb_clone(skb, GFP_ATOMIC); 5206 next_skb = skb_clone(skb, GFP_ATOMIC);
5202 5207
5203 rx_status = IEEE80211_SKB_RXCB(skb); 5208 rx_status = IEEE80211_SKB_RXCB(skb);
@@ -5215,7 +5220,7 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb)
5215 rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats, 5220 rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats,
5216 rx_desc->rxmcs); 5221 rx_desc->rxmcs);
5217 5222
5218 rx_status->mactime = le32_to_cpu(rx_desc->tsfl); 5223 rx_status->mactime = rx_desc->tsfl;
5219 rx_status->flag |= RX_FLAG_MACTIME_START; 5224 rx_status->flag |= RX_FLAG_MACTIME_START;
5220 5225
5221 if (!rx_desc->swdec) 5226 if (!rx_desc->swdec)
@@ -5285,7 +5290,7 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb)
5285 rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats, 5290 rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats,
5286 rx_desc->rxmcs); 5291 rx_desc->rxmcs);
5287 5292
5288 rx_status->mactime = le32_to_cpu(rx_desc->tsfl); 5293 rx_status->mactime = rx_desc->tsfl;
5289 rx_status->flag |= RX_FLAG_MACTIME_START; 5294 rx_status->flag |= RX_FLAG_MACTIME_START;
5290 5295
5291 if (!rx_desc->swdec) 5296 if (!rx_desc->swdec)
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index f95760c13c56..8e7f23c11680 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -111,7 +111,7 @@ static void rtl_fw_do_work(const struct firmware *firmware, void *context,
111 if (!err) 111 if (!err)
112 goto found_alt; 112 goto found_alt;
113 } 113 }
114 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); 114 pr_err("Selected firmware is not available\n");
115 rtlpriv->max_fw_size = 0; 115 rtlpriv->max_fw_size = 0;
116 return; 116 return;
117 } 117 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index e7b11b40e68d..f361808def47 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -86,6 +86,7 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
86 struct rtl_priv *rtlpriv = rtl_priv(hw); 86 struct rtl_priv *rtlpriv = rtl_priv(hw);
87 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 87 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
88 u8 tid; 88 u8 tid;
89 char *fw_name;
89 90
90 rtl8188ee_bt_reg_init(hw); 91 rtl8188ee_bt_reg_init(hw);
91 rtlpriv->dm.dm_initialgain_enable = 1; 92 rtlpriv->dm.dm_initialgain_enable = 1;
@@ -169,10 +170,10 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
169 return 1; 170 return 1;
170 } 171 }
171 172
172 rtlpriv->cfg->fw_name = "rtlwifi/rtl8188efw.bin"; 173 fw_name = "rtlwifi/rtl8188efw.bin";
173 rtlpriv->max_fw_size = 0x8000; 174 rtlpriv->max_fw_size = 0x8000;
174 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 175 pr_info("Using firmware %s\n", fw_name);
175 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 176 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
176 rtlpriv->io.dev, GFP_KERNEL, hw, 177 rtlpriv->io.dev, GFP_KERNEL, hw,
177 rtl_fw_cb); 178 rtl_fw_cb);
178 if (err) { 179 if (err) {
@@ -284,7 +285,6 @@ static const struct rtl_hal_cfg rtl88ee_hal_cfg = {
284 .bar_id = 2, 285 .bar_id = 2,
285 .write_readback = true, 286 .write_readback = true,
286 .name = "rtl88e_pci", 287 .name = "rtl88e_pci",
287 .fw_name = "rtlwifi/rtl8188efw.bin",
288 .ops = &rtl8188ee_hal_ops, 288 .ops = &rtl8188ee_hal_ops,
289 .mod_params = &rtl88ee_mod_params, 289 .mod_params = &rtl88ee_mod_params,
290 290
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index 87aa209ae325..8b6e37ce3f66 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -96,6 +96,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
96 struct rtl_priv *rtlpriv = rtl_priv(hw); 96 struct rtl_priv *rtlpriv = rtl_priv(hw);
97 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 97 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
98 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 98 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
99 char *fw_name = "rtlwifi/rtl8192cfwU.bin";
99 100
100 rtl8192ce_bt_reg_init(hw); 101 rtl8192ce_bt_reg_init(hw);
101 102
@@ -167,15 +168,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
167 } 168 }
168 169
169 /* request fw */ 170 /* request fw */
170 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && 171 if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version))
171 !IS_92C_SERIAL(rtlhal->version)) 172 fw_name = "rtlwifi/rtl8192cfwU_B.bin";
172 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin";
173 else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version))
174 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin";
175 173
176 rtlpriv->max_fw_size = 0x4000; 174 rtlpriv->max_fw_size = 0x4000;
177 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 175 pr_info("Using firmware %s\n", fw_name);
178 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 176 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
179 rtlpriv->io.dev, GFP_KERNEL, hw, 177 rtlpriv->io.dev, GFP_KERNEL, hw,
180 rtl_fw_cb); 178 rtl_fw_cb);
181 if (err) { 179 if (err) {
@@ -262,7 +260,6 @@ static const struct rtl_hal_cfg rtl92ce_hal_cfg = {
262 .bar_id = 2, 260 .bar_id = 2,
263 .write_readback = true, 261 .write_readback = true,
264 .name = "rtl92c_pci", 262 .name = "rtl92c_pci",
265 .fw_name = "rtlwifi/rtl8192cfw.bin",
266 .ops = &rtl8192ce_hal_ops, 263 .ops = &rtl8192ce_hal_ops,
267 .mod_params = &rtl92ce_mod_params, 264 .mod_params = &rtl92ce_mod_params,
268 265
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
index 7c6f7f0d18c6..f953320f0e23 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
@@ -59,6 +59,7 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
59{ 59{
60 struct rtl_priv *rtlpriv = rtl_priv(hw); 60 struct rtl_priv *rtlpriv = rtl_priv(hw);
61 int err; 61 int err;
62 char *fw_name;
62 63
63 rtlpriv->dm.dm_initialgain_enable = true; 64 rtlpriv->dm.dm_initialgain_enable = true;
64 rtlpriv->dm.dm_flag = 0; 65 rtlpriv->dm.dm_flag = 0;
@@ -77,18 +78,18 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
77 } 78 }
78 if (IS_VENDOR_UMC_A_CUT(rtlpriv->rtlhal.version) && 79 if (IS_VENDOR_UMC_A_CUT(rtlpriv->rtlhal.version) &&
79 !IS_92C_SERIAL(rtlpriv->rtlhal.version)) { 80 !IS_92C_SERIAL(rtlpriv->rtlhal.version)) {
80 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_A.bin"; 81 fw_name = "rtlwifi/rtl8192cufw_A.bin";
81 } else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlpriv->rtlhal.version)) { 82 } else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlpriv->rtlhal.version)) {
82 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_B.bin"; 83 fw_name = "rtlwifi/rtl8192cufw_B.bin";
83 } else { 84 } else {
84 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_TMSC.bin"; 85 fw_name = "rtlwifi/rtl8192cufw_TMSC.bin";
85 } 86 }
86 /* provide name of alternative file */ 87 /* provide name of alternative file */
87 rtlpriv->cfg->alt_fw_name = "rtlwifi/rtl8192cufw.bin"; 88 rtlpriv->cfg->alt_fw_name = "rtlwifi/rtl8192cufw.bin";
88 pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name); 89 pr_info("Loading firmware %s\n", fw_name);
89 rtlpriv->max_fw_size = 0x4000; 90 rtlpriv->max_fw_size = 0x4000;
90 err = request_firmware_nowait(THIS_MODULE, 1, 91 err = request_firmware_nowait(THIS_MODULE, 1,
91 rtlpriv->cfg->fw_name, rtlpriv->io.dev, 92 fw_name, rtlpriv->io.dev,
92 GFP_KERNEL, hw, rtl_fw_cb); 93 GFP_KERNEL, hw, rtl_fw_cb);
93 return err; 94 return err;
94} 95}
@@ -187,7 +188,6 @@ static struct rtl_hal_usbint_cfg rtl92cu_interface_cfg = {
187 188
188static struct rtl_hal_cfg rtl92cu_hal_cfg = { 189static struct rtl_hal_cfg rtl92cu_hal_cfg = {
189 .name = "rtl92c_usb", 190 .name = "rtl92c_usb",
190 .fw_name = "rtlwifi/rtl8192cufw.bin",
191 .ops = &rtl8192cu_hal_ops, 191 .ops = &rtl8192cu_hal_ops,
192 .mod_params = &rtl92cu_mod_params, 192 .mod_params = &rtl92cu_mod_params,
193 .usb_interface_cfg = &rtl92cu_interface_cfg, 193 .usb_interface_cfg = &rtl92cu_interface_cfg,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
index 0538a4d09568..1ebfee18882f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
@@ -92,6 +92,7 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
92 u8 tid; 92 u8 tid;
93 struct rtl_priv *rtlpriv = rtl_priv(hw); 93 struct rtl_priv *rtlpriv = rtl_priv(hw);
94 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 94 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
95 char *fw_name = "rtlwifi/rtl8192defw.bin";
95 96
96 rtlpriv->dm.dm_initialgain_enable = true; 97 rtlpriv->dm.dm_initialgain_enable = true;
97 rtlpriv->dm.dm_flag = 0; 98 rtlpriv->dm.dm_flag = 0;
@@ -181,10 +182,10 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
181 182
182 rtlpriv->max_fw_size = 0x8000; 183 rtlpriv->max_fw_size = 0x8000;
183 pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); 184 pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
184 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); 185 pr_info("Loading firmware file %s\n", fw_name);
185 186
186 /* request fw */ 187 /* request fw */
187 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 188 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
188 rtlpriv->io.dev, GFP_KERNEL, hw, 189 rtlpriv->io.dev, GFP_KERNEL, hw,
189 rtl_fw_cb); 190 rtl_fw_cb);
190 if (err) { 191 if (err) {
@@ -266,7 +267,6 @@ static const struct rtl_hal_cfg rtl92de_hal_cfg = {
266 .bar_id = 2, 267 .bar_id = 2,
267 .write_readback = true, 268 .write_readback = true,
268 .name = "rtl8192de", 269 .name = "rtl8192de",
269 .fw_name = "rtlwifi/rtl8192defw.bin",
270 .ops = &rtl8192de_hal_ops, 270 .ops = &rtl8192de_hal_ops,
271 .mod_params = &rtl92de_mod_params, 271 .mod_params = &rtl92de_mod_params,
272 272
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index ac299cbe59b0..46b605de36e7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -91,6 +91,7 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
91 struct rtl_priv *rtlpriv = rtl_priv(hw); 91 struct rtl_priv *rtlpriv = rtl_priv(hw);
92 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 92 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
93 int err = 0; 93 int err = 0;
94 char *fw_name;
94 95
95 rtl92ee_bt_reg_init(hw); 96 rtl92ee_bt_reg_init(hw);
96 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; 97 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support;
@@ -170,11 +171,11 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
170 } 171 }
171 172
172 /* request fw */ 173 /* request fw */
173 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192eefw.bin"; 174 fw_name = "rtlwifi/rtl8192eefw.bin";
174 175
175 rtlpriv->max_fw_size = 0x8000; 176 rtlpriv->max_fw_size = 0x8000;
176 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 177 pr_info("Using firmware %s\n", fw_name);
177 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 178 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
178 rtlpriv->io.dev, GFP_KERNEL, hw, 179 rtlpriv->io.dev, GFP_KERNEL, hw,
179 rtl_fw_cb); 180 rtl_fw_cb);
180 if (err) { 181 if (err) {
@@ -266,7 +267,6 @@ static const struct rtl_hal_cfg rtl92ee_hal_cfg = {
266 .bar_id = 2, 267 .bar_id = 2,
267 .write_readback = true, 268 .write_readback = true,
268 .name = "rtl92ee_pci", 269 .name = "rtl92ee_pci",
269 .fw_name = "rtlwifi/rtl8192eefw.bin",
270 .ops = &rtl8192ee_hal_ops, 270 .ops = &rtl8192ee_hal_ops,
271 .mod_params = &rtl92ee_mod_params, 271 .mod_params = &rtl92ee_mod_params,
272 272
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
index 5e8e02d5de8a..3e1eaeac4fdc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
@@ -89,12 +89,13 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
89 struct ieee80211_hw *hw = context; 89 struct ieee80211_hw *hw = context;
90 struct rtl_priv *rtlpriv = rtl_priv(hw); 90 struct rtl_priv *rtlpriv = rtl_priv(hw);
91 struct rt_firmware *pfirmware = NULL; 91 struct rt_firmware *pfirmware = NULL;
92 char *fw_name = "rtlwifi/rtl8192sefw.bin";
92 93
93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 94 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
94 "Firmware callback routine entered!\n"); 95 "Firmware callback routine entered!\n");
95 complete(&rtlpriv->firmware_loading_complete); 96 complete(&rtlpriv->firmware_loading_complete);
96 if (!firmware) { 97 if (!firmware) {
97 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); 98 pr_err("Firmware %s not available\n", fw_name);
98 rtlpriv->max_fw_size = 0; 99 rtlpriv->max_fw_size = 0;
99 return; 100 return;
100 } 101 }
@@ -117,6 +118,7 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
117 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 118 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
118 int err = 0; 119 int err = 0;
119 u16 earlyrxthreshold = 7; 120 u16 earlyrxthreshold = 7;
121 char *fw_name = "rtlwifi/rtl8192sefw.bin";
120 122
121 rtlpriv->dm.dm_initialgain_enable = true; 123 rtlpriv->dm.dm_initialgain_enable = true;
122 rtlpriv->dm.dm_flag = 0; 124 rtlpriv->dm.dm_flag = 0;
@@ -214,9 +216,9 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
214 rtlpriv->max_fw_size = RTL8190_MAX_FIRMWARE_CODE_SIZE*2 + 216 rtlpriv->max_fw_size = RTL8190_MAX_FIRMWARE_CODE_SIZE*2 +
215 sizeof(struct fw_hdr); 217 sizeof(struct fw_hdr);
216 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" 218 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
217 "Loading firmware %s\n", rtlpriv->cfg->fw_name); 219 "Loading firmware %s\n", fw_name);
218 /* request fw */ 220 /* request fw */
219 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 221 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
220 rtlpriv->io.dev, GFP_KERNEL, hw, 222 rtlpriv->io.dev, GFP_KERNEL, hw,
221 rtl92se_fw_cb); 223 rtl92se_fw_cb);
222 if (err) { 224 if (err) {
@@ -310,7 +312,6 @@ static const struct rtl_hal_cfg rtl92se_hal_cfg = {
310 .bar_id = 1, 312 .bar_id = 1,
311 .write_readback = false, 313 .write_readback = false,
312 .name = "rtl92s_pci", 314 .name = "rtl92s_pci",
313 .fw_name = "rtlwifi/rtl8192sefw.bin",
314 .ops = &rtl8192se_hal_ops, 315 .ops = &rtl8192se_hal_ops,
315 .mod_params = &rtl92se_mod_params, 316 .mod_params = &rtl92se_mod_params,
316 317
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index 89c828ad89f4..c51a9e8234e9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -94,6 +94,7 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
94 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 94 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
95 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 95 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
96 int err = 0; 96 int err = 0;
97 char *fw_name = "rtlwifi/rtl8723fw.bin";
97 98
98 rtl8723e_bt_reg_init(hw); 99 rtl8723e_bt_reg_init(hw);
99 100
@@ -176,14 +177,12 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
176 return 1; 177 return 1;
177 } 178 }
178 179
179 if (IS_VENDOR_8723_A_CUT(rtlhal->version)) 180 if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version))
180 rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw.bin"; 181 fw_name = "rtlwifi/rtl8723fw_B.bin";
181 else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version))
182 rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw_B.bin";
183 182
184 rtlpriv->max_fw_size = 0x6000; 183 rtlpriv->max_fw_size = 0x6000;
185 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 184 pr_info("Using firmware %s\n", fw_name);
186 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 185 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
187 rtlpriv->io.dev, GFP_KERNEL, hw, 186 rtlpriv->io.dev, GFP_KERNEL, hw,
188 rtl_fw_cb); 187 rtl_fw_cb);
189 if (err) { 188 if (err) {
@@ -280,7 +279,6 @@ static const struct rtl_hal_cfg rtl8723e_hal_cfg = {
280 .bar_id = 2, 279 .bar_id = 2,
281 .write_readback = true, 280 .write_readback = true,
282 .name = "rtl8723e_pci", 281 .name = "rtl8723e_pci",
283 .fw_name = "rtlwifi/rtl8723efw.bin",
284 .ops = &rtl8723e_hal_ops, 282 .ops = &rtl8723e_hal_ops,
285 .mod_params = &rtl8723e_mod_params, 283 .mod_params = &rtl8723e_mod_params,
286 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, 284 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index 20b53f035483..847644d1f5f5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -91,6 +91,7 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
91 struct rtl_priv *rtlpriv = rtl_priv(hw); 91 struct rtl_priv *rtlpriv = rtl_priv(hw);
92 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 92 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
93 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 93 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
94 char *fw_name = "rtlwifi/rtl8723befw.bin";
94 95
95 rtl8723be_bt_reg_init(hw); 96 rtl8723be_bt_reg_init(hw);
96 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); 97 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();
@@ -184,8 +185,8 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
184 } 185 }
185 186
186 rtlpriv->max_fw_size = 0x8000; 187 rtlpriv->max_fw_size = 0x8000;
187 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 188 pr_info("Using firmware %s\n", fw_name);
188 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 189 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
189 rtlpriv->io.dev, GFP_KERNEL, hw, 190 rtlpriv->io.dev, GFP_KERNEL, hw,
190 rtl_fw_cb); 191 rtl_fw_cb);
191 if (err) { 192 if (err) {
@@ -280,7 +281,6 @@ static const struct rtl_hal_cfg rtl8723be_hal_cfg = {
280 .bar_id = 2, 281 .bar_id = 2,
281 .write_readback = true, 282 .write_readback = true,
282 .name = "rtl8723be_pci", 283 .name = "rtl8723be_pci",
283 .fw_name = "rtlwifi/rtl8723befw.bin",
284 .ops = &rtl8723be_hal_ops, 284 .ops = &rtl8723be_hal_ops,
285 .mod_params = &rtl8723be_mod_params, 285 .mod_params = &rtl8723be_mod_params,
286 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, 286 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
index 22f687b1f133..297938e0effd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
@@ -93,6 +93,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
94 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 94 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
95 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 95 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
96 char *fw_name, *wowlan_fw_name;
96 97
97 rtl8821ae_bt_reg_init(hw); 98 rtl8821ae_bt_reg_init(hw);
98 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); 99 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();
@@ -203,17 +204,17 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
203 } 204 }
204 205
205 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { 206 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
206 rtlpriv->cfg->fw_name = "rtlwifi/rtl8812aefw.bin"; 207 fw_name = "rtlwifi/rtl8812aefw.bin";
207 rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin"; 208 wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin";
208 } else { 209 } else {
209 rtlpriv->cfg->fw_name = "rtlwifi/rtl8821aefw.bin"; 210 fw_name = "rtlwifi/rtl8821aefw.bin";
210 rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8821aefw_wowlan.bin"; 211 wowlan_fw_name = "rtlwifi/rtl8821aefw_wowlan.bin";
211 } 212 }
212 213
213 rtlpriv->max_fw_size = 0x8000; 214 rtlpriv->max_fw_size = 0x8000;
214 /*load normal firmware*/ 215 /*load normal firmware*/
215 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 216 pr_info("Using firmware %s\n", fw_name);
216 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 217 err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
217 rtlpriv->io.dev, GFP_KERNEL, hw, 218 rtlpriv->io.dev, GFP_KERNEL, hw,
218 rtl_fw_cb); 219 rtl_fw_cb);
219 if (err) { 220 if (err) {
@@ -222,9 +223,9 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
222 return 1; 223 return 1;
223 } 224 }
224 /*load wowlan firmware*/ 225 /*load wowlan firmware*/
225 pr_info("Using firmware %s\n", rtlpriv->cfg->wowlan_fw_name); 226 pr_info("Using firmware %s\n", wowlan_fw_name);
226 err = request_firmware_nowait(THIS_MODULE, 1, 227 err = request_firmware_nowait(THIS_MODULE, 1,
227 rtlpriv->cfg->wowlan_fw_name, 228 wowlan_fw_name,
228 rtlpriv->io.dev, GFP_KERNEL, hw, 229 rtlpriv->io.dev, GFP_KERNEL, hw,
229 rtl_wowlan_fw_cb); 230 rtl_wowlan_fw_cb);
230 if (err) { 231 if (err) {
@@ -320,7 +321,6 @@ static const struct rtl_hal_cfg rtl8821ae_hal_cfg = {
320 .bar_id = 2, 321 .bar_id = 2,
321 .write_readback = true, 322 .write_readback = true,
322 .name = "rtl8821ae_pci", 323 .name = "rtl8821ae_pci",
323 .fw_name = "rtlwifi/rtl8821aefw.bin",
324 .ops = &rtl8821ae_hal_ops, 324 .ops = &rtl8821ae_hal_ops,
325 .mod_params = &rtl8821ae_mod_params, 325 .mod_params = &rtl8821ae_mod_params,
326 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, 326 .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 595f7d5d091a..dafe486f8448 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2278,9 +2278,7 @@ struct rtl_hal_cfg {
2278 u8 bar_id; 2278 u8 bar_id;
2279 bool write_readback; 2279 bool write_readback;
2280 char *name; 2280 char *name;
2281 char *fw_name;
2282 char *alt_fw_name; 2281 char *alt_fw_name;
2283 char *wowlan_fw_name;
2284 struct rtl_hal_ops *ops; 2282 struct rtl_hal_ops *ops;
2285 struct rtl_mod_params *mod_params; 2283 struct rtl_mod_params *mod_params;
2286 struct rtl_hal_usbint_cfg *usb_interface_cfg; 2284 struct rtl_hal_usbint_cfg *usb_interface_cfg;
diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
index a6e94b1a12cb..47fe7f96a242 100644
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -391,7 +391,6 @@ static void wl1271_remove(struct sdio_func *func)
391 pm_runtime_get_noresume(&func->dev); 391 pm_runtime_get_noresume(&func->dev);
392 392
393 platform_device_unregister(glue->core); 393 platform_device_unregister(glue->core);
394 kfree(glue);
395} 394}
396 395
397#ifdef CONFIG_PM 396#ifdef CONFIG_PM
diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig
index 8b2b740d6679..124c2432ac9c 100644
--- a/drivers/nvdimm/Kconfig
+++ b/drivers/nvdimm/Kconfig
@@ -89,7 +89,7 @@ config NVDIMM_PFN
89 Select Y if unsure 89 Select Y if unsure
90 90
91config NVDIMM_DAX 91config NVDIMM_DAX
92 tristate "NVDIMM DAX: Raw access to persistent memory" 92 bool "NVDIMM DAX: Raw access to persistent memory"
93 default LIBNVDIMM 93 default LIBNVDIMM
94 depends on NVDIMM_PFN 94 depends on NVDIMM_PFN
95 help 95 help
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 3509cff68ef9..abe5c6bc756c 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2176,12 +2176,14 @@ static struct device **scan_labels(struct nd_region *nd_region)
2176 return devs; 2176 return devs;
2177 2177
2178 err: 2178 err:
2179 for (i = 0; devs[i]; i++) 2179 if (devs) {
2180 if (is_nd_blk(&nd_region->dev)) 2180 for (i = 0; devs[i]; i++)
2181 namespace_blk_release(devs[i]); 2181 if (is_nd_blk(&nd_region->dev))
2182 else 2182 namespace_blk_release(devs[i]);
2183 namespace_pmem_release(devs[i]); 2183 else
2184 kfree(devs); 2184 namespace_pmem_release(devs[i]);
2185 kfree(devs);
2186 }
2185 return NULL; 2187 return NULL;
2186} 2188}
2187 2189
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 42b3a8217073..24618431a14b 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -47,7 +47,7 @@ static struct nd_region *to_region(struct pmem_device *pmem)
47 return to_nd_region(to_dev(pmem)->parent); 47 return to_nd_region(to_dev(pmem)->parent);
48} 48}
49 49
50static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset, 50static int pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
51 unsigned int len) 51 unsigned int len)
52{ 52{
53 struct device *dev = to_dev(pmem); 53 struct device *dev = to_dev(pmem);
@@ -62,8 +62,12 @@ static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
62 __func__, (unsigned long long) sector, 62 __func__, (unsigned long long) sector,
63 cleared / 512, cleared / 512 > 1 ? "s" : ""); 63 cleared / 512, cleared / 512 > 1 ? "s" : "");
64 badblocks_clear(&pmem->bb, sector, cleared / 512); 64 badblocks_clear(&pmem->bb, sector, cleared / 512);
65 } else {
66 return -EIO;
65 } 67 }
68
66 invalidate_pmem(pmem->virt_addr + offset, len); 69 invalidate_pmem(pmem->virt_addr + offset, len);
70 return 0;
67} 71}
68 72
69static void write_pmem(void *pmem_addr, struct page *page, 73static void write_pmem(void *pmem_addr, struct page *page,
@@ -123,7 +127,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
123 flush_dcache_page(page); 127 flush_dcache_page(page);
124 write_pmem(pmem_addr, page, off, len); 128 write_pmem(pmem_addr, page, off, len);
125 if (unlikely(bad_pmem)) { 129 if (unlikely(bad_pmem)) {
126 pmem_clear_poison(pmem, pmem_off, len); 130 rc = pmem_clear_poison(pmem, pmem_off, len);
127 write_pmem(pmem_addr, page, off, len); 131 write_pmem(pmem_addr, page, off, len);
128 } 132 }
129 } 133 }
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 329381a28edf..79e679d12f3b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -554,7 +554,7 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
554 554
555 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */ 555 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */
556 c.identify.opcode = nvme_admin_identify; 556 c.identify.opcode = nvme_admin_identify;
557 c.identify.cns = cpu_to_le32(1); 557 c.identify.cns = cpu_to_le32(NVME_ID_CNS_CTRL);
558 558
559 *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL); 559 *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL);
560 if (!*id) 560 if (!*id)
@@ -572,7 +572,7 @@ static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *n
572 struct nvme_command c = { }; 572 struct nvme_command c = { };
573 573
574 c.identify.opcode = nvme_admin_identify; 574 c.identify.opcode = nvme_admin_identify;
575 c.identify.cns = cpu_to_le32(2); 575 c.identify.cns = cpu_to_le32(NVME_ID_CNS_NS_ACTIVE_LIST);
576 c.identify.nsid = cpu_to_le32(nsid); 576 c.identify.nsid = cpu_to_le32(nsid);
577 return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list, 0x1000); 577 return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list, 0x1000);
578} 578}
@@ -900,9 +900,9 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
900 return -ENODEV; 900 return -ENODEV;
901 } 901 }
902 902
903 if (ns->ctrl->vs >= NVME_VS(1, 1)) 903 if (ns->ctrl->vs >= NVME_VS(1, 1, 0))
904 memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui)); 904 memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
905 if (ns->ctrl->vs >= NVME_VS(1, 2)) 905 if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
906 memcpy(ns->uuid, (*id)->nguid, sizeof(ns->uuid)); 906 memcpy(ns->uuid, (*id)->nguid, sizeof(ns->uuid));
907 907
908 return 0; 908 return 0;
@@ -1086,6 +1086,8 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)
1086 int ret; 1086 int ret;
1087 1087
1088 while ((ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &csts)) == 0) { 1088 while ((ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &csts)) == 0) {
1089 if (csts == ~0)
1090 return -ENODEV;
1089 if ((csts & NVME_CSTS_RDY) == bit) 1091 if ((csts & NVME_CSTS_RDY) == bit)
1090 break; 1092 break;
1091 1093
@@ -1240,7 +1242,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1240 } 1242 }
1241 page_shift = NVME_CAP_MPSMIN(cap) + 12; 1243 page_shift = NVME_CAP_MPSMIN(cap) + 12;
1242 1244
1243 if (ctrl->vs >= NVME_VS(1, 1)) 1245 if (ctrl->vs >= NVME_VS(1, 1, 0))
1244 ctrl->subsystem = NVME_CAP_NSSRC(cap); 1246 ctrl->subsystem = NVME_CAP_NSSRC(cap);
1245 1247
1246 ret = nvme_identify_ctrl(ctrl, &id); 1248 ret = nvme_identify_ctrl(ctrl, &id);
@@ -1840,7 +1842,7 @@ static void nvme_scan_work(struct work_struct *work)
1840 return; 1842 return;
1841 1843
1842 nn = le32_to_cpu(id->nn); 1844 nn = le32_to_cpu(id->nn);
1843 if (ctrl->vs >= NVME_VS(1, 1) && 1845 if (ctrl->vs >= NVME_VS(1, 1, 0) &&
1844 !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) { 1846 !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) {
1845 if (!nvme_scan_ns_list(ctrl, nn)) 1847 if (!nvme_scan_ns_list(ctrl, nn))
1846 goto done; 1848 goto done;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 0fc99f0f2571..0248d0e21fee 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -99,6 +99,7 @@ struct nvme_dev {
99 dma_addr_t cmb_dma_addr; 99 dma_addr_t cmb_dma_addr;
100 u64 cmb_size; 100 u64 cmb_size;
101 u32 cmbsz; 101 u32 cmbsz;
102 u32 cmbloc;
102 struct nvme_ctrl ctrl; 103 struct nvme_ctrl ctrl;
103 struct completion ioq_wait; 104 struct completion ioq_wait;
104}; 105};
@@ -893,7 +894,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
893 "I/O %d QID %d timeout, reset controller\n", 894 "I/O %d QID %d timeout, reset controller\n",
894 req->tag, nvmeq->qid); 895 req->tag, nvmeq->qid);
895 nvme_dev_disable(dev, false); 896 nvme_dev_disable(dev, false);
896 queue_work(nvme_workq, &dev->reset_work); 897 nvme_reset(dev);
897 898
898 /* 899 /*
899 * Mark the request as handled, since the inline shutdown 900 * Mark the request as handled, since the inline shutdown
@@ -1214,7 +1215,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
1214 u64 cap = lo_hi_readq(dev->bar + NVME_REG_CAP); 1215 u64 cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
1215 struct nvme_queue *nvmeq; 1216 struct nvme_queue *nvmeq;
1216 1217
1217 dev->subsystem = readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 1) ? 1218 dev->subsystem = readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 1, 0) ?
1218 NVME_CAP_NSSRC(cap) : 0; 1219 NVME_CAP_NSSRC(cap) : 0;
1219 1220
1220 if (dev->subsystem && 1221 if (dev->subsystem &&
@@ -1291,7 +1292,7 @@ static void nvme_watchdog_timer(unsigned long data)
1291 1292
1292 /* Skip controllers under certain specific conditions. */ 1293 /* Skip controllers under certain specific conditions. */
1293 if (nvme_should_reset(dev, csts)) { 1294 if (nvme_should_reset(dev, csts)) {
1294 if (queue_work(nvme_workq, &dev->reset_work)) 1295 if (!nvme_reset(dev))
1295 dev_warn(dev->dev, 1296 dev_warn(dev->dev,
1296 "Failed status: 0x%x, reset controller.\n", 1297 "Failed status: 0x%x, reset controller.\n",
1297 csts); 1298 csts);
@@ -1331,28 +1332,37 @@ static int nvme_create_io_queues(struct nvme_dev *dev)
1331 return ret >= 0 ? 0 : ret; 1332 return ret >= 0 ? 0 : ret;
1332} 1333}
1333 1334
1335static ssize_t nvme_cmb_show(struct device *dev,
1336 struct device_attribute *attr,
1337 char *buf)
1338{
1339 struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
1340
1341 return snprintf(buf, PAGE_SIZE, "cmbloc : x%08x\ncmbsz : x%08x\n",
1342 ndev->cmbloc, ndev->cmbsz);
1343}
1344static DEVICE_ATTR(cmb, S_IRUGO, nvme_cmb_show, NULL);
1345
1334static void __iomem *nvme_map_cmb(struct nvme_dev *dev) 1346static void __iomem *nvme_map_cmb(struct nvme_dev *dev)
1335{ 1347{
1336 u64 szu, size, offset; 1348 u64 szu, size, offset;
1337 u32 cmbloc;
1338 resource_size_t bar_size; 1349 resource_size_t bar_size;
1339 struct pci_dev *pdev = to_pci_dev(dev->dev); 1350 struct pci_dev *pdev = to_pci_dev(dev->dev);
1340 void __iomem *cmb; 1351 void __iomem *cmb;
1341 dma_addr_t dma_addr; 1352 dma_addr_t dma_addr;
1342 1353
1343 if (!use_cmb_sqes)
1344 return NULL;
1345
1346 dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ); 1354 dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ);
1347 if (!(NVME_CMB_SZ(dev->cmbsz))) 1355 if (!(NVME_CMB_SZ(dev->cmbsz)))
1348 return NULL; 1356 return NULL;
1357 dev->cmbloc = readl(dev->bar + NVME_REG_CMBLOC);
1349 1358
1350 cmbloc = readl(dev->bar + NVME_REG_CMBLOC); 1359 if (!use_cmb_sqes)
1360 return NULL;
1351 1361
1352 szu = (u64)1 << (12 + 4 * NVME_CMB_SZU(dev->cmbsz)); 1362 szu = (u64)1 << (12 + 4 * NVME_CMB_SZU(dev->cmbsz));
1353 size = szu * NVME_CMB_SZ(dev->cmbsz); 1363 size = szu * NVME_CMB_SZ(dev->cmbsz);
1354 offset = szu * NVME_CMB_OFST(cmbloc); 1364 offset = szu * NVME_CMB_OFST(dev->cmbloc);
1355 bar_size = pci_resource_len(pdev, NVME_CMB_BIR(cmbloc)); 1365 bar_size = pci_resource_len(pdev, NVME_CMB_BIR(dev->cmbloc));
1356 1366
1357 if (offset > bar_size) 1367 if (offset > bar_size)
1358 return NULL; 1368 return NULL;
@@ -1365,7 +1375,7 @@ static void __iomem *nvme_map_cmb(struct nvme_dev *dev)
1365 if (size > bar_size - offset) 1375 if (size > bar_size - offset)
1366 size = bar_size - offset; 1376 size = bar_size - offset;
1367 1377
1368 dma_addr = pci_resource_start(pdev, NVME_CMB_BIR(cmbloc)) + offset; 1378 dma_addr = pci_resource_start(pdev, NVME_CMB_BIR(dev->cmbloc)) + offset;
1369 cmb = ioremap_wc(dma_addr, size); 1379 cmb = ioremap_wc(dma_addr, size);
1370 if (!cmb) 1380 if (!cmb)
1371 return NULL; 1381 return NULL;
@@ -1511,9 +1521,9 @@ static int nvme_delete_queue(struct nvme_queue *nvmeq, u8 opcode)
1511 return 0; 1521 return 0;
1512} 1522}
1513 1523
1514static void nvme_disable_io_queues(struct nvme_dev *dev) 1524static void nvme_disable_io_queues(struct nvme_dev *dev, int queues)
1515{ 1525{
1516 int pass, queues = dev->online_queues - 1; 1526 int pass;
1517 unsigned long timeout; 1527 unsigned long timeout;
1518 u8 opcode = nvme_admin_delete_sq; 1528 u8 opcode = nvme_admin_delete_sq;
1519 1529
@@ -1616,9 +1626,25 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1616 dev->q_depth); 1626 dev->q_depth);
1617 } 1627 }
1618 1628
1619 if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2)) 1629 /*
1630 * CMBs can currently only exist on >=1.2 PCIe devices. We only
1631 * populate sysfs if a CMB is implemented. Note that we add the
1632 * CMB attribute to the nvme_ctrl kobj which removes the need to remove
1633 * it on exit. Since nvme_dev_attrs_group has no name we can pass
1634 * NULL as final argument to sysfs_add_file_to_group.
1635 */
1636
1637 if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) {
1620 dev->cmb = nvme_map_cmb(dev); 1638 dev->cmb = nvme_map_cmb(dev);
1621 1639
1640 if (dev->cmbsz) {
1641 if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
1642 &dev_attr_cmb.attr, NULL))
1643 dev_warn(dev->dev,
1644 "failed to add sysfs attribute for CMB\n");
1645 }
1646 }
1647
1622 pci_enable_pcie_error_reporting(pdev); 1648 pci_enable_pcie_error_reporting(pdev);
1623 pci_save_state(pdev); 1649 pci_save_state(pdev);
1624 return 0; 1650 return 0;
@@ -1649,7 +1675,7 @@ static void nvme_pci_disable(struct nvme_dev *dev)
1649 1675
1650static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) 1676static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1651{ 1677{
1652 int i; 1678 int i, queues;
1653 u32 csts = -1; 1679 u32 csts = -1;
1654 1680
1655 del_timer_sync(&dev->watchdog_timer); 1681 del_timer_sync(&dev->watchdog_timer);
@@ -1660,6 +1686,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1660 csts = readl(dev->bar + NVME_REG_CSTS); 1686 csts = readl(dev->bar + NVME_REG_CSTS);
1661 } 1687 }
1662 1688
1689 queues = dev->online_queues - 1;
1663 for (i = dev->queue_count - 1; i > 0; i--) 1690 for (i = dev->queue_count - 1; i > 0; i--)
1664 nvme_suspend_queue(dev->queues[i]); 1691 nvme_suspend_queue(dev->queues[i]);
1665 1692
@@ -1671,7 +1698,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1671 if (dev->queue_count) 1698 if (dev->queue_count)
1672 nvme_suspend_queue(dev->queues[0]); 1699 nvme_suspend_queue(dev->queues[0]);
1673 } else { 1700 } else {
1674 nvme_disable_io_queues(dev); 1701 nvme_disable_io_queues(dev, queues);
1675 nvme_disable_admin_queue(dev, shutdown); 1702 nvme_disable_admin_queue(dev, shutdown);
1676 } 1703 }
1677 nvme_pci_disable(dev); 1704 nvme_pci_disable(dev);
@@ -1818,11 +1845,10 @@ static int nvme_reset(struct nvme_dev *dev)
1818{ 1845{
1819 if (!dev->ctrl.admin_q || blk_queue_dying(dev->ctrl.admin_q)) 1846 if (!dev->ctrl.admin_q || blk_queue_dying(dev->ctrl.admin_q))
1820 return -ENODEV; 1847 return -ENODEV;
1821 1848 if (work_busy(&dev->reset_work))
1849 return -ENODEV;
1822 if (!queue_work(nvme_workq, &dev->reset_work)) 1850 if (!queue_work(nvme_workq, &dev->reset_work))
1823 return -EBUSY; 1851 return -EBUSY;
1824
1825 flush_work(&dev->reset_work);
1826 return 0; 1852 return 0;
1827} 1853}
1828 1854
@@ -1846,7 +1872,12 @@ static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
1846 1872
1847static int nvme_pci_reset_ctrl(struct nvme_ctrl *ctrl) 1873static int nvme_pci_reset_ctrl(struct nvme_ctrl *ctrl)
1848{ 1874{
1849 return nvme_reset(to_nvme_dev(ctrl)); 1875 struct nvme_dev *dev = to_nvme_dev(ctrl);
1876 int ret = nvme_reset(dev);
1877
1878 if (!ret)
1879 flush_work(&dev->reset_work);
1880 return ret;
1850} 1881}
1851 1882
1852static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = { 1883static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
@@ -1940,7 +1971,7 @@ static void nvme_reset_notify(struct pci_dev *pdev, bool prepare)
1940 if (prepare) 1971 if (prepare)
1941 nvme_dev_disable(dev, false); 1972 nvme_dev_disable(dev, false);
1942 else 1973 else
1943 queue_work(nvme_workq, &dev->reset_work); 1974 nvme_reset(dev);
1944} 1975}
1945 1976
1946static void nvme_shutdown(struct pci_dev *pdev) 1977static void nvme_shutdown(struct pci_dev *pdev)
@@ -2009,7 +2040,7 @@ static int nvme_resume(struct device *dev)
2009 struct pci_dev *pdev = to_pci_dev(dev); 2040 struct pci_dev *pdev = to_pci_dev(dev);
2010 struct nvme_dev *ndev = pci_get_drvdata(pdev); 2041 struct nvme_dev *ndev = pci_get_drvdata(pdev);
2011 2042
2012 queue_work(nvme_workq, &ndev->reset_work); 2043 nvme_reset(ndev);
2013 return 0; 2044 return 0;
2014} 2045}
2015#endif 2046#endif
@@ -2048,7 +2079,7 @@ static pci_ers_result_t nvme_slot_reset(struct pci_dev *pdev)
2048 2079
2049 dev_info(dev->ctrl.device, "restart after slot reset\n"); 2080 dev_info(dev->ctrl.device, "restart after slot reset\n");
2050 pci_restore_state(pdev); 2081 pci_restore_state(pdev);
2051 queue_work(nvme_workq, &dev->reset_work); 2082 nvme_reset(dev);
2052 return PCI_ERS_RESULT_RECOVERED; 2083 return PCI_ERS_RESULT_RECOVERED;
2053} 2084}
2054 2085
diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c
index c2a0a1c7d05d..3eaa4d27801e 100644
--- a/drivers/nvme/host/scsi.c
+++ b/drivers/nvme/host/scsi.c
@@ -606,7 +606,7 @@ static int nvme_fill_device_id_eui64(struct nvme_ns *ns, struct sg_io_hdr *hdr,
606 eui = id_ns->eui64; 606 eui = id_ns->eui64;
607 len = sizeof(id_ns->eui64); 607 len = sizeof(id_ns->eui64);
608 608
609 if (ns->ctrl->vs >= NVME_VS(1, 2)) { 609 if (ns->ctrl->vs >= NVME_VS(1, 2, 0)) {
610 if (bitmap_empty(eui, len * 8)) { 610 if (bitmap_empty(eui, len * 8)) {
611 eui = id_ns->nguid; 611 eui = id_ns->nguid;
612 len = sizeof(id_ns->nguid); 612 len = sizeof(id_ns->nguid);
@@ -679,7 +679,7 @@ static int nvme_trans_device_id_page(struct nvme_ns *ns, struct sg_io_hdr *hdr,
679{ 679{
680 int res; 680 int res;
681 681
682 if (ns->ctrl->vs >= NVME_VS(1, 1)) { 682 if (ns->ctrl->vs >= NVME_VS(1, 1, 0)) {
683 res = nvme_fill_device_id_eui64(ns, hdr, resp, alloc_len); 683 res = nvme_fill_device_id_eui64(ns, hdr, resp, alloc_len);
684 if (res != -EOPNOTSUPP) 684 if (res != -EOPNOTSUPP)
685 return res; 685 return res;
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 7ab9c9381b98..6fe4c48a21e4 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -199,7 +199,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
199 */ 199 */
200 200
201 /* we support multiple ports and multiples hosts: */ 201 /* we support multiple ports and multiples hosts: */
202 id->mic = (1 << 0) | (1 << 1); 202 id->cmic = (1 << 0) | (1 << 1);
203 203
204 /* no limit on data transfer sizes for now */ 204 /* no limit on data transfer sizes for now */
205 id->mdts = 0; 205 id->mdts = 0;
@@ -511,13 +511,13 @@ int nvmet_parse_admin_cmd(struct nvmet_req *req)
511 case nvme_admin_identify: 511 case nvme_admin_identify:
512 req->data_len = 4096; 512 req->data_len = 4096;
513 switch (le32_to_cpu(cmd->identify.cns)) { 513 switch (le32_to_cpu(cmd->identify.cns)) {
514 case 0x00: 514 case NVME_ID_CNS_NS:
515 req->execute = nvmet_execute_identify_ns; 515 req->execute = nvmet_execute_identify_ns;
516 return 0; 516 return 0;
517 case 0x01: 517 case NVME_ID_CNS_CTRL:
518 req->execute = nvmet_execute_identify_ctrl; 518 req->execute = nvmet_execute_identify_ctrl;
519 return 0; 519 return 0;
520 case 0x02: 520 case NVME_ID_CNS_NS_ACTIVE_LIST:
521 req->execute = nvmet_execute_identify_nslist; 521 req->execute = nvmet_execute_identify_nslist;
522 return 0; 522 return 0;
523 } 523 }
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 6559d5afa7bf..b4cacb6f0258 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -882,7 +882,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
882 if (!subsys) 882 if (!subsys)
883 return NULL; 883 return NULL;
884 884
885 subsys->ver = (1 << 16) | (2 << 8) | 1; /* NVMe 1.2.1 */ 885 subsys->ver = NVME_VS(1, 2, 1); /* NVMe 1.2.1 */
886 886
887 switch (type) { 887 switch (type) {
888 case NVME_NQN_NVME: 888 case NVME_NQN_NVME:
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index 6f65646e89cf..12f39eea569f 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -54,7 +54,7 @@ static void nvmet_format_discovery_entry(struct nvmf_disc_rsp_page_hdr *hdr,
54 /* we support only dynamic controllers */ 54 /* we support only dynamic controllers */
55 e->cntlid = cpu_to_le16(NVME_CNTLID_DYNAMIC); 55 e->cntlid = cpu_to_le16(NVME_CNTLID_DYNAMIC);
56 e->asqsz = cpu_to_le16(NVMF_AQ_DEPTH); 56 e->asqsz = cpu_to_le16(NVMF_AQ_DEPTH);
57 e->nqntype = type; 57 e->subtype = type;
58 memcpy(e->trsvcid, port->disc_addr.trsvcid, NVMF_TRSVCID_SIZE); 58 memcpy(e->trsvcid, port->disc_addr.trsvcid, NVMF_TRSVCID_SIZE);
59 memcpy(e->traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE); 59 memcpy(e->traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE);
60 memcpy(e->tsas.common, port->disc_addr.tsas.common, NVMF_TSAS_SIZE); 60 memcpy(e->tsas.common, port->disc_addr.tsas.common, NVMF_TSAS_SIZE);
@@ -187,7 +187,7 @@ int nvmet_parse_discovery_cmd(struct nvmet_req *req)
187 case nvme_admin_identify: 187 case nvme_admin_identify:
188 req->data_len = 4096; 188 req->data_len = 4096;
189 switch (le32_to_cpu(cmd->identify.cns)) { 189 switch (le32_to_cpu(cmd->identify.cns)) {
190 case 0x01: 190 case NVME_ID_CNS_CTRL:
191 req->execute = 191 req->execute =
192 nvmet_execute_identify_disc_ctrl; 192 nvmet_execute_identify_disc_ctrl;
193 return 0; 193 return 0;
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index 2cb7315e26d0..653707996342 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -247,6 +247,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
247 247
248 pp = &pcie->pp; 248 pp = &pcie->pp;
249 pp->dev = dev; 249 pp->dev = dev;
250 pcie->drvdata = match->data;
250 pp->ops = pcie->drvdata->ops; 251 pp->ops = pcie->drvdata->ops;
251 252
252 dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); 253 dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
@@ -256,7 +257,6 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
256 return PTR_ERR(pcie->pp.dbi_base); 257 return PTR_ERR(pcie->pp.dbi_base);
257 } 258 }
258 259
259 pcie->drvdata = match->data;
260 pcie->lut = pcie->pp.dbi_base + pcie->drvdata->lut_offset; 260 pcie->lut = pcie->pp.dbi_base + pcie->drvdata->lut_offset;
261 261
262 if (!ls_pcie_is_bridge(pcie)) 262 if (!ls_pcie_is_bridge(pcie))
diff --git a/drivers/pci/host/pcie-designware-plat.c b/drivers/pci/host/pcie-designware-plat.c
index 537f58a664fa..8df6312ed300 100644
--- a/drivers/pci/host/pcie-designware-plat.c
+++ b/drivers/pci/host/pcie-designware-plat.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) 4 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
5 * 5 *
6 * Authors: Joao Pinto <jpinto@synopsys.com> 6 * Authors: Joao Pinto <jpmpinto@gmail.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index bfdd0744b686..ad70507cfb56 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -610,6 +610,7 @@ static int msi_verify_entries(struct pci_dev *dev)
610 * msi_capability_init - configure device's MSI capability structure 610 * msi_capability_init - configure device's MSI capability structure
611 * @dev: pointer to the pci_dev data structure of MSI device function 611 * @dev: pointer to the pci_dev data structure of MSI device function
612 * @nvec: number of interrupts to allocate 612 * @nvec: number of interrupts to allocate
613 * @affinity: flag to indicate cpu irq affinity mask should be set
613 * 614 *
614 * Setup the MSI capability structure of the device with the requested 615 * Setup the MSI capability structure of the device with the requested
615 * number of interrupts. A return value of zero indicates the successful 616 * number of interrupts. A return value of zero indicates the successful
@@ -752,6 +753,7 @@ static void msix_program_entries(struct pci_dev *dev,
752 * @dev: pointer to the pci_dev data structure of MSI-X device function 753 * @dev: pointer to the pci_dev data structure of MSI-X device function
753 * @entries: pointer to an array of struct msix_entry entries 754 * @entries: pointer to an array of struct msix_entry entries
754 * @nvec: number of @entries 755 * @nvec: number of @entries
756 * @affinity: flag to indicate cpu irq affinity mask should be set
755 * 757 *
756 * Setup the MSI-X capability structure of device function with a 758 * Setup the MSI-X capability structure of device function with a
757 * single MSI-X irq. A return of zero indicates the successful setup of 759 * single MSI-X irq. A return of zero indicates the successful setup of
diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index c2ac7646b99f..a8ac4bcef2c0 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -1011,7 +1011,7 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
1011 rc = acpi_dev_get_resources(adev, &resource_list, 1011 rc = acpi_dev_get_resources(adev, &resource_list,
1012 acpi_pmu_dev_add_resource, &res); 1012 acpi_pmu_dev_add_resource, &res);
1013 acpi_dev_free_resource_list(&resource_list); 1013 acpi_dev_free_resource_list(&resource_list);
1014 if (rc < 0 || IS_ERR(&res)) { 1014 if (rc < 0) {
1015 dev_err(dev, "PMU type %d: No resource address found\n", type); 1015 dev_err(dev, "PMU type %d: No resource address found\n", type);
1016 goto err; 1016 goto err;
1017 } 1017 }
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 67426c0477d3..5c1519b229e0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2754,7 +2754,7 @@ static int _regulator_set_voltage_time(struct regulator_dev *rdev,
2754 ramp_delay = rdev->desc->ramp_delay; 2754 ramp_delay = rdev->desc->ramp_delay;
2755 2755
2756 if (ramp_delay == 0) { 2756 if (ramp_delay == 0) {
2757 rdev_warn(rdev, "ramp_delay not set\n"); 2757 rdev_dbg(rdev, "ramp_delay not set\n");
2758 return 0; 2758 return 0;
2759 } 2759 }
2760 2760
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 8b2558e7363e..968c3ae4535c 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -154,7 +154,7 @@ const struct uniphier_reset_data uniphier_sld3_mio_reset_data[] = {
154 UNIPHIER_RESET_END, 154 UNIPHIER_RESET_END,
155}; 155};
156 156
157const struct uniphier_reset_data uniphier_pro5_mio_reset_data[] = { 157const struct uniphier_reset_data uniphier_pro5_sd_reset_data[] = {
158 UNIPHIER_MIO_RESET_SD(0, 0), 158 UNIPHIER_MIO_RESET_SD(0, 0),
159 UNIPHIER_MIO_RESET_SD(1, 1), 159 UNIPHIER_MIO_RESET_SD(1, 1),
160 UNIPHIER_MIO_RESET_EMMC_HW_RESET(6, 1), 160 UNIPHIER_MIO_RESET_EMMC_HW_RESET(6, 1),
@@ -360,7 +360,7 @@ static const struct of_device_id uniphier_reset_match[] = {
360 .compatible = "socionext,uniphier-ld20-reset", 360 .compatible = "socionext,uniphier-ld20-reset",
361 .data = uniphier_ld20_sys_reset_data, 361 .data = uniphier_ld20_sys_reset_data,
362 }, 362 },
363 /* Media I/O reset */ 363 /* Media I/O reset, SD reset */
364 { 364 {
365 .compatible = "socionext,uniphier-sld3-mio-reset", 365 .compatible = "socionext,uniphier-sld3-mio-reset",
366 .data = uniphier_sld3_mio_reset_data, 366 .data = uniphier_sld3_mio_reset_data,
@@ -378,20 +378,20 @@ static const struct of_device_id uniphier_reset_match[] = {
378 .data = uniphier_sld3_mio_reset_data, 378 .data = uniphier_sld3_mio_reset_data,
379 }, 379 },
380 { 380 {
381 .compatible = "socionext,uniphier-pro5-mio-reset", 381 .compatible = "socionext,uniphier-pro5-sd-reset",
382 .data = uniphier_pro5_mio_reset_data, 382 .data = uniphier_pro5_sd_reset_data,
383 }, 383 },
384 { 384 {
385 .compatible = "socionext,uniphier-pxs2-mio-reset", 385 .compatible = "socionext,uniphier-pxs2-sd-reset",
386 .data = uniphier_pro5_mio_reset_data, 386 .data = uniphier_pro5_sd_reset_data,
387 }, 387 },
388 { 388 {
389 .compatible = "socionext,uniphier-ld11-mio-reset", 389 .compatible = "socionext,uniphier-ld11-mio-reset",
390 .data = uniphier_sld3_mio_reset_data, 390 .data = uniphier_sld3_mio_reset_data,
391 }, 391 },
392 { 392 {
393 .compatible = "socionext,uniphier-ld20-mio-reset", 393 .compatible = "socionext,uniphier-ld20-sd-reset",
394 .data = uniphier_pro5_mio_reset_data, 394 .data = uniphier_pro5_sd_reset_data,
395 }, 395 },
396 /* Peripheral reset */ 396 /* Peripheral reset */
397 { 397 {
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 831935af7389..a7a88476e215 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1205,7 +1205,7 @@ static int verify_fcx_max_data(struct dasd_device *device, __u8 lpm)
1205 mdc, lpm); 1205 mdc, lpm);
1206 return mdc; 1206 return mdc;
1207 } 1207 }
1208 fcx_max_data = mdc * FCX_MAX_DATA_FACTOR; 1208 fcx_max_data = (u32)mdc * FCX_MAX_DATA_FACTOR;
1209 if (fcx_max_data < private->fcx_max_data) { 1209 if (fcx_max_data < private->fcx_max_data) {
1210 dev_warn(&device->cdev->dev, 1210 dev_warn(&device->cdev->dev,
1211 "The maximum data size for zHPF requests %u " 1211 "The maximum data size for zHPF requests %u "
@@ -1675,7 +1675,7 @@ static u32 get_fcx_max_data(struct dasd_device *device)
1675 " data size for zHPF requests failed\n"); 1675 " data size for zHPF requests failed\n");
1676 return 0; 1676 return 0;
1677 } else 1677 } else
1678 return mdc * FCX_MAX_DATA_FACTOR; 1678 return (u32)mdc * FCX_MAX_DATA_FACTOR;
1679} 1679}
1680 1680
1681/* 1681/*
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
index 46be25c7461e..876c7e6e3a99 100644
--- a/drivers/s390/cio/chp.c
+++ b/drivers/s390/cio/chp.c
@@ -780,7 +780,7 @@ static int cfg_wait_idle(void)
780static int __init chp_init(void) 780static int __init chp_init(void)
781{ 781{
782 struct chp_id chpid; 782 struct chp_id chpid;
783 int ret; 783 int state, ret;
784 784
785 ret = crw_register_handler(CRW_RSC_CPATH, chp_process_crw); 785 ret = crw_register_handler(CRW_RSC_CPATH, chp_process_crw);
786 if (ret) 786 if (ret)
@@ -791,7 +791,9 @@ static int __init chp_init(void)
791 return 0; 791 return 0;
792 /* Register available channel-paths. */ 792 /* Register available channel-paths. */
793 chp_id_for_each(&chpid) { 793 chp_id_for_each(&chpid) {
794 if (chp_info_get_status(chpid) != CHP_STATUS_NOT_RECOGNIZED) 794 state = chp_info_get_status(chpid);
795 if (state == CHP_STATUS_CONFIGURED ||
796 state == CHP_STATUS_STANDBY)
795 chp_new(chpid); 797 chp_new(chpid);
796 } 798 }
797 799
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 637cf8973c9e..581001989937 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -384,7 +384,7 @@ void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf,
384 /* if (len > rec_len): 384 /* if (len > rec_len):
385 * dump data up to cap_len ignoring small duplicate in rec->payload 385 * dump data up to cap_len ignoring small duplicate in rec->payload
386 */ 386 */
387 spin_lock_irqsave(&dbf->pay_lock, flags); 387 spin_lock(&dbf->pay_lock);
388 memset(payload, 0, sizeof(*payload)); 388 memset(payload, 0, sizeof(*payload));
389 memcpy(payload->area, paytag, ZFCP_DBF_TAG_LEN); 389 memcpy(payload->area, paytag, ZFCP_DBF_TAG_LEN);
390 payload->fsf_req_id = req_id; 390 payload->fsf_req_id = req_id;
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index db2739079cbb..790babc5ef66 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -353,7 +353,7 @@ static void NCR5380_print_phase(struct Scsi_Host *instance)
353#endif 353#endif
354 354
355 355
356static int probe_irq __initdata; 356static int probe_irq;
357 357
358/** 358/**
359 * probe_intr - helper for IRQ autoprobe 359 * probe_intr - helper for IRQ autoprobe
@@ -365,7 +365,7 @@ static int probe_irq __initdata;
365 * used by the IRQ probe code. 365 * used by the IRQ probe code.
366 */ 366 */
367 367
368static irqreturn_t __init probe_intr(int irq, void *dev_id) 368static irqreturn_t probe_intr(int irq, void *dev_id)
369{ 369{
370 probe_irq = irq; 370 probe_irq = irq;
371 return IRQ_HANDLED; 371 return IRQ_HANDLED;
@@ -380,7 +380,7 @@ static irqreturn_t __init probe_intr(int irq, void *dev_id)
380 * and then looking to see what interrupt actually turned up. 380 * and then looking to see what interrupt actually turned up.
381 */ 381 */
382 382
383static int __init __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance, 383static int __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance,
384 int possible) 384 int possible)
385{ 385{
386 struct NCR5380_hostdata *hostdata = shost_priv(instance); 386 struct NCR5380_hostdata *hostdata = shost_priv(instance);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 68138a647dfc..d9239c2d49b1 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -900,8 +900,9 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
900static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) 900static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
901{ 901{
902 struct sgl_handle *psgl_handle; 902 struct sgl_handle *psgl_handle;
903 unsigned long flags;
903 904
904 spin_lock_bh(&phba->io_sgl_lock); 905 spin_lock_irqsave(&phba->io_sgl_lock, flags);
905 if (phba->io_sgl_hndl_avbl) { 906 if (phba->io_sgl_hndl_avbl) {
906 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, 907 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
907 "BM_%d : In alloc_io_sgl_handle," 908 "BM_%d : In alloc_io_sgl_handle,"
@@ -919,14 +920,16 @@ static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
919 phba->io_sgl_alloc_index++; 920 phba->io_sgl_alloc_index++;
920 } else 921 } else
921 psgl_handle = NULL; 922 psgl_handle = NULL;
922 spin_unlock_bh(&phba->io_sgl_lock); 923 spin_unlock_irqrestore(&phba->io_sgl_lock, flags);
923 return psgl_handle; 924 return psgl_handle;
924} 925}
925 926
926static void 927static void
927free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 928free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
928{ 929{
929 spin_lock_bh(&phba->io_sgl_lock); 930 unsigned long flags;
931
932 spin_lock_irqsave(&phba->io_sgl_lock, flags);
930 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, 933 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
931 "BM_%d : In free_,io_sgl_free_index=%d\n", 934 "BM_%d : In free_,io_sgl_free_index=%d\n",
932 phba->io_sgl_free_index); 935 phba->io_sgl_free_index);
@@ -941,7 +944,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
941 "value there=%p\n", phba->io_sgl_free_index, 944 "value there=%p\n", phba->io_sgl_free_index,
942 phba->io_sgl_hndl_base 945 phba->io_sgl_hndl_base
943 [phba->io_sgl_free_index]); 946 [phba->io_sgl_free_index]);
944 spin_unlock_bh(&phba->io_sgl_lock); 947 spin_unlock_irqrestore(&phba->io_sgl_lock, flags);
945 return; 948 return;
946 } 949 }
947 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; 950 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle;
@@ -950,7 +953,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
950 phba->io_sgl_free_index = 0; 953 phba->io_sgl_free_index = 0;
951 else 954 else
952 phba->io_sgl_free_index++; 955 phba->io_sgl_free_index++;
953 spin_unlock_bh(&phba->io_sgl_lock); 956 spin_unlock_irqrestore(&phba->io_sgl_lock, flags);
954} 957}
955 958
956static inline struct wrb_handle * 959static inline struct wrb_handle *
@@ -958,15 +961,16 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context *pwrb_context,
958 unsigned int wrbs_per_cxn) 961 unsigned int wrbs_per_cxn)
959{ 962{
960 struct wrb_handle *pwrb_handle; 963 struct wrb_handle *pwrb_handle;
964 unsigned long flags;
961 965
962 spin_lock_bh(&pwrb_context->wrb_lock); 966 spin_lock_irqsave(&pwrb_context->wrb_lock, flags);
963 pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index]; 967 pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
964 pwrb_context->wrb_handles_available--; 968 pwrb_context->wrb_handles_available--;
965 if (pwrb_context->alloc_index == (wrbs_per_cxn - 1)) 969 if (pwrb_context->alloc_index == (wrbs_per_cxn - 1))
966 pwrb_context->alloc_index = 0; 970 pwrb_context->alloc_index = 0;
967 else 971 else
968 pwrb_context->alloc_index++; 972 pwrb_context->alloc_index++;
969 spin_unlock_bh(&pwrb_context->wrb_lock); 973 spin_unlock_irqrestore(&pwrb_context->wrb_lock, flags);
970 974
971 if (pwrb_handle) 975 if (pwrb_handle)
972 memset(pwrb_handle->pwrb, 0, sizeof(*pwrb_handle->pwrb)); 976 memset(pwrb_handle->pwrb, 0, sizeof(*pwrb_handle->pwrb));
@@ -1001,14 +1005,16 @@ beiscsi_put_wrb_handle(struct hwi_wrb_context *pwrb_context,
1001 struct wrb_handle *pwrb_handle, 1005 struct wrb_handle *pwrb_handle,
1002 unsigned int wrbs_per_cxn) 1006 unsigned int wrbs_per_cxn)
1003{ 1007{
1004 spin_lock_bh(&pwrb_context->wrb_lock); 1008 unsigned long flags;
1009
1010 spin_lock_irqsave(&pwrb_context->wrb_lock, flags);
1005 pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle; 1011 pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle;
1006 pwrb_context->wrb_handles_available++; 1012 pwrb_context->wrb_handles_available++;
1007 if (pwrb_context->free_index == (wrbs_per_cxn - 1)) 1013 if (pwrb_context->free_index == (wrbs_per_cxn - 1))
1008 pwrb_context->free_index = 0; 1014 pwrb_context->free_index = 0;
1009 else 1015 else
1010 pwrb_context->free_index++; 1016 pwrb_context->free_index++;
1011 spin_unlock_bh(&pwrb_context->wrb_lock); 1017 spin_unlock_irqrestore(&pwrb_context->wrb_lock, flags);
1012} 1018}
1013 1019
1014/** 1020/**
@@ -1037,8 +1043,9 @@ free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context,
1037static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) 1043static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba)
1038{ 1044{
1039 struct sgl_handle *psgl_handle; 1045 struct sgl_handle *psgl_handle;
1046 unsigned long flags;
1040 1047
1041 spin_lock_bh(&phba->mgmt_sgl_lock); 1048 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags);
1042 if (phba->eh_sgl_hndl_avbl) { 1049 if (phba->eh_sgl_hndl_avbl) {
1043 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; 1050 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index];
1044 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; 1051 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL;
@@ -1056,14 +1063,16 @@ static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba)
1056 phba->eh_sgl_alloc_index++; 1063 phba->eh_sgl_alloc_index++;
1057 } else 1064 } else
1058 psgl_handle = NULL; 1065 psgl_handle = NULL;
1059 spin_unlock_bh(&phba->mgmt_sgl_lock); 1066 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags);
1060 return psgl_handle; 1067 return psgl_handle;
1061} 1068}
1062 1069
1063void 1070void
1064free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 1071free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
1065{ 1072{
1066 spin_lock_bh(&phba->mgmt_sgl_lock); 1073 unsigned long flags;
1074
1075 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags);
1067 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 1076 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1068 "BM_%d : In free_mgmt_sgl_handle," 1077 "BM_%d : In free_mgmt_sgl_handle,"
1069 "eh_sgl_free_index=%d\n", 1078 "eh_sgl_free_index=%d\n",
@@ -1078,7 +1087,7 @@ free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
1078 "BM_%d : Double Free in eh SGL ," 1087 "BM_%d : Double Free in eh SGL ,"
1079 "eh_sgl_free_index=%d\n", 1088 "eh_sgl_free_index=%d\n",
1080 phba->eh_sgl_free_index); 1089 phba->eh_sgl_free_index);
1081 spin_unlock_bh(&phba->mgmt_sgl_lock); 1090 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags);
1082 return; 1091 return;
1083 } 1092 }
1084 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; 1093 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle;
@@ -1088,7 +1097,7 @@ free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
1088 phba->eh_sgl_free_index = 0; 1097 phba->eh_sgl_free_index = 0;
1089 else 1098 else
1090 phba->eh_sgl_free_index++; 1099 phba->eh_sgl_free_index++;
1091 spin_unlock_bh(&phba->mgmt_sgl_lock); 1100 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags);
1092} 1101}
1093 1102
1094static void 1103static void
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index a8762a3efeef..532474109624 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2586,7 +2586,6 @@ static void ipr_process_error(struct ipr_cmnd *ipr_cmd)
2586 struct ipr_hostrcb *hostrcb = ipr_cmd->u.hostrcb; 2586 struct ipr_hostrcb *hostrcb = ipr_cmd->u.hostrcb;
2587 u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc); 2587 u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
2588 u32 fd_ioasc; 2588 u32 fd_ioasc;
2589 char *envp[] = { "ASYNC_ERR_LOG=1", NULL };
2590 2589
2591 if (ioa_cfg->sis64) 2590 if (ioa_cfg->sis64)
2592 fd_ioasc = be32_to_cpu(hostrcb->hcam.u.error64.fd_ioasc); 2591 fd_ioasc = be32_to_cpu(hostrcb->hcam.u.error64.fd_ioasc);
@@ -2607,8 +2606,8 @@ static void ipr_process_error(struct ipr_cmnd *ipr_cmd)
2607 } 2606 }
2608 2607
2609 list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_report_q); 2608 list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_report_q);
2609 schedule_work(&ioa_cfg->work_q);
2610 hostrcb = ipr_get_free_hostrcb(ioa_cfg); 2610 hostrcb = ipr_get_free_hostrcb(ioa_cfg);
2611 kobject_uevent_env(&ioa_cfg->host->shost_dev.kobj, KOBJ_CHANGE, envp);
2612 2611
2613 ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_LOG_DATA, hostrcb); 2612 ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_LOG_DATA, hostrcb);
2614} 2613}
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c051694bfcb0..f9b6fba689ff 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -791,9 +791,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
791 791
792free_task: 792free_task:
793 /* regular RX path uses back_lock */ 793 /* regular RX path uses back_lock */
794 spin_lock_bh(&session->back_lock); 794 spin_lock(&session->back_lock);
795 __iscsi_put_task(task); 795 __iscsi_put_task(task);
796 spin_unlock_bh(&session->back_lock); 796 spin_unlock(&session->back_lock);
797 return NULL; 797 return NULL;
798} 798}
799 799
diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index 54d446c9f56e..b8d3b97b217a 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -36,9 +36,9 @@ struct scsi_dh_blist {
36}; 36};
37 37
38static const struct scsi_dh_blist scsi_dh_blist[] = { 38static const struct scsi_dh_blist scsi_dh_blist[] = {
39 {"DGC", "RAID", "clariion" }, 39 {"DGC", "RAID", "emc" },
40 {"DGC", "DISK", "clariion" }, 40 {"DGC", "DISK", "emc" },
41 {"DGC", "VRAID", "clariion" }, 41 {"DGC", "VRAID", "emc" },
42 42
43 {"COMPAQ", "MSA1000 VOLUME", "hp_sw" }, 43 {"COMPAQ", "MSA1000 VOLUME", "hp_sw" },
44 {"COMPAQ", "HSV110", "hp_sw" }, 44 {"COMPAQ", "HSV110", "hp_sw" },
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 212e98d940bc..6f7128f49c30 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1307,7 +1307,6 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
1307static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, 1307static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1308 enum scsi_scan_mode rescan) 1308 enum scsi_scan_mode rescan)
1309{ 1309{
1310 char devname[64];
1311 unsigned char scsi_cmd[MAX_COMMAND_SIZE]; 1310 unsigned char scsi_cmd[MAX_COMMAND_SIZE];
1312 unsigned int length; 1311 unsigned int length;
1313 u64 lun; 1312 u64 lun;
@@ -1349,9 +1348,6 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1349 } 1348 }
1350 } 1349 }
1351 1350
1352 sprintf(devname, "host %d channel %d id %d",
1353 shost->host_no, sdev->channel, sdev->id);
1354
1355 /* 1351 /*
1356 * Allocate enough to hold the header (the same size as one scsi_lun) 1352 * Allocate enough to hold the header (the same size as one scsi_lun)
1357 * plus the number of luns we are requesting. 511 was the default 1353 * plus the number of luns we are requesting. 511 was the default
@@ -1470,12 +1466,12 @@ retry:
1470 out_err: 1466 out_err:
1471 kfree(lun_data); 1467 kfree(lun_data);
1472 out: 1468 out:
1473 scsi_device_put(sdev);
1474 if (scsi_device_created(sdev)) 1469 if (scsi_device_created(sdev))
1475 /* 1470 /*
1476 * the sdev we used didn't appear in the report luns scan 1471 * the sdev we used didn't appear in the report luns scan
1477 */ 1472 */
1478 __scsi_remove_device(sdev); 1473 __scsi_remove_device(sdev);
1474 scsi_device_put(sdev);
1479 return ret; 1475 return ret;
1480} 1476}
1481 1477
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 35c0dd945668..a67b0ff6a362 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -70,6 +70,7 @@
70#define SPI_SR 0x2c 70#define SPI_SR 0x2c
71#define SPI_SR_EOQF 0x10000000 71#define SPI_SR_EOQF 0x10000000
72#define SPI_SR_TCFQF 0x80000000 72#define SPI_SR_TCFQF 0x80000000
73#define SPI_SR_CLEAR 0xdaad0000
73 74
74#define SPI_RSER 0x30 75#define SPI_RSER 0x30
75#define SPI_RSER_EOQFE 0x10000000 76#define SPI_RSER_EOQFE 0x10000000
@@ -646,6 +647,11 @@ static const struct regmap_config dspi_regmap_config = {
646 .max_register = 0x88, 647 .max_register = 0x88,
647}; 648};
648 649
650static void dspi_init(struct fsl_dspi *dspi)
651{
652 regmap_write(dspi->regmap, SPI_SR, SPI_SR_CLEAR);
653}
654
649static int dspi_probe(struct platform_device *pdev) 655static int dspi_probe(struct platform_device *pdev)
650{ 656{
651 struct device_node *np = pdev->dev.of_node; 657 struct device_node *np = pdev->dev.of_node;
@@ -709,6 +715,7 @@ static int dspi_probe(struct platform_device *pdev)
709 return PTR_ERR(dspi->regmap); 715 return PTR_ERR(dspi->regmap);
710 } 716 }
711 717
718 dspi_init(dspi);
712 dspi->irq = platform_get_irq(pdev, 0); 719 dspi->irq = platform_get_irq(pdev, 0);
713 if (dspi->irq < 0) { 720 if (dspi->irq < 0) {
714 dev_err(&pdev->dev, "can't get platform irq\n"); 721 dev_err(&pdev->dev, "can't get platform irq\n");
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 7451585a080e..2c175b9495f7 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -458,7 +458,7 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
458 458
459 mspi->len -= rx_nr_bytes; 459 mspi->len -= rx_nr_bytes;
460 460
461 if (mspi->rx) 461 if (rx_nr_bytes && mspi->rx)
462 mspi->get_rx(rx_data, mspi); 462 mspi->get_rx(rx_data, mspi);
463 } 463 }
464 464
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5787b723b593..838783c3fed0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1618,9 +1618,11 @@ static void of_register_spi_devices(struct spi_master *master)
1618 if (of_node_test_and_set_flag(nc, OF_POPULATED)) 1618 if (of_node_test_and_set_flag(nc, OF_POPULATED))
1619 continue; 1619 continue;
1620 spi = of_register_spi_device(master, nc); 1620 spi = of_register_spi_device(master, nc);
1621 if (IS_ERR(spi)) 1621 if (IS_ERR(spi)) {
1622 dev_warn(&master->dev, "Failed to create SPI device for %s\n", 1622 dev_warn(&master->dev, "Failed to create SPI device for %s\n",
1623 nc->full_name); 1623 nc->full_name);
1624 of_node_clear_flag(nc, OF_POPULATED);
1625 }
1624 } 1626 }
1625} 1627}
1626#else 1628#else
@@ -3131,6 +3133,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
3131 if (IS_ERR(spi)) { 3133 if (IS_ERR(spi)) {
3132 pr_err("%s: failed to create for '%s'\n", 3134 pr_err("%s: failed to create for '%s'\n",
3133 __func__, rd->dn->full_name); 3135 __func__, rd->dn->full_name);
3136 of_node_clear_flag(rd->dn, OF_POPULATED);
3134 return notifier_from_errno(PTR_ERR(spi)); 3137 return notifier_from_errno(PTR_ERR(spi));
3135 } 3138 }
3136 break; 3139 break;
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 396ded52ab70..209a8f7ef02b 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1187,8 +1187,10 @@ int ion_query_heaps(struct ion_client *client, struct ion_heap_query *query)
1187 hdata.type = heap->type; 1187 hdata.type = heap->type;
1188 hdata.heap_id = heap->id; 1188 hdata.heap_id = heap->id;
1189 1189
1190 ret = copy_to_user(&buffer[cnt], 1190 if (copy_to_user(&buffer[cnt], &hdata, sizeof(hdata))) {
1191 &hdata, sizeof(hdata)); 1191 ret = -EFAULT;
1192 goto out;
1193 }
1192 1194
1193 cnt++; 1195 cnt++;
1194 if (cnt >= max_cnt) 1196 if (cnt >= max_cnt)
diff --git a/drivers/staging/android/ion/ion_of.c b/drivers/staging/android/ion/ion_of.c
index 15bac92b7f04..46b2bb99bfd6 100644
--- a/drivers/staging/android/ion/ion_of.c
+++ b/drivers/staging/android/ion/ion_of.c
@@ -107,7 +107,7 @@ struct ion_platform_data *ion_parse_dt(struct platform_device *pdev,
107 107
108 heap_pdev = of_platform_device_create(node, heaps[i].name, 108 heap_pdev = of_platform_device_create(node, heaps[i].name,
109 &pdev->dev); 109 &pdev->dev);
110 if (!pdev) 110 if (!heap_pdev)
111 return ERR_PTR(-ENOMEM); 111 return ERR_PTR(-ENOMEM);
112 heap_pdev->dev.platform_data = &heaps[i]; 112 heap_pdev->dev.platform_data = &heaps[i];
113 113
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index e36ee984485b..34307ac3f255 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -128,6 +128,7 @@ int arche_platform_change_state(enum arche_platform_state state,
128 pdev = of_find_device_by_node(np); 128 pdev = of_find_device_by_node(np);
129 if (!pdev) { 129 if (!pdev) {
130 pr_err("arche-platform device not found\n"); 130 pr_err("arche-platform device not found\n");
131 of_node_put(np);
131 return -ENODEV; 132 return -ENODEV;
132 } 133 }
133 134
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index 071bb1cfd3ae..baab460eeaa3 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -1548,7 +1548,8 @@ static int ap_probe(struct usb_interface *interface,
1548 INIT_LIST_HEAD(&es2->arpcs); 1548 INIT_LIST_HEAD(&es2->arpcs);
1549 spin_lock_init(&es2->arpc_lock); 1549 spin_lock_init(&es2->arpc_lock);
1550 1550
1551 if (es2_arpc_in_enable(es2)) 1551 retval = es2_arpc_in_enable(es2);
1552 if (retval)
1552 goto error; 1553 goto error;
1553 1554
1554 retval = gb_hd_add(hd); 1555 retval = gb_hd_add(hd);
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index 5e06e4229e42..250caa00de5e 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -702,15 +702,13 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
702 ret = gb_gpio_irqchip_add(gpio, irqc, 0, 702 ret = gb_gpio_irqchip_add(gpio, irqc, 0,
703 handle_level_irq, IRQ_TYPE_NONE); 703 handle_level_irq, IRQ_TYPE_NONE);
704 if (ret) { 704 if (ret) {
705 dev_err(&connection->bundle->dev, 705 dev_err(&gbphy_dev->dev, "failed to add irq chip: %d\n", ret);
706 "failed to add irq chip: %d\n", ret);
707 goto exit_line_free; 706 goto exit_line_free;
708 } 707 }
709 708
710 ret = gpiochip_add(gpio); 709 ret = gpiochip_add(gpio);
711 if (ret) { 710 if (ret) {
712 dev_err(&connection->bundle->dev, 711 dev_err(&gbphy_dev->dev, "failed to add gpio chip: %d\n", ret);
713 "failed to add gpio chip: %d\n", ret);
714 goto exit_gpio_irqchip_remove; 712 goto exit_gpio_irqchip_remove;
715 } 713 }
716 714
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index 69f67ddbd4a3..660b4674a76f 100644
--- a/drivers/staging/greybus/module.c
+++ b/drivers/staging/greybus/module.c
@@ -127,7 +127,7 @@ struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
127 return module; 127 return module;
128 128
129err_put_interfaces: 129err_put_interfaces:
130 for (--i; i > 0; --i) 130 for (--i; i >= 0; --i)
131 gb_interface_put(module->interfaces[i]); 131 gb_interface_put(module->interfaces[i]);
132 132
133 put_device(&module->dev); 133 put_device(&module->dev);
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 5ee7954bd9f9..2633d2bfb1b4 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -888,7 +888,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
888 minor = alloc_minor(gb_tty); 888 minor = alloc_minor(gb_tty);
889 if (minor < 0) { 889 if (minor < 0) {
890 if (minor == -ENOSPC) { 890 if (minor == -ENOSPC) {
891 dev_err(&connection->bundle->dev, 891 dev_err(&gbphy_dev->dev,
892 "no more free minor numbers\n"); 892 "no more free minor numbers\n");
893 retval = -ENODEV; 893 retval = -ENODEV;
894 } else { 894 } else {
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index d626125d7af9..564b36d4f648 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -468,6 +468,8 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st,
468 case SCA3000_MEAS_MODE_OP_2: 468 case SCA3000_MEAS_MODE_OP_2:
469 *base_freq = info->option_mode_2_freq; 469 *base_freq = info->option_mode_2_freq;
470 break; 470 break;
471 default:
472 ret = -EINVAL;
471 } 473 }
472error_ret: 474error_ret:
473 return ret; 475 return ret;
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 6eae60595905..23fda9d98bff 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -871,12 +871,10 @@ static ssize_t xattr_cache_store(struct kobject *kobj,
871} 871}
872LUSTRE_RW_ATTR(xattr_cache); 872LUSTRE_RW_ATTR(xattr_cache);
873 873
874static ssize_t unstable_stats_show(struct kobject *kobj, 874static int ll_unstable_stats_seq_show(struct seq_file *m, void *v)
875 struct attribute *attr,
876 char *buf)
877{ 875{
878 struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, 876 struct super_block *sb = m->private;
879 ll_kobj); 877 struct ll_sb_info *sbi = ll_s2sbi(sb);
880 struct cl_client_cache *cache = sbi->ll_cache; 878 struct cl_client_cache *cache = sbi->ll_cache;
881 long pages; 879 long pages;
882 int mb; 880 int mb;
@@ -884,19 +882,21 @@ static ssize_t unstable_stats_show(struct kobject *kobj,
884 pages = atomic_long_read(&cache->ccc_unstable_nr); 882 pages = atomic_long_read(&cache->ccc_unstable_nr);
885 mb = (pages * PAGE_SIZE) >> 20; 883 mb = (pages * PAGE_SIZE) >> 20;
886 884
887 return sprintf(buf, "unstable_check: %8d\n" 885 seq_printf(m,
888 "unstable_pages: %12ld\n" 886 "unstable_check: %8d\n"
889 "unstable_mb: %8d\n", 887 "unstable_pages: %12ld\n"
890 cache->ccc_unstable_check, pages, mb); 888 "unstable_mb: %8d\n",
889 cache->ccc_unstable_check, pages, mb);
890
891 return 0;
891} 892}
892 893
893static ssize_t unstable_stats_store(struct kobject *kobj, 894static ssize_t ll_unstable_stats_seq_write(struct file *file,
894 struct attribute *attr, 895 const char __user *buffer,
895 const char *buffer, 896 size_t count, loff_t *off)
896 size_t count)
897{ 897{
898 struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, 898 struct super_block *sb = ((struct seq_file *)file->private_data)->private;
899 ll_kobj); 899 struct ll_sb_info *sbi = ll_s2sbi(sb);
900 char kernbuf[128]; 900 char kernbuf[128];
901 int val, rc; 901 int val, rc;
902 902
@@ -922,7 +922,7 @@ static ssize_t unstable_stats_store(struct kobject *kobj,
922 922
923 return count; 923 return count;
924} 924}
925LUSTRE_RW_ATTR(unstable_stats); 925LPROC_SEQ_FOPS(ll_unstable_stats);
926 926
927static ssize_t root_squash_show(struct kobject *kobj, struct attribute *attr, 927static ssize_t root_squash_show(struct kobject *kobj, struct attribute *attr,
928 char *buf) 928 char *buf)
@@ -995,6 +995,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
995 /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ 995 /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */
996 { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, 996 { "max_cached_mb", &ll_max_cached_mb_fops, NULL },
997 { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, 997 { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 },
998 { "unstable_stats", &ll_unstable_stats_fops, NULL },
998 { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, 999 { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 },
999 { .name = "nosquash_nids", 1000 { .name = "nosquash_nids",
1000 .fops = &ll_nosquash_nids_fops }, 1001 .fops = &ll_nosquash_nids_fops },
@@ -1026,7 +1027,6 @@ static struct attribute *llite_attrs[] = {
1026 &lustre_attr_max_easize.attr, 1027 &lustre_attr_max_easize.attr,
1027 &lustre_attr_default_easize.attr, 1028 &lustre_attr_default_easize.attr,
1028 &lustre_attr_xattr_cache.attr, 1029 &lustre_attr_xattr_cache.attr,
1029 &lustre_attr_unstable_stats.attr,
1030 &lustre_attr_root_squash.attr, 1030 &lustre_attr_root_squash.attr,
1031 NULL, 1031 NULL,
1032}; 1032};
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 78f5613e9467..6ab7443eabde 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3388,7 +3388,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3388 3388
3389 clients_count++; 3389 clients_count++;
3390 3390
3391 destroy_workqueue(hif_workqueue);
3392_fail_: 3391_fail_:
3393 return result; 3392 return result;
3394} 3393}
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 39b928c2849d..b7d747e92c7a 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1804,6 +1804,10 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1804 * Otherwise, initiator is not expecting a NOPIN is response. 1804 * Otherwise, initiator is not expecting a NOPIN is response.
1805 * Just ignore for now. 1805 * Just ignore for now.
1806 */ 1806 */
1807
1808 if (cmd)
1809 iscsit_free_cmd(cmd, false);
1810
1807 return 0; 1811 return 0;
1808} 1812}
1809EXPORT_SYMBOL(iscsit_process_nop_out); 1813EXPORT_SYMBOL(iscsit_process_nop_out);
@@ -2982,7 +2986,7 @@ iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
2982 2986
2983 pr_debug("Built NOPIN %s Response ITT: 0x%08x, TTT: 0x%08x," 2987 pr_debug("Built NOPIN %s Response ITT: 0x%08x, TTT: 0x%08x,"
2984 " StatSN: 0x%08x, Length %u\n", (nopout_response) ? 2988 " StatSN: 0x%08x, Length %u\n", (nopout_response) ?
2985 "Solicitied" : "Unsolicitied", cmd->init_task_tag, 2989 "Solicited" : "Unsolicited", cmd->init_task_tag,
2986 cmd->targ_xfer_tag, cmd->stat_sn, cmd->buf_ptr_size); 2990 cmd->targ_xfer_tag, cmd->stat_sn, cmd->buf_ptr_size);
2987} 2991}
2988EXPORT_SYMBOL(iscsit_build_nopin_rsp); 2992EXPORT_SYMBOL(iscsit_build_nopin_rsp);
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index adf419fa4291..15f79a2ca34a 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -434,7 +434,7 @@ static int iscsi_login_zero_tsih_s2(
434 434
435 /* 435 /*
436 * Make MaxRecvDataSegmentLength PAGE_SIZE aligned for 436 * Make MaxRecvDataSegmentLength PAGE_SIZE aligned for
437 * Immediate Data + Unsolicitied Data-OUT if necessary.. 437 * Immediate Data + Unsolicited Data-OUT if necessary..
438 */ 438 */
439 param = iscsi_find_param_from_key("MaxRecvDataSegmentLength", 439 param = iscsi_find_param_from_key("MaxRecvDataSegmentLength",
440 conn->param_list); 440 conn->param_list);
@@ -646,7 +646,7 @@ static void iscsi_post_login_start_timers(struct iscsi_conn *conn)
646{ 646{
647 struct iscsi_session *sess = conn->sess; 647 struct iscsi_session *sess = conn->sess;
648 /* 648 /*
649 * FIXME: Unsolicitied NopIN support for ISER 649 * FIXME: Unsolicited NopIN support for ISER
650 */ 650 */
651 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND) 651 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND)
652 return; 652 return;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 6094a6beddde..7dfefd66df93 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -754,15 +754,7 @@ EXPORT_SYMBOL(target_complete_cmd);
754 754
755void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length) 755void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length)
756{ 756{
757 if (scsi_status != SAM_STAT_GOOD) { 757 if (scsi_status == SAM_STAT_GOOD && length < cmd->data_length) {
758 return;
759 }
760
761 /*
762 * Calculate new residual count based upon length of SCSI data
763 * transferred.
764 */
765 if (length < cmd->data_length) {
766 if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) { 758 if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
767 cmd->residual_count += cmd->data_length - length; 759 cmd->residual_count += cmd->data_length - length;
768 } else { 760 } else {
@@ -771,12 +763,6 @@ void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int len
771 } 763 }
772 764
773 cmd->data_length = length; 765 cmd->data_length = length;
774 } else if (length > cmd->data_length) {
775 cmd->se_cmd_flags |= SCF_OVERFLOW_BIT;
776 cmd->residual_count = length - cmd->data_length;
777 } else {
778 cmd->se_cmd_flags &= ~(SCF_OVERFLOW_BIT | SCF_UNDERFLOW_BIT);
779 cmd->residual_count = 0;
780 } 766 }
781 767
782 target_complete_cmd(cmd, scsi_status); 768 target_complete_cmd(cmd, scsi_status);
@@ -1706,6 +1692,7 @@ void transport_generic_request_failure(struct se_cmd *cmd,
1706 case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED: 1692 case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED:
1707 case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED: 1693 case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED:
1708 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:
1709 break; 1696 break;
1710 case TCM_OUT_OF_RESOURCES: 1697 case TCM_OUT_OF_RESOURCES:
1711 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1698 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -2547,8 +2534,12 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref)
2547 * fabric acknowledgement that requires two target_put_sess_cmd() 2534 * fabric acknowledgement that requires two target_put_sess_cmd()
2548 * invocations before se_cmd descriptor release. 2535 * invocations before se_cmd descriptor release.
2549 */ 2536 */
2550 if (ack_kref) 2537 if (ack_kref) {
2551 kref_get(&se_cmd->cmd_kref); 2538 if (!kref_get_unless_zero(&se_cmd->cmd_kref))
2539 return -EINVAL;
2540
2541 se_cmd->se_cmd_flags |= SCF_ACK_KREF;
2542 }
2552 2543
2553 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); 2544 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
2554 if (se_sess->sess_tearing_down) { 2545 if (se_sess->sess_tearing_down) {
@@ -2627,7 +2618,7 @@ EXPORT_SYMBOL(target_put_sess_cmd);
2627 */ 2618 */
2628void target_sess_cmd_list_set_waiting(struct se_session *se_sess) 2619void target_sess_cmd_list_set_waiting(struct se_session *se_sess)
2629{ 2620{
2630 struct se_cmd *se_cmd; 2621 struct se_cmd *se_cmd, *tmp_cmd;
2631 unsigned long flags; 2622 unsigned long flags;
2632 int rc; 2623 int rc;
2633 2624
@@ -2639,14 +2630,16 @@ void target_sess_cmd_list_set_waiting(struct se_session *se_sess)
2639 se_sess->sess_tearing_down = 1; 2630 se_sess->sess_tearing_down = 1;
2640 list_splice_init(&se_sess->sess_cmd_list, &se_sess->sess_wait_list); 2631 list_splice_init(&se_sess->sess_cmd_list, &se_sess->sess_wait_list);
2641 2632
2642 list_for_each_entry(se_cmd, &se_sess->sess_wait_list, se_cmd_list) { 2633 list_for_each_entry_safe(se_cmd, tmp_cmd,
2634 &se_sess->sess_wait_list, se_cmd_list) {
2643 rc = kref_get_unless_zero(&se_cmd->cmd_kref); 2635 rc = kref_get_unless_zero(&se_cmd->cmd_kref);
2644 if (rc) { 2636 if (rc) {
2645 se_cmd->cmd_wait_set = 1; 2637 se_cmd->cmd_wait_set = 1;
2646 spin_lock(&se_cmd->t_state_lock); 2638 spin_lock(&se_cmd->t_state_lock);
2647 se_cmd->transport_state |= CMD_T_FABRIC_STOP; 2639 se_cmd->transport_state |= CMD_T_FABRIC_STOP;
2648 spin_unlock(&se_cmd->t_state_lock); 2640 spin_unlock(&se_cmd->t_state_lock);
2649 } 2641 } else
2642 list_del_init(&se_cmd->se_cmd_list);
2650 } 2643 }
2651 2644
2652 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2645 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
@@ -2871,6 +2864,12 @@ static const struct sense_info sense_info_table[] = {
2871 .ascq = 0x03, /* LOGICAL BLOCK REFERENCE TAG CHECK FAILED */ 2864 .ascq = 0x03, /* LOGICAL BLOCK REFERENCE TAG CHECK FAILED */
2872 .add_sector_info = true, 2865 .add_sector_info = true,
2873 }, 2866 },
2867 [TCM_COPY_TARGET_DEVICE_NOT_REACHABLE] = {
2868 .key = COPY_ABORTED,
2869 .asc = 0x0d,
2870 .ascq = 0x02, /* COPY TARGET DEVICE NOT REACHABLE */
2871
2872 },
2874 [TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE] = { 2873 [TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE] = {
2875 /* 2874 /*
2876 * Returning ILLEGAL REQUEST would cause immediate IO errors on 2875 * Returning ILLEGAL REQUEST would cause immediate IO errors on
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 62bf4fe5704a..47562509b489 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -96,7 +96,7 @@ struct tcmu_dev {
96 size_t dev_size; 96 size_t dev_size;
97 u32 cmdr_size; 97 u32 cmdr_size;
98 u32 cmdr_last_cleaned; 98 u32 cmdr_last_cleaned;
99 /* Offset of data ring from start of mb */ 99 /* Offset of data area from start of mb */
100 /* Must add data_off and mb_addr to get the address */ 100 /* Must add data_off and mb_addr to get the address */
101 size_t data_off; 101 size_t data_off;
102 size_t data_size; 102 size_t data_size;
@@ -349,7 +349,7 @@ static inline size_t spc_bitmap_free(unsigned long *bitmap)
349 349
350/* 350/*
351 * We can't queue a command until we have space available on the cmd ring *and* 351 * We can't queue a command until we have space available on the cmd ring *and*
352 * space available on the data ring. 352 * space available on the data area.
353 * 353 *
354 * Called with ring lock held. 354 * Called with ring lock held.
355 */ 355 */
@@ -389,7 +389,8 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, size_t cmd_size, size_t d
389 return true; 389 return true;
390} 390}
391 391
392static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) 392static sense_reason_t
393tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
393{ 394{
394 struct tcmu_dev *udev = tcmu_cmd->tcmu_dev; 395 struct tcmu_dev *udev = tcmu_cmd->tcmu_dev;
395 struct se_cmd *se_cmd = tcmu_cmd->se_cmd; 396 struct se_cmd *se_cmd = tcmu_cmd->se_cmd;
@@ -405,7 +406,7 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
405 DECLARE_BITMAP(old_bitmap, DATA_BLOCK_BITS); 406 DECLARE_BITMAP(old_bitmap, DATA_BLOCK_BITS);
406 407
407 if (test_bit(TCMU_DEV_BIT_BROKEN, &udev->flags)) 408 if (test_bit(TCMU_DEV_BIT_BROKEN, &udev->flags))
408 return -EINVAL; 409 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
409 410
410 /* 411 /*
411 * Must be a certain minimum size for response sense info, but 412 * Must be a certain minimum size for response sense info, but
@@ -432,11 +433,14 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
432 BUG_ON(!(se_cmd->t_bidi_data_sg && se_cmd->t_bidi_data_nents)); 433 BUG_ON(!(se_cmd->t_bidi_data_sg && se_cmd->t_bidi_data_nents));
433 data_length += se_cmd->t_bidi_data_sg->length; 434 data_length += se_cmd->t_bidi_data_sg->length;
434 } 435 }
435 if ((command_size > (udev->cmdr_size / 2)) 436 if ((command_size > (udev->cmdr_size / 2)) ||
436 || data_length > udev->data_size) 437 data_length > udev->data_size) {
437 pr_warn("TCMU: Request of size %zu/%zu may be too big for %u/%zu " 438 pr_warn("TCMU: Request of size %zu/%zu is too big for %u/%zu "
438 "cmd/data ring buffers\n", command_size, data_length, 439 "cmd ring/data area\n", command_size, data_length,
439 udev->cmdr_size, udev->data_size); 440 udev->cmdr_size, udev->data_size);
441 spin_unlock_irq(&udev->cmdr_lock);
442 return TCM_INVALID_CDB_FIELD;
443 }
440 444
441 while (!is_ring_space_avail(udev, command_size, data_length)) { 445 while (!is_ring_space_avail(udev, command_size, data_length)) {
442 int ret; 446 int ret;
@@ -450,7 +454,7 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
450 finish_wait(&udev->wait_cmdr, &__wait); 454 finish_wait(&udev->wait_cmdr, &__wait);
451 if (!ret) { 455 if (!ret) {
452 pr_warn("tcmu: command timed out\n"); 456 pr_warn("tcmu: command timed out\n");
453 return -ETIMEDOUT; 457 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
454 } 458 }
455 459
456 spin_lock_irq(&udev->cmdr_lock); 460 spin_lock_irq(&udev->cmdr_lock);
@@ -487,9 +491,7 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
487 491
488 bitmap_copy(old_bitmap, udev->data_bitmap, DATA_BLOCK_BITS); 492 bitmap_copy(old_bitmap, udev->data_bitmap, DATA_BLOCK_BITS);
489 493
490 /* 494 /* Handle allocating space from the data area */
491 * Fix up iovecs, and handle if allocation in data ring wrapped.
492 */
493 iov = &entry->req.iov[0]; 495 iov = &entry->req.iov[0];
494 iov_cnt = 0; 496 iov_cnt = 0;
495 copy_to_data_area = (se_cmd->data_direction == DMA_TO_DEVICE 497 copy_to_data_area = (se_cmd->data_direction == DMA_TO_DEVICE
@@ -526,10 +528,11 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
526 mod_timer(&udev->timeout, 528 mod_timer(&udev->timeout,
527 round_jiffies_up(jiffies + msecs_to_jiffies(TCMU_TIME_OUT))); 529 round_jiffies_up(jiffies + msecs_to_jiffies(TCMU_TIME_OUT)));
528 530
529 return 0; 531 return TCM_NO_SENSE;
530} 532}
531 533
532static int tcmu_queue_cmd(struct se_cmd *se_cmd) 534static sense_reason_t
535tcmu_queue_cmd(struct se_cmd *se_cmd)
533{ 536{
534 struct se_device *se_dev = se_cmd->se_dev; 537 struct se_device *se_dev = se_cmd->se_dev;
535 struct tcmu_dev *udev = TCMU_DEV(se_dev); 538 struct tcmu_dev *udev = TCMU_DEV(se_dev);
@@ -538,10 +541,10 @@ static int tcmu_queue_cmd(struct se_cmd *se_cmd)
538 541
539 tcmu_cmd = tcmu_alloc_cmd(se_cmd); 542 tcmu_cmd = tcmu_alloc_cmd(se_cmd);
540 if (!tcmu_cmd) 543 if (!tcmu_cmd)
541 return -ENOMEM; 544 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
542 545
543 ret = tcmu_queue_cmd_ring(tcmu_cmd); 546 ret = tcmu_queue_cmd_ring(tcmu_cmd);
544 if (ret < 0) { 547 if (ret != TCM_NO_SENSE) {
545 pr_err("TCMU: Could not queue command\n"); 548 pr_err("TCMU: Could not queue command\n");
546 spin_lock_irq(&udev->commands_lock); 549 spin_lock_irq(&udev->commands_lock);
547 idr_remove(&udev->commands, tcmu_cmd->cmd_id); 550 idr_remove(&udev->commands, tcmu_cmd->cmd_id);
@@ -561,7 +564,7 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
561 if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags)) { 564 if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags)) {
562 /* 565 /*
563 * cmd has been completed already from timeout, just reclaim 566 * cmd has been completed already from timeout, just reclaim
564 * data ring space and free cmd 567 * data area space and free cmd
565 */ 568 */
566 free_data_area(udev, cmd); 569 free_data_area(udev, cmd);
567 570
@@ -1129,20 +1132,9 @@ static sector_t tcmu_get_blocks(struct se_device *dev)
1129} 1132}
1130 1133
1131static sense_reason_t 1134static sense_reason_t
1132tcmu_pass_op(struct se_cmd *se_cmd)
1133{
1134 int ret = tcmu_queue_cmd(se_cmd);
1135
1136 if (ret != 0)
1137 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1138 else
1139 return TCM_NO_SENSE;
1140}
1141
1142static sense_reason_t
1143tcmu_parse_cdb(struct se_cmd *cmd) 1135tcmu_parse_cdb(struct se_cmd *cmd)
1144{ 1136{
1145 return passthrough_parse_cdb(cmd, tcmu_pass_op); 1137 return passthrough_parse_cdb(cmd, tcmu_queue_cmd);
1146} 1138}
1147 1139
1148static const struct target_backend_ops tcmu_ops = { 1140static const struct target_backend_ops tcmu_ops = {
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 75cd85426ae3..094a1440eacb 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -104,7 +104,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
104 } 104 }
105 mutex_unlock(&g_device_mutex); 105 mutex_unlock(&g_device_mutex);
106 106
107 pr_err("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n"); 107 pr_debug_ratelimited("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n");
108 return -EINVAL; 108 return -EINVAL;
109} 109}
110 110
@@ -185,7 +185,7 @@ static int target_xcopy_parse_tiddesc_e4(struct se_cmd *se_cmd, struct xcopy_op
185 185
186static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd, 186static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
187 struct xcopy_op *xop, unsigned char *p, 187 struct xcopy_op *xop, unsigned char *p,
188 unsigned short tdll) 188 unsigned short tdll, sense_reason_t *sense_ret)
189{ 189{
190 struct se_device *local_dev = se_cmd->se_dev; 190 struct se_device *local_dev = se_cmd->se_dev;
191 unsigned char *desc = p; 191 unsigned char *desc = p;
@@ -193,6 +193,8 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
193 unsigned short start = 0; 193 unsigned short start = 0;
194 bool src = true; 194 bool src = true;
195 195
196 *sense_ret = TCM_INVALID_PARAMETER_LIST;
197
196 if (offset != 0) { 198 if (offset != 0) {
197 pr_err("XCOPY target descriptor list length is not" 199 pr_err("XCOPY target descriptor list length is not"
198 " multiple of %d\n", XCOPY_TARGET_DESC_LEN); 200 " multiple of %d\n", XCOPY_TARGET_DESC_LEN);
@@ -243,9 +245,16 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
243 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, true); 245 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, true);
244 else 246 else
245 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, false); 247 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, false);
246 248 /*
247 if (rc < 0) 249 * If a matching IEEE NAA 0x83 descriptor for the requested device
250 * is not located on this node, return COPY_ABORTED with ASQ/ASQC
251 * 0x0d/0x02 - COPY_TARGET_DEVICE_NOT_REACHABLE to request the
252 * initiator to fall back to normal copy method.
253 */
254 if (rc < 0) {
255 *sense_ret = TCM_COPY_TARGET_DEVICE_NOT_REACHABLE;
248 goto out; 256 goto out;
257 }
249 258
250 pr_debug("XCOPY TGT desc: Source dev: %p NAA IEEE WWN: 0x%16phN\n", 259 pr_debug("XCOPY TGT desc: Source dev: %p NAA IEEE WWN: 0x%16phN\n",
251 xop->src_dev, &xop->src_tid_wwn[0]); 260 xop->src_dev, &xop->src_tid_wwn[0]);
@@ -653,6 +662,7 @@ static int target_xcopy_read_source(
653 rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0], 662 rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0],
654 remote_port, true); 663 remote_port, true);
655 if (rc < 0) { 664 if (rc < 0) {
665 ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
656 transport_generic_free_cmd(se_cmd, 0); 666 transport_generic_free_cmd(se_cmd, 0);
657 return rc; 667 return rc;
658 } 668 }
@@ -664,6 +674,7 @@ static int target_xcopy_read_source(
664 674
665 rc = target_xcopy_issue_pt_cmd(xpt_cmd); 675 rc = target_xcopy_issue_pt_cmd(xpt_cmd);
666 if (rc < 0) { 676 if (rc < 0) {
677 ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
667 transport_generic_free_cmd(se_cmd, 0); 678 transport_generic_free_cmd(se_cmd, 0);
668 return rc; 679 return rc;
669 } 680 }
@@ -714,6 +725,7 @@ static int target_xcopy_write_destination(
714 remote_port, false); 725 remote_port, false);
715 if (rc < 0) { 726 if (rc < 0) {
716 struct se_cmd *src_cmd = &xop->src_pt_cmd->se_cmd; 727 struct se_cmd *src_cmd = &xop->src_pt_cmd->se_cmd;
728 ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
717 /* 729 /*
718 * If the failure happened before the t_mem_list hand-off in 730 * If the failure happened before the t_mem_list hand-off in
719 * target_xcopy_setup_pt_cmd(), Reset memory + clear flag so that 731 * target_xcopy_setup_pt_cmd(), Reset memory + clear flag so that
@@ -729,6 +741,7 @@ static int target_xcopy_write_destination(
729 741
730 rc = target_xcopy_issue_pt_cmd(xpt_cmd); 742 rc = target_xcopy_issue_pt_cmd(xpt_cmd);
731 if (rc < 0) { 743 if (rc < 0) {
744 ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
732 se_cmd->se_cmd_flags &= ~SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC; 745 se_cmd->se_cmd_flags &= ~SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC;
733 transport_generic_free_cmd(se_cmd, 0); 746 transport_generic_free_cmd(se_cmd, 0);
734 return rc; 747 return rc;
@@ -815,9 +828,14 @@ static void target_xcopy_do_work(struct work_struct *work)
815out: 828out:
816 xcopy_pt_undepend_remotedev(xop); 829 xcopy_pt_undepend_remotedev(xop);
817 kfree(xop); 830 kfree(xop);
818 831 /*
819 pr_warn("target_xcopy_do_work: Setting X-COPY CHECK_CONDITION -> sending response\n"); 832 * Don't override an error scsi status if it has already been set
820 ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION; 833 */
834 if (ec_cmd->scsi_status == SAM_STAT_GOOD) {
835 pr_warn_ratelimited("target_xcopy_do_work: rc: %d, Setting X-COPY"
836 " CHECK_CONDITION -> sending response\n", rc);
837 ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
838 }
821 target_complete_cmd(ec_cmd, SAM_STAT_CHECK_CONDITION); 839 target_complete_cmd(ec_cmd, SAM_STAT_CHECK_CONDITION);
822} 840}
823 841
@@ -875,7 +893,7 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
875 " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, 893 " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage,
876 tdll, sdll, inline_dl); 894 tdll, sdll, inline_dl);
877 895
878 rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll); 896 rc = target_xcopy_parse_target_descriptors(se_cmd, xop, &p[16], tdll, &ret);
879 if (rc <= 0) 897 if (rc <= 0)
880 goto out; 898 goto out;
881 899
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 216e18cc9133..ff5de9a96643 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -572,10 +572,10 @@ static void ft_send_work(struct work_struct *work)
572 if (target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb, 572 if (target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb,
573 &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), 573 &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun),
574 ntohl(fcp->fc_dl), task_attr, data_dir, 574 ntohl(fcp->fc_dl), task_attr, data_dir,
575 TARGET_SCF_ACK_KREF)) 575 TARGET_SCF_ACK_KREF | TARGET_SCF_USE_CPUID))
576 goto err; 576 goto err;
577 577
578 pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl); 578 pr_debug("r_ctl %x target_submit_cmd %p\n", fh->fh_r_ctl, cmd);
579 return; 579 return;
580 580
581err: 581err:
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index 6ffbb603d912..fd5c3de79470 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -39,6 +39,11 @@
39 39
40#include "tcm_fc.h" 40#include "tcm_fc.h"
41 41
42#define TFC_SESS_DBG(lport, fmt, args...) \
43 pr_debug("host%u: rport %6.6x: " fmt, \
44 (lport)->host->host_no, \
45 (lport)->port_id, ##args )
46
42static void ft_sess_delete_all(struct ft_tport *); 47static void ft_sess_delete_all(struct ft_tport *);
43 48
44/* 49/*
@@ -167,24 +172,29 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id)
167 struct ft_tport *tport; 172 struct ft_tport *tport;
168 struct hlist_head *head; 173 struct hlist_head *head;
169 struct ft_sess *sess; 174 struct ft_sess *sess;
175 char *reason = "no session created";
170 176
171 rcu_read_lock(); 177 rcu_read_lock();
172 tport = rcu_dereference(lport->prov[FC_TYPE_FCP]); 178 tport = rcu_dereference(lport->prov[FC_TYPE_FCP]);
173 if (!tport) 179 if (!tport) {
180 reason = "not an FCP port";
174 goto out; 181 goto out;
182 }
175 183
176 head = &tport->hash[ft_sess_hash(port_id)]; 184 head = &tport->hash[ft_sess_hash(port_id)];
177 hlist_for_each_entry_rcu(sess, head, hash) { 185 hlist_for_each_entry_rcu(sess, head, hash) {
178 if (sess->port_id == port_id) { 186 if (sess->port_id == port_id) {
179 kref_get(&sess->kref); 187 kref_get(&sess->kref);
180 rcu_read_unlock(); 188 rcu_read_unlock();
181 pr_debug("port_id %x found %p\n", port_id, sess); 189 TFC_SESS_DBG(lport, "port_id %x found %p\n",
190 port_id, sess);
182 return sess; 191 return sess;
183 } 192 }
184 } 193 }
185out: 194out:
186 rcu_read_unlock(); 195 rcu_read_unlock();
187 pr_debug("port_id %x not found\n", port_id); 196 TFC_SESS_DBG(lport, "port_id %x not found, %s\n",
197 port_id, reason);
188 return NULL; 198 return NULL;
189} 199}
190 200
@@ -195,7 +205,7 @@ static int ft_sess_alloc_cb(struct se_portal_group *se_tpg,
195 struct ft_tport *tport = sess->tport; 205 struct ft_tport *tport = sess->tport;
196 struct hlist_head *head = &tport->hash[ft_sess_hash(sess->port_id)]; 206 struct hlist_head *head = &tport->hash[ft_sess_hash(sess->port_id)];
197 207
198 pr_debug("port_id %x sess %p\n", sess->port_id, sess); 208 TFC_SESS_DBG(tport->lport, "port_id %x sess %p\n", sess->port_id, sess);
199 hlist_add_head_rcu(&sess->hash, head); 209 hlist_add_head_rcu(&sess->hash, head);
200 tport->sess_count++; 210 tport->sess_count++;
201 211
@@ -223,7 +233,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
223 233
224 sess = kzalloc(sizeof(*sess), GFP_KERNEL); 234 sess = kzalloc(sizeof(*sess), GFP_KERNEL);
225 if (!sess) 235 if (!sess)
226 return NULL; 236 return ERR_PTR(-ENOMEM);
227 237
228 kref_init(&sess->kref); /* ref for table entry */ 238 kref_init(&sess->kref); /* ref for table entry */
229 sess->tport = tport; 239 sess->tport = tport;
@@ -234,8 +244,9 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
234 TARGET_PROT_NORMAL, &initiatorname[0], 244 TARGET_PROT_NORMAL, &initiatorname[0],
235 sess, ft_sess_alloc_cb); 245 sess, ft_sess_alloc_cb);
236 if (IS_ERR(sess->se_sess)) { 246 if (IS_ERR(sess->se_sess)) {
247 int rc = PTR_ERR(sess->se_sess);
237 kfree(sess); 248 kfree(sess);
238 return NULL; 249 sess = ERR_PTR(rc);
239 } 250 }
240 return sess; 251 return sess;
241} 252}
@@ -319,7 +330,7 @@ void ft_sess_close(struct se_session *se_sess)
319 mutex_unlock(&ft_lport_lock); 330 mutex_unlock(&ft_lport_lock);
320 return; 331 return;
321 } 332 }
322 pr_debug("port_id %x\n", port_id); 333 TFC_SESS_DBG(sess->tport->lport, "port_id %x close session\n", port_id);
323 ft_sess_unhash(sess); 334 ft_sess_unhash(sess);
324 mutex_unlock(&ft_lport_lock); 335 mutex_unlock(&ft_lport_lock);
325 ft_close_sess(sess); 336 ft_close_sess(sess);
@@ -379,8 +390,13 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
379 if (!(fcp_parm & FCP_SPPF_INIT_FCN)) 390 if (!(fcp_parm & FCP_SPPF_INIT_FCN))
380 return FC_SPP_RESP_CONF; 391 return FC_SPP_RESP_CONF;
381 sess = ft_sess_create(tport, rdata->ids.port_id, rdata); 392 sess = ft_sess_create(tport, rdata->ids.port_id, rdata);
382 if (!sess) 393 if (IS_ERR(sess)) {
383 return FC_SPP_RESP_RES; 394 if (PTR_ERR(sess) == -EACCES) {
395 spp->spp_flags &= ~FC_SPP_EST_IMG_PAIR;
396 return FC_SPP_RESP_CONF;
397 } else
398 return FC_SPP_RESP_RES;
399 }
384 if (!sess->params) 400 if (!sess->params)
385 rdata->prli_count++; 401 rdata->prli_count++;
386 sess->params = fcp_parm; 402 sess->params = fcp_parm;
@@ -423,8 +439,8 @@ static int ft_prli(struct fc_rport_priv *rdata, u32 spp_len,
423 mutex_lock(&ft_lport_lock); 439 mutex_lock(&ft_lport_lock);
424 ret = ft_prli_locked(rdata, spp_len, rspp, spp); 440 ret = ft_prli_locked(rdata, spp_len, rspp, spp);
425 mutex_unlock(&ft_lport_lock); 441 mutex_unlock(&ft_lport_lock);
426 pr_debug("port_id %x flags %x ret %x\n", 442 TFC_SESS_DBG(rdata->local_port, "port_id %x flags %x ret %x\n",
427 rdata->ids.port_id, rspp ? rspp->spp_flags : 0, ret); 443 rdata->ids.port_id, rspp ? rspp->spp_flags : 0, ret);
428 return ret; 444 return ret;
429} 445}
430 446
@@ -477,11 +493,11 @@ static void ft_recv(struct fc_lport *lport, struct fc_frame *fp)
477 struct ft_sess *sess; 493 struct ft_sess *sess;
478 u32 sid = fc_frame_sid(fp); 494 u32 sid = fc_frame_sid(fp);
479 495
480 pr_debug("sid %x\n", sid); 496 TFC_SESS_DBG(lport, "recv sid %x\n", sid);
481 497
482 sess = ft_sess_get(lport, sid); 498 sess = ft_sess_get(lport, sid);
483 if (!sess) { 499 if (!sess) {
484 pr_debug("sid %x sess lookup failed\n", sid); 500 TFC_SESS_DBG(lport, "sid %x sess lookup failed\n", sid);
485 /* TBD XXX - if FCP_CMND, send PRLO */ 501 /* TBD XXX - if FCP_CMND, send PRLO */
486 fc_frame_free(fp); 502 fc_frame_free(fp);
487 return; 503 return;
diff --git a/drivers/thermal/intel_pch_thermal.c b/drivers/thermal/intel_pch_thermal.c
index 9b4815e81b0d..19bf2028e508 100644
--- a/drivers/thermal/intel_pch_thermal.c
+++ b/drivers/thermal/intel_pch_thermal.c
@@ -20,10 +20,13 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/acpi.h>
23#include <linux/thermal.h> 24#include <linux/thermal.h>
24#include <linux/pm.h> 25#include <linux/pm.h>
25 26
26/* Intel PCH thermal Device IDs */ 27/* Intel PCH thermal Device IDs */
28#define PCH_THERMAL_DID_HSW_1 0x9C24 /* Haswell PCH */
29#define PCH_THERMAL_DID_HSW_2 0x8C24 /* Haswell PCH */
27#define PCH_THERMAL_DID_WPT 0x9CA4 /* Wildcat Point */ 30#define PCH_THERMAL_DID_WPT 0x9CA4 /* Wildcat Point */
28#define PCH_THERMAL_DID_SKL 0x9D31 /* Skylake PCH */ 31#define PCH_THERMAL_DID_SKL 0x9D31 /* Skylake PCH */
29 32
@@ -66,9 +69,53 @@ struct pch_thermal_device {
66 unsigned long crt_temp; 69 unsigned long crt_temp;
67 int hot_trip_id; 70 int hot_trip_id;
68 unsigned long hot_temp; 71 unsigned long hot_temp;
72 int psv_trip_id;
73 unsigned long psv_temp;
69 bool bios_enabled; 74 bool bios_enabled;
70}; 75};
71 76
77#ifdef CONFIG_ACPI
78
79/*
80 * On some platforms, there is a companion ACPI device, which adds
81 * passive trip temperature using _PSV method. There is no specific
82 * passive temperature setting in MMIO interface of this PCI device.
83 */
84static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
85 int *nr_trips)
86{
87 struct acpi_device *adev;
88
89 ptd->psv_trip_id = -1;
90
91 adev = ACPI_COMPANION(&ptd->pdev->dev);
92 if (adev) {
93 unsigned long long r;
94 acpi_status status;
95
96 status = acpi_evaluate_integer(adev->handle, "_PSV", NULL,
97 &r);
98 if (ACPI_SUCCESS(status)) {
99 unsigned long trip_temp;
100
101 trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r);
102 if (trip_temp) {
103 ptd->psv_temp = trip_temp;
104 ptd->psv_trip_id = *nr_trips;
105 ++(*nr_trips);
106 }
107 }
108 }
109}
110#else
111static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
112 int *nr_trips)
113{
114 ptd->psv_trip_id = -1;
115
116}
117#endif
118
72static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) 119static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
73{ 120{
74 u8 tsel; 121 u8 tsel;
@@ -119,6 +166,8 @@ read_trips:
119 ++(*nr_trips); 166 ++(*nr_trips);
120 } 167 }
121 168
169 pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
170
122 return 0; 171 return 0;
123} 172}
124 173
@@ -194,6 +243,8 @@ static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip,
194 *type = THERMAL_TRIP_CRITICAL; 243 *type = THERMAL_TRIP_CRITICAL;
195 else if (ptd->hot_trip_id == trip) 244 else if (ptd->hot_trip_id == trip)
196 *type = THERMAL_TRIP_HOT; 245 *type = THERMAL_TRIP_HOT;
246 else if (ptd->psv_trip_id == trip)
247 *type = THERMAL_TRIP_PASSIVE;
197 else 248 else
198 return -EINVAL; 249 return -EINVAL;
199 250
@@ -208,6 +259,8 @@ static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, int *tem
208 *temp = ptd->crt_temp; 259 *temp = ptd->crt_temp;
209 else if (ptd->hot_trip_id == trip) 260 else if (ptd->hot_trip_id == trip)
210 *temp = ptd->hot_temp; 261 *temp = ptd->hot_temp;
262 else if (ptd->psv_trip_id == trip)
263 *temp = ptd->psv_temp;
211 else 264 else
212 return -EINVAL; 265 return -EINVAL;
213 266
@@ -242,6 +295,11 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
242 ptd->ops = &pch_dev_ops_wpt; 295 ptd->ops = &pch_dev_ops_wpt;
243 dev_name = "pch_skylake"; 296 dev_name = "pch_skylake";
244 break; 297 break;
298 case PCH_THERMAL_DID_HSW_1:
299 case PCH_THERMAL_DID_HSW_2:
300 ptd->ops = &pch_dev_ops_wpt;
301 dev_name = "pch_haswell";
302 break;
245 default: 303 default:
246 dev_err(&pdev->dev, "unknown pch thermal device\n"); 304 dev_err(&pdev->dev, "unknown pch thermal device\n");
247 return -ENODEV; 305 return -ENODEV;
@@ -324,6 +382,8 @@ static int intel_pch_thermal_resume(struct device *device)
324static struct pci_device_id intel_pch_thermal_id[] = { 382static struct pci_device_id intel_pch_thermal_id[] = {
325 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WPT) }, 383 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WPT) },
326 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_SKL) }, 384 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_SKL) },
385 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_HSW_1) },
386 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_HSW_2) },
327 { 0, }, 387 { 0, },
328}; 388};
329MODULE_DEVICE_TABLE(pci, intel_pch_thermal_id); 389MODULE_DEVICE_TABLE(pci, intel_pch_thermal_id);
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index 0e4dc0afcfd2..7a223074df3d 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -669,20 +669,10 @@ static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
669 .set_cur_state = powerclamp_set_cur_state, 669 .set_cur_state = powerclamp_set_cur_state,
670}; 670};
671 671
672static const struct x86_cpu_id intel_powerclamp_ids[] __initconst = {
673 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_MWAIT },
674 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_ARAT },
675 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_NONSTOP_TSC },
676 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_CONSTANT_TSC},
677 {}
678};
679MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
680
681static int __init powerclamp_probe(void) 672static int __init powerclamp_probe(void)
682{ 673{
683 if (!x86_match_cpu(intel_powerclamp_ids)) { 674 if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
684 pr_err("Intel powerclamp does not run on family %d model %d\n", 675 pr_err("CPU does not support MWAIT");
685 boot_cpu_data.x86, boot_cpu_data.x86_model);
686 return -ENODEV; 676 return -ENODEV;
687 } 677 }
688 678
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 886fcf37f291..b9923464599f 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -213,7 +213,7 @@ static int qrk_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
213 struct pci_dev *pdev = to_pci_dev(port->dev); 213 struct pci_dev *pdev = to_pci_dev(port->dev);
214 int ret; 214 int ret;
215 215
216 ret = pci_alloc_irq_vectors(pdev, 1, 1, 0); 216 ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
217 if (ret < 0) 217 if (ret < 0)
218 return ret; 218 return ret;
219 219
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 1bfb6fdbaa20..1731b98d2471 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -83,7 +83,8 @@ static const struct serial8250_config uart_config[] = {
83 .name = "16550A", 83 .name = "16550A",
84 .fifo_size = 16, 84 .fifo_size = 16,
85 .tx_loadsz = 16, 85 .tx_loadsz = 16,
86 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 86 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10 |
87 UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
87 .rxtrig_bytes = {1, 4, 8, 14}, 88 .rxtrig_bytes = {1, 4, 8, 14},
88 .flags = UART_CAP_FIFO, 89 .flags = UART_CAP_FIFO,
89 }, 90 },
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c
index b8d9c8c9d02a..417d9e7038e1 100644
--- a/drivers/tty/serial/8250/8250_uniphier.c
+++ b/drivers/tty/serial/8250/8250_uniphier.c
@@ -99,7 +99,7 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value)
99 case UART_LCR: 99 case UART_LCR:
100 valshift = UNIPHIER_UART_LCR_SHIFT; 100 valshift = UNIPHIER_UART_LCR_SHIFT;
101 /* Divisor latch access bit does not exist. */ 101 /* Divisor latch access bit does not exist. */
102 value &= ~(UART_LCR_DLAB << valshift); 102 value &= ~UART_LCR_DLAB;
103 /* fall through */ 103 /* fall through */
104 case UART_MCR: 104 case UART_MCR:
105 offset = UNIPHIER_UART_LCR_MCR; 105 offset = UNIPHIER_UART_LCR_MCR;
@@ -199,7 +199,7 @@ static int uniphier_uart_probe(struct platform_device *pdev)
199 199
200 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 200 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
201 if (!regs) { 201 if (!regs) {
202 dev_err(dev, "failed to get memory resource"); 202 dev_err(dev, "failed to get memory resource\n");
203 return -EINVAL; 203 return -EINVAL;
204 } 204 }
205 205
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index c7831407a882..25c1d7bc0100 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1625,6 +1625,7 @@ config SERIAL_SPRD_CONSOLE
1625config SERIAL_STM32 1625config SERIAL_STM32
1626 tristate "STMicroelectronics STM32 serial port support" 1626 tristate "STMicroelectronics STM32 serial port support"
1627 select SERIAL_CORE 1627 select SERIAL_CORE
1628 depends on HAS_DMA
1628 depends on ARM || COMPILE_TEST 1629 depends on ARM || COMPILE_TEST
1629 help 1630 help
1630 This driver is for the on-chip Serial Controller on 1631 This driver is for the on-chip Serial Controller on
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index fd8aa1f4ba78..168b10cad47b 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2132,11 +2132,29 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2132 mode |= ATMEL_US_USMODE_RS485; 2132 mode |= ATMEL_US_USMODE_RS485;
2133 } else if (termios->c_cflag & CRTSCTS) { 2133 } else if (termios->c_cflag & CRTSCTS) {
2134 /* RS232 with hardware handshake (RTS/CTS) */ 2134 /* RS232 with hardware handshake (RTS/CTS) */
2135 if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) { 2135 if (atmel_use_fifo(port) &&
2136 dev_info(port->dev, "not enabling hardware flow control because DMA is used"); 2136 !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
2137 termios->c_cflag &= ~CRTSCTS; 2137 /*
2138 } else { 2138 * with ATMEL_US_USMODE_HWHS set, the controller will
2139 * be able to drive the RTS pin high/low when the RX
2140 * FIFO is above RXFTHRES/below RXFTHRES2.
2141 * It will also disable the transmitter when the CTS
2142 * pin is high.
2143 * This mode is not activated if CTS pin is a GPIO
2144 * because in this case, the transmitter is always
2145 * disabled (there must be an internal pull-up
2146 * responsible for this behaviour).
2147 * If the RTS pin is a GPIO, the controller won't be
2148 * able to drive it according to the FIFO thresholds,
2149 * but it will be handled by the driver.
2150 */
2139 mode |= ATMEL_US_USMODE_HWHS; 2151 mode |= ATMEL_US_USMODE_HWHS;
2152 } else {
2153 /*
2154 * For platforms without FIFO, the flow control is
2155 * handled by the driver.
2156 */
2157 mode |= ATMEL_US_USMODE_NORMAL;
2140 } 2158 }
2141 } else { 2159 } else {
2142 /* RS232 without hadware handshake */ 2160 /* RS232 without hadware handshake */
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index de9d5107c00a..76103f2c4a80 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -328,7 +328,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
328 328
329 sport->dma_tx_bytes = uart_circ_chars_pending(xmit); 329 sport->dma_tx_bytes = uart_circ_chars_pending(xmit);
330 330
331 if (xmit->tail < xmit->head) { 331 if (xmit->tail < xmit->head || xmit->head == 0) {
332 sport->dma_tx_nents = 1; 332 sport->dma_tx_nents = 1;
333 sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes); 333 sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes);
334 } else { 334 } else {
@@ -359,7 +359,6 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
359 sport->dma_tx_in_progress = true; 359 sport->dma_tx_in_progress = true;
360 sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc); 360 sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc);
361 dma_async_issue_pending(sport->dma_tx_chan); 361 dma_async_issue_pending(sport->dma_tx_chan);
362
363} 362}
364 363
365static void lpuart_dma_tx_complete(void *arg) 364static void lpuart_dma_tx_complete(void *arg)
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index d391650b82e7..42caccb5e87e 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -419,6 +419,7 @@ static struct dmi_system_id pch_uart_dmi_table[] = {
419 }, 419 },
420 (void *)MINNOW_UARTCLK, 420 (void *)MINNOW_UARTCLK,
421 }, 421 },
422 { }
422}; 423};
423 424
424/* Return UART clock, checking for board specific clocks. */ 425/* Return UART clock, checking for board specific clocks. */
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 2675792a8f59..fb0672554123 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1130,9 +1130,13 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip,
1130{ 1130{
1131 struct sc16is7xx_port *s = gpiochip_get_data(chip); 1131 struct sc16is7xx_port *s = gpiochip_get_data(chip);
1132 struct uart_port *port = &s->p[0].port; 1132 struct uart_port *port = &s->p[0].port;
1133 u8 state = sc16is7xx_port_read(port, SC16IS7XX_IOSTATE_REG);
1133 1134
1134 sc16is7xx_port_update(port, SC16IS7XX_IOSTATE_REG, BIT(offset), 1135 if (val)
1135 val ? BIT(offset) : 0); 1136 state |= BIT(offset);
1137 else
1138 state &= ~BIT(offset);
1139 sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state);
1136 sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset), 1140 sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset),
1137 BIT(offset)); 1141 BIT(offset));
1138 1142
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 6e4f63627479..f2303f390345 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -111,7 +111,7 @@ void uart_write_wakeup(struct uart_port *port)
111 * closed. No cookie for you. 111 * closed. No cookie for you.
112 */ 112 */
113 BUG_ON(!state); 113 BUG_ON(!state);
114 tty_wakeup(state->port.tty); 114 tty_port_tty_wakeup(&state->port);
115} 115}
116 116
117static void uart_stop(struct tty_struct *tty) 117static void uart_stop(struct tty_struct *tty)
@@ -632,7 +632,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
632 if (port->ops->flush_buffer) 632 if (port->ops->flush_buffer)
633 port->ops->flush_buffer(port); 633 port->ops->flush_buffer(port);
634 uart_port_unlock(port, flags); 634 uart_port_unlock(port, flags);
635 tty_wakeup(tty); 635 tty_port_tty_wakeup(&state->port);
636} 636}
637 637
638/* 638/*
@@ -2746,8 +2746,6 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2746 uport->cons = drv->cons; 2746 uport->cons = drv->cons;
2747 uport->minor = drv->tty_driver->minor_start + uport->line; 2747 uport->minor = drv->tty_driver->minor_start + uport->line;
2748 2748
2749 port->console = uart_console(uport);
2750
2751 /* 2749 /*
2752 * If this port is a console, then the spinlock is already 2750 * If this port is a console, then the spinlock is already
2753 * initialised. 2751 * initialised.
@@ -2761,6 +2759,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2761 2759
2762 uart_configure_port(drv, state, uport); 2760 uart_configure_port(drv, state, uport);
2763 2761
2762 port->console = uart_console(uport);
2763
2764 num_groups = 2; 2764 num_groups = 2;
2765 if (uport->attr_group) 2765 if (uport->attr_group)
2766 num_groups++; 2766 num_groups++;
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index 41d974923102..cd97ceb76e4f 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -31,7 +31,7 @@ struct stm32_usart_info {
31 struct stm32_usart_config cfg; 31 struct stm32_usart_config cfg;
32}; 32};
33 33
34#define UNDEF_REG ~0 34#define UNDEF_REG 0xff
35 35
36/* Register offsets */ 36/* Register offsets */
37struct stm32_usart_info stm32f4_info = { 37struct stm32_usart_info stm32f4_info = {
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index f37edaa5ac75..dd4c02fa4820 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1200,6 +1200,7 @@ static int __init cdns_early_console_setup(struct earlycon_device *device,
1200OF_EARLYCON_DECLARE(cdns, "xlnx,xuartps", cdns_early_console_setup); 1200OF_EARLYCON_DECLARE(cdns, "xlnx,xuartps", cdns_early_console_setup);
1201OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p8", cdns_early_console_setup); 1201OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p8", cdns_early_console_setup);
1202OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup); 1202OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup);
1203OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup);
1203 1204
1204/** 1205/**
1205 * cdns_uart_console_write - perform write operation 1206 * cdns_uart_console_write - perform write operation
@@ -1438,6 +1439,7 @@ static const struct of_device_id cdns_uart_of_match[] = {
1438 { .compatible = "xlnx,xuartps", }, 1439 { .compatible = "xlnx,xuartps", },
1439 { .compatible = "cdns,uart-r1p8", }, 1440 { .compatible = "cdns,uart-r1p8", },
1440 { .compatible = "cdns,uart-r1p12", .data = &zynqmp_uart_def }, 1441 { .compatible = "cdns,uart-r1p12", .data = &zynqmp_uart_def },
1442 { .compatible = "xlnx,zynqmp-uart", .data = &zynqmp_uart_def },
1441 {} 1443 {}
1442}; 1444};
1443MODULE_DEVICE_TABLE(of, cdns_uart_of_match); 1445MODULE_DEVICE_TABLE(of, cdns_uart_of_match);
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 06fb39c1d6dd..8c3bf3d613c0 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -870,10 +870,15 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
870 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) 870 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
871 return 0; 871 return 0;
872 872
873 if (new_screen_size > (4 << 20))
874 return -EINVAL;
873 newscreen = kmalloc(new_screen_size, GFP_USER); 875 newscreen = kmalloc(new_screen_size, GFP_USER);
874 if (!newscreen) 876 if (!newscreen)
875 return -ENOMEM; 877 return -ENOMEM;
876 878
879 if (vc == sel_cons)
880 clear_selection();
881
877 old_rows = vc->vc_rows; 882 old_rows = vc->vc_rows;
878 old_row_size = vc->vc_size_row; 883 old_row_size = vc->vc_size_row;
879 884
@@ -1176,7 +1181,7 @@ static void csi_J(struct vc_data *vc, int vpar)
1176 break; 1181 break;
1177 case 3: /* erase scroll-back buffer (and whole display) */ 1182 case 3: /* erase scroll-back buffer (and whole display) */
1178 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, 1183 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
1179 vc->vc_screenbuf_size >> 1); 1184 vc->vc_screenbuf_size);
1180 set_origin(vc); 1185 set_origin(vc);
1181 if (con_is_visible(vc)) 1186 if (con_is_visible(vc))
1182 update_screen(vc); 1187 update_screen(vc);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 96ae69502c86..111b0e0b8698 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -188,6 +188,8 @@ static void host_stop(struct ci_hdrc *ci)
188 188
189 if (hcd) { 189 if (hcd) {
190 usb_remove_hcd(hcd); 190 usb_remove_hcd(hcd);
191 ci->role = CI_ROLE_END;
192 synchronize_irq(ci->irq);
191 usb_put_hcd(hcd); 193 usb_put_hcd(hcd);
192 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && 194 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&
193 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) 195 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON))
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index fa9b26b91507..4c0fa0b17353 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -463,9 +463,18 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
463 */ 463 */
464void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg) 464void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
465{ 465{
466 bool ret;
467
466 switch (hsotg->dr_mode) { 468 switch (hsotg->dr_mode) {
467 case USB_DR_MODE_HOST: 469 case USB_DR_MODE_HOST:
468 dwc2_force_mode(hsotg, true); 470 ret = dwc2_force_mode(hsotg, true);
471 /*
472 * NOTE: This is required for some rockchip soc based
473 * platforms on their host-only dwc2.
474 */
475 if (!ret)
476 msleep(50);
477
469 break; 478 break;
470 case USB_DR_MODE_PERIPHERAL: 479 case USB_DR_MODE_PERIPHERAL:
471 dwc2_force_mode(hsotg, false); 480 dwc2_force_mode(hsotg, false);
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index aad4107ef927..2a21a0414b1d 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -259,6 +259,13 @@ enum dwc2_lx_state {
259 DWC2_L3, /* Off state */ 259 DWC2_L3, /* Off state */
260}; 260};
261 261
262/*
263 * Gadget periodic tx fifo sizes as used by legacy driver
264 * EP0 is not included
265 */
266#define DWC2_G_P_LEGACY_TX_FIFO_SIZE {256, 256, 256, 256, 768, 768, 768, \
267 768, 0, 0, 0, 0, 0, 0, 0}
268
262/* Gadget ep0 states */ 269/* Gadget ep0 states */
263enum dwc2_ep0_state { 270enum dwc2_ep0_state {
264 DWC2_EP0_SETUP, 271 DWC2_EP0_SETUP,
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 4cd6403a7566..24fbebc9b409 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -186,10 +186,9 @@ static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg *hsotg,
186 */ 186 */
187static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) 187static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
188{ 188{
189 unsigned int fifo; 189 unsigned int ep;
190 unsigned int addr; 190 unsigned int addr;
191 int timeout; 191 int timeout;
192 u32 dptxfsizn;
193 u32 val; 192 u32 val;
194 193
195 /* Reset fifo map if not correctly cleared during previous session */ 194 /* Reset fifo map if not correctly cleared during previous session */
@@ -217,16 +216,16 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
217 * them to endpoints dynamically according to maxpacket size value of 216 * them to endpoints dynamically according to maxpacket size value of
218 * given endpoint. 217 * given endpoint.
219 */ 218 */
220 for (fifo = 1; fifo < MAX_EPS_CHANNELS; fifo++) { 219 for (ep = 1; ep < MAX_EPS_CHANNELS; ep++) {
221 dptxfsizn = dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)); 220 if (!hsotg->g_tx_fifo_sz[ep])
222 221 continue;
223 val = (dptxfsizn & FIFOSIZE_DEPTH_MASK) | addr; 222 val = addr;
224 addr += dptxfsizn >> FIFOSIZE_DEPTH_SHIFT; 223 val |= hsotg->g_tx_fifo_sz[ep] << FIFOSIZE_DEPTH_SHIFT;
225 224 WARN_ONCE(addr + hsotg->g_tx_fifo_sz[ep] > hsotg->fifo_mem,
226 if (addr > hsotg->fifo_mem) 225 "insufficient fifo memory");
227 break; 226 addr += hsotg->g_tx_fifo_sz[ep];
228 227
229 dwc2_writel(val, hsotg->regs + DPTXFSIZN(fifo)); 228 dwc2_writel(val, hsotg->regs + DPTXFSIZN(ep));
230 } 229 }
231 230
232 /* 231 /*
@@ -3807,10 +3806,36 @@ static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg)
3807static void dwc2_hsotg_of_probe(struct dwc2_hsotg *hsotg) 3806static void dwc2_hsotg_of_probe(struct dwc2_hsotg *hsotg)
3808{ 3807{
3809 struct device_node *np = hsotg->dev->of_node; 3808 struct device_node *np = hsotg->dev->of_node;
3809 u32 len = 0;
3810 u32 i = 0;
3810 3811
3811 /* Enable dma if requested in device tree */ 3812 /* Enable dma if requested in device tree */
3812 hsotg->g_using_dma = of_property_read_bool(np, "g-use-dma"); 3813 hsotg->g_using_dma = of_property_read_bool(np, "g-use-dma");
3813 3814
3815 /*
3816 * Register TX periodic fifo size per endpoint.
3817 * EP0 is excluded since it has no fifo configuration.
3818 */
3819 if (!of_find_property(np, "g-tx-fifo-size", &len))
3820 goto rx_fifo;
3821
3822 len /= sizeof(u32);
3823
3824 /* Read tx fifo sizes other than ep0 */
3825 if (of_property_read_u32_array(np, "g-tx-fifo-size",
3826 &hsotg->g_tx_fifo_sz[1], len))
3827 goto rx_fifo;
3828
3829 /* Add ep0 */
3830 len++;
3831
3832 /* Make remaining TX fifos unavailable */
3833 if (len < MAX_EPS_CHANNELS) {
3834 for (i = len; i < MAX_EPS_CHANNELS; i++)
3835 hsotg->g_tx_fifo_sz[i] = 0;
3836 }
3837
3838rx_fifo:
3814 /* Register RX fifo size */ 3839 /* Register RX fifo size */
3815 of_property_read_u32(np, "g-rx-fifo-size", &hsotg->g_rx_fifo_sz); 3840 of_property_read_u32(np, "g-rx-fifo-size", &hsotg->g_rx_fifo_sz);
3816 3841
@@ -3832,10 +3857,13 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3832 struct device *dev = hsotg->dev; 3857 struct device *dev = hsotg->dev;
3833 int epnum; 3858 int epnum;
3834 int ret; 3859 int ret;
3860 int i;
3861 u32 p_tx_fifo[] = DWC2_G_P_LEGACY_TX_FIFO_SIZE;
3835 3862
3836 /* Initialize to legacy fifo configuration values */ 3863 /* Initialize to legacy fifo configuration values */
3837 hsotg->g_rx_fifo_sz = 2048; 3864 hsotg->g_rx_fifo_sz = 2048;
3838 hsotg->g_np_g_tx_fifo_sz = 1024; 3865 hsotg->g_np_g_tx_fifo_sz = 1024;
3866 memcpy(&hsotg->g_tx_fifo_sz[1], p_tx_fifo, sizeof(p_tx_fifo));
3839 /* Device tree specific probe */ 3867 /* Device tree specific probe */
3840 dwc2_hsotg_of_probe(hsotg); 3868 dwc2_hsotg_of_probe(hsotg);
3841 3869
@@ -3853,6 +3881,9 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3853 dev_dbg(dev, "NonPeriodic TXFIFO size: %d\n", 3881 dev_dbg(dev, "NonPeriodic TXFIFO size: %d\n",
3854 hsotg->g_np_g_tx_fifo_sz); 3882 hsotg->g_np_g_tx_fifo_sz);
3855 dev_dbg(dev, "RXFIFO size: %d\n", hsotg->g_rx_fifo_sz); 3883 dev_dbg(dev, "RXFIFO size: %d\n", hsotg->g_rx_fifo_sz);
3884 for (i = 0; i < MAX_EPS_CHANNELS; i++)
3885 dev_dbg(dev, "Periodic TXFIFO%2d size: %d\n", i,
3886 hsotg->g_tx_fifo_sz[i]);
3856 3887
3857 hsotg->gadget.max_speed = USB_SPEED_HIGH; 3888 hsotg->gadget.max_speed = USB_SPEED_HIGH;
3858 hsotg->gadget.ops = &dwc2_hsotg_gadget_ops; 3889 hsotg->gadget.ops = &dwc2_hsotg_gadget_ops;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 07cc8929f271..1dfa56a5f1c5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -783,6 +783,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
783 req->trb = trb; 783 req->trb = trb;
784 req->trb_dma = dwc3_trb_dma_offset(dep, trb); 784 req->trb_dma = dwc3_trb_dma_offset(dep, trb);
785 req->first_trb_index = dep->trb_enqueue; 785 req->first_trb_index = dep->trb_enqueue;
786 dep->queued_requests++;
786 } 787 }
787 788
788 dwc3_ep_inc_enq(dep); 789 dwc3_ep_inc_enq(dep);
@@ -833,8 +834,6 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
833 834
834 trb->ctrl |= DWC3_TRB_CTRL_HWO; 835 trb->ctrl |= DWC3_TRB_CTRL_HWO;
835 836
836 dep->queued_requests++;
837
838 trace_dwc3_prepare_trb(dep, trb); 837 trace_dwc3_prepare_trb(dep, trb);
839} 838}
840 839
@@ -1074,9 +1073,17 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
1074 1073
1075 list_add_tail(&req->list, &dep->pending_list); 1074 list_add_tail(&req->list, &dep->pending_list);
1076 1075
1077 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && 1076 /*
1078 dep->flags & DWC3_EP_PENDING_REQUEST) { 1077 * NOTICE: Isochronous endpoints should NEVER be prestarted. We must
1079 if (list_empty(&dep->started_list)) { 1078 * wait for a XferNotReady event so we will know what's the current
1079 * (micro-)frame number.
1080 *
1081 * Without this trick, we are very, very likely gonna get Bus Expiry
1082 * errors which will force us issue EndTransfer command.
1083 */
1084 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1085 if ((dep->flags & DWC3_EP_PENDING_REQUEST) &&
1086 list_empty(&dep->started_list)) {
1080 dwc3_stop_active_transfer(dwc, dep->number, true); 1087 dwc3_stop_active_transfer(dwc, dep->number, true);
1081 dep->flags = DWC3_EP_ENABLED; 1088 dep->flags = DWC3_EP_ENABLED;
1082 } 1089 }
@@ -1861,8 +1868,11 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
1861 unsigned int s_pkt = 0; 1868 unsigned int s_pkt = 0;
1862 unsigned int trb_status; 1869 unsigned int trb_status;
1863 1870
1864 dep->queued_requests--;
1865 dwc3_ep_inc_deq(dep); 1871 dwc3_ep_inc_deq(dep);
1872
1873 if (req->trb == trb)
1874 dep->queued_requests--;
1875
1866 trace_dwc3_complete_trb(dep, trb); 1876 trace_dwc3_complete_trb(dep, trb);
1867 1877
1868 /* 1878 /*
@@ -2980,7 +2990,7 @@ err3:
2980 kfree(dwc->setup_buf); 2990 kfree(dwc->setup_buf);
2981 2991
2982err2: 2992err2:
2983 dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), 2993 dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2,
2984 dwc->ep0_trb, dwc->ep0_trb_addr); 2994 dwc->ep0_trb, dwc->ep0_trb_addr);
2985 2995
2986err1: 2996err1:
@@ -3005,7 +3015,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
3005 kfree(dwc->setup_buf); 3015 kfree(dwc->setup_buf);
3006 kfree(dwc->zlp_buf); 3016 kfree(dwc->zlp_buf);
3007 3017
3008 dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), 3018 dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2,
3009 dwc->ep0_trb, dwc->ep0_trb_addr); 3019 dwc->ep0_trb, dwc->ep0_trb_addr);
3010 3020
3011 dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req), 3021 dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 54ad100af35b..e40d47d47d82 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -136,8 +136,60 @@ struct ffs_epfile {
136 /* 136 /*
137 * Buffer for holding data from partial reads which may happen since 137 * Buffer for holding data from partial reads which may happen since
138 * we’re rounding user read requests to a multiple of a max packet size. 138 * we’re rounding user read requests to a multiple of a max packet size.
139 *
140 * The pointer is initialised with NULL value and may be set by
141 * __ffs_epfile_read_data function to point to a temporary buffer.
142 *
143 * In normal operation, calls to __ffs_epfile_read_buffered will consume
144 * data from said buffer and eventually free it. Importantly, while the
145 * function is using the buffer, it sets the pointer to NULL. This is
146 * all right since __ffs_epfile_read_data and __ffs_epfile_read_buffered
147 * can never run concurrently (they are synchronised by epfile->mutex)
148 * so the latter will not assign a new value to the pointer.
149 *
150 * Meanwhile ffs_func_eps_disable frees the buffer (if the pointer is
151 * valid) and sets the pointer to READ_BUFFER_DROP value. This special
152 * value is crux of the synchronisation between ffs_func_eps_disable and
153 * __ffs_epfile_read_data.
154 *
155 * Once __ffs_epfile_read_data is about to finish it will try to set the
156 * pointer back to its old value (as described above), but seeing as the
157 * pointer is not-NULL (namely READ_BUFFER_DROP) it will instead free
158 * the buffer.
159 *
160 * == State transitions ==
161 *
162 * • ptr == NULL: (initial state)
163 * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP
164 * â—¦ __ffs_epfile_read_buffered: nop
165 * â—¦ __ffs_epfile_read_data allocates temp buffer: go to ptr == buf
166 * ◦ reading finishes: n/a, not in ‘and reading’ state
167 * • ptr == DROP:
168 * â—¦ __ffs_epfile_read_buffer_free: nop
169 * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL
170 * â—¦ __ffs_epfile_read_data allocates temp buffer: free buf, nop
171 * ◦ reading finishes: n/a, not in ‘and reading’ state
172 * • ptr == buf:
173 * â—¦ __ffs_epfile_read_buffer_free: free buf, go to ptr == DROP
174 * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL and reading
175 * â—¦ __ffs_epfile_read_data: n/a, __ffs_epfile_read_buffered
176 * is always called first
177 * ◦ reading finishes: n/a, not in ‘and reading’ state
178 * • ptr == NULL and reading:
179 * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP and reading
180 * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held
181 * â—¦ __ffs_epfile_read_data: n/a, mutex is held
182 * ◦ reading finishes and …
183 * … all data read: free buf, go to ptr == NULL
184 * … otherwise: go to ptr == buf and reading
185 * • ptr == DROP and reading:
186 * â—¦ __ffs_epfile_read_buffer_free: nop
187 * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held
188 * â—¦ __ffs_epfile_read_data: n/a, mutex is held
189 * â—¦ reading finishes: free buf, go to ptr == DROP
139 */ 190 */
140 struct ffs_buffer *read_buffer; /* P: epfile->mutex */ 191 struct ffs_buffer *read_buffer;
192#define READ_BUFFER_DROP ((struct ffs_buffer *)ERR_PTR(-ESHUTDOWN))
141 193
142 char name[5]; 194 char name[5];
143 195
@@ -736,25 +788,47 @@ static void ffs_epfile_async_io_complete(struct usb_ep *_ep,
736 schedule_work(&io_data->work); 788 schedule_work(&io_data->work);
737} 789}
738 790
791static void __ffs_epfile_read_buffer_free(struct ffs_epfile *epfile)
792{
793 /*
794 * See comment in struct ffs_epfile for full read_buffer pointer
795 * synchronisation story.
796 */
797 struct ffs_buffer *buf = xchg(&epfile->read_buffer, READ_BUFFER_DROP);
798 if (buf && buf != READ_BUFFER_DROP)
799 kfree(buf);
800}
801
739/* Assumes epfile->mutex is held. */ 802/* Assumes epfile->mutex is held. */
740static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile, 803static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile,
741 struct iov_iter *iter) 804 struct iov_iter *iter)
742{ 805{
743 struct ffs_buffer *buf = epfile->read_buffer; 806 /*
807 * Null out epfile->read_buffer so ffs_func_eps_disable does not free
808 * the buffer while we are using it. See comment in struct ffs_epfile
809 * for full read_buffer pointer synchronisation story.
810 */
811 struct ffs_buffer *buf = xchg(&epfile->read_buffer, NULL);
744 ssize_t ret; 812 ssize_t ret;
745 if (!buf) 813 if (!buf || buf == READ_BUFFER_DROP)
746 return 0; 814 return 0;
747 815
748 ret = copy_to_iter(buf->data, buf->length, iter); 816 ret = copy_to_iter(buf->data, buf->length, iter);
749 if (buf->length == ret) { 817 if (buf->length == ret) {
750 kfree(buf); 818 kfree(buf);
751 epfile->read_buffer = NULL; 819 return ret;
752 } else if (unlikely(iov_iter_count(iter))) { 820 }
821
822 if (unlikely(iov_iter_count(iter))) {
753 ret = -EFAULT; 823 ret = -EFAULT;
754 } else { 824 } else {
755 buf->length -= ret; 825 buf->length -= ret;
756 buf->data += ret; 826 buf->data += ret;
757 } 827 }
828
829 if (cmpxchg(&epfile->read_buffer, NULL, buf))
830 kfree(buf);
831
758 return ret; 832 return ret;
759} 833}
760 834
@@ -783,7 +857,15 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
783 buf->length = data_len; 857 buf->length = data_len;
784 buf->data = buf->storage; 858 buf->data = buf->storage;
785 memcpy(buf->storage, data + ret, data_len); 859 memcpy(buf->storage, data + ret, data_len);
786 epfile->read_buffer = buf; 860
861 /*
862 * At this point read_buffer is NULL or READ_BUFFER_DROP (if
863 * ffs_func_eps_disable has been called in the meanwhile). See comment
864 * in struct ffs_epfile for full read_buffer pointer synchronisation
865 * story.
866 */
867 if (unlikely(cmpxchg(&epfile->read_buffer, NULL, buf)))
868 kfree(buf);
787 869
788 return ret; 870 return ret;
789} 871}
@@ -1097,8 +1179,7 @@ ffs_epfile_release(struct inode *inode, struct file *file)
1097 1179
1098 ENTER(); 1180 ENTER();
1099 1181
1100 kfree(epfile->read_buffer); 1182 __ffs_epfile_read_buffer_free(epfile);
1101 epfile->read_buffer = NULL;
1102 ffs_data_closed(epfile->ffs); 1183 ffs_data_closed(epfile->ffs);
1103 1184
1104 return 0; 1185 return 0;
@@ -1724,24 +1805,20 @@ static void ffs_func_eps_disable(struct ffs_function *func)
1724 unsigned count = func->ffs->eps_count; 1805 unsigned count = func->ffs->eps_count;
1725 unsigned long flags; 1806 unsigned long flags;
1726 1807
1808 spin_lock_irqsave(&func->ffs->eps_lock, flags);
1727 do { 1809 do {
1728 if (epfile)
1729 mutex_lock(&epfile->mutex);
1730 spin_lock_irqsave(&func->ffs->eps_lock, flags);
1731 /* pending requests get nuked */ 1810 /* pending requests get nuked */
1732 if (likely(ep->ep)) 1811 if (likely(ep->ep))
1733 usb_ep_disable(ep->ep); 1812 usb_ep_disable(ep->ep);
1734 ++ep; 1813 ++ep;
1735 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
1736 1814
1737 if (epfile) { 1815 if (epfile) {
1738 epfile->ep = NULL; 1816 epfile->ep = NULL;
1739 kfree(epfile->read_buffer); 1817 __ffs_epfile_read_buffer_free(epfile);
1740 epfile->read_buffer = NULL;
1741 mutex_unlock(&epfile->mutex);
1742 ++epfile; 1818 ++epfile;
1743 } 1819 }
1744 } while (--count); 1820 } while (--count);
1821 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
1745} 1822}
1746 1823
1747static int ffs_func_eps_enable(struct ffs_function *func) 1824static int ffs_func_eps_enable(struct ffs_function *func)
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 9c8c9ed1dc9e..fe1811650dbc 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -590,8 +590,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
590 590
591 /* throttle high/super speed IRQ rate back slightly */ 591 /* throttle high/super speed IRQ rate back slightly */
592 if (gadget_is_dualspeed(dev->gadget)) 592 if (gadget_is_dualspeed(dev->gadget))
593 req->no_interrupt = (dev->gadget->speed == USB_SPEED_HIGH || 593 req->no_interrupt = (((dev->gadget->speed == USB_SPEED_HIGH ||
594 dev->gadget->speed == USB_SPEED_SUPER) 594 dev->gadget->speed == USB_SPEED_SUPER)) &&
595 !list_empty(&dev->tx_reqs))
595 ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0) 596 ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0)
596 : 0; 597 : 0;
597 598
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index bb1f6c8f0f01..45bc997d0711 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1978,7 +1978,7 @@ 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 = name; 1981 ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index);
1982 1982
1983 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); 1983 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
1984 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); 1984 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 876dca4fc216..a268d9e8d6cf 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -39,7 +39,7 @@
39 39
40#define DRIVER_DESC "EHCI generic platform driver" 40#define DRIVER_DESC "EHCI generic platform driver"
41#define EHCI_MAX_CLKS 4 41#define EHCI_MAX_CLKS 4
42#define EHCI_MAX_RSTS 3 42#define EHCI_MAX_RSTS 4
43#define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) 43#define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
44 44
45struct ehci_platform_priv { 45struct ehci_platform_priv {
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 5b5880c0ae19..b38a228134df 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -221,6 +221,12 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
221 ohci->num_ports = board->ports; 221 ohci->num_ports = board->ports;
222 at91_start_hc(pdev); 222 at91_start_hc(pdev);
223 223
224 /*
225 * The RemoteWakeupConnected bit has to be set explicitly
226 * before calling ohci_run. The reset value of this bit is 0.
227 */
228 ohci->hc_control = OHCI_CTRL_RWC;
229
224 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 230 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
225 if (retval == 0) { 231 if (retval == 0) {
226 device_wakeup_enable(hcd->self.controller); 232 device_wakeup_enable(hcd->self.controller);
@@ -677,9 +683,6 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
677 * REVISIT: some boards will be able to turn VBUS off... 683 * REVISIT: some boards will be able to turn VBUS off...
678 */ 684 */
679 if (!ohci_at91->wakeup) { 685 if (!ohci_at91->wakeup) {
680 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
681 ohci->hc_control &= OHCI_CTRL_RWC;
682 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
683 ohci->rh_state = OHCI_RH_HALTED; 686 ohci->rh_state = OHCI_RH_HALTED;
684 687
685 /* flush the writes */ 688 /* flush the writes */
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 1700908b84ef..86612ac3fda2 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -72,7 +72,7 @@
72static const char hcd_name [] = "ohci_hcd"; 72static const char hcd_name [] = "ohci_hcd";
73 73
74#define STATECHANGE_DELAY msecs_to_jiffies(300) 74#define STATECHANGE_DELAY msecs_to_jiffies(300)
75#define IO_WATCHDOG_DELAY msecs_to_jiffies(250) 75#define IO_WATCHDOG_DELAY msecs_to_jiffies(275)
76 76
77#include "ohci.h" 77#include "ohci.h"
78#include "pci-quirks.h" 78#include "pci-quirks.h"
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 730b9fd26685..0ef16900efed 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1166,7 +1166,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1166 xhci_set_link_state(xhci, port_array, wIndex, 1166 xhci_set_link_state(xhci, port_array, wIndex,
1167 XDEV_RESUME); 1167 XDEV_RESUME);
1168 spin_unlock_irqrestore(&xhci->lock, flags); 1168 spin_unlock_irqrestore(&xhci->lock, flags);
1169 msleep(20); 1169 msleep(USB_RESUME_TIMEOUT);
1170 spin_lock_irqsave(&xhci->lock, flags); 1170 spin_lock_irqsave(&xhci->lock, flags);
1171 xhci_set_link_state(xhci, port_array, wIndex, 1171 xhci_set_link_state(xhci, port_array, wIndex,
1172 XDEV_U0); 1172 XDEV_U0);
@@ -1355,6 +1355,35 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1355 return 0; 1355 return 0;
1356} 1356}
1357 1357
1358/*
1359 * Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3.
1360 * warm reset a USB3 device stuck in polling or compliance mode after resume.
1361 * See Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8
1362 */
1363static bool xhci_port_missing_cas_quirk(int port_index,
1364 __le32 __iomem **port_array)
1365{
1366 u32 portsc;
1367
1368 portsc = readl(port_array[port_index]);
1369
1370 /* if any of these are set we are not stuck */
1371 if (portsc & (PORT_CONNECT | PORT_CAS))
1372 return false;
1373
1374 if (((portsc & PORT_PLS_MASK) != XDEV_POLLING) &&
1375 ((portsc & PORT_PLS_MASK) != XDEV_COMP_MODE))
1376 return false;
1377
1378 /* clear wakeup/change bits, and do a warm port reset */
1379 portsc &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
1380 portsc |= PORT_WR;
1381 writel(portsc, port_array[port_index]);
1382 /* flush write */
1383 readl(port_array[port_index]);
1384 return true;
1385}
1386
1358int xhci_bus_resume(struct usb_hcd *hcd) 1387int xhci_bus_resume(struct usb_hcd *hcd)
1359{ 1388{
1360 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1389 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
@@ -1392,6 +1421,14 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1392 u32 temp; 1421 u32 temp;
1393 1422
1394 temp = readl(port_array[port_index]); 1423 temp = readl(port_array[port_index]);
1424
1425 /* warm reset CAS limited ports stuck in polling/compliance */
1426 if ((xhci->quirks & XHCI_MISSING_CAS) &&
1427 (hcd->speed >= HCD_USB3) &&
1428 xhci_port_missing_cas_quirk(port_index, port_array)) {
1429 xhci_dbg(xhci, "reset stuck port %d\n", port_index);
1430 continue;
1431 }
1395 if (DEV_SUPERSPEED_ANY(temp)) 1432 if (DEV_SUPERSPEED_ANY(temp))
1396 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); 1433 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
1397 else 1434 else
@@ -1410,7 +1447,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1410 1447
1411 if (need_usb2_u3_exit) { 1448 if (need_usb2_u3_exit) {
1412 spin_unlock_irqrestore(&xhci->lock, flags); 1449 spin_unlock_irqrestore(&xhci->lock, flags);
1413 msleep(20); 1450 msleep(USB_RESUME_TIMEOUT);
1414 spin_lock_irqsave(&xhci->lock, flags); 1451 spin_lock_irqsave(&xhci->lock, flags);
1415 } 1452 }
1416 1453
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index d7b0f97abbad..e96ae80d107e 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -45,11 +45,13 @@
45 45
46#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 46#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
47#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 47#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
48#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
48#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5 49#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
49#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f 50#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
50#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f 51#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
51#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
52#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
54#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
53 55
54static const char hcd_name[] = "xhci_hcd"; 56static const char hcd_name[] = "xhci_hcd";
55 57
@@ -153,7 +155,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
153 xhci->quirks |= XHCI_SPURIOUS_REBOOT; 155 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
154 } 156 }
155 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 157 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
156 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { 158 (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ||
159 pdev->device == PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI)) {
157 xhci->quirks |= XHCI_SPURIOUS_REBOOT; 160 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
158 xhci->quirks |= XHCI_SPURIOUS_WAKEUP; 161 xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
159 } 162 }
@@ -169,6 +172,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
169 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) { 172 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
170 xhci->quirks |= XHCI_SSIC_PORT_UNUSED; 173 xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
171 } 174 }
175 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
176 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
177 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
178 xhci->quirks |= XHCI_MISSING_CAS;
179
172 if (pdev->vendor == PCI_VENDOR_ID_ETRON && 180 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
173 pdev->device == PCI_DEVICE_ID_EJ168) { 181 pdev->device == PCI_DEVICE_ID_EJ168) {
174 xhci->quirks |= XHCI_RESET_ON_RESUME; 182 xhci->quirks |= XHCI_RESET_ON_RESUME;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b2c1dc5dc0f3..f945380035d0 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -314,6 +314,8 @@ struct xhci_op_regs {
314#define XDEV_U2 (0x2 << 5) 314#define XDEV_U2 (0x2 << 5)
315#define XDEV_U3 (0x3 << 5) 315#define XDEV_U3 (0x3 << 5)
316#define XDEV_INACTIVE (0x6 << 5) 316#define XDEV_INACTIVE (0x6 << 5)
317#define XDEV_POLLING (0x7 << 5)
318#define XDEV_COMP_MODE (0xa << 5)
317#define XDEV_RESUME (0xf << 5) 319#define XDEV_RESUME (0xf << 5)
318/* true: port has power (see HCC_PPC) */ 320/* true: port has power (see HCC_PPC) */
319#define PORT_POWER (1 << 9) 321#define PORT_POWER (1 << 9)
@@ -1653,6 +1655,7 @@ struct xhci_hcd {
1653#define XHCI_MTK_HOST (1 << 21) 1655#define XHCI_MTK_HOST (1 << 21)
1654#define XHCI_SSIC_PORT_UNUSED (1 << 22) 1656#define XHCI_SSIC_PORT_UNUSED (1 << 22)
1655#define XHCI_NO_64BIT_SUPPORT (1 << 23) 1657#define XHCI_NO_64BIT_SUPPORT (1 << 23)
1658#define XHCI_MISSING_CAS (1 << 24)
1656 unsigned int num_active_eps; 1659 unsigned int num_active_eps;
1657 unsigned int limit_active_eps; 1660 unsigned int limit_active_eps;
1658 /* There are two roothubs to keep track of bus suspend info for */ 1661 /* There are two roothubs to keep track of bus suspend info for */
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index bff4869a57cd..4042ea017985 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1255,6 +1255,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1255 1255
1256 map_dma_buffer(request, musb, musb_ep); 1256 map_dma_buffer(request, musb, musb_ep);
1257 1257
1258 pm_runtime_get_sync(musb->controller);
1258 spin_lock_irqsave(&musb->lock, lockflags); 1259 spin_lock_irqsave(&musb->lock, lockflags);
1259 1260
1260 /* don't queue if the ep is down */ 1261 /* don't queue if the ep is down */
@@ -1275,6 +1276,9 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1275 1276
1276unlock: 1277unlock:
1277 spin_unlock_irqrestore(&musb->lock, lockflags); 1278 spin_unlock_irqrestore(&musb->lock, lockflags);
1279 pm_runtime_mark_last_busy(musb->controller);
1280 pm_runtime_put_autosuspend(musb->controller);
1281
1278 return status; 1282 return status;
1279} 1283}
1280 1284
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 1ab6973d4f61..cc1225485509 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -287,6 +287,7 @@ static int omap2430_musb_init(struct musb *musb)
287 } 287 }
288 musb->isr = omap2430_musb_interrupt; 288 musb->isr = omap2430_musb_interrupt;
289 phy_init(musb->phy); 289 phy_init(musb->phy);
290 phy_power_on(musb->phy);
290 291
291 l = musb_readl(musb->mregs, OTG_INTERFSEL); 292 l = musb_readl(musb->mregs, OTG_INTERFSEL);
292 293
@@ -323,8 +324,6 @@ static void omap2430_musb_enable(struct musb *musb)
323 struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); 324 struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
324 struct omap_musb_board_data *data = pdata->board_data; 325 struct omap_musb_board_data *data = pdata->board_data;
325 326
326 if (!WARN_ON(!musb->phy))
327 phy_power_on(musb->phy);
328 327
329 switch (glue->status) { 328 switch (glue->status) {
330 329
@@ -361,9 +360,6 @@ static void omap2430_musb_disable(struct musb *musb)
361 struct device *dev = musb->controller; 360 struct device *dev = musb->controller;
362 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 361 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
363 362
364 if (!WARN_ON(!musb->phy))
365 phy_power_off(musb->phy);
366
367 if (glue->status != MUSB_UNKNOWN) 363 if (glue->status != MUSB_UNKNOWN)
368 omap_control_usb_set_mode(glue->control_otghs, 364 omap_control_usb_set_mode(glue->control_otghs,
369 USB_MODE_DISCONNECT); 365 USB_MODE_DISCONNECT);
@@ -375,6 +371,7 @@ static int omap2430_musb_exit(struct musb *musb)
375 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 371 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
376 372
377 omap2430_low_level_exit(musb); 373 omap2430_low_level_exit(musb);
374 phy_power_off(musb->phy);
378 phy_exit(musb->phy); 375 phy_exit(musb->phy);
379 musb->phy = NULL; 376 musb->phy = NULL;
380 cancel_work_sync(&glue->omap_musb_mailbox_work); 377 cancel_work_sync(&glue->omap_musb_mailbox_work);
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
index 1d70add926f0..d544b331c9f2 100644
--- a/drivers/usb/renesas_usbhs/rcar3.c
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -9,6 +9,7 @@
9 * 9 *
10 */ 10 */
11 11
12#include <linux/delay.h>
12#include <linux/io.h> 13#include <linux/io.h>
13#include "common.h" 14#include "common.h"
14#include "rcar3.h" 15#include "rcar3.h"
@@ -35,10 +36,13 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev,
35 36
36 usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG); 37 usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG);
37 38
38 if (enable) 39 if (enable) {
39 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); 40 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
40 else 41 /* The controller on R-Car Gen3 needs to wait up to 45 usec */
42 udelay(45);
43 } else {
41 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); 44 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0);
45 }
42 46
43 return 0; 47 return 0;
44} 48}
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 54a4de0efdba..f61477bed3a8 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1077,7 +1077,9 @@ static int cp210x_tiocmget(struct tty_struct *tty)
1077 u8 control; 1077 u8 control;
1078 int result; 1078 int result;
1079 1079
1080 cp210x_read_u8_reg(port, CP210X_GET_MDMSTS, &control); 1080 result = cp210x_read_u8_reg(port, CP210X_GET_MDMSTS, &control);
1081 if (result)
1082 return result;
1081 1083
1082 result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) 1084 result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0)
1083 |((control & CONTROL_RTS) ? TIOCM_RTS : 0) 1085 |((control & CONTROL_RTS) ? TIOCM_RTS : 0)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b2d767e743fc..0ff7f38d7800 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -986,7 +986,8 @@ static const struct usb_device_id id_table_combined[] = {
986 /* ekey Devices */ 986 /* ekey Devices */
987 { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) }, 987 { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
988 /* Infineon Devices */ 988 /* Infineon Devices */
989 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, 989 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC1798_PID, 1) },
990 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC2X7_PID, 1) },
990 /* GE Healthcare devices */ 991 /* GE Healthcare devices */
991 { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) }, 992 { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) },
992 /* Active Research (Actisense) devices */ 993 /* Active Research (Actisense) devices */
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index f87a938cf005..21011c0a4c64 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -626,8 +626,9 @@
626/* 626/*
627 * Infineon Technologies 627 * Infineon Technologies
628 */ 628 */
629#define INFINEON_VID 0x058b 629#define INFINEON_VID 0x058b
630#define INFINEON_TRIBOARD_PID 0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */ 630#define INFINEON_TRIBOARD_TC1798_PID 0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */
631#define INFINEON_TRIBOARD_TC2X7_PID 0x0043 /* DAS JTAG TriBoard TC2X7 V1.0 */
631 632
632/* 633/*
633 * Acton Research Corp. 634 * Acton Research Corp.
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index d213cf44a7e4..4a037b4a79cf 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1078,7 +1078,8 @@ static int usb_serial_probe(struct usb_interface *interface,
1078 1078
1079 serial->disconnected = 0; 1079 serial->disconnected = 0;
1080 1080
1081 usb_serial_console_init(serial->port[0]->minor); 1081 if (num_ports > 0)
1082 usb_serial_console_init(serial->port[0]->minor);
1082exit: 1083exit:
1083 module_put(type->driver.owner); 1084 module_put(type->driver.owner);
1084 return 0; 1085 return 0;
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c
index 79b2b628066d..79451f7ef1b7 100644
--- a/drivers/usb/wusbcore/crypto.c
+++ b/drivers/usb/wusbcore/crypto.c
@@ -133,6 +133,13 @@ static void bytewise_xor(void *_bo, const void *_bi1, const void *_bi2,
133 bo[itr] = bi1[itr] ^ bi2[itr]; 133 bo[itr] = bi1[itr] ^ bi2[itr];
134} 134}
135 135
136/* Scratch space for MAC calculations. */
137struct wusb_mac_scratch {
138 struct aes_ccm_b0 b0;
139 struct aes_ccm_b1 b1;
140 struct aes_ccm_a ax;
141};
142
136/* 143/*
137 * CC-MAC function WUSB1.0[6.5] 144 * CC-MAC function WUSB1.0[6.5]
138 * 145 *
@@ -197,16 +204,15 @@ static void bytewise_xor(void *_bo, const void *_bi1, const void *_bi2,
197 * what sg[4] is for. Maybe there is a smarter way to do this. 204 * what sg[4] is for. Maybe there is a smarter way to do this.
198 */ 205 */
199static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, 206static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
200 struct crypto_cipher *tfm_aes, void *mic, 207 struct crypto_cipher *tfm_aes,
208 struct wusb_mac_scratch *scratch,
209 void *mic,
201 const struct aes_ccm_nonce *n, 210 const struct aes_ccm_nonce *n,
202 const struct aes_ccm_label *a, const void *b, 211 const struct aes_ccm_label *a, const void *b,
203 size_t blen) 212 size_t blen)
204{ 213{
205 int result = 0; 214 int result = 0;
206 SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); 215 SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc);
207 struct aes_ccm_b0 b0;
208 struct aes_ccm_b1 b1;
209 struct aes_ccm_a ax;
210 struct scatterlist sg[4], sg_dst; 216 struct scatterlist sg[4], sg_dst;
211 void *dst_buf; 217 void *dst_buf;
212 size_t dst_size; 218 size_t dst_size;
@@ -218,16 +224,17 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
218 * These checks should be compile time optimized out 224 * These checks should be compile time optimized out
219 * ensure @a fills b1's mac_header and following fields 225 * ensure @a fills b1's mac_header and following fields
220 */ 226 */
221 WARN_ON(sizeof(*a) != sizeof(b1) - sizeof(b1.la)); 227 WARN_ON(sizeof(*a) != sizeof(scratch->b1) - sizeof(scratch->b1.la));
222 WARN_ON(sizeof(b0) != sizeof(struct aes_ccm_block)); 228 WARN_ON(sizeof(scratch->b0) != sizeof(struct aes_ccm_block));
223 WARN_ON(sizeof(b1) != sizeof(struct aes_ccm_block)); 229 WARN_ON(sizeof(scratch->b1) != sizeof(struct aes_ccm_block));
224 WARN_ON(sizeof(ax) != sizeof(struct aes_ccm_block)); 230 WARN_ON(sizeof(scratch->ax) != sizeof(struct aes_ccm_block));
225 231
226 result = -ENOMEM; 232 result = -ENOMEM;
227 zero_padding = blen % sizeof(struct aes_ccm_block); 233 zero_padding = blen % sizeof(struct aes_ccm_block);
228 if (zero_padding) 234 if (zero_padding)
229 zero_padding = sizeof(struct aes_ccm_block) - zero_padding; 235 zero_padding = sizeof(struct aes_ccm_block) - zero_padding;
230 dst_size = blen + sizeof(b0) + sizeof(b1) + zero_padding; 236 dst_size = blen + sizeof(scratch->b0) + sizeof(scratch->b1) +
237 zero_padding;
231 dst_buf = kzalloc(dst_size, GFP_KERNEL); 238 dst_buf = kzalloc(dst_size, GFP_KERNEL);
232 if (!dst_buf) 239 if (!dst_buf)
233 goto error_dst_buf; 240 goto error_dst_buf;
@@ -235,9 +242,9 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
235 memset(iv, 0, sizeof(iv)); 242 memset(iv, 0, sizeof(iv));
236 243
237 /* Setup B0 */ 244 /* Setup B0 */
238 b0.flags = 0x59; /* Format B0 */ 245 scratch->b0.flags = 0x59; /* Format B0 */
239 b0.ccm_nonce = *n; 246 scratch->b0.ccm_nonce = *n;
240 b0.lm = cpu_to_be16(0); /* WUSB1.0[6.5] sez l(m) is 0 */ 247 scratch->b0.lm = cpu_to_be16(0); /* WUSB1.0[6.5] sez l(m) is 0 */
241 248
242 /* Setup B1 249 /* Setup B1
243 * 250 *
@@ -246,12 +253,12 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
246 * 14'--after clarification, it means to use A's contents 253 * 14'--after clarification, it means to use A's contents
247 * for MAC Header, EO, sec reserved and padding. 254 * for MAC Header, EO, sec reserved and padding.
248 */ 255 */
249 b1.la = cpu_to_be16(blen + 14); 256 scratch->b1.la = cpu_to_be16(blen + 14);
250 memcpy(&b1.mac_header, a, sizeof(*a)); 257 memcpy(&scratch->b1.mac_header, a, sizeof(*a));
251 258
252 sg_init_table(sg, ARRAY_SIZE(sg)); 259 sg_init_table(sg, ARRAY_SIZE(sg));
253 sg_set_buf(&sg[0], &b0, sizeof(b0)); 260 sg_set_buf(&sg[0], &scratch->b0, sizeof(scratch->b0));
254 sg_set_buf(&sg[1], &b1, sizeof(b1)); 261 sg_set_buf(&sg[1], &scratch->b1, sizeof(scratch->b1));
255 sg_set_buf(&sg[2], b, blen); 262 sg_set_buf(&sg[2], b, blen);
256 /* 0 if well behaved :) */ 263 /* 0 if well behaved :) */
257 sg_set_buf(&sg[3], bzero, zero_padding); 264 sg_set_buf(&sg[3], bzero, zero_padding);
@@ -276,11 +283,12 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
276 * POS Crypto API: size is assumed to be AES's block size. 283 * POS Crypto API: size is assumed to be AES's block size.
277 * Thanks for documenting it -- tip taken from airo.c 284 * Thanks for documenting it -- tip taken from airo.c
278 */ 285 */
279 ax.flags = 0x01; /* as per WUSB 1.0 spec */ 286 scratch->ax.flags = 0x01; /* as per WUSB 1.0 spec */
280 ax.ccm_nonce = *n; 287 scratch->ax.ccm_nonce = *n;
281 ax.counter = 0; 288 scratch->ax.counter = 0;
282 crypto_cipher_encrypt_one(tfm_aes, (void *)&ax, (void *)&ax); 289 crypto_cipher_encrypt_one(tfm_aes, (void *)&scratch->ax,
283 bytewise_xor(mic, &ax, iv, 8); 290 (void *)&scratch->ax);
291 bytewise_xor(mic, &scratch->ax, iv, 8);
284 result = 8; 292 result = 8;
285error_cbc_crypt: 293error_cbc_crypt:
286 kfree(dst_buf); 294 kfree(dst_buf);
@@ -303,6 +311,7 @@ ssize_t wusb_prf(void *out, size_t out_size,
303 struct aes_ccm_nonce n = *_n; 311 struct aes_ccm_nonce n = *_n;
304 struct crypto_skcipher *tfm_cbc; 312 struct crypto_skcipher *tfm_cbc;
305 struct crypto_cipher *tfm_aes; 313 struct crypto_cipher *tfm_aes;
314 struct wusb_mac_scratch *scratch;
306 u64 sfn = 0; 315 u64 sfn = 0;
307 __le64 sfn_le; 316 __le64 sfn_le;
308 317
@@ -329,17 +338,25 @@ ssize_t wusb_prf(void *out, size_t out_size,
329 printk(KERN_ERR "E: can't set AES key: %d\n", (int)result); 338 printk(KERN_ERR "E: can't set AES key: %d\n", (int)result);
330 goto error_setkey_aes; 339 goto error_setkey_aes;
331 } 340 }
341 scratch = kmalloc(sizeof(*scratch), GFP_KERNEL);
342 if (!scratch) {
343 result = -ENOMEM;
344 goto error_alloc_scratch;
345 }
332 346
333 for (bitr = 0; bitr < (len + 63) / 64; bitr++) { 347 for (bitr = 0; bitr < (len + 63) / 64; bitr++) {
334 sfn_le = cpu_to_le64(sfn++); 348 sfn_le = cpu_to_le64(sfn++);
335 memcpy(&n.sfn, &sfn_le, sizeof(n.sfn)); /* n.sfn++... */ 349 memcpy(&n.sfn, &sfn_le, sizeof(n.sfn)); /* n.sfn++... */
336 result = wusb_ccm_mac(tfm_cbc, tfm_aes, out + bytes, 350 result = wusb_ccm_mac(tfm_cbc, tfm_aes, scratch, out + bytes,
337 &n, a, b, blen); 351 &n, a, b, blen);
338 if (result < 0) 352 if (result < 0)
339 goto error_ccm_mac; 353 goto error_ccm_mac;
340 bytes += result; 354 bytes += result;
341 } 355 }
342 result = bytes; 356 result = bytes;
357
358 kfree(scratch);
359error_alloc_scratch:
343error_ccm_mac: 360error_ccm_mac:
344error_setkey_aes: 361error_setkey_aes:
345 crypto_free_cipher(tfm_aes); 362 crypto_free_cipher(tfm_aes);
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 15b64076bc26..bdbadaa47ef3 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -156,12 +156,16 @@ size_t vme_get_size(struct vme_resource *resource)
156 case VME_MASTER: 156 case VME_MASTER:
157 retval = vme_master_get(resource, &enabled, &base, &size, 157 retval = vme_master_get(resource, &enabled, &base, &size,
158 &aspace, &cycle, &dwidth); 158 &aspace, &cycle, &dwidth);
159 if (retval)
160 return 0;
159 161
160 return size; 162 return size;
161 break; 163 break;
162 case VME_SLAVE: 164 case VME_SLAVE:
163 retval = vme_slave_get(resource, &enabled, &base, &size, 165 retval = vme_slave_get(resource, &enabled, &base, &size,
164 &buf_base, &aspace, &cycle); 166 &buf_base, &aspace, &cycle);
167 if (retval)
168 return 0;
165 169
166 return size; 170 return size;
167 break; 171 break;
diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
index e473e3b23720..6d1fbda0f461 100644
--- a/drivers/watchdog/wdat_wdt.c
+++ b/drivers/watchdog/wdat_wdt.c
@@ -499,6 +499,10 @@ static int wdat_wdt_resume_noirq(struct device *dev)
499 ret = wdat_wdt_enable_reboot(wdat); 499 ret = wdat_wdt_enable_reboot(wdat);
500 if (ret) 500 if (ret)
501 return ret; 501 return ret;
502
503 ret = wdat_wdt_ping(&wdat->wdd);
504 if (ret)
505 return ret;
502 } 506 }
503 507
504 return wdat_wdt_start(&wdat->wdd); 508 return wdat_wdt_start(&wdat->wdd);
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index e12bd3635f83..26e5e8507f03 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -168,7 +168,9 @@ out:
168#endif /* CONFIG_HIBERNATE_CALLBACKS */ 168#endif /* CONFIG_HIBERNATE_CALLBACKS */
169 169
170struct shutdown_handler { 170struct shutdown_handler {
171 const char *command; 171#define SHUTDOWN_CMD_SIZE 11
172 const char command[SHUTDOWN_CMD_SIZE];
173 bool flag;
172 void (*cb)(void); 174 void (*cb)(void);
173}; 175};
174 176
@@ -206,22 +208,22 @@ static void do_reboot(void)
206 ctrl_alt_del(); 208 ctrl_alt_del();
207} 209}
208 210
211static struct shutdown_handler shutdown_handlers[] = {
212 { "poweroff", true, do_poweroff },
213 { "halt", false, do_poweroff },
214 { "reboot", true, do_reboot },
215#ifdef CONFIG_HIBERNATE_CALLBACKS
216 { "suspend", true, do_suspend },
217#endif
218};
219
209static void shutdown_handler(struct xenbus_watch *watch, 220static void shutdown_handler(struct xenbus_watch *watch,
210 const char **vec, unsigned int len) 221 const char **vec, unsigned int len)
211{ 222{
212 char *str; 223 char *str;
213 struct xenbus_transaction xbt; 224 struct xenbus_transaction xbt;
214 int err; 225 int err;
215 static struct shutdown_handler handlers[] = { 226 int idx;
216 { "poweroff", do_poweroff },
217 { "halt", do_poweroff },
218 { "reboot", do_reboot },
219#ifdef CONFIG_HIBERNATE_CALLBACKS
220 { "suspend", do_suspend },
221#endif
222 {NULL, NULL},
223 };
224 static struct shutdown_handler *handler;
225 227
226 if (shutting_down != SHUTDOWN_INVALID) 228 if (shutting_down != SHUTDOWN_INVALID)
227 return; 229 return;
@@ -238,13 +240,13 @@ static void shutdown_handler(struct xenbus_watch *watch,
238 return; 240 return;
239 } 241 }
240 242
241 for (handler = &handlers[0]; handler->command; handler++) { 243 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
242 if (strcmp(str, handler->command) == 0) 244 if (strcmp(str, shutdown_handlers[idx].command) == 0)
243 break; 245 break;
244 } 246 }
245 247
246 /* Only acknowledge commands which we are prepared to handle. */ 248 /* Only acknowledge commands which we are prepared to handle. */
247 if (handler->cb) 249 if (idx < ARRAY_SIZE(shutdown_handlers))
248 xenbus_write(xbt, "control", "shutdown", ""); 250 xenbus_write(xbt, "control", "shutdown", "");
249 251
250 err = xenbus_transaction_end(xbt, 0); 252 err = xenbus_transaction_end(xbt, 0);
@@ -253,8 +255,8 @@ static void shutdown_handler(struct xenbus_watch *watch,
253 goto again; 255 goto again;
254 } 256 }
255 257
256 if (handler->cb) { 258 if (idx < ARRAY_SIZE(shutdown_handlers)) {
257 handler->cb(); 259 shutdown_handlers[idx].cb();
258 } else { 260 } else {
259 pr_info("Ignoring shutdown request: %s\n", str); 261 pr_info("Ignoring shutdown request: %s\n", str);
260 shutting_down = SHUTDOWN_INVALID; 262 shutting_down = SHUTDOWN_INVALID;
@@ -310,6 +312,9 @@ static struct notifier_block xen_reboot_nb = {
310static int setup_shutdown_watcher(void) 312static int setup_shutdown_watcher(void)
311{ 313{
312 int err; 314 int err;
315 int idx;
316#define FEATURE_PATH_SIZE (SHUTDOWN_CMD_SIZE + sizeof("feature-"))
317 char node[FEATURE_PATH_SIZE];
313 318
314 err = register_xenbus_watch(&shutdown_watch); 319 err = register_xenbus_watch(&shutdown_watch);
315 if (err) { 320 if (err) {
@@ -326,6 +331,14 @@ static int setup_shutdown_watcher(void)
326 } 331 }
327#endif 332#endif
328 333
334 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
335 if (!shutdown_handlers[idx].flag)
336 continue;
337 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
338 shutdown_handlers[idx].command);
339 xenbus_printf(XBT_NIL, "control", node, "%u", 1);
340 }
341
329 return 0; 342 return 0;
330} 343}
331 344
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index c1010f018bd8..1e8be12ebb55 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -364,7 +364,7 @@ out:
364 364
365static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u) 365static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
366{ 366{
367 struct watch_adapter *watch, *tmp_watch; 367 struct watch_adapter *watch;
368 char *path, *token; 368 char *path, *token;
369 int err, rc; 369 int err, rc;
370 LIST_HEAD(staging_q); 370 LIST_HEAD(staging_q);
@@ -399,7 +399,7 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
399 } 399 }
400 list_add(&watch->list, &u->watches); 400 list_add(&watch->list, &u->watches);
401 } else { 401 } else {
402 list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) { 402 list_for_each_entry(watch, &u->watches, list) {
403 if (!strcmp(watch->token, token) && 403 if (!strcmp(watch->token, token) &&
404 !strcmp(watch->watch.node, path)) { 404 !strcmp(watch->watch.node, path)) {
405 unregister_xenbus_watch(&watch->watch); 405 unregister_xenbus_watch(&watch->watch);
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index 611a23119675..6d40a972ffb2 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -335,7 +335,9 @@ static int backend_state;
335static void xenbus_reset_backend_state_changed(struct xenbus_watch *w, 335static void xenbus_reset_backend_state_changed(struct xenbus_watch *w,
336 const char **v, unsigned int l) 336 const char **v, unsigned int l)
337{ 337{
338 xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", &backend_state); 338 if (xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i",
339 &backend_state) != 1)
340 backend_state = XenbusStateUnknown;
339 printk(KERN_DEBUG "XENBUS: backend %s %s\n", 341 printk(KERN_DEBUG "XENBUS: backend %s %s\n",
340 v[XS_WATCH_PATH], xenbus_strstate(backend_state)); 342 v[XS_WATCH_PATH], xenbus_strstate(backend_state));
341 wake_up(&backend_state_wq); 343 wake_up(&backend_state_wq);
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 2037e7a77a37..d764236072b1 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -91,11 +91,9 @@ static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
91 */ 91 */
92bool afs_cm_incoming_call(struct afs_call *call) 92bool afs_cm_incoming_call(struct afs_call *call)
93{ 93{
94 u32 operation_id = ntohl(call->operation_ID); 94 _enter("{CB.OP %u}", call->operation_ID);
95 95
96 _enter("{CB.OP %u}", operation_id); 96 switch (call->operation_ID) {
97
98 switch (operation_id) {
99 case CBCallBack: 97 case CBCallBack:
100 call->type = &afs_SRXCBCallBack; 98 call->type = &afs_SRXCBCallBack;
101 return true; 99 return true;
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 96f4d764d1a6..31c616ab9b40 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -364,7 +364,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
364 buffer = kmap(page); 364 buffer = kmap(page);
365 ret = afs_extract_data(call, buffer, 365 ret = afs_extract_data(call, buffer,
366 call->count, true); 366 call->count, true);
367 kunmap(buffer); 367 kunmap(page);
368 if (ret < 0) 368 if (ret < 0)
369 return ret; 369 return ret;
370 } 370 }
@@ -397,7 +397,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
397 page = call->reply3; 397 page = call->reply3;
398 buffer = kmap(page); 398 buffer = kmap(page);
399 memset(buffer + call->count, 0, PAGE_SIZE - call->count); 399 memset(buffer + call->count, 0, PAGE_SIZE - call->count);
400 kunmap(buffer); 400 kunmap(page);
401 } 401 }
402 402
403 _leave(" = 0 [done]"); 403 _leave(" = 0 [done]");
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 5497c8496055..535a38d2c1d0 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -112,7 +112,7 @@ struct afs_call {
112 bool need_attention; /* T if RxRPC poked us */ 112 bool need_attention; /* T if RxRPC poked us */
113 u16 service_id; /* RxRPC service ID to call */ 113 u16 service_id; /* RxRPC service ID to call */
114 __be16 port; /* target UDP port */ 114 __be16 port; /* target UDP port */
115 __be32 operation_ID; /* operation ID for an incoming call */ 115 u32 operation_ID; /* operation ID for an incoming call */
116 u32 count; /* count for use in unmarshalling */ 116 u32 count; /* count for use in unmarshalling */
117 __be32 tmp; /* place to extract temporary data */ 117 __be32 tmp; /* place to extract temporary data */
118 afs_dataversion_t store_version; /* updated version expected from store */ 118 afs_dataversion_t store_version; /* updated version expected from store */
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index 477928b25940..25f05a8d21b1 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -676,10 +676,11 @@ static int afs_deliver_cm_op_id(struct afs_call *call)
676 ASSERTCMP(call->offset, <, 4); 676 ASSERTCMP(call->offset, <, 4);
677 677
678 /* the operation ID forms the first four bytes of the request data */ 678 /* the operation ID forms the first four bytes of the request data */
679 ret = afs_extract_data(call, &call->operation_ID, 4, true); 679 ret = afs_extract_data(call, &call->tmp, 4, true);
680 if (ret < 0) 680 if (ret < 0)
681 return ret; 681 return ret;
682 682
683 call->operation_ID = ntohl(call->tmp);
683 call->state = AFS_CALL_AWAIT_REQUEST; 684 call->state = AFS_CALL_AWAIT_REQUEST;
684 call->offset = 0; 685 call->offset = 0;
685 686
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 01bc36cec26e..71261b459863 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -5805,6 +5805,64 @@ static int changed_extent(struct send_ctx *sctx,
5805 int ret = 0; 5805 int ret = 0;
5806 5806
5807 if (sctx->cur_ino != sctx->cmp_key->objectid) { 5807 if (sctx->cur_ino != sctx->cmp_key->objectid) {
5808
5809 if (result == BTRFS_COMPARE_TREE_CHANGED) {
5810 struct extent_buffer *leaf_l;
5811 struct extent_buffer *leaf_r;
5812 struct btrfs_file_extent_item *ei_l;
5813 struct btrfs_file_extent_item *ei_r;
5814
5815 leaf_l = sctx->left_path->nodes[0];
5816 leaf_r = sctx->right_path->nodes[0];
5817 ei_l = btrfs_item_ptr(leaf_l,
5818 sctx->left_path->slots[0],
5819 struct btrfs_file_extent_item);
5820 ei_r = btrfs_item_ptr(leaf_r,
5821 sctx->right_path->slots[0],
5822 struct btrfs_file_extent_item);
5823
5824 /*
5825 * We may have found an extent item that has changed
5826 * only its disk_bytenr field and the corresponding
5827 * inode item was not updated. This case happens due to
5828 * very specific timings during relocation when a leaf
5829 * that contains file extent items is COWed while
5830 * relocation is ongoing and its in the stage where it
5831 * updates data pointers. So when this happens we can
5832 * safely ignore it since we know it's the same extent,
5833 * but just at different logical and physical locations
5834 * (when an extent is fully replaced with a new one, we
5835 * know the generation number must have changed too,
5836 * since snapshot creation implies committing the current
5837 * transaction, and the inode item must have been updated
5838 * as well).
5839 * This replacement of the disk_bytenr happens at
5840 * relocation.c:replace_file_extents() through
5841 * relocation.c:btrfs_reloc_cow_block().
5842 */
5843 if (btrfs_file_extent_generation(leaf_l, ei_l) ==
5844 btrfs_file_extent_generation(leaf_r, ei_r) &&
5845 btrfs_file_extent_ram_bytes(leaf_l, ei_l) ==
5846 btrfs_file_extent_ram_bytes(leaf_r, ei_r) &&
5847 btrfs_file_extent_compression(leaf_l, ei_l) ==
5848 btrfs_file_extent_compression(leaf_r, ei_r) &&
5849 btrfs_file_extent_encryption(leaf_l, ei_l) ==
5850 btrfs_file_extent_encryption(leaf_r, ei_r) &&
5851 btrfs_file_extent_other_encoding(leaf_l, ei_l) ==
5852 btrfs_file_extent_other_encoding(leaf_r, ei_r) &&
5853 btrfs_file_extent_type(leaf_l, ei_l) ==
5854 btrfs_file_extent_type(leaf_r, ei_r) &&
5855 btrfs_file_extent_disk_bytenr(leaf_l, ei_l) !=
5856 btrfs_file_extent_disk_bytenr(leaf_r, ei_r) &&
5857 btrfs_file_extent_disk_num_bytes(leaf_l, ei_l) ==
5858 btrfs_file_extent_disk_num_bytes(leaf_r, ei_r) &&
5859 btrfs_file_extent_offset(leaf_l, ei_l) ==
5860 btrfs_file_extent_offset(leaf_r, ei_r) &&
5861 btrfs_file_extent_num_bytes(leaf_l, ei_l) ==
5862 btrfs_file_extent_num_bytes(leaf_r, ei_r))
5863 return 0;
5864 }
5865
5808 inconsistent_snapshot_error(sctx, result, "extent"); 5866 inconsistent_snapshot_error(sctx, result, "extent");
5809 return -EIO; 5867 return -EIO;
5810 } 5868 }
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 528cae123dc9..3d33c4e41e5f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2713,14 +2713,12 @@ static inline void btrfs_remove_all_log_ctxs(struct btrfs_root *root,
2713 int index, int error) 2713 int index, int error)
2714{ 2714{
2715 struct btrfs_log_ctx *ctx; 2715 struct btrfs_log_ctx *ctx;
2716 struct btrfs_log_ctx *safe;
2716 2717
2717 if (!error) { 2718 list_for_each_entry_safe(ctx, safe, &root->log_ctxs[index], list) {
2718 INIT_LIST_HEAD(&root->log_ctxs[index]); 2719 list_del_init(&ctx->list);
2719 return;
2720 }
2721
2722 list_for_each_entry(ctx, &root->log_ctxs[index], list)
2723 ctx->log_ret = error; 2720 ctx->log_ret = error;
2721 }
2724 2722
2725 INIT_LIST_HEAD(&root->log_ctxs[index]); 2723 INIT_LIST_HEAD(&root->log_ctxs[index]);
2726} 2724}
@@ -2961,13 +2959,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2961 mutex_unlock(&root->log_mutex); 2959 mutex_unlock(&root->log_mutex);
2962 2960
2963out_wake_log_root: 2961out_wake_log_root:
2964 /* 2962 mutex_lock(&log_root_tree->log_mutex);
2965 * We needn't get log_mutex here because we are sure all
2966 * the other tasks are blocked.
2967 */
2968 btrfs_remove_all_log_ctxs(log_root_tree, index2, ret); 2963 btrfs_remove_all_log_ctxs(log_root_tree, index2, ret);
2969 2964
2970 mutex_lock(&log_root_tree->log_mutex);
2971 log_root_tree->log_transid_committed++; 2965 log_root_tree->log_transid_committed++;
2972 atomic_set(&log_root_tree->log_commit[index2], 0); 2966 atomic_set(&log_root_tree->log_commit[index2], 0);
2973 mutex_unlock(&log_root_tree->log_mutex); 2967 mutex_unlock(&log_root_tree->log_mutex);
@@ -2978,10 +2972,8 @@ out_wake_log_root:
2978 if (waitqueue_active(&log_root_tree->log_commit_wait[index2])) 2972 if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))
2979 wake_up(&log_root_tree->log_commit_wait[index2]); 2973 wake_up(&log_root_tree->log_commit_wait[index2]);
2980out: 2974out:
2981 /* See above. */
2982 btrfs_remove_all_log_ctxs(root, index1, ret);
2983
2984 mutex_lock(&root->log_mutex); 2975 mutex_lock(&root->log_mutex);
2976 btrfs_remove_all_log_ctxs(root, index1, ret);
2985 root->log_transid_committed++; 2977 root->log_transid_committed++;
2986 atomic_set(&root->log_commit[index1], 0); 2978 atomic_set(&root->log_commit[index1], 0);
2987 mutex_unlock(&root->log_mutex); 2979 mutex_unlock(&root->log_mutex);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 7bf08825cc11..18630e800208 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1272,7 +1272,8 @@ again:
1272 statret = __ceph_do_getattr(inode, page, 1272 statret = __ceph_do_getattr(inode, page,
1273 CEPH_STAT_CAP_INLINE_DATA, !!page); 1273 CEPH_STAT_CAP_INLINE_DATA, !!page);
1274 if (statret < 0) { 1274 if (statret < 0) {
1275 __free_page(page); 1275 if (page)
1276 __free_page(page);
1276 if (statret == -ENODATA) { 1277 if (statret == -ENODATA) {
1277 BUG_ON(retry_op != READ_INLINE); 1278 BUG_ON(retry_op != READ_INLINE);
1278 goto again; 1279 goto again;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index bca1b49c1c4b..ef4d04647325 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1511,7 +1511,8 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
1511 ceph_fill_dirfrag(d_inode(parent), rinfo->dir_dir); 1511 ceph_fill_dirfrag(d_inode(parent), rinfo->dir_dir);
1512 } 1512 }
1513 1513
1514 if (ceph_frag_is_leftmost(frag) && req->r_readdir_offset == 2) { 1514 if (ceph_frag_is_leftmost(frag) && req->r_readdir_offset == 2 &&
1515 !(rinfo->hash_order && req->r_path2)) {
1515 /* note dir version at start of readdir so we can tell 1516 /* note dir version at start of readdir so we can tell
1516 * if any dentries get dropped */ 1517 * if any dentries get dropped */
1517 req->r_dir_release_cnt = atomic64_read(&ci->i_release_count); 1518 req->r_dir_release_cnt = atomic64_read(&ci->i_release_count);
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index a29ffce98187..b382e5910eea 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -845,6 +845,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
845 err = ceph_fs_debugfs_init(fsc); 845 err = ceph_fs_debugfs_init(fsc);
846 if (err < 0) 846 if (err < 0)
847 goto fail; 847 goto fail;
848 } else {
849 root = dget(fsc->sb->s_root);
848 } 850 }
849 851
850 fsc->mount_state = CEPH_MOUNT_MOUNTED; 852 fsc->mount_state = CEPH_MOUNT_MOUNTED;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 40b703217977..febc28f9e2c2 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -16,7 +16,7 @@
16static int __remove_xattr(struct ceph_inode_info *ci, 16static int __remove_xattr(struct ceph_inode_info *ci,
17 struct ceph_inode_xattr *xattr); 17 struct ceph_inode_xattr *xattr);
18 18
19const struct xattr_handler ceph_other_xattr_handler; 19static const struct xattr_handler ceph_other_xattr_handler;
20 20
21/* 21/*
22 * List of handlers for synthetic system.* attributes. Other 22 * List of handlers for synthetic system.* attributes. Other
@@ -1086,7 +1086,7 @@ static int ceph_set_xattr_handler(const struct xattr_handler *handler,
1086 return __ceph_setxattr(inode, name, value, size, flags); 1086 return __ceph_setxattr(inode, name, value, size, flags);
1087} 1087}
1088 1088
1089const struct xattr_handler ceph_other_xattr_handler = { 1089static const struct xattr_handler ceph_other_xattr_handler = {
1090 .prefix = "", /* match any name => handlers called with full name */ 1090 .prefix = "", /* match any name => handlers called with full name */
1091 .get = ceph_get_xattr_handler, 1091 .get = ceph_get_xattr_handler,
1092 .set = ceph_set_xattr_handler, 1092 .set = ceph_set_xattr_handler,
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 61057b7dbddb..98f87fe8f186 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -151,7 +151,10 @@ static int do_page_crypto(struct inode *inode,
151 struct page *src_page, struct page *dest_page, 151 struct page *src_page, struct page *dest_page,
152 gfp_t gfp_flags) 152 gfp_t gfp_flags)
153{ 153{
154 u8 xts_tweak[FS_XTS_TWEAK_SIZE]; 154 struct {
155 __le64 index;
156 u8 padding[FS_XTS_TWEAK_SIZE - sizeof(__le64)];
157 } xts_tweak;
155 struct skcipher_request *req = NULL; 158 struct skcipher_request *req = NULL;
156 DECLARE_FS_COMPLETION_RESULT(ecr); 159 DECLARE_FS_COMPLETION_RESULT(ecr);
157 struct scatterlist dst, src; 160 struct scatterlist dst, src;
@@ -171,17 +174,15 @@ static int do_page_crypto(struct inode *inode,
171 req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 174 req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
172 page_crypt_complete, &ecr); 175 page_crypt_complete, &ecr);
173 176
174 BUILD_BUG_ON(FS_XTS_TWEAK_SIZE < sizeof(index)); 177 BUILD_BUG_ON(sizeof(xts_tweak) != FS_XTS_TWEAK_SIZE);
175 memcpy(xts_tweak, &index, sizeof(index)); 178 xts_tweak.index = cpu_to_le64(index);
176 memset(&xts_tweak[sizeof(index)], 0, 179 memset(xts_tweak.padding, 0, sizeof(xts_tweak.padding));
177 FS_XTS_TWEAK_SIZE - sizeof(index));
178 180
179 sg_init_table(&dst, 1); 181 sg_init_table(&dst, 1);
180 sg_set_page(&dst, dest_page, PAGE_SIZE, 0); 182 sg_set_page(&dst, dest_page, PAGE_SIZE, 0);
181 sg_init_table(&src, 1); 183 sg_init_table(&src, 1);
182 sg_set_page(&src, src_page, PAGE_SIZE, 0); 184 sg_set_page(&src, src_page, PAGE_SIZE, 0);
183 skcipher_request_set_crypt(req, &src, &dst, PAGE_SIZE, 185 skcipher_request_set_crypt(req, &src, &dst, PAGE_SIZE, &xts_tweak);
184 xts_tweak);
185 if (rw == FS_DECRYPT) 186 if (rw == FS_DECRYPT)
186 res = crypto_skcipher_decrypt(req); 187 res = crypto_skcipher_decrypt(req);
187 else 188 else
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index ed115acb5dee..6865663aac69 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -109,6 +109,8 @@ int fscrypt_process_policy(struct file *filp,
109 if (ret) 109 if (ret)
110 return ret; 110 return ret;
111 111
112 inode_lock(inode);
113
112 if (!inode_has_encryption_context(inode)) { 114 if (!inode_has_encryption_context(inode)) {
113 if (!S_ISDIR(inode->i_mode)) 115 if (!S_ISDIR(inode->i_mode))
114 ret = -EINVAL; 116 ret = -EINVAL;
@@ -127,6 +129,8 @@ int fscrypt_process_policy(struct file *filp,
127 ret = -EINVAL; 129 ret = -EINVAL;
128 } 130 }
129 131
132 inode_unlock(inode);
133
130 mnt_drop_write_file(filp); 134 mnt_drop_write_file(filp);
131 return ret; 135 return ret;
132} 136}
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index 79101651fe9e..42f9a0a0c4ca 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -137,7 +137,7 @@ Espan:
137bad_entry: 137bad_entry:
138 EXOFS_ERR( 138 EXOFS_ERR(
139 "ERROR [exofs_check_page]: bad entry in directory(0x%lx): %s - " 139 "ERROR [exofs_check_page]: bad entry in directory(0x%lx): %s - "
140 "offset=%lu, inode=0x%llu, rec_len=%d, name_len=%d\n", 140 "offset=%lu, inode=0x%llx, rec_len=%d, name_len=%d\n",
141 dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs, 141 dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
142 _LLU(le64_to_cpu(p->inode_no)), 142 _LLU(le64_to_cpu(p->inode_no)),
143 rec_len, p->name_len); 143 rec_len, p->name_len);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index d831e24dc885..41b8b44a391c 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -622,7 +622,7 @@ static int ext2_get_blocks(struct inode *inode,
622 u32 *bno, bool *new, bool *boundary, 622 u32 *bno, bool *new, bool *boundary,
623 int create) 623 int create)
624{ 624{
625 int err = -EIO; 625 int err;
626 int offsets[4]; 626 int offsets[4];
627 Indirect chain[4]; 627 Indirect chain[4];
628 Indirect *partial; 628 Indirect *partial;
@@ -639,7 +639,7 @@ static int ext2_get_blocks(struct inode *inode,
639 depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary); 639 depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
640 640
641 if (depth == 0) 641 if (depth == 0)
642 return (err); 642 return -EIO;
643 643
644 partial = ext2_get_branch(inode, depth, offsets, chain, &err); 644 partial = ext2_get_branch(inode, depth, offsets, chain, &err);
645 /* Simplest case - block found, no allocation needed */ 645 /* Simplest case - block found, no allocation needed */
@@ -761,7 +761,6 @@ static int ext2_get_blocks(struct inode *inode,
761 ext2_splice_branch(inode, iblock, partial, indirect_blks, count); 761 ext2_splice_branch(inode, iblock, partial, indirect_blks, count);
762 mutex_unlock(&ei->truncate_mutex); 762 mutex_unlock(&ei->truncate_mutex);
763got_it: 763got_it:
764 *bno = le32_to_cpu(chain[depth-1].key);
765 if (count > blocks_to_boundary) 764 if (count > blocks_to_boundary)
766 *boundary = true; 765 *boundary = true;
767 err = count; 766 err = count;
@@ -772,6 +771,8 @@ cleanup:
772 brelse(partial->bh); 771 brelse(partial->bh);
773 partial--; 772 partial--;
774 } 773 }
774 if (err > 0)
775 *bno = le32_to_cpu(chain[depth-1].key);
775 return err; 776 return err;
776} 777}
777 778
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 02ddec6d8a7d..fdb19543af1e 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -128,12 +128,12 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
128 node = rb_first(&sbi->system_blks); 128 node = rb_first(&sbi->system_blks);
129 while (node) { 129 while (node) {
130 entry = rb_entry(node, struct ext4_system_zone, node); 130 entry = rb_entry(node, struct ext4_system_zone, node);
131 printk("%s%llu-%llu", first ? "" : ", ", 131 printk(KERN_CONT "%s%llu-%llu", first ? "" : ", ",
132 entry->start_blk, entry->start_blk + entry->count - 1); 132 entry->start_blk, entry->start_blk + entry->count - 1);
133 first = 0; 133 first = 0;
134 node = rb_next(node); 134 node = rb_next(node);
135 } 135 }
136 printk("\n"); 136 printk(KERN_CONT "\n");
137} 137}
138 138
139int ext4_setup_system_zone(struct super_block *sb) 139int ext4_setup_system_zone(struct super_block *sb)
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h
index 3ef1df6ae9ec..1aba469f8220 100644
--- a/fs/ext4/mballoc.h
+++ b/fs/ext4/mballoc.h
@@ -27,16 +27,15 @@
27#ifdef CONFIG_EXT4_DEBUG 27#ifdef CONFIG_EXT4_DEBUG
28extern ushort ext4_mballoc_debug; 28extern ushort ext4_mballoc_debug;
29 29
30#define mb_debug(n, fmt, a...) \ 30#define mb_debug(n, fmt, ...) \
31 do { \ 31do { \
32 if ((n) <= ext4_mballoc_debug) { \ 32 if ((n) <= ext4_mballoc_debug) { \
33 printk(KERN_DEBUG "(%s, %d): %s: ", \ 33 printk(KERN_DEBUG "(%s, %d): %s: " fmt, \
34 __FILE__, __LINE__, __func__); \ 34 __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
35 printk(fmt, ## a); \ 35 } \
36 } \ 36} while (0)
37 } while (0)
38#else 37#else
39#define mb_debug(n, fmt, a...) no_printk(fmt, ## a) 38#define mb_debug(n, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
40#endif 39#endif
41 40
42#define EXT4_MB_HISTORY_ALLOC 1 /* allocation */ 41#define EXT4_MB_HISTORY_ALLOC 1 /* allocation */
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index f92f10d4f66a..104f8bfba718 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -577,12 +577,13 @@ static inline unsigned dx_node_limit(struct inode *dir)
577static void dx_show_index(char * label, struct dx_entry *entries) 577static void dx_show_index(char * label, struct dx_entry *entries)
578{ 578{
579 int i, n = dx_get_count (entries); 579 int i, n = dx_get_count (entries);
580 printk(KERN_DEBUG "%s index ", label); 580 printk(KERN_DEBUG "%s index", label);
581 for (i = 0; i < n; i++) { 581 for (i = 0; i < n; i++) {
582 printk("%x->%lu ", i ? dx_get_hash(entries + i) : 582 printk(KERN_CONT " %x->%lu",
583 0, (unsigned long)dx_get_block(entries + i)); 583 i ? dx_get_hash(entries + i) : 0,
584 (unsigned long)dx_get_block(entries + i));
584 } 585 }
585 printk("\n"); 586 printk(KERN_CONT "\n");
586} 587}
587 588
588struct stats 589struct stats
@@ -679,7 +680,7 @@ static struct stats dx_show_leaf(struct inode *dir,
679 } 680 }
680 de = ext4_next_entry(de, size); 681 de = ext4_next_entry(de, size);
681 } 682 }
682 printk("(%i)\n", names); 683 printk(KERN_CONT "(%i)\n", names);
683 return (struct stats) { names, space, 1 }; 684 return (struct stats) { names, space, 1 };
684} 685}
685 686
@@ -798,7 +799,7 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
798 q = entries + count - 1; 799 q = entries + count - 1;
799 while (p <= q) { 800 while (p <= q) {
800 m = p + (q - p) / 2; 801 m = p + (q - p) / 2;
801 dxtrace(printk(".")); 802 dxtrace(printk(KERN_CONT "."));
802 if (dx_get_hash(m) > hash) 803 if (dx_get_hash(m) > hash)
803 q = m - 1; 804 q = m - 1;
804 else 805 else
@@ -810,7 +811,7 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
810 at = entries; 811 at = entries;
811 while (n--) 812 while (n--)
812 { 813 {
813 dxtrace(printk(",")); 814 dxtrace(printk(KERN_CONT ","));
814 if (dx_get_hash(++at) > hash) 815 if (dx_get_hash(++at) > hash)
815 { 816 {
816 at--; 817 at--;
@@ -821,7 +822,8 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
821 } 822 }
822 823
823 at = p - 1; 824 at = p - 1;
824 dxtrace(printk(" %x->%u\n", at == entries ? 0 : dx_get_hash(at), 825 dxtrace(printk(KERN_CONT " %x->%u\n",
826 at == entries ? 0 : dx_get_hash(at),
825 dx_get_block(at))); 827 dx_get_block(at)));
826 frame->entries = entries; 828 frame->entries = entries;
827 frame->at = at; 829 frame->at = at;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6db81fbcbaa6..20da99da0a34 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -597,14 +597,15 @@ void __ext4_std_error(struct super_block *sb, const char *function,
597void __ext4_abort(struct super_block *sb, const char *function, 597void __ext4_abort(struct super_block *sb, const char *function,
598 unsigned int line, const char *fmt, ...) 598 unsigned int line, const char *fmt, ...)
599{ 599{
600 struct va_format vaf;
600 va_list args; 601 va_list args;
601 602
602 save_error_info(sb, function, line); 603 save_error_info(sb, function, line);
603 va_start(args, fmt); 604 va_start(args, fmt);
604 printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: ", sb->s_id, 605 vaf.fmt = fmt;
605 function, line); 606 vaf.va = &args;
606 vprintk(fmt, args); 607 printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: %pV\n",
607 printk("\n"); 608 sb->s_id, function, line, &vaf);
608 va_end(args); 609 va_end(args);
609 610
610 if ((sb->s_flags & MS_RDONLY) == 0) { 611 if ((sb->s_flags & MS_RDONLY) == 0) {
@@ -2715,12 +2716,12 @@ static void print_daily_error_info(unsigned long arg)
2715 es->s_first_error_func, 2716 es->s_first_error_func,
2716 le32_to_cpu(es->s_first_error_line)); 2717 le32_to_cpu(es->s_first_error_line));
2717 if (es->s_first_error_ino) 2718 if (es->s_first_error_ino)
2718 printk(": inode %u", 2719 printk(KERN_CONT ": inode %u",
2719 le32_to_cpu(es->s_first_error_ino)); 2720 le32_to_cpu(es->s_first_error_ino));
2720 if (es->s_first_error_block) 2721 if (es->s_first_error_block)
2721 printk(": block %llu", (unsigned long long) 2722 printk(KERN_CONT ": block %llu", (unsigned long long)
2722 le64_to_cpu(es->s_first_error_block)); 2723 le64_to_cpu(es->s_first_error_block));
2723 printk("\n"); 2724 printk(KERN_CONT "\n");
2724 } 2725 }
2725 if (es->s_last_error_time) { 2726 if (es->s_last_error_time) {
2726 printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d", 2727 printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d",
@@ -2729,12 +2730,12 @@ static void print_daily_error_info(unsigned long arg)
2729 es->s_last_error_func, 2730 es->s_last_error_func,
2730 le32_to_cpu(es->s_last_error_line)); 2731 le32_to_cpu(es->s_last_error_line));
2731 if (es->s_last_error_ino) 2732 if (es->s_last_error_ino)
2732 printk(": inode %u", 2733 printk(KERN_CONT ": inode %u",
2733 le32_to_cpu(es->s_last_error_ino)); 2734 le32_to_cpu(es->s_last_error_ino));
2734 if (es->s_last_error_block) 2735 if (es->s_last_error_block)
2735 printk(": block %llu", (unsigned long long) 2736 printk(KERN_CONT ": block %llu", (unsigned long long)
2736 le64_to_cpu(es->s_last_error_block)); 2737 le64_to_cpu(es->s_last_error_block));
2737 printk("\n"); 2738 printk(KERN_CONT "\n");
2738 } 2739 }
2739 mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ); /* Once a day */ 2740 mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ); /* Once a day */
2740} 2741}
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 73bcfd41f5f2..42145be5c6b4 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -223,14 +223,18 @@ static struct attribute *ext4_attrs[] = {
223EXT4_ATTR_FEATURE(lazy_itable_init); 223EXT4_ATTR_FEATURE(lazy_itable_init);
224EXT4_ATTR_FEATURE(batched_discard); 224EXT4_ATTR_FEATURE(batched_discard);
225EXT4_ATTR_FEATURE(meta_bg_resize); 225EXT4_ATTR_FEATURE(meta_bg_resize);
226#ifdef CONFIG_EXT4_FS_ENCRYPTION
226EXT4_ATTR_FEATURE(encryption); 227EXT4_ATTR_FEATURE(encryption);
228#endif
227EXT4_ATTR_FEATURE(metadata_csum_seed); 229EXT4_ATTR_FEATURE(metadata_csum_seed);
228 230
229static struct attribute *ext4_feat_attrs[] = { 231static struct attribute *ext4_feat_attrs[] = {
230 ATTR_LIST(lazy_itable_init), 232 ATTR_LIST(lazy_itable_init),
231 ATTR_LIST(batched_discard), 233 ATTR_LIST(batched_discard),
232 ATTR_LIST(meta_bg_resize), 234 ATTR_LIST(meta_bg_resize),
235#ifdef CONFIG_EXT4_FS_ENCRYPTION
233 ATTR_LIST(encryption), 236 ATTR_LIST(encryption),
237#endif
234 ATTR_LIST(metadata_csum_seed), 238 ATTR_LIST(metadata_csum_seed),
235 NULL, 239 NULL,
236}; 240};
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index c15d63389957..d77be9e9f535 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -61,18 +61,12 @@
61#include "acl.h" 61#include "acl.h"
62 62
63#ifdef EXT4_XATTR_DEBUG 63#ifdef EXT4_XATTR_DEBUG
64# define ea_idebug(inode, f...) do { \ 64# define ea_idebug(inode, fmt, ...) \
65 printk(KERN_DEBUG "inode %s:%lu: ", \ 65 printk(KERN_DEBUG "inode %s:%lu: " fmt "\n", \
66 inode->i_sb->s_id, inode->i_ino); \ 66 inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
67 printk(f); \ 67# define ea_bdebug(bh, fmt, ...) \
68 printk("\n"); \ 68 printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \
69 } while (0) 69 bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
70# define ea_bdebug(bh, f...) do { \
71 printk(KERN_DEBUG "block %pg:%lu: ", \
72 bh->b_bdev, (unsigned long) bh->b_blocknr); \
73 printk(f); \
74 printk("\n"); \
75 } while (0)
76#else 70#else
77# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__) 71# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
78# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) 72# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
@@ -241,7 +235,7 @@ __xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header,
241 int error = -EFSCORRUPTED; 235 int error = -EFSCORRUPTED;
242 236
243 if (((void *) header >= end) || 237 if (((void *) header >= end) ||
244 (header->h_magic != le32_to_cpu(EXT4_XATTR_MAGIC))) 238 (header->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC)))
245 goto errout; 239 goto errout;
246 error = ext4_xattr_check_names(entry, end, entry); 240 error = ext4_xattr_check_names(entry, end, entry);
247errout: 241errout:
diff --git a/fs/iomap.c b/fs/iomap.c
index 013d1d36fbbf..a8ee8c33ca78 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -433,8 +433,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
433 struct page *page = data; 433 struct page *page = data;
434 int ret; 434 int ret;
435 435
436 ret = __block_write_begin_int(page, pos & ~PAGE_MASK, length, 436 ret = __block_write_begin_int(page, pos, length, NULL, iomap);
437 NULL, iomap);
438 if (ret) 437 if (ret)
439 return ret; 438 return ret;
440 439
@@ -561,7 +560,7 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,
561 } 560 }
562 561
563 while (len > 0) { 562 while (len > 0) {
564 ret = iomap_apply(inode, start, len, 0, ops, &ctx, 563 ret = iomap_apply(inode, start, len, IOMAP_REPORT, ops, &ctx,
565 iomap_fiemap_actor); 564 iomap_fiemap_actor);
566 /* inode with no (attribute) mapping will give ENOENT */ 565 /* inode with no (attribute) mapping will give ENOENT */
567 if (ret == -ENOENT) 566 if (ret == -ENOENT)
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index ad0c745ebad7..871c8b392099 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -687,6 +687,11 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
687 pri_bh = NULL; 687 pri_bh = NULL;
688 688
689root_found: 689root_found:
690 /* We don't support read-write mounts */
691 if (!(s->s_flags & MS_RDONLY)) {
692 error = -EACCES;
693 goto out_freebh;
694 }
690 695
691 if (joliet_level && (pri == NULL || !opt.rock)) { 696 if (joliet_level && (pri == NULL || !opt.rock)) {
692 /* This is the case of Joliet with the norock mount flag. 697 /* This is the case of Joliet with the norock mount flag.
@@ -1501,9 +1506,6 @@ struct inode *__isofs_iget(struct super_block *sb,
1501static struct dentry *isofs_mount(struct file_system_type *fs_type, 1506static struct dentry *isofs_mount(struct file_system_type *fs_type,
1502 int flags, const char *dev_name, void *data) 1507 int flags, const char *dev_name, void *data)
1503{ 1508{
1504 /* We don't support read-write mounts */
1505 if (!(flags & MS_RDONLY))
1506 return ERR_PTR(-EACCES);
1507 return mount_bdev(fs_type, flags, dev_name, data, isofs_fill_super); 1509 return mount_bdev(fs_type, flags, dev_name, data, isofs_fill_super);
1508} 1510}
1509 1511
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 3d8246a9faa4..e1652665bd93 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1149,6 +1149,7 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
1149 JBUFFER_TRACE(jh, "file as BJ_Reserved"); 1149 JBUFFER_TRACE(jh, "file as BJ_Reserved");
1150 spin_lock(&journal->j_list_lock); 1150 spin_lock(&journal->j_list_lock);
1151 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved); 1151 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
1152 spin_unlock(&journal->j_list_lock);
1152 } else if (jh->b_transaction == journal->j_committing_transaction) { 1153 } else if (jh->b_transaction == journal->j_committing_transaction) {
1153 /* first access by this transaction */ 1154 /* first access by this transaction */
1154 jh->b_modified = 0; 1155 jh->b_modified = 0;
@@ -1156,8 +1157,8 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
1156 JBUFFER_TRACE(jh, "set next transaction"); 1157 JBUFFER_TRACE(jh, "set next transaction");
1157 spin_lock(&journal->j_list_lock); 1158 spin_lock(&journal->j_list_lock);
1158 jh->b_next_transaction = transaction; 1159 jh->b_next_transaction = transaction;
1160 spin_unlock(&journal->j_list_lock);
1159 } 1161 }
1160 spin_unlock(&journal->j_list_lock);
1161 jbd_unlock_bh_state(bh); 1162 jbd_unlock_bh_state(bh);
1162 1163
1163 /* 1164 /*
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 2bcb86e6e6ca..78219d5644e9 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -911,6 +911,7 @@ const struct file_operations kernfs_file_fops = {
911 .open = kernfs_fop_open, 911 .open = kernfs_fop_open,
912 .release = kernfs_fop_release, 912 .release = kernfs_fop_release,
913 .poll = kernfs_fop_poll, 913 .poll = kernfs_fop_poll,
914 .fsync = noop_fsync,
914}; 915};
915 916
916/** 917/**
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 217847679f0e..2905479f214a 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -344,9 +344,10 @@ static void bl_write_cleanup(struct work_struct *work)
344 u64 start = hdr->args.offset & (loff_t)PAGE_MASK; 344 u64 start = hdr->args.offset & (loff_t)PAGE_MASK;
345 u64 end = (hdr->args.offset + hdr->args.count + 345 u64 end = (hdr->args.offset + hdr->args.count +
346 PAGE_SIZE - 1) & (loff_t)PAGE_MASK; 346 PAGE_SIZE - 1) & (loff_t)PAGE_MASK;
347 u64 lwb = hdr->args.offset + hdr->args.count;
347 348
348 ext_tree_mark_written(bl, start >> SECTOR_SHIFT, 349 ext_tree_mark_written(bl, start >> SECTOR_SHIFT,
349 (end - start) >> SECTOR_SHIFT, end); 350 (end - start) >> SECTOR_SHIFT, lwb);
350 } 351 }
351 352
352 pnfs_ld_write_done(hdr); 353 pnfs_ld_write_done(hdr);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ad917bd72b38..7897826d7c51 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1545,7 +1545,7 @@ static int update_open_stateid(struct nfs4_state *state,
1545 struct nfs_client *clp = server->nfs_client; 1545 struct nfs_client *clp = server->nfs_client;
1546 struct nfs_inode *nfsi = NFS_I(state->inode); 1546 struct nfs_inode *nfsi = NFS_I(state->inode);
1547 struct nfs_delegation *deleg_cur; 1547 struct nfs_delegation *deleg_cur;
1548 nfs4_stateid freeme = {0}; 1548 nfs4_stateid freeme = { };
1549 int ret = 0; 1549 int ret = 0;
1550 1550
1551 fmode &= (FMODE_READ|FMODE_WRITE); 1551 fmode &= (FMODE_READ|FMODE_WRITE);
diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c
index 1e8fe844e69f..5355efba4bc8 100644
--- a/fs/orangefs/dcache.c
+++ b/fs/orangefs/dcache.c
@@ -73,7 +73,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
73 } 73 }
74 } 74 }
75 75
76 dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 76 orangefs_set_timeout(dentry);
77 ret = 1; 77 ret = 1;
78out_release_op: 78out_release_op:
79 op_release(new_op); 79 op_release(new_op);
@@ -94,8 +94,9 @@ out_drop:
94static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags) 94static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags)
95{ 95{
96 int ret; 96 int ret;
97 unsigned long time = (unsigned long) dentry->d_fsdata;
97 98
98 if (time_before(jiffies, dentry->d_time)) 99 if (time_before(jiffies, time))
99 return 1; 100 return 1;
100 101
101 if (flags & LOOKUP_RCU) 102 if (flags & LOOKUP_RCU)
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 66ea0cc37b18..02cc6139ec90 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -621,9 +621,9 @@ static int orangefs_file_release(struct inode *inode, struct file *file)
621 * readahead cache (if any); this forces an expensive refresh of 621 * readahead cache (if any); this forces an expensive refresh of
622 * data for the next caller of mmap (or 'get_block' accesses) 622 * data for the next caller of mmap (or 'get_block' accesses)
623 */ 623 */
624 if (file->f_path.dentry->d_inode && 624 if (file_inode(file) &&
625 file->f_path.dentry->d_inode->i_mapping && 625 file_inode(file)->i_mapping &&
626 mapping_nrpages(&file->f_path.dentry->d_inode->i_data)) { 626 mapping_nrpages(&file_inode(file)->i_data)) {
627 if (orangefs_features & ORANGEFS_FEATURE_READAHEAD) { 627 if (orangefs_features & ORANGEFS_FEATURE_READAHEAD) {
628 gossip_debug(GOSSIP_INODE_DEBUG, 628 gossip_debug(GOSSIP_INODE_DEBUG,
629 "calling flush_racache on %pU\n", 629 "calling flush_racache on %pU\n",
@@ -632,7 +632,7 @@ static int orangefs_file_release(struct inode *inode, struct file *file)
632 gossip_debug(GOSSIP_INODE_DEBUG, 632 gossip_debug(GOSSIP_INODE_DEBUG,
633 "flush_racache finished\n"); 633 "flush_racache finished\n");
634 } 634 }
635 truncate_inode_pages(file->f_path.dentry->d_inode->i_mapping, 635 truncate_inode_pages(file_inode(file)->i_mapping,
636 0); 636 0);
637 } 637 }
638 return 0; 638 return 0;
@@ -648,7 +648,7 @@ static int orangefs_fsync(struct file *file,
648{ 648{
649 int ret = -EINVAL; 649 int ret = -EINVAL;
650 struct orangefs_inode_s *orangefs_inode = 650 struct orangefs_inode_s *orangefs_inode =
651 ORANGEFS_I(file->f_path.dentry->d_inode); 651 ORANGEFS_I(file_inode(file));
652 struct orangefs_kernel_op_s *new_op = NULL; 652 struct orangefs_kernel_op_s *new_op = NULL;
653 653
654 /* required call */ 654 /* required call */
@@ -661,7 +661,7 @@ static int orangefs_fsync(struct file *file,
661 661
662 ret = service_operation(new_op, 662 ret = service_operation(new_op,
663 "orangefs_fsync", 663 "orangefs_fsync",
664 get_interruptible_flag(file->f_path.dentry->d_inode)); 664 get_interruptible_flag(file_inode(file)));
665 665
666 gossip_debug(GOSSIP_FILE_DEBUG, 666 gossip_debug(GOSSIP_FILE_DEBUG,
667 "orangefs_fsync got return value of %d\n", 667 "orangefs_fsync got return value of %d\n",
@@ -669,7 +669,7 @@ static int orangefs_fsync(struct file *file,
669 669
670 op_release(new_op); 670 op_release(new_op);
671 671
672 orangefs_flush_inode(file->f_path.dentry->d_inode); 672 orangefs_flush_inode(file_inode(file));
673 return ret; 673 return ret;
674} 674}
675 675
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index d15d3d2dba62..a290ff6ec756 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -72,7 +72,7 @@ static int orangefs_create(struct inode *dir,
72 72
73 d_instantiate(dentry, inode); 73 d_instantiate(dentry, inode);
74 unlock_new_inode(inode); 74 unlock_new_inode(inode);
75 dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 75 orangefs_set_timeout(dentry);
76 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 76 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
77 77
78 gossip_debug(GOSSIP_NAME_DEBUG, 78 gossip_debug(GOSSIP_NAME_DEBUG,
@@ -183,7 +183,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
183 goto out; 183 goto out;
184 } 184 }
185 185
186 dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 186 orangefs_set_timeout(dentry);
187 187
188 inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); 188 inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
189 if (IS_ERR(inode)) { 189 if (IS_ERR(inode)) {
@@ -322,7 +322,7 @@ static int orangefs_symlink(struct inode *dir,
322 322
323 d_instantiate(dentry, inode); 323 d_instantiate(dentry, inode);
324 unlock_new_inode(inode); 324 unlock_new_inode(inode);
325 dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 325 orangefs_set_timeout(dentry);
326 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 326 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
327 327
328 gossip_debug(GOSSIP_NAME_DEBUG, 328 gossip_debug(GOSSIP_NAME_DEBUG,
@@ -386,7 +386,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
386 386
387 d_instantiate(dentry, inode); 387 d_instantiate(dentry, inode);
388 unlock_new_inode(inode); 388 unlock_new_inode(inode);
389 dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 389 orangefs_set_timeout(dentry);
390 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 390 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
391 391
392 gossip_debug(GOSSIP_NAME_DEBUG, 392 gossip_debug(GOSSIP_NAME_DEBUG,
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 0a82048f3aaf..3bf803d732c5 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -580,4 +580,11 @@ static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size)
580#endif 580#endif
581} 581}
582 582
583static inline void orangefs_set_timeout(struct dentry *dentry)
584{
585 unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
586
587 dentry->d_fsdata = (void *) time;
588}
589
583#endif /* __ORANGEFSKERNEL_H */ 590#endif /* __ORANGEFSKERNEL_H */
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 89600fd5963d..81818adb8e9e 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -412,10 +412,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
412 mm = get_task_mm(task); 412 mm = get_task_mm(task);
413 if (mm) { 413 if (mm) {
414 vsize = task_vsize(mm); 414 vsize = task_vsize(mm);
415 if (permitted) { 415 /*
416 eip = KSTK_EIP(task); 416 * esp and eip are intentionally zeroed out. There is no
417 esp = KSTK_ESP(task); 417 * non-racy way to read them without freezing the task.
418 } 418 * Programs that need reliable values can use ptrace(2).
419 */
419 } 420 }
420 421
421 get_task_comm(tcomm, task); 422 get_task_comm(tcomm, task);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8e654468ab67..ca651ac00660 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -252,7 +252,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
252 * Inherently racy -- command line shares address space 252 * Inherently racy -- command line shares address space
253 * with code and data. 253 * with code and data.
254 */ 254 */
255 rv = access_remote_vm(mm, arg_end - 1, &c, 1, FOLL_FORCE); 255 rv = access_remote_vm(mm, arg_end - 1, &c, 1, 0);
256 if (rv <= 0) 256 if (rv <= 0)
257 goto out_free_page; 257 goto out_free_page;
258 258
@@ -270,8 +270,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
270 int nr_read; 270 int nr_read;
271 271
272 _count = min3(count, len, PAGE_SIZE); 272 _count = min3(count, len, PAGE_SIZE);
273 nr_read = access_remote_vm(mm, p, page, _count, 273 nr_read = access_remote_vm(mm, p, page, _count, 0);
274 FOLL_FORCE);
275 if (nr_read < 0) 274 if (nr_read < 0)
276 rv = nr_read; 275 rv = nr_read;
277 if (nr_read <= 0) 276 if (nr_read <= 0)
@@ -306,8 +305,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
306 bool final; 305 bool final;
307 306
308 _count = min3(count, len, PAGE_SIZE); 307 _count = min3(count, len, PAGE_SIZE);
309 nr_read = access_remote_vm(mm, p, page, _count, 308 nr_read = access_remote_vm(mm, p, page, _count, 0);
310 FOLL_FORCE);
311 if (nr_read < 0) 309 if (nr_read < 0)
312 rv = nr_read; 310 rv = nr_read;
313 if (nr_read <= 0) 311 if (nr_read <= 0)
@@ -356,8 +354,7 @@ skip_argv:
356 bool final; 354 bool final;
357 355
358 _count = min3(count, len, PAGE_SIZE); 356 _count = min3(count, len, PAGE_SIZE);
359 nr_read = access_remote_vm(mm, p, page, _count, 357 nr_read = access_remote_vm(mm, p, page, _count, 0);
360 FOLL_FORCE);
361 if (nr_read < 0) 358 if (nr_read < 0)
362 rv = nr_read; 359 rv = nr_read;
363 if (nr_read <= 0) 360 if (nr_read <= 0)
@@ -835,7 +832,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
835 unsigned long addr = *ppos; 832 unsigned long addr = *ppos;
836 ssize_t copied; 833 ssize_t copied;
837 char *page; 834 char *page;
838 unsigned int flags = FOLL_FORCE; 835 unsigned int flags;
839 836
840 if (!mm) 837 if (!mm)
841 return 0; 838 return 0;
@@ -848,6 +845,8 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
848 if (!atomic_inc_not_zero(&mm->mm_users)) 845 if (!atomic_inc_not_zero(&mm->mm_users))
849 goto free; 846 goto free;
850 847
848 /* Maybe we should limit FOLL_FORCE to actual ptrace users? */
849 flags = FOLL_FORCE;
851 if (write) 850 if (write)
852 flags |= FOLL_WRITE; 851 flags |= FOLL_WRITE;
853 852
@@ -971,8 +970,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
971 max_len = min_t(size_t, PAGE_SIZE, count); 970 max_len = min_t(size_t, PAGE_SIZE, count);
972 this_len = min(max_len, this_len); 971 this_len = min(max_len, this_len);
973 972
974 retval = access_remote_vm(mm, (env_start + src), 973 retval = access_remote_vm(mm, (env_start + src), page, this_len, 0);
975 page, this_len, FOLL_FORCE);
976 974
977 if (retval <= 0) { 975 if (retval <= 0) {
978 ret = retval; 976 ret = retval;
@@ -1014,6 +1012,9 @@ static ssize_t auxv_read(struct file *file, char __user *buf,
1014{ 1012{
1015 struct mm_struct *mm = file->private_data; 1013 struct mm_struct *mm = file->private_data;
1016 unsigned int nwords = 0; 1014 unsigned int nwords = 0;
1015
1016 if (!mm)
1017 return 0;
1017 do { 1018 do {
1018 nwords += 2; 1019 nwords += 2;
1019 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */ 1020 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 6909582ce5e5..35b92d81692f 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -266,24 +266,15 @@ static int do_maps_open(struct inode *inode, struct file *file,
266 * /proc/PID/maps that is the stack of the main task. 266 * /proc/PID/maps that is the stack of the main task.
267 */ 267 */
268static int is_stack(struct proc_maps_private *priv, 268static int is_stack(struct proc_maps_private *priv,
269 struct vm_area_struct *vma, int is_pid) 269 struct vm_area_struct *vma)
270{ 270{
271 int stack = 0; 271 /*
272 272 * We make no effort to guess what a given thread considers to be
273 if (is_pid) { 273 * its "stack". It's not even well-defined for programs written
274 stack = vma->vm_start <= vma->vm_mm->start_stack && 274 * languages like Go.
275 vma->vm_end >= vma->vm_mm->start_stack; 275 */
276 } else { 276 return vma->vm_start <= vma->vm_mm->start_stack &&
277 struct inode *inode = priv->inode; 277 vma->vm_end >= vma->vm_mm->start_stack;
278 struct task_struct *task;
279
280 rcu_read_lock();
281 task = pid_task(proc_pid(inode), PIDTYPE_PID);
282 if (task)
283 stack = vma_is_stack_for_task(vma, task);
284 rcu_read_unlock();
285 }
286 return stack;
287} 278}
288 279
289static void 280static void
@@ -354,7 +345,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
354 goto done; 345 goto done;
355 } 346 }
356 347
357 if (is_stack(priv, vma, is_pid)) 348 if (is_stack(priv, vma))
358 name = "[stack]"; 349 name = "[stack]";
359 } 350 }
360 351
@@ -1669,7 +1660,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1669 seq_file_path(m, file, "\n\t= "); 1660 seq_file_path(m, file, "\n\t= ");
1670 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1661 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
1671 seq_puts(m, " heap"); 1662 seq_puts(m, " heap");
1672 } else if (is_stack(proc_priv, vma, is_pid)) { 1663 } else if (is_stack(proc_priv, vma)) {
1673 seq_puts(m, " stack"); 1664 seq_puts(m, " stack");
1674 } 1665 }
1675 1666
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index faacb0c0d857..37175621e890 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -124,25 +124,17 @@ unsigned long task_statm(struct mm_struct *mm,
124} 124}
125 125
126static int is_stack(struct proc_maps_private *priv, 126static int is_stack(struct proc_maps_private *priv,
127 struct vm_area_struct *vma, int is_pid) 127 struct vm_area_struct *vma)
128{ 128{
129 struct mm_struct *mm = vma->vm_mm; 129 struct mm_struct *mm = vma->vm_mm;
130 int stack = 0; 130
131 131 /*
132 if (is_pid) { 132 * We make no effort to guess what a given thread considers to be
133 stack = vma->vm_start <= mm->start_stack && 133 * its "stack". It's not even well-defined for programs written
134 vma->vm_end >= mm->start_stack; 134 * languages like Go.
135 } else { 135 */
136 struct inode *inode = priv->inode; 136 return vma->vm_start <= mm->start_stack &&
137 struct task_struct *task; 137 vma->vm_end >= mm->start_stack;
138
139 rcu_read_lock();
140 task = pid_task(proc_pid(inode), PIDTYPE_PID);
141 if (task)
142 stack = vma_is_stack_for_task(vma, task);
143 rcu_read_unlock();
144 }
145 return stack;
146} 138}
147 139
148/* 140/*
@@ -184,7 +176,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
184 if (file) { 176 if (file) {
185 seq_pad(m, ' '); 177 seq_pad(m, ' ');
186 seq_file_path(m, file, ""); 178 seq_file_path(m, file, "");
187 } else if (mm && is_stack(priv, vma, is_pid)) { 179 } else if (mm && is_stack(priv, vma)) {
188 seq_pad(m, ' '); 180 seq_pad(m, ' ');
189 seq_printf(m, "[stack]"); 181 seq_printf(m, "[stack]");
190 } 182 }
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index c8f60df2733e..ca16c5d7bab1 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -439,7 +439,7 @@ static unsigned int vfs_dent_type(uint8_t type)
439 */ 439 */
440static int ubifs_readdir(struct file *file, struct dir_context *ctx) 440static int ubifs_readdir(struct file *file, struct dir_context *ctx)
441{ 441{
442 int err; 442 int err = 0;
443 struct qstr nm; 443 struct qstr nm;
444 union ubifs_key key; 444 union ubifs_key key;
445 struct ubifs_dent_node *dent; 445 struct ubifs_dent_node *dent;
@@ -541,14 +541,20 @@ out:
541 kfree(file->private_data); 541 kfree(file->private_data);
542 file->private_data = NULL; 542 file->private_data = NULL;
543 543
544 if (err != -ENOENT) { 544 if (err != -ENOENT)
545 ubifs_err(c, "cannot find next direntry, error %d", err); 545 ubifs_err(c, "cannot find next direntry, error %d", err);
546 return err; 546 else
547 } 547 /*
548 * -ENOENT is a non-fatal error in this context, the TNC uses
549 * it to indicate that the cursor moved past the current directory
550 * and readdir() has to stop.
551 */
552 err = 0;
553
548 554
549 /* 2 is a special value indicating that there are no more direntries */ 555 /* 2 is a special value indicating that there are no more direntries */
550 ctx->pos = 2; 556 ctx->pos = 2;
551 return 0; 557 return err;
552} 558}
553 559
554/* Free saved readdir() state when the directory is closed */ 560/* Free saved readdir() state when the directory is closed */
@@ -1060,9 +1066,9 @@ static void unlock_4_inodes(struct inode *inode1, struct inode *inode2,
1060 mutex_unlock(&ubifs_inode(inode1)->ui_mutex); 1066 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
1061} 1067}
1062 1068
1063static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry, 1069static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
1064 struct inode *new_dir, struct dentry *new_dentry, 1070 struct inode *new_dir, struct dentry *new_dentry,
1065 unsigned int flags) 1071 unsigned int flags)
1066{ 1072{
1067 struct ubifs_info *c = old_dir->i_sb->s_fs_info; 1073 struct ubifs_info *c = old_dir->i_sb->s_fs_info;
1068 struct inode *old_inode = d_inode(old_dentry); 1074 struct inode *old_inode = d_inode(old_dentry);
@@ -1323,7 +1329,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
1323 return err; 1329 return err;
1324} 1330}
1325 1331
1326static int ubifs_rename2(struct inode *old_dir, struct dentry *old_dentry, 1332static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1327 struct inode *new_dir, struct dentry *new_dentry, 1333 struct inode *new_dir, struct dentry *new_dentry,
1328 unsigned int flags) 1334 unsigned int flags)
1329{ 1335{
@@ -1336,7 +1342,7 @@ static int ubifs_rename2(struct inode *old_dir, struct dentry *old_dentry,
1336 if (flags & RENAME_EXCHANGE) 1342 if (flags & RENAME_EXCHANGE)
1337 return ubifs_xrename(old_dir, old_dentry, new_dir, new_dentry); 1343 return ubifs_xrename(old_dir, old_dentry, new_dir, new_dentry);
1338 1344
1339 return ubifs_rename(old_dir, old_dentry, new_dir, new_dentry, flags); 1345 return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
1340} 1346}
1341 1347
1342int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry, 1348int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -1387,7 +1393,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
1387 .mkdir = ubifs_mkdir, 1393 .mkdir = ubifs_mkdir,
1388 .rmdir = ubifs_rmdir, 1394 .rmdir = ubifs_rmdir,
1389 .mknod = ubifs_mknod, 1395 .mknod = ubifs_mknod,
1390 .rename = ubifs_rename2, 1396 .rename = ubifs_rename,
1391 .setattr = ubifs_setattr, 1397 .setattr = ubifs_setattr,
1392 .getattr = ubifs_getattr, 1398 .getattr = ubifs_getattr,
1393 .listxattr = ubifs_listxattr, 1399 .listxattr = ubifs_listxattr,
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 6c2f4d41ed73..d9f9615bfd71 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -172,6 +172,7 @@ out_cancel:
172 host_ui->xattr_cnt -= 1; 172 host_ui->xattr_cnt -= 1;
173 host_ui->xattr_size -= CALC_DENT_SIZE(nm->len); 173 host_ui->xattr_size -= CALC_DENT_SIZE(nm->len);
174 host_ui->xattr_size -= CALC_XATTR_BYTES(size); 174 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
175 host_ui->xattr_names -= nm->len;
175 mutex_unlock(&host_ui->ui_mutex); 176 mutex_unlock(&host_ui->ui_mutex);
176out_free: 177out_free:
177 make_bad_inode(inode); 178 make_bad_inode(inode);
@@ -478,6 +479,7 @@ out_cancel:
478 host_ui->xattr_cnt += 1; 479 host_ui->xattr_cnt += 1;
479 host_ui->xattr_size += CALC_DENT_SIZE(nm->len); 480 host_ui->xattr_size += CALC_DENT_SIZE(nm->len);
480 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); 481 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
482 host_ui->xattr_names += nm->len;
481 mutex_unlock(&host_ui->ui_mutex); 483 mutex_unlock(&host_ui->ui_mutex);
482 ubifs_release_budget(c, &req); 484 ubifs_release_budget(c, &req);
483 make_bad_inode(inode); 485 make_bad_inode(inode);
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c27344cf38e1..c6eb21940783 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3974,9 +3974,6 @@ xfs_bmap_remap_alloc(
3974 * allocating, so skip that check by pretending to be freeing. 3974 * allocating, so skip that check by pretending to be freeing.
3975 */ 3975 */
3976 error = xfs_alloc_fix_freelist(&args, XFS_ALLOC_FLAG_FREEING); 3976 error = xfs_alloc_fix_freelist(&args, XFS_ALLOC_FLAG_FREEING);
3977 if (error)
3978 goto error0;
3979error0:
3980 xfs_perag_put(args.pag); 3977 xfs_perag_put(args.pag);
3981 if (error) 3978 if (error)
3982 trace_xfs_bmap_remap_alloc_error(ap->ip, error, _RET_IP_); 3979 trace_xfs_bmap_remap_alloc_error(ap->ip, error, _RET_IP_);
@@ -3999,6 +3996,39 @@ xfs_bmap_alloc(
3999 return xfs_bmap_btalloc(ap); 3996 return xfs_bmap_btalloc(ap);
4000} 3997}
4001 3998
3999/* Trim extent to fit a logical block range. */
4000void
4001xfs_trim_extent(
4002 struct xfs_bmbt_irec *irec,
4003 xfs_fileoff_t bno,
4004 xfs_filblks_t len)
4005{
4006 xfs_fileoff_t distance;
4007 xfs_fileoff_t end = bno + len;
4008
4009 if (irec->br_startoff + irec->br_blockcount <= bno ||
4010 irec->br_startoff >= end) {
4011 irec->br_blockcount = 0;
4012 return;
4013 }
4014
4015 if (irec->br_startoff < bno) {
4016 distance = bno - irec->br_startoff;
4017 if (isnullstartblock(irec->br_startblock))
4018 irec->br_startblock = DELAYSTARTBLOCK;
4019 if (irec->br_startblock != DELAYSTARTBLOCK &&
4020 irec->br_startblock != HOLESTARTBLOCK)
4021 irec->br_startblock += distance;
4022 irec->br_startoff += distance;
4023 irec->br_blockcount -= distance;
4024 }
4025
4026 if (end < irec->br_startoff + irec->br_blockcount) {
4027 distance = irec->br_startoff + irec->br_blockcount - end;
4028 irec->br_blockcount -= distance;
4029 }
4030}
4031
4002/* 4032/*
4003 * Trim the returned map to the required bounds 4033 * Trim the returned map to the required bounds
4004 */ 4034 */
@@ -4829,6 +4859,219 @@ xfs_bmap_split_indlen(
4829 return stolen; 4859 return stolen;
4830} 4860}
4831 4861
4862int
4863xfs_bmap_del_extent_delay(
4864 struct xfs_inode *ip,
4865 int whichfork,
4866 xfs_extnum_t *idx,
4867 struct xfs_bmbt_irec *got,
4868 struct xfs_bmbt_irec *del)
4869{
4870 struct xfs_mount *mp = ip->i_mount;
4871 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
4872 struct xfs_bmbt_irec new;
4873 int64_t da_old, da_new, da_diff = 0;
4874 xfs_fileoff_t del_endoff, got_endoff;
4875 xfs_filblks_t got_indlen, new_indlen, stolen;
4876 int error = 0, state = 0;
4877 bool isrt;
4878
4879 XFS_STATS_INC(mp, xs_del_exlist);
4880
4881 isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
4882 del_endoff = del->br_startoff + del->br_blockcount;
4883 got_endoff = got->br_startoff + got->br_blockcount;
4884 da_old = startblockval(got->br_startblock);
4885 da_new = 0;
4886
4887 ASSERT(*idx >= 0);
4888 ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
4889 ASSERT(del->br_blockcount > 0);
4890 ASSERT(got->br_startoff <= del->br_startoff);
4891 ASSERT(got_endoff >= del_endoff);
4892
4893 if (isrt) {
4894 int64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount);
4895
4896 do_div(rtexts, mp->m_sb.sb_rextsize);
4897 xfs_mod_frextents(mp, rtexts);
4898 }
4899
4900 /*
4901 * Update the inode delalloc counter now and wait to update the
4902 * sb counters as we might have to borrow some blocks for the
4903 * indirect block accounting.
4904 */
4905 xfs_trans_reserve_quota_nblks(NULL, ip, -((long)del->br_blockcount), 0,
4906 isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
4907 ip->i_delayed_blks -= del->br_blockcount;
4908
4909 if (whichfork == XFS_COW_FORK)
4910 state |= BMAP_COWFORK;
4911
4912 if (got->br_startoff == del->br_startoff)
4913 state |= BMAP_LEFT_CONTIG;
4914 if (got_endoff == del_endoff)
4915 state |= BMAP_RIGHT_CONTIG;
4916
4917 switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) {
4918 case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
4919 /*
4920 * Matches the whole extent. Delete the entry.
4921 */
4922 xfs_iext_remove(ip, *idx, 1, state);
4923 --*idx;
4924 break;
4925 case BMAP_LEFT_CONTIG:
4926 /*
4927 * Deleting the first part of the extent.
4928 */
4929 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
4930 got->br_startoff = del_endoff;
4931 got->br_blockcount -= del->br_blockcount;
4932 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip,
4933 got->br_blockcount), da_old);
4934 got->br_startblock = nullstartblock((int)da_new);
4935 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
4936 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
4937 break;
4938 case BMAP_RIGHT_CONTIG:
4939 /*
4940 * Deleting the last part of the extent.
4941 */
4942 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
4943 got->br_blockcount = got->br_blockcount - del->br_blockcount;
4944 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip,
4945 got->br_blockcount), da_old);
4946 got->br_startblock = nullstartblock((int)da_new);
4947 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
4948 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
4949 break;
4950 case 0:
4951 /*
4952 * Deleting the middle of the extent.
4953 *
4954 * Distribute the original indlen reservation across the two new
4955 * extents. Steal blocks from the deleted extent if necessary.
4956 * Stealing blocks simply fudges the fdblocks accounting below.
4957 * Warn if either of the new indlen reservations is zero as this
4958 * can lead to delalloc problems.
4959 */
4960 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
4961
4962 got->br_blockcount = del->br_startoff - got->br_startoff;
4963 got_indlen = xfs_bmap_worst_indlen(ip, got->br_blockcount);
4964
4965 new.br_blockcount = got_endoff - del_endoff;
4966 new_indlen = xfs_bmap_worst_indlen(ip, new.br_blockcount);
4967
4968 WARN_ON_ONCE(!got_indlen || !new_indlen);
4969 stolen = xfs_bmap_split_indlen(da_old, &got_indlen, &new_indlen,
4970 del->br_blockcount);
4971
4972 got->br_startblock = nullstartblock((int)got_indlen);
4973 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
4974 trace_xfs_bmap_post_update(ip, *idx, 0, _THIS_IP_);
4975
4976 new.br_startoff = del_endoff;
4977 new.br_state = got->br_state;
4978 new.br_startblock = nullstartblock((int)new_indlen);
4979
4980 ++*idx;
4981 xfs_iext_insert(ip, *idx, 1, &new, state);
4982
4983 da_new = got_indlen + new_indlen - stolen;
4984 del->br_blockcount -= stolen;
4985 break;
4986 }
4987
4988 ASSERT(da_old >= da_new);
4989 da_diff = da_old - da_new;
4990 if (!isrt)
4991 da_diff += del->br_blockcount;
4992 if (da_diff)
4993 xfs_mod_fdblocks(mp, da_diff, false);
4994 return error;
4995}
4996
4997void
4998xfs_bmap_del_extent_cow(
4999 struct xfs_inode *ip,
5000 xfs_extnum_t *idx,
5001 struct xfs_bmbt_irec *got,
5002 struct xfs_bmbt_irec *del)
5003{
5004 struct xfs_mount *mp = ip->i_mount;
5005 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
5006 struct xfs_bmbt_irec new;
5007 xfs_fileoff_t del_endoff, got_endoff;
5008 int state = BMAP_COWFORK;
5009
5010 XFS_STATS_INC(mp, xs_del_exlist);
5011
5012 del_endoff = del->br_startoff + del->br_blockcount;
5013 got_endoff = got->br_startoff + got->br_blockcount;
5014
5015 ASSERT(*idx >= 0);
5016 ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
5017 ASSERT(del->br_blockcount > 0);
5018 ASSERT(got->br_startoff <= del->br_startoff);
5019 ASSERT(got_endoff >= del_endoff);
5020 ASSERT(!isnullstartblock(got->br_startblock));
5021
5022 if (got->br_startoff == del->br_startoff)
5023 state |= BMAP_LEFT_CONTIG;
5024 if (got_endoff == del_endoff)
5025 state |= BMAP_RIGHT_CONTIG;
5026
5027 switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) {
5028 case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
5029 /*
5030 * Matches the whole extent. Delete the entry.
5031 */
5032 xfs_iext_remove(ip, *idx, 1, state);
5033 --*idx;
5034 break;
5035 case BMAP_LEFT_CONTIG:
5036 /*
5037 * Deleting the first part of the extent.
5038 */
5039 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
5040 got->br_startoff = del_endoff;
5041 got->br_blockcount -= del->br_blockcount;
5042 got->br_startblock = del->br_startblock + del->br_blockcount;
5043 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
5044 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
5045 break;
5046 case BMAP_RIGHT_CONTIG:
5047 /*
5048 * Deleting the last part of the extent.
5049 */
5050 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
5051 got->br_blockcount -= del->br_blockcount;
5052 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
5053 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
5054 break;
5055 case 0:
5056 /*
5057 * Deleting the middle of the extent.
5058 */
5059 trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_);
5060 got->br_blockcount = del->br_startoff - got->br_startoff;
5061 xfs_bmbt_set_all(xfs_iext_get_ext(ifp, *idx), got);
5062 trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_);
5063
5064 new.br_startoff = del_endoff;
5065 new.br_blockcount = got_endoff - del_endoff;
5066 new.br_state = got->br_state;
5067 new.br_startblock = del->br_startblock + del->br_blockcount;
5068
5069 ++*idx;
5070 xfs_iext_insert(ip, *idx, 1, &new, state);
5071 break;
5072 }
5073}
5074
4832/* 5075/*
4833 * Called by xfs_bmapi to update file extent records and the btree 5076 * Called by xfs_bmapi to update file extent records and the btree
4834 * after removing space (or undoing a delayed allocation). 5077 * after removing space (or undoing a delayed allocation).
@@ -5171,175 +5414,6 @@ done:
5171 return error; 5414 return error;
5172} 5415}
5173 5416
5174/* Remove an extent from the CoW fork. Similar to xfs_bmap_del_extent. */
5175int
5176xfs_bunmapi_cow(
5177 struct xfs_inode *ip,
5178 struct xfs_bmbt_irec *del)
5179{
5180 xfs_filblks_t da_new;
5181 xfs_filblks_t da_old;
5182 xfs_fsblock_t del_endblock = 0;
5183 xfs_fileoff_t del_endoff;
5184 int delay;
5185 struct xfs_bmbt_rec_host *ep;
5186 int error;
5187 struct xfs_bmbt_irec got;
5188 xfs_fileoff_t got_endoff;
5189 struct xfs_ifork *ifp;
5190 struct xfs_mount *mp;
5191 xfs_filblks_t nblks;
5192 struct xfs_bmbt_irec new;
5193 /* REFERENCED */
5194 uint qfield;
5195 xfs_filblks_t temp;
5196 xfs_filblks_t temp2;
5197 int state = BMAP_COWFORK;
5198 int eof;
5199 xfs_extnum_t eidx;
5200
5201 mp = ip->i_mount;
5202 XFS_STATS_INC(mp, xs_del_exlist);
5203
5204 ep = xfs_bmap_search_extents(ip, del->br_startoff, XFS_COW_FORK, &eof,
5205 &eidx, &got, &new);
5206
5207 ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); ifp = ifp;
5208 ASSERT((eidx >= 0) && (eidx < ifp->if_bytes /
5209 (uint)sizeof(xfs_bmbt_rec_t)));
5210 ASSERT(del->br_blockcount > 0);
5211 ASSERT(got.br_startoff <= del->br_startoff);
5212 del_endoff = del->br_startoff + del->br_blockcount;
5213 got_endoff = got.br_startoff + got.br_blockcount;
5214 ASSERT(got_endoff >= del_endoff);
5215 delay = isnullstartblock(got.br_startblock);
5216 ASSERT(isnullstartblock(del->br_startblock) == delay);
5217 qfield = 0;
5218 error = 0;
5219 /*
5220 * If deleting a real allocation, must free up the disk space.
5221 */
5222 if (!delay) {
5223 nblks = del->br_blockcount;
5224 qfield = XFS_TRANS_DQ_BCOUNT;
5225 /*
5226 * Set up del_endblock and cur for later.
5227 */
5228 del_endblock = del->br_startblock + del->br_blockcount;
5229 da_old = da_new = 0;
5230 } else {
5231 da_old = startblockval(got.br_startblock);
5232 da_new = 0;
5233 nblks = 0;
5234 }
5235 qfield = qfield;
5236 nblks = nblks;
5237
5238 /*
5239 * Set flag value to use in switch statement.
5240 * Left-contig is 2, right-contig is 1.
5241 */
5242 switch (((got.br_startoff == del->br_startoff) << 1) |
5243 (got_endoff == del_endoff)) {
5244 case 3:
5245 /*
5246 * Matches the whole extent. Delete the entry.
5247 */
5248 xfs_iext_remove(ip, eidx, 1, BMAP_COWFORK);
5249 --eidx;
5250 break;
5251
5252 case 2:
5253 /*
5254 * Deleting the first part of the extent.
5255 */
5256 trace_xfs_bmap_pre_update(ip, eidx, state, _THIS_IP_);
5257 xfs_bmbt_set_startoff(ep, del_endoff);
5258 temp = got.br_blockcount - del->br_blockcount;
5259 xfs_bmbt_set_blockcount(ep, temp);
5260 if (delay) {
5261 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
5262 da_old);
5263 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
5264 trace_xfs_bmap_post_update(ip, eidx, state, _THIS_IP_);
5265 da_new = temp;
5266 break;
5267 }
5268 xfs_bmbt_set_startblock(ep, del_endblock);
5269 trace_xfs_bmap_post_update(ip, eidx, state, _THIS_IP_);
5270 break;
5271
5272 case 1:
5273 /*
5274 * Deleting the last part of the extent.
5275 */
5276 temp = got.br_blockcount - del->br_blockcount;
5277 trace_xfs_bmap_pre_update(ip, eidx, state, _THIS_IP_);
5278 xfs_bmbt_set_blockcount(ep, temp);
5279 if (delay) {
5280 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
5281 da_old);
5282 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
5283 trace_xfs_bmap_post_update(ip, eidx, state, _THIS_IP_);
5284 da_new = temp;
5285 break;
5286 }
5287 trace_xfs_bmap_post_update(ip, eidx, state, _THIS_IP_);
5288 break;
5289
5290 case 0:
5291 /*
5292 * Deleting the middle of the extent.
5293 */
5294 temp = del->br_startoff - got.br_startoff;
5295 trace_xfs_bmap_pre_update(ip, eidx, state, _THIS_IP_);
5296 xfs_bmbt_set_blockcount(ep, temp);
5297 new.br_startoff = del_endoff;
5298 temp2 = got_endoff - del_endoff;
5299 new.br_blockcount = temp2;
5300 new.br_state = got.br_state;
5301 if (!delay) {
5302 new.br_startblock = del_endblock;
5303 } else {
5304 temp = xfs_bmap_worst_indlen(ip, temp);
5305 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
5306 temp2 = xfs_bmap_worst_indlen(ip, temp2);
5307 new.br_startblock = nullstartblock((int)temp2);
5308 da_new = temp + temp2;
5309 while (da_new > da_old) {
5310 if (temp) {
5311 temp--;
5312 da_new--;
5313 xfs_bmbt_set_startblock(ep,
5314 nullstartblock((int)temp));
5315 }
5316 if (da_new == da_old)
5317 break;
5318 if (temp2) {
5319 temp2--;
5320 da_new--;
5321 new.br_startblock =
5322 nullstartblock((int)temp2);
5323 }
5324 }
5325 }
5326 trace_xfs_bmap_post_update(ip, eidx, state, _THIS_IP_);
5327 xfs_iext_insert(ip, eidx + 1, 1, &new, state);
5328 ++eidx;
5329 break;
5330 }
5331
5332 /*
5333 * Account for change in delayed indirect blocks.
5334 * Nothing to do for disk quota accounting here.
5335 */
5336 ASSERT(da_old >= da_new);
5337 if (da_old > da_new)
5338 xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), false);
5339
5340 return error;
5341}
5342
5343/* 5417/*
5344 * Unmap (remove) blocks from a file. 5418 * Unmap (remove) blocks from a file.
5345 * If nexts is nonzero then the number of extents to remove is limited to 5419 * If nexts is nonzero then the number of extents to remove is limited to
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index f97db7132564..7cae6ec27fa6 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -190,6 +190,8 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt,
190#define XFS_BMAP_TRACE_EXLIST(ip,c,w) 190#define XFS_BMAP_TRACE_EXLIST(ip,c,w)
191#endif 191#endif
192 192
193void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
194 xfs_filblks_t len);
193int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); 195int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
194void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); 196void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
195void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 197void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
@@ -221,7 +223,11 @@ int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
221 xfs_fileoff_t bno, xfs_filblks_t len, int flags, 223 xfs_fileoff_t bno, xfs_filblks_t len, int flags,
222 xfs_extnum_t nexts, xfs_fsblock_t *firstblock, 224 xfs_extnum_t nexts, xfs_fsblock_t *firstblock,
223 struct xfs_defer_ops *dfops, int *done); 225 struct xfs_defer_ops *dfops, int *done);
224int xfs_bunmapi_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *del); 226int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
227 xfs_extnum_t *idx, struct xfs_bmbt_irec *got,
228 struct xfs_bmbt_irec *del);
229void xfs_bmap_del_extent_cow(struct xfs_inode *ip, xfs_extnum_t *idx,
230 struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *del);
225int xfs_check_nostate_extents(struct xfs_ifork *ifp, xfs_extnum_t idx, 231int xfs_check_nostate_extents(struct xfs_ifork *ifp, xfs_extnum_t idx,
226 xfs_extnum_t num); 232 xfs_extnum_t num);
227uint xfs_default_attroffset(struct xfs_inode *ip); 233uint xfs_default_attroffset(struct xfs_inode *ip);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 5c8e6f2ce44f..0e80993c8a59 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -4826,7 +4826,7 @@ xfs_btree_calc_size(
4826 return rval; 4826 return rval;
4827} 4827}
4828 4828
4829int 4829static int
4830xfs_btree_count_blocks_helper( 4830xfs_btree_count_blocks_helper(
4831 struct xfs_btree_cur *cur, 4831 struct xfs_btree_cur *cur,
4832 int level, 4832 int level,
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index 3cc3cf767474..ac9a003dd29a 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -191,8 +191,7 @@ xfs_dquot_buf_verify_crc(
191 if (mp->m_quotainfo) 191 if (mp->m_quotainfo)
192 ndquots = mp->m_quotainfo->qi_dqperchunk; 192 ndquots = mp->m_quotainfo->qi_dqperchunk;
193 else 193 else
194 ndquots = xfs_calc_dquots_per_chunk( 194 ndquots = xfs_calc_dquots_per_chunk(bp->b_length);
195 XFS_BB_TO_FSB(mp, bp->b_length));
196 195
197 for (i = 0; i < ndquots; i++, d++) { 196 for (i = 0; i < ndquots; i++, d++) {
198 if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk), 197 if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index f6547fc5e016..6b7579e7b60a 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -865,7 +865,6 @@ typedef struct xfs_timestamp {
865 * padding field for v3 inodes. 865 * padding field for v3 inodes.
866 */ 866 */
867#define XFS_DINODE_MAGIC 0x494e /* 'IN' */ 867#define XFS_DINODE_MAGIC 0x494e /* 'IN' */
868#define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3)
869typedef struct xfs_dinode { 868typedef struct xfs_dinode {
870 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 869 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
871 __be16 di_mode; /* mode and type of file */ 870 __be16 di_mode; /* mode and type of file */
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 8de9a3a29589..134424fac434 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -57,6 +57,17 @@ xfs_inobp_check(
57} 57}
58#endif 58#endif
59 59
60bool
61xfs_dinode_good_version(
62 struct xfs_mount *mp,
63 __u8 version)
64{
65 if (xfs_sb_version_hascrc(&mp->m_sb))
66 return version == 3;
67
68 return version == 1 || version == 2;
69}
70
60/* 71/*
61 * If we are doing readahead on an inode buffer, we might be in log recovery 72 * If we are doing readahead on an inode buffer, we might be in log recovery
62 * reading an inode allocation buffer that hasn't yet been replayed, and hence 73 * reading an inode allocation buffer that hasn't yet been replayed, and hence
@@ -91,7 +102,7 @@ xfs_inode_buf_verify(
91 102
92 dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog)); 103 dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
93 di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && 104 di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
94 XFS_DINODE_GOOD_VERSION(dip->di_version); 105 xfs_dinode_good_version(mp, dip->di_version);
95 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, 106 if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
96 XFS_ERRTAG_ITOBP_INOTOBP, 107 XFS_ERRTAG_ITOBP_INOTOBP,
97 XFS_RANDOM_ITOBP_INOTOBP))) { 108 XFS_RANDOM_ITOBP_INOTOBP))) {
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 62d9d4681c8c..3cfe12a4f58a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -74,6 +74,8 @@ void xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
74void xfs_log_dinode_to_disk(struct xfs_log_dinode *from, 74void xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
75 struct xfs_dinode *to); 75 struct xfs_dinode *to);
76 76
77bool xfs_dinode_good_version(struct xfs_mount *mp, __u8 version);
78
77#if defined(DEBUG) 79#if defined(DEBUG)
78void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); 80void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
79#else 81#else
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index a314fc7b56fa..6e4f7f900fea 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -249,6 +249,7 @@ xfs_file_dio_aio_read(
249 struct xfs_inode *ip = XFS_I(inode); 249 struct xfs_inode *ip = XFS_I(inode);
250 loff_t isize = i_size_read(inode); 250 loff_t isize = i_size_read(inode);
251 size_t count = iov_iter_count(to); 251 size_t count = iov_iter_count(to);
252 loff_t end = iocb->ki_pos + count - 1;
252 struct iov_iter data; 253 struct iov_iter data;
253 struct xfs_buftarg *target; 254 struct xfs_buftarg *target;
254 ssize_t ret = 0; 255 ssize_t ret = 0;
@@ -272,49 +273,21 @@ xfs_file_dio_aio_read(
272 273
273 file_accessed(iocb->ki_filp); 274 file_accessed(iocb->ki_filp);
274 275
275 /*
276 * Locking is a bit tricky here. If we take an exclusive lock for direct
277 * IO, we effectively serialise all new concurrent read IO to this file
278 * and block it behind IO that is currently in progress because IO in
279 * progress holds the IO lock shared. We only need to hold the lock
280 * exclusive to blow away the page cache, so only take lock exclusively
281 * if the page cache needs invalidation. This allows the normal direct
282 * IO case of no page cache pages to proceeed concurrently without
283 * serialisation.
284 */
285 xfs_rw_ilock(ip, XFS_IOLOCK_SHARED); 276 xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
286 if (mapping->nrpages) { 277 if (mapping->nrpages) {
287 xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED); 278 ret = filemap_write_and_wait_range(mapping, iocb->ki_pos, end);
288 xfs_rw_ilock(ip, XFS_IOLOCK_EXCL); 279 if (ret)
280 goto out_unlock;
289 281
290 /* 282 /*
291 * The generic dio code only flushes the range of the particular 283 * Invalidate whole pages. This can return an error if we fail
292 * I/O. Because we take an exclusive lock here, this whole 284 * to invalidate a page, but this should never happen on XFS.
293 * sequence is considerably more expensive for us. This has a 285 * Warn if it does fail.
294 * noticeable performance impact for any file with cached pages,
295 * even when outside of the range of the particular I/O.
296 *
297 * Hence, amortize the cost of the lock against a full file
298 * flush and reduce the chances of repeated iolock cycles going
299 * forward.
300 */ 286 */
301 if (mapping->nrpages) { 287 ret = invalidate_inode_pages2_range(mapping,
302 ret = filemap_write_and_wait(mapping); 288 iocb->ki_pos >> PAGE_SHIFT, end >> PAGE_SHIFT);
303 if (ret) { 289 WARN_ON_ONCE(ret);
304 xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL); 290 ret = 0;
305 return ret;
306 }
307
308 /*
309 * Invalidate whole pages. This can return an error if
310 * we fail to invalidate a page, but this should never
311 * happen on XFS. Warn if it does fail.
312 */
313 ret = invalidate_inode_pages2(mapping);
314 WARN_ON_ONCE(ret);
315 ret = 0;
316 }
317 xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
318 } 291 }
319 292
320 data = *to; 293 data = *to;
@@ -324,8 +297,9 @@ xfs_file_dio_aio_read(
324 iocb->ki_pos += ret; 297 iocb->ki_pos += ret;
325 iov_iter_advance(to, ret); 298 iov_iter_advance(to, ret);
326 } 299 }
327 xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
328 300
301out_unlock:
302 xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
329 return ret; 303 return ret;
330} 304}
331 305
@@ -570,61 +544,49 @@ xfs_file_dio_aio_write(
570 if ((iocb->ki_pos | count) & target->bt_logical_sectormask) 544 if ((iocb->ki_pos | count) & target->bt_logical_sectormask)
571 return -EINVAL; 545 return -EINVAL;
572 546
573 /* "unaligned" here means not aligned to a filesystem block */
574 if ((iocb->ki_pos & mp->m_blockmask) ||
575 ((iocb->ki_pos + count) & mp->m_blockmask))
576 unaligned_io = 1;
577
578 /* 547 /*
579 * We don't need to take an exclusive lock unless there page cache needs 548 * Don't take the exclusive iolock here unless the I/O is unaligned to
580 * to be invalidated or unaligned IO is being executed. We don't need to 549 * the file system block size. We don't need to consider the EOF
581 * consider the EOF extension case here because 550 * extension case here because xfs_file_aio_write_checks() will relock
582 * xfs_file_aio_write_checks() will relock the inode as necessary for 551 * the inode as necessary for EOF zeroing cases and fill out the new
583 * EOF zeroing cases and fill out the new inode size as appropriate. 552 * inode size as appropriate.
584 */ 553 */
585 if (unaligned_io || mapping->nrpages) 554 if ((iocb->ki_pos & mp->m_blockmask) ||
555 ((iocb->ki_pos + count) & mp->m_blockmask)) {
556 unaligned_io = 1;
586 iolock = XFS_IOLOCK_EXCL; 557 iolock = XFS_IOLOCK_EXCL;
587 else 558 } else {
588 iolock = XFS_IOLOCK_SHARED; 559 iolock = XFS_IOLOCK_SHARED;
589 xfs_rw_ilock(ip, iolock);
590
591 /*
592 * Recheck if there are cached pages that need invalidate after we got
593 * the iolock to protect against other threads adding new pages while
594 * we were waiting for the iolock.
595 */
596 if (mapping->nrpages && iolock == XFS_IOLOCK_SHARED) {
597 xfs_rw_iunlock(ip, iolock);
598 iolock = XFS_IOLOCK_EXCL;
599 xfs_rw_ilock(ip, iolock);
600 } 560 }
601 561
562 xfs_rw_ilock(ip, iolock);
563
602 ret = xfs_file_aio_write_checks(iocb, from, &iolock); 564 ret = xfs_file_aio_write_checks(iocb, from, &iolock);
603 if (ret) 565 if (ret)
604 goto out; 566 goto out;
605 count = iov_iter_count(from); 567 count = iov_iter_count(from);
606 end = iocb->ki_pos + count - 1; 568 end = iocb->ki_pos + count - 1;
607 569
608 /*
609 * See xfs_file_dio_aio_read() for why we do a full-file flush here.
610 */
611 if (mapping->nrpages) { 570 if (mapping->nrpages) {
612 ret = filemap_write_and_wait(VFS_I(ip)->i_mapping); 571 ret = filemap_write_and_wait_range(mapping, iocb->ki_pos, end);
613 if (ret) 572 if (ret)
614 goto out; 573 goto out;
574
615 /* 575 /*
616 * Invalidate whole pages. This can return an error if we fail 576 * Invalidate whole pages. This can return an error if we fail
617 * to invalidate a page, but this should never happen on XFS. 577 * to invalidate a page, but this should never happen on XFS.
618 * Warn if it does fail. 578 * Warn if it does fail.
619 */ 579 */
620 ret = invalidate_inode_pages2(VFS_I(ip)->i_mapping); 580 ret = invalidate_inode_pages2_range(mapping,
581 iocb->ki_pos >> PAGE_SHIFT, end >> PAGE_SHIFT);
621 WARN_ON_ONCE(ret); 582 WARN_ON_ONCE(ret);
622 ret = 0; 583 ret = 0;
623 } 584 }
624 585
625 /* 586 /*
626 * If we are doing unaligned IO, wait for all other IO to drain, 587 * If we are doing unaligned IO, wait for all other IO to drain,
627 * otherwise demote the lock if we had to flush cached pages 588 * otherwise demote the lock if we had to take the exclusive lock
589 * for other reasons in xfs_file_aio_write_checks.
628 */ 590 */
629 if (unaligned_io) 591 if (unaligned_io)
630 inode_dio_wait(inode); 592 inode_dio_wait(inode);
@@ -947,134 +909,6 @@ out_unlock:
947 return error; 909 return error;
948} 910}
949 911
950/*
951 * Flush all file writes out to disk.
952 */
953static int
954xfs_file_wait_for_io(
955 struct inode *inode,
956 loff_t offset,
957 size_t len)
958{
959 loff_t rounding;
960 loff_t ioffset;
961 loff_t iendoffset;
962 loff_t bs;
963 int ret;
964
965 bs = inode->i_sb->s_blocksize;
966 inode_dio_wait(inode);
967
968 rounding = max_t(xfs_off_t, bs, PAGE_SIZE);
969 ioffset = round_down(offset, rounding);
970 iendoffset = round_up(offset + len, rounding) - 1;
971 ret = filemap_write_and_wait_range(inode->i_mapping, ioffset,
972 iendoffset);
973 return ret;
974}
975
976/* Hook up to the VFS reflink function */
977STATIC int
978xfs_file_share_range(
979 struct file *file_in,
980 loff_t pos_in,
981 struct file *file_out,
982 loff_t pos_out,
983 u64 len,
984 bool is_dedupe)
985{
986 struct inode *inode_in;
987 struct inode *inode_out;
988 ssize_t ret;
989 loff_t bs;
990 loff_t isize;
991 int same_inode;
992 loff_t blen;
993 unsigned int flags = 0;
994
995 inode_in = file_inode(file_in);
996 inode_out = file_inode(file_out);
997 bs = inode_out->i_sb->s_blocksize;
998
999 /* Don't touch certain kinds of inodes */
1000 if (IS_IMMUTABLE(inode_out))
1001 return -EPERM;
1002 if (IS_SWAPFILE(inode_in) ||
1003 IS_SWAPFILE(inode_out))
1004 return -ETXTBSY;
1005
1006 /* Reflink only works within this filesystem. */
1007 if (inode_in->i_sb != inode_out->i_sb)
1008 return -EXDEV;
1009 same_inode = (inode_in->i_ino == inode_out->i_ino);
1010
1011 /* Don't reflink dirs, pipes, sockets... */
1012 if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
1013 return -EISDIR;
1014 if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode))
1015 return -EINVAL;
1016 if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
1017 return -EINVAL;
1018
1019 /* Don't share DAX file data for now. */
1020 if (IS_DAX(inode_in) || IS_DAX(inode_out))
1021 return -EINVAL;
1022
1023 /* Are we going all the way to the end? */
1024 isize = i_size_read(inode_in);
1025 if (isize == 0)
1026 return 0;
1027 if (len == 0)
1028 len = isize - pos_in;
1029
1030 /* Ensure offsets don't wrap and the input is inside i_size */
1031 if (pos_in + len < pos_in || pos_out + len < pos_out ||
1032 pos_in + len > isize)
1033 return -EINVAL;
1034
1035 /* Don't allow dedupe past EOF in the dest file */
1036 if (is_dedupe) {
1037 loff_t disize;
1038
1039 disize = i_size_read(inode_out);
1040 if (pos_out >= disize || pos_out + len > disize)
1041 return -EINVAL;
1042 }
1043
1044 /* If we're linking to EOF, continue to the block boundary. */
1045 if (pos_in + len == isize)
1046 blen = ALIGN(isize, bs) - pos_in;
1047 else
1048 blen = len;
1049
1050 /* Only reflink if we're aligned to block boundaries */
1051 if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) ||
1052 !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs))
1053 return -EINVAL;
1054
1055 /* Don't allow overlapped reflink within the same file */
1056 if (same_inode && pos_out + blen > pos_in && pos_out < pos_in + blen)
1057 return -EINVAL;
1058
1059 /* Wait for the completion of any pending IOs on srcfile */
1060 ret = xfs_file_wait_for_io(inode_in, pos_in, len);
1061 if (ret)
1062 goto out;
1063 ret = xfs_file_wait_for_io(inode_out, pos_out, len);
1064 if (ret)
1065 goto out;
1066
1067 if (is_dedupe)
1068 flags |= XFS_REFLINK_DEDUPE;
1069 ret = xfs_reflink_remap_range(XFS_I(inode_in), pos_in, XFS_I(inode_out),
1070 pos_out, len, flags);
1071 if (ret < 0)
1072 goto out;
1073
1074out:
1075 return ret;
1076}
1077
1078STATIC ssize_t 912STATIC ssize_t
1079xfs_file_copy_range( 913xfs_file_copy_range(
1080 struct file *file_in, 914 struct file *file_in,
@@ -1086,7 +920,7 @@ xfs_file_copy_range(
1086{ 920{
1087 int error; 921 int error;
1088 922
1089 error = xfs_file_share_range(file_in, pos_in, file_out, pos_out, 923 error = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out,
1090 len, false); 924 len, false);
1091 if (error) 925 if (error)
1092 return error; 926 return error;
@@ -1101,7 +935,7 @@ xfs_file_clone_range(
1101 loff_t pos_out, 935 loff_t pos_out,
1102 u64 len) 936 u64 len)
1103{ 937{
1104 return xfs_file_share_range(file_in, pos_in, file_out, pos_out, 938 return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out,
1105 len, false); 939 len, false);
1106} 940}
1107 941
@@ -1124,7 +958,7 @@ xfs_file_dedupe_range(
1124 if (len > XFS_MAX_DEDUPE_LEN) 958 if (len > XFS_MAX_DEDUPE_LEN)
1125 len = XFS_MAX_DEDUPE_LEN; 959 len = XFS_MAX_DEDUPE_LEN;
1126 960
1127 error = xfs_file_share_range(src_file, loff, dst_file, dst_loff, 961 error = xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff,
1128 len, true); 962 len, true);
1129 if (error) 963 if (error)
1130 return error; 964 return error;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 14796b744e0a..f295049db681 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1656,9 +1656,9 @@ void
1656xfs_inode_set_cowblocks_tag( 1656xfs_inode_set_cowblocks_tag(
1657 xfs_inode_t *ip) 1657 xfs_inode_t *ip)
1658{ 1658{
1659 trace_xfs_inode_set_eofblocks_tag(ip); 1659 trace_xfs_inode_set_cowblocks_tag(ip);
1660 return __xfs_inode_set_eofblocks_tag(ip, xfs_queue_cowblocks, 1660 return __xfs_inode_set_eofblocks_tag(ip, xfs_queue_cowblocks,
1661 trace_xfs_perag_set_eofblocks, 1661 trace_xfs_perag_set_cowblocks,
1662 XFS_ICI_COWBLOCKS_TAG); 1662 XFS_ICI_COWBLOCKS_TAG);
1663} 1663}
1664 1664
@@ -1666,7 +1666,7 @@ void
1666xfs_inode_clear_cowblocks_tag( 1666xfs_inode_clear_cowblocks_tag(
1667 xfs_inode_t *ip) 1667 xfs_inode_t *ip)
1668{ 1668{
1669 trace_xfs_inode_clear_eofblocks_tag(ip); 1669 trace_xfs_inode_clear_cowblocks_tag(ip);
1670 return __xfs_inode_clear_eofblocks_tag(ip, 1670 return __xfs_inode_clear_eofblocks_tag(ip,
1671 trace_xfs_perag_clear_eofblocks, XFS_ICI_COWBLOCKS_TAG); 1671 trace_xfs_perag_clear_cowblocks, XFS_ICI_COWBLOCKS_TAG);
1672} 1672}
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index d907eb9f8ef3..436e109bb01e 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -566,6 +566,17 @@ xfs_file_iomap_begin_delay(
566 xfs_bmap_search_extents(ip, offset_fsb, XFS_DATA_FORK, &eof, &idx, 566 xfs_bmap_search_extents(ip, offset_fsb, XFS_DATA_FORK, &eof, &idx,
567 &got, &prev); 567 &got, &prev);
568 if (!eof && got.br_startoff <= offset_fsb) { 568 if (!eof && got.br_startoff <= offset_fsb) {
569 if (xfs_is_reflink_inode(ip)) {
570 bool shared;
571
572 end_fsb = min(XFS_B_TO_FSB(mp, offset + count),
573 maxbytes_fsb);
574 xfs_trim_extent(&got, offset_fsb, end_fsb - offset_fsb);
575 error = xfs_reflink_reserve_cow(ip, &got, &shared);
576 if (error)
577 goto out_unlock;
578 }
579
569 trace_xfs_iomap_found(ip, offset, count, 0, &got); 580 trace_xfs_iomap_found(ip, offset, count, 0, &got);
570 goto done; 581 goto done;
571 } 582 }
@@ -961,19 +972,13 @@ xfs_file_iomap_begin(
961 struct xfs_mount *mp = ip->i_mount; 972 struct xfs_mount *mp = ip->i_mount;
962 struct xfs_bmbt_irec imap; 973 struct xfs_bmbt_irec imap;
963 xfs_fileoff_t offset_fsb, end_fsb; 974 xfs_fileoff_t offset_fsb, end_fsb;
964 bool shared, trimmed;
965 int nimaps = 1, error = 0; 975 int nimaps = 1, error = 0;
976 bool shared = false, trimmed = false;
966 unsigned lockmode; 977 unsigned lockmode;
967 978
968 if (XFS_FORCED_SHUTDOWN(mp)) 979 if (XFS_FORCED_SHUTDOWN(mp))
969 return -EIO; 980 return -EIO;
970 981
971 if ((flags & (IOMAP_WRITE | IOMAP_ZERO)) && xfs_is_reflink_inode(ip)) {
972 error = xfs_reflink_reserve_cow_range(ip, offset, length);
973 if (error < 0)
974 return error;
975 }
976
977 if ((flags & IOMAP_WRITE) && !IS_DAX(inode) && 982 if ((flags & IOMAP_WRITE) && !IS_DAX(inode) &&
978 !xfs_get_extsz_hint(ip)) { 983 !xfs_get_extsz_hint(ip)) {
979 /* Reserve delalloc blocks for regular writeback. */ 984 /* Reserve delalloc blocks for regular writeback. */
@@ -981,7 +986,16 @@ xfs_file_iomap_begin(
981 iomap); 986 iomap);
982 } 987 }
983 988
984 lockmode = xfs_ilock_data_map_shared(ip); 989 /*
990 * COW writes will allocate delalloc space, so we need to make sure
991 * to take the lock exclusively here.
992 */
993 if ((flags & (IOMAP_WRITE | IOMAP_ZERO)) && xfs_is_reflink_inode(ip)) {
994 lockmode = XFS_ILOCK_EXCL;
995 xfs_ilock(ip, XFS_ILOCK_EXCL);
996 } else {
997 lockmode = xfs_ilock_data_map_shared(ip);
998 }
985 999
986 ASSERT(offset <= mp->m_super->s_maxbytes); 1000 ASSERT(offset <= mp->m_super->s_maxbytes);
987 if ((xfs_fsize_t)offset + length > mp->m_super->s_maxbytes) 1001 if ((xfs_fsize_t)offset + length > mp->m_super->s_maxbytes)
@@ -991,16 +1005,24 @@ xfs_file_iomap_begin(
991 1005
992 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap, 1006 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
993 &nimaps, 0); 1007 &nimaps, 0);
994 if (error) { 1008 if (error)
995 xfs_iunlock(ip, lockmode); 1009 goto out_unlock;
996 return error; 1010
1011 if (flags & IOMAP_REPORT) {
1012 /* Trim the mapping to the nearest shared extent boundary. */
1013 error = xfs_reflink_trim_around_shared(ip, &imap, &shared,
1014 &trimmed);
1015 if (error)
1016 goto out_unlock;
997 } 1017 }
998 1018
999 /* Trim the mapping to the nearest shared extent boundary. */ 1019 if ((flags & (IOMAP_WRITE | IOMAP_ZERO)) && xfs_is_reflink_inode(ip)) {
1000 error = xfs_reflink_trim_around_shared(ip, &imap, &shared, &trimmed); 1020 error = xfs_reflink_reserve_cow(ip, &imap, &shared);
1001 if (error) { 1021 if (error)
1002 xfs_iunlock(ip, lockmode); 1022 goto out_unlock;
1003 return error; 1023
1024 end_fsb = imap.br_startoff + imap.br_blockcount;
1025 length = XFS_FSB_TO_B(mp, end_fsb) - offset;
1004 } 1026 }
1005 1027
1006 if ((flags & IOMAP_WRITE) && imap_needs_alloc(inode, &imap, nimaps)) { 1028 if ((flags & IOMAP_WRITE) && imap_needs_alloc(inode, &imap, nimaps)) {
@@ -1039,6 +1061,9 @@ xfs_file_iomap_begin(
1039 if (shared) 1061 if (shared)
1040 iomap->flags |= IOMAP_F_SHARED; 1062 iomap->flags |= IOMAP_F_SHARED;
1041 return 0; 1063 return 0;
1064out_unlock:
1065 xfs_iunlock(ip, lockmode);
1066 return error;
1042} 1067}
1043 1068
1044static int 1069static int
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index fc7873942bea..b341f10cf481 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1009,6 +1009,7 @@ xfs_mountfs(
1009 out_quota: 1009 out_quota:
1010 xfs_qm_unmount_quotas(mp); 1010 xfs_qm_unmount_quotas(mp);
1011 out_rtunmount: 1011 out_rtunmount:
1012 mp->m_super->s_flags &= ~MS_ACTIVE;
1012 xfs_rtunmount_inodes(mp); 1013 xfs_rtunmount_inodes(mp);
1013 out_rele_rip: 1014 out_rele_rip:
1014 IRELE(rip); 1015 IRELE(rip);
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 5965e9455d91..a279b4e7f5fe 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -182,7 +182,8 @@ xfs_reflink_trim_around_shared(
182 if (!xfs_is_reflink_inode(ip) || 182 if (!xfs_is_reflink_inode(ip) ||
183 ISUNWRITTEN(irec) || 183 ISUNWRITTEN(irec) ||
184 irec->br_startblock == HOLESTARTBLOCK || 184 irec->br_startblock == HOLESTARTBLOCK ||
185 irec->br_startblock == DELAYSTARTBLOCK) { 185 irec->br_startblock == DELAYSTARTBLOCK ||
186 isnullstartblock(irec->br_startblock)) {
186 *shared = false; 187 *shared = false;
187 return 0; 188 return 0;
188 } 189 }
@@ -227,50 +228,54 @@ xfs_reflink_trim_around_shared(
227 } 228 }
228} 229}
229 230
230/* Create a CoW reservation for a range of blocks within a file. */ 231/*
231static int 232 * Trim the passed in imap to the next shared/unshared extent boundary, and
232__xfs_reflink_reserve_cow( 233 * if imap->br_startoff points to a shared extent reserve space for it in the
234 * COW fork. In this case *shared is set to true, else to false.
235 *
236 * Note that imap will always contain the block numbers for the existing blocks
237 * in the data fork, as the upper layers need them for read-modify-write
238 * operations.
239 */
240int
241xfs_reflink_reserve_cow(
233 struct xfs_inode *ip, 242 struct xfs_inode *ip,
234 xfs_fileoff_t *offset_fsb, 243 struct xfs_bmbt_irec *imap,
235 xfs_fileoff_t end_fsb, 244 bool *shared)
236 bool *skipped)
237{ 245{
238 struct xfs_bmbt_irec got, prev, imap; 246 struct xfs_bmbt_irec got, prev;
239 xfs_fileoff_t orig_end_fsb; 247 xfs_fileoff_t end_fsb, orig_end_fsb;
240 int nimaps, eof = 0, error = 0; 248 int eof = 0, error = 0;
241 bool shared = false, trimmed = false; 249 bool trimmed;
242 xfs_extnum_t idx; 250 xfs_extnum_t idx;
243 xfs_extlen_t align; 251 xfs_extlen_t align;
244 252
245 /* Already reserved? Skip the refcount btree access. */ 253 /*
246 xfs_bmap_search_extents(ip, *offset_fsb, XFS_COW_FORK, &eof, &idx, 254 * Search the COW fork extent list first. This serves two purposes:
255 * first this implement the speculative preallocation using cowextisze,
256 * so that we also unshared block adjacent to shared blocks instead
257 * of just the shared blocks themselves. Second the lookup in the
258 * extent list is generally faster than going out to the shared extent
259 * tree.
260 */
261 xfs_bmap_search_extents(ip, imap->br_startoff, XFS_COW_FORK, &eof, &idx,
247 &got, &prev); 262 &got, &prev);
248 if (!eof && got.br_startoff <= *offset_fsb) { 263 if (!eof && got.br_startoff <= imap->br_startoff) {
249 end_fsb = orig_end_fsb = got.br_startoff + got.br_blockcount; 264 trace_xfs_reflink_cow_found(ip, imap);
250 trace_xfs_reflink_cow_found(ip, &got); 265 xfs_trim_extent(imap, got.br_startoff, got.br_blockcount);
251 goto done;
252 }
253 266
254 /* Read extent from the source file. */ 267 *shared = true;
255 nimaps = 1; 268 return 0;
256 error = xfs_bmapi_read(ip, *offset_fsb, end_fsb - *offset_fsb, 269 }
257 &imap, &nimaps, 0);
258 if (error)
259 goto out_unlock;
260 ASSERT(nimaps == 1);
261 270
262 /* Trim the mapping to the nearest shared extent boundary. */ 271 /* Trim the mapping to the nearest shared extent boundary. */
263 error = xfs_reflink_trim_around_shared(ip, &imap, &shared, &trimmed); 272 error = xfs_reflink_trim_around_shared(ip, imap, shared, &trimmed);
264 if (error) 273 if (error)
265 goto out_unlock; 274 return error;
266
267 end_fsb = orig_end_fsb = imap.br_startoff + imap.br_blockcount;
268 275
269 /* Not shared? Just report the (potentially capped) extent. */ 276 /* Not shared? Just report the (potentially capped) extent. */
270 if (!shared) { 277 if (!*shared)
271 *skipped = true; 278 return 0;
272 goto done;
273 }
274 279
275 /* 280 /*
276 * Fork all the shared blocks from our write offset until the end of 281 * Fork all the shared blocks from our write offset until the end of
@@ -278,72 +283,38 @@ __xfs_reflink_reserve_cow(
278 */ 283 */
279 error = xfs_qm_dqattach_locked(ip, 0); 284 error = xfs_qm_dqattach_locked(ip, 0);
280 if (error) 285 if (error)
281 goto out_unlock; 286 return error;
287
288 end_fsb = orig_end_fsb = imap->br_startoff + imap->br_blockcount;
282 289
283 align = xfs_eof_alignment(ip, xfs_get_cowextsz_hint(ip)); 290 align = xfs_eof_alignment(ip, xfs_get_cowextsz_hint(ip));
284 if (align) 291 if (align)
285 end_fsb = roundup_64(end_fsb, align); 292 end_fsb = roundup_64(end_fsb, align);
286 293
287retry: 294retry:
288 error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, *offset_fsb, 295 error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, imap->br_startoff,
289 end_fsb - *offset_fsb, &got, 296 end_fsb - imap->br_startoff, &got, &prev, &idx, eof);
290 &prev, &idx, eof);
291 switch (error) { 297 switch (error) {
292 case 0: 298 case 0:
293 break; 299 break;
294 case -ENOSPC: 300 case -ENOSPC:
295 case -EDQUOT: 301 case -EDQUOT:
296 /* retry without any preallocation */ 302 /* retry without any preallocation */
297 trace_xfs_reflink_cow_enospc(ip, &imap); 303 trace_xfs_reflink_cow_enospc(ip, imap);
298 if (end_fsb != orig_end_fsb) { 304 if (end_fsb != orig_end_fsb) {
299 end_fsb = orig_end_fsb; 305 end_fsb = orig_end_fsb;
300 goto retry; 306 goto retry;
301 } 307 }
302 /*FALLTHRU*/ 308 /*FALLTHRU*/
303 default: 309 default:
304 goto out_unlock; 310 return error;
305 } 311 }
306 312
307 if (end_fsb != orig_end_fsb) 313 if (end_fsb != orig_end_fsb)
308 xfs_inode_set_cowblocks_tag(ip); 314 xfs_inode_set_cowblocks_tag(ip);
309 315
310 trace_xfs_reflink_cow_alloc(ip, &got); 316 trace_xfs_reflink_cow_alloc(ip, &got);
311done: 317 return 0;
312 *offset_fsb = end_fsb;
313out_unlock:
314 return error;
315}
316
317/* Create a CoW reservation for part of a file. */
318int
319xfs_reflink_reserve_cow_range(
320 struct xfs_inode *ip,
321 xfs_off_t offset,
322 xfs_off_t count)
323{
324 struct xfs_mount *mp = ip->i_mount;
325 xfs_fileoff_t offset_fsb, end_fsb;
326 bool skipped = false;
327 int error;
328
329 trace_xfs_reflink_reserve_cow_range(ip, offset, count);
330
331 offset_fsb = XFS_B_TO_FSBT(mp, offset);
332 end_fsb = XFS_B_TO_FSB(mp, offset + count);
333
334 xfs_ilock(ip, XFS_ILOCK_EXCL);
335 while (offset_fsb < end_fsb) {
336 error = __xfs_reflink_reserve_cow(ip, &offset_fsb, end_fsb,
337 &skipped);
338 if (error) {
339 trace_xfs_reflink_reserve_cow_range_error(ip, error,
340 _RET_IP_);
341 break;
342 }
343 }
344 xfs_iunlock(ip, XFS_ILOCK_EXCL);
345
346 return error;
347} 318}
348 319
349/* Allocate all CoW reservations covering a range of blocks in a file. */ 320/* Allocate all CoW reservations covering a range of blocks in a file. */
@@ -358,9 +329,8 @@ __xfs_reflink_allocate_cow(
358 struct xfs_defer_ops dfops; 329 struct xfs_defer_ops dfops;
359 struct xfs_trans *tp; 330 struct xfs_trans *tp;
360 xfs_fsblock_t first_block; 331 xfs_fsblock_t first_block;
361 xfs_fileoff_t next_fsb;
362 int nimaps = 1, error; 332 int nimaps = 1, error;
363 bool skipped = false; 333 bool shared;
364 334
365 xfs_defer_init(&dfops, &first_block); 335 xfs_defer_init(&dfops, &first_block);
366 336
@@ -371,33 +341,38 @@ __xfs_reflink_allocate_cow(
371 341
372 xfs_ilock(ip, XFS_ILOCK_EXCL); 342 xfs_ilock(ip, XFS_ILOCK_EXCL);
373 343
374 next_fsb = *offset_fsb; 344 /* Read extent from the source file. */
375 error = __xfs_reflink_reserve_cow(ip, &next_fsb, end_fsb, &skipped); 345 nimaps = 1;
346 error = xfs_bmapi_read(ip, *offset_fsb, end_fsb - *offset_fsb,
347 &imap, &nimaps, 0);
348 if (error)
349 goto out_unlock;
350 ASSERT(nimaps == 1);
351
352 error = xfs_reflink_reserve_cow(ip, &imap, &shared);
376 if (error) 353 if (error)
377 goto out_trans_cancel; 354 goto out_trans_cancel;
378 355
379 if (skipped) { 356 if (!shared) {
380 *offset_fsb = next_fsb; 357 *offset_fsb = imap.br_startoff + imap.br_blockcount;
381 goto out_trans_cancel; 358 goto out_trans_cancel;
382 } 359 }
383 360
384 xfs_trans_ijoin(tp, ip, 0); 361 xfs_trans_ijoin(tp, ip, 0);
385 error = xfs_bmapi_write(tp, ip, *offset_fsb, next_fsb - *offset_fsb, 362 error = xfs_bmapi_write(tp, ip, imap.br_startoff, imap.br_blockcount,
386 XFS_BMAPI_COWFORK, &first_block, 363 XFS_BMAPI_COWFORK, &first_block,
387 XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 364 XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK),
388 &imap, &nimaps, &dfops); 365 &imap, &nimaps, &dfops);
389 if (error) 366 if (error)
390 goto out_trans_cancel; 367 goto out_trans_cancel;
391 368
392 /* We might not have been able to map the whole delalloc extent */
393 *offset_fsb = min(*offset_fsb + imap.br_blockcount, next_fsb);
394
395 error = xfs_defer_finish(&tp, &dfops, NULL); 369 error = xfs_defer_finish(&tp, &dfops, NULL);
396 if (error) 370 if (error)
397 goto out_trans_cancel; 371 goto out_trans_cancel;
398 372
399 error = xfs_trans_commit(tp); 373 error = xfs_trans_commit(tp);
400 374
375 *offset_fsb = imap.br_startoff + imap.br_blockcount;
401out_unlock: 376out_unlock:
402 xfs_iunlock(ip, XFS_ILOCK_EXCL); 377 xfs_iunlock(ip, XFS_ILOCK_EXCL);
403 return error; 378 return error;
@@ -536,58 +511,49 @@ xfs_reflink_cancel_cow_blocks(
536 xfs_fileoff_t offset_fsb, 511 xfs_fileoff_t offset_fsb,
537 xfs_fileoff_t end_fsb) 512 xfs_fileoff_t end_fsb)
538{ 513{
539 struct xfs_bmbt_irec irec; 514 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
540 xfs_filblks_t count_fsb; 515 struct xfs_bmbt_irec got, prev, del;
516 xfs_extnum_t idx;
541 xfs_fsblock_t firstfsb; 517 xfs_fsblock_t firstfsb;
542 struct xfs_defer_ops dfops; 518 struct xfs_defer_ops dfops;
543 int error = 0; 519 int error = 0, eof = 0;
544 int nimaps;
545 520
546 if (!xfs_is_reflink_inode(ip)) 521 if (!xfs_is_reflink_inode(ip))
547 return 0; 522 return 0;
548 523
549 /* Go find the old extent in the CoW fork. */ 524 xfs_bmap_search_extents(ip, offset_fsb, XFS_COW_FORK, &eof, &idx,
550 while (offset_fsb < end_fsb) { 525 &got, &prev);
551 nimaps = 1; 526 if (eof)
552 count_fsb = (xfs_filblks_t)(end_fsb - offset_fsb); 527 return 0;
553 error = xfs_bmapi_read(ip, offset_fsb, count_fsb, &irec,
554 &nimaps, XFS_BMAPI_COWFORK);
555 if (error)
556 break;
557 ASSERT(nimaps == 1);
558
559 trace_xfs_reflink_cancel_cow(ip, &irec);
560 528
561 if (irec.br_startblock == DELAYSTARTBLOCK) { 529 while (got.br_startoff < end_fsb) {
562 /* Free a delayed allocation. */ 530 del = got;
563 xfs_mod_fdblocks(ip->i_mount, irec.br_blockcount, 531 xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
564 false); 532 trace_xfs_reflink_cancel_cow(ip, &del);
565 ip->i_delayed_blks -= irec.br_blockcount;
566 533
567 /* Remove the mapping from the CoW fork. */ 534 if (isnullstartblock(del.br_startblock)) {
568 error = xfs_bunmapi_cow(ip, &irec); 535 error = xfs_bmap_del_extent_delay(ip, XFS_COW_FORK,
536 &idx, &got, &del);
569 if (error) 537 if (error)
570 break; 538 break;
571 } else if (irec.br_startblock == HOLESTARTBLOCK) {
572 /* empty */
573 } else { 539 } else {
574 xfs_trans_ijoin(*tpp, ip, 0); 540 xfs_trans_ijoin(*tpp, ip, 0);
575 xfs_defer_init(&dfops, &firstfsb); 541 xfs_defer_init(&dfops, &firstfsb);
576 542
577 /* Free the CoW orphan record. */ 543 /* Free the CoW orphan record. */
578 error = xfs_refcount_free_cow_extent(ip->i_mount, 544 error = xfs_refcount_free_cow_extent(ip->i_mount,
579 &dfops, irec.br_startblock, 545 &dfops, del.br_startblock,
580 irec.br_blockcount); 546 del.br_blockcount);
581 if (error) 547 if (error)
582 break; 548 break;
583 549
584 xfs_bmap_add_free(ip->i_mount, &dfops, 550 xfs_bmap_add_free(ip->i_mount, &dfops,
585 irec.br_startblock, irec.br_blockcount, 551 del.br_startblock, del.br_blockcount,
586 NULL); 552 NULL);
587 553
588 /* Update quota accounting */ 554 /* Update quota accounting */
589 xfs_trans_mod_dquot_byino(*tpp, ip, XFS_TRANS_DQ_BCOUNT, 555 xfs_trans_mod_dquot_byino(*tpp, ip, XFS_TRANS_DQ_BCOUNT,
590 -(long)irec.br_blockcount); 556 -(long)del.br_blockcount);
591 557
592 /* Roll the transaction */ 558 /* Roll the transaction */
593 error = xfs_defer_finish(tpp, &dfops, ip); 559 error = xfs_defer_finish(tpp, &dfops, ip);
@@ -597,15 +563,18 @@ xfs_reflink_cancel_cow_blocks(
597 } 563 }
598 564
599 /* Remove the mapping from the CoW fork. */ 565 /* Remove the mapping from the CoW fork. */
600 error = xfs_bunmapi_cow(ip, &irec); 566 xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
601 if (error)
602 break;
603 } 567 }
604 568
605 /* Roll on... */ 569 if (++idx >= ifp->if_bytes / sizeof(struct xfs_bmbt_rec))
606 offset_fsb = irec.br_startoff + irec.br_blockcount; 570 break;
571 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
607 } 572 }
608 573
574 /* clear tag if cow fork is emptied */
575 if (!ifp->if_bytes)
576 xfs_inode_clear_cowblocks_tag(ip);
577
609 return error; 578 return error;
610} 579}
611 580
@@ -668,25 +637,26 @@ xfs_reflink_end_cow(
668 xfs_off_t offset, 637 xfs_off_t offset,
669 xfs_off_t count) 638 xfs_off_t count)
670{ 639{
671 struct xfs_bmbt_irec irec; 640 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
672 struct xfs_bmbt_irec uirec; 641 struct xfs_bmbt_irec got, prev, del;
673 struct xfs_trans *tp; 642 struct xfs_trans *tp;
674 xfs_fileoff_t offset_fsb; 643 xfs_fileoff_t offset_fsb;
675 xfs_fileoff_t end_fsb; 644 xfs_fileoff_t end_fsb;
676 xfs_filblks_t count_fsb;
677 xfs_fsblock_t firstfsb; 645 xfs_fsblock_t firstfsb;
678 struct xfs_defer_ops dfops; 646 struct xfs_defer_ops dfops;
679 int error; 647 int error, eof = 0;
680 unsigned int resblks; 648 unsigned int resblks;
681 xfs_filblks_t ilen;
682 xfs_filblks_t rlen; 649 xfs_filblks_t rlen;
683 int nimaps; 650 xfs_extnum_t idx;
684 651
685 trace_xfs_reflink_end_cow(ip, offset, count); 652 trace_xfs_reflink_end_cow(ip, offset, count);
686 653
654 /* No COW extents? That's easy! */
655 if (ifp->if_bytes == 0)
656 return 0;
657
687 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset); 658 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset);
688 end_fsb = XFS_B_TO_FSB(ip->i_mount, offset + count); 659 end_fsb = XFS_B_TO_FSB(ip->i_mount, offset + count);
689 count_fsb = (xfs_filblks_t)(end_fsb - offset_fsb);
690 660
691 /* Start a rolling transaction to switch the mappings */ 661 /* Start a rolling transaction to switch the mappings */
692 resblks = XFS_EXTENTADD_SPACE_RES(ip->i_mount, XFS_DATA_FORK); 662 resblks = XFS_EXTENTADD_SPACE_RES(ip->i_mount, XFS_DATA_FORK);
@@ -698,72 +668,65 @@ xfs_reflink_end_cow(
698 xfs_ilock(ip, XFS_ILOCK_EXCL); 668 xfs_ilock(ip, XFS_ILOCK_EXCL);
699 xfs_trans_ijoin(tp, ip, 0); 669 xfs_trans_ijoin(tp, ip, 0);
700 670
701 /* Go find the old extent in the CoW fork. */ 671 xfs_bmap_search_extents(ip, end_fsb - 1, XFS_COW_FORK, &eof, &idx,
702 while (offset_fsb < end_fsb) { 672 &got, &prev);
703 /* Read extent from the source file */
704 nimaps = 1;
705 count_fsb = (xfs_filblks_t)(end_fsb - offset_fsb);
706 error = xfs_bmapi_read(ip, offset_fsb, count_fsb, &irec,
707 &nimaps, XFS_BMAPI_COWFORK);
708 if (error)
709 goto out_cancel;
710 ASSERT(nimaps == 1);
711 673
712 ASSERT(irec.br_startblock != DELAYSTARTBLOCK); 674 /* If there is a hole at end_fsb - 1 go to the previous extent */
713 trace_xfs_reflink_cow_remap(ip, &irec); 675 if (eof || got.br_startoff > end_fsb) {
676 ASSERT(idx > 0);
677 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, --idx), &got);
678 }
714 679
715 /* 680 /* Walk backwards until we're out of the I/O range... */
716 * We can have a hole in the CoW fork if part of a directio 681 while (got.br_startoff + got.br_blockcount > offset_fsb) {
717 * write is CoW but part of it isn't. 682 del = got;
718 */ 683 xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
719 rlen = ilen = irec.br_blockcount; 684
720 if (irec.br_startblock == HOLESTARTBLOCK) 685 /* Extent delete may have bumped idx forward */
686 if (!del.br_blockcount) {
687 idx--;
721 goto next_extent; 688 goto next_extent;
689 }
690
691 ASSERT(!isnullstartblock(got.br_startblock));
722 692
723 /* Unmap the old blocks in the data fork. */ 693 /* Unmap the old blocks in the data fork. */
724 while (rlen) { 694 xfs_defer_init(&dfops, &firstfsb);
725 xfs_defer_init(&dfops, &firstfsb); 695 rlen = del.br_blockcount;
726 error = __xfs_bunmapi(tp, ip, irec.br_startoff, 696 error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1,
727 &rlen, 0, 1, &firstfsb, &dfops); 697 &firstfsb, &dfops);
728 if (error) 698 if (error)
729 goto out_defer; 699 goto out_defer;
730
731 /*
732 * Trim the extent to whatever got unmapped.
733 * Remember, bunmapi works backwards.
734 */
735 uirec.br_startblock = irec.br_startblock + rlen;
736 uirec.br_startoff = irec.br_startoff + rlen;
737 uirec.br_blockcount = irec.br_blockcount - rlen;
738 irec.br_blockcount = rlen;
739 trace_xfs_reflink_cow_remap_piece(ip, &uirec);
740 700
741 /* Free the CoW orphan record. */ 701 /* Trim the extent to whatever got unmapped. */
742 error = xfs_refcount_free_cow_extent(tp->t_mountp, 702 if (rlen) {
743 &dfops, uirec.br_startblock, 703 xfs_trim_extent(&del, del.br_startoff + rlen,
744 uirec.br_blockcount); 704 del.br_blockcount - rlen);
745 if (error) 705 }
746 goto out_defer; 706 trace_xfs_reflink_cow_remap(ip, &del);
747 707
748 /* Map the new blocks into the data fork. */ 708 /* Free the CoW orphan record. */
749 error = xfs_bmap_map_extent(tp->t_mountp, &dfops, 709 error = xfs_refcount_free_cow_extent(tp->t_mountp, &dfops,
750 ip, &uirec); 710 del.br_startblock, del.br_blockcount);
751 if (error) 711 if (error)
752 goto out_defer; 712 goto out_defer;
753 713
754 /* Remove the mapping from the CoW fork. */ 714 /* Map the new blocks into the data fork. */
755 error = xfs_bunmapi_cow(ip, &uirec); 715 error = xfs_bmap_map_extent(tp->t_mountp, &dfops, ip, &del);
756 if (error) 716 if (error)
757 goto out_defer; 717 goto out_defer;
758 718
759 error = xfs_defer_finish(&tp, &dfops, ip); 719 /* Remove the mapping from the CoW fork. */
760 if (error) 720 xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
761 goto out_defer; 721
762 } 722 error = xfs_defer_finish(&tp, &dfops, ip);
723 if (error)
724 goto out_defer;
763 725
764next_extent: 726next_extent:
765 /* Roll on... */ 727 if (idx < 0)
766 offset_fsb = irec.br_startoff + ilen; 728 break;
729 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
767 } 730 }
768 731
769 error = xfs_trans_commit(tp); 732 error = xfs_trans_commit(tp);
@@ -774,7 +737,6 @@ next_extent:
774 737
775out_defer: 738out_defer:
776 xfs_defer_cancel(&dfops); 739 xfs_defer_cancel(&dfops);
777out_cancel:
778 xfs_trans_cancel(tp); 740 xfs_trans_cancel(tp);
779 xfs_iunlock(ip, XFS_ILOCK_EXCL); 741 xfs_iunlock(ip, XFS_ILOCK_EXCL);
780out: 742out:
@@ -1312,19 +1274,26 @@ out_error:
1312 */ 1274 */
1313int 1275int
1314xfs_reflink_remap_range( 1276xfs_reflink_remap_range(
1315 struct xfs_inode *src, 1277 struct file *file_in,
1316 xfs_off_t srcoff, 1278 loff_t pos_in,
1317 struct xfs_inode *dest, 1279 struct file *file_out,
1318 xfs_off_t destoff, 1280 loff_t pos_out,
1319 xfs_off_t len, 1281 u64 len,
1320 unsigned int flags) 1282 bool is_dedupe)
1321{ 1283{
1284 struct inode *inode_in = file_inode(file_in);
1285 struct xfs_inode *src = XFS_I(inode_in);
1286 struct inode *inode_out = file_inode(file_out);
1287 struct xfs_inode *dest = XFS_I(inode_out);
1322 struct xfs_mount *mp = src->i_mount; 1288 struct xfs_mount *mp = src->i_mount;
1289 loff_t bs = inode_out->i_sb->s_blocksize;
1290 bool same_inode = (inode_in == inode_out);
1323 xfs_fileoff_t sfsbno, dfsbno; 1291 xfs_fileoff_t sfsbno, dfsbno;
1324 xfs_filblks_t fsblen; 1292 xfs_filblks_t fsblen;
1325 int error;
1326 xfs_extlen_t cowextsize; 1293 xfs_extlen_t cowextsize;
1327 bool is_same; 1294 loff_t isize;
1295 ssize_t ret;
1296 loff_t blen;
1328 1297
1329 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1298 if (!xfs_sb_version_hasreflink(&mp->m_sb))
1330 return -EOPNOTSUPP; 1299 return -EOPNOTSUPP;
@@ -1332,17 +1301,8 @@ xfs_reflink_remap_range(
1332 if (XFS_FORCED_SHUTDOWN(mp)) 1301 if (XFS_FORCED_SHUTDOWN(mp))
1333 return -EIO; 1302 return -EIO;
1334 1303
1335 /* Don't reflink realtime inodes */
1336 if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest))
1337 return -EINVAL;
1338
1339 if (flags & ~XFS_REFLINK_ALL)
1340 return -EINVAL;
1341
1342 trace_xfs_reflink_remap_range(src, srcoff, len, dest, destoff);
1343
1344 /* Lock both files against IO */ 1304 /* Lock both files against IO */
1345 if (src->i_ino == dest->i_ino) { 1305 if (same_inode) {
1346 xfs_ilock(src, XFS_IOLOCK_EXCL); 1306 xfs_ilock(src, XFS_IOLOCK_EXCL);
1347 xfs_ilock(src, XFS_MMAPLOCK_EXCL); 1307 xfs_ilock(src, XFS_MMAPLOCK_EXCL);
1348 } else { 1308 } else {
@@ -1350,39 +1310,126 @@ xfs_reflink_remap_range(
1350 xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); 1310 xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL);
1351 } 1311 }
1352 1312
1313 /* Don't touch certain kinds of inodes */
1314 ret = -EPERM;
1315 if (IS_IMMUTABLE(inode_out))
1316 goto out_unlock;
1317
1318 ret = -ETXTBSY;
1319 if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out))
1320 goto out_unlock;
1321
1322
1323 /* Don't reflink dirs, pipes, sockets... */
1324 ret = -EISDIR;
1325 if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
1326 goto out_unlock;
1327 ret = -EINVAL;
1328 if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode))
1329 goto out_unlock;
1330 if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
1331 goto out_unlock;
1332
1333 /* Don't reflink realtime inodes */
1334 if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest))
1335 goto out_unlock;
1336
1337 /* Don't share DAX file data for now. */
1338 if (IS_DAX(inode_in) || IS_DAX(inode_out))
1339 goto out_unlock;
1340
1341 /* Are we going all the way to the end? */
1342 isize = i_size_read(inode_in);
1343 if (isize == 0) {
1344 ret = 0;
1345 goto out_unlock;
1346 }
1347
1348 if (len == 0)
1349 len = isize - pos_in;
1350
1351 /* Ensure offsets don't wrap and the input is inside i_size */
1352 if (pos_in + len < pos_in || pos_out + len < pos_out ||
1353 pos_in + len > isize)
1354 goto out_unlock;
1355
1356 /* Don't allow dedupe past EOF in the dest file */
1357 if (is_dedupe) {
1358 loff_t disize;
1359
1360 disize = i_size_read(inode_out);
1361 if (pos_out >= disize || pos_out + len > disize)
1362 goto out_unlock;
1363 }
1364
1365 /* If we're linking to EOF, continue to the block boundary. */
1366 if (pos_in + len == isize)
1367 blen = ALIGN(isize, bs) - pos_in;
1368 else
1369 blen = len;
1370
1371 /* Only reflink if we're aligned to block boundaries */
1372 if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) ||
1373 !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs))
1374 goto out_unlock;
1375
1376 /* Don't allow overlapped reflink within the same file */
1377 if (same_inode) {
1378 if (pos_out + blen > pos_in && pos_out < pos_in + blen)
1379 goto out_unlock;
1380 }
1381
1382 /* Wait for the completion of any pending IOs on both files */
1383 inode_dio_wait(inode_in);
1384 if (!same_inode)
1385 inode_dio_wait(inode_out);
1386
1387 ret = filemap_write_and_wait_range(inode_in->i_mapping,
1388 pos_in, pos_in + len - 1);
1389 if (ret)
1390 goto out_unlock;
1391
1392 ret = filemap_write_and_wait_range(inode_out->i_mapping,
1393 pos_out, pos_out + len - 1);
1394 if (ret)
1395 goto out_unlock;
1396
1397 trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out);
1398
1353 /* 1399 /*
1354 * Check that the extents are the same. 1400 * Check that the extents are the same.
1355 */ 1401 */
1356 if (flags & XFS_REFLINK_DEDUPE) { 1402 if (is_dedupe) {
1357 is_same = false; 1403 bool is_same = false;
1358 error = xfs_compare_extents(VFS_I(src), srcoff, VFS_I(dest), 1404
1359 destoff, len, &is_same); 1405 ret = xfs_compare_extents(inode_in, pos_in, inode_out, pos_out,
1360 if (error) 1406 len, &is_same);
1361 goto out_error; 1407 if (ret)
1408 goto out_unlock;
1362 if (!is_same) { 1409 if (!is_same) {
1363 error = -EBADE; 1410 ret = -EBADE;
1364 goto out_error; 1411 goto out_unlock;
1365 } 1412 }
1366 } 1413 }
1367 1414
1368 error = xfs_reflink_set_inode_flag(src, dest); 1415 ret = xfs_reflink_set_inode_flag(src, dest);
1369 if (error) 1416 if (ret)
1370 goto out_error; 1417 goto out_unlock;
1371 1418
1372 /* 1419 /*
1373 * Invalidate the page cache so that we can clear any CoW mappings 1420 * Invalidate the page cache so that we can clear any CoW mappings
1374 * in the destination file. 1421 * in the destination file.
1375 */ 1422 */
1376 truncate_inode_pages_range(&VFS_I(dest)->i_data, destoff, 1423 truncate_inode_pages_range(&inode_out->i_data, pos_out,
1377 PAGE_ALIGN(destoff + len) - 1); 1424 PAGE_ALIGN(pos_out + len) - 1);
1378 1425
1379 dfsbno = XFS_B_TO_FSBT(mp, destoff); 1426 dfsbno = XFS_B_TO_FSBT(mp, pos_out);
1380 sfsbno = XFS_B_TO_FSBT(mp, srcoff); 1427 sfsbno = XFS_B_TO_FSBT(mp, pos_in);
1381 fsblen = XFS_B_TO_FSB(mp, len); 1428 fsblen = XFS_B_TO_FSB(mp, len);
1382 error = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen, 1429 ret = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen,
1383 destoff + len); 1430 pos_out + len);
1384 if (error) 1431 if (ret)
1385 goto out_error; 1432 goto out_unlock;
1386 1433
1387 /* 1434 /*
1388 * Carry the cowextsize hint from src to dest if we're sharing the 1435 * Carry the cowextsize hint from src to dest if we're sharing the
@@ -1390,26 +1437,24 @@ xfs_reflink_remap_range(
1390 * has a cowextsize hint, and the destination file does not. 1437 * has a cowextsize hint, and the destination file does not.
1391 */ 1438 */
1392 cowextsize = 0; 1439 cowextsize = 0;
1393 if (srcoff == 0 && len == i_size_read(VFS_I(src)) && 1440 if (pos_in == 0 && len == i_size_read(inode_in) &&
1394 (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) && 1441 (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) &&
1395 destoff == 0 && len >= i_size_read(VFS_I(dest)) && 1442 pos_out == 0 && len >= i_size_read(inode_out) &&
1396 !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) 1443 !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
1397 cowextsize = src->i_d.di_cowextsize; 1444 cowextsize = src->i_d.di_cowextsize;
1398 1445
1399 error = xfs_reflink_update_dest(dest, destoff + len, cowextsize); 1446 ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize);
1400 if (error)
1401 goto out_error;
1402 1447
1403out_error: 1448out_unlock:
1404 xfs_iunlock(src, XFS_MMAPLOCK_EXCL); 1449 xfs_iunlock(src, XFS_MMAPLOCK_EXCL);
1405 xfs_iunlock(src, XFS_IOLOCK_EXCL); 1450 xfs_iunlock(src, XFS_IOLOCK_EXCL);
1406 if (src->i_ino != dest->i_ino) { 1451 if (src->i_ino != dest->i_ino) {
1407 xfs_iunlock(dest, XFS_MMAPLOCK_EXCL); 1452 xfs_iunlock(dest, XFS_MMAPLOCK_EXCL);
1408 xfs_iunlock(dest, XFS_IOLOCK_EXCL); 1453 xfs_iunlock(dest, XFS_IOLOCK_EXCL);
1409 } 1454 }
1410 if (error) 1455 if (ret)
1411 trace_xfs_reflink_remap_range_error(dest, error, _RET_IP_); 1456 trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_);
1412 return error; 1457 return ret;
1413} 1458}
1414 1459
1415/* 1460/*
diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
index 5dc3c8ac12aa..fad11607c9ad 100644
--- a/fs/xfs/xfs_reflink.h
+++ b/fs/xfs/xfs_reflink.h
@@ -26,8 +26,8 @@ extern int xfs_reflink_find_shared(struct xfs_mount *mp, xfs_agnumber_t agno,
26extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip, 26extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
27 struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed); 27 struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed);
28 28
29extern int xfs_reflink_reserve_cow_range(struct xfs_inode *ip, 29extern int xfs_reflink_reserve_cow(struct xfs_inode *ip,
30 xfs_off_t offset, xfs_off_t count); 30 struct xfs_bmbt_irec *imap, bool *shared);
31extern int xfs_reflink_allocate_cow_range(struct xfs_inode *ip, 31extern int xfs_reflink_allocate_cow_range(struct xfs_inode *ip,
32 xfs_off_t offset, xfs_off_t count); 32 xfs_off_t offset, xfs_off_t count);
33extern bool xfs_reflink_find_cow_mapping(struct xfs_inode *ip, xfs_off_t offset, 33extern bool xfs_reflink_find_cow_mapping(struct xfs_inode *ip, xfs_off_t offset,
@@ -43,11 +43,8 @@ extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
43extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, 43extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
44 xfs_off_t count); 44 xfs_off_t count);
45extern int xfs_reflink_recover_cow(struct xfs_mount *mp); 45extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
46#define XFS_REFLINK_DEDUPE 1 /* only reflink if contents match */ 46extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
47#define XFS_REFLINK_ALL (XFS_REFLINK_DEDUPE) 47 struct file *file_out, loff_t pos_out, u64 len, bool is_dedupe);
48extern int xfs_reflink_remap_range(struct xfs_inode *src, xfs_off_t srcoff,
49 struct xfs_inode *dest, xfs_off_t destoff, xfs_off_t len,
50 unsigned int flags);
51extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, 48extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
52 struct xfs_trans **tpp); 49 struct xfs_trans **tpp);
53extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset, 50extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 5f8d55d29a11..276d3023d60f 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -512,13 +512,13 @@ static struct attribute *xfs_error_attrs[] = {
512}; 512};
513 513
514 514
515struct kobj_type xfs_error_cfg_ktype = { 515static struct kobj_type xfs_error_cfg_ktype = {
516 .release = xfs_sysfs_release, 516 .release = xfs_sysfs_release,
517 .sysfs_ops = &xfs_sysfs_ops, 517 .sysfs_ops = &xfs_sysfs_ops,
518 .default_attrs = xfs_error_attrs, 518 .default_attrs = xfs_error_attrs,
519}; 519};
520 520
521struct kobj_type xfs_error_ktype = { 521static struct kobj_type xfs_error_ktype = {
522 .release = xfs_sysfs_release, 522 .release = xfs_sysfs_release,
523 .sysfs_ops = &xfs_sysfs_ops, 523 .sysfs_ops = &xfs_sysfs_ops,
524}; 524};
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index ad188d3a83f3..0907752be62d 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -3346,7 +3346,7 @@ DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_alloc);
3346DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found); 3346DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
3347DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc); 3347DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
3348 3348
3349DEFINE_RW_EVENT(xfs_reflink_reserve_cow_range); 3349DEFINE_RW_EVENT(xfs_reflink_reserve_cow);
3350DEFINE_RW_EVENT(xfs_reflink_allocate_cow_range); 3350DEFINE_RW_EVENT(xfs_reflink_allocate_cow_range);
3351 3351
3352DEFINE_INODE_IREC_EVENT(xfs_reflink_bounce_dio_write); 3352DEFINE_INODE_IREC_EVENT(xfs_reflink_bounce_dio_write);
@@ -3356,9 +3356,7 @@ DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_irec);
3356DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range); 3356DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range);
3357DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow); 3357DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow);
3358DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap); 3358DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap);
3359DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap_piece);
3360 3359
3361DEFINE_INODE_ERROR_EVENT(xfs_reflink_reserve_cow_range_error);
3362DEFINE_INODE_ERROR_EVENT(xfs_reflink_allocate_cow_range_error); 3360DEFINE_INODE_ERROR_EVENT(xfs_reflink_allocate_cow_range_error);
3363DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error); 3361DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error);
3364DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error); 3362DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error);
diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h
index 17a940a14477..8caa79c61703 100644
--- a/include/acpi/pcc.h
+++ b/include/acpi/pcc.h
@@ -21,7 +21,7 @@ extern void pcc_mbox_free_channel(struct mbox_chan *chan);
21static inline struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, 21static inline struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl,
22 int subspace_id) 22 int subspace_id)
23{ 23{
24 return NULL; 24 return ERR_PTR(-ENODEV);
25} 25}
26static inline void pcc_mbox_free_channel(struct mbox_chan *chan) { } 26static inline void pcc_mbox_free_channel(struct mbox_chan *chan) { }
27#endif 27#endif
diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
index 43199a049da5..63554e9f6e0c 100644
--- a/include/asm-generic/export.h
+++ b/include/asm-generic/export.h
@@ -70,7 +70,7 @@ KSYM(__kcrctab_\name):
70#include <generated/autoksyms.h> 70#include <generated/autoksyms.h>
71 71
72#define __EXPORT_SYMBOL(sym, val, sec) \ 72#define __EXPORT_SYMBOL(sym, val, sec) \
73 __cond_export_sym(sym, val, sec, config_enabled(__KSYM_##sym)) 73 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
74#define __cond_export_sym(sym, val, sec, conf) \ 74#define __cond_export_sym(sym, val, sec, conf) \
75 ___cond_export_sym(sym, val, sec, conf) 75 ___cond_export_sym(sym, val, sec, conf)
76#define ___cond_export_sym(sym, val, sec, enabled) \ 76#define ___cond_export_sym(sym, val, sec, enabled) \
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ddbeda6dbdc8..689a8b9b9c8f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -326,6 +326,7 @@ struct pci_dev;
326int acpi_pci_irq_enable (struct pci_dev *dev); 326int acpi_pci_irq_enable (struct pci_dev *dev);
327void acpi_penalize_isa_irq(int irq, int active); 327void acpi_penalize_isa_irq(int irq, int active);
328bool acpi_isa_irq_available(int irq); 328bool acpi_isa_irq_available(int irq);
329void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
329void acpi_pci_irq_disable (struct pci_dev *dev); 330void acpi_pci_irq_disable (struct pci_dev *dev);
330 331
331extern int ec_read(u8 addr, u8 *val); 332extern int ec_read(u8 addr, u8 *val);
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index af596381fa0f..a428aec36ace 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -785,7 +785,7 @@ extern struct of_device_id __clk_of_table;
785 * routines, one at of_clk_init(), and one at platform device probe 785 * routines, one at of_clk_init(), and one at platform device probe
786 */ 786 */
787#define CLK_OF_DECLARE_DRIVER(name, compat, fn) \ 787#define CLK_OF_DECLARE_DRIVER(name, compat, fn) \
788 static void name##_of_clk_init_driver(struct device_node *np) \ 788 static void __init name##_of_clk_init_driver(struct device_node *np) \
789 { \ 789 { \
790 of_node_clear_flag(np, OF_POPULATED); \ 790 of_node_clear_flag(np, OF_POPULATED); \
791 fn(np); \ 791 fn(np); \
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 5fa55fc56e18..32dc0cbd51ca 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -677,10 +677,10 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
677 if (best == table - 1) 677 if (best == table - 1)
678 return pos - table; 678 return pos - table;
679 679
680 return best - pos; 680 return best - table;
681 } 681 }
682 682
683 return best - pos; 683 return best - table;
684} 684}
685 685
686/* Works only on sorted freq-tables */ 686/* Works only on sorted freq-tables */
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 9b207a8c5af3..afe641c02dca 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -81,6 +81,7 @@ enum cpuhp_state {
81 CPUHP_AP_ARM_ARCH_TIMER_STARTING, 81 CPUHP_AP_ARM_ARCH_TIMER_STARTING,
82 CPUHP_AP_ARM_GLOBAL_TIMER_STARTING, 82 CPUHP_AP_ARM_GLOBAL_TIMER_STARTING,
83 CPUHP_AP_DUMMY_TIMER_STARTING, 83 CPUHP_AP_DUMMY_TIMER_STARTING,
84 CPUHP_AP_JCORE_TIMER_STARTING,
84 CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING, 85 CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING,
85 CPUHP_AP_ARM_TWD_STARTING, 86 CPUHP_AP_ARM_TWD_STARTING,
86 CPUHP_AP_METAG_TIMER_STARTING, 87 CPUHP_AP_METAG_TIMER_STARTING,
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 6824556d37ed..cd184bdca58f 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1169,13 +1169,6 @@ int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
1169 const char *mod_name); 1169 const char *mod_name);
1170void vmbus_driver_unregister(struct hv_driver *hv_driver); 1170void vmbus_driver_unregister(struct hv_driver *hv_driver);
1171 1171
1172static inline const char *vmbus_dev_name(const struct hv_device *device_obj)
1173{
1174 const struct kobject *kobj = &device_obj->device.kobj;
1175
1176 return kobj->name;
1177}
1178
1179void vmbus_hvsock_device_unregister(struct vmbus_channel *channel); 1172void vmbus_hvsock_device_unregister(struct vmbus_channel *channel);
1180 1173
1181int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, 1174int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
diff --git a/include/linux/io.h b/include/linux/io.h
index e2c8419278c1..82ef36eac8a1 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -141,4 +141,26 @@ enum {
141void *memremap(resource_size_t offset, size_t size, unsigned long flags); 141void *memremap(resource_size_t offset, size_t size, unsigned long flags);
142void memunmap(void *addr); 142void memunmap(void *addr);
143 143
144/*
145 * On x86 PAT systems we have memory tracking that keeps track of
146 * the allowed mappings on memory ranges. This tracking works for
147 * all the in-kernel mapping APIs (ioremap*), but where the user
148 * wishes to map a range from a physical device into user memory
149 * the tracking won't be updated. This API is to be used by
150 * drivers which remap physical device pages into userspace,
151 * and wants to make sure they are mapped WC and not UC.
152 */
153#ifndef arch_io_reserve_memtype_wc
154static inline int arch_io_reserve_memtype_wc(resource_size_t base,
155 resource_size_t size)
156{
157 return 0;
158}
159
160static inline void arch_io_free_memtype_wc(resource_size_t base,
161 resource_size_t size)
162{
163}
164#endif
165
144#endif /* _LINUX_IO_H */ 166#endif /* _LINUX_IO_H */
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index e63e288dee83..7892f55a1866 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -19,11 +19,15 @@ struct vm_fault;
19#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ 19#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */
20 20
21/* 21/*
22 * Flags for iomap mappings: 22 * Flags for all iomap mappings:
23 */ 23 */
24#define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */ 24#define IOMAP_F_NEW 0x01 /* blocks have been newly allocated */
25#define IOMAP_F_SHARED 0x02 /* block shared with another file */ 25
26#define IOMAP_F_NEW 0x04 /* blocks have been newly allocated */ 26/*
27 * Flags that only need to be reported for IOMAP_REPORT requests:
28 */
29#define IOMAP_F_MERGED 0x10 /* contains multiple blocks/extents */
30#define IOMAP_F_SHARED 0x20 /* block shared with another file */
27 31
28/* 32/*
29 * Magic value for blkno: 33 * Magic value for blkno:
@@ -42,8 +46,9 @@ struct iomap {
42/* 46/*
43 * Flags for iomap_begin / iomap_end. No flag implies a read. 47 * Flags for iomap_begin / iomap_end. No flag implies a read.
44 */ 48 */
45#define IOMAP_WRITE (1 << 0) 49#define IOMAP_WRITE (1 << 0) /* writing, must allocate blocks */
46#define IOMAP_ZERO (1 << 1) 50#define IOMAP_ZERO (1 << 1) /* zeroing operation, may skip holes */
51#define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */
47 52
48struct iomap_ops { 53struct iomap_ops {
49 /* 54 /*
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 7e9a789be5e0..ca1ad9ebbc92 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -123,12 +123,12 @@ struct inet6_skb_parm {
123}; 123};
124 124
125#if defined(CONFIG_NET_L3_MASTER_DEV) 125#if defined(CONFIG_NET_L3_MASTER_DEV)
126static inline bool skb_l3mdev_slave(__u16 flags) 126static inline bool ipv6_l3mdev_skb(__u16 flags)
127{ 127{
128 return flags & IP6SKB_L3SLAVE; 128 return flags & IP6SKB_L3SLAVE;
129} 129}
130#else 130#else
131static inline bool skb_l3mdev_slave(__u16 flags) 131static inline bool ipv6_l3mdev_skb(__u16 flags)
132{ 132{
133 return false; 133 return false;
134} 134}
@@ -139,11 +139,22 @@ static inline bool skb_l3mdev_slave(__u16 flags)
139 139
140static inline int inet6_iif(const struct sk_buff *skb) 140static inline int inet6_iif(const struct sk_buff *skb)
141{ 141{
142 bool l3_slave = skb_l3mdev_slave(IP6CB(skb)->flags); 142 bool l3_slave = ipv6_l3mdev_skb(IP6CB(skb)->flags);
143 143
144 return l3_slave ? skb->skb_iif : IP6CB(skb)->iif; 144 return l3_slave ? skb->skb_iif : IP6CB(skb)->iif;
145} 145}
146 146
147/* can not be used in TCP layer after tcp_v6_fill_cb */
148static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb)
149{
150#if defined(CONFIG_NET_L3_MASTER_DEV)
151 if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
152 ipv6_l3mdev_skb(IP6CB(skb)->flags))
153 return true;
154#endif
155 return false;
156}
157
147struct tcp6_request_sock { 158struct tcp6_request_sock {
148 struct tcp_request_sock tcp6rsk_tcp; 159 struct tcp_request_sock tcp6rsk_tcp;
149}; 160};
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index 8361c8d3edd1..b7e34313cdfe 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -290,7 +290,7 @@
290#define GITS_BASER_TYPE_SHIFT (56) 290#define GITS_BASER_TYPE_SHIFT (56)
291#define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7) 291#define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7)
292#define GITS_BASER_ENTRY_SIZE_SHIFT (48) 292#define GITS_BASER_ENTRY_SIZE_SHIFT (48)
293#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0xff) + 1) 293#define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0x1f) + 1)
294#define GITS_BASER_SHAREABILITY_SHIFT (10) 294#define GITS_BASER_SHAREABILITY_SHIFT (10)
295#define GITS_BASER_InnerShareable \ 295#define GITS_BASER_InnerShareable \
296 GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable) 296 GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable)
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 15ec117ec537..8f2e059e4d45 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -31,7 +31,6 @@
31 * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when 31 * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
32 * the last step cherry picks the 2nd arg, we get a zero. 32 * the last step cherry picks the 2nd arg, we get a zero.
33 */ 33 */
34#define config_enabled(cfg) ___is_defined(cfg)
35#define __is_defined(x) ___is_defined(x) 34#define __is_defined(x) ___is_defined(x)
36#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val) 35#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
37#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0) 36#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
@@ -41,13 +40,13 @@
41 * otherwise. For boolean options, this is equivalent to 40 * otherwise. For boolean options, this is equivalent to
42 * IS_ENABLED(CONFIG_FOO). 41 * IS_ENABLED(CONFIG_FOO).
43 */ 42 */
44#define IS_BUILTIN(option) config_enabled(option) 43#define IS_BUILTIN(option) __is_defined(option)
45 44
46/* 45/*
47 * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0 46 * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
48 * otherwise. 47 * otherwise.
49 */ 48 */
50#define IS_MODULE(option) config_enabled(option##_MODULE) 49#define IS_MODULE(option) __is_defined(option##_MODULE)
51 50
52/* 51/*
53 * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled 52 * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index f6a164297358..3be7abd6e722 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -1399,7 +1399,8 @@ void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr,
1399 u32 *lkey, u32 *rkey); 1399 u32 *lkey, u32 *rkey);
1400int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr); 1400int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
1401int mlx4_SYNC_TPT(struct mlx4_dev *dev); 1401int mlx4_SYNC_TPT(struct mlx4_dev *dev);
1402int mlx4_test_interrupts(struct mlx4_dev *dev); 1402int mlx4_test_interrupt(struct mlx4_dev *dev, int vector);
1403int mlx4_test_async(struct mlx4_dev *dev);
1403int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier, 1404int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier,
1404 const u32 offset[], u32 value[], 1405 const u32 offset[], u32 value[],
1405 size_t array_len, u8 port); 1406 size_t array_len, u8 port);
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 85c4786427e4..ecc451d89ccd 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -418,8 +418,12 @@ struct mlx5_core_health {
418 u32 prev; 418 u32 prev;
419 int miss_counter; 419 int miss_counter;
420 bool sick; 420 bool sick;
421 /* wq spinlock to synchronize draining */
422 spinlock_t wq_lock;
421 struct workqueue_struct *wq; 423 struct workqueue_struct *wq;
424 unsigned long flags;
422 struct work_struct work; 425 struct work_struct work;
426 struct delayed_work recover_work;
423}; 427};
424 428
425struct mlx5_cq_table { 429struct mlx5_cq_table {
@@ -626,10 +630,6 @@ struct mlx5_db {
626}; 630};
627 631
628enum { 632enum {
629 MLX5_DB_PER_PAGE = PAGE_SIZE / L1_CACHE_BYTES,
630};
631
632enum {
633 MLX5_COMP_EQ_SIZE = 1024, 633 MLX5_COMP_EQ_SIZE = 1024,
634}; 634};
635 635
@@ -638,13 +638,6 @@ enum {
638 MLX5_PTYS_EN = 1 << 2, 638 MLX5_PTYS_EN = 1 << 2,
639}; 639};
640 640
641struct mlx5_db_pgdir {
642 struct list_head list;
643 DECLARE_BITMAP(bitmap, MLX5_DB_PER_PAGE);
644 __be32 *db_page;
645 dma_addr_t db_dma;
646};
647
648typedef void (*mlx5_cmd_cbk_t)(int status, void *context); 641typedef void (*mlx5_cmd_cbk_t)(int status, void *context);
649 642
650struct mlx5_cmd_work_ent { 643struct mlx5_cmd_work_ent {
@@ -789,6 +782,7 @@ void mlx5_health_cleanup(struct mlx5_core_dev *dev);
789int mlx5_health_init(struct mlx5_core_dev *dev); 782int mlx5_health_init(struct mlx5_core_dev *dev);
790void mlx5_start_health_poll(struct mlx5_core_dev *dev); 783void mlx5_start_health_poll(struct mlx5_core_dev *dev);
791void mlx5_stop_health_poll(struct mlx5_core_dev *dev); 784void mlx5_stop_health_poll(struct mlx5_core_dev *dev);
785void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
792int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size, 786int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size,
793 struct mlx5_buf *buf, int node); 787 struct mlx5_buf *buf, int node);
794int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf); 788int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ffbd72979ee7..a92c8d73aeaf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1271,10 +1271,6 @@ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *
1271extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, 1271extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
1272 void *buf, int len, unsigned int gup_flags); 1272 void *buf, int len, unsigned int gup_flags);
1273 1273
1274long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1275 unsigned long start, unsigned long nr_pages,
1276 unsigned int foll_flags, struct page **pages,
1277 struct vm_area_struct **vmas, int *nonblocking);
1278long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm, 1274long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
1279 unsigned long start, unsigned long nr_pages, 1275 unsigned long start, unsigned long nr_pages,
1280 unsigned int gup_flags, struct page **pages, 1276 unsigned int gup_flags, struct page **pages,
@@ -1391,7 +1387,7 @@ static inline int stack_guard_page_end(struct vm_area_struct *vma,
1391 !vma_growsup(vma->vm_next, addr); 1387 !vma_growsup(vma->vm_next, addr);
1392} 1388}
1393 1389
1394int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t); 1390int vma_is_stack_for_current(struct vm_area_struct *vma);
1395 1391
1396extern unsigned long move_page_tables(struct vm_area_struct *vma, 1392extern unsigned long move_page_tables(struct vm_area_struct *vma,
1397 unsigned long old_addr, struct vm_area_struct *new_vma, 1393 unsigned long old_addr, struct vm_area_struct *new_vma,
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7f2ae99e5daf..0f088f3a2fed 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -440,33 +440,7 @@ struct zone {
440 seqlock_t span_seqlock; 440 seqlock_t span_seqlock;
441#endif 441#endif
442 442
443 /* 443 int initialized;
444 * wait_table -- the array holding the hash table
445 * wait_table_hash_nr_entries -- the size of the hash table array
446 * wait_table_bits -- wait_table_size == (1 << wait_table_bits)
447 *
448 * The purpose of all these is to keep track of the people
449 * waiting for a page to become available and make them
450 * runnable again when possible. The trouble is that this
451 * consumes a lot of space, especially when so few things
452 * wait on pages at a given time. So instead of using
453 * per-page waitqueues, we use a waitqueue hash table.
454 *
455 * The bucket discipline is to sleep on the same queue when
456 * colliding and wake all in that wait queue when removing.
457 * When something wakes, it must check to be sure its page is
458 * truly available, a la thundering herd. The cost of a
459 * collision is great, but given the expected load of the
460 * table, they should be so rare as to be outweighed by the
461 * benefits from the saved space.
462 *
463 * __wait_on_page_locked() and unlock_page() in mm/filemap.c, are the
464 * primary users of these fields, and in mm/page_alloc.c
465 * free_area_init_core() performs the initialization of them.
466 */
467 wait_queue_head_t *wait_table;
468 unsigned long wait_table_hash_nr_entries;
469 unsigned long wait_table_bits;
470 444
471 /* Write-intensive fields used from the page allocator */ 445 /* Write-intensive fields used from the page allocator */
472 ZONE_PADDING(_pad1_) 446 ZONE_PADDING(_pad1_)
@@ -546,7 +520,7 @@ static inline bool zone_spans_pfn(const struct zone *zone, unsigned long pfn)
546 520
547static inline bool zone_is_initialized(struct zone *zone) 521static inline bool zone_is_initialized(struct zone *zone)
548{ 522{
549 return !!zone->wait_table; 523 return zone->initialized;
550} 524}
551 525
552static inline bool zone_is_empty(struct zone *zone) 526static inline bool zone_is_empty(struct zone *zone)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 136ae6bbe81e..91ee3643ccc8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2169,7 +2169,10 @@ struct napi_gro_cb {
2169 /* Used to determine if flush_id can be ignored */ 2169 /* Used to determine if flush_id can be ignored */
2170 u8 is_atomic:1; 2170 u8 is_atomic:1;
2171 2171
2172 /* 5 bit hole */ 2172 /* Number of gro_receive callbacks this packet already went through */
2173 u8 recursion_counter:4;
2174
2175 /* 1 bit hole */
2173 2176
2174 /* used to support CHECKSUM_COMPLETE for tunneling protocols */ 2177 /* used to support CHECKSUM_COMPLETE for tunneling protocols */
2175 __wsum csum; 2178 __wsum csum;
@@ -2180,6 +2183,40 @@ struct napi_gro_cb {
2180 2183
2181#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb) 2184#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb)
2182 2185
2186#define GRO_RECURSION_LIMIT 15
2187static inline int gro_recursion_inc_test(struct sk_buff *skb)
2188{
2189 return ++NAPI_GRO_CB(skb)->recursion_counter == GRO_RECURSION_LIMIT;
2190}
2191
2192typedef struct sk_buff **(*gro_receive_t)(struct sk_buff **, struct sk_buff *);
2193static inline struct sk_buff **call_gro_receive(gro_receive_t cb,
2194 struct sk_buff **head,
2195 struct sk_buff *skb)
2196{
2197 if (unlikely(gro_recursion_inc_test(skb))) {
2198 NAPI_GRO_CB(skb)->flush |= 1;
2199 return NULL;
2200 }
2201
2202 return cb(head, skb);
2203}
2204
2205typedef struct sk_buff **(*gro_receive_sk_t)(struct sock *, struct sk_buff **,
2206 struct sk_buff *);
2207static inline struct sk_buff **call_gro_receive_sk(gro_receive_sk_t cb,
2208 struct sock *sk,
2209 struct sk_buff **head,
2210 struct sk_buff *skb)
2211{
2212 if (unlikely(gro_recursion_inc_test(skb))) {
2213 NAPI_GRO_CB(skb)->flush |= 1;
2214 return NULL;
2215 }
2216
2217 return cb(sk, head, skb);
2218}
2219
2183struct packet_type { 2220struct packet_type {
2184 __be16 type; /* This is really htons(ether_type). */ 2221 __be16 type; /* This is really htons(ether_type). */
2185 struct net_device *dev; /* NULL is wildcarded here */ 2222 struct net_device *dev; /* NULL is wildcarded here */
@@ -3877,7 +3914,7 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
3877 ldev = netdev_all_lower_get_next(dev, &(iter))) 3914 ldev = netdev_all_lower_get_next(dev, &(iter)))
3878 3915
3879#define netdev_for_each_all_lower_dev_rcu(dev, ldev, iter) \ 3916#define netdev_for_each_all_lower_dev_rcu(dev, ldev, iter) \
3880 for (iter = (dev)->all_adj_list.lower.next, \ 3917 for (iter = &(dev)->all_adj_list.lower, \
3881 ldev = netdev_all_lower_get_next_rcu(dev, &(iter)); \ 3918 ldev = netdev_all_lower_get_next_rcu(dev, &(iter)); \
3882 ldev; \ 3919 ldev; \
3883 ldev = netdev_all_lower_get_next_rcu(dev, &(iter))) 3920 ldev = netdev_all_lower_get_next_rcu(dev, &(iter)))
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 7676557ce357..fc3c24206593 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -16,7 +16,6 @@
16#define _LINUX_NVME_H 16#define _LINUX_NVME_H
17 17
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/uuid.h>
20 19
21/* NQN names in commands fields specified one size */ 20/* NQN names in commands fields specified one size */
22#define NVMF_NQN_FIELD_LEN 256 21#define NVMF_NQN_FIELD_LEN 256
@@ -182,7 +181,7 @@ struct nvme_id_ctrl {
182 char fr[8]; 181 char fr[8];
183 __u8 rab; 182 __u8 rab;
184 __u8 ieee[3]; 183 __u8 ieee[3];
185 __u8 mic; 184 __u8 cmic;
186 __u8 mdts; 185 __u8 mdts;
187 __le16 cntlid; 186 __le16 cntlid;
188 __le32 ver; 187 __le32 ver;
@@ -202,7 +201,13 @@ struct nvme_id_ctrl {
202 __u8 apsta; 201 __u8 apsta;
203 __le16 wctemp; 202 __le16 wctemp;
204 __le16 cctemp; 203 __le16 cctemp;
205 __u8 rsvd270[50]; 204 __le16 mtfa;
205 __le32 hmpre;
206 __le32 hmmin;
207 __u8 tnvmcap[16];
208 __u8 unvmcap[16];
209 __le32 rpmbs;
210 __u8 rsvd316[4];
206 __le16 kas; 211 __le16 kas;
207 __u8 rsvd322[190]; 212 __u8 rsvd322[190];
208 __u8 sqes; 213 __u8 sqes;
@@ -267,7 +272,7 @@ struct nvme_id_ns {
267 __le16 nabo; 272 __le16 nabo;
268 __le16 nabspf; 273 __le16 nabspf;
269 __u16 rsvd46; 274 __u16 rsvd46;
270 __le64 nvmcap[2]; 275 __u8 nvmcap[16];
271 __u8 rsvd64[40]; 276 __u8 rsvd64[40];
272 __u8 nguid[16]; 277 __u8 nguid[16];
273 __u8 eui64[8]; 278 __u8 eui64[8];
@@ -277,6 +282,16 @@ struct nvme_id_ns {
277}; 282};
278 283
279enum { 284enum {
285 NVME_ID_CNS_NS = 0x00,
286 NVME_ID_CNS_CTRL = 0x01,
287 NVME_ID_CNS_NS_ACTIVE_LIST = 0x02,
288 NVME_ID_CNS_NS_PRESENT_LIST = 0x10,
289 NVME_ID_CNS_NS_PRESENT = 0x11,
290 NVME_ID_CNS_CTRL_NS_LIST = 0x12,
291 NVME_ID_CNS_CTRL_LIST = 0x13,
292};
293
294enum {
280 NVME_NS_FEAT_THIN = 1 << 0, 295 NVME_NS_FEAT_THIN = 1 << 0,
281 NVME_NS_FLBAS_LBA_MASK = 0xf, 296 NVME_NS_FLBAS_LBA_MASK = 0xf,
282 NVME_NS_FLBAS_META_EXT = 0x10, 297 NVME_NS_FLBAS_META_EXT = 0x10,
@@ -556,8 +571,10 @@ enum nvme_admin_opcode {
556 nvme_admin_set_features = 0x09, 571 nvme_admin_set_features = 0x09,
557 nvme_admin_get_features = 0x0a, 572 nvme_admin_get_features = 0x0a,
558 nvme_admin_async_event = 0x0c, 573 nvme_admin_async_event = 0x0c,
574 nvme_admin_ns_mgmt = 0x0d,
559 nvme_admin_activate_fw = 0x10, 575 nvme_admin_activate_fw = 0x10,
560 nvme_admin_download_fw = 0x11, 576 nvme_admin_download_fw = 0x11,
577 nvme_admin_ns_attach = 0x15,
561 nvme_admin_keep_alive = 0x18, 578 nvme_admin_keep_alive = 0x18,
562 nvme_admin_format_nvm = 0x80, 579 nvme_admin_format_nvm = 0x80,
563 nvme_admin_security_send = 0x81, 580 nvme_admin_security_send = 0x81,
@@ -583,6 +600,7 @@ enum {
583 NVME_FEAT_WRITE_ATOMIC = 0x0a, 600 NVME_FEAT_WRITE_ATOMIC = 0x0a,
584 NVME_FEAT_ASYNC_EVENT = 0x0b, 601 NVME_FEAT_ASYNC_EVENT = 0x0b,
585 NVME_FEAT_AUTO_PST = 0x0c, 602 NVME_FEAT_AUTO_PST = 0x0c,
603 NVME_FEAT_HOST_MEM_BUF = 0x0d,
586 NVME_FEAT_KATO = 0x0f, 604 NVME_FEAT_KATO = 0x0f,
587 NVME_FEAT_SW_PROGRESS = 0x80, 605 NVME_FEAT_SW_PROGRESS = 0x80,
588 NVME_FEAT_HOST_ID = 0x81, 606 NVME_FEAT_HOST_ID = 0x81,
@@ -745,7 +763,7 @@ struct nvmf_common_command {
745struct nvmf_disc_rsp_page_entry { 763struct nvmf_disc_rsp_page_entry {
746 __u8 trtype; 764 __u8 trtype;
747 __u8 adrfam; 765 __u8 adrfam;
748 __u8 nqntype; 766 __u8 subtype;
749 __u8 treq; 767 __u8 treq;
750 __le16 portid; 768 __le16 portid;
751 __le16 cntlid; 769 __le16 cntlid;
@@ -794,7 +812,7 @@ struct nvmf_connect_command {
794}; 812};
795 813
796struct nvmf_connect_data { 814struct nvmf_connect_data {
797 uuid_be hostid; 815 __u8 hostid[16];
798 __le16 cntlid; 816 __le16 cntlid;
799 char resv4[238]; 817 char resv4[238];
800 char subsysnqn[NVMF_NQN_FIELD_LEN]; 818 char subsysnqn[NVMF_NQN_FIELD_LEN];
@@ -905,12 +923,23 @@ enum {
905 NVME_SC_INVALID_VECTOR = 0x108, 923 NVME_SC_INVALID_VECTOR = 0x108,
906 NVME_SC_INVALID_LOG_PAGE = 0x109, 924 NVME_SC_INVALID_LOG_PAGE = 0x109,
907 NVME_SC_INVALID_FORMAT = 0x10a, 925 NVME_SC_INVALID_FORMAT = 0x10a,
908 NVME_SC_FIRMWARE_NEEDS_RESET = 0x10b, 926 NVME_SC_FW_NEEDS_CONV_RESET = 0x10b,
909 NVME_SC_INVALID_QUEUE = 0x10c, 927 NVME_SC_INVALID_QUEUE = 0x10c,
910 NVME_SC_FEATURE_NOT_SAVEABLE = 0x10d, 928 NVME_SC_FEATURE_NOT_SAVEABLE = 0x10d,
911 NVME_SC_FEATURE_NOT_CHANGEABLE = 0x10e, 929 NVME_SC_FEATURE_NOT_CHANGEABLE = 0x10e,
912 NVME_SC_FEATURE_NOT_PER_NS = 0x10f, 930 NVME_SC_FEATURE_NOT_PER_NS = 0x10f,
913 NVME_SC_FW_NEEDS_RESET_SUBSYS = 0x110, 931 NVME_SC_FW_NEEDS_SUBSYS_RESET = 0x110,
932 NVME_SC_FW_NEEDS_RESET = 0x111,
933 NVME_SC_FW_NEEDS_MAX_TIME = 0x112,
934 NVME_SC_FW_ACIVATE_PROHIBITED = 0x113,
935 NVME_SC_OVERLAPPING_RANGE = 0x114,
936 NVME_SC_NS_INSUFFICENT_CAP = 0x115,
937 NVME_SC_NS_ID_UNAVAILABLE = 0x116,
938 NVME_SC_NS_ALREADY_ATTACHED = 0x118,
939 NVME_SC_NS_IS_PRIVATE = 0x119,
940 NVME_SC_NS_NOT_ATTACHED = 0x11a,
941 NVME_SC_THIN_PROV_NOT_SUPP = 0x11b,
942 NVME_SC_CTRL_LIST_INVALID = 0x11c,
914 943
915 /* 944 /*
916 * I/O Command Set Specific - NVM commands: 945 * I/O Command Set Specific - NVM commands:
@@ -941,6 +970,7 @@ enum {
941 NVME_SC_REFTAG_CHECK = 0x284, 970 NVME_SC_REFTAG_CHECK = 0x284,
942 NVME_SC_COMPARE_FAILED = 0x285, 971 NVME_SC_COMPARE_FAILED = 0x285,
943 NVME_SC_ACCESS_DENIED = 0x286, 972 NVME_SC_ACCESS_DENIED = 0x286,
973 NVME_SC_UNWRITTEN_BLOCK = 0x287,
944 974
945 NVME_SC_DNR = 0x4000, 975 NVME_SC_DNR = 0x4000,
946}; 976};
@@ -960,6 +990,7 @@ struct nvme_completion {
960 __le16 status; /* did the command fail, and if so, why? */ 990 __le16 status; /* did the command fail, and if so, why? */
961}; 991};
962 992
963#define NVME_VS(major, minor) (((major) << 16) | ((minor) << 8)) 993#define NVME_VS(major, minor, tertiary) \
994 (((major) << 16) | ((minor) << 8) | (tertiary))
964 995
965#endif /* _LINUX_NVME_H */ 996#endif /* _LINUX_NVME_H */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 060d0ede88df..4741ecdb9817 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1257,6 +1257,7 @@ extern u64 perf_swevent_set_period(struct perf_event *event);
1257extern void perf_event_enable(struct perf_event *event); 1257extern void perf_event_enable(struct perf_event *event);
1258extern void perf_event_disable(struct perf_event *event); 1258extern 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_task_tick(void); 1261extern void perf_event_task_tick(void);
1261#else /* !CONFIG_PERF_EVENTS: */ 1262#else /* !CONFIG_PERF_EVENTS: */
1262static inline void * 1263static inline void *
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index f9ae903bbb84..8978a60371f4 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -146,6 +146,7 @@ enum qed_led_mode {
146#define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr)) 146#define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
147 147
148#define QED_COALESCE_MAX 0xFF 148#define QED_COALESCE_MAX 0xFF
149#define QED_DEFAULT_RX_USECS 12
149 150
150/* forward */ 151/* forward */
151struct qed_dev; 152struct qed_dev;
diff --git a/include/linux/qed/qede_roce.h b/include/linux/qed/qede_roce.h
index 99fbe6d55acb..f48d64b0e2fb 100644
--- a/include/linux/qed/qede_roce.h
+++ b/include/linux/qed/qede_roce.h
@@ -68,7 +68,7 @@ void qede_roce_unregister_driver(struct qedr_driver *drv);
68 68
69bool qede_roce_supported(struct qede_dev *dev); 69bool qede_roce_supported(struct qede_dev *dev);
70 70
71#if IS_ENABLED(CONFIG_INFINIBAND_QEDR) 71#if IS_ENABLED(CONFIG_QED_RDMA)
72int qede_roce_dev_add(struct qede_dev *dev); 72int qede_roce_dev_add(struct qede_dev *dev);
73void qede_roce_dev_event_open(struct qede_dev *dev); 73void qede_roce_dev_event_open(struct qede_dev *dev);
74void qede_roce_dev_event_close(struct qede_dev *dev); 74void qede_roce_dev_event_close(struct qede_dev *dev);
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 9adc7b21903d..f6673132431d 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/rbtree.h> 17#include <linux/rbtree.h>
18#include <linux/delay.h>
18#include <linux/err.h> 19#include <linux/err.h>
19#include <linux/bug.h> 20#include <linux/bug.h>
20#include <linux/lockdep.h> 21#include <linux/lockdep.h>
@@ -116,22 +117,22 @@ struct reg_sequence {
116#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ 117#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
117({ \ 118({ \
118 ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ 119 ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \
119 int ret; \ 120 int pollret; \
120 might_sleep_if(sleep_us); \ 121 might_sleep_if(sleep_us); \
121 for (;;) { \ 122 for (;;) { \
122 ret = regmap_read((map), (addr), &(val)); \ 123 pollret = regmap_read((map), (addr), &(val)); \
123 if (ret) \ 124 if (pollret) \
124 break; \ 125 break; \
125 if (cond) \ 126 if (cond) \
126 break; \ 127 break; \
127 if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ 128 if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
128 ret = regmap_read((map), (addr), &(val)); \ 129 pollret = regmap_read((map), (addr), &(val)); \
129 break; \ 130 break; \
130 } \ 131 } \
131 if (sleep_us) \ 132 if (sleep_us) \
132 usleep_range((sleep_us >> 2) + 1, sleep_us); \ 133 usleep_range((sleep_us >> 2) + 1, sleep_us); \
133 } \ 134 } \
134 ret ?: ((cond) ? 0 : -ETIMEDOUT); \ 135 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
135}) 136})
136 137
137#ifdef CONFIG_REGMAP 138#ifdef CONFIG_REGMAP
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 601258f6e621..32810f279f8e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -936,6 +936,7 @@ struct sk_buff_fclones {
936 936
937/** 937/**
938 * skb_fclone_busy - check if fclone is busy 938 * skb_fclone_busy - check if fclone is busy
939 * @sk: socket
939 * @skb: buffer 940 * @skb: buffer
940 * 941 *
941 * Returns true if skb is a fast clone, and its clone is not freed. 942 * Returns true if skb is a fast clone, and its clone is not freed.
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 45f004e9cc59..2873baf5372a 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -14,17 +14,6 @@ struct timespec;
14struct compat_timespec; 14struct compat_timespec;
15 15
16#ifdef CONFIG_THREAD_INFO_IN_TASK 16#ifdef CONFIG_THREAD_INFO_IN_TASK
17struct thread_info {
18 unsigned long flags; /* low level flags */
19};
20
21#define INIT_THREAD_INFO(tsk) \
22{ \
23 .flags = 0, \
24}
25#endif
26
27#ifdef CONFIG_THREAD_INFO_IN_TASK
28#define current_thread_info() ((struct thread_info *)current) 17#define current_thread_info() ((struct thread_info *)current)
29#endif 18#endif
30 19
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index f2d072787947..8f998afc1384 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -174,6 +174,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex,
174 const struct in6_addr *addr); 174 const struct in6_addr *addr);
175int ipv6_sock_mc_drop(struct sock *sk, int ifindex, 175int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
176 const struct in6_addr *addr); 176 const struct in6_addr *addr);
177void __ipv6_sock_mc_close(struct sock *sk);
177void ipv6_sock_mc_close(struct sock *sk); 178void ipv6_sock_mc_close(struct sock *sk);
178bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr, 179bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
179 const struct in6_addr *src_addr); 180 const struct in6_addr *src_addr);
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bd19faad0d96..14b51d739c3b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4047,14 +4047,29 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
4047 */ 4047 */
4048 4048
4049/** 4049/**
4050 * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
4051 * @skb: the 802.11 data frame
4052 * @ehdr: pointer to a &struct ethhdr that will get the header, instead
4053 * of it being pushed into the SKB
4054 * @addr: the device MAC address
4055 * @iftype: the virtual interface type
4056 * Return: 0 on success. Non-zero on error.
4057 */
4058int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
4059 const u8 *addr, enum nl80211_iftype iftype);
4060
4061/**
4050 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 4062 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
4051 * @skb: the 802.11 data frame 4063 * @skb: the 802.11 data frame
4052 * @addr: the device MAC address 4064 * @addr: the device MAC address
4053 * @iftype: the virtual interface type 4065 * @iftype: the virtual interface type
4054 * Return: 0 on success. Non-zero on error. 4066 * Return: 0 on success. Non-zero on error.
4055 */ 4067 */
4056int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, 4068static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
4057 enum nl80211_iftype iftype); 4069 enum nl80211_iftype iftype)
4070{
4071 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype);
4072}
4058 4073
4059/** 4074/**
4060 * ieee80211_data_from_8023 - convert an 802.3 frame to 802.11 4075 * ieee80211_data_from_8023 - convert an 802.3 frame to 802.11
@@ -4072,22 +4087,23 @@ int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
4072/** 4087/**
4073 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame 4088 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
4074 * 4089 *
4075 * Decode an IEEE 802.11n A-MSDU frame and convert it to a list of 4090 * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
4076 * 802.3 frames. The @list will be empty if the decode fails. The 4091 * The @list will be empty if the decode fails. The @skb must be fully
4077 * @skb is consumed after the function returns. 4092 * header-less before being passed in here; it is freed in this function.
4078 * 4093 *
4079 * @skb: The input IEEE 802.11n A-MSDU frame. 4094 * @skb: The input A-MSDU frame without any headers.
4080 * @list: The output list of 802.3 frames. It must be allocated and 4095 * @list: The output list of 802.3 frames. It must be allocated and
4081 * initialized by by the caller. 4096 * initialized by by the caller.
4082 * @addr: The device MAC address. 4097 * @addr: The device MAC address.
4083 * @iftype: The device interface type. 4098 * @iftype: The device interface type.
4084 * @extra_headroom: The hardware extra headroom for SKBs in the @list. 4099 * @extra_headroom: The hardware extra headroom for SKBs in the @list.
4085 * @has_80211_header: Set it true if SKB is with IEEE 802.11 header. 4100 * @check_da: DA to check in the inner ethernet header, or NULL
4101 * @check_sa: SA to check in the inner ethernet header, or NULL
4086 */ 4102 */
4087void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, 4103void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
4088 const u8 *addr, enum nl80211_iftype iftype, 4104 const u8 *addr, enum nl80211_iftype iftype,
4089 const unsigned int extra_headroom, 4105 const unsigned int extra_headroom,
4090 bool has_80211_header); 4106 const u8 *check_da, const u8 *check_sa);
4091 4107
4092/** 4108/**
4093 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame 4109 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 515352c6280a..b0576cb2ab25 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -190,8 +190,8 @@ struct inet6_dev {
190 __u32 if_flags; 190 __u32 if_flags;
191 int dead; 191 int dead;
192 192
193 u32 desync_factor;
193 u8 rndid[8]; 194 u8 rndid[8];
194 struct timer_list regen_timer;
195 struct list_head tempaddr_list; 195 struct list_head tempaddr_list;
196 196
197 struct in6_addr token; 197 struct in6_addr token;
diff --git a/include/net/ip.h b/include/net/ip.h
index bc43c0fcae12..5413883ac47f 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -38,7 +38,7 @@ struct sock;
38struct inet_skb_parm { 38struct inet_skb_parm {
39 int iif; 39 int iif;
40 struct ip_options opt; /* Compiled IP options */ 40 struct ip_options opt; /* Compiled IP options */
41 unsigned char flags; 41 u16 flags;
42 42
43#define IPSKB_FORWARDED BIT(0) 43#define IPSKB_FORWARDED BIT(0)
44#define IPSKB_XFRM_TUNNEL_SIZE BIT(1) 44#define IPSKB_XFRM_TUNNEL_SIZE BIT(1)
@@ -48,10 +48,16 @@ struct inet_skb_parm {
48#define IPSKB_DOREDIRECT BIT(5) 48#define IPSKB_DOREDIRECT BIT(5)
49#define IPSKB_FRAG_PMTU BIT(6) 49#define IPSKB_FRAG_PMTU BIT(6)
50#define IPSKB_FRAG_SEGS BIT(7) 50#define IPSKB_FRAG_SEGS BIT(7)
51#define IPSKB_L3SLAVE BIT(8)
51 52
52 u16 frag_max_size; 53 u16 frag_max_size;
53}; 54};
54 55
56static inline bool ipv4_l3mdev_skb(u16 flags)
57{
58 return !!(flags & IPSKB_L3SLAVE);
59}
60
55static inline unsigned int ip_hdrlen(const struct sk_buff *skb) 61static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
56{ 62{
57 return ip_hdr(skb)->ihl * 4; 63 return ip_hdr(skb)->ihl * 4;
@@ -572,7 +578,7 @@ int ip_options_rcv_srr(struct sk_buff *skb);
572 */ 578 */
573 579
574void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb); 580void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb);
575void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb, int offset); 581void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb, int tlen, int offset);
576int ip_cmsg_send(struct sock *sk, struct msghdr *msg, 582int ip_cmsg_send(struct sock *sk, struct msghdr *msg,
577 struct ipcm_cookie *ipc, bool allow_ipv6); 583 struct ipcm_cookie *ipc, bool allow_ipv6);
578int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, 584int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
@@ -594,7 +600,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
594 600
595static inline void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb) 601static inline void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
596{ 602{
597 ip_cmsg_recv_offset(msg, skb, 0); 603 ip_cmsg_recv_offset(msg, skb, 0, 0);
598} 604}
599 605
600bool icmp_global_allow(void); 606bool icmp_global_allow(void);
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index fb961a576abe..a74e2aa40ef4 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -230,6 +230,8 @@ struct fib6_table {
230 rwlock_t tb6_lock; 230 rwlock_t tb6_lock;
231 struct fib6_node tb6_root; 231 struct fib6_node tb6_root;
232 struct inet_peer_base tb6_peers; 232 struct inet_peer_base tb6_peers;
233 unsigned int flags;
234#define RT6_TABLE_HAS_DFLT_ROUTER BIT(0)
233}; 235};
234 236
235#define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC 237#define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index e0cd318d5103..f83e78d071a3 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -32,6 +32,7 @@ struct route_info {
32#define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008 32#define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008
33#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010 33#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
34#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020 34#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020
35#define RT6_LOOKUP_F_IGNORE_LINKSTATE 0x00000040
35 36
36/* We do not (yet ?) support IPv6 jumbograms (RFC 2675) 37/* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
37 * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header 38 * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a810dfcb83c2..e2dba93e374f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -811,14 +811,18 @@ enum mac80211_rate_control_flags {
811 * in the control information, and it will be filled by the rate 811 * in the control information, and it will be filled by the rate
812 * control algorithm according to what should be sent. For example, 812 * control algorithm according to what should be sent. For example,
813 * if this array contains, in the format { <idx>, <count> } the 813 * if this array contains, in the format { <idx>, <count> } the
814 * information 814 * information::
815 *
815 * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 } 816 * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
817 *
816 * then this means that the frame should be transmitted 818 * then this means that the frame should be transmitted
817 * up to twice at rate 3, up to twice at rate 2, and up to four 819 * up to twice at rate 3, up to twice at rate 2, and up to four
818 * times at rate 1 if it doesn't get acknowledged. Say it gets 820 * times at rate 1 if it doesn't get acknowledged. Say it gets
819 * acknowledged by the peer after the fifth attempt, the status 821 * acknowledged by the peer after the fifth attempt, the status
820 * information should then contain 822 * information should then contain::
823 *
821 * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ... 824 * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
825 *
822 * since it was transmitted twice at rate 3, twice at rate 2 826 * since it was transmitted twice at rate 3, twice at rate 2
823 * and once at rate 1 after which we received an acknowledgement. 827 * and once at rate 1 after which we received an acknowledgement.
824 */ 828 */
@@ -1168,8 +1172,8 @@ enum mac80211_rx_vht_flags {
1168 * @rate_idx: index of data rate into band's supported rates or MCS index if 1172 * @rate_idx: index of data rate into band's supported rates or MCS index if
1169 * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT) 1173 * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
1170 * @vht_nss: number of streams (VHT only) 1174 * @vht_nss: number of streams (VHT only)
1171 * @flag: %RX_FLAG_* 1175 * @flag: %RX_FLAG_\*
1172 * @vht_flag: %RX_VHT_FLAG_* 1176 * @vht_flag: %RX_VHT_FLAG_\*
1173 * @rx_flags: internal RX flags for mac80211 1177 * @rx_flags: internal RX flags for mac80211
1174 * @ampdu_reference: A-MPDU reference number, must be a different value for 1178 * @ampdu_reference: A-MPDU reference number, must be a different value for
1175 * each A-MPDU but the same for each subframe within one A-MPDU 1179 * each A-MPDU but the same for each subframe within one A-MPDU
@@ -1432,7 +1436,7 @@ enum ieee80211_vif_flags {
1432 * @probe_req_reg: probe requests should be reported to mac80211 for this 1436 * @probe_req_reg: probe requests should be reported to mac80211 for this
1433 * interface. 1437 * interface.
1434 * @drv_priv: data area for driver use, will always be aligned to 1438 * @drv_priv: data area for driver use, will always be aligned to
1435 * sizeof(void *). 1439 * sizeof(void \*).
1436 * @txq: the multicast data TX queue (if driver uses the TXQ abstraction) 1440 * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
1437 */ 1441 */
1438struct ieee80211_vif { 1442struct ieee80211_vif {
@@ -1743,7 +1747,7 @@ struct ieee80211_sta_rates {
1743 * @wme: indicates whether the STA supports QoS/WME (if local devices does, 1747 * @wme: indicates whether the STA supports QoS/WME (if local devices does,
1744 * otherwise always false) 1748 * otherwise always false)
1745 * @drv_priv: data area for driver use, will always be aligned to 1749 * @drv_priv: data area for driver use, will always be aligned to
1746 * sizeof(void *), size is determined in hw information. 1750 * sizeof(void \*), size is determined in hw information.
1747 * @uapsd_queues: bitmap of queues configured for uapsd. Only valid 1751 * @uapsd_queues: bitmap of queues configured for uapsd. Only valid
1748 * if wme is supported. 1752 * if wme is supported.
1749 * @max_sp: max Service Period. Only valid if wme is supported. 1753 * @max_sp: max Service Period. Only valid if wme is supported.
@@ -2146,12 +2150,12 @@ enum ieee80211_hw_flags {
2146 * 2150 *
2147 * @radiotap_mcs_details: lists which MCS information can the HW 2151 * @radiotap_mcs_details: lists which MCS information can the HW
2148 * reports, by default it is set to _MCS, _GI and _BW but doesn't 2152 * reports, by default it is set to _MCS, _GI and _BW but doesn't
2149 * include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_* values, only 2153 * include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_\* values, only
2150 * adding _BW is supported today. 2154 * adding _BW is supported today.
2151 * 2155 *
2152 * @radiotap_vht_details: lists which VHT MCS information the HW reports, 2156 * @radiotap_vht_details: lists which VHT MCS information the HW reports,
2153 * the default is _GI | _BANDWIDTH. 2157 * the default is _GI | _BANDWIDTH.
2154 * Use the %IEEE80211_RADIOTAP_VHT_KNOWN_* values. 2158 * Use the %IEEE80211_RADIOTAP_VHT_KNOWN_\* values.
2155 * 2159 *
2156 * @radiotap_timestamp: Information for the radiotap timestamp field; if the 2160 * @radiotap_timestamp: Information for the radiotap timestamp field; if the
2157 * 'units_pos' member is set to a non-negative value it must be set to 2161 * 'units_pos' member is set to a non-negative value it must be set to
@@ -2486,6 +2490,7 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
2486 * in the software stack cares about, we will, in the future, have mac80211 2490 * in the software stack cares about, we will, in the future, have mac80211
2487 * tell the driver which information elements are interesting in the sense 2491 * tell the driver which information elements are interesting in the sense
2488 * that we want to see changes in them. This will include 2492 * that we want to see changes in them. This will include
2493 *
2489 * - a list of information element IDs 2494 * - a list of information element IDs
2490 * - a list of OUIs for the vendor information element 2495 * - a list of OUIs for the vendor information element
2491 * 2496 *
diff --git a/include/net/sock.h b/include/net/sock.h
index ebf75db08e06..73c6b008f1b7 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -252,6 +252,7 @@ struct sock_common {
252 * @sk_pacing_rate: Pacing rate (if supported by transport/packet scheduler) 252 * @sk_pacing_rate: Pacing rate (if supported by transport/packet scheduler)
253 * @sk_max_pacing_rate: Maximum pacing rate (%SO_MAX_PACING_RATE) 253 * @sk_max_pacing_rate: Maximum pacing rate (%SO_MAX_PACING_RATE)
254 * @sk_sndbuf: size of send buffer in bytes 254 * @sk_sndbuf: size of send buffer in bytes
255 * @sk_padding: unused element for alignment
255 * @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets 256 * @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets
256 * @sk_no_check_rx: allow zero checksum in RX packets 257 * @sk_no_check_rx: allow zero checksum in RX packets
257 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) 258 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
@@ -302,7 +303,8 @@ struct sock_common {
302 * @sk_backlog_rcv: callback to process the backlog 303 * @sk_backlog_rcv: callback to process the backlog
303 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0 304 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
304 * @sk_reuseport_cb: reuseport group container 305 * @sk_reuseport_cb: reuseport group container
305 */ 306 * @sk_rcu: used during RCU grace period
307 */
306struct sock { 308struct sock {
307 /* 309 /*
308 * Now struct inet_timewait_sock also uses sock_common, so please just 310 * Now struct inet_timewait_sock also uses sock_common, so please just
diff --git a/include/net/tcp.h b/include/net/tcp.h
index f83b7f220a65..5b82d4d94834 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -794,12 +794,23 @@ struct tcp_skb_cb {
794 */ 794 */
795static inline int tcp_v6_iif(const struct sk_buff *skb) 795static inline int tcp_v6_iif(const struct sk_buff *skb)
796{ 796{
797 bool l3_slave = skb_l3mdev_slave(TCP_SKB_CB(skb)->header.h6.flags); 797 bool l3_slave = ipv6_l3mdev_skb(TCP_SKB_CB(skb)->header.h6.flags);
798 798
799 return l3_slave ? skb->skb_iif : TCP_SKB_CB(skb)->header.h6.iif; 799 return l3_slave ? skb->skb_iif : TCP_SKB_CB(skb)->header.h6.iif;
800} 800}
801#endif 801#endif
802 802
803/* TCP_SKB_CB reference means this can not be used from early demux */
804static inline bool inet_exact_dif_match(struct net *net, struct sk_buff *skb)
805{
806#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
807 if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
808 ipv4_l3mdev_skb(TCP_SKB_CB(skb)->header.h4.flags))
809 return true;
810#endif
811 return false;
812}
813
803/* Due to TSO, an SKB can be composed of multiple actual 814/* Due to TSO, an SKB can be composed of multiple actual
804 * packets. To keep these tracked properly, we use this. 815 * packets. To keep these tracked properly, we use this.
805 */ 816 */
diff --git a/include/net/udp.h b/include/net/udp.h
index ea53a87d880f..4948790d393d 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -258,6 +258,7 @@ void udp_flush_pending_frames(struct sock *sk);
258void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst); 258void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst);
259int udp_rcv(struct sk_buff *skb); 259int udp_rcv(struct sk_buff *skb);
260int udp_ioctl(struct sock *sk, int cmd, unsigned long arg); 260int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
261int __udp_disconnect(struct sock *sk, int flags);
261int udp_disconnect(struct sock *sk, int flags); 262int udp_disconnect(struct sock *sk, int flags);
262unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait); 263unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait);
263struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, 264struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 0255613a54a4..308adc4154f4 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -225,9 +225,9 @@ struct vxlan_config {
225struct vxlan_dev { 225struct vxlan_dev {
226 struct hlist_node hlist; /* vni hash table */ 226 struct hlist_node hlist; /* vni hash table */
227 struct list_head next; /* vxlan's per namespace list */ 227 struct list_head next; /* vxlan's per namespace list */
228 struct vxlan_sock *vn4_sock; /* listening socket for IPv4 */ 228 struct vxlan_sock __rcu *vn4_sock; /* listening socket for IPv4 */
229#if IS_ENABLED(CONFIG_IPV6) 229#if IS_ENABLED(CONFIG_IPV6)
230 struct vxlan_sock *vn6_sock; /* listening socket for IPv6 */ 230 struct vxlan_sock __rcu *vn6_sock; /* listening socket for IPv6 */
231#endif 231#endif
232 struct net_device *dev; 232 struct net_device *dev;
233 struct net *net; /* netns for packet i/o */ 233 struct net *net; /* netns for packet i/o */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index fb8e3b6febdf..c2119008990a 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -177,6 +177,7 @@ enum tcm_sense_reason_table {
177 TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED = R(0x15), 177 TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED = R(0x15),
178 TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = R(0x16), 178 TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = R(0x16),
179 TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = R(0x17), 179 TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = R(0x17),
180 TCM_COPY_TARGET_DEVICE_NOT_REACHABLE = R(0x18),
180#undef R 181#undef R
181}; 182};
182 183
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 6965d0909554..cd2be1c8e9fb 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -75,6 +75,7 @@ header-y += bpf_perf_event.h
75header-y += bpf.h 75header-y += bpf.h
76header-y += bpqether.h 76header-y += bpqether.h
77header-y += bsg.h 77header-y += bsg.h
78header-y += bt-bmc.h
78header-y += btrfs.h 79header-y += btrfs.h
79header-y += can.h 80header-y += can.h
80header-y += capability.h 81header-y += capability.h
diff --git a/include/uapi/linux/bt-bmc.h b/include/uapi/linux/bt-bmc.h
new file mode 100644
index 000000000000..d9ec766a63d0
--- /dev/null
+++ b/include/uapi/linux/bt-bmc.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright (c) 2015-2016, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#ifndef _UAPI_LINUX_BT_BMC_H
11#define _UAPI_LINUX_BT_BMC_H
12
13#include <linux/ioctl.h>
14
15#define __BT_BMC_IOCTL_MAGIC 0xb1
16#define BT_BMC_IOCTL_SMS_ATN _IO(__BT_BMC_IOCTL_MAGIC, 0x00)
17
18#endif /* _UAPI_LINUX_BT_BMC_H */
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 099a4200732c..8e547231c1b7 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -119,8 +119,7 @@ struct ethtool_cmd {
119static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, 119static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
120 __u32 speed) 120 __u32 speed)
121{ 121{
122 122 ep->speed = (__u16)(speed & 0xFFFF);
123 ep->speed = (__u16)speed;
124 ep->speed_hi = (__u16)(speed >> 16); 123 ep->speed_hi = (__u16)(speed >> 16);
125} 124}
126 125
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 262f0379d83a..5a78be518101 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -350,7 +350,7 @@ struct rtnexthop {
350#define RTNH_F_OFFLOAD 8 /* offloaded route */ 350#define RTNH_F_OFFLOAD 8 /* offloaded route */
351#define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */ 351#define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */
352 352
353#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN) 353#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
354 354
355/* Macros to handle hexthops */ 355/* Macros to handle hexthops */
356 356
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index a521999de4f1..bf74eaa5c39f 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -53,7 +53,7 @@ static struct msg_msg *alloc_msg(size_t len)
53 size_t alen; 53 size_t alen;
54 54
55 alen = min(len, DATALEN_MSG); 55 alen = min(len, DATALEN_MSG);
56 msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL); 56 msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL_ACCOUNT);
57 if (msg == NULL) 57 if (msg == NULL)
58 return NULL; 58 return NULL;
59 59
@@ -65,7 +65,7 @@ static struct msg_msg *alloc_msg(size_t len)
65 while (len > 0) { 65 while (len > 0) {
66 struct msg_msgseg *seg; 66 struct msg_msgseg *seg;
67 alen = min(len, DATALEN_SEG); 67 alen = min(len, DATALEN_SEG);
68 seg = kmalloc(sizeof(*seg) + alen, GFP_KERNEL); 68 seg = kmalloc(sizeof(*seg) + alen, GFP_KERNEL_ACCOUNT);
69 if (seg == NULL) 69 if (seg == NULL)
70 goto out_err; 70 goto out_err;
71 *pseg = seg; 71 *pseg = seg;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index c6e47e97b33f..0e292132efac 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1960,6 +1960,12 @@ void perf_event_disable(struct perf_event *event)
1960} 1960}
1961EXPORT_SYMBOL_GPL(perf_event_disable); 1961EXPORT_SYMBOL_GPL(perf_event_disable);
1962 1962
1963void perf_event_disable_inatomic(struct perf_event *event)
1964{
1965 event->pending_disable = 1;
1966 irq_work_queue(&event->pending);
1967}
1968
1963static void perf_set_shadow_time(struct perf_event *event, 1969static void perf_set_shadow_time(struct perf_event *event,
1964 struct perf_event_context *ctx, 1970 struct perf_event_context *ctx,
1965 u64 tstamp) 1971 u64 tstamp)
@@ -7075,8 +7081,8 @@ static int __perf_event_overflow(struct perf_event *event,
7075 if (events && atomic_dec_and_test(&event->event_limit)) { 7081 if (events && atomic_dec_and_test(&event->event_limit)) {
7076 ret = 1; 7082 ret = 1;
7077 event->pending_kill = POLL_HUP; 7083 event->pending_kill = POLL_HUP;
7078 event->pending_disable = 1; 7084
7079 irq_work_queue(&event->pending); 7085 perf_event_disable_inatomic(event);
7080 } 7086 }
7081 7087
7082 READ_ONCE(event->overflow_handler)(event, data, regs); 7088 READ_ONCE(event->overflow_handler)(event, data, regs);
@@ -8855,7 +8861,10 @@ EXPORT_SYMBOL_GPL(perf_pmu_register);
8855 8861
8856void perf_pmu_unregister(struct pmu *pmu) 8862void perf_pmu_unregister(struct pmu *pmu)
8857{ 8863{
8864 int remove_device;
8865
8858 mutex_lock(&pmus_lock); 8866 mutex_lock(&pmus_lock);
8867 remove_device = pmu_bus_running;
8859 list_del_rcu(&pmu->entry); 8868 list_del_rcu(&pmu->entry);
8860 mutex_unlock(&pmus_lock); 8869 mutex_unlock(&pmus_lock);
8861 8870
@@ -8869,10 +8878,12 @@ void perf_pmu_unregister(struct pmu *pmu)
8869 free_percpu(pmu->pmu_disable_count); 8878 free_percpu(pmu->pmu_disable_count);
8870 if (pmu->type >= PERF_TYPE_MAX) 8879 if (pmu->type >= PERF_TYPE_MAX)
8871 idr_remove(&pmu_idr, pmu->type); 8880 idr_remove(&pmu_idr, pmu->type);
8872 if (pmu->nr_addr_filters) 8881 if (remove_device) {
8873 device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); 8882 if (pmu->nr_addr_filters)
8874 device_del(pmu->dev); 8883 device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
8875 put_device(pmu->dev); 8884 device_del(pmu->dev);
8885 put_device(pmu->dev);
8886 }
8876 free_pmu_context(pmu); 8887 free_pmu_context(pmu);
8877} 8888}
8878EXPORT_SYMBOL_GPL(perf_pmu_unregister); 8889EXPORT_SYMBOL_GPL(perf_pmu_unregister);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 0c5f1a5db654..9c4d30483264 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -721,6 +721,7 @@ int irq_set_parent(int irq, int parent_irq)
721 irq_put_desc_unlock(desc, flags); 721 irq_put_desc_unlock(desc, flags);
722 return 0; 722 return 0;
723} 723}
724EXPORT_SYMBOL_GPL(irq_set_parent);
724#endif 725#endif
725 726
726/* 727/*
diff --git a/kernel/kcov.c b/kernel/kcov.c
index 8d44b3fea9d0..30e6d05aa5a9 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -53,8 +53,15 @@ void notrace __sanitizer_cov_trace_pc(void)
53 /* 53 /*
54 * We are interested in code coverage as a function of a syscall inputs, 54 * We are interested in code coverage as a function of a syscall inputs,
55 * so we ignore code executed in interrupts. 55 * so we ignore code executed in interrupts.
56 * The checks for whether we are in an interrupt are open-coded, because
57 * 1. We can't use in_interrupt() here, since it also returns true
58 * when we are inside local_bh_disable() section.
59 * 2. We don't want to use (in_irq() | in_serving_softirq() | in_nmi()),
60 * since that leads to slower generated code (three separate tests,
61 * one for each of the flags).
56 */ 62 */
57 if (!t || in_interrupt()) 63 if (!t || (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_OFFSET
64 | NMI_MASK)))
58 return; 65 return;
59 mode = READ_ONCE(t->kcov_mode); 66 mode = READ_ONCE(t->kcov_mode);
60 if (mode == KCOV_MODE_TRACE) { 67 if (mode == KCOV_MODE_TRACE) {
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 1e7f5da648d9..6ccb08f57fcb 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -498,9 +498,9 @@ static int enter_state(suspend_state_t state)
498 498
499#ifndef CONFIG_SUSPEND_SKIP_SYNC 499#ifndef CONFIG_SUSPEND_SKIP_SYNC
500 trace_suspend_resume(TPS("sync_filesystems"), 0, true); 500 trace_suspend_resume(TPS("sync_filesystems"), 0, true);
501 printk(KERN_INFO "PM: Syncing filesystems ... "); 501 pr_info("PM: Syncing filesystems ... ");
502 sys_sync(); 502 sys_sync();
503 printk("done.\n"); 503 pr_cont("done.\n");
504 trace_suspend_resume(TPS("sync_filesystems"), 0, false); 504 trace_suspend_resume(TPS("sync_filesystems"), 0, false);
505#endif 505#endif
506 506
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 94732d1ab00a..42d4027f9e26 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7515,11 +7515,27 @@ static struct kmem_cache *task_group_cache __read_mostly;
7515DECLARE_PER_CPU(cpumask_var_t, load_balance_mask); 7515DECLARE_PER_CPU(cpumask_var_t, load_balance_mask);
7516DECLARE_PER_CPU(cpumask_var_t, select_idle_mask); 7516DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
7517 7517
7518#define WAIT_TABLE_BITS 8
7519#define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS)
7520static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned;
7521
7522wait_queue_head_t *bit_waitqueue(void *word, int bit)
7523{
7524 const int shift = BITS_PER_LONG == 32 ? 5 : 6;
7525 unsigned long val = (unsigned long)word << shift | bit;
7526
7527 return bit_wait_table + hash_long(val, WAIT_TABLE_BITS);
7528}
7529EXPORT_SYMBOL(bit_waitqueue);
7530
7518void __init sched_init(void) 7531void __init sched_init(void)
7519{ 7532{
7520 int i, j; 7533 int i, j;
7521 unsigned long alloc_size = 0, ptr; 7534 unsigned long alloc_size = 0, ptr;
7522 7535
7536 for (i = 0; i < WAIT_TABLE_SIZE; i++)
7537 init_waitqueue_head(bit_wait_table + i);
7538
7523#ifdef CONFIG_FAIR_GROUP_SCHED 7539#ifdef CONFIG_FAIR_GROUP_SCHED
7524 alloc_size += 2 * nr_cpu_ids * sizeof(void **); 7540 alloc_size += 2 * nr_cpu_ids * sizeof(void **);
7525#endif 7541#endif
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d941c97dfbc3..c242944f5cbd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8839,7 +8839,6 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
8839{ 8839{
8840 struct sched_entity *se; 8840 struct sched_entity *se;
8841 struct cfs_rq *cfs_rq; 8841 struct cfs_rq *cfs_rq;
8842 struct rq *rq;
8843 int i; 8842 int i;
8844 8843
8845 tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL); 8844 tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL);
@@ -8854,8 +8853,6 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
8854 init_cfs_bandwidth(tg_cfs_bandwidth(tg)); 8853 init_cfs_bandwidth(tg_cfs_bandwidth(tg));
8855 8854
8856 for_each_possible_cpu(i) { 8855 for_each_possible_cpu(i) {
8857 rq = cpu_rq(i);
8858
8859 cfs_rq = kzalloc_node(sizeof(struct cfs_rq), 8856 cfs_rq = kzalloc_node(sizeof(struct cfs_rq),
8860 GFP_KERNEL, cpu_to_node(i)); 8857 GFP_KERNEL, cpu_to_node(i));
8861 if (!cfs_rq) 8858 if (!cfs_rq)
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index 4f7053579fe3..9453efe9b25a 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -480,16 +480,6 @@ void wake_up_bit(void *word, int bit)
480} 480}
481EXPORT_SYMBOL(wake_up_bit); 481EXPORT_SYMBOL(wake_up_bit);
482 482
483wait_queue_head_t *bit_waitqueue(void *word, int bit)
484{
485 const int shift = BITS_PER_LONG == 32 ? 5 : 6;
486 const struct zone *zone = page_zone(virt_to_page(word));
487 unsigned long val = (unsigned long)word << shift | bit;
488
489 return &zone->wait_table[hash_long(val, zone->wait_table_bits)];
490}
491EXPORT_SYMBOL(bit_waitqueue);
492
493/* 483/*
494 * Manipulate the atomic_t address to produce a better bit waitqueue table hash 484 * Manipulate the atomic_t address to produce a better bit waitqueue table hash
495 * index (we're keying off bit -1, but that would produce a horrible hash 485 * index (we're keying off bit -1, but that would produce a horrible hash
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 1bf81ef91375..744fa611cae0 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -58,7 +58,7 @@ static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp
58DEFINE_PER_CPU(struct task_struct *, ksoftirqd); 58DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
59 59
60const char * const softirq_to_name[NR_SOFTIRQS] = { 60const char * const softirq_to_name[NR_SOFTIRQS] = {
61 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL", 61 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "IRQ_POLL",
62 "TASKLET", "SCHED", "HRTIMER", "RCU" 62 "TASKLET", "SCHED", "HRTIMER", "RCU"
63}; 63};
64 64
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 2d47980a1bc4..c611c47de884 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -878,7 +878,7 @@ static inline struct timer_base *get_timer_base(u32 tflags)
878 878
879#ifdef CONFIG_NO_HZ_COMMON 879#ifdef CONFIG_NO_HZ_COMMON
880static inline struct timer_base * 880static inline struct timer_base *
881__get_target_base(struct timer_base *base, unsigned tflags) 881get_target_base(struct timer_base *base, unsigned tflags)
882{ 882{
883#ifdef CONFIG_SMP 883#ifdef CONFIG_SMP
884 if ((tflags & TIMER_PINNED) || !base->migration_enabled) 884 if ((tflags & TIMER_PINNED) || !base->migration_enabled)
@@ -891,25 +891,27 @@ __get_target_base(struct timer_base *base, unsigned tflags)
891 891
892static inline void forward_timer_base(struct timer_base *base) 892static inline void forward_timer_base(struct timer_base *base)
893{ 893{
894 unsigned long jnow = READ_ONCE(jiffies);
895
894 /* 896 /*
895 * We only forward the base when it's idle and we have a delta between 897 * We only forward the base when it's idle and we have a delta between
896 * base clock and jiffies. 898 * base clock and jiffies.
897 */ 899 */
898 if (!base->is_idle || (long) (jiffies - base->clk) < 2) 900 if (!base->is_idle || (long) (jnow - base->clk) < 2)
899 return; 901 return;
900 902
901 /* 903 /*
902 * If the next expiry value is > jiffies, then we fast forward to 904 * If the next expiry value is > jiffies, then we fast forward to
903 * jiffies otherwise we forward to the next expiry value. 905 * jiffies otherwise we forward to the next expiry value.
904 */ 906 */
905 if (time_after(base->next_expiry, jiffies)) 907 if (time_after(base->next_expiry, jnow))
906 base->clk = jiffies; 908 base->clk = jnow;
907 else 909 else
908 base->clk = base->next_expiry; 910 base->clk = base->next_expiry;
909} 911}
910#else 912#else
911static inline struct timer_base * 913static inline struct timer_base *
912__get_target_base(struct timer_base *base, unsigned tflags) 914get_target_base(struct timer_base *base, unsigned tflags)
913{ 915{
914 return get_timer_this_cpu_base(tflags); 916 return get_timer_this_cpu_base(tflags);
915} 917}
@@ -917,14 +919,6 @@ __get_target_base(struct timer_base *base, unsigned tflags)
917static inline void forward_timer_base(struct timer_base *base) { } 919static inline void forward_timer_base(struct timer_base *base) { }
918#endif 920#endif
919 921
920static inline struct timer_base *
921get_target_base(struct timer_base *base, unsigned tflags)
922{
923 struct timer_base *target = __get_target_base(base, tflags);
924
925 forward_timer_base(target);
926 return target;
927}
928 922
929/* 923/*
930 * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means 924 * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means
@@ -943,7 +937,14 @@ static struct timer_base *lock_timer_base(struct timer_list *timer,
943{ 937{
944 for (;;) { 938 for (;;) {
945 struct timer_base *base; 939 struct timer_base *base;
946 u32 tf = timer->flags; 940 u32 tf;
941
942 /*
943 * We need to use READ_ONCE() here, otherwise the compiler
944 * might re-read @tf between the check for TIMER_MIGRATING
945 * and spin_lock().
946 */
947 tf = READ_ONCE(timer->flags);
947 948
948 if (!(tf & TIMER_MIGRATING)) { 949 if (!(tf & TIMER_MIGRATING)) {
949 base = get_timer_base(tf); 950 base = get_timer_base(tf);
@@ -964,6 +965,8 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
964 unsigned long clk = 0, flags; 965 unsigned long clk = 0, flags;
965 int ret = 0; 966 int ret = 0;
966 967
968 BUG_ON(!timer->function);
969
967 /* 970 /*
968 * This is a common optimization triggered by the networking code - if 971 * This is a common optimization triggered by the networking code - if
969 * the timer is re-modified to have the same timeout or ends up in the 972 * the timer is re-modified to have the same timeout or ends up in the
@@ -972,13 +975,16 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
972 if (timer_pending(timer)) { 975 if (timer_pending(timer)) {
973 if (timer->expires == expires) 976 if (timer->expires == expires)
974 return 1; 977 return 1;
978
975 /* 979 /*
976 * Take the current timer_jiffies of base, but without holding 980 * We lock timer base and calculate the bucket index right
977 * the lock! 981 * here. If the timer ends up in the same bucket, then we
982 * just update the expiry time and avoid the whole
983 * dequeue/enqueue dance.
978 */ 984 */
979 base = get_timer_base(timer->flags); 985 base = lock_timer_base(timer, &flags);
980 clk = base->clk;
981 986
987 clk = base->clk;
982 idx = calc_wheel_index(expires, clk); 988 idx = calc_wheel_index(expires, clk);
983 989
984 /* 990 /*
@@ -988,14 +994,14 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
988 */ 994 */
989 if (idx == timer_get_idx(timer)) { 995 if (idx == timer_get_idx(timer)) {
990 timer->expires = expires; 996 timer->expires = expires;
991 return 1; 997 ret = 1;
998 goto out_unlock;
992 } 999 }
1000 } else {
1001 base = lock_timer_base(timer, &flags);
993 } 1002 }
994 1003
995 timer_stats_timer_set_start_info(timer); 1004 timer_stats_timer_set_start_info(timer);
996 BUG_ON(!timer->function);
997
998 base = lock_timer_base(timer, &flags);
999 1005
1000 ret = detach_if_pending(timer, base, false); 1006 ret = detach_if_pending(timer, base, false);
1001 if (!ret && pending_only) 1007 if (!ret && pending_only)
@@ -1025,12 +1031,16 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
1025 } 1031 }
1026 } 1032 }
1027 1033
1034 /* Try to forward a stale timer base clock */
1035 forward_timer_base(base);
1036
1028 timer->expires = expires; 1037 timer->expires = expires;
1029 /* 1038 /*
1030 * If 'idx' was calculated above and the base time did not advance 1039 * If 'idx' was calculated above and the base time did not advance
1031 * between calculating 'idx' and taking the lock, only enqueue_timer() 1040 * between calculating 'idx' and possibly switching the base, only
1032 * and trigger_dyntick_cpu() is required. Otherwise we need to 1041 * enqueue_timer() and trigger_dyntick_cpu() is required. Otherwise
1033 * (re)calculate the wheel index via internal_add_timer(). 1042 * we need to (re)calculate the wheel index via
1043 * internal_add_timer().
1034 */ 1044 */
1035 if (idx != UINT_MAX && clk == base->clk) { 1045 if (idx != UINT_MAX && clk == base->clk) {
1036 enqueue_timer(base, timer, idx); 1046 enqueue_timer(base, timer, idx);
@@ -1510,12 +1520,16 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
1510 is_max_delta = (nextevt == base->clk + NEXT_TIMER_MAX_DELTA); 1520 is_max_delta = (nextevt == base->clk + NEXT_TIMER_MAX_DELTA);
1511 base->next_expiry = nextevt; 1521 base->next_expiry = nextevt;
1512 /* 1522 /*
1513 * We have a fresh next event. Check whether we can forward the base: 1523 * We have a fresh next event. Check whether we can forward the
1524 * base. We can only do that when @basej is past base->clk
1525 * otherwise we might rewind base->clk.
1514 */ 1526 */
1515 if (time_after(nextevt, jiffies)) 1527 if (time_after(basej, base->clk)) {
1516 base->clk = jiffies; 1528 if (time_after(nextevt, basej))
1517 else if (time_after(nextevt, base->clk)) 1529 base->clk = basej;
1518 base->clk = nextevt; 1530 else if (time_after(nextevt, base->clk))
1531 base->clk = nextevt;
1532 }
1519 1533
1520 if (time_before_eq(nextevt, basej)) { 1534 if (time_before_eq(nextevt, basej)) {
1521 expires = basem; 1535 expires = basem;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 33bc56cf60d7..b01e547d4d04 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -198,6 +198,7 @@ config FRAME_WARN
198 int "Warn for stack frames larger than (needs gcc 4.4)" 198 int "Warn for stack frames larger than (needs gcc 4.4)"
199 range 0 8192 199 range 0 8192
200 default 0 if KASAN 200 default 0 if KASAN
201 default 2048 if GCC_PLUGIN_LATENT_ENTROPY
201 default 1024 if !64BIT 202 default 1024 if !64BIT
202 default 2048 if 64BIT 203 default 2048 if 64BIT
203 help 204 help
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 0a1139644d32..144fe6b1a03e 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -292,7 +292,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
292 struct gen_pool_chunk *chunk; 292 struct gen_pool_chunk *chunk;
293 unsigned long addr = 0; 293 unsigned long addr = 0;
294 int order = pool->min_alloc_order; 294 int order = pool->min_alloc_order;
295 int nbits, start_bit = 0, end_bit, remain; 295 int nbits, start_bit, end_bit, remain;
296 296
297#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG 297#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
298 BUG_ON(in_nmi()); 298 BUG_ON(in_nmi());
@@ -307,6 +307,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
307 if (size > atomic_read(&chunk->avail)) 307 if (size > atomic_read(&chunk->avail))
308 continue; 308 continue;
309 309
310 start_bit = 0;
310 end_bit = chunk_size(chunk) >> order; 311 end_bit = chunk_size(chunk) >> order;
311retry: 312retry:
312 start_bit = algo(chunk->bits, end_bit, start_bit, 313 start_bit = algo(chunk->bits, end_bit, start_bit,
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 60f77f1d470a..4d830e299989 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -50,7 +50,7 @@
50 STACK_ALLOC_ALIGN) 50 STACK_ALLOC_ALIGN)
51#define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \ 51#define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \
52 STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS) 52 STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS)
53#define STACK_ALLOC_SLABS_CAP 1024 53#define STACK_ALLOC_SLABS_CAP 8192
54#define STACK_ALLOC_MAX_SLABS \ 54#define STACK_ALLOC_MAX_SLABS \
55 (((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \ 55 (((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \
56 (1LL << (STACK_ALLOC_INDEX_BITS)) : STACK_ALLOC_SLABS_CAP) 56 (1LL << (STACK_ALLOC_INDEX_BITS)) : STACK_ALLOC_SLABS_CAP)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 94346b4d8984..0362da0b66c3 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4831,7 +4831,7 @@ static struct bpf_test tests[] = {
4831 { }, 4831 { },
4832 INTERNAL, 4832 INTERNAL,
4833 { 0x34 }, 4833 { 0x34 },
4834 { { 1, 0xbef } }, 4834 { { ETH_HLEN, 0xbef } },
4835 .fill_helper = bpf_fill_ld_abs_vlan_push_pop, 4835 .fill_helper = bpf_fill_ld_abs_vlan_push_pop,
4836 }, 4836 },
4837 /* 4837 /*
diff --git a/mm/Kconfig b/mm/Kconfig
index be0ee11fa0d9..86e3e0e74d20 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -187,7 +187,7 @@ config MEMORY_HOTPLUG
187 bool "Allow for memory hot-add" 187 bool "Allow for memory hot-add"
188 depends on SPARSEMEM || X86_64_ACPI_NUMA 188 depends on SPARSEMEM || X86_64_ACPI_NUMA
189 depends on ARCH_ENABLE_MEMORY_HOTPLUG 189 depends on ARCH_ENABLE_MEMORY_HOTPLUG
190 depends on !KASAN 190 depends on COMPILE_TEST || !KASAN
191 191
192config MEMORY_HOTPLUG_SPARSE 192config MEMORY_HOTPLUG_SPARSE
193 def_bool y 193 def_bool y
diff --git a/mm/filemap.c b/mm/filemap.c
index 849f459ad078..c7fe2f16503f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -790,9 +790,7 @@ EXPORT_SYMBOL(__page_cache_alloc);
790 */ 790 */
791wait_queue_head_t *page_waitqueue(struct page *page) 791wait_queue_head_t *page_waitqueue(struct page *page)
792{ 792{
793 const struct zone *zone = page_zone(page); 793 return bit_waitqueue(page, 0);
794
795 return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
796} 794}
797EXPORT_SYMBOL(page_waitqueue); 795EXPORT_SYMBOL(page_waitqueue);
798 796
diff --git a/mm/gup.c b/mm/gup.c
index 7aa113c2d373..ec4f82704b6f 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -526,7 +526,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
526 * instead of __get_user_pages. __get_user_pages should be used only if 526 * instead of __get_user_pages. __get_user_pages should be used only if
527 * you need some special @gup_flags. 527 * you need some special @gup_flags.
528 */ 528 */
529long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 529static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
530 unsigned long start, unsigned long nr_pages, 530 unsigned long start, unsigned long nr_pages,
531 unsigned int gup_flags, struct page **pages, 531 unsigned int gup_flags, struct page **pages,
532 struct vm_area_struct **vmas, int *nonblocking) 532 struct vm_area_struct **vmas, int *nonblocking)
@@ -631,7 +631,6 @@ next_page:
631 } while (nr_pages); 631 } while (nr_pages);
632 return i; 632 return i;
633} 633}
634EXPORT_SYMBOL(__get_user_pages);
635 634
636bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags) 635bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags)
637{ 636{
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index a5e453cf05c4..e5355a5b423f 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1453,8 +1453,11 @@ static void kmemleak_scan(void)
1453 1453
1454 read_lock(&tasklist_lock); 1454 read_lock(&tasklist_lock);
1455 do_each_thread(g, p) { 1455 do_each_thread(g, p) {
1456 scan_block(task_stack_page(p), task_stack_page(p) + 1456 void *stack = try_get_task_stack(p);
1457 THREAD_SIZE, NULL); 1457 if (stack) {
1458 scan_block(stack, stack + THREAD_SIZE, NULL);
1459 put_task_stack(p);
1460 }
1458 } while_each_thread(g, p); 1461 } while_each_thread(g, p);
1459 read_unlock(&tasklist_lock); 1462 read_unlock(&tasklist_lock);
1460 } 1463 }
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 1d05cb9d363d..234676e31edd 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -554,6 +554,8 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
554 err = memcg_init_list_lru(lru, memcg_aware); 554 err = memcg_init_list_lru(lru, memcg_aware);
555 if (err) { 555 if (err) {
556 kfree(lru->node); 556 kfree(lru->node);
557 /* Do this so a list_lru_destroy() doesn't crash: */
558 lru->node = NULL;
557 goto out; 559 goto out;
558 } 560 }
559 561
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ae052b5e3315..0f870ba43942 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1917,6 +1917,15 @@ retry:
1917 current->flags & PF_EXITING)) 1917 current->flags & PF_EXITING))
1918 goto force; 1918 goto force;
1919 1919
1920 /*
1921 * Prevent unbounded recursion when reclaim operations need to
1922 * allocate memory. This might exceed the limits temporarily,
1923 * but we prefer facilitating memory reclaim and getting back
1924 * under the limit over triggering OOM kills in these cases.
1925 */
1926 if (unlikely(current->flags & PF_MEMALLOC))
1927 goto force;
1928
1920 if (unlikely(task_in_memcg_oom(current))) 1929 if (unlikely(task_in_memcg_oom(current)))
1921 goto nomem; 1930 goto nomem;
1922 1931
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 962927309b6e..cad4b9125695 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -268,7 +268,6 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
268 unsigned long i, pfn, end_pfn, nr_pages; 268 unsigned long i, pfn, end_pfn, nr_pages;
269 int node = pgdat->node_id; 269 int node = pgdat->node_id;
270 struct page *page; 270 struct page *page;
271 struct zone *zone;
272 271
273 nr_pages = PAGE_ALIGN(sizeof(struct pglist_data)) >> PAGE_SHIFT; 272 nr_pages = PAGE_ALIGN(sizeof(struct pglist_data)) >> PAGE_SHIFT;
274 page = virt_to_page(pgdat); 273 page = virt_to_page(pgdat);
@@ -276,19 +275,6 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
276 for (i = 0; i < nr_pages; i++, page++) 275 for (i = 0; i < nr_pages; i++, page++)
277 get_page_bootmem(node, page, NODE_INFO); 276 get_page_bootmem(node, page, NODE_INFO);
278 277
279 zone = &pgdat->node_zones[0];
280 for (; zone < pgdat->node_zones + MAX_NR_ZONES - 1; zone++) {
281 if (zone_is_initialized(zone)) {
282 nr_pages = zone->wait_table_hash_nr_entries
283 * sizeof(wait_queue_head_t);
284 nr_pages = PAGE_ALIGN(nr_pages) >> PAGE_SHIFT;
285 page = virt_to_page(zone->wait_table);
286
287 for (i = 0; i < nr_pages; i++, page++)
288 get_page_bootmem(node, page, NODE_INFO);
289 }
290 }
291
292 pfn = pgdat->node_start_pfn; 278 pfn = pgdat->node_start_pfn;
293 end_pfn = pgdat_end_pfn(pgdat); 279 end_pfn = pgdat_end_pfn(pgdat);
294 280
@@ -2131,7 +2117,6 @@ void try_offline_node(int nid)
2131 unsigned long start_pfn = pgdat->node_start_pfn; 2117 unsigned long start_pfn = pgdat->node_start_pfn;
2132 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 2118 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
2133 unsigned long pfn; 2119 unsigned long pfn;
2134 int i;
2135 2120
2136 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 2121 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
2137 unsigned long section_nr = pfn_to_section_nr(pfn); 2122 unsigned long section_nr = pfn_to_section_nr(pfn);
@@ -2158,20 +2143,6 @@ void try_offline_node(int nid)
2158 */ 2143 */
2159 node_set_offline(nid); 2144 node_set_offline(nid);
2160 unregister_one_node(nid); 2145 unregister_one_node(nid);
2161
2162 /* free waittable in each zone */
2163 for (i = 0; i < MAX_NR_ZONES; i++) {
2164 struct zone *zone = pgdat->node_zones + i;
2165
2166 /*
2167 * wait_table may be allocated from boot memory,
2168 * here only free if it's allocated by vmalloc.
2169 */
2170 if (is_vmalloc_addr(zone->wait_table)) {
2171 vfree(zone->wait_table);
2172 zone->wait_table = NULL;
2173 }
2174 }
2175} 2146}
2176EXPORT_SYMBOL(try_offline_node); 2147EXPORT_SYMBOL(try_offline_node);
2177 2148
diff --git a/mm/mprotect.c b/mm/mprotect.c
index bcdbe62f3e6d..11936526b08b 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -25,7 +25,6 @@
25#include <linux/perf_event.h> 25#include <linux/perf_event.h>
26#include <linux/pkeys.h> 26#include <linux/pkeys.h>
27#include <linux/ksm.h> 27#include <linux/ksm.h>
28#include <linux/pkeys.h>
29#include <asm/uaccess.h> 28#include <asm/uaccess.h>
30#include <asm/pgtable.h> 29#include <asm/pgtable.h>
31#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
diff --git a/mm/nommu.c b/mm/nommu.c
index db5fd1795298..8b8faaf2a9e9 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -109,7 +109,7 @@ unsigned int kobjsize(const void *objp)
109 return PAGE_SIZE << compound_order(page); 109 return PAGE_SIZE << compound_order(page);
110} 110}
111 111
112long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 112static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
113 unsigned long start, unsigned long nr_pages, 113 unsigned long start, unsigned long nr_pages,
114 unsigned int foll_flags, struct page **pages, 114 unsigned int foll_flags, struct page **pages,
115 struct vm_area_struct **vmas, int *nonblocking) 115 struct vm_area_struct **vmas, int *nonblocking)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3f639739cab9..2dd614877de2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4224,7 +4224,7 @@ static void show_migration_types(unsigned char type)
4224 } 4224 }
4225 4225
4226 *p = '\0'; 4226 *p = '\0';
4227 printk("(%s) ", tmp); 4227 printk(KERN_CONT "(%s) ", tmp);
4228} 4228}
4229 4229
4230/* 4230/*
@@ -4335,7 +4335,8 @@ void show_free_areas(unsigned int filter)
4335 free_pcp += per_cpu_ptr(zone->pageset, cpu)->pcp.count; 4335 free_pcp += per_cpu_ptr(zone->pageset, cpu)->pcp.count;
4336 4336
4337 show_node(zone); 4337 show_node(zone);
4338 printk("%s" 4338 printk(KERN_CONT
4339 "%s"
4339 " free:%lukB" 4340 " free:%lukB"
4340 " min:%lukB" 4341 " min:%lukB"
4341 " low:%lukB" 4342 " low:%lukB"
@@ -4382,8 +4383,8 @@ void show_free_areas(unsigned int filter)
4382 K(zone_page_state(zone, NR_FREE_CMA_PAGES))); 4383 K(zone_page_state(zone, NR_FREE_CMA_PAGES)));
4383 printk("lowmem_reserve[]:"); 4384 printk("lowmem_reserve[]:");
4384 for (i = 0; i < MAX_NR_ZONES; i++) 4385 for (i = 0; i < MAX_NR_ZONES; i++)
4385 printk(" %ld", zone->lowmem_reserve[i]); 4386 printk(KERN_CONT " %ld", zone->lowmem_reserve[i]);
4386 printk("\n"); 4387 printk(KERN_CONT "\n");
4387 } 4388 }
4388 4389
4389 for_each_populated_zone(zone) { 4390 for_each_populated_zone(zone) {
@@ -4394,7 +4395,7 @@ void show_free_areas(unsigned int filter)
4394 if (skip_free_areas_node(filter, zone_to_nid(zone))) 4395 if (skip_free_areas_node(filter, zone_to_nid(zone)))
4395 continue; 4396 continue;
4396 show_node(zone); 4397 show_node(zone);
4397 printk("%s: ", zone->name); 4398 printk(KERN_CONT "%s: ", zone->name);
4398 4399
4399 spin_lock_irqsave(&zone->lock, flags); 4400 spin_lock_irqsave(&zone->lock, flags);
4400 for (order = 0; order < MAX_ORDER; order++) { 4401 for (order = 0; order < MAX_ORDER; order++) {
@@ -4412,11 +4413,12 @@ void show_free_areas(unsigned int filter)
4412 } 4413 }
4413 spin_unlock_irqrestore(&zone->lock, flags); 4414 spin_unlock_irqrestore(&zone->lock, flags);
4414 for (order = 0; order < MAX_ORDER; order++) { 4415 for (order = 0; order < MAX_ORDER; order++) {
4415 printk("%lu*%lukB ", nr[order], K(1UL) << order); 4416 printk(KERN_CONT "%lu*%lukB ",
4417 nr[order], K(1UL) << order);
4416 if (nr[order]) 4418 if (nr[order])
4417 show_migration_types(types[order]); 4419 show_migration_types(types[order]);
4418 } 4420 }
4419 printk("= %lukB\n", K(total)); 4421 printk(KERN_CONT "= %lukB\n", K(total));
4420 } 4422 }
4421 4423
4422 hugetlb_show_meminfo(); 4424 hugetlb_show_meminfo();
@@ -4977,72 +4979,6 @@ void __ref build_all_zonelists(pg_data_t *pgdat, struct zone *zone)
4977} 4979}
4978 4980
4979/* 4981/*
4980 * Helper functions to size the waitqueue hash table.
4981 * Essentially these want to choose hash table sizes sufficiently
4982 * large so that collisions trying to wait on pages are rare.
4983 * But in fact, the number of active page waitqueues on typical
4984 * systems is ridiculously low, less than 200. So this is even
4985 * conservative, even though it seems large.
4986 *
4987 * The constant PAGES_PER_WAITQUEUE specifies the ratio of pages to
4988 * waitqueues, i.e. the size of the waitq table given the number of pages.
4989 */
4990#define PAGES_PER_WAITQUEUE 256
4991
4992#ifndef CONFIG_MEMORY_HOTPLUG
4993static inline unsigned long wait_table_hash_nr_entries(unsigned long pages)
4994{
4995 unsigned long size = 1;
4996
4997 pages /= PAGES_PER_WAITQUEUE;
4998
4999 while (size < pages)
5000 size <<= 1;
5001
5002 /*
5003 * Once we have dozens or even hundreds of threads sleeping
5004 * on IO we've got bigger problems than wait queue collision.
5005 * Limit the size of the wait table to a reasonable size.
5006 */
5007 size = min(size, 4096UL);
5008
5009 return max(size, 4UL);
5010}
5011#else
5012/*
5013 * A zone's size might be changed by hot-add, so it is not possible to determine
5014 * a suitable size for its wait_table. So we use the maximum size now.
5015 *
5016 * The max wait table size = 4096 x sizeof(wait_queue_head_t). ie:
5017 *
5018 * i386 (preemption config) : 4096 x 16 = 64Kbyte.
5019 * ia64, x86-64 (no preemption): 4096 x 20 = 80Kbyte.
5020 * ia64, x86-64 (preemption) : 4096 x 24 = 96Kbyte.
5021 *
5022 * The maximum entries are prepared when a zone's memory is (512K + 256) pages
5023 * or more by the traditional way. (See above). It equals:
5024 *
5025 * i386, x86-64, powerpc(4K page size) : = ( 2G + 1M)byte.
5026 * ia64(16K page size) : = ( 8G + 4M)byte.
5027 * powerpc (64K page size) : = (32G +16M)byte.
5028 */
5029static inline unsigned long wait_table_hash_nr_entries(unsigned long pages)
5030{
5031 return 4096UL;
5032}
5033#endif
5034
5035/*
5036 * This is an integer logarithm so that shifts can be used later
5037 * to extract the more random high bits from the multiplicative
5038 * hash function before the remainder is taken.
5039 */
5040static inline unsigned long wait_table_bits(unsigned long size)
5041{
5042 return ffz(~size);
5043}
5044
5045/*
5046 * Initially all pages are reserved - free ones are freed 4982 * Initially all pages are reserved - free ones are freed
5047 * up by free_all_bootmem() once the early boot process is 4983 * up by free_all_bootmem() once the early boot process is
5048 * done. Non-atomic initialization, single-pass. 4984 * done. Non-atomic initialization, single-pass.
@@ -5304,49 +5240,6 @@ void __init setup_per_cpu_pageset(void)
5304 alloc_percpu(struct per_cpu_nodestat); 5240 alloc_percpu(struct per_cpu_nodestat);
5305} 5241}
5306 5242
5307static noinline __ref
5308int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
5309{
5310 int i;
5311 size_t alloc_size;
5312
5313 /*
5314 * The per-page waitqueue mechanism uses hashed waitqueues
5315 * per zone.
5316 */
5317 zone->wait_table_hash_nr_entries =
5318 wait_table_hash_nr_entries(zone_size_pages);
5319 zone->wait_table_bits =
5320 wait_table_bits(zone->wait_table_hash_nr_entries);
5321 alloc_size = zone->wait_table_hash_nr_entries
5322 * sizeof(wait_queue_head_t);
5323
5324 if (!slab_is_available()) {
5325 zone->wait_table = (wait_queue_head_t *)
5326 memblock_virt_alloc_node_nopanic(
5327 alloc_size, zone->zone_pgdat->node_id);
5328 } else {
5329 /*
5330 * This case means that a zone whose size was 0 gets new memory
5331 * via memory hot-add.
5332 * But it may be the case that a new node was hot-added. In
5333 * this case vmalloc() will not be able to use this new node's
5334 * memory - this wait_table must be initialized to use this new
5335 * node itself as well.
5336 * To use this new node's memory, further consideration will be
5337 * necessary.
5338 */
5339 zone->wait_table = vmalloc(alloc_size);
5340 }
5341 if (!zone->wait_table)
5342 return -ENOMEM;
5343
5344 for (i = 0; i < zone->wait_table_hash_nr_entries; ++i)
5345 init_waitqueue_head(zone->wait_table + i);
5346
5347 return 0;
5348}
5349
5350static __meminit void zone_pcp_init(struct zone *zone) 5243static __meminit void zone_pcp_init(struct zone *zone)
5351{ 5244{
5352 /* 5245 /*
@@ -5367,10 +5260,7 @@ int __meminit init_currently_empty_zone(struct zone *zone,
5367 unsigned long size) 5260 unsigned long size)
5368{ 5261{
5369 struct pglist_data *pgdat = zone->zone_pgdat; 5262 struct pglist_data *pgdat = zone->zone_pgdat;
5370 int ret; 5263
5371 ret = zone_wait_table_init(zone, size);
5372 if (ret)
5373 return ret;
5374 pgdat->nr_zones = zone_idx(zone) + 1; 5264 pgdat->nr_zones = zone_idx(zone) + 1;
5375 5265
5376 zone->zone_start_pfn = zone_start_pfn; 5266 zone->zone_start_pfn = zone_start_pfn;
@@ -5382,6 +5272,7 @@ int __meminit init_currently_empty_zone(struct zone *zone,
5382 zone_start_pfn, (zone_start_pfn + size)); 5272 zone_start_pfn, (zone_start_pfn + size));
5383 5273
5384 zone_init_free_lists(zone); 5274 zone_init_free_lists(zone);
5275 zone->initialized = 1;
5385 5276
5386 return 0; 5277 return 0;
5387} 5278}
diff --git a/mm/slab.c b/mm/slab.c
index 090fb26b3a39..0b0550ca85b4 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -233,6 +233,7 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
233 spin_lock_init(&parent->list_lock); 233 spin_lock_init(&parent->list_lock);
234 parent->free_objects = 0; 234 parent->free_objects = 0;
235 parent->free_touched = 0; 235 parent->free_touched = 0;
236 parent->num_slabs = 0;
236} 237}
237 238
238#define MAKE_LIST(cachep, listp, slab, nodeid) \ 239#define MAKE_LIST(cachep, listp, slab, nodeid) \
@@ -966,7 +967,7 @@ static int setup_kmem_cache_node(struct kmem_cache *cachep,
966 * guaranteed to be valid until irq is re-enabled, because it will be 967 * guaranteed to be valid until irq is re-enabled, because it will be
967 * freed after synchronize_sched(). 968 * freed after synchronize_sched().
968 */ 969 */
969 if (force_change) 970 if (old_shared && force_change)
970 synchronize_sched(); 971 synchronize_sched();
971 972
972fail: 973fail:
@@ -1382,24 +1383,27 @@ slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
1382 for_each_kmem_cache_node(cachep, node, n) { 1383 for_each_kmem_cache_node(cachep, node, n) {
1383 unsigned long active_objs = 0, num_objs = 0, free_objects = 0; 1384 unsigned long active_objs = 0, num_objs = 0, free_objects = 0;
1384 unsigned long active_slabs = 0, num_slabs = 0; 1385 unsigned long active_slabs = 0, num_slabs = 0;
1386 unsigned long num_slabs_partial = 0, num_slabs_free = 0;
1387 unsigned long num_slabs_full;
1385 1388
1386 spin_lock_irqsave(&n->list_lock, flags); 1389 spin_lock_irqsave(&n->list_lock, flags);
1387 list_for_each_entry(page, &n->slabs_full, lru) { 1390 num_slabs = n->num_slabs;
1388 active_objs += cachep->num;
1389 active_slabs++;
1390 }
1391 list_for_each_entry(page, &n->slabs_partial, lru) { 1391 list_for_each_entry(page, &n->slabs_partial, lru) {
1392 active_objs += page->active; 1392 active_objs += page->active;
1393 active_slabs++; 1393 num_slabs_partial++;
1394 } 1394 }
1395 list_for_each_entry(page, &n->slabs_free, lru) 1395 list_for_each_entry(page, &n->slabs_free, lru)
1396 num_slabs++; 1396 num_slabs_free++;
1397 1397
1398 free_objects += n->free_objects; 1398 free_objects += n->free_objects;
1399 spin_unlock_irqrestore(&n->list_lock, flags); 1399 spin_unlock_irqrestore(&n->list_lock, flags);
1400 1400
1401 num_slabs += active_slabs;
1402 num_objs = num_slabs * cachep->num; 1401 num_objs = num_slabs * cachep->num;
1402 active_slabs = num_slabs - num_slabs_free;
1403 num_slabs_full = num_slabs -
1404 (num_slabs_partial + num_slabs_free);
1405 active_objs += (num_slabs_full * cachep->num);
1406
1403 pr_warn(" node %d: slabs: %ld/%ld, objs: %ld/%ld, free: %ld\n", 1407 pr_warn(" node %d: slabs: %ld/%ld, objs: %ld/%ld, free: %ld\n",
1404 node, active_slabs, num_slabs, active_objs, num_objs, 1408 node, active_slabs, num_slabs, active_objs, num_objs,
1405 free_objects); 1409 free_objects);
@@ -2314,6 +2318,7 @@ static int drain_freelist(struct kmem_cache *cache,
2314 2318
2315 page = list_entry(p, struct page, lru); 2319 page = list_entry(p, struct page, lru);
2316 list_del(&page->lru); 2320 list_del(&page->lru);
2321 n->num_slabs--;
2317 /* 2322 /*
2318 * Safe to drop the lock. The slab is no longer linked 2323 * Safe to drop the lock. The slab is no longer linked
2319 * to the cache. 2324 * to the cache.
@@ -2752,6 +2757,8 @@ static void cache_grow_end(struct kmem_cache *cachep, struct page *page)
2752 list_add_tail(&page->lru, &(n->slabs_free)); 2757 list_add_tail(&page->lru, &(n->slabs_free));
2753 else 2758 else
2754 fixup_slab_list(cachep, n, page, &list); 2759 fixup_slab_list(cachep, n, page, &list);
2760
2761 n->num_slabs++;
2755 STATS_INC_GROWN(cachep); 2762 STATS_INC_GROWN(cachep);
2756 n->free_objects += cachep->num - page->active; 2763 n->free_objects += cachep->num - page->active;
2757 spin_unlock(&n->list_lock); 2764 spin_unlock(&n->list_lock);
@@ -3443,6 +3450,7 @@ static void free_block(struct kmem_cache *cachep, void **objpp,
3443 3450
3444 page = list_last_entry(&n->slabs_free, struct page, lru); 3451 page = list_last_entry(&n->slabs_free, struct page, lru);
3445 list_move(&page->lru, list); 3452 list_move(&page->lru, list);
3453 n->num_slabs--;
3446 } 3454 }
3447} 3455}
3448 3456
@@ -4099,6 +4107,8 @@ void get_slabinfo(struct kmem_cache *cachep, struct slabinfo *sinfo)
4099 unsigned long num_objs; 4107 unsigned long num_objs;
4100 unsigned long active_slabs = 0; 4108 unsigned long active_slabs = 0;
4101 unsigned long num_slabs, free_objects = 0, shared_avail = 0; 4109 unsigned long num_slabs, free_objects = 0, shared_avail = 0;
4110 unsigned long num_slabs_partial = 0, num_slabs_free = 0;
4111 unsigned long num_slabs_full = 0;
4102 const char *name; 4112 const char *name;
4103 char *error = NULL; 4113 char *error = NULL;
4104 int node; 4114 int node;
@@ -4111,33 +4121,34 @@ void get_slabinfo(struct kmem_cache *cachep, struct slabinfo *sinfo)
4111 check_irq_on(); 4121 check_irq_on();
4112 spin_lock_irq(&n->list_lock); 4122 spin_lock_irq(&n->list_lock);
4113 4123
4114 list_for_each_entry(page, &n->slabs_full, lru) { 4124 num_slabs += n->num_slabs;
4115 if (page->active != cachep->num && !error) 4125
4116 error = "slabs_full accounting error";
4117 active_objs += cachep->num;
4118 active_slabs++;
4119 }
4120 list_for_each_entry(page, &n->slabs_partial, lru) { 4126 list_for_each_entry(page, &n->slabs_partial, lru) {
4121 if (page->active == cachep->num && !error) 4127 if (page->active == cachep->num && !error)
4122 error = "slabs_partial accounting error"; 4128 error = "slabs_partial accounting error";
4123 if (!page->active && !error) 4129 if (!page->active && !error)
4124 error = "slabs_partial accounting error"; 4130 error = "slabs_partial accounting error";
4125 active_objs += page->active; 4131 active_objs += page->active;
4126 active_slabs++; 4132 num_slabs_partial++;
4127 } 4133 }
4134
4128 list_for_each_entry(page, &n->slabs_free, lru) { 4135 list_for_each_entry(page, &n->slabs_free, lru) {
4129 if (page->active && !error) 4136 if (page->active && !error)
4130 error = "slabs_free accounting error"; 4137 error = "slabs_free accounting error";
4131 num_slabs++; 4138 num_slabs_free++;
4132 } 4139 }
4140
4133 free_objects += n->free_objects; 4141 free_objects += n->free_objects;
4134 if (n->shared) 4142 if (n->shared)
4135 shared_avail += n->shared->avail; 4143 shared_avail += n->shared->avail;
4136 4144
4137 spin_unlock_irq(&n->list_lock); 4145 spin_unlock_irq(&n->list_lock);
4138 } 4146 }
4139 num_slabs += active_slabs;
4140 num_objs = num_slabs * cachep->num; 4147 num_objs = num_slabs * cachep->num;
4148 active_slabs = num_slabs - num_slabs_free;
4149 num_slabs_full = num_slabs - (num_slabs_partial + num_slabs_free);
4150 active_objs += (num_slabs_full * cachep->num);
4151
4141 if (num_objs - active_objs != free_objects && !error) 4152 if (num_objs - active_objs != free_objects && !error)
4142 error = "free_objects accounting error"; 4153 error = "free_objects accounting error";
4143 4154
diff --git a/mm/slab.h b/mm/slab.h
index 9653f2e2591a..bc05fdc3edce 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -432,6 +432,7 @@ struct kmem_cache_node {
432 struct list_head slabs_partial; /* partial list first, better asm code */ 432 struct list_head slabs_partial; /* partial list first, better asm code */
433 struct list_head slabs_full; 433 struct list_head slabs_full;
434 struct list_head slabs_free; 434 struct list_head slabs_free;
435 unsigned long num_slabs;
435 unsigned long free_objects; 436 unsigned long free_objects;
436 unsigned int free_limit; 437 unsigned int free_limit;
437 unsigned int colour_next; /* Per-node cache coloring */ 438 unsigned int colour_next; /* Per-node cache coloring */
diff --git a/mm/util.c b/mm/util.c
index 952cbe7ad7b7..1a41553db866 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -230,8 +230,10 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
230} 230}
231 231
232/* Check if the vma is being used as a stack by this task */ 232/* Check if the vma is being used as a stack by this task */
233int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t) 233int vma_is_stack_for_current(struct vm_area_struct *vma)
234{ 234{
235 struct task_struct * __maybe_unused t = current;
236
235 return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t)); 237 return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t));
236} 238}
237 239
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 744f926af442..76fda2268148 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3043,7 +3043,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
3043 sc.gfp_mask, 3043 sc.gfp_mask,
3044 sc.reclaim_idx); 3044 sc.reclaim_idx);
3045 3045
3046 current->flags |= PF_MEMALLOC;
3046 nr_reclaimed = do_try_to_free_pages(zonelist, &sc); 3047 nr_reclaimed = do_try_to_free_pages(zonelist, &sc);
3048 current->flags &= ~PF_MEMALLOC;
3047 3049
3048 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); 3050 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);
3049 3051
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8de138d3306b..f2531ad66b68 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -664,7 +664,7 @@ static struct sk_buff **vlan_gro_receive(struct sk_buff **head,
664 664
665 skb_gro_pull(skb, sizeof(*vhdr)); 665 skb_gro_pull(skb, sizeof(*vhdr));
666 skb_gro_postpull_rcsum(skb, vhdr, sizeof(*vhdr)); 666 skb_gro_postpull_rcsum(skb, vhdr, sizeof(*vhdr));
667 pp = ptype->callbacks.gro_receive(head, skb); 667 pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
668 668
669out_unlock: 669out_unlock:
670 rcu_read_unlock(); 670 rcu_read_unlock();
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 08ce36147c4c..e034afbd1bb0 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -652,7 +652,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
652 batadv_softif_destroy_sysfs(hard_iface->soft_iface); 652 batadv_softif_destroy_sysfs(hard_iface->soft_iface);
653 } 653 }
654 654
655 hard_iface->soft_iface = NULL;
656 batadv_hardif_put(hard_iface); 655 batadv_hardif_put(hard_iface);
657 656
658out: 657out:
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index e0e1a88c3e58..d2905a855d1b 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -63,7 +63,7 @@ enum batadv_dbg_level {
63 BATADV_DBG_NC = BIT(5), 63 BATADV_DBG_NC = BIT(5),
64 BATADV_DBG_MCAST = BIT(6), 64 BATADV_DBG_MCAST = BIT(6),
65 BATADV_DBG_TP_METER = BIT(7), 65 BATADV_DBG_TP_METER = BIT(7),
66 BATADV_DBG_ALL = 127, 66 BATADV_DBG_ALL = 255,
67}; 67};
68 68
69#ifdef CONFIG_BATMAN_ADV_DEBUG 69#ifdef CONFIG_BATMAN_ADV_DEBUG
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 5f3bfc41aeb1..7c8d16086f0f 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -544,7 +544,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
544 if (bat_priv->algo_ops->neigh.hardif_init) 544 if (bat_priv->algo_ops->neigh.hardif_init)
545 bat_priv->algo_ops->neigh.hardif_init(hardif_neigh); 545 bat_priv->algo_ops->neigh.hardif_init(hardif_neigh);
546 546
547 hlist_add_head(&hardif_neigh->list, &hard_iface->neigh_list); 547 hlist_add_head_rcu(&hardif_neigh->list, &hard_iface->neigh_list);
548 548
549out: 549out:
550 spin_unlock_bh(&hard_iface->neigh_list_lock); 550 spin_unlock_bh(&hard_iface->neigh_list_lock);
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index e2288421fe6b..1015d9c8d97d 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -969,41 +969,38 @@ void __hci_req_enable_advertising(struct hci_request *req)
969 hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable); 969 hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
970} 970}
971 971
972static u8 append_local_name(struct hci_dev *hdev, u8 *ptr, u8 ad_len) 972u8 append_local_name(struct hci_dev *hdev, u8 *ptr, u8 ad_len)
973{ 973{
974 size_t complete_len;
975 size_t short_len; 974 size_t short_len;
976 int max_len; 975 size_t complete_len;
977
978 max_len = HCI_MAX_AD_LENGTH - ad_len - 2;
979 complete_len = strlen(hdev->dev_name);
980 short_len = strlen(hdev->short_name);
981
982 /* no space left for name */
983 if (max_len < 1)
984 return ad_len;
985 976
986 /* no name set */ 977 /* no space left for name (+ NULL + type + len) */
987 if (!complete_len) 978 if ((HCI_MAX_AD_LENGTH - ad_len) < HCI_MAX_SHORT_NAME_LENGTH + 3)
988 return ad_len; 979 return ad_len;
989 980
990 /* complete name fits and is eq to max short name len or smaller */ 981 /* use complete name if present and fits */
991 if (complete_len <= max_len && 982 complete_len = strlen(hdev->dev_name);
992 complete_len <= HCI_MAX_SHORT_NAME_LENGTH) { 983 if (complete_len && complete_len <= HCI_MAX_SHORT_NAME_LENGTH)
993 return eir_append_data(ptr, ad_len, EIR_NAME_COMPLETE, 984 return eir_append_data(ptr, ad_len, EIR_NAME_COMPLETE,
994 hdev->dev_name, complete_len); 985 hdev->dev_name, complete_len + 1);
995 }
996 986
997 /* short name set and fits */ 987 /* use short name if present */
998 if (short_len && short_len <= max_len) { 988 short_len = strlen(hdev->short_name);
989 if (short_len)
999 return eir_append_data(ptr, ad_len, EIR_NAME_SHORT, 990 return eir_append_data(ptr, ad_len, EIR_NAME_SHORT,
1000 hdev->short_name, short_len); 991 hdev->short_name, short_len + 1);
1001 }
1002 992
1003 /* no short name set so shorten complete name */ 993 /* use shortened full name if present, we already know that name
1004 if (!short_len) { 994 * is longer then HCI_MAX_SHORT_NAME_LENGTH
1005 return eir_append_data(ptr, ad_len, EIR_NAME_SHORT, 995 */
1006 hdev->dev_name, max_len); 996 if (complete_len) {
997 u8 name[HCI_MAX_SHORT_NAME_LENGTH + 1];
998
999 memcpy(name, hdev->dev_name, HCI_MAX_SHORT_NAME_LENGTH);
1000 name[HCI_MAX_SHORT_NAME_LENGTH] = '\0';
1001
1002 return eir_append_data(ptr, ad_len, EIR_NAME_SHORT, name,
1003 sizeof(name));
1007 } 1004 }
1008 1005
1009 return ad_len; 1006 return ad_len;
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
index 6b06629245a8..dde77bd59f91 100644
--- a/net/bluetooth/hci_request.h
+++ b/net/bluetooth/hci_request.h
@@ -106,6 +106,8 @@ static inline void hci_update_background_scan(struct hci_dev *hdev)
106void hci_request_setup(struct hci_dev *hdev); 106void hci_request_setup(struct hci_dev *hdev);
107void hci_request_cancel_all(struct hci_dev *hdev); 107void hci_request_cancel_all(struct hci_dev *hdev);
108 108
109u8 append_local_name(struct hci_dev *hdev, u8 *ptr, u8 ad_len);
110
109static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, 111static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type,
110 u8 *data, u8 data_len) 112 u8 *data, u8 data_len)
111{ 113{
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 736038085feb..1fba2a03f8ae 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6017,7 +6017,15 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
6017 return err; 6017 return err;
6018} 6018}
6019 6019
6020static u8 tlv_data_max_len(u32 adv_flags, bool is_adv_data) 6020static u8 calculate_name_len(struct hci_dev *hdev)
6021{
6022 u8 buf[HCI_MAX_SHORT_NAME_LENGTH + 3];
6023
6024 return append_local_name(hdev, buf, 0);
6025}
6026
6027static u8 tlv_data_max_len(struct hci_dev *hdev, u32 adv_flags,
6028 bool is_adv_data)
6021{ 6029{
6022 u8 max_len = HCI_MAX_AD_LENGTH; 6030 u8 max_len = HCI_MAX_AD_LENGTH;
6023 6031
@@ -6030,9 +6038,8 @@ static u8 tlv_data_max_len(u32 adv_flags, bool is_adv_data)
6030 if (adv_flags & MGMT_ADV_FLAG_TX_POWER) 6038 if (adv_flags & MGMT_ADV_FLAG_TX_POWER)
6031 max_len -= 3; 6039 max_len -= 3;
6032 } else { 6040 } else {
6033 /* at least 1 byte of name should fit in */
6034 if (adv_flags & MGMT_ADV_FLAG_LOCAL_NAME) 6041 if (adv_flags & MGMT_ADV_FLAG_LOCAL_NAME)
6035 max_len -= 3; 6042 max_len -= calculate_name_len(hdev);
6036 6043
6037 if (adv_flags & (MGMT_ADV_FLAG_APPEARANCE)) 6044 if (adv_flags & (MGMT_ADV_FLAG_APPEARANCE))
6038 max_len -= 4; 6045 max_len -= 4;
@@ -6063,12 +6070,13 @@ static bool appearance_managed(u32 adv_flags)
6063 return adv_flags & MGMT_ADV_FLAG_APPEARANCE; 6070 return adv_flags & MGMT_ADV_FLAG_APPEARANCE;
6064} 6071}
6065 6072
6066static bool tlv_data_is_valid(u32 adv_flags, u8 *data, u8 len, bool is_adv_data) 6073static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
6074 u8 len, bool is_adv_data)
6067{ 6075{
6068 int i, cur_len; 6076 int i, cur_len;
6069 u8 max_len; 6077 u8 max_len;
6070 6078
6071 max_len = tlv_data_max_len(adv_flags, is_adv_data); 6079 max_len = tlv_data_max_len(hdev, adv_flags, is_adv_data);
6072 6080
6073 if (len > max_len) 6081 if (len > max_len)
6074 return false; 6082 return false;
@@ -6215,8 +6223,8 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
6215 goto unlock; 6223 goto unlock;
6216 } 6224 }
6217 6225
6218 if (!tlv_data_is_valid(flags, cp->data, cp->adv_data_len, true) || 6226 if (!tlv_data_is_valid(hdev, flags, cp->data, cp->adv_data_len, true) ||
6219 !tlv_data_is_valid(flags, cp->data + cp->adv_data_len, 6227 !tlv_data_is_valid(hdev, flags, cp->data + cp->adv_data_len,
6220 cp->scan_rsp_len, false)) { 6228 cp->scan_rsp_len, false)) {
6221 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, 6229 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING,
6222 MGMT_STATUS_INVALID_PARAMS); 6230 MGMT_STATUS_INVALID_PARAMS);
@@ -6429,8 +6437,8 @@ static int get_adv_size_info(struct sock *sk, struct hci_dev *hdev,
6429 6437
6430 rp.instance = cp->instance; 6438 rp.instance = cp->instance;
6431 rp.flags = cp->flags; 6439 rp.flags = cp->flags;
6432 rp.max_adv_data_len = tlv_data_max_len(flags, true); 6440 rp.max_adv_data_len = tlv_data_max_len(hdev, flags, true);
6433 rp.max_scan_rsp_len = tlv_data_max_len(flags, false); 6441 rp.max_scan_rsp_len = tlv_data_max_len(hdev, flags, false);
6434 6442
6435 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, 6443 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO,
6436 MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); 6444 MGMT_STATUS_SUCCESS, &rp, sizeof(rp));
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index c5fea9393946..2136e45f5277 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -972,13 +972,12 @@ static void br_multicast_enable(struct bridge_mcast_own_query *query)
972 mod_timer(&query->timer, jiffies); 972 mod_timer(&query->timer, jiffies);
973} 973}
974 974
975void br_multicast_enable_port(struct net_bridge_port *port) 975static void __br_multicast_enable_port(struct net_bridge_port *port)
976{ 976{
977 struct net_bridge *br = port->br; 977 struct net_bridge *br = port->br;
978 978
979 spin_lock(&br->multicast_lock);
980 if (br->multicast_disabled || !netif_running(br->dev)) 979 if (br->multicast_disabled || !netif_running(br->dev))
981 goto out; 980 return;
982 981
983 br_multicast_enable(&port->ip4_own_query); 982 br_multicast_enable(&port->ip4_own_query);
984#if IS_ENABLED(CONFIG_IPV6) 983#if IS_ENABLED(CONFIG_IPV6)
@@ -987,8 +986,14 @@ void br_multicast_enable_port(struct net_bridge_port *port)
987 if (port->multicast_router == MDB_RTR_TYPE_PERM && 986 if (port->multicast_router == MDB_RTR_TYPE_PERM &&
988 hlist_unhashed(&port->rlist)) 987 hlist_unhashed(&port->rlist))
989 br_multicast_add_router(br, port); 988 br_multicast_add_router(br, port);
989}
990 990
991out: 991void br_multicast_enable_port(struct net_bridge_port *port)
992{
993 struct net_bridge *br = port->br;
994
995 spin_lock(&br->multicast_lock);
996 __br_multicast_enable_port(port);
992 spin_unlock(&br->multicast_lock); 997 spin_unlock(&br->multicast_lock);
993} 998}
994 999
@@ -1994,8 +1999,9 @@ static void br_multicast_start_querier(struct net_bridge *br,
1994 1999
1995int br_multicast_toggle(struct net_bridge *br, unsigned long val) 2000int br_multicast_toggle(struct net_bridge *br, unsigned long val)
1996{ 2001{
1997 int err = 0;
1998 struct net_bridge_mdb_htable *mdb; 2002 struct net_bridge_mdb_htable *mdb;
2003 struct net_bridge_port *port;
2004 int err = 0;
1999 2005
2000 spin_lock_bh(&br->multicast_lock); 2006 spin_lock_bh(&br->multicast_lock);
2001 if (br->multicast_disabled == !val) 2007 if (br->multicast_disabled == !val)
@@ -2023,10 +2029,9 @@ rollback:
2023 goto rollback; 2029 goto rollback;
2024 } 2030 }
2025 2031
2026 br_multicast_start_querier(br, &br->ip4_own_query); 2032 br_multicast_open(br);
2027#if IS_ENABLED(CONFIG_IPV6) 2033 list_for_each_entry(port, &br->port_list, list)
2028 br_multicast_start_querier(br, &br->ip6_own_query); 2034 __br_multicast_enable_port(port);
2029#endif
2030 2035
2031unlock: 2036unlock:
2032 spin_unlock_bh(&br->multicast_lock); 2037 spin_unlock_bh(&br->multicast_lock);
diff --git a/net/core/dev.c b/net/core/dev.c
index 4bc19a164ba5..820bac239738 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3035,6 +3035,7 @@ struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *d
3035 } 3035 }
3036 return head; 3036 return head;
3037} 3037}
3038EXPORT_SYMBOL_GPL(validate_xmit_skb_list);
3038 3039
3039static void qdisc_pkt_len_init(struct sk_buff *skb) 3040static void qdisc_pkt_len_init(struct sk_buff *skb)
3040{ 3041{
@@ -4511,6 +4512,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
4511 NAPI_GRO_CB(skb)->flush = 0; 4512 NAPI_GRO_CB(skb)->flush = 0;
4512 NAPI_GRO_CB(skb)->free = 0; 4513 NAPI_GRO_CB(skb)->free = 0;
4513 NAPI_GRO_CB(skb)->encap_mark = 0; 4514 NAPI_GRO_CB(skb)->encap_mark = 0;
4515 NAPI_GRO_CB(skb)->recursion_counter = 0;
4514 NAPI_GRO_CB(skb)->is_fou = 0; 4516 NAPI_GRO_CB(skb)->is_fou = 0;
4515 NAPI_GRO_CB(skb)->is_atomic = 1; 4517 NAPI_GRO_CB(skb)->is_atomic = 1;
4516 NAPI_GRO_CB(skb)->gro_remcsum_start = 0; 4518 NAPI_GRO_CB(skb)->gro_remcsum_start = 0;
@@ -5511,10 +5513,14 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
5511{ 5513{
5512 struct netdev_adjacent *lower; 5514 struct netdev_adjacent *lower;
5513 5515
5514 lower = list_first_or_null_rcu(&dev->all_adj_list.lower, 5516 lower = list_entry_rcu((*iter)->next, struct netdev_adjacent, list);
5515 struct netdev_adjacent, list); 5517
5518 if (&lower->list == &dev->all_adj_list.lower)
5519 return NULL;
5520
5521 *iter = &lower->list;
5516 5522
5517 return lower ? lower->dev : NULL; 5523 return lower->dev;
5518} 5524}
5519EXPORT_SYMBOL(netdev_all_lower_get_next_rcu); 5525EXPORT_SYMBOL(netdev_all_lower_get_next_rcu);
5520 5526
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 1a7b80f73376..ab193e5def07 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -246,15 +246,13 @@ ipv6:
246 case htons(ETH_P_8021AD): 246 case htons(ETH_P_8021AD):
247 case htons(ETH_P_8021Q): { 247 case htons(ETH_P_8021Q): {
248 const struct vlan_hdr *vlan; 248 const struct vlan_hdr *vlan;
249 struct vlan_hdr _vlan;
250 bool vlan_tag_present = skb && skb_vlan_tag_present(skb);
249 251
250 if (skb_vlan_tag_present(skb)) 252 if (vlan_tag_present)
251 proto = skb->protocol; 253 proto = skb->protocol;
252 254
253 if (!skb_vlan_tag_present(skb) || 255 if (!vlan_tag_present || eth_type_vlan(skb->protocol)) {
254 proto == cpu_to_be16(ETH_P_8021Q) ||
255 proto == cpu_to_be16(ETH_P_8021AD)) {
256 struct vlan_hdr _vlan;
257
258 vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan), 256 vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan),
259 data, hlen, &_vlan); 257 data, hlen, &_vlan);
260 if (!vlan) 258 if (!vlan)
@@ -272,7 +270,7 @@ ipv6:
272 FLOW_DISSECTOR_KEY_VLAN, 270 FLOW_DISSECTOR_KEY_VLAN,
273 target_container); 271 target_container);
274 272
275 if (skb_vlan_tag_present(skb)) { 273 if (vlan_tag_present) {
276 key_vlan->vlan_id = skb_vlan_tag_get_id(skb); 274 key_vlan->vlan_id = skb_vlan_tag_get_id(skb);
277 key_vlan->vlan_priority = 275 key_vlan->vlan_priority =
278 (skb_vlan_tag_get_prio(skb) >> VLAN_PRIO_SHIFT); 276 (skb_vlan_tag_get_prio(skb) >> VLAN_PRIO_SHIFT);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 989434f36f96..f61c0e02a413 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -215,13 +215,14 @@ static void rtnl_net_notifyid(struct net *net, int cmd, int id);
215 */ 215 */
216int peernet2id_alloc(struct net *net, struct net *peer) 216int peernet2id_alloc(struct net *net, struct net *peer)
217{ 217{
218 unsigned long flags;
218 bool alloc; 219 bool alloc;
219 int id; 220 int id;
220 221
221 spin_lock_bh(&net->nsid_lock); 222 spin_lock_irqsave(&net->nsid_lock, flags);
222 alloc = atomic_read(&peer->count) == 0 ? false : true; 223 alloc = atomic_read(&peer->count) == 0 ? false : true;
223 id = __peernet2id_alloc(net, peer, &alloc); 224 id = __peernet2id_alloc(net, peer, &alloc);
224 spin_unlock_bh(&net->nsid_lock); 225 spin_unlock_irqrestore(&net->nsid_lock, flags);
225 if (alloc && id >= 0) 226 if (alloc && id >= 0)
226 rtnl_net_notifyid(net, RTM_NEWNSID, id); 227 rtnl_net_notifyid(net, RTM_NEWNSID, id);
227 return id; 228 return id;
@@ -230,11 +231,12 @@ int peernet2id_alloc(struct net *net, struct net *peer)
230/* This function returns, if assigned, the id of a peer netns. */ 231/* This function returns, if assigned, the id of a peer netns. */
231int peernet2id(struct net *net, struct net *peer) 232int peernet2id(struct net *net, struct net *peer)
232{ 233{
234 unsigned long flags;
233 int id; 235 int id;
234 236
235 spin_lock_bh(&net->nsid_lock); 237 spin_lock_irqsave(&net->nsid_lock, flags);
236 id = __peernet2id(net, peer); 238 id = __peernet2id(net, peer);
237 spin_unlock_bh(&net->nsid_lock); 239 spin_unlock_irqrestore(&net->nsid_lock, flags);
238 return id; 240 return id;
239} 241}
240EXPORT_SYMBOL(peernet2id); 242EXPORT_SYMBOL(peernet2id);
@@ -249,17 +251,18 @@ bool peernet_has_id(struct net *net, struct net *peer)
249 251
250struct net *get_net_ns_by_id(struct net *net, int id) 252struct net *get_net_ns_by_id(struct net *net, int id)
251{ 253{
254 unsigned long flags;
252 struct net *peer; 255 struct net *peer;
253 256
254 if (id < 0) 257 if (id < 0)
255 return NULL; 258 return NULL;
256 259
257 rcu_read_lock(); 260 rcu_read_lock();
258 spin_lock_bh(&net->nsid_lock); 261 spin_lock_irqsave(&net->nsid_lock, flags);
259 peer = idr_find(&net->netns_ids, id); 262 peer = idr_find(&net->netns_ids, id);
260 if (peer) 263 if (peer)
261 get_net(peer); 264 get_net(peer);
262 spin_unlock_bh(&net->nsid_lock); 265 spin_unlock_irqrestore(&net->nsid_lock, flags);
263 rcu_read_unlock(); 266 rcu_read_unlock();
264 267
265 return peer; 268 return peer;
@@ -422,17 +425,17 @@ static void cleanup_net(struct work_struct *work)
422 for_each_net(tmp) { 425 for_each_net(tmp) {
423 int id; 426 int id;
424 427
425 spin_lock_bh(&tmp->nsid_lock); 428 spin_lock_irq(&tmp->nsid_lock);
426 id = __peernet2id(tmp, net); 429 id = __peernet2id(tmp, net);
427 if (id >= 0) 430 if (id >= 0)
428 idr_remove(&tmp->netns_ids, id); 431 idr_remove(&tmp->netns_ids, id);
429 spin_unlock_bh(&tmp->nsid_lock); 432 spin_unlock_irq(&tmp->nsid_lock);
430 if (id >= 0) 433 if (id >= 0)
431 rtnl_net_notifyid(tmp, RTM_DELNSID, id); 434 rtnl_net_notifyid(tmp, RTM_DELNSID, id);
432 } 435 }
433 spin_lock_bh(&net->nsid_lock); 436 spin_lock_irq(&net->nsid_lock);
434 idr_destroy(&net->netns_ids); 437 idr_destroy(&net->netns_ids);
435 spin_unlock_bh(&net->nsid_lock); 438 spin_unlock_irq(&net->nsid_lock);
436 439
437 } 440 }
438 rtnl_unlock(); 441 rtnl_unlock();
@@ -561,6 +564,7 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh)
561{ 564{
562 struct net *net = sock_net(skb->sk); 565 struct net *net = sock_net(skb->sk);
563 struct nlattr *tb[NETNSA_MAX + 1]; 566 struct nlattr *tb[NETNSA_MAX + 1];
567 unsigned long flags;
564 struct net *peer; 568 struct net *peer;
565 int nsid, err; 569 int nsid, err;
566 570
@@ -581,15 +585,15 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh)
581 if (IS_ERR(peer)) 585 if (IS_ERR(peer))
582 return PTR_ERR(peer); 586 return PTR_ERR(peer);
583 587
584 spin_lock_bh(&net->nsid_lock); 588 spin_lock_irqsave(&net->nsid_lock, flags);
585 if (__peernet2id(net, peer) >= 0) { 589 if (__peernet2id(net, peer) >= 0) {
586 spin_unlock_bh(&net->nsid_lock); 590 spin_unlock_irqrestore(&net->nsid_lock, flags);
587 err = -EEXIST; 591 err = -EEXIST;
588 goto out; 592 goto out;
589 } 593 }
590 594
591 err = alloc_netid(net, peer, nsid); 595 err = alloc_netid(net, peer, nsid);
592 spin_unlock_bh(&net->nsid_lock); 596 spin_unlock_irqrestore(&net->nsid_lock, flags);
593 if (err >= 0) { 597 if (err >= 0) {
594 rtnl_net_notifyid(net, RTM_NEWNSID, err); 598 rtnl_net_notifyid(net, RTM_NEWNSID, err);
595 err = 0; 599 err = 0;
@@ -711,10 +715,11 @@ static int rtnl_net_dumpid(struct sk_buff *skb, struct netlink_callback *cb)
711 .idx = 0, 715 .idx = 0,
712 .s_idx = cb->args[0], 716 .s_idx = cb->args[0],
713 }; 717 };
718 unsigned long flags;
714 719
715 spin_lock_bh(&net->nsid_lock); 720 spin_lock_irqsave(&net->nsid_lock, flags);
716 idr_for_each(&net->netns_ids, rtnl_net_dumpid_one, &net_cb); 721 idr_for_each(&net->netns_ids, rtnl_net_dumpid_one, &net_cb);
717 spin_unlock_bh(&net->nsid_lock); 722 spin_unlock_irqrestore(&net->nsid_lock, flags);
718 723
719 cb->args[0] = net_cb.idx; 724 cb->args[0] = net_cb.idx;
720 return skb->len; 725 return skb->len;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 5219a9e2127a..306b8f0e03c1 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -216,8 +216,8 @@
216#define M_QUEUE_XMIT 2 /* Inject packet into qdisc */ 216#define M_QUEUE_XMIT 2 /* Inject packet into qdisc */
217 217
218/* If lock -- protects updating of if_list */ 218/* If lock -- protects updating of if_list */
219#define if_lock(t) spin_lock(&(t->if_lock)); 219#define if_lock(t) mutex_lock(&(t->if_lock));
220#define if_unlock(t) spin_unlock(&(t->if_lock)); 220#define if_unlock(t) mutex_unlock(&(t->if_lock));
221 221
222/* Used to help with determining the pkts on receive */ 222/* Used to help with determining the pkts on receive */
223#define PKTGEN_MAGIC 0xbe9be955 223#define PKTGEN_MAGIC 0xbe9be955
@@ -423,7 +423,7 @@ struct pktgen_net {
423}; 423};
424 424
425struct pktgen_thread { 425struct pktgen_thread {
426 spinlock_t if_lock; /* for list of devices */ 426 struct mutex if_lock; /* for list of devices */
427 struct list_head if_list; /* All device here */ 427 struct list_head if_list; /* All device here */
428 struct list_head th_list; 428 struct list_head th_list;
429 struct task_struct *tsk; 429 struct task_struct *tsk;
@@ -2010,11 +2010,13 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
2010{ 2010{
2011 struct pktgen_thread *t; 2011 struct pktgen_thread *t;
2012 2012
2013 mutex_lock(&pktgen_thread_lock);
2014
2013 list_for_each_entry(t, &pn->pktgen_threads, th_list) { 2015 list_for_each_entry(t, &pn->pktgen_threads, th_list) {
2014 struct pktgen_dev *pkt_dev; 2016 struct pktgen_dev *pkt_dev;
2015 2017
2016 rcu_read_lock(); 2018 if_lock(t);
2017 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) { 2019 list_for_each_entry(pkt_dev, &t->if_list, list) {
2018 if (pkt_dev->odev != dev) 2020 if (pkt_dev->odev != dev)
2019 continue; 2021 continue;
2020 2022
@@ -2029,8 +2031,9 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
2029 dev->name); 2031 dev->name);
2030 break; 2032 break;
2031 } 2033 }
2032 rcu_read_unlock(); 2034 if_unlock(t);
2033 } 2035 }
2036 mutex_unlock(&pktgen_thread_lock);
2034} 2037}
2035 2038
2036static int pktgen_device_event(struct notifier_block *unused, 2039static int pktgen_device_event(struct notifier_block *unused,
@@ -3762,7 +3765,7 @@ static int __net_init pktgen_create_thread(int cpu, struct pktgen_net *pn)
3762 return -ENOMEM; 3765 return -ENOMEM;
3763 } 3766 }
3764 3767
3765 spin_lock_init(&t->if_lock); 3768 mutex_init(&t->if_lock);
3766 t->cpu = cpu; 3769 t->cpu = cpu;
3767 3770
3768 INIT_LIST_HEAD(&t->if_list); 3771 INIT_LIST_HEAD(&t->if_list);
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index e92b759d906c..9a1a352fd1eb 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -129,7 +129,6 @@ int reuseport_add_sock(struct sock *sk, struct sock *sk2)
129 129
130 return 0; 130 return 0;
131} 131}
132EXPORT_SYMBOL(reuseport_add_sock);
133 132
134static void reuseport_free_rcu(struct rcu_head *head) 133static void reuseport_free_rcu(struct rcu_head *head)
135{ 134{
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 66dff5e3d772..02acfff36028 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -439,7 +439,7 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head,
439 439
440 skb_gro_pull(skb, sizeof(*eh)); 440 skb_gro_pull(skb, sizeof(*eh));
441 skb_gro_postpull_rcsum(skb, eh, sizeof(*eh)); 441 skb_gro_postpull_rcsum(skb, eh, sizeof(*eh));
442 pp = ptype->callbacks.gro_receive(head, skb); 442 pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
443 443
444out_unlock: 444out_unlock:
445 rcu_read_unlock(); 445 rcu_read_unlock();
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 5ee1d43f1310..4ebe2aa3e7d3 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -300,10 +300,6 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
300static void check_local_dest(struct hsr_priv *hsr, struct sk_buff *skb, 300static void check_local_dest(struct hsr_priv *hsr, struct sk_buff *skb,
301 struct hsr_frame_info *frame) 301 struct hsr_frame_info *frame)
302{ 302{
303 struct net_device *master_dev;
304
305 master_dev = hsr_port_get_hsr(hsr, HSR_PT_MASTER)->dev;
306
307 if (hsr_addr_is_self(hsr, eth_hdr(skb)->h_dest)) { 303 if (hsr_addr_is_self(hsr, eth_hdr(skb)->h_dest)) {
308 frame->is_local_exclusive = true; 304 frame->is_local_exclusive = true;
309 skb->pkt_type = PACKET_HOST; 305 skb->pkt_type = PACKET_HOST;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1effc986739e..9648c97e541f 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1391,7 +1391,7 @@ struct sk_buff **inet_gro_receive(struct sk_buff **head, struct sk_buff *skb)
1391 skb_gro_pull(skb, sizeof(*iph)); 1391 skb_gro_pull(skb, sizeof(*iph));
1392 skb_set_transport_header(skb, skb_gro_offset(skb)); 1392 skb_set_transport_header(skb, skb_gro_offset(skb));
1393 1393
1394 pp = ops->callbacks.gro_receive(head, skb); 1394 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb);
1395 1395
1396out_unlock: 1396out_unlock:
1397 rcu_read_unlock(); 1397 rcu_read_unlock();
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index cf50f7e2b012..030d1531e897 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -249,7 +249,7 @@ static struct sk_buff **fou_gro_receive(struct sock *sk,
249 if (!ops || !ops->callbacks.gro_receive) 249 if (!ops || !ops->callbacks.gro_receive)
250 goto out_unlock; 250 goto out_unlock;
251 251
252 pp = ops->callbacks.gro_receive(head, skb); 252 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb);
253 253
254out_unlock: 254out_unlock:
255 rcu_read_unlock(); 255 rcu_read_unlock();
@@ -441,7 +441,7 @@ next_proto:
441 if (WARN_ON_ONCE(!ops || !ops->callbacks.gro_receive)) 441 if (WARN_ON_ONCE(!ops || !ops->callbacks.gro_receive))
442 goto out_unlock; 442 goto out_unlock;
443 443
444 pp = ops->callbacks.gro_receive(head, skb); 444 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb);
445 flush = 0; 445 flush = 0;
446 446
447out_unlock: 447out_unlock:
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index 96e0efecefa6..d5cac99170b1 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -229,7 +229,7 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head,
229 /* Adjusted NAPI_GRO_CB(skb)->csum after skb_gro_pull()*/ 229 /* Adjusted NAPI_GRO_CB(skb)->csum after skb_gro_pull()*/
230 skb_gro_postpull_rcsum(skb, greh, grehlen); 230 skb_gro_postpull_rcsum(skb, greh, grehlen);
231 231
232 pp = ptype->callbacks.gro_receive(head, skb); 232 pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
233 flush = 0; 233 flush = 0;
234 234
235out_unlock: 235out_unlock:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 77c20a489218..ca97835bfec4 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -25,6 +25,7 @@
25#include <net/inet_hashtables.h> 25#include <net/inet_hashtables.h>
26#include <net/secure_seq.h> 26#include <net/secure_seq.h>
27#include <net/ip.h> 27#include <net/ip.h>
28#include <net/tcp.h>
28#include <net/sock_reuseport.h> 29#include <net/sock_reuseport.h>
29 30
30static u32 inet_ehashfn(const struct net *net, const __be32 laddr, 31static u32 inet_ehashfn(const struct net *net, const __be32 laddr,
@@ -172,7 +173,7 @@ EXPORT_SYMBOL_GPL(__inet_inherit_port);
172 173
173static inline int compute_score(struct sock *sk, struct net *net, 174static inline int compute_score(struct sock *sk, struct net *net,
174 const unsigned short hnum, const __be32 daddr, 175 const unsigned short hnum, const __be32 daddr,
175 const int dif) 176 const int dif, bool exact_dif)
176{ 177{
177 int score = -1; 178 int score = -1;
178 struct inet_sock *inet = inet_sk(sk); 179 struct inet_sock *inet = inet_sk(sk);
@@ -186,7 +187,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
186 return -1; 187 return -1;
187 score += 4; 188 score += 4;
188 } 189 }
189 if (sk->sk_bound_dev_if) { 190 if (sk->sk_bound_dev_if || exact_dif) {
190 if (sk->sk_bound_dev_if != dif) 191 if (sk->sk_bound_dev_if != dif)
191 return -1; 192 return -1;
192 score += 4; 193 score += 4;
@@ -215,11 +216,12 @@ struct sock *__inet_lookup_listener(struct net *net,
215 unsigned int hash = inet_lhashfn(net, hnum); 216 unsigned int hash = inet_lhashfn(net, hnum);
216 struct inet_listen_hashbucket *ilb = &hashinfo->listening_hash[hash]; 217 struct inet_listen_hashbucket *ilb = &hashinfo->listening_hash[hash];
217 int score, hiscore = 0, matches = 0, reuseport = 0; 218 int score, hiscore = 0, matches = 0, reuseport = 0;
219 bool exact_dif = inet_exact_dif_match(net, skb);
218 struct sock *sk, *result = NULL; 220 struct sock *sk, *result = NULL;
219 u32 phash = 0; 221 u32 phash = 0;
220 222
221 sk_for_each_rcu(sk, &ilb->head) { 223 sk_for_each_rcu(sk, &ilb->head) {
222 score = compute_score(sk, net, hnum, daddr, dif); 224 score = compute_score(sk, net, hnum, daddr, dif, exact_dif);
223 if (score > hiscore) { 225 if (score > hiscore) {
224 reuseport = sk->sk_reuseport; 226 reuseport = sk->sk_reuseport;
225 if (reuseport) { 227 if (reuseport) {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 05d105832bdb..03e7f7310423 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -538,7 +538,6 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
538{ 538{
539 struct iphdr *iph; 539 struct iphdr *iph;
540 int ptr; 540 int ptr;
541 struct net_device *dev;
542 struct sk_buff *skb2; 541 struct sk_buff *skb2;
543 unsigned int mtu, hlen, left, len, ll_rs; 542 unsigned int mtu, hlen, left, len, ll_rs;
544 int offset; 543 int offset;
@@ -546,8 +545,6 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
546 struct rtable *rt = skb_rtable(skb); 545 struct rtable *rt = skb_rtable(skb);
547 int err = 0; 546 int err = 0;
548 547
549 dev = rt->dst.dev;
550
551 /* for offloaded checksums cleanup checksum before fragmentation */ 548 /* for offloaded checksums cleanup checksum before fragmentation */
552 if (skb->ip_summed == CHECKSUM_PARTIAL && 549 if (skb->ip_summed == CHECKSUM_PARTIAL &&
553 (err = skb_checksum_help(skb))) 550 (err = skb_checksum_help(skb)))
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index af4919792b6a..b8a2d63d1fb8 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -98,7 +98,7 @@ static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb)
98} 98}
99 99
100static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb, 100static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,
101 int offset) 101 int tlen, int offset)
102{ 102{
103 __wsum csum = skb->csum; 103 __wsum csum = skb->csum;
104 104
@@ -106,8 +106,9 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,
106 return; 106 return;
107 107
108 if (offset != 0) 108 if (offset != 0)
109 csum = csum_sub(csum, csum_partial(skb_transport_header(skb), 109 csum = csum_sub(csum,
110 offset, 0)); 110 csum_partial(skb_transport_header(skb) + tlen,
111 offset, 0));
111 112
112 put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum); 113 put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);
113} 114}
@@ -153,7 +154,7 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
153} 154}
154 155
155void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb, 156void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb,
156 int offset) 157 int tlen, int offset)
157{ 158{
158 struct inet_sock *inet = inet_sk(skb->sk); 159 struct inet_sock *inet = inet_sk(skb->sk);
159 unsigned int flags = inet->cmsg_flags; 160 unsigned int flags = inet->cmsg_flags;
@@ -216,7 +217,7 @@ void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb,
216 } 217 }
217 218
218 if (flags & IP_CMSG_CHECKSUM) 219 if (flags & IP_CMSG_CHECKSUM)
219 ip_cmsg_recv_checksum(msg, skb, offset); 220 ip_cmsg_recv_checksum(msg, skb, tlen, offset);
220} 221}
221EXPORT_SYMBOL(ip_cmsg_recv_offset); 222EXPORT_SYMBOL(ip_cmsg_recv_offset);
222 223
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 7cf7d6e380c2..205e2000d395 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -994,7 +994,7 @@ struct proto ping_prot = {
994 .init = ping_init_sock, 994 .init = ping_init_sock,
995 .close = ping_close, 995 .close = ping_close,
996 .connect = ip4_datagram_connect, 996 .connect = ip4_datagram_connect,
997 .disconnect = udp_disconnect, 997 .disconnect = __udp_disconnect,
998 .setsockopt = ip_setsockopt, 998 .setsockopt = ip_setsockopt,
999 .getsockopt = ip_getsockopt, 999 .getsockopt = ip_getsockopt,
1000 .sendmsg = ping_v4_sendmsg, 1000 .sendmsg = ping_v4_sendmsg,
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 90a85c955872..ecbe5a7c2d6d 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -918,7 +918,7 @@ struct proto raw_prot = {
918 .close = raw_close, 918 .close = raw_close,
919 .destroy = raw_destroy, 919 .destroy = raw_destroy,
920 .connect = ip4_datagram_connect, 920 .connect = ip4_datagram_connect,
921 .disconnect = udp_disconnect, 921 .disconnect = __udp_disconnect,
922 .ioctl = raw_ioctl, 922 .ioctl = raw_ioctl,
923 .init = raw_init, 923 .init = raw_init,
924 .setsockopt = raw_setsockopt, 924 .setsockopt = raw_setsockopt,
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 1cb67de106fe..80bc36b25de2 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -96,11 +96,11 @@ static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low
96 container_of(table->data, struct net, ipv4.ping_group_range.range); 96 container_of(table->data, struct net, ipv4.ping_group_range.range);
97 unsigned int seq; 97 unsigned int seq;
98 do { 98 do {
99 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock); 99 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
100 100
101 *low = data[0]; 101 *low = data[0];
102 *high = data[1]; 102 *high = data[1];
103 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq)); 103 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
104} 104}
105 105
106/* Update system visible IP port range */ 106/* Update system visible IP port range */
@@ -109,10 +109,10 @@ static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t hig
109 kgid_t *data = table->data; 109 kgid_t *data = table->data;
110 struct net *net = 110 struct net *net =
111 container_of(table->data, struct net, ipv4.ping_group_range.range); 111 container_of(table->data, struct net, ipv4.ping_group_range.range);
112 write_seqlock(&net->ipv4.ip_local_ports.lock); 112 write_seqlock(&net->ipv4.ping_group_range.lock);
113 data[0] = low; 113 data[0] = low;
114 data[1] = high; 114 data[1] = high;
115 write_sequnlock(&net->ipv4.ip_local_ports.lock); 115 write_sequnlock(&net->ipv4.ping_group_range.lock);
116} 116}
117 117
118/* Validate changes from /proc interface. */ 118/* Validate changes from /proc interface. */
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index bd5e8d10893f..61b7be303eec 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -86,7 +86,6 @@
86 86
87int sysctl_tcp_tw_reuse __read_mostly; 87int sysctl_tcp_tw_reuse __read_mostly;
88int sysctl_tcp_low_latency __read_mostly; 88int sysctl_tcp_low_latency __read_mostly;
89EXPORT_SYMBOL(sysctl_tcp_low_latency);
90 89
91#ifdef CONFIG_TCP_MD5SIG 90#ifdef CONFIG_TCP_MD5SIG
92static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key, 91static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
@@ -1887,7 +1886,6 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
1887 struct tcp_iter_state *st = seq->private; 1886 struct tcp_iter_state *st = seq->private;
1888 struct net *net = seq_file_net(seq); 1887 struct net *net = seq_file_net(seq);
1889 struct inet_listen_hashbucket *ilb; 1888 struct inet_listen_hashbucket *ilb;
1890 struct inet_connection_sock *icsk;
1891 struct sock *sk = cur; 1889 struct sock *sk = cur;
1892 1890
1893 if (!sk) { 1891 if (!sk) {
@@ -1909,7 +1907,6 @@ get_sk:
1909 continue; 1907 continue;
1910 if (sk->sk_family == st->family) 1908 if (sk->sk_family == st->family)
1911 return sk; 1909 return sk;
1912 icsk = inet_csk(sk);
1913 } 1910 }
1914 spin_unlock_bh(&ilb->lock); 1911 spin_unlock_bh(&ilb->lock);
1915 st->offset = 0; 1912 st->offset = 0;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 7d96dc2d3d08..d123d68f4d1d 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1322,7 +1322,7 @@ try_again:
1322 *addr_len = sizeof(*sin); 1322 *addr_len = sizeof(*sin);
1323 } 1323 }
1324 if (inet->cmsg_flags) 1324 if (inet->cmsg_flags)
1325 ip_cmsg_recv_offset(msg, skb, sizeof(struct udphdr) + off); 1325 ip_cmsg_recv_offset(msg, skb, sizeof(struct udphdr), off);
1326 1326
1327 err = copied; 1327 err = copied;
1328 if (flags & MSG_TRUNC) 1328 if (flags & MSG_TRUNC)
@@ -1345,7 +1345,7 @@ csum_copy_err:
1345 goto try_again; 1345 goto try_again;
1346} 1346}
1347 1347
1348int udp_disconnect(struct sock *sk, int flags) 1348int __udp_disconnect(struct sock *sk, int flags)
1349{ 1349{
1350 struct inet_sock *inet = inet_sk(sk); 1350 struct inet_sock *inet = inet_sk(sk);
1351 /* 1351 /*
@@ -1367,6 +1367,15 @@ int udp_disconnect(struct sock *sk, int flags)
1367 sk_dst_reset(sk); 1367 sk_dst_reset(sk);
1368 return 0; 1368 return 0;
1369} 1369}
1370EXPORT_SYMBOL(__udp_disconnect);
1371
1372int udp_disconnect(struct sock *sk, int flags)
1373{
1374 lock_sock(sk);
1375 __udp_disconnect(sk, flags);
1376 release_sock(sk);
1377 return 0;
1378}
1370EXPORT_SYMBOL(udp_disconnect); 1379EXPORT_SYMBOL(udp_disconnect);
1371 1380
1372void udp_lib_unhash(struct sock *sk) 1381void udp_lib_unhash(struct sock *sk)
@@ -2193,7 +2202,7 @@ int udp_abort(struct sock *sk, int err)
2193 2202
2194 sk->sk_err = err; 2203 sk->sk_err = err;
2195 sk->sk_error_report(sk); 2204 sk->sk_error_report(sk);
2196 udp_disconnect(sk, 0); 2205 __udp_disconnect(sk, 0);
2197 2206
2198 release_sock(sk); 2207 release_sock(sk);
2199 2208
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index f9333c963607..b2be1d9757ef 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -295,7 +295,7 @@ unflush:
295 295
296 skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */ 296 skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */
297 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr)); 297 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));
298 pp = udp_sk(sk)->gro_receive(sk, head, skb); 298 pp = call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb);
299 299
300out_unlock: 300out_unlock:
301 rcu_read_unlock(); 301 rcu_read_unlock();
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d8983e15f859..060dd9922018 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -147,9 +147,8 @@ static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)
147} 147}
148#endif 148#endif
149 149
150static void __ipv6_regen_rndid(struct inet6_dev *idev); 150static void ipv6_regen_rndid(struct inet6_dev *idev);
151static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 151static void ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
152static void ipv6_regen_rndid(unsigned long data);
153 152
154static int ipv6_generate_eui64(u8 *eui, struct net_device *dev); 153static int ipv6_generate_eui64(u8 *eui, struct net_device *dev);
155static int ipv6_count_addresses(struct inet6_dev *idev); 154static int ipv6_count_addresses(struct inet6_dev *idev);
@@ -409,9 +408,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
409 goto err_release; 408 goto err_release;
410 } 409 }
411 410
412 /* One reference from device. We must do this before 411 /* One reference from device. */
413 * we invoke __ipv6_regen_rndid().
414 */
415 in6_dev_hold(ndev); 412 in6_dev_hold(ndev);
416 413
417 if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) 414 if (dev->flags & (IFF_NOARP | IFF_LOOPBACK))
@@ -425,17 +422,15 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
425#endif 422#endif
426 423
427 INIT_LIST_HEAD(&ndev->tempaddr_list); 424 INIT_LIST_HEAD(&ndev->tempaddr_list);
428 setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev); 425 ndev->desync_factor = U32_MAX;
429 if ((dev->flags&IFF_LOOPBACK) || 426 if ((dev->flags&IFF_LOOPBACK) ||
430 dev->type == ARPHRD_TUNNEL || 427 dev->type == ARPHRD_TUNNEL ||
431 dev->type == ARPHRD_TUNNEL6 || 428 dev->type == ARPHRD_TUNNEL6 ||
432 dev->type == ARPHRD_SIT || 429 dev->type == ARPHRD_SIT ||
433 dev->type == ARPHRD_NONE) { 430 dev->type == ARPHRD_NONE) {
434 ndev->cnf.use_tempaddr = -1; 431 ndev->cnf.use_tempaddr = -1;
435 } else { 432 } else
436 in6_dev_hold(ndev); 433 ipv6_regen_rndid(ndev);
437 ipv6_regen_rndid((unsigned long) ndev);
438 }
439 434
440 ndev->token = in6addr_any; 435 ndev->token = in6addr_any;
441 436
@@ -447,7 +442,6 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
447 err = addrconf_sysctl_register(ndev); 442 err = addrconf_sysctl_register(ndev);
448 if (err) { 443 if (err) {
449 ipv6_mc_destroy_dev(ndev); 444 ipv6_mc_destroy_dev(ndev);
450 del_timer(&ndev->regen_timer);
451 snmp6_unregister_dev(ndev); 445 snmp6_unregister_dev(ndev);
452 goto err_release; 446 goto err_release;
453 } 447 }
@@ -1190,6 +1184,8 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i
1190 int ret = 0; 1184 int ret = 0;
1191 u32 addr_flags; 1185 u32 addr_flags;
1192 unsigned long now = jiffies; 1186 unsigned long now = jiffies;
1187 long max_desync_factor;
1188 s32 cnf_temp_preferred_lft;
1193 1189
1194 write_lock_bh(&idev->lock); 1190 write_lock_bh(&idev->lock);
1195 if (ift) { 1191 if (ift) {
@@ -1222,23 +1218,42 @@ retry:
1222 } 1218 }
1223 in6_ifa_hold(ifp); 1219 in6_ifa_hold(ifp);
1224 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8); 1220 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
1225 __ipv6_try_regen_rndid(idev, tmpaddr); 1221 ipv6_try_regen_rndid(idev, tmpaddr);
1226 memcpy(&addr.s6_addr[8], idev->rndid, 8); 1222 memcpy(&addr.s6_addr[8], idev->rndid, 8);
1227 age = (now - ifp->tstamp) / HZ; 1223 age = (now - ifp->tstamp) / HZ;
1224
1225 regen_advance = idev->cnf.regen_max_retry *
1226 idev->cnf.dad_transmits *
1227 NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ;
1228
1229 /* recalculate max_desync_factor each time and update
1230 * idev->desync_factor if it's larger
1231 */
1232 cnf_temp_preferred_lft = READ_ONCE(idev->cnf.temp_prefered_lft);
1233 max_desync_factor = min_t(__u32,
1234 idev->cnf.max_desync_factor,
1235 cnf_temp_preferred_lft - regen_advance);
1236
1237 if (unlikely(idev->desync_factor > max_desync_factor)) {
1238 if (max_desync_factor > 0) {
1239 get_random_bytes(&idev->desync_factor,
1240 sizeof(idev->desync_factor));
1241 idev->desync_factor %= max_desync_factor;
1242 } else {
1243 idev->desync_factor = 0;
1244 }
1245 }
1246
1228 tmp_valid_lft = min_t(__u32, 1247 tmp_valid_lft = min_t(__u32,
1229 ifp->valid_lft, 1248 ifp->valid_lft,
1230 idev->cnf.temp_valid_lft + age); 1249 idev->cnf.temp_valid_lft + age);
1231 tmp_prefered_lft = min_t(__u32, 1250 tmp_prefered_lft = cnf_temp_preferred_lft + age -
1232 ifp->prefered_lft, 1251 idev->desync_factor;
1233 idev->cnf.temp_prefered_lft + age - 1252 tmp_prefered_lft = min_t(__u32, ifp->prefered_lft, tmp_prefered_lft);
1234 idev->cnf.max_desync_factor);
1235 tmp_plen = ifp->prefix_len; 1253 tmp_plen = ifp->prefix_len;
1236 tmp_tstamp = ifp->tstamp; 1254 tmp_tstamp = ifp->tstamp;
1237 spin_unlock_bh(&ifp->lock); 1255 spin_unlock_bh(&ifp->lock);
1238 1256
1239 regen_advance = idev->cnf.regen_max_retry *
1240 idev->cnf.dad_transmits *
1241 NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ;
1242 write_unlock_bh(&idev->lock); 1257 write_unlock_bh(&idev->lock);
1243 1258
1244 /* A temporary address is created only if this calculated Preferred 1259 /* A temporary address is created only if this calculated Preferred
@@ -2150,7 +2165,7 @@ static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)
2150} 2165}
2151 2166
2152/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */ 2167/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */
2153static void __ipv6_regen_rndid(struct inet6_dev *idev) 2168static void ipv6_regen_rndid(struct inet6_dev *idev)
2154{ 2169{
2155regen: 2170regen:
2156 get_random_bytes(idev->rndid, sizeof(idev->rndid)); 2171 get_random_bytes(idev->rndid, sizeof(idev->rndid));
@@ -2179,43 +2194,10 @@ regen:
2179 } 2194 }
2180} 2195}
2181 2196
2182static void ipv6_regen_rndid(unsigned long data) 2197static void ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr)
2183{
2184 struct inet6_dev *idev = (struct inet6_dev *) data;
2185 unsigned long expires;
2186
2187 rcu_read_lock_bh();
2188 write_lock_bh(&idev->lock);
2189
2190 if (idev->dead)
2191 goto out;
2192
2193 __ipv6_regen_rndid(idev);
2194
2195 expires = jiffies +
2196 idev->cnf.temp_prefered_lft * HZ -
2197 idev->cnf.regen_max_retry * idev->cnf.dad_transmits *
2198 NEIGH_VAR(idev->nd_parms, RETRANS_TIME) -
2199 idev->cnf.max_desync_factor * HZ;
2200 if (time_before(expires, jiffies)) {
2201 pr_warn("%s: too short regeneration interval; timer disabled for %s\n",
2202 __func__, idev->dev->name);
2203 goto out;
2204 }
2205
2206 if (!mod_timer(&idev->regen_timer, expires))
2207 in6_dev_hold(idev);
2208
2209out:
2210 write_unlock_bh(&idev->lock);
2211 rcu_read_unlock_bh();
2212 in6_dev_put(idev);
2213}
2214
2215static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr)
2216{ 2198{
2217 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0) 2199 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0)
2218 __ipv6_regen_rndid(idev); 2200 ipv6_regen_rndid(idev);
2219} 2201}
2220 2202
2221/* 2203/*
@@ -2356,7 +2338,7 @@ static void manage_tempaddrs(struct inet6_dev *idev,
2356 max_valid = 0; 2338 max_valid = 0;
2357 2339
2358 max_prefered = idev->cnf.temp_prefered_lft - 2340 max_prefered = idev->cnf.temp_prefered_lft -
2359 idev->cnf.max_desync_factor - age; 2341 idev->desync_factor - age;
2360 if (max_prefered < 0) 2342 if (max_prefered < 0)
2361 max_prefered = 0; 2343 max_prefered = 0;
2362 2344
@@ -3018,7 +3000,7 @@ static void init_loopback(struct net_device *dev)
3018 * lo device down, release this obsolete dst and 3000 * lo device down, release this obsolete dst and
3019 * reallocate a new router for ifa. 3001 * reallocate a new router for ifa.
3020 */ 3002 */
3021 if (sp_ifa->rt->dst.obsolete > 0) { 3003 if (!atomic_read(&sp_ifa->rt->rt6i_ref)) {
3022 ip6_rt_put(sp_ifa->rt); 3004 ip6_rt_put(sp_ifa->rt);
3023 sp_ifa->rt = NULL; 3005 sp_ifa->rt = NULL;
3024 } else { 3006 } else {
@@ -3594,9 +3576,6 @@ restart:
3594 if (!how) 3576 if (!how)
3595 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY); 3577 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY);
3596 3578
3597 if (how && del_timer(&idev->regen_timer))
3598 in6_dev_put(idev);
3599
3600 /* Step 3: clear tempaddr list */ 3579 /* Step 3: clear tempaddr list */
3601 while (!list_empty(&idev->tempaddr_list)) { 3580 while (!list_empty(&idev->tempaddr_list)) {
3602 ifa = list_first_entry(&idev->tempaddr_list, 3581 ifa = list_first_entry(&idev->tempaddr_list,
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 00cf28ad4565..02761c9fe43e 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -96,7 +96,7 @@ EXPORT_SYMBOL(__inet6_lookup_established);
96static inline int compute_score(struct sock *sk, struct net *net, 96static inline int compute_score(struct sock *sk, struct net *net,
97 const unsigned short hnum, 97 const unsigned short hnum,
98 const struct in6_addr *daddr, 98 const struct in6_addr *daddr,
99 const int dif) 99 const int dif, bool exact_dif)
100{ 100{
101 int score = -1; 101 int score = -1;
102 102
@@ -109,7 +109,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
109 return -1; 109 return -1;
110 score++; 110 score++;
111 } 111 }
112 if (sk->sk_bound_dev_if) { 112 if (sk->sk_bound_dev_if || exact_dif) {
113 if (sk->sk_bound_dev_if != dif) 113 if (sk->sk_bound_dev_if != dif)
114 return -1; 114 return -1;
115 score++; 115 score++;
@@ -131,11 +131,12 @@ struct sock *inet6_lookup_listener(struct net *net,
131 unsigned int hash = inet_lhashfn(net, hnum); 131 unsigned int hash = inet_lhashfn(net, hnum);
132 struct inet_listen_hashbucket *ilb = &hashinfo->listening_hash[hash]; 132 struct inet_listen_hashbucket *ilb = &hashinfo->listening_hash[hash];
133 int score, hiscore = 0, matches = 0, reuseport = 0; 133 int score, hiscore = 0, matches = 0, reuseport = 0;
134 bool exact_dif = inet6_exact_dif_match(net, skb);
134 struct sock *sk, *result = NULL; 135 struct sock *sk, *result = NULL;
135 u32 phash = 0; 136 u32 phash = 0;
136 137
137 sk_for_each(sk, &ilb->head) { 138 sk_for_each(sk, &ilb->head) {
138 score = compute_score(sk, net, hnum, daddr, dif); 139 score = compute_score(sk, net, hnum, daddr, dif, exact_dif);
139 if (score > hiscore) { 140 if (score > hiscore) {
140 reuseport = sk->sk_reuseport; 141 reuseport = sk->sk_reuseport;
141 if (reuseport) { 142 if (reuseport) {
@@ -263,13 +264,15 @@ EXPORT_SYMBOL_GPL(inet6_hash_connect);
263 264
264int inet6_hash(struct sock *sk) 265int inet6_hash(struct sock *sk)
265{ 266{
267 int err = 0;
268
266 if (sk->sk_state != TCP_CLOSE) { 269 if (sk->sk_state != TCP_CLOSE) {
267 local_bh_disable(); 270 local_bh_disable();
268 __inet_hash(sk, NULL, ipv6_rcv_saddr_equal); 271 err = __inet_hash(sk, NULL, ipv6_rcv_saddr_equal);
269 local_bh_enable(); 272 local_bh_enable();
270 } 273 }
271 274
272 return 0; 275 return err;
273} 276}
274EXPORT_SYMBOL_GPL(inet6_hash); 277EXPORT_SYMBOL_GPL(inet6_hash);
275 278
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index e7bfd55899a3..1fcf61f1cbc3 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -246,7 +246,7 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
246 246
247 skb_gro_postpull_rcsum(skb, iph, nlen); 247 skb_gro_postpull_rcsum(skb, iph, nlen);
248 248
249 pp = ops->callbacks.gro_receive(head, skb); 249 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb);
250 250
251out_unlock: 251out_unlock:
252 rcu_read_unlock(); 252 rcu_read_unlock();
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 6a66adba0c22..87784560dc46 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -157,6 +157,7 @@ ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_
157 hash = HASH(&any, local); 157 hash = HASH(&any, local);
158 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { 158 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
159 if (ipv6_addr_equal(local, &t->parms.laddr) && 159 if (ipv6_addr_equal(local, &t->parms.laddr) &&
160 ipv6_addr_any(&t->parms.raddr) &&
160 (t->dev->flags & IFF_UP)) 161 (t->dev->flags & IFF_UP))
161 return t; 162 return t;
162 } 163 }
@@ -164,6 +165,7 @@ ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_
164 hash = HASH(remote, &any); 165 hash = HASH(remote, &any);
165 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { 166 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
166 if (ipv6_addr_equal(remote, &t->parms.raddr) && 167 if (ipv6_addr_equal(remote, &t->parms.raddr) &&
168 ipv6_addr_any(&t->parms.laddr) &&
167 (t->dev->flags & IFF_UP)) 169 (t->dev->flags & IFF_UP))
168 return t; 170 return t;
169 } 171 }
@@ -1170,6 +1172,7 @@ route_lookup:
1170 if (err) 1172 if (err)
1171 return err; 1173 return err;
1172 1174
1175 skb->protocol = htons(ETH_P_IPV6);
1173 skb_push(skb, sizeof(struct ipv6hdr)); 1176 skb_push(skb, sizeof(struct ipv6hdr));
1174 skb_reset_network_header(skb); 1177 skb_reset_network_header(skb);
1175 ipv6h = ipv6_hdr(skb); 1178 ipv6h = ipv6_hdr(skb);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 5330262ab673..636ec56f5f50 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -120,6 +120,7 @@ struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
120static bool setsockopt_needs_rtnl(int optname) 120static bool setsockopt_needs_rtnl(int optname)
121{ 121{
122 switch (optname) { 122 switch (optname) {
123 case IPV6_ADDRFORM:
123 case IPV6_ADD_MEMBERSHIP: 124 case IPV6_ADD_MEMBERSHIP:
124 case IPV6_DROP_MEMBERSHIP: 125 case IPV6_DROP_MEMBERSHIP:
125 case IPV6_JOIN_ANYCAST: 126 case IPV6_JOIN_ANYCAST:
@@ -198,7 +199,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
198 } 199 }
199 200
200 fl6_free_socklist(sk); 201 fl6_free_socklist(sk);
201 ipv6_sock_mc_close(sk); 202 __ipv6_sock_mc_close(sk);
202 203
203 /* 204 /*
204 * Sock is moving from IPv6 to IPv4 (sk_prot), so 205 * Sock is moving from IPv6 to IPv4 (sk_prot), so
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 75c1fc54f188..14a3903f1c82 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -276,16 +276,14 @@ static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net,
276 return idev; 276 return idev;
277} 277}
278 278
279void ipv6_sock_mc_close(struct sock *sk) 279void __ipv6_sock_mc_close(struct sock *sk)
280{ 280{
281 struct ipv6_pinfo *np = inet6_sk(sk); 281 struct ipv6_pinfo *np = inet6_sk(sk);
282 struct ipv6_mc_socklist *mc_lst; 282 struct ipv6_mc_socklist *mc_lst;
283 struct net *net = sock_net(sk); 283 struct net *net = sock_net(sk);
284 284
285 if (!rcu_access_pointer(np->ipv6_mc_list)) 285 ASSERT_RTNL();
286 return;
287 286
288 rtnl_lock();
289 while ((mc_lst = rtnl_dereference(np->ipv6_mc_list)) != NULL) { 287 while ((mc_lst = rtnl_dereference(np->ipv6_mc_list)) != NULL) {
290 struct net_device *dev; 288 struct net_device *dev;
291 289
@@ -303,8 +301,17 @@ void ipv6_sock_mc_close(struct sock *sk)
303 301
304 atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc); 302 atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc);
305 kfree_rcu(mc_lst, rcu); 303 kfree_rcu(mc_lst, rcu);
306
307 } 304 }
305}
306
307void ipv6_sock_mc_close(struct sock *sk)
308{
309 struct ipv6_pinfo *np = inet6_sk(sk);
310
311 if (!rcu_access_pointer(np->ipv6_mc_list))
312 return;
313 rtnl_lock();
314 __ipv6_sock_mc_close(sk);
308 rtnl_unlock(); 315 rtnl_unlock();
309} 316}
310 317
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
index 0e983b694ee8..66e2d9dfc43a 100644
--- a/net/ipv6/ping.c
+++ b/net/ipv6/ping.c
@@ -180,7 +180,7 @@ struct proto pingv6_prot = {
180 .init = ping_init_sock, 180 .init = ping_init_sock,
181 .close = ping_close, 181 .close = ping_close,
182 .connect = ip6_datagram_connect_v6_only, 182 .connect = ip6_datagram_connect_v6_only,
183 .disconnect = udp_disconnect, 183 .disconnect = __udp_disconnect,
184 .setsockopt = ipv6_setsockopt, 184 .setsockopt = ipv6_setsockopt,
185 .getsockopt = ipv6_getsockopt, 185 .getsockopt = ipv6_getsockopt,
186 .sendmsg = ping_v6_sendmsg, 186 .sendmsg = ping_v6_sendmsg,
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 54404f08efcc..054a1d84fc5e 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1241,7 +1241,7 @@ struct proto rawv6_prot = {
1241 .close = rawv6_close, 1241 .close = rawv6_close,
1242 .destroy = raw6_destroy, 1242 .destroy = raw6_destroy,
1243 .connect = ip6_datagram_connect_v6_only, 1243 .connect = ip6_datagram_connect_v6_only,
1244 .disconnect = udp_disconnect, 1244 .disconnect = __udp_disconnect,
1245 .ioctl = rawv6_ioctl, 1245 .ioctl = rawv6_ioctl,
1246 .init = rawv6_init_sk, 1246 .init = rawv6_init_sk,
1247 .setsockopt = rawv6_setsockopt, 1247 .setsockopt = rawv6_setsockopt,
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 2160d5d009cb..3815e8505ed2 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -456,7 +456,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
456 skb_network_header(head)[nhoff] = skb_transport_header(head)[0]; 456 skb_network_header(head)[nhoff] = skb_transport_header(head)[0];
457 memmove(head->head + sizeof(struct frag_hdr), head->head, 457 memmove(head->head + sizeof(struct frag_hdr), head->head,
458 (head->data - head->head) - sizeof(struct frag_hdr)); 458 (head->data - head->head) - sizeof(struct frag_hdr));
459 head->mac_header += sizeof(struct frag_hdr); 459 if (skb_mac_header_was_set(head))
460 head->mac_header += sizeof(struct frag_hdr);
460 head->network_header += sizeof(struct frag_hdr); 461 head->network_header += sizeof(struct frag_hdr);
461 462
462 skb_reset_transport_header(head); 463 skb_reset_transport_header(head);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index bdbc38e8bf29..947ed1ded026 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -102,11 +102,13 @@ static int rt6_score_route(struct rt6_info *rt, int oif, int strict);
102#ifdef CONFIG_IPV6_ROUTE_INFO 102#ifdef CONFIG_IPV6_ROUTE_INFO
103static struct rt6_info *rt6_add_route_info(struct net *net, 103static struct rt6_info *rt6_add_route_info(struct net *net,
104 const struct in6_addr *prefix, int prefixlen, 104 const struct in6_addr *prefix, int prefixlen,
105 const struct in6_addr *gwaddr, int ifindex, 105 const struct in6_addr *gwaddr,
106 struct net_device *dev,
106 unsigned int pref); 107 unsigned int pref);
107static struct rt6_info *rt6_get_route_info(struct net *net, 108static struct rt6_info *rt6_get_route_info(struct net *net,
108 const struct in6_addr *prefix, int prefixlen, 109 const struct in6_addr *prefix, int prefixlen,
109 const struct in6_addr *gwaddr, int ifindex); 110 const struct in6_addr *gwaddr,
111 struct net_device *dev);
110#endif 112#endif
111 113
112struct uncached_list { 114struct uncached_list {
@@ -656,7 +658,8 @@ static struct rt6_info *find_match(struct rt6_info *rt, int oif, int strict,
656 struct net_device *dev = rt->dst.dev; 658 struct net_device *dev = rt->dst.dev;
657 659
658 if (dev && !netif_carrier_ok(dev) && 660 if (dev && !netif_carrier_ok(dev) &&
659 idev->cnf.ignore_routes_with_linkdown) 661 idev->cnf.ignore_routes_with_linkdown &&
662 !(strict & RT6_LOOKUP_F_IGNORE_LINKSTATE))
660 goto out; 663 goto out;
661 664
662 if (rt6_check_expired(rt)) 665 if (rt6_check_expired(rt))
@@ -803,7 +806,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
803 rt = rt6_get_dflt_router(gwaddr, dev); 806 rt = rt6_get_dflt_router(gwaddr, dev);
804 else 807 else
805 rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, 808 rt = rt6_get_route_info(net, prefix, rinfo->prefix_len,
806 gwaddr, dev->ifindex); 809 gwaddr, dev);
807 810
808 if (rt && !lifetime) { 811 if (rt && !lifetime) {
809 ip6_del_rt(rt); 812 ip6_del_rt(rt);
@@ -811,8 +814,8 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
811 } 814 }
812 815
813 if (!rt && lifetime) 816 if (!rt && lifetime)
814 rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex, 817 rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr,
815 pref); 818 dev, pref);
816 else if (rt) 819 else if (rt)
817 rt->rt6i_flags = RTF_ROUTEINFO | 820 rt->rt6i_flags = RTF_ROUTEINFO |
818 (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); 821 (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
@@ -1050,6 +1053,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
1050 int strict = 0; 1053 int strict = 0;
1051 1054
1052 strict |= flags & RT6_LOOKUP_F_IFACE; 1055 strict |= flags & RT6_LOOKUP_F_IFACE;
1056 strict |= flags & RT6_LOOKUP_F_IGNORE_LINKSTATE;
1053 if (net->ipv6.devconf_all->forwarding == 0) 1057 if (net->ipv6.devconf_all->forwarding == 0)
1054 strict |= RT6_LOOKUP_F_REACHABLE; 1058 strict |= RT6_LOOKUP_F_REACHABLE;
1055 1059
@@ -1789,7 +1793,7 @@ static struct rt6_info *ip6_nh_lookup_table(struct net *net,
1789 }; 1793 };
1790 struct fib6_table *table; 1794 struct fib6_table *table;
1791 struct rt6_info *rt; 1795 struct rt6_info *rt;
1792 int flags = RT6_LOOKUP_F_IFACE; 1796 int flags = RT6_LOOKUP_F_IFACE | RT6_LOOKUP_F_IGNORE_LINKSTATE;
1793 1797
1794 table = fib6_get_table(net, cfg->fc_table); 1798 table = fib6_get_table(net, cfg->fc_table);
1795 if (!table) 1799 if (!table)
@@ -2325,13 +2329,16 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort)
2325#ifdef CONFIG_IPV6_ROUTE_INFO 2329#ifdef CONFIG_IPV6_ROUTE_INFO
2326static struct rt6_info *rt6_get_route_info(struct net *net, 2330static struct rt6_info *rt6_get_route_info(struct net *net,
2327 const struct in6_addr *prefix, int prefixlen, 2331 const struct in6_addr *prefix, int prefixlen,
2328 const struct in6_addr *gwaddr, int ifindex) 2332 const struct in6_addr *gwaddr,
2333 struct net_device *dev)
2329{ 2334{
2335 u32 tb_id = l3mdev_fib_table(dev) ? : RT6_TABLE_INFO;
2336 int ifindex = dev->ifindex;
2330 struct fib6_node *fn; 2337 struct fib6_node *fn;
2331 struct rt6_info *rt = NULL; 2338 struct rt6_info *rt = NULL;
2332 struct fib6_table *table; 2339 struct fib6_table *table;
2333 2340
2334 table = fib6_get_table(net, RT6_TABLE_INFO); 2341 table = fib6_get_table(net, tb_id);
2335 if (!table) 2342 if (!table)
2336 return NULL; 2343 return NULL;
2337 2344
@@ -2357,12 +2364,13 @@ out:
2357 2364
2358static struct rt6_info *rt6_add_route_info(struct net *net, 2365static struct rt6_info *rt6_add_route_info(struct net *net,
2359 const struct in6_addr *prefix, int prefixlen, 2366 const struct in6_addr *prefix, int prefixlen,
2360 const struct in6_addr *gwaddr, int ifindex, 2367 const struct in6_addr *gwaddr,
2368 struct net_device *dev,
2361 unsigned int pref) 2369 unsigned int pref)
2362{ 2370{
2363 struct fib6_config cfg = { 2371 struct fib6_config cfg = {
2364 .fc_metric = IP6_RT_PRIO_USER, 2372 .fc_metric = IP6_RT_PRIO_USER,
2365 .fc_ifindex = ifindex, 2373 .fc_ifindex = dev->ifindex,
2366 .fc_dst_len = prefixlen, 2374 .fc_dst_len = prefixlen,
2367 .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO | 2375 .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO |
2368 RTF_UP | RTF_PREF(pref), 2376 RTF_UP | RTF_PREF(pref),
@@ -2371,7 +2379,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net,
2371 .fc_nlinfo.nl_net = net, 2379 .fc_nlinfo.nl_net = net,
2372 }; 2380 };
2373 2381
2374 cfg.fc_table = l3mdev_fib_table_by_index(net, ifindex) ? : RT6_TABLE_INFO; 2382 cfg.fc_table = l3mdev_fib_table(dev) ? : RT6_TABLE_INFO,
2375 cfg.fc_dst = *prefix; 2383 cfg.fc_dst = *prefix;
2376 cfg.fc_gateway = *gwaddr; 2384 cfg.fc_gateway = *gwaddr;
2377 2385
@@ -2381,16 +2389,17 @@ static struct rt6_info *rt6_add_route_info(struct net *net,
2381 2389
2382 ip6_route_add(&cfg); 2390 ip6_route_add(&cfg);
2383 2391
2384 return rt6_get_route_info(net, prefix, prefixlen, gwaddr, ifindex); 2392 return rt6_get_route_info(net, prefix, prefixlen, gwaddr, dev);
2385} 2393}
2386#endif 2394#endif
2387 2395
2388struct rt6_info *rt6_get_dflt_router(const struct in6_addr *addr, struct net_device *dev) 2396struct rt6_info *rt6_get_dflt_router(const struct in6_addr *addr, struct net_device *dev)
2389{ 2397{
2398 u32 tb_id = l3mdev_fib_table(dev) ? : RT6_TABLE_DFLT;
2390 struct rt6_info *rt; 2399 struct rt6_info *rt;
2391 struct fib6_table *table; 2400 struct fib6_table *table;
2392 2401
2393 table = fib6_get_table(dev_net(dev), RT6_TABLE_DFLT); 2402 table = fib6_get_table(dev_net(dev), tb_id);
2394 if (!table) 2403 if (!table)
2395 return NULL; 2404 return NULL;
2396 2405
@@ -2424,20 +2433,20 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,
2424 2433
2425 cfg.fc_gateway = *gwaddr; 2434 cfg.fc_gateway = *gwaddr;
2426 2435
2427 ip6_route_add(&cfg); 2436 if (!ip6_route_add(&cfg)) {
2437 struct fib6_table *table;
2438
2439 table = fib6_get_table(dev_net(dev), cfg.fc_table);
2440 if (table)
2441 table->flags |= RT6_TABLE_HAS_DFLT_ROUTER;
2442 }
2428 2443
2429 return rt6_get_dflt_router(gwaddr, dev); 2444 return rt6_get_dflt_router(gwaddr, dev);
2430} 2445}
2431 2446
2432void rt6_purge_dflt_routers(struct net *net) 2447static void __rt6_purge_dflt_routers(struct fib6_table *table)
2433{ 2448{
2434 struct rt6_info *rt; 2449 struct rt6_info *rt;
2435 struct fib6_table *table;
2436
2437 /* NOTE: Keep consistent with rt6_get_dflt_router */
2438 table = fib6_get_table(net, RT6_TABLE_DFLT);
2439 if (!table)
2440 return;
2441 2450
2442restart: 2451restart:
2443 read_lock_bh(&table->tb6_lock); 2452 read_lock_bh(&table->tb6_lock);
@@ -2451,6 +2460,27 @@ restart:
2451 } 2460 }
2452 } 2461 }
2453 read_unlock_bh(&table->tb6_lock); 2462 read_unlock_bh(&table->tb6_lock);
2463
2464 table->flags &= ~RT6_TABLE_HAS_DFLT_ROUTER;
2465}
2466
2467void rt6_purge_dflt_routers(struct net *net)
2468{
2469 struct fib6_table *table;
2470 struct hlist_head *head;
2471 unsigned int h;
2472
2473 rcu_read_lock();
2474
2475 for (h = 0; h < FIB6_TABLE_HASHSZ; h++) {
2476 head = &net->ipv6.fib_table_hash[h];
2477 hlist_for_each_entry_rcu(table, head, tb6_hlist) {
2478 if (table->flags & RT6_TABLE_HAS_DFLT_ROUTER)
2479 __rt6_purge_dflt_routers(table);
2480 }
2481 }
2482
2483 rcu_read_unlock();
2454} 2484}
2455 2485
2456static void rtmsg_to_fib6_config(struct net *net, 2486static void rtmsg_to_fib6_config(struct net *net,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 9aa7c1c7a9ce..b2ef061e6836 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -427,7 +427,8 @@ try_again:
427 427
428 if (is_udp4) { 428 if (is_udp4) {
429 if (inet->cmsg_flags) 429 if (inet->cmsg_flags)
430 ip_cmsg_recv(msg, skb); 430 ip_cmsg_recv_offset(msg, skb,
431 sizeof(struct udphdr), off);
431 } else { 432 } else {
432 if (np->rxopt.all) 433 if (np->rxopt.all)
433 ip6_datagram_recv_specific_ctl(sk, msg, skb); 434 ip6_datagram_recv_specific_ctl(sk, msg, skb);
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 42de4ccd159f..fce25afb652a 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -338,7 +338,7 @@ static int l2tp_ip_disconnect(struct sock *sk, int flags)
338 if (sock_flag(sk, SOCK_ZAPPED)) 338 if (sock_flag(sk, SOCK_ZAPPED))
339 return 0; 339 return 0;
340 340
341 return udp_disconnect(sk, flags); 341 return __udp_disconnect(sk, flags);
342} 342}
343 343
344static int l2tp_ip_getname(struct socket *sock, struct sockaddr *uaddr, 344static int l2tp_ip_getname(struct socket *sock, struct sockaddr *uaddr,
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index ea2ae6664cc8..ad3468c32b53 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -410,7 +410,7 @@ static int l2tp_ip6_disconnect(struct sock *sk, int flags)
410 if (sock_flag(sk, SOCK_ZAPPED)) 410 if (sock_flag(sk, SOCK_ZAPPED))
411 return 0; 411 return 0;
412 412
413 return udp_disconnect(sk, flags); 413 return __udp_disconnect(sk, flags);
414} 414}
415 415
416static int l2tp_ip6_getname(struct socket *sock, struct sockaddr *uaddr, 416static int l2tp_ip6_getname(struct socket *sock, struct sockaddr *uaddr,
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index 7663c28ba353..a4e0d59a40dd 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -18,21 +18,24 @@
18#include "key.h" 18#include "key.h"
19#include "aes_ccm.h" 19#include "aes_ccm.h"
20 20
21void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 21int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
22 u8 *data, size_t data_len, u8 *mic, 22 u8 *data, size_t data_len, u8 *mic,
23 size_t mic_len) 23 size_t mic_len)
24{ 24{
25 struct scatterlist sg[3]; 25 struct scatterlist sg[3];
26 struct aead_request *aead_req;
27 int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
28 u8 *__aad;
26 29
27 char aead_req_data[sizeof(struct aead_request) + 30 aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
28 crypto_aead_reqsize(tfm)] 31 if (!aead_req)
29 __aligned(__alignof__(struct aead_request)); 32 return -ENOMEM;
30 struct aead_request *aead_req = (void *) aead_req_data;
31 33
32 memset(aead_req, 0, sizeof(aead_req_data)); 34 __aad = (u8 *)aead_req + reqsize;
35 memcpy(__aad, aad, CCM_AAD_LEN);
33 36
34 sg_init_table(sg, 3); 37 sg_init_table(sg, 3);
35 sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); 38 sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
36 sg_set_buf(&sg[1], data, data_len); 39 sg_set_buf(&sg[1], data, data_len);
37 sg_set_buf(&sg[2], mic, mic_len); 40 sg_set_buf(&sg[2], mic, mic_len);
38 41
@@ -41,6 +44,9 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
41 aead_request_set_ad(aead_req, sg[0].length); 44 aead_request_set_ad(aead_req, sg[0].length);
42 45
43 crypto_aead_encrypt(aead_req); 46 crypto_aead_encrypt(aead_req);
47 kzfree(aead_req);
48
49 return 0;
44} 50}
45 51
46int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 52int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
@@ -48,18 +54,23 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
48 size_t mic_len) 54 size_t mic_len)
49{ 55{
50 struct scatterlist sg[3]; 56 struct scatterlist sg[3];
51 char aead_req_data[sizeof(struct aead_request) + 57 struct aead_request *aead_req;
52 crypto_aead_reqsize(tfm)] 58 int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
53 __aligned(__alignof__(struct aead_request)); 59 u8 *__aad;
54 struct aead_request *aead_req = (void *) aead_req_data; 60 int err;
55 61
56 if (data_len == 0) 62 if (data_len == 0)
57 return -EINVAL; 63 return -EINVAL;
58 64
59 memset(aead_req, 0, sizeof(aead_req_data)); 65 aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
66 if (!aead_req)
67 return -ENOMEM;
68
69 __aad = (u8 *)aead_req + reqsize;
70 memcpy(__aad, aad, CCM_AAD_LEN);
60 71
61 sg_init_table(sg, 3); 72 sg_init_table(sg, 3);
62 sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); 73 sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
63 sg_set_buf(&sg[1], data, data_len); 74 sg_set_buf(&sg[1], data, data_len);
64 sg_set_buf(&sg[2], mic, mic_len); 75 sg_set_buf(&sg[2], mic, mic_len);
65 76
@@ -67,7 +78,10 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
67 aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0); 78 aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0);
68 aead_request_set_ad(aead_req, sg[0].length); 79 aead_request_set_ad(aead_req, sg[0].length);
69 80
70 return crypto_aead_decrypt(aead_req); 81 err = crypto_aead_decrypt(aead_req);
82 kzfree(aead_req);
83
84 return err;
71} 85}
72 86
73struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[], 87struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
diff --git a/net/mac80211/aes_ccm.h b/net/mac80211/aes_ccm.h
index 6a73d1e4d186..fcd3254c5cf0 100644
--- a/net/mac80211/aes_ccm.h
+++ b/net/mac80211/aes_ccm.h
@@ -12,12 +12,14 @@
12 12
13#include <linux/crypto.h> 13#include <linux/crypto.h>
14 14
15#define CCM_AAD_LEN 32
16
15struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[], 17struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
16 size_t key_len, 18 size_t key_len,
17 size_t mic_len); 19 size_t mic_len);
18void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 20int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
19 u8 *data, size_t data_len, u8 *mic, 21 u8 *data, size_t data_len, u8 *mic,
20 size_t mic_len); 22 size_t mic_len);
21int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 23int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
22 u8 *data, size_t data_len, u8 *mic, 24 u8 *data, size_t data_len, u8 *mic,
23 size_t mic_len); 25 size_t mic_len);
diff --git a/net/mac80211/aes_gcm.c b/net/mac80211/aes_gcm.c
index 3afe361fd27c..8a4397cc1b08 100644
--- a/net/mac80211/aes_gcm.c
+++ b/net/mac80211/aes_gcm.c
@@ -15,20 +15,23 @@
15#include "key.h" 15#include "key.h"
16#include "aes_gcm.h" 16#include "aes_gcm.h"
17 17
18void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, 18int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
19 u8 *data, size_t data_len, u8 *mic) 19 u8 *data, size_t data_len, u8 *mic)
20{ 20{
21 struct scatterlist sg[3]; 21 struct scatterlist sg[3];
22 struct aead_request *aead_req;
23 int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
24 u8 *__aad;
22 25
23 char aead_req_data[sizeof(struct aead_request) + 26 aead_req = kzalloc(reqsize + GCM_AAD_LEN, GFP_ATOMIC);
24 crypto_aead_reqsize(tfm)] 27 if (!aead_req)
25 __aligned(__alignof__(struct aead_request)); 28 return -ENOMEM;
26 struct aead_request *aead_req = (void *)aead_req_data;
27 29
28 memset(aead_req, 0, sizeof(aead_req_data)); 30 __aad = (u8 *)aead_req + reqsize;
31 memcpy(__aad, aad, GCM_AAD_LEN);
29 32
30 sg_init_table(sg, 3); 33 sg_init_table(sg, 3);
31 sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); 34 sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
32 sg_set_buf(&sg[1], data, data_len); 35 sg_set_buf(&sg[1], data, data_len);
33 sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); 36 sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN);
34 37
@@ -37,24 +40,31 @@ void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
37 aead_request_set_ad(aead_req, sg[0].length); 40 aead_request_set_ad(aead_req, sg[0].length);
38 41
39 crypto_aead_encrypt(aead_req); 42 crypto_aead_encrypt(aead_req);
43 kzfree(aead_req);
44 return 0;
40} 45}
41 46
42int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, 47int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
43 u8 *data, size_t data_len, u8 *mic) 48 u8 *data, size_t data_len, u8 *mic)
44{ 49{
45 struct scatterlist sg[3]; 50 struct scatterlist sg[3];
46 char aead_req_data[sizeof(struct aead_request) + 51 struct aead_request *aead_req;
47 crypto_aead_reqsize(tfm)] 52 int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
48 __aligned(__alignof__(struct aead_request)); 53 u8 *__aad;
49 struct aead_request *aead_req = (void *)aead_req_data; 54 int err;
50 55
51 if (data_len == 0) 56 if (data_len == 0)
52 return -EINVAL; 57 return -EINVAL;
53 58
54 memset(aead_req, 0, sizeof(aead_req_data)); 59 aead_req = kzalloc(reqsize + GCM_AAD_LEN, GFP_ATOMIC);
60 if (!aead_req)
61 return -ENOMEM;
62
63 __aad = (u8 *)aead_req + reqsize;
64 memcpy(__aad, aad, GCM_AAD_LEN);
55 65
56 sg_init_table(sg, 3); 66 sg_init_table(sg, 3);
57 sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); 67 sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
58 sg_set_buf(&sg[1], data, data_len); 68 sg_set_buf(&sg[1], data, data_len);
59 sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); 69 sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN);
60 70
@@ -63,7 +73,10 @@ int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
63 data_len + IEEE80211_GCMP_MIC_LEN, j_0); 73 data_len + IEEE80211_GCMP_MIC_LEN, j_0);
64 aead_request_set_ad(aead_req, sg[0].length); 74 aead_request_set_ad(aead_req, sg[0].length);
65 75
66 return crypto_aead_decrypt(aead_req); 76 err = crypto_aead_decrypt(aead_req);
77 kzfree(aead_req);
78
79 return err;
67} 80}
68 81
69struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], 82struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
diff --git a/net/mac80211/aes_gcm.h b/net/mac80211/aes_gcm.h
index 1347fda6b76a..55aed5352494 100644
--- a/net/mac80211/aes_gcm.h
+++ b/net/mac80211/aes_gcm.h
@@ -11,8 +11,10 @@
11 11
12#include <linux/crypto.h> 12#include <linux/crypto.h>
13 13
14void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, 14#define GCM_AAD_LEN 32
15 u8 *data, size_t data_len, u8 *mic); 15
16int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
17 u8 *data, size_t data_len, u8 *mic);
16int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, 18int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
17 u8 *data, size_t data_len, u8 *mic); 19 u8 *data, size_t data_len, u8 *mic);
18struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], 20struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
diff --git a/net/mac80211/aes_gmac.c b/net/mac80211/aes_gmac.c
index 3ddd927aaf30..bd72a862ddb7 100644
--- a/net/mac80211/aes_gmac.c
+++ b/net/mac80211/aes_gmac.c
@@ -17,28 +17,27 @@
17#include "key.h" 17#include "key.h"
18#include "aes_gmac.h" 18#include "aes_gmac.h"
19 19
20#define GMAC_MIC_LEN 16
21#define GMAC_NONCE_LEN 12
22#define AAD_LEN 20
23
24int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, 20int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce,
25 const u8 *data, size_t data_len, u8 *mic) 21 const u8 *data, size_t data_len, u8 *mic)
26{ 22{
27 struct scatterlist sg[4]; 23 struct scatterlist sg[4];
28 char aead_req_data[sizeof(struct aead_request) + 24 u8 *zero, *__aad, iv[AES_BLOCK_SIZE];
29 crypto_aead_reqsize(tfm)] 25 struct aead_request *aead_req;
30 __aligned(__alignof__(struct aead_request)); 26 int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
31 struct aead_request *aead_req = (void *)aead_req_data;
32 u8 zero[GMAC_MIC_LEN], iv[AES_BLOCK_SIZE];
33 27
34 if (data_len < GMAC_MIC_LEN) 28 if (data_len < GMAC_MIC_LEN)
35 return -EINVAL; 29 return -EINVAL;
36 30
37 memset(aead_req, 0, sizeof(aead_req_data)); 31 aead_req = kzalloc(reqsize + GMAC_MIC_LEN + GMAC_AAD_LEN, GFP_ATOMIC);
32 if (!aead_req)
33 return -ENOMEM;
34
35 zero = (u8 *)aead_req + reqsize;
36 __aad = zero + GMAC_MIC_LEN;
37 memcpy(__aad, aad, GMAC_AAD_LEN);
38 38
39 memset(zero, 0, GMAC_MIC_LEN);
40 sg_init_table(sg, 4); 39 sg_init_table(sg, 4);
41 sg_set_buf(&sg[0], aad, AAD_LEN); 40 sg_set_buf(&sg[0], __aad, GMAC_AAD_LEN);
42 sg_set_buf(&sg[1], data, data_len - GMAC_MIC_LEN); 41 sg_set_buf(&sg[1], data, data_len - GMAC_MIC_LEN);
43 sg_set_buf(&sg[2], zero, GMAC_MIC_LEN); 42 sg_set_buf(&sg[2], zero, GMAC_MIC_LEN);
44 sg_set_buf(&sg[3], mic, GMAC_MIC_LEN); 43 sg_set_buf(&sg[3], mic, GMAC_MIC_LEN);
@@ -49,9 +48,10 @@ int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce,
49 48
50 aead_request_set_tfm(aead_req, tfm); 49 aead_request_set_tfm(aead_req, tfm);
51 aead_request_set_crypt(aead_req, sg, sg, 0, iv); 50 aead_request_set_crypt(aead_req, sg, sg, 0, iv);
52 aead_request_set_ad(aead_req, AAD_LEN + data_len); 51 aead_request_set_ad(aead_req, GMAC_AAD_LEN + data_len);
53 52
54 crypto_aead_encrypt(aead_req); 53 crypto_aead_encrypt(aead_req);
54 kzfree(aead_req);
55 55
56 return 0; 56 return 0;
57} 57}
diff --git a/net/mac80211/aes_gmac.h b/net/mac80211/aes_gmac.h
index d328204d73a8..32e6442c95be 100644
--- a/net/mac80211/aes_gmac.h
+++ b/net/mac80211/aes_gmac.h
@@ -11,6 +11,10 @@
11 11
12#include <linux/crypto.h> 12#include <linux/crypto.h>
13 13
14#define GMAC_AAD_LEN 20
15#define GMAC_MIC_LEN 16
16#define GMAC_NONCE_LEN 12
17
14struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[], 18struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
15 size_t key_len); 19 size_t key_len);
16int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, 20int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce,
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index c3f610bba3fe..eede5c6db8d5 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -820,7 +820,7 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
820 mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) 820 mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT)
821 break; 821 break;
822 rcu_read_lock(); 822 rcu_read_lock();
823 sta = sta_info_get(sdata, mgmt->da); 823 sta = sta_info_get_bss(sdata, mgmt->da);
824 rcu_read_unlock(); 824 rcu_read_unlock();
825 if (!sta) 825 if (!sta)
826 return -ENOLINK; 826 return -ENOLINK;
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 6175db385ba7..a47bbc973f2d 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2298,6 +2298,8 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
2298 __le16 fc = hdr->frame_control; 2298 __le16 fc = hdr->frame_control;
2299 struct sk_buff_head frame_list; 2299 struct sk_buff_head frame_list;
2300 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); 2300 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
2301 struct ethhdr ethhdr;
2302 const u8 *check_da = ethhdr.h_dest, *check_sa = ethhdr.h_source;
2301 2303
2302 if (unlikely(!ieee80211_is_data(fc))) 2304 if (unlikely(!ieee80211_is_data(fc)))
2303 return RX_CONTINUE; 2305 return RX_CONTINUE;
@@ -2308,24 +2310,53 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
2308 if (!(status->rx_flags & IEEE80211_RX_AMSDU)) 2310 if (!(status->rx_flags & IEEE80211_RX_AMSDU))
2309 return RX_CONTINUE; 2311 return RX_CONTINUE;
2310 2312
2311 if (ieee80211_has_a4(hdr->frame_control) && 2313 if (unlikely(ieee80211_has_a4(hdr->frame_control))) {
2312 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && 2314 switch (rx->sdata->vif.type) {
2313 !rx->sdata->u.vlan.sta) 2315 case NL80211_IFTYPE_AP_VLAN:
2314 return RX_DROP_UNUSABLE; 2316 if (!rx->sdata->u.vlan.sta)
2317 return RX_DROP_UNUSABLE;
2318 break;
2319 case NL80211_IFTYPE_STATION:
2320 if (!rx->sdata->u.mgd.use_4addr)
2321 return RX_DROP_UNUSABLE;
2322 break;
2323 default:
2324 return RX_DROP_UNUSABLE;
2325 }
2326 check_da = NULL;
2327 check_sa = NULL;
2328 } else switch (rx->sdata->vif.type) {
2329 case NL80211_IFTYPE_AP:
2330 case NL80211_IFTYPE_AP_VLAN:
2331 check_da = NULL;
2332 break;
2333 case NL80211_IFTYPE_STATION:
2334 if (!rx->sta ||
2335 !test_sta_flag(rx->sta, WLAN_STA_TDLS_PEER))
2336 check_sa = NULL;
2337 break;
2338 case NL80211_IFTYPE_MESH_POINT:
2339 check_sa = NULL;
2340 break;
2341 default:
2342 break;
2343 }
2315 2344
2316 if (is_multicast_ether_addr(hdr->addr1) && 2345 if (is_multicast_ether_addr(hdr->addr1))
2317 ((rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2318 rx->sdata->u.vlan.sta) ||
2319 (rx->sdata->vif.type == NL80211_IFTYPE_STATION &&
2320 rx->sdata->u.mgd.use_4addr)))
2321 return RX_DROP_UNUSABLE; 2346 return RX_DROP_UNUSABLE;
2322 2347
2323 skb->dev = dev; 2348 skb->dev = dev;
2324 __skb_queue_head_init(&frame_list); 2349 __skb_queue_head_init(&frame_list);
2325 2350
2351 if (ieee80211_data_to_8023_exthdr(skb, &ethhdr,
2352 rx->sdata->vif.addr,
2353 rx->sdata->vif.type))
2354 return RX_DROP_UNUSABLE;
2355
2326 ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, 2356 ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr,
2327 rx->sdata->vif.type, 2357 rx->sdata->vif.type,
2328 rx->local->hw.extra_tx_headroom, true); 2358 rx->local->hw.extra_tx_headroom,
2359 check_da, check_sa);
2329 2360
2330 while (!skb_queue_empty(&frame_list)) { 2361 while (!skb_queue_empty(&frame_list)) {
2331 rx->skb = __skb_dequeue(&frame_list); 2362 rx->skb = __skb_dequeue(&frame_list);
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index b48c1e13e281..42ce9bd4426f 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -405,7 +405,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb,
405 u8 *pos; 405 u8 *pos;
406 u8 pn[6]; 406 u8 pn[6];
407 u64 pn64; 407 u64 pn64;
408 u8 aad[2 * AES_BLOCK_SIZE]; 408 u8 aad[CCM_AAD_LEN];
409 u8 b_0[AES_BLOCK_SIZE]; 409 u8 b_0[AES_BLOCK_SIZE];
410 410
411 if (info->control.hw_key && 411 if (info->control.hw_key &&
@@ -461,10 +461,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb,
461 461
462 pos += IEEE80211_CCMP_HDR_LEN; 462 pos += IEEE80211_CCMP_HDR_LEN;
463 ccmp_special_blocks(skb, pn, b_0, aad); 463 ccmp_special_blocks(skb, pn, b_0, aad);
464 ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len, 464 return ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
465 skb_put(skb, mic_len), mic_len); 465 skb_put(skb, mic_len), mic_len);
466
467 return 0;
468} 466}
469 467
470 468
@@ -639,7 +637,7 @@ static int gcmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
639 u8 *pos; 637 u8 *pos;
640 u8 pn[6]; 638 u8 pn[6];
641 u64 pn64; 639 u64 pn64;
642 u8 aad[2 * AES_BLOCK_SIZE]; 640 u8 aad[GCM_AAD_LEN];
643 u8 j_0[AES_BLOCK_SIZE]; 641 u8 j_0[AES_BLOCK_SIZE];
644 642
645 if (info->control.hw_key && 643 if (info->control.hw_key &&
@@ -696,10 +694,8 @@ static int gcmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
696 694
697 pos += IEEE80211_GCMP_HDR_LEN; 695 pos += IEEE80211_GCMP_HDR_LEN;
698 gcmp_special_blocks(skb, pn, j_0, aad); 696 gcmp_special_blocks(skb, pn, j_0, aad);
699 ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len, 697 return ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
700 skb_put(skb, IEEE80211_GCMP_MIC_LEN)); 698 skb_put(skb, IEEE80211_GCMP_MIC_LEN));
701
702 return 0;
703} 699}
704 700
705ieee80211_tx_result 701ieee80211_tx_result
@@ -1123,9 +1119,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct ieee80211_tx_data *tx)
1123 struct ieee80211_key *key = tx->key; 1119 struct ieee80211_key *key = tx->key;
1124 struct ieee80211_mmie_16 *mmie; 1120 struct ieee80211_mmie_16 *mmie;
1125 struct ieee80211_hdr *hdr; 1121 struct ieee80211_hdr *hdr;
1126 u8 aad[20]; 1122 u8 aad[GMAC_AAD_LEN];
1127 u64 pn64; 1123 u64 pn64;
1128 u8 nonce[12]; 1124 u8 nonce[GMAC_NONCE_LEN];
1129 1125
1130 if (WARN_ON(skb_queue_len(&tx->skbs) != 1)) 1126 if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
1131 return TX_DROP; 1127 return TX_DROP;
@@ -1171,7 +1167,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
1171 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 1167 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1172 struct ieee80211_key *key = rx->key; 1168 struct ieee80211_key *key = rx->key;
1173 struct ieee80211_mmie_16 *mmie; 1169 struct ieee80211_mmie_16 *mmie;
1174 u8 aad[20], mic[16], ipn[6], nonce[12]; 1170 u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN];
1175 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1171 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1176 1172
1177 if (!ieee80211_is_mgmt(hdr->frame_control)) 1173 if (!ieee80211_is_mgmt(hdr->frame_control))
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index 13290a70fa71..1308a56f2591 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -246,6 +246,7 @@ enum {
246 ncsi_dev_state_config_gls, 246 ncsi_dev_state_config_gls,
247 ncsi_dev_state_config_done, 247 ncsi_dev_state_config_done,
248 ncsi_dev_state_suspend_select = 0x0401, 248 ncsi_dev_state_suspend_select = 0x0401,
249 ncsi_dev_state_suspend_gls,
249 ncsi_dev_state_suspend_dcnt, 250 ncsi_dev_state_suspend_dcnt,
250 ncsi_dev_state_suspend_dc, 251 ncsi_dev_state_suspend_dc,
251 ncsi_dev_state_suspend_deselect, 252 ncsi_dev_state_suspend_deselect,
@@ -264,6 +265,7 @@ struct ncsi_dev_priv {
264#endif 265#endif
265 unsigned int package_num; /* Number of packages */ 266 unsigned int package_num; /* Number of packages */
266 struct list_head packages; /* List of packages */ 267 struct list_head packages; /* List of packages */
268 struct ncsi_channel *hot_channel; /* Channel was ever active */
267 struct ncsi_request requests[256]; /* Request table */ 269 struct ncsi_request requests[256]; /* Request table */
268 unsigned int request_id; /* Last used request ID */ 270 unsigned int request_id; /* Last used request ID */
269#define NCSI_REQ_START_IDX 1 271#define NCSI_REQ_START_IDX 1
diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index b41a6617d498..6898e7229285 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -141,23 +141,35 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,
141 return -ENODEV; 141 return -ENODEV;
142 142
143 /* If the channel is active one, we need reconfigure it */ 143 /* If the channel is active one, we need reconfigure it */
144 spin_lock_irqsave(&nc->lock, flags);
144 ncm = &nc->modes[NCSI_MODE_LINK]; 145 ncm = &nc->modes[NCSI_MODE_LINK];
145 hncdsc = (struct ncsi_aen_hncdsc_pkt *)h; 146 hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
146 ncm->data[3] = ntohl(hncdsc->status); 147 ncm->data[3] = ntohl(hncdsc->status);
147 if (!list_empty(&nc->link) || 148 if (!list_empty(&nc->link) ||
148 nc->state != NCSI_CHANNEL_ACTIVE || 149 nc->state != NCSI_CHANNEL_ACTIVE) {
149 (ncm->data[3] & 0x1)) 150 spin_unlock_irqrestore(&nc->lock, flags);
150 return 0; 151 return 0;
152 }
151 153
152 if (ndp->flags & NCSI_DEV_HWA) 154 spin_unlock_irqrestore(&nc->lock, flags);
155 if (!(ndp->flags & NCSI_DEV_HWA) && !(ncm->data[3] & 0x1))
153 ndp->flags |= NCSI_DEV_RESHUFFLE; 156 ndp->flags |= NCSI_DEV_RESHUFFLE;
154 157
155 /* If this channel is the active one and the link doesn't 158 /* If this channel is the active one and the link doesn't
156 * work, we have to choose another channel to be active one. 159 * work, we have to choose another channel to be active one.
157 * The logic here is exactly similar to what we do when link 160 * The logic here is exactly similar to what we do when link
158 * is down on the active channel. 161 * is down on the active channel.
162 *
163 * On the other hand, we need configure it when host driver
164 * state on the active channel becomes ready.
159 */ 165 */
160 ncsi_stop_channel_monitor(nc); 166 ncsi_stop_channel_monitor(nc);
167
168 spin_lock_irqsave(&nc->lock, flags);
169 nc->state = (ncm->data[3] & 0x1) ? NCSI_CHANNEL_INACTIVE :
170 NCSI_CHANNEL_ACTIVE;
171 spin_unlock_irqrestore(&nc->lock, flags);
172
161 spin_lock_irqsave(&ndp->lock, flags); 173 spin_lock_irqsave(&ndp->lock, flags);
162 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 174 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
163 spin_unlock_irqrestore(&ndp->lock, flags); 175 spin_unlock_irqrestore(&ndp->lock, flags);
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 5e509e547c2d..a3bd5fa8ad09 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -540,42 +540,86 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)
540 nd->state = ncsi_dev_state_suspend_select; 540 nd->state = ncsi_dev_state_suspend_select;
541 /* Fall through */ 541 /* Fall through */
542 case ncsi_dev_state_suspend_select: 542 case ncsi_dev_state_suspend_select:
543 case ncsi_dev_state_suspend_dcnt:
544 case ncsi_dev_state_suspend_dc:
545 case ncsi_dev_state_suspend_deselect:
546 ndp->pending_req_num = 1; 543 ndp->pending_req_num = 1;
547 544
548 np = ndp->active_package; 545 nca.type = NCSI_PKT_CMD_SP;
549 nc = ndp->active_channel;
550 nca.package = np->id; 546 nca.package = np->id;
551 if (nd->state == ncsi_dev_state_suspend_select) { 547 nca.channel = NCSI_RESERVED_CHANNEL;
552 nca.type = NCSI_PKT_CMD_SP; 548 if (ndp->flags & NCSI_DEV_HWA)
553 nca.channel = NCSI_RESERVED_CHANNEL; 549 nca.bytes[0] = 0;
554 if (ndp->flags & NCSI_DEV_HWA) 550 else
555 nca.bytes[0] = 0; 551 nca.bytes[0] = 1;
556 else 552
557 nca.bytes[0] = 1; 553 /* To retrieve the last link states of channels in current
554 * package when current active channel needs fail over to
555 * another one. It means we will possibly select another
556 * channel as next active one. The link states of channels
557 * are most important factor of the selection. So we need
558 * accurate link states. Unfortunately, the link states on
559 * inactive channels can't be updated with LSC AEN in time.
560 */
561 if (ndp->flags & NCSI_DEV_RESHUFFLE)
562 nd->state = ncsi_dev_state_suspend_gls;
563 else
558 nd->state = ncsi_dev_state_suspend_dcnt; 564 nd->state = ncsi_dev_state_suspend_dcnt;
559 } else if (nd->state == ncsi_dev_state_suspend_dcnt) { 565 ret = ncsi_xmit_cmd(&nca);
560 nca.type = NCSI_PKT_CMD_DCNT; 566 if (ret)
561 nca.channel = nc->id; 567 goto error;
562 nd->state = ncsi_dev_state_suspend_dc; 568
563 } else if (nd->state == ncsi_dev_state_suspend_dc) { 569 break;
564 nca.type = NCSI_PKT_CMD_DC; 570 case ncsi_dev_state_suspend_gls:
571 ndp->pending_req_num = np->channel_num;
572
573 nca.type = NCSI_PKT_CMD_GLS;
574 nca.package = np->id;
575
576 nd->state = ncsi_dev_state_suspend_dcnt;
577 NCSI_FOR_EACH_CHANNEL(np, nc) {
565 nca.channel = nc->id; 578 nca.channel = nc->id;
566 nca.bytes[0] = 1; 579 ret = ncsi_xmit_cmd(&nca);
567 nd->state = ncsi_dev_state_suspend_deselect; 580 if (ret)
568 } else if (nd->state == ncsi_dev_state_suspend_deselect) { 581 goto error;
569 nca.type = NCSI_PKT_CMD_DP;
570 nca.channel = NCSI_RESERVED_CHANNEL;
571 nd->state = ncsi_dev_state_suspend_done;
572 } 582 }
573 583
584 break;
585 case ncsi_dev_state_suspend_dcnt:
586 ndp->pending_req_num = 1;
587
588 nca.type = NCSI_PKT_CMD_DCNT;
589 nca.package = np->id;
590 nca.channel = nc->id;
591
592 nd->state = ncsi_dev_state_suspend_dc;
574 ret = ncsi_xmit_cmd(&nca); 593 ret = ncsi_xmit_cmd(&nca);
575 if (ret) { 594 if (ret)
576 nd->state = ncsi_dev_state_functional; 595 goto error;
577 return; 596
578 } 597 break;
598 case ncsi_dev_state_suspend_dc:
599 ndp->pending_req_num = 1;
600
601 nca.type = NCSI_PKT_CMD_DC;
602 nca.package = np->id;
603 nca.channel = nc->id;
604 nca.bytes[0] = 1;
605
606 nd->state = ncsi_dev_state_suspend_deselect;
607 ret = ncsi_xmit_cmd(&nca);
608 if (ret)
609 goto error;
610
611 break;
612 case ncsi_dev_state_suspend_deselect:
613 ndp->pending_req_num = 1;
614
615 nca.type = NCSI_PKT_CMD_DP;
616 nca.package = np->id;
617 nca.channel = NCSI_RESERVED_CHANNEL;
618
619 nd->state = ncsi_dev_state_suspend_done;
620 ret = ncsi_xmit_cmd(&nca);
621 if (ret)
622 goto error;
579 623
580 break; 624 break;
581 case ncsi_dev_state_suspend_done: 625 case ncsi_dev_state_suspend_done:
@@ -589,6 +633,10 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)
589 netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n", 633 netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n",
590 nd->state); 634 nd->state);
591 } 635 }
636
637 return;
638error:
639 nd->state = ncsi_dev_state_functional;
592} 640}
593 641
594static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) 642static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
@@ -597,6 +645,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
597 struct net_device *dev = nd->dev; 645 struct net_device *dev = nd->dev;
598 struct ncsi_package *np = ndp->active_package; 646 struct ncsi_package *np = ndp->active_package;
599 struct ncsi_channel *nc = ndp->active_channel; 647 struct ncsi_channel *nc = ndp->active_channel;
648 struct ncsi_channel *hot_nc = NULL;
600 struct ncsi_cmd_arg nca; 649 struct ncsi_cmd_arg nca;
601 unsigned char index; 650 unsigned char index;
602 unsigned long flags; 651 unsigned long flags;
@@ -702,12 +751,20 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
702 break; 751 break;
703 case ncsi_dev_state_config_done: 752 case ncsi_dev_state_config_done:
704 spin_lock_irqsave(&nc->lock, flags); 753 spin_lock_irqsave(&nc->lock, flags);
705 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) 754 if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) {
755 hot_nc = nc;
706 nc->state = NCSI_CHANNEL_ACTIVE; 756 nc->state = NCSI_CHANNEL_ACTIVE;
707 else 757 } else {
758 hot_nc = NULL;
708 nc->state = NCSI_CHANNEL_INACTIVE; 759 nc->state = NCSI_CHANNEL_INACTIVE;
760 }
709 spin_unlock_irqrestore(&nc->lock, flags); 761 spin_unlock_irqrestore(&nc->lock, flags);
710 762
763 /* Update the hot channel */
764 spin_lock_irqsave(&ndp->lock, flags);
765 ndp->hot_channel = hot_nc;
766 spin_unlock_irqrestore(&ndp->lock, flags);
767
711 ncsi_start_channel_monitor(nc); 768 ncsi_start_channel_monitor(nc);
712 ncsi_process_next_channel(ndp); 769 ncsi_process_next_channel(ndp);
713 break; 770 break;
@@ -725,10 +782,14 @@ error:
725static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) 782static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
726{ 783{
727 struct ncsi_package *np; 784 struct ncsi_package *np;
728 struct ncsi_channel *nc, *found; 785 struct ncsi_channel *nc, *found, *hot_nc;
729 struct ncsi_channel_mode *ncm; 786 struct ncsi_channel_mode *ncm;
730 unsigned long flags; 787 unsigned long flags;
731 788
789 spin_lock_irqsave(&ndp->lock, flags);
790 hot_nc = ndp->hot_channel;
791 spin_unlock_irqrestore(&ndp->lock, flags);
792
732 /* The search is done once an inactive channel with up 793 /* The search is done once an inactive channel with up
733 * link is found. 794 * link is found.
734 */ 795 */
@@ -746,6 +807,9 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
746 if (!found) 807 if (!found)
747 found = nc; 808 found = nc;
748 809
810 if (nc == hot_nc)
811 found = nc;
812
749 ncm = &nc->modes[NCSI_MODE_LINK]; 813 ncm = &nc->modes[NCSI_MODE_LINK];
750 if (ncm->data[2] & 0x1) { 814 if (ncm->data[2] & 0x1) {
751 spin_unlock_irqrestore(&nc->lock, flags); 815 spin_unlock_irqrestore(&nc->lock, flags);
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index fcb5d1df11e9..004af030ef1a 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -361,16 +361,9 @@ next_hook:
361 if (ret == 0) 361 if (ret == 0)
362 ret = -EPERM; 362 ret = -EPERM;
363 } else if ((verdict & NF_VERDICT_MASK) == NF_QUEUE) { 363 } else if ((verdict & NF_VERDICT_MASK) == NF_QUEUE) {
364 int err; 364 ret = nf_queue(skb, state, &entry, verdict);
365 365 if (ret == 1 && entry)
366 RCU_INIT_POINTER(state->hook_entries, entry); 366 goto next_hook;
367 err = nf_queue(skb, state, verdict >> NF_VERDICT_QBITS);
368 if (err < 0) {
369 if (err == -ESRCH &&
370 (verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
371 goto next_hook;
372 kfree_skb(skb);
373 }
374 } 367 }
375 return ret; 368 return ret;
376} 369}
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index ba6a1d421222..df2f5a3901df 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -983,7 +983,7 @@ static void gc_worker(struct work_struct *work)
983 return; 983 return;
984 984
985 ratio = scanned ? expired_count * 100 / scanned : 0; 985 ratio = scanned ? expired_count * 100 / scanned : 0;
986 if (ratio >= 90) 986 if (ratio >= 90 || expired_count == GC_MAX_EVICTS)
987 next_run = 0; 987 next_run = 0;
988 988
989 gc_work->last_bucket = i; 989 gc_work->last_bucket = i;
diff --git a/net/netfilter/nf_internals.h b/net/netfilter/nf_internals.h
index e0adb5959342..9fdb655f85bc 100644
--- a/net/netfilter/nf_internals.h
+++ b/net/netfilter/nf_internals.h
@@ -18,7 +18,7 @@ unsigned int nf_iterate(struct sk_buff *skb, struct nf_hook_state *state,
18 18
19/* nf_queue.c */ 19/* nf_queue.c */
20int nf_queue(struct sk_buff *skb, struct nf_hook_state *state, 20int nf_queue(struct sk_buff *skb, struct nf_hook_state *state,
21 unsigned int queuenum); 21 struct nf_hook_entry **entryp, unsigned int verdict);
22void nf_queue_nf_hook_drop(struct net *net, const struct nf_hook_entry *entry); 22void nf_queue_nf_hook_drop(struct net *net, const struct nf_hook_entry *entry);
23int __init netfilter_queue_init(void); 23int __init netfilter_queue_init(void);
24 24
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 96964a0070e1..8f08d759844a 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -107,13 +107,8 @@ void nf_queue_nf_hook_drop(struct net *net, const struct nf_hook_entry *entry)
107 rcu_read_unlock(); 107 rcu_read_unlock();
108} 108}
109 109
110/* 110static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
111 * Any packet that leaves via this function must come back 111 unsigned int queuenum)
112 * through nf_reinject().
113 */
114int nf_queue(struct sk_buff *skb,
115 struct nf_hook_state *state,
116 unsigned int queuenum)
117{ 112{
118 int status = -ENOENT; 113 int status = -ENOENT;
119 struct nf_queue_entry *entry = NULL; 114 struct nf_queue_entry *entry = NULL;
@@ -161,6 +156,27 @@ err:
161 return status; 156 return status;
162} 157}
163 158
159/* Packets leaving via this function must come back through nf_reinject(). */
160int nf_queue(struct sk_buff *skb, struct nf_hook_state *state,
161 struct nf_hook_entry **entryp, unsigned int verdict)
162{
163 struct nf_hook_entry *entry = *entryp;
164 int ret;
165
166 RCU_INIT_POINTER(state->hook_entries, entry);
167 ret = __nf_queue(skb, state, verdict >> NF_VERDICT_QBITS);
168 if (ret < 0) {
169 if (ret == -ESRCH &&
170 (verdict & NF_VERDICT_FLAG_QUEUE_BYPASS)) {
171 *entryp = rcu_dereference(entry->next);
172 return 1;
173 }
174 kfree_skb(skb);
175 }
176
177 return 0;
178}
179
164void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) 180void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
165{ 181{
166 struct nf_hook_entry *hook_entry; 182 struct nf_hook_entry *hook_entry;
@@ -187,26 +203,26 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
187 entry->state.thresh = INT_MIN; 203 entry->state.thresh = INT_MIN;
188 204
189 if (verdict == NF_ACCEPT) { 205 if (verdict == NF_ACCEPT) {
190 next_hook: 206 hook_entry = rcu_dereference(hook_entry->next);
191 verdict = nf_iterate(skb, &entry->state, &hook_entry); 207 if (hook_entry)
208next_hook:
209 verdict = nf_iterate(skb, &entry->state, &hook_entry);
192 } 210 }
193 211
194 switch (verdict & NF_VERDICT_MASK) { 212 switch (verdict & NF_VERDICT_MASK) {
195 case NF_ACCEPT: 213 case NF_ACCEPT:
196 case NF_STOP: 214 case NF_STOP:
215okfn:
197 local_bh_disable(); 216 local_bh_disable();
198 entry->state.okfn(entry->state.net, entry->state.sk, skb); 217 entry->state.okfn(entry->state.net, entry->state.sk, skb);
199 local_bh_enable(); 218 local_bh_enable();
200 break; 219 break;
201 case NF_QUEUE: 220 case NF_QUEUE:
202 RCU_INIT_POINTER(entry->state.hook_entries, hook_entry); 221 err = nf_queue(skb, &entry->state, &hook_entry, verdict);
203 err = nf_queue(skb, &entry->state, 222 if (err == 1) {
204 verdict >> NF_VERDICT_QBITS); 223 if (hook_entry)
205 if (err < 0) {
206 if (err == -ESRCH &&
207 (verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
208 goto next_hook; 224 goto next_hook;
209 kfree_skb(skb); 225 goto okfn;
210 } 226 }
211 break; 227 break;
212 case NF_STOLEN: 228 case NF_STOLEN:
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b70d3ea1430e..24db22257586 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4423,7 +4423,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
4423 */ 4423 */
4424unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest) 4424unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
4425{ 4425{
4426 int val; 4426 u32 val;
4427 4427
4428 val = ntohl(nla_get_be32(attr)); 4428 val = ntohl(nla_get_be32(attr));
4429 if (val > max) 4429 if (val > max)
diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
index e3b83c31da2e..517f08767a3c 100644
--- a/net/netfilter/nft_dynset.c
+++ b/net/netfilter/nft_dynset.c
@@ -158,7 +158,8 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
158 if (tb[NFTA_DYNSET_TIMEOUT] != NULL) { 158 if (tb[NFTA_DYNSET_TIMEOUT] != NULL) {
159 if (!(set->flags & NFT_SET_TIMEOUT)) 159 if (!(set->flags & NFT_SET_TIMEOUT))
160 return -EINVAL; 160 return -EINVAL;
161 timeout = be64_to_cpu(nla_get_be64(tb[NFTA_DYNSET_TIMEOUT])); 161 timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
162 tb[NFTA_DYNSET_TIMEOUT])));
162 } 163 }
163 164
164 priv->sreg_key = nft_parse_register(tb[NFTA_DYNSET_SREG_KEY]); 165 priv->sreg_key = nft_parse_register(tb[NFTA_DYNSET_SREG_KEY]);
@@ -246,7 +247,8 @@ static int nft_dynset_dump(struct sk_buff *skb, const struct nft_expr *expr)
246 goto nla_put_failure; 247 goto nla_put_failure;
247 if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name)) 248 if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name))
248 goto nla_put_failure; 249 goto nla_put_failure;
249 if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout), 250 if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT,
251 cpu_to_be64(jiffies_to_msecs(priv->timeout)),
250 NFTA_DYNSET_PAD)) 252 NFTA_DYNSET_PAD))
251 goto nla_put_failure; 253 goto nla_put_failure;
252 if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr)) 254 if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr))
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index a84cf3d66056..47beb3abcc9d 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -59,7 +59,8 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
59 const struct nlattr * const tb[]) 59 const struct nlattr * const tb[])
60{ 60{
61 struct nft_exthdr *priv = nft_expr_priv(expr); 61 struct nft_exthdr *priv = nft_expr_priv(expr);
62 u32 offset, len, err; 62 u32 offset, len;
63 int err;
63 64
64 if (tb[NFTA_EXTHDR_DREG] == NULL || 65 if (tb[NFTA_EXTHDR_DREG] == NULL ||
65 tb[NFTA_EXTHDR_TYPE] == NULL || 66 tb[NFTA_EXTHDR_TYPE] == NULL ||
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 09473b415b95..baf694de3935 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -44,6 +44,7 @@ static const struct nla_policy nft_hash_policy[NFTA_HASH_MAX + 1] = {
44 [NFTA_HASH_LEN] = { .type = NLA_U32 }, 44 [NFTA_HASH_LEN] = { .type = NLA_U32 },
45 [NFTA_HASH_MODULUS] = { .type = NLA_U32 }, 45 [NFTA_HASH_MODULUS] = { .type = NLA_U32 },
46 [NFTA_HASH_SEED] = { .type = NLA_U32 }, 46 [NFTA_HASH_SEED] = { .type = NLA_U32 },
47 [NFTA_HASH_OFFSET] = { .type = NLA_U32 },
47}; 48};
48 49
49static int nft_hash_init(const struct nft_ctx *ctx, 50static int nft_hash_init(const struct nft_ctx *ctx,
diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
index c6d5358482d1..fbc88009ca2e 100644
--- a/net/netfilter/nft_range.c
+++ b/net/netfilter/nft_range.c
@@ -28,22 +28,20 @@ static void nft_range_eval(const struct nft_expr *expr,
28 const struct nft_pktinfo *pkt) 28 const struct nft_pktinfo *pkt)
29{ 29{
30 const struct nft_range_expr *priv = nft_expr_priv(expr); 30 const struct nft_range_expr *priv = nft_expr_priv(expr);
31 bool mismatch;
32 int d1, d2; 31 int d1, d2;
33 32
34 d1 = memcmp(&regs->data[priv->sreg], &priv->data_from, priv->len); 33 d1 = memcmp(&regs->data[priv->sreg], &priv->data_from, priv->len);
35 d2 = memcmp(&regs->data[priv->sreg], &priv->data_to, priv->len); 34 d2 = memcmp(&regs->data[priv->sreg], &priv->data_to, priv->len);
36 switch (priv->op) { 35 switch (priv->op) {
37 case NFT_RANGE_EQ: 36 case NFT_RANGE_EQ:
38 mismatch = (d1 < 0 || d2 > 0); 37 if (d1 < 0 || d2 > 0)
38 regs->verdict.code = NFT_BREAK;
39 break; 39 break;
40 case NFT_RANGE_NEQ: 40 case NFT_RANGE_NEQ:
41 mismatch = (d1 >= 0 && d2 <= 0); 41 if (d1 >= 0 && d2 <= 0)
42 regs->verdict.code = NFT_BREAK;
42 break; 43 break;
43 } 44 }
44
45 if (mismatch)
46 regs->verdict.code = NFT_BREAK;
47} 45}
48 46
49static const struct nla_policy nft_range_policy[NFTA_RANGE_MAX + 1] = { 47static const struct nla_policy nft_range_policy[NFTA_RANGE_MAX + 1] = {
@@ -59,6 +57,7 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr
59 struct nft_range_expr *priv = nft_expr_priv(expr); 57 struct nft_range_expr *priv = nft_expr_priv(expr);
60 struct nft_data_desc desc_from, desc_to; 58 struct nft_data_desc desc_from, desc_to;
61 int err; 59 int err;
60 u32 op;
62 61
63 err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from), 62 err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from),
64 &desc_from, tb[NFTA_RANGE_FROM_DATA]); 63 &desc_from, tb[NFTA_RANGE_FROM_DATA]);
@@ -80,7 +79,20 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr
80 if (err < 0) 79 if (err < 0)
81 goto err2; 80 goto err2;
82 81
83 priv->op = ntohl(nla_get_be32(tb[NFTA_RANGE_OP])); 82 err = nft_parse_u32_check(tb[NFTA_RANGE_OP], U8_MAX, &op);
83 if (err < 0)
84 goto err2;
85
86 switch (op) {
87 case NFT_RANGE_EQ:
88 case NFT_RANGE_NEQ:
89 break;
90 default:
91 err = -EINVAL;
92 goto err2;
93 }
94
95 priv->op = op;
84 priv->len = desc_from.len; 96 priv->len = desc_from.len;
85 return 0; 97 return 0;
86err2: 98err2:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index e0aa7c1d0224..fc4977456c30 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1513,7 +1513,7 @@ xt_hook_ops_alloc(const struct xt_table *table, nf_hookfn *fn)
1513 if (!num_hooks) 1513 if (!num_hooks)
1514 return ERR_PTR(-EINVAL); 1514 return ERR_PTR(-EINVAL);
1515 1515
1516 ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL); 1516 ops = kcalloc(num_hooks, sizeof(*ops), GFP_KERNEL);
1517 if (ops == NULL) 1517 if (ops == NULL)
1518 return ERR_PTR(-ENOMEM); 1518 return ERR_PTR(-ENOMEM);
1519 1519
diff --git a/net/netfilter/xt_NFLOG.c b/net/netfilter/xt_NFLOG.c
index 018eed7e1ff1..8668a5c18dc3 100644
--- a/net/netfilter/xt_NFLOG.c
+++ b/net/netfilter/xt_NFLOG.c
@@ -32,6 +32,7 @@ nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
32 li.u.ulog.copy_len = info->len; 32 li.u.ulog.copy_len = info->len;
33 li.u.ulog.group = info->group; 33 li.u.ulog.group = info->group;
34 li.u.ulog.qthreshold = info->threshold; 34 li.u.ulog.qthreshold = info->threshold;
35 li.u.ulog.flags = 0;
35 36
36 if (info->flags & XT_NFLOG_F_COPY_LEN) 37 if (info->flags & XT_NFLOG_F_COPY_LEN)
37 li.u.ulog.flags |= NF_LOG_F_COPY_LEN; 38 li.u.ulog.flags |= NF_LOG_F_COPY_LEN;
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 2fab0c65aa94..b89b688e9d01 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -431,7 +431,7 @@ static void htable_put(struct xt_hashlimit_htable *hinfo)
431 CREDITS_PER_JIFFY*HZ*60*60*24 < 2^32 ie. 431 CREDITS_PER_JIFFY*HZ*60*60*24 < 2^32 ie.
432*/ 432*/
433#define MAX_CPJ_v1 (0xFFFFFFFF / (HZ*60*60*24)) 433#define MAX_CPJ_v1 (0xFFFFFFFF / (HZ*60*60*24))
434#define MAX_CPJ (0xFFFFFFFFFFFFFFFF / (HZ*60*60*24)) 434#define MAX_CPJ (0xFFFFFFFFFFFFFFFFULL / (HZ*60*60*24))
435 435
436/* Repeated shift and or gives us all 1s, final shift and add 1 gives 436/* Repeated shift and or gives us all 1s, final shift and add 1 gives
437 * us the power of 2 below the theoretical max, so GCC simply does a 437 * us the power of 2 below the theoretical max, so GCC simply does a
@@ -473,7 +473,7 @@ static u64 user2credits(u64 user, int revision)
473 return div64_u64(user * HZ * CREDITS_PER_JIFFY_v1, 473 return div64_u64(user * HZ * CREDITS_PER_JIFFY_v1,
474 XT_HASHLIMIT_SCALE); 474 XT_HASHLIMIT_SCALE);
475 } else { 475 } else {
476 if (user > 0xFFFFFFFFFFFFFFFF / (HZ*CREDITS_PER_JIFFY)) 476 if (user > 0xFFFFFFFFFFFFFFFFULL / (HZ*CREDITS_PER_JIFFY))
477 return div64_u64(user, XT_HASHLIMIT_SCALE_v2) 477 return div64_u64(user, XT_HASHLIMIT_SCALE_v2)
478 * HZ * CREDITS_PER_JIFFY; 478 * HZ * CREDITS_PER_JIFFY;
479 479
diff --git a/net/netfilter/xt_ipcomp.c b/net/netfilter/xt_ipcomp.c
index 89d53104c6b3..000e70377f85 100644
--- a/net/netfilter/xt_ipcomp.c
+++ b/net/netfilter/xt_ipcomp.c
@@ -26,6 +26,8 @@
26MODULE_LICENSE("GPL"); 26MODULE_LICENSE("GPL");
27MODULE_AUTHOR("Fan Du <fan.du@windriver.com>"); 27MODULE_AUTHOR("Fan Du <fan.du@windriver.com>");
28MODULE_DESCRIPTION("Xtables: IPv4/6 IPsec-IPComp SPI match"); 28MODULE_DESCRIPTION("Xtables: IPv4/6 IPsec-IPComp SPI match");
29MODULE_ALIAS("ipt_ipcomp");
30MODULE_ALIAS("ip6t_ipcomp");
29 31
30/* Returns 1 if the spi is matched by the range, 0 otherwise */ 32/* Returns 1 if the spi is matched by the range, 0 otherwise */
31static inline bool 33static inline bool
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 11db0d619c00..d2238b204691 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -250,7 +250,7 @@ static void __fanout_link(struct sock *sk, struct packet_sock *po);
250static int packet_direct_xmit(struct sk_buff *skb) 250static int packet_direct_xmit(struct sk_buff *skb)
251{ 251{
252 struct net_device *dev = skb->dev; 252 struct net_device *dev = skb->dev;
253 netdev_features_t features; 253 struct sk_buff *orig_skb = skb;
254 struct netdev_queue *txq; 254 struct netdev_queue *txq;
255 int ret = NETDEV_TX_BUSY; 255 int ret = NETDEV_TX_BUSY;
256 256
@@ -258,9 +258,8 @@ static int packet_direct_xmit(struct sk_buff *skb)
258 !netif_carrier_ok(dev))) 258 !netif_carrier_ok(dev)))
259 goto drop; 259 goto drop;
260 260
261 features = netif_skb_features(skb); 261 skb = validate_xmit_skb_list(skb, dev);
262 if (skb_needs_linearize(skb, features) && 262 if (skb != orig_skb)
263 __skb_linearize(skb))
264 goto drop; 263 goto drop;
265 264
266 txq = skb_get_tx_queue(dev, skb); 265 txq = skb_get_tx_queue(dev, skb);
@@ -280,7 +279,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
280 return ret; 279 return ret;
281drop: 280drop:
282 atomic_long_inc(&dev->tx_dropped); 281 atomic_long_inc(&dev->tx_dropped);
283 kfree_skb(skb); 282 kfree_skb_list(skb);
284 return NET_XMIT_DROP; 283 return NET_XMIT_DROP;
285} 284}
286 285
diff --git a/net/rds/Makefile b/net/rds/Makefile
index 0e72bec1529f..56c7d27eefee 100644
--- a/net/rds/Makefile
+++ b/net/rds/Makefile
@@ -13,5 +13,5 @@ obj-$(CONFIG_RDS_TCP) += rds_tcp.o
13rds_tcp-y := tcp.o tcp_connect.o tcp_listen.o tcp_recv.o \ 13rds_tcp-y := tcp.o tcp_connect.o tcp_listen.o tcp_recv.o \
14 tcp_send.o tcp_stats.o 14 tcp_send.o tcp_stats.o
15 15
16ccflags-$(CONFIG_RDS_DEBUG) := -DDEBUG 16ccflags-$(CONFIG_RDS_DEBUG) := -DRDS_DEBUG
17 17
diff --git a/net/rds/rds.h b/net/rds/rds.h
index fd0bccb2f9f9..67ba67c058b1 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -33,7 +33,7 @@
33#define KERNEL_HAS_ATOMIC64 33#define KERNEL_HAS_ATOMIC64
34#endif 34#endif
35 35
36#ifdef DEBUG 36#ifdef RDS_DEBUG
37#define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args) 37#define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args)
38#else 38#else
39/* sigh, pr_debug() causes unused variable warnings */ 39/* sigh, pr_debug() causes unused variable warnings */
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index 4353a29f3b57..1ed18d8c9c9f 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -276,7 +276,7 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
276 goto error; 276 goto error;
277 277
278 trace_rxrpc_call(call, rxrpc_call_connected, atomic_read(&call->usage), 278 trace_rxrpc_call(call, rxrpc_call_connected, atomic_read(&call->usage),
279 here, ERR_PTR(ret)); 279 here, NULL);
280 280
281 spin_lock_bh(&call->conn->params.peer->lock); 281 spin_lock_bh(&call->conn->params.peer->lock);
282 hlist_add_head(&call->error_link, 282 hlist_add_head(&call->error_link,
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index 941b724d523b..862eea6b266c 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -193,8 +193,8 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer)
193 fl6->fl6_dport = htons(7001); 193 fl6->fl6_dport = htons(7001);
194 fl6->fl6_sport = htons(7000); 194 fl6->fl6_sport = htons(7000);
195 dst = ip6_route_output(&init_net, NULL, fl6); 195 dst = ip6_route_output(&init_net, NULL, fl6);
196 if (IS_ERR(dst)) { 196 if (dst->error) {
197 _leave(" [route err %ld]", PTR_ERR(dst)); 197 _leave(" [route err %d]", dst->error);
198 return; 198 return;
199 } 199 }
200 break; 200 break;
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index a512b18c0088..f893d180da1c 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -1028,8 +1028,7 @@ static struct nlattr *find_dump_kind(const struct nlmsghdr *n)
1028 1028
1029 if (tb[1] == NULL) 1029 if (tb[1] == NULL)
1030 return NULL; 1030 return NULL;
1031 if (nla_parse(tb2, TCA_ACT_MAX, nla_data(tb[1]), 1031 if (nla_parse_nested(tb2, TCA_ACT_MAX, tb[1], NULL) < 0)
1032 nla_len(tb[1]), NULL) < 0)
1033 return NULL; 1032 return NULL;
1034 kind = tb2[TCA_ACT_KIND]; 1033 kind = tb2[TCA_ACT_KIND];
1035 1034
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 667dc382df82..6b07fba5770b 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -207,8 +207,11 @@ out:
207static void tcf_stats_update(struct tc_action *a, u64 bytes, u32 packets, 207static void tcf_stats_update(struct tc_action *a, u64 bytes, u32 packets,
208 u64 lastuse) 208 u64 lastuse)
209{ 209{
210 tcf_lastuse_update(&a->tcfa_tm); 210 struct tcf_mirred *m = to_mirred(a);
211 struct tcf_t *tm = &m->tcf_tm;
212
211 _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), bytes, packets); 213 _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), bytes, packets);
214 tm->lastuse = lastuse;
212} 215}
213 216
214static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, 217static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 2ee29a3375f6..2b2a7974e4bb 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -345,7 +345,8 @@ replay:
345 if (err == 0) { 345 if (err == 0) {
346 struct tcf_proto *next = rtnl_dereference(tp->next); 346 struct tcf_proto *next = rtnl_dereference(tp->next);
347 347
348 tfilter_notify(net, skb, n, tp, fh, 348 tfilter_notify(net, skb, n, tp,
349 t->tcm_handle,
349 RTM_DELTFILTER, false); 350 RTM_DELTFILTER, false);
350 if (tcf_destroy(tp, false)) 351 if (tcf_destroy(tp, false))
351 RCU_INIT_POINTER(*back, next); 352 RCU_INIT_POINTER(*back, next);
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 2a5c1896d18f..6cb0df859195 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -418,6 +418,7 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
418 __u8 has_data = 0; 418 __u8 has_data = 0;
419 int gso = 0; 419 int gso = 0;
420 int pktcount = 0; 420 int pktcount = 0;
421 int auth_len = 0;
421 struct dst_entry *dst; 422 struct dst_entry *dst;
422 unsigned char *auth = NULL; /* pointer to auth in skb data */ 423 unsigned char *auth = NULL; /* pointer to auth in skb data */
423 424
@@ -510,7 +511,12 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
510 list_for_each_entry(chunk, &packet->chunk_list, list) { 511 list_for_each_entry(chunk, &packet->chunk_list, list) {
511 int padded = SCTP_PAD4(chunk->skb->len); 512 int padded = SCTP_PAD4(chunk->skb->len);
512 513
513 if (pkt_size + padded > tp->pathmtu) 514 if (chunk == packet->auth)
515 auth_len = padded;
516 else if (auth_len + padded + packet->overhead >
517 tp->pathmtu)
518 goto nomem;
519 else if (pkt_size + padded > tp->pathmtu)
514 break; 520 break;
515 pkt_size += padded; 521 pkt_size += padded;
516 } 522 }
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 026e3bca4a94..8ec20a64a3f8 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -3422,6 +3422,12 @@ sctp_disposition_t sctp_sf_ootb(struct net *net,
3422 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, 3422 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
3423 commands); 3423 commands);
3424 3424
3425 /* Report violation if chunk len overflows */
3426 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
3427 if (ch_end > skb_tail_pointer(skb))
3428 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
3429 commands);
3430
3425 /* Now that we know we at least have a chunk header, 3431 /* Now that we know we at least have a chunk header,
3426 * do things that are type appropriate. 3432 * do things that are type appropriate.
3427 */ 3433 */
@@ -3453,12 +3459,6 @@ sctp_disposition_t sctp_sf_ootb(struct net *net,
3453 } 3459 }
3454 } 3460 }
3455 3461
3456 /* Report violation if chunk len overflows */
3457 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
3458 if (ch_end > skb_tail_pointer(skb))
3459 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
3460 commands);
3461
3462 ch = (sctp_chunkhdr_t *) ch_end; 3462 ch = (sctp_chunkhdr_t *) ch_end;
3463 } while (ch_end < skb_tail_pointer(skb)); 3463 } while (ch_end < skb_tail_pointer(skb));
3464 3464
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index fb02c7033307..9fbb6feb8c27 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4687,7 +4687,7 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
4687static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval, 4687static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
4688 int __user *optlen) 4688 int __user *optlen)
4689{ 4689{
4690 if (len <= 0) 4690 if (len == 0)
4691 return -EINVAL; 4691 return -EINVAL;
4692 if (len > sizeof(struct sctp_event_subscribe)) 4692 if (len > sizeof(struct sctp_event_subscribe))
4693 len = sizeof(struct sctp_event_subscribe); 4693 len = sizeof(struct sctp_event_subscribe);
@@ -6430,6 +6430,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
6430 if (get_user(len, optlen)) 6430 if (get_user(len, optlen))
6431 return -EFAULT; 6431 return -EFAULT;
6432 6432
6433 if (len < 0)
6434 return -EINVAL;
6435
6433 lock_sock(sk); 6436 lock_sock(sk);
6434 6437
6435 switch (optname) { 6438 switch (optname) {
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 02beb35f577f..3b95fe980fa2 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -771,6 +771,9 @@ int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
771 u32 mask = BR_LEARNING | BR_LEARNING_SYNC | BR_FLOOD; 771 u32 mask = BR_LEARNING | BR_LEARNING_SYNC | BR_FLOOD;
772 int err; 772 int err;
773 773
774 if (!netif_is_bridge_port(dev))
775 return -EOPNOTSUPP;
776
774 err = switchdev_port_attr_get(dev, &attr); 777 err = switchdev_port_attr_get(dev, &attr);
775 if (err && err != -EOPNOTSUPP) 778 if (err && err != -EOPNOTSUPP)
776 return err; 779 return err;
@@ -926,6 +929,9 @@ int switchdev_port_bridge_setlink(struct net_device *dev,
926 struct nlattr *afspec; 929 struct nlattr *afspec;
927 int err = 0; 930 int err = 0;
928 931
932 if (!netif_is_bridge_port(dev))
933 return -EOPNOTSUPP;
934
929 protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), 935 protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg),
930 IFLA_PROTINFO); 936 IFLA_PROTINFO);
931 if (protinfo) { 937 if (protinfo) {
@@ -959,6 +965,9 @@ int switchdev_port_bridge_dellink(struct net_device *dev,
959{ 965{
960 struct nlattr *afspec; 966 struct nlattr *afspec;
961 967
968 if (!netif_is_bridge_port(dev))
969 return -EOPNOTSUPP;
970
962 afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), 971 afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg),
963 IFLA_AF_SPEC); 972 IFLA_AF_SPEC);
964 if (afspec) 973 if (afspec)
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 753f774cb46f..aa1babbea385 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -247,11 +247,17 @@ int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb)
247 * 247 *
248 * RCU is locked, no other locks set 248 * RCU is locked, no other locks set
249 */ 249 */
250void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, u32 acked) 250void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
251 struct tipc_msg *hdr)
251{ 252{
252 struct sk_buff_head *inputq = &tipc_bc_base(net)->inputq; 253 struct sk_buff_head *inputq = &tipc_bc_base(net)->inputq;
254 u16 acked = msg_bcast_ack(hdr);
253 struct sk_buff_head xmitq; 255 struct sk_buff_head xmitq;
254 256
257 /* Ignore bc acks sent by peer before bcast synch point was received */
258 if (msg_bc_ack_invalid(hdr))
259 return;
260
255 __skb_queue_head_init(&xmitq); 261 __skb_queue_head_init(&xmitq);
256 262
257 tipc_bcast_lock(net); 263 tipc_bcast_lock(net);
@@ -279,11 +285,11 @@ int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
279 __skb_queue_head_init(&xmitq); 285 __skb_queue_head_init(&xmitq);
280 286
281 tipc_bcast_lock(net); 287 tipc_bcast_lock(net);
282 if (msg_type(hdr) == STATE_MSG) { 288 if (msg_type(hdr) != STATE_MSG) {
289 tipc_link_bc_init_rcv(l, hdr);
290 } else if (!msg_bc_ack_invalid(hdr)) {
283 tipc_link_bc_ack_rcv(l, msg_bcast_ack(hdr), &xmitq); 291 tipc_link_bc_ack_rcv(l, msg_bcast_ack(hdr), &xmitq);
284 rc = tipc_link_bc_sync_rcv(l, hdr, &xmitq); 292 rc = tipc_link_bc_sync_rcv(l, hdr, &xmitq);
285 } else {
286 tipc_link_bc_init_rcv(l, hdr);
287 } 293 }
288 tipc_bcast_unlock(net); 294 tipc_bcast_unlock(net);
289 295
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index 5ffe34472ccd..855d53c64ab3 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -55,7 +55,8 @@ void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id);
55int tipc_bcast_get_mtu(struct net *net); 55int tipc_bcast_get_mtu(struct net *net);
56int tipc_bcast_xmit(struct net *net, struct sk_buff_head *list); 56int tipc_bcast_xmit(struct net *net, struct sk_buff_head *list);
57int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb); 57int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
58void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, u32 acked); 58void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
59 struct tipc_msg *hdr);
59int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l, 60int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
60 struct tipc_msg *hdr); 61 struct tipc_msg *hdr);
61int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg); 62int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index b36e16cdc945..1055164c6232 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1312,6 +1312,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1312 msg_set_next_sent(hdr, l->snd_nxt); 1312 msg_set_next_sent(hdr, l->snd_nxt);
1313 msg_set_ack(hdr, l->rcv_nxt - 1); 1313 msg_set_ack(hdr, l->rcv_nxt - 1);
1314 msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1); 1314 msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1);
1315 msg_set_bc_ack_invalid(hdr, !node_up);
1315 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1); 1316 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
1316 msg_set_link_tolerance(hdr, tolerance); 1317 msg_set_link_tolerance(hdr, tolerance);
1317 msg_set_linkprio(hdr, priority); 1318 msg_set_linkprio(hdr, priority);
@@ -1574,6 +1575,7 @@ static void tipc_link_build_bc_init_msg(struct tipc_link *l,
1574 __skb_queue_head_init(&list); 1575 __skb_queue_head_init(&list);
1575 if (!tipc_link_build_bc_proto_msg(l->bc_rcvlink, false, 0, &list)) 1576 if (!tipc_link_build_bc_proto_msg(l->bc_rcvlink, false, 0, &list))
1576 return; 1577 return;
1578 msg_set_bc_ack_invalid(buf_msg(skb_peek(&list)), true);
1577 tipc_link_xmit(l, &list, xmitq); 1579 tipc_link_xmit(l, &list, xmitq);
1578} 1580}
1579 1581
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index c3832cdf2278..50a739860d37 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -714,6 +714,23 @@ static inline void msg_set_peer_stopping(struct tipc_msg *m, u32 s)
714 msg_set_bits(m, 5, 13, 0x1, s); 714 msg_set_bits(m, 5, 13, 0x1, s);
715} 715}
716 716
717static inline bool msg_bc_ack_invalid(struct tipc_msg *m)
718{
719 switch (msg_user(m)) {
720 case BCAST_PROTOCOL:
721 case NAME_DISTRIBUTOR:
722 case LINK_PROTOCOL:
723 return msg_bits(m, 5, 14, 0x1);
724 default:
725 return false;
726 }
727}
728
729static inline void msg_set_bc_ack_invalid(struct tipc_msg *m, bool invalid)
730{
731 msg_set_bits(m, 5, 14, 0x1, invalid);
732}
733
717static inline char *msg_media_addr(struct tipc_msg *m) 734static inline char *msg_media_addr(struct tipc_msg *m)
718{ 735{
719 return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET]; 736 return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET];
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index a04fe9be1c60..c1cfd92de17a 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -156,6 +156,7 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
156 pr_warn("Bulk publication failure\n"); 156 pr_warn("Bulk publication failure\n");
157 return; 157 return;
158 } 158 }
159 msg_set_bc_ack_invalid(buf_msg(skb), true);
159 item = (struct distr_item *)msg_data(buf_msg(skb)); 160 item = (struct distr_item *)msg_data(buf_msg(skb));
160 } 161 }
161 162
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 7ef14e2d2356..9d2f4c2b08ab 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1535,7 +1535,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
1535 if (unlikely(usr == LINK_PROTOCOL)) 1535 if (unlikely(usr == LINK_PROTOCOL))
1536 tipc_node_bc_sync_rcv(n, hdr, bearer_id, &xmitq); 1536 tipc_node_bc_sync_rcv(n, hdr, bearer_id, &xmitq);
1537 else if (unlikely(tipc_link_acked(n->bc_entry.link) != bc_ack)) 1537 else if (unlikely(tipc_link_acked(n->bc_entry.link) != bc_ack))
1538 tipc_bcast_ack_rcv(net, n->bc_entry.link, bc_ack); 1538 tipc_bcast_ack_rcv(net, n->bc_entry.link, hdr);
1539 1539
1540 /* Receive packet directly if conditions permit */ 1540 /* Receive packet directly if conditions permit */
1541 tipc_node_read_lock(n); 1541 tipc_node_read_lock(n);
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 0082f4b01795..14b3f007826d 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -104,13 +104,16 @@ static int wiphy_suspend(struct device *dev)
104 104
105 rtnl_lock(); 105 rtnl_lock();
106 if (rdev->wiphy.registered) { 106 if (rdev->wiphy.registered) {
107 if (!rdev->wiphy.wowlan_config) 107 if (!rdev->wiphy.wowlan_config) {
108 cfg80211_leave_all(rdev); 108 cfg80211_leave_all(rdev);
109 cfg80211_process_rdev_events(rdev);
110 }
109 if (rdev->ops->suspend) 111 if (rdev->ops->suspend)
110 ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config); 112 ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config);
111 if (ret == 1) { 113 if (ret == 1) {
112 /* Driver refuse to configure wowlan */ 114 /* Driver refuse to configure wowlan */
113 cfg80211_leave_all(rdev); 115 cfg80211_leave_all(rdev);
116 cfg80211_process_rdev_events(rdev);
114 ret = rdev_suspend(rdev, NULL); 117 ret = rdev_suspend(rdev, NULL);
115 } 118 }
116 } 119 }
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 8edce22d1b93..5ea12afc7706 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -420,8 +420,8 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
420} 420}
421EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen); 421EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen);
422 422
423static int __ieee80211_data_to_8023(struct sk_buff *skb, struct ethhdr *ehdr, 423int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
424 const u8 *addr, enum nl80211_iftype iftype) 424 const u8 *addr, enum nl80211_iftype iftype)
425{ 425{
426 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 426 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
427 struct { 427 struct {
@@ -525,13 +525,7 @@ static int __ieee80211_data_to_8023(struct sk_buff *skb, struct ethhdr *ehdr,
525 525
526 return 0; 526 return 0;
527} 527}
528 528EXPORT_SYMBOL(ieee80211_data_to_8023_exthdr);
529int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
530 enum nl80211_iftype iftype)
531{
532 return __ieee80211_data_to_8023(skb, NULL, addr, iftype);
533}
534EXPORT_SYMBOL(ieee80211_data_to_8023);
535 529
536int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, 530int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
537 enum nl80211_iftype iftype, 531 enum nl80211_iftype iftype,
@@ -746,24 +740,18 @@ __ieee80211_amsdu_copy(struct sk_buff *skb, unsigned int hlen,
746void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, 740void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
747 const u8 *addr, enum nl80211_iftype iftype, 741 const u8 *addr, enum nl80211_iftype iftype,
748 const unsigned int extra_headroom, 742 const unsigned int extra_headroom,
749 bool has_80211_header) 743 const u8 *check_da, const u8 *check_sa)
750{ 744{
751 unsigned int hlen = ALIGN(extra_headroom, 4); 745 unsigned int hlen = ALIGN(extra_headroom, 4);
752 struct sk_buff *frame = NULL; 746 struct sk_buff *frame = NULL;
753 u16 ethertype; 747 u16 ethertype;
754 u8 *payload; 748 u8 *payload;
755 int offset = 0, remaining, err; 749 int offset = 0, remaining;
756 struct ethhdr eth; 750 struct ethhdr eth;
757 bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb); 751 bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb);
758 bool reuse_skb = false; 752 bool reuse_skb = false;
759 bool last = false; 753 bool last = false;
760 754
761 if (has_80211_header) {
762 err = __ieee80211_data_to_8023(skb, &eth, addr, iftype);
763 if (err)
764 goto out;
765 }
766
767 while (!last) { 755 while (!last) {
768 unsigned int subframe_len; 756 unsigned int subframe_len;
769 int len; 757 int len;
@@ -780,8 +768,17 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
780 goto purge; 768 goto purge;
781 769
782 offset += sizeof(struct ethhdr); 770 offset += sizeof(struct ethhdr);
783 /* reuse skb for the last subframe */
784 last = remaining <= subframe_len + padding; 771 last = remaining <= subframe_len + padding;
772
773 /* FIXME: should we really accept multicast DA? */
774 if ((check_da && !is_multicast_ether_addr(eth.h_dest) &&
775 !ether_addr_equal(check_da, eth.h_dest)) ||
776 (check_sa && !ether_addr_equal(check_sa, eth.h_source))) {
777 offset += len + padding;
778 continue;
779 }
780
781 /* reuse skb for the last subframe */
785 if (!skb_is_nonlinear(skb) && !reuse_frag && last) { 782 if (!skb_is_nonlinear(skb) && !reuse_frag && last) {
786 skb_pull(skb, offset); 783 skb_pull(skb, offset);
787 frame = skb; 784 frame = skb;
@@ -819,7 +816,6 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
819 816
820 purge: 817 purge:
821 __skb_queue_purge(list); 818 __skb_queue_purge(list);
822 out:
823 dev_kfree_skb(skb); 819 dev_kfree_skb(skb);
824} 820}
825EXPORT_SYMBOL(ieee80211_amsdu_to_8023s); 821EXPORT_SYMBOL(ieee80211_amsdu_to_8023s);
diff --git a/samples/bpf/parse_ldabs.c b/samples/bpf/parse_ldabs.c
index d17550198d06..6db6b21fdc6d 100644
--- a/samples/bpf/parse_ldabs.c
+++ b/samples/bpf/parse_ldabs.c
@@ -4,6 +4,7 @@
4 * modify it under the terms of version 2 of the GNU General Public 4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation. 5 * License as published by the Free Software Foundation.
6 */ 6 */
7#define KBUILD_MODNAME "foo"
7#include <linux/ip.h> 8#include <linux/ip.h>
8#include <linux/ipv6.h> 9#include <linux/ipv6.h>
9#include <linux/in.h> 10#include <linux/in.h>
diff --git a/samples/bpf/parse_simple.c b/samples/bpf/parse_simple.c
index cf2511c33905..10af53d33cc2 100644
--- a/samples/bpf/parse_simple.c
+++ b/samples/bpf/parse_simple.c
@@ -4,6 +4,7 @@
4 * modify it under the terms of version 2 of the GNU General Public 4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation. 5 * License as published by the Free Software Foundation.
6 */ 6 */
7#define KBUILD_MODNAME "foo"
7#include <linux/ip.h> 8#include <linux/ip.h>
8#include <linux/ipv6.h> 9#include <linux/ipv6.h>
9#include <linux/in.h> 10#include <linux/in.h>
diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index edab34dce79b..95c16324760c 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -4,6 +4,7 @@
4 * modify it under the terms of version 2 of the GNU General Public 4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation. 5 * License as published by the Free Software Foundation.
6 */ 6 */
7#define KBUILD_MODNAME "foo"
7#include <linux/if_ether.h> 8#include <linux/if_ether.h>
8#include <linux/ip.h> 9#include <linux/ip.h>
9#include <linux/ipv6.h> 10#include <linux/ipv6.h>
diff --git a/samples/bpf/tcbpf1_kern.c b/samples/bpf/tcbpf1_kern.c
index fa051b3d53ee..274c884c87fe 100644
--- a/samples/bpf/tcbpf1_kern.c
+++ b/samples/bpf/tcbpf1_kern.c
@@ -1,3 +1,4 @@
1#define KBUILD_MODNAME "foo"
1#include <uapi/linux/bpf.h> 2#include <uapi/linux/bpf.h>
2#include <uapi/linux/if_ether.h> 3#include <uapi/linux/if_ether.h>
3#include <uapi/linux/if_packet.h> 4#include <uapi/linux/if_packet.h>
diff --git a/samples/bpf/tcbpf2_kern.c b/samples/bpf/tcbpf2_kern.c
index 3303bb85593b..9c823a609e75 100644
--- a/samples/bpf/tcbpf2_kern.c
+++ b/samples/bpf/tcbpf2_kern.c
@@ -5,6 +5,7 @@
5 * modify it under the terms of version 2 of the GNU General Public 5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation. 6 * License as published by the Free Software Foundation.
7 */ 7 */
8#define KBUILD_MODNAME "foo"
8#include <uapi/linux/bpf.h> 9#include <uapi/linux/bpf.h>
9#include <uapi/linux/if_ether.h> 10#include <uapi/linux/if_ether.h>
10#include <uapi/linux/if_packet.h> 11#include <uapi/linux/if_packet.h>
diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c
index 10ff73404e3a..1547b36a7b7b 100644
--- a/samples/bpf/test_cgrp2_tc_kern.c
+++ b/samples/bpf/test_cgrp2_tc_kern.c
@@ -4,6 +4,7 @@
4 * modify it under the terms of version 2 of the GNU General Public 4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation. 5 * License as published by the Free Software Foundation.
6 */ 6 */
7#define KBUILD_MODNAME "foo"
7#include <uapi/linux/if_ether.h> 8#include <uapi/linux/if_ether.h>
8#include <uapi/linux/in6.h> 9#include <uapi/linux/in6.h>
9#include <uapi/linux/ipv6.h> 10#include <uapi/linux/ipv6.h>
diff --git a/security/keys/Kconfig b/security/keys/Kconfig
index f826e8739023..d942c7c2bc0a 100644
--- a/security/keys/Kconfig
+++ b/security/keys/Kconfig
@@ -41,7 +41,7 @@ config BIG_KEYS
41 bool "Large payload keys" 41 bool "Large payload keys"
42 depends on KEYS 42 depends on KEYS
43 depends on TMPFS 43 depends on TMPFS
44 select CRYPTO 44 depends on (CRYPTO_ANSI_CPRNG = y || CRYPTO_DRBG = y)
45 select CRYPTO_AES 45 select CRYPTO_AES
46 select CRYPTO_ECB 46 select CRYPTO_ECB
47 select CRYPTO_RNG 47 select CRYPTO_RNG
diff --git a/security/keys/big_key.c b/security/keys/big_key.c
index c0b3030b5634..835c1ab30d01 100644
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -9,6 +9,7 @@
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) "big_key: "fmt
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/seq_file.h> 14#include <linux/seq_file.h>
14#include <linux/file.h> 15#include <linux/file.h>
@@ -341,44 +342,48 @@ error:
341 */ 342 */
342static int __init big_key_init(void) 343static int __init big_key_init(void)
343{ 344{
344 return register_key_type(&key_type_big_key); 345 struct crypto_skcipher *cipher;
345} 346 struct crypto_rng *rng;
346 347 int ret;
347/*
348 * Initialize big_key crypto and RNG algorithms
349 */
350static int __init big_key_crypto_init(void)
351{
352 int ret = -EINVAL;
353 348
354 /* init RNG */ 349 rng = crypto_alloc_rng(big_key_rng_name, 0, 0);
355 big_key_rng = crypto_alloc_rng(big_key_rng_name, 0, 0); 350 if (IS_ERR(rng)) {
356 if (IS_ERR(big_key_rng)) { 351 pr_err("Can't alloc rng: %ld\n", PTR_ERR(rng));
357 big_key_rng = NULL; 352 return PTR_ERR(rng);
358 return -EFAULT;
359 } 353 }
360 354
355 big_key_rng = rng;
356
361 /* seed RNG */ 357 /* seed RNG */
362 ret = crypto_rng_reset(big_key_rng, NULL, crypto_rng_seedsize(big_key_rng)); 358 ret = crypto_rng_reset(rng, NULL, crypto_rng_seedsize(rng));
363 if (ret) 359 if (ret) {
364 goto error; 360 pr_err("Can't reset rng: %d\n", ret);
361 goto error_rng;
362 }
365 363
366 /* init block cipher */ 364 /* init block cipher */
367 big_key_skcipher = crypto_alloc_skcipher(big_key_alg_name, 365 cipher = crypto_alloc_skcipher(big_key_alg_name, 0, CRYPTO_ALG_ASYNC);
368 0, CRYPTO_ALG_ASYNC); 366 if (IS_ERR(cipher)) {
369 if (IS_ERR(big_key_skcipher)) { 367 ret = PTR_ERR(cipher);
370 big_key_skcipher = NULL; 368 pr_err("Can't alloc crypto: %d\n", ret);
371 ret = -EFAULT; 369 goto error_rng;
372 goto error; 370 }
371
372 big_key_skcipher = cipher;
373
374 ret = register_key_type(&key_type_big_key);
375 if (ret < 0) {
376 pr_err("Can't register type: %d\n", ret);
377 goto error_cipher;
373 } 378 }
374 379
375 return 0; 380 return 0;
376 381
377error: 382error_cipher:
383 crypto_free_skcipher(big_key_skcipher);
384error_rng:
378 crypto_free_rng(big_key_rng); 385 crypto_free_rng(big_key_rng);
379 big_key_rng = NULL;
380 return ret; 386 return ret;
381} 387}
382 388
383device_initcall(big_key_init); 389late_initcall(big_key_init);
384late_initcall(big_key_crypto_init);
diff --git a/security/keys/proc.c b/security/keys/proc.c
index f0611a6368cd..b9f531c9e4fa 100644
--- a/security/keys/proc.c
+++ b/security/keys/proc.c
@@ -181,7 +181,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
181 struct timespec now; 181 struct timespec now;
182 unsigned long timo; 182 unsigned long timo;
183 key_ref_t key_ref, skey_ref; 183 key_ref_t key_ref, skey_ref;
184 char xbuf[12]; 184 char xbuf[16];
185 int rc; 185 int rc;
186 186
187 struct keyring_search_context ctx = { 187 struct keyring_search_context ctx = {
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 085057936287..09fd6108e421 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3557,7 +3557,7 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
3557 } else if (!vma->vm_file && 3557 } else if (!vma->vm_file &&
3558 ((vma->vm_start <= vma->vm_mm->start_stack && 3558 ((vma->vm_start <= vma->vm_mm->start_stack &&
3559 vma->vm_end >= vma->vm_mm->start_stack) || 3559 vma->vm_end >= vma->vm_mm->start_stack) ||
3560 vma_is_stack_for_task(vma, current))) { 3560 vma_is_stack_for_current(vma))) {
3561 rc = current_has_perm(current, PROCESS__EXECSTACK); 3561 rc = current_has_perm(current, PROCESS__EXECSTACK);
3562 } else if (vma->vm_file && vma->anon_vma) { 3562 } else if (vma->vm_file && vma->anon_vma) {
3563 /* 3563 /*
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index dcc102813aef..37d9cfbc29f9 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -448,8 +448,8 @@ snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr)
448 448
449 ktime_get_ts64(&tm); 449 ktime_get_ts64(&tm);
450 tm = timespec64_sub(tm, tmr->last_update); 450 tm = timespec64_sub(tm, tmr->last_update);
451 cur_time.tv_nsec = tm.tv_nsec; 451 cur_time.tv_nsec += tm.tv_nsec;
452 cur_time.tv_sec = tm.tv_sec; 452 cur_time.tv_sec += tm.tv_sec;
453 snd_seq_sanity_real_time(&cur_time); 453 snd_seq_sanity_real_time(&cur_time);
454 } 454 }
455 spin_unlock_irqrestore(&tmr->lock, flags); 455 spin_unlock_irqrestore(&tmr->lock, flags);
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index d17937b92331..7e3aa50b21f9 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -111,7 +111,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
111 return -EINVAL; 111 return -EINVAL;
112 112
113 hm = kmalloc(sizeof(*hm), GFP_KERNEL); 113 hm = kmalloc(sizeof(*hm), GFP_KERNEL);
114 hr = kmalloc(sizeof(*hr), GFP_KERNEL); 114 hr = kzalloc(sizeof(*hr), GFP_KERNEL);
115 if (!hm || !hr) { 115 if (!hm || !hr) {
116 err = -ENOMEM; 116 err = -ENOMEM;
117 goto out; 117 goto out;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index c3469f756ec2..c64d986009a9 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -341,8 +341,7 @@ enum {
341 341
342/* quirks for Nvidia */ 342/* quirks for Nvidia */
343#define AZX_DCAPS_PRESET_NVIDIA \ 343#define AZX_DCAPS_PRESET_NVIDIA \
344 (AZX_DCAPS_NO_MSI | /*AZX_DCAPS_ALIGN_BUFSIZE |*/ \ 344 (AZX_DCAPS_NO_MSI | AZX_DCAPS_CORBRP_SELF_CLEAR |\
345 AZX_DCAPS_NO_64BIT | AZX_DCAPS_CORBRP_SELF_CLEAR |\
346 AZX_DCAPS_SNOOP_TYPE(NVIDIA)) 345 AZX_DCAPS_SNOOP_TYPE(NVIDIA))
347 346
348#define AZX_DCAPS_PRESET_CTHDA \ 347#define AZX_DCAPS_PRESET_CTHDA \
@@ -1716,6 +1715,10 @@ static int azx_first_init(struct azx *chip)
1716 } 1715 }
1717 } 1716 }
1718 1717
1718 /* NVidia hardware normally only supports up to 40 bits of DMA */
1719 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA)
1720 dma_bits = 40;
1721
1719 /* disable 64bit DMA address on some devices */ 1722 /* disable 64bit DMA address on some devices */
1720 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { 1723 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) {
1721 dev_dbg(card->dev, "Disabling 64bit DMA\n"); 1724 dev_dbg(card->dev, "Disabling 64bit DMA\n");
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b58e8c76346a..2f909dd8b7b8 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5811,8 +5811,6 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
5811#define ALC295_STANDARD_PINS \ 5811#define ALC295_STANDARD_PINS \
5812 {0x12, 0xb7a60130}, \ 5812 {0x12, 0xb7a60130}, \
5813 {0x14, 0x90170110}, \ 5813 {0x14, 0x90170110}, \
5814 {0x17, 0x21014020}, \
5815 {0x18, 0x21a19030}, \
5816 {0x21, 0x04211020} 5814 {0x21, 0x04211020}
5817 5815
5818#define ALC298_STANDARD_PINS \ 5816#define ALC298_STANDARD_PINS \
@@ -5859,11 +5857,19 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5859 {0x1b, 0x02011020}, 5857 {0x1b, 0x02011020},
5860 {0x21, 0x0221101f}), 5858 {0x21, 0x0221101f}),
5861 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5859 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5860 {0x14, 0x90170110},
5861 {0x1b, 0x01011020},
5862 {0x21, 0x0221101f}),
5863 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5862 {0x14, 0x90170130}, 5864 {0x14, 0x90170130},
5863 {0x1b, 0x01014020}, 5865 {0x1b, 0x01014020},
5864 {0x21, 0x0221103f}), 5866 {0x21, 0x0221103f}),
5865 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5867 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5866 {0x14, 0x90170130}, 5868 {0x14, 0x90170130},
5869 {0x1b, 0x01011020},
5870 {0x21, 0x0221103f}),
5871 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5872 {0x14, 0x90170130},
5867 {0x1b, 0x02011020}, 5873 {0x1b, 0x02011020},
5868 {0x21, 0x0221103f}), 5874 {0x21, 0x0221103f}),
5869 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5875 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
@@ -6039,7 +6045,13 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6039 ALC292_STANDARD_PINS, 6045 ALC292_STANDARD_PINS,
6040 {0x13, 0x90a60140}), 6046 {0x13, 0x90a60140}),
6041 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, 6047 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6042 ALC295_STANDARD_PINS), 6048 ALC295_STANDARD_PINS,
6049 {0x17, 0x21014020},
6050 {0x18, 0x21a19030}),
6051 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6052 ALC295_STANDARD_PINS,
6053 {0x17, 0x21014040},
6054 {0x18, 0x21a19050}),
6043 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, 6055 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6044 ALC298_STANDARD_PINS, 6056 ALC298_STANDARD_PINS,
6045 {0x17, 0x90170110}), 6057 {0x17, 0x90170110}),
@@ -6613,6 +6625,7 @@ enum {
6613 ALC891_FIXUP_HEADSET_MODE, 6625 ALC891_FIXUP_HEADSET_MODE,
6614 ALC891_FIXUP_DELL_MIC_NO_PRESENCE, 6626 ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
6615 ALC662_FIXUP_ACER_VERITON, 6627 ALC662_FIXUP_ACER_VERITON,
6628 ALC892_FIXUP_ASROCK_MOBO,
6616}; 6629};
6617 6630
6618static const struct hda_fixup alc662_fixups[] = { 6631static const struct hda_fixup alc662_fixups[] = {
@@ -6889,6 +6902,16 @@ static const struct hda_fixup alc662_fixups[] = {
6889 { } 6902 { }
6890 } 6903 }
6891 }, 6904 },
6905 [ALC892_FIXUP_ASROCK_MOBO] = {
6906 .type = HDA_FIXUP_PINS,
6907 .v.pins = (const struct hda_pintbl[]) {
6908 { 0x15, 0x40f000f0 }, /* disabled */
6909 { 0x16, 0x40f000f0 }, /* disabled */
6910 { 0x18, 0x01014011 }, /* LO */
6911 { 0x1a, 0x01014012 }, /* LO */
6912 { }
6913 }
6914 },
6892}; 6915};
6893 6916
6894static const struct snd_pci_quirk alc662_fixup_tbl[] = { 6917static const struct snd_pci_quirk alc662_fixup_tbl[] = {
@@ -6926,6 +6949,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6926 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 6949 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
6927 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 6950 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6928 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 6951 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
6952 SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
6929 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), 6953 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
6930 SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON), 6954 SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
6931 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), 6955 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index c60a776e815d..8a59d4782a0f 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2907,6 +2907,23 @@ AU0828_DEVICE(0x2040, 0x7260, "Hauppauge", "HVR-950Q"),
2907AU0828_DEVICE(0x2040, 0x7213, "Hauppauge", "HVR-950Q"), 2907AU0828_DEVICE(0x2040, 0x7213, "Hauppauge", "HVR-950Q"),
2908AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), 2908AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
2909 2909
2910/* Syntek STK1160 */
2911{
2912 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2913 USB_DEVICE_ID_MATCH_INT_CLASS |
2914 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2915 .idVendor = 0x05e1,
2916 .idProduct = 0x0408,
2917 .bInterfaceClass = USB_CLASS_AUDIO,
2918 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2919 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2920 .vendor_name = "Syntek",
2921 .product_name = "STK1160",
2922 .ifnum = QUIRK_ANY_INTERFACE,
2923 .type = QUIRK_AUDIO_ALIGN_TRANSFER
2924 }
2925},
2926
2910/* Digidesign Mbox */ 2927/* Digidesign Mbox */
2911{ 2928{
2912 /* Thanks to Clemens Ladisch <clemens@ladisch.de> */ 2929 /* Thanks to Clemens Ladisch <clemens@ladisch.de> */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 1188bc849ee3..a39629206864 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -194,6 +194,8 @@
194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
195 195
196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ 196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */
197#define X86_FEATURE_AVX512_4VNNIW (7*32+16) /* AVX-512 Neural Network Instructions */
198#define X86_FEATURE_AVX512_4FMAPS (7*32+17) /* AVX-512 Multiply Accumulation Single precision */
197 199
198/* Virtualization flags: Linux defined, word 8 */ 200/* Virtualization flags: Linux defined, word 8 */
199#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 201#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 4490601a9235..e8a1f699058a 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -754,7 +754,7 @@ static struct rela *find_switch_table(struct objtool_file *file,
754 if (insn->type == INSN_JUMP_UNCONDITIONAL && 754 if (insn->type == INSN_JUMP_UNCONDITIONAL &&
755 insn->jump_dest && 755 insn->jump_dest &&
756 (insn->jump_dest->offset <= insn->offset || 756 (insn->jump_dest->offset <= insn->offset ||
757 insn->jump_dest->offset >= orig_insn->offset)) 757 insn->jump_dest->offset > orig_insn->offset))
758 break; 758 break;
759 759
760 text_rela = find_rela_by_dest_range(insn->sec, insn->offset, 760 text_rela = find_rela_by_dest_range(insn->sec, insn->offset,
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 28510e72618a..2907b7b78654 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1346,21 +1346,19 @@ unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *w
1346static int get_user_page_nowait(unsigned long start, int write, 1346static int get_user_page_nowait(unsigned long start, int write,
1347 struct page **page) 1347 struct page **page)
1348{ 1348{
1349 int flags = FOLL_TOUCH | FOLL_NOWAIT | FOLL_HWPOISON | FOLL_GET; 1349 int flags = FOLL_NOWAIT | FOLL_HWPOISON;
1350 1350
1351 if (write) 1351 if (write)
1352 flags |= FOLL_WRITE; 1352 flags |= FOLL_WRITE;
1353 1353
1354 return __get_user_pages(current, current->mm, start, 1, flags, page, 1354 return get_user_pages(start, 1, flags, page, NULL);
1355 NULL, NULL);
1356} 1355}
1357 1356
1358static inline int check_user_page_hwpoison(unsigned long addr) 1357static inline int check_user_page_hwpoison(unsigned long addr)
1359{ 1358{
1360 int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE; 1359 int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
1361 1360
1362 rc = __get_user_pages(current, current->mm, addr, 1, 1361 rc = get_user_pages(addr, 1, flags, NULL, NULL);
1363 flags, NULL, NULL, NULL);
1364 return rc == -EHWPOISON; 1362 return rc == -EHWPOISON;
1365} 1363}
1366 1364