aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-12-11 07:07:13 -0500
committerIngo Molnar <mingo@kernel.org>2016-12-11 07:07:13 -0500
commit6f38751510073cc054c5dffc3339b22f9385ceed (patch)
treeb7704b2d3388293118a6794f7a858e8891bcec60
parentf4ec57b632fe15ed7a355099cb96ed4b647416de (diff)
parent045169816b31b10faed984b01c390db1b32ee4c1 (diff)
Merge branch 'linus' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--CREDITS8
-rw-r--r--Documentation/devicetree/bindings/net/ethernet.txt24
-rw-r--r--Documentation/networking/nf_conntrack-sysctl.txt7
-rw-r--r--MAINTAINERS23
-rw-r--r--Makefile13
-rw-r--r--arch/arc/include/asm/delay.h9
-rw-r--r--arch/arc/include/asm/pgtable.h2
-rw-r--r--arch/arc/mm/cache.c2
-rw-r--r--arch/arm/boot/dts/Makefile2
-rw-r--r--arch/arm/boot/dts/imx7s.dtsi5
-rw-r--r--arch/arm/boot/dts/orion5x-linkstation-lsgl.dts4
-rw-r--r--arch/arm/boot/dts/stih407-family.dtsi16
-rw-r--r--arch/arm/boot/dts/sun5i-gr8-evb.dts (renamed from arch/arm/boot/dts/ntc-gr8-evb.dts)2
-rw-r--r--arch/arm/boot/dts/sun5i-gr8.dtsi (renamed from arch/arm/boot/dts/ntc-gr8.dtsi)0
-rw-r--r--arch/arm/boot/dts/sun8i-h3.dtsi2
-rw-r--r--arch/arm/include/asm/Kbuild1
-rw-r--r--arch/arm/kernel/Makefile2
-rw-r--r--arch/arm/kernel/armksyms.c183
-rw-r--r--arch/arm/kernel/entry-ftrace.S3
-rw-r--r--arch/arm/kernel/head.S3
-rw-r--r--arch/arm/kernel/smccc-call.S3
-rw-r--r--arch/arm/lib/ashldi3.S3
-rw-r--r--arch/arm/lib/ashrdi3.S3
-rw-r--r--arch/arm/lib/bitops.h5
-rw-r--r--arch/arm/lib/bswapsdi2.S3
-rw-r--r--arch/arm/lib/clear_user.S4
-rw-r--r--arch/arm/lib/copy_from_user.S2
-rw-r--r--arch/arm/lib/copy_page.S2
-rw-r--r--arch/arm/lib/copy_to_user.S4
-rw-r--r--arch/arm/lib/csumipv6.S3
-rw-r--r--arch/arm/lib/csumpartial.S2
-rw-r--r--arch/arm/lib/csumpartialcopy.S1
-rw-r--r--arch/arm/lib/csumpartialcopygeneric.S2
-rw-r--r--arch/arm/lib/csumpartialcopyuser.S1
-rw-r--r--arch/arm/lib/delay.c2
-rw-r--r--arch/arm/lib/div64.S2
-rw-r--r--arch/arm/lib/findbit.S9
-rw-r--r--arch/arm/lib/getuser.S9
-rw-r--r--arch/arm/lib/io-readsb.S2
-rw-r--r--arch/arm/lib/io-readsl.S2
-rw-r--r--arch/arm/lib/io-readsw-armv3.S3
-rw-r--r--arch/arm/lib/io-readsw-armv4.S2
-rw-r--r--arch/arm/lib/io-writesb.S2
-rw-r--r--arch/arm/lib/io-writesl.S2
-rw-r--r--arch/arm/lib/io-writesw-armv3.S2
-rw-r--r--arch/arm/lib/io-writesw-armv4.S2
-rw-r--r--arch/arm/lib/lib1funcs.S9
-rw-r--r--arch/arm/lib/lshrdi3.S3
-rw-r--r--arch/arm/lib/memchr.S2
-rw-r--r--arch/arm/lib/memcpy.S3
-rw-r--r--arch/arm/lib/memmove.S2
-rw-r--r--arch/arm/lib/memset.S3
-rw-r--r--arch/arm/lib/memzero.S2
-rw-r--r--arch/arm/lib/muldi3.S3
-rw-r--r--arch/arm/lib/putuser.S5
-rw-r--r--arch/arm/lib/strchr.S2
-rw-r--r--arch/arm/lib/strrchr.S2
-rw-r--r--arch/arm/lib/uaccess_with_memcpy.c3
-rw-r--r--arch/arm/lib/ucmpdi2.S3
-rw-r--r--arch/arm/mach-imx/Makefile1
-rw-r--r--arch/arm/mach-imx/ssi-fiq-ksym.c20
-rw-r--r--arch/arm/mach-imx/ssi-fiq.S7
-rw-r--r--arch/arm64/boot/dts/arm/juno-base.dtsi2
-rw-r--r--arch/arm64/boot/dts/arm/juno-r1.dts2
-rw-r--r--arch/arm64/boot/dts/arm/juno-r2.dts2
-rw-r--r--arch/arm64/boot/dts/arm/juno.dts2
-rw-r--r--arch/m68k/configs/amiga_defconfig8
-rw-r--r--arch/m68k/configs/apollo_defconfig8
-rw-r--r--arch/m68k/configs/atari_defconfig8
-rw-r--r--arch/m68k/configs/bvme6000_defconfig8
-rw-r--r--arch/m68k/configs/hp300_defconfig8
-rw-r--r--arch/m68k/configs/mac_defconfig8
-rw-r--r--arch/m68k/configs/multi_defconfig8
-rw-r--r--arch/m68k/configs/mvme147_defconfig8
-rw-r--r--arch/m68k/configs/mvme16x_defconfig8
-rw-r--r--arch/m68k/configs/q40_defconfig8
-rw-r--r--arch/m68k/configs/sun3_defconfig8
-rw-r--r--arch/m68k/configs/sun3x_defconfig8
-rw-r--r--arch/m68k/include/asm/delay.h2
-rw-r--r--arch/mips/include/asm/mipsregs.h6
-rw-r--r--arch/mips/include/asm/tlb.h13
-rw-r--r--arch/mips/mm/fault.c9
-rw-r--r--arch/mips/mm/init.c4
-rw-r--r--arch/mips/mm/tlb-r4k.c6
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/parisc/include/asm/pgtable.h8
-rw-r--r--arch/parisc/kernel/cache.c40
-rw-r--r--arch/parisc/kernel/inventory.c8
-rw-r--r--arch/parisc/kernel/pacache.S49
-rw-r--r--arch/parisc/kernel/pci-dma.c2
-rw-r--r--arch/parisc/kernel/setup.c4
-rw-r--r--arch/parisc/kernel/time.c57
-rw-r--r--arch/powerpc/boot/Makefile3
-rw-r--r--arch/powerpc/boot/main.c8
-rw-r--r--arch/powerpc/boot/opal-calls.S13
-rw-r--r--arch/powerpc/boot/opal.c13
-rw-r--r--arch/powerpc/boot/ops.h1
-rw-r--r--arch/powerpc/include/asm/asm-prototypes.h12
-rw-r--r--arch/powerpc/include/asm/mmu.h14
-rw-r--r--arch/powerpc/include/asm/reg.h1
-rw-r--r--arch/powerpc/kernel/cpu_setup_power.S8
-rw-r--r--arch/powerpc/kernel/eeh_driver.c4
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S9
-rw-r--r--arch/powerpc/mm/hash64_4k.c2
-rw-r--r--arch/powerpc/mm/hash64_64k.c4
-rw-r--r--arch/powerpc/mm/hash_utils_64.c8
-rw-r--r--arch/x86/events/core.c2
-rw-r--r--arch/x86/events/intel/core.c2
-rw-r--r--arch/x86/events/intel/cstate.c1
-rw-r--r--arch/x86/include/asm/compat.h4
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c4
-rw-r--r--arch/x86/kernel/unwind_guess.c9
-rw-r--r--arch/x86/kvm/emulate.c36
-rw-r--r--arch/x86/kvm/ioapic.c2
-rw-r--r--arch/x86/kvm/ioapic.h4
-rw-r--r--arch/x86/kvm/irq_comm.c13
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/platform/olpc/olpc-xo15-sci.c2
-rw-r--r--arch/x86/tools/relocs.h2
-rw-r--r--block/blk-map.c4
-rw-r--r--crypto/Makefile1
-rw-r--r--crypto/algif_aead.c59
-rw-r--r--crypto/asymmetric_keys/x509_cert_parser.c1
-rw-r--r--crypto/drbg.c29
-rw-r--r--crypto/mcryptd.c19
-rw-r--r--drivers/acpi/nfit/core.c55
-rw-r--r--drivers/acpi/nfit/nfit.h2
-rw-r--r--drivers/acpi/sleep.c29
-rw-r--r--drivers/ata/ahci.c7
-rw-r--r--drivers/ata/libata-scsi.c3
-rw-r--r--drivers/ata/sata_mv.c15
-rw-r--r--drivers/atm/eni.c2
-rw-r--r--drivers/atm/lanai.c1
-rw-r--r--drivers/block/zram/zram_drv.c11
-rw-r--r--drivers/clk/bcm/Kconfig2
-rw-r--r--drivers/clk/sunxi-ng/ccu-sun6i-a31.c2
-rw-r--r--drivers/clk/sunxi-ng/ccu-sun8i-a33.c2
-rw-r--r--drivers/crypto/caam/ctrl.c5
-rw-r--r--drivers/crypto/chelsio/chcr_algo.h3
-rw-r--r--drivers/crypto/marvell/hash.c11
-rw-r--r--drivers/dax/dax.c4
-rw-r--r--drivers/dax/pmem.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c5
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c12
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c5
-rw-r--r--drivers/gpu/drm/arm/hdlcd_crtc.c5
-rw-r--r--drivers/gpu/drm/arm/hdlcd_drv.c2
-rw-r--r--drivers/gpu/drm/drm_ioctl.c10
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c5
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c5
-rw-r--r--drivers/gpu/drm/i915/intel_display.c3
-rw-r--r--drivers/gpu/drm/mediatek/mtk_disp_ovl.c14
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c2
-rw-r--r--drivers/gpu/drm/mediatek/mtk_dsi.c64
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c16
-rw-r--r--drivers/hid/hid-cp2112.c115
-rw-r--r--drivers/hid/hid-lg.c14
-rw-r--r--drivers/hid/hid-magicmouse.c12
-rw-r--r--drivers/hid/hid-rmi.c10
-rw-r--r--drivers/hid/hid-sensor-hub.c1
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c64
-rw-r--r--drivers/i2c/busses/i2c-octeon-core.c4
-rw-r--r--drivers/i2c/busses/i2c-octeon-core.h27
-rw-r--r--drivers/input/mouse/psmouse-base.c4
-rw-r--r--drivers/iommu/dmar.c4
-rw-r--r--drivers/iommu/intel-iommu.c13
-rw-r--r--drivers/iommu/intel-svm.c28
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c4
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c1
-rw-r--r--drivers/media/tuners/tuner-xc2028.c37
-rw-r--r--drivers/mfd/syscon.c4
-rw-r--r--drivers/mfd/wm8994-core.c16
-rw-r--r--drivers/mmc/host/dw_mmc.c1
-rw-r--r--drivers/mmc/host/sdhci-of-esdhc.c14
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_ucan.h37
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_core.c8
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_core.h2
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_fd.c104
-rw-r--r--drivers/net/dsa/bcm_sf2.c4
-rw-r--r--drivers/net/ethernet/altera/altera_tse_main.c21
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-main.c4
-rw-r--r--drivers/net/ethernet/aurora/nb8800.c9
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c17
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c8
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c5
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c17
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c8
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c10
-rw-r--r--drivers/net/ethernet/cadence/macb.c5
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c1
-rw-r--r--drivers/net/ethernet/cirrus/ep93xx_eth.c4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c3
-rw-r--r--drivers/net/ethernet/freescale/fec.h2
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c37
-rw-r--r--drivers/net/ethernet/freescale/fman/fman_memac.c3
-rw-r--r--drivers/net/ethernet/freescale/fman/fman_tgec.c3
-rw-r--r--drivers/net/ethernet/freescale/fman/mac.c2
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c7
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c8
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c23
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c65
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.h1
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c1
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c8
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c8
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c8
-rw-r--r--drivers/net/ethernet/lantiq_etop.c1
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c7
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c2
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c43
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h15
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.c1
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-phy.c1
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c4
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c19
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c2
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c9
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c17
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c25
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c17
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c23
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c32
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c21
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c39
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c23
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c19
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c26
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c39
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h2
-rw-r--r--drivers/net/ethernet/synopsys/dwc_eth_qos.c22
-rw-r--r--drivers/net/ethernet/ti/cpmac.c1
-rw-r--r--drivers/net/ethernet/ti/cpsw-phy-sel.c1
-rw-r--r--drivers/net/ethernet/ti/cpsw.c20
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c10
-rw-r--r--drivers/net/geneve.c14
-rw-r--r--drivers/net/hyperv/netvsc_drv.c5
-rw-r--r--drivers/net/ieee802154/adf7242.c1
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c19
-rw-r--r--drivers/net/irda/irda-usb.c1
-rw-r--r--drivers/net/irda/w83977af_ir.c4
-rw-r--r--drivers/net/macvlan.c3
-rw-r--r--drivers/net/macvtap.c19
-rw-r--r--drivers/net/phy/micrel.c8
-rw-r--r--drivers/net/phy/phy_device.c16
-rw-r--r--drivers/net/phy/realtek.c20
-rw-r--r--drivers/net/tun.c10
-rw-r--r--drivers/net/usb/asix_devices.c6
-rw-r--r--drivers/net/usb/cdc_ether.c38
-rw-r--r--drivers/net/usb/cdc_mbim.c21
-rw-r--r--drivers/net/usb/cdc_ncm.c14
-rw-r--r--drivers/net/usb/lan78xx.c1
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/virtio_net.c19
-rw-r--r--drivers/net/vxlan.c10
-rw-r--r--drivers/net/wireless/marvell/mwifiex/cfg80211.c13
-rw-r--r--drivers/nvdimm/bus.c25
-rw-r--r--drivers/of/of_mdio.c15
-rw-r--r--drivers/pci/host/pcie-designware-plat.c2
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c14
-rw-r--r--drivers/pci/probe.c28
-rw-r--r--drivers/phy/phy-twl4030-usb.c4
-rw-r--r--drivers/pwm/pwm-meson.c1
-rw-r--r--drivers/pwm/sysfs.c2
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c2
-rw-r--r--drivers/scsi/hpsa.c16
-rw-r--r--drivers/scsi/hpsa.h2
-rw-r--r--drivers/scsi/libfc/fc_lport.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c14
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c13
-rw-r--r--drivers/scsi/mvsas/mv_sas.c4
-rw-r--r--drivers/scsi/qlogicpti.h4
-rw-r--r--drivers/usb/chipidea/core.c1
-rw-r--r--drivers/usb/chipidea/udc.c2
-rw-r--r--drivers/usb/gadget/function/f_fs.c8
-rw-r--r--drivers/usb/musb/musb_core.c147
-rw-r--r--drivers/usb/musb/musb_core.h13
-rw-r--r--drivers/usb/musb/musb_dsps.c58
-rw-r--r--drivers/usb/musb/musb_gadget.c39
-rw-r--r--drivers/usb/musb/omap2430.c10
-rw-r--r--drivers/usb/musb/tusb6010.c6
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h6
-rw-r--r--drivers/usb/storage/transport.c7
-rw-r--r--drivers/vhost/vsock.c2
-rw-r--r--drivers/watchdog/Kconfig1
-rw-r--r--fs/ceph/dir.c24
-rw-r--r--fs/cifs/cifsencrypt.c11
-rw-r--r--fs/cifs/cifssmb.c4
-rw-r--r--fs/cifs/connect.c25
-rw-r--r--fs/fuse/dir.c7
-rw-r--r--fs/isofs/rock.c4
-rw-r--r--fs/overlayfs/super.c6
-rw-r--r--fs/splice.c3
-rw-r--r--include/crypto/drbg.h2
-rw-r--r--include/linux/compiler-gcc.h4
-rw-r--r--include/linux/intel-iommu.h1
-rw-r--r--include/linux/libnvdimm.h2
-rw-r--r--include/linux/mlx4/device.h1
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/of_mdio.h4
-rw-r--r--include/linux/pagemap.h21
-rw-r--r--include/linux/pci.h14
-rw-r--r--include/linux/usb/cdc_ncm.h3
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/netfilter/nf_conntrack.h6
-rw-r--r--include/net/netfilter/nf_tables.h2
-rw-r--r--include/uapi/linux/can.h1
-rw-r--r--include/uapi/linux/if.h4
-rw-r--r--include/uapi/linux/input-event-codes.h2
-rw-r--r--include/uapi/linux/netfilter/Kbuild1
-rw-r--r--include/uapi/linux/tc_act/Kbuild2
-rw-r--r--init/do_mounts_rd.c2
-rw-r--r--kernel/bpf/verifier.c10
-rw-r--r--kernel/events/core.c19
-rw-r--r--kernel/kcov.c1
-rw-r--r--kernel/locking/lockdep.c111
-rw-r--r--kernel/module.c5
-rw-r--r--kernel/sched/auto_group.c4
-rw-r--r--lib/debugobjects.c8
-rw-r--r--lib/mpi/mpi-pow.c7
-rw-r--r--lib/test_kasan.c29
-rw-r--r--mm/huge_memory.c4
-rw-r--r--mm/kasan/kasan.c19
-rw-r--r--mm/kasan/kasan.h4
-rw-r--r--mm/kasan/report.c3
-rw-r--r--mm/khugepaged.c2
-rw-r--r--mm/mlock.c7
-rw-r--r--mm/mremap.c12
-rw-r--r--mm/shmem.c15
-rw-r--r--mm/truncate.c8
-rw-r--r--mm/vmscan.c2
-rw-r--r--mm/workingset.c2
-rw-r--r--net/batman-adv/translation-table.c4
-rw-r--r--net/bluetooth/6lowpan.c4
-rw-r--r--net/bluetooth/hci_conn.c26
-rw-r--r--net/bluetooth/l2cap_core.c2
-rw-r--r--net/bluetooth/rfcomm/tty.c2
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bridge/br_sysfs_br.c1
-rw-r--r--net/caif/caif_socket.c5
-rw-r--r--net/can/bcm.c18
-rw-r--r--net/can/raw.c3
-rw-r--r--net/core/ethtool.c1
-rw-r--r--net/core/flow.c6
-rw-r--r--net/core/flow_dissector.c2
-rw-r--r--net/core/rtnetlink.c6
-rw-r--r--net/core/sock.c4
-rw-r--r--net/dcb/dcbnl.c1
-rw-r--r--net/dccp/ipv4.c12
-rw-r--r--net/dsa/dsa.c13
-rw-r--r--net/dsa/dsa2.c4
-rw-r--r--net/dsa/slave.c19
-rw-r--r--net/ipv4/Kconfig1
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/fib_trie.c68
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/netfilter.c5
-rw-r--r--net/ipv4/netfilter/arp_tables.c4
-rw-r--r--net/ipv4/ping.c4
-rw-r--r--net/ipv4/tcp_input.c22
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv4/udp_impl.h2
-rw-r--r--net/ipv4/udplite.c2
-rw-r--r--net/ipv6/addrconf.c18
-rw-r--r--net/ipv6/datagram.c4
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/icmp.c6
-rw-r--r--net/ipv6/ip6_offload.c2
-rw-r--r--net/ipv6/ip6_tunnel.c1
-rw-r--r--net/ipv6/ip6_vti.c31
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c4
-rw-r--r--net/ipv6/netfilter/nf_defrag_ipv6_hooks.c2
-rw-r--r--net/ipv6/netfilter/nf_reject_ipv6.c1
-rw-r--r--net/ipv6/output_core.c2
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/ipv6/udp_impl.h2
-rw-r--r--net/ipv6/udplite.c2
-rw-r--r--net/l2tp/l2tp_eth.c2
-rw-r--r--net/l2tp/l2tp_ip.c63
-rw-r--r--net/l2tp/l2tp_ip6.c79
-rw-r--r--net/mpls/af_mpls.c2
-rw-r--r--net/netfilter/nf_nat_core.c49
-rw-r--r--net/netfilter/nf_tables_api.c14
-rw-r--r--net/netfilter/nft_hash.c7
-rw-r--r--net/netfilter/nft_range.c6
-rw-r--r--net/netlink/af_netlink.c21
-rw-r--r--net/netlink/af_netlink.h2
-rw-r--r--net/openvswitch/conntrack.c5
-rw-r--r--net/packet/af_packet.c18
-rw-r--r--net/rds/tcp.c2
-rw-r--r--net/sched/act_pedit.c24
-rw-r--r--net/sched/cls_api.c2
-rw-r--r--net/sched/cls_basic.c4
-rw-r--r--net/sched/cls_bpf.c4
-rw-r--r--net/sched/cls_cgroup.c7
-rw-r--r--net/sched/cls_flow.c1
-rw-r--r--net/sched/cls_flower.c41
-rw-r--r--net/sched/cls_matchall.c1
-rw-r--r--net/sched/cls_rsvp.h3
-rw-r--r--net/sched/cls_tcindex.c1
-rw-r--r--net/tipc/bearer.c11
-rw-r--r--net/tipc/bearer.h13
-rw-r--r--net/tipc/link.c40
-rw-r--r--net/tipc/monitor.c10
-rw-r--r--net/tipc/socket.c2
-rw-r--r--net/tipc/udp_media.c5
-rw-r--r--net/xfrm/xfrm_policy.c10
-rw-r--r--net/xfrm/xfrm_user.c2
-rw-r--r--samples/bpf/bpf_helpers.h2
-rw-r--r--samples/bpf/sampleip_kern.c2
-rw-r--r--samples/bpf/trace_event_kern.c2
-rw-r--r--scripts/kconfig/Makefile2
-rw-r--r--sound/sparc/dbri.c27
-rw-r--r--tools/objtool/arch/x86/decode.c2
-rw-r--r--tools/testing/nvdimm/Kbuild1
-rw-r--r--tools/testing/nvdimm/test/iomap.c23
-rw-r--r--tools/testing/nvdimm/test/nfit.c236
-rw-r--r--tools/testing/nvdimm/test/nfit_test.h8
-rw-r--r--virt/kvm/arm/vgic/vgic-v2.c6
-rw-r--r--virt/kvm/arm/vgic/vgic-v3.c6
-rw-r--r--virt/kvm/kvm_main.c2
446 files changed, 3435 insertions, 1540 deletions
diff --git a/CREDITS b/CREDITS
index 837367624e45..d7ebdfbc4d4f 100644
--- a/CREDITS
+++ b/CREDITS
@@ -9,7 +9,7 @@
9 Linus 9 Linus
10---------- 10----------
11 11
12M: Matt Mackal 12N: Matt Mackal
13E: mpm@selenic.com 13E: mpm@selenic.com
14D: SLOB slab allocator 14D: SLOB slab allocator
15 15
@@ -1910,7 +1910,7 @@ S: Ra'annana, Israel
1910 1910
1911N: Andi Kleen 1911N: Andi Kleen
1912E: andi@firstfloor.org 1912E: andi@firstfloor.org
1913U: http://www.halobates.de 1913W: http://www.halobates.de
1914D: network, x86, NUMA, various hacks 1914D: network, x86, NUMA, various hacks
1915S: Schwalbenstr. 96 1915S: Schwalbenstr. 96
1916S: 85551 Ottobrunn 1916S: 85551 Ottobrunn
@@ -2089,8 +2089,8 @@ D: ST Microelectronics SPEAr13xx PCI host bridge driver
2089D: Synopsys Designware PCI host bridge driver 2089D: Synopsys Designware PCI host bridge driver
2090 2090
2091N: Gabor Kuti 2091N: Gabor Kuti
2092M: seasons@falcon.sch.bme.hu 2092E: seasons@falcon.sch.bme.hu
2093M: seasons@makosteszta.sote.hu 2093E: seasons@makosteszta.sote.hu
2094D: Original author of software suspend 2094D: Original author of software suspend
2095 2095
2096N: Jaroslav Kysela 2096N: Jaroslav Kysela
diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index e1d76812419c..05150957ecfd 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -9,10 +9,26 @@ The following properties are common to the Ethernet controllers:
9- max-speed: number, specifies maximum speed in Mbit/s supported by the device; 9- max-speed: number, specifies maximum speed in Mbit/s supported by the device;
10- max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than 10- max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
11 the maximum frame size (there's contradiction in ePAPR). 11 the maximum frame size (there's contradiction in ePAPR).
12- phy-mode: string, operation mode of the PHY interface; supported values are 12- phy-mode: string, operation mode of the PHY interface. This is now a de-facto
13 "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id", 13 standard property; supported values are:
14 "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii", "trgmii"; this is now a 14 * "mii"
15 de-facto standard property; 15 * "gmii"
16 * "sgmii"
17 * "qsgmii"
18 * "tbi"
19 * "rev-mii"
20 * "rmii"
21 * "rgmii" (RX and TX delays are added by the MAC when required)
22 * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the
23 MAC should not add the RX or TX delays in this case)
24 * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC
25 should not add an RX delay in this case)
26 * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC
27 should not add an TX delay in this case)
28 * "rtbi"
29 * "smii"
30 * "xgmii"
31 * "trgmii"
16- phy-connection-type: the same as "phy-mode" property but described in ePAPR; 32- phy-connection-type: the same as "phy-mode" property but described in ePAPR;
17- phy-handle: phandle, specifies a reference to a node representing a PHY 33- phy-handle: phandle, specifies a reference to a node representing a PHY
18 device; this property is described in ePAPR and so preferred; 34 device; this property is described in ePAPR and so preferred;
diff --git a/Documentation/networking/nf_conntrack-sysctl.txt b/Documentation/networking/nf_conntrack-sysctl.txt
index 399e4e866a9c..433b6724797a 100644
--- a/Documentation/networking/nf_conntrack-sysctl.txt
+++ b/Documentation/networking/nf_conntrack-sysctl.txt
@@ -62,10 +62,13 @@ nf_conntrack_generic_timeout - INTEGER (seconds)
62 protocols. 62 protocols.
63 63
64nf_conntrack_helper - BOOLEAN 64nf_conntrack_helper - BOOLEAN
65 0 - disabled 65 0 - disabled (default)
66 not 0 - enabled (default) 66 not 0 - enabled
67 67
68 Enable automatic conntrack helper assignment. 68 Enable automatic conntrack helper assignment.
69 If disabled it is required to set up iptables rules to assign
70 helpers to connections. See the CT target description in the
71 iptables-extensions(8) man page for further information.
69 72
70nf_conntrack_icmp_timeout - INTEGER (seconds) 73nf_conntrack_icmp_timeout - INTEGER (seconds)
71 default 30 74 default 30
diff --git a/MAINTAINERS b/MAINTAINERS
index ad9b965e5e44..63cefa62324c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -77,6 +77,7 @@ Descriptions of section entries:
77 Q: Patchwork web based patch tracking system site 77 Q: Patchwork web based patch tracking system site
78 T: SCM tree type and location. 78 T: SCM tree type and location.
79 Type is one of: git, hg, quilt, stgit, topgit 79 Type is one of: git, hg, quilt, stgit, topgit
80 B: Bug tracking system location.
80 S: Status, one of the following: 81 S: Status, one of the following:
81 Supported: Someone is actually paid to look after this. 82 Supported: Someone is actually paid to look after this.
82 Maintained: Someone actually looks after it. 83 Maintained: Someone actually looks after it.
@@ -281,6 +282,7 @@ L: linux-acpi@vger.kernel.org
281W: https://01.org/linux-acpi 282W: https://01.org/linux-acpi
282Q: https://patchwork.kernel.org/project/linux-acpi/list/ 283Q: https://patchwork.kernel.org/project/linux-acpi/list/
283T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm 284T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
285B: https://bugzilla.kernel.org
284S: Supported 286S: Supported
285F: drivers/acpi/ 287F: drivers/acpi/
286F: drivers/pnp/pnpacpi/ 288F: drivers/pnp/pnpacpi/
@@ -304,6 +306,8 @@ W: https://acpica.org/
304W: https://github.com/acpica/acpica/ 306W: https://github.com/acpica/acpica/
305Q: https://patchwork.kernel.org/project/linux-acpi/list/ 307Q: https://patchwork.kernel.org/project/linux-acpi/list/
306T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm 308T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
309B: https://bugzilla.kernel.org
310B: https://bugs.acpica.org
307S: Supported 311S: Supported
308F: drivers/acpi/acpica/ 312F: drivers/acpi/acpica/
309F: include/acpi/ 313F: include/acpi/
@@ -313,6 +317,7 @@ ACPI FAN DRIVER
313M: Zhang Rui <rui.zhang@intel.com> 317M: Zhang Rui <rui.zhang@intel.com>
314L: linux-acpi@vger.kernel.org 318L: linux-acpi@vger.kernel.org
315W: https://01.org/linux-acpi 319W: https://01.org/linux-acpi
320B: https://bugzilla.kernel.org
316S: Supported 321S: Supported
317F: drivers/acpi/fan.c 322F: drivers/acpi/fan.c
318 323
@@ -328,6 +333,7 @@ ACPI THERMAL DRIVER
328M: Zhang Rui <rui.zhang@intel.com> 333M: Zhang Rui <rui.zhang@intel.com>
329L: linux-acpi@vger.kernel.org 334L: linux-acpi@vger.kernel.org
330W: https://01.org/linux-acpi 335W: https://01.org/linux-acpi
336B: https://bugzilla.kernel.org
331S: Supported 337S: Supported
332F: drivers/acpi/*thermal* 338F: drivers/acpi/*thermal*
333 339
@@ -335,6 +341,7 @@ ACPI VIDEO DRIVER
335M: Zhang Rui <rui.zhang@intel.com> 341M: Zhang Rui <rui.zhang@intel.com>
336L: linux-acpi@vger.kernel.org 342L: linux-acpi@vger.kernel.org
337W: https://01.org/linux-acpi 343W: https://01.org/linux-acpi
344B: https://bugzilla.kernel.org
338S: Supported 345S: Supported
339F: drivers/acpi/acpi_video.c 346F: drivers/acpi/acpi_video.c
340 347
@@ -5663,6 +5670,7 @@ HIBERNATION (aka Software Suspend, aka swsusp)
5663M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 5670M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
5664M: Pavel Machek <pavel@ucw.cz> 5671M: Pavel Machek <pavel@ucw.cz>
5665L: linux-pm@vger.kernel.org 5672L: linux-pm@vger.kernel.org
5673B: https://bugzilla.kernel.org
5666S: Supported 5674S: Supported
5667F: arch/x86/power/ 5675F: arch/x86/power/
5668F: drivers/base/power/ 5676F: drivers/base/power/
@@ -9249,11 +9257,12 @@ S: Maintained
9249F: drivers/pci/host/*layerscape* 9257F: drivers/pci/host/*layerscape*
9250 9258
9251PCI DRIVER FOR IMX6 9259PCI DRIVER FOR IMX6
9252M: Richard Zhu <Richard.Zhu@freescale.com> 9260M: Richard Zhu <hongxing.zhu@nxp.com>
9253M: Lucas Stach <l.stach@pengutronix.de> 9261M: Lucas Stach <l.stach@pengutronix.de>
9254L: linux-pci@vger.kernel.org 9262L: linux-pci@vger.kernel.org
9255L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 9263L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
9256S: Maintained 9264S: Maintained
9265F: Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
9257F: drivers/pci/host/*imx6* 9266F: drivers/pci/host/*imx6*
9258 9267
9259PCI DRIVER FOR TI KEYSTONE 9268PCI DRIVER FOR TI KEYSTONE
@@ -9312,17 +9321,11 @@ F: drivers/pci/host/pci-exynos.c
9312 9321
9313PCI DRIVER FOR SYNOPSIS DESIGNWARE 9322PCI DRIVER FOR SYNOPSIS DESIGNWARE
9314M: Jingoo Han <jingoohan1@gmail.com> 9323M: Jingoo Han <jingoohan1@gmail.com>
9315M: Pratyush Anand <pratyush.anand@gmail.com> 9324M: Joao Pinto <Joao.Pinto@synopsys.com>
9316L: linux-pci@vger.kernel.org
9317S: Maintained
9318F: drivers/pci/host/*designware*
9319
9320PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE
9321M: Jose Abreu <Jose.Abreu@synopsys.com>
9322L: linux-pci@vger.kernel.org 9325L: linux-pci@vger.kernel.org
9323S: Maintained 9326S: Maintained
9324F: Documentation/devicetree/bindings/pci/designware-pcie.txt 9327F: Documentation/devicetree/bindings/pci/designware-pcie.txt
9325F: drivers/pci/host/pcie-designware-plat.c 9328F: drivers/pci/host/*designware*
9326 9329
9327PCI DRIVER FOR GENERIC OF HOSTS 9330PCI DRIVER FOR GENERIC OF HOSTS
9328M: Will Deacon <will.deacon@arm.com> 9331M: Will Deacon <will.deacon@arm.com>
@@ -9624,6 +9627,7 @@ POWER MANAGEMENT CORE
9624M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 9627M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
9625L: linux-pm@vger.kernel.org 9628L: linux-pm@vger.kernel.org
9626T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm 9629T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
9630B: https://bugzilla.kernel.org
9627S: Supported 9631S: Supported
9628F: drivers/base/power/ 9632F: drivers/base/power/
9629F: include/linux/pm.h 9633F: include/linux/pm.h
@@ -11613,6 +11617,7 @@ M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
11613M: Len Brown <len.brown@intel.com> 11617M: Len Brown <len.brown@intel.com>
11614M: Pavel Machek <pavel@ucw.cz> 11618M: Pavel Machek <pavel@ucw.cz>
11615L: linux-pm@vger.kernel.org 11619L: linux-pm@vger.kernel.org
11620B: https://bugzilla.kernel.org
11616S: Supported 11621S: Supported
11617F: Documentation/power/ 11622F: Documentation/power/
11618F: arch/x86/kernel/acpi/ 11623F: arch/x86/kernel/acpi/
diff --git a/Makefile b/Makefile
index 0ede48ba5aaf..369099dc0fae 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 9 2PATCHLEVEL = 9
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc6 4EXTRAVERSION = -rc8
5NAME = Psychotic Stoned Sheep 5NAME = Psychotic Stoned Sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -607,6 +607,13 @@ else
607include/config/auto.conf: ; 607include/config/auto.conf: ;
608endif # $(dot-config) 608endif # $(dot-config)
609 609
610# For the kernel to actually contain only the needed exported symbols,
611# we have to build modules as well to determine what those symbols are.
612# (this can be evaluated only once include/config/auto.conf has been included)
613ifdef CONFIG_TRIM_UNUSED_KSYMS
614 KBUILD_MODULES := 1
615endif
616
610# The all: target is the default when no target is given on the 617# The all: target is the default when no target is given on the
611# command line. 618# command line.
612# This allow a user to issue only 'make' to build a kernel including modules 619# This allow a user to issue only 'make' to build a kernel including modules
@@ -944,7 +951,7 @@ ifdef CONFIG_GDB_SCRIPTS
944endif 951endif
945ifdef CONFIG_TRIM_UNUSED_KSYMS 952ifdef CONFIG_TRIM_UNUSED_KSYMS
946 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ 953 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
947 "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq" 954 "$(MAKE) -f $(srctree)/Makefile vmlinux"
948endif 955endif
949 956
950# standalone target for easier testing 957# standalone target for easier testing
@@ -1019,8 +1026,6 @@ prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic
1019prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ 1026prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
1020 include/config/auto.conf 1027 include/config/auto.conf
1021 $(cmd_crmodverdir) 1028 $(cmd_crmodverdir)
1022 $(Q)test -e include/generated/autoksyms.h || \
1023 touch include/generated/autoksyms.h
1024 1029
1025archprepare: archheaders archscripts prepare1 scripts_basic 1030archprepare: archheaders archscripts prepare1 scripts_basic
1026 1031
diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h
index 08e7e2a16ac1..a36e8601114d 100644
--- a/arch/arc/include/asm/delay.h
+++ b/arch/arc/include/asm/delay.h
@@ -22,10 +22,11 @@
22static inline void __delay(unsigned long loops) 22static inline void __delay(unsigned long loops)
23{ 23{
24 __asm__ __volatile__( 24 __asm__ __volatile__(
25 " lp 1f \n" 25 " mov lp_count, %0 \n"
26 " nop \n" 26 " lp 1f \n"
27 "1: \n" 27 " nop \n"
28 : "+l"(loops)); 28 "1: \n"
29 : : "r"(loops));
29} 30}
30 31
31extern void __bad_udelay(void); 32extern void __bad_udelay(void);
diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 89eeb3720051..e94ca72b974e 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -280,7 +280,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
280 280
281#define pte_page(pte) pfn_to_page(pte_pfn(pte)) 281#define pte_page(pte) pfn_to_page(pte_pfn(pte))
282#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) 282#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
283#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 283#define pfn_pte(pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot))
284 284
285/* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ 285/* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/
286#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) 286#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 2b96cfc3be75..50d71695cd4e 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -23,7 +23,7 @@
23 23
24static int l2_line_sz; 24static int l2_line_sz;
25static int ioc_exists; 25static int ioc_exists;
26int slc_enable = 1, ioc_enable = 1; 26int slc_enable = 1, ioc_enable = 0;
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
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index befcd2619902..c558ba75cbcc 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -745,7 +745,6 @@ dtb-$(CONFIG_MACH_SUN4I) += \
745 sun4i-a10-pcduino2.dtb \ 745 sun4i-a10-pcduino2.dtb \
746 sun4i-a10-pov-protab2-ips9.dtb 746 sun4i-a10-pov-protab2-ips9.dtb
747dtb-$(CONFIG_MACH_SUN5I) += \ 747dtb-$(CONFIG_MACH_SUN5I) += \
748 ntc-gr8-evb.dtb \
749 sun5i-a10s-auxtek-t003.dtb \ 748 sun5i-a10s-auxtek-t003.dtb \
750 sun5i-a10s-auxtek-t004.dtb \ 749 sun5i-a10s-auxtek-t004.dtb \
751 sun5i-a10s-mk802.dtb \ 750 sun5i-a10s-mk802.dtb \
@@ -761,6 +760,7 @@ dtb-$(CONFIG_MACH_SUN5I) += \
761 sun5i-a13-olinuxino-micro.dtb \ 760 sun5i-a13-olinuxino-micro.dtb \
762 sun5i-a13-q8-tablet.dtb \ 761 sun5i-a13-q8-tablet.dtb \
763 sun5i-a13-utoo-p66.dtb \ 762 sun5i-a13-utoo-p66.dtb \
763 sun5i-gr8-evb.dtb \
764 sun5i-r8-chip.dtb 764 sun5i-r8-chip.dtb
765dtb-$(CONFIG_MACH_SUN6I) += \ 765dtb-$(CONFIG_MACH_SUN6I) += \
766 sun6i-a31-app4-evb1.dtb \ 766 sun6i-a31-app4-evb1.dtb \
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 0d7d5ac6257b..2b6cb05bc01a 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -643,9 +643,8 @@
643 reg = <0x30730000 0x10000>; 643 reg = <0x30730000 0x10000>;
644 interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>; 644 interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
645 clocks = <&clks IMX7D_LCDIF_PIXEL_ROOT_CLK>, 645 clocks = <&clks IMX7D_LCDIF_PIXEL_ROOT_CLK>,
646 <&clks IMX7D_CLK_DUMMY>, 646 <&clks IMX7D_LCDIF_PIXEL_ROOT_CLK>;
647 <&clks IMX7D_CLK_DUMMY>; 647 clock-names = "pix", "axi";
648 clock-names = "pix", "axi", "disp_axi";
649 status = "disabled"; 648 status = "disabled";
650 }; 649 };
651 }; 650 };
diff --git a/arch/arm/boot/dts/orion5x-linkstation-lsgl.dts b/arch/arm/boot/dts/orion5x-linkstation-lsgl.dts
index 1cf644bfd7ea..51dc734cd5b9 100644
--- a/arch/arm/boot/dts/orion5x-linkstation-lsgl.dts
+++ b/arch/arm/boot/dts/orion5x-linkstation-lsgl.dts
@@ -82,6 +82,10 @@
82 gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; 82 gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
83}; 83};
84 84
85&sata {
86 nr-ports = <2>;
87};
88
85&ehci1 { 89&ehci1 {
86 status = "okay"; 90 status = "okay";
87}; 91};
diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
index 91096a49efa9..8f79b4147bba 100644
--- a/arch/arm/boot/dts/stih407-family.dtsi
+++ b/arch/arm/boot/dts/stih407-family.dtsi
@@ -283,6 +283,8 @@
283 clock-frequency = <400000>; 283 clock-frequency = <400000>;
284 pinctrl-names = "default"; 284 pinctrl-names = "default";
285 pinctrl-0 = <&pinctrl_i2c0_default>; 285 pinctrl-0 = <&pinctrl_i2c0_default>;
286 #address-cells = <1>;
287 #size-cells = <0>;
286 288
287 status = "disabled"; 289 status = "disabled";
288 }; 290 };
@@ -296,6 +298,8 @@
296 clock-frequency = <400000>; 298 clock-frequency = <400000>;
297 pinctrl-names = "default"; 299 pinctrl-names = "default";
298 pinctrl-0 = <&pinctrl_i2c1_default>; 300 pinctrl-0 = <&pinctrl_i2c1_default>;
301 #address-cells = <1>;
302 #size-cells = <0>;
299 303
300 status = "disabled"; 304 status = "disabled";
301 }; 305 };
@@ -309,6 +313,8 @@
309 clock-frequency = <400000>; 313 clock-frequency = <400000>;
310 pinctrl-names = "default"; 314 pinctrl-names = "default";
311 pinctrl-0 = <&pinctrl_i2c2_default>; 315 pinctrl-0 = <&pinctrl_i2c2_default>;
316 #address-cells = <1>;
317 #size-cells = <0>;
312 318
313 status = "disabled"; 319 status = "disabled";
314 }; 320 };
@@ -322,6 +328,8 @@
322 clock-frequency = <400000>; 328 clock-frequency = <400000>;
323 pinctrl-names = "default"; 329 pinctrl-names = "default";
324 pinctrl-0 = <&pinctrl_i2c3_default>; 330 pinctrl-0 = <&pinctrl_i2c3_default>;
331 #address-cells = <1>;
332 #size-cells = <0>;
325 333
326 status = "disabled"; 334 status = "disabled";
327 }; 335 };
@@ -335,6 +343,8 @@
335 clock-frequency = <400000>; 343 clock-frequency = <400000>;
336 pinctrl-names = "default"; 344 pinctrl-names = "default";
337 pinctrl-0 = <&pinctrl_i2c4_default>; 345 pinctrl-0 = <&pinctrl_i2c4_default>;
346 #address-cells = <1>;
347 #size-cells = <0>;
338 348
339 status = "disabled"; 349 status = "disabled";
340 }; 350 };
@@ -348,6 +358,8 @@
348 clock-frequency = <400000>; 358 clock-frequency = <400000>;
349 pinctrl-names = "default"; 359 pinctrl-names = "default";
350 pinctrl-0 = <&pinctrl_i2c5_default>; 360 pinctrl-0 = <&pinctrl_i2c5_default>;
361 #address-cells = <1>;
362 #size-cells = <0>;
351 363
352 status = "disabled"; 364 status = "disabled";
353 }; 365 };
@@ -363,6 +375,8 @@
363 clock-frequency = <400000>; 375 clock-frequency = <400000>;
364 pinctrl-names = "default"; 376 pinctrl-names = "default";
365 pinctrl-0 = <&pinctrl_i2c10_default>; 377 pinctrl-0 = <&pinctrl_i2c10_default>;
378 #address-cells = <1>;
379 #size-cells = <0>;
366 380
367 status = "disabled"; 381 status = "disabled";
368 }; 382 };
@@ -376,6 +390,8 @@
376 clock-frequency = <400000>; 390 clock-frequency = <400000>;
377 pinctrl-names = "default"; 391 pinctrl-names = "default";
378 pinctrl-0 = <&pinctrl_i2c11_default>; 392 pinctrl-0 = <&pinctrl_i2c11_default>;
393 #address-cells = <1>;
394 #size-cells = <0>;
379 395
380 status = "disabled"; 396 status = "disabled";
381 }; 397 };
diff --git a/arch/arm/boot/dts/ntc-gr8-evb.dts b/arch/arm/boot/dts/sun5i-gr8-evb.dts
index 4b622f3b5220..714381fd64d7 100644
--- a/arch/arm/boot/dts/ntc-gr8-evb.dts
+++ b/arch/arm/boot/dts/sun5i-gr8-evb.dts
@@ -44,7 +44,7 @@
44 */ 44 */
45 45
46/dts-v1/; 46/dts-v1/;
47#include "ntc-gr8.dtsi" 47#include "sun5i-gr8.dtsi"
48#include "sunxi-common-regulators.dtsi" 48#include "sunxi-common-regulators.dtsi"
49 49
50#include <dt-bindings/gpio/gpio.h> 50#include <dt-bindings/gpio/gpio.h>
diff --git a/arch/arm/boot/dts/ntc-gr8.dtsi b/arch/arm/boot/dts/sun5i-gr8.dtsi
index ca54e03ef366..ca54e03ef366 100644
--- a/arch/arm/boot/dts/ntc-gr8.dtsi
+++ b/arch/arm/boot/dts/sun5i-gr8.dtsi
diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
index 75a865406d3e..f4ba088b225e 100644
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
@@ -410,7 +410,7 @@
410 }; 410 };
411 411
412 uart3_pins: uart3 { 412 uart3_pins: uart3 {
413 allwinner,pins = "PG13", "PG14"; 413 allwinner,pins = "PA13", "PA14";
414 allwinner,function = "uart3"; 414 allwinner,function = "uart3";
415 allwinner,drive = <SUN4I_PINCTRL_10_MA>; 415 allwinner,drive = <SUN4I_PINCTRL_10_MA>;
416 allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; 416 allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 0745538b26d3..55e0e3ea9cb6 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -8,7 +8,6 @@ generic-y += early_ioremap.h
8generic-y += emergency-restart.h 8generic-y += emergency-restart.h
9generic-y += errno.h 9generic-y += errno.h
10generic-y += exec.h 10generic-y += exec.h
11generic-y += export.h
12generic-y += ioctl.h 11generic-y += ioctl.h
13generic-y += ipcbuf.h 12generic-y += ipcbuf.h
14generic-y += irq_regs.h 13generic-y += irq_regs.h
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 68c2c097cffe..ad325a8c7e1e 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -33,7 +33,7 @@ endif
33obj-$(CONFIG_CPU_IDLE) += cpuidle.o 33obj-$(CONFIG_CPU_IDLE) += cpuidle.o
34obj-$(CONFIG_ISA_DMA_API) += dma.o 34obj-$(CONFIG_ISA_DMA_API) += dma.o
35obj-$(CONFIG_FIQ) += fiq.o fiqasm.o 35obj-$(CONFIG_FIQ) += fiq.o fiqasm.o
36obj-$(CONFIG_MODULES) += module.o 36obj-$(CONFIG_MODULES) += armksyms.o module.o
37obj-$(CONFIG_ARM_MODULE_PLTS) += module-plts.o 37obj-$(CONFIG_ARM_MODULE_PLTS) += module-plts.o
38obj-$(CONFIG_ISA_DMA) += dma-isa.o 38obj-$(CONFIG_ISA_DMA) += dma-isa.o
39obj-$(CONFIG_PCI) += bios32.o isa.o 39obj-$(CONFIG_PCI) += bios32.o isa.o
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
new file mode 100644
index 000000000000..7e45f69a0ddc
--- /dev/null
+++ b/arch/arm/kernel/armksyms.c
@@ -0,0 +1,183 @@
1/*
2 * linux/arch/arm/kernel/armksyms.c
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/export.h>
11#include <linux/sched.h>
12#include <linux/string.h>
13#include <linux/cryptohash.h>
14#include <linux/delay.h>
15#include <linux/in6.h>
16#include <linux/syscalls.h>
17#include <linux/uaccess.h>
18#include <linux/io.h>
19#include <linux/arm-smccc.h>
20
21#include <asm/checksum.h>
22#include <asm/ftrace.h>
23
24/*
25 * libgcc functions - functions that are used internally by the
26 * compiler... (prototypes are not correct though, but that
27 * doesn't really matter since they're not versioned).
28 */
29extern void __ashldi3(void);
30extern void __ashrdi3(void);
31extern void __divsi3(void);
32extern void __lshrdi3(void);
33extern void __modsi3(void);
34extern void __muldi3(void);
35extern void __ucmpdi2(void);
36extern void __udivsi3(void);
37extern void __umodsi3(void);
38extern void __do_div64(void);
39extern void __bswapsi2(void);
40extern void __bswapdi2(void);
41
42extern void __aeabi_idiv(void);
43extern void __aeabi_idivmod(void);
44extern void __aeabi_lasr(void);
45extern void __aeabi_llsl(void);
46extern void __aeabi_llsr(void);
47extern void __aeabi_lmul(void);
48extern void __aeabi_uidiv(void);
49extern void __aeabi_uidivmod(void);
50extern void __aeabi_ulcmp(void);
51
52extern void fpundefinstr(void);
53
54void mmioset(void *, unsigned int, size_t);
55void mmiocpy(void *, const void *, size_t);
56
57 /* platform dependent support */
58EXPORT_SYMBOL(arm_delay_ops);
59
60 /* networking */
61EXPORT_SYMBOL(csum_partial);
62EXPORT_SYMBOL(csum_partial_copy_from_user);
63EXPORT_SYMBOL(csum_partial_copy_nocheck);
64EXPORT_SYMBOL(__csum_ipv6_magic);
65
66 /* io */
67#ifndef __raw_readsb
68EXPORT_SYMBOL(__raw_readsb);
69#endif
70#ifndef __raw_readsw
71EXPORT_SYMBOL(__raw_readsw);
72#endif
73#ifndef __raw_readsl
74EXPORT_SYMBOL(__raw_readsl);
75#endif
76#ifndef __raw_writesb
77EXPORT_SYMBOL(__raw_writesb);
78#endif
79#ifndef __raw_writesw
80EXPORT_SYMBOL(__raw_writesw);
81#endif
82#ifndef __raw_writesl
83EXPORT_SYMBOL(__raw_writesl);
84#endif
85
86 /* string / mem functions */
87EXPORT_SYMBOL(strchr);
88EXPORT_SYMBOL(strrchr);
89EXPORT_SYMBOL(memset);
90EXPORT_SYMBOL(memcpy);
91EXPORT_SYMBOL(memmove);
92EXPORT_SYMBOL(memchr);
93EXPORT_SYMBOL(__memzero);
94
95EXPORT_SYMBOL(mmioset);
96EXPORT_SYMBOL(mmiocpy);
97
98#ifdef CONFIG_MMU
99EXPORT_SYMBOL(copy_page);
100
101EXPORT_SYMBOL(arm_copy_from_user);
102EXPORT_SYMBOL(arm_copy_to_user);
103EXPORT_SYMBOL(arm_clear_user);
104
105EXPORT_SYMBOL(__get_user_1);
106EXPORT_SYMBOL(__get_user_2);
107EXPORT_SYMBOL(__get_user_4);
108EXPORT_SYMBOL(__get_user_8);
109
110#ifdef __ARMEB__
111EXPORT_SYMBOL(__get_user_64t_1);
112EXPORT_SYMBOL(__get_user_64t_2);
113EXPORT_SYMBOL(__get_user_64t_4);
114EXPORT_SYMBOL(__get_user_32t_8);
115#endif
116
117EXPORT_SYMBOL(__put_user_1);
118EXPORT_SYMBOL(__put_user_2);
119EXPORT_SYMBOL(__put_user_4);
120EXPORT_SYMBOL(__put_user_8);
121#endif
122
123 /* gcc lib functions */
124EXPORT_SYMBOL(__ashldi3);
125EXPORT_SYMBOL(__ashrdi3);
126EXPORT_SYMBOL(__divsi3);
127EXPORT_SYMBOL(__lshrdi3);
128EXPORT_SYMBOL(__modsi3);
129EXPORT_SYMBOL(__muldi3);
130EXPORT_SYMBOL(__ucmpdi2);
131EXPORT_SYMBOL(__udivsi3);
132EXPORT_SYMBOL(__umodsi3);
133EXPORT_SYMBOL(__do_div64);
134EXPORT_SYMBOL(__bswapsi2);
135EXPORT_SYMBOL(__bswapdi2);
136
137#ifdef CONFIG_AEABI
138EXPORT_SYMBOL(__aeabi_idiv);
139EXPORT_SYMBOL(__aeabi_idivmod);
140EXPORT_SYMBOL(__aeabi_lasr);
141EXPORT_SYMBOL(__aeabi_llsl);
142EXPORT_SYMBOL(__aeabi_llsr);
143EXPORT_SYMBOL(__aeabi_lmul);
144EXPORT_SYMBOL(__aeabi_uidiv);
145EXPORT_SYMBOL(__aeabi_uidivmod);
146EXPORT_SYMBOL(__aeabi_ulcmp);
147#endif
148
149 /* bitops */
150EXPORT_SYMBOL(_set_bit);
151EXPORT_SYMBOL(_test_and_set_bit);
152EXPORT_SYMBOL(_clear_bit);
153EXPORT_SYMBOL(_test_and_clear_bit);
154EXPORT_SYMBOL(_change_bit);
155EXPORT_SYMBOL(_test_and_change_bit);
156EXPORT_SYMBOL(_find_first_zero_bit_le);
157EXPORT_SYMBOL(_find_next_zero_bit_le);
158EXPORT_SYMBOL(_find_first_bit_le);
159EXPORT_SYMBOL(_find_next_bit_le);
160
161#ifdef __ARMEB__
162EXPORT_SYMBOL(_find_first_zero_bit_be);
163EXPORT_SYMBOL(_find_next_zero_bit_be);
164EXPORT_SYMBOL(_find_first_bit_be);
165EXPORT_SYMBOL(_find_next_bit_be);
166#endif
167
168#ifdef CONFIG_FUNCTION_TRACER
169#ifdef CONFIG_OLD_MCOUNT
170EXPORT_SYMBOL(mcount);
171#endif
172EXPORT_SYMBOL(__gnu_mcount_nc);
173#endif
174
175#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
176EXPORT_SYMBOL(__pv_phys_pfn_offset);
177EXPORT_SYMBOL(__pv_offset);
178#endif
179
180#ifdef CONFIG_HAVE_ARM_SMCCC
181EXPORT_SYMBOL(arm_smccc_smc);
182EXPORT_SYMBOL(arm_smccc_hvc);
183#endif
diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S
index b629d3f11c3d..c73c4030ca5d 100644
--- a/arch/arm/kernel/entry-ftrace.S
+++ b/arch/arm/kernel/entry-ftrace.S
@@ -7,7 +7,6 @@
7#include <asm/assembler.h> 7#include <asm/assembler.h>
8#include <asm/ftrace.h> 8#include <asm/ftrace.h>
9#include <asm/unwind.h> 9#include <asm/unwind.h>
10#include <asm/export.h>
11 10
12#include "entry-header.S" 11#include "entry-header.S"
13 12
@@ -154,7 +153,6 @@ ENTRY(mcount)
154 __mcount _old 153 __mcount _old
155#endif 154#endif
156ENDPROC(mcount) 155ENDPROC(mcount)
157EXPORT_SYMBOL(mcount)
158 156
159#ifdef CONFIG_DYNAMIC_FTRACE 157#ifdef CONFIG_DYNAMIC_FTRACE
160ENTRY(ftrace_caller_old) 158ENTRY(ftrace_caller_old)
@@ -207,7 +205,6 @@ UNWIND(.fnstart)
207#endif 205#endif
208UNWIND(.fnend) 206UNWIND(.fnend)
209ENDPROC(__gnu_mcount_nc) 207ENDPROC(__gnu_mcount_nc)
210EXPORT_SYMBOL(__gnu_mcount_nc)
211 208
212#ifdef CONFIG_DYNAMIC_FTRACE 209#ifdef CONFIG_DYNAMIC_FTRACE
213ENTRY(ftrace_caller) 210ENTRY(ftrace_caller)
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index f41cee4c5746..04286fd9e09c 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -22,7 +22,6 @@
22#include <asm/memory.h> 22#include <asm/memory.h>
23#include <asm/thread_info.h> 23#include <asm/thread_info.h>
24#include <asm/pgtable.h> 24#include <asm/pgtable.h>
25#include <asm/export.h>
26 25
27#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_SEMIHOSTING) 26#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_SEMIHOSTING)
28#include CONFIG_DEBUG_LL_INCLUDE 27#include CONFIG_DEBUG_LL_INCLUDE
@@ -728,8 +727,6 @@ __pv_phys_pfn_offset:
728__pv_offset: 727__pv_offset:
729 .quad 0 728 .quad 0
730 .size __pv_offset, . -__pv_offset 729 .size __pv_offset, . -__pv_offset
731EXPORT_SYMBOL(__pv_phys_pfn_offset)
732EXPORT_SYMBOL(__pv_offset)
733#endif 730#endif
734 731
735#include "head-common.S" 732#include "head-common.S"
diff --git a/arch/arm/kernel/smccc-call.S b/arch/arm/kernel/smccc-call.S
index 37669e7e13af..2e48b674aab1 100644
--- a/arch/arm/kernel/smccc-call.S
+++ b/arch/arm/kernel/smccc-call.S
@@ -16,7 +16,6 @@
16#include <asm/opcodes-sec.h> 16#include <asm/opcodes-sec.h>
17#include <asm/opcodes-virt.h> 17#include <asm/opcodes-virt.h>
18#include <asm/unwind.h> 18#include <asm/unwind.h>
19#include <asm/export.h>
20 19
21 /* 20 /*
22 * Wrap c macros in asm macros to delay expansion until after the 21 * Wrap c macros in asm macros to delay expansion until after the
@@ -52,7 +51,6 @@ UNWIND( .fnend)
52ENTRY(arm_smccc_smc) 51ENTRY(arm_smccc_smc)
53 SMCCC SMCCC_SMC 52 SMCCC SMCCC_SMC
54ENDPROC(arm_smccc_smc) 53ENDPROC(arm_smccc_smc)
55EXPORT_SYMBOL(arm_smccc_smc)
56 54
57/* 55/*
58 * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, 56 * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
@@ -62,4 +60,3 @@ EXPORT_SYMBOL(arm_smccc_smc)
62ENTRY(arm_smccc_hvc) 60ENTRY(arm_smccc_hvc)
63 SMCCC SMCCC_HVC 61 SMCCC SMCCC_HVC
64ENDPROC(arm_smccc_hvc) 62ENDPROC(arm_smccc_hvc)
65EXPORT_SYMBOL(arm_smccc_hvc)
diff --git a/arch/arm/lib/ashldi3.S b/arch/arm/lib/ashldi3.S
index a7e7de89bd75..b05e95840651 100644
--- a/arch/arm/lib/ashldi3.S
+++ b/arch/arm/lib/ashldi3.S
@@ -28,7 +28,6 @@ Boston, MA 02110-1301, USA. */
28 28
29#include <linux/linkage.h> 29#include <linux/linkage.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/export.h>
32 31
33#ifdef __ARMEB__ 32#ifdef __ARMEB__
34#define al r1 33#define al r1
@@ -53,5 +52,3 @@ ENTRY(__aeabi_llsl)
53 52
54ENDPROC(__ashldi3) 53ENDPROC(__ashldi3)
55ENDPROC(__aeabi_llsl) 54ENDPROC(__aeabi_llsl)
56EXPORT_SYMBOL(__ashldi3)
57EXPORT_SYMBOL(__aeabi_llsl)
diff --git a/arch/arm/lib/ashrdi3.S b/arch/arm/lib/ashrdi3.S
index 490336e42518..275d7d2341a4 100644
--- a/arch/arm/lib/ashrdi3.S
+++ b/arch/arm/lib/ashrdi3.S
@@ -28,7 +28,6 @@ Boston, MA 02110-1301, USA. */
28 28
29#include <linux/linkage.h> 29#include <linux/linkage.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/export.h>
32 31
33#ifdef __ARMEB__ 32#ifdef __ARMEB__
34#define al r1 33#define al r1
@@ -53,5 +52,3 @@ ENTRY(__aeabi_lasr)
53 52
54ENDPROC(__ashrdi3) 53ENDPROC(__ashrdi3)
55ENDPROC(__aeabi_lasr) 54ENDPROC(__aeabi_lasr)
56EXPORT_SYMBOL(__ashrdi3)
57EXPORT_SYMBOL(__aeabi_lasr)
diff --git a/arch/arm/lib/bitops.h b/arch/arm/lib/bitops.h
index df06638b327c..7d807cfd8ef5 100644
--- a/arch/arm/lib/bitops.h
+++ b/arch/arm/lib/bitops.h
@@ -1,6 +1,5 @@
1#include <asm/assembler.h> 1#include <asm/assembler.h>
2#include <asm/unwind.h> 2#include <asm/unwind.h>
3#include <asm/export.h>
4 3
5#if __LINUX_ARM_ARCH__ >= 6 4#if __LINUX_ARM_ARCH__ >= 6
6 .macro bitop, name, instr 5 .macro bitop, name, instr
@@ -26,7 +25,6 @@ UNWIND( .fnstart )
26 bx lr 25 bx lr
27UNWIND( .fnend ) 26UNWIND( .fnend )
28ENDPROC(\name ) 27ENDPROC(\name )
29EXPORT_SYMBOL(\name )
30 .endm 28 .endm
31 29
32 .macro testop, name, instr, store 30 .macro testop, name, instr, store
@@ -57,7 +55,6 @@ UNWIND( .fnstart )
572: bx lr 552: bx lr
58UNWIND( .fnend ) 56UNWIND( .fnend )
59ENDPROC(\name ) 57ENDPROC(\name )
60EXPORT_SYMBOL(\name )
61 .endm 58 .endm
62#else 59#else
63 .macro bitop, name, instr 60 .macro bitop, name, instr
@@ -77,7 +74,6 @@ UNWIND( .fnstart )
77 ret lr 74 ret lr
78UNWIND( .fnend ) 75UNWIND( .fnend )
79ENDPROC(\name ) 76ENDPROC(\name )
80EXPORT_SYMBOL(\name )
81 .endm 77 .endm
82 78
83/** 79/**
@@ -106,6 +102,5 @@ UNWIND( .fnstart )
106 ret lr 102 ret lr
107UNWIND( .fnend ) 103UNWIND( .fnend )
108ENDPROC(\name ) 104ENDPROC(\name )
109EXPORT_SYMBOL(\name )
110 .endm 105 .endm
111#endif 106#endif
diff --git a/arch/arm/lib/bswapsdi2.S b/arch/arm/lib/bswapsdi2.S
index f05f78247304..07cda737bb11 100644
--- a/arch/arm/lib/bswapsdi2.S
+++ b/arch/arm/lib/bswapsdi2.S
@@ -1,6 +1,5 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/assembler.h> 2#include <asm/assembler.h>
3#include <asm/export.h>
4 3
5#if __LINUX_ARM_ARCH__ >= 6 4#if __LINUX_ARM_ARCH__ >= 6
6ENTRY(__bswapsi2) 5ENTRY(__bswapsi2)
@@ -36,5 +35,3 @@ ENTRY(__bswapdi2)
36 ret lr 35 ret lr
37ENDPROC(__bswapdi2) 36ENDPROC(__bswapdi2)
38#endif 37#endif
39EXPORT_SYMBOL(__bswapsi2)
40EXPORT_SYMBOL(__bswapdi2)
diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
index b566154f5cf4..e936352ccb00 100644
--- a/arch/arm/lib/clear_user.S
+++ b/arch/arm/lib/clear_user.S
@@ -10,7 +10,6 @@
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/unwind.h> 12#include <asm/unwind.h>
13#include <asm/export.h>
14 13
15 .text 14 .text
16 15
@@ -51,9 +50,6 @@ USER( strnebt r2, [r0])
51UNWIND(.fnend) 50UNWIND(.fnend)
52ENDPROC(arm_clear_user) 51ENDPROC(arm_clear_user)
53ENDPROC(__clear_user_std) 52ENDPROC(__clear_user_std)
54#ifndef CONFIG_UACCESS_WITH_MEMCPY
55EXPORT_SYMBOL(arm_clear_user)
56#endif
57 53
58 .pushsection .text.fixup,"ax" 54 .pushsection .text.fixup,"ax"
59 .align 0 55 .align 0
diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
index 63e4c1ed0225..7a4b06049001 100644
--- a/arch/arm/lib/copy_from_user.S
+++ b/arch/arm/lib/copy_from_user.S
@@ -13,7 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/unwind.h> 15#include <asm/unwind.h>
16#include <asm/export.h>
17 16
18/* 17/*
19 * Prototype: 18 * Prototype:
@@ -95,7 +94,6 @@ ENTRY(arm_copy_from_user)
95#include "copy_template.S" 94#include "copy_template.S"
96 95
97ENDPROC(arm_copy_from_user) 96ENDPROC(arm_copy_from_user)
98EXPORT_SYMBOL(arm_copy_from_user)
99 97
100 .pushsection .fixup,"ax" 98 .pushsection .fixup,"ax"
101 .align 0 99 .align 0
diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
index d97851d4af7a..6ee2f6706f86 100644
--- a/arch/arm/lib/copy_page.S
+++ b/arch/arm/lib/copy_page.S
@@ -13,7 +13,6 @@
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/cache.h> 15#include <asm/cache.h>
16#include <asm/export.h>
17 16
18#define COPY_COUNT (PAGE_SZ / (2 * L1_CACHE_BYTES) PLD( -1 )) 17#define COPY_COUNT (PAGE_SZ / (2 * L1_CACHE_BYTES) PLD( -1 ))
19 18
@@ -46,4 +45,3 @@ ENTRY(copy_page)
46 PLD( beq 2b ) 45 PLD( beq 2b )
47 ldmfd sp!, {r4, pc} @ 3 46 ldmfd sp!, {r4, pc} @ 3
48ENDPROC(copy_page) 47ENDPROC(copy_page)
49EXPORT_SYMBOL(copy_page)
diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
index 592c179112d1..caf5019d8161 100644
--- a/arch/arm/lib/copy_to_user.S
+++ b/arch/arm/lib/copy_to_user.S
@@ -13,7 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/unwind.h> 15#include <asm/unwind.h>
16#include <asm/export.h>
17 16
18/* 17/*
19 * Prototype: 18 * Prototype:
@@ -100,9 +99,6 @@ WEAK(arm_copy_to_user)
100 99
101ENDPROC(arm_copy_to_user) 100ENDPROC(arm_copy_to_user)
102ENDPROC(__copy_to_user_std) 101ENDPROC(__copy_to_user_std)
103#ifndef CONFIG_UACCESS_WITH_MEMCPY
104EXPORT_SYMBOL(arm_copy_to_user)
105#endif
106 102
107 .pushsection .text.fixup,"ax" 103 .pushsection .text.fixup,"ax"
108 .align 0 104 .align 0
diff --git a/arch/arm/lib/csumipv6.S b/arch/arm/lib/csumipv6.S
index 68603b5ee537..3ac6ef01bc43 100644
--- a/arch/arm/lib/csumipv6.S
+++ b/arch/arm/lib/csumipv6.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14 .text 13 .text
15 14
@@ -31,4 +30,4 @@ ENTRY(__csum_ipv6_magic)
31 adcs r0, r0, #0 30 adcs r0, r0, #0
32 ldmfd sp!, {pc} 31 ldmfd sp!, {pc}
33ENDPROC(__csum_ipv6_magic) 32ENDPROC(__csum_ipv6_magic)
34EXPORT_SYMBOL(__csum_ipv6_magic) 33
diff --git a/arch/arm/lib/csumpartial.S b/arch/arm/lib/csumpartial.S
index 830b20e81c37..984e0f29d548 100644
--- a/arch/arm/lib/csumpartial.S
+++ b/arch/arm/lib/csumpartial.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14 .text 13 .text
15 14
@@ -141,4 +140,3 @@ ENTRY(csum_partial)
141 bne 4b 140 bne 4b
142 b .Lless4 141 b .Lless4
143ENDPROC(csum_partial) 142ENDPROC(csum_partial)
144EXPORT_SYMBOL(csum_partial)
diff --git a/arch/arm/lib/csumpartialcopy.S b/arch/arm/lib/csumpartialcopy.S
index 9c3383fed129..d03fc71fc88c 100644
--- a/arch/arm/lib/csumpartialcopy.S
+++ b/arch/arm/lib/csumpartialcopy.S
@@ -49,6 +49,5 @@
49 49
50#define FN_ENTRY ENTRY(csum_partial_copy_nocheck) 50#define FN_ENTRY ENTRY(csum_partial_copy_nocheck)
51#define FN_EXIT ENDPROC(csum_partial_copy_nocheck) 51#define FN_EXIT ENDPROC(csum_partial_copy_nocheck)
52#define FN_EXPORT EXPORT_SYMBOL(csum_partial_copy_nocheck)
53 52
54#include "csumpartialcopygeneric.S" 53#include "csumpartialcopygeneric.S"
diff --git a/arch/arm/lib/csumpartialcopygeneric.S b/arch/arm/lib/csumpartialcopygeneric.S
index 8b94d20e51d1..10b45909610c 100644
--- a/arch/arm/lib/csumpartialcopygeneric.S
+++ b/arch/arm/lib/csumpartialcopygeneric.S
@@ -8,7 +8,6 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <asm/assembler.h> 10#include <asm/assembler.h>
11#include <asm/export.h>
12 11
13/* 12/*
14 * unsigned int 13 * unsigned int
@@ -332,4 +331,3 @@ FN_ENTRY
332 mov r5, r4, get_byte_1 331 mov r5, r4, get_byte_1
333 b .Lexit 332 b .Lexit
334FN_EXIT 333FN_EXIT
335FN_EXPORT
diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
index 5d495edf3d83..1712f132b80d 100644
--- a/arch/arm/lib/csumpartialcopyuser.S
+++ b/arch/arm/lib/csumpartialcopyuser.S
@@ -73,7 +73,6 @@
73 73
74#define FN_ENTRY ENTRY(csum_partial_copy_from_user) 74#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
75#define FN_EXIT ENDPROC(csum_partial_copy_from_user) 75#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
76#define FN_EXPORT EXPORT_SYMBOL(csum_partial_copy_from_user)
77 76
78#include "csumpartialcopygeneric.S" 77#include "csumpartialcopygeneric.S"
79 78
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 69aad80a3af4..2cef11884857 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/export.h>
28#include <linux/timex.h> 27#include <linux/timex.h>
29 28
30/* 29/*
@@ -35,7 +34,6 @@ struct arm_delay_ops arm_delay_ops __ro_after_init = {
35 .const_udelay = __loop_const_udelay, 34 .const_udelay = __loop_const_udelay,
36 .udelay = __loop_udelay, 35 .udelay = __loop_udelay,
37}; 36};
38EXPORT_SYMBOL(arm_delay_ops);
39 37
40static const struct delay_timer *delay_timer; 38static const struct delay_timer *delay_timer;
41static bool delay_calibrated; 39static bool delay_calibrated;
diff --git a/arch/arm/lib/div64.S b/arch/arm/lib/div64.S
index 0c9e1c18fc9e..a9eafe4981eb 100644
--- a/arch/arm/lib/div64.S
+++ b/arch/arm/lib/div64.S
@@ -15,7 +15,6 @@
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <asm/assembler.h> 16#include <asm/assembler.h>
17#include <asm/unwind.h> 17#include <asm/unwind.h>
18#include <asm/export.h>
19 18
20#ifdef __ARMEB__ 19#ifdef __ARMEB__
21#define xh r0 20#define xh r0
@@ -211,4 +210,3 @@ Ldiv0_64:
211 210
212UNWIND(.fnend) 211UNWIND(.fnend)
213ENDPROC(__do_div64) 212ENDPROC(__do_div64)
214EXPORT_SYMBOL(__do_div64)
diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
index 26302b8cd38f..7848780e8834 100644
--- a/arch/arm/lib/findbit.S
+++ b/arch/arm/lib/findbit.S
@@ -15,7 +15,6 @@
15 */ 15 */
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <asm/assembler.h> 17#include <asm/assembler.h>
18#include <asm/export.h>
19 .text 18 .text
20 19
21/* 20/*
@@ -38,7 +37,6 @@ ENTRY(_find_first_zero_bit_le)
383: mov r0, r1 @ no free bits 373: mov r0, r1 @ no free bits
39 ret lr 38 ret lr
40ENDPROC(_find_first_zero_bit_le) 39ENDPROC(_find_first_zero_bit_le)
41EXPORT_SYMBOL(_find_first_zero_bit_le)
42 40
43/* 41/*
44 * Purpose : Find next 'zero' bit 42 * Purpose : Find next 'zero' bit
@@ -59,7 +57,6 @@ ENTRY(_find_next_zero_bit_le)
59 add r2, r2, #1 @ align bit pointer 57 add r2, r2, #1 @ align bit pointer
60 b 2b @ loop for next bit 58 b 2b @ loop for next bit
61ENDPROC(_find_next_zero_bit_le) 59ENDPROC(_find_next_zero_bit_le)
62EXPORT_SYMBOL(_find_next_zero_bit_le)
63 60
64/* 61/*
65 * Purpose : Find a 'one' bit 62 * Purpose : Find a 'one' bit
@@ -81,7 +78,6 @@ ENTRY(_find_first_bit_le)
813: mov r0, r1 @ no free bits 783: mov r0, r1 @ no free bits
82 ret lr 79 ret lr
83ENDPROC(_find_first_bit_le) 80ENDPROC(_find_first_bit_le)
84EXPORT_SYMBOL(_find_first_bit_le)
85 81
86/* 82/*
87 * Purpose : Find next 'one' bit 83 * Purpose : Find next 'one' bit
@@ -101,7 +97,6 @@ ENTRY(_find_next_bit_le)
101 add r2, r2, #1 @ align bit pointer 97 add r2, r2, #1 @ align bit pointer
102 b 2b @ loop for next bit 98 b 2b @ loop for next bit
103ENDPROC(_find_next_bit_le) 99ENDPROC(_find_next_bit_le)
104EXPORT_SYMBOL(_find_next_bit_le)
105 100
106#ifdef __ARMEB__ 101#ifdef __ARMEB__
107 102
@@ -121,7 +116,6 @@ ENTRY(_find_first_zero_bit_be)
1213: mov r0, r1 @ no free bits 1163: mov r0, r1 @ no free bits
122 ret lr 117 ret lr
123ENDPROC(_find_first_zero_bit_be) 118ENDPROC(_find_first_zero_bit_be)
124EXPORT_SYMBOL(_find_first_zero_bit_be)
125 119
126ENTRY(_find_next_zero_bit_be) 120ENTRY(_find_next_zero_bit_be)
127 teq r1, #0 121 teq r1, #0
@@ -139,7 +133,6 @@ ENTRY(_find_next_zero_bit_be)
139 add r2, r2, #1 @ align bit pointer 133 add r2, r2, #1 @ align bit pointer
140 b 2b @ loop for next bit 134 b 2b @ loop for next bit
141ENDPROC(_find_next_zero_bit_be) 135ENDPROC(_find_next_zero_bit_be)
142EXPORT_SYMBOL(_find_next_zero_bit_be)
143 136
144ENTRY(_find_first_bit_be) 137ENTRY(_find_first_bit_be)
145 teq r1, #0 138 teq r1, #0
@@ -157,7 +150,6 @@ ENTRY(_find_first_bit_be)
1573: mov r0, r1 @ no free bits 1503: mov r0, r1 @ no free bits
158 ret lr 151 ret lr
159ENDPROC(_find_first_bit_be) 152ENDPROC(_find_first_bit_be)
160EXPORT_SYMBOL(_find_first_bit_be)
161 153
162ENTRY(_find_next_bit_be) 154ENTRY(_find_next_bit_be)
163 teq r1, #0 155 teq r1, #0
@@ -174,7 +166,6 @@ ENTRY(_find_next_bit_be)
174 add r2, r2, #1 @ align bit pointer 166 add r2, r2, #1 @ align bit pointer
175 b 2b @ loop for next bit 167 b 2b @ loop for next bit
176ENDPROC(_find_next_bit_be) 168ENDPROC(_find_next_bit_be)
177EXPORT_SYMBOL(_find_next_bit_be)
178 169
179#endif 170#endif
180 171
diff --git a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S
index 9d09a38e73af..8ecfd15c3a02 100644
--- a/arch/arm/lib/getuser.S
+++ b/arch/arm/lib/getuser.S
@@ -31,7 +31,6 @@
31#include <asm/assembler.h> 31#include <asm/assembler.h>
32#include <asm/errno.h> 32#include <asm/errno.h>
33#include <asm/domain.h> 33#include <asm/domain.h>
34#include <asm/export.h>
35 34
36ENTRY(__get_user_1) 35ENTRY(__get_user_1)
37 check_uaccess r0, 1, r1, r2, __get_user_bad 36 check_uaccess r0, 1, r1, r2, __get_user_bad
@@ -39,7 +38,6 @@ ENTRY(__get_user_1)
39 mov r0, #0 38 mov r0, #0
40 ret lr 39 ret lr
41ENDPROC(__get_user_1) 40ENDPROC(__get_user_1)
42EXPORT_SYMBOL(__get_user_1)
43 41
44ENTRY(__get_user_2) 42ENTRY(__get_user_2)
45 check_uaccess r0, 2, r1, r2, __get_user_bad 43 check_uaccess r0, 2, r1, r2, __get_user_bad
@@ -60,7 +58,6 @@ rb .req r0
60 mov r0, #0 58 mov r0, #0
61 ret lr 59 ret lr
62ENDPROC(__get_user_2) 60ENDPROC(__get_user_2)
63EXPORT_SYMBOL(__get_user_2)
64 61
65ENTRY(__get_user_4) 62ENTRY(__get_user_4)
66 check_uaccess r0, 4, r1, r2, __get_user_bad 63 check_uaccess r0, 4, r1, r2, __get_user_bad
@@ -68,7 +65,6 @@ ENTRY(__get_user_4)
68 mov r0, #0 65 mov r0, #0
69 ret lr 66 ret lr
70ENDPROC(__get_user_4) 67ENDPROC(__get_user_4)
71EXPORT_SYMBOL(__get_user_4)
72 68
73ENTRY(__get_user_8) 69ENTRY(__get_user_8)
74 check_uaccess r0, 8, r1, r2, __get_user_bad 70 check_uaccess r0, 8, r1, r2, __get_user_bad
@@ -82,7 +78,6 @@ ENTRY(__get_user_8)
82 mov r0, #0 78 mov r0, #0
83 ret lr 79 ret lr
84ENDPROC(__get_user_8) 80ENDPROC(__get_user_8)
85EXPORT_SYMBOL(__get_user_8)
86 81
87#ifdef __ARMEB__ 82#ifdef __ARMEB__
88ENTRY(__get_user_32t_8) 83ENTRY(__get_user_32t_8)
@@ -96,7 +91,6 @@ ENTRY(__get_user_32t_8)
96 mov r0, #0 91 mov r0, #0
97 ret lr 92 ret lr
98ENDPROC(__get_user_32t_8) 93ENDPROC(__get_user_32t_8)
99EXPORT_SYMBOL(__get_user_32t_8)
100 94
101ENTRY(__get_user_64t_1) 95ENTRY(__get_user_64t_1)
102 check_uaccess r0, 1, r1, r2, __get_user_bad8 96 check_uaccess r0, 1, r1, r2, __get_user_bad8
@@ -104,7 +98,6 @@ ENTRY(__get_user_64t_1)
104 mov r0, #0 98 mov r0, #0
105 ret lr 99 ret lr
106ENDPROC(__get_user_64t_1) 100ENDPROC(__get_user_64t_1)
107EXPORT_SYMBOL(__get_user_64t_1)
108 101
109ENTRY(__get_user_64t_2) 102ENTRY(__get_user_64t_2)
110 check_uaccess r0, 2, r1, r2, __get_user_bad8 103 check_uaccess r0, 2, r1, r2, __get_user_bad8
@@ -121,7 +114,6 @@ rb .req r0
121 mov r0, #0 114 mov r0, #0
122 ret lr 115 ret lr
123ENDPROC(__get_user_64t_2) 116ENDPROC(__get_user_64t_2)
124EXPORT_SYMBOL(__get_user_64t_2)
125 117
126ENTRY(__get_user_64t_4) 118ENTRY(__get_user_64t_4)
127 check_uaccess r0, 4, r1, r2, __get_user_bad8 119 check_uaccess r0, 4, r1, r2, __get_user_bad8
@@ -129,7 +121,6 @@ ENTRY(__get_user_64t_4)
129 mov r0, #0 121 mov r0, #0
130 ret lr 122 ret lr
131ENDPROC(__get_user_64t_4) 123ENDPROC(__get_user_64t_4)
132EXPORT_SYMBOL(__get_user_64t_4)
133#endif 124#endif
134 125
135__get_user_bad8: 126__get_user_bad8:
diff --git a/arch/arm/lib/io-readsb.S b/arch/arm/lib/io-readsb.S
index 3dff7a3a2aef..c31b2f3153f1 100644
--- a/arch/arm/lib/io-readsb.S
+++ b/arch/arm/lib/io-readsb.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14.Linsb_align: rsb ip, ip, #4 13.Linsb_align: rsb ip, ip, #4
15 cmp ip, r2 14 cmp ip, r2
@@ -122,4 +121,3 @@ ENTRY(__raw_readsb)
122 121
123 ldmfd sp!, {r4 - r6, pc} 122 ldmfd sp!, {r4 - r6, pc}
124ENDPROC(__raw_readsb) 123ENDPROC(__raw_readsb)
125EXPORT_SYMBOL(__raw_readsb)
diff --git a/arch/arm/lib/io-readsl.S b/arch/arm/lib/io-readsl.S
index bfd39682325b..2ed86fa5465f 100644
--- a/arch/arm/lib/io-readsl.S
+++ b/arch/arm/lib/io-readsl.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14ENTRY(__raw_readsl) 13ENTRY(__raw_readsl)
15 teq r2, #0 @ do we have to check for the zero len? 14 teq r2, #0 @ do we have to check for the zero len?
@@ -78,4 +77,3 @@ ENTRY(__raw_readsl)
78 strb r3, [r1, #0] 77 strb r3, [r1, #0]
79 ret lr 78 ret lr
80ENDPROC(__raw_readsl) 79ENDPROC(__raw_readsl)
81EXPORT_SYMBOL(__raw_readsl)
diff --git a/arch/arm/lib/io-readsw-armv3.S b/arch/arm/lib/io-readsw-armv3.S
index b3af3db6caac..413da9914529 100644
--- a/arch/arm/lib/io-readsw-armv3.S
+++ b/arch/arm/lib/io-readsw-armv3.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14.Linsw_bad_alignment: 13.Linsw_bad_alignment:
15 adr r0, .Linsw_bad_align_msg 14 adr r0, .Linsw_bad_align_msg
@@ -104,4 +103,4 @@ ENTRY(__raw_readsw)
104 103
105 ldmfd sp!, {r4, r5, r6, pc} 104 ldmfd sp!, {r4, r5, r6, pc}
106 105
107EXPORT_SYMBOL(__raw_readsw) 106
diff --git a/arch/arm/lib/io-readsw-armv4.S b/arch/arm/lib/io-readsw-armv4.S
index 3c7a7a40b33e..d9a45e9692ae 100644
--- a/arch/arm/lib/io-readsw-armv4.S
+++ b/arch/arm/lib/io-readsw-armv4.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14 .macro pack, rd, hw1, hw2 13 .macro pack, rd, hw1, hw2
15#ifndef __ARMEB__ 14#ifndef __ARMEB__
@@ -130,4 +129,3 @@ ENTRY(__raw_readsw)
130 strneb ip, [r1] 129 strneb ip, [r1]
131 ldmfd sp!, {r4, pc} 130 ldmfd sp!, {r4, pc}
132ENDPROC(__raw_readsw) 131ENDPROC(__raw_readsw)
133EXPORT_SYMBOL(__raw_readsw)
diff --git a/arch/arm/lib/io-writesb.S b/arch/arm/lib/io-writesb.S
index fa3633594415..a46bbc9b168b 100644
--- a/arch/arm/lib/io-writesb.S
+++ b/arch/arm/lib/io-writesb.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14 .macro outword, rd 13 .macro outword, rd
15#ifndef __ARMEB__ 14#ifndef __ARMEB__
@@ -93,4 +92,3 @@ ENTRY(__raw_writesb)
93 92
94 ldmfd sp!, {r4, r5, pc} 93 ldmfd sp!, {r4, r5, pc}
95ENDPROC(__raw_writesb) 94ENDPROC(__raw_writesb)
96EXPORT_SYMBOL(__raw_writesb)
diff --git a/arch/arm/lib/io-writesl.S b/arch/arm/lib/io-writesl.S
index 98ed6aec0b47..4ea2435988c1 100644
--- a/arch/arm/lib/io-writesl.S
+++ b/arch/arm/lib/io-writesl.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14ENTRY(__raw_writesl) 13ENTRY(__raw_writesl)
15 teq r2, #0 @ do we have to check for the zero len? 14 teq r2, #0 @ do we have to check for the zero len?
@@ -66,4 +65,3 @@ ENTRY(__raw_writesl)
66 bne 6b 65 bne 6b
67 ret lr 66 ret lr
68ENDPROC(__raw_writesl) 67ENDPROC(__raw_writesl)
69EXPORT_SYMBOL(__raw_writesl)
diff --git a/arch/arm/lib/io-writesw-armv3.S b/arch/arm/lib/io-writesw-armv3.S
index 577184c082bb..121789eb6802 100644
--- a/arch/arm/lib/io-writesw-armv3.S
+++ b/arch/arm/lib/io-writesw-armv3.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14.Loutsw_bad_alignment: 13.Loutsw_bad_alignment:
15 adr r0, .Loutsw_bad_align_msg 14 adr r0, .Loutsw_bad_align_msg
@@ -125,4 +124,3 @@ ENTRY(__raw_writesw)
125 strne ip, [r0] 124 strne ip, [r0]
126 125
127 ldmfd sp!, {r4, r5, r6, pc} 126 ldmfd sp!, {r4, r5, r6, pc}
128EXPORT_SYMBOL(__raw_writesw)
diff --git a/arch/arm/lib/io-writesw-armv4.S b/arch/arm/lib/io-writesw-armv4.S
index e335f489d1fc..269f90c51ad2 100644
--- a/arch/arm/lib/io-writesw-armv4.S
+++ b/arch/arm/lib/io-writesw-armv4.S
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/export.h>
13 12
14 .macro outword, rd 13 .macro outword, rd
15#ifndef __ARMEB__ 14#ifndef __ARMEB__
@@ -99,4 +98,3 @@ ENTRY(__raw_writesw)
99 strneh ip, [r0] 98 strneh ip, [r0]
100 ret lr 99 ret lr
101ENDPROC(__raw_writesw) 100ENDPROC(__raw_writesw)
102EXPORT_SYMBOL(__raw_writesw)
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index f541bc013bff..9397b2e532af 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -36,7 +36,6 @@ Boston, MA 02111-1307, USA. */
36#include <linux/linkage.h> 36#include <linux/linkage.h>
37#include <asm/assembler.h> 37#include <asm/assembler.h>
38#include <asm/unwind.h> 38#include <asm/unwind.h>
39#include <asm/export.h>
40 39
41.macro ARM_DIV_BODY dividend, divisor, result, curbit 40.macro ARM_DIV_BODY dividend, divisor, result, curbit
42 41
@@ -239,8 +238,6 @@ UNWIND(.fnstart)
239UNWIND(.fnend) 238UNWIND(.fnend)
240ENDPROC(__udivsi3) 239ENDPROC(__udivsi3)
241ENDPROC(__aeabi_uidiv) 240ENDPROC(__aeabi_uidiv)
242EXPORT_SYMBOL(__udivsi3)
243EXPORT_SYMBOL(__aeabi_uidiv)
244 241
245ENTRY(__umodsi3) 242ENTRY(__umodsi3)
246UNWIND(.fnstart) 243UNWIND(.fnstart)
@@ -259,7 +256,6 @@ UNWIND(.fnstart)
259 256
260UNWIND(.fnend) 257UNWIND(.fnend)
261ENDPROC(__umodsi3) 258ENDPROC(__umodsi3)
262EXPORT_SYMBOL(__umodsi3)
263 259
264#ifdef CONFIG_ARM_PATCH_IDIV 260#ifdef CONFIG_ARM_PATCH_IDIV
265 .align 3 261 .align 3
@@ -307,8 +303,6 @@ UNWIND(.fnstart)
307UNWIND(.fnend) 303UNWIND(.fnend)
308ENDPROC(__divsi3) 304ENDPROC(__divsi3)
309ENDPROC(__aeabi_idiv) 305ENDPROC(__aeabi_idiv)
310EXPORT_SYMBOL(__divsi3)
311EXPORT_SYMBOL(__aeabi_idiv)
312 306
313ENTRY(__modsi3) 307ENTRY(__modsi3)
314UNWIND(.fnstart) 308UNWIND(.fnstart)
@@ -333,7 +327,6 @@ UNWIND(.fnstart)
333 327
334UNWIND(.fnend) 328UNWIND(.fnend)
335ENDPROC(__modsi3) 329ENDPROC(__modsi3)
336EXPORT_SYMBOL(__modsi3)
337 330
338#ifdef CONFIG_AEABI 331#ifdef CONFIG_AEABI
339 332
@@ -350,7 +343,6 @@ UNWIND(.save {r0, r1, ip, lr} )
350 343
351UNWIND(.fnend) 344UNWIND(.fnend)
352ENDPROC(__aeabi_uidivmod) 345ENDPROC(__aeabi_uidivmod)
353EXPORT_SYMBOL(__aeabi_uidivmod)
354 346
355ENTRY(__aeabi_idivmod) 347ENTRY(__aeabi_idivmod)
356UNWIND(.fnstart) 348UNWIND(.fnstart)
@@ -364,7 +356,6 @@ UNWIND(.save {r0, r1, ip, lr} )
364 356
365UNWIND(.fnend) 357UNWIND(.fnend)
366ENDPROC(__aeabi_idivmod) 358ENDPROC(__aeabi_idivmod)
367EXPORT_SYMBOL(__aeabi_idivmod)
368 359
369#endif 360#endif
370 361
diff --git a/arch/arm/lib/lshrdi3.S b/arch/arm/lib/lshrdi3.S
index e40833981417..922dcd88b02b 100644
--- a/arch/arm/lib/lshrdi3.S
+++ b/arch/arm/lib/lshrdi3.S
@@ -28,7 +28,6 @@ Boston, MA 02110-1301, USA. */
28 28
29#include <linux/linkage.h> 29#include <linux/linkage.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/export.h>
32 31
33#ifdef __ARMEB__ 32#ifdef __ARMEB__
34#define al r1 33#define al r1
@@ -53,5 +52,3 @@ ENTRY(__aeabi_llsr)
53 52
54ENDPROC(__lshrdi3) 53ENDPROC(__lshrdi3)
55ENDPROC(__aeabi_llsr) 54ENDPROC(__aeabi_llsr)
56EXPORT_SYMBOL(__lshrdi3)
57EXPORT_SYMBOL(__aeabi_llsr)
diff --git a/arch/arm/lib/memchr.S b/arch/arm/lib/memchr.S
index 44182bf686a5..74a5bed6d999 100644
--- a/arch/arm/lib/memchr.S
+++ b/arch/arm/lib/memchr.S
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/export.h>
15 14
16 .text 15 .text
17 .align 5 16 .align 5
@@ -25,4 +24,3 @@ ENTRY(memchr)
252: movne r0, #0 242: movne r0, #0
26 ret lr 25 ret lr
27ENDPROC(memchr) 26ENDPROC(memchr)
28EXPORT_SYMBOL(memchr)
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index 1be5b6ddf37c..64111bd4440b 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -13,7 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/unwind.h> 15#include <asm/unwind.h>
16#include <asm/export.h>
17 16
18#define LDR1W_SHIFT 0 17#define LDR1W_SHIFT 0
19#define STR1W_SHIFT 0 18#define STR1W_SHIFT 0
@@ -69,5 +68,3 @@ ENTRY(memcpy)
69 68
70ENDPROC(memcpy) 69ENDPROC(memcpy)
71ENDPROC(mmiocpy) 70ENDPROC(mmiocpy)
72EXPORT_SYMBOL(memcpy)
73EXPORT_SYMBOL(mmiocpy)
diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S
index 71dcc5400d02..69a9d47fc5ab 100644
--- a/arch/arm/lib/memmove.S
+++ b/arch/arm/lib/memmove.S
@@ -13,7 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/unwind.h> 15#include <asm/unwind.h>
16#include <asm/export.h>
17 16
18 .text 17 .text
19 18
@@ -226,4 +225,3 @@ ENTRY(memmove)
22618: backward_copy_shift push=24 pull=8 22518: backward_copy_shift push=24 pull=8
227 226
228ENDPROC(memmove) 227ENDPROC(memmove)
229EXPORT_SYMBOL(memmove)
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 7b72044cba62..3c65e3bd790f 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -12,7 +12,6 @@
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/unwind.h> 14#include <asm/unwind.h>
15#include <asm/export.h>
16 15
17 .text 16 .text
18 .align 5 17 .align 5
@@ -136,5 +135,3 @@ UNWIND( .fnstart )
136UNWIND( .fnend ) 135UNWIND( .fnend )
137ENDPROC(memset) 136ENDPROC(memset)
138ENDPROC(mmioset) 137ENDPROC(mmioset)
139EXPORT_SYMBOL(memset)
140EXPORT_SYMBOL(mmioset)
diff --git a/arch/arm/lib/memzero.S b/arch/arm/lib/memzero.S
index 6dec26ed5bcc..0eded952e089 100644
--- a/arch/arm/lib/memzero.S
+++ b/arch/arm/lib/memzero.S
@@ -10,7 +10,6 @@
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/unwind.h> 12#include <asm/unwind.h>
13#include <asm/export.h>
14 13
15 .text 14 .text
16 .align 5 15 .align 5
@@ -136,4 +135,3 @@ UNWIND( .fnstart )
136 ret lr @ 1 135 ret lr @ 1
137UNWIND( .fnend ) 136UNWIND( .fnend )
138ENDPROC(__memzero) 137ENDPROC(__memzero)
139EXPORT_SYMBOL(__memzero)
diff --git a/arch/arm/lib/muldi3.S b/arch/arm/lib/muldi3.S
index b8f12388ccac..204305956925 100644
--- a/arch/arm/lib/muldi3.S
+++ b/arch/arm/lib/muldi3.S
@@ -12,7 +12,6 @@
12 12
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/export.h>
16 15
17#ifdef __ARMEB__ 16#ifdef __ARMEB__
18#define xh r0 17#define xh r0
@@ -47,5 +46,3 @@ ENTRY(__aeabi_lmul)
47 46
48ENDPROC(__muldi3) 47ENDPROC(__muldi3)
49ENDPROC(__aeabi_lmul) 48ENDPROC(__aeabi_lmul)
50EXPORT_SYMBOL(__muldi3)
51EXPORT_SYMBOL(__aeabi_lmul)
diff --git a/arch/arm/lib/putuser.S b/arch/arm/lib/putuser.S
index 11de126e2ed6..38d660d3705f 100644
--- a/arch/arm/lib/putuser.S
+++ b/arch/arm/lib/putuser.S
@@ -31,7 +31,6 @@
31#include <asm/assembler.h> 31#include <asm/assembler.h>
32#include <asm/errno.h> 32#include <asm/errno.h>
33#include <asm/domain.h> 33#include <asm/domain.h>
34#include <asm/export.h>
35 34
36ENTRY(__put_user_1) 35ENTRY(__put_user_1)
37 check_uaccess r0, 1, r1, ip, __put_user_bad 36 check_uaccess r0, 1, r1, ip, __put_user_bad
@@ -39,7 +38,6 @@ ENTRY(__put_user_1)
39 mov r0, #0 38 mov r0, #0
40 ret lr 39 ret lr
41ENDPROC(__put_user_1) 40ENDPROC(__put_user_1)
42EXPORT_SYMBOL(__put_user_1)
43 41
44ENTRY(__put_user_2) 42ENTRY(__put_user_2)
45 check_uaccess r0, 2, r1, ip, __put_user_bad 43 check_uaccess r0, 2, r1, ip, __put_user_bad
@@ -64,7 +62,6 @@ ENTRY(__put_user_2)
64 mov r0, #0 62 mov r0, #0
65 ret lr 63 ret lr
66ENDPROC(__put_user_2) 64ENDPROC(__put_user_2)
67EXPORT_SYMBOL(__put_user_2)
68 65
69ENTRY(__put_user_4) 66ENTRY(__put_user_4)
70 check_uaccess r0, 4, r1, ip, __put_user_bad 67 check_uaccess r0, 4, r1, ip, __put_user_bad
@@ -72,7 +69,6 @@ ENTRY(__put_user_4)
72 mov r0, #0 69 mov r0, #0
73 ret lr 70 ret lr
74ENDPROC(__put_user_4) 71ENDPROC(__put_user_4)
75EXPORT_SYMBOL(__put_user_4)
76 72
77ENTRY(__put_user_8) 73ENTRY(__put_user_8)
78 check_uaccess r0, 8, r1, ip, __put_user_bad 74 check_uaccess r0, 8, r1, ip, __put_user_bad
@@ -86,7 +82,6 @@ ENTRY(__put_user_8)
86 mov r0, #0 82 mov r0, #0
87 ret lr 83 ret lr
88ENDPROC(__put_user_8) 84ENDPROC(__put_user_8)
89EXPORT_SYMBOL(__put_user_8)
90 85
91__put_user_bad: 86__put_user_bad:
92 mov r0, #-EFAULT 87 mov r0, #-EFAULT
diff --git a/arch/arm/lib/strchr.S b/arch/arm/lib/strchr.S
index 7301f6e6046c..013d64c71e8d 100644
--- a/arch/arm/lib/strchr.S
+++ b/arch/arm/lib/strchr.S
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/export.h>
15 14
16 .text 15 .text
17 .align 5 16 .align 5
@@ -26,4 +25,3 @@ ENTRY(strchr)
26 subeq r0, r0, #1 25 subeq r0, r0, #1
27 ret lr 26 ret lr
28ENDPROC(strchr) 27ENDPROC(strchr)
29EXPORT_SYMBOL(strchr)
diff --git a/arch/arm/lib/strrchr.S b/arch/arm/lib/strrchr.S
index aaf9fd98b754..3cec1c7482c4 100644
--- a/arch/arm/lib/strrchr.S
+++ b/arch/arm/lib/strrchr.S
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/export.h>
15 14
16 .text 15 .text
17 .align 5 16 .align 5
@@ -25,4 +24,3 @@ ENTRY(strrchr)
25 mov r0, r3 24 mov r0, r3
26 ret lr 25 ret lr
27ENDPROC(strrchr) 26ENDPROC(strrchr)
28EXPORT_SYMBOL(strrchr)
diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
index 1626e3a551a1..6bd1089b07e0 100644
--- a/arch/arm/lib/uaccess_with_memcpy.c
+++ b/arch/arm/lib/uaccess_with_memcpy.c
@@ -19,7 +19,6 @@
19#include <linux/gfp.h> 19#include <linux/gfp.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/hugetlb.h> 21#include <linux/hugetlb.h>
22#include <linux/export.h>
23#include <asm/current.h> 22#include <asm/current.h>
24#include <asm/page.h> 23#include <asm/page.h>
25 24
@@ -157,7 +156,6 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n)
157 } 156 }
158 return n; 157 return n;
159} 158}
160EXPORT_SYMBOL(arm_copy_to_user);
161 159
162static unsigned long noinline 160static unsigned long noinline
163__clear_user_memset(void __user *addr, unsigned long n) 161__clear_user_memset(void __user *addr, unsigned long n)
@@ -215,7 +213,6 @@ unsigned long arm_clear_user(void __user *addr, unsigned long n)
215 } 213 }
216 return n; 214 return n;
217} 215}
218EXPORT_SYMBOL(arm_clear_user);
219 216
220#if 0 217#if 0
221 218
diff --git a/arch/arm/lib/ucmpdi2.S b/arch/arm/lib/ucmpdi2.S
index 127a91af46f3..ad4a6309141a 100644
--- a/arch/arm/lib/ucmpdi2.S
+++ b/arch/arm/lib/ucmpdi2.S
@@ -12,7 +12,6 @@
12 12
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/export.h>
16 15
17#ifdef __ARMEB__ 16#ifdef __ARMEB__
18#define xh r0 17#define xh r0
@@ -36,7 +35,6 @@ ENTRY(__ucmpdi2)
36 ret lr 35 ret lr
37 36
38ENDPROC(__ucmpdi2) 37ENDPROC(__ucmpdi2)
39EXPORT_SYMBOL(__ucmpdi2)
40 38
41#ifdef CONFIG_AEABI 39#ifdef CONFIG_AEABI
42 40
@@ -50,7 +48,6 @@ ENTRY(__aeabi_ulcmp)
50 ret lr 48 ret lr
51 49
52ENDPROC(__aeabi_ulcmp) 50ENDPROC(__aeabi_ulcmp)
53EXPORT_SYMBOL(__aeabi_ulcmp)
54 51
55#endif 52#endif
56 53
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 737450fe790c..cab128913e72 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -32,6 +32,7 @@ endif
32 32
33ifdef CONFIG_SND_IMX_SOC 33ifdef CONFIG_SND_IMX_SOC
34obj-y += ssi-fiq.o 34obj-y += ssi-fiq.o
35obj-y += ssi-fiq-ksym.o
35endif 36endif
36 37
37# i.MX21 based machines 38# i.MX21 based machines
diff --git a/arch/arm/mach-imx/ssi-fiq-ksym.c b/arch/arm/mach-imx/ssi-fiq-ksym.c
new file mode 100644
index 000000000000..792090f9a032
--- /dev/null
+++ b/arch/arm/mach-imx/ssi-fiq-ksym.c
@@ -0,0 +1,20 @@
1/*
2 * Exported ksyms for the SSI FIQ handler
3 *
4 * Copyright (C) 2009, Sascha Hauer <s.hauer@pengutronix.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12
13#include <linux/platform_data/asoc-imx-ssi.h>
14
15EXPORT_SYMBOL(imx_ssi_fiq_tx_buffer);
16EXPORT_SYMBOL(imx_ssi_fiq_rx_buffer);
17EXPORT_SYMBOL(imx_ssi_fiq_start);
18EXPORT_SYMBOL(imx_ssi_fiq_end);
19EXPORT_SYMBOL(imx_ssi_fiq_base);
20
diff --git a/arch/arm/mach-imx/ssi-fiq.S b/arch/arm/mach-imx/ssi-fiq.S
index fd7917f1c204..a8b93c5f29b5 100644
--- a/arch/arm/mach-imx/ssi-fiq.S
+++ b/arch/arm/mach-imx/ssi-fiq.S
@@ -8,7 +8,6 @@
8 8
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/assembler.h> 10#include <asm/assembler.h>
11#include <asm/export.h>
12 11
13/* 12/*
14 * r8 = bit 0-15: tx offset, bit 16-31: tx buffer size 13 * r8 = bit 0-15: tx offset, bit 16-31: tx buffer size
@@ -145,8 +144,4 @@ imx_ssi_fiq_tx_buffer:
145 .word 0x0 144 .word 0x0
146.L_imx_ssi_fiq_end: 145.L_imx_ssi_fiq_end:
147imx_ssi_fiq_end: 146imx_ssi_fiq_end:
148EXPORT_SYMBOL(imx_ssi_fiq_tx_buffer) 147
149EXPORT_SYMBOL(imx_ssi_fiq_rx_buffer)
150EXPORT_SYMBOL(imx_ssi_fiq_start)
151EXPORT_SYMBOL(imx_ssi_fiq_end)
152EXPORT_SYMBOL(imx_ssi_fiq_base)
diff --git a/arch/arm64/boot/dts/arm/juno-base.dtsi b/arch/arm64/boot/dts/arm/juno-base.dtsi
index 334271a25f70..7d3a2acc6a55 100644
--- a/arch/arm64/boot/dts/arm/juno-base.dtsi
+++ b/arch/arm64/boot/dts/arm/juno-base.dtsi
@@ -393,7 +393,7 @@
393 #address-cells = <3>; 393 #address-cells = <3>;
394 #size-cells = <2>; 394 #size-cells = <2>;
395 dma-coherent; 395 dma-coherent;
396 ranges = <0x01000000 0x00 0x5f800000 0x00 0x5f800000 0x0 0x00800000>, 396 ranges = <0x01000000 0x00 0x00000000 0x00 0x5f800000 0x0 0x00800000>,
397 <0x02000000 0x00 0x50000000 0x00 0x50000000 0x0 0x08000000>, 397 <0x02000000 0x00 0x50000000 0x00 0x50000000 0x0 0x08000000>,
398 <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>; 398 <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>;
399 #interrupt-cells = <1>; 399 #interrupt-cells = <1>;
diff --git a/arch/arm64/boot/dts/arm/juno-r1.dts b/arch/arm64/boot/dts/arm/juno-r1.dts
index 123a58b29cbd..f0b857d6d73c 100644
--- a/arch/arm64/boot/dts/arm/juno-r1.dts
+++ b/arch/arm64/boot/dts/arm/juno-r1.dts
@@ -76,7 +76,7 @@
76 compatible = "arm,idle-state"; 76 compatible = "arm,idle-state";
77 arm,psci-suspend-param = <0x1010000>; 77 arm,psci-suspend-param = <0x1010000>;
78 local-timer-stop; 78 local-timer-stop;
79 entry-latency-us = <300>; 79 entry-latency-us = <400>;
80 exit-latency-us = <1200>; 80 exit-latency-us = <1200>;
81 min-residency-us = <2500>; 81 min-residency-us = <2500>;
82 }; 82 };
diff --git a/arch/arm64/boot/dts/arm/juno-r2.dts b/arch/arm64/boot/dts/arm/juno-r2.dts
index 007be826efce..26aaa6a7670f 100644
--- a/arch/arm64/boot/dts/arm/juno-r2.dts
+++ b/arch/arm64/boot/dts/arm/juno-r2.dts
@@ -76,7 +76,7 @@
76 compatible = "arm,idle-state"; 76 compatible = "arm,idle-state";
77 arm,psci-suspend-param = <0x1010000>; 77 arm,psci-suspend-param = <0x1010000>;
78 local-timer-stop; 78 local-timer-stop;
79 entry-latency-us = <300>; 79 entry-latency-us = <400>;
80 exit-latency-us = <1200>; 80 exit-latency-us = <1200>;
81 min-residency-us = <2500>; 81 min-residency-us = <2500>;
82 }; 82 };
diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
index a7270eff6939..6e154d948a80 100644
--- a/arch/arm64/boot/dts/arm/juno.dts
+++ b/arch/arm64/boot/dts/arm/juno.dts
@@ -76,7 +76,7 @@
76 compatible = "arm,idle-state"; 76 compatible = "arm,idle-state";
77 arm,psci-suspend-param = <0x1010000>; 77 arm,psci-suspend-param = <0x1010000>;
78 local-timer-stop; 78 local-timer-stop;
79 entry-latency-us = <300>; 79 entry-latency-us = <400>;
80 exit-latency-us = <1200>; 80 exit-latency-us = <1200>;
81 min-residency-us = <2500>; 81 min-residency-us = <2500>;
82 }; 82 };
diff --git a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
index 55be7e3ff109..b98acd15ca22 100644
--- a/arch/m68k/configs/amiga_defconfig
+++ b/arch/m68k/configs/amiga_defconfig
@@ -95,9 +95,10 @@ CONFIG_NF_TABLES_INET=m
95CONFIG_NF_TABLES_NETDEV=m 95CONFIG_NF_TABLES_NETDEV=m
96CONFIG_NFT_EXTHDR=m 96CONFIG_NFT_EXTHDR=m
97CONFIG_NFT_META=m 97CONFIG_NFT_META=m
98CONFIG_NFT_NUMGEN=m
98CONFIG_NFT_CT=m 99CONFIG_NFT_CT=m
99CONFIG_NFT_RBTREE=m 100CONFIG_NFT_SET_RBTREE=m
100CONFIG_NFT_HASH=m 101CONFIG_NFT_SET_HASH=m
101CONFIG_NFT_COUNTER=m 102CONFIG_NFT_COUNTER=m
102CONFIG_NFT_LOG=m 103CONFIG_NFT_LOG=m
103CONFIG_NFT_LIMIT=m 104CONFIG_NFT_LIMIT=m
@@ -105,8 +106,10 @@ CONFIG_NFT_MASQ=m
105CONFIG_NFT_REDIR=m 106CONFIG_NFT_REDIR=m
106CONFIG_NFT_NAT=m 107CONFIG_NFT_NAT=m
107CONFIG_NFT_QUEUE=m 108CONFIG_NFT_QUEUE=m
109CONFIG_NFT_QUOTA=m
108CONFIG_NFT_REJECT=m 110CONFIG_NFT_REJECT=m
109CONFIG_NFT_COMPAT=m 111CONFIG_NFT_COMPAT=m
112CONFIG_NFT_HASH=m
110CONFIG_NFT_DUP_NETDEV=m 113CONFIG_NFT_DUP_NETDEV=m
111CONFIG_NFT_FWD_NETDEV=m 114CONFIG_NFT_FWD_NETDEV=m
112CONFIG_NETFILTER_XT_SET=m 115CONFIG_NETFILTER_XT_SET=m
@@ -366,6 +369,7 @@ CONFIG_NETCONSOLE=m
366CONFIG_NETCONSOLE_DYNAMIC=y 369CONFIG_NETCONSOLE_DYNAMIC=y
367CONFIG_VETH=m 370CONFIG_VETH=m
368# CONFIG_NET_VENDOR_3COM is not set 371# CONFIG_NET_VENDOR_3COM is not set
372# CONFIG_NET_VENDOR_AMAZON is not set
369CONFIG_A2065=y 373CONFIG_A2065=y
370CONFIG_ARIADNE=y 374CONFIG_ARIADNE=y
371# CONFIG_NET_VENDOR_ARC is not set 375# CONFIG_NET_VENDOR_ARC is not set
diff --git a/arch/m68k/configs/apollo_defconfig b/arch/m68k/configs/apollo_defconfig
index 365dda66b0e6..f80dc57e6374 100644
--- a/arch/m68k/configs/apollo_defconfig
+++ b/arch/m68k/configs/apollo_defconfig
@@ -93,9 +93,10 @@ CONFIG_NF_TABLES_INET=m
93CONFIG_NF_TABLES_NETDEV=m 93CONFIG_NF_TABLES_NETDEV=m
94CONFIG_NFT_EXTHDR=m 94CONFIG_NFT_EXTHDR=m
95CONFIG_NFT_META=m 95CONFIG_NFT_META=m
96CONFIG_NFT_NUMGEN=m
96CONFIG_NFT_CT=m 97CONFIG_NFT_CT=m
97CONFIG_NFT_RBTREE=m 98CONFIG_NFT_SET_RBTREE=m
98CONFIG_NFT_HASH=m 99CONFIG_NFT_SET_HASH=m
99CONFIG_NFT_COUNTER=m 100CONFIG_NFT_COUNTER=m
100CONFIG_NFT_LOG=m 101CONFIG_NFT_LOG=m
101CONFIG_NFT_LIMIT=m 102CONFIG_NFT_LIMIT=m
@@ -103,8 +104,10 @@ CONFIG_NFT_MASQ=m
103CONFIG_NFT_REDIR=m 104CONFIG_NFT_REDIR=m
104CONFIG_NFT_NAT=m 105CONFIG_NFT_NAT=m
105CONFIG_NFT_QUEUE=m 106CONFIG_NFT_QUEUE=m
107CONFIG_NFT_QUOTA=m
106CONFIG_NFT_REJECT=m 108CONFIG_NFT_REJECT=m
107CONFIG_NFT_COMPAT=m 109CONFIG_NFT_COMPAT=m
110CONFIG_NFT_HASH=m
108CONFIG_NFT_DUP_NETDEV=m 111CONFIG_NFT_DUP_NETDEV=m
109CONFIG_NFT_FWD_NETDEV=m 112CONFIG_NFT_FWD_NETDEV=m
110CONFIG_NETFILTER_XT_SET=m 113CONFIG_NETFILTER_XT_SET=m
@@ -347,6 +350,7 @@ CONFIG_MACSEC=m
347CONFIG_NETCONSOLE=m 350CONFIG_NETCONSOLE=m
348CONFIG_NETCONSOLE_DYNAMIC=y 351CONFIG_NETCONSOLE_DYNAMIC=y
349CONFIG_VETH=m 352CONFIG_VETH=m
353# CONFIG_NET_VENDOR_AMAZON is not set
350# CONFIG_NET_VENDOR_ARC is not set 354# CONFIG_NET_VENDOR_ARC is not set
351# CONFIG_NET_CADENCE is not set 355# CONFIG_NET_CADENCE is not set
352# CONFIG_NET_VENDOR_BROADCOM is not set 356# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/m68k/configs/atari_defconfig b/arch/m68k/configs/atari_defconfig
index ce3cbfd16fcd..4e16b1821fbb 100644
--- a/arch/m68k/configs/atari_defconfig
+++ b/arch/m68k/configs/atari_defconfig
@@ -93,9 +93,10 @@ CONFIG_NF_TABLES_INET=m
93CONFIG_NF_TABLES_NETDEV=m 93CONFIG_NF_TABLES_NETDEV=m
94CONFIG_NFT_EXTHDR=m 94CONFIG_NFT_EXTHDR=m
95CONFIG_NFT_META=m 95CONFIG_NFT_META=m
96CONFIG_NFT_NUMGEN=m
96CONFIG_NFT_CT=m 97CONFIG_NFT_CT=m
97CONFIG_NFT_RBTREE=m 98CONFIG_NFT_SET_RBTREE=m
98CONFIG_NFT_HASH=m 99CONFIG_NFT_SET_HASH=m
99CONFIG_NFT_COUNTER=m 100CONFIG_NFT_COUNTER=m
100CONFIG_NFT_LOG=m 101CONFIG_NFT_LOG=m
101CONFIG_NFT_LIMIT=m 102CONFIG_NFT_LIMIT=m
@@ -103,8 +104,10 @@ CONFIG_NFT_MASQ=m
103CONFIG_NFT_REDIR=m 104CONFIG_NFT_REDIR=m
104CONFIG_NFT_NAT=m 105CONFIG_NFT_NAT=m
105CONFIG_NFT_QUEUE=m 106CONFIG_NFT_QUEUE=m
107CONFIG_NFT_QUOTA=m
106CONFIG_NFT_REJECT=m 108CONFIG_NFT_REJECT=m
107CONFIG_NFT_COMPAT=m 109CONFIG_NFT_COMPAT=m
110CONFIG_NFT_HASH=m
108CONFIG_NFT_DUP_NETDEV=m 111CONFIG_NFT_DUP_NETDEV=m
109CONFIG_NFT_FWD_NETDEV=m 112CONFIG_NFT_FWD_NETDEV=m
110CONFIG_NETFILTER_XT_SET=m 113CONFIG_NETFILTER_XT_SET=m
@@ -356,6 +359,7 @@ CONFIG_MACSEC=m
356CONFIG_NETCONSOLE=m 359CONFIG_NETCONSOLE=m
357CONFIG_NETCONSOLE_DYNAMIC=y 360CONFIG_NETCONSOLE_DYNAMIC=y
358CONFIG_VETH=m 361CONFIG_VETH=m
362# CONFIG_NET_VENDOR_AMAZON is not set
359CONFIG_ATARILANCE=y 363CONFIG_ATARILANCE=y
360# CONFIG_NET_VENDOR_ARC is not set 364# CONFIG_NET_VENDOR_ARC is not set
361# CONFIG_NET_CADENCE is not set 365# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/bvme6000_defconfig b/arch/m68k/configs/bvme6000_defconfig
index 8db496a9797d..2767bbf5ad61 100644
--- a/arch/m68k/configs/bvme6000_defconfig
+++ b/arch/m68k/configs/bvme6000_defconfig
@@ -91,9 +91,10 @@ CONFIG_NF_TABLES_INET=m
91CONFIG_NF_TABLES_NETDEV=m 91CONFIG_NF_TABLES_NETDEV=m
92CONFIG_NFT_EXTHDR=m 92CONFIG_NFT_EXTHDR=m
93CONFIG_NFT_META=m 93CONFIG_NFT_META=m
94CONFIG_NFT_NUMGEN=m
94CONFIG_NFT_CT=m 95CONFIG_NFT_CT=m
95CONFIG_NFT_RBTREE=m 96CONFIG_NFT_SET_RBTREE=m
96CONFIG_NFT_HASH=m 97CONFIG_NFT_SET_HASH=m
97CONFIG_NFT_COUNTER=m 98CONFIG_NFT_COUNTER=m
98CONFIG_NFT_LOG=m 99CONFIG_NFT_LOG=m
99CONFIG_NFT_LIMIT=m 100CONFIG_NFT_LIMIT=m
@@ -101,8 +102,10 @@ CONFIG_NFT_MASQ=m
101CONFIG_NFT_REDIR=m 102CONFIG_NFT_REDIR=m
102CONFIG_NFT_NAT=m 103CONFIG_NFT_NAT=m
103CONFIG_NFT_QUEUE=m 104CONFIG_NFT_QUEUE=m
105CONFIG_NFT_QUOTA=m
104CONFIG_NFT_REJECT=m 106CONFIG_NFT_REJECT=m
105CONFIG_NFT_COMPAT=m 107CONFIG_NFT_COMPAT=m
108CONFIG_NFT_HASH=m
106CONFIG_NFT_DUP_NETDEV=m 109CONFIG_NFT_DUP_NETDEV=m
107CONFIG_NFT_FWD_NETDEV=m 110CONFIG_NFT_FWD_NETDEV=m
108CONFIG_NETFILTER_XT_SET=m 111CONFIG_NETFILTER_XT_SET=m
@@ -346,6 +349,7 @@ CONFIG_MACSEC=m
346CONFIG_NETCONSOLE=m 349CONFIG_NETCONSOLE=m
347CONFIG_NETCONSOLE_DYNAMIC=y 350CONFIG_NETCONSOLE_DYNAMIC=y
348CONFIG_VETH=m 351CONFIG_VETH=m
352# CONFIG_NET_VENDOR_AMAZON is not set
349# CONFIG_NET_VENDOR_ARC is not set 353# CONFIG_NET_VENDOR_ARC is not set
350# CONFIG_NET_CADENCE is not set 354# CONFIG_NET_CADENCE is not set
351# CONFIG_NET_VENDOR_BROADCOM is not set 355# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/m68k/configs/hp300_defconfig b/arch/m68k/configs/hp300_defconfig
index 8314156f7149..d13ba309265e 100644
--- a/arch/m68k/configs/hp300_defconfig
+++ b/arch/m68k/configs/hp300_defconfig
@@ -93,9 +93,10 @@ CONFIG_NF_TABLES_INET=m
93CONFIG_NF_TABLES_NETDEV=m 93CONFIG_NF_TABLES_NETDEV=m
94CONFIG_NFT_EXTHDR=m 94CONFIG_NFT_EXTHDR=m
95CONFIG_NFT_META=m 95CONFIG_NFT_META=m
96CONFIG_NFT_NUMGEN=m
96CONFIG_NFT_CT=m 97CONFIG_NFT_CT=m
97CONFIG_NFT_RBTREE=m 98CONFIG_NFT_SET_RBTREE=m
98CONFIG_NFT_HASH=m 99CONFIG_NFT_SET_HASH=m
99CONFIG_NFT_COUNTER=m 100CONFIG_NFT_COUNTER=m
100CONFIG_NFT_LOG=m 101CONFIG_NFT_LOG=m
101CONFIG_NFT_LIMIT=m 102CONFIG_NFT_LIMIT=m
@@ -103,8 +104,10 @@ CONFIG_NFT_MASQ=m
103CONFIG_NFT_REDIR=m 104CONFIG_NFT_REDIR=m
104CONFIG_NFT_NAT=m 105CONFIG_NFT_NAT=m
105CONFIG_NFT_QUEUE=m 106CONFIG_NFT_QUEUE=m
107CONFIG_NFT_QUOTA=m
106CONFIG_NFT_REJECT=m 108CONFIG_NFT_REJECT=m
107CONFIG_NFT_COMPAT=m 109CONFIG_NFT_COMPAT=m
110CONFIG_NFT_HASH=m
108CONFIG_NFT_DUP_NETDEV=m 111CONFIG_NFT_DUP_NETDEV=m
109CONFIG_NFT_FWD_NETDEV=m 112CONFIG_NFT_FWD_NETDEV=m
110CONFIG_NETFILTER_XT_SET=m 113CONFIG_NETFILTER_XT_SET=m
@@ -347,6 +350,7 @@ CONFIG_MACSEC=m
347CONFIG_NETCONSOLE=m 350CONFIG_NETCONSOLE=m
348CONFIG_NETCONSOLE_DYNAMIC=y 351CONFIG_NETCONSOLE_DYNAMIC=y
349CONFIG_VETH=m 352CONFIG_VETH=m
353# CONFIG_NET_VENDOR_AMAZON is not set
350CONFIG_HPLANCE=y 354CONFIG_HPLANCE=y
351# CONFIG_NET_VENDOR_ARC is not set 355# CONFIG_NET_VENDOR_ARC is not set
352# CONFIG_NET_CADENCE is not set 356# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
index 6600270b9622..78b5101c1aa6 100644
--- a/arch/m68k/configs/mac_defconfig
+++ b/arch/m68k/configs/mac_defconfig
@@ -92,9 +92,10 @@ CONFIG_NF_TABLES_INET=m
92CONFIG_NF_TABLES_NETDEV=m 92CONFIG_NF_TABLES_NETDEV=m
93CONFIG_NFT_EXTHDR=m 93CONFIG_NFT_EXTHDR=m
94CONFIG_NFT_META=m 94CONFIG_NFT_META=m
95CONFIG_NFT_NUMGEN=m
95CONFIG_NFT_CT=m 96CONFIG_NFT_CT=m
96CONFIG_NFT_RBTREE=m 97CONFIG_NFT_SET_RBTREE=m
97CONFIG_NFT_HASH=m 98CONFIG_NFT_SET_HASH=m
98CONFIG_NFT_COUNTER=m 99CONFIG_NFT_COUNTER=m
99CONFIG_NFT_LOG=m 100CONFIG_NFT_LOG=m
100CONFIG_NFT_LIMIT=m 101CONFIG_NFT_LIMIT=m
@@ -102,8 +103,10 @@ CONFIG_NFT_MASQ=m
102CONFIG_NFT_REDIR=m 103CONFIG_NFT_REDIR=m
103CONFIG_NFT_NAT=m 104CONFIG_NFT_NAT=m
104CONFIG_NFT_QUEUE=m 105CONFIG_NFT_QUEUE=m
106CONFIG_NFT_QUOTA=m
105CONFIG_NFT_REJECT=m 107CONFIG_NFT_REJECT=m
106CONFIG_NFT_COMPAT=m 108CONFIG_NFT_COMPAT=m
109CONFIG_NFT_HASH=m
107CONFIG_NFT_DUP_NETDEV=m 110CONFIG_NFT_DUP_NETDEV=m
108CONFIG_NFT_FWD_NETDEV=m 111CONFIG_NFT_FWD_NETDEV=m
109CONFIG_NETFILTER_XT_SET=m 112CONFIG_NETFILTER_XT_SET=m
@@ -363,6 +366,7 @@ CONFIG_MACSEC=m
363CONFIG_NETCONSOLE=m 366CONFIG_NETCONSOLE=m
364CONFIG_NETCONSOLE_DYNAMIC=y 367CONFIG_NETCONSOLE_DYNAMIC=y
365CONFIG_VETH=m 368CONFIG_VETH=m
369# CONFIG_NET_VENDOR_AMAZON is not set
366CONFIG_MACMACE=y 370CONFIG_MACMACE=y
367# CONFIG_NET_VENDOR_ARC is not set 371# CONFIG_NET_VENDOR_ARC is not set
368# CONFIG_NET_CADENCE is not set 372# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_defconfig
index 90abfe9eabba..38e5bcbd0d62 100644
--- a/arch/m68k/configs/multi_defconfig
+++ b/arch/m68k/configs/multi_defconfig
@@ -102,9 +102,10 @@ CONFIG_NF_TABLES_INET=m
102CONFIG_NF_TABLES_NETDEV=m 102CONFIG_NF_TABLES_NETDEV=m
103CONFIG_NFT_EXTHDR=m 103CONFIG_NFT_EXTHDR=m
104CONFIG_NFT_META=m 104CONFIG_NFT_META=m
105CONFIG_NFT_NUMGEN=m
105CONFIG_NFT_CT=m 106CONFIG_NFT_CT=m
106CONFIG_NFT_RBTREE=m 107CONFIG_NFT_SET_RBTREE=m
107CONFIG_NFT_HASH=m 108CONFIG_NFT_SET_HASH=m
108CONFIG_NFT_COUNTER=m 109CONFIG_NFT_COUNTER=m
109CONFIG_NFT_LOG=m 110CONFIG_NFT_LOG=m
110CONFIG_NFT_LIMIT=m 111CONFIG_NFT_LIMIT=m
@@ -112,8 +113,10 @@ CONFIG_NFT_MASQ=m
112CONFIG_NFT_REDIR=m 113CONFIG_NFT_REDIR=m
113CONFIG_NFT_NAT=m 114CONFIG_NFT_NAT=m
114CONFIG_NFT_QUEUE=m 115CONFIG_NFT_QUEUE=m
116CONFIG_NFT_QUOTA=m
115CONFIG_NFT_REJECT=m 117CONFIG_NFT_REJECT=m
116CONFIG_NFT_COMPAT=m 118CONFIG_NFT_COMPAT=m
119CONFIG_NFT_HASH=m
117CONFIG_NFT_DUP_NETDEV=m 120CONFIG_NFT_DUP_NETDEV=m
118CONFIG_NFT_FWD_NETDEV=m 121CONFIG_NFT_FWD_NETDEV=m
119CONFIG_NETFILTER_XT_SET=m 122CONFIG_NETFILTER_XT_SET=m
@@ -397,6 +400,7 @@ CONFIG_NETCONSOLE=m
397CONFIG_NETCONSOLE_DYNAMIC=y 400CONFIG_NETCONSOLE_DYNAMIC=y
398CONFIG_VETH=m 401CONFIG_VETH=m
399# CONFIG_NET_VENDOR_3COM is not set 402# CONFIG_NET_VENDOR_3COM is not set
403# CONFIG_NET_VENDOR_AMAZON is not set
400CONFIG_A2065=y 404CONFIG_A2065=y
401CONFIG_ARIADNE=y 405CONFIG_ARIADNE=y
402CONFIG_ATARILANCE=y 406CONFIG_ATARILANCE=y
diff --git a/arch/m68k/configs/mvme147_defconfig b/arch/m68k/configs/mvme147_defconfig
index 0d502c2f73d5..28687192b68e 100644
--- a/arch/m68k/configs/mvme147_defconfig
+++ b/arch/m68k/configs/mvme147_defconfig
@@ -90,9 +90,10 @@ CONFIG_NF_TABLES_INET=m
90CONFIG_NF_TABLES_NETDEV=m 90CONFIG_NF_TABLES_NETDEV=m
91CONFIG_NFT_EXTHDR=m 91CONFIG_NFT_EXTHDR=m
92CONFIG_NFT_META=m 92CONFIG_NFT_META=m
93CONFIG_NFT_NUMGEN=m
93CONFIG_NFT_CT=m 94CONFIG_NFT_CT=m
94CONFIG_NFT_RBTREE=m 95CONFIG_NFT_SET_RBTREE=m
95CONFIG_NFT_HASH=m 96CONFIG_NFT_SET_HASH=m
96CONFIG_NFT_COUNTER=m 97CONFIG_NFT_COUNTER=m
97CONFIG_NFT_LOG=m 98CONFIG_NFT_LOG=m
98CONFIG_NFT_LIMIT=m 99CONFIG_NFT_LIMIT=m
@@ -100,8 +101,10 @@ CONFIG_NFT_MASQ=m
100CONFIG_NFT_REDIR=m 101CONFIG_NFT_REDIR=m
101CONFIG_NFT_NAT=m 102CONFIG_NFT_NAT=m
102CONFIG_NFT_QUEUE=m 103CONFIG_NFT_QUEUE=m
104CONFIG_NFT_QUOTA=m
103CONFIG_NFT_REJECT=m 105CONFIG_NFT_REJECT=m
104CONFIG_NFT_COMPAT=m 106CONFIG_NFT_COMPAT=m
107CONFIG_NFT_HASH=m
105CONFIG_NFT_DUP_NETDEV=m 108CONFIG_NFT_DUP_NETDEV=m
106CONFIG_NFT_FWD_NETDEV=m 109CONFIG_NFT_FWD_NETDEV=m
107CONFIG_NETFILTER_XT_SET=m 110CONFIG_NETFILTER_XT_SET=m
@@ -345,6 +348,7 @@ CONFIG_MACSEC=m
345CONFIG_NETCONSOLE=m 348CONFIG_NETCONSOLE=m
346CONFIG_NETCONSOLE_DYNAMIC=y 349CONFIG_NETCONSOLE_DYNAMIC=y
347CONFIG_VETH=m 350CONFIG_VETH=m
351# CONFIG_NET_VENDOR_AMAZON is not set
348CONFIG_MVME147_NET=y 352CONFIG_MVME147_NET=y
349# CONFIG_NET_VENDOR_ARC is not set 353# CONFIG_NET_VENDOR_ARC is not set
350# CONFIG_NET_CADENCE is not set 354# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/mvme16x_defconfig b/arch/m68k/configs/mvme16x_defconfig
index 5930e91fc710..5a5f109ab3cd 100644
--- a/arch/m68k/configs/mvme16x_defconfig
+++ b/arch/m68k/configs/mvme16x_defconfig
@@ -91,9 +91,10 @@ CONFIG_NF_TABLES_INET=m
91CONFIG_NF_TABLES_NETDEV=m 91CONFIG_NF_TABLES_NETDEV=m
92CONFIG_NFT_EXTHDR=m 92CONFIG_NFT_EXTHDR=m
93CONFIG_NFT_META=m 93CONFIG_NFT_META=m
94CONFIG_NFT_NUMGEN=m
94CONFIG_NFT_CT=m 95CONFIG_NFT_CT=m
95CONFIG_NFT_RBTREE=m 96CONFIG_NFT_SET_RBTREE=m
96CONFIG_NFT_HASH=m 97CONFIG_NFT_SET_HASH=m
97CONFIG_NFT_COUNTER=m 98CONFIG_NFT_COUNTER=m
98CONFIG_NFT_LOG=m 99CONFIG_NFT_LOG=m
99CONFIG_NFT_LIMIT=m 100CONFIG_NFT_LIMIT=m
@@ -101,8 +102,10 @@ CONFIG_NFT_MASQ=m
101CONFIG_NFT_REDIR=m 102CONFIG_NFT_REDIR=m
102CONFIG_NFT_NAT=m 103CONFIG_NFT_NAT=m
103CONFIG_NFT_QUEUE=m 104CONFIG_NFT_QUEUE=m
105CONFIG_NFT_QUOTA=m
104CONFIG_NFT_REJECT=m 106CONFIG_NFT_REJECT=m
105CONFIG_NFT_COMPAT=m 107CONFIG_NFT_COMPAT=m
108CONFIG_NFT_HASH=m
106CONFIG_NFT_DUP_NETDEV=m 109CONFIG_NFT_DUP_NETDEV=m
107CONFIG_NFT_FWD_NETDEV=m 110CONFIG_NFT_FWD_NETDEV=m
108CONFIG_NETFILTER_XT_SET=m 111CONFIG_NETFILTER_XT_SET=m
@@ -346,6 +349,7 @@ CONFIG_MACSEC=m
346CONFIG_NETCONSOLE=m 349CONFIG_NETCONSOLE=m
347CONFIG_NETCONSOLE_DYNAMIC=y 350CONFIG_NETCONSOLE_DYNAMIC=y
348CONFIG_VETH=m 351CONFIG_VETH=m
352# CONFIG_NET_VENDOR_AMAZON is not set
349# CONFIG_NET_VENDOR_ARC is not set 353# CONFIG_NET_VENDOR_ARC is not set
350# CONFIG_NET_CADENCE is not set 354# CONFIG_NET_CADENCE is not set
351# CONFIG_NET_VENDOR_BROADCOM is not set 355# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/m68k/configs/q40_defconfig b/arch/m68k/configs/q40_defconfig
index 74e3ad82eca9..e557c9de3fbc 100644
--- a/arch/m68k/configs/q40_defconfig
+++ b/arch/m68k/configs/q40_defconfig
@@ -91,9 +91,10 @@ CONFIG_NF_TABLES_INET=m
91CONFIG_NF_TABLES_NETDEV=m 91CONFIG_NF_TABLES_NETDEV=m
92CONFIG_NFT_EXTHDR=m 92CONFIG_NFT_EXTHDR=m
93CONFIG_NFT_META=m 93CONFIG_NFT_META=m
94CONFIG_NFT_NUMGEN=m
94CONFIG_NFT_CT=m 95CONFIG_NFT_CT=m
95CONFIG_NFT_RBTREE=m 96CONFIG_NFT_SET_RBTREE=m
96CONFIG_NFT_HASH=m 97CONFIG_NFT_SET_HASH=m
97CONFIG_NFT_COUNTER=m 98CONFIG_NFT_COUNTER=m
98CONFIG_NFT_LOG=m 99CONFIG_NFT_LOG=m
99CONFIG_NFT_LIMIT=m 100CONFIG_NFT_LIMIT=m
@@ -101,8 +102,10 @@ CONFIG_NFT_MASQ=m
101CONFIG_NFT_REDIR=m 102CONFIG_NFT_REDIR=m
102CONFIG_NFT_NAT=m 103CONFIG_NFT_NAT=m
103CONFIG_NFT_QUEUE=m 104CONFIG_NFT_QUEUE=m
105CONFIG_NFT_QUOTA=m
104CONFIG_NFT_REJECT=m 106CONFIG_NFT_REJECT=m
105CONFIG_NFT_COMPAT=m 107CONFIG_NFT_COMPAT=m
108CONFIG_NFT_HASH=m
106CONFIG_NFT_DUP_NETDEV=m 109CONFIG_NFT_DUP_NETDEV=m
107CONFIG_NFT_FWD_NETDEV=m 110CONFIG_NFT_FWD_NETDEV=m
108CONFIG_NETFILTER_XT_SET=m 111CONFIG_NETFILTER_XT_SET=m
@@ -353,6 +356,7 @@ CONFIG_NETCONSOLE=m
353CONFIG_NETCONSOLE_DYNAMIC=y 356CONFIG_NETCONSOLE_DYNAMIC=y
354CONFIG_VETH=m 357CONFIG_VETH=m
355# CONFIG_NET_VENDOR_3COM is not set 358# CONFIG_NET_VENDOR_3COM is not set
359# CONFIG_NET_VENDOR_AMAZON is not set
356# CONFIG_NET_VENDOR_AMD is not set 360# CONFIG_NET_VENDOR_AMD is not set
357# CONFIG_NET_VENDOR_ARC is not set 361# CONFIG_NET_VENDOR_ARC is not set
358# CONFIG_NET_CADENCE is not set 362# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/sun3_defconfig b/arch/m68k/configs/sun3_defconfig
index 4ba8606a4e69..c6a748a36daf 100644
--- a/arch/m68k/configs/sun3_defconfig
+++ b/arch/m68k/configs/sun3_defconfig
@@ -88,9 +88,10 @@ CONFIG_NF_TABLES_INET=m
88CONFIG_NF_TABLES_NETDEV=m 88CONFIG_NF_TABLES_NETDEV=m
89CONFIG_NFT_EXTHDR=m 89CONFIG_NFT_EXTHDR=m
90CONFIG_NFT_META=m 90CONFIG_NFT_META=m
91CONFIG_NFT_NUMGEN=m
91CONFIG_NFT_CT=m 92CONFIG_NFT_CT=m
92CONFIG_NFT_RBTREE=m 93CONFIG_NFT_SET_RBTREE=m
93CONFIG_NFT_HASH=m 94CONFIG_NFT_SET_HASH=m
94CONFIG_NFT_COUNTER=m 95CONFIG_NFT_COUNTER=m
95CONFIG_NFT_LOG=m 96CONFIG_NFT_LOG=m
96CONFIG_NFT_LIMIT=m 97CONFIG_NFT_LIMIT=m
@@ -98,8 +99,10 @@ CONFIG_NFT_MASQ=m
98CONFIG_NFT_REDIR=m 99CONFIG_NFT_REDIR=m
99CONFIG_NFT_NAT=m 100CONFIG_NFT_NAT=m
100CONFIG_NFT_QUEUE=m 101CONFIG_NFT_QUEUE=m
102CONFIG_NFT_QUOTA=m
101CONFIG_NFT_REJECT=m 103CONFIG_NFT_REJECT=m
102CONFIG_NFT_COMPAT=m 104CONFIG_NFT_COMPAT=m
105CONFIG_NFT_HASH=m
103CONFIG_NFT_DUP_NETDEV=m 106CONFIG_NFT_DUP_NETDEV=m
104CONFIG_NFT_FWD_NETDEV=m 107CONFIG_NFT_FWD_NETDEV=m
105CONFIG_NETFILTER_XT_SET=m 108CONFIG_NETFILTER_XT_SET=m
@@ -343,6 +346,7 @@ CONFIG_MACSEC=m
343CONFIG_NETCONSOLE=m 346CONFIG_NETCONSOLE=m
344CONFIG_NETCONSOLE_DYNAMIC=y 347CONFIG_NETCONSOLE_DYNAMIC=y
345CONFIG_VETH=m 348CONFIG_VETH=m
349# CONFIG_NET_VENDOR_AMAZON is not set
346CONFIG_SUN3LANCE=y 350CONFIG_SUN3LANCE=y
347# CONFIG_NET_VENDOR_ARC is not set 351# CONFIG_NET_VENDOR_ARC is not set
348# CONFIG_NET_CADENCE is not set 352# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/configs/sun3x_defconfig b/arch/m68k/configs/sun3x_defconfig
index c6f49726a6c9..10d60857b9a6 100644
--- a/arch/m68k/configs/sun3x_defconfig
+++ b/arch/m68k/configs/sun3x_defconfig
@@ -88,9 +88,10 @@ CONFIG_NF_TABLES_INET=m
88CONFIG_NF_TABLES_NETDEV=m 88CONFIG_NF_TABLES_NETDEV=m
89CONFIG_NFT_EXTHDR=m 89CONFIG_NFT_EXTHDR=m
90CONFIG_NFT_META=m 90CONFIG_NFT_META=m
91CONFIG_NFT_NUMGEN=m
91CONFIG_NFT_CT=m 92CONFIG_NFT_CT=m
92CONFIG_NFT_RBTREE=m 93CONFIG_NFT_SET_RBTREE=m
93CONFIG_NFT_HASH=m 94CONFIG_NFT_SET_HASH=m
94CONFIG_NFT_COUNTER=m 95CONFIG_NFT_COUNTER=m
95CONFIG_NFT_LOG=m 96CONFIG_NFT_LOG=m
96CONFIG_NFT_LIMIT=m 97CONFIG_NFT_LIMIT=m
@@ -98,8 +99,10 @@ CONFIG_NFT_MASQ=m
98CONFIG_NFT_REDIR=m 99CONFIG_NFT_REDIR=m
99CONFIG_NFT_NAT=m 100CONFIG_NFT_NAT=m
100CONFIG_NFT_QUEUE=m 101CONFIG_NFT_QUEUE=m
102CONFIG_NFT_QUOTA=m
101CONFIG_NFT_REJECT=m 103CONFIG_NFT_REJECT=m
102CONFIG_NFT_COMPAT=m 104CONFIG_NFT_COMPAT=m
105CONFIG_NFT_HASH=m
103CONFIG_NFT_DUP_NETDEV=m 106CONFIG_NFT_DUP_NETDEV=m
104CONFIG_NFT_FWD_NETDEV=m 107CONFIG_NFT_FWD_NETDEV=m
105CONFIG_NETFILTER_XT_SET=m 108CONFIG_NETFILTER_XT_SET=m
@@ -343,6 +346,7 @@ CONFIG_MACSEC=m
343CONFIG_NETCONSOLE=m 346CONFIG_NETCONSOLE=m
344CONFIG_NETCONSOLE_DYNAMIC=y 347CONFIG_NETCONSOLE_DYNAMIC=y
345CONFIG_VETH=m 348CONFIG_VETH=m
349# CONFIG_NET_VENDOR_AMAZON is not set
346CONFIG_SUN3LANCE=y 350CONFIG_SUN3LANCE=y
347# CONFIG_NET_VENDOR_ARC is not set 351# CONFIG_NET_VENDOR_ARC is not set
348# CONFIG_NET_CADENCE is not set 352# CONFIG_NET_CADENCE is not set
diff --git a/arch/m68k/include/asm/delay.h b/arch/m68k/include/asm/delay.h
index d28fa8fe26fe..c598d847d56b 100644
--- a/arch/m68k/include/asm/delay.h
+++ b/arch/m68k/include/asm/delay.h
@@ -114,6 +114,6 @@ static inline void __udelay(unsigned long usecs)
114 */ 114 */
115#define HZSCALE (268435456 / (1000000 / HZ)) 115#define HZSCALE (268435456 / (1000000 / HZ))
116 116
117#define ndelay(n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000)); 117#define ndelay(n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000))
118 118
119#endif /* defined(_M68K_DELAY_H) */ 119#endif /* defined(_M68K_DELAY_H) */
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 7dd2dd47909a..df78b2ca70eb 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -215,6 +215,12 @@
215#endif 215#endif
216 216
217/* 217/*
218 * Wired register bits
219 */
220#define MIPSR6_WIRED_LIMIT (_ULCAST_(0xffff) << 16)
221#define MIPSR6_WIRED_WIRED (_ULCAST_(0xffff) << 0)
222
223/*
218 * Values used for computation of new tlb entries 224 * Values used for computation of new tlb entries
219 */ 225 */
220#define PL_4K 12 226#define PL_4K 12
diff --git a/arch/mips/include/asm/tlb.h b/arch/mips/include/asm/tlb.h
index 4a2349302b55..dd179fd8acda 100644
--- a/arch/mips/include/asm/tlb.h
+++ b/arch/mips/include/asm/tlb.h
@@ -1,6 +1,9 @@
1#ifndef __ASM_TLB_H 1#ifndef __ASM_TLB_H
2#define __ASM_TLB_H 2#define __ASM_TLB_H
3 3
4#include <asm/cpu-features.h>
5#include <asm/mipsregs.h>
6
4/* 7/*
5 * MIPS doesn't need any special per-pte or per-vma handling, except 8 * MIPS doesn't need any special per-pte or per-vma handling, except
6 * we need to flush cache for area to be unmapped. 9 * we need to flush cache for area to be unmapped.
@@ -22,6 +25,16 @@
22 ((CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) | \ 25 ((CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) | \
23 (cpu_has_tlbinv ? MIPS_ENTRYHI_EHINV : 0)) 26 (cpu_has_tlbinv ? MIPS_ENTRYHI_EHINV : 0))
24 27
28static inline unsigned int num_wired_entries(void)
29{
30 unsigned int wired = read_c0_wired();
31
32 if (cpu_has_mips_r6)
33 wired &= MIPSR6_WIRED_WIRED;
34
35 return wired;
36}
37
25#include <asm-generic/tlb.h> 38#include <asm-generic/tlb.h>
26 39
27#endif /* __ASM_TLB_H */ 40#endif /* __ASM_TLB_H */
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index d56a855828c2..3bef306cdfdb 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -209,17 +209,18 @@ bad_area_nosemaphore:
209 if (show_unhandled_signals && 209 if (show_unhandled_signals &&
210 unhandled_signal(tsk, SIGSEGV) && 210 unhandled_signal(tsk, SIGSEGV) &&
211 __ratelimit(&ratelimit_state)) { 211 __ratelimit(&ratelimit_state)) {
212 pr_info("\ndo_page_fault(): sending SIGSEGV to %s for invalid %s %0*lx", 212 pr_info("do_page_fault(): sending SIGSEGV to %s for invalid %s %0*lx\n",
213 tsk->comm, 213 tsk->comm,
214 write ? "write access to" : "read access from", 214 write ? "write access to" : "read access from",
215 field, address); 215 field, address);
216 pr_info("epc = %0*lx in", field, 216 pr_info("epc = %0*lx in", field,
217 (unsigned long) regs->cp0_epc); 217 (unsigned long) regs->cp0_epc);
218 print_vma_addr(" ", regs->cp0_epc); 218 print_vma_addr(KERN_CONT " ", regs->cp0_epc);
219 pr_cont("\n");
219 pr_info("ra = %0*lx in", field, 220 pr_info("ra = %0*lx in", field,
220 (unsigned long) regs->regs[31]); 221 (unsigned long) regs->regs[31]);
221 print_vma_addr(" ", regs->regs[31]); 222 print_vma_addr(KERN_CONT " ", regs->regs[31]);
222 pr_info("\n"); 223 pr_cont("\n");
223 } 224 }
224 current->thread.trap_nr = (regs->cp0_cause >> 2) & 0x1f; 225 current->thread.trap_nr = (regs->cp0_cause >> 2) & 0x1f;
225 info.si_signo = SIGSEGV; 226 info.si_signo = SIGSEGV;
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 3a6edecc3f38..e86ebcf5c071 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -118,7 +118,7 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
118 writex_c0_entrylo1(entrylo); 118 writex_c0_entrylo1(entrylo);
119 } 119 }
120#endif 120#endif
121 tlbidx = read_c0_wired(); 121 tlbidx = num_wired_entries();
122 write_c0_wired(tlbidx + 1); 122 write_c0_wired(tlbidx + 1);
123 write_c0_index(tlbidx); 123 write_c0_index(tlbidx);
124 mtc0_tlbw_hazard(); 124 mtc0_tlbw_hazard();
@@ -147,7 +147,7 @@ void kunmap_coherent(void)
147 147
148 local_irq_save(flags); 148 local_irq_save(flags);
149 old_ctx = read_c0_entryhi(); 149 old_ctx = read_c0_entryhi();
150 wired = read_c0_wired() - 1; 150 wired = num_wired_entries() - 1;
151 write_c0_wired(wired); 151 write_c0_wired(wired);
152 write_c0_index(wired); 152 write_c0_index(wired);
153 write_c0_entryhi(UNIQUE_ENTRYHI(wired)); 153 write_c0_entryhi(UNIQUE_ENTRYHI(wired));
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index bba9c1484b41..0596505770db 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -65,7 +65,7 @@ void local_flush_tlb_all(void)
65 write_c0_entrylo0(0); 65 write_c0_entrylo0(0);
66 write_c0_entrylo1(0); 66 write_c0_entrylo1(0);
67 67
68 entry = read_c0_wired(); 68 entry = num_wired_entries();
69 69
70 /* 70 /*
71 * Blast 'em all away. 71 * Blast 'em all away.
@@ -385,7 +385,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
385 old_ctx = read_c0_entryhi(); 385 old_ctx = read_c0_entryhi();
386 htw_stop(); 386 htw_stop();
387 old_pagemask = read_c0_pagemask(); 387 old_pagemask = read_c0_pagemask();
388 wired = read_c0_wired(); 388 wired = num_wired_entries();
389 write_c0_wired(wired + 1); 389 write_c0_wired(wired + 1);
390 write_c0_index(wired); 390 write_c0_index(wired);
391 tlbw_use_hazard(); /* What is the hazard here? */ 391 tlbw_use_hazard(); /* What is the hazard here? */
@@ -449,7 +449,7 @@ __init int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
449 htw_stop(); 449 htw_stop();
450 old_ctx = read_c0_entryhi(); 450 old_ctx = read_c0_entryhi();
451 old_pagemask = read_c0_pagemask(); 451 old_pagemask = read_c0_pagemask();
452 wired = read_c0_wired(); 452 wired = num_wired_entries();
453 if (--temp_tlb_entry < wired) { 453 if (--temp_tlb_entry < wired) {
454 printk(KERN_WARNING 454 printk(KERN_WARNING
455 "No TLB space left for add_temporary_entry\n"); 455 "No TLB space left for add_temporary_entry\n");
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 71c4a3aa3752..a14b86587013 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -34,7 +34,9 @@ config PARISC
34 select HAVE_ARCH_HASH 34 select HAVE_ARCH_HASH
35 select HAVE_ARCH_SECCOMP_FILTER 35 select HAVE_ARCH_SECCOMP_FILTER
36 select HAVE_ARCH_TRACEHOOK 36 select HAVE_ARCH_TRACEHOOK
37 select HAVE_UNSTABLE_SCHED_CLOCK if (SMP || !64BIT) 37 select GENERIC_SCHED_CLOCK
38 select HAVE_UNSTABLE_SCHED_CLOCK if SMP
39 select GENERIC_CLOCKEVENTS
38 select ARCH_NO_COHERENT_DMA_MMAP 40 select ARCH_NO_COHERENT_DMA_MMAP
39 select CPU_NO_EFFICIENT_FFS 41 select CPU_NO_EFFICIENT_FFS
40 42
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index c2c43f714684..3a4ed9f91d57 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -65,9 +65,9 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
65 unsigned long flags; \ 65 unsigned long flags; \
66 spin_lock_irqsave(&pa_tlb_lock, flags); \ 66 spin_lock_irqsave(&pa_tlb_lock, flags); \
67 old_pte = *ptep; \ 67 old_pte = *ptep; \
68 set_pte(ptep, pteval); \
69 if (pte_inserted(old_pte)) \ 68 if (pte_inserted(old_pte)) \
70 purge_tlb_entries(mm, addr); \ 69 purge_tlb_entries(mm, addr); \
70 set_pte(ptep, pteval); \
71 spin_unlock_irqrestore(&pa_tlb_lock, flags); \ 71 spin_unlock_irqrestore(&pa_tlb_lock, flags); \
72 } while (0) 72 } while (0)
73 73
@@ -478,8 +478,8 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned
478 spin_unlock_irqrestore(&pa_tlb_lock, flags); 478 spin_unlock_irqrestore(&pa_tlb_lock, flags);
479 return 0; 479 return 0;
480 } 480 }
481 set_pte(ptep, pte_mkold(pte));
482 purge_tlb_entries(vma->vm_mm, addr); 481 purge_tlb_entries(vma->vm_mm, addr);
482 set_pte(ptep, pte_mkold(pte));
483 spin_unlock_irqrestore(&pa_tlb_lock, flags); 483 spin_unlock_irqrestore(&pa_tlb_lock, flags);
484 return 1; 484 return 1;
485} 485}
@@ -492,9 +492,9 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
492 492
493 spin_lock_irqsave(&pa_tlb_lock, flags); 493 spin_lock_irqsave(&pa_tlb_lock, flags);
494 old_pte = *ptep; 494 old_pte = *ptep;
495 set_pte(ptep, __pte(0));
496 if (pte_inserted(old_pte)) 495 if (pte_inserted(old_pte))
497 purge_tlb_entries(mm, addr); 496 purge_tlb_entries(mm, addr);
497 set_pte(ptep, __pte(0));
498 spin_unlock_irqrestore(&pa_tlb_lock, flags); 498 spin_unlock_irqrestore(&pa_tlb_lock, flags);
499 499
500 return old_pte; 500 return old_pte;
@@ -504,8 +504,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
504{ 504{
505 unsigned long flags; 505 unsigned long flags;
506 spin_lock_irqsave(&pa_tlb_lock, flags); 506 spin_lock_irqsave(&pa_tlb_lock, flags);
507 set_pte(ptep, pte_wrprotect(*ptep));
508 purge_tlb_entries(mm, addr); 507 purge_tlb_entries(mm, addr);
508 set_pte(ptep, pte_wrprotect(*ptep));
509 spin_unlock_irqrestore(&pa_tlb_lock, flags); 509 spin_unlock_irqrestore(&pa_tlb_lock, flags);
510} 510}
511 511
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 629eb464d5ba..977f0a4f5ecf 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -369,6 +369,7 @@ void __init parisc_setup_cache_timing(void)
369{ 369{
370 unsigned long rangetime, alltime; 370 unsigned long rangetime, alltime;
371 unsigned long size, start; 371 unsigned long size, start;
372 unsigned long threshold;
372 373
373 alltime = mfctl(16); 374 alltime = mfctl(16);
374 flush_data_cache(); 375 flush_data_cache();
@@ -382,26 +383,30 @@ void __init parisc_setup_cache_timing(void)
382 printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n", 383 printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n",
383 alltime, size, rangetime); 384 alltime, size, rangetime);
384 385
385 /* Racy, but if we see an intermediate value, it's ok too... */ 386 threshold = L1_CACHE_ALIGN(size * alltime / rangetime);
386 parisc_cache_flush_threshold = size * alltime / rangetime; 387 if (threshold > cache_info.dc_size)
387 388 threshold = cache_info.dc_size;
388 parisc_cache_flush_threshold = L1_CACHE_ALIGN(parisc_cache_flush_threshold); 389 if (threshold)
389 if (!parisc_cache_flush_threshold) 390 parisc_cache_flush_threshold = threshold;
390 parisc_cache_flush_threshold = FLUSH_THRESHOLD; 391 printk(KERN_INFO "Cache flush threshold set to %lu KiB\n",
391
392 if (parisc_cache_flush_threshold > cache_info.dc_size)
393 parisc_cache_flush_threshold = cache_info.dc_size;
394
395 printk(KERN_INFO "Setting cache flush threshold to %lu kB\n",
396 parisc_cache_flush_threshold/1024); 392 parisc_cache_flush_threshold/1024);
397 393
398 /* calculate TLB flush threshold */ 394 /* calculate TLB flush threshold */
399 395
396 /* On SMP machines, skip the TLB measure of kernel text which
397 * has been mapped as huge pages. */
398 if (num_online_cpus() > 1 && !parisc_requires_coherency()) {
399 threshold = max(cache_info.it_size, cache_info.dt_size);
400 threshold *= PAGE_SIZE;
401 threshold /= num_online_cpus();
402 goto set_tlb_threshold;
403 }
404
400 alltime = mfctl(16); 405 alltime = mfctl(16);
401 flush_tlb_all(); 406 flush_tlb_all();
402 alltime = mfctl(16) - alltime; 407 alltime = mfctl(16) - alltime;
403 408
404 size = PAGE_SIZE; 409 size = 0;
405 start = (unsigned long) _text; 410 start = (unsigned long) _text;
406 rangetime = mfctl(16); 411 rangetime = mfctl(16);
407 while (start < (unsigned long) _end) { 412 while (start < (unsigned long) _end) {
@@ -414,13 +419,12 @@ void __init parisc_setup_cache_timing(void)
414 printk(KERN_DEBUG "Whole TLB flush %lu cycles, flushing %lu bytes %lu cycles\n", 419 printk(KERN_DEBUG "Whole TLB flush %lu cycles, flushing %lu bytes %lu cycles\n",
415 alltime, size, rangetime); 420 alltime, size, rangetime);
416 421
417 parisc_tlb_flush_threshold = size * alltime / rangetime; 422 threshold = PAGE_ALIGN(num_online_cpus() * size * alltime / rangetime);
418 parisc_tlb_flush_threshold *= num_online_cpus();
419 parisc_tlb_flush_threshold = PAGE_ALIGN(parisc_tlb_flush_threshold);
420 if (!parisc_tlb_flush_threshold)
421 parisc_tlb_flush_threshold = FLUSH_TLB_THRESHOLD;
422 423
423 printk(KERN_INFO "Setting TLB flush threshold to %lu kB\n", 424set_tlb_threshold:
425 if (threshold)
426 parisc_tlb_flush_threshold = threshold;
427 printk(KERN_INFO "TLB flush threshold set to %lu KiB\n",
424 parisc_tlb_flush_threshold/1024); 428 parisc_tlb_flush_threshold/1024);
425} 429}
426 430
diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c
index 545f9d2fe711..c05d1876d27c 100644
--- a/arch/parisc/kernel/inventory.c
+++ b/arch/parisc/kernel/inventory.c
@@ -58,7 +58,7 @@ void __init setup_pdc(void)
58 status = pdc_system_map_find_mods(&module_result, &module_path, 0); 58 status = pdc_system_map_find_mods(&module_result, &module_path, 0);
59 if (status == PDC_OK) { 59 if (status == PDC_OK) {
60 pdc_type = PDC_TYPE_SYSTEM_MAP; 60 pdc_type = PDC_TYPE_SYSTEM_MAP;
61 printk("System Map.\n"); 61 pr_cont("System Map.\n");
62 return; 62 return;
63 } 63 }
64 64
@@ -77,7 +77,7 @@ void __init setup_pdc(void)
77 status = pdc_pat_cell_get_number(&cell_info); 77 status = pdc_pat_cell_get_number(&cell_info);
78 if (status == PDC_OK) { 78 if (status == PDC_OK) {
79 pdc_type = PDC_TYPE_PAT; 79 pdc_type = PDC_TYPE_PAT;
80 printk("64 bit PAT.\n"); 80 pr_cont("64 bit PAT.\n");
81 return; 81 return;
82 } 82 }
83#endif 83#endif
@@ -97,12 +97,12 @@ void __init setup_pdc(void)
97 case 0xC: /* 715/64, at least */ 97 case 0xC: /* 715/64, at least */
98 98
99 pdc_type = PDC_TYPE_SNAKE; 99 pdc_type = PDC_TYPE_SNAKE;
100 printk("Snake.\n"); 100 pr_cont("Snake.\n");
101 return; 101 return;
102 102
103 default: /* Everything else */ 103 default: /* Everything else */
104 104
105 printk("Unsupported.\n"); 105 pr_cont("Unsupported.\n");
106 panic("If this is a 64-bit machine, please try a 64-bit kernel.\n"); 106 panic("If this is a 64-bit machine, please try a 64-bit kernel.\n");
107 } 107 }
108} 108}
diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
index 985e06da37f5..adf7187f8951 100644
--- a/arch/parisc/kernel/pacache.S
+++ b/arch/parisc/kernel/pacache.S
@@ -96,7 +96,7 @@ fitmanyloop: /* Loop if LOOP >= 2 */
96 96
97fitmanymiddle: /* Loop if LOOP >= 2 */ 97fitmanymiddle: /* Loop if LOOP >= 2 */
98 addib,COND(>) -1, %r31, fitmanymiddle /* Adjusted inner loop decr */ 98 addib,COND(>) -1, %r31, fitmanymiddle /* Adjusted inner loop decr */
99 pitlbe 0(%sr1, %r28) 99 pitlbe %r0(%sr1, %r28)
100 pitlbe,m %arg1(%sr1, %r28) /* Last pitlbe and addr adjust */ 100 pitlbe,m %arg1(%sr1, %r28) /* Last pitlbe and addr adjust */
101 addib,COND(>) -1, %r29, fitmanymiddle /* Middle loop decr */ 101 addib,COND(>) -1, %r29, fitmanymiddle /* Middle loop decr */
102 copy %arg3, %r31 /* Re-init inner loop count */ 102 copy %arg3, %r31 /* Re-init inner loop count */
@@ -139,7 +139,7 @@ fdtmanyloop: /* Loop if LOOP >= 2 */
139 139
140fdtmanymiddle: /* Loop if LOOP >= 2 */ 140fdtmanymiddle: /* Loop if LOOP >= 2 */
141 addib,COND(>) -1, %r31, fdtmanymiddle /* Adjusted inner loop decr */ 141 addib,COND(>) -1, %r31, fdtmanymiddle /* Adjusted inner loop decr */
142 pdtlbe 0(%sr1, %r28) 142 pdtlbe %r0(%sr1, %r28)
143 pdtlbe,m %arg1(%sr1, %r28) /* Last pdtlbe and addr adjust */ 143 pdtlbe,m %arg1(%sr1, %r28) /* Last pdtlbe and addr adjust */
144 addib,COND(>) -1, %r29, fdtmanymiddle /* Middle loop decr */ 144 addib,COND(>) -1, %r29, fdtmanymiddle /* Middle loop decr */
145 copy %arg3, %r31 /* Re-init inner loop count */ 145 copy %arg3, %r31 /* Re-init inner loop count */
@@ -626,12 +626,12 @@ ENTRY_CFI(copy_user_page_asm)
626 /* Purge any old translations */ 626 /* Purge any old translations */
627 627
628#ifdef CONFIG_PA20 628#ifdef CONFIG_PA20
629 pdtlb,l 0(%r28) 629 pdtlb,l %r0(%r28)
630 pdtlb,l 0(%r29) 630 pdtlb,l %r0(%r29)
631#else 631#else
632 tlb_lock %r20,%r21,%r22 632 tlb_lock %r20,%r21,%r22
633 pdtlb 0(%r28) 633 pdtlb %r0(%r28)
634 pdtlb 0(%r29) 634 pdtlb %r0(%r29)
635 tlb_unlock %r20,%r21,%r22 635 tlb_unlock %r20,%r21,%r22
636#endif 636#endif
637 637
@@ -774,10 +774,10 @@ ENTRY_CFI(clear_user_page_asm)
774 /* Purge any old translation */ 774 /* Purge any old translation */
775 775
776#ifdef CONFIG_PA20 776#ifdef CONFIG_PA20
777 pdtlb,l 0(%r28) 777 pdtlb,l %r0(%r28)
778#else 778#else
779 tlb_lock %r20,%r21,%r22 779 tlb_lock %r20,%r21,%r22
780 pdtlb 0(%r28) 780 pdtlb %r0(%r28)
781 tlb_unlock %r20,%r21,%r22 781 tlb_unlock %r20,%r21,%r22
782#endif 782#endif
783 783
@@ -858,10 +858,10 @@ ENTRY_CFI(flush_dcache_page_asm)
858 /* Purge any old translation */ 858 /* Purge any old translation */
859 859
860#ifdef CONFIG_PA20 860#ifdef CONFIG_PA20
861 pdtlb,l 0(%r28) 861 pdtlb,l %r0(%r28)
862#else 862#else
863 tlb_lock %r20,%r21,%r22 863 tlb_lock %r20,%r21,%r22
864 pdtlb 0(%r28) 864 pdtlb %r0(%r28)
865 tlb_unlock %r20,%r21,%r22 865 tlb_unlock %r20,%r21,%r22
866#endif 866#endif
867 867
@@ -892,19 +892,10 @@ ENTRY_CFI(flush_dcache_page_asm)
892 fdc,m r31(%r28) 892 fdc,m r31(%r28)
893 fdc,m r31(%r28) 893 fdc,m r31(%r28)
894 fdc,m r31(%r28) 894 fdc,m r31(%r28)
895 cmpb,COND(<<) %r28, %r25,1b 895 cmpb,COND(<<) %r28, %r25,1b
896 fdc,m r31(%r28) 896 fdc,m r31(%r28)
897 897
898 sync 898 sync
899
900#ifdef CONFIG_PA20
901 pdtlb,l 0(%r25)
902#else
903 tlb_lock %r20,%r21,%r22
904 pdtlb 0(%r25)
905 tlb_unlock %r20,%r21,%r22
906#endif
907
908 bv %r0(%r2) 899 bv %r0(%r2)
909 nop 900 nop
910 .exit 901 .exit
@@ -931,13 +922,18 @@ ENTRY_CFI(flush_icache_page_asm)
931 depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */ 922 depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
932#endif 923#endif
933 924
934 /* Purge any old translation */ 925 /* Purge any old translation. Note that the FIC instruction
926 * may use either the instruction or data TLB. Given that we
927 * have a flat address space, it's not clear which TLB will be
928 * used. So, we purge both entries. */
935 929
936#ifdef CONFIG_PA20 930#ifdef CONFIG_PA20
931 pdtlb,l %r0(%r28)
937 pitlb,l %r0(%sr4,%r28) 932 pitlb,l %r0(%sr4,%r28)
938#else 933#else
939 tlb_lock %r20,%r21,%r22 934 tlb_lock %r20,%r21,%r22
940 pitlb (%sr4,%r28) 935 pdtlb %r0(%r28)
936 pitlb %r0(%sr4,%r28)
941 tlb_unlock %r20,%r21,%r22 937 tlb_unlock %r20,%r21,%r22
942#endif 938#endif
943 939
@@ -974,15 +970,6 @@ ENTRY_CFI(flush_icache_page_asm)
974 fic,m %r31(%sr4,%r28) 970 fic,m %r31(%sr4,%r28)
975 971
976 sync 972 sync
977
978#ifdef CONFIG_PA20
979 pitlb,l %r0(%sr4,%r25)
980#else
981 tlb_lock %r20,%r21,%r22
982 pitlb (%sr4,%r25)
983 tlb_unlock %r20,%r21,%r22
984#endif
985
986 bv %r0(%r2) 973 bv %r0(%r2)
987 nop 974 nop
988 .exit 975 .exit
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 02d9ed0f3949..494ff6e8c88a 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -95,8 +95,8 @@ static inline int map_pte_uncached(pte_t * pte,
95 95
96 if (!pte_none(*pte)) 96 if (!pte_none(*pte))
97 printk(KERN_ERR "map_pte_uncached: page already exists\n"); 97 printk(KERN_ERR "map_pte_uncached: page already exists\n");
98 set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
99 purge_tlb_start(flags); 98 purge_tlb_start(flags);
99 set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
100 pdtlb_kernel(orig_vaddr); 100 pdtlb_kernel(orig_vaddr);
101 purge_tlb_end(flags); 101 purge_tlb_end(flags);
102 vaddr += PAGE_SIZE; 102 vaddr += PAGE_SIZE;
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 81d6f6391944..2e66a887788e 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -334,6 +334,10 @@ static int __init parisc_init(void)
334 /* tell PDC we're Linux. Nevermind failure. */ 334 /* tell PDC we're Linux. Nevermind failure. */
335 pdc_stable_write(0x40, &osid, sizeof(osid)); 335 pdc_stable_write(0x40, &osid, sizeof(osid));
336 336
337 /* start with known state */
338 flush_cache_all_local();
339 flush_tlb_all_local(NULL);
340
337 processor_init(); 341 processor_init();
338#ifdef CONFIG_SMP 342#ifdef CONFIG_SMP
339 pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n", 343 pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n",
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 9b63b876a13a..325f30d82b64 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/rtc.h> 15#include <linux/rtc.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/sched_clock.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/param.h> 19#include <linux/param.h>
19#include <linux/string.h> 20#include <linux/string.h>
@@ -39,18 +40,6 @@
39 40
40static unsigned long clocktick __read_mostly; /* timer cycles per tick */ 41static unsigned long clocktick __read_mostly; /* timer cycles per tick */
41 42
42#ifndef CONFIG_64BIT
43/*
44 * The processor-internal cycle counter (Control Register 16) is used as time
45 * source for the sched_clock() function. This register is 64bit wide on a
46 * 64-bit kernel and 32bit on a 32-bit kernel. Since sched_clock() always
47 * requires a 64bit counter we emulate on the 32-bit kernel the higher 32bits
48 * with a per-cpu variable which we increase every time the counter
49 * wraps-around (which happens every ~4 secounds).
50 */
51static DEFINE_PER_CPU(unsigned long, cr16_high_32_bits);
52#endif
53
54/* 43/*
55 * We keep time on PA-RISC Linux by using the Interval Timer which is 44 * We keep time on PA-RISC Linux by using the Interval Timer which is
56 * a pair of registers; one is read-only and one is write-only; both 45 * a pair of registers; one is read-only and one is write-only; both
@@ -121,12 +110,6 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
121 */ 110 */
122 mtctl(next_tick, 16); 111 mtctl(next_tick, 16);
123 112
124#if !defined(CONFIG_64BIT)
125 /* check for overflow on a 32bit kernel (every ~4 seconds). */
126 if (unlikely(next_tick < now))
127 this_cpu_inc(cr16_high_32_bits);
128#endif
129
130 /* Skip one clocktick on purpose if we missed next_tick. 113 /* Skip one clocktick on purpose if we missed next_tick.
131 * The new CR16 must be "later" than current CR16 otherwise 114 * The new CR16 must be "later" than current CR16 otherwise
132 * itimer would not fire until CR16 wrapped - e.g 4 seconds 115 * itimer would not fire until CR16 wrapped - e.g 4 seconds
@@ -208,7 +191,7 @@ EXPORT_SYMBOL(profile_pc);
208 191
209/* clock source code */ 192/* clock source code */
210 193
211static cycle_t read_cr16(struct clocksource *cs) 194static cycle_t notrace read_cr16(struct clocksource *cs)
212{ 195{
213 return get_cycles(); 196 return get_cycles();
214} 197}
@@ -287,26 +270,9 @@ void read_persistent_clock(struct timespec *ts)
287} 270}
288 271
289 272
290/* 273static u64 notrace read_cr16_sched_clock(void)
291 * sched_clock() framework
292 */
293
294static u32 cyc2ns_mul __read_mostly;
295static u32 cyc2ns_shift __read_mostly;
296
297u64 sched_clock(void)
298{ 274{
299 u64 now; 275 return get_cycles();
300
301 /* Get current cycle counter (Control Register 16). */
302#ifdef CONFIG_64BIT
303 now = mfctl(16);
304#else
305 now = mfctl(16) + (((u64) this_cpu_read(cr16_high_32_bits)) << 32);
306#endif
307
308 /* return the value in ns (cycles_2_ns) */
309 return mul_u64_u32_shr(now, cyc2ns_mul, cyc2ns_shift);
310} 276}
311 277
312 278
@@ -316,17 +282,16 @@ u64 sched_clock(void)
316 282
317void __init time_init(void) 283void __init time_init(void)
318{ 284{
319 unsigned long current_cr16_khz; 285 unsigned long cr16_hz;
320 286
321 current_cr16_khz = PAGE0->mem_10msec/10; /* kHz */
322 clocktick = (100 * PAGE0->mem_10msec) / HZ; 287 clocktick = (100 * PAGE0->mem_10msec) / HZ;
323
324 /* calculate mult/shift values for cr16 */
325 clocks_calc_mult_shift(&cyc2ns_mul, &cyc2ns_shift, current_cr16_khz,
326 NSEC_PER_MSEC, 0);
327
328 start_cpu_itimer(); /* get CPU 0 started */ 288 start_cpu_itimer(); /* get CPU 0 started */
329 289
290 cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */
291
330 /* register at clocksource framework */ 292 /* register at clocksource framework */
331 clocksource_register_khz(&clocksource_cr16, current_cr16_khz); 293 clocksource_register_hz(&clocksource_cr16, cr16_hz);
294
295 /* register as sched_clock source */
296 sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz);
332} 297}
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index eae2dc8bc218..9d47f2efa830 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -100,7 +100,8 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c decompress.c main.c \
100 ns16550.c serial.c simple_alloc.c div64.S util.S \ 100 ns16550.c serial.c simple_alloc.c div64.S util.S \
101 elf_util.c $(zlib-y) devtree.c stdlib.c \ 101 elf_util.c $(zlib-y) devtree.c stdlib.c \
102 oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \ 102 oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
103 uartlite.c mpc52xx-psc.c opal.c opal-calls.S 103 uartlite.c mpc52xx-psc.c opal.c
104src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S
104src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c 105src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
105src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c 106src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
106src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c 107src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 57d42d129033..78aaf4ffd7ab 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -232,8 +232,12 @@ void start(void)
232 console_ops.close(); 232 console_ops.close();
233 233
234 kentry = (kernel_entry_t) vmlinux.addr; 234 kentry = (kernel_entry_t) vmlinux.addr;
235 if (ft_addr) 235 if (ft_addr) {
236 kentry(ft_addr, 0, NULL); 236 if(platform_ops.kentry)
237 platform_ops.kentry(ft_addr, vmlinux.addr);
238 else
239 kentry(ft_addr, 0, NULL);
240 }
237 else 241 else
238 kentry((unsigned long)initrd.addr, initrd.size, 242 kentry((unsigned long)initrd.addr, initrd.size,
239 loader_info.promptr); 243 loader_info.promptr);
diff --git a/arch/powerpc/boot/opal-calls.S b/arch/powerpc/boot/opal-calls.S
index ff2f1b97bc53..2a99fc9a3ccf 100644
--- a/arch/powerpc/boot/opal-calls.S
+++ b/arch/powerpc/boot/opal-calls.S
@@ -12,6 +12,19 @@
12 12
13 .text 13 .text
14 14
15 .globl opal_kentry
16opal_kentry:
17 /* r3 is the fdt ptr */
18 mtctr r4
19 li r4, 0
20 li r5, 0
21 li r6, 0
22 li r7, 0
23 ld r11,opal@got(r2)
24 ld r8,0(r11)
25 ld r9,8(r11)
26 bctr
27
15#define OPAL_CALL(name, token) \ 28#define OPAL_CALL(name, token) \
16 .globl name; \ 29 .globl name; \
17name: \ 30name: \
diff --git a/arch/powerpc/boot/opal.c b/arch/powerpc/boot/opal.c
index 1f37e1c1d6d8..0272570d02de 100644
--- a/arch/powerpc/boot/opal.c
+++ b/arch/powerpc/boot/opal.c
@@ -13,7 +13,7 @@
13#include <libfdt.h> 13#include <libfdt.h>
14#include "../include/asm/opal-api.h" 14#include "../include/asm/opal-api.h"
15 15
16#ifdef __powerpc64__ 16#ifdef CONFIG_PPC64_BOOT_WRAPPER
17 17
18/* Global OPAL struct used by opal-call.S */ 18/* Global OPAL struct used by opal-call.S */
19struct opal { 19struct opal {
@@ -23,14 +23,25 @@ struct opal {
23 23
24static u32 opal_con_id; 24static u32 opal_con_id;
25 25
26/* see opal-wrappers.S */
26int64_t opal_console_write(int64_t term_number, u64 *length, const u8 *buffer); 27int64_t opal_console_write(int64_t term_number, u64 *length, const u8 *buffer);
27int64_t opal_console_read(int64_t term_number, uint64_t *length, u8 *buffer); 28int64_t opal_console_read(int64_t term_number, uint64_t *length, u8 *buffer);
28int64_t opal_console_write_buffer_space(uint64_t term_number, uint64_t *length); 29int64_t opal_console_write_buffer_space(uint64_t term_number, uint64_t *length);
29int64_t opal_console_flush(uint64_t term_number); 30int64_t opal_console_flush(uint64_t term_number);
30int64_t opal_poll_events(uint64_t *outstanding_event_mask); 31int64_t opal_poll_events(uint64_t *outstanding_event_mask);
31 32
33void opal_kentry(unsigned long fdt_addr, void *vmlinux_addr);
34
32static int opal_con_open(void) 35static int opal_con_open(void)
33{ 36{
37 /*
38 * When OPAL loads the boot kernel it stashes the OPAL base and entry
39 * address in r8 and r9 so the kernel can use the OPAL console
40 * before unflattening the devicetree. While executing the wrapper will
41 * probably trash r8 and r9 so this kentry hook restores them before
42 * entering the decompressed kernel.
43 */
44 platform_ops.kentry = opal_kentry;
34 return 0; 45 return 0;
35} 46}
36 47
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 309d1b127e96..fad1862f4b2d 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -30,6 +30,7 @@ struct platform_ops {
30 void * (*realloc)(void *ptr, unsigned long size); 30 void * (*realloc)(void *ptr, unsigned long size);
31 void (*exit)(void); 31 void (*exit)(void);
32 void * (*vmlinux_alloc)(unsigned long size); 32 void * (*vmlinux_alloc)(unsigned long size);
33 void (*kentry)(unsigned long fdt_addr, void *vmlinux_addr);
33}; 34};
34extern struct platform_ops platform_ops; 35extern struct platform_ops platform_ops;
35 36
diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h
index d1492736d852..e0baba1535e6 100644
--- a/arch/powerpc/include/asm/asm-prototypes.h
+++ b/arch/powerpc/include/asm/asm-prototypes.h
@@ -14,6 +14,10 @@
14 14
15#include <linux/threads.h> 15#include <linux/threads.h>
16#include <linux/kprobes.h> 16#include <linux/kprobes.h>
17#include <asm/cacheflush.h>
18#include <asm/checksum.h>
19#include <asm/uaccess.h>
20#include <asm/epapr_hcalls.h>
17 21
18#include <uapi/asm/ucontext.h> 22#include <uapi/asm/ucontext.h>
19 23
@@ -109,4 +113,12 @@ void early_setup_secondary(void);
109/* time */ 113/* time */
110void accumulate_stolen_time(void); 114void accumulate_stolen_time(void);
111 115
116/* misc runtime */
117extern u64 __bswapdi2(u64);
118extern s64 __lshrdi3(s64, int);
119extern s64 __ashldi3(s64, int);
120extern s64 __ashrdi3(s64, int);
121extern int __cmpdi2(s64, s64);
122extern int __ucmpdi2(u64, u64);
123
112#endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */ 124#endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e88368354e49..e311c25751a4 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -29,6 +29,12 @@
29 */ 29 */
30 30
31/* 31/*
32 * Kernel read only support.
33 * We added the ppp value 0b110 in ISA 2.04.
34 */
35#define MMU_FTR_KERNEL_RO ASM_CONST(0x00004000)
36
37/*
32 * We need to clear top 16bits of va (from the remaining 64 bits )in 38 * We need to clear top 16bits of va (from the remaining 64 bits )in
33 * tlbie* instructions 39 * tlbie* instructions
34 */ 40 */
@@ -103,10 +109,10 @@
103#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2 109#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2
104#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA 110#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA
105#define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE 111#define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
106#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE 112#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
107#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE 113#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
108#define MMU_FTRS_POWER8 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE 114#define MMU_FTRS_POWER8 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
109#define MMU_FTRS_POWER9 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE 115#define MMU_FTRS_POWER9 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
110#define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ 116#define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
111 MMU_FTR_CI_LARGE_PAGE 117 MMU_FTR_CI_LARGE_PAGE
112#define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ 118#define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 9cd4e8cbc78c..9e1499f98def 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -355,6 +355,7 @@
355#define LPCR_PECE0 ASM_CONST(0x0000000000004000) /* ext. exceptions can cause exit */ 355#define LPCR_PECE0 ASM_CONST(0x0000000000004000) /* ext. exceptions can cause exit */
356#define LPCR_PECE1 ASM_CONST(0x0000000000002000) /* decrementer can cause exit */ 356#define LPCR_PECE1 ASM_CONST(0x0000000000002000) /* decrementer can cause exit */
357#define LPCR_PECE2 ASM_CONST(0x0000000000001000) /* machine check etc can cause exit */ 357#define LPCR_PECE2 ASM_CONST(0x0000000000001000) /* machine check etc can cause exit */
358#define LPCR_PECE_HVEE ASM_CONST(0x0000400000000000) /* P9 Wakeup on HV interrupts */
358#define LPCR_MER ASM_CONST(0x0000000000000800) /* Mediated External Exception */ 359#define LPCR_MER ASM_CONST(0x0000000000000800) /* Mediated External Exception */
359#define LPCR_MER_SH 11 360#define LPCR_MER_SH 11
360#define LPCR_TC ASM_CONST(0x0000000000000200) /* Translation control */ 361#define LPCR_TC ASM_CONST(0x0000000000000200) /* Translation control */
diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
index 52ff3f025437..37c027ca83b2 100644
--- a/arch/powerpc/kernel/cpu_setup_power.S
+++ b/arch/powerpc/kernel/cpu_setup_power.S
@@ -98,8 +98,8 @@ _GLOBAL(__setup_cpu_power9)
98 li r0,0 98 li r0,0
99 mtspr SPRN_LPID,r0 99 mtspr SPRN_LPID,r0
100 mfspr r3,SPRN_LPCR 100 mfspr r3,SPRN_LPCR
101 ori r3, r3, LPCR_PECEDH 101 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
102 ori r3, r3, LPCR_HVICE 102 or r3, r3, r4
103 bl __init_LPCR 103 bl __init_LPCR
104 bl __init_HFSCR 104 bl __init_HFSCR
105 bl __init_tlb_power9 105 bl __init_tlb_power9
@@ -118,8 +118,8 @@ _GLOBAL(__restore_cpu_power9)
118 li r0,0 118 li r0,0
119 mtspr SPRN_LPID,r0 119 mtspr SPRN_LPID,r0
120 mfspr r3,SPRN_LPCR 120 mfspr r3,SPRN_LPCR
121 ori r3, r3, LPCR_PECEDH 121 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
122 ori r3, r3, LPCR_HVICE 122 or r3, r3, r4
123 bl __init_LPCR 123 bl __init_LPCR
124 bl __init_HFSCR 124 bl __init_HFSCR
125 bl __init_tlb_power9 125 bl __init_tlb_power9
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index a62be72da274..5c31369435f2 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -671,8 +671,10 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
671 671
672 /* Clear frozen state */ 672 /* Clear frozen state */
673 rc = eeh_clear_pe_frozen_state(pe, false); 673 rc = eeh_clear_pe_frozen_state(pe, false);
674 if (rc) 674 if (rc) {
675 pci_unlock_rescan_remove();
675 return rc; 676 return rc;
677 }
676 678
677 /* Give the system 5 seconds to finish running the user-space 679 /* Give the system 5 seconds to finish running the user-space
678 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, 680 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 8295f51c1a5f..7394b770ae1f 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -94,8 +94,17 @@ SECTIONS
94 * detected, and will result in a crash at boot due to offsets being 94 * detected, and will result in a crash at boot due to offsets being
95 * wrong. 95 * wrong.
96 */ 96 */
97#ifdef CONFIG_PPC64
98 /*
99 * BLOCK(0) overrides the default output section alignment because
100 * this needs to start right after .head.text in order for fixed
101 * section placement to work.
102 */
103 .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
104#else
97 .text : AT(ADDR(.text) - LOAD_OFFSET) { 105 .text : AT(ADDR(.text) - LOAD_OFFSET) {
98 ALIGN_FUNCTION(); 106 ALIGN_FUNCTION();
107#endif
99 /* careful! __ftr_alt_* sections need to be close to .text */ 108 /* careful! __ftr_alt_* sections need to be close to .text */
100 *(.text .fixup __ftr_alt_* .ref.text) 109 *(.text .fixup __ftr_alt_* .ref.text)
101 SCHED_TEXT 110 SCHED_TEXT
diff --git a/arch/powerpc/mm/hash64_4k.c b/arch/powerpc/mm/hash64_4k.c
index 42c702b3be1f..6fa450c12d6d 100644
--- a/arch/powerpc/mm/hash64_4k.c
+++ b/arch/powerpc/mm/hash64_4k.c
@@ -55,7 +55,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
55 */ 55 */
56 rflags = htab_convert_pte_flags(new_pte); 56 rflags = htab_convert_pte_flags(new_pte);
57 57
58 if (!cpu_has_feature(CPU_FTR_NOEXECUTE) && 58 if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
59 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) 59 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE))
60 rflags = hash_page_do_lazy_icache(rflags, __pte(old_pte), trap); 60 rflags = hash_page_do_lazy_icache(rflags, __pte(old_pte), trap);
61 61
diff --git a/arch/powerpc/mm/hash64_64k.c b/arch/powerpc/mm/hash64_64k.c
index 3bbbea07378c..1a68cb19b0e3 100644
--- a/arch/powerpc/mm/hash64_64k.c
+++ b/arch/powerpc/mm/hash64_64k.c
@@ -87,7 +87,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
87 subpg_pte = new_pte & ~subpg_prot; 87 subpg_pte = new_pte & ~subpg_prot;
88 rflags = htab_convert_pte_flags(subpg_pte); 88 rflags = htab_convert_pte_flags(subpg_pte);
89 89
90 if (!cpu_has_feature(CPU_FTR_NOEXECUTE) && 90 if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
91 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) { 91 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) {
92 92
93 /* 93 /*
@@ -258,7 +258,7 @@ int __hash_page_64K(unsigned long ea, unsigned long access,
258 258
259 rflags = htab_convert_pte_flags(new_pte); 259 rflags = htab_convert_pte_flags(new_pte);
260 260
261 if (!cpu_has_feature(CPU_FTR_NOEXECUTE) && 261 if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
262 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) 262 !cpu_has_feature(CPU_FTR_COHERENT_ICACHE))
263 rflags = hash_page_do_lazy_icache(rflags, __pte(old_pte), trap); 263 rflags = hash_page_do_lazy_icache(rflags, __pte(old_pte), trap);
264 264
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 5503078090cd..78dabf065ba9 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -193,8 +193,12 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
193 /* 193 /*
194 * Kernel read only mapped with ppp bits 0b110 194 * Kernel read only mapped with ppp bits 0b110
195 */ 195 */
196 if (!(pteflags & _PAGE_WRITE)) 196 if (!(pteflags & _PAGE_WRITE)) {
197 rflags |= (HPTE_R_PP0 | 0x2); 197 if (mmu_has_feature(MMU_FTR_KERNEL_RO))
198 rflags |= (HPTE_R_PP0 | 0x2);
199 else
200 rflags |= 0x3;
201 }
198 } else { 202 } else {
199 if (pteflags & _PAGE_RWX) 203 if (pteflags & _PAGE_RWX)
200 rflags |= 0x2; 204 rflags |= 0x2;
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 9d4bf3ab049e..6e395c996900 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -69,7 +69,7 @@ u64 x86_perf_event_update(struct perf_event *event)
69 int shift = 64 - x86_pmu.cntval_bits; 69 int shift = 64 - x86_pmu.cntval_bits;
70 u64 prev_raw_count, new_raw_count; 70 u64 prev_raw_count, new_raw_count;
71 int idx = hwc->idx; 71 int idx = hwc->idx;
72 s64 delta; 72 u64 delta;
73 73
74 if (idx == INTEL_PMC_IDX_FIXED_BTS) 74 if (idx == INTEL_PMC_IDX_FIXED_BTS)
75 return 0; 75 return 0;
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a74a2dbc0180..cb8522290e6a 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -4034,7 +4034,7 @@ __init int intel_pmu_init(void)
4034 4034
4035 /* Support full width counters using alternative MSR range */ 4035 /* Support full width counters using alternative MSR range */
4036 if (x86_pmu.intel_cap.full_width_write) { 4036 if (x86_pmu.intel_cap.full_width_write) {
4037 x86_pmu.max_period = x86_pmu.cntval_mask; 4037 x86_pmu.max_period = x86_pmu.cntval_mask >> 1;
4038 x86_pmu.perfctr = MSR_IA32_PMC0; 4038 x86_pmu.perfctr = MSR_IA32_PMC0;
4039 pr_cont("full-width counters, "); 4039 pr_cont("full-width counters, ");
4040 } 4040 }
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index 4f5ac726335f..da51e5a3e2ff 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -540,6 +540,7 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
540 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates), 540 X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates),
541 541
542 X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNL, knl_cstates), 542 X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNL, knl_cstates),
543 X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNM, knl_cstates),
543 { }, 544 { },
544}; 545};
545MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match); 546MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match);
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index 03d269bed941..24118c0b4640 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -272,7 +272,6 @@ struct compat_shmid64_ds {
272/* 272/*
273 * The type of struct elf_prstatus.pr_reg in compatible core dumps. 273 * The type of struct elf_prstatus.pr_reg in compatible core dumps.
274 */ 274 */
275#ifdef CONFIG_X86_X32_ABI
276typedef struct user_regs_struct compat_elf_gregset_t; 275typedef struct user_regs_struct compat_elf_gregset_t;
277 276
278/* Full regset -- prstatus on x32, otherwise on ia32 */ 277/* Full regset -- prstatus on x32, otherwise on ia32 */
@@ -281,10 +280,9 @@ typedef struct user_regs_struct compat_elf_gregset_t;
281 do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \ 280 do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \
282 while (0) 281 while (0)
283 282
283#ifdef CONFIG_X86_X32_ABI
284#define COMPAT_USE_64BIT_TIME \ 284#define COMPAT_USE_64BIT_TIME \
285 (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) 285 (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
286#else
287typedef struct user_regs_struct32 compat_elf_gregset_t;
288#endif 286#endif
289 287
290/* 288/*
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index aeef53ce93e1..35690a168cf7 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -815,9 +815,9 @@ static __init void map_mmioh_high_uv3(int index, int min_pnode, int max_pnode)
815 l = li; 815 l = li;
816 } 816 }
817 addr1 = (base << shift) + 817 addr1 = (base << shift) +
818 f * (unsigned long)(1 << m_io); 818 f * (1ULL << m_io);
819 addr2 = (base << shift) + 819 addr2 = (base << shift) +
820 (l + 1) * (unsigned long)(1 << m_io); 820 (l + 1) * (1ULL << m_io);
821 pr_info("UV: %s[%03d..%03d] NASID 0x%04x ADDR 0x%016lx - 0x%016lx\n", 821 pr_info("UV: %s[%03d..%03d] NASID 0x%04x ADDR 0x%016lx - 0x%016lx\n",
822 id, fi, li, lnasid, addr1, addr2); 822 id, fi, li, lnasid, addr1, addr2);
823 if (max_io < l) 823 if (max_io < l)
diff --git a/arch/x86/kernel/unwind_guess.c b/arch/x86/kernel/unwind_guess.c
index b80e8bf43cc6..22881ddcbb9f 100644
--- a/arch/x86/kernel/unwind_guess.c
+++ b/arch/x86/kernel/unwind_guess.c
@@ -7,11 +7,13 @@
7 7
8unsigned long unwind_get_return_address(struct unwind_state *state) 8unsigned long unwind_get_return_address(struct unwind_state *state)
9{ 9{
10 unsigned long addr = READ_ONCE_NOCHECK(*state->sp); 10 unsigned long addr;
11 11
12 if (unwind_done(state)) 12 if (unwind_done(state))
13 return 0; 13 return 0;
14 14
15 addr = READ_ONCE_NOCHECK(*state->sp);
16
15 return ftrace_graph_ret_addr(state->task, &state->graph_idx, 17 return ftrace_graph_ret_addr(state->task, &state->graph_idx,
16 addr, state->sp); 18 addr, state->sp);
17} 19}
@@ -25,11 +27,12 @@ bool unwind_next_frame(struct unwind_state *state)
25 return false; 27 return false;
26 28
27 do { 29 do {
28 unsigned long addr = READ_ONCE_NOCHECK(*state->sp); 30 for (state->sp++; state->sp < info->end; state->sp++) {
31 unsigned long addr = READ_ONCE_NOCHECK(*state->sp);
29 32
30 for (state->sp++; state->sp < info->end; state->sp++)
31 if (__kernel_text_address(addr)) 33 if (__kernel_text_address(addr))
32 return true; 34 return true;
35 }
33 36
34 state->sp = info->next_sp; 37 state->sp = info->next_sp;
35 38
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index cbd7b92585bb..a3ce9d260d68 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2105,16 +2105,10 @@ static int em_iret(struct x86_emulate_ctxt *ctxt)
2105static int em_jmp_far(struct x86_emulate_ctxt *ctxt) 2105static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
2106{ 2106{
2107 int rc; 2107 int rc;
2108 unsigned short sel, old_sel; 2108 unsigned short sel;
2109 struct desc_struct old_desc, new_desc; 2109 struct desc_struct new_desc;
2110 const struct x86_emulate_ops *ops = ctxt->ops;
2111 u8 cpl = ctxt->ops->cpl(ctxt); 2110 u8 cpl = ctxt->ops->cpl(ctxt);
2112 2111
2113 /* Assignment of RIP may only fail in 64-bit mode */
2114 if (ctxt->mode == X86EMUL_MODE_PROT64)
2115 ops->get_segment(ctxt, &old_sel, &old_desc, NULL,
2116 VCPU_SREG_CS);
2117
2118 memcpy(&sel, ctxt->src.valptr + ctxt->op_bytes, 2); 2112 memcpy(&sel, ctxt->src.valptr + ctxt->op_bytes, 2);
2119 2113
2120 rc = __load_segment_descriptor(ctxt, sel, VCPU_SREG_CS, cpl, 2114 rc = __load_segment_descriptor(ctxt, sel, VCPU_SREG_CS, cpl,
@@ -2124,12 +2118,10 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
2124 return rc; 2118 return rc;
2125 2119
2126 rc = assign_eip_far(ctxt, ctxt->src.val, &new_desc); 2120 rc = assign_eip_far(ctxt, ctxt->src.val, &new_desc);
2127 if (rc != X86EMUL_CONTINUE) { 2121 /* Error handling is not implemented. */
2128 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64); 2122 if (rc != X86EMUL_CONTINUE)
2129 /* assigning eip failed; restore the old cs */ 2123 return X86EMUL_UNHANDLEABLE;
2130 ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS); 2124
2131 return rc;
2132 }
2133 return rc; 2125 return rc;
2134} 2126}
2135 2127
@@ -2189,14 +2181,8 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
2189{ 2181{
2190 int rc; 2182 int rc;
2191 unsigned long eip, cs; 2183 unsigned long eip, cs;
2192 u16 old_cs;
2193 int cpl = ctxt->ops->cpl(ctxt); 2184 int cpl = ctxt->ops->cpl(ctxt);
2194 struct desc_struct old_desc, new_desc; 2185 struct desc_struct new_desc;
2195 const struct x86_emulate_ops *ops = ctxt->ops;
2196
2197 if (ctxt->mode == X86EMUL_MODE_PROT64)
2198 ops->get_segment(ctxt, &old_cs, &old_desc, NULL,
2199 VCPU_SREG_CS);
2200 2186
2201 rc = emulate_pop(ctxt, &eip, ctxt->op_bytes); 2187 rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
2202 if (rc != X86EMUL_CONTINUE) 2188 if (rc != X86EMUL_CONTINUE)
@@ -2213,10 +2199,10 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
2213 if (rc != X86EMUL_CONTINUE) 2199 if (rc != X86EMUL_CONTINUE)
2214 return rc; 2200 return rc;
2215 rc = assign_eip_far(ctxt, eip, &new_desc); 2201 rc = assign_eip_far(ctxt, eip, &new_desc);
2216 if (rc != X86EMUL_CONTINUE) { 2202 /* Error handling is not implemented. */
2217 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64); 2203 if (rc != X86EMUL_CONTINUE)
2218 ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS); 2204 return X86EMUL_UNHANDLEABLE;
2219 } 2205
2220 return rc; 2206 return rc;
2221} 2207}
2222 2208
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 1a22de70f7f7..6e219e5c07d2 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -94,7 +94,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
94static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) 94static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)
95{ 95{
96 ioapic->rtc_status.pending_eoi = 0; 96 ioapic->rtc_status.pending_eoi = 0;
97 bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPUS); 97 bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID);
98} 98}
99 99
100static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic); 100static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
index 7d2692a49657..1cc6e54436db 100644
--- a/arch/x86/kvm/ioapic.h
+++ b/arch/x86/kvm/ioapic.h
@@ -42,13 +42,13 @@ struct kvm_vcpu;
42 42
43struct dest_map { 43struct dest_map {
44 /* vcpu bitmap where IRQ has been sent */ 44 /* vcpu bitmap where IRQ has been sent */
45 DECLARE_BITMAP(map, KVM_MAX_VCPUS); 45 DECLARE_BITMAP(map, KVM_MAX_VCPU_ID);
46 46
47 /* 47 /*
48 * Vector sent to a given vcpu, only valid when 48 * Vector sent to a given vcpu, only valid when
49 * the vcpu's bit in map is set 49 * the vcpu's bit in map is set
50 */ 50 */
51 u8 vectors[KVM_MAX_VCPUS]; 51 u8 vectors[KVM_MAX_VCPU_ID];
52}; 52};
53 53
54 54
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 4da03030d5a7..6c0191615f23 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -41,6 +41,15 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
41 bool line_status) 41 bool line_status)
42{ 42{
43 struct kvm_pic *pic = pic_irqchip(kvm); 43 struct kvm_pic *pic = pic_irqchip(kvm);
44
45 /*
46 * XXX: rejecting pic routes when pic isn't in use would be better,
47 * but the default routing table is installed while kvm->arch.vpic is
48 * NULL and KVM_CREATE_IRQCHIP can race with KVM_IRQ_LINE.
49 */
50 if (!pic)
51 return -1;
52
44 return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level); 53 return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level);
45} 54}
46 55
@@ -49,6 +58,10 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
49 bool line_status) 58 bool line_status)
50{ 59{
51 struct kvm_ioapic *ioapic = kvm->arch.vioapic; 60 struct kvm_ioapic *ioapic = kvm->arch.vioapic;
61
62 if (!ioapic)
63 return -1;
64
52 return kvm_ioapic_set_irq(ioapic, e->irqchip.pin, irq_source_id, level, 65 return kvm_ioapic_set_irq(ioapic, e->irqchip.pin, irq_source_id, level,
53 line_status); 66 line_status);
54} 67}
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 23b99f305382..6f69340f9fa3 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -138,7 +138,7 @@ static inline bool kvm_apic_map_get_logical_dest(struct kvm_apic_map *map,
138 *mask = dest_id & 0xff; 138 *mask = dest_id & 0xff;
139 return true; 139 return true;
140 case KVM_APIC_MODE_XAPIC_CLUSTER: 140 case KVM_APIC_MODE_XAPIC_CLUSTER:
141 *cluster = map->xapic_cluster_map[dest_id >> 4]; 141 *cluster = map->xapic_cluster_map[(dest_id >> 4) & 0xf];
142 *mask = dest_id & 0xf; 142 *mask = dest_id & 0xf;
143 return true; 143 return true;
144 default: 144 default:
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 55130846ac87..c0533fbc39e3 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -196,6 +196,7 @@ static int xo15_sci_remove(struct acpi_device *device)
196 return 0; 196 return 0;
197} 197}
198 198
199#ifdef CONFIG_PM_SLEEP
199static int xo15_sci_resume(struct device *dev) 200static int xo15_sci_resume(struct device *dev)
200{ 201{
201 /* Enable all EC events */ 202 /* Enable all EC events */
@@ -207,6 +208,7 @@ static int xo15_sci_resume(struct device *dev)
207 208
208 return 0; 209 return 0;
209} 210}
211#endif
210 212
211static SIMPLE_DEV_PM_OPS(xo15_sci_pm, NULL, xo15_sci_resume); 213static SIMPLE_DEV_PM_OPS(xo15_sci_pm, NULL, xo15_sci_resume);
212 214
diff --git a/arch/x86/tools/relocs.h b/arch/x86/tools/relocs.h
index f59590645b68..1d23bf953a4a 100644
--- a/arch/x86/tools/relocs.h
+++ b/arch/x86/tools/relocs.h
@@ -16,7 +16,7 @@
16#include <regex.h> 16#include <regex.h>
17#include <tools/le_byteshift.h> 17#include <tools/le_byteshift.h>
18 18
19void die(char *fmt, ...); 19void die(char *fmt, ...) __attribute__((noreturn));
20 20
21#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 21#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
22 22
diff --git a/block/blk-map.c b/block/blk-map.c
index b8657fa8dc9a..27fd8d92892d 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -118,6 +118,9 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
118 struct iov_iter i; 118 struct iov_iter i;
119 int ret; 119 int ret;
120 120
121 if (!iter_is_iovec(iter))
122 goto fail;
123
121 if (map_data) 124 if (map_data)
122 copy = true; 125 copy = true;
123 else if (iov_iter_alignment(iter) & align) 126 else if (iov_iter_alignment(iter) & align)
@@ -140,6 +143,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
140 143
141unmap_rq: 144unmap_rq:
142 __blk_rq_unmap_user(bio); 145 __blk_rq_unmap_user(bio);
146fail:
143 rq->bio = NULL; 147 rq->bio = NULL;
144 return -EINVAL; 148 return -EINVAL;
145} 149}
diff --git a/crypto/Makefile b/crypto/Makefile
index 99cc64ac70ef..bd6a029094e6 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o
40 40
41$(obj)/rsapubkey-asn1.o: $(obj)/rsapubkey-asn1.c $(obj)/rsapubkey-asn1.h 41$(obj)/rsapubkey-asn1.o: $(obj)/rsapubkey-asn1.c $(obj)/rsapubkey-asn1.h
42$(obj)/rsaprivkey-asn1.o: $(obj)/rsaprivkey-asn1.c $(obj)/rsaprivkey-asn1.h 42$(obj)/rsaprivkey-asn1.o: $(obj)/rsaprivkey-asn1.c $(obj)/rsaprivkey-asn1.h
43$(obj)/rsa_helper.o: $(obj)/rsapubkey-asn1.h $(obj)/rsaprivkey-asn1.h
43clean-files += rsapubkey-asn1.c rsapubkey-asn1.h 44clean-files += rsapubkey-asn1.c rsapubkey-asn1.h
44clean-files += rsaprivkey-asn1.c rsaprivkey-asn1.h 45clean-files += rsaprivkey-asn1.c rsaprivkey-asn1.h
45 46
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 80a0f1a78551..e9c0993b131d 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -81,7 +81,11 @@ static inline bool aead_sufficient_data(struct aead_ctx *ctx)
81{ 81{
82 unsigned as = crypto_aead_authsize(crypto_aead_reqtfm(&ctx->aead_req)); 82 unsigned as = crypto_aead_authsize(crypto_aead_reqtfm(&ctx->aead_req));
83 83
84 return ctx->used >= ctx->aead_assoclen + as; 84 /*
85 * The minimum amount of memory needed for an AEAD cipher is
86 * the AAD and in case of decryption the tag.
87 */
88 return ctx->used >= ctx->aead_assoclen + (ctx->enc ? 0 : as);
85} 89}
86 90
87static void aead_reset_ctx(struct aead_ctx *ctx) 91static void aead_reset_ctx(struct aead_ctx *ctx)
@@ -416,7 +420,7 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
416 unsigned int i, reqlen = GET_REQ_SIZE(tfm); 420 unsigned int i, reqlen = GET_REQ_SIZE(tfm);
417 int err = -ENOMEM; 421 int err = -ENOMEM;
418 unsigned long used; 422 unsigned long used;
419 size_t outlen; 423 size_t outlen = 0;
420 size_t usedpages = 0; 424 size_t usedpages = 0;
421 425
422 lock_sock(sk); 426 lock_sock(sk);
@@ -426,12 +430,15 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
426 goto unlock; 430 goto unlock;
427 } 431 }
428 432
429 used = ctx->used;
430 outlen = used;
431
432 if (!aead_sufficient_data(ctx)) 433 if (!aead_sufficient_data(ctx))
433 goto unlock; 434 goto unlock;
434 435
436 used = ctx->used;
437 if (ctx->enc)
438 outlen = used + as;
439 else
440 outlen = used - as;
441
435 req = sock_kmalloc(sk, reqlen, GFP_KERNEL); 442 req = sock_kmalloc(sk, reqlen, GFP_KERNEL);
436 if (unlikely(!req)) 443 if (unlikely(!req))
437 goto unlock; 444 goto unlock;
@@ -445,7 +452,7 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
445 aead_request_set_ad(req, ctx->aead_assoclen); 452 aead_request_set_ad(req, ctx->aead_assoclen);
446 aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 453 aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
447 aead_async_cb, sk); 454 aead_async_cb, sk);
448 used -= ctx->aead_assoclen + (ctx->enc ? as : 0); 455 used -= ctx->aead_assoclen;
449 456
450 /* take over all tx sgls from ctx */ 457 /* take over all tx sgls from ctx */
451 areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * sgl->cur, 458 areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * sgl->cur,
@@ -461,7 +468,7 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
461 areq->tsgls = sgl->cur; 468 areq->tsgls = sgl->cur;
462 469
463 /* create rx sgls */ 470 /* create rx sgls */
464 while (iov_iter_count(&msg->msg_iter)) { 471 while (outlen > usedpages && iov_iter_count(&msg->msg_iter)) {
465 size_t seglen = min_t(size_t, iov_iter_count(&msg->msg_iter), 472 size_t seglen = min_t(size_t, iov_iter_count(&msg->msg_iter),
466 (outlen - usedpages)); 473 (outlen - usedpages));
467 474
@@ -491,16 +498,14 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
491 498
492 last_rsgl = rsgl; 499 last_rsgl = rsgl;
493 500
494 /* we do not need more iovecs as we have sufficient memory */
495 if (outlen <= usedpages)
496 break;
497
498 iov_iter_advance(&msg->msg_iter, err); 501 iov_iter_advance(&msg->msg_iter, err);
499 } 502 }
500 err = -EINVAL; 503
501 /* ensure output buffer is sufficiently large */ 504 /* ensure output buffer is sufficiently large */
502 if (usedpages < outlen) 505 if (usedpages < outlen) {
503 goto free; 506 err = -EINVAL;
507 goto unlock;
508 }
504 509
505 aead_request_set_crypt(req, areq->tsgl, areq->first_rsgl.sgl.sg, used, 510 aead_request_set_crypt(req, areq->tsgl, areq->first_rsgl.sgl.sg, used,
506 areq->iv); 511 areq->iv);
@@ -571,6 +576,7 @@ static int aead_recvmsg_sync(struct socket *sock, struct msghdr *msg, int flags)
571 goto unlock; 576 goto unlock;
572 } 577 }
573 578
579 /* data length provided by caller via sendmsg/sendpage */
574 used = ctx->used; 580 used = ctx->used;
575 581
576 /* 582 /*
@@ -585,16 +591,27 @@ static int aead_recvmsg_sync(struct socket *sock, struct msghdr *msg, int flags)
585 if (!aead_sufficient_data(ctx)) 591 if (!aead_sufficient_data(ctx))
586 goto unlock; 592 goto unlock;
587 593
588 outlen = used; 594 /*
595 * Calculate the minimum output buffer size holding the result of the
596 * cipher operation. When encrypting data, the receiving buffer is
597 * larger by the tag length compared to the input buffer as the
598 * encryption operation generates the tag. For decryption, the input
599 * buffer provides the tag which is consumed resulting in only the
600 * plaintext without a buffer for the tag returned to the caller.
601 */
602 if (ctx->enc)
603 outlen = used + as;
604 else
605 outlen = used - as;
589 606
590 /* 607 /*
591 * The cipher operation input data is reduced by the associated data 608 * The cipher operation input data is reduced by the associated data
592 * length as this data is processed separately later on. 609 * length as this data is processed separately later on.
593 */ 610 */
594 used -= ctx->aead_assoclen + (ctx->enc ? as : 0); 611 used -= ctx->aead_assoclen;
595 612
596 /* convert iovecs of output buffers into scatterlists */ 613 /* convert iovecs of output buffers into scatterlists */
597 while (iov_iter_count(&msg->msg_iter)) { 614 while (outlen > usedpages && iov_iter_count(&msg->msg_iter)) {
598 size_t seglen = min_t(size_t, iov_iter_count(&msg->msg_iter), 615 size_t seglen = min_t(size_t, iov_iter_count(&msg->msg_iter),
599 (outlen - usedpages)); 616 (outlen - usedpages));
600 617
@@ -621,16 +638,14 @@ static int aead_recvmsg_sync(struct socket *sock, struct msghdr *msg, int flags)
621 638
622 last_rsgl = rsgl; 639 last_rsgl = rsgl;
623 640
624 /* we do not need more iovecs as we have sufficient memory */
625 if (outlen <= usedpages)
626 break;
627 iov_iter_advance(&msg->msg_iter, err); 641 iov_iter_advance(&msg->msg_iter, err);
628 } 642 }
629 643
630 err = -EINVAL;
631 /* ensure output buffer is sufficiently large */ 644 /* ensure output buffer is sufficiently large */
632 if (usedpages < outlen) 645 if (usedpages < outlen) {
646 err = -EINVAL;
633 goto unlock; 647 goto unlock;
648 }
634 649
635 sg_mark_end(sgl->sg + sgl->cur - 1); 650 sg_mark_end(sgl->sg + sgl->cur - 1);
636 aead_request_set_crypt(&ctx->aead_req, sgl->sg, ctx->first_rsgl.sgl.sg, 651 aead_request_set_crypt(&ctx->aead_req, sgl->sg, ctx->first_rsgl.sgl.sg,
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 865f46ea724f..c80765b211cf 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -133,7 +133,6 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
133 return cert; 133 return cert;
134 134
135error_decode: 135error_decode:
136 kfree(cert->pub->key);
137 kfree(ctx); 136 kfree(ctx);
138error_no_ctx: 137error_no_ctx:
139 x509_free_certificate(cert); 138 x509_free_certificate(cert);
diff --git a/crypto/drbg.c b/crypto/drbg.c
index fb33f7d3b052..053035b5c8f8 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -262,6 +262,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
262 u8 *inbuf, u32 inbuflen, 262 u8 *inbuf, u32 inbuflen,
263 u8 *outbuf, u32 outlen); 263 u8 *outbuf, u32 outlen);
264#define DRBG_CTR_NULL_LEN 128 264#define DRBG_CTR_NULL_LEN 128
265#define DRBG_OUTSCRATCHLEN DRBG_CTR_NULL_LEN
265 266
266/* BCC function for CTR DRBG as defined in 10.4.3 */ 267/* BCC function for CTR DRBG as defined in 10.4.3 */
267static int drbg_ctr_bcc(struct drbg_state *drbg, 268static int drbg_ctr_bcc(struct drbg_state *drbg,
@@ -1644,6 +1645,9 @@ static int drbg_fini_sym_kernel(struct drbg_state *drbg)
1644 kfree(drbg->ctr_null_value_buf); 1645 kfree(drbg->ctr_null_value_buf);
1645 drbg->ctr_null_value = NULL; 1646 drbg->ctr_null_value = NULL;
1646 1647
1648 kfree(drbg->outscratchpadbuf);
1649 drbg->outscratchpadbuf = NULL;
1650
1647 return 0; 1651 return 0;
1648} 1652}
1649 1653
@@ -1708,6 +1712,15 @@ static int drbg_init_sym_kernel(struct drbg_state *drbg)
1708 drbg->ctr_null_value = (u8 *)PTR_ALIGN(drbg->ctr_null_value_buf, 1712 drbg->ctr_null_value = (u8 *)PTR_ALIGN(drbg->ctr_null_value_buf,
1709 alignmask + 1); 1713 alignmask + 1);
1710 1714
1715 drbg->outscratchpadbuf = kmalloc(DRBG_OUTSCRATCHLEN + alignmask,
1716 GFP_KERNEL);
1717 if (!drbg->outscratchpadbuf) {
1718 drbg_fini_sym_kernel(drbg);
1719 return -ENOMEM;
1720 }
1721 drbg->outscratchpad = (u8 *)PTR_ALIGN(drbg->outscratchpadbuf,
1722 alignmask + 1);
1723
1711 return alignmask; 1724 return alignmask;
1712} 1725}
1713 1726
@@ -1737,15 +1750,16 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
1737 u8 *outbuf, u32 outlen) 1750 u8 *outbuf, u32 outlen)
1738{ 1751{
1739 struct scatterlist sg_in; 1752 struct scatterlist sg_in;
1753 int ret;
1740 1754
1741 sg_init_one(&sg_in, inbuf, inlen); 1755 sg_init_one(&sg_in, inbuf, inlen);
1742 1756
1743 while (outlen) { 1757 while (outlen) {
1744 u32 cryptlen = min_t(u32, inlen, outlen); 1758 u32 cryptlen = min3(inlen, outlen, (u32)DRBG_OUTSCRATCHLEN);
1745 struct scatterlist sg_out; 1759 struct scatterlist sg_out;
1746 int ret;
1747 1760
1748 sg_init_one(&sg_out, outbuf, cryptlen); 1761 /* Output buffer may not be valid for SGL, use scratchpad */
1762 sg_init_one(&sg_out, drbg->outscratchpad, cryptlen);
1749 skcipher_request_set_crypt(drbg->ctr_req, &sg_in, &sg_out, 1763 skcipher_request_set_crypt(drbg->ctr_req, &sg_in, &sg_out,
1750 cryptlen, drbg->V); 1764 cryptlen, drbg->V);
1751 ret = crypto_skcipher_encrypt(drbg->ctr_req); 1765 ret = crypto_skcipher_encrypt(drbg->ctr_req);
@@ -1761,14 +1775,19 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
1761 break; 1775 break;
1762 } 1776 }
1763 default: 1777 default:
1764 return ret; 1778 goto out;
1765 } 1779 }
1766 init_completion(&drbg->ctr_completion); 1780 init_completion(&drbg->ctr_completion);
1767 1781
1782 memcpy(outbuf, drbg->outscratchpad, cryptlen);
1783
1768 outlen -= cryptlen; 1784 outlen -= cryptlen;
1769 } 1785 }
1786 ret = 0;
1770 1787
1771 return 0; 1788out:
1789 memzero_explicit(drbg->outscratchpad, DRBG_OUTSCRATCHLEN);
1790 return ret;
1772} 1791}
1773#endif /* CONFIG_CRYPTO_DRBG_CTR */ 1792#endif /* CONFIG_CRYPTO_DRBG_CTR */
1774 1793
diff --git a/crypto/mcryptd.c b/crypto/mcryptd.c
index 94ee44acd465..c207458d6299 100644
--- a/crypto/mcryptd.c
+++ b/crypto/mcryptd.c
@@ -254,18 +254,22 @@ out_free_inst:
254 goto out; 254 goto out;
255} 255}
256 256
257static inline void mcryptd_check_internal(struct rtattr **tb, u32 *type, 257static inline bool mcryptd_check_internal(struct rtattr **tb, u32 *type,
258 u32 *mask) 258 u32 *mask)
259{ 259{
260 struct crypto_attr_type *algt; 260 struct crypto_attr_type *algt;
261 261
262 algt = crypto_get_attr_type(tb); 262 algt = crypto_get_attr_type(tb);
263 if (IS_ERR(algt)) 263 if (IS_ERR(algt))
264 return; 264 return false;
265 if ((algt->type & CRYPTO_ALG_INTERNAL)) 265
266 *type |= CRYPTO_ALG_INTERNAL; 266 *type |= algt->type & CRYPTO_ALG_INTERNAL;
267 if ((algt->mask & CRYPTO_ALG_INTERNAL)) 267 *mask |= algt->mask & CRYPTO_ALG_INTERNAL;
268 *mask |= CRYPTO_ALG_INTERNAL; 268
269 if (*type & *mask & CRYPTO_ALG_INTERNAL)
270 return true;
271 else
272 return false;
269} 273}
270 274
271static int mcryptd_hash_init_tfm(struct crypto_tfm *tfm) 275static int mcryptd_hash_init_tfm(struct crypto_tfm *tfm)
@@ -492,7 +496,8 @@ static int mcryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
492 u32 mask = 0; 496 u32 mask = 0;
493 int err; 497 int err;
494 498
495 mcryptd_check_internal(tb, &type, &mask); 499 if (!mcryptd_check_internal(tb, &type, &mask))
500 return -EINVAL;
496 501
497 halg = ahash_attr_alg(tb[1], type, mask); 502 halg = ahash_attr_alg(tb[1], type, mask);
498 if (IS_ERR(halg)) 503 if (IS_ERR(halg))
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 71a7d07c28c9..312c4b4dc363 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -94,7 +94,7 @@ static struct acpi_device *to_acpi_dev(struct acpi_nfit_desc *acpi_desc)
94 return to_acpi_device(acpi_desc->dev); 94 return to_acpi_device(acpi_desc->dev);
95} 95}
96 96
97static int xlat_status(void *buf, unsigned int cmd, u32 status) 97static int xlat_bus_status(void *buf, unsigned int cmd, u32 status)
98{ 98{
99 struct nd_cmd_clear_error *clear_err; 99 struct nd_cmd_clear_error *clear_err;
100 struct nd_cmd_ars_status *ars_status; 100 struct nd_cmd_ars_status *ars_status;
@@ -113,7 +113,7 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
113 flags = ND_ARS_PERSISTENT | ND_ARS_VOLATILE; 113 flags = ND_ARS_PERSISTENT | ND_ARS_VOLATILE;
114 if ((status >> 16 & flags) == 0) 114 if ((status >> 16 & flags) == 0)
115 return -ENOTTY; 115 return -ENOTTY;
116 break; 116 return 0;
117 case ND_CMD_ARS_START: 117 case ND_CMD_ARS_START:
118 /* ARS is in progress */ 118 /* ARS is in progress */
119 if ((status & 0xffff) == NFIT_ARS_START_BUSY) 119 if ((status & 0xffff) == NFIT_ARS_START_BUSY)
@@ -122,7 +122,7 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
122 /* Command failed */ 122 /* Command failed */
123 if (status & 0xffff) 123 if (status & 0xffff)
124 return -EIO; 124 return -EIO;
125 break; 125 return 0;
126 case ND_CMD_ARS_STATUS: 126 case ND_CMD_ARS_STATUS:
127 ars_status = buf; 127 ars_status = buf;
128 /* Command failed */ 128 /* Command failed */
@@ -146,7 +146,8 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
146 * then just continue with the returned results. 146 * then just continue with the returned results.
147 */ 147 */
148 if (status == NFIT_ARS_STATUS_INTR) { 148 if (status == NFIT_ARS_STATUS_INTR) {
149 if (ars_status->flags & NFIT_ARS_F_OVERFLOW) 149 if (ars_status->out_length >= 40 && (ars_status->flags
150 & NFIT_ARS_F_OVERFLOW))
150 return -ENOSPC; 151 return -ENOSPC;
151 return 0; 152 return 0;
152 } 153 }
@@ -154,7 +155,7 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
154 /* Unknown status */ 155 /* Unknown status */
155 if (status >> 16) 156 if (status >> 16)
156 return -EIO; 157 return -EIO;
157 break; 158 return 0;
158 case ND_CMD_CLEAR_ERROR: 159 case ND_CMD_CLEAR_ERROR:
159 clear_err = buf; 160 clear_err = buf;
160 if (status & 0xffff) 161 if (status & 0xffff)
@@ -163,7 +164,7 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
163 return -EIO; 164 return -EIO;
164 if (clear_err->length > clear_err->cleared) 165 if (clear_err->length > clear_err->cleared)
165 return clear_err->cleared; 166 return clear_err->cleared;
166 break; 167 return 0;
167 default: 168 default:
168 break; 169 break;
169 } 170 }
@@ -174,9 +175,18 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
174 return 0; 175 return 0;
175} 176}
176 177
177static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 178static int xlat_status(struct nvdimm *nvdimm, void *buf, unsigned int cmd,
178 struct nvdimm *nvdimm, unsigned int cmd, void *buf, 179 u32 status)
179 unsigned int buf_len, int *cmd_rc) 180{
181 if (!nvdimm)
182 return xlat_bus_status(buf, cmd, status);
183 if (status)
184 return -EIO;
185 return 0;
186}
187
188int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
189 unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc)
180{ 190{
181 struct acpi_nfit_desc *acpi_desc = to_acpi_nfit_desc(nd_desc); 191 struct acpi_nfit_desc *acpi_desc = to_acpi_nfit_desc(nd_desc);
182 union acpi_object in_obj, in_buf, *out_obj; 192 union acpi_object in_obj, in_buf, *out_obj;
@@ -298,7 +308,8 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
298 308
299 for (i = 0, offset = 0; i < desc->out_num; i++) { 309 for (i = 0, offset = 0; i < desc->out_num; i++) {
300 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf, 310 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
301 (u32 *) out_obj->buffer.pointer); 311 (u32 *) out_obj->buffer.pointer,
312 out_obj->buffer.length - offset);
302 313
303 if (offset + out_size > out_obj->buffer.length) { 314 if (offset + out_size > out_obj->buffer.length) {
304 dev_dbg(dev, "%s:%s output object underflow cmd: %s field: %d\n", 315 dev_dbg(dev, "%s:%s output object underflow cmd: %s field: %d\n",
@@ -333,7 +344,8 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
333 */ 344 */
334 rc = buf_len - offset - in_buf.buffer.length; 345 rc = buf_len - offset - in_buf.buffer.length;
335 if (cmd_rc) 346 if (cmd_rc)
336 *cmd_rc = xlat_status(buf, cmd, fw_status); 347 *cmd_rc = xlat_status(nvdimm, buf, cmd,
348 fw_status);
337 } else { 349 } else {
338 dev_err(dev, "%s:%s underrun cmd: %s buf_len: %d out_len: %d\n", 350 dev_err(dev, "%s:%s underrun cmd: %s buf_len: %d out_len: %d\n",
339 __func__, dimm_name, cmd_name, buf_len, 351 __func__, dimm_name, cmd_name, buf_len,
@@ -343,7 +355,7 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
343 } else { 355 } else {
344 rc = 0; 356 rc = 0;
345 if (cmd_rc) 357 if (cmd_rc)
346 *cmd_rc = xlat_status(buf, cmd, fw_status); 358 *cmd_rc = xlat_status(nvdimm, buf, cmd, fw_status);
347 } 359 }
348 360
349 out: 361 out:
@@ -351,6 +363,7 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
351 363
352 return rc; 364 return rc;
353} 365}
366EXPORT_SYMBOL_GPL(acpi_nfit_ctl);
354 367
355static const char *spa_type_name(u16 type) 368static const char *spa_type_name(u16 type)
356{ 369{
@@ -2001,19 +2014,32 @@ static int ars_get_status(struct acpi_nfit_desc *acpi_desc)
2001 return cmd_rc; 2014 return cmd_rc;
2002} 2015}
2003 2016
2004static int ars_status_process_records(struct nvdimm_bus *nvdimm_bus, 2017static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc,
2005 struct nd_cmd_ars_status *ars_status) 2018 struct nd_cmd_ars_status *ars_status)
2006{ 2019{
2020 struct nvdimm_bus *nvdimm_bus = acpi_desc->nvdimm_bus;
2007 int rc; 2021 int rc;
2008 u32 i; 2022 u32 i;
2009 2023
2024 /*
2025 * First record starts at 44 byte offset from the start of the
2026 * payload.
2027 */
2028 if (ars_status->out_length < 44)
2029 return 0;
2010 for (i = 0; i < ars_status->num_records; i++) { 2030 for (i = 0; i < ars_status->num_records; i++) {
2031 /* only process full records */
2032 if (ars_status->out_length
2033 < 44 + sizeof(struct nd_ars_record) * (i + 1))
2034 break;
2011 rc = nvdimm_bus_add_poison(nvdimm_bus, 2035 rc = nvdimm_bus_add_poison(nvdimm_bus,
2012 ars_status->records[i].err_address, 2036 ars_status->records[i].err_address,
2013 ars_status->records[i].length); 2037 ars_status->records[i].length);
2014 if (rc) 2038 if (rc)
2015 return rc; 2039 return rc;
2016 } 2040 }
2041 if (i < ars_status->num_records)
2042 dev_warn(acpi_desc->dev, "detected truncated ars results\n");
2017 2043
2018 return 0; 2044 return 0;
2019} 2045}
@@ -2266,8 +2292,7 @@ static int acpi_nfit_query_poison(struct acpi_nfit_desc *acpi_desc,
2266 if (rc < 0 && rc != -ENOSPC) 2292 if (rc < 0 && rc != -ENOSPC)
2267 return rc; 2293 return rc;
2268 2294
2269 if (ars_status_process_records(acpi_desc->nvdimm_bus, 2295 if (ars_status_process_records(acpi_desc, acpi_desc->ars_status))
2270 acpi_desc->ars_status))
2271 return -ENOMEM; 2296 return -ENOMEM;
2272 2297
2273 return 0; 2298 return 0;
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 14296f5267c8..fc29c2e9832e 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -240,5 +240,7 @@ const u8 *to_nfit_uuid(enum nfit_uuids id);
240int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *nfit, acpi_size sz); 240int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *nfit, acpi_size sz);
241void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event); 241void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event);
242void __acpi_nvdimm_notify(struct device *dev, u32 event); 242void __acpi_nvdimm_notify(struct device *dev, u32 event);
243int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
244 unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc);
243void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev); 245void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev);
244#endif /* __NFIT_H__ */ 246#endif /* __NFIT_H__ */
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index deb0ff78eba8..54abb26b7366 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -47,32 +47,15 @@ static void acpi_sleep_tts_switch(u32 acpi_state)
47 } 47 }
48} 48}
49 49
50static void acpi_sleep_pts_switch(u32 acpi_state) 50static int tts_notify_reboot(struct notifier_block *this,
51{
52 acpi_status status;
53
54 status = acpi_execute_simple_method(NULL, "\\_PTS", acpi_state);
55 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
56 /*
57 * OS can't evaluate the _PTS object correctly. Some warning
58 * message will be printed. But it won't break anything.
59 */
60 printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
61 }
62}
63
64static int sleep_notify_reboot(struct notifier_block *this,
65 unsigned long code, void *x) 51 unsigned long code, void *x)
66{ 52{
67 acpi_sleep_tts_switch(ACPI_STATE_S5); 53 acpi_sleep_tts_switch(ACPI_STATE_S5);
68
69 acpi_sleep_pts_switch(ACPI_STATE_S5);
70
71 return NOTIFY_DONE; 54 return NOTIFY_DONE;
72} 55}
73 56
74static struct notifier_block sleep_notifier = { 57static struct notifier_block tts_notifier = {
75 .notifier_call = sleep_notify_reboot, 58 .notifier_call = tts_notify_reboot,
76 .next = NULL, 59 .next = NULL,
77 .priority = 0, 60 .priority = 0,
78}; 61};
@@ -916,9 +899,9 @@ int __init acpi_sleep_init(void)
916 pr_info(PREFIX "(supports%s)\n", supported); 899 pr_info(PREFIX "(supports%s)\n", supported);
917 900
918 /* 901 /*
919 * Register the sleep_notifier to reboot notifier list so that the _TTS 902 * Register the tts_notifier to reboot notifier list so that the _TTS
920 * and _PTS object can also be evaluated when the system enters S5. 903 * object can also be evaluated when the system enters S5.
921 */ 904 */
922 register_reboot_notifier(&sleep_notifier); 905 register_reboot_notifier(&tts_notifier);
923 return 0; 906 return 0;
924} 907}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 9669fc7c19df..74f4c662f776 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1436,13 +1436,6 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
1436 "ahci: MRSM is on, fallback to single MSI\n"); 1436 "ahci: MRSM is on, fallback to single MSI\n");
1437 pci_free_irq_vectors(pdev); 1437 pci_free_irq_vectors(pdev);
1438 } 1438 }
1439
1440 /*
1441 * -ENOSPC indicated we don't have enough vectors. Don't bother
1442 * trying a single vectors for any other error:
1443 */
1444 if (nvec < 0 && nvec != -ENOSPC)
1445 return nvec;
1446 } 1439 }
1447 1440
1448 /* 1441 /*
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 9cceb4a875a5..8e575fbdf31d 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1088,7 +1088,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
1088 desc[1] = tf->command; /* status */ 1088 desc[1] = tf->command; /* status */
1089 desc[2] = tf->device; 1089 desc[2] = tf->device;
1090 desc[3] = tf->nsect; 1090 desc[3] = tf->nsect;
1091 desc[0] = 0; 1091 desc[7] = 0;
1092 if (tf->flags & ATA_TFLAG_LBA48) { 1092 if (tf->flags & ATA_TFLAG_LBA48) {
1093 desc[8] |= 0x80; 1093 desc[8] |= 0x80;
1094 if (tf->hob_nsect) 1094 if (tf->hob_nsect)
@@ -1159,6 +1159,7 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
1159{ 1159{
1160 sdev->use_10_for_rw = 1; 1160 sdev->use_10_for_rw = 1;
1161 sdev->use_10_for_ms = 1; 1161 sdev->use_10_for_ms = 1;
1162 sdev->no_write_same = 1;
1162 1163
1163 /* Schedule policy is determined by ->qc_defer() callback and 1164 /* Schedule policy is determined by ->qc_defer() callback and
1164 * it needs to see every deferred qc. Set dev_blocked to 1 to 1165 * it needs to see every deferred qc. Set dev_blocked to 1 to
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index efc48bf89d51..823e938c9a78 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4090,7 +4090,20 @@ static int mv_platform_probe(struct platform_device *pdev)
4090 4090
4091 /* allocate host */ 4091 /* allocate host */
4092 if (pdev->dev.of_node) { 4092 if (pdev->dev.of_node) {
4093 of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports); 4093 rc = of_property_read_u32(pdev->dev.of_node, "nr-ports",
4094 &n_ports);
4095 if (rc) {
4096 dev_err(&pdev->dev,
4097 "error parsing nr-ports property: %d\n", rc);
4098 return rc;
4099 }
4100
4101 if (n_ports <= 0) {
4102 dev_err(&pdev->dev, "nr-ports must be positive: %d\n",
4103 n_ports);
4104 return -EINVAL;
4105 }
4106
4094 irq = irq_of_parse_and_map(pdev->dev.of_node, 0); 4107 irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
4095 } else { 4108 } else {
4096 mv_platform_data = dev_get_platdata(&pdev->dev); 4109 mv_platform_data = dev_get_platdata(&pdev->dev);
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index f2aaf9e32a36..40c2d561417b 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1727,7 +1727,7 @@ static int eni_do_init(struct atm_dev *dev)
1727 printk("\n"); 1727 printk("\n");
1728 printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page " 1728 printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page "
1729 "mapping\n",dev->number); 1729 "mapping\n",dev->number);
1730 return error; 1730 return -ENOMEM;
1731 } 1731 }
1732 eni_dev->ioaddr = base; 1732 eni_dev->ioaddr = base;
1733 eni_dev->base_diff = real_base - (unsigned long) base; 1733 eni_dev->base_diff = real_base - (unsigned long) base;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index ce43ae3e87b3..445505d9ea07 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -2143,6 +2143,7 @@ static int lanai_dev_open(struct atm_dev *atmdev)
2143 lanai->base = (bus_addr_t) ioremap(raw_base, LANAI_MAPPING_SIZE); 2143 lanai->base = (bus_addr_t) ioremap(raw_base, LANAI_MAPPING_SIZE);
2144 if (lanai->base == NULL) { 2144 if (lanai->base == NULL) {
2145 printk(KERN_ERR DEV_LABEL ": couldn't remap I/O space\n"); 2145 printk(KERN_ERR DEV_LABEL ": couldn't remap I/O space\n");
2146 result = -ENOMEM;
2146 goto error_pci; 2147 goto error_pci;
2147 } 2148 }
2148 /* 3.3: Reset lanai and PHY */ 2149 /* 3.3: Reset lanai and PHY */
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 04365b17ee67..5497f7fc44d0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1403,7 +1403,8 @@ static ssize_t hot_remove_store(struct class *class,
1403 zram = idr_find(&zram_index_idr, dev_id); 1403 zram = idr_find(&zram_index_idr, dev_id);
1404 if (zram) { 1404 if (zram) {
1405 ret = zram_remove(zram); 1405 ret = zram_remove(zram);
1406 idr_remove(&zram_index_idr, dev_id); 1406 if (!ret)
1407 idr_remove(&zram_index_idr, dev_id);
1407 } else { 1408 } else {
1408 ret = -ENODEV; 1409 ret = -ENODEV;
1409 } 1410 }
@@ -1412,8 +1413,14 @@ static ssize_t hot_remove_store(struct class *class,
1412 return ret ? ret : count; 1413 return ret ? ret : count;
1413} 1414}
1414 1415
1416/*
1417 * NOTE: hot_add attribute is not the usual read-only sysfs attribute. In a
1418 * sense that reading from this file does alter the state of your system -- it
1419 * creates a new un-initialized zram device and returns back this device's
1420 * device_id (or an error code if it fails to create a new device).
1421 */
1415static struct class_attribute zram_control_class_attrs[] = { 1422static struct class_attribute zram_control_class_attrs[] = {
1416 __ATTR_RO(hot_add), 1423 __ATTR(hot_add, 0400, hot_add_show, NULL),
1417 __ATTR_WO(hot_remove), 1424 __ATTR_WO(hot_remove),
1418 __ATTR_NULL, 1425 __ATTR_NULL,
1419}; 1426};
diff --git a/drivers/clk/bcm/Kconfig b/drivers/clk/bcm/Kconfig
index f21e9b7afd1a..e3eed5a78404 100644
--- a/drivers/clk/bcm/Kconfig
+++ b/drivers/clk/bcm/Kconfig
@@ -20,7 +20,7 @@ config CLK_BCM_KONA
20 20
21config COMMON_CLK_IPROC 21config COMMON_CLK_IPROC
22 bool "Broadcom iProc clock support" 22 bool "Broadcom iProc clock support"
23 depends on ARCH_BCM_IPROC || COMPILE_TEST 23 depends on ARCH_BCM_IPROC || ARCH_BCM_63XX || COMPILE_TEST
24 depends on COMMON_CLK 24 depends on COMMON_CLK
25 default ARCH_BCM_IPROC 25 default ARCH_BCM_IPROC
26 help 26 help
diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
index 4a82a49cff5e..fc75a335a7ce 100644
--- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
+++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
@@ -143,7 +143,7 @@ static SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(pll_mipi_clk, "pll-mipi",
143 4, 2, /* K */ 143 4, 2, /* K */
144 0, 4, /* M */ 144 0, 4, /* M */
145 21, 0, /* mux */ 145 21, 0, /* mux */
146 BIT(31), /* gate */ 146 BIT(31) | BIT(23) | BIT(22), /* gate */
147 BIT(28), /* lock */ 147 BIT(28), /* lock */
148 CLK_SET_RATE_UNGATE); 148 CLK_SET_RATE_UNGATE);
149 149
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
index 96b40ca57697..9bd1f78a0547 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
@@ -131,7 +131,7 @@ static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi",
131 8, 4, /* N */ 131 8, 4, /* N */
132 4, 2, /* K */ 132 4, 2, /* K */
133 0, 4, /* M */ 133 0, 4, /* M */
134 BIT(31), /* gate */ 134 BIT(31) | BIT(23) | BIT(22), /* gate */
135 BIT(28), /* lock */ 135 BIT(28), /* lock */
136 CLK_SET_RATE_UNGATE); 136 CLK_SET_RATE_UNGATE);
137 137
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 72ff19658985..e483b78c6343 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -558,8 +558,9 @@ static int caam_probe(struct platform_device *pdev)
558 * Enable DECO watchdogs and, if this is a PHYS_ADDR_T_64BIT kernel, 558 * Enable DECO watchdogs and, if this is a PHYS_ADDR_T_64BIT kernel,
559 * long pointers in master configuration register 559 * long pointers in master configuration register
560 */ 560 */
561 clrsetbits_32(&ctrl->mcr, MCFGR_AWCACHE_MASK, MCFGR_AWCACHE_CACH | 561 clrsetbits_32(&ctrl->mcr, MCFGR_AWCACHE_MASK | MCFGR_LONG_PTR,
562 MCFGR_AWCACHE_BUFF | MCFGR_WDENABLE | MCFGR_LARGE_BURST | 562 MCFGR_AWCACHE_CACH | MCFGR_AWCACHE_BUFF |
563 MCFGR_WDENABLE | MCFGR_LARGE_BURST |
563 (sizeof(dma_addr_t) == sizeof(u64) ? MCFGR_LONG_PTR : 0)); 564 (sizeof(dma_addr_t) == sizeof(u64) ? MCFGR_LONG_PTR : 0));
564 565
565 /* 566 /*
diff --git a/drivers/crypto/chelsio/chcr_algo.h b/drivers/crypto/chelsio/chcr_algo.h
index ec64fbcdeb49..199b0bb69b89 100644
--- a/drivers/crypto/chelsio/chcr_algo.h
+++ b/drivers/crypto/chelsio/chcr_algo.h
@@ -422,7 +422,7 @@ static inline void get_aes_decrypt_key(unsigned char *dec_key,
422{ 422{
423 u32 temp; 423 u32 temp;
424 u32 w_ring[MAX_NK]; 424 u32 w_ring[MAX_NK];
425 int i, j, k = 0; 425 int i, j, k;
426 u8 nr, nk; 426 u8 nr, nk;
427 427
428 switch (keylength) { 428 switch (keylength) {
@@ -460,6 +460,7 @@ static inline void get_aes_decrypt_key(unsigned char *dec_key,
460 temp = w_ring[i % nk]; 460 temp = w_ring[i % nk];
461 i++; 461 i++;
462 } 462 }
463 i--;
463 for (k = 0, j = i % nk; k < nk; k++) { 464 for (k = 0, j = i % nk; k < nk; k++) {
464 *((u32 *)dec_key + k) = htonl(w_ring[j]); 465 *((u32 *)dec_key + k) = htonl(w_ring[j]);
465 j--; 466 j--;
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index 9f284682c091..77712b375b84 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -168,12 +168,11 @@ static void mv_cesa_ahash_std_step(struct ahash_request *req)
168 mv_cesa_adjust_op(engine, &creq->op_tmpl); 168 mv_cesa_adjust_op(engine, &creq->op_tmpl);
169 memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl)); 169 memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl));
170 170
171 digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(req)); 171 if (!sreq->offset) {
172 for (i = 0; i < digsize / 4; i++) 172 digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(req));
173 writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i)); 173 for (i = 0; i < digsize / 4; i++)
174 174 writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i));
175 mv_cesa_adjust_op(engine, &creq->op_tmpl); 175 }
176 memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl));
177 176
178 if (creq->cache_ptr) 177 if (creq->cache_ptr)
179 memcpy_toio(engine->sram + CESA_SA_DATA_SRAM_OFFSET, 178 memcpy_toio(engine->sram + CESA_SA_DATA_SRAM_OFFSET,
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index 0e499bfca41c..286447a83dab 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -270,8 +270,8 @@ static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma,
270 if (!dax_dev->alive) 270 if (!dax_dev->alive)
271 return -ENXIO; 271 return -ENXIO;
272 272
273 /* prevent private / writable mappings from being established */ 273 /* prevent private mappings from being established */
274 if ((vma->vm_flags & (VM_NORESERVE|VM_SHARED|VM_WRITE)) == VM_WRITE) { 274 if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
275 dev_info(dev, "%s: %s: fail, attempted private mapping\n", 275 dev_info(dev, "%s: %s: fail, attempted private mapping\n",
276 current->comm, func); 276 current->comm, func);
277 return -EINVAL; 277 return -EINVAL;
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 4a15fa5df98b..73c6ce93a0d9 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -78,7 +78,9 @@ static int dax_pmem_probe(struct device *dev)
78 nsio = to_nd_namespace_io(&ndns->dev); 78 nsio = to_nd_namespace_io(&ndns->dev);
79 79
80 /* parse the 'pfn' info block via ->rw_bytes */ 80 /* parse the 'pfn' info block via ->rw_bytes */
81 devm_nsio_enable(dev, nsio); 81 rc = devm_nsio_enable(dev, nsio);
82 if (rc)
83 return rc;
82 altmap = nvdimm_setup_pfn(nd_pfn, &res, &__altmap); 84 altmap = nvdimm_setup_pfn(nd_pfn, &res, &__altmap);
83 if (IS_ERR(altmap)) 85 if (IS_ERR(altmap))
84 return PTR_ERR(altmap); 86 return PTR_ERR(altmap);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 496f72b134eb..05c2850c04b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2472,6 +2472,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
2472 struct drm_file *file_priv); 2472 struct drm_file *file_priv);
2473void amdgpu_driver_preclose_kms(struct drm_device *dev, 2473void amdgpu_driver_preclose_kms(struct drm_device *dev,
2474 struct drm_file *file_priv); 2474 struct drm_file *file_priv);
2475int amdgpu_suspend(struct amdgpu_device *adev);
2475int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon); 2476int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon);
2476int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon); 2477int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
2477u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe); 2478u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index dae35a96a694..6c343a933182 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -34,6 +34,7 @@ struct amdgpu_atpx {
34 34
35static struct amdgpu_atpx_priv { 35static struct amdgpu_atpx_priv {
36 bool atpx_detected; 36 bool atpx_detected;
37 bool bridge_pm_usable;
37 /* handle for device - and atpx */ 38 /* handle for device - and atpx */
38 acpi_handle dhandle; 39 acpi_handle dhandle;
39 acpi_handle other_handle; 40 acpi_handle other_handle;
@@ -205,7 +206,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
205 atpx->is_hybrid = false; 206 atpx->is_hybrid = false;
206 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { 207 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
207 printk("ATPX Hybrid Graphics\n"); 208 printk("ATPX Hybrid Graphics\n");
208 atpx->functions.power_cntl = false; 209 /*
210 * Disable legacy PM methods only when pcie port PM is usable,
211 * otherwise the device might fail to power off or power on.
212 */
213 atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
209 atpx->is_hybrid = true; 214 atpx->is_hybrid = true;
210 } 215 }
211 216
@@ -555,17 +560,25 @@ static bool amdgpu_atpx_detect(void)
555 struct pci_dev *pdev = NULL; 560 struct pci_dev *pdev = NULL;
556 bool has_atpx = false; 561 bool has_atpx = false;
557 int vga_count = 0; 562 int vga_count = 0;
563 bool d3_supported = false;
564 struct pci_dev *parent_pdev;
558 565
559 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 566 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
560 vga_count++; 567 vga_count++;
561 568
562 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true); 569 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
570
571 parent_pdev = pci_upstream_bridge(pdev);
572 d3_supported |= parent_pdev && parent_pdev->bridge_d3;
563 } 573 }
564 574
565 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 575 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
566 vga_count++; 576 vga_count++;
567 577
568 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true); 578 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
579
580 parent_pdev = pci_upstream_bridge(pdev);
581 d3_supported |= parent_pdev && parent_pdev->bridge_d3;
569 } 582 }
570 583
571 if (has_atpx && vga_count == 2) { 584 if (has_atpx && vga_count == 2) {
@@ -573,6 +586,7 @@ static bool amdgpu_atpx_detect(void)
573 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n", 586 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
574 acpi_method_name); 587 acpi_method_name);
575 amdgpu_atpx_priv.atpx_detected = true; 588 amdgpu_atpx_priv.atpx_detected = true;
589 amdgpu_atpx_priv.bridge_pm_usable = d3_supported;
576 amdgpu_atpx_init(); 590 amdgpu_atpx_init();
577 return true; 591 return true;
578 } 592 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 3161d77bf299..e41d4baebf86 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1493,7 +1493,7 @@ static int amdgpu_fini(struct amdgpu_device *adev)
1493 return 0; 1493 return 0;
1494} 1494}
1495 1495
1496static int amdgpu_suspend(struct amdgpu_device *adev) 1496int amdgpu_suspend(struct amdgpu_device *adev)
1497{ 1497{
1498 int i, r; 1498 int i, r;
1499 1499
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 02ff0747197c..e0890deccb2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -479,12 +479,15 @@ amdgpu_pci_remove(struct pci_dev *pdev)
479static void 479static void
480amdgpu_pci_shutdown(struct pci_dev *pdev) 480amdgpu_pci_shutdown(struct pci_dev *pdev)
481{ 481{
482 struct drm_device *dev = pci_get_drvdata(pdev);
483 struct amdgpu_device *adev = dev->dev_private;
484
482 /* if we are running in a VM, make sure the device 485 /* if we are running in a VM, make sure the device
483 * torn down properly on reboot/shutdown. 486 * torn down properly on reboot/shutdown.
484 * unfortunately we can't detect certain 487 * unfortunately we can't detect certain
485 * hypervisors so just do this all the time. 488 * hypervisors so just do this all the time.
486 */ 489 */
487 amdgpu_pci_remove(pdev); 490 amdgpu_suspend(adev);
488} 491}
489 492
490static int amdgpu_pmops_suspend(struct device *dev) 493static int amdgpu_pmops_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 13f2b705ea49..08cd0bd3ebe5 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
2984 if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk) 2984 if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
2985 data->highest_mclk = memory_clock; 2985 data->highest_mclk = memory_clock;
2986 2986
2987 performance_level = &(ps->performance_levels
2988 [ps->performance_level_count++]);
2989
2990 PP_ASSERT_WITH_CODE( 2987 PP_ASSERT_WITH_CODE(
2991 (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)), 2988 (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
2992 "Performance levels exceeds SMC limit!", 2989 "Performance levels exceeds SMC limit!",
2993 return -EINVAL); 2990 return -EINVAL);
2994 2991
2995 PP_ASSERT_WITH_CODE( 2992 PP_ASSERT_WITH_CODE(
2996 (ps->performance_level_count <= 2993 (ps->performance_level_count <
2997 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels), 2994 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
2998 "Performance levels exceeds Driver limit!", 2995 "Performance levels exceeds Driver limit, Skip!",
2999 return -EINVAL); 2996 return 0);
2997
2998 performance_level = &(ps->performance_levels
2999 [ps->performance_level_count++]);
3000 3000
3001 /* Performance levels are arranged from low to high. */ 3001 /* Performance levels are arranged from low to high. */
3002 performance_level->memory_clock = memory_clock; 3002 performance_level->memory_clock = memory_clock;
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
index 4ccc0b72324d..71bb2f8dc157 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
@@ -2214,6 +2214,7 @@ uint32_t polaris10_get_mac_definition(uint32_t value)
2214int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr) 2214int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr)
2215{ 2215{
2216 struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend); 2216 struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend);
2217 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
2217 uint32_t tmp; 2218 uint32_t tmp;
2218 int result; 2219 int result;
2219 bool error = false; 2220 bool error = false;
@@ -2233,8 +2234,10 @@ int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr)
2233 offsetof(SMU74_Firmware_Header, SoftRegisters), 2234 offsetof(SMU74_Firmware_Header, SoftRegisters),
2234 &tmp, SMC_RAM_END); 2235 &tmp, SMC_RAM_END);
2235 2236
2236 if (!result) 2237 if (!result) {
2238 data->soft_regs_start = tmp;
2237 smu_data->smu7_data.soft_regs_start = tmp; 2239 smu_data->smu7_data.soft_regs_start = tmp;
2240 }
2238 2241
2239 error |= (0 != result); 2242 error |= (0 != result);
2240 2243
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 48019ae22ddb..28341b32067f 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -150,15 +150,14 @@ static void hdlcd_crtc_enable(struct drm_crtc *crtc)
150 clk_prepare_enable(hdlcd->clk); 150 clk_prepare_enable(hdlcd->clk);
151 hdlcd_crtc_mode_set_nofb(crtc); 151 hdlcd_crtc_mode_set_nofb(crtc);
152 hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1); 152 hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1);
153 drm_crtc_vblank_on(crtc);
153} 154}
154 155
155static void hdlcd_crtc_disable(struct drm_crtc *crtc) 156static void hdlcd_crtc_disable(struct drm_crtc *crtc)
156{ 157{
157 struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); 158 struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
158 159
159 if (!crtc->state->active) 160 drm_crtc_vblank_off(crtc);
160 return;
161
162 hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0); 161 hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0);
163 clk_disable_unprepare(hdlcd->clk); 162 clk_disable_unprepare(hdlcd->clk);
164} 163}
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index fb6a418ce6be..e138fb51e8ce 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -375,7 +375,6 @@ static int hdlcd_drm_bind(struct device *dev)
375 375
376err_fbdev: 376err_fbdev:
377 drm_kms_helper_poll_fini(drm); 377 drm_kms_helper_poll_fini(drm);
378 drm_mode_config_cleanup(drm);
379 drm_vblank_cleanup(drm); 378 drm_vblank_cleanup(drm);
380err_vblank: 379err_vblank:
381 pm_runtime_disable(drm->dev); 380 pm_runtime_disable(drm->dev);
@@ -387,6 +386,7 @@ err_unload:
387 drm_irq_uninstall(drm); 386 drm_irq_uninstall(drm);
388 of_reserved_mem_device_release(drm->dev); 387 of_reserved_mem_device_release(drm->dev);
389err_free: 388err_free:
389 drm_mode_config_cleanup(drm);
390 dev_set_drvdata(dev, NULL); 390 dev_set_drvdata(dev, NULL);
391 drm_dev_unref(drm); 391 drm_dev_unref(drm);
392 392
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 0ad2c47f808f..71c3473476c7 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -254,10 +254,12 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
254 req->value = dev->mode_config.async_page_flip; 254 req->value = dev->mode_config.async_page_flip;
255 break; 255 break;
256 case DRM_CAP_PAGE_FLIP_TARGET: 256 case DRM_CAP_PAGE_FLIP_TARGET:
257 req->value = 1; 257 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
258 drm_for_each_crtc(crtc, dev) { 258 req->value = 1;
259 if (!crtc->funcs->page_flip_target) 259 drm_for_each_crtc(crtc, dev) {
260 req->value = 0; 260 if (!crtc->funcs->page_flip_target)
261 req->value = 0;
262 }
261 } 263 }
262 break; 264 break;
263 case DRM_CAP_CURSOR_WIDTH: 265 case DRM_CAP_CURSOR_WIDTH:
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index e8fb6ef947ee..38eaa63afb31 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -1907,6 +1907,8 @@ err_disable_pm_runtime:
1907err_hdmiphy: 1907err_hdmiphy:
1908 if (hdata->hdmiphy_port) 1908 if (hdata->hdmiphy_port)
1909 put_device(&hdata->hdmiphy_port->dev); 1909 put_device(&hdata->hdmiphy_port->dev);
1910 if (hdata->regs_hdmiphy)
1911 iounmap(hdata->regs_hdmiphy);
1910err_ddc: 1912err_ddc:
1911 put_device(&hdata->ddc_adpt->dev); 1913 put_device(&hdata->ddc_adpt->dev);
1912 1914
@@ -1929,6 +1931,9 @@ static int hdmi_remove(struct platform_device *pdev)
1929 if (hdata->hdmiphy_port) 1931 if (hdata->hdmiphy_port)
1930 put_device(&hdata->hdmiphy_port->dev); 1932 put_device(&hdata->hdmiphy_port->dev);
1931 1933
1934 if (hdata->regs_hdmiphy)
1935 iounmap(hdata->regs_hdmiphy);
1936
1932 put_device(&hdata->ddc_adpt->dev); 1937 put_device(&hdata->ddc_adpt->dev);
1933 1938
1934 return 0; 1939 return 0;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 91ab7e9d6d2e..00eb4814b913 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2268,7 +2268,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
2268 page = shmem_read_mapping_page(mapping, i); 2268 page = shmem_read_mapping_page(mapping, i);
2269 if (IS_ERR(page)) { 2269 if (IS_ERR(page)) {
2270 ret = PTR_ERR(page); 2270 ret = PTR_ERR(page);
2271 goto err_pages; 2271 goto err_sg;
2272 } 2272 }
2273 } 2273 }
2274#ifdef CONFIG_SWIOTLB 2274#ifdef CONFIG_SWIOTLB
@@ -2311,8 +2311,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
2311 2311
2312 return 0; 2312 return 0;
2313 2313
2314err_pages: 2314err_sg:
2315 sg_mark_end(sg); 2315 sg_mark_end(sg);
2316err_pages:
2316 for_each_sgt_page(page, sgt_iter, st) 2317 for_each_sgt_page(page, sgt_iter, st)
2317 put_page(page); 2318 put_page(page);
2318 sg_free_table(st); 2319 sg_free_table(st);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 81c11499bcf0..3cb70d73239b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12260,7 +12260,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
12260 intel_crtc->reset_count = i915_reset_count(&dev_priv->gpu_error); 12260 intel_crtc->reset_count = i915_reset_count(&dev_priv->gpu_error);
12261 if (i915_reset_in_progress_or_wedged(&dev_priv->gpu_error)) { 12261 if (i915_reset_in_progress_or_wedged(&dev_priv->gpu_error)) {
12262 ret = -EIO; 12262 ret = -EIO;
12263 goto cleanup; 12263 goto unlock;
12264 } 12264 }
12265 12265
12266 atomic_inc(&intel_crtc->unpin_work_count); 12266 atomic_inc(&intel_crtc->unpin_work_count);
@@ -12352,6 +12352,7 @@ cleanup_unpin:
12352 intel_unpin_fb_obj(fb, crtc->primary->state->rotation); 12352 intel_unpin_fb_obj(fb, crtc->primary->state->rotation);
12353cleanup_pending: 12353cleanup_pending:
12354 atomic_dec(&intel_crtc->unpin_work_count); 12354 atomic_dec(&intel_crtc->unpin_work_count);
12355unlock:
12355 mutex_unlock(&dev->struct_mutex); 12356 mutex_unlock(&dev->struct_mutex);
12356cleanup: 12357cleanup:
12357 crtc->primary->fb = old_fb; 12358 crtc->primary->fb = old_fb;
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index f75c5b5a536c..c70310206ac5 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -251,13 +251,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
251 if (irq < 0) 251 if (irq < 0)
252 return irq; 252 return irq;
253 253
254 ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
255 IRQF_TRIGGER_NONE, dev_name(dev), priv);
256 if (ret < 0) {
257 dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
258 return ret;
259 }
260
261 comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL); 254 comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL);
262 if (comp_id < 0) { 255 if (comp_id < 0) {
263 dev_err(dev, "Failed to identify by alias: %d\n", comp_id); 256 dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
@@ -273,6 +266,13 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
273 266
274 platform_set_drvdata(pdev, priv); 267 platform_set_drvdata(pdev, priv);
275 268
269 ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
270 IRQF_TRIGGER_NONE, dev_name(dev), priv);
271 if (ret < 0) {
272 dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
273 return ret;
274 }
275
276 ret = component_add(dev, &mtk_disp_ovl_component_ops); 276 ret = component_add(dev, &mtk_disp_ovl_component_ops);
277 if (ret) 277 if (ret)
278 dev_err(dev, "Failed to add component: %d\n", ret); 278 dev_err(dev, "Failed to add component: %d\n", ret);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index df33b3ca6ffd..48cc01fd20c7 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -123,7 +123,7 @@ static void mtk_od_config(struct mtk_ddp_comp *comp, unsigned int w,
123 unsigned int bpc) 123 unsigned int bpc)
124{ 124{
125 writel(w << 16 | h, comp->regs + DISP_OD_SIZE); 125 writel(w << 16 | h, comp->regs + DISP_OD_SIZE);
126 writel(OD_RELAYMODE, comp->regs + OD_RELAYMODE); 126 writel(OD_RELAYMODE, comp->regs + DISP_OD_CFG);
127 mtk_dither_set(comp, bpc, DISP_OD_CFG); 127 mtk_dither_set(comp, bpc, DISP_OD_CFG);
128} 128}
129 129
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 28b2044ed9f2..eaa5a2240c0c 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -86,7 +86,7 @@
86 86
87#define DSI_PHY_TIMECON0 0x110 87#define DSI_PHY_TIMECON0 0x110
88#define LPX (0xff << 0) 88#define LPX (0xff << 0)
89#define HS_PRPR (0xff << 8) 89#define HS_PREP (0xff << 8)
90#define HS_ZERO (0xff << 16) 90#define HS_ZERO (0xff << 16)
91#define HS_TRAIL (0xff << 24) 91#define HS_TRAIL (0xff << 24)
92 92
@@ -102,10 +102,16 @@
102#define CLK_TRAIL (0xff << 24) 102#define CLK_TRAIL (0xff << 24)
103 103
104#define DSI_PHY_TIMECON3 0x11c 104#define DSI_PHY_TIMECON3 0x11c
105#define CLK_HS_PRPR (0xff << 0) 105#define CLK_HS_PREP (0xff << 0)
106#define CLK_HS_POST (0xff << 8) 106#define CLK_HS_POST (0xff << 8)
107#define CLK_HS_EXIT (0xff << 16) 107#define CLK_HS_EXIT (0xff << 16)
108 108
109#define T_LPX 5
110#define T_HS_PREP 6
111#define T_HS_TRAIL 8
112#define T_HS_EXIT 7
113#define T_HS_ZERO 10
114
109#define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0)) 115#define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0))
110 116
111struct phy; 117struct phy;
@@ -161,20 +167,18 @@ static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data)
161static void dsi_phy_timconfig(struct mtk_dsi *dsi) 167static void dsi_phy_timconfig(struct mtk_dsi *dsi)
162{ 168{
163 u32 timcon0, timcon1, timcon2, timcon3; 169 u32 timcon0, timcon1, timcon2, timcon3;
164 unsigned int ui, cycle_time; 170 u32 ui, cycle_time;
165 unsigned int lpx;
166 171
167 ui = 1000 / dsi->data_rate + 0x01; 172 ui = 1000 / dsi->data_rate + 0x01;
168 cycle_time = 8000 / dsi->data_rate + 0x01; 173 cycle_time = 8000 / dsi->data_rate + 0x01;
169 lpx = 5;
170 174
171 timcon0 = (8 << 24) | (0xa << 16) | (0x6 << 8) | lpx; 175 timcon0 = T_LPX | T_HS_PREP << 8 | T_HS_ZERO << 16 | T_HS_TRAIL << 24;
172 timcon1 = (7 << 24) | (5 * lpx << 16) | ((3 * lpx) / 2) << 8 | 176 timcon1 = 4 * T_LPX | (3 * T_LPX / 2) << 8 | 5 * T_LPX << 16 |
173 (4 * lpx); 177 T_HS_EXIT << 24;
174 timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) | 178 timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) |
175 (NS_TO_CYCLE(0x150, cycle_time) << 16); 179 (NS_TO_CYCLE(0x150, cycle_time) << 16);
176 timcon3 = (2 * lpx) << 16 | NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8 | 180 timcon3 = NS_TO_CYCLE(0x40, cycle_time) | (2 * T_LPX) << 16 |
177 NS_TO_CYCLE(0x40, cycle_time); 181 NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8;
178 182
179 writel(timcon0, dsi->regs + DSI_PHY_TIMECON0); 183 writel(timcon0, dsi->regs + DSI_PHY_TIMECON0);
180 writel(timcon1, dsi->regs + DSI_PHY_TIMECON1); 184 writel(timcon1, dsi->regs + DSI_PHY_TIMECON1);
@@ -202,19 +206,47 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
202{ 206{
203 struct device *dev = dsi->dev; 207 struct device *dev = dsi->dev;
204 int ret; 208 int ret;
209 u64 pixel_clock, total_bits;
210 u32 htotal, htotal_bits, bit_per_pixel, overhead_cycles, overhead_bits;
205 211
206 if (++dsi->refcount != 1) 212 if (++dsi->refcount != 1)
207 return 0; 213 return 0;
208 214
215 switch (dsi->format) {
216 case MIPI_DSI_FMT_RGB565:
217 bit_per_pixel = 16;
218 break;
219 case MIPI_DSI_FMT_RGB666_PACKED:
220 bit_per_pixel = 18;
221 break;
222 case MIPI_DSI_FMT_RGB666:
223 case MIPI_DSI_FMT_RGB888:
224 default:
225 bit_per_pixel = 24;
226 break;
227 }
228
209 /** 229 /**
210 * data_rate = (pixel_clock / 1000) * pixel_dipth * mipi_ratio; 230 * vm.pixelclock is in kHz, pixel_clock unit is Hz, so multiply by 1000
211 * pixel_clock unit is Khz, data_rata unit is MHz, so need divide 1000. 231 * htotal_time = htotal * byte_per_pixel / num_lanes
212 * mipi_ratio is mipi clk coefficient for balance the pixel clk in mipi. 232 * overhead_time = lpx + hs_prepare + hs_zero + hs_trail + hs_exit
213 * we set mipi_ratio is 1.05. 233 * mipi_ratio = (htotal_time + overhead_time) / htotal_time
234 * data_rate = pixel_clock * bit_per_pixel * mipi_ratio / num_lanes;
214 */ 235 */
215 dsi->data_rate = dsi->vm.pixelclock * 3 * 21 / (1 * 1000 * 10); 236 pixel_clock = dsi->vm.pixelclock * 1000;
237 htotal = dsi->vm.hactive + dsi->vm.hback_porch + dsi->vm.hfront_porch +
238 dsi->vm.hsync_len;
239 htotal_bits = htotal * bit_per_pixel;
240
241 overhead_cycles = T_LPX + T_HS_PREP + T_HS_ZERO + T_HS_TRAIL +
242 T_HS_EXIT;
243 overhead_bits = overhead_cycles * dsi->lanes * 8;
244 total_bits = htotal_bits + overhead_bits;
245
246 dsi->data_rate = DIV_ROUND_UP_ULL(pixel_clock * total_bits,
247 htotal * dsi->lanes);
216 248
217 ret = clk_set_rate(dsi->hs_clk, dsi->data_rate * 1000000); 249 ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
218 if (ret < 0) { 250 if (ret < 0) {
219 dev_err(dev, "Failed to set data rate: %d\n", ret); 251 dev_err(dev, "Failed to set data rate: %d\n", ret);
220 goto err_refcount; 252 goto err_refcount;
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 2fdcd04bc93f..0ae13cd2adda 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -34,6 +34,7 @@ struct radeon_atpx {
34 34
35static struct radeon_atpx_priv { 35static struct radeon_atpx_priv {
36 bool atpx_detected; 36 bool atpx_detected;
37 bool bridge_pm_usable;
37 /* handle for device - and atpx */ 38 /* handle for device - and atpx */
38 acpi_handle dhandle; 39 acpi_handle dhandle;
39 struct radeon_atpx atpx; 40 struct radeon_atpx atpx;
@@ -203,7 +204,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
203 atpx->is_hybrid = false; 204 atpx->is_hybrid = false;
204 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { 205 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
205 printk("ATPX Hybrid Graphics\n"); 206 printk("ATPX Hybrid Graphics\n");
206 atpx->functions.power_cntl = false; 207 /*
208 * Disable legacy PM methods only when pcie port PM is usable,
209 * otherwise the device might fail to power off or power on.
210 */
211 atpx->functions.power_cntl = !radeon_atpx_priv.bridge_pm_usable;
207 atpx->is_hybrid = true; 212 atpx->is_hybrid = true;
208 } 213 }
209 214
@@ -548,11 +553,16 @@ static bool radeon_atpx_detect(void)
548 struct pci_dev *pdev = NULL; 553 struct pci_dev *pdev = NULL;
549 bool has_atpx = false; 554 bool has_atpx = false;
550 int vga_count = 0; 555 int vga_count = 0;
556 bool d3_supported = false;
557 struct pci_dev *parent_pdev;
551 558
552 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 559 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
553 vga_count++; 560 vga_count++;
554 561
555 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); 562 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
563
564 parent_pdev = pci_upstream_bridge(pdev);
565 d3_supported |= parent_pdev && parent_pdev->bridge_d3;
556 } 566 }
557 567
558 /* some newer PX laptops mark the dGPU as a non-VGA display device */ 568 /* some newer PX laptops mark the dGPU as a non-VGA display device */
@@ -560,6 +570,9 @@ static bool radeon_atpx_detect(void)
560 vga_count++; 570 vga_count++;
561 571
562 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); 572 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
573
574 parent_pdev = pci_upstream_bridge(pdev);
575 d3_supported |= parent_pdev && parent_pdev->bridge_d3;
563 } 576 }
564 577
565 if (has_atpx && vga_count == 2) { 578 if (has_atpx && vga_count == 2) {
@@ -567,6 +580,7 @@ static bool radeon_atpx_detect(void)
567 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n", 580 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
568 acpi_method_name); 581 acpi_method_name);
569 radeon_atpx_priv.atpx_detected = true; 582 radeon_atpx_priv.atpx_detected = true;
583 radeon_atpx_priv.bridge_pm_usable = d3_supported;
570 radeon_atpx_init(); 584 radeon_atpx_init();
571 return true; 585 return true;
572 } 586 }
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 086d8a507157..60d30203a5fa 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -32,6 +32,11 @@
32#include <linux/usb/ch9.h> 32#include <linux/usb/ch9.h>
33#include "hid-ids.h" 33#include "hid-ids.h"
34 34
35#define CP2112_REPORT_MAX_LENGTH 64
36#define CP2112_GPIO_CONFIG_LENGTH 5
37#define CP2112_GPIO_GET_LENGTH 2
38#define CP2112_GPIO_SET_LENGTH 3
39
35enum { 40enum {
36 CP2112_GPIO_CONFIG = 0x02, 41 CP2112_GPIO_CONFIG = 0x02,
37 CP2112_GPIO_GET = 0x03, 42 CP2112_GPIO_GET = 0x03,
@@ -161,6 +166,8 @@ struct cp2112_device {
161 atomic_t read_avail; 166 atomic_t read_avail;
162 atomic_t xfer_avail; 167 atomic_t xfer_avail;
163 struct gpio_chip gc; 168 struct gpio_chip gc;
169 u8 *in_out_buffer;
170 spinlock_t lock;
164}; 171};
165 172
166static int gpio_push_pull = 0xFF; 173static int gpio_push_pull = 0xFF;
@@ -171,62 +178,86 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
171{ 178{
172 struct cp2112_device *dev = gpiochip_get_data(chip); 179 struct cp2112_device *dev = gpiochip_get_data(chip);
173 struct hid_device *hdev = dev->hdev; 180 struct hid_device *hdev = dev->hdev;
174 u8 buf[5]; 181 u8 *buf = dev->in_out_buffer;
182 unsigned long flags;
175 int ret; 183 int ret;
176 184
185 spin_lock_irqsave(&dev->lock, flags);
186
177 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, 187 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
178 sizeof(buf), HID_FEATURE_REPORT, 188 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
179 HID_REQ_GET_REPORT); 189 HID_REQ_GET_REPORT);
180 if (ret != sizeof(buf)) { 190 if (ret != CP2112_GPIO_CONFIG_LENGTH) {
181 hid_err(hdev, "error requesting GPIO config: %d\n", ret); 191 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
182 return ret; 192 goto exit;
183 } 193 }
184 194
185 buf[1] &= ~(1 << offset); 195 buf[1] &= ~(1 << offset);
186 buf[2] = gpio_push_pull; 196 buf[2] = gpio_push_pull;
187 197
188 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), 198 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
189 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 199 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
200 HID_REQ_SET_REPORT);
190 if (ret < 0) { 201 if (ret < 0) {
191 hid_err(hdev, "error setting GPIO config: %d\n", ret); 202 hid_err(hdev, "error setting GPIO config: %d\n", ret);
192 return ret; 203 goto exit;
193 } 204 }
194 205
195 return 0; 206 ret = 0;
207
208exit:
209 spin_unlock_irqrestore(&dev->lock, flags);
210 return ret <= 0 ? ret : -EIO;
196} 211}
197 212
198static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 213static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
199{ 214{
200 struct cp2112_device *dev = gpiochip_get_data(chip); 215 struct cp2112_device *dev = gpiochip_get_data(chip);
201 struct hid_device *hdev = dev->hdev; 216 struct hid_device *hdev = dev->hdev;
202 u8 buf[3]; 217 u8 *buf = dev->in_out_buffer;
218 unsigned long flags;
203 int ret; 219 int ret;
204 220
221 spin_lock_irqsave(&dev->lock, flags);
222
205 buf[0] = CP2112_GPIO_SET; 223 buf[0] = CP2112_GPIO_SET;
206 buf[1] = value ? 0xff : 0; 224 buf[1] = value ? 0xff : 0;
207 buf[2] = 1 << offset; 225 buf[2] = 1 << offset;
208 226
209 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, sizeof(buf), 227 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf,
210 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 228 CP2112_GPIO_SET_LENGTH, HID_FEATURE_REPORT,
229 HID_REQ_SET_REPORT);
211 if (ret < 0) 230 if (ret < 0)
212 hid_err(hdev, "error setting GPIO values: %d\n", ret); 231 hid_err(hdev, "error setting GPIO values: %d\n", ret);
232
233 spin_unlock_irqrestore(&dev->lock, flags);
213} 234}
214 235
215static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset) 236static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset)
216{ 237{
217 struct cp2112_device *dev = gpiochip_get_data(chip); 238 struct cp2112_device *dev = gpiochip_get_data(chip);
218 struct hid_device *hdev = dev->hdev; 239 struct hid_device *hdev = dev->hdev;
219 u8 buf[2]; 240 u8 *buf = dev->in_out_buffer;
241 unsigned long flags;
220 int ret; 242 int ret;
221 243
222 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf, sizeof(buf), 244 spin_lock_irqsave(&dev->lock, flags);
223 HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 245
224 if (ret != sizeof(buf)) { 246 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf,
247 CP2112_GPIO_GET_LENGTH, HID_FEATURE_REPORT,
248 HID_REQ_GET_REPORT);
249 if (ret != CP2112_GPIO_GET_LENGTH) {
225 hid_err(hdev, "error requesting GPIO values: %d\n", ret); 250 hid_err(hdev, "error requesting GPIO values: %d\n", ret);
226 return ret; 251 ret = ret < 0 ? ret : -EIO;
252 goto exit;
227 } 253 }
228 254
229 return (buf[1] >> offset) & 1; 255 ret = (buf[1] >> offset) & 1;
256
257exit:
258 spin_unlock_irqrestore(&dev->lock, flags);
259
260 return ret;
230} 261}
231 262
232static int cp2112_gpio_direction_output(struct gpio_chip *chip, 263static int cp2112_gpio_direction_output(struct gpio_chip *chip,
@@ -234,27 +265,33 @@ static int cp2112_gpio_direction_output(struct gpio_chip *chip,
234{ 265{
235 struct cp2112_device *dev = gpiochip_get_data(chip); 266 struct cp2112_device *dev = gpiochip_get_data(chip);
236 struct hid_device *hdev = dev->hdev; 267 struct hid_device *hdev = dev->hdev;
237 u8 buf[5]; 268 u8 *buf = dev->in_out_buffer;
269 unsigned long flags;
238 int ret; 270 int ret;
239 271
272 spin_lock_irqsave(&dev->lock, flags);
273
240 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, 274 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
241 sizeof(buf), HID_FEATURE_REPORT, 275 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
242 HID_REQ_GET_REPORT); 276 HID_REQ_GET_REPORT);
243 if (ret != sizeof(buf)) { 277 if (ret != CP2112_GPIO_CONFIG_LENGTH) {
244 hid_err(hdev, "error requesting GPIO config: %d\n", ret); 278 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
245 return ret; 279 goto fail;
246 } 280 }
247 281
248 buf[1] |= 1 << offset; 282 buf[1] |= 1 << offset;
249 buf[2] = gpio_push_pull; 283 buf[2] = gpio_push_pull;
250 284
251 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), 285 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
252 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 286 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
287 HID_REQ_SET_REPORT);
253 if (ret < 0) { 288 if (ret < 0) {
254 hid_err(hdev, "error setting GPIO config: %d\n", ret); 289 hid_err(hdev, "error setting GPIO config: %d\n", ret);
255 return ret; 290 goto fail;
256 } 291 }
257 292
293 spin_unlock_irqrestore(&dev->lock, flags);
294
258 /* 295 /*
259 * Set gpio value when output direction is already set, 296 * Set gpio value when output direction is already set,
260 * as specified in AN495, Rev. 0.2, cpt. 4.4 297 * as specified in AN495, Rev. 0.2, cpt. 4.4
@@ -262,6 +299,10 @@ static int cp2112_gpio_direction_output(struct gpio_chip *chip,
262 cp2112_gpio_set(chip, offset, value); 299 cp2112_gpio_set(chip, offset, value);
263 300
264 return 0; 301 return 0;
302
303fail:
304 spin_unlock_irqrestore(&dev->lock, flags);
305 return ret < 0 ? ret : -EIO;
265} 306}
266 307
267static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number, 308static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
@@ -1007,6 +1048,17 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1007 struct cp2112_smbus_config_report config; 1048 struct cp2112_smbus_config_report config;
1008 int ret; 1049 int ret;
1009 1050
1051 dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);
1052 if (!dev)
1053 return -ENOMEM;
1054
1055 dev->in_out_buffer = devm_kzalloc(&hdev->dev, CP2112_REPORT_MAX_LENGTH,
1056 GFP_KERNEL);
1057 if (!dev->in_out_buffer)
1058 return -ENOMEM;
1059
1060 spin_lock_init(&dev->lock);
1061
1010 ret = hid_parse(hdev); 1062 ret = hid_parse(hdev);
1011 if (ret) { 1063 if (ret) {
1012 hid_err(hdev, "parse failed\n"); 1064 hid_err(hdev, "parse failed\n");
@@ -1063,12 +1115,6 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1063 goto err_power_normal; 1115 goto err_power_normal;
1064 } 1116 }
1065 1117
1066 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1067 if (!dev) {
1068 ret = -ENOMEM;
1069 goto err_power_normal;
1070 }
1071
1072 hid_set_drvdata(hdev, (void *)dev); 1118 hid_set_drvdata(hdev, (void *)dev);
1073 dev->hdev = hdev; 1119 dev->hdev = hdev;
1074 dev->adap.owner = THIS_MODULE; 1120 dev->adap.owner = THIS_MODULE;
@@ -1087,7 +1133,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1087 1133
1088 if (ret) { 1134 if (ret) {
1089 hid_err(hdev, "error registering i2c adapter\n"); 1135 hid_err(hdev, "error registering i2c adapter\n");
1090 goto err_free_dev; 1136 goto err_power_normal;
1091 } 1137 }
1092 1138
1093 hid_dbg(hdev, "adapter registered\n"); 1139 hid_dbg(hdev, "adapter registered\n");
@@ -1123,8 +1169,6 @@ err_gpiochip_remove:
1123 gpiochip_remove(&dev->gc); 1169 gpiochip_remove(&dev->gc);
1124err_free_i2c: 1170err_free_i2c:
1125 i2c_del_adapter(&dev->adap); 1171 i2c_del_adapter(&dev->adap);
1126err_free_dev:
1127 kfree(dev);
1128err_power_normal: 1172err_power_normal:
1129 hid_hw_power(hdev, PM_HINT_NORMAL); 1173 hid_hw_power(hdev, PM_HINT_NORMAL);
1130err_hid_close: 1174err_hid_close:
@@ -1149,7 +1193,6 @@ static void cp2112_remove(struct hid_device *hdev)
1149 */ 1193 */
1150 hid_hw_close(hdev); 1194 hid_hw_close(hdev);
1151 hid_hw_stop(hdev); 1195 hid_hw_stop(hdev);
1152 kfree(dev);
1153} 1196}
1154 1197
1155static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report, 1198static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report,
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 76f644deb0a7..c5c5fbe9d605 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -756,11 +756,16 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
756 756
757 /* Setup wireless link with Logitech Wii wheel */ 757 /* Setup wireless link with Logitech Wii wheel */
758 if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) { 758 if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
759 unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 759 const unsigned char cbuf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
760 u8 *buf = kmemdup(cbuf, sizeof(cbuf), GFP_KERNEL);
760 761
761 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), 762 if (!buf) {
762 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 763 ret = -ENOMEM;
764 goto err_free;
765 }
763 766
767 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
768 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
764 if (ret >= 0) { 769 if (ret >= 0) {
765 /* insert a little delay of 10 jiffies ~ 40ms */ 770 /* insert a little delay of 10 jiffies ~ 40ms */
766 wait_queue_head_t wait; 771 wait_queue_head_t wait;
@@ -772,9 +777,10 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
772 buf[1] = 0xB2; 777 buf[1] = 0xB2;
773 get_random_bytes(&buf[2], 2); 778 get_random_bytes(&buf[2], 2);
774 779
775 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), 780 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
776 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 781 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
777 } 782 }
783 kfree(buf);
778 } 784 }
779 785
780 if (drv_data->quirks & LG_FF) 786 if (drv_data->quirks & LG_FF)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index d6fa496d0ca2..20b40ad26325 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -493,7 +493,8 @@ static int magicmouse_input_configured(struct hid_device *hdev,
493static int magicmouse_probe(struct hid_device *hdev, 493static int magicmouse_probe(struct hid_device *hdev,
494 const struct hid_device_id *id) 494 const struct hid_device_id *id)
495{ 495{
496 __u8 feature[] = { 0xd7, 0x01 }; 496 const u8 feature[] = { 0xd7, 0x01 };
497 u8 *buf;
497 struct magicmouse_sc *msc; 498 struct magicmouse_sc *msc;
498 struct hid_report *report; 499 struct hid_report *report;
499 int ret; 500 int ret;
@@ -544,6 +545,12 @@ static int magicmouse_probe(struct hid_device *hdev,
544 } 545 }
545 report->size = 6; 546 report->size = 6;
546 547
548 buf = kmemdup(feature, sizeof(feature), GFP_KERNEL);
549 if (!buf) {
550 ret = -ENOMEM;
551 goto err_stop_hw;
552 }
553
547 /* 554 /*
548 * Some devices repond with 'invalid report id' when feature 555 * Some devices repond with 'invalid report id' when feature
549 * report switching it into multitouch mode is sent to it. 556 * report switching it into multitouch mode is sent to it.
@@ -552,8 +559,9 @@ static int magicmouse_probe(struct hid_device *hdev,
552 * but there seems to be no other way of switching the mode. 559 * but there seems to be no other way of switching the mode.
553 * Thus the super-ugly hacky success check below. 560 * Thus the super-ugly hacky success check below.
554 */ 561 */
555 ret = hid_hw_raw_request(hdev, feature[0], feature, sizeof(feature), 562 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(feature),
556 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 563 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
564 kfree(buf);
557 if (ret != -EIO && ret != sizeof(feature)) { 565 if (ret != -EIO && ret != sizeof(feature)) {
558 hid_err(hdev, "unable to request touch data (%d)\n", ret); 566 hid_err(hdev, "unable to request touch data (%d)\n", ret);
559 goto err_stop_hw; 567 goto err_stop_hw;
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 9cd2ca34a6be..be89bcbf6a71 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -188,10 +188,16 @@ static int rmi_set_page(struct hid_device *hdev, u8 page)
188static int rmi_set_mode(struct hid_device *hdev, u8 mode) 188static int rmi_set_mode(struct hid_device *hdev, u8 mode)
189{ 189{
190 int ret; 190 int ret;
191 u8 txbuf[2] = {RMI_SET_RMI_MODE_REPORT_ID, mode}; 191 const u8 txbuf[2] = {RMI_SET_RMI_MODE_REPORT_ID, mode};
192 u8 *buf;
192 193
193 ret = hid_hw_raw_request(hdev, RMI_SET_RMI_MODE_REPORT_ID, txbuf, 194 buf = kmemdup(txbuf, sizeof(txbuf), GFP_KERNEL);
195 if (!buf)
196 return -ENOMEM;
197
198 ret = hid_hw_raw_request(hdev, RMI_SET_RMI_MODE_REPORT_ID, buf,
194 sizeof(txbuf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 199 sizeof(txbuf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
200 kfree(buf);
195 if (ret < 0) { 201 if (ret < 0) {
196 dev_err(&hdev->dev, "unable to set rmi mode to %d (%d)\n", mode, 202 dev_err(&hdev->dev, "unable to set rmi mode to %d (%d)\n", mode,
197 ret); 203 ret);
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index c5c3d6111729..60875625cbdf 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -212,6 +212,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
212 __s32 value; 212 __s32 value;
213 int ret = 0; 213 int ret = 0;
214 214
215 memset(buffer, 0, buffer_size);
215 mutex_lock(&data->mutex); 216 mutex_lock(&data->mutex);
216 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); 217 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
217 if (!report || (field_index >= report->maxfield)) { 218 if (!report || (field_index >= report->maxfield)) {
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 11e866d05368..b403fa5ecf49 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -91,9 +91,7 @@
91 DW_IC_INTR_TX_ABRT | \ 91 DW_IC_INTR_TX_ABRT | \
92 DW_IC_INTR_STOP_DET) 92 DW_IC_INTR_STOP_DET)
93 93
94#define DW_IC_STATUS_ACTIVITY 0x1 94#define DW_IC_STATUS_ACTIVITY 0x1
95#define DW_IC_STATUS_TFE BIT(2)
96#define DW_IC_STATUS_MST_ACTIVITY BIT(5)
97 95
98#define DW_IC_SDA_HOLD_RX_SHIFT 16 96#define DW_IC_SDA_HOLD_RX_SHIFT 16
99#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, DW_IC_SDA_HOLD_RX_SHIFT) 97#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, DW_IC_SDA_HOLD_RX_SHIFT)
@@ -478,25 +476,9 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
478{ 476{
479 struct i2c_msg *msgs = dev->msgs; 477 struct i2c_msg *msgs = dev->msgs;
480 u32 ic_tar = 0; 478 u32 ic_tar = 0;
481 bool enabled;
482 479
483 enabled = dw_readl(dev, DW_IC_ENABLE_STATUS) & 1; 480 /* Disable the adapter */
484 481 __i2c_dw_enable_and_wait(dev, false);
485 if (enabled) {
486 u32 ic_status;
487
488 /*
489 * Only disable adapter if ic_tar and ic_con can't be
490 * dynamically updated
491 */
492 ic_status = dw_readl(dev, DW_IC_STATUS);
493 if (!dev->dynamic_tar_update_enabled ||
494 (ic_status & DW_IC_STATUS_MST_ACTIVITY) ||
495 !(ic_status & DW_IC_STATUS_TFE)) {
496 __i2c_dw_enable_and_wait(dev, false);
497 enabled = false;
498 }
499 }
500 482
501 /* if the slave address is ten bit address, enable 10BITADDR */ 483 /* if the slave address is ten bit address, enable 10BITADDR */
502 if (dev->dynamic_tar_update_enabled) { 484 if (dev->dynamic_tar_update_enabled) {
@@ -526,8 +508,8 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
526 /* enforce disabled interrupts (due to HW issues) */ 508 /* enforce disabled interrupts (due to HW issues) */
527 i2c_dw_disable_int(dev); 509 i2c_dw_disable_int(dev);
528 510
529 if (!enabled) 511 /* Enable the adapter */
530 __i2c_dw_enable(dev, true); 512 __i2c_dw_enable(dev, true);
531 513
532 /* Clear and enable interrupts */ 514 /* Clear and enable interrupts */
533 dw_readl(dev, DW_IC_CLR_INTR); 515 dw_readl(dev, DW_IC_CLR_INTR);
@@ -611,7 +593,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
611 if (msgs[dev->msg_write_idx].flags & I2C_M_RD) { 593 if (msgs[dev->msg_write_idx].flags & I2C_M_RD) {
612 594
613 /* avoid rx buffer overrun */ 595 /* avoid rx buffer overrun */
614 if (rx_limit - dev->rx_outstanding <= 0) 596 if (dev->rx_outstanding >= dev->rx_fifo_depth)
615 break; 597 break;
616 598
617 dw_writel(dev, cmd | 0x100, DW_IC_DATA_CMD); 599 dw_writel(dev, cmd | 0x100, DW_IC_DATA_CMD);
@@ -708,8 +690,7 @@ static int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev)
708} 690}
709 691
710/* 692/*
711 * Prepare controller for a transaction and start transfer by calling 693 * Prepare controller for a transaction and call i2c_dw_xfer_msg
712 * i2c_dw_xfer_init()
713 */ 694 */
714static int 695static int
715i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 696i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
@@ -752,13 +733,23 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
752 goto done; 733 goto done;
753 } 734 }
754 735
736 /*
737 * We must disable the adapter before returning and signaling the end
738 * of the current transfer. Otherwise the hardware might continue
739 * generating interrupts which in turn causes a race condition with
740 * the following transfer. Needs some more investigation if the
741 * additional interrupts are a hardware bug or this driver doesn't
742 * handle them correctly yet.
743 */
744 __i2c_dw_enable(dev, false);
745
755 if (dev->msg_err) { 746 if (dev->msg_err) {
756 ret = dev->msg_err; 747 ret = dev->msg_err;
757 goto done; 748 goto done;
758 } 749 }
759 750
760 /* no error */ 751 /* no error */
761 if (likely(!dev->cmd_err)) { 752 if (likely(!dev->cmd_err && !dev->status)) {
762 ret = num; 753 ret = num;
763 goto done; 754 goto done;
764 } 755 }
@@ -768,6 +759,11 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
768 ret = i2c_dw_handle_tx_abort(dev); 759 ret = i2c_dw_handle_tx_abort(dev);
769 goto done; 760 goto done;
770 } 761 }
762
763 if (dev->status)
764 dev_err(dev->dev,
765 "transfer terminated early - interrupt latency too high?\n");
766
771 ret = -EIO; 767 ret = -EIO;
772 768
773done: 769done:
@@ -888,19 +884,9 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
888 */ 884 */
889 885
890tx_aborted: 886tx_aborted:
891 if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) 887 if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err)
892 || dev->msg_err) {
893 /*
894 * We must disable interruts before returning and signaling
895 * the end of the current transfer. Otherwise the hardware
896 * might continue generating interrupts for non-existent
897 * transfers.
898 */
899 i2c_dw_disable_int(dev);
900 dw_readl(dev, DW_IC_CLR_INTR);
901
902 complete(&dev->cmd_complete); 888 complete(&dev->cmd_complete);
903 } else if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) { 889 else if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) {
904 /* workaround to trigger pending interrupt */ 890 /* workaround to trigger pending interrupt */
905 stat = dw_readl(dev, DW_IC_INTR_MASK); 891 stat = dw_readl(dev, DW_IC_INTR_MASK);
906 i2c_dw_disable_int(dev); 892 i2c_dw_disable_int(dev);
diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index 419b54bfc7c7..5e63b17f935d 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -381,9 +381,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
381 if (result) 381 if (result)
382 return result; 382 return result;
383 383
384 data[i] = octeon_i2c_data_read(i2c, &result); 384 data[i] = octeon_i2c_data_read(i2c);
385 if (result)
386 return result;
387 if (recv_len && i == 0) { 385 if (recv_len && i == 0) {
388 if (data[i] > I2C_SMBUS_BLOCK_MAX + 1) 386 if (data[i] > I2C_SMBUS_BLOCK_MAX + 1)
389 return -EPROTO; 387 return -EPROTO;
diff --git a/drivers/i2c/busses/i2c-octeon-core.h b/drivers/i2c/busses/i2c-octeon-core.h
index 1db7c835a454..87151ea74acd 100644
--- a/drivers/i2c/busses/i2c-octeon-core.h
+++ b/drivers/i2c/busses/i2c-octeon-core.h
@@ -5,7 +5,6 @@
5#include <linux/i2c.h> 5#include <linux/i2c.h>
6#include <linux/i2c-smbus.h> 6#include <linux/i2c-smbus.h>
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/iopoll.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/pci.h> 9#include <linux/pci.h>
11 10
@@ -145,9 +144,9 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8
145 u64 tmp; 144 u64 tmp;
146 145
147 __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI(i2c)); 146 __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI(i2c));
148 147 do {
149 readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp, tmp & SW_TWSI_V, 148 tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c));
150 I2C_OCTEON_EVENT_WAIT, i2c->adap.timeout); 149 } while ((tmp & SW_TWSI_V) != 0);
151} 150}
152 151
153#define octeon_i2c_ctl_write(i2c, val) \ 152#define octeon_i2c_ctl_write(i2c, val) \
@@ -164,28 +163,24 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8
164 * 163 *
165 * The I2C core registers are accessed indirectly via the SW_TWSI CSR. 164 * The I2C core registers are accessed indirectly via the SW_TWSI CSR.
166 */ 165 */
167static inline int octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg, 166static inline u8 octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg)
168 int *error)
169{ 167{
170 u64 tmp; 168 u64 tmp;
171 int ret;
172 169
173 __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI(i2c)); 170 __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI(i2c));
171 do {
172 tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c));
173 } while ((tmp & SW_TWSI_V) != 0);
174 174
175 ret = readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp,
176 tmp & SW_TWSI_V, I2C_OCTEON_EVENT_WAIT,
177 i2c->adap.timeout);
178 if (error)
179 *error = ret;
180 return tmp & 0xFF; 175 return tmp & 0xFF;
181} 176}
182 177
183#define octeon_i2c_ctl_read(i2c) \ 178#define octeon_i2c_ctl_read(i2c) \
184 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL, NULL) 179 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL)
185#define octeon_i2c_data_read(i2c, error) \ 180#define octeon_i2c_data_read(i2c) \
186 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA, error) 181 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA)
187#define octeon_i2c_stat_read(i2c) \ 182#define octeon_i2c_stat_read(i2c) \
188 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT, NULL) 183 octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT)
189 184
190/** 185/**
191 * octeon_i2c_read_int - read the TWSI_INT register 186 * octeon_i2c_read_int - read the TWSI_INT register
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index fb4b185dea96..bee267424972 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1115,10 +1115,6 @@ static int psmouse_extensions(struct psmouse *psmouse,
1115 if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2, 1115 if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2,
1116 &max_proto, set_properties, true)) 1116 &max_proto, set_properties, true))
1117 return PSMOUSE_TOUCHKIT_PS2; 1117 return PSMOUSE_TOUCHKIT_PS2;
1118
1119 if (psmouse_try_protocol(psmouse, PSMOUSE_BYD,
1120 &max_proto, set_properties, true))
1121 return PSMOUSE_BYD;
1122 } 1118 }
1123 1119
1124 /* 1120 /*
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 58470f5ced04..8c53748a769d 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -338,7 +338,9 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
338 struct pci_dev *pdev = to_pci_dev(data); 338 struct pci_dev *pdev = to_pci_dev(data);
339 struct dmar_pci_notify_info *info; 339 struct dmar_pci_notify_info *info;
340 340
341 /* Only care about add/remove events for physical functions */ 341 /* Only care about add/remove events for physical functions.
342 * For VFs we actually do the lookup based on the corresponding
343 * PF in device_to_iommu() anyway. */
342 if (pdev->is_virtfn) 344 if (pdev->is_virtfn)
343 return NOTIFY_DONE; 345 return NOTIFY_DONE;
344 if (action != BUS_NOTIFY_ADD_DEVICE && 346 if (action != BUS_NOTIFY_ADD_DEVICE &&
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 3965e73db51c..d8376c2d18b3 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -892,7 +892,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
892 return NULL; 892 return NULL;
893 893
894 if (dev_is_pci(dev)) { 894 if (dev_is_pci(dev)) {
895 struct pci_dev *pf_pdev;
896
895 pdev = to_pci_dev(dev); 897 pdev = to_pci_dev(dev);
898 /* VFs aren't listed in scope tables; we need to look up
899 * the PF instead to find the IOMMU. */
900 pf_pdev = pci_physfn(pdev);
901 dev = &pf_pdev->dev;
896 segment = pci_domain_nr(pdev->bus); 902 segment = pci_domain_nr(pdev->bus);
897 } else if (has_acpi_companion(dev)) 903 } else if (has_acpi_companion(dev))
898 dev = &ACPI_COMPANION(dev)->dev; 904 dev = &ACPI_COMPANION(dev)->dev;
@@ -905,6 +911,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
905 for_each_active_dev_scope(drhd->devices, 911 for_each_active_dev_scope(drhd->devices,
906 drhd->devices_cnt, i, tmp) { 912 drhd->devices_cnt, i, tmp) {
907 if (tmp == dev) { 913 if (tmp == dev) {
914 /* For a VF use its original BDF# not that of the PF
915 * which we used for the IOMMU lookup. Strictly speaking
916 * we could do this for all PCI devices; we only need to
917 * get the BDF# from the scope table for ACPI matches. */
918 if (pdev->is_virtfn)
919 goto got_pdev;
920
908 *bus = drhd->devices[i].bus; 921 *bus = drhd->devices[i].bus;
909 *devfn = drhd->devices[i].devfn; 922 *devfn = drhd->devices[i].devfn;
910 goto out; 923 goto out;
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 8ebb3530afa7..cb72e0011310 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -39,10 +39,18 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
39 struct page *pages; 39 struct page *pages;
40 int order; 40 int order;
41 41
42 order = ecap_pss(iommu->ecap) + 7 - PAGE_SHIFT; 42 /* Start at 2 because it's defined as 2^(1+PSS) */
43 if (order < 0) 43 iommu->pasid_max = 2 << ecap_pss(iommu->ecap);
44 order = 0; 44
45 45 /* Eventually I'm promised we will get a multi-level PASID table
46 * and it won't have to be physically contiguous. Until then,
47 * limit the size because 8MiB contiguous allocations can be hard
48 * to come by. The limit of 0x20000, which is 1MiB for each of
49 * the PASID and PASID-state tables, is somewhat arbitrary. */
50 if (iommu->pasid_max > 0x20000)
51 iommu->pasid_max = 0x20000;
52
53 order = get_order(sizeof(struct pasid_entry) * iommu->pasid_max);
46 pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order); 54 pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
47 if (!pages) { 55 if (!pages) {
48 pr_warn("IOMMU: %s: Failed to allocate PASID table\n", 56 pr_warn("IOMMU: %s: Failed to allocate PASID table\n",
@@ -53,6 +61,8 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
53 pr_info("%s: Allocated order %d PASID table.\n", iommu->name, order); 61 pr_info("%s: Allocated order %d PASID table.\n", iommu->name, order);
54 62
55 if (ecap_dis(iommu->ecap)) { 63 if (ecap_dis(iommu->ecap)) {
64 /* Just making it explicit... */
65 BUILD_BUG_ON(sizeof(struct pasid_entry) != sizeof(struct pasid_state_entry));
56 pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order); 66 pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
57 if (pages) 67 if (pages)
58 iommu->pasid_state_table = page_address(pages); 68 iommu->pasid_state_table = page_address(pages);
@@ -68,11 +78,7 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
68 78
69int intel_svm_free_pasid_tables(struct intel_iommu *iommu) 79int intel_svm_free_pasid_tables(struct intel_iommu *iommu)
70{ 80{
71 int order; 81 int order = get_order(sizeof(struct pasid_entry) * iommu->pasid_max);
72
73 order = ecap_pss(iommu->ecap) + 7 - PAGE_SHIFT;
74 if (order < 0)
75 order = 0;
76 82
77 if (iommu->pasid_table) { 83 if (iommu->pasid_table) {
78 free_pages((unsigned long)iommu->pasid_table, order); 84 free_pages((unsigned long)iommu->pasid_table, order);
@@ -371,8 +377,8 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
371 } 377 }
372 svm->iommu = iommu; 378 svm->iommu = iommu;
373 379
374 if (pasid_max > 2 << ecap_pss(iommu->ecap)) 380 if (pasid_max > iommu->pasid_max)
375 pasid_max = 2 << ecap_pss(iommu->ecap); 381 pasid_max = iommu->pasid_max;
376 382
377 /* Do not use PASID 0 in caching mode (virtualised IOMMU) */ 383 /* Do not use PASID 0 in caching mode (virtualised IOMMU) */
378 ret = idr_alloc(&iommu->pasid_idr, svm, 384 ret = idr_alloc(&iommu->pasid_idr, svm,
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index d1f8ab915b15..b90776ef56ec 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -755,8 +755,10 @@ static int __init ser_gigaset_init(void)
755 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 755 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
756 GIGASET_MODULENAME, GIGASET_DEVNAME, 756 GIGASET_MODULENAME, GIGASET_DEVNAME,
757 &ops, THIS_MODULE); 757 &ops, THIS_MODULE);
758 if (!driver) 758 if (!driver) {
759 rc = -ENOMEM;
759 goto error; 760 goto error;
761 }
760 762
761 rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc); 763 rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc);
762 if (rc != 0) { 764 if (rc != 0) {
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index 9600cd771f1a..e034ed847ff3 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -1499,6 +1499,7 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1499 printk(KERN_INFO 1499 printk(KERN_INFO
1500 "HFC-4S/8S: failed to request address space at 0x%04x\n", 1500 "HFC-4S/8S: failed to request address space at 0x%04x\n",
1501 hw->iobase); 1501 hw->iobase);
1502 err = -EBUSY;
1502 goto out; 1503 goto out;
1503 } 1504 }
1504 1505
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 317ef63ee789..8d96a22647b3 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -281,6 +281,14 @@ static void free_firmware(struct xc2028_data *priv)
281 int i; 281 int i;
282 tuner_dbg("%s called\n", __func__); 282 tuner_dbg("%s called\n", __func__);
283 283
284 /* free allocated f/w string */
285 if (priv->fname != firmware_name)
286 kfree(priv->fname);
287 priv->fname = NULL;
288
289 priv->state = XC2028_NO_FIRMWARE;
290 memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
291
284 if (!priv->firm) 292 if (!priv->firm)
285 return; 293 return;
286 294
@@ -291,9 +299,6 @@ static void free_firmware(struct xc2028_data *priv)
291 299
292 priv->firm = NULL; 300 priv->firm = NULL;
293 priv->firm_size = 0; 301 priv->firm_size = 0;
294 priv->state = XC2028_NO_FIRMWARE;
295
296 memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
297} 302}
298 303
299static int load_all_firmwares(struct dvb_frontend *fe, 304static int load_all_firmwares(struct dvb_frontend *fe,
@@ -884,9 +889,8 @@ read_not_reliable:
884 return 0; 889 return 0;
885 890
886fail: 891fail:
887 priv->state = XC2028_NO_FIRMWARE; 892 free_firmware(priv);
888 893
889 memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
890 if (retry_count < 8) { 894 if (retry_count < 8) {
891 msleep(50); 895 msleep(50);
892 retry_count++; 896 retry_count++;
@@ -1332,11 +1336,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
1332 mutex_lock(&xc2028_list_mutex); 1336 mutex_lock(&xc2028_list_mutex);
1333 1337
1334 /* only perform final cleanup if this is the last instance */ 1338 /* only perform final cleanup if this is the last instance */
1335 if (hybrid_tuner_report_instance_count(priv) == 1) { 1339 if (hybrid_tuner_report_instance_count(priv) == 1)
1336 free_firmware(priv); 1340 free_firmware(priv);
1337 kfree(priv->ctrl.fname);
1338 priv->ctrl.fname = NULL;
1339 }
1340 1341
1341 if (priv) 1342 if (priv)
1342 hybrid_tuner_release_state(priv); 1343 hybrid_tuner_release_state(priv);
@@ -1399,19 +1400,8 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
1399 1400
1400 /* 1401 /*
1401 * Copy the config data. 1402 * Copy the config data.
1402 * For the firmware name, keep a local copy of the string,
1403 * in order to avoid troubles during device release.
1404 */ 1403 */
1405 kfree(priv->ctrl.fname);
1406 priv->ctrl.fname = NULL;
1407 memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); 1404 memcpy(&priv->ctrl, p, sizeof(priv->ctrl));
1408 if (p->fname) {
1409 priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL);
1410 if (priv->ctrl.fname == NULL) {
1411 rc = -ENOMEM;
1412 goto unlock;
1413 }
1414 }
1415 1405
1416 /* 1406 /*
1417 * If firmware name changed, frees firmware. As free_firmware will 1407 * If firmware name changed, frees firmware. As free_firmware will
@@ -1426,10 +1416,15 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
1426 1416
1427 if (priv->state == XC2028_NO_FIRMWARE) { 1417 if (priv->state == XC2028_NO_FIRMWARE) {
1428 if (!firmware_name[0]) 1418 if (!firmware_name[0])
1429 priv->fname = priv->ctrl.fname; 1419 priv->fname = kstrdup(p->fname, GFP_KERNEL);
1430 else 1420 else
1431 priv->fname = firmware_name; 1421 priv->fname = firmware_name;
1432 1422
1423 if (!priv->fname) {
1424 rc = -ENOMEM;
1425 goto unlock;
1426 }
1427
1433 rc = request_firmware_nowait(THIS_MODULE, 1, 1428 rc = request_firmware_nowait(THIS_MODULE, 1,
1434 priv->fname, 1429 priv->fname,
1435 priv->i2c_props.adap->dev.parent, 1430 priv->i2c_props.adap->dev.parent,
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 2f2225e845ef..b93fe4c4957a 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -73,8 +73,10 @@ static struct syscon *of_syscon_register(struct device_node *np)
73 /* Parse the device's DT node for an endianness specification */ 73 /* Parse the device's DT node for an endianness specification */
74 if (of_property_read_bool(np, "big-endian")) 74 if (of_property_read_bool(np, "big-endian"))
75 syscon_config.val_format_endian = REGMAP_ENDIAN_BIG; 75 syscon_config.val_format_endian = REGMAP_ENDIAN_BIG;
76 else if (of_property_read_bool(np, "little-endian")) 76 else if (of_property_read_bool(np, "little-endian"))
77 syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE; 77 syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE;
78 else if (of_property_read_bool(np, "native-endian"))
79 syscon_config.val_format_endian = REGMAP_ENDIAN_NATIVE;
78 80
79 /* 81 /*
80 * search for reg-io-width property in DT. If it is not provided, 82 * search for reg-io-width property in DT. If it is not provided,
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 7eec619a6023..8588dbad3301 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -393,8 +393,13 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
393 BUG(); 393 BUG();
394 goto err; 394 goto err;
395 } 395 }
396 396
397 ret = devm_regulator_bulk_get(wm8994->dev, wm8994->num_supplies, 397 /*
398 * Can't use devres helper here as some of the supplies are provided by
399 * wm8994->dev's children (regulators) and those regulators are
400 * unregistered by the devres core before the supplies are freed.
401 */
402 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
398 wm8994->supplies); 403 wm8994->supplies);
399 if (ret != 0) { 404 if (ret != 0) {
400 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); 405 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
@@ -405,7 +410,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
405 wm8994->supplies); 410 wm8994->supplies);
406 if (ret != 0) { 411 if (ret != 0) {
407 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); 412 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
408 goto err; 413 goto err_regulator_free;
409 } 414 }
410 415
411 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); 416 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
@@ -596,6 +601,8 @@ err_irq:
596err_enable: 601err_enable:
597 regulator_bulk_disable(wm8994->num_supplies, 602 regulator_bulk_disable(wm8994->num_supplies,
598 wm8994->supplies); 603 wm8994->supplies);
604err_regulator_free:
605 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
599err: 606err:
600 mfd_remove_devices(wm8994->dev); 607 mfd_remove_devices(wm8994->dev);
601 return ret; 608 return ret;
@@ -604,10 +611,11 @@ err:
604static void wm8994_device_exit(struct wm8994 *wm8994) 611static void wm8994_device_exit(struct wm8994 *wm8994)
605{ 612{
606 pm_runtime_disable(wm8994->dev); 613 pm_runtime_disable(wm8994->dev);
607 mfd_remove_devices(wm8994->dev);
608 wm8994_irq_exit(wm8994); 614 wm8994_irq_exit(wm8994);
609 regulator_bulk_disable(wm8994->num_supplies, 615 regulator_bulk_disable(wm8994->num_supplies,
610 wm8994->supplies); 616 wm8994->supplies);
617 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
618 mfd_remove_devices(wm8994->dev);
611} 619}
612 620
613static const struct of_device_id wm8994_of_match[] = { 621static const struct of_device_id wm8994_of_match[] = {
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 50a674be6655..df478ae72e23 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1058,6 +1058,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
1058 spin_unlock_irqrestore(&host->irq_lock, irqflags); 1058 spin_unlock_irqrestore(&host->irq_lock, irqflags);
1059 1059
1060 if (host->dma_ops->start(host, sg_len)) { 1060 if (host->dma_ops->start(host, sg_len)) {
1061 host->dma_ops->stop(host);
1061 /* We can't do DMA, try PIO for this one */ 1062 /* We can't do DMA, try PIO for this one */
1062 dev_dbg(host->dev, 1063 dev_dbg(host->dev,
1063 "%s: fall back to PIO mode for current transfer\n", 1064 "%s: fall back to PIO mode for current transfer\n",
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index fb71c866eacc..1bb11e4a9fe5 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -66,6 +66,20 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
66 return ret; 66 return ret;
67 } 67 }
68 } 68 }
69 /*
70 * The DAT[3:0] line signal levels and the CMD line signal level are
71 * not compatible with standard SDHC register. The line signal levels
72 * DAT[7:0] are at bits 31:24 and the command line signal level is at
73 * bit 23. All other bits are the same as in the standard SDHC
74 * register.
75 */
76 if (spec_reg == SDHCI_PRESENT_STATE) {
77 ret = value & 0x000fffff;
78 ret |= (value >> 4) & SDHCI_DATA_LVL_MASK;
79 ret |= (value << 1) & SDHCI_CMD_LVL;
80 return ret;
81 }
82
69 ret = value; 83 ret = value;
70 return ret; 84 return ret;
71} 85}
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 766df17fb7eb..2570455b219a 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -73,6 +73,7 @@
73#define SDHCI_DATA_LVL_MASK 0x00F00000 73#define SDHCI_DATA_LVL_MASK 0x00F00000
74#define SDHCI_DATA_LVL_SHIFT 20 74#define SDHCI_DATA_LVL_SHIFT 20
75#define SDHCI_DATA_0_LVL_MASK 0x00100000 75#define SDHCI_DATA_0_LVL_MASK 0x00100000
76#define SDHCI_CMD_LVL 0x01000000
76 77
77#define SDHCI_HOST_CONTROL 0x28 78#define SDHCI_HOST_CONTROL 0x28
78#define SDHCI_CTRL_LED 0x01 79#define SDHCI_CTRL_LED 0x01
diff --git a/drivers/net/can/usb/peak_usb/pcan_ucan.h b/drivers/net/can/usb/peak_usb/pcan_ucan.h
index e8fc4952c6b0..2147678f0225 100644
--- a/drivers/net/can/usb/peak_usb/pcan_ucan.h
+++ b/drivers/net/can/usb/peak_usb/pcan_ucan.h
@@ -43,11 +43,22 @@ struct __packed pucan_command {
43 u16 args[3]; 43 u16 args[3];
44}; 44};
45 45
46#define PUCAN_TSLOW_BRP_BITS 10
47#define PUCAN_TSLOW_TSGEG1_BITS 8
48#define PUCAN_TSLOW_TSGEG2_BITS 7
49#define PUCAN_TSLOW_SJW_BITS 7
50
51#define PUCAN_TSLOW_BRP_MASK ((1 << PUCAN_TSLOW_BRP_BITS) - 1)
52#define PUCAN_TSLOW_TSEG1_MASK ((1 << PUCAN_TSLOW_TSGEG1_BITS) - 1)
53#define PUCAN_TSLOW_TSEG2_MASK ((1 << PUCAN_TSLOW_TSGEG2_BITS) - 1)
54#define PUCAN_TSLOW_SJW_MASK ((1 << PUCAN_TSLOW_SJW_BITS) - 1)
55
46/* uCAN TIMING_SLOW command fields */ 56/* uCAN TIMING_SLOW command fields */
47#define PUCAN_TSLOW_SJW_T(s, t) (((s) & 0xf) | ((!!(t)) << 7)) 57#define PUCAN_TSLOW_SJW_T(s, t) (((s) & PUCAN_TSLOW_SJW_MASK) | \
48#define PUCAN_TSLOW_TSEG2(t) ((t) & 0xf) 58 ((!!(t)) << 7))
49#define PUCAN_TSLOW_TSEG1(t) ((t) & 0x3f) 59#define PUCAN_TSLOW_TSEG2(t) ((t) & PUCAN_TSLOW_TSEG2_MASK)
50#define PUCAN_TSLOW_BRP(b) ((b) & 0x3ff) 60#define PUCAN_TSLOW_TSEG1(t) ((t) & PUCAN_TSLOW_TSEG1_MASK)
61#define PUCAN_TSLOW_BRP(b) ((b) & PUCAN_TSLOW_BRP_MASK)
51 62
52struct __packed pucan_timing_slow { 63struct __packed pucan_timing_slow {
53 __le16 opcode_channel; 64 __le16 opcode_channel;
@@ -60,11 +71,21 @@ struct __packed pucan_timing_slow {
60 __le16 brp; /* BaudRate Prescaler */ 71 __le16 brp; /* BaudRate Prescaler */
61}; 72};
62 73
74#define PUCAN_TFAST_BRP_BITS 10
75#define PUCAN_TFAST_TSGEG1_BITS 5
76#define PUCAN_TFAST_TSGEG2_BITS 4
77#define PUCAN_TFAST_SJW_BITS 4
78
79#define PUCAN_TFAST_BRP_MASK ((1 << PUCAN_TFAST_BRP_BITS) - 1)
80#define PUCAN_TFAST_TSEG1_MASK ((1 << PUCAN_TFAST_TSGEG1_BITS) - 1)
81#define PUCAN_TFAST_TSEG2_MASK ((1 << PUCAN_TFAST_TSGEG2_BITS) - 1)
82#define PUCAN_TFAST_SJW_MASK ((1 << PUCAN_TFAST_SJW_BITS) - 1)
83
63/* uCAN TIMING_FAST command fields */ 84/* uCAN TIMING_FAST command fields */
64#define PUCAN_TFAST_SJW(s) ((s) & 0x3) 85#define PUCAN_TFAST_SJW(s) ((s) & PUCAN_TFAST_SJW_MASK)
65#define PUCAN_TFAST_TSEG2(t) ((t) & 0x7) 86#define PUCAN_TFAST_TSEG2(t) ((t) & PUCAN_TFAST_TSEG2_MASK)
66#define PUCAN_TFAST_TSEG1(t) ((t) & 0xf) 87#define PUCAN_TFAST_TSEG1(t) ((t) & PUCAN_TFAST_TSEG1_MASK)
67#define PUCAN_TFAST_BRP(b) ((b) & 0x3ff) 88#define PUCAN_TFAST_BRP(b) ((b) & PUCAN_TFAST_BRP_MASK)
68 89
69struct __packed pucan_timing_fast { 90struct __packed pucan_timing_fast {
70 __le16 opcode_channel; 91 __le16 opcode_channel;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index c06382cdfdfe..0b0302af3bd2 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = {
39 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, 39 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)},
40 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, 40 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)},
41 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, 41 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)},
42 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)},
42 {} /* Terminating entry */ 43 {} /* Terminating entry */
43}; 44};
44 45
@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = {
50 &pcan_usb_pro, 51 &pcan_usb_pro,
51 &pcan_usb_fd, 52 &pcan_usb_fd,
52 &pcan_usb_pro_fd, 53 &pcan_usb_pro_fd,
54 &pcan_usb_x6,
53}; 55};
54 56
55/* 57/*
@@ -868,23 +870,25 @@ lbl_free_candev:
868static void peak_usb_disconnect(struct usb_interface *intf) 870static void peak_usb_disconnect(struct usb_interface *intf)
869{ 871{
870 struct peak_usb_device *dev; 872 struct peak_usb_device *dev;
873 struct peak_usb_device *dev_prev_siblings;
871 874
872 /* unregister as many netdev devices as siblings */ 875 /* unregister as many netdev devices as siblings */
873 for (dev = usb_get_intfdata(intf); dev; dev = dev->prev_siblings) { 876 for (dev = usb_get_intfdata(intf); dev; dev = dev_prev_siblings) {
874 struct net_device *netdev = dev->netdev; 877 struct net_device *netdev = dev->netdev;
875 char name[IFNAMSIZ]; 878 char name[IFNAMSIZ];
876 879
880 dev_prev_siblings = dev->prev_siblings;
877 dev->state &= ~PCAN_USB_STATE_CONNECTED; 881 dev->state &= ~PCAN_USB_STATE_CONNECTED;
878 strncpy(name, netdev->name, IFNAMSIZ); 882 strncpy(name, netdev->name, IFNAMSIZ);
879 883
880 unregister_netdev(netdev); 884 unregister_netdev(netdev);
881 free_candev(netdev);
882 885
883 kfree(dev->cmd_buf); 886 kfree(dev->cmd_buf);
884 dev->next_siblings = NULL; 887 dev->next_siblings = NULL;
885 if (dev->adapter->dev_free) 888 if (dev->adapter->dev_free)
886 dev->adapter->dev_free(dev); 889 dev->adapter->dev_free(dev);
887 890
891 free_candev(netdev);
888 dev_info(&intf->dev, "%s removed\n", name); 892 dev_info(&intf->dev, "%s removed\n", name);
889 } 893 }
890 894
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index 506fe506c9d3..3cbfb069893d 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -27,6 +27,7 @@
27#define PCAN_USBPRO_PRODUCT_ID 0x000d 27#define PCAN_USBPRO_PRODUCT_ID 0x000d
28#define PCAN_USBPROFD_PRODUCT_ID 0x0011 28#define PCAN_USBPROFD_PRODUCT_ID 0x0011
29#define PCAN_USBFD_PRODUCT_ID 0x0012 29#define PCAN_USBFD_PRODUCT_ID 0x0012
30#define PCAN_USBX6_PRODUCT_ID 0x0014
30 31
31#define PCAN_USB_DRIVER_NAME "peak_usb" 32#define PCAN_USB_DRIVER_NAME "peak_usb"
32 33
@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb;
90extern const struct peak_usb_adapter pcan_usb_pro; 91extern const struct peak_usb_adapter pcan_usb_pro;
91extern const struct peak_usb_adapter pcan_usb_fd; 92extern const struct peak_usb_adapter pcan_usb_fd;
92extern const struct peak_usb_adapter pcan_usb_pro_fd; 93extern const struct peak_usb_adapter pcan_usb_pro_fd;
94extern const struct peak_usb_adapter pcan_usb_x6;
93 95
94struct peak_time_ref { 96struct peak_time_ref {
95 struct timeval tv_host_0, tv_host; 97 struct timeval tv_host_0, tv_host;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index ce44a033f63b..304732550f0a 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev)
993static const struct can_bittiming_const pcan_usb_fd_const = { 993static const struct can_bittiming_const pcan_usb_fd_const = {
994 .name = "pcan_usb_fd", 994 .name = "pcan_usb_fd",
995 .tseg1_min = 1, 995 .tseg1_min = 1,
996 .tseg1_max = 64, 996 .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
997 .tseg2_min = 1, 997 .tseg2_min = 1,
998 .tseg2_max = 16, 998 .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
999 .sjw_max = 16, 999 .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
1000 .brp_min = 1, 1000 .brp_min = 1,
1001 .brp_max = 1024, 1001 .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
1002 .brp_inc = 1, 1002 .brp_inc = 1,
1003}; 1003};
1004 1004
1005static const struct can_bittiming_const pcan_usb_fd_data_const = { 1005static const struct can_bittiming_const pcan_usb_fd_data_const = {
1006 .name = "pcan_usb_fd", 1006 .name = "pcan_usb_fd",
1007 .tseg1_min = 1, 1007 .tseg1_min = 1,
1008 .tseg1_max = 16, 1008 .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
1009 .tseg2_min = 1, 1009 .tseg2_min = 1,
1010 .tseg2_max = 8, 1010 .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1011 .sjw_max = 4, 1011 .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
1012 .brp_min = 1, 1012 .brp_min = 1,
1013 .brp_max = 1024, 1013 .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
1014 .brp_inc = 1, 1014 .brp_inc = 1,
1015}; 1015};
1016 1016
@@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = {
1065static const struct can_bittiming_const pcan_usb_pro_fd_const = { 1065static const struct can_bittiming_const pcan_usb_pro_fd_const = {
1066 .name = "pcan_usb_pro_fd", 1066 .name = "pcan_usb_pro_fd",
1067 .tseg1_min = 1, 1067 .tseg1_min = 1,
1068 .tseg1_max = 64, 1068 .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
1069 .tseg2_min = 1, 1069 .tseg2_min = 1,
1070 .tseg2_max = 16, 1070 .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
1071 .sjw_max = 16, 1071 .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
1072 .brp_min = 1, 1072 .brp_min = 1,
1073 .brp_max = 1024, 1073 .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
1074 .brp_inc = 1, 1074 .brp_inc = 1,
1075}; 1075};
1076 1076
1077static const struct can_bittiming_const pcan_usb_pro_fd_data_const = { 1077static const struct can_bittiming_const pcan_usb_pro_fd_data_const = {
1078 .name = "pcan_usb_pro_fd", 1078 .name = "pcan_usb_pro_fd",
1079 .tseg1_min = 1, 1079 .tseg1_min = 1,
1080 .tseg1_max = 16, 1080 .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
1081 .tseg2_min = 1, 1081 .tseg2_min = 1,
1082 .tseg2_max = 8, 1082 .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1083 .sjw_max = 4, 1083 .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
1084 .brp_min = 1, 1084 .brp_min = 1,
1085 .brp_max = 1024, 1085 .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
1086 .brp_inc = 1, 1086 .brp_inc = 1,
1087}; 1087};
1088 1088
@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = {
1132 1132
1133 .do_get_berr_counter = pcan_usb_fd_get_berr_counter, 1133 .do_get_berr_counter = pcan_usb_fd_get_berr_counter,
1134}; 1134};
1135
1136/* describes the PCAN-USB X6 adapter */
1137static const struct can_bittiming_const pcan_usb_x6_const = {
1138 .name = "pcan_usb_x6",
1139 .tseg1_min = 1,
1140 .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
1141 .tseg2_min = 1,
1142 .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
1143 .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
1144 .brp_min = 1,
1145 .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
1146 .brp_inc = 1,
1147};
1148
1149static const struct can_bittiming_const pcan_usb_x6_data_const = {
1150 .name = "pcan_usb_x6",
1151 .tseg1_min = 1,
1152 .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
1153 .tseg2_min = 1,
1154 .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1155 .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
1156 .brp_min = 1,
1157 .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
1158 .brp_inc = 1,
1159};
1160
1161const struct peak_usb_adapter pcan_usb_x6 = {
1162 .name = "PCAN-USB X6",
1163 .device_id = PCAN_USBX6_PRODUCT_ID,
1164 .ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
1165 .ctrlmode_supported = CAN_CTRLMODE_FD |
1166 CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
1167 .clock = {
1168 .freq = PCAN_UFD_CRYSTAL_HZ,
1169 },
1170 .bittiming_const = &pcan_usb_x6_const,
1171 .data_bittiming_const = &pcan_usb_x6_data_const,
1172
1173 /* size of device private data */
1174 .sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
1175
1176 /* timestamps usage */
1177 .ts_used_bits = 32,
1178 .ts_period = 1000000, /* calibration period in ts. */
1179 .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
1180 .us_per_ts_shift = 0,
1181
1182 /* give here messages in/out endpoints */
1183 .ep_msg_in = PCAN_USBPRO_EP_MSGIN,
1184 .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
1185
1186 /* size of rx/tx usb buffers */
1187 .rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
1188 .tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
1189
1190 /* device callbacks */
1191 .intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
1192 .dev_init = pcan_usb_fd_init,
1193
1194 .dev_exit = pcan_usb_fd_exit,
1195 .dev_free = pcan_usb_fd_free,
1196 .dev_set_bus = pcan_usb_fd_set_bus,
1197 .dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
1198 .dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
1199 .dev_decode_buf = pcan_usb_fd_decode_buf,
1200 .dev_start = pcan_usb_fd_start,
1201 .dev_stop = pcan_usb_fd_stop,
1202 .dev_restart_async = pcan_usb_fd_restart_async,
1203 .dev_encode_msg = pcan_usb_fd_encode_msg,
1204
1205 .do_get_berr_counter = pcan_usb_fd_get_berr_counter,
1206};
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index e3ee27ce13dd..9ec33b51a0ed 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -588,6 +588,7 @@ static void bcm_sf2_sw_adjust_link(struct dsa_switch *ds, int port,
588 struct phy_device *phydev) 588 struct phy_device *phydev)
589{ 589{
590 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); 590 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
591 struct ethtool_eee *p = &priv->port_sts[port].eee;
591 u32 id_mode_dis = 0, port_mode; 592 u32 id_mode_dis = 0, port_mode;
592 const char *str = NULL; 593 const char *str = NULL;
593 u32 reg; 594 u32 reg;
@@ -662,6 +663,9 @@ force_link:
662 reg |= DUPLX_MODE; 663 reg |= DUPLX_MODE;
663 664
664 core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port)); 665 core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port));
666
667 if (!phydev->is_pseudo_fixed_link)
668 p->eee_enabled = bcm_sf2_eee_init(ds, port, phydev);
665} 669}
666 670
667static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port, 671static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index bda31f308cc2..a0eee7218695 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -400,12 +400,6 @@ static int tse_rx(struct altera_tse_private *priv, int limit)
400 400
401 skb_put(skb, pktlength); 401 skb_put(skb, pktlength);
402 402
403 /* make cache consistent with receive packet buffer */
404 dma_sync_single_for_cpu(priv->device,
405 priv->rx_ring[entry].dma_addr,
406 priv->rx_ring[entry].len,
407 DMA_FROM_DEVICE);
408
409 dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr, 403 dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr,
410 priv->rx_ring[entry].len, DMA_FROM_DEVICE); 404 priv->rx_ring[entry].len, DMA_FROM_DEVICE);
411 405
@@ -469,7 +463,6 @@ static int tse_tx_complete(struct altera_tse_private *priv)
469 463
470 if (unlikely(netif_queue_stopped(priv->dev) && 464 if (unlikely(netif_queue_stopped(priv->dev) &&
471 tse_tx_avail(priv) > TSE_TX_THRESH(priv))) { 465 tse_tx_avail(priv) > TSE_TX_THRESH(priv))) {
472 netif_tx_lock(priv->dev);
473 if (netif_queue_stopped(priv->dev) && 466 if (netif_queue_stopped(priv->dev) &&
474 tse_tx_avail(priv) > TSE_TX_THRESH(priv)) { 467 tse_tx_avail(priv) > TSE_TX_THRESH(priv)) {
475 if (netif_msg_tx_done(priv)) 468 if (netif_msg_tx_done(priv))
@@ -477,7 +470,6 @@ static int tse_tx_complete(struct altera_tse_private *priv)
477 __func__); 470 __func__);
478 netif_wake_queue(priv->dev); 471 netif_wake_queue(priv->dev);
479 } 472 }
480 netif_tx_unlock(priv->dev);
481 } 473 }
482 474
483 spin_unlock(&priv->tx_lock); 475 spin_unlock(&priv->tx_lock);
@@ -592,10 +584,6 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev)
592 buffer->dma_addr = dma_addr; 584 buffer->dma_addr = dma_addr;
593 buffer->len = nopaged_len; 585 buffer->len = nopaged_len;
594 586
595 /* Push data out of the cache hierarchy into main memory */
596 dma_sync_single_for_device(priv->device, buffer->dma_addr,
597 buffer->len, DMA_TO_DEVICE);
598
599 priv->dmaops->tx_buffer(priv, buffer); 587 priv->dmaops->tx_buffer(priv, buffer);
600 588
601 skb_tx_timestamp(skb); 589 skb_tx_timestamp(skb);
@@ -819,6 +807,8 @@ static int init_phy(struct net_device *dev)
819 807
820 if (!phydev) { 808 if (!phydev) {
821 netdev_err(dev, "Could not find the PHY\n"); 809 netdev_err(dev, "Could not find the PHY\n");
810 if (fixed_link)
811 of_phy_deregister_fixed_link(priv->device->of_node);
822 return -ENODEV; 812 return -ENODEV;
823 } 813 }
824 814
@@ -1545,10 +1535,15 @@ err_free_netdev:
1545static int altera_tse_remove(struct platform_device *pdev) 1535static int altera_tse_remove(struct platform_device *pdev)
1546{ 1536{
1547 struct net_device *ndev = platform_get_drvdata(pdev); 1537 struct net_device *ndev = platform_get_drvdata(pdev);
1538 struct altera_tse_private *priv = netdev_priv(ndev);
1548 1539
1549 if (ndev->phydev) 1540 if (ndev->phydev) {
1550 phy_disconnect(ndev->phydev); 1541 phy_disconnect(ndev->phydev);
1551 1542
1543 if (of_phy_is_fixed_link(priv->device->of_node))
1544 of_phy_deregister_fixed_link(priv->device->of_node);
1545 }
1546
1552 platform_set_drvdata(pdev, NULL); 1547 platform_set_drvdata(pdev, NULL);
1553 altera_tse_mdio_destroy(ndev); 1548 altera_tse_mdio_destroy(ndev);
1554 unregister_netdev(ndev); 1549 unregister_netdev(ndev);
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 9de078819aa6..4f7635178200 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -829,7 +829,7 @@ static int xgbe_remove(struct platform_device *pdev)
829 return 0; 829 return 0;
830} 830}
831 831
832#ifdef CONFIG_PM 832#ifdef CONFIG_PM_SLEEP
833static int xgbe_suspend(struct device *dev) 833static int xgbe_suspend(struct device *dev)
834{ 834{
835 struct net_device *netdev = dev_get_drvdata(dev); 835 struct net_device *netdev = dev_get_drvdata(dev);
@@ -874,7 +874,7 @@ static int xgbe_resume(struct device *dev)
874 874
875 return ret; 875 return ret;
876} 876}
877#endif /* CONFIG_PM */ 877#endif /* CONFIG_PM_SLEEP */
878 878
879#ifdef CONFIG_ACPI 879#ifdef CONFIG_ACPI
880static const struct acpi_device_id xgbe_acpi_match[] = { 880static const struct acpi_device_id xgbe_acpi_match[] = {
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
index 00c38bf151e6..e078d8da978c 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -1466,12 +1466,12 @@ static int nb8800_probe(struct platform_device *pdev)
1466 1466
1467 ret = nb8800_hw_init(dev); 1467 ret = nb8800_hw_init(dev);
1468 if (ret) 1468 if (ret)
1469 goto err_free_bus; 1469 goto err_deregister_fixed_link;
1470 1470
1471 if (ops && ops->init) { 1471 if (ops && ops->init) {
1472 ret = ops->init(dev); 1472 ret = ops->init(dev);
1473 if (ret) 1473 if (ret)
1474 goto err_free_bus; 1474 goto err_deregister_fixed_link;
1475 } 1475 }
1476 1476
1477 dev->netdev_ops = &nb8800_netdev_ops; 1477 dev->netdev_ops = &nb8800_netdev_ops;
@@ -1504,6 +1504,9 @@ static int nb8800_probe(struct platform_device *pdev)
1504 1504
1505err_free_dma: 1505err_free_dma:
1506 nb8800_dma_free(dev); 1506 nb8800_dma_free(dev);
1507err_deregister_fixed_link:
1508 if (of_phy_is_fixed_link(pdev->dev.of_node))
1509 of_phy_deregister_fixed_link(pdev->dev.of_node);
1507err_free_bus: 1510err_free_bus:
1508 of_node_put(priv->phy_node); 1511 of_node_put(priv->phy_node);
1509 mdiobus_unregister(bus); 1512 mdiobus_unregister(bus);
@@ -1521,6 +1524,8 @@ static int nb8800_remove(struct platform_device *pdev)
1521 struct nb8800_priv *priv = netdev_priv(ndev); 1524 struct nb8800_priv *priv = netdev_priv(ndev);
1522 1525
1523 unregister_netdev(ndev); 1526 unregister_netdev(ndev);
1527 if (of_phy_is_fixed_link(pdev->dev.of_node))
1528 of_phy_deregister_fixed_link(pdev->dev.of_node);
1524 of_node_put(priv->phy_node); 1529 of_node_put(priv->phy_node);
1525 1530
1526 mdiobus_unregister(priv->mii_bus); 1531 mdiobus_unregister(priv->mii_bus);
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index c3354b9941d1..25d1eb4933d0 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1755,13 +1755,13 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1755 if (priv->irq0 <= 0 || priv->irq1 <= 0) { 1755 if (priv->irq0 <= 0 || priv->irq1 <= 0) {
1756 dev_err(&pdev->dev, "invalid interrupts\n"); 1756 dev_err(&pdev->dev, "invalid interrupts\n");
1757 ret = -EINVAL; 1757 ret = -EINVAL;
1758 goto err; 1758 goto err_free_netdev;
1759 } 1759 }
1760 1760
1761 priv->base = devm_ioremap_resource(&pdev->dev, r); 1761 priv->base = devm_ioremap_resource(&pdev->dev, r);
1762 if (IS_ERR(priv->base)) { 1762 if (IS_ERR(priv->base)) {
1763 ret = PTR_ERR(priv->base); 1763 ret = PTR_ERR(priv->base);
1764 goto err; 1764 goto err_free_netdev;
1765 } 1765 }
1766 1766
1767 priv->netdev = dev; 1767 priv->netdev = dev;
@@ -1779,7 +1779,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1779 ret = of_phy_register_fixed_link(dn); 1779 ret = of_phy_register_fixed_link(dn);
1780 if (ret) { 1780 if (ret) {
1781 dev_err(&pdev->dev, "failed to register fixed PHY\n"); 1781 dev_err(&pdev->dev, "failed to register fixed PHY\n");
1782 goto err; 1782 goto err_free_netdev;
1783 } 1783 }
1784 1784
1785 priv->phy_dn = dn; 1785 priv->phy_dn = dn;
@@ -1821,7 +1821,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1821 ret = register_netdev(dev); 1821 ret = register_netdev(dev);
1822 if (ret) { 1822 if (ret) {
1823 dev_err(&pdev->dev, "failed to register net_device\n"); 1823 dev_err(&pdev->dev, "failed to register net_device\n");
1824 goto err; 1824 goto err_deregister_fixed_link;
1825 } 1825 }
1826 1826
1827 priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; 1827 priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK;
@@ -1832,7 +1832,11 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1832 priv->base, priv->irq0, priv->irq1, txq, rxq); 1832 priv->base, priv->irq0, priv->irq1, txq, rxq);
1833 1833
1834 return 0; 1834 return 0;
1835err: 1835
1836err_deregister_fixed_link:
1837 if (of_phy_is_fixed_link(dn))
1838 of_phy_deregister_fixed_link(dn);
1839err_free_netdev:
1836 free_netdev(dev); 1840 free_netdev(dev);
1837 return ret; 1841 return ret;
1838} 1842}
@@ -1840,11 +1844,14 @@ err:
1840static int bcm_sysport_remove(struct platform_device *pdev) 1844static int bcm_sysport_remove(struct platform_device *pdev)
1841{ 1845{
1842 struct net_device *dev = dev_get_drvdata(&pdev->dev); 1846 struct net_device *dev = dev_get_drvdata(&pdev->dev);
1847 struct device_node *dn = pdev->dev.of_node;
1843 1848
1844 /* Not much to do, ndo_close has been called 1849 /* Not much to do, ndo_close has been called
1845 * and we use managed allocations 1850 * and we use managed allocations
1846 */ 1851 */
1847 unregister_netdev(dev); 1852 unregister_netdev(dev);
1853 if (of_phy_is_fixed_link(dn))
1854 of_phy_deregister_fixed_link(dn);
1848 free_netdev(dev); 1855 free_netdev(dev);
1849 dev_set_drvdata(&pdev->dev, NULL); 1856 dev_set_drvdata(&pdev->dev, NULL);
1850 1857
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 85a7800bfc12..5f19427c7b27 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1872,8 +1872,16 @@ static void bnx2x_get_ringparam(struct net_device *dev,
1872 1872
1873 ering->rx_max_pending = MAX_RX_AVAIL; 1873 ering->rx_max_pending = MAX_RX_AVAIL;
1874 1874
1875 /* If size isn't already set, we give an estimation of the number
1876 * of buffers we'll have. We're neglecting some possible conditions
1877 * [we couldn't know for certain at this point if number of queues
1878 * might shrink] but the number would be correct for the likely
1879 * scenario.
1880 */
1875 if (bp->rx_ring_size) 1881 if (bp->rx_ring_size)
1876 ering->rx_pending = bp->rx_ring_size; 1882 ering->rx_pending = bp->rx_ring_size;
1883 else if (BNX2X_NUM_RX_QUEUES(bp))
1884 ering->rx_pending = MAX_RX_AVAIL / BNX2X_NUM_RX_QUEUES(bp);
1877 else 1885 else
1878 ering->rx_pending = MAX_RX_AVAIL; 1886 ering->rx_pending = MAX_RX_AVAIL;
1879 1887
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0cee4c0283f9..4febe60eadc2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10138,7 +10138,7 @@ static void __bnx2x_add_udp_port(struct bnx2x *bp, u16 port,
10138{ 10138{
10139 struct bnx2x_udp_tunnel *udp_port = &bp->udp_tunnel_ports[type]; 10139 struct bnx2x_udp_tunnel *udp_port = &bp->udp_tunnel_ports[type];
10140 10140
10141 if (!netif_running(bp->dev) || !IS_PF(bp)) 10141 if (!netif_running(bp->dev) || !IS_PF(bp) || CHIP_IS_E1x(bp))
10142 return; 10142 return;
10143 10143
10144 if (udp_port->count && udp_port->dst_port == port) { 10144 if (udp_port->count && udp_port->dst_port == port) {
@@ -10163,7 +10163,7 @@ static void __bnx2x_del_udp_port(struct bnx2x *bp, u16 port,
10163{ 10163{
10164 struct bnx2x_udp_tunnel *udp_port = &bp->udp_tunnel_ports[type]; 10164 struct bnx2x_udp_tunnel *udp_port = &bp->udp_tunnel_ports[type];
10165 10165
10166 if (!IS_PF(bp)) 10166 if (!IS_PF(bp) || CHIP_IS_E1x(bp))
10167 return; 10167 return;
10168 10168
10169 if (!udp_port->count || udp_port->dst_port != port) { 10169 if (!udp_port->count || udp_port->dst_port != port) {
@@ -13505,6 +13505,7 @@ static int bnx2x_init_firmware(struct bnx2x *bp)
13505 13505
13506 /* Initialize the pointers to the init arrays */ 13506 /* Initialize the pointers to the init arrays */
13507 /* Blob */ 13507 /* Blob */
13508 rc = -ENOMEM;
13508 BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n); 13509 BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n);
13509 13510
13510 /* Opcodes */ 13511 /* Opcodes */
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e18635b2a002..f08a20b921e7 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1811,6 +1811,9 @@ static int bnxt_busy_poll(struct napi_struct *napi)
1811 if (atomic_read(&bp->intr_sem) != 0) 1811 if (atomic_read(&bp->intr_sem) != 0)
1812 return LL_FLUSH_FAILED; 1812 return LL_FLUSH_FAILED;
1813 1813
1814 if (!bp->link_info.link_up)
1815 return LL_FLUSH_FAILED;
1816
1814 if (!bnxt_lock_poll(bnapi)) 1817 if (!bnxt_lock_poll(bnapi))
1815 return LL_FLUSH_BUSY; 1818 return LL_FLUSH_BUSY;
1816 1819
@@ -3210,11 +3213,17 @@ static int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, __be16 port,
3210 goto err_out; 3213 goto err_out;
3211 } 3214 }
3212 3215
3213 if (tunnel_type & TUNNEL_DST_PORT_ALLOC_REQ_TUNNEL_TYPE_VXLAN) 3216 switch (tunnel_type) {
3217 case TUNNEL_DST_PORT_ALLOC_REQ_TUNNEL_TYPE_VXLAN:
3214 bp->vxlan_fw_dst_port_id = resp->tunnel_dst_port_id; 3218 bp->vxlan_fw_dst_port_id = resp->tunnel_dst_port_id;
3215 3219 break;
3216 else if (tunnel_type & TUNNEL_DST_PORT_ALLOC_REQ_TUNNEL_TYPE_GENEVE) 3220 case TUNNEL_DST_PORT_ALLOC_REQ_TUNNEL_TYPE_GENEVE:
3217 bp->nge_fw_dst_port_id = resp->tunnel_dst_port_id; 3221 bp->nge_fw_dst_port_id = resp->tunnel_dst_port_id;
3222 break;
3223 default:
3224 break;
3225 }
3226
3218err_out: 3227err_out:
3219 mutex_unlock(&bp->hwrm_cmd_lock); 3228 mutex_unlock(&bp->hwrm_cmd_lock);
3220 return rc; 3229 return rc;
@@ -4111,7 +4120,7 @@ static int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp)
4111 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; 4120 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id;
4112 } 4121 }
4113 mutex_unlock(&bp->hwrm_cmd_lock); 4122 mutex_unlock(&bp->hwrm_cmd_lock);
4114 return 0; 4123 return rc;
4115} 4124}
4116 4125
4117static int bnxt_hwrm_func_qcfg(struct bnxt *bp) 4126static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 4464bc5db934..a4e60e56c14f 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1172,6 +1172,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
1172 struct bcmgenet_tx_ring *ring) 1172 struct bcmgenet_tx_ring *ring)
1173{ 1173{
1174 struct bcmgenet_priv *priv = netdev_priv(dev); 1174 struct bcmgenet_priv *priv = netdev_priv(dev);
1175 struct device *kdev = &priv->pdev->dev;
1175 struct enet_cb *tx_cb_ptr; 1176 struct enet_cb *tx_cb_ptr;
1176 struct netdev_queue *txq; 1177 struct netdev_queue *txq;
1177 unsigned int pkts_compl = 0; 1178 unsigned int pkts_compl = 0;
@@ -1199,13 +1200,13 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
1199 if (tx_cb_ptr->skb) { 1200 if (tx_cb_ptr->skb) {
1200 pkts_compl++; 1201 pkts_compl++;
1201 bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; 1202 bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent;
1202 dma_unmap_single(&dev->dev, 1203 dma_unmap_single(kdev,
1203 dma_unmap_addr(tx_cb_ptr, dma_addr), 1204 dma_unmap_addr(tx_cb_ptr, dma_addr),
1204 dma_unmap_len(tx_cb_ptr, dma_len), 1205 dma_unmap_len(tx_cb_ptr, dma_len),
1205 DMA_TO_DEVICE); 1206 DMA_TO_DEVICE);
1206 bcmgenet_free_cb(tx_cb_ptr); 1207 bcmgenet_free_cb(tx_cb_ptr);
1207 } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { 1208 } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
1208 dma_unmap_page(&dev->dev, 1209 dma_unmap_page(kdev,
1209 dma_unmap_addr(tx_cb_ptr, dma_addr), 1210 dma_unmap_addr(tx_cb_ptr, dma_addr),
1210 dma_unmap_len(tx_cb_ptr, dma_len), 1211 dma_unmap_len(tx_cb_ptr, dma_len),
1211 DMA_TO_DEVICE); 1212 DMA_TO_DEVICE);
@@ -1775,6 +1776,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv,
1775 1776
1776static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) 1777static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
1777{ 1778{
1779 struct device *kdev = &priv->pdev->dev;
1778 struct enet_cb *cb; 1780 struct enet_cb *cb;
1779 int i; 1781 int i;
1780 1782
@@ -1782,7 +1784,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
1782 cb = &priv->rx_cbs[i]; 1784 cb = &priv->rx_cbs[i];
1783 1785
1784 if (dma_unmap_addr(cb, dma_addr)) { 1786 if (dma_unmap_addr(cb, dma_addr)) {
1785 dma_unmap_single(&priv->dev->dev, 1787 dma_unmap_single(kdev,
1786 dma_unmap_addr(cb, dma_addr), 1788 dma_unmap_addr(cb, dma_addr),
1787 priv->rx_buf_len, DMA_FROM_DEVICE); 1789 priv->rx_buf_len, DMA_FROM_DEVICE);
1788 dma_unmap_addr_set(cb, dma_addr, 0); 1790 dma_unmap_addr_set(cb, dma_addr, 0);
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 457c3bc8cfff..e87607621e62 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
542 /* Make sure we initialize MoCA PHYs with a link down */ 542 /* Make sure we initialize MoCA PHYs with a link down */
543 if (phy_mode == PHY_INTERFACE_MODE_MOCA) { 543 if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
544 phydev = of_phy_find_device(dn); 544 phydev = of_phy_find_device(dn);
545 if (phydev) 545 if (phydev) {
546 phydev->link = 0; 546 phydev->link = 0;
547 put_device(&phydev->mdio.dev);
548 }
547 } 549 }
548 550
549 return 0; 551 return 0;
@@ -625,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv)
625int bcmgenet_mii_init(struct net_device *dev) 627int bcmgenet_mii_init(struct net_device *dev)
626{ 628{
627 struct bcmgenet_priv *priv = netdev_priv(dev); 629 struct bcmgenet_priv *priv = netdev_priv(dev);
630 struct device_node *dn = priv->pdev->dev.of_node;
628 int ret; 631 int ret;
629 632
630 ret = bcmgenet_mii_alloc(priv); 633 ret = bcmgenet_mii_alloc(priv);
@@ -638,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev)
638 return 0; 641 return 0;
639 642
640out: 643out:
644 if (of_phy_is_fixed_link(dn))
645 of_phy_deregister_fixed_link(dn);
641 of_node_put(priv->phy_dn); 646 of_node_put(priv->phy_dn);
642 mdiobus_unregister(priv->mii_bus); 647 mdiobus_unregister(priv->mii_bus);
643 mdiobus_free(priv->mii_bus); 648 mdiobus_free(priv->mii_bus);
@@ -647,7 +652,10 @@ out:
647void bcmgenet_mii_exit(struct net_device *dev) 652void bcmgenet_mii_exit(struct net_device *dev)
648{ 653{
649 struct bcmgenet_priv *priv = netdev_priv(dev); 654 struct bcmgenet_priv *priv = netdev_priv(dev);
655 struct device_node *dn = priv->pdev->dev.of_node;
650 656
657 if (of_phy_is_fixed_link(dn))
658 of_phy_deregister_fixed_link(dn);
651 of_node_put(priv->phy_dn); 659 of_node_put(priv->phy_dn);
652 mdiobus_unregister(priv->mii_bus); 660 mdiobus_unregister(priv->mii_bus);
653 mdiobus_free(priv->mii_bus); 661 mdiobus_free(priv->mii_bus);
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 533653bd7aec..ec09fcece711 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -975,6 +975,7 @@ static inline void macb_init_rx_ring(struct macb *bp)
975 addr += bp->rx_buffer_size; 975 addr += bp->rx_buffer_size;
976 } 976 }
977 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); 977 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
978 bp->rx_tail = 0;
978} 979}
979 980
980static int macb_rx(struct macb *bp, int budget) 981static int macb_rx(struct macb *bp, int budget)
@@ -1156,6 +1157,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
1156 if (status & MACB_BIT(RXUBR)) { 1157 if (status & MACB_BIT(RXUBR)) {
1157 ctrl = macb_readl(bp, NCR); 1158 ctrl = macb_readl(bp, NCR);
1158 macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE)); 1159 macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE));
1160 wmb();
1159 macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); 1161 macb_writel(bp, NCR, ctrl | MACB_BIT(RE));
1160 1162
1161 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1163 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
@@ -1616,8 +1618,6 @@ static void macb_init_rings(struct macb *bp)
1616 bp->queues[0].tx_head = 0; 1618 bp->queues[0].tx_head = 0;
1617 bp->queues[0].tx_tail = 0; 1619 bp->queues[0].tx_tail = 0;
1618 bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); 1620 bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
1619
1620 bp->rx_tail = 0;
1621} 1621}
1622 1622
1623static void macb_reset_hw(struct macb *bp) 1623static void macb_reset_hw(struct macb *bp)
@@ -2770,6 +2770,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
2770 if (intstatus & MACB_BIT(RXUBR)) { 2770 if (intstatus & MACB_BIT(RXUBR)) {
2771 ctl = macb_readl(lp, NCR); 2771 ctl = macb_readl(lp, NCR);
2772 macb_writel(lp, NCR, ctl & ~MACB_BIT(RE)); 2772 macb_writel(lp, NCR, ctl & ~MACB_BIT(RE));
2773 wmb();
2773 macb_writel(lp, NCR, ctl | MACB_BIT(RE)); 2774 macb_writel(lp, NCR, ctl | MACB_BIT(RE));
2774 } 2775 }
2775 2776
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 57eb4e1345cb..19dc9e25aa72 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4931,6 +4931,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4931 */ 4931 */
4932 for_each_port(adapter, i) { 4932 for_each_port(adapter, i) {
4933 pi = adap2pinfo(adapter, i); 4933 pi = adap2pinfo(adapter, i);
4934 adapter->port[i]->dev_port = pi->lport;
4934 netif_set_real_num_tx_queues(adapter->port[i], pi->nqsets); 4935 netif_set_real_num_tx_queues(adapter->port[i], pi->nqsets);
4935 netif_set_real_num_rx_queues(adapter->port[i], pi->nqsets); 4936 netif_set_real_num_rx_queues(adapter->port[i], pi->nqsets);
4936 4937
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 20dec85da63d..e8139514d32c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -7851,7 +7851,6 @@ int t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
7851 return ret; 7851 return ret;
7852 7852
7853 memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN); 7853 memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN);
7854 adap->port[i]->dev_port = j;
7855 j++; 7854 j++;
7856 } 7855 }
7857 return 0; 7856 return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index df1573c4a659..ecf3ccc257bc 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -168,6 +168,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
168 CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */ 168 CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */
169 CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */ 169 CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */
170 CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/ 170 CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/
171 CH_PCI_ID_TABLE_FENTRY(0x509d), /* Custom T540-CR*/
171 172
172 /* T6 adapters: 173 /* T6 adapters:
173 */ 174 */
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 100b2cc064a3..a37481c04a87 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2969,6 +2969,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
2969 2969
2970 netdev->netdev_ops = &cxgb4vf_netdev_ops; 2970 netdev->netdev_ops = &cxgb4vf_netdev_ops;
2971 netdev->ethtool_ops = &cxgb4vf_ethtool_ops; 2971 netdev->ethtool_ops = &cxgb4vf_ethtool_ops;
2972 netdev->dev_port = pi->port_id;
2972 2973
2973 /* 2974 /*
2974 * Initialize the hardware/software state for the port. 2975 * Initialize the hardware/software state for the port.
diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index de9f7c97d916..9a161e981529 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -468,6 +468,9 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
468 struct device *dev = ep->dev->dev.parent; 468 struct device *dev = ep->dev->dev.parent;
469 int i; 469 int i;
470 470
471 if (!ep->descs)
472 return;
473
471 for (i = 0; i < RX_QUEUE_ENTRIES; i++) { 474 for (i = 0; i < RX_QUEUE_ENTRIES; i++) {
472 dma_addr_t d; 475 dma_addr_t d;
473 476
@@ -490,6 +493,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
490 493
491 dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs, 494 dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs,
492 ep->descs_dma_addr); 495 ep->descs_dma_addr);
496 ep->descs = NULL;
493} 497}
494 498
495static int ep93xx_alloc_buffers(struct ep93xx_priv *ep) 499static int ep93xx_alloc_buffers(struct ep93xx_priv *ep)
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 1fb5d7239254..0e74529a4209 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -90,7 +90,8 @@ static struct be_cmd_priv_map cmd_priv_map[] = {
90 { 90 {
91 OPCODE_COMMON_SET_HSW_CONFIG, 91 OPCODE_COMMON_SET_HSW_CONFIG,
92 CMD_SUBSYSTEM_COMMON, 92 CMD_SUBSYSTEM_COMMON,
93 BE_PRIV_DEVCFG | BE_PRIV_VHADM 93 BE_PRIV_DEVCFG | BE_PRIV_VHADM |
94 BE_PRIV_DEVSEC
94 }, 95 },
95 { 96 {
96 OPCODE_COMMON_GET_EXT_FAT_CAPABILITIES, 97 OPCODE_COMMON_GET_EXT_FAT_CAPABILITIES,
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index c865135f3cb9..5ea740b4cf14 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -574,6 +574,8 @@ struct fec_enet_private {
574 unsigned int reload_period; 574 unsigned int reload_period;
575 int pps_enable; 575 int pps_enable;
576 unsigned int next_counter; 576 unsigned int next_counter;
577
578 u64 ethtool_stats[0];
577}; 579};
578 580
579void fec_ptp_init(struct platform_device *pdev); 581void fec_ptp_init(struct platform_device *pdev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 5aa9d4ded214..12aef1b15356 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2313,14 +2313,26 @@ static const struct fec_stat {
2313 { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK }, 2313 { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK },
2314}; 2314};
2315 2315
2316static void fec_enet_get_ethtool_stats(struct net_device *dev, 2316#define FEC_STATS_SIZE (ARRAY_SIZE(fec_stats) * sizeof(u64))
2317 struct ethtool_stats *stats, u64 *data) 2317
2318static void fec_enet_update_ethtool_stats(struct net_device *dev)
2318{ 2319{
2319 struct fec_enet_private *fep = netdev_priv(dev); 2320 struct fec_enet_private *fep = netdev_priv(dev);
2320 int i; 2321 int i;
2321 2322
2322 for (i = 0; i < ARRAY_SIZE(fec_stats); i++) 2323 for (i = 0; i < ARRAY_SIZE(fec_stats); i++)
2323 data[i] = readl(fep->hwp + fec_stats[i].offset); 2324 fep->ethtool_stats[i] = readl(fep->hwp + fec_stats[i].offset);
2325}
2326
2327static void fec_enet_get_ethtool_stats(struct net_device *dev,
2328 struct ethtool_stats *stats, u64 *data)
2329{
2330 struct fec_enet_private *fep = netdev_priv(dev);
2331
2332 if (netif_running(dev))
2333 fec_enet_update_ethtool_stats(dev);
2334
2335 memcpy(data, fep->ethtool_stats, FEC_STATS_SIZE);
2324} 2336}
2325 2337
2326static void fec_enet_get_strings(struct net_device *netdev, 2338static void fec_enet_get_strings(struct net_device *netdev,
@@ -2345,6 +2357,12 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
2345 return -EOPNOTSUPP; 2357 return -EOPNOTSUPP;
2346 } 2358 }
2347} 2359}
2360
2361#else /* !defined(CONFIG_M5272) */
2362#define FEC_STATS_SIZE 0
2363static inline void fec_enet_update_ethtool_stats(struct net_device *dev)
2364{
2365}
2348#endif /* !defined(CONFIG_M5272) */ 2366#endif /* !defined(CONFIG_M5272) */
2349 2367
2350static int fec_enet_nway_reset(struct net_device *dev) 2368static int fec_enet_nway_reset(struct net_device *dev)
@@ -2874,6 +2892,8 @@ fec_enet_close(struct net_device *ndev)
2874 if (fep->quirks & FEC_QUIRK_ERR006687) 2892 if (fep->quirks & FEC_QUIRK_ERR006687)
2875 imx6q_cpuidle_fec_irqs_unused(); 2893 imx6q_cpuidle_fec_irqs_unused();
2876 2894
2895 fec_enet_update_ethtool_stats(ndev);
2896
2877 fec_enet_clk_enable(ndev, false); 2897 fec_enet_clk_enable(ndev, false);
2878 pinctrl_pm_select_sleep_state(&fep->pdev->dev); 2898 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
2879 pm_runtime_mark_last_busy(&fep->pdev->dev); 2899 pm_runtime_mark_last_busy(&fep->pdev->dev);
@@ -3180,6 +3200,8 @@ static int fec_enet_init(struct net_device *ndev)
3180 3200
3181 fec_restart(ndev); 3201 fec_restart(ndev);
3182 3202
3203 fec_enet_update_ethtool_stats(ndev);
3204
3183 return 0; 3205 return 0;
3184} 3206}
3185 3207
@@ -3278,8 +3300,8 @@ fec_probe(struct platform_device *pdev)
3278 fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); 3300 fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
3279 3301
3280 /* Init network device */ 3302 /* Init network device */
3281 ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private), 3303 ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) +
3282 num_tx_qs, num_rx_qs); 3304 FEC_STATS_SIZE, num_tx_qs, num_rx_qs);
3283 if (!ndev) 3305 if (!ndev)
3284 return -ENOMEM; 3306 return -ENOMEM;
3285 3307
@@ -3475,6 +3497,8 @@ failed_regulator:
3475failed_clk_ipg: 3497failed_clk_ipg:
3476 fec_enet_clk_enable(ndev, false); 3498 fec_enet_clk_enable(ndev, false);
3477failed_clk: 3499failed_clk:
3500 if (of_phy_is_fixed_link(np))
3501 of_phy_deregister_fixed_link(np);
3478failed_phy: 3502failed_phy:
3479 of_node_put(phy_node); 3503 of_node_put(phy_node);
3480failed_ioremap: 3504failed_ioremap:
@@ -3488,6 +3512,7 @@ fec_drv_remove(struct platform_device *pdev)
3488{ 3512{
3489 struct net_device *ndev = platform_get_drvdata(pdev); 3513 struct net_device *ndev = platform_get_drvdata(pdev);
3490 struct fec_enet_private *fep = netdev_priv(ndev); 3514 struct fec_enet_private *fep = netdev_priv(ndev);
3515 struct device_node *np = pdev->dev.of_node;
3491 3516
3492 cancel_work_sync(&fep->tx_timeout_work); 3517 cancel_work_sync(&fep->tx_timeout_work);
3493 fec_ptp_stop(pdev); 3518 fec_ptp_stop(pdev);
@@ -3495,6 +3520,8 @@ fec_drv_remove(struct platform_device *pdev)
3495 fec_enet_mii_remove(fep); 3520 fec_enet_mii_remove(fep);
3496 if (fep->reg_phy) 3521 if (fep->reg_phy)
3497 regulator_disable(fep->reg_phy); 3522 regulator_disable(fep->reg_phy);
3523 if (of_phy_is_fixed_link(np))
3524 of_phy_deregister_fixed_link(np);
3498 of_node_put(fep->phy_node); 3525 of_node_put(fep->phy_node);
3499 free_netdev(ndev); 3526 free_netdev(ndev);
3500 3527
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 53ef51e3bd9e..71a5ded9d1de 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -1107,6 +1107,9 @@ int memac_free(struct fman_mac *memac)
1107{ 1107{
1108 free_init_resources(memac); 1108 free_init_resources(memac);
1109 1109
1110 if (memac->pcsphy)
1111 put_device(&memac->pcsphy->mdio.dev);
1112
1110 kfree(memac->memac_drv_param); 1113 kfree(memac->memac_drv_param);
1111 kfree(memac); 1114 kfree(memac);
1112 1115
diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c b/drivers/net/ethernet/freescale/fman/fman_tgec.c
index efabb04a1ae8..4b0f3a50b293 100644
--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
@@ -722,9 +722,6 @@ int tgec_free(struct fman_mac *tgec)
722{ 722{
723 free_init_resources(tgec); 723 free_init_resources(tgec);
724 724
725 if (tgec->cfg)
726 tgec->cfg = NULL;
727
728 kfree(tgec->cfg); 725 kfree(tgec->cfg);
729 kfree(tgec); 726 kfree(tgec);
730 727
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 8fe6b3e253fa..736db9d9b0ad 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -892,6 +892,8 @@ static int mac_probe(struct platform_device *_of_dev)
892 priv->fixed_link->duplex = phy->duplex; 892 priv->fixed_link->duplex = phy->duplex;
893 priv->fixed_link->pause = phy->pause; 893 priv->fixed_link->pause = phy->pause;
894 priv->fixed_link->asym_pause = phy->asym_pause; 894 priv->fixed_link->asym_pause = phy->asym_pause;
895
896 put_device(&phy->mdio.dev);
895 } 897 }
896 898
897 err = mac_dev->init(mac_dev); 899 err = mac_dev->init(mac_dev);
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index dc120c148d97..4b86260584a0 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
980 err = clk_prepare_enable(clk); 980 err = clk_prepare_enable(clk);
981 if (err) { 981 if (err) {
982 ret = err; 982 ret = err;
983 goto out_free_fpi; 983 goto out_deregister_fixed_link;
984 } 984 }
985 fpi->clk_per = clk; 985 fpi->clk_per = clk;
986 } 986 }
@@ -1061,6 +1061,9 @@ out_put:
1061 of_node_put(fpi->phy_node); 1061 of_node_put(fpi->phy_node);
1062 if (fpi->clk_per) 1062 if (fpi->clk_per)
1063 clk_disable_unprepare(fpi->clk_per); 1063 clk_disable_unprepare(fpi->clk_per);
1064out_deregister_fixed_link:
1065 if (of_phy_is_fixed_link(ofdev->dev.of_node))
1066 of_phy_deregister_fixed_link(ofdev->dev.of_node);
1064out_free_fpi: 1067out_free_fpi:
1065 kfree(fpi); 1068 kfree(fpi);
1066 return ret; 1069 return ret;
@@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev)
1079 of_node_put(fep->fpi->phy_node); 1082 of_node_put(fep->fpi->phy_node);
1080 if (fep->fpi->clk_per) 1083 if (fep->fpi->clk_per)
1081 clk_disable_unprepare(fep->fpi->clk_per); 1084 clk_disable_unprepare(fep->fpi->clk_per);
1085 if (of_phy_is_fixed_link(ofdev->dev.of_node))
1086 of_phy_deregister_fixed_link(ofdev->dev.of_node);
1082 free_netdev(ndev); 1087 free_netdev(ndev);
1083 return 0; 1088 return 0;
1084} 1089}
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 4b4f5bc0e279..9061c2f82b9c 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1312,6 +1312,7 @@ static void gfar_init_addr_hash_table(struct gfar_private *priv)
1312 */ 1312 */
1313static int gfar_probe(struct platform_device *ofdev) 1313static int gfar_probe(struct platform_device *ofdev)
1314{ 1314{
1315 struct device_node *np = ofdev->dev.of_node;
1315 struct net_device *dev = NULL; 1316 struct net_device *dev = NULL;
1316 struct gfar_private *priv = NULL; 1317 struct gfar_private *priv = NULL;
1317 int err = 0, i; 1318 int err = 0, i;
@@ -1462,6 +1463,8 @@ static int gfar_probe(struct platform_device *ofdev)
1462 return 0; 1463 return 0;
1463 1464
1464register_fail: 1465register_fail:
1466 if (of_phy_is_fixed_link(np))
1467 of_phy_deregister_fixed_link(np);
1465 unmap_group_regs(priv); 1468 unmap_group_regs(priv);
1466 gfar_free_rx_queues(priv); 1469 gfar_free_rx_queues(priv);
1467 gfar_free_tx_queues(priv); 1470 gfar_free_tx_queues(priv);
@@ -1474,11 +1477,16 @@ register_fail:
1474static int gfar_remove(struct platform_device *ofdev) 1477static int gfar_remove(struct platform_device *ofdev)
1475{ 1478{
1476 struct gfar_private *priv = platform_get_drvdata(ofdev); 1479 struct gfar_private *priv = platform_get_drvdata(ofdev);
1480 struct device_node *np = ofdev->dev.of_node;
1477 1481
1478 of_node_put(priv->phy_node); 1482 of_node_put(priv->phy_node);
1479 of_node_put(priv->tbi_node); 1483 of_node_put(priv->tbi_node);
1480 1484
1481 unregister_netdev(priv->ndev); 1485 unregister_netdev(priv->ndev);
1486
1487 if (of_phy_is_fixed_link(np))
1488 of_phy_deregister_fixed_link(np);
1489
1482 unmap_group_regs(priv); 1490 unmap_group_regs(priv);
1483 gfar_free_rx_queues(priv); 1491 gfar_free_rx_queues(priv);
1484 gfar_free_tx_queues(priv); 1492 gfar_free_tx_queues(priv);
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 186ef8f16c80..f76d33279454 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3868 dev = alloc_etherdev(sizeof(*ugeth)); 3868 dev = alloc_etherdev(sizeof(*ugeth));
3869 3869
3870 if (dev == NULL) { 3870 if (dev == NULL) {
3871 of_node_put(ug_info->tbi_node); 3871 err = -ENOMEM;
3872 of_node_put(ug_info->phy_node); 3872 goto err_deregister_fixed_link;
3873 return -ENOMEM;
3874 } 3873 }
3875 3874
3876 ugeth = netdev_priv(dev); 3875 ugeth = netdev_priv(dev);
@@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3907 if (netif_msg_probe(ugeth)) 3906 if (netif_msg_probe(ugeth))
3908 pr_err("%s: Cannot register net device, aborting\n", 3907 pr_err("%s: Cannot register net device, aborting\n",
3909 dev->name); 3908 dev->name);
3910 free_netdev(dev); 3909 goto err_free_netdev;
3911 of_node_put(ug_info->tbi_node);
3912 of_node_put(ug_info->phy_node);
3913 return err;
3914 } 3910 }
3915 3911
3916 mac_addr = of_get_mac_address(np); 3912 mac_addr = of_get_mac_address(np);
@@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3923 ugeth->node = np; 3919 ugeth->node = np;
3924 3920
3925 return 0; 3921 return 0;
3922
3923err_free_netdev:
3924 free_netdev(dev);
3925err_deregister_fixed_link:
3926 if (of_phy_is_fixed_link(np))
3927 of_phy_deregister_fixed_link(np);
3928 of_node_put(ug_info->tbi_node);
3929 of_node_put(ug_info->phy_node);
3930
3931 return err;
3926} 3932}
3927 3933
3928static int ucc_geth_remove(struct platform_device* ofdev) 3934static int ucc_geth_remove(struct platform_device* ofdev)
3929{ 3935{
3930 struct net_device *dev = platform_get_drvdata(ofdev); 3936 struct net_device *dev = platform_get_drvdata(ofdev);
3931 struct ucc_geth_private *ugeth = netdev_priv(dev); 3937 struct ucc_geth_private *ugeth = netdev_priv(dev);
3938 struct device_node *np = ofdev->dev.of_node;
3932 3939
3933 unregister_netdev(dev); 3940 unregister_netdev(dev);
3934 free_netdev(dev); 3941 free_netdev(dev);
3935 ucc_geth_memclean(ugeth); 3942 ucc_geth_memclean(ugeth);
3943 if (of_phy_is_fixed_link(np))
3944 of_phy_deregister_fixed_link(np);
3936 of_node_put(ugeth->ug_info->tbi_node); 3945 of_node_put(ugeth->ug_info->tbi_node);
3937 of_node_put(ugeth->ug_info->phy_node); 3946 of_node_put(ugeth->ug_info->phy_node);
3938 3947
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index ebe60719e489..a36022ba4e42 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -58,7 +58,7 @@ static struct kobj_type ktype_veth_pool;
58 58
59static const char ibmveth_driver_name[] = "ibmveth"; 59static const char ibmveth_driver_name[] = "ibmveth";
60static const char ibmveth_driver_string[] = "IBM Power Virtual Ethernet Driver"; 60static const char ibmveth_driver_string[] = "IBM Power Virtual Ethernet Driver";
61#define ibmveth_driver_version "1.05" 61#define ibmveth_driver_version "1.06"
62 62
63MODULE_AUTHOR("Santiago Leon <santil@linux.vnet.ibm.com>"); 63MODULE_AUTHOR("Santiago Leon <santil@linux.vnet.ibm.com>");
64MODULE_DESCRIPTION("IBM Power Virtual Ethernet Driver"); 64MODULE_DESCRIPTION("IBM Power Virtual Ethernet Driver");
@@ -137,6 +137,11 @@ static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter)
137 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK; 137 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK;
138} 138}
139 139
140static inline int ibmveth_rxq_large_packet(struct ibmveth_adapter *adapter)
141{
142 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_LRG_PKT;
143}
144
140static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) 145static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
141{ 146{
142 return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length); 147 return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length);
@@ -1174,6 +1179,45 @@ map_failed:
1174 goto retry_bounce; 1179 goto retry_bounce;
1175} 1180}
1176 1181
1182static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
1183{
1184 int offset = 0;
1185
1186 /* only TCP packets will be aggregated */
1187 if (skb->protocol == htons(ETH_P_IP)) {
1188 struct iphdr *iph = (struct iphdr *)skb->data;
1189
1190 if (iph->protocol == IPPROTO_TCP) {
1191 offset = iph->ihl * 4;
1192 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
1193 } else {
1194 return;
1195 }
1196 } else if (skb->protocol == htons(ETH_P_IPV6)) {
1197 struct ipv6hdr *iph6 = (struct ipv6hdr *)skb->data;
1198
1199 if (iph6->nexthdr == IPPROTO_TCP) {
1200 offset = sizeof(struct ipv6hdr);
1201 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
1202 } else {
1203 return;
1204 }
1205 } else {
1206 return;
1207 }
1208 /* if mss is not set through Large Packet bit/mss in rx buffer,
1209 * expect that the mss will be written to the tcp header checksum.
1210 */
1211 if (lrg_pkt) {
1212 skb_shinfo(skb)->gso_size = mss;
1213 } else if (offset) {
1214 struct tcphdr *tcph = (struct tcphdr *)(skb->data + offset);
1215
1216 skb_shinfo(skb)->gso_size = ntohs(tcph->check);
1217 tcph->check = 0;
1218 }
1219}
1220
1177static int ibmveth_poll(struct napi_struct *napi, int budget) 1221static int ibmveth_poll(struct napi_struct *napi, int budget)
1178{ 1222{
1179 struct ibmveth_adapter *adapter = 1223 struct ibmveth_adapter *adapter =
@@ -1182,6 +1226,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
1182 int frames_processed = 0; 1226 int frames_processed = 0;
1183 unsigned long lpar_rc; 1227 unsigned long lpar_rc;
1184 struct iphdr *iph; 1228 struct iphdr *iph;
1229 u16 mss = 0;
1185 1230
1186restart_poll: 1231restart_poll:
1187 while (frames_processed < budget) { 1232 while (frames_processed < budget) {
@@ -1199,9 +1244,21 @@ restart_poll:
1199 int length = ibmveth_rxq_frame_length(adapter); 1244 int length = ibmveth_rxq_frame_length(adapter);
1200 int offset = ibmveth_rxq_frame_offset(adapter); 1245 int offset = ibmveth_rxq_frame_offset(adapter);
1201 int csum_good = ibmveth_rxq_csum_good(adapter); 1246 int csum_good = ibmveth_rxq_csum_good(adapter);
1247 int lrg_pkt = ibmveth_rxq_large_packet(adapter);
1202 1248
1203 skb = ibmveth_rxq_get_buffer(adapter); 1249 skb = ibmveth_rxq_get_buffer(adapter);
1204 1250
1251 /* if the large packet bit is set in the rx queue
1252 * descriptor, the mss will be written by PHYP eight
1253 * bytes from the start of the rx buffer, which is
1254 * skb->data at this stage
1255 */
1256 if (lrg_pkt) {
1257 __be64 *rxmss = (__be64 *)(skb->data + 8);
1258
1259 mss = (u16)be64_to_cpu(*rxmss);
1260 }
1261
1205 new_skb = NULL; 1262 new_skb = NULL;
1206 if (length < rx_copybreak) 1263 if (length < rx_copybreak)
1207 new_skb = netdev_alloc_skb(netdev, length); 1264 new_skb = netdev_alloc_skb(netdev, length);
@@ -1235,11 +1292,15 @@ restart_poll:
1235 if (iph->check == 0xffff) { 1292 if (iph->check == 0xffff) {
1236 iph->check = 0; 1293 iph->check = 0;
1237 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); 1294 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
1238 adapter->rx_large_packets++;
1239 } 1295 }
1240 } 1296 }
1241 } 1297 }
1242 1298
1299 if (length > netdev->mtu + ETH_HLEN) {
1300 ibmveth_rx_mss_helper(skb, mss, lrg_pkt);
1301 adapter->rx_large_packets++;
1302 }
1303
1243 napi_gro_receive(napi, skb); /* send it up */ 1304 napi_gro_receive(napi, skb); /* send it up */
1244 1305
1245 netdev->stats.rx_packets++; 1306 netdev->stats.rx_packets++;
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index 4eade67fe30c..7acda04d034e 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -209,6 +209,7 @@ struct ibmveth_rx_q_entry {
209#define IBMVETH_RXQ_TOGGLE 0x80000000 209#define IBMVETH_RXQ_TOGGLE 0x80000000
210#define IBMVETH_RXQ_TOGGLE_SHIFT 31 210#define IBMVETH_RXQ_TOGGLE_SHIFT 31
211#define IBMVETH_RXQ_VALID 0x40000000 211#define IBMVETH_RXQ_VALID 0x40000000
212#define IBMVETH_RXQ_LRG_PKT 0x04000000
212#define IBMVETH_RXQ_NO_CSUM 0x02000000 213#define IBMVETH_RXQ_NO_CSUM 0x02000000
213#define IBMVETH_RXQ_CSUM_GOOD 0x01000000 214#define IBMVETH_RXQ_CSUM_GOOD 0x01000000
214#define IBMVETH_RXQ_OFF_MASK 0x0000FFFF 215#define IBMVETH_RXQ_OFF_MASK 0x0000FFFF
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 4f3281a03e7e..0fbf686f5e7c 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -74,7 +74,6 @@
74#include <asm/iommu.h> 74#include <asm/iommu.h>
75#include <linux/uaccess.h> 75#include <linux/uaccess.h>
76#include <asm/firmware.h> 76#include <asm/firmware.h>
77#include <linux/seq_file.h>
78#include <linux/workqueue.h> 77#include <linux/workqueue.h>
79 78
80#include "ibmvnic.h" 79#include "ibmvnic.h"
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index edc9a6ac5169..9affd7c198bd 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4931,11 +4931,15 @@ static int igb_tso(struct igb_ring *tx_ring,
4931 4931
4932 /* initialize outer IP header fields */ 4932 /* initialize outer IP header fields */
4933 if (ip.v4->version == 4) { 4933 if (ip.v4->version == 4) {
4934 unsigned char *csum_start = skb_checksum_start(skb);
4935 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
4936
4934 /* IP header will have to cancel out any data that 4937 /* IP header will have to cancel out any data that
4935 * is not a part of the outer IP header 4938 * is not a part of the outer IP header
4936 */ 4939 */
4937 ip.v4->check = csum_fold(csum_add(lco_csum(skb), 4940 ip.v4->check = csum_fold(csum_partial(trans_start,
4938 csum_unfold(l4.tcp->check))); 4941 csum_start - trans_start,
4942 0));
4939 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; 4943 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
4940 4944
4941 ip.v4->tot_len = 0; 4945 ip.v4->tot_len = 0;
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 12bb877df860..7dff7f6239cd 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1965,11 +1965,15 @@ static int igbvf_tso(struct igbvf_ring *tx_ring,
1965 1965
1966 /* initialize outer IP header fields */ 1966 /* initialize outer IP header fields */
1967 if (ip.v4->version == 4) { 1967 if (ip.v4->version == 4) {
1968 unsigned char *csum_start = skb_checksum_start(skb);
1969 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
1970
1968 /* IP header will have to cancel out any data that 1971 /* IP header will have to cancel out any data that
1969 * is not a part of the outer IP header 1972 * is not a part of the outer IP header
1970 */ 1973 */
1971 ip.v4->check = csum_fold(csum_add(lco_csum(skb), 1974 ip.v4->check = csum_fold(csum_partial(trans_start,
1972 csum_unfold(l4.tcp->check))); 1975 csum_start - trans_start,
1976 0));
1973 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; 1977 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
1974 1978
1975 ip.v4->tot_len = 0; 1979 ip.v4->tot_len = 0;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index bd93d823cc25..fee1f2918ead 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7277,11 +7277,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
7277 7277
7278 /* initialize outer IP header fields */ 7278 /* initialize outer IP header fields */
7279 if (ip.v4->version == 4) { 7279 if (ip.v4->version == 4) {
7280 unsigned char *csum_start = skb_checksum_start(skb);
7281 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
7282
7280 /* IP header will have to cancel out any data that 7283 /* IP header will have to cancel out any data that
7281 * is not a part of the outer IP header 7284 * is not a part of the outer IP header
7282 */ 7285 */
7283 ip.v4->check = csum_fold(csum_add(lco_csum(skb), 7286 ip.v4->check = csum_fold(csum_partial(trans_start,
7284 csum_unfold(l4.tcp->check))); 7287 csum_start - trans_start,
7288 0));
7285 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; 7289 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
7286 7290
7287 ip.v4->tot_len = 0; 7291 ip.v4->tot_len = 0;
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 7eaac3234049..cbf70fe4028a 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -3329,11 +3329,15 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring,
3329 3329
3330 /* initialize outer IP header fields */ 3330 /* initialize outer IP header fields */
3331 if (ip.v4->version == 4) { 3331 if (ip.v4->version == 4) {
3332 unsigned char *csum_start = skb_checksum_start(skb);
3333 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
3334
3332 /* IP header will have to cancel out any data that 3335 /* IP header will have to cancel out any data that
3333 * is not a part of the outer IP header 3336 * is not a part of the outer IP header
3334 */ 3337 */
3335 ip.v4->check = csum_fold(csum_add(lco_csum(skb), 3338 ip.v4->check = csum_fold(csum_partial(trans_start,
3336 csum_unfold(l4.tcp->check))); 3339 csum_start - trans_start,
3340 0));
3337 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; 3341 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
3338 3342
3339 ip.v4->tot_len = 0; 3343 ip.v4->tot_len = 0;
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 91e09d68b7e2..a167fd7ee13e 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -704,6 +704,7 @@ ltq_etop_probe(struct platform_device *pdev)
704 priv->pldata = dev_get_platdata(&pdev->dev); 704 priv->pldata = dev_get_platdata(&pdev->dev);
705 priv->netdev = dev; 705 priv->netdev = dev;
706 spin_lock_init(&priv->lock); 706 spin_lock_init(&priv->lock);
707 SET_NETDEV_DEV(dev, &pdev->dev);
707 708
708 for (i = 0; i < MAX_DMA_CHAN; i++) { 709 for (i = 0; i < MAX_DMA_CHAN; i++) {
709 if (IS_TX(i)) 710 if (IS_TX(i))
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 5cb07c2017bf..707bc4680b9b 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4151,7 +4151,7 @@ static int mvneta_probe(struct platform_device *pdev)
4151 dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 4151 dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
4152 dev->hw_features |= dev->features; 4152 dev->hw_features |= dev->features;
4153 dev->vlan_features |= dev->features; 4153 dev->vlan_features |= dev->features;
4154 dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE; 4154 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
4155 dev->gso_max_segs = MVNETA_MAX_TSO_SEGS; 4155 dev->gso_max_segs = MVNETA_MAX_TSO_SEGS;
4156 4156
4157 err = register_netdev(dev); 4157 err = register_netdev(dev);
@@ -4191,6 +4191,8 @@ err_clk:
4191 clk_disable_unprepare(pp->clk); 4191 clk_disable_unprepare(pp->clk);
4192err_put_phy_node: 4192err_put_phy_node:
4193 of_node_put(phy_node); 4193 of_node_put(phy_node);
4194 if (of_phy_is_fixed_link(dn))
4195 of_phy_deregister_fixed_link(dn);
4194err_free_irq: 4196err_free_irq:
4195 irq_dispose_mapping(dev->irq); 4197 irq_dispose_mapping(dev->irq);
4196err_free_netdev: 4198err_free_netdev:
@@ -4202,6 +4204,7 @@ err_free_netdev:
4202static int mvneta_remove(struct platform_device *pdev) 4204static int mvneta_remove(struct platform_device *pdev)
4203{ 4205{
4204 struct net_device *dev = platform_get_drvdata(pdev); 4206 struct net_device *dev = platform_get_drvdata(pdev);
4207 struct device_node *dn = pdev->dev.of_node;
4205 struct mvneta_port *pp = netdev_priv(dev); 4208 struct mvneta_port *pp = netdev_priv(dev);
4206 4209
4207 unregister_netdev(dev); 4210 unregister_netdev(dev);
@@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev)
4209 clk_disable_unprepare(pp->clk); 4212 clk_disable_unprepare(pp->clk);
4210 free_percpu(pp->ports); 4213 free_percpu(pp->ports);
4211 free_percpu(pp->stats); 4214 free_percpu(pp->stats);
4215 if (of_phy_is_fixed_link(dn))
4216 of_phy_deregister_fixed_link(dn);
4212 irq_dispose_mapping(dev->irq); 4217 irq_dispose_mapping(dev->irq);
4213 of_node_put(pp->phy_node); 4218 of_node_put(pp->phy_node);
4214 free_netdev(dev); 4219 free_netdev(dev);
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 60227a3452a4..1026c452e39d 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3293,7 +3293,7 @@ static void mvpp2_cls_init(struct mvpp2 *priv)
3293 mvpp2_write(priv, MVPP2_CLS_MODE_REG, MVPP2_CLS_MODE_ACTIVE_MASK); 3293 mvpp2_write(priv, MVPP2_CLS_MODE_REG, MVPP2_CLS_MODE_ACTIVE_MASK);
3294 3294
3295 /* Clear classifier flow table */ 3295 /* Clear classifier flow table */
3296 memset(&fe.data, 0, MVPP2_CLS_FLOWS_TBL_DATA_WORDS); 3296 memset(&fe.data, 0, sizeof(fe.data));
3297 for (index = 0; index < MVPP2_CLS_FLOWS_TBL_SIZE; index++) { 3297 for (index = 0; index < MVPP2_CLS_FLOWS_TBL_SIZE; index++) {
3298 fe.index = index; 3298 fe.index = index;
3299 mvpp2_cls_flow_write(priv, &fe); 3299 mvpp2_cls_flow_write(priv, &fe);
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 4a62ffd7729d..86a89cbd3ec9 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -318,6 +318,8 @@ static int mtk_phy_connect(struct net_device *dev)
318 return 0; 318 return 0;
319 319
320err_phy: 320err_phy:
321 if (of_phy_is_fixed_link(mac->of_node))
322 of_phy_deregister_fixed_link(mac->of_node);
321 of_node_put(np); 323 of_node_put(np);
322 dev_err(eth->dev, "%s: invalid phy\n", __func__); 324 dev_err(eth->dev, "%s: invalid phy\n", __func__);
323 return -EINVAL; 325 return -EINVAL;
@@ -1923,6 +1925,8 @@ static void mtk_uninit(struct net_device *dev)
1923 struct mtk_eth *eth = mac->hw; 1925 struct mtk_eth *eth = mac->hw;
1924 1926
1925 phy_disconnect(dev->phydev); 1927 phy_disconnect(dev->phydev);
1928 if (of_phy_is_fixed_link(mac->of_node))
1929 of_phy_deregister_fixed_link(mac->of_node);
1926 mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0); 1930 mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0);
1927 mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0); 1931 mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0);
1928} 1932}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 3a47e83d3e07..fb8bb027b69c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -129,6 +129,9 @@ static enum mlx4_net_trans_rule_id mlx4_ip_proto_to_trans_rule_id(u8 ip_proto)
129 } 129 }
130}; 130};
131 131
132/* Must not acquire state_lock, as its corresponding work_sync
133 * is done under it.
134 */
132static void mlx4_en_filter_work(struct work_struct *work) 135static void mlx4_en_filter_work(struct work_struct *work)
133{ 136{
134 struct mlx4_en_filter *filter = container_of(work, 137 struct mlx4_en_filter *filter = container_of(work,
@@ -2076,13 +2079,6 @@ err:
2076 return -ENOMEM; 2079 return -ENOMEM;
2077} 2080}
2078 2081
2079static void mlx4_en_shutdown(struct net_device *dev)
2080{
2081 rtnl_lock();
2082 netif_device_detach(dev);
2083 mlx4_en_close(dev);
2084 rtnl_unlock();
2085}
2086 2082
2087static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, 2083static int mlx4_en_copy_priv(struct mlx4_en_priv *dst,
2088 struct mlx4_en_priv *src, 2084 struct mlx4_en_priv *src,
@@ -2159,8 +2155,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2159{ 2155{
2160 struct mlx4_en_priv *priv = netdev_priv(dev); 2156 struct mlx4_en_priv *priv = netdev_priv(dev);
2161 struct mlx4_en_dev *mdev = priv->mdev; 2157 struct mlx4_en_dev *mdev = priv->mdev;
2162 bool shutdown = mdev->dev->persist->interface_state &
2163 MLX4_INTERFACE_STATE_SHUTDOWN;
2164 2158
2165 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); 2159 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
2166 2160
@@ -2168,10 +2162,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2168 if (priv->registered) { 2162 if (priv->registered) {
2169 devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, 2163 devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
2170 priv->port)); 2164 priv->port));
2171 if (shutdown) 2165 unregister_netdev(dev);
2172 mlx4_en_shutdown(dev);
2173 else
2174 unregister_netdev(dev);
2175 } 2166 }
2176 2167
2177 if (priv->allocated) 2168 if (priv->allocated)
@@ -2189,19 +2180,18 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2189 mutex_lock(&mdev->state_lock); 2180 mutex_lock(&mdev->state_lock);
2190 mdev->pndev[priv->port] = NULL; 2181 mdev->pndev[priv->port] = NULL;
2191 mdev->upper[priv->port] = NULL; 2182 mdev->upper[priv->port] = NULL;
2192 mutex_unlock(&mdev->state_lock);
2193 2183
2194#ifdef CONFIG_RFS_ACCEL 2184#ifdef CONFIG_RFS_ACCEL
2195 mlx4_en_cleanup_filters(priv); 2185 mlx4_en_cleanup_filters(priv);
2196#endif 2186#endif
2197 2187
2198 mlx4_en_free_resources(priv); 2188 mlx4_en_free_resources(priv);
2189 mutex_unlock(&mdev->state_lock);
2199 2190
2200 kfree(priv->tx_ring); 2191 kfree(priv->tx_ring);
2201 kfree(priv->tx_cq); 2192 kfree(priv->tx_cq);
2202 2193
2203 if (!shutdown) 2194 free_netdev(dev);
2204 free_netdev(dev);
2205} 2195}
2206 2196
2207static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) 2197static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 6f4e67bc3538..75d07fa9d0b1 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -4147,11 +4147,8 @@ static void mlx4_shutdown(struct pci_dev *pdev)
4147 4147
4148 mlx4_info(persist->dev, "mlx4_shutdown was called\n"); 4148 mlx4_info(persist->dev, "mlx4_shutdown was called\n");
4149 mutex_lock(&persist->interface_state_mutex); 4149 mutex_lock(&persist->interface_state_mutex);
4150 if (persist->interface_state & MLX4_INTERFACE_STATE_UP) { 4150 if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
4151 /* Notify mlx4 clients that the kernel is being shut down */
4152 persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN;
4153 mlx4_unload_one(pdev); 4151 mlx4_unload_one(pdev);
4154 }
4155 mutex_unlock(&persist->interface_state_mutex); 4152 mutex_unlock(&persist->interface_state_mutex);
4156} 4153}
4157 4154
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index 94b891c118c1..1a670b681555 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -1457,7 +1457,12 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach);
1457int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, 1457int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port,
1458 u32 qpn, enum mlx4_net_trans_promisc_mode mode) 1458 u32 qpn, enum mlx4_net_trans_promisc_mode mode)
1459{ 1459{
1460 struct mlx4_net_trans_rule rule; 1460 struct mlx4_net_trans_rule rule = {
1461 .queue_mode = MLX4_NET_TRANS_Q_FIFO,
1462 .exclusive = 0,
1463 .allow_loopback = 1,
1464 };
1465
1461 u64 *regid_p; 1466 u64 *regid_p;
1462 1467
1463 switch (mode) { 1468 switch (mode) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index aae46884bf93..521cfdb7d11e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -18,8 +18,6 @@ config MLX5_CORE_EN
18 default n 18 default n
19 ---help--- 19 ---help---
20 Ethernet support in Mellanox Technologies ConnectX-4 NIC. 20 Ethernet support in Mellanox Technologies ConnectX-4 NIC.
21 Ethernet and Infiniband support in ConnectX-4 are currently mutually
22 exclusive.
23 21
24config MLX5_CORE_EN_DCB 22config MLX5_CORE_EN_DCB
25 bool "Data Center Bridging (DCB) Support" 23 bool "Data Center Bridging (DCB) Support"
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 1e639f886021..bfe410e8a469 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -268,11 +268,6 @@ static void dump_buf(void *buf, int size, int data_only, int offset)
268 pr_debug("\n"); 268 pr_debug("\n");
269} 269}
270 270
271enum {
272 MLX5_DRIVER_STATUS_ABORTED = 0xfe,
273 MLX5_DRIVER_SYND = 0xbadd00de,
274};
275
276static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, 271static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
277 u32 *synd, u8 *status) 272 u32 *synd, u8 *status)
278{ 273{
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 7a43502a89cc..71382df59fc0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -241,7 +241,7 @@ struct mlx5e_tstamp {
241}; 241};
242 242
243enum { 243enum {
244 MLX5E_RQ_STATE_FLUSH, 244 MLX5E_RQ_STATE_ENABLED,
245 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, 245 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
246 MLX5E_RQ_STATE_AM, 246 MLX5E_RQ_STATE_AM,
247}; 247};
@@ -394,7 +394,7 @@ struct mlx5e_sq_dma {
394}; 394};
395 395
396enum { 396enum {
397 MLX5E_SQ_STATE_FLUSH, 397 MLX5E_SQ_STATE_ENABLED,
398 MLX5E_SQ_STATE_BF_ENABLE, 398 MLX5E_SQ_STATE_BF_ENABLE,
399}; 399};
400 400
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 84e8b250e2af..246d98ebb588 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -759,6 +759,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
759 if (err) 759 if (err)
760 goto err_destroy_rq; 760 goto err_destroy_rq;
761 761
762 set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
762 err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RST, MLX5_RQC_STATE_RDY); 763 err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RST, MLX5_RQC_STATE_RDY);
763 if (err) 764 if (err)
764 goto err_disable_rq; 765 goto err_disable_rq;
@@ -773,6 +774,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
773 return 0; 774 return 0;
774 775
775err_disable_rq: 776err_disable_rq:
777 clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
776 mlx5e_disable_rq(rq); 778 mlx5e_disable_rq(rq);
777err_destroy_rq: 779err_destroy_rq:
778 mlx5e_destroy_rq(rq); 780 mlx5e_destroy_rq(rq);
@@ -782,7 +784,7 @@ err_destroy_rq:
782 784
783static void mlx5e_close_rq(struct mlx5e_rq *rq) 785static void mlx5e_close_rq(struct mlx5e_rq *rq)
784{ 786{
785 set_bit(MLX5E_RQ_STATE_FLUSH, &rq->state); 787 clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
786 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ 788 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */
787 cancel_work_sync(&rq->am.work); 789 cancel_work_sync(&rq->am.work);
788 790
@@ -1006,7 +1008,6 @@ static int mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
1006 MLX5_SET(sqc, sqc, min_wqe_inline_mode, sq->min_inline_mode); 1008 MLX5_SET(sqc, sqc, min_wqe_inline_mode, sq->min_inline_mode);
1007 MLX5_SET(sqc, sqc, state, MLX5_SQC_STATE_RST); 1009 MLX5_SET(sqc, sqc, state, MLX5_SQC_STATE_RST);
1008 MLX5_SET(sqc, sqc, tis_lst_sz, param->type == MLX5E_SQ_ICO ? 0 : 1); 1010 MLX5_SET(sqc, sqc, tis_lst_sz, param->type == MLX5E_SQ_ICO ? 0 : 1);
1009 MLX5_SET(sqc, sqc, flush_in_error_en, 1);
1010 1011
1011 MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC); 1012 MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
1012 MLX5_SET(wq, wq, uar_page, sq->uar.index); 1013 MLX5_SET(wq, wq, uar_page, sq->uar.index);
@@ -1083,6 +1084,7 @@ static int mlx5e_open_sq(struct mlx5e_channel *c,
1083 if (err) 1084 if (err)
1084 goto err_destroy_sq; 1085 goto err_destroy_sq;
1085 1086
1087 set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
1086 err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RST, MLX5_SQC_STATE_RDY, 1088 err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RST, MLX5_SQC_STATE_RDY,
1087 false, 0); 1089 false, 0);
1088 if (err) 1090 if (err)
@@ -1096,6 +1098,7 @@ static int mlx5e_open_sq(struct mlx5e_channel *c,
1096 return 0; 1098 return 0;
1097 1099
1098err_disable_sq: 1100err_disable_sq:
1101 clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
1099 mlx5e_disable_sq(sq); 1102 mlx5e_disable_sq(sq);
1100err_destroy_sq: 1103err_destroy_sq:
1101 mlx5e_destroy_sq(sq); 1104 mlx5e_destroy_sq(sq);
@@ -1112,7 +1115,7 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq)
1112 1115
1113static void mlx5e_close_sq(struct mlx5e_sq *sq) 1116static void mlx5e_close_sq(struct mlx5e_sq *sq)
1114{ 1117{
1115 set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); 1118 clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
1116 /* prevent netif_tx_wake_queue */ 1119 /* prevent netif_tx_wake_queue */
1117 napi_synchronize(&sq->channel->napi); 1120 napi_synchronize(&sq->channel->napi);
1118 1121
@@ -3092,7 +3095,7 @@ static void mlx5e_tx_timeout(struct net_device *dev)
3092 if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) 3095 if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i)))
3093 continue; 3096 continue;
3094 sched_work = true; 3097 sched_work = true;
3095 set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); 3098 clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
3096 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n", 3099 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n",
3097 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc); 3100 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc);
3098 } 3101 }
@@ -3147,13 +3150,13 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
3147 for (i = 0; i < priv->params.num_channels; i++) { 3150 for (i = 0; i < priv->params.num_channels; i++) {
3148 struct mlx5e_channel *c = priv->channel[i]; 3151 struct mlx5e_channel *c = priv->channel[i];
3149 3152
3150 set_bit(MLX5E_RQ_STATE_FLUSH, &c->rq.state); 3153 clear_bit(MLX5E_RQ_STATE_ENABLED, &c->rq.state);
3151 napi_synchronize(&c->napi); 3154 napi_synchronize(&c->napi);
3152 /* prevent mlx5e_poll_rx_cq from accessing rq->xdp_prog */ 3155 /* prevent mlx5e_poll_rx_cq from accessing rq->xdp_prog */
3153 3156
3154 old_prog = xchg(&c->rq.xdp_prog, prog); 3157 old_prog = xchg(&c->rq.xdp_prog, prog);
3155 3158
3156 clear_bit(MLX5E_RQ_STATE_FLUSH, &c->rq.state); 3159 set_bit(MLX5E_RQ_STATE_ENABLED, &c->rq.state);
3157 /* napi_schedule in case we have missed anything */ 3160 /* napi_schedule in case we have missed anything */
3158 set_bit(MLX5E_CHANNEL_NAPI_SCHED, &c->flags); 3161 set_bit(MLX5E_CHANNEL_NAPI_SCHED, &c->flags);
3159 napi_schedule(&c->napi); 3162 napi_schedule(&c->napi);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index c6de6fba5843..33495d88aeb2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -340,7 +340,7 @@ static inline void mlx5e_post_umr_wqe(struct mlx5e_rq *rq, u16 ix)
340 while ((pi = (sq->pc & wq->sz_m1)) > sq->edge) { 340 while ((pi = (sq->pc & wq->sz_m1)) > sq->edge) {
341 sq->db.ico_wqe[pi].opcode = MLX5_OPCODE_NOP; 341 sq->db.ico_wqe[pi].opcode = MLX5_OPCODE_NOP;
342 sq->db.ico_wqe[pi].num_wqebbs = 1; 342 sq->db.ico_wqe[pi].num_wqebbs = 1;
343 mlx5e_send_nop(sq, true); 343 mlx5e_send_nop(sq, false);
344 } 344 }
345 345
346 wqe = mlx5_wq_cyc_get_wqe(wq, pi); 346 wqe = mlx5_wq_cyc_get_wqe(wq, pi);
@@ -412,7 +412,7 @@ void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq)
412 412
413 clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state); 413 clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
414 414
415 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) { 415 if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) {
416 mlx5e_free_rx_mpwqe(rq, &rq->mpwqe.info[wq->head]); 416 mlx5e_free_rx_mpwqe(rq, &rq->mpwqe.info[wq->head]);
417 return; 417 return;
418 } 418 }
@@ -445,7 +445,7 @@ void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
445} 445}
446 446
447#define RQ_CANNOT_POST(rq) \ 447#define RQ_CANNOT_POST(rq) \
448 (test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state) || \ 448 (!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state) || \
449 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 449 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state))
450 450
451bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) 451bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
@@ -924,7 +924,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
924 struct mlx5e_sq *xdp_sq = &rq->channel->xdp_sq; 924 struct mlx5e_sq *xdp_sq = &rq->channel->xdp_sq;
925 int work_done = 0; 925 int work_done = 0;
926 926
927 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) 927 if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
928 return 0; 928 return 0;
929 929
930 if (cq->decmprs_left) 930 if (cq->decmprs_left)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 70a717382357..cfb68371c397 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -409,7 +409,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
409 409
410 sq = container_of(cq, struct mlx5e_sq, cq); 410 sq = container_of(cq, struct mlx5e_sq, cq);
411 411
412 if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) 412 if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
413 return false; 413 return false;
414 414
415 npkts = 0; 415 npkts = 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
index 5703f19a6a24..e5c12a732aa1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
@@ -56,7 +56,7 @@ static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
56 struct mlx5_cqe64 *cqe; 56 struct mlx5_cqe64 *cqe;
57 u16 sqcc; 57 u16 sqcc;
58 58
59 if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) 59 if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
60 return; 60 return;
61 61
62 cqe = mlx5e_get_cqe(cq); 62 cqe = mlx5e_get_cqe(cq);
@@ -113,7 +113,7 @@ static inline bool mlx5e_poll_xdp_tx_cq(struct mlx5e_cq *cq)
113 113
114 sq = container_of(cq, struct mlx5e_sq, cq); 114 sq = container_of(cq, struct mlx5e_sq, cq);
115 115
116 if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) 116 if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
117 return false; 117 return false;
118 118
119 /* sq->cc must be updated only after mlx5_cqwq_update_db_record(), 119 /* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 3eb931585b3e..ada24e103b02 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -46,7 +46,6 @@
46#include <linux/mlx5/srq.h> 46#include <linux/mlx5/srq.h>
47#include <linux/debugfs.h> 47#include <linux/debugfs.h>
48#include <linux/kmod.h> 48#include <linux/kmod.h>
49#include <linux/delay.h>
50#include <linux/mlx5/mlx5_ifc.h> 49#include <linux/mlx5/mlx5_ifc.h>
51#ifdef CONFIG_RFS_ACCEL 50#ifdef CONFIG_RFS_ACCEL
52#include <linux/cpu_rmap.h> 51#include <linux/cpu_rmap.h>
@@ -63,13 +62,13 @@ MODULE_DESCRIPTION("Mellanox Connect-IB, ConnectX-4 core driver");
63MODULE_LICENSE("Dual BSD/GPL"); 62MODULE_LICENSE("Dual BSD/GPL");
64MODULE_VERSION(DRIVER_VERSION); 63MODULE_VERSION(DRIVER_VERSION);
65 64
66int mlx5_core_debug_mask; 65unsigned int mlx5_core_debug_mask;
67module_param_named(debug_mask, mlx5_core_debug_mask, int, 0644); 66module_param_named(debug_mask, mlx5_core_debug_mask, uint, 0644);
68MODULE_PARM_DESC(debug_mask, "debug mask: 1 = dump cmd data, 2 = dump cmd exec time, 3 = both. Default=0"); 67MODULE_PARM_DESC(debug_mask, "debug mask: 1 = dump cmd data, 2 = dump cmd exec time, 3 = both. Default=0");
69 68
70#define MLX5_DEFAULT_PROF 2 69#define MLX5_DEFAULT_PROF 2
71static int prof_sel = MLX5_DEFAULT_PROF; 70static unsigned int prof_sel = MLX5_DEFAULT_PROF;
72module_param_named(prof_sel, prof_sel, int, 0444); 71module_param_named(prof_sel, prof_sel, uint, 0444);
73MODULE_PARM_DESC(prof_sel, "profile selector. Valid range 0 - 2"); 72MODULE_PARM_DESC(prof_sel, "profile selector. Valid range 0 - 2");
74 73
75enum { 74enum {
@@ -733,13 +732,15 @@ static int mlx5_core_set_issi(struct mlx5_core_dev *dev)
733 u8 status; 732 u8 status;
734 733
735 mlx5_cmd_mbox_status(query_out, &status, &syndrome); 734 mlx5_cmd_mbox_status(query_out, &status, &syndrome);
736 if (status == MLX5_CMD_STAT_BAD_OP_ERR) { 735 if (!status || syndrome == MLX5_DRIVER_SYND) {
737 pr_debug("Only ISSI 0 is supported\n"); 736 mlx5_core_err(dev, "Failed to query ISSI err(%d) status(%d) synd(%d)\n",
738 return 0; 737 err, status, syndrome);
738 return err;
739 } 739 }
740 740
741 pr_err("failed to query ISSI err(%d)\n", err); 741 mlx5_core_warn(dev, "Query ISSI is not supported by FW, ISSI is 0\n");
742 return err; 742 dev->issi = 0;
743 return 0;
743 } 744 }
744 745
745 sup_issi = MLX5_GET(query_issi_out, query_out, supported_issi_dw0); 746 sup_issi = MLX5_GET(query_issi_out, query_out, supported_issi_dw0);
@@ -753,7 +754,8 @@ static int mlx5_core_set_issi(struct mlx5_core_dev *dev)
753 err = mlx5_cmd_exec(dev, set_in, sizeof(set_in), 754 err = mlx5_cmd_exec(dev, set_in, sizeof(set_in),
754 set_out, sizeof(set_out)); 755 set_out, sizeof(set_out));
755 if (err) { 756 if (err) {
756 pr_err("failed to set ISSI=1 err(%d)\n", err); 757 mlx5_core_err(dev, "Failed to set ISSI to 1 err(%d)\n",
758 err);
757 return err; 759 return err;
758 } 760 }
759 761
@@ -1228,13 +1230,6 @@ static int init_one(struct pci_dev *pdev,
1228 1230
1229 dev->pdev = pdev; 1231 dev->pdev = pdev;
1230 dev->event = mlx5_core_event; 1232 dev->event = mlx5_core_event;
1231
1232 if (prof_sel < 0 || prof_sel >= ARRAY_SIZE(profile)) {
1233 mlx5_core_warn(dev,
1234 "selected profile out of range, selecting default (%d)\n",
1235 MLX5_DEFAULT_PROF);
1236 prof_sel = MLX5_DEFAULT_PROF;
1237 }
1238 dev->profile = &profile[prof_sel]; 1233 dev->profile = &profile[prof_sel];
1239 1234
1240 INIT_LIST_HEAD(&priv->ctx_list); 1235 INIT_LIST_HEAD(&priv->ctx_list);
@@ -1451,10 +1446,22 @@ static struct pci_driver mlx5_core_driver = {
1451 .sriov_configure = mlx5_core_sriov_configure, 1446 .sriov_configure = mlx5_core_sriov_configure,
1452}; 1447};
1453 1448
1449static void mlx5_core_verify_params(void)
1450{
1451 if (prof_sel >= ARRAY_SIZE(profile)) {
1452 pr_warn("mlx5_core: WARNING: Invalid module parameter prof_sel %d, valid range 0-%zu, changing back to default(%d)\n",
1453 prof_sel,
1454 ARRAY_SIZE(profile) - 1,
1455 MLX5_DEFAULT_PROF);
1456 prof_sel = MLX5_DEFAULT_PROF;
1457 }
1458}
1459
1454static int __init init(void) 1460static int __init init(void)
1455{ 1461{
1456 int err; 1462 int err;
1457 1463
1464 mlx5_core_verify_params();
1458 mlx5_register_debugfs(); 1465 mlx5_register_debugfs();
1459 1466
1460 err = pci_register_driver(&mlx5_core_driver); 1467 err = pci_register_driver(&mlx5_core_driver);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 187662c8ea96..63b9a0dba885 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -44,11 +44,11 @@
44 44
45#define MLX5_TOTAL_VPORTS(mdev) (1 + pci_sriov_get_totalvfs(mdev->pdev)) 45#define MLX5_TOTAL_VPORTS(mdev) (1 + pci_sriov_get_totalvfs(mdev->pdev))
46 46
47extern int mlx5_core_debug_mask; 47extern uint mlx5_core_debug_mask;
48 48
49#define mlx5_core_dbg(__dev, format, ...) \ 49#define mlx5_core_dbg(__dev, format, ...) \
50 dev_dbg(&(__dev)->pdev->dev, "%s:%s:%d:(pid %d): " format, \ 50 dev_dbg(&(__dev)->pdev->dev, "%s:%d:(pid %d): " format, \
51 (__dev)->priv.name, __func__, __LINE__, current->pid, \ 51 __func__, __LINE__, current->pid, \
52 ##__VA_ARGS__) 52 ##__VA_ARGS__)
53 53
54#define mlx5_core_dbg_mask(__dev, mask, format, ...) \ 54#define mlx5_core_dbg_mask(__dev, mask, format, ...) \
@@ -63,8 +63,8 @@ do { \
63 ##__VA_ARGS__) 63 ##__VA_ARGS__)
64 64
65#define mlx5_core_warn(__dev, format, ...) \ 65#define mlx5_core_warn(__dev, format, ...) \
66 dev_warn(&(__dev)->pdev->dev, "%s:%s:%d:(pid %d): " format, \ 66 dev_warn(&(__dev)->pdev->dev, "%s:%d:(pid %d): " format, \
67 (__dev)->priv.name, __func__, __LINE__, current->pid, \ 67 __func__, __LINE__, current->pid, \
68 ##__VA_ARGS__) 68 ##__VA_ARGS__)
69 69
70#define mlx5_core_info(__dev, format, ...) \ 70#define mlx5_core_info(__dev, format, ...) \
@@ -75,6 +75,11 @@ enum {
75 MLX5_CMD_TIME, /* print command execution time */ 75 MLX5_CMD_TIME, /* print command execution time */
76}; 76};
77 77
78enum {
79 MLX5_DRIVER_STATUS_ABORTED = 0xfe,
80 MLX5_DRIVER_SYND = 0xbadd00de,
81};
82
78int mlx5_query_hca_caps(struct mlx5_core_dev *dev); 83int mlx5_query_hca_caps(struct mlx5_core_dev *dev);
79int mlx5_query_board_id(struct mlx5_core_dev *dev); 84int mlx5_query_board_id(struct mlx5_core_dev *dev);
80int mlx5_cmd_init_hca(struct mlx5_core_dev *dev); 85int mlx5_cmd_init_hca(struct mlx5_core_dev *dev);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index f95385cbbd40..62ae55bd81b8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -1730,6 +1730,7 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb)
1730 mapping))) { 1730 mapping))) {
1731 DP_NOTICE(cdev, 1731 DP_NOTICE(cdev,
1732 "Unable to map frag - dropping packet\n"); 1732 "Unable to map frag - dropping packet\n");
1733 rc = -ENOMEM;
1733 goto err; 1734 goto err;
1734 } 1735 }
1735 } else { 1736 } else {
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
index da4e90db4d98..99a14df28b96 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
212 212
213 phy_np = of_parse_phandle(np, "phy-handle", 0); 213 phy_np = of_parse_phandle(np, "phy-handle", 0);
214 adpt->phydev = of_phy_find_device(phy_np); 214 adpt->phydev = of_phy_find_device(phy_np);
215 of_node_put(phy_np);
215 } 216 }
216 217
217 if (!adpt->phydev) { 218 if (!adpt->phydev) {
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 4fede4b86538..57b35aeac51a 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev)
711err_undo_napi: 711err_undo_napi:
712 netif_napi_del(&adpt->rx_q.napi); 712 netif_napi_del(&adpt->rx_q.napi);
713err_undo_mdiobus: 713err_undo_mdiobus:
714 if (!has_acpi_companion(&pdev->dev))
715 put_device(&adpt->phydev->mdio.dev);
714 mdiobus_unregister(adpt->mii_bus); 716 mdiobus_unregister(adpt->mii_bus);
715err_undo_clocks: 717err_undo_clocks:
716 emac_clks_teardown(adpt); 718 emac_clks_teardown(adpt);
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev)
730 732
731 emac_clks_teardown(adpt); 733 emac_clks_teardown(adpt);
732 734
735 if (!has_acpi_companion(&pdev->dev))
736 put_device(&adpt->phydev->mdio.dev);
733 mdiobus_unregister(adpt->mii_bus); 737 mdiobus_unregister(adpt->mii_bus);
734 free_netdev(netdev); 738 free_netdev(netdev);
735 739
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 630536bc72f9..d6a217874a8b 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1008,20 +1008,18 @@ static int ravb_phy_init(struct net_device *ndev)
1008 of_node_put(pn); 1008 of_node_put(pn);
1009 if (!phydev) { 1009 if (!phydev) {
1010 netdev_err(ndev, "failed to connect PHY\n"); 1010 netdev_err(ndev, "failed to connect PHY\n");
1011 return -ENOENT; 1011 err = -ENOENT;
1012 goto err_deregister_fixed_link;
1012 } 1013 }
1013 1014
1014 /* This driver only support 10/100Mbit speeds on Gen3 1015 /* This driver only support 10/100Mbit speeds on Gen3
1015 * at this time. 1016 * at this time.
1016 */ 1017 */
1017 if (priv->chip_id == RCAR_GEN3) { 1018 if (priv->chip_id == RCAR_GEN3) {
1018 int err;
1019
1020 err = phy_set_max_speed(phydev, SPEED_100); 1019 err = phy_set_max_speed(phydev, SPEED_100);
1021 if (err) { 1020 if (err) {
1022 netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n"); 1021 netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n");
1023 phy_disconnect(phydev); 1022 goto err_phy_disconnect;
1024 return err;
1025 } 1023 }
1026 1024
1027 netdev_info(ndev, "limited PHY to 100Mbit/s\n"); 1025 netdev_info(ndev, "limited PHY to 100Mbit/s\n");
@@ -1033,6 +1031,14 @@ static int ravb_phy_init(struct net_device *ndev)
1033 phy_attached_info(phydev); 1031 phy_attached_info(phydev);
1034 1032
1035 return 0; 1033 return 0;
1034
1035err_phy_disconnect:
1036 phy_disconnect(phydev);
1037err_deregister_fixed_link:
1038 if (of_phy_is_fixed_link(np))
1039 of_phy_deregister_fixed_link(np);
1040
1041 return err;
1036} 1042}
1037 1043
1038/* PHY control start function */ 1044/* PHY control start function */
@@ -1634,6 +1640,7 @@ static void ravb_set_rx_mode(struct net_device *ndev)
1634/* Device close function for Ethernet AVB */ 1640/* Device close function for Ethernet AVB */
1635static int ravb_close(struct net_device *ndev) 1641static int ravb_close(struct net_device *ndev)
1636{ 1642{
1643 struct device_node *np = ndev->dev.parent->of_node;
1637 struct ravb_private *priv = netdev_priv(ndev); 1644 struct ravb_private *priv = netdev_priv(ndev);
1638 struct ravb_tstamp_skb *ts_skb, *ts_skb2; 1645 struct ravb_tstamp_skb *ts_skb, *ts_skb2;
1639 1646
@@ -1663,6 +1670,8 @@ static int ravb_close(struct net_device *ndev)
1663 if (ndev->phydev) { 1670 if (ndev->phydev) {
1664 phy_stop(ndev->phydev); 1671 phy_stop(ndev->phydev);
1665 phy_disconnect(ndev->phydev); 1672 phy_disconnect(ndev->phydev);
1673 if (of_phy_is_fixed_link(np))
1674 of_phy_deregister_fixed_link(np);
1666 } 1675 }
1667 1676
1668 if (priv->chip_id != RCAR_GEN2) { 1677 if (priv->chip_id != RCAR_GEN2) {
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 05b0dc55de77..1a92de705199 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -518,7 +518,7 @@ static struct sh_eth_cpu_data r7s72100_data = {
518 518
519 .ecsr_value = ECSR_ICD, 519 .ecsr_value = ECSR_ICD,
520 .ecsipr_value = ECSIPR_ICDIP, 520 .ecsipr_value = ECSIPR_ICDIP,
521 .eesipr_value = 0xff7f009f, 521 .eesipr_value = 0xe77f009f,
522 522
523 .tx_check = EESR_TC1 | EESR_FTC, 523 .tx_check = EESR_TC1 | EESR_FTC,
524 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 524 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index e9b8579e6241..8b0016a785c0 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -438,9 +438,16 @@ static int smsc911x_request_resources(struct platform_device *pdev)
438 ret = regulator_bulk_get(&pdev->dev, 438 ret = regulator_bulk_get(&pdev->dev,
439 ARRAY_SIZE(pdata->supplies), 439 ARRAY_SIZE(pdata->supplies),
440 pdata->supplies); 440 pdata->supplies);
441 if (ret) 441 if (ret) {
442 /*
443 * Retry on deferrals, else just report the error
444 * and try to continue.
445 */
446 if (ret == -EPROBE_DEFER)
447 return ret;
442 netdev_err(ndev, "couldn't get regulators %d\n", 448 netdev_err(ndev, "couldn't get regulators %d\n",
443 ret); 449 ret);
450 }
444 451
445 /* Request optional RESET GPIO */ 452 /* Request optional RESET GPIO */
446 pdata->reset_gpiod = devm_gpiod_get_optional(&pdev->dev, 453 pdata->reset_gpiod = devm_gpiod_get_optional(&pdev->dev,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
index b1e5f24708c9..e6e6c2fcc4b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
@@ -50,10 +50,23 @@ static int dwmac_generic_probe(struct platform_device *pdev)
50 if (plat_dat->init) { 50 if (plat_dat->init) {
51 ret = plat_dat->init(pdev, plat_dat->bsp_priv); 51 ret = plat_dat->init(pdev, plat_dat->bsp_priv);
52 if (ret) 52 if (ret)
53 return ret; 53 goto err_remove_config_dt;
54 } 54 }
55 55
56 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 56 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
57 if (ret)
58 goto err_exit;
59
60 return 0;
61
62err_exit:
63 if (plat_dat->exit)
64 plat_dat->exit(pdev, plat_dat->bsp_priv);
65err_remove_config_dt:
66 if (pdev->dev.of_node)
67 stmmac_remove_config_dt(pdev, plat_dat);
68
69 return ret;
57} 70}
58 71
59static const struct of_device_id dwmac_generic_match[] = { 72static const struct of_device_id dwmac_generic_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 36d3355f2fb0..866444b6c82f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -271,15 +271,17 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
271 return PTR_ERR(plat_dat); 271 return PTR_ERR(plat_dat);
272 272
273 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); 273 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
274 if (!gmac) 274 if (!gmac) {
275 return -ENOMEM; 275 err = -ENOMEM;
276 goto err_remove_config_dt;
277 }
276 278
277 gmac->pdev = pdev; 279 gmac->pdev = pdev;
278 280
279 err = ipq806x_gmac_of_parse(gmac); 281 err = ipq806x_gmac_of_parse(gmac);
280 if (err) { 282 if (err) {
281 dev_err(dev, "device tree parsing error\n"); 283 dev_err(dev, "device tree parsing error\n");
282 return err; 284 goto err_remove_config_dt;
283 } 285 }
284 286
285 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, 287 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL,
@@ -300,7 +302,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
300 default: 302 default:
301 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", 303 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
302 phy_modes(gmac->phy_mode)); 304 phy_modes(gmac->phy_mode));
303 return -EINVAL; 305 err = -EINVAL;
306 goto err_remove_config_dt;
304 } 307 }
305 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); 308 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
306 309
@@ -319,7 +322,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
319 default: 322 default:
320 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", 323 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
321 phy_modes(gmac->phy_mode)); 324 phy_modes(gmac->phy_mode));
322 return -EINVAL; 325 err = -EINVAL;
326 goto err_remove_config_dt;
323 } 327 }
324 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); 328 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
325 329
@@ -346,7 +350,16 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
346 plat_dat->bsp_priv = gmac; 350 plat_dat->bsp_priv = gmac;
347 plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed; 351 plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed;
348 352
349 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 353 err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
354 if (err)
355 goto err_remove_config_dt;
356
357 return 0;
358
359err_remove_config_dt:
360 stmmac_remove_config_dt(pdev, plat_dat);
361
362 return err;
350} 363}
351 364
352static const struct of_device_id ipq806x_gmac_dwmac_match[] = { 365static const struct of_device_id ipq806x_gmac_dwmac_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
index 78e9d1861896..3d3f43d91b98 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
@@ -46,7 +46,8 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
46 reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg"); 46 reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
47 if (IS_ERR(reg)) { 47 if (IS_ERR(reg)) {
48 dev_err(&pdev->dev, "syscon lookup failed\n"); 48 dev_err(&pdev->dev, "syscon lookup failed\n");
49 return PTR_ERR(reg); 49 ret = PTR_ERR(reg);
50 goto err_remove_config_dt;
50 } 51 }
51 52
52 if (plat_dat->interface == PHY_INTERFACE_MODE_MII) { 53 if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
@@ -55,13 +56,23 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
55 ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII; 56 ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
56 } else { 57 } else {
57 dev_err(&pdev->dev, "Only MII and RMII mode supported\n"); 58 dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
58 return -EINVAL; 59 ret = -EINVAL;
60 goto err_remove_config_dt;
59 } 61 }
60 62
61 regmap_update_bits(reg, LPC18XX_CREG_CREG6, 63 regmap_update_bits(reg, LPC18XX_CREG_CREG6,
62 LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode); 64 LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
63 65
64 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 66 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
67 if (ret)
68 goto err_remove_config_dt;
69
70 return 0;
71
72err_remove_config_dt:
73 stmmac_remove_config_dt(pdev, plat_dat);
74
75 return ret;
65} 76}
66 77
67static const struct of_device_id lpc18xx_dwmac_match[] = { 78static const struct of_device_id lpc18xx_dwmac_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
index 309d99536a2c..7fdd1760a74c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -64,18 +64,31 @@ static int meson6_dwmac_probe(struct platform_device *pdev)
64 return PTR_ERR(plat_dat); 64 return PTR_ERR(plat_dat);
65 65
66 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 66 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
67 if (!dwmac) 67 if (!dwmac) {
68 return -ENOMEM; 68 ret = -ENOMEM;
69 goto err_remove_config_dt;
70 }
69 71
70 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 72 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
71 dwmac->reg = devm_ioremap_resource(&pdev->dev, res); 73 dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
72 if (IS_ERR(dwmac->reg)) 74 if (IS_ERR(dwmac->reg)) {
73 return PTR_ERR(dwmac->reg); 75 ret = PTR_ERR(dwmac->reg);
76 goto err_remove_config_dt;
77 }
74 78
75 plat_dat->bsp_priv = dwmac; 79 plat_dat->bsp_priv = dwmac;
76 plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed; 80 plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;
77 81
78 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 82 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
83 if (ret)
84 goto err_remove_config_dt;
85
86 return 0;
87
88err_remove_config_dt:
89 stmmac_remove_config_dt(pdev, plat_dat);
90
91 return ret;
79} 92}
80 93
81static const struct of_device_id meson6_dwmac_match[] = { 94static const struct of_device_id meson6_dwmac_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index 250e4ceafc8d..ffaed1f35efe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -264,32 +264,48 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
264 return PTR_ERR(plat_dat); 264 return PTR_ERR(plat_dat);
265 265
266 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 266 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
267 if (!dwmac) 267 if (!dwmac) {
268 return -ENOMEM; 268 ret = -ENOMEM;
269 goto err_remove_config_dt;
270 }
269 271
270 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 272 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
271 dwmac->regs = devm_ioremap_resource(&pdev->dev, res); 273 dwmac->regs = devm_ioremap_resource(&pdev->dev, res);
272 if (IS_ERR(dwmac->regs)) 274 if (IS_ERR(dwmac->regs)) {
273 return PTR_ERR(dwmac->regs); 275 ret = PTR_ERR(dwmac->regs);
276 goto err_remove_config_dt;
277 }
274 278
275 dwmac->pdev = pdev; 279 dwmac->pdev = pdev;
276 dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); 280 dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node);
277 if (dwmac->phy_mode < 0) { 281 if (dwmac->phy_mode < 0) {
278 dev_err(&pdev->dev, "missing phy-mode property\n"); 282 dev_err(&pdev->dev, "missing phy-mode property\n");
279 return -EINVAL; 283 ret = -EINVAL;
284 goto err_remove_config_dt;
280 } 285 }
281 286
282 ret = meson8b_init_clk(dwmac); 287 ret = meson8b_init_clk(dwmac);
283 if (ret) 288 if (ret)
284 return ret; 289 goto err_remove_config_dt;
285 290
286 ret = meson8b_init_prg_eth(dwmac); 291 ret = meson8b_init_prg_eth(dwmac);
287 if (ret) 292 if (ret)
288 return ret; 293 goto err_remove_config_dt;
289 294
290 plat_dat->bsp_priv = dwmac; 295 plat_dat->bsp_priv = dwmac;
291 296
292 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 297 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
298 if (ret)
299 goto err_clk_disable;
300
301 return 0;
302
303err_clk_disable:
304 clk_disable_unprepare(dwmac->m25_div_clk);
305err_remove_config_dt:
306 stmmac_remove_config_dt(pdev, plat_dat);
307
308 return ret;
293} 309}
294 310
295static int meson8b_dwmac_remove(struct platform_device *pdev) 311static int meson8b_dwmac_remove(struct platform_device *pdev)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 3740a4417fa0..d80c88bd2bba 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -981,14 +981,27 @@ static int rk_gmac_probe(struct platform_device *pdev)
981 plat_dat->resume = rk_gmac_resume; 981 plat_dat->resume = rk_gmac_resume;
982 982
983 plat_dat->bsp_priv = rk_gmac_setup(pdev, data); 983 plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
984 if (IS_ERR(plat_dat->bsp_priv)) 984 if (IS_ERR(plat_dat->bsp_priv)) {
985 return PTR_ERR(plat_dat->bsp_priv); 985 ret = PTR_ERR(plat_dat->bsp_priv);
986 goto err_remove_config_dt;
987 }
986 988
987 ret = rk_gmac_init(pdev, plat_dat->bsp_priv); 989 ret = rk_gmac_init(pdev, plat_dat->bsp_priv);
988 if (ret) 990 if (ret)
989 return ret; 991 goto err_remove_config_dt;
992
993 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
994 if (ret)
995 goto err_gmac_exit;
996
997 return 0;
998
999err_gmac_exit:
1000 rk_gmac_exit(pdev, plat_dat->bsp_priv);
1001err_remove_config_dt:
1002 stmmac_remove_config_dt(pdev, plat_dat);
990 1003
991 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 1004 return ret;
992} 1005}
993 1006
994static const struct of_device_id rk_gmac_dwmac_match[] = { 1007static const struct of_device_id rk_gmac_dwmac_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index bec6963ac71e..0c420e97de1e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -304,6 +304,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
304 struct device *dev = &pdev->dev; 304 struct device *dev = &pdev->dev;
305 int ret; 305 int ret;
306 struct socfpga_dwmac *dwmac; 306 struct socfpga_dwmac *dwmac;
307 struct net_device *ndev;
308 struct stmmac_priv *stpriv;
307 309
308 ret = stmmac_get_platform_resources(pdev, &stmmac_res); 310 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
309 if (ret) 311 if (ret)
@@ -314,32 +316,43 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
314 return PTR_ERR(plat_dat); 316 return PTR_ERR(plat_dat);
315 317
316 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); 318 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
317 if (!dwmac) 319 if (!dwmac) {
318 return -ENOMEM; 320 ret = -ENOMEM;
321 goto err_remove_config_dt;
322 }
319 323
320 ret = socfpga_dwmac_parse_data(dwmac, dev); 324 ret = socfpga_dwmac_parse_data(dwmac, dev);
321 if (ret) { 325 if (ret) {
322 dev_err(dev, "Unable to parse OF data\n"); 326 dev_err(dev, "Unable to parse OF data\n");
323 return ret; 327 goto err_remove_config_dt;
324 } 328 }
325 329
326 plat_dat->bsp_priv = dwmac; 330 plat_dat->bsp_priv = dwmac;
327 plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; 331 plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
328 332
329 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 333 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
334 if (ret)
335 goto err_remove_config_dt;
330 336
331 if (!ret) { 337 ndev = platform_get_drvdata(pdev);
332 struct net_device *ndev = platform_get_drvdata(pdev); 338 stpriv = netdev_priv(ndev);
333 struct stmmac_priv *stpriv = netdev_priv(ndev);
334 339
335 /* The socfpga driver needs to control the stmmac reset to 340 /* The socfpga driver needs to control the stmmac reset to set the phy
336 * set the phy mode. Create a copy of the core reset handel 341 * mode. Create a copy of the core reset handle so it can be used by
337 * so it can be used by the driver later. 342 * the driver later.
338 */ 343 */
339 dwmac->stmmac_rst = stpriv->stmmac_rst; 344 dwmac->stmmac_rst = stpriv->stmmac_rst;
340 345
341 ret = socfpga_dwmac_set_phy_mode(dwmac); 346 ret = socfpga_dwmac_set_phy_mode(dwmac);
342 } 347 if (ret)
348 goto err_dvr_remove;
349
350 return 0;
351
352err_dvr_remove:
353 stmmac_dvr_remove(&pdev->dev);
354err_remove_config_dt:
355 stmmac_remove_config_dt(pdev, plat_dat);
343 356
344 return ret; 357 return ret;
345} 358}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 58c05acc2aab..060b98c37a85 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -345,13 +345,15 @@ static int sti_dwmac_probe(struct platform_device *pdev)
345 return PTR_ERR(plat_dat); 345 return PTR_ERR(plat_dat);
346 346
347 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 347 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
348 if (!dwmac) 348 if (!dwmac) {
349 return -ENOMEM; 349 ret = -ENOMEM;
350 goto err_remove_config_dt;
351 }
350 352
351 ret = sti_dwmac_parse_data(dwmac, pdev); 353 ret = sti_dwmac_parse_data(dwmac, pdev);
352 if (ret) { 354 if (ret) {
353 dev_err(&pdev->dev, "Unable to parse OF data\n"); 355 dev_err(&pdev->dev, "Unable to parse OF data\n");
354 return ret; 356 goto err_remove_config_dt;
355 } 357 }
356 358
357 dwmac->fix_retime_src = data->fix_retime_src; 359 dwmac->fix_retime_src = data->fix_retime_src;
@@ -363,9 +365,20 @@ static int sti_dwmac_probe(struct platform_device *pdev)
363 365
364 ret = sti_dwmac_init(pdev, plat_dat->bsp_priv); 366 ret = sti_dwmac_init(pdev, plat_dat->bsp_priv);
365 if (ret) 367 if (ret)
366 return ret; 368 goto err_remove_config_dt;
369
370 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
371 if (ret)
372 goto err_dwmac_exit;
373
374 return 0;
375
376err_dwmac_exit:
377 sti_dwmac_exit(pdev, plat_dat->bsp_priv);
378err_remove_config_dt:
379 stmmac_remove_config_dt(pdev, plat_dat);
367 380
368 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 381 return ret;
369} 382}
370 383
371static const struct sti_dwmac_of_data stih4xx_dwmac_data = { 384static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index e5a926b8bee7..61cb24810d10 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -107,24 +107,33 @@ static int stm32_dwmac_probe(struct platform_device *pdev)
107 return PTR_ERR(plat_dat); 107 return PTR_ERR(plat_dat);
108 108
109 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 109 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
110 if (!dwmac) 110 if (!dwmac) {
111 return -ENOMEM; 111 ret = -ENOMEM;
112 goto err_remove_config_dt;
113 }
112 114
113 ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); 115 ret = stm32_dwmac_parse_data(dwmac, &pdev->dev);
114 if (ret) { 116 if (ret) {
115 dev_err(&pdev->dev, "Unable to parse OF data\n"); 117 dev_err(&pdev->dev, "Unable to parse OF data\n");
116 return ret; 118 goto err_remove_config_dt;
117 } 119 }
118 120
119 plat_dat->bsp_priv = dwmac; 121 plat_dat->bsp_priv = dwmac;
120 122
121 ret = stm32_dwmac_init(plat_dat); 123 ret = stm32_dwmac_init(plat_dat);
122 if (ret) 124 if (ret)
123 return ret; 125 goto err_remove_config_dt;
124 126
125 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 127 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
126 if (ret) 128 if (ret)
127 stm32_dwmac_clk_disable(dwmac); 129 goto err_clk_disable;
130
131 return 0;
132
133err_clk_disable:
134 stm32_dwmac_clk_disable(dwmac);
135err_remove_config_dt:
136 stmmac_remove_config_dt(pdev, plat_dat);
128 137
129 return ret; 138 return ret;
130} 139}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index adff46375a32..d07520fb969e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -120,22 +120,27 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
120 return PTR_ERR(plat_dat); 120 return PTR_ERR(plat_dat);
121 121
122 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); 122 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
123 if (!gmac) 123 if (!gmac) {
124 return -ENOMEM; 124 ret = -ENOMEM;
125 goto err_remove_config_dt;
126 }
125 127
126 gmac->interface = of_get_phy_mode(dev->of_node); 128 gmac->interface = of_get_phy_mode(dev->of_node);
127 129
128 gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); 130 gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
129 if (IS_ERR(gmac->tx_clk)) { 131 if (IS_ERR(gmac->tx_clk)) {
130 dev_err(dev, "could not get tx clock\n"); 132 dev_err(dev, "could not get tx clock\n");
131 return PTR_ERR(gmac->tx_clk); 133 ret = PTR_ERR(gmac->tx_clk);
134 goto err_remove_config_dt;
132 } 135 }
133 136
134 /* Optional regulator for PHY */ 137 /* Optional regulator for PHY */
135 gmac->regulator = devm_regulator_get_optional(dev, "phy"); 138 gmac->regulator = devm_regulator_get_optional(dev, "phy");
136 if (IS_ERR(gmac->regulator)) { 139 if (IS_ERR(gmac->regulator)) {
137 if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) 140 if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) {
138 return -EPROBE_DEFER; 141 ret = -EPROBE_DEFER;
142 goto err_remove_config_dt;
143 }
139 dev_info(dev, "no regulator found\n"); 144 dev_info(dev, "no regulator found\n");
140 gmac->regulator = NULL; 145 gmac->regulator = NULL;
141 } 146 }
@@ -151,11 +156,18 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
151 156
152 ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv); 157 ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv);
153 if (ret) 158 if (ret)
154 return ret; 159 goto err_remove_config_dt;
155 160
156 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 161 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
157 if (ret) 162 if (ret)
158 sun7i_gmac_exit(pdev, plat_dat->bsp_priv); 163 goto err_gmac_exit;
164
165 return 0;
166
167err_gmac_exit:
168 sun7i_gmac_exit(pdev, plat_dat->bsp_priv);
169err_remove_config_dt:
170 stmmac_remove_config_dt(pdev, plat_dat);
159 171
160 return ret; 172 return ret;
161} 173}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
index 990746955216..f35385266fbf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -43,9 +43,11 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
43 if (axi->axi_xit_frm) 43 if (axi->axi_xit_frm)
44 value |= DMA_AXI_LPI_XIT_FRM; 44 value |= DMA_AXI_LPI_XIT_FRM;
45 45
46 value &= ~DMA_AXI_WR_OSR_LMT;
46 value |= (axi->axi_wr_osr_lmt & DMA_AXI_WR_OSR_LMT_MASK) << 47 value |= (axi->axi_wr_osr_lmt & DMA_AXI_WR_OSR_LMT_MASK) <<
47 DMA_AXI_WR_OSR_LMT_SHIFT; 48 DMA_AXI_WR_OSR_LMT_SHIFT;
48 49
50 value &= ~DMA_AXI_RD_OSR_LMT;
49 value |= (axi->axi_rd_osr_lmt & DMA_AXI_RD_OSR_LMT_MASK) << 51 value |= (axi->axi_rd_osr_lmt & DMA_AXI_RD_OSR_LMT_MASK) <<
50 DMA_AXI_RD_OSR_LMT_SHIFT; 52 DMA_AXI_RD_OSR_LMT_SHIFT;
51 53
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index 116151cd6a95..32bc2fc73cdc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -30,9 +30,11 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
30 if (axi->axi_xit_frm) 30 if (axi->axi_xit_frm)
31 value |= DMA_AXI_LPI_XIT_FRM; 31 value |= DMA_AXI_LPI_XIT_FRM;
32 32
33 value &= ~DMA_AXI_WR_OSR_LMT;
33 value |= (axi->axi_wr_osr_lmt & DMA_AXI_OSR_MAX) << 34 value |= (axi->axi_wr_osr_lmt & DMA_AXI_OSR_MAX) <<
34 DMA_AXI_WR_OSR_LMT_SHIFT; 35 DMA_AXI_WR_OSR_LMT_SHIFT;
35 36
37 value &= ~DMA_AXI_RD_OSR_LMT;
36 value |= (axi->axi_rd_osr_lmt & DMA_AXI_OSR_MAX) << 38 value |= (axi->axi_rd_osr_lmt & DMA_AXI_OSR_MAX) <<
37 DMA_AXI_RD_OSR_LMT_SHIFT; 39 DMA_AXI_RD_OSR_LMT_SHIFT;
38 40
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1f9ec02fa7f8..caf069a465f2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3416,7 +3416,6 @@ int stmmac_dvr_remove(struct device *dev)
3416 stmmac_set_mac(priv->ioaddr, false); 3416 stmmac_set_mac(priv->ioaddr, false);
3417 netif_carrier_off(ndev); 3417 netif_carrier_off(ndev);
3418 unregister_netdev(ndev); 3418 unregister_netdev(ndev);
3419 of_node_put(priv->plat->phy_node);
3420 if (priv->stmmac_rst) 3419 if (priv->stmmac_rst)
3421 reset_control_assert(priv->stmmac_rst); 3420 reset_control_assert(priv->stmmac_rst);
3422 clk_disable_unprepare(priv->pclk); 3421 clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 0a0d6a86f397..ac3d39c69509 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -126,8 +126,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
126 axi->axi_mb = of_property_read_bool(np, "snps,axi_mb"); 126 axi->axi_mb = of_property_read_bool(np, "snps,axi_mb");
127 axi->axi_rb = of_property_read_bool(np, "snps,axi_rb"); 127 axi->axi_rb = of_property_read_bool(np, "snps,axi_rb");
128 128
129 of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt); 129 if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt))
130 of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt); 130 axi->axi_wr_osr_lmt = 1;
131 if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt))
132 axi->axi_rd_osr_lmt = 1;
131 of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN); 133 of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
132 of_node_put(np); 134 of_node_put(np);
133 135
@@ -200,7 +202,6 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
200/** 202/**
201 * stmmac_probe_config_dt - parse device-tree driver parameters 203 * stmmac_probe_config_dt - parse device-tree driver parameters
202 * @pdev: platform_device structure 204 * @pdev: platform_device structure
203 * @plat: driver data platform structure
204 * @mac: MAC address to use 205 * @mac: MAC address to use
205 * Description: 206 * Description:
206 * this function is to read the driver parameters from device-tree and 207 * this function is to read the driver parameters from device-tree and
@@ -306,7 +307,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
306 dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), 307 dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
307 GFP_KERNEL); 308 GFP_KERNEL);
308 if (!dma_cfg) { 309 if (!dma_cfg) {
309 of_node_put(plat->phy_node); 310 stmmac_remove_config_dt(pdev, plat);
310 return ERR_PTR(-ENOMEM); 311 return ERR_PTR(-ENOMEM);
311 } 312 }
312 plat->dma_cfg = dma_cfg; 313 plat->dma_cfg = dma_cfg;
@@ -329,14 +330,37 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
329 330
330 return plat; 331 return plat;
331} 332}
333
334/**
335 * stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt()
336 * @pdev: platform_device structure
337 * @plat: driver data platform structure
338 *
339 * Release resources claimed by stmmac_probe_config_dt().
340 */
341void stmmac_remove_config_dt(struct platform_device *pdev,
342 struct plat_stmmacenet_data *plat)
343{
344 struct device_node *np = pdev->dev.of_node;
345
346 if (of_phy_is_fixed_link(np))
347 of_phy_deregister_fixed_link(np);
348 of_node_put(plat->phy_node);
349}
332#else 350#else
333struct plat_stmmacenet_data * 351struct plat_stmmacenet_data *
334stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) 352stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
335{ 353{
336 return ERR_PTR(-ENOSYS); 354 return ERR_PTR(-ENOSYS);
337} 355}
356
357void stmmac_remove_config_dt(struct platform_device *pdev,
358 struct plat_stmmacenet_data *plat)
359{
360}
338#endif /* CONFIG_OF */ 361#endif /* CONFIG_OF */
339EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); 362EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
363EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
340 364
341int stmmac_get_platform_resources(struct platform_device *pdev, 365int stmmac_get_platform_resources(struct platform_device *pdev,
342 struct stmmac_resources *stmmac_res) 366 struct stmmac_resources *stmmac_res)
@@ -392,10 +416,13 @@ int stmmac_pltfr_remove(struct platform_device *pdev)
392{ 416{
393 struct net_device *ndev = platform_get_drvdata(pdev); 417 struct net_device *ndev = platform_get_drvdata(pdev);
394 struct stmmac_priv *priv = netdev_priv(ndev); 418 struct stmmac_priv *priv = netdev_priv(ndev);
419 struct plat_stmmacenet_data *plat = priv->plat;
395 int ret = stmmac_dvr_remove(&pdev->dev); 420 int ret = stmmac_dvr_remove(&pdev->dev);
396 421
397 if (priv->plat->exit) 422 if (plat->exit)
398 priv->plat->exit(pdev, priv->plat->bsp_priv); 423 plat->exit(pdev, plat->bsp_priv);
424
425 stmmac_remove_config_dt(pdev, plat);
399 426
400 return ret; 427 return ret;
401} 428}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 64e147f53a9c..b72eb0de57b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -23,6 +23,8 @@
23 23
24struct plat_stmmacenet_data * 24struct plat_stmmacenet_data *
25stmmac_probe_config_dt(struct platform_device *pdev, const char **mac); 25stmmac_probe_config_dt(struct platform_device *pdev, const char **mac);
26void stmmac_remove_config_dt(struct platform_device *pdev,
27 struct plat_stmmacenet_data *plat);
26 28
27int stmmac_get_platform_resources(struct platform_device *pdev, 29int stmmac_get_platform_resources(struct platform_device *pdev,
28 struct stmmac_resources *stmmac_res); 30 struct stmmac_resources *stmmac_res);
diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 5eedac495077..97d64bfed465 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -33,7 +33,6 @@
33#include <linux/stat.h> 33#include <linux/stat.h>
34#include <linux/types.h> 34#include <linux/types.h>
35 35
36#include <linux/types.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/mm.h> 38#include <linux/mm.h>
@@ -43,7 +42,6 @@
43 42
44#include <linux/phy.h> 43#include <linux/phy.h>
45#include <linux/mii.h> 44#include <linux/mii.h>
46#include <linux/delay.h>
47#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
48#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
49 47
@@ -2883,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev)
2883 ret = of_get_phy_mode(lp->pdev->dev.of_node); 2881 ret = of_get_phy_mode(lp->pdev->dev.of_node);
2884 if (ret < 0) { 2882 if (ret < 0) {
2885 dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); 2883 dev_err(&lp->pdev->dev, "error in getting phy i/f\n");
2886 goto err_out_clk_dis_phy; 2884 goto err_out_deregister_fixed_link;
2887 } 2885 }
2888 2886
2889 lp->phy_interface = ret; 2887 lp->phy_interface = ret;
@@ -2891,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev)
2891 ret = dwceqos_mii_init(lp); 2889 ret = dwceqos_mii_init(lp);
2892 if (ret) { 2890 if (ret) {
2893 dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); 2891 dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n");
2894 goto err_out_clk_dis_phy; 2892 goto err_out_deregister_fixed_link;
2895 } 2893 }
2896 2894
2897 ret = dwceqos_mii_probe(ndev); 2895 ret = dwceqos_mii_probe(ndev);
2898 if (ret != 0) { 2896 if (ret != 0) {
2899 netdev_err(ndev, "mii_probe fail.\n"); 2897 netdev_err(ndev, "mii_probe fail.\n");
2900 ret = -ENXIO; 2898 ret = -ENXIO;
2901 goto err_out_clk_dis_phy; 2899 goto err_out_deregister_fixed_link;
2902 } 2900 }
2903 2901
2904 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); 2902 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0);
@@ -2916,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev)
2916 if (ret) { 2914 if (ret) {
2917 dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", 2915 dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n",
2918 ret); 2916 ret);
2919 goto err_out_clk_dis_phy; 2917 goto err_out_deregister_fixed_link;
2920 } 2918 }
2921 dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", 2919 dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n",
2922 pdev->id, ndev->base_addr, ndev->irq); 2920 pdev->id, ndev->base_addr, ndev->irq);
@@ -2926,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev)
2926 if (ret) { 2924 if (ret) {
2927 dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", 2925 dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n",
2928 ndev->irq, ret); 2926 ndev->irq, ret);
2929 goto err_out_clk_dis_phy; 2927 goto err_out_deregister_fixed_link;
2930 } 2928 }
2931 2929
2932 if (netif_msg_probe(lp)) 2930 if (netif_msg_probe(lp))
@@ -2937,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev)
2937 ret = register_netdev(ndev); 2935 ret = register_netdev(ndev);
2938 if (ret) { 2936 if (ret) {
2939 dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); 2937 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
2940 goto err_out_clk_dis_phy; 2938 goto err_out_deregister_fixed_link;
2941 } 2939 }
2942 2940
2943 return 0; 2941 return 0;
2944 2942
2943err_out_deregister_fixed_link:
2944 if (of_phy_is_fixed_link(pdev->dev.of_node))
2945 of_phy_deregister_fixed_link(pdev->dev.of_node);
2945err_out_clk_dis_phy: 2946err_out_clk_dis_phy:
2946 clk_disable_unprepare(lp->phy_ref_clk); 2947 clk_disable_unprepare(lp->phy_ref_clk);
2947err_out_clk_dis_aper: 2948err_out_clk_dis_aper:
@@ -2961,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev)
2961 if (ndev) { 2962 if (ndev) {
2962 lp = netdev_priv(ndev); 2963 lp = netdev_priv(ndev);
2963 2964
2964 if (ndev->phydev) 2965 if (ndev->phydev) {
2965 phy_disconnect(ndev->phydev); 2966 phy_disconnect(ndev->phydev);
2967 if (of_phy_is_fixed_link(pdev->dev.of_node))
2968 of_phy_deregister_fixed_link(pdev->dev.of_node);
2969 }
2966 mdiobus_unregister(lp->mii_bus); 2970 mdiobus_unregister(lp->mii_bus);
2967 mdiobus_free(lp->mii_bus); 2971 mdiobus_free(lp->mii_bus);
2968 2972
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index fa0cfda24fd9..28097be2ff28 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1113,6 +1113,7 @@ static int cpmac_probe(struct platform_device *pdev)
1113 if (!dev) 1113 if (!dev)
1114 return -ENOMEM; 1114 return -ENOMEM;
1115 1115
1116 SET_NETDEV_DEV(dev, &pdev->dev);
1116 platform_set_drvdata(pdev, dev); 1117 platform_set_drvdata(pdev, dev);
1117 priv = netdev_priv(dev); 1118 priv = netdev_priv(dev);
1118 1119
diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
index ba1e45ff6aae..18013645e76c 100644
--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
+++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
@@ -81,6 +81,7 @@ static void cpsw_gmii_sel_am3352(struct cpsw_phy_sel_priv *priv,
81 }; 81 };
82 82
83 mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6); 83 mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6);
84 mask |= BIT(slave + 4);
84 mode <<= slave * 2; 85 mode <<= slave * 2;
85 86
86 if (priv->rmii_clock_external) { 87 if (priv->rmii_clock_external) {
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 58947aae31c7..b9087b828eff 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2459,20 +2459,8 @@ static void cpsw_remove_dt(struct platform_device *pdev)
2459 if (strcmp(slave_node->name, "slave")) 2459 if (strcmp(slave_node->name, "slave"))
2460 continue; 2460 continue;
2461 2461
2462 if (of_phy_is_fixed_link(slave_node)) { 2462 if (of_phy_is_fixed_link(slave_node))
2463 struct phy_device *phydev; 2463 of_phy_deregister_fixed_link(slave_node);
2464
2465 phydev = of_phy_find_device(slave_node);
2466 if (phydev) {
2467 fixed_phy_unregister(phydev);
2468 /* Put references taken by
2469 * of_phy_find_device() and
2470 * of_phy_register_fixed_link().
2471 */
2472 phy_device_free(phydev);
2473 phy_device_free(phydev);
2474 }
2475 }
2476 2464
2477 of_node_put(slave_data->phy_node); 2465 of_node_put(slave_data->phy_node);
2478 2466
@@ -2942,6 +2930,8 @@ static int cpsw_resume(struct device *dev)
2942 /* Select default pin state */ 2930 /* Select default pin state */
2943 pinctrl_pm_select_default_state(dev); 2931 pinctrl_pm_select_default_state(dev);
2944 2932
2933 /* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */
2934 rtnl_lock();
2945 if (cpsw->data.dual_emac) { 2935 if (cpsw->data.dual_emac) {
2946 int i; 2936 int i;
2947 2937
@@ -2953,6 +2943,8 @@ static int cpsw_resume(struct device *dev)
2953 if (netif_running(ndev)) 2943 if (netif_running(ndev))
2954 cpsw_ndo_open(ndev); 2944 cpsw_ndo_open(ndev);
2955 } 2945 }
2946 rtnl_unlock();
2947
2956 return 0; 2948 return 0;
2957} 2949}
2958#endif 2950#endif
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 84fbe5714f8b..481c7bf0395b 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1767,6 +1767,7 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev,
1767 */ 1767 */
1768static int davinci_emac_probe(struct platform_device *pdev) 1768static int davinci_emac_probe(struct platform_device *pdev)
1769{ 1769{
1770 struct device_node *np = pdev->dev.of_node;
1770 int rc = 0; 1771 int rc = 0;
1771 struct resource *res, *res_ctrl; 1772 struct resource *res, *res_ctrl;
1772 struct net_device *ndev; 1773 struct net_device *ndev;
@@ -1805,7 +1806,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1805 if (!pdata) { 1806 if (!pdata) {
1806 dev_err(&pdev->dev, "no platform data\n"); 1807 dev_err(&pdev->dev, "no platform data\n");
1807 rc = -ENODEV; 1808 rc = -ENODEV;
1808 goto no_pdata; 1809 goto err_free_netdev;
1809 } 1810 }
1810 1811
1811 /* MAC addr and PHY mask , RMII enable info from platform_data */ 1812 /* MAC addr and PHY mask , RMII enable info from platform_data */
@@ -1941,6 +1942,10 @@ no_cpdma_chan:
1941 cpdma_chan_destroy(priv->rxchan); 1942 cpdma_chan_destroy(priv->rxchan);
1942 cpdma_ctlr_destroy(priv->dma); 1943 cpdma_ctlr_destroy(priv->dma);
1943no_pdata: 1944no_pdata:
1945 if (of_phy_is_fixed_link(np))
1946 of_phy_deregister_fixed_link(np);
1947 of_node_put(priv->phy_node);
1948err_free_netdev:
1944 free_netdev(ndev); 1949 free_netdev(ndev);
1945 return rc; 1950 return rc;
1946} 1951}
@@ -1956,6 +1961,7 @@ static int davinci_emac_remove(struct platform_device *pdev)
1956{ 1961{
1957 struct net_device *ndev = platform_get_drvdata(pdev); 1962 struct net_device *ndev = platform_get_drvdata(pdev);
1958 struct emac_priv *priv = netdev_priv(ndev); 1963 struct emac_priv *priv = netdev_priv(ndev);
1964 struct device_node *np = pdev->dev.of_node;
1959 1965
1960 dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n"); 1966 dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n");
1961 1967
@@ -1968,6 +1974,8 @@ static int davinci_emac_remove(struct platform_device *pdev)
1968 unregister_netdev(ndev); 1974 unregister_netdev(ndev);
1969 of_node_put(priv->phy_node); 1975 of_node_put(priv->phy_node);
1970 pm_runtime_disable(&pdev->dev); 1976 pm_runtime_disable(&pdev->dev);
1977 if (of_phy_is_fixed_link(np))
1978 of_phy_deregister_fixed_link(np);
1971 free_netdev(ndev); 1979 free_netdev(ndev);
1972 1980
1973 return 0; 1981 return 0;
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 42edd7b7902f..8b4822ad27cb 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -859,7 +859,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
859 struct geneve_dev *geneve = netdev_priv(dev); 859 struct geneve_dev *geneve = netdev_priv(dev);
860 struct geneve_sock *gs4; 860 struct geneve_sock *gs4;
861 struct rtable *rt = NULL; 861 struct rtable *rt = NULL;
862 const struct iphdr *iip; /* interior IP header */
863 int err = -EINVAL; 862 int err = -EINVAL;
864 struct flowi4 fl4; 863 struct flowi4 fl4;
865 __u8 tos, ttl; 864 __u8 tos, ttl;
@@ -890,8 +889,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
890 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 889 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
891 skb_reset_mac_header(skb); 890 skb_reset_mac_header(skb);
892 891
893 iip = ip_hdr(skb);
894
895 if (info) { 892 if (info) {
896 const struct ip_tunnel_key *key = &info->key; 893 const struct ip_tunnel_key *key = &info->key;
897 u8 *opts = NULL; 894 u8 *opts = NULL;
@@ -911,7 +908,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
911 if (unlikely(err)) 908 if (unlikely(err))
912 goto tx_error; 909 goto tx_error;
913 910
914 tos = ip_tunnel_ecn_encap(key->tos, iip, skb); 911 tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb);
915 ttl = key->ttl; 912 ttl = key->ttl;
916 df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; 913 df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
917 } else { 914 } else {
@@ -920,7 +917,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
920 if (unlikely(err)) 917 if (unlikely(err))
921 goto tx_error; 918 goto tx_error;
922 919
923 tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb); 920 tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb);
924 ttl = geneve->ttl; 921 ttl = geneve->ttl;
925 if (!ttl && IN_MULTICAST(ntohl(fl4.daddr))) 922 if (!ttl && IN_MULTICAST(ntohl(fl4.daddr)))
926 ttl = 1; 923 ttl = 1;
@@ -952,7 +949,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
952{ 949{
953 struct geneve_dev *geneve = netdev_priv(dev); 950 struct geneve_dev *geneve = netdev_priv(dev);
954 struct dst_entry *dst = NULL; 951 struct dst_entry *dst = NULL;
955 const struct iphdr *iip; /* interior IP header */
956 struct geneve_sock *gs6; 952 struct geneve_sock *gs6;
957 int err = -EINVAL; 953 int err = -EINVAL;
958 struct flowi6 fl6; 954 struct flowi6 fl6;
@@ -982,8 +978,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
982 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 978 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
983 skb_reset_mac_header(skb); 979 skb_reset_mac_header(skb);
984 980
985 iip = ip_hdr(skb);
986
987 if (info) { 981 if (info) {
988 const struct ip_tunnel_key *key = &info->key; 982 const struct ip_tunnel_key *key = &info->key;
989 u8 *opts = NULL; 983 u8 *opts = NULL;
@@ -1004,7 +998,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
1004 if (unlikely(err)) 998 if (unlikely(err))
1005 goto tx_error; 999 goto tx_error;
1006 1000
1007 prio = ip_tunnel_ecn_encap(key->tos, iip, skb); 1001 prio = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb);
1008 ttl = key->ttl; 1002 ttl = key->ttl;
1009 label = info->key.label; 1003 label = info->key.label;
1010 } else { 1004 } else {
@@ -1014,7 +1008,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
1014 goto tx_error; 1008 goto tx_error;
1015 1009
1016 prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel), 1010 prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel),
1017 iip, skb); 1011 ip_hdr(skb), skb);
1018 ttl = geneve->ttl; 1012 ttl = geneve->ttl;
1019 if (!ttl && ipv6_addr_is_multicast(&fl6.daddr)) 1013 if (!ttl && ipv6_addr_is_multicast(&fl6.daddr))
1020 ttl = 1; 1014 ttl = 1;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f6382150b16a..c9140c3aeb67 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -47,6 +47,10 @@
47 NETIF_F_TSO | \ 47 NETIF_F_TSO | \
48 NETIF_F_TSO6 | \ 48 NETIF_F_TSO6 | \
49 NETIF_F_HW_CSUM) 49 NETIF_F_HW_CSUM)
50
51/* Restrict GSO size to account for NVGRE */
52#define NETVSC_GSO_MAX_SIZE 62768
53
50static int ring_size = 128; 54static int ring_size = 128;
51module_param(ring_size, int, S_IRUGO); 55module_param(ring_size, int, S_IRUGO);
52MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); 56MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
@@ -1400,6 +1404,7 @@ static int netvsc_probe(struct hv_device *dev,
1400 nvdev = net_device_ctx->nvdev; 1404 nvdev = net_device_ctx->nvdev;
1401 netif_set_real_num_tx_queues(net, nvdev->num_chn); 1405 netif_set_real_num_tx_queues(net, nvdev->num_chn);
1402 netif_set_real_num_rx_queues(net, nvdev->num_chn); 1406 netif_set_real_num_rx_queues(net, nvdev->num_chn);
1407 netif_set_gso_max_size(net, NETVSC_GSO_MAX_SIZE);
1403 1408
1404 ret = register_netdev(net); 1409 ret = register_netdev(net);
1405 if (ret != 0) { 1410 if (ret != 0) {
diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
index 9fa7ac9f8e68..f355df7cf84a 100644
--- a/drivers/net/ieee802154/adf7242.c
+++ b/drivers/net/ieee802154/adf7242.c
@@ -20,7 +20,6 @@
20#include <linux/skbuff.h> 20#include <linux/skbuff.h>
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/delay.h>
24#include <linux/debugfs.h> 23#include <linux/debugfs.h>
25#include <linux/bitops.h> 24#include <linux/bitops.h>
26#include <linux/ieee802154.h> 25#include <linux/ieee802154.h>
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index f442eb366863..dfbc4ef6d507 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -497,6 +497,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
497 struct net_device *phy_dev; 497 struct net_device *phy_dev;
498 int err; 498 int err;
499 u16 mode = IPVLAN_MODE_L3; 499 u16 mode = IPVLAN_MODE_L3;
500 bool create = false;
500 501
501 if (!tb[IFLA_LINK]) 502 if (!tb[IFLA_LINK])
502 return -EINVAL; 503 return -EINVAL;
@@ -513,6 +514,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
513 err = ipvlan_port_create(phy_dev); 514 err = ipvlan_port_create(phy_dev);
514 if (err < 0) 515 if (err < 0)
515 return err; 516 return err;
517 create = true;
516 } 518 }
517 519
518 if (data && data[IFLA_IPVLAN_MODE]) 520 if (data && data[IFLA_IPVLAN_MODE])
@@ -536,22 +538,29 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
536 538
537 err = register_netdevice(dev); 539 err = register_netdevice(dev);
538 if (err < 0) 540 if (err < 0)
539 return err; 541 goto destroy_ipvlan_port;
540 542
541 err = netdev_upper_dev_link(phy_dev, dev); 543 err = netdev_upper_dev_link(phy_dev, dev);
542 if (err) { 544 if (err) {
543 unregister_netdevice(dev); 545 goto unregister_netdev;
544 return err;
545 } 546 }
546 err = ipvlan_set_port_mode(port, mode); 547 err = ipvlan_set_port_mode(port, mode);
547 if (err) { 548 if (err) {
548 unregister_netdevice(dev); 549 goto unlink_netdev;
549 return err;
550 } 550 }
551 551
552 list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans); 552 list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans);
553 netif_stacked_transfer_operstate(phy_dev, dev); 553 netif_stacked_transfer_operstate(phy_dev, dev);
554 return 0; 554 return 0;
555
556unlink_netdev:
557 netdev_upper_dev_unlink(phy_dev, dev);
558unregister_netdev:
559 unregister_netdevice(dev);
560destroy_ipvlan_port:
561 if (create)
562 ipvlan_port_destroy(phy_dev);
563 return err;
555} 564}
556 565
557static void ipvlan_link_delete(struct net_device *dev, struct list_head *head) 566static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index a198946bc54f..8716b8c07feb 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1723,6 +1723,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1723 /* Don't change this buffer size and allocation without doing 1723 /* Don't change this buffer size and allocation without doing
1724 * some heavy and complete testing. Don't ask why :-( 1724 * some heavy and complete testing. Don't ask why :-(
1725 * Jean II */ 1725 * Jean II */
1726 ret = -ENOMEM;
1726 self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); 1727 self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
1727 if (!self->speed_buff) 1728 if (!self->speed_buff)
1728 goto err_out_3; 1729 goto err_out_3;
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 4e3d2e7c697c..e8c3a8c32534 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
518 518
519 mtt = irda_get_mtt(skb); 519 mtt = irda_get_mtt(skb);
520 pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); 520 pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
521 if (mtt) 521 if (mtt > 1000)
522 mdelay(mtt/1000);
523 else if (mtt)
522 udelay(mtt); 524 udelay(mtt);
523 525
524 /* Enable DMA interrupt */ 526 /* Enable DMA interrupt */
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index d2d6f12a112f..26d6f0bbe14b 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -623,7 +623,8 @@ hash_add:
623 return 0; 623 return 0;
624 624
625clear_multi: 625clear_multi:
626 dev_set_allmulti(lowerdev, -1); 626 if (dev->flags & IFF_ALLMULTI)
627 dev_set_allmulti(lowerdev, -1);
627del_unicast: 628del_unicast:
628 dev_uc_del(lowerdev, dev->dev_addr); 629 dev_uc_del(lowerdev, dev->dev_addr);
629out: 630out:
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 070e3290aa6e..7869b0651576 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -491,7 +491,13 @@ static int macvtap_newlink(struct net *src_net,
491 /* Don't put anything that may fail after macvlan_common_newlink 491 /* Don't put anything that may fail after macvlan_common_newlink
492 * because we can't undo what it does. 492 * because we can't undo what it does.
493 */ 493 */
494 return macvlan_common_newlink(src_net, dev, tb, data); 494 err = macvlan_common_newlink(src_net, dev, tb, data);
495 if (err) {
496 netdev_rx_handler_unregister(dev);
497 return err;
498 }
499
500 return 0;
495} 501}
496 502
497static void macvtap_dellink(struct net_device *dev, 503static void macvtap_dellink(struct net_device *dev,
@@ -736,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
736 742
737 if (zerocopy) 743 if (zerocopy)
738 err = zerocopy_sg_from_iter(skb, from); 744 err = zerocopy_sg_from_iter(skb, from);
739 else { 745 else
740 err = skb_copy_datagram_from_iter(skb, 0, from, len); 746 err = skb_copy_datagram_from_iter(skb, 0, from, len);
741 if (!err && m && m->msg_control) {
742 struct ubuf_info *uarg = m->msg_control;
743 uarg->callback(uarg, false);
744 }
745 }
746 747
747 if (err) 748 if (err)
748 goto err_kfree; 749 goto err_kfree;
@@ -773,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
773 skb_shinfo(skb)->destructor_arg = m->msg_control; 774 skb_shinfo(skb)->destructor_arg = m->msg_control;
774 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 775 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
775 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; 776 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
777 } else if (m && m->msg_control) {
778 struct ubuf_info *uarg = m->msg_control;
779 uarg->callback(uarg, false);
776 } 780 }
781
777 if (vlan) { 782 if (vlan) {
778 skb->dev = vlan->dev; 783 skb->dev = vlan->dev;
779 dev_queue_xmit(skb); 784 dev_queue_xmit(skb);
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 081df68d2ce1..ea92d524d5a8 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -318,12 +318,12 @@ static int ksz8041_config_init(struct phy_device *phydev)
318 /* Limit supported and advertised modes in fiber mode */ 318 /* Limit supported and advertised modes in fiber mode */
319 if (of_property_read_bool(of_node, "micrel,fiber-mode")) { 319 if (of_property_read_bool(of_node, "micrel,fiber-mode")) {
320 phydev->dev_flags |= MICREL_PHY_FXEN; 320 phydev->dev_flags |= MICREL_PHY_FXEN;
321 phydev->supported &= SUPPORTED_FIBRE | 321 phydev->supported &= SUPPORTED_100baseT_Full |
322 SUPPORTED_100baseT_Full |
323 SUPPORTED_100baseT_Half; 322 SUPPORTED_100baseT_Half;
324 phydev->advertising &= ADVERTISED_FIBRE | 323 phydev->supported |= SUPPORTED_FIBRE;
325 ADVERTISED_100baseT_Full | 324 phydev->advertising &= ADVERTISED_100baseT_Full |
326 ADVERTISED_100baseT_Half; 325 ADVERTISED_100baseT_Half;
326 phydev->advertising |= ADVERTISED_FIBRE;
327 phydev->autoneg = AUTONEG_DISABLE; 327 phydev->autoneg = AUTONEG_DISABLE;
328 } 328 }
329 329
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1a4bf8acad78..c4ceb082e970 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -857,11 +857,17 @@ EXPORT_SYMBOL(phy_attached_print);
857int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, 857int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
858 u32 flags, phy_interface_t interface) 858 u32 flags, phy_interface_t interface)
859{ 859{
860 struct module *ndev_owner = dev->dev.parent->driver->owner;
860 struct mii_bus *bus = phydev->mdio.bus; 861 struct mii_bus *bus = phydev->mdio.bus;
861 struct device *d = &phydev->mdio.dev; 862 struct device *d = &phydev->mdio.dev;
862 int err; 863 int err;
863 864
864 if (!try_module_get(bus->owner)) { 865 /* For Ethernet device drivers that register their own MDIO bus, we
866 * will have bus->owner match ndev_mod, so we do not want to increment
867 * our own module->refcnt here, otherwise we would not be able to
868 * unload later on.
869 */
870 if (ndev_owner != bus->owner && !try_module_get(bus->owner)) {
865 dev_err(&dev->dev, "failed to get the bus module\n"); 871 dev_err(&dev->dev, "failed to get the bus module\n");
866 return -EIO; 872 return -EIO;
867 } 873 }
@@ -921,7 +927,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
921 927
922error: 928error:
923 put_device(d); 929 put_device(d);
924 module_put(bus->owner); 930 if (ndev_owner != bus->owner)
931 module_put(bus->owner);
925 return err; 932 return err;
926} 933}
927EXPORT_SYMBOL(phy_attach_direct); 934EXPORT_SYMBOL(phy_attach_direct);
@@ -971,6 +978,8 @@ EXPORT_SYMBOL(phy_attach);
971 */ 978 */
972void phy_detach(struct phy_device *phydev) 979void phy_detach(struct phy_device *phydev)
973{ 980{
981 struct net_device *dev = phydev->attached_dev;
982 struct module *ndev_owner = dev->dev.parent->driver->owner;
974 struct mii_bus *bus; 983 struct mii_bus *bus;
975 int i; 984 int i;
976 985
@@ -998,7 +1007,8 @@ void phy_detach(struct phy_device *phydev)
998 bus = phydev->mdio.bus; 1007 bus = phydev->mdio.bus;
999 1008
1000 put_device(&phydev->mdio.dev); 1009 put_device(&phydev->mdio.dev);
1001 module_put(bus->owner); 1010 if (ndev_owner != bus->owner)
1011 module_put(bus->owner);
1002} 1012}
1003EXPORT_SYMBOL(phy_detach); 1013EXPORT_SYMBOL(phy_detach);
1004 1014
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index aadd6e9f54ad..9cbe645e3d89 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev)
102 if (ret < 0) 102 if (ret < 0)
103 return ret; 103 return ret;
104 104
105 if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { 105 phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
106 /* enable TXDLY */ 106 reg = phy_read(phydev, 0x11);
107 phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); 107
108 reg = phy_read(phydev, 0x11); 108 /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */
109 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
110 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
109 reg |= RTL8211F_TX_DELAY; 111 reg |= RTL8211F_TX_DELAY;
110 phy_write(phydev, 0x11, reg); 112 else
111 /* restore to default page 0 */ 113 reg &= ~RTL8211F_TX_DELAY;
112 phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); 114
113 } 115 phy_write(phydev, 0x11, reg);
116 /* restore to default page 0 */
117 phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
114 118
115 return 0; 119 return 0;
116} 120}
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8093e39ae263..db6acecabeaa 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1246 1246
1247 if (zerocopy) 1247 if (zerocopy)
1248 err = zerocopy_sg_from_iter(skb, from); 1248 err = zerocopy_sg_from_iter(skb, from);
1249 else { 1249 else
1250 err = skb_copy_datagram_from_iter(skb, 0, from, len); 1250 err = skb_copy_datagram_from_iter(skb, 0, from, len);
1251 if (!err && msg_control) {
1252 struct ubuf_info *uarg = msg_control;
1253 uarg->callback(uarg, false);
1254 }
1255 }
1256 1251
1257 if (err) { 1252 if (err) {
1258 this_cpu_inc(tun->pcpu_stats->rx_dropped); 1253 this_cpu_inc(tun->pcpu_stats->rx_dropped);
@@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1298 skb_shinfo(skb)->destructor_arg = msg_control; 1293 skb_shinfo(skb)->destructor_arg = msg_control;
1299 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 1294 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
1300 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; 1295 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
1296 } else if (msg_control) {
1297 struct ubuf_info *uarg = msg_control;
1298 uarg->callback(uarg, false);
1301 } 1299 }
1302 1300
1303 skb_reset_network_header(skb); 1301 skb_reset_network_header(skb);
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index cce24950a0ab..dc7b6392e75a 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -603,12 +603,12 @@ static void ax88772_suspend(struct usbnet *dev)
603 u16 medium; 603 u16 medium;
604 604
605 /* Stop MAC operation */ 605 /* Stop MAC operation */
606 medium = asix_read_medium_status(dev, 0); 606 medium = asix_read_medium_status(dev, 1);
607 medium &= ~AX_MEDIUM_RE; 607 medium &= ~AX_MEDIUM_RE;
608 asix_write_medium_mode(dev, medium, 0); 608 asix_write_medium_mode(dev, medium, 1);
609 609
610 netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n", 610 netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n",
611 asix_read_medium_status(dev, 0)); 611 asix_read_medium_status(dev, 1));
612 612
613 /* Preserve BMCR for restoring */ 613 /* Preserve BMCR for restoring */
614 priv->presvd_phy_bmcr = 614 priv->presvd_phy_bmcr =
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index c47ec0a04c8e..dd623f674487 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -388,12 +388,6 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
388 case USB_CDC_NOTIFY_NETWORK_CONNECTION: 388 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
389 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", 389 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
390 event->wValue ? "on" : "off"); 390 event->wValue ? "on" : "off");
391
392 /* Work-around for devices with broken off-notifications */
393 if (event->wValue &&
394 !test_bit(__LINK_STATE_NOCARRIER, &dev->net->state))
395 usbnet_link_change(dev, 0, 0);
396
397 usbnet_link_change(dev, !!event->wValue, 0); 391 usbnet_link_change(dev, !!event->wValue, 0);
398 break; 392 break;
399 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ 393 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
@@ -466,6 +460,36 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
466 return 1; 460 return 1;
467} 461}
468 462
463/* Ensure correct link state
464 *
465 * Some devices (ZTE MF823/831/910) export two carrier on notifications when
466 * connected. This causes the link state to be incorrect. Work around this by
467 * always setting the state to off, then on.
468 */
469void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
470{
471 struct usb_cdc_notification *event;
472
473 if (urb->actual_length < sizeof(*event))
474 return;
475
476 event = urb->transfer_buffer;
477
478 if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) {
479 usbnet_cdc_status(dev, urb);
480 return;
481 }
482
483 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
484 event->wValue ? "on" : "off");
485
486 if (event->wValue &&
487 netif_carrier_ok(dev->net))
488 netif_carrier_off(dev->net);
489
490 usbnet_link_change(dev, !!event->wValue, 0);
491}
492
469static const struct driver_info cdc_info = { 493static const struct driver_info cdc_info = {
470 .description = "CDC Ethernet Device", 494 .description = "CDC Ethernet Device",
471 .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 495 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -481,7 +505,7 @@ static const struct driver_info zte_cdc_info = {
481 .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 505 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
482 .bind = usbnet_cdc_zte_bind, 506 .bind = usbnet_cdc_zte_bind,
483 .unbind = usbnet_cdc_unbind, 507 .unbind = usbnet_cdc_unbind,
484 .status = usbnet_cdc_status, 508 .status = usbnet_cdc_zte_status,
485 .set_rx_mode = usbnet_cdc_update_filter, 509 .set_rx_mode = usbnet_cdc_update_filter,
486 .manage_power = usbnet_manage_power, 510 .manage_power = usbnet_manage_power,
487 .rx_fixup = usbnet_cdc_zte_rx_fixup, 511 .rx_fixup = usbnet_cdc_zte_rx_fixup,
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 96a5028621c8..3a98f3762a4c 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -602,6 +602,21 @@ static const struct driver_info cdc_mbim_info_ndp_to_end = {
602 .data = CDC_NCM_FLAG_NDP_TO_END, 602 .data = CDC_NCM_FLAG_NDP_TO_END,
603}; 603};
604 604
605/* Some modems (e.g. Telit LE922A6) do not work properly with altsetting
606 * toggle done in cdc_ncm_bind_common. CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE
607 * flag is used to avoid this procedure.
608 */
609static const struct driver_info cdc_mbim_info_avoid_altsetting_toggle = {
610 .description = "CDC MBIM",
611 .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
612 .bind = cdc_mbim_bind,
613 .unbind = cdc_mbim_unbind,
614 .manage_power = cdc_mbim_manage_power,
615 .rx_fixup = cdc_mbim_rx_fixup,
616 .tx_fixup = cdc_mbim_tx_fixup,
617 .data = CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE,
618};
619
605static const struct usb_device_id mbim_devs[] = { 620static const struct usb_device_id mbim_devs[] = {
606 /* This duplicate NCM entry is intentional. MBIM devices can 621 /* This duplicate NCM entry is intentional. MBIM devices can
607 * be disguised as NCM by default, and this is necessary to 622 * be disguised as NCM by default, and this is necessary to
@@ -626,6 +641,12 @@ static const struct usb_device_id mbim_devs[] = {
626 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 641 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
627 .driver_info = (unsigned long)&cdc_mbim_info_ndp_to_end, 642 .driver_info = (unsigned long)&cdc_mbim_info_ndp_to_end,
628 }, 643 },
644
645 /* Telit LE922A6 in MBIM composition */
646 { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1041, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
647 .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
648 },
649
629 /* default entry */ 650 /* default entry */
630 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 651 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
631 .driver_info = (unsigned long)&cdc_mbim_info_zlp, 652 .driver_info = (unsigned long)&cdc_mbim_info_zlp,
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 877c9516e781..afbfc0f656f3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -839,11 +839,18 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
839 839
840 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; 840 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
841 841
842 /* Device-specific flags */
843 ctx->drvflags = drvflags;
844
842 /* Reset data interface. Some devices will not reset properly 845 /* Reset data interface. Some devices will not reset properly
843 * unless they are configured first. Toggle the altsetting to 846 * unless they are configured first. Toggle the altsetting to
844 * force a reset 847 * force a reset.
848 * Some other devices do not work properly with this procedure
849 * that can be avoided using quirk CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE
845 */ 850 */
846 usb_set_interface(dev->udev, iface_no, data_altsetting); 851 if (!(ctx->drvflags & CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE))
852 usb_set_interface(dev->udev, iface_no, data_altsetting);
853
847 temp = usb_set_interface(dev->udev, iface_no, 0); 854 temp = usb_set_interface(dev->udev, iface_no, 0);
848 if (temp) { 855 if (temp) {
849 dev_dbg(&intf->dev, "set interface failed\n"); 856 dev_dbg(&intf->dev, "set interface failed\n");
@@ -890,9 +897,6 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
890 /* finish setting up the device specific data */ 897 /* finish setting up the device specific data */
891 cdc_ncm_setup(dev); 898 cdc_ncm_setup(dev);
892 899
893 /* Device-specific flags */
894 ctx->drvflags = drvflags;
895
896 /* Allocate the delayed NDP if needed. */ 900 /* Allocate the delayed NDP if needed. */
897 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) { 901 if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
898 ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL); 902 ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index db558b8b32fe..f33460cec79f 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3395,6 +3395,7 @@ static int lan78xx_probe(struct usb_interface *intf,
3395 if (buf) { 3395 if (buf) {
3396 dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL); 3396 dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL);
3397 if (!dev->urb_intr) { 3397 if (!dev->urb_intr) {
3398 ret = -ENOMEM;
3398 kfree(buf); 3399 kfree(buf);
3399 goto out3; 3400 goto out3;
3400 } else { 3401 } else {
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 3ff76c6db4f6..6fe1cdb0174f 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -894,6 +894,7 @@ static const struct usb_device_id products[] = {
894 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ 894 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
895 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ 895 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
896 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ 896 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
897 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */
897 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 898 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
898 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ 899 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
899 {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ 900 {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7276d5a95bd0..cbf1c613c67a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -969,12 +969,17 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
969 struct virtnet_info *vi = netdev_priv(dev); 969 struct virtnet_info *vi = netdev_priv(dev);
970 struct virtio_device *vdev = vi->vdev; 970 struct virtio_device *vdev = vi->vdev;
971 int ret; 971 int ret;
972 struct sockaddr *addr = p; 972 struct sockaddr *addr;
973 struct scatterlist sg; 973 struct scatterlist sg;
974 974
975 ret = eth_prepare_mac_addr_change(dev, p); 975 addr = kmalloc(sizeof(*addr), GFP_KERNEL);
976 if (!addr)
977 return -ENOMEM;
978 memcpy(addr, p, sizeof(*addr));
979
980 ret = eth_prepare_mac_addr_change(dev, addr);
976 if (ret) 981 if (ret)
977 return ret; 982 goto out;
978 983
979 if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR)) { 984 if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
980 sg_init_one(&sg, addr->sa_data, dev->addr_len); 985 sg_init_one(&sg, addr->sa_data, dev->addr_len);
@@ -982,7 +987,8 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
982 VIRTIO_NET_CTRL_MAC_ADDR_SET, &sg)) { 987 VIRTIO_NET_CTRL_MAC_ADDR_SET, &sg)) {
983 dev_warn(&vdev->dev, 988 dev_warn(&vdev->dev,
984 "Failed to set mac address by vq command.\n"); 989 "Failed to set mac address by vq command.\n");
985 return -EINVAL; 990 ret = -EINVAL;
991 goto out;
986 } 992 }
987 } else if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC) && 993 } else if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC) &&
988 !virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { 994 !virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
@@ -996,8 +1002,11 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
996 } 1002 }
997 1003
998 eth_commit_mac_addr_change(dev, p); 1004 eth_commit_mac_addr_change(dev, p);
1005 ret = 0;
999 1006
1000 return 0; 1007out:
1008 kfree(addr);
1009 return ret;
1001} 1010}
1002 1011
1003static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev, 1012static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev,
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 24532cdebb00..2ba01ca02c9c 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -611,6 +611,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
611 struct vxlan_rdst *rd = NULL; 611 struct vxlan_rdst *rd = NULL;
612 struct vxlan_fdb *f; 612 struct vxlan_fdb *f;
613 int notify = 0; 613 int notify = 0;
614 int rc;
614 615
615 f = __vxlan_find_mac(vxlan, mac); 616 f = __vxlan_find_mac(vxlan, mac);
616 if (f) { 617 if (f) {
@@ -641,8 +642,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
641 if ((flags & NLM_F_APPEND) && 642 if ((flags & NLM_F_APPEND) &&
642 (is_multicast_ether_addr(f->eth_addr) || 643 (is_multicast_ether_addr(f->eth_addr) ||
643 is_zero_ether_addr(f->eth_addr))) { 644 is_zero_ether_addr(f->eth_addr))) {
644 int rc = vxlan_fdb_append(f, ip, port, vni, ifindex, 645 rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
645 &rd);
646 646
647 if (rc < 0) 647 if (rc < 0)
648 return rc; 648 return rc;
@@ -673,7 +673,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
673 INIT_LIST_HEAD(&f->remotes); 673 INIT_LIST_HEAD(&f->remotes);
674 memcpy(f->eth_addr, mac, ETH_ALEN); 674 memcpy(f->eth_addr, mac, ETH_ALEN);
675 675
676 vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); 676 rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
677 if (rc < 0) {
678 kfree(f);
679 return rc;
680 }
677 681
678 ++vxlan->addrcnt; 682 ++vxlan->addrcnt;
679 hlist_add_head_rcu(&f->hlist, 683 hlist_add_head_rcu(&f->hlist,
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 39ce76ad00bc..16241d21727b 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -2222,8 +2222,9 @@ done:
2222 is_scanning_required = 1; 2222 is_scanning_required = 1;
2223 } else { 2223 } else {
2224 mwifiex_dbg(priv->adapter, MSG, 2224 mwifiex_dbg(priv->adapter, MSG,
2225 "info: trying to associate to '%s' bssid %pM\n", 2225 "info: trying to associate to '%.*s' bssid %pM\n",
2226 (char *)req_ssid.ssid, bss->bssid); 2226 req_ssid.ssid_len, (char *)req_ssid.ssid,
2227 bss->bssid);
2227 memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); 2228 memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN);
2228 break; 2229 break;
2229 } 2230 }
@@ -2283,8 +2284,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
2283 } 2284 }
2284 2285
2285 mwifiex_dbg(adapter, INFO, 2286 mwifiex_dbg(adapter, INFO,
2286 "info: Trying to associate to %s and bssid %pM\n", 2287 "info: Trying to associate to %.*s and bssid %pM\n",
2287 (char *)sme->ssid, sme->bssid); 2288 (int)sme->ssid_len, (char *)sme->ssid, sme->bssid);
2288 2289
2289 if (!mwifiex_stop_bg_scan(priv)) 2290 if (!mwifiex_stop_bg_scan(priv))
2290 cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy); 2291 cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
@@ -2417,8 +2418,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2417 } 2418 }
2418 2419
2419 mwifiex_dbg(priv->adapter, MSG, 2420 mwifiex_dbg(priv->adapter, MSG,
2420 "info: trying to join to %s and bssid %pM\n", 2421 "info: trying to join to %.*s and bssid %pM\n",
2421 (char *)params->ssid, params->bssid); 2422 params->ssid_len, (char *)params->ssid, params->bssid);
2422 2423
2423 mwifiex_set_ibss_params(priv, params); 2424 mwifiex_set_ibss_params(priv, params);
2424 2425
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b6949a8778..23d4a1728cdf 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -715,7 +715,7 @@ EXPORT_SYMBOL_GPL(nd_cmd_in_size);
715 715
716u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd, 716u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
717 const struct nd_cmd_desc *desc, int idx, const u32 *in_field, 717 const struct nd_cmd_desc *desc, int idx, const u32 *in_field,
718 const u32 *out_field) 718 const u32 *out_field, unsigned long remainder)
719{ 719{
720 if (idx >= desc->out_num) 720 if (idx >= desc->out_num)
721 return UINT_MAX; 721 return UINT_MAX;
@@ -727,9 +727,24 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
727 return in_field[1]; 727 return in_field[1];
728 else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2) 728 else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2)
729 return out_field[1]; 729 return out_field[1];
730 else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2) 730 else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2) {
731 return out_field[1] - 8; 731 /*
732 else if (cmd == ND_CMD_CALL) { 732 * Per table 9-276 ARS Data in ACPI 6.1, out_field[1] is
733 * "Size of Output Buffer in bytes, including this
734 * field."
735 */
736 if (out_field[1] < 4)
737 return 0;
738 /*
739 * ACPI 6.1 is ambiguous if 'status' is included in the
740 * output size. If we encounter an output size that
741 * overshoots the remainder by 4 bytes, assume it was
742 * including 'status'.
743 */
744 if (out_field[1] - 8 == remainder)
745 return remainder;
746 return out_field[1] - 4;
747 } else if (cmd == ND_CMD_CALL) {
733 struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *) in_field; 748 struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *) in_field;
734 749
735 return pkg->nd_size_out; 750 return pkg->nd_size_out;
@@ -876,7 +891,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
876 /* process an output envelope */ 891 /* process an output envelope */
877 for (i = 0; i < desc->out_num; i++) { 892 for (i = 0; i < desc->out_num; i++) {
878 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, 893 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i,
879 (u32 *) in_env, (u32 *) out_env); 894 (u32 *) in_env, (u32 *) out_env, 0);
880 u32 copy; 895 u32 copy;
881 896
882 if (out_size == UINT_MAX) { 897 if (out_size == UINT_MAX) {
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 5a3145a02547..262281bd68fa 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -490,3 +490,18 @@ int of_phy_register_fixed_link(struct device_node *np)
490 return -ENODEV; 490 return -ENODEV;
491} 491}
492EXPORT_SYMBOL(of_phy_register_fixed_link); 492EXPORT_SYMBOL(of_phy_register_fixed_link);
493
494void of_phy_deregister_fixed_link(struct device_node *np)
495{
496 struct phy_device *phydev;
497
498 phydev = of_phy_find_device(np);
499 if (!phydev)
500 return;
501
502 fixed_phy_unregister(phydev);
503
504 put_device(&phydev->mdio.dev); /* of_phy_find_device() */
505 phy_device_free(phydev); /* fixed_phy_register() */
506}
507EXPORT_SYMBOL(of_phy_deregister_fixed_link);
diff --git a/drivers/pci/host/pcie-designware-plat.c b/drivers/pci/host/pcie-designware-plat.c
index 8df6312ed300..1a02038c4640 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 <jpmpinto@gmail.com> 6 * Authors: Joao Pinto <Joao.Pinto@synopsys.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/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index db553dc22c8e..2b6a59266689 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -307,20 +307,6 @@ out:
307 return 0; 307 return 0;
308} 308}
309 309
310static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
311{
312 while (1) {
313 if (!pci_is_pcie(dev))
314 break;
315 if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
316 return dev;
317 if (!dev->bus->self)
318 break;
319 dev = dev->bus->self;
320 }
321 return NULL;
322}
323
324static int find_aer_device_iter(struct device *device, void *data) 310static int find_aer_device_iter(struct device *device, void *data)
325{ 311{
326 struct pcie_device **result = data; 312 struct pcie_device **result = data;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ab002671fa60..104c46d53121 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1439,6 +1439,21 @@ static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
1439 dev_warn(&dev->dev, "PCI-X settings not supported\n"); 1439 dev_warn(&dev->dev, "PCI-X settings not supported\n");
1440} 1440}
1441 1441
1442static bool pcie_root_rcb_set(struct pci_dev *dev)
1443{
1444 struct pci_dev *rp = pcie_find_root_port(dev);
1445 u16 lnkctl;
1446
1447 if (!rp)
1448 return false;
1449
1450 pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
1451 if (lnkctl & PCI_EXP_LNKCTL_RCB)
1452 return true;
1453
1454 return false;
1455}
1456
1442static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) 1457static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
1443{ 1458{
1444 int pos; 1459 int pos;
@@ -1468,9 +1483,20 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
1468 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); 1483 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
1469 1484
1470 /* Initialize Link Control Register */ 1485 /* Initialize Link Control Register */
1471 if (pcie_cap_has_lnkctl(dev)) 1486 if (pcie_cap_has_lnkctl(dev)) {
1487
1488 /*
1489 * If the Root Port supports Read Completion Boundary of
1490 * 128, set RCB to 128. Otherwise, clear it.
1491 */
1492 hpp->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB;
1493 hpp->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB;
1494 if (pcie_root_rcb_set(dev))
1495 hpp->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB;
1496
1472 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, 1497 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
1473 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); 1498 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
1499 }
1474 1500
1475 /* Find Advanced Error Reporting Enhanced Capability */ 1501 /* Find Advanced Error Reporting Enhanced Capability */
1476 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 1502 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 87e6334eab93..547ca7b3f098 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -459,8 +459,6 @@ static int twl4030_phy_power_off(struct phy *phy)
459 struct twl4030_usb *twl = phy_get_drvdata(phy); 459 struct twl4030_usb *twl = phy_get_drvdata(phy);
460 460
461 dev_dbg(twl->dev, "%s\n", __func__); 461 dev_dbg(twl->dev, "%s\n", __func__);
462 pm_runtime_mark_last_busy(twl->dev);
463 pm_runtime_put_autosuspend(twl->dev);
464 462
465 return 0; 463 return 0;
466} 464}
@@ -472,6 +470,8 @@ static int twl4030_phy_power_on(struct phy *phy)
472 dev_dbg(twl->dev, "%s\n", __func__); 470 dev_dbg(twl->dev, "%s\n", __func__);
473 pm_runtime_get_sync(twl->dev); 471 pm_runtime_get_sync(twl->dev);
474 schedule_delayed_work(&twl->id_workaround_work, HZ); 472 schedule_delayed_work(&twl->id_workaround_work, HZ);
473 pm_runtime_mark_last_busy(twl->dev);
474 pm_runtime_put_autosuspend(twl->dev);
475 475
476 return 0; 476 return 0;
477} 477}
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 381871b2bb46..9d5bd7d5c610 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -474,6 +474,7 @@ static int meson_pwm_probe(struct platform_device *pdev)
474 if (IS_ERR(meson->base)) 474 if (IS_ERR(meson->base))
475 return PTR_ERR(meson->base); 475 return PTR_ERR(meson->base);
476 476
477 spin_lock_init(&meson->lock);
477 meson->chip.dev = &pdev->dev; 478 meson->chip.dev = &pdev->dev;
478 meson->chip.ops = &meson_pwm_ops; 479 meson->chip.ops = &meson_pwm_ops;
479 meson->chip.base = -1; 480 meson->chip.base = -1;
diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 0296d8178ae2..a813239300c3 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -425,6 +425,8 @@ void pwmchip_sysfs_unexport_children(struct pwm_chip *chip)
425 if (test_bit(PWMF_EXPORTED, &pwm->flags)) 425 if (test_bit(PWMF_EXPORTED, &pwm->flags))
426 pwm_unexport_child(parent, pwm); 426 pwm_unexport_child(parent, pwm);
427 } 427 }
428
429 put_device(parent);
428} 430}
429 431
430static int __init pwm_sysfs_init(void) 432static int __init pwm_sysfs_init(void)
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index aebc4ddb3060..ac05317bba7f 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1083,7 +1083,7 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba)
1083 nonemb_cmd = &phba->boot_struct.nonemb_cmd; 1083 nonemb_cmd = &phba->boot_struct.nonemb_cmd;
1084 nonemb_cmd->size = sizeof(*resp); 1084 nonemb_cmd->size = sizeof(*resp);
1085 nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev, 1085 nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
1086 sizeof(nonemb_cmd->size), 1086 nonemb_cmd->size,
1087 &nonemb_cmd->dma); 1087 &nonemb_cmd->dma);
1088 if (!nonemb_cmd->va) { 1088 if (!nonemb_cmd->va) {
1089 mutex_unlock(&ctrl->mbox_lock); 1089 mutex_unlock(&ctrl->mbox_lock);
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index d007ec18179a..a1d6ab76a514 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2009,7 +2009,7 @@ static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h,
2009 2009
2010static int hpsa_slave_alloc(struct scsi_device *sdev) 2010static int hpsa_slave_alloc(struct scsi_device *sdev)
2011{ 2011{
2012 struct hpsa_scsi_dev_t *sd; 2012 struct hpsa_scsi_dev_t *sd = NULL;
2013 unsigned long flags; 2013 unsigned long flags;
2014 struct ctlr_info *h; 2014 struct ctlr_info *h;
2015 2015
@@ -2026,7 +2026,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
2026 sd->target = sdev_id(sdev); 2026 sd->target = sdev_id(sdev);
2027 sd->lun = sdev->lun; 2027 sd->lun = sdev->lun;
2028 } 2028 }
2029 } else 2029 }
2030 if (!sd)
2030 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), 2031 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
2031 sdev_id(sdev), sdev->lun); 2032 sdev_id(sdev), sdev->lun);
2032 2033
@@ -3840,6 +3841,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
3840 sizeof(this_device->vendor)); 3841 sizeof(this_device->vendor));
3841 memcpy(this_device->model, &inq_buff[16], 3842 memcpy(this_device->model, &inq_buff[16],
3842 sizeof(this_device->model)); 3843 sizeof(this_device->model));
3844 this_device->rev = inq_buff[2];
3843 memset(this_device->device_id, 0, 3845 memset(this_device->device_id, 0,
3844 sizeof(this_device->device_id)); 3846 sizeof(this_device->device_id));
3845 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, 3847 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
@@ -3929,10 +3931,14 @@ static void figure_bus_target_lun(struct ctlr_info *h,
3929 3931
3930 if (!is_logical_dev_addr_mode(lunaddrbytes)) { 3932 if (!is_logical_dev_addr_mode(lunaddrbytes)) {
3931 /* physical device, target and lun filled in later */ 3933 /* physical device, target and lun filled in later */
3932 if (is_hba_lunid(lunaddrbytes)) 3934 if (is_hba_lunid(lunaddrbytes)) {
3935 int bus = HPSA_HBA_BUS;
3936
3937 if (!device->rev)
3938 bus = HPSA_LEGACY_HBA_BUS;
3933 hpsa_set_bus_target_lun(device, 3939 hpsa_set_bus_target_lun(device,
3934 HPSA_HBA_BUS, 0, lunid & 0x3fff); 3940 bus, 0, lunid & 0x3fff);
3935 else 3941 } else
3936 /* defer target, lun assignment for physical devices */ 3942 /* defer target, lun assignment for physical devices */
3937 hpsa_set_bus_target_lun(device, 3943 hpsa_set_bus_target_lun(device,
3938 HPSA_PHYSICAL_DEVICE_BUS, -1, -1); 3944 HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 82cdfad874f3..9ea162de80dc 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t {
69 u64 sas_address; 69 u64 sas_address;
70 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */ 70 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
71 unsigned char model[16]; /* bytes 16-31 of inquiry data */ 71 unsigned char model[16]; /* bytes 16-31 of inquiry data */
72 unsigned char rev; /* byte 2 of inquiry data */
72 unsigned char raid_level; /* from inquiry page 0xC1 */ 73 unsigned char raid_level; /* from inquiry page 0xC1 */
73 unsigned char volume_offline; /* discovered via TUR or VPD */ 74 unsigned char volume_offline; /* discovered via TUR or VPD */
74 u16 queue_depth; /* max queue_depth for this device */ 75 u16 queue_depth; /* max queue_depth for this device */
@@ -402,6 +403,7 @@ struct offline_device_entry {
402#define HPSA_RAID_VOLUME_BUS 1 403#define HPSA_RAID_VOLUME_BUS 1
403#define HPSA_EXTERNAL_RAID_VOLUME_BUS 2 404#define HPSA_EXTERNAL_RAID_VOLUME_BUS 2
404#define HPSA_HBA_BUS 0 405#define HPSA_HBA_BUS 0
406#define HPSA_LEGACY_HBA_BUS 3
405 407
406/* 408/*
407 Send the command to the hardware 409 Send the command to the hardware
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 04ce7cfb6d1b..50c71678a156 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -308,7 +308,7 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
308 fc_stats = &lport->host_stats; 308 fc_stats = &lport->host_stats;
309 memset(fc_stats, 0, sizeof(struct fc_host_statistics)); 309 memset(fc_stats, 0, sizeof(struct fc_host_statistics));
310 310
311 fc_stats->seconds_since_last_reset = (lport->boot_time - jiffies) / HZ; 311 fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ;
312 312
313 for_each_possible_cpu(cpu) { 313 for_each_possible_cpu(cpu) {
314 struct fc_stats *stats; 314 struct fc_stats *stats;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index c5326055beee..f4f77c5b0c83 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1323,18 +1323,20 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
1323{ 1323{
1324 lockdep_assert_held(&phba->hbalock); 1324 lockdep_assert_held(&phba->hbalock);
1325 1325
1326 BUG_ON(!piocb || !piocb->vport); 1326 BUG_ON(!piocb);
1327 1327
1328 list_add_tail(&piocb->list, &pring->txcmplq); 1328 list_add_tail(&piocb->list, &pring->txcmplq);
1329 piocb->iocb_flag |= LPFC_IO_ON_TXCMPLQ; 1329 piocb->iocb_flag |= LPFC_IO_ON_TXCMPLQ;
1330 1330
1331 if ((unlikely(pring->ringno == LPFC_ELS_RING)) && 1331 if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
1332 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && 1332 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
1333 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) && 1333 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) {
1334 (!(piocb->vport->load_flag & FC_UNLOADING))) 1334 BUG_ON(!piocb->vport);
1335 mod_timer(&piocb->vport->els_tmofunc, 1335 if (!(piocb->vport->load_flag & FC_UNLOADING))
1336 jiffies + 1336 mod_timer(&piocb->vport->els_tmofunc,
1337 msecs_to_jiffies(1000 * (phba->fc_ratov << 1))); 1337 jiffies +
1338 msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
1339 }
1338 1340
1339 return 0; 1341 return 0;
1340} 1342}
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 91b70bc46e7f..1c4744e78173 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3885,6 +3885,11 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
3885 } 3885 }
3886} 3886}
3887 3887
3888static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
3889{
3890 return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
3891}
3892
3888/** 3893/**
3889 * _scsih_flush_running_cmds - completing outstanding commands. 3894 * _scsih_flush_running_cmds - completing outstanding commands.
3890 * @ioc: per adapter object 3895 * @ioc: per adapter object
@@ -3906,6 +3911,9 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
3906 if (!scmd) 3911 if (!scmd)
3907 continue; 3912 continue;
3908 count++; 3913 count++;
3914 if (ata_12_16_cmd(scmd))
3915 scsi_internal_device_unblock(scmd->device,
3916 SDEV_RUNNING);
3909 mpt3sas_base_free_smid(ioc, smid); 3917 mpt3sas_base_free_smid(ioc, smid);
3910 scsi_dma_unmap(scmd); 3918 scsi_dma_unmap(scmd);
3911 if (ioc->pci_error_recovery) 3919 if (ioc->pci_error_recovery)
@@ -4010,11 +4018,6 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
4010 SAM_STAT_CHECK_CONDITION; 4018 SAM_STAT_CHECK_CONDITION;
4011} 4019}
4012 4020
4013static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
4014{
4015 return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
4016}
4017
4018/** 4021/**
4019 * scsih_qcmd - main scsi request entry point 4022 * scsih_qcmd - main scsi request entry point
4020 * @scmd: pointer to scsi command object 4023 * @scmd: pointer to scsi command object
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 86eb19902bac..c7cc8035eacb 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -791,8 +791,10 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf
791 slot->slot_tag = tag; 791 slot->slot_tag = tag;
792 792
793 slot->buf = pci_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma); 793 slot->buf = pci_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
794 if (!slot->buf) 794 if (!slot->buf) {
795 rc = -ENOMEM;
795 goto err_out_tag; 796 goto err_out_tag;
797 }
796 memset(slot->buf, 0, MVS_SLOT_BUF_SZ); 798 memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
797 799
798 tei.task = task; 800 tei.task = task;
diff --git a/drivers/scsi/qlogicpti.h b/drivers/scsi/qlogicpti.h
index 4377e87ee79c..892a0b058b99 100644
--- a/drivers/scsi/qlogicpti.h
+++ b/drivers/scsi/qlogicpti.h
@@ -356,8 +356,8 @@ struct qlogicpti {
356 356
357 /* The rest of the elements are unimportant for performance. */ 357 /* The rest of the elements are unimportant for performance. */
358 struct qlogicpti *next; 358 struct qlogicpti *next;
359 __u32 res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/ 359 dma_addr_t res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/
360 __u32 req_dvma; /* Ptr to REQUEST bufs (DVMA) */ 360 dma_addr_t req_dvma; /* Ptr to REQUEST bufs (DVMA) */
361 u_char fware_majrev, fware_minrev, fware_micrev; 361 u_char fware_majrev, fware_minrev, fware_micrev;
362 struct Scsi_Host *qhost; 362 struct Scsi_Host *qhost;
363 int qpti_id; 363 int qpti_id;
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 69426e644d17..3dbb4a21ab44 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -914,6 +914,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
914 if (!ci) 914 if (!ci)
915 return -ENOMEM; 915 return -ENOMEM;
916 916
917 spin_lock_init(&ci->lock);
917 ci->dev = dev; 918 ci->dev = dev;
918 ci->platdata = dev_get_platdata(dev); 919 ci->platdata = dev_get_platdata(dev);
919 ci->imx28_write_fix = !!(ci->platdata->flags & 920 ci->imx28_write_fix = !!(ci->platdata->flags &
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 661f43fe0f9e..c9e80ad48fdc 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1889,8 +1889,6 @@ static int udc_start(struct ci_hdrc *ci)
1889 struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; 1889 struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
1890 int retval = 0; 1890 int retval = 0;
1891 1891
1892 spin_lock_init(&ci->lock);
1893
1894 ci->gadget.ops = &usb_gadget_ops; 1892 ci->gadget.ops = &usb_gadget_ops;
1895 ci->gadget.speed = USB_SPEED_UNKNOWN; 1893 ci->gadget.speed = USB_SPEED_UNKNOWN;
1896 ci->gadget.max_speed = USB_SPEED_HIGH; 1894 ci->gadget.max_speed = USB_SPEED_HIGH;
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index e40d47d47d82..17989b72cdae 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3225,11 +3225,11 @@ static bool ffs_func_req_match(struct usb_function *f,
3225 3225
3226 switch (creq->bRequestType & USB_RECIP_MASK) { 3226 switch (creq->bRequestType & USB_RECIP_MASK) {
3227 case USB_RECIP_INTERFACE: 3227 case USB_RECIP_INTERFACE:
3228 return ffs_func_revmap_intf(func, 3228 return (ffs_func_revmap_intf(func,
3229 le16_to_cpu(creq->wIndex) >= 0); 3229 le16_to_cpu(creq->wIndex)) >= 0);
3230 case USB_RECIP_ENDPOINT: 3230 case USB_RECIP_ENDPOINT:
3231 return ffs_func_revmap_ep(func, 3231 return (ffs_func_revmap_ep(func,
3232 le16_to_cpu(creq->wIndex) >= 0); 3232 le16_to_cpu(creq->wIndex)) >= 0);
3233 default: 3233 default:
3234 return (bool) (func->ffs->user_flags & 3234 return (bool) (func->ffs->user_flags &
3235 FUNCTIONFS_ALL_CTRL_RECIP); 3235 FUNCTIONFS_ALL_CTRL_RECIP);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e01116e4c067..c3e172e15ec3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -986,7 +986,7 @@ b_host:
986 } 986 }
987#endif 987#endif
988 988
989 schedule_work(&musb->irq_work); 989 schedule_delayed_work(&musb->irq_work, 0);
990 990
991 return handled; 991 return handled;
992} 992}
@@ -1855,14 +1855,23 @@ static void musb_pm_runtime_check_session(struct musb *musb)
1855 MUSB_DEVCTL_HR; 1855 MUSB_DEVCTL_HR;
1856 switch (devctl & ~s) { 1856 switch (devctl & ~s) {
1857 case MUSB_QUIRK_B_INVALID_VBUS_91: 1857 case MUSB_QUIRK_B_INVALID_VBUS_91:
1858 if (!musb->session && !musb->quirk_invalid_vbus) { 1858 if (musb->quirk_retries--) {
1859 musb->quirk_invalid_vbus = true;
1860 musb_dbg(musb, 1859 musb_dbg(musb,
1861 "First invalid vbus, assume no session"); 1860 "Poll devctl on invalid vbus, assume no session");
1861 schedule_delayed_work(&musb->irq_work,
1862 msecs_to_jiffies(1000));
1863
1862 return; 1864 return;
1863 } 1865 }
1864 break;
1865 case MUSB_QUIRK_A_DISCONNECT_19: 1866 case MUSB_QUIRK_A_DISCONNECT_19:
1867 if (musb->quirk_retries--) {
1868 musb_dbg(musb,
1869 "Poll devctl on possible host mode disconnect");
1870 schedule_delayed_work(&musb->irq_work,
1871 msecs_to_jiffies(1000));
1872
1873 return;
1874 }
1866 if (!musb->session) 1875 if (!musb->session)
1867 break; 1876 break;
1868 musb_dbg(musb, "Allow PM on possible host mode disconnect"); 1877 musb_dbg(musb, "Allow PM on possible host mode disconnect");
@@ -1886,9 +1895,9 @@ static void musb_pm_runtime_check_session(struct musb *musb)
1886 if (error < 0) 1895 if (error < 0)
1887 dev_err(musb->controller, "Could not enable: %i\n", 1896 dev_err(musb->controller, "Could not enable: %i\n",
1888 error); 1897 error);
1898 musb->quirk_retries = 3;
1889 } else { 1899 } else {
1890 musb_dbg(musb, "Allow PM with no session: %02x", devctl); 1900 musb_dbg(musb, "Allow PM with no session: %02x", devctl);
1891 musb->quirk_invalid_vbus = false;
1892 pm_runtime_mark_last_busy(musb->controller); 1901 pm_runtime_mark_last_busy(musb->controller);
1893 pm_runtime_put_autosuspend(musb->controller); 1902 pm_runtime_put_autosuspend(musb->controller);
1894 } 1903 }
@@ -1899,7 +1908,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
1899/* Only used to provide driver mode change events */ 1908/* Only used to provide driver mode change events */
1900static void musb_irq_work(struct work_struct *data) 1909static void musb_irq_work(struct work_struct *data)
1901{ 1910{
1902 struct musb *musb = container_of(data, struct musb, irq_work); 1911 struct musb *musb = container_of(data, struct musb, irq_work.work);
1903 1912
1904 musb_pm_runtime_check_session(musb); 1913 musb_pm_runtime_check_session(musb);
1905 1914
@@ -1969,6 +1978,7 @@ static struct musb *allocate_instance(struct device *dev,
1969 INIT_LIST_HEAD(&musb->control); 1978 INIT_LIST_HEAD(&musb->control);
1970 INIT_LIST_HEAD(&musb->in_bulk); 1979 INIT_LIST_HEAD(&musb->in_bulk);
1971 INIT_LIST_HEAD(&musb->out_bulk); 1980 INIT_LIST_HEAD(&musb->out_bulk);
1981 INIT_LIST_HEAD(&musb->pending_list);
1972 1982
1973 musb->vbuserr_retry = VBUSERR_RETRY_COUNT; 1983 musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
1974 musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON; 1984 musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
@@ -2018,6 +2028,84 @@ static void musb_free(struct musb *musb)
2018 musb_host_free(musb); 2028 musb_host_free(musb);
2019} 2029}
2020 2030
2031struct musb_pending_work {
2032 int (*callback)(struct musb *musb, void *data);
2033 void *data;
2034 struct list_head node;
2035};
2036
2037/*
2038 * Called from musb_runtime_resume(), musb_resume(), and
2039 * musb_queue_resume_work(). Callers must take musb->lock.
2040 */
2041static int musb_run_resume_work(struct musb *musb)
2042{
2043 struct musb_pending_work *w, *_w;
2044 unsigned long flags;
2045 int error = 0;
2046
2047 spin_lock_irqsave(&musb->list_lock, flags);
2048 list_for_each_entry_safe(w, _w, &musb->pending_list, node) {
2049 if (w->callback) {
2050 error = w->callback(musb, w->data);
2051 if (error < 0) {
2052 dev_err(musb->controller,
2053 "resume callback %p failed: %i\n",
2054 w->callback, error);
2055 }
2056 }
2057 list_del(&w->node);
2058 devm_kfree(musb->controller, w);
2059 }
2060 spin_unlock_irqrestore(&musb->list_lock, flags);
2061
2062 return error;
2063}
2064
2065/*
2066 * Called to run work if device is active or else queue the work to happen
2067 * on resume. Caller must take musb->lock and must hold an RPM reference.
2068 *
2069 * Note that we cowardly refuse queuing work after musb PM runtime
2070 * resume is done calling musb_run_resume_work() and return -EINPROGRESS
2071 * instead.
2072 */
2073int musb_queue_resume_work(struct musb *musb,
2074 int (*callback)(struct musb *musb, void *data),
2075 void *data)
2076{
2077 struct musb_pending_work *w;
2078 unsigned long flags;
2079 int error;
2080
2081 if (WARN_ON(!callback))
2082 return -EINVAL;
2083
2084 if (pm_runtime_active(musb->controller))
2085 return callback(musb, data);
2086
2087 w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC);
2088 if (!w)
2089 return -ENOMEM;
2090
2091 w->callback = callback;
2092 w->data = data;
2093 spin_lock_irqsave(&musb->list_lock, flags);
2094 if (musb->is_runtime_suspended) {
2095 list_add_tail(&w->node, &musb->pending_list);
2096 error = 0;
2097 } else {
2098 dev_err(musb->controller, "could not add resume work %p\n",
2099 callback);
2100 devm_kfree(musb->controller, w);
2101 error = -EINPROGRESS;
2102 }
2103 spin_unlock_irqrestore(&musb->list_lock, flags);
2104
2105 return error;
2106}
2107EXPORT_SYMBOL_GPL(musb_queue_resume_work);
2108
2021static void musb_deassert_reset(struct work_struct *work) 2109static void musb_deassert_reset(struct work_struct *work)
2022{ 2110{
2023 struct musb *musb; 2111 struct musb *musb;
@@ -2065,6 +2153,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2065 } 2153 }
2066 2154
2067 spin_lock_init(&musb->lock); 2155 spin_lock_init(&musb->lock);
2156 spin_lock_init(&musb->list_lock);
2068 musb->board_set_power = plat->set_power; 2157 musb->board_set_power = plat->set_power;
2069 musb->min_power = plat->min_power; 2158 musb->min_power = plat->min_power;
2070 musb->ops = plat->platform_ops; 2159 musb->ops = plat->platform_ops;
@@ -2208,7 +2297,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2208 musb_generic_disable(musb); 2297 musb_generic_disable(musb);
2209 2298
2210 /* Init IRQ workqueue before request_irq */ 2299 /* Init IRQ workqueue before request_irq */
2211 INIT_WORK(&musb->irq_work, musb_irq_work); 2300 INIT_DELAYED_WORK(&musb->irq_work, musb_irq_work);
2212 INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset); 2301 INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset);
2213 INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume); 2302 INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume);
2214 2303
@@ -2291,6 +2380,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2291 if (status) 2380 if (status)
2292 goto fail5; 2381 goto fail5;
2293 2382
2383 musb->is_initialized = 1;
2294 pm_runtime_mark_last_busy(musb->controller); 2384 pm_runtime_mark_last_busy(musb->controller);
2295 pm_runtime_put_autosuspend(musb->controller); 2385 pm_runtime_put_autosuspend(musb->controller);
2296 2386
@@ -2304,7 +2394,7 @@ fail4:
2304 musb_host_cleanup(musb); 2394 musb_host_cleanup(musb);
2305 2395
2306fail3: 2396fail3:
2307 cancel_work_sync(&musb->irq_work); 2397 cancel_delayed_work_sync(&musb->irq_work);
2308 cancel_delayed_work_sync(&musb->finish_resume_work); 2398 cancel_delayed_work_sync(&musb->finish_resume_work);
2309 cancel_delayed_work_sync(&musb->deassert_reset_work); 2399 cancel_delayed_work_sync(&musb->deassert_reset_work);
2310 if (musb->dma_controller) 2400 if (musb->dma_controller)
@@ -2371,7 +2461,7 @@ static int musb_remove(struct platform_device *pdev)
2371 */ 2461 */
2372 musb_exit_debugfs(musb); 2462 musb_exit_debugfs(musb);
2373 2463
2374 cancel_work_sync(&musb->irq_work); 2464 cancel_delayed_work_sync(&musb->irq_work);
2375 cancel_delayed_work_sync(&musb->finish_resume_work); 2465 cancel_delayed_work_sync(&musb->finish_resume_work);
2376 cancel_delayed_work_sync(&musb->deassert_reset_work); 2466 cancel_delayed_work_sync(&musb->deassert_reset_work);
2377 pm_runtime_get_sync(musb->controller); 2467 pm_runtime_get_sync(musb->controller);
@@ -2557,6 +2647,7 @@ static int musb_suspend(struct device *dev)
2557 2647
2558 musb_platform_disable(musb); 2648 musb_platform_disable(musb);
2559 musb_generic_disable(musb); 2649 musb_generic_disable(musb);
2650 WARN_ON(!list_empty(&musb->pending_list));
2560 2651
2561 spin_lock_irqsave(&musb->lock, flags); 2652 spin_lock_irqsave(&musb->lock, flags);
2562 2653
@@ -2578,9 +2669,11 @@ static int musb_suspend(struct device *dev)
2578 2669
2579static int musb_resume(struct device *dev) 2670static int musb_resume(struct device *dev)
2580{ 2671{
2581 struct musb *musb = dev_to_musb(dev); 2672 struct musb *musb = dev_to_musb(dev);
2582 u8 devctl; 2673 unsigned long flags;
2583 u8 mask; 2674 int error;
2675 u8 devctl;
2676 u8 mask;
2584 2677
2585 /* 2678 /*
2586 * For static cmos like DaVinci, register values were preserved 2679 * For static cmos like DaVinci, register values were preserved
@@ -2614,6 +2707,13 @@ static int musb_resume(struct device *dev)
2614 2707
2615 musb_start(musb); 2708 musb_start(musb);
2616 2709
2710 spin_lock_irqsave(&musb->lock, flags);
2711 error = musb_run_resume_work(musb);
2712 if (error)
2713 dev_err(musb->controller, "resume work failed with %i\n",
2714 error);
2715 spin_unlock_irqrestore(&musb->lock, flags);
2716
2617 return 0; 2717 return 0;
2618} 2718}
2619 2719
@@ -2622,14 +2722,16 @@ static int musb_runtime_suspend(struct device *dev)
2622 struct musb *musb = dev_to_musb(dev); 2722 struct musb *musb = dev_to_musb(dev);
2623 2723
2624 musb_save_context(musb); 2724 musb_save_context(musb);
2725 musb->is_runtime_suspended = 1;
2625 2726
2626 return 0; 2727 return 0;
2627} 2728}
2628 2729
2629static int musb_runtime_resume(struct device *dev) 2730static int musb_runtime_resume(struct device *dev)
2630{ 2731{
2631 struct musb *musb = dev_to_musb(dev); 2732 struct musb *musb = dev_to_musb(dev);
2632 static int first = 1; 2733 unsigned long flags;
2734 int error;
2633 2735
2634 /* 2736 /*
2635 * When pm_runtime_get_sync called for the first time in driver 2737 * When pm_runtime_get_sync called for the first time in driver
@@ -2640,9 +2742,10 @@ static int musb_runtime_resume(struct device *dev)
2640 * Also context restore without save does not make 2742 * Also context restore without save does not make
2641 * any sense 2743 * any sense
2642 */ 2744 */
2643 if (!first) 2745 if (!musb->is_initialized)
2644 musb_restore_context(musb); 2746 return 0;
2645 first = 0; 2747
2748 musb_restore_context(musb);
2646 2749
2647 if (musb->need_finish_resume) { 2750 if (musb->need_finish_resume) {
2648 musb->need_finish_resume = 0; 2751 musb->need_finish_resume = 0;
@@ -2650,6 +2753,14 @@ static int musb_runtime_resume(struct device *dev)
2650 msecs_to_jiffies(USB_RESUME_TIMEOUT)); 2753 msecs_to_jiffies(USB_RESUME_TIMEOUT));
2651 } 2754 }
2652 2755
2756 spin_lock_irqsave(&musb->lock, flags);
2757 error = musb_run_resume_work(musb);
2758 if (error)
2759 dev_err(musb->controller, "resume work failed with %i\n",
2760 error);
2761 musb->is_runtime_suspended = 0;
2762 spin_unlock_irqrestore(&musb->lock, flags);
2763
2653 return 0; 2764 return 0;
2654} 2765}
2655 2766
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 2cb88a498f8a..91817d77d59c 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -303,13 +303,14 @@ struct musb_context_registers {
303struct musb { 303struct musb {
304 /* device lock */ 304 /* device lock */
305 spinlock_t lock; 305 spinlock_t lock;
306 spinlock_t list_lock; /* resume work list lock */
306 307
307 struct musb_io io; 308 struct musb_io io;
308 const struct musb_platform_ops *ops; 309 const struct musb_platform_ops *ops;
309 struct musb_context_registers context; 310 struct musb_context_registers context;
310 311
311 irqreturn_t (*isr)(int, void *); 312 irqreturn_t (*isr)(int, void *);
312 struct work_struct irq_work; 313 struct delayed_work irq_work;
313 struct delayed_work deassert_reset_work; 314 struct delayed_work deassert_reset_work;
314 struct delayed_work finish_resume_work; 315 struct delayed_work finish_resume_work;
315 struct delayed_work gadget_work; 316 struct delayed_work gadget_work;
@@ -337,6 +338,7 @@ struct musb {
337 struct list_head control; /* of musb_qh */ 338 struct list_head control; /* of musb_qh */
338 struct list_head in_bulk; /* of musb_qh */ 339 struct list_head in_bulk; /* of musb_qh */
339 struct list_head out_bulk; /* of musb_qh */ 340 struct list_head out_bulk; /* of musb_qh */
341 struct list_head pending_list; /* pending work list */
340 342
341 struct timer_list otg_timer; 343 struct timer_list otg_timer;
342 struct notifier_block nb; 344 struct notifier_block nb;
@@ -379,12 +381,15 @@ struct musb {
379 381
380 int port_mode; /* MUSB_PORT_MODE_* */ 382 int port_mode; /* MUSB_PORT_MODE_* */
381 bool session; 383 bool session;
382 bool quirk_invalid_vbus; 384 unsigned long quirk_retries;
383 bool is_host; 385 bool is_host;
384 386
385 int a_wait_bcon; /* VBUS timeout in msecs */ 387 int a_wait_bcon; /* VBUS timeout in msecs */
386 unsigned long idle_timeout; /* Next timeout in jiffies */ 388 unsigned long idle_timeout; /* Next timeout in jiffies */
387 389
390 unsigned is_initialized:1;
391 unsigned is_runtime_suspended:1;
392
388 /* active means connected and not suspended */ 393 /* active means connected and not suspended */
389 unsigned is_active:1; 394 unsigned is_active:1;
390 395
@@ -540,6 +545,10 @@ extern irqreturn_t musb_interrupt(struct musb *);
540 545
541extern void musb_hnp_stop(struct musb *musb); 546extern void musb_hnp_stop(struct musb *musb);
542 547
548int musb_queue_resume_work(struct musb *musb,
549 int (*callback)(struct musb *musb, void *data),
550 void *data);
551
543static inline void musb_platform_set_vbus(struct musb *musb, int is_on) 552static inline void musb_platform_set_vbus(struct musb *musb, int is_on)
544{ 553{
545 if (musb->ops->set_vbus) 554 if (musb->ops->set_vbus)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 0f17d2140db6..feae1561b9ab 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -185,24 +185,19 @@ static void dsps_musb_disable(struct musb *musb)
185 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); 185 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap);
186 musb_writel(reg_base, wrp->epintr_clear, 186 musb_writel(reg_base, wrp->epintr_clear,
187 wrp->txep_bitmap | wrp->rxep_bitmap); 187 wrp->txep_bitmap | wrp->rxep_bitmap);
188 del_timer_sync(&glue->timer);
188 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 189 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
189} 190}
190 191
191static void otg_timer(unsigned long _musb) 192/* Caller must take musb->lock */
193static int dsps_check_status(struct musb *musb, void *unused)
192{ 194{
193 struct musb *musb = (void *)_musb;
194 void __iomem *mregs = musb->mregs; 195 void __iomem *mregs = musb->mregs;
195 struct device *dev = musb->controller; 196 struct device *dev = musb->controller;
196 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 197 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
197 const struct dsps_musb_wrapper *wrp = glue->wrp; 198 const struct dsps_musb_wrapper *wrp = glue->wrp;
198 u8 devctl; 199 u8 devctl;
199 unsigned long flags;
200 int skip_session = 0; 200 int skip_session = 0;
201 int err;
202
203 err = pm_runtime_get_sync(dev);
204 if (err < 0)
205 dev_err(dev, "Poll could not pm_runtime_get: %i\n", err);
206 201
207 /* 202 /*
208 * We poll because DSPS IP's won't expose several OTG-critical 203 * We poll because DSPS IP's won't expose several OTG-critical
@@ -212,7 +207,6 @@ static void otg_timer(unsigned long _musb)
212 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, 207 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
213 usb_otg_state_string(musb->xceiv->otg->state)); 208 usb_otg_state_string(musb->xceiv->otg->state));
214 209
215 spin_lock_irqsave(&musb->lock, flags);
216 switch (musb->xceiv->otg->state) { 210 switch (musb->xceiv->otg->state) {
217 case OTG_STATE_A_WAIT_VRISE: 211 case OTG_STATE_A_WAIT_VRISE:
218 mod_timer(&glue->timer, jiffies + 212 mod_timer(&glue->timer, jiffies +
@@ -245,8 +239,30 @@ static void otg_timer(unsigned long _musb)
245 default: 239 default:
246 break; 240 break;
247 } 241 }
248 spin_unlock_irqrestore(&musb->lock, flags);
249 242
243 return 0;
244}
245
246static void otg_timer(unsigned long _musb)
247{
248 struct musb *musb = (void *)_musb;
249 struct device *dev = musb->controller;
250 unsigned long flags;
251 int err;
252
253 err = pm_runtime_get(dev);
254 if ((err != -EINPROGRESS) && err < 0) {
255 dev_err(dev, "Poll could not pm_runtime_get: %i\n", err);
256 pm_runtime_put_noidle(dev);
257
258 return;
259 }
260
261 spin_lock_irqsave(&musb->lock, flags);
262 err = musb_queue_resume_work(musb, dsps_check_status, NULL);
263 if (err < 0)
264 dev_err(dev, "%s resume work: %i\n", __func__, err);
265 spin_unlock_irqrestore(&musb->lock, flags);
250 pm_runtime_mark_last_busy(dev); 266 pm_runtime_mark_last_busy(dev);
251 pm_runtime_put_autosuspend(dev); 267 pm_runtime_put_autosuspend(dev);
252} 268}
@@ -767,28 +783,13 @@ static int dsps_probe(struct platform_device *pdev)
767 783
768 platform_set_drvdata(pdev, glue); 784 platform_set_drvdata(pdev, glue);
769 pm_runtime_enable(&pdev->dev); 785 pm_runtime_enable(&pdev->dev);
770 pm_runtime_use_autosuspend(&pdev->dev);
771 pm_runtime_set_autosuspend_delay(&pdev->dev, 200);
772
773 ret = pm_runtime_get_sync(&pdev->dev);
774 if (ret < 0) {
775 dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
776 goto err2;
777 }
778
779 ret = dsps_create_musb_pdev(glue, pdev); 786 ret = dsps_create_musb_pdev(glue, pdev);
780 if (ret) 787 if (ret)
781 goto err3; 788 goto err;
782
783 pm_runtime_mark_last_busy(&pdev->dev);
784 pm_runtime_put_autosuspend(&pdev->dev);
785 789
786 return 0; 790 return 0;
787 791
788err3: 792err:
789 pm_runtime_put_sync(&pdev->dev);
790err2:
791 pm_runtime_dont_use_autosuspend(&pdev->dev);
792 pm_runtime_disable(&pdev->dev); 793 pm_runtime_disable(&pdev->dev);
793 return ret; 794 return ret;
794} 795}
@@ -799,9 +800,6 @@ static int dsps_remove(struct platform_device *pdev)
799 800
800 platform_device_unregister(glue->musb); 801 platform_device_unregister(glue->musb);
801 802
802 /* disable usbss clocks */
803 pm_runtime_dont_use_autosuspend(&pdev->dev);
804 pm_runtime_put_sync(&pdev->dev);
805 pm_runtime_disable(&pdev->dev); 803 pm_runtime_disable(&pdev->dev);
806 804
807 return 0; 805 return 0;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 4042ea017985..a55173c9e564 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1114,7 +1114,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
1114 musb_ep->dma ? "dma, " : "", 1114 musb_ep->dma ? "dma, " : "",
1115 musb_ep->packet_sz); 1115 musb_ep->packet_sz);
1116 1116
1117 schedule_work(&musb->irq_work); 1117 schedule_delayed_work(&musb->irq_work, 0);
1118 1118
1119fail: 1119fail:
1120 spin_unlock_irqrestore(&musb->lock, flags); 1120 spin_unlock_irqrestore(&musb->lock, flags);
@@ -1158,7 +1158,7 @@ static int musb_gadget_disable(struct usb_ep *ep)
1158 musb_ep->desc = NULL; 1158 musb_ep->desc = NULL;
1159 musb_ep->end_point.desc = NULL; 1159 musb_ep->end_point.desc = NULL;
1160 1160
1161 schedule_work(&musb->irq_work); 1161 schedule_delayed_work(&musb->irq_work, 0);
1162 1162
1163 spin_unlock_irqrestore(&(musb->lock), flags); 1163 spin_unlock_irqrestore(&(musb->lock), flags);
1164 1164
@@ -1222,13 +1222,22 @@ void musb_ep_restart(struct musb *musb, struct musb_request *req)
1222 rxstate(musb, req); 1222 rxstate(musb, req);
1223} 1223}
1224 1224
1225static int musb_ep_restart_resume_work(struct musb *musb, void *data)
1226{
1227 struct musb_request *req = data;
1228
1229 musb_ep_restart(musb, req);
1230
1231 return 0;
1232}
1233
1225static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, 1234static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1226 gfp_t gfp_flags) 1235 gfp_t gfp_flags)
1227{ 1236{
1228 struct musb_ep *musb_ep; 1237 struct musb_ep *musb_ep;
1229 struct musb_request *request; 1238 struct musb_request *request;
1230 struct musb *musb; 1239 struct musb *musb;
1231 int status = 0; 1240 int status;
1232 unsigned long lockflags; 1241 unsigned long lockflags;
1233 1242
1234 if (!ep || !req) 1243 if (!ep || !req)
@@ -1245,6 +1254,17 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1245 if (request->ep != musb_ep) 1254 if (request->ep != musb_ep)
1246 return -EINVAL; 1255 return -EINVAL;
1247 1256
1257 status = pm_runtime_get(musb->controller);
1258 if ((status != -EINPROGRESS) && status < 0) {
1259 dev_err(musb->controller,
1260 "pm runtime get failed in %s\n",
1261 __func__);
1262 pm_runtime_put_noidle(musb->controller);
1263
1264 return status;
1265 }
1266 status = 0;
1267
1248 trace_musb_req_enq(request); 1268 trace_musb_req_enq(request);
1249 1269
1250 /* request is mine now... */ 1270 /* request is mine now... */
@@ -1255,7 +1275,6 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1255 1275
1256 map_dma_buffer(request, musb, musb_ep); 1276 map_dma_buffer(request, musb, musb_ep);
1257 1277
1258 pm_runtime_get_sync(musb->controller);
1259 spin_lock_irqsave(&musb->lock, lockflags); 1278 spin_lock_irqsave(&musb->lock, lockflags);
1260 1279
1261 /* don't queue if the ep is down */ 1280 /* don't queue if the ep is down */
@@ -1271,8 +1290,14 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1271 list_add_tail(&request->list, &musb_ep->req_list); 1290 list_add_tail(&request->list, &musb_ep->req_list);
1272 1291
1273 /* it this is the head of the queue, start i/o ... */ 1292 /* it this is the head of the queue, start i/o ... */
1274 if (!musb_ep->busy && &request->list == musb_ep->req_list.next) 1293 if (!musb_ep->busy && &request->list == musb_ep->req_list.next) {
1275 musb_ep_restart(musb, request); 1294 status = musb_queue_resume_work(musb,
1295 musb_ep_restart_resume_work,
1296 request);
1297 if (status < 0)
1298 dev_err(musb->controller, "%s resume work: %i\n",
1299 __func__, status);
1300 }
1276 1301
1277unlock: 1302unlock:
1278 spin_unlock_irqrestore(&musb->lock, lockflags); 1303 spin_unlock_irqrestore(&musb->lock, lockflags);
@@ -1969,7 +1994,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
1969 */ 1994 */
1970 1995
1971 /* Force check of devctl register for PM runtime */ 1996 /* Force check of devctl register for PM runtime */
1972 schedule_work(&musb->irq_work); 1997 schedule_delayed_work(&musb->irq_work, 0);
1973 1998
1974 pm_runtime_mark_last_busy(musb->controller); 1999 pm_runtime_mark_last_busy(musb->controller);
1975 pm_runtime_put_autosuspend(musb->controller); 2000 pm_runtime_put_autosuspend(musb->controller);
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index cc1225485509..e8be8e39ab8f 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -513,17 +513,18 @@ static int omap2430_probe(struct platform_device *pdev)
513 } 513 }
514 514
515 pm_runtime_enable(glue->dev); 515 pm_runtime_enable(glue->dev);
516 pm_runtime_use_autosuspend(glue->dev);
517 pm_runtime_set_autosuspend_delay(glue->dev, 100);
518 516
519 ret = platform_device_add(musb); 517 ret = platform_device_add(musb);
520 if (ret) { 518 if (ret) {
521 dev_err(&pdev->dev, "failed to register musb device\n"); 519 dev_err(&pdev->dev, "failed to register musb device\n");
522 goto err2; 520 goto err3;
523 } 521 }
524 522
525 return 0; 523 return 0;
526 524
525err3:
526 pm_runtime_disable(glue->dev);
527
527err2: 528err2:
528 platform_device_put(musb); 529 platform_device_put(musb);
529 530
@@ -535,10 +536,7 @@ static int omap2430_remove(struct platform_device *pdev)
535{ 536{
536 struct omap2430_glue *glue = platform_get_drvdata(pdev); 537 struct omap2430_glue *glue = platform_get_drvdata(pdev);
537 538
538 pm_runtime_get_sync(glue->dev);
539 platform_device_unregister(glue->musb); 539 platform_device_unregister(glue->musb);
540 pm_runtime_put_sync(glue->dev);
541 pm_runtime_dont_use_autosuspend(glue->dev);
542 pm_runtime_disable(glue->dev); 540 pm_runtime_disable(glue->dev);
543 541
544 return 0; 542 return 0;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index df7c9f46be54..e85cc8e4e7a9 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -724,7 +724,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
724 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", 724 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
725 usb_otg_state_string(musb->xceiv->otg->state), otg_stat); 725 usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
726 idle_timeout = jiffies + (1 * HZ); 726 idle_timeout = jiffies + (1 * HZ);
727 schedule_work(&musb->irq_work); 727 schedule_delayed_work(&musb->irq_work, 0);
728 728
729 } else /* A-dev state machine */ { 729 } else /* A-dev state machine */ {
730 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", 730 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
@@ -814,7 +814,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
814 break; 814 break;
815 } 815 }
816 } 816 }
817 schedule_work(&musb->irq_work); 817 schedule_delayed_work(&musb->irq_work, 0);
818 818
819 return idle_timeout; 819 return idle_timeout;
820} 820}
@@ -864,7 +864,7 @@ static irqreturn_t tusb_musb_interrupt(int irq, void *__hci)
864 musb_writel(tbase, TUSB_PRCM_WAKEUP_CLEAR, reg); 864 musb_writel(tbase, TUSB_PRCM_WAKEUP_CLEAR, reg);
865 if (reg & ~TUSB_PRCM_WNORCS) { 865 if (reg & ~TUSB_PRCM_WNORCS) {
866 musb->is_active = 1; 866 musb->is_active = 1;
867 schedule_work(&musb->irq_work); 867 schedule_delayed_work(&musb->irq_work, 0);
868 } 868 }
869 dev_dbg(musb->controller, "wake %sactive %02x\n", 869 dev_dbg(musb->controller, "wake %sactive %02x\n",
870 musb->is_active ? "" : "in", reg); 870 musb->is_active ? "" : "in", reg);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index f61477bed3a8..243ac5ebe46a 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -131,6 +131,7 @@ static const struct usb_device_id id_table[] = {
131 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ 131 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
132 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ 132 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
133 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ 133 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
134 { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */
134 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */ 135 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
135 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ 136 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
136 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ 137 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0ff7f38d7800..6e9fc8bcc285 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1012,6 +1012,8 @@ static const struct usb_device_id id_table_combined[] = {
1012 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) }, 1012 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) },
1013 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) }, 1013 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) },
1014 { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) }, 1014 { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
1015 { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
1016 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
1015 { } /* Terminating entry */ 1017 { } /* Terminating entry */
1016}; 1018};
1017 1019
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 21011c0a4c64..48ee04c94a75 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -596,6 +596,12 @@
596#define STK541_PID 0x2109 /* Zigbee Controller */ 596#define STK541_PID 0x2109 /* Zigbee Controller */
597 597
598/* 598/*
599 * Texas Instruments
600 */
601#define TI_VID 0x0451
602#define TI_CC3200_LAUNCHPAD_PID 0xC32A /* SimpleLink Wi-Fi CC3200 LaunchPad */
603
604/*
599 * Blackfin gnICE JTAG 605 * Blackfin gnICE JTAG
600 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice 606 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
601 */ 607 */
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index ffd086733421..1a59f335b063 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -954,10 +954,15 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
954 954
955 /* COMMAND STAGE */ 955 /* COMMAND STAGE */
956 /* let's send the command via the control pipe */ 956 /* let's send the command via the control pipe */
957 /*
958 * Command is sometime (f.e. after scsi_eh_prep_cmnd) on the stack.
959 * Stack may be vmallocated. So no DMA for us. Make a copy.
960 */
961 memcpy(us->iobuf, srb->cmnd, srb->cmd_len);
957 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, 962 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
958 US_CBI_ADSC, 963 US_CBI_ADSC,
959 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 964 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
960 us->ifnum, srb->cmnd, srb->cmd_len); 965 us->ifnum, us->iobuf, srb->cmd_len);
961 966
962 /* check the return code for the command */ 967 /* check the return code for the command */
963 usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n", 968 usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n",
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index e3b30ea9ece5..a504e2e003da 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -506,7 +506,7 @@ static void vhost_vsock_reset_orphans(struct sock *sk)
506 * executing. 506 * executing.
507 */ 507 */
508 508
509 if (!vhost_vsock_get(vsk->local_addr.svm_cid)) { 509 if (!vhost_vsock_get(vsk->remote_addr.svm_cid)) {
510 sock_set_flag(sk, SOCK_DONE); 510 sock_set_flag(sk, SOCK_DONE);
511 vsk->peer_shutdown = SHUTDOWN_MASK; 511 vsk->peer_shutdown = SHUTDOWN_MASK;
512 sk->sk_state = SS_UNCONNECTED; 512 sk->sk_state = SS_UNCONNECTED;
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index fdd3228e0678..3eb58cb51e56 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -155,6 +155,7 @@ config TANGOX_WATCHDOG
155config WDAT_WDT 155config WDAT_WDT
156 tristate "ACPI Watchdog Action Table (WDAT)" 156 tristate "ACPI Watchdog Action Table (WDAT)"
157 depends on ACPI 157 depends on ACPI
158 select WATCHDOG_CORE
158 select ACPI_WATCHDOG 159 select ACPI_WATCHDOG
159 help 160 help
160 This driver adds support for systems with ACPI Watchdog Action 161 This driver adds support for systems with ACPI Watchdog Action
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 78180d151730..a594c7879cc2 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1261,26 +1261,30 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
1261 return -ECHILD; 1261 return -ECHILD;
1262 1262
1263 op = ceph_snap(dir) == CEPH_SNAPDIR ? 1263 op = ceph_snap(dir) == CEPH_SNAPDIR ?
1264 CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP; 1264 CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_GETATTR;
1265 req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS); 1265 req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
1266 if (!IS_ERR(req)) { 1266 if (!IS_ERR(req)) {
1267 req->r_dentry = dget(dentry); 1267 req->r_dentry = dget(dentry);
1268 req->r_num_caps = 2; 1268 req->r_num_caps = op == CEPH_MDS_OP_GETATTR ? 1 : 2;
1269 1269
1270 mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED; 1270 mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
1271 if (ceph_security_xattr_wanted(dir)) 1271 if (ceph_security_xattr_wanted(dir))
1272 mask |= CEPH_CAP_XATTR_SHARED; 1272 mask |= CEPH_CAP_XATTR_SHARED;
1273 req->r_args.getattr.mask = mask; 1273 req->r_args.getattr.mask = mask;
1274 1274
1275 req->r_locked_dir = dir;
1276 err = ceph_mdsc_do_request(mdsc, NULL, req); 1275 err = ceph_mdsc_do_request(mdsc, NULL, req);
1277 if (err == 0 || err == -ENOENT) { 1276 switch (err) {
1278 if (dentry == req->r_dentry) { 1277 case 0:
1279 valid = !d_unhashed(dentry); 1278 if (d_really_is_positive(dentry) &&
1280 } else { 1279 d_inode(dentry) == req->r_target_inode)
1281 d_invalidate(req->r_dentry); 1280 valid = 1;
1282 err = -EAGAIN; 1281 break;
1283 } 1282 case -ENOENT:
1283 if (d_really_is_negative(dentry))
1284 valid = 1;
1285 /* Fallthrough */
1286 default:
1287 break;
1284 } 1288 }
1285 ceph_mdsc_put_request(req); 1289 ceph_mdsc_put_request(req);
1286 dout("d_revalidate %p lookup result=%d\n", 1290 dout("d_revalidate %p lookup result=%d\n",
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 8347c90cf483..5eb04129f938 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -808,7 +808,11 @@ calc_seckey(struct cifs_ses *ses)
808 struct crypto_skcipher *tfm_arc4; 808 struct crypto_skcipher *tfm_arc4;
809 struct scatterlist sgin, sgout; 809 struct scatterlist sgin, sgout;
810 struct skcipher_request *req; 810 struct skcipher_request *req;
811 unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */ 811 unsigned char *sec_key;
812
813 sec_key = kmalloc(CIFS_SESS_KEY_SIZE, GFP_KERNEL);
814 if (sec_key == NULL)
815 return -ENOMEM;
812 816
813 get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE); 817 get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
814 818
@@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses)
816 if (IS_ERR(tfm_arc4)) { 820 if (IS_ERR(tfm_arc4)) {
817 rc = PTR_ERR(tfm_arc4); 821 rc = PTR_ERR(tfm_arc4);
818 cifs_dbg(VFS, "could not allocate crypto API arc4\n"); 822 cifs_dbg(VFS, "could not allocate crypto API arc4\n");
819 return rc; 823 goto out;
820 } 824 }
821 825
822 rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response, 826 rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response,
@@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses)
854 858
855out_free_cipher: 859out_free_cipher:
856 crypto_free_skcipher(tfm_arc4); 860 crypto_free_skcipher(tfm_arc4);
857 861out:
862 kfree(sec_key);
858 return rc; 863 return rc;
859} 864}
860 865
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 3f3185febc58..e3fed9249a04 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -3427,6 +3427,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
3427 __u16 rc = 0; 3427 __u16 rc = 0;
3428 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data; 3428 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;
3429 struct posix_acl_xattr_header *local_acl = (void *)pACL; 3429 struct posix_acl_xattr_header *local_acl = (void *)pACL;
3430 struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1);
3430 int count; 3431 int count;
3431 int i; 3432 int i;
3432 3433
@@ -3453,8 +3454,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
3453 return 0; 3454 return 0;
3454 } 3455 }
3455 for (i = 0; i < count; i++) { 3456 for (i = 0; i < count; i++) {
3456 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], 3457 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]);
3457 (struct posix_acl_xattr_entry *)(local_acl + 1));
3458 if (rc != 0) { 3458 if (rc != 0) {
3459 /* ACE not converted */ 3459 /* ACE not converted */
3460 break; 3460 break;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index aab5227979e2..4547aeddd12b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
412 } 412 }
413 } while (server->tcpStatus == CifsNeedReconnect); 413 } while (server->tcpStatus == CifsNeedReconnect);
414 414
415 if (server->tcpStatus == CifsNeedNegotiate)
416 mod_delayed_work(cifsiod_wq, &server->echo, 0);
417
415 return rc; 418 return rc;
416} 419}
417 420
@@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work)
421 int rc; 424 int rc;
422 struct TCP_Server_Info *server = container_of(work, 425 struct TCP_Server_Info *server = container_of(work,
423 struct TCP_Server_Info, echo.work); 426 struct TCP_Server_Info, echo.work);
424 unsigned long echo_interval = server->echo_interval; 427 unsigned long echo_interval;
428
429 /*
430 * If we need to renegotiate, set echo interval to zero to
431 * immediately call echo service where we can renegotiate.
432 */
433 if (server->tcpStatus == CifsNeedNegotiate)
434 echo_interval = 0;
435 else
436 echo_interval = server->echo_interval;
425 437
426 /* 438 /*
427 * We cannot send an echo if it is disabled or until the 439 * We cannot send an echo if it is disabled.
428 * NEGOTIATE_PROTOCOL request is done, which is indicated by 440 * Also, no need to ping if we got a response recently.
429 * server->ops->need_neg() == true. Also, no need to ping if
430 * we got a response recently.
431 */ 441 */
432 442
433 if (server->tcpStatus == CifsNeedReconnect || 443 if (server->tcpStatus == CifsNeedReconnect ||
434 server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || 444 server->tcpStatus == CifsExiting ||
445 server->tcpStatus == CifsNew ||
435 (server->ops->can_echo && !server->ops->can_echo(server)) || 446 (server->ops->can_echo && !server->ops->can_echo(server)) ||
436 time_before(jiffies, server->lstrp + echo_interval - HZ)) 447 time_before(jiffies, server->lstrp + echo_interval - HZ))
437 goto requeue_echo; 448 goto requeue_echo;
@@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work)
442 server->hostname); 453 server->hostname);
443 454
444requeue_echo: 455requeue_echo:
445 queue_delayed_work(cifsiod_wq, &server->echo, echo_interval); 456 queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
446} 457}
447 458
448static bool 459static bool
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index b3ebe512d64c..096f79997f75 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1739,8 +1739,6 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1739 * This should be done on write(), truncate() and chown(). 1739 * This should be done on write(), truncate() and chown().
1740 */ 1740 */
1741 if (!fc->handle_killpriv) { 1741 if (!fc->handle_killpriv) {
1742 int kill;
1743
1744 /* 1742 /*
1745 * ia_mode calculation may have used stale i_mode. 1743 * ia_mode calculation may have used stale i_mode.
1746 * Refresh and recalculate. 1744 * Refresh and recalculate.
@@ -1750,12 +1748,11 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1750 return ret; 1748 return ret;
1751 1749
1752 attr->ia_mode = inode->i_mode; 1750 attr->ia_mode = inode->i_mode;
1753 kill = should_remove_suid(entry); 1751 if (inode->i_mode & S_ISUID) {
1754 if (kill & ATTR_KILL_SUID) {
1755 attr->ia_valid |= ATTR_MODE; 1752 attr->ia_valid |= ATTR_MODE;
1756 attr->ia_mode &= ~S_ISUID; 1753 attr->ia_mode &= ~S_ISUID;
1757 } 1754 }
1758 if (kill & ATTR_KILL_SGID) { 1755 if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
1759 attr->ia_valid |= ATTR_MODE; 1756 attr->ia_valid |= ATTR_MODE;
1760 attr->ia_mode &= ~S_ISGID; 1757 attr->ia_mode &= ~S_ISGID;
1761 } 1758 }
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 98b3eb7d8eaf..0ec137310320 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -377,9 +377,9 @@ repeat:
377 { 377 {
378 int p; 378 int p;
379 for (p = 0; p < rr->u.ER.len_id; p++) 379 for (p = 0; p < rr->u.ER.len_id; p++)
380 printk("%c", rr->u.ER.data[p]); 380 printk(KERN_CONT "%c", rr->u.ER.data[p]);
381 } 381 }
382 printk("\n"); 382 printk(KERN_CONT "\n");
383 break; 383 break;
384 case SIG('P', 'X'): 384 case SIG('P', 'X'):
385 inode->i_mode = isonum_733(rr->u.PX.mode); 385 inode->i_mode = isonum_733(rr->u.PX.mode);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index edd46a0e951d..0e100856c7b8 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -328,11 +328,11 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
328 if (!real) 328 if (!real)
329 goto bug; 329 goto bug;
330 330
331 /* Handle recursion */
332 real = d_real(real, inode, open_flags);
333
331 if (!inode || inode == d_inode(real)) 334 if (!inode || inode == d_inode(real))
332 return real; 335 return real;
333
334 /* Handle recursion */
335 return d_real(real, inode, open_flags);
336bug: 336bug:
337 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry, 337 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
338 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0); 338 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
diff --git a/fs/splice.c b/fs/splice.c
index dcaf185a5731..5a7750bd2eea 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -408,7 +408,8 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
408 if (res <= 0) 408 if (res <= 0)
409 return -ENOMEM; 409 return -ENOMEM;
410 410
411 nr_pages = res / PAGE_SIZE; 411 BUG_ON(dummy);
412 nr_pages = DIV_ROUND_UP(res, PAGE_SIZE);
412 413
413 vec = __vec; 414 vec = __vec;
414 if (nr_pages > PIPE_DEF_BUFFERS) { 415 if (nr_pages > PIPE_DEF_BUFFERS) {
diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h
index 61580b19f9f6..22f884c97387 100644
--- a/include/crypto/drbg.h
+++ b/include/crypto/drbg.h
@@ -124,6 +124,8 @@ struct drbg_state {
124 struct skcipher_request *ctr_req; /* CTR mode request handle */ 124 struct skcipher_request *ctr_req; /* CTR mode request handle */
125 __u8 *ctr_null_value_buf; /* CTR mode unaligned buffer */ 125 __u8 *ctr_null_value_buf; /* CTR mode unaligned buffer */
126 __u8 *ctr_null_value; /* CTR mode aligned zero buf */ 126 __u8 *ctr_null_value; /* CTR mode aligned zero buf */
127 __u8 *outscratchpadbuf; /* CTR mode output scratchpad */
128 __u8 *outscratchpad; /* CTR mode aligned outbuf */
127 struct completion ctr_completion; /* CTR mode async handler */ 129 struct completion ctr_completion; /* CTR mode async handler */
128 int ctr_async_err; /* CTR mode async error */ 130 int ctr_async_err; /* CTR mode async error */
129 131
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 432f5c97e18f..928e5ca0caee 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -263,7 +263,9 @@
263#endif 263#endif
264#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */ 264#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
265 265
266#if GCC_VERSION >= 50000 266#if GCC_VERSION >= 70000
267#define KASAN_ABI_VERSION 5
268#elif GCC_VERSION >= 50000
267#define KASAN_ABI_VERSION 4 269#define KASAN_ABI_VERSION 4
268#elif GCC_VERSION >= 40902 270#elif GCC_VERSION >= 40902
269#define KASAN_ABI_VERSION 3 271#define KASAN_ABI_VERSION 3
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 2d9b650047a5..d49e26c6cdc7 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -429,6 +429,7 @@ struct intel_iommu {
429 struct page_req_dsc *prq; 429 struct page_req_dsc *prq;
430 unsigned char prq_name[16]; /* Name for PRQ interrupt */ 430 unsigned char prq_name[16]; /* Name for PRQ interrupt */
431 struct idr pasid_idr; 431 struct idr pasid_idr;
432 u32 pasid_max;
432#endif 433#endif
433 struct q_inval *qi; /* Queued invalidation info */ 434 struct q_inval *qi; /* Queued invalidation info */
434 u32 *iommu_state; /* Store iommu states between suspend and resume.*/ 435 u32 *iommu_state; /* Store iommu states between suspend and resume.*/
diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index f4947fda11e7..8458c5351e56 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -143,7 +143,7 @@ u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
143 const struct nd_cmd_desc *desc, int idx, void *buf); 143 const struct nd_cmd_desc *desc, int idx, void *buf);
144u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd, 144u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
145 const struct nd_cmd_desc *desc, int idx, const u32 *in_field, 145 const struct nd_cmd_desc *desc, int idx, const u32 *in_field,
146 const u32 *out_field); 146 const u32 *out_field, unsigned long remainder);
147int nvdimm_bus_check_dimm_count(struct nvdimm_bus *nvdimm_bus, int dimm_count); 147int nvdimm_bus_check_dimm_count(struct nvdimm_bus *nvdimm_bus, int dimm_count);
148struct nd_region *nvdimm_pmem_region_create(struct nvdimm_bus *nvdimm_bus, 148struct nd_region *nvdimm_pmem_region_create(struct nvdimm_bus *nvdimm_bus,
149 struct nd_region_desc *ndr_desc); 149 struct nd_region_desc *ndr_desc);
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 3be7abd6e722..c9f379689dd0 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -476,7 +476,6 @@ enum {
476enum { 476enum {
477 MLX4_INTERFACE_STATE_UP = 1 << 0, 477 MLX4_INTERFACE_STATE_UP = 1 << 0,
478 MLX4_INTERFACE_STATE_DELETION = 1 << 1, 478 MLX4_INTERFACE_STATE_DELETION = 1 << 1,
479 MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2,
480}; 479};
481 480
482#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ 481#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bf04a46f6d5b..e16a2a980ea8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1619,7 +1619,7 @@ enum netdev_priv_flags {
1619 * @dcbnl_ops: Data Center Bridging netlink ops 1619 * @dcbnl_ops: Data Center Bridging netlink ops
1620 * @num_tc: Number of traffic classes in the net device 1620 * @num_tc: Number of traffic classes in the net device
1621 * @tc_to_txq: XXX: need comments on this one 1621 * @tc_to_txq: XXX: need comments on this one
1622 * @prio_tc_map XXX: need comments on this one 1622 * @prio_tc_map: XXX: need comments on this one
1623 * 1623 *
1624 * @fcoe_ddp_xid: Max exchange id for FCoE LRO by ddp 1624 * @fcoe_ddp_xid: Max exchange id for FCoE LRO by ddp
1625 * 1625 *
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 2ab233661ae5..a58cca8bcb29 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -29,6 +29,7 @@ struct phy_device *of_phy_attach(struct net_device *dev,
29extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); 29extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
30extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np); 30extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
31extern int of_phy_register_fixed_link(struct device_node *np); 31extern int of_phy_register_fixed_link(struct device_node *np);
32extern void of_phy_deregister_fixed_link(struct device_node *np);
32extern bool of_phy_is_fixed_link(struct device_node *np); 33extern bool of_phy_is_fixed_link(struct device_node *np);
33 34
34#else /* CONFIG_OF */ 35#else /* CONFIG_OF */
@@ -83,6 +84,9 @@ static inline int of_phy_register_fixed_link(struct device_node *np)
83{ 84{
84 return -ENOSYS; 85 return -ENOSYS;
85} 86}
87static inline void of_phy_deregister_fixed_link(struct device_node *np)
88{
89}
86static inline bool of_phy_is_fixed_link(struct device_node *np) 90static inline bool of_phy_is_fixed_link(struct device_node *np)
87{ 91{
88 return false; 92 return false;
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index dd15d39e1985..7dbe9148b2f8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -374,16 +374,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
374} 374}
375 375
376/* 376/*
377 * Get the offset in PAGE_SIZE. 377 * Get index of the page with in radix-tree
378 * (TODO: hugepage should have ->index in PAGE_SIZE) 378 * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
379 */ 379 */
380static inline pgoff_t page_to_pgoff(struct page *page) 380static inline pgoff_t page_to_index(struct page *page)
381{ 381{
382 pgoff_t pgoff; 382 pgoff_t pgoff;
383 383
384 if (unlikely(PageHeadHuge(page)))
385 return page->index << compound_order(page);
386
387 if (likely(!PageTransTail(page))) 384 if (likely(!PageTransTail(page)))
388 return page->index; 385 return page->index;
389 386
@@ -397,6 +394,18 @@ static inline pgoff_t page_to_pgoff(struct page *page)
397} 394}
398 395
399/* 396/*
397 * Get the offset in PAGE_SIZE.
398 * (TODO: hugepage should have ->index in PAGE_SIZE)
399 */
400static inline pgoff_t page_to_pgoff(struct page *page)
401{
402 if (unlikely(PageHeadHuge(page)))
403 return page->index << compound_order(page);
404
405 return page_to_index(page);
406}
407
408/*
400 * Return byte-offset into filesystem object for page. 409 * Return byte-offset into filesystem object for page.
401 */ 410 */
402static inline loff_t page_offset(struct page *page) 411static inline loff_t page_offset(struct page *page)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 0e49f70dbd9b..a38772a85588 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1928,6 +1928,20 @@ static inline int pci_pcie_type(const struct pci_dev *dev)
1928 return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; 1928 return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
1929} 1929}
1930 1930
1931static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
1932{
1933 while (1) {
1934 if (!pci_is_pcie(dev))
1935 break;
1936 if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
1937 return dev;
1938 if (!dev->bus->self)
1939 break;
1940 dev = dev->bus->self;
1941 }
1942 return NULL;
1943}
1944
1931void pci_request_acs(void); 1945void pci_request_acs(void);
1932bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); 1946bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
1933bool pci_acs_path_enabled(struct pci_dev *start, 1947bool pci_acs_path_enabled(struct pci_dev *start,
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 3a375d07d0dc..00d232406f18 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -81,7 +81,8 @@
81#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC) 81#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC)
82 82
83/* Driver flags */ 83/* Driver flags */
84#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */ 84#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
85#define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04 /* Avoid altsetting toggle during init */
85 86
86#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ 87#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
87 (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) 88 (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f00bf667ec33..554671c81f4a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1018,7 +1018,7 @@ static inline void hci_set_drvdata(struct hci_dev *hdev, void *data)
1018} 1018}
1019 1019
1020struct hci_dev *hci_dev_get(int index); 1020struct hci_dev *hci_dev_get(int index);
1021struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); 1021struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, u8 src_type);
1022 1022
1023struct hci_dev *hci_alloc_dev(void); 1023struct hci_dev *hci_alloc_dev(void);
1024void hci_free_dev(struct hci_dev *hdev); 1024void hci_free_dev(struct hci_dev *hdev);
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 8fed1cd78658..f11ca837361b 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -970,6 +970,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname,
970int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, 970int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
971 char __user *optval, int __user *optlen); 971 char __user *optval, int __user *optlen);
972 972
973int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr,
974 int addr_len);
973int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); 975int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len);
974int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr, 976int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr,
975 int addr_len); 977 int addr_len);
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 50418052a520..d9d52c020a70 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -100,6 +100,9 @@ struct nf_conn {
100 100
101 possible_net_t ct_net; 101 possible_net_t ct_net;
102 102
103#if IS_ENABLED(CONFIG_NF_NAT)
104 struct rhlist_head nat_bysource;
105#endif
103 /* all members below initialized via memset */ 106 /* all members below initialized via memset */
104 u8 __nfct_init_offset[0]; 107 u8 __nfct_init_offset[0];
105 108
@@ -117,9 +120,6 @@ struct nf_conn {
117 /* Extensions */ 120 /* Extensions */
118 struct nf_ct_ext *ext; 121 struct nf_ct_ext *ext;
119 122
120#if IS_ENABLED(CONFIG_NF_NAT)
121 struct rhash_head nat_bysource;
122#endif
123 /* Storage reserved for other modules, must be the last member */ 123 /* Storage reserved for other modules, must be the last member */
124 union nf_conntrack_proto proto; 124 union nf_conntrack_proto proto;
125}; 125};
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index d79d1e9b9546..b02af0bf5777 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -313,7 +313,7 @@ void nft_unregister_set(struct nft_set_ops *ops);
313 * @size: maximum set size 313 * @size: maximum set size
314 * @nelems: number of elements 314 * @nelems: number of elements
315 * @ndeact: number of deactivated elements queued for removal 315 * @ndeact: number of deactivated elements queued for removal
316 * @timeout: default timeout value in msecs 316 * @timeout: default timeout value in jiffies
317 * @gc_int: garbage collection interval in msecs 317 * @gc_int: garbage collection interval in msecs
318 * @policy: set parameterization (see enum nft_set_policies) 318 * @policy: set parameterization (see enum nft_set_policies)
319 * @udlen: user data length 319 * @udlen: user data length
diff --git a/include/uapi/linux/can.h b/include/uapi/linux/can.h
index 9692cda5f8fc..c48d93a28d1a 100644
--- a/include/uapi/linux/can.h
+++ b/include/uapi/linux/can.h
@@ -196,5 +196,6 @@ struct can_filter {
196}; 196};
197 197
198#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */ 198#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
199#define CAN_RAW_FILTER_MAX 512 /* maximum number of can_filter set via setsockopt() */
199 200
200#endif /* !_UAPI_CAN_H */ 201#endif /* !_UAPI_CAN_H */
diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index e601c8c3bdc7..1158a043342a 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -31,7 +31,7 @@
31#include <linux/hdlc/ioctl.h> 31#include <linux/hdlc/ioctl.h>
32 32
33/* For glibc compatibility. An empty enum does not compile. */ 33/* For glibc compatibility. An empty enum does not compile. */
34#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && \ 34#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \
35 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 35 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
36/** 36/**
37 * enum net_device_flags - &struct net_device flags 37 * enum net_device_flags - &struct net_device flags
@@ -99,7 +99,7 @@ enum net_device_flags {
99 IFF_ECHO = 1<<18, /* volatile */ 99 IFF_ECHO = 1<<18, /* volatile */
100#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ 100#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
101}; 101};
102#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */ 102#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */
103 103
104/* for compatibility with glibc net/if.h */ 104/* for compatibility with glibc net/if.h */
105#if __UAPI_DEF_IF_NET_DEVICE_FLAGS 105#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index d6d071fc3c56..3af60ee69053 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -640,7 +640,7 @@
640 * Control a data application associated with the currently viewed channel, 640 * Control a data application associated with the currently viewed channel,
641 * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) 641 * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
642 */ 642 */
643#define KEY_DATA 0x275 643#define KEY_DATA 0x277
644 644
645#define BTN_TRIGGER_HAPPY 0x2c0 645#define BTN_TRIGGER_HAPPY 0x2c0
646#define BTN_TRIGGER_HAPPY1 0x2c0 646#define BTN_TRIGGER_HAPPY1 0x2c0
diff --git a/include/uapi/linux/netfilter/Kbuild b/include/uapi/linux/netfilter/Kbuild
index cd26d7a0fd07..03f194aeadc5 100644
--- a/include/uapi/linux/netfilter/Kbuild
+++ b/include/uapi/linux/netfilter/Kbuild
@@ -5,6 +5,7 @@ header-y += nf_conntrack_ftp.h
5header-y += nf_conntrack_sctp.h 5header-y += nf_conntrack_sctp.h
6header-y += nf_conntrack_tcp.h 6header-y += nf_conntrack_tcp.h
7header-y += nf_conntrack_tuple_common.h 7header-y += nf_conntrack_tuple_common.h
8header-y += nf_log.h
8header-y += nf_tables.h 9header-y += nf_tables.h
9header-y += nf_tables_compat.h 10header-y += nf_tables_compat.h
10header-y += nf_nat.h 11header-y += nf_nat.h
diff --git a/include/uapi/linux/tc_act/Kbuild b/include/uapi/linux/tc_act/Kbuild
index e3969bd939e4..e3db7403296f 100644
--- a/include/uapi/linux/tc_act/Kbuild
+++ b/include/uapi/linux/tc_act/Kbuild
@@ -11,3 +11,5 @@ header-y += tc_vlan.h
11header-y += tc_bpf.h 11header-y += tc_bpf.h
12header-y += tc_connmark.h 12header-y += tc_connmark.h
13header-y += tc_ife.h 13header-y += tc_ife.h
14header-y += tc_tunnel_key.h
15header-y += tc_skbmod.h
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 8a09b32e07d6..dd4104c9aa12 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -272,7 +272,7 @@ int __init rd_load_image(char *from)
272 sys_write(out_fd, buf, BLOCK_SIZE); 272 sys_write(out_fd, buf, BLOCK_SIZE);
273#if !defined(CONFIG_S390) 273#if !defined(CONFIG_S390)
274 if (!(i % 16)) { 274 if (!(i % 16)) {
275 printk("%c\b", rotator[rotate & 0x3]); 275 pr_cont("%c\b", rotator[rotate & 0x3]);
276 rotate++; 276 rotate++;
277 } 277 }
278#endif 278#endif
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 6a936159c6e0..8199821f54cf 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2454,6 +2454,7 @@ static bool states_equal(struct bpf_verifier_env *env,
2454 struct bpf_verifier_state *old, 2454 struct bpf_verifier_state *old,
2455 struct bpf_verifier_state *cur) 2455 struct bpf_verifier_state *cur)
2456{ 2456{
2457 bool varlen_map_access = env->varlen_map_value_access;
2457 struct bpf_reg_state *rold, *rcur; 2458 struct bpf_reg_state *rold, *rcur;
2458 int i; 2459 int i;
2459 2460
@@ -2467,12 +2468,17 @@ static bool states_equal(struct bpf_verifier_env *env,
2467 /* If the ranges were not the same, but everything else was and 2468 /* If the ranges were not the same, but everything else was and
2468 * we didn't do a variable access into a map then we are a-ok. 2469 * we didn't do a variable access into a map then we are a-ok.
2469 */ 2470 */
2470 if (!env->varlen_map_value_access && 2471 if (!varlen_map_access &&
2471 rold->type == rcur->type && rold->imm == rcur->imm) 2472 rold->type == rcur->type && rold->imm == rcur->imm)
2472 continue; 2473 continue;
2473 2474
2475 /* If we didn't map access then again we don't care about the
2476 * mismatched range values and it's ok if our old type was
2477 * UNKNOWN and we didn't go to a NOT_INIT'ed reg.
2478 */
2474 if (rold->type == NOT_INIT || 2479 if (rold->type == NOT_INIT ||
2475 (rold->type == UNKNOWN_VALUE && rcur->type != NOT_INIT)) 2480 (!varlen_map_access && rold->type == UNKNOWN_VALUE &&
2481 rcur->type != NOT_INIT))
2476 continue; 2482 continue;
2477 2483
2478 if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET && 2484 if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET &&
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6ee1febdf6ff..02c8421f8c01 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -903,17 +903,14 @@ list_update_cgroup_event(struct perf_event *event,
903 */ 903 */
904 cpuctx = __get_cpu_context(ctx); 904 cpuctx = __get_cpu_context(ctx);
905 905
906 /* Only set/clear cpuctx->cgrp if current task uses event->cgrp. */ 906 /*
907 if (perf_cgroup_from_task(current, ctx) != event->cgrp) { 907 * cpuctx->cgrp is NULL until a cgroup event is sched in or
908 /* 908 * ctx->nr_cgroup == 0 .
909 * We are removing the last cpu event in this context. 909 */
910 * If that event is not active in this cpu, cpuctx->cgrp 910 if (add && perf_cgroup_from_task(current, ctx) == event->cgrp)
911 * should've been cleared by perf_cgroup_switch. 911 cpuctx->cgrp = event->cgrp;
912 */ 912 else if (!add)
913 WARN_ON_ONCE(!add && cpuctx->cgrp); 913 cpuctx->cgrp = NULL;
914 return;
915 }
916 cpuctx->cgrp = add ? event->cgrp : NULL;
917} 914}
918 915
919#else /* !CONFIG_CGROUP_PERF */ 916#else /* !CONFIG_CGROUP_PERF */
diff --git a/kernel/kcov.c b/kernel/kcov.c
index 30e6d05aa5a9..3cbb0c879705 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -7,6 +7,7 @@
7#include <linux/fs.h> 7#include <linux/fs.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/printk.h> 9#include <linux/printk.h>
10#include <linux/sched.h>
10#include <linux/slab.h> 11#include <linux/slab.h>
11#include <linux/spinlock.h> 12#include <linux/spinlock.h>
12#include <linux/vmalloc.h> 13#include <linux/vmalloc.h>
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index e74b438c850b..7bd265f6b098 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -506,13 +506,13 @@ static void __print_lock_name(struct lock_class *class)
506 name = class->name; 506 name = class->name;
507 if (!name) { 507 if (!name) {
508 name = __get_key_name(class->key, str); 508 name = __get_key_name(class->key, str);
509 printk("%s", name); 509 printk(KERN_CONT "%s", name);
510 } else { 510 } else {
511 printk("%s", name); 511 printk(KERN_CONT "%s", name);
512 if (class->name_version > 1) 512 if (class->name_version > 1)
513 printk("#%d", class->name_version); 513 printk(KERN_CONT "#%d", class->name_version);
514 if (class->subclass) 514 if (class->subclass)
515 printk("/%d", class->subclass); 515 printk(KERN_CONT "/%d", class->subclass);
516 } 516 }
517} 517}
518 518
@@ -522,9 +522,9 @@ static void print_lock_name(struct lock_class *class)
522 522
523 get_usage_chars(class, usage); 523 get_usage_chars(class, usage);
524 524
525 printk(" ("); 525 printk(KERN_CONT " (");
526 __print_lock_name(class); 526 __print_lock_name(class);
527 printk("){%s}", usage); 527 printk(KERN_CONT "){%s}", usage);
528} 528}
529 529
530static void print_lockdep_cache(struct lockdep_map *lock) 530static void print_lockdep_cache(struct lockdep_map *lock)
@@ -536,7 +536,7 @@ static void print_lockdep_cache(struct lockdep_map *lock)
536 if (!name) 536 if (!name)
537 name = __get_key_name(lock->key->subkeys, str); 537 name = __get_key_name(lock->key->subkeys, str);
538 538
539 printk("%s", name); 539 printk(KERN_CONT "%s", name);
540} 540}
541 541
542static void print_lock(struct held_lock *hlock) 542static void print_lock(struct held_lock *hlock)
@@ -551,13 +551,13 @@ static void print_lock(struct held_lock *hlock)
551 barrier(); 551 barrier();
552 552
553 if (!class_idx || (class_idx - 1) >= MAX_LOCKDEP_KEYS) { 553 if (!class_idx || (class_idx - 1) >= MAX_LOCKDEP_KEYS) {
554 printk("<RELEASED>\n"); 554 printk(KERN_CONT "<RELEASED>\n");
555 return; 555 return;
556 } 556 }
557 557
558 print_lock_name(lock_classes + class_idx - 1); 558 print_lock_name(lock_classes + class_idx - 1);
559 printk(", at: "); 559 printk(KERN_CONT ", at: [<%p>] %pS\n",
560 print_ip_sym(hlock->acquire_ip); 560 (void *)hlock->acquire_ip, (void *)hlock->acquire_ip);
561} 561}
562 562
563static void lockdep_print_held_locks(struct task_struct *curr) 563static void lockdep_print_held_locks(struct task_struct *curr)
@@ -792,8 +792,8 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
792 792
793 printk("\nnew class %p: %s", class->key, class->name); 793 printk("\nnew class %p: %s", class->key, class->name);
794 if (class->name_version > 1) 794 if (class->name_version > 1)
795 printk("#%d", class->name_version); 795 printk(KERN_CONT "#%d", class->name_version);
796 printk("\n"); 796 printk(KERN_CONT "\n");
797 dump_stack(); 797 dump_stack();
798 798
799 if (!graph_lock()) { 799 if (!graph_lock()) {
@@ -1071,7 +1071,7 @@ print_circular_bug_entry(struct lock_list *target, int depth)
1071 return 0; 1071 return 0;
1072 printk("\n-> #%u", depth); 1072 printk("\n-> #%u", depth);
1073 print_lock_name(target->class); 1073 print_lock_name(target->class);
1074 printk(":\n"); 1074 printk(KERN_CONT ":\n");
1075 print_stack_trace(&target->trace, 6); 1075 print_stack_trace(&target->trace, 6);
1076 1076
1077 return 0; 1077 return 0;
@@ -1102,11 +1102,11 @@ print_circular_lock_scenario(struct held_lock *src,
1102 if (parent != source) { 1102 if (parent != source) {
1103 printk("Chain exists of:\n "); 1103 printk("Chain exists of:\n ");
1104 __print_lock_name(source); 1104 __print_lock_name(source);
1105 printk(" --> "); 1105 printk(KERN_CONT " --> ");
1106 __print_lock_name(parent); 1106 __print_lock_name(parent);
1107 printk(" --> "); 1107 printk(KERN_CONT " --> ");
1108 __print_lock_name(target); 1108 __print_lock_name(target);
1109 printk("\n\n"); 1109 printk(KERN_CONT "\n\n");
1110 } 1110 }
1111 1111
1112 printk(" Possible unsafe locking scenario:\n\n"); 1112 printk(" Possible unsafe locking scenario:\n\n");
@@ -1114,16 +1114,16 @@ print_circular_lock_scenario(struct held_lock *src,
1114 printk(" ---- ----\n"); 1114 printk(" ---- ----\n");
1115 printk(" lock("); 1115 printk(" lock(");
1116 __print_lock_name(target); 1116 __print_lock_name(target);
1117 printk(");\n"); 1117 printk(KERN_CONT ");\n");
1118 printk(" lock("); 1118 printk(" lock(");
1119 __print_lock_name(parent); 1119 __print_lock_name(parent);
1120 printk(");\n"); 1120 printk(KERN_CONT ");\n");
1121 printk(" lock("); 1121 printk(" lock(");
1122 __print_lock_name(target); 1122 __print_lock_name(target);
1123 printk(");\n"); 1123 printk(KERN_CONT ");\n");
1124 printk(" lock("); 1124 printk(" lock(");
1125 __print_lock_name(source); 1125 __print_lock_name(source);
1126 printk(");\n"); 1126 printk(KERN_CONT ");\n");
1127 printk("\n *** DEADLOCK ***\n\n"); 1127 printk("\n *** DEADLOCK ***\n\n");
1128} 1128}
1129 1129
@@ -1359,22 +1359,22 @@ static void print_lock_class_header(struct lock_class *class, int depth)
1359 1359
1360 printk("%*s->", depth, ""); 1360 printk("%*s->", depth, "");
1361 print_lock_name(class); 1361 print_lock_name(class);
1362 printk(" ops: %lu", class->ops); 1362 printk(KERN_CONT " ops: %lu", class->ops);
1363 printk(" {\n"); 1363 printk(KERN_CONT " {\n");
1364 1364
1365 for (bit = 0; bit < LOCK_USAGE_STATES; bit++) { 1365 for (bit = 0; bit < LOCK_USAGE_STATES; bit++) {
1366 if (class->usage_mask & (1 << bit)) { 1366 if (class->usage_mask & (1 << bit)) {
1367 int len = depth; 1367 int len = depth;
1368 1368
1369 len += printk("%*s %s", depth, "", usage_str[bit]); 1369 len += printk("%*s %s", depth, "", usage_str[bit]);
1370 len += printk(" at:\n"); 1370 len += printk(KERN_CONT " at:\n");
1371 print_stack_trace(class->usage_traces + bit, len); 1371 print_stack_trace(class->usage_traces + bit, len);
1372 } 1372 }
1373 } 1373 }
1374 printk("%*s }\n", depth, ""); 1374 printk("%*s }\n", depth, "");
1375 1375
1376 printk("%*s ... key at: ",depth,""); 1376 printk("%*s ... key at: [<%p>] %pS\n",
1377 print_ip_sym((unsigned long)class->key); 1377 depth, "", class->key, class->key);
1378} 1378}
1379 1379
1380/* 1380/*
@@ -1437,11 +1437,11 @@ print_irq_lock_scenario(struct lock_list *safe_entry,
1437 if (middle_class != unsafe_class) { 1437 if (middle_class != unsafe_class) {
1438 printk("Chain exists of:\n "); 1438 printk("Chain exists of:\n ");
1439 __print_lock_name(safe_class); 1439 __print_lock_name(safe_class);
1440 printk(" --> "); 1440 printk(KERN_CONT " --> ");
1441 __print_lock_name(middle_class); 1441 __print_lock_name(middle_class);
1442 printk(" --> "); 1442 printk(KERN_CONT " --> ");
1443 __print_lock_name(unsafe_class); 1443 __print_lock_name(unsafe_class);
1444 printk("\n\n"); 1444 printk(KERN_CONT "\n\n");
1445 } 1445 }
1446 1446
1447 printk(" Possible interrupt unsafe locking scenario:\n\n"); 1447 printk(" Possible interrupt unsafe locking scenario:\n\n");
@@ -1449,18 +1449,18 @@ print_irq_lock_scenario(struct lock_list *safe_entry,
1449 printk(" ---- ----\n"); 1449 printk(" ---- ----\n");
1450 printk(" lock("); 1450 printk(" lock(");
1451 __print_lock_name(unsafe_class); 1451 __print_lock_name(unsafe_class);
1452 printk(");\n"); 1452 printk(KERN_CONT ");\n");
1453 printk(" local_irq_disable();\n"); 1453 printk(" local_irq_disable();\n");
1454 printk(" lock("); 1454 printk(" lock(");
1455 __print_lock_name(safe_class); 1455 __print_lock_name(safe_class);
1456 printk(");\n"); 1456 printk(KERN_CONT ");\n");
1457 printk(" lock("); 1457 printk(" lock(");
1458 __print_lock_name(middle_class); 1458 __print_lock_name(middle_class);
1459 printk(");\n"); 1459 printk(KERN_CONT ");\n");
1460 printk(" <Interrupt>\n"); 1460 printk(" <Interrupt>\n");
1461 printk(" lock("); 1461 printk(" lock(");
1462 __print_lock_name(safe_class); 1462 __print_lock_name(safe_class);
1463 printk(");\n"); 1463 printk(KERN_CONT ");\n");
1464 printk("\n *** DEADLOCK ***\n\n"); 1464 printk("\n *** DEADLOCK ***\n\n");
1465} 1465}
1466 1466
@@ -1497,9 +1497,9 @@ print_bad_irq_dependency(struct task_struct *curr,
1497 print_lock(prev); 1497 print_lock(prev);
1498 printk("which would create a new lock dependency:\n"); 1498 printk("which would create a new lock dependency:\n");
1499 print_lock_name(hlock_class(prev)); 1499 print_lock_name(hlock_class(prev));
1500 printk(" ->"); 1500 printk(KERN_CONT " ->");
1501 print_lock_name(hlock_class(next)); 1501 print_lock_name(hlock_class(next));
1502 printk("\n"); 1502 printk(KERN_CONT "\n");
1503 1503
1504 printk("\nbut this new dependency connects a %s-irq-safe lock:\n", 1504 printk("\nbut this new dependency connects a %s-irq-safe lock:\n",
1505 irqclass); 1505 irqclass);
@@ -1521,8 +1521,7 @@ print_bad_irq_dependency(struct task_struct *curr,
1521 1521
1522 lockdep_print_held_locks(curr); 1522 lockdep_print_held_locks(curr);
1523 1523
1524 printk("\nthe dependencies between %s-irq-safe lock", irqclass); 1524 printk("\nthe dependencies between %s-irq-safe lock and the holding lock:\n", irqclass);
1525 printk(" and the holding lock:\n");
1526 if (!save_trace(&prev_root->trace)) 1525 if (!save_trace(&prev_root->trace))
1527 return 0; 1526 return 0;
1528 print_shortest_lock_dependencies(backwards_entry, prev_root); 1527 print_shortest_lock_dependencies(backwards_entry, prev_root);
@@ -1694,10 +1693,10 @@ print_deadlock_scenario(struct held_lock *nxt,
1694 printk(" ----\n"); 1693 printk(" ----\n");
1695 printk(" lock("); 1694 printk(" lock(");
1696 __print_lock_name(prev); 1695 __print_lock_name(prev);
1697 printk(");\n"); 1696 printk(KERN_CONT ");\n");
1698 printk(" lock("); 1697 printk(" lock(");
1699 __print_lock_name(next); 1698 __print_lock_name(next);
1700 printk(");\n"); 1699 printk(KERN_CONT ");\n");
1701 printk("\n *** DEADLOCK ***\n\n"); 1700 printk("\n *** DEADLOCK ***\n\n");
1702 printk(" May be due to missing lock nesting notation\n\n"); 1701 printk(" May be due to missing lock nesting notation\n\n");
1703} 1702}
@@ -1891,9 +1890,9 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
1891 graph_unlock(); 1890 graph_unlock();
1892 printk("\n new dependency: "); 1891 printk("\n new dependency: ");
1893 print_lock_name(hlock_class(prev)); 1892 print_lock_name(hlock_class(prev));
1894 printk(" => "); 1893 printk(KERN_CONT " => ");
1895 print_lock_name(hlock_class(next)); 1894 print_lock_name(hlock_class(next));
1896 printk("\n"); 1895 printk(KERN_CONT "\n");
1897 dump_stack(); 1896 dump_stack();
1898 return graph_lock(); 1897 return graph_lock();
1899 } 1898 }
@@ -2343,11 +2342,11 @@ print_usage_bug_scenario(struct held_lock *lock)
2343 printk(" ----\n"); 2342 printk(" ----\n");
2344 printk(" lock("); 2343 printk(" lock(");
2345 __print_lock_name(class); 2344 __print_lock_name(class);
2346 printk(");\n"); 2345 printk(KERN_CONT ");\n");
2347 printk(" <Interrupt>\n"); 2346 printk(" <Interrupt>\n");
2348 printk(" lock("); 2347 printk(" lock(");
2349 __print_lock_name(class); 2348 __print_lock_name(class);
2350 printk(");\n"); 2349 printk(KERN_CONT ");\n");
2351 printk("\n *** DEADLOCK ***\n\n"); 2350 printk("\n *** DEADLOCK ***\n\n");
2352} 2351}
2353 2352
@@ -2522,14 +2521,18 @@ check_usage_backwards(struct task_struct *curr, struct held_lock *this,
2522void print_irqtrace_events(struct task_struct *curr) 2521void print_irqtrace_events(struct task_struct *curr)
2523{ 2522{
2524 printk("irq event stamp: %u\n", curr->irq_events); 2523 printk("irq event stamp: %u\n", curr->irq_events);
2525 printk("hardirqs last enabled at (%u): ", curr->hardirq_enable_event); 2524 printk("hardirqs last enabled at (%u): [<%p>] %pS\n",
2526 print_ip_sym(curr->hardirq_enable_ip); 2525 curr->hardirq_enable_event, (void *)curr->hardirq_enable_ip,
2527 printk("hardirqs last disabled at (%u): ", curr->hardirq_disable_event); 2526 (void *)curr->hardirq_enable_ip);
2528 print_ip_sym(curr->hardirq_disable_ip); 2527 printk("hardirqs last disabled at (%u): [<%p>] %pS\n",
2529 printk("softirqs last enabled at (%u): ", curr->softirq_enable_event); 2528 curr->hardirq_disable_event, (void *)curr->hardirq_disable_ip,
2530 print_ip_sym(curr->softirq_enable_ip); 2529 (void *)curr->hardirq_disable_ip);
2531 printk("softirqs last disabled at (%u): ", curr->softirq_disable_event); 2530 printk("softirqs last enabled at (%u): [<%p>] %pS\n",
2532 print_ip_sym(curr->softirq_disable_ip); 2531 curr->softirq_enable_event, (void *)curr->softirq_enable_ip,
2532 (void *)curr->softirq_enable_ip);
2533 printk("softirqs last disabled at (%u): [<%p>] %pS\n",
2534 curr->softirq_disable_event, (void *)curr->softirq_disable_ip,
2535 (void *)curr->softirq_disable_ip);
2533} 2536}
2534 2537
2535static int HARDIRQ_verbose(struct lock_class *class) 2538static int HARDIRQ_verbose(struct lock_class *class)
@@ -3235,8 +3238,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
3235 if (very_verbose(class)) { 3238 if (very_verbose(class)) {
3236 printk("\nacquire class [%p] %s", class->key, class->name); 3239 printk("\nacquire class [%p] %s", class->key, class->name);
3237 if (class->name_version > 1) 3240 if (class->name_version > 1)
3238 printk("#%d", class->name_version); 3241 printk(KERN_CONT "#%d", class->name_version);
3239 printk("\n"); 3242 printk(KERN_CONT "\n");
3240 dump_stack(); 3243 dump_stack();
3241 } 3244 }
3242 3245
@@ -3378,7 +3381,7 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
3378 printk("%s/%d is trying to release lock (", 3381 printk("%s/%d is trying to release lock (",
3379 curr->comm, task_pid_nr(curr)); 3382 curr->comm, task_pid_nr(curr));
3380 print_lockdep_cache(lock); 3383 print_lockdep_cache(lock);
3381 printk(") at:\n"); 3384 printk(KERN_CONT ") at:\n");
3382 print_ip_sym(ip); 3385 print_ip_sym(ip);
3383 printk("but there are no more locks to release!\n"); 3386 printk("but there are no more locks to release!\n");
3384 printk("\nother info that might help us debug this:\n"); 3387 printk("\nother info that might help us debug this:\n");
@@ -3871,7 +3874,7 @@ print_lock_contention_bug(struct task_struct *curr, struct lockdep_map *lock,
3871 printk("%s/%d is trying to contend lock (", 3874 printk("%s/%d is trying to contend lock (",
3872 curr->comm, task_pid_nr(curr)); 3875 curr->comm, task_pid_nr(curr));
3873 print_lockdep_cache(lock); 3876 print_lockdep_cache(lock);
3874 printk(") at:\n"); 3877 printk(KERN_CONT ") at:\n");
3875 print_ip_sym(ip); 3878 print_ip_sym(ip);
3876 printk("but there are no locks held!\n"); 3879 printk("but there are no locks held!\n");
3877 printk("\nother info that might help us debug this:\n"); 3880 printk("\nother info that might help us debug this:\n");
diff --git a/kernel/module.c b/kernel/module.c
index f57dd63186e6..0e54d5bf0097 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1301,8 +1301,9 @@ static int check_version(Elf_Shdr *sechdrs,
1301 goto bad_version; 1301 goto bad_version;
1302 } 1302 }
1303 1303
1304 pr_warn("%s: no symbol version for %s\n", mod->name, symname); 1304 /* Broken toolchain. Warn once, then let it go.. */
1305 return 0; 1305 pr_warn_once("%s: no symbol version for %s\n", mod->name, symname);
1306 return 1;
1306 1307
1307bad_version: 1308bad_version:
1308 pr_warn("%s: disagrees about version of symbol %s\n", 1309 pr_warn("%s: disagrees about version of symbol %s\n",
diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index f1c8fd566246..da39489d2d80 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -212,6 +212,7 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
212{ 212{
213 static unsigned long next = INITIAL_JIFFIES; 213 static unsigned long next = INITIAL_JIFFIES;
214 struct autogroup *ag; 214 struct autogroup *ag;
215 unsigned long shares;
215 int err; 216 int err;
216 217
217 if (nice < MIN_NICE || nice > MAX_NICE) 218 if (nice < MIN_NICE || nice > MAX_NICE)
@@ -230,9 +231,10 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
230 231
231 next = HZ / 10 + jiffies; 232 next = HZ / 10 + jiffies;
232 ag = autogroup_task_get(p); 233 ag = autogroup_task_get(p);
234 shares = scale_load(sched_prio_to_weight[nice + 20]);
233 235
234 down_write(&ag->lock); 236 down_write(&ag->lock);
235 err = sched_group_set_shares(ag->tg, sched_prio_to_weight[nice + 20]); 237 err = sched_group_set_shares(ag->tg, shares);
236 if (!err) 238 if (!err)
237 ag->nice = nice; 239 ag->nice = nice;
238 up_write(&ag->lock); 240 up_write(&ag->lock);
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index a8e12601eb37..056052dc8e91 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -362,6 +362,7 @@ void debug_object_init(void *addr, struct debug_obj_descr *descr)
362 362
363 __debug_object_init(addr, descr, 0); 363 __debug_object_init(addr, descr, 0);
364} 364}
365EXPORT_SYMBOL_GPL(debug_object_init);
365 366
366/** 367/**
367 * debug_object_init_on_stack - debug checks when an object on stack is 368 * debug_object_init_on_stack - debug checks when an object on stack is
@@ -376,6 +377,7 @@ void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr)
376 377
377 __debug_object_init(addr, descr, 1); 378 __debug_object_init(addr, descr, 1);
378} 379}
380EXPORT_SYMBOL_GPL(debug_object_init_on_stack);
379 381
380/** 382/**
381 * debug_object_activate - debug checks when an object is activated 383 * debug_object_activate - debug checks when an object is activated
@@ -449,6 +451,7 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr)
449 } 451 }
450 return 0; 452 return 0;
451} 453}
454EXPORT_SYMBOL_GPL(debug_object_activate);
452 455
453/** 456/**
454 * debug_object_deactivate - debug checks when an object is deactivated 457 * debug_object_deactivate - debug checks when an object is deactivated
@@ -496,6 +499,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
496 499
497 raw_spin_unlock_irqrestore(&db->lock, flags); 500 raw_spin_unlock_irqrestore(&db->lock, flags);
498} 501}
502EXPORT_SYMBOL_GPL(debug_object_deactivate);
499 503
500/** 504/**
501 * debug_object_destroy - debug checks when an object is destroyed 505 * debug_object_destroy - debug checks when an object is destroyed
@@ -542,6 +546,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
542out_unlock: 546out_unlock:
543 raw_spin_unlock_irqrestore(&db->lock, flags); 547 raw_spin_unlock_irqrestore(&db->lock, flags);
544} 548}
549EXPORT_SYMBOL_GPL(debug_object_destroy);
545 550
546/** 551/**
547 * debug_object_free - debug checks when an object is freed 552 * debug_object_free - debug checks when an object is freed
@@ -582,6 +587,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr)
582out_unlock: 587out_unlock:
583 raw_spin_unlock_irqrestore(&db->lock, flags); 588 raw_spin_unlock_irqrestore(&db->lock, flags);
584} 589}
590EXPORT_SYMBOL_GPL(debug_object_free);
585 591
586/** 592/**
587 * debug_object_assert_init - debug checks when object should be init-ed 593 * debug_object_assert_init - debug checks when object should be init-ed
@@ -626,6 +632,7 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr)
626 632
627 raw_spin_unlock_irqrestore(&db->lock, flags); 633 raw_spin_unlock_irqrestore(&db->lock, flags);
628} 634}
635EXPORT_SYMBOL_GPL(debug_object_assert_init);
629 636
630/** 637/**
631 * debug_object_active_state - debug checks object usage state machine 638 * debug_object_active_state - debug checks object usage state machine
@@ -673,6 +680,7 @@ debug_object_active_state(void *addr, struct debug_obj_descr *descr,
673 680
674 raw_spin_unlock_irqrestore(&db->lock, flags); 681 raw_spin_unlock_irqrestore(&db->lock, flags);
675} 682}
683EXPORT_SYMBOL_GPL(debug_object_active_state);
676 684
677#ifdef CONFIG_DEBUG_OBJECTS_FREE 685#ifdef CONFIG_DEBUG_OBJECTS_FREE
678static void __debug_check_no_obj_freed(const void *address, unsigned long size) 686static void __debug_check_no_obj_freed(const void *address, unsigned long size)
diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c8744ea9..e24388a863a7 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
64 if (!esize) { 64 if (!esize) {
65 /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 65 /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
66 * depending on if MOD equals 1. */ 66 * depending on if MOD equals 1. */
67 rp[0] = 1;
68 res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1; 67 res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
68 if (res->nlimbs) {
69 if (mpi_resize(res, 1) < 0)
70 goto enomem;
71 rp = res->d;
72 rp[0] = 1;
73 }
69 res->sign = 0; 74 res->sign = 0;
70 goto leave; 75 goto leave;
71 } 76 }
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 5e51872b3fc1..fbdf87920093 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -20,6 +20,11 @@
20#include <linux/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/module.h> 21#include <linux/module.h>
22 22
23/*
24 * Note: test functions are marked noinline so that their names appear in
25 * reports.
26 */
27
23static noinline void __init kmalloc_oob_right(void) 28static noinline void __init kmalloc_oob_right(void)
24{ 29{
25 char *ptr; 30 char *ptr;
@@ -411,6 +416,29 @@ static noinline void __init copy_user_test(void)
411 kfree(kmem); 416 kfree(kmem);
412} 417}
413 418
419static noinline void __init use_after_scope_test(void)
420{
421 volatile char *volatile p;
422
423 pr_info("use-after-scope on int\n");
424 {
425 int local = 0;
426
427 p = (char *)&local;
428 }
429 p[0] = 1;
430 p[3] = 1;
431
432 pr_info("use-after-scope on array\n");
433 {
434 char local[1024] = {0};
435
436 p = local;
437 }
438 p[0] = 1;
439 p[1023] = 1;
440}
441
414static int __init kmalloc_tests_init(void) 442static int __init kmalloc_tests_init(void)
415{ 443{
416 kmalloc_oob_right(); 444 kmalloc_oob_right();
@@ -436,6 +464,7 @@ static int __init kmalloc_tests_init(void)
436 kasan_global_oob(); 464 kasan_global_oob();
437 ksize_unpoisons_memory(); 465 ksize_unpoisons_memory();
438 copy_user_test(); 466 copy_user_test();
467 use_after_scope_test();
439 return -EAGAIN; 468 return -EAGAIN;
440} 469}
441 470
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index eff3de359d50..d4a6e4001512 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1456,9 +1456,9 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
1456 new_ptl = pmd_lockptr(mm, new_pmd); 1456 new_ptl = pmd_lockptr(mm, new_pmd);
1457 if (new_ptl != old_ptl) 1457 if (new_ptl != old_ptl)
1458 spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING); 1458 spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
1459 if (pmd_present(*old_pmd) && pmd_dirty(*old_pmd))
1460 force_flush = true;
1461 pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd); 1459 pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
1460 if (pmd_present(pmd) && pmd_dirty(pmd))
1461 force_flush = true;
1462 VM_BUG_ON(!pmd_none(*new_pmd)); 1462 VM_BUG_ON(!pmd_none(*new_pmd));
1463 1463
1464 if (pmd_move_must_withdraw(new_ptl, old_ptl) && 1464 if (pmd_move_must_withdraw(new_ptl, old_ptl) &&
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 70c009741aab..0e9505f66ec1 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -764,6 +764,25 @@ EXPORT_SYMBOL(__asan_storeN_noabort);
764void __asan_handle_no_return(void) {} 764void __asan_handle_no_return(void) {}
765EXPORT_SYMBOL(__asan_handle_no_return); 765EXPORT_SYMBOL(__asan_handle_no_return);
766 766
767/* Emitted by compiler to poison large objects when they go out of scope. */
768void __asan_poison_stack_memory(const void *addr, size_t size)
769{
770 /*
771 * Addr is KASAN_SHADOW_SCALE_SIZE-aligned and the object is surrounded
772 * by redzones, so we simply round up size to simplify logic.
773 */
774 kasan_poison_shadow(addr, round_up(size, KASAN_SHADOW_SCALE_SIZE),
775 KASAN_USE_AFTER_SCOPE);
776}
777EXPORT_SYMBOL(__asan_poison_stack_memory);
778
779/* Emitted by compiler to unpoison large objects when they go into scope. */
780void __asan_unpoison_stack_memory(const void *addr, size_t size)
781{
782 kasan_unpoison_shadow(addr, size);
783}
784EXPORT_SYMBOL(__asan_unpoison_stack_memory);
785
767#ifdef CONFIG_MEMORY_HOTPLUG 786#ifdef CONFIG_MEMORY_HOTPLUG
768static int kasan_mem_notifier(struct notifier_block *nb, 787static int kasan_mem_notifier(struct notifier_block *nb,
769 unsigned long action, void *data) 788 unsigned long action, void *data)
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index e5c2181fee6f..1c260e6b3b3c 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -21,6 +21,7 @@
21#define KASAN_STACK_MID 0xF2 21#define KASAN_STACK_MID 0xF2
22#define KASAN_STACK_RIGHT 0xF3 22#define KASAN_STACK_RIGHT 0xF3
23#define KASAN_STACK_PARTIAL 0xF4 23#define KASAN_STACK_PARTIAL 0xF4
24#define KASAN_USE_AFTER_SCOPE 0xF8
24 25
25/* Don't break randconfig/all*config builds */ 26/* Don't break randconfig/all*config builds */
26#ifndef KASAN_ABI_VERSION 27#ifndef KASAN_ABI_VERSION
@@ -53,6 +54,9 @@ struct kasan_global {
53#if KASAN_ABI_VERSION >= 4 54#if KASAN_ABI_VERSION >= 4
54 struct kasan_source_location *location; 55 struct kasan_source_location *location;
55#endif 56#endif
57#if KASAN_ABI_VERSION >= 5
58 char *odr_indicator;
59#endif
56}; 60};
57 61
58/** 62/**
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 24c1211fe9d5..073325aedc68 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -90,6 +90,9 @@ static void print_error_description(struct kasan_access_info *info)
90 case KASAN_KMALLOC_FREE: 90 case KASAN_KMALLOC_FREE:
91 bug_type = "use-after-free"; 91 bug_type = "use-after-free";
92 break; 92 break;
93 case KASAN_USE_AFTER_SCOPE:
94 bug_type = "use-after-scope";
95 break;
93 } 96 }
94 97
95 pr_err("BUG: KASAN: %s in %pS at addr %p\n", 98 pr_err("BUG: KASAN: %s in %pS at addr %p\n",
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 728d7790dc2d..87e1a7ca3846 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -103,6 +103,7 @@ static struct khugepaged_scan khugepaged_scan = {
103 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head), 103 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head),
104}; 104};
105 105
106#ifdef CONFIG_SYSFS
106static ssize_t scan_sleep_millisecs_show(struct kobject *kobj, 107static ssize_t scan_sleep_millisecs_show(struct kobject *kobj,
107 struct kobj_attribute *attr, 108 struct kobj_attribute *attr,
108 char *buf) 109 char *buf)
@@ -295,6 +296,7 @@ struct attribute_group khugepaged_attr_group = {
295 .attrs = khugepaged_attr, 296 .attrs = khugepaged_attr,
296 .name = "khugepaged", 297 .name = "khugepaged",
297}; 298};
299#endif /* CONFIG_SYSFS */
298 300
299#define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB) 301#define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB)
300 302
diff --git a/mm/mlock.c b/mm/mlock.c
index 145a4258ddbc..cdbed8aaa426 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -190,10 +190,13 @@ unsigned int munlock_vma_page(struct page *page)
190 */ 190 */
191 spin_lock_irq(zone_lru_lock(zone)); 191 spin_lock_irq(zone_lru_lock(zone));
192 192
193 nr_pages = hpage_nr_pages(page); 193 if (!TestClearPageMlocked(page)) {
194 if (!TestClearPageMlocked(page)) 194 /* Potentially, PTE-mapped THP: do not skip the rest PTEs */
195 nr_pages = 1;
195 goto unlock_out; 196 goto unlock_out;
197 }
196 198
199 nr_pages = hpage_nr_pages(page);
197 __mod_zone_page_state(zone, NR_MLOCK, -nr_pages); 200 __mod_zone_page_state(zone, NR_MLOCK, -nr_pages);
198 201
199 if (__munlock_isolate_lru_page(page, true)) { 202 if (__munlock_isolate_lru_page(page, true)) {
diff --git a/mm/mremap.c b/mm/mremap.c
index 6ccecc03f56a..30d7d2482eea 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -149,14 +149,18 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
149 if (pte_none(*old_pte)) 149 if (pte_none(*old_pte))
150 continue; 150 continue;
151 151
152 pte = ptep_get_and_clear(mm, old_addr, old_pte);
152 /* 153 /*
153 * We are remapping a dirty PTE, make sure to 154 * If we are remapping a dirty PTE, make sure
154 * flush TLB before we drop the PTL for the 155 * to flush TLB before we drop the PTL for the
155 * old PTE or we may race with page_mkclean(). 156 * old PTE or we may race with page_mkclean().
157 *
158 * This check has to be done after we removed the
159 * old PTE from page tables or another thread may
160 * dirty it after the check and before the removal.
156 */ 161 */
157 if (pte_present(*old_pte) && pte_dirty(*old_pte)) 162 if (pte_present(pte) && pte_dirty(pte))
158 force_flush = true; 163 force_flush = true;
159 pte = ptep_get_and_clear(mm, old_addr, old_pte);
160 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr); 164 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
161 pte = move_soft_dirty_pte(pte); 165 pte = move_soft_dirty_pte(pte);
162 set_pte_at(mm, new_addr, new_pte, pte); 166 set_pte_at(mm, new_addr, new_pte, pte);
diff --git a/mm/shmem.c b/mm/shmem.c
index 166ebf5d2bce..9d32e1cb9f38 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1848,6 +1848,18 @@ unlock:
1848 return error; 1848 return error;
1849} 1849}
1850 1850
1851/*
1852 * This is like autoremove_wake_function, but it removes the wait queue
1853 * entry unconditionally - even if something else had already woken the
1854 * target.
1855 */
1856static int synchronous_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
1857{
1858 int ret = default_wake_function(wait, mode, sync, key);
1859 list_del_init(&wait->task_list);
1860 return ret;
1861}
1862
1851static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 1863static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1852{ 1864{
1853 struct inode *inode = file_inode(vma->vm_file); 1865 struct inode *inode = file_inode(vma->vm_file);
@@ -1883,7 +1895,7 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1883 vmf->pgoff >= shmem_falloc->start && 1895 vmf->pgoff >= shmem_falloc->start &&
1884 vmf->pgoff < shmem_falloc->next) { 1896 vmf->pgoff < shmem_falloc->next) {
1885 wait_queue_head_t *shmem_falloc_waitq; 1897 wait_queue_head_t *shmem_falloc_waitq;
1886 DEFINE_WAIT(shmem_fault_wait); 1898 DEFINE_WAIT_FUNC(shmem_fault_wait, synchronous_wake_function);
1887 1899
1888 ret = VM_FAULT_NOPAGE; 1900 ret = VM_FAULT_NOPAGE;
1889 if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) && 1901 if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) &&
@@ -2665,6 +2677,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
2665 spin_lock(&inode->i_lock); 2677 spin_lock(&inode->i_lock);
2666 inode->i_private = NULL; 2678 inode->i_private = NULL;
2667 wake_up_all(&shmem_falloc_waitq); 2679 wake_up_all(&shmem_falloc_waitq);
2680 WARN_ON_ONCE(!list_empty(&shmem_falloc_waitq.task_list));
2668 spin_unlock(&inode->i_lock); 2681 spin_unlock(&inode->i_lock);
2669 error = 0; 2682 error = 0;
2670 goto out; 2683 goto out;
diff --git a/mm/truncate.c b/mm/truncate.c
index a01cce450a26..8d8c62d89e6d 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
283 283
284 if (!trylock_page(page)) 284 if (!trylock_page(page))
285 continue; 285 continue;
286 WARN_ON(page_to_pgoff(page) != index); 286 WARN_ON(page_to_index(page) != index);
287 if (PageWriteback(page)) { 287 if (PageWriteback(page)) {
288 unlock_page(page); 288 unlock_page(page);
289 continue; 289 continue;
@@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
371 } 371 }
372 372
373 lock_page(page); 373 lock_page(page);
374 WARN_ON(page_to_pgoff(page) != index); 374 WARN_ON(page_to_index(page) != index);
375 wait_on_page_writeback(page); 375 wait_on_page_writeback(page);
376 truncate_inode_page(mapping, page); 376 truncate_inode_page(mapping, page);
377 unlock_page(page); 377 unlock_page(page);
@@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
492 if (!trylock_page(page)) 492 if (!trylock_page(page))
493 continue; 493 continue;
494 494
495 WARN_ON(page_to_pgoff(page) != index); 495 WARN_ON(page_to_index(page) != index);
496 496
497 /* Middle of THP: skip */ 497 /* Middle of THP: skip */
498 if (PageTransTail(page)) { 498 if (PageTransTail(page)) {
@@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
612 } 612 }
613 613
614 lock_page(page); 614 lock_page(page);
615 WARN_ON(page_to_pgoff(page) != index); 615 WARN_ON(page_to_index(page) != index);
616 if (page->mapping != mapping) { 616 if (page->mapping != mapping) {
617 unlock_page(page); 617 unlock_page(page);
618 continue; 618 continue;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 76fda2268148..d75cdf360730 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2354,6 +2354,8 @@ static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memc
2354 } 2354 }
2355 } 2355 }
2356 2356
2357 cond_resched();
2358
2357 if (nr_reclaimed < nr_to_reclaim || scan_adjusted) 2359 if (nr_reclaimed < nr_to_reclaim || scan_adjusted)
2358 continue; 2360 continue;
2359 2361
diff --git a/mm/workingset.c b/mm/workingset.c
index 617475f529f4..fb1f9183d89a 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -348,7 +348,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
348 shadow_nodes = list_lru_shrink_count(&workingset_shadow_nodes, sc); 348 shadow_nodes = list_lru_shrink_count(&workingset_shadow_nodes, sc);
349 local_irq_enable(); 349 local_irq_enable();
350 350
351 if (memcg_kmem_enabled()) { 351 if (sc->memcg) {
352 pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid, 352 pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
353 LRU_ALL_FILE); 353 LRU_ALL_FILE);
354 } else { 354 } else {
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 7f663092f6de..0dc85eb1cb7a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3282,7 +3282,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv,
3282 &tvlv_tt_data, 3282 &tvlv_tt_data,
3283 &tt_change, 3283 &tt_change,
3284 &tt_len); 3284 &tt_len);
3285 if (!tt_len) 3285 if (!tt_len || !tvlv_len)
3286 goto unlock; 3286 goto unlock;
3287 3287
3288 /* Copy the last orig_node's OGM buffer */ 3288 /* Copy the last orig_node's OGM buffer */
@@ -3300,7 +3300,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv,
3300 &tvlv_tt_data, 3300 &tvlv_tt_data,
3301 &tt_change, 3301 &tt_change,
3302 &tt_len); 3302 &tt_len);
3303 if (!tt_len) 3303 if (!tt_len || !tvlv_len)
3304 goto out; 3304 goto out;
3305 3305
3306 /* fill the rest of the tvlv with the real TT entries */ 3306 /* fill the rest of the tvlv with the real TT entries */
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index d020299baba4..1904a93f47d5 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -1090,7 +1090,6 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
1090{ 1090{
1091 struct hci_conn *hcon; 1091 struct hci_conn *hcon;
1092 struct hci_dev *hdev; 1092 struct hci_dev *hdev;
1093 bdaddr_t *src = BDADDR_ANY;
1094 int n; 1093 int n;
1095 1094
1096 n = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu", 1095 n = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu",
@@ -1101,7 +1100,8 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
1101 if (n < 7) 1100 if (n < 7)
1102 return -EINVAL; 1101 return -EINVAL;
1103 1102
1104 hdev = hci_get_route(addr, src); 1103 /* The LE_PUBLIC address type is ignored because of BDADDR_ANY */
1104 hdev = hci_get_route(addr, BDADDR_ANY, BDADDR_LE_PUBLIC);
1105 if (!hdev) 1105 if (!hdev)
1106 return -ENOENT; 1106 return -ENOENT;
1107 1107
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3809617aa98d..dc59eae54717 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -613,7 +613,7 @@ int hci_conn_del(struct hci_conn *conn)
613 return 0; 613 return 0;
614} 614}
615 615
616struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) 616struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, uint8_t src_type)
617{ 617{
618 int use_src = bacmp(src, BDADDR_ANY); 618 int use_src = bacmp(src, BDADDR_ANY);
619 struct hci_dev *hdev = NULL, *d; 619 struct hci_dev *hdev = NULL, *d;
@@ -634,7 +634,29 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
634 */ 634 */
635 635
636 if (use_src) { 636 if (use_src) {
637 if (!bacmp(&d->bdaddr, src)) { 637 bdaddr_t id_addr;
638 u8 id_addr_type;
639
640 if (src_type == BDADDR_BREDR) {
641 if (!lmp_bredr_capable(d))
642 continue;
643 bacpy(&id_addr, &d->bdaddr);
644 id_addr_type = BDADDR_BREDR;
645 } else {
646 if (!lmp_le_capable(d))
647 continue;
648
649 hci_copy_identity_address(d, &id_addr,
650 &id_addr_type);
651
652 /* Convert from HCI to three-value type */
653 if (id_addr_type == ADDR_LE_DEV_PUBLIC)
654 id_addr_type = BDADDR_LE_PUBLIC;
655 else
656 id_addr_type = BDADDR_LE_RANDOM;
657 }
658
659 if (!bacmp(&id_addr, src) && id_addr_type == src_type) {
638 hdev = d; break; 660 hdev = d; break;
639 } 661 }
640 } else { 662 } else {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d4cad29b033f..577f1c01454a 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7060,7 +7060,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7060 BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", &chan->src, dst, 7060 BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", &chan->src, dst,
7061 dst_type, __le16_to_cpu(psm)); 7061 dst_type, __le16_to_cpu(psm));
7062 7062
7063 hdev = hci_get_route(dst, &chan->src); 7063 hdev = hci_get_route(dst, &chan->src, chan->src_type);
7064 if (!hdev) 7064 if (!hdev)
7065 return -EHOSTUNREACH; 7065 return -EHOSTUNREACH;
7066 7066
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 8e385a0ae60e..2f2cb5e27cdd 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -178,7 +178,7 @@ static void rfcomm_reparent_device(struct rfcomm_dev *dev)
178 struct hci_dev *hdev; 178 struct hci_dev *hdev;
179 struct hci_conn *conn; 179 struct hci_conn *conn;
180 180
181 hdev = hci_get_route(&dev->dst, &dev->src); 181 hdev = hci_get_route(&dev->dst, &dev->src, BDADDR_BREDR);
182 if (!hdev) 182 if (!hdev)
183 return; 183 return;
184 184
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index f52bcbf2e58c..3125ce670c2f 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -219,7 +219,7 @@ static int sco_connect(struct sock *sk)
219 219
220 BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst); 220 BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
221 221
222 hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src); 222 hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, BDADDR_BREDR);
223 if (!hdev) 223 if (!hdev)
224 return -EHOSTUNREACH; 224 return -EHOSTUNREACH;
225 225
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index e120307c6e36..f88c4df3f91e 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -898,6 +898,7 @@ int br_sysfs_addbr(struct net_device *dev)
898 if (!br->ifobj) { 898 if (!br->ifobj) {
899 pr_info("%s: can't add kobject (directory) %s/%s\n", 899 pr_info("%s: can't add kobject (directory) %s/%s\n",
900 __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR); 900 __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
901 err = -ENOMEM;
901 goto out3; 902 goto out3;
902 } 903 }
903 return 0; 904 return 0;
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index aa209b1066c9..92cbbd2afddb 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -1107,10 +1107,7 @@ static struct net_proto_family caif_family_ops = {
1107 1107
1108static int __init caif_sktinit_module(void) 1108static int __init caif_sktinit_module(void)
1109{ 1109{
1110 int err = sock_register(&caif_family_ops); 1110 return sock_register(&caif_family_ops);
1111 if (!err)
1112 return err;
1113 return 0;
1114} 1111}
1115 1112
1116static void __exit caif_sktexit_module(void) 1113static void __exit caif_sktexit_module(void)
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 8af9d25ff988..436a7537e6a9 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -77,7 +77,7 @@
77 (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \ 77 (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \
78 (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG)) 78 (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
79 79
80#define CAN_BCM_VERSION "20160617" 80#define CAN_BCM_VERSION "20161123"
81 81
82MODULE_DESCRIPTION("PF_CAN broadcast manager protocol"); 82MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
83MODULE_LICENSE("Dual BSD/GPL"); 83MODULE_LICENSE("Dual BSD/GPL");
@@ -109,8 +109,9 @@ struct bcm_op {
109 u32 count; 109 u32 count;
110 u32 nframes; 110 u32 nframes;
111 u32 currframe; 111 u32 currframe;
112 struct canfd_frame *frames; 112 /* void pointers to arrays of struct can[fd]_frame */
113 struct canfd_frame *last_frames; 113 void *frames;
114 void *last_frames;
114 struct canfd_frame sframe; 115 struct canfd_frame sframe;
115 struct canfd_frame last_sframe; 116 struct canfd_frame last_sframe;
116 struct sock *sk; 117 struct sock *sk;
@@ -681,7 +682,7 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
681 682
682 if (op->flags & RX_FILTER_ID) { 683 if (op->flags & RX_FILTER_ID) {
683 /* the easiest case */ 684 /* the easiest case */
684 bcm_rx_update_and_send(op, &op->last_frames[0], rxframe); 685 bcm_rx_update_and_send(op, op->last_frames, rxframe);
685 goto rx_starttimer; 686 goto rx_starttimer;
686 } 687 }
687 688
@@ -1068,7 +1069,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1068 1069
1069 if (msg_head->nframes) { 1070 if (msg_head->nframes) {
1070 /* update CAN frames content */ 1071 /* update CAN frames content */
1071 err = memcpy_from_msg((u8 *)op->frames, msg, 1072 err = memcpy_from_msg(op->frames, msg,
1072 msg_head->nframes * op->cfsiz); 1073 msg_head->nframes * op->cfsiz);
1073 if (err < 0) 1074 if (err < 0)
1074 return err; 1075 return err;
@@ -1118,7 +1119,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1118 } 1119 }
1119 1120
1120 if (msg_head->nframes) { 1121 if (msg_head->nframes) {
1121 err = memcpy_from_msg((u8 *)op->frames, msg, 1122 err = memcpy_from_msg(op->frames, msg,
1122 msg_head->nframes * op->cfsiz); 1123 msg_head->nframes * op->cfsiz);
1123 if (err < 0) { 1124 if (err < 0) {
1124 if (op->frames != &op->sframe) 1125 if (op->frames != &op->sframe)
@@ -1163,6 +1164,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1163 /* check flags */ 1164 /* check flags */
1164 1165
1165 if (op->flags & RX_RTR_FRAME) { 1166 if (op->flags & RX_RTR_FRAME) {
1167 struct canfd_frame *frame0 = op->frames;
1166 1168
1167 /* no timers in RTR-mode */ 1169 /* no timers in RTR-mode */
1168 hrtimer_cancel(&op->thrtimer); 1170 hrtimer_cancel(&op->thrtimer);
@@ -1174,8 +1176,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1174 * prevent a full-load-loopback-test ... ;-] 1176 * prevent a full-load-loopback-test ... ;-]
1175 */ 1177 */
1176 if ((op->flags & TX_CP_CAN_ID) || 1178 if ((op->flags & TX_CP_CAN_ID) ||
1177 (op->frames[0].can_id == op->can_id)) 1179 (frame0->can_id == op->can_id))
1178 op->frames[0].can_id = op->can_id & ~CAN_RTR_FLAG; 1180 frame0->can_id = op->can_id & ~CAN_RTR_FLAG;
1179 1181
1180 } else { 1182 } else {
1181 if (op->flags & SETTIMER) { 1183 if (op->flags & SETTIMER) {
diff --git a/net/can/raw.c b/net/can/raw.c
index 972c187d40ab..b075f028d7e2 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -499,6 +499,9 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
499 if (optlen % sizeof(struct can_filter) != 0) 499 if (optlen % sizeof(struct can_filter) != 0)
500 return -EINVAL; 500 return -EINVAL;
501 501
502 if (optlen > CAN_RAW_FILTER_MAX * sizeof(struct can_filter))
503 return -EINVAL;
504
502 count = optlen / sizeof(struct can_filter); 505 count = optlen / sizeof(struct can_filter);
503 506
504 if (count > 1) { 507 if (count > 1) {
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 977489820eb9..047a1752ece1 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -2479,6 +2479,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
2479 case ETHTOOL_GET_TS_INFO: 2479 case ETHTOOL_GET_TS_INFO:
2480 case ETHTOOL_GEEE: 2480 case ETHTOOL_GEEE:
2481 case ETHTOOL_GTUNABLE: 2481 case ETHTOOL_GTUNABLE:
2482 case ETHTOOL_GLINKSETTINGS:
2482 break; 2483 break;
2483 default: 2484 default:
2484 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 2485 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
diff --git a/net/core/flow.c b/net/core/flow.c
index 3937b1b68d5b..18e8893d4be5 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -95,7 +95,6 @@ static void flow_cache_gc_task(struct work_struct *work)
95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) { 95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) {
96 flow_entry_kill(fce, xfrm); 96 flow_entry_kill(fce, xfrm);
97 atomic_dec(&xfrm->flow_cache_gc_count); 97 atomic_dec(&xfrm->flow_cache_gc_count);
98 WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0);
99 } 98 }
100} 99}
101 100
@@ -236,9 +235,8 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
236 if (fcp->hash_count > fc->high_watermark) 235 if (fcp->hash_count > fc->high_watermark)
237 flow_cache_shrink(fc, fcp); 236 flow_cache_shrink(fc, fcp);
238 237
239 if (fcp->hash_count > 2 * fc->high_watermark || 238 if (atomic_read(&net->xfrm.flow_cache_gc_count) >
240 atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) { 239 2 * num_online_cpus() * fc->high_watermark) {
241 atomic_inc(&net->xfrm.flow_cache_genid);
242 flo = ERR_PTR(-ENOBUFS); 240 flo = ERR_PTR(-ENOBUFS);
243 goto ret_object; 241 goto ret_object;
244 } 242 }
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 69e4463a4b1b..c6d8207ffa7e 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -1013,4 +1013,4 @@ static int __init init_default_flow_dissectors(void)
1013 return 0; 1013 return 0;
1014} 1014}
1015 1015
1016late_initcall_sync(init_default_flow_dissectors); 1016core_initcall(init_default_flow_dissectors);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a99917b5de33..a6196cf844f6 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -931,8 +931,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
931 + nla_total_size(4) /* IFLA_PROMISCUITY */ 931 + nla_total_size(4) /* IFLA_PROMISCUITY */
932 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */ 932 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
933 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */ 933 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
934 + nla_total_size(4) /* IFLA_MAX_GSO_SEGS */ 934 + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */
935 + nla_total_size(4) /* IFLA_MAX_GSO_SIZE */ 935 + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */
936 + nla_total_size(1) /* IFLA_OPERSTATE */ 936 + nla_total_size(1) /* IFLA_OPERSTATE */
937 + nla_total_size(1) /* IFLA_LINKMODE */ 937 + nla_total_size(1) /* IFLA_LINKMODE */
938 + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ 938 + nla_total_size(4) /* IFLA_CARRIER_CHANGES */
@@ -2737,7 +2737,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
2737 ext_filter_mask)); 2737 ext_filter_mask));
2738 } 2738 }
2739 2739
2740 return min_ifinfo_dump_size; 2740 return nlmsg_total_size(min_ifinfo_dump_size);
2741} 2741}
2742 2742
2743static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb) 2743static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
diff --git a/net/core/sock.c b/net/core/sock.c
index 5e3ca414357e..00a074dbfe9b 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -715,7 +715,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
715 val = min_t(u32, val, sysctl_wmem_max); 715 val = min_t(u32, val, sysctl_wmem_max);
716set_sndbuf: 716set_sndbuf:
717 sk->sk_userlocks |= SOCK_SNDBUF_LOCK; 717 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
718 sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF); 718 sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
719 /* Wake up sending tasks if we upped the value. */ 719 /* Wake up sending tasks if we upped the value. */
720 sk->sk_write_space(sk); 720 sk->sk_write_space(sk);
721 break; 721 break;
@@ -751,7 +751,7 @@ set_rcvbuf:
751 * returning the value we actually used in getsockopt 751 * returning the value we actually used in getsockopt
752 * is the most desirable behavior. 752 * is the most desirable behavior.
753 */ 753 */
754 sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF); 754 sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF);
755 break; 755 break;
756 756
757 case SO_RCVBUFFORCE: 757 case SO_RCVBUFFORCE:
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 4f6c1862dfd2..3202d75329b5 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1353,6 +1353,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1353dcb_unlock: 1353dcb_unlock:
1354 spin_unlock_bh(&dcb_lock); 1354 spin_unlock_bh(&dcb_lock);
1355nla_put_failure: 1355nla_put_failure:
1356 err = -EMSGSIZE;
1356 return err; 1357 return err;
1357} 1358}
1358 1359
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index b567c8725aea..edbe59d203ef 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -700,6 +700,7 @@ int dccp_invalid_packet(struct sk_buff *skb)
700{ 700{
701 const struct dccp_hdr *dh; 701 const struct dccp_hdr *dh;
702 unsigned int cscov; 702 unsigned int cscov;
703 u8 dccph_doff;
703 704
704 if (skb->pkt_type != PACKET_HOST) 705 if (skb->pkt_type != PACKET_HOST)
705 return 1; 706 return 1;
@@ -721,18 +722,19 @@ int dccp_invalid_packet(struct sk_buff *skb)
721 /* 722 /*
722 * If P.Data Offset is too small for packet type, drop packet and return 723 * If P.Data Offset is too small for packet type, drop packet and return
723 */ 724 */
724 if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { 725 dccph_doff = dh->dccph_doff;
725 DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff); 726 if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
727 DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff);
726 return 1; 728 return 1;
727 } 729 }
728 /* 730 /*
729 * If P.Data Offset is too too large for packet, drop packet and return 731 * If P.Data Offset is too too large for packet, drop packet and return
730 */ 732 */
731 if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { 733 if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) {
732 DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff); 734 DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff);
733 return 1; 735 return 1;
734 } 736 }
735 737 dh = dccp_hdr(skb);
736 /* 738 /*
737 * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet 739 * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
738 * has short sequence numbers), drop packet and return 740 * has short sequence numbers), drop packet and return
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index a6902c1e2f28..7899919cd9f0 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -233,6 +233,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
233 genphy_read_status(phydev); 233 genphy_read_status(phydev);
234 if (ds->ops->adjust_link) 234 if (ds->ops->adjust_link)
235 ds->ops->adjust_link(ds, port, phydev); 235 ds->ops->adjust_link(ds, port, phydev);
236
237 put_device(&phydev->mdio.dev);
236 } 238 }
237 239
238 return 0; 240 return 0;
@@ -504,15 +506,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
504 506
505void dsa_cpu_dsa_destroy(struct device_node *port_dn) 507void dsa_cpu_dsa_destroy(struct device_node *port_dn)
506{ 508{
507 struct phy_device *phydev; 509 if (of_phy_is_fixed_link(port_dn))
508 510 of_phy_deregister_fixed_link(port_dn);
509 if (of_phy_is_fixed_link(port_dn)) {
510 phydev = of_phy_find_device(port_dn);
511 if (phydev) {
512 phy_device_free(phydev);
513 fixed_phy_unregister(phydev);
514 }
515 }
516} 511}
517 512
518static void dsa_switch_destroy(struct dsa_switch *ds) 513static void dsa_switch_destroy(struct dsa_switch *ds)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index f8a7d9aab437..5fff951a0a49 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -28,8 +28,10 @@ static struct dsa_switch_tree *dsa_get_dst(u32 tree)
28 struct dsa_switch_tree *dst; 28 struct dsa_switch_tree *dst;
29 29
30 list_for_each_entry(dst, &dsa_switch_trees, list) 30 list_for_each_entry(dst, &dsa_switch_trees, list)
31 if (dst->tree == tree) 31 if (dst->tree == tree) {
32 kref_get(&dst->refcount);
32 return dst; 33 return dst;
34 }
33 return NULL; 35 return NULL;
34} 36}
35 37
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6b1282c006b1..30e2e21d7619 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1125 p->phy_interface = mode; 1125 p->phy_interface = mode;
1126 1126
1127 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); 1127 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
1128 if (of_phy_is_fixed_link(port_dn)) { 1128 if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
1129 /* In the case of a fixed PHY, the DT node associated 1129 /* In the case of a fixed PHY, the DT node associated
1130 * to the fixed PHY is the Port DT node 1130 * to the fixed PHY is the Port DT node
1131 */ 1131 */
@@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1135 return ret; 1135 return ret;
1136 } 1136 }
1137 phy_is_fixed = true; 1137 phy_is_fixed = true;
1138 phy_dn = port_dn; 1138 phy_dn = of_node_get(port_dn);
1139 } 1139 }
1140 1140
1141 if (ds->ops->get_phy_flags) 1141 if (ds->ops->get_phy_flags)
@@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1154 ret = dsa_slave_phy_connect(p, slave_dev, phy_id); 1154 ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
1155 if (ret) { 1155 if (ret) {
1156 netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); 1156 netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
1157 of_node_put(phy_dn);
1157 return ret; 1158 return ret;
1158 } 1159 }
1159 } else { 1160 } else {
@@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1162 phy_flags, 1163 phy_flags,
1163 p->phy_interface); 1164 p->phy_interface);
1164 } 1165 }
1166
1167 of_node_put(phy_dn);
1165 } 1168 }
1166 1169
1167 if (p->phy && phy_is_fixed) 1170 if (p->phy && phy_is_fixed)
@@ -1174,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1174 ret = dsa_slave_phy_connect(p, slave_dev, p->port); 1177 ret = dsa_slave_phy_connect(p, slave_dev, p->port);
1175 if (ret) { 1178 if (ret) {
1176 netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); 1179 netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
1180 if (phy_is_fixed)
1181 of_phy_deregister_fixed_link(port_dn);
1177 return ret; 1182 return ret;
1178 } 1183 }
1179 } 1184 }
@@ -1289,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
1289void dsa_slave_destroy(struct net_device *slave_dev) 1294void dsa_slave_destroy(struct net_device *slave_dev)
1290{ 1295{
1291 struct dsa_slave_priv *p = netdev_priv(slave_dev); 1296 struct dsa_slave_priv *p = netdev_priv(slave_dev);
1297 struct dsa_switch *ds = p->parent;
1298 struct device_node *port_dn;
1299
1300 port_dn = ds->ports[p->port].dn;
1292 1301
1293 netif_carrier_off(slave_dev); 1302 netif_carrier_off(slave_dev);
1294 if (p->phy) 1303 if (p->phy) {
1295 phy_disconnect(p->phy); 1304 phy_disconnect(p->phy);
1305
1306 if (of_phy_is_fixed_link(port_dn))
1307 of_phy_deregister_fixed_link(port_dn);
1308 }
1296 unregister_netdev(slave_dev); 1309 unregister_netdev(slave_dev);
1297 free_netdev(slave_dev); 1310 free_netdev(slave_dev);
1298} 1311}
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 300b06888fdf..b54b3ca939db 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -715,6 +715,7 @@ config DEFAULT_TCP_CONG
715 default "reno" if DEFAULT_RENO 715 default "reno" if DEFAULT_RENO
716 default "dctcp" if DEFAULT_DCTCP 716 default "dctcp" if DEFAULT_DCTCP
717 default "cdg" if DEFAULT_CDG 717 default "cdg" if DEFAULT_CDG
718 default "bbr" if DEFAULT_BBR
718 default "cubic" 719 default "cubic"
719 720
720config TCP_MD5SIG 721config TCP_MD5SIG
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 5ddf5cda07f4..215143246e4b 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1233,7 +1233,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1233 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); 1233 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
1234 1234
1235 /* fixed ID is invalid if DF bit is not set */ 1235 /* fixed ID is invalid if DF bit is not set */
1236 if (fixedid && !(iph->frag_off & htons(IP_DF))) 1236 if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF)))
1237 goto out; 1237 goto out;
1238 } 1238 }
1239 1239
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index d95631d09248..20fb25e3027b 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -476,7 +476,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
476 esph = (void *)skb_push(skb, 4); 476 esph = (void *)skb_push(skb, 4);
477 *seqhi = esph->spi; 477 *seqhi = esph->spi;
478 esph->spi = esph->seq_no; 478 esph->spi = esph->seq_no;
479 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); 479 esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi;
480 aead_request_set_callback(req, 0, esp_input_done_esn, skb); 480 aead_request_set_callback(req, 0, esp_input_done_esn, skb);
481 } 481 }
482 482
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 026f309c51e9..e3665bf7a7f3 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -719,6 +719,13 @@ static unsigned char update_suffix(struct key_vector *tn)
719{ 719{
720 unsigned char slen = tn->pos; 720 unsigned char slen = tn->pos;
721 unsigned long stride, i; 721 unsigned long stride, i;
722 unsigned char slen_max;
723
724 /* only vector 0 can have a suffix length greater than or equal to
725 * tn->pos + tn->bits, the second highest node will have a suffix
726 * length at most of tn->pos + tn->bits - 1
727 */
728 slen_max = min_t(unsigned char, tn->pos + tn->bits - 1, tn->slen);
722 729
723 /* search though the list of children looking for nodes that might 730 /* search though the list of children looking for nodes that might
724 * have a suffix greater than the one we currently have. This is 731 * have a suffix greater than the one we currently have. This is
@@ -736,12 +743,8 @@ static unsigned char update_suffix(struct key_vector *tn)
736 slen = n->slen; 743 slen = n->slen;
737 i &= ~(stride - 1); 744 i &= ~(stride - 1);
738 745
739 /* if slen covers all but the last bit we can stop here 746 /* stop searching if we have hit the maximum possible value */
740 * there will be nothing longer than that since only node 747 if (slen >= slen_max)
741 * 0 and 1 << (bits - 1) could have that as their suffix
742 * length.
743 */
744 if ((slen + 1) >= (tn->pos + tn->bits))
745 break; 748 break;
746 } 749 }
747 750
@@ -913,39 +916,27 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
913 return collapse(t, tn); 916 return collapse(t, tn);
914 917
915 /* update parent in case halve failed */ 918 /* update parent in case halve failed */
916 tp = node_parent(tn); 919 return node_parent(tn);
917
918 /* Return if at least one deflate was run */
919 if (max_work != MAX_WORK)
920 return tp;
921
922 /* push the suffix length to the parent node */
923 if (tn->slen > tn->pos) {
924 unsigned char slen = update_suffix(tn);
925
926 if (slen > tp->slen)
927 tp->slen = slen;
928 }
929
930 return tp;
931} 920}
932 921
933static void leaf_pull_suffix(struct key_vector *tp, struct key_vector *l) 922static void node_pull_suffix(struct key_vector *tn, unsigned char slen)
934{ 923{
935 while ((tp->slen > tp->pos) && (tp->slen > l->slen)) { 924 unsigned char node_slen = tn->slen;
936 if (update_suffix(tp) > l->slen) 925
926 while ((node_slen > tn->pos) && (node_slen > slen)) {
927 slen = update_suffix(tn);
928 if (node_slen == slen)
937 break; 929 break;
938 tp = node_parent(tp); 930
931 tn = node_parent(tn);
932 node_slen = tn->slen;
939 } 933 }
940} 934}
941 935
942static void leaf_push_suffix(struct key_vector *tn, struct key_vector *l) 936static void node_push_suffix(struct key_vector *tn, unsigned char slen)
943{ 937{
944 /* if this is a new leaf then tn will be NULL and we can sort 938 while (tn->slen < slen) {
945 * out parent suffix lengths as a part of trie_rebalance 939 tn->slen = slen;
946 */
947 while (tn->slen < l->slen) {
948 tn->slen = l->slen;
949 tn = node_parent(tn); 940 tn = node_parent(tn);
950 } 941 }
951} 942}
@@ -1066,6 +1057,7 @@ static int fib_insert_node(struct trie *t, struct key_vector *tp,
1066 } 1057 }
1067 1058
1068 /* Case 3: n is NULL, and will just insert a new leaf */ 1059 /* Case 3: n is NULL, and will just insert a new leaf */
1060 node_push_suffix(tp, new->fa_slen);
1069 NODE_INIT_PARENT(l, tp); 1061 NODE_INIT_PARENT(l, tp);
1070 put_child_root(tp, key, l); 1062 put_child_root(tp, key, l);
1071 trie_rebalance(t, tp); 1063 trie_rebalance(t, tp);
@@ -1107,7 +1099,7 @@ static int fib_insert_alias(struct trie *t, struct key_vector *tp,
1107 /* if we added to the tail node then we need to update slen */ 1099 /* if we added to the tail node then we need to update slen */
1108 if (l->slen < new->fa_slen) { 1100 if (l->slen < new->fa_slen) {
1109 l->slen = new->fa_slen; 1101 l->slen = new->fa_slen;
1110 leaf_push_suffix(tp, l); 1102 node_push_suffix(tp, new->fa_slen);
1111 } 1103 }
1112 1104
1113 return 0; 1105 return 0;
@@ -1499,6 +1491,8 @@ static void fib_remove_alias(struct trie *t, struct key_vector *tp,
1499 * out parent suffix lengths as a part of trie_rebalance 1491 * out parent suffix lengths as a part of trie_rebalance
1500 */ 1492 */
1501 if (hlist_empty(&l->leaf)) { 1493 if (hlist_empty(&l->leaf)) {
1494 if (tp->slen == l->slen)
1495 node_pull_suffix(tp, tp->pos);
1502 put_child_root(tp, l->key, NULL); 1496 put_child_root(tp, l->key, NULL);
1503 node_free(l); 1497 node_free(l);
1504 trie_rebalance(t, tp); 1498 trie_rebalance(t, tp);
@@ -1511,7 +1505,7 @@ static void fib_remove_alias(struct trie *t, struct key_vector *tp,
1511 1505
1512 /* update the trie with the latest suffix length */ 1506 /* update the trie with the latest suffix length */
1513 l->slen = fa->fa_slen; 1507 l->slen = fa->fa_slen;
1514 leaf_pull_suffix(tp, l); 1508 node_pull_suffix(tp, fa->fa_slen);
1515} 1509}
1516 1510
1517/* Caller must hold RTNL. */ 1511/* Caller must hold RTNL. */
@@ -1783,6 +1777,10 @@ void fib_table_flush_external(struct fib_table *tb)
1783 if (IS_TRIE(pn)) 1777 if (IS_TRIE(pn))
1784 break; 1778 break;
1785 1779
1780 /* update the suffix to address pulled leaves */
1781 if (pn->slen > pn->pos)
1782 update_suffix(pn);
1783
1786 /* resize completed node */ 1784 /* resize completed node */
1787 pn = resize(t, pn); 1785 pn = resize(t, pn);
1788 cindex = get_index(pkey, pn); 1786 cindex = get_index(pkey, pn);
@@ -1849,6 +1847,10 @@ int fib_table_flush(struct net *net, struct fib_table *tb)
1849 if (IS_TRIE(pn)) 1847 if (IS_TRIE(pn))
1850 break; 1848 break;
1851 1849
1850 /* update the suffix to address pulled leaves */
1851 if (pn->slen > pn->pos)
1852 update_suffix(pn);
1853
1852 /* resize completed node */ 1854 /* resize completed node */
1853 pn = resize(t, pn); 1855 pn = resize(t, pn);
1854 cindex = get_index(pkey, pn); 1856 cindex = get_index(pkey, pn);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 105908d841a3..877bdb02e887 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -107,6 +107,8 @@ int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
107 if (unlikely(!skb)) 107 if (unlikely(!skb))
108 return 0; 108 return 0;
109 109
110 skb->protocol = htons(ETH_P_IP);
111
110 return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, 112 return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
111 net, sk, skb, NULL, skb_dst(skb)->dev, 113 net, sk, skb, NULL, skb_dst(skb)->dev,
112 dst_output); 114 dst_output);
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index c3776ff6749f..b3cc1335adbc 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -24,10 +24,11 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t
24 struct flowi4 fl4 = {}; 24 struct flowi4 fl4 = {};
25 __be32 saddr = iph->saddr; 25 __be32 saddr = iph->saddr;
26 __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0; 26 __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0;
27 struct net_device *dev = skb_dst(skb)->dev;
27 unsigned int hh_len; 28 unsigned int hh_len;
28 29
29 if (addr_type == RTN_UNSPEC) 30 if (addr_type == RTN_UNSPEC)
30 addr_type = inet_addr_type(net, saddr); 31 addr_type = inet_addr_type_dev_table(net, dev, saddr);
31 if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST) 32 if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST)
32 flags |= FLOWI_FLAG_ANYSRC; 33 flags |= FLOWI_FLAG_ANYSRC;
33 else 34 else
@@ -40,6 +41,8 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t
40 fl4.saddr = saddr; 41 fl4.saddr = saddr;
41 fl4.flowi4_tos = RT_TOS(iph->tos); 42 fl4.flowi4_tos = RT_TOS(iph->tos);
42 fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; 43 fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0;
44 if (!fl4.flowi4_oif)
45 fl4.flowi4_oif = l3mdev_master_ifindex(dev);
43 fl4.flowi4_mark = skb->mark; 46 fl4.flowi4_mark = skb->mark;
44 fl4.flowi4_flags = flags; 47 fl4.flowi4_flags = flags;
45 rt = ip_route_output_key(net, &fl4); 48 rt = ip_route_output_key(net, &fl4);
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index b31df597fd37..697538464e6e 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -1201,8 +1201,8 @@ static int translate_compat_table(struct xt_table_info **pinfo,
1201 1201
1202 newinfo->number = compatr->num_entries; 1202 newinfo->number = compatr->num_entries;
1203 for (i = 0; i < NF_ARP_NUMHOOKS; i++) { 1203 for (i = 0; i < NF_ARP_NUMHOOKS; i++) {
1204 newinfo->hook_entry[i] = info->hook_entry[i]; 1204 newinfo->hook_entry[i] = compatr->hook_entry[i];
1205 newinfo->underflow[i] = info->underflow[i]; 1205 newinfo->underflow[i] = compatr->underflow[i];
1206 } 1206 }
1207 entry1 = newinfo->entries; 1207 entry1 = newinfo->entries;
1208 pos = entry1; 1208 pos = entry1;
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 205e2000d395..96b8e2b95731 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -657,6 +657,10 @@ int ping_common_sendmsg(int family, struct msghdr *msg, size_t len,
657 if (len > 0xFFFF) 657 if (len > 0xFFFF)
658 return -EMSGSIZE; 658 return -EMSGSIZE;
659 659
660 /* Must have at least a full ICMP header. */
661 if (len < icmph_len)
662 return -EINVAL;
663
660 /* 664 /*
661 * Check the flags. 665 * Check the flags.
662 */ 666 */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a27b9c0e27c0..c71d49ce0c93 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -128,6 +128,23 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2;
128#define REXMIT_LOST 1 /* retransmit packets marked lost */ 128#define REXMIT_LOST 1 /* retransmit packets marked lost */
129#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ 129#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */
130 130
131static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb)
132{
133 static bool __once __read_mostly;
134
135 if (!__once) {
136 struct net_device *dev;
137
138 __once = true;
139
140 rcu_read_lock();
141 dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
142 pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
143 dev ? dev->name : "Unknown driver");
144 rcu_read_unlock();
145 }
146}
147
131/* Adapt the MSS value used to make delayed ack decision to the 148/* Adapt the MSS value used to make delayed ack decision to the
132 * real world. 149 * real world.
133 */ 150 */
@@ -144,7 +161,10 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
144 */ 161 */
145 len = skb_shinfo(skb)->gso_size ? : skb->len; 162 len = skb_shinfo(skb)->gso_size ? : skb->len;
146 if (len >= icsk->icsk_ack.rcv_mss) { 163 if (len >= icsk->icsk_ack.rcv_mss) {
147 icsk->icsk_ack.rcv_mss = len; 164 icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
165 tcp_sk(sk)->advmss);
166 if (unlikely(icsk->icsk_ack.rcv_mss != len))
167 tcp_gro_dev_warn(sk, skb);
148 } else { 168 } else {
149 /* Otherwise, we make more careful check taking into account, 169 /* Otherwise, we make more careful check taking into account,
150 * that SACKs block is variable. 170 * that SACKs block is variable.
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 0de9d5d2b9ae..5bab6c3f7a2f 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1455,7 +1455,7 @@ static void udp_v4_rehash(struct sock *sk)
1455 udp_lib_rehash(sk, new_hash); 1455 udp_lib_rehash(sk, new_hash);
1456} 1456}
1457 1457
1458static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 1458int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1459{ 1459{
1460 int rc; 1460 int rc;
1461 1461
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index 7e0fe4bdd967..feb50a16398d 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -25,7 +25,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
25 int flags, int *addr_len); 25 int flags, int *addr_len);
26int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size, 26int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size,
27 int flags); 27 int flags);
28int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 28int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
29void udp_destroy_sock(struct sock *sk); 29void udp_destroy_sock(struct sock *sk);
30 30
31#ifdef CONFIG_PROC_FS 31#ifdef CONFIG_PROC_FS
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index af817158d830..ff450c2aad9b 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -50,7 +50,7 @@ struct proto udplite_prot = {
50 .sendmsg = udp_sendmsg, 50 .sendmsg = udp_sendmsg,
51 .recvmsg = udp_recvmsg, 51 .recvmsg = udp_recvmsg,
52 .sendpage = udp_sendpage, 52 .sendpage = udp_sendpage,
53 .backlog_rcv = udp_queue_rcv_skb, 53 .backlog_rcv = __udp_queue_rcv_skb,
54 .hash = udp_lib_hash, 54 .hash = udp_lib_hash,
55 .unhash = udp_lib_unhash, 55 .unhash = udp_lib_unhash,
56 .get_port = udp_v4_get_port, 56 .get_port = udp_v4_get_port,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 060dd9922018..4bc5ba3ae452 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -183,7 +183,7 @@ static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
183 183
184static void addrconf_dad_start(struct inet6_ifaddr *ifp); 184static void addrconf_dad_start(struct inet6_ifaddr *ifp);
185static void addrconf_dad_work(struct work_struct *w); 185static void addrconf_dad_work(struct work_struct *w);
186static void addrconf_dad_completed(struct inet6_ifaddr *ifp); 186static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id);
187static void addrconf_dad_run(struct inet6_dev *idev); 187static void addrconf_dad_run(struct inet6_dev *idev);
188static void addrconf_rs_timer(unsigned long data); 188static void addrconf_rs_timer(unsigned long data);
189static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa); 189static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
@@ -2898,6 +2898,7 @@ static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
2898 spin_lock_bh(&ifp->lock); 2898 spin_lock_bh(&ifp->lock);
2899 ifp->flags &= ~IFA_F_TENTATIVE; 2899 ifp->flags &= ~IFA_F_TENTATIVE;
2900 spin_unlock_bh(&ifp->lock); 2900 spin_unlock_bh(&ifp->lock);
2901 rt_genid_bump_ipv6(dev_net(idev->dev));
2901 ipv6_ifa_notify(RTM_NEWADDR, ifp); 2902 ipv6_ifa_notify(RTM_NEWADDR, ifp);
2902 in6_ifa_put(ifp); 2903 in6_ifa_put(ifp);
2903 } 2904 }
@@ -3740,7 +3741,7 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
3740{ 3741{
3741 struct inet6_dev *idev = ifp->idev; 3742 struct inet6_dev *idev = ifp->idev;
3742 struct net_device *dev = idev->dev; 3743 struct net_device *dev = idev->dev;
3743 bool notify = false; 3744 bool bump_id, notify = false;
3744 3745
3745 addrconf_join_solict(dev, &ifp->addr); 3746 addrconf_join_solict(dev, &ifp->addr);
3746 3747
@@ -3755,11 +3756,12 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
3755 idev->cnf.accept_dad < 1 || 3756 idev->cnf.accept_dad < 1 ||
3756 !(ifp->flags&IFA_F_TENTATIVE) || 3757 !(ifp->flags&IFA_F_TENTATIVE) ||
3757 ifp->flags & IFA_F_NODAD) { 3758 ifp->flags & IFA_F_NODAD) {
3759 bump_id = ifp->flags & IFA_F_TENTATIVE;
3758 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); 3760 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
3759 spin_unlock(&ifp->lock); 3761 spin_unlock(&ifp->lock);
3760 read_unlock_bh(&idev->lock); 3762 read_unlock_bh(&idev->lock);
3761 3763
3762 addrconf_dad_completed(ifp); 3764 addrconf_dad_completed(ifp, bump_id);
3763 return; 3765 return;
3764 } 3766 }
3765 3767
@@ -3819,8 +3821,8 @@ static void addrconf_dad_work(struct work_struct *w)
3819 struct inet6_ifaddr, 3821 struct inet6_ifaddr,
3820 dad_work); 3822 dad_work);
3821 struct inet6_dev *idev = ifp->idev; 3823 struct inet6_dev *idev = ifp->idev;
3824 bool bump_id, disable_ipv6 = false;
3822 struct in6_addr mcaddr; 3825 struct in6_addr mcaddr;
3823 bool disable_ipv6 = false;
3824 3826
3825 enum { 3827 enum {
3826 DAD_PROCESS, 3828 DAD_PROCESS,
@@ -3890,11 +3892,12 @@ static void addrconf_dad_work(struct work_struct *w)
3890 * DAD was successful 3892 * DAD was successful
3891 */ 3893 */
3892 3894
3895 bump_id = ifp->flags & IFA_F_TENTATIVE;
3893 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); 3896 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
3894 spin_unlock(&ifp->lock); 3897 spin_unlock(&ifp->lock);
3895 write_unlock_bh(&idev->lock); 3898 write_unlock_bh(&idev->lock);
3896 3899
3897 addrconf_dad_completed(ifp); 3900 addrconf_dad_completed(ifp, bump_id);
3898 3901
3899 goto out; 3902 goto out;
3900 } 3903 }
@@ -3931,7 +3934,7 @@ static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp)
3931 return true; 3934 return true;
3932} 3935}
3933 3936
3934static void addrconf_dad_completed(struct inet6_ifaddr *ifp) 3937static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
3935{ 3938{
3936 struct net_device *dev = ifp->idev->dev; 3939 struct net_device *dev = ifp->idev->dev;
3937 struct in6_addr lladdr; 3940 struct in6_addr lladdr;
@@ -3983,6 +3986,9 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp)
3983 spin_unlock(&ifp->lock); 3986 spin_unlock(&ifp->lock);
3984 write_unlock_bh(&ifp->idev->lock); 3987 write_unlock_bh(&ifp->idev->lock);
3985 } 3988 }
3989
3990 if (bump_id)
3991 rt_genid_bump_ipv6(dev_net(dev));
3986} 3992}
3987 3993
3988static void addrconf_dad_run(struct inet6_dev *idev) 3994static void addrconf_dad_run(struct inet6_dev *idev)
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 37874e2f30ed..ccf40550c475 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -139,7 +139,8 @@ void ip6_datagram_release_cb(struct sock *sk)
139} 139}
140EXPORT_SYMBOL_GPL(ip6_datagram_release_cb); 140EXPORT_SYMBOL_GPL(ip6_datagram_release_cb);
141 141
142static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) 142int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
143 int addr_len)
143{ 144{
144 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; 145 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
145 struct inet_sock *inet = inet_sk(sk); 146 struct inet_sock *inet = inet_sk(sk);
@@ -252,6 +253,7 @@ ipv4_connected:
252out: 253out:
253 return err; 254 return err;
254} 255}
256EXPORT_SYMBOL_GPL(__ip6_datagram_connect);
255 257
256int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) 258int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
257{ 259{
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 060a60b2f8a6..111ba55fd512 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -418,7 +418,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
418 esph = (void *)skb_push(skb, 4); 418 esph = (void *)skb_push(skb, 4);
419 *seqhi = esph->spi; 419 *seqhi = esph->spi;
420 esph->spi = esph->seq_no; 420 esph->spi = esph->seq_no;
421 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); 421 esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi;
422 aead_request_set_callback(req, 0, esp_input_done_esn, skb); 422 aead_request_set_callback(req, 0, esp_input_done_esn, skb);
423 } 423 }
424 424
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 7370ad2e693a..2772004ba5a1 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -447,8 +447,10 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
447 447
448 if (__ipv6_addr_needs_scope_id(addr_type)) 448 if (__ipv6_addr_needs_scope_id(addr_type))
449 iif = skb->dev->ifindex; 449 iif = skb->dev->ifindex;
450 else 450 else {
451 iif = l3mdev_master_ifindex(skb_dst(skb)->dev); 451 dst = skb_dst(skb);
452 iif = l3mdev_master_ifindex(dst ? dst->dev : skb->dev);
453 }
452 454
453 /* 455 /*
454 * Must not send error if the source does not uniquely 456 * Must not send error if the source does not uniquely
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 1fcf61f1cbc3..89c59e656f44 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -99,7 +99,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
99 segs = ops->callbacks.gso_segment(skb, features); 99 segs = ops->callbacks.gso_segment(skb, features);
100 } 100 }
101 101
102 if (IS_ERR(segs)) 102 if (IS_ERR_OR_NULL(segs))
103 goto out; 103 goto out;
104 104
105 gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL); 105 gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL);
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 0a4759b89da2..d76674efe523 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1181,7 +1181,6 @@ route_lookup:
1181 if (err) 1181 if (err)
1182 return err; 1182 return err;
1183 1183
1184 skb->protocol = htons(ETH_P_IPV6);
1185 skb_push(skb, sizeof(struct ipv6hdr)); 1184 skb_push(skb, sizeof(struct ipv6hdr));
1186 skb_reset_network_header(skb); 1185 skb_reset_network_header(skb);
1187 ipv6h = ipv6_hdr(skb); 1186 ipv6h = ipv6_hdr(skb);
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 8a02ca8a11af..c299c1e2bbf0 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -1138,6 +1138,33 @@ static struct xfrm6_protocol vti_ipcomp6_protocol __read_mostly = {
1138 .priority = 100, 1138 .priority = 100,
1139}; 1139};
1140 1140
1141static bool is_vti6_tunnel(const struct net_device *dev)
1142{
1143 return dev->netdev_ops == &vti6_netdev_ops;
1144}
1145
1146static int vti6_device_event(struct notifier_block *unused,
1147 unsigned long event, void *ptr)
1148{
1149 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1150 struct ip6_tnl *t = netdev_priv(dev);
1151
1152 if (!is_vti6_tunnel(dev))
1153 return NOTIFY_DONE;
1154
1155 switch (event) {
1156 case NETDEV_DOWN:
1157 if (!net_eq(t->net, dev_net(dev)))
1158 xfrm_garbage_collect(t->net);
1159 break;
1160 }
1161 return NOTIFY_DONE;
1162}
1163
1164static struct notifier_block vti6_notifier_block __read_mostly = {
1165 .notifier_call = vti6_device_event,
1166};
1167
1141/** 1168/**
1142 * vti6_tunnel_init - register protocol and reserve needed resources 1169 * vti6_tunnel_init - register protocol and reserve needed resources
1143 * 1170 *
@@ -1148,6 +1175,8 @@ static int __init vti6_tunnel_init(void)
1148 const char *msg; 1175 const char *msg;
1149 int err; 1176 int err;
1150 1177
1178 register_netdevice_notifier(&vti6_notifier_block);
1179
1151 msg = "tunnel device"; 1180 msg = "tunnel device";
1152 err = register_pernet_device(&vti6_net_ops); 1181 err = register_pernet_device(&vti6_net_ops);
1153 if (err < 0) 1182 if (err < 0)
@@ -1180,6 +1209,7 @@ xfrm_proto_ah_failed:
1180xfrm_proto_esp_failed: 1209xfrm_proto_esp_failed:
1181 unregister_pernet_device(&vti6_net_ops); 1210 unregister_pernet_device(&vti6_net_ops);
1182pernet_dev_failed: 1211pernet_dev_failed:
1212 unregister_netdevice_notifier(&vti6_notifier_block);
1183 pr_err("vti6 init: failed to register %s\n", msg); 1213 pr_err("vti6 init: failed to register %s\n", msg);
1184 return err; 1214 return err;
1185} 1215}
@@ -1194,6 +1224,7 @@ static void __exit vti6_tunnel_cleanup(void)
1194 xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH); 1224 xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH);
1195 xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); 1225 xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP);
1196 unregister_pernet_device(&vti6_net_ops); 1226 unregister_pernet_device(&vti6_net_ops);
1227 unregister_netdevice_notifier(&vti6_notifier_block);
1197} 1228}
1198 1229
1199module_init(vti6_tunnel_init); 1230module_init(vti6_tunnel_init);
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index e4347aeb2e65..9948b5ce52da 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -576,11 +576,11 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
576 /* Jumbo payload inhibits frag. header */ 576 /* Jumbo payload inhibits frag. header */
577 if (ipv6_hdr(skb)->payload_len == 0) { 577 if (ipv6_hdr(skb)->payload_len == 0) {
578 pr_debug("payload len = 0\n"); 578 pr_debug("payload len = 0\n");
579 return -EINVAL; 579 return 0;
580 } 580 }
581 581
582 if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0) 582 if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)
583 return -EINVAL; 583 return 0;
584 584
585 if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr))) 585 if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr)))
586 return -ENOMEM; 586 return -ENOMEM;
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index f7aab5ab93a5..f06b0471f39f 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -69,7 +69,7 @@ static unsigned int ipv6_defrag(void *priv,
69 if (err == -EINPROGRESS) 69 if (err == -EINPROGRESS)
70 return NF_STOLEN; 70 return NF_STOLEN;
71 71
72 return NF_ACCEPT; 72 return err == 0 ? NF_ACCEPT : NF_DROP;
73} 73}
74 74
75static struct nf_hook_ops ipv6_defrag_ops[] = { 75static struct nf_hook_ops ipv6_defrag_ops[] = {
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index a5400223fd74..10090400c72f 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -156,6 +156,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
156 fl6.daddr = oip6h->saddr; 156 fl6.daddr = oip6h->saddr;
157 fl6.fl6_sport = otcph->dest; 157 fl6.fl6_sport = otcph->dest;
158 fl6.fl6_dport = otcph->source; 158 fl6.fl6_dport = otcph->source;
159 fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev);
159 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); 160 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
160 dst = ip6_route_output(net, NULL, &fl6); 161 dst = ip6_route_output(net, NULL, &fl6);
161 if (dst->error) { 162 if (dst->error) {
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index 7cca8ac66fe9..cd4252346a32 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -155,6 +155,8 @@ int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
155 if (unlikely(!skb)) 155 if (unlikely(!skb))
156 return 0; 156 return 0;
157 157
158 skb->protocol = htons(ETH_P_IPV6);
159
158 return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, 160 return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
159 net, sk, skb, NULL, skb_dst(skb)->dev, 161 net, sk, skb, NULL, skb_dst(skb)->dev,
160 dst_output); 162 dst_output);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e5056d4873d1..e4a8000d59ad 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -514,7 +514,7 @@ out:
514 return; 514 return;
515} 515}
516 516
517static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 517int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
518{ 518{
519 int rc; 519 int rc;
520 520
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index f6eb1ab34f4b..e78bdc76dcc3 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -26,7 +26,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
26int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); 26int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
27int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, 27int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
28 int flags, int *addr_len); 28 int flags, int *addr_len);
29int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 29int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
30void udpv6_destroy_sock(struct sock *sk); 30void udpv6_destroy_sock(struct sock *sk);
31 31
32#ifdef CONFIG_PROC_FS 32#ifdef CONFIG_PROC_FS
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 47d0d2b87106..2f5101a12283 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -45,7 +45,7 @@ struct proto udplitev6_prot = {
45 .getsockopt = udpv6_getsockopt, 45 .getsockopt = udpv6_getsockopt,
46 .sendmsg = udpv6_sendmsg, 46 .sendmsg = udpv6_sendmsg,
47 .recvmsg = udpv6_recvmsg, 47 .recvmsg = udpv6_recvmsg,
48 .backlog_rcv = udpv6_queue_rcv_skb, 48 .backlog_rcv = __udpv6_queue_rcv_skb,
49 .hash = udp_lib_hash, 49 .hash = udp_lib_hash,
50 .unhash = udp_lib_unhash, 50 .unhash = udp_lib_unhash,
51 .get_port = udp_v6_get_port, 51 .get_port = udp_v6_get_port,
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 3dc97b4f982b..965f7e344cef 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -97,7 +97,7 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
97 unsigned int len = skb->len; 97 unsigned int len = skb->len;
98 int ret = l2tp_xmit_skb(session, skb, session->hdr_len); 98 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
99 99
100 if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { 100 if (likely(ret == NET_XMIT_SUCCESS)) {
101 atomic_long_add(len, &priv->tx_bytes); 101 atomic_long_add(len, &priv->tx_bytes);
102 atomic_long_inc(&priv->tx_packets); 102 atomic_long_inc(&priv->tx_packets);
103 } else { 103 } else {
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 982f6c44ea01..8938b6ba57a0 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -61,7 +61,8 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif
61 if ((l2tp->conn_id == tunnel_id) && 61 if ((l2tp->conn_id == tunnel_id) &&
62 net_eq(sock_net(sk), net) && 62 net_eq(sock_net(sk), net) &&
63 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && 63 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
64 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) 64 (!sk->sk_bound_dev_if || !dif ||
65 sk->sk_bound_dev_if == dif))
65 goto found; 66 goto found;
66 } 67 }
67 68
@@ -182,15 +183,17 @@ pass_up:
182 struct iphdr *iph = (struct iphdr *) skb_network_header(skb); 183 struct iphdr *iph = (struct iphdr *) skb_network_header(skb);
183 184
184 read_lock_bh(&l2tp_ip_lock); 185 read_lock_bh(&l2tp_ip_lock);
185 sk = __l2tp_ip_bind_lookup(net, iph->daddr, 0, tunnel_id); 186 sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb),
187 tunnel_id);
188 if (!sk) {
189 read_unlock_bh(&l2tp_ip_lock);
190 goto discard;
191 }
192
193 sock_hold(sk);
186 read_unlock_bh(&l2tp_ip_lock); 194 read_unlock_bh(&l2tp_ip_lock);
187 } 195 }
188 196
189 if (sk == NULL)
190 goto discard;
191
192 sock_hold(sk);
193
194 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) 197 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
195 goto discard_put; 198 goto discard_put;
196 199
@@ -256,15 +259,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
256 if (addr->l2tp_family != AF_INET) 259 if (addr->l2tp_family != AF_INET)
257 return -EINVAL; 260 return -EINVAL;
258 261
259 ret = -EADDRINUSE;
260 read_lock_bh(&l2tp_ip_lock);
261 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr,
262 sk->sk_bound_dev_if, addr->l2tp_conn_id))
263 goto out_in_use;
264
265 read_unlock_bh(&l2tp_ip_lock);
266
267 lock_sock(sk); 262 lock_sock(sk);
263
264 ret = -EINVAL;
268 if (!sock_flag(sk, SOCK_ZAPPED)) 265 if (!sock_flag(sk, SOCK_ZAPPED))
269 goto out; 266 goto out;
270 267
@@ -281,14 +278,22 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
281 inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr; 278 inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr;
282 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) 279 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
283 inet->inet_saddr = 0; /* Use device */ 280 inet->inet_saddr = 0; /* Use device */
284 sk_dst_reset(sk);
285 281
282 write_lock_bh(&l2tp_ip_lock);
283 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr,
284 sk->sk_bound_dev_if, addr->l2tp_conn_id)) {
285 write_unlock_bh(&l2tp_ip_lock);
286 ret = -EADDRINUSE;
287 goto out;
288 }
289
290 sk_dst_reset(sk);
286 l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id; 291 l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id;
287 292
288 write_lock_bh(&l2tp_ip_lock);
289 sk_add_bind_node(sk, &l2tp_ip_bind_table); 293 sk_add_bind_node(sk, &l2tp_ip_bind_table);
290 sk_del_node_init(sk); 294 sk_del_node_init(sk);
291 write_unlock_bh(&l2tp_ip_lock); 295 write_unlock_bh(&l2tp_ip_lock);
296
292 ret = 0; 297 ret = 0;
293 sock_reset_flag(sk, SOCK_ZAPPED); 298 sock_reset_flag(sk, SOCK_ZAPPED);
294 299
@@ -296,11 +301,6 @@ out:
296 release_sock(sk); 301 release_sock(sk);
297 302
298 return ret; 303 return ret;
299
300out_in_use:
301 read_unlock_bh(&l2tp_ip_lock);
302
303 return ret;
304} 304}
305 305
306static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) 306static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
@@ -308,21 +308,24 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
308 struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; 308 struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr;
309 int rc; 309 int rc;
310 310
311 if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
312 return -EINVAL;
313
314 if (addr_len < sizeof(*lsa)) 311 if (addr_len < sizeof(*lsa))
315 return -EINVAL; 312 return -EINVAL;
316 313
317 if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) 314 if (ipv4_is_multicast(lsa->l2tp_addr.s_addr))
318 return -EINVAL; 315 return -EINVAL;
319 316
320 rc = ip4_datagram_connect(sk, uaddr, addr_len);
321 if (rc < 0)
322 return rc;
323
324 lock_sock(sk); 317 lock_sock(sk);
325 318
319 /* Must bind first - autobinding does not work */
320 if (sock_flag(sk, SOCK_ZAPPED)) {
321 rc = -EINVAL;
322 goto out_sk;
323 }
324
325 rc = __ip4_datagram_connect(sk, uaddr, addr_len);
326 if (rc < 0)
327 goto out_sk;
328
326 l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; 329 l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
327 330
328 write_lock_bh(&l2tp_ip_lock); 331 write_lock_bh(&l2tp_ip_lock);
@@ -330,7 +333,9 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
330 sk_add_bind_node(sk, &l2tp_ip_bind_table); 333 sk_add_bind_node(sk, &l2tp_ip_bind_table);
331 write_unlock_bh(&l2tp_ip_lock); 334 write_unlock_bh(&l2tp_ip_lock);
332 335
336out_sk:
333 release_sock(sk); 337 release_sock(sk);
338
334 return rc; 339 return rc;
335} 340}
336 341
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 9978d01ba0ba..aa821cb639e5 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -72,8 +72,9 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
72 72
73 if ((l2tp->conn_id == tunnel_id) && 73 if ((l2tp->conn_id == tunnel_id) &&
74 net_eq(sock_net(sk), net) && 74 net_eq(sock_net(sk), net) &&
75 !(addr && ipv6_addr_equal(addr, laddr)) && 75 (!addr || ipv6_addr_equal(addr, laddr)) &&
76 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) 76 (!sk->sk_bound_dev_if || !dif ||
77 sk->sk_bound_dev_if == dif))
77 goto found; 78 goto found;
78 } 79 }
79 80
@@ -196,16 +197,17 @@ pass_up:
196 struct ipv6hdr *iph = ipv6_hdr(skb); 197 struct ipv6hdr *iph = ipv6_hdr(skb);
197 198
198 read_lock_bh(&l2tp_ip6_lock); 199 read_lock_bh(&l2tp_ip6_lock);
199 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, 200 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb),
200 0, tunnel_id); 201 tunnel_id);
202 if (!sk) {
203 read_unlock_bh(&l2tp_ip6_lock);
204 goto discard;
205 }
206
207 sock_hold(sk);
201 read_unlock_bh(&l2tp_ip6_lock); 208 read_unlock_bh(&l2tp_ip6_lock);
202 } 209 }
203 210
204 if (sk == NULL)
205 goto discard;
206
207 sock_hold(sk);
208
209 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 211 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
210 goto discard_put; 212 goto discard_put;
211 213
@@ -266,6 +268,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
266 struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr; 268 struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr;
267 struct net *net = sock_net(sk); 269 struct net *net = sock_net(sk);
268 __be32 v4addr = 0; 270 __be32 v4addr = 0;
271 int bound_dev_if;
269 int addr_type; 272 int addr_type;
270 int err; 273 int err;
271 274
@@ -284,13 +287,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
284 if (addr_type & IPV6_ADDR_MULTICAST) 287 if (addr_type & IPV6_ADDR_MULTICAST)
285 return -EADDRNOTAVAIL; 288 return -EADDRNOTAVAIL;
286 289
287 err = -EADDRINUSE;
288 read_lock_bh(&l2tp_ip6_lock);
289 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr,
290 sk->sk_bound_dev_if, addr->l2tp_conn_id))
291 goto out_in_use;
292 read_unlock_bh(&l2tp_ip6_lock);
293
294 lock_sock(sk); 290 lock_sock(sk);
295 291
296 err = -EINVAL; 292 err = -EINVAL;
@@ -300,28 +296,25 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
300 if (sk->sk_state != TCP_CLOSE) 296 if (sk->sk_state != TCP_CLOSE)
301 goto out_unlock; 297 goto out_unlock;
302 298
299 bound_dev_if = sk->sk_bound_dev_if;
300
303 /* Check if the address belongs to the host. */ 301 /* Check if the address belongs to the host. */
304 rcu_read_lock(); 302 rcu_read_lock();
305 if (addr_type != IPV6_ADDR_ANY) { 303 if (addr_type != IPV6_ADDR_ANY) {
306 struct net_device *dev = NULL; 304 struct net_device *dev = NULL;
307 305
308 if (addr_type & IPV6_ADDR_LINKLOCAL) { 306 if (addr_type & IPV6_ADDR_LINKLOCAL) {
309 if (addr_len >= sizeof(struct sockaddr_in6) && 307 if (addr->l2tp_scope_id)
310 addr->l2tp_scope_id) { 308 bound_dev_if = addr->l2tp_scope_id;
311 /* Override any existing binding, if another
312 * one is supplied by user.
313 */
314 sk->sk_bound_dev_if = addr->l2tp_scope_id;
315 }
316 309
317 /* Binding to link-local address requires an 310 /* Binding to link-local address requires an
318 interface */ 311 * interface.
319 if (!sk->sk_bound_dev_if) 312 */
313 if (!bound_dev_if)
320 goto out_unlock_rcu; 314 goto out_unlock_rcu;
321 315
322 err = -ENODEV; 316 err = -ENODEV;
323 dev = dev_get_by_index_rcu(sock_net(sk), 317 dev = dev_get_by_index_rcu(sock_net(sk), bound_dev_if);
324 sk->sk_bound_dev_if);
325 if (!dev) 318 if (!dev)
326 goto out_unlock_rcu; 319 goto out_unlock_rcu;
327 } 320 }
@@ -336,13 +329,22 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
336 } 329 }
337 rcu_read_unlock(); 330 rcu_read_unlock();
338 331
339 inet->inet_rcv_saddr = inet->inet_saddr = v4addr; 332 write_lock_bh(&l2tp_ip6_lock);
333 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if,
334 addr->l2tp_conn_id)) {
335 write_unlock_bh(&l2tp_ip6_lock);
336 err = -EADDRINUSE;
337 goto out_unlock;
338 }
339
340 inet->inet_saddr = v4addr;
341 inet->inet_rcv_saddr = v4addr;
342 sk->sk_bound_dev_if = bound_dev_if;
340 sk->sk_v6_rcv_saddr = addr->l2tp_addr; 343 sk->sk_v6_rcv_saddr = addr->l2tp_addr;
341 np->saddr = addr->l2tp_addr; 344 np->saddr = addr->l2tp_addr;
342 345
343 l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id; 346 l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id;
344 347
345 write_lock_bh(&l2tp_ip6_lock);
346 sk_add_bind_node(sk, &l2tp_ip6_bind_table); 348 sk_add_bind_node(sk, &l2tp_ip6_bind_table);
347 sk_del_node_init(sk); 349 sk_del_node_init(sk);
348 write_unlock_bh(&l2tp_ip6_lock); 350 write_unlock_bh(&l2tp_ip6_lock);
@@ -355,10 +357,7 @@ out_unlock_rcu:
355 rcu_read_unlock(); 357 rcu_read_unlock();
356out_unlock: 358out_unlock:
357 release_sock(sk); 359 release_sock(sk);
358 return err;
359 360
360out_in_use:
361 read_unlock_bh(&l2tp_ip6_lock);
362 return err; 361 return err;
363} 362}
364 363
@@ -371,9 +370,6 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
371 int addr_type; 370 int addr_type;
372 int rc; 371 int rc;
373 372
374 if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
375 return -EINVAL;
376
377 if (addr_len < sizeof(*lsa)) 373 if (addr_len < sizeof(*lsa))
378 return -EINVAL; 374 return -EINVAL;
379 375
@@ -390,10 +386,18 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
390 return -EINVAL; 386 return -EINVAL;
391 } 387 }
392 388
393 rc = ip6_datagram_connect(sk, uaddr, addr_len);
394
395 lock_sock(sk); 389 lock_sock(sk);
396 390
391 /* Must bind first - autobinding does not work */
392 if (sock_flag(sk, SOCK_ZAPPED)) {
393 rc = -EINVAL;
394 goto out_sk;
395 }
396
397 rc = __ip6_datagram_connect(sk, uaddr, addr_len);
398 if (rc < 0)
399 goto out_sk;
400
397 l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; 401 l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
398 402
399 write_lock_bh(&l2tp_ip6_lock); 403 write_lock_bh(&l2tp_ip6_lock);
@@ -401,6 +405,7 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
401 sk_add_bind_node(sk, &l2tp_ip6_bind_table); 405 sk_add_bind_node(sk, &l2tp_ip6_bind_table);
402 write_unlock_bh(&l2tp_ip6_lock); 406 write_unlock_bh(&l2tp_ip6_lock);
403 407
408out_sk:
404 release_sock(sk); 409 release_sock(sk);
405 410
406 return rc; 411 return rc;
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 0e4334cbde17..15fe97644ffe 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1252,7 +1252,7 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
1252 if (!nla) 1252 if (!nla)
1253 continue; 1253 continue;
1254 1254
1255 switch(index) { 1255 switch (index) {
1256 case RTA_OIF: 1256 case RTA_OIF:
1257 cfg->rc_ifindex = nla_get_u32(nla); 1257 cfg->rc_ifindex = nla_get_u32(nla);
1258 break; 1258 break;
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index bbb8f3df79f7..5b9c884a452e 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -42,7 +42,7 @@ struct nf_nat_conn_key {
42 const struct nf_conntrack_zone *zone; 42 const struct nf_conntrack_zone *zone;
43}; 43};
44 44
45static struct rhashtable nf_nat_bysource_table; 45static struct rhltable nf_nat_bysource_table;
46 46
47inline const struct nf_nat_l3proto * 47inline const struct nf_nat_l3proto *
48__nf_nat_l3proto_find(u8 family) 48__nf_nat_l3proto_find(u8 family)
@@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg,
193 const struct nf_nat_conn_key *key = arg->key; 193 const struct nf_nat_conn_key *key = arg->key;
194 const struct nf_conn *ct = obj; 194 const struct nf_conn *ct = obj;
195 195
196 return same_src(ct, key->tuple) && 196 if (!same_src(ct, key->tuple) ||
197 net_eq(nf_ct_net(ct), key->net) && 197 !net_eq(nf_ct_net(ct), key->net) ||
198 nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL); 198 !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL))
199 return 1;
200
201 return 0;
199} 202}
200 203
201static struct rhashtable_params nf_nat_bysource_params = { 204static struct rhashtable_params nf_nat_bysource_params = {
@@ -204,7 +207,6 @@ static struct rhashtable_params nf_nat_bysource_params = {
204 .obj_cmpfn = nf_nat_bysource_cmp, 207 .obj_cmpfn = nf_nat_bysource_cmp,
205 .nelem_hint = 256, 208 .nelem_hint = 256,
206 .min_size = 1024, 209 .min_size = 1024,
207 .nulls_base = (1U << RHT_BASE_SHIFT),
208}; 210};
209 211
210/* Only called for SRC manip */ 212/* Only called for SRC manip */
@@ -223,12 +225,15 @@ find_appropriate_src(struct net *net,
223 .tuple = tuple, 225 .tuple = tuple,
224 .zone = zone 226 .zone = zone
225 }; 227 };
228 struct rhlist_head *hl;
226 229
227 ct = rhashtable_lookup_fast(&nf_nat_bysource_table, &key, 230 hl = rhltable_lookup(&nf_nat_bysource_table, &key,
228 nf_nat_bysource_params); 231 nf_nat_bysource_params);
229 if (!ct) 232 if (!hl)
230 return 0; 233 return 0;
231 234
235 ct = container_of(hl, typeof(*ct), nat_bysource);
236
232 nf_ct_invert_tuplepr(result, 237 nf_ct_invert_tuplepr(result,
233 &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 238 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
234 result->dst = tuple->dst; 239 result->dst = tuple->dst;
@@ -446,11 +451,17 @@ nf_nat_setup_info(struct nf_conn *ct,
446 } 451 }
447 452
448 if (maniptype == NF_NAT_MANIP_SRC) { 453 if (maniptype == NF_NAT_MANIP_SRC) {
454 struct nf_nat_conn_key key = {
455 .net = nf_ct_net(ct),
456 .tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
457 .zone = nf_ct_zone(ct),
458 };
449 int err; 459 int err;
450 460
451 err = rhashtable_insert_fast(&nf_nat_bysource_table, 461 err = rhltable_insert_key(&nf_nat_bysource_table,
452 &ct->nat_bysource, 462 &key,
453 nf_nat_bysource_params); 463 &ct->nat_bysource,
464 nf_nat_bysource_params);
454 if (err) 465 if (err)
455 return NF_DROP; 466 return NF_DROP;
456 } 467 }
@@ -567,8 +578,8 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
567 * will delete entry from already-freed table. 578 * will delete entry from already-freed table.
568 */ 579 */
569 ct->status &= ~IPS_NAT_DONE_MASK; 580 ct->status &= ~IPS_NAT_DONE_MASK;
570 rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, 581 rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
571 nf_nat_bysource_params); 582 nf_nat_bysource_params);
572 583
573 /* don't delete conntrack. Although that would make things a lot 584 /* don't delete conntrack. Although that would make things a lot
574 * simpler, we'd end up flushing all conntracks on nat rmmod. 585 * simpler, we'd end up flushing all conntracks on nat rmmod.
@@ -698,8 +709,8 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
698 if (!nat) 709 if (!nat)
699 return; 710 return;
700 711
701 rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, 712 rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
702 nf_nat_bysource_params); 713 nf_nat_bysource_params);
703} 714}
704 715
705static struct nf_ct_ext_type nat_extend __read_mostly = { 716static struct nf_ct_ext_type nat_extend __read_mostly = {
@@ -834,13 +845,13 @@ static int __init nf_nat_init(void)
834{ 845{
835 int ret; 846 int ret;
836 847
837 ret = rhashtable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); 848 ret = rhltable_init(&nf_nat_bysource_table, &nf_nat_bysource_params);
838 if (ret) 849 if (ret)
839 return ret; 850 return ret;
840 851
841 ret = nf_ct_extend_register(&nat_extend); 852 ret = nf_ct_extend_register(&nat_extend);
842 if (ret < 0) { 853 if (ret < 0) {
843 rhashtable_destroy(&nf_nat_bysource_table); 854 rhltable_destroy(&nf_nat_bysource_table);
844 printk(KERN_ERR "nf_nat_core: Unable to register extension\n"); 855 printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
845 return ret; 856 return ret;
846 } 857 }
@@ -864,7 +875,7 @@ static int __init nf_nat_init(void)
864 return 0; 875 return 0;
865 876
866 cleanup_extend: 877 cleanup_extend:
867 rhashtable_destroy(&nf_nat_bysource_table); 878 rhltable_destroy(&nf_nat_bysource_table);
868 nf_ct_extend_unregister(&nat_extend); 879 nf_ct_extend_unregister(&nat_extend);
869 return ret; 880 return ret;
870} 881}
@@ -883,7 +894,7 @@ static void __exit nf_nat_cleanup(void)
883 for (i = 0; i < NFPROTO_NUMPROTO; i++) 894 for (i = 0; i < NFPROTO_NUMPROTO; i++)
884 kfree(nf_nat_l4protos[i]); 895 kfree(nf_nat_l4protos[i]);
885 896
886 rhashtable_destroy(&nf_nat_bysource_table); 897 rhltable_destroy(&nf_nat_bysource_table);
887} 898}
888 899
889MODULE_LICENSE("GPL"); 900MODULE_LICENSE("GPL");
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 026581b04ea8..e5194f6f906c 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2570,7 +2570,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
2570 } 2570 }
2571 2571
2572 if (set->timeout && 2572 if (set->timeout &&
2573 nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout), 2573 nla_put_be64(skb, NFTA_SET_TIMEOUT,
2574 cpu_to_be64(jiffies_to_msecs(set->timeout)),
2574 NFTA_SET_PAD)) 2575 NFTA_SET_PAD))
2575 goto nla_put_failure; 2576 goto nla_put_failure;
2576 if (set->gc_int && 2577 if (set->gc_int &&
@@ -2859,7 +2860,8 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
2859 if (nla[NFTA_SET_TIMEOUT] != NULL) { 2860 if (nla[NFTA_SET_TIMEOUT] != NULL) {
2860 if (!(flags & NFT_SET_TIMEOUT)) 2861 if (!(flags & NFT_SET_TIMEOUT))
2861 return -EINVAL; 2862 return -EINVAL;
2862 timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_TIMEOUT])); 2863 timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
2864 nla[NFTA_SET_TIMEOUT])));
2863 } 2865 }
2864 gc_int = 0; 2866 gc_int = 0;
2865 if (nla[NFTA_SET_GC_INTERVAL] != NULL) { 2867 if (nla[NFTA_SET_GC_INTERVAL] != NULL) {
@@ -3178,7 +3180,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb,
3178 3180
3179 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) && 3181 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) &&
3180 nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT, 3182 nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT,
3181 cpu_to_be64(*nft_set_ext_timeout(ext)), 3183 cpu_to_be64(jiffies_to_msecs(
3184 *nft_set_ext_timeout(ext))),
3182 NFTA_SET_ELEM_PAD)) 3185 NFTA_SET_ELEM_PAD))
3183 goto nla_put_failure; 3186 goto nla_put_failure;
3184 3187
@@ -3447,7 +3450,7 @@ void *nft_set_elem_init(const struct nft_set *set,
3447 memcpy(nft_set_ext_data(ext), data, set->dlen); 3450 memcpy(nft_set_ext_data(ext), data, set->dlen);
3448 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) 3451 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION))
3449 *nft_set_ext_expiration(ext) = 3452 *nft_set_ext_expiration(ext) =
3450 jiffies + msecs_to_jiffies(timeout); 3453 jiffies + timeout;
3451 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT)) 3454 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT))
3452 *nft_set_ext_timeout(ext) = timeout; 3455 *nft_set_ext_timeout(ext) = timeout;
3453 3456
@@ -3535,7 +3538,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
3535 if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) { 3538 if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) {
3536 if (!(set->flags & NFT_SET_TIMEOUT)) 3539 if (!(set->flags & NFT_SET_TIMEOUT))
3537 return -EINVAL; 3540 return -EINVAL;
3538 timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_ELEM_TIMEOUT])); 3541 timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
3542 nla[NFTA_SET_ELEM_TIMEOUT])));
3539 } else if (set->flags & NFT_SET_TIMEOUT) { 3543 } else if (set->flags & NFT_SET_TIMEOUT) {
3540 timeout = set->timeout; 3544 timeout = set->timeout;
3541 } 3545 }
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index baf694de3935..d5447a22275c 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -53,6 +53,7 @@ static int nft_hash_init(const struct nft_ctx *ctx,
53{ 53{
54 struct nft_hash *priv = nft_expr_priv(expr); 54 struct nft_hash *priv = nft_expr_priv(expr);
55 u32 len; 55 u32 len;
56 int err;
56 57
57 if (!tb[NFTA_HASH_SREG] || 58 if (!tb[NFTA_HASH_SREG] ||
58 !tb[NFTA_HASH_DREG] || 59 !tb[NFTA_HASH_DREG] ||
@@ -67,8 +68,10 @@ static int nft_hash_init(const struct nft_ctx *ctx,
67 priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]); 68 priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]);
68 priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]); 69 priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
69 70
70 len = ntohl(nla_get_be32(tb[NFTA_HASH_LEN])); 71 err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len);
71 if (len == 0 || len > U8_MAX) 72 if (err < 0)
73 return err;
74 if (len == 0)
72 return -ERANGE; 75 return -ERANGE;
73 76
74 priv->len = len; 77 priv->len = len;
diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
index fbc88009ca2e..8f0aaaea1376 100644
--- a/net/netfilter/nft_range.c
+++ b/net/netfilter/nft_range.c
@@ -59,6 +59,12 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr
59 int err; 59 int err;
60 u32 op; 60 u32 op;
61 61
62 if (!tb[NFTA_RANGE_SREG] ||
63 !tb[NFTA_RANGE_OP] ||
64 !tb[NFTA_RANGE_FROM_DATA] ||
65 !tb[NFTA_RANGE_TO_DATA])
66 return -EINVAL;
67
62 err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from), 68 err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from),
63 &desc_from, tb[NFTA_RANGE_FROM_DATA]); 69 &desc_from, tb[NFTA_RANGE_FROM_DATA]);
64 if (err < 0) 70 if (err < 0)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 62bea4591054..246f29d365c0 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -329,7 +329,6 @@ static void netlink_sock_destruct(struct sock *sk)
329 if (nlk->cb_running) { 329 if (nlk->cb_running) {
330 if (nlk->cb.done) 330 if (nlk->cb.done)
331 nlk->cb.done(&nlk->cb); 331 nlk->cb.done(&nlk->cb);
332
333 module_put(nlk->cb.module); 332 module_put(nlk->cb.module);
334 kfree_skb(nlk->cb.skb); 333 kfree_skb(nlk->cb.skb);
335 } 334 }
@@ -346,6 +345,14 @@ static void netlink_sock_destruct(struct sock *sk)
346 WARN_ON(nlk_sk(sk)->groups); 345 WARN_ON(nlk_sk(sk)->groups);
347} 346}
348 347
348static void netlink_sock_destruct_work(struct work_struct *work)
349{
350 struct netlink_sock *nlk = container_of(work, struct netlink_sock,
351 work);
352
353 sk_free(&nlk->sk);
354}
355
349/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on 356/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
350 * SMP. Look, when several writers sleep and reader wakes them up, all but one 357 * SMP. Look, when several writers sleep and reader wakes them up, all but one
351 * immediately hit write lock and grab all the cpus. Exclusive sleep solves 358 * immediately hit write lock and grab all the cpus. Exclusive sleep solves
@@ -648,8 +655,18 @@ out_module:
648static void deferred_put_nlk_sk(struct rcu_head *head) 655static void deferred_put_nlk_sk(struct rcu_head *head)
649{ 656{
650 struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu); 657 struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
658 struct sock *sk = &nlk->sk;
659
660 if (!atomic_dec_and_test(&sk->sk_refcnt))
661 return;
662
663 if (nlk->cb_running && nlk->cb.done) {
664 INIT_WORK(&nlk->work, netlink_sock_destruct_work);
665 schedule_work(&nlk->work);
666 return;
667 }
651 668
652 sock_put(&nlk->sk); 669 sk_free(sk);
653} 670}
654 671
655static int netlink_release(struct socket *sock) 672static int netlink_release(struct socket *sock)
diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h
index 3cfd6cc60504..4fdb38318977 100644
--- a/net/netlink/af_netlink.h
+++ b/net/netlink/af_netlink.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/rhashtable.h> 4#include <linux/rhashtable.h>
5#include <linux/atomic.h> 5#include <linux/atomic.h>
6#include <linux/workqueue.h>
6#include <net/sock.h> 7#include <net/sock.h>
7 8
8#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) 9#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8)
@@ -33,6 +34,7 @@ struct netlink_sock {
33 34
34 struct rhash_head node; 35 struct rhash_head node;
35 struct rcu_head rcu; 36 struct rcu_head rcu;
37 struct work_struct work;
36}; 38};
37 39
38static inline struct netlink_sock *nlk_sk(struct sock *sk) 40static inline struct netlink_sock *nlk_sk(struct sock *sk)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 31045ef44a82..fecefa2dc94e 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
370 skb_orphan(skb); 370 skb_orphan(skb);
371 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); 371 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
372 err = nf_ct_frag6_gather(net, skb, user); 372 err = nf_ct_frag6_gather(net, skb, user);
373 if (err) 373 if (err) {
374 if (err != -EINPROGRESS)
375 kfree_skb(skb);
374 return err; 376 return err;
377 }
375 378
376 key->ip.proto = ipv6_hdr(skb)->nexthdr; 379 key->ip.proto = ipv6_hdr(skb)->nexthdr;
377 ovs_cb.mru = IP6CB(skb)->frag_max_size; 380 ovs_cb.mru = IP6CB(skb)->frag_max_size;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d2238b204691..dd2332390c45 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3648,19 +3648,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
3648 3648
3649 if (optlen != sizeof(val)) 3649 if (optlen != sizeof(val))
3650 return -EINVAL; 3650 return -EINVAL;
3651 if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
3652 return -EBUSY;
3653 if (copy_from_user(&val, optval, sizeof(val))) 3651 if (copy_from_user(&val, optval, sizeof(val)))
3654 return -EFAULT; 3652 return -EFAULT;
3655 switch (val) { 3653 switch (val) {
3656 case TPACKET_V1: 3654 case TPACKET_V1:
3657 case TPACKET_V2: 3655 case TPACKET_V2:
3658 case TPACKET_V3: 3656 case TPACKET_V3:
3659 po->tp_version = val; 3657 break;
3660 return 0;
3661 default: 3658 default:
3662 return -EINVAL; 3659 return -EINVAL;
3663 } 3660 }
3661 lock_sock(sk);
3662 if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
3663 ret = -EBUSY;
3664 } else {
3665 po->tp_version = val;
3666 ret = 0;
3667 }
3668 release_sock(sk);
3669 return ret;
3664 } 3670 }
3665 case PACKET_RESERVE: 3671 case PACKET_RESERVE:
3666 { 3672 {
@@ -4164,6 +4170,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
4164 /* Added to avoid minimal code churn */ 4170 /* Added to avoid minimal code churn */
4165 struct tpacket_req *req = &req_u->req; 4171 struct tpacket_req *req = &req_u->req;
4166 4172
4173 lock_sock(sk);
4167 /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ 4174 /* Opening a Tx-ring is NOT supported in TPACKET_V3 */
4168 if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { 4175 if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) {
4169 net_warn_ratelimited("Tx-ring is not supported.\n"); 4176 net_warn_ratelimited("Tx-ring is not supported.\n");
@@ -4245,7 +4252,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
4245 goto out; 4252 goto out;
4246 } 4253 }
4247 4254
4248 lock_sock(sk);
4249 4255
4250 /* Detach socket from network */ 4256 /* Detach socket from network */
4251 spin_lock(&po->bind_lock); 4257 spin_lock(&po->bind_lock);
@@ -4294,11 +4300,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
4294 if (!tx_ring) 4300 if (!tx_ring)
4295 prb_shutdown_retire_blk_timer(po, rb_queue); 4301 prb_shutdown_retire_blk_timer(po, rb_queue);
4296 } 4302 }
4297 release_sock(sk);
4298 4303
4299 if (pg_vec) 4304 if (pg_vec)
4300 free_pg_vec(pg_vec, order, req->tp_block_nr); 4305 free_pg_vec(pg_vec, order, req->tp_block_nr);
4301out: 4306out:
4307 release_sock(sk);
4302 return err; 4308 return err;
4303} 4309}
4304 4310
diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index fcddacc92e01..20e2923dc827 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -659,6 +659,8 @@ out_recv:
659out_pernet: 659out_pernet:
660 unregister_pernet_subsys(&rds_tcp_net_ops); 660 unregister_pernet_subsys(&rds_tcp_net_ops);
661out_slab: 661out_slab:
662 if (unregister_netdevice_notifier(&rds_tcp_dev_notifier))
663 pr_warn("could not unregister rds_tcp_dev_notifier\n");
662 kmem_cache_destroy(rds_tcp_conn_slab); 664 kmem_cache_destroy(rds_tcp_conn_slab);
663out: 665out:
664 return ret; 666 return ret;
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index b54d56d4959b..cf9b2fe8eac6 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -108,6 +108,17 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind)
108 kfree(keys); 108 kfree(keys);
109} 109}
110 110
111static bool offset_valid(struct sk_buff *skb, int offset)
112{
113 if (offset > 0 && offset > skb->len)
114 return false;
115
116 if (offset < 0 && -offset > skb_headroom(skb))
117 return false;
118
119 return true;
120}
121
111static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, 122static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
112 struct tcf_result *res) 123 struct tcf_result *res)
113{ 124{
@@ -134,6 +145,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
134 if (tkey->offmask) { 145 if (tkey->offmask) {
135 char *d, _d; 146 char *d, _d;
136 147
148 if (!offset_valid(skb, off + tkey->at)) {
149 pr_info("tc filter pedit 'at' offset %d out of bounds\n",
150 off + tkey->at);
151 goto bad;
152 }
137 d = skb_header_pointer(skb, off + tkey->at, 1, 153 d = skb_header_pointer(skb, off + tkey->at, 1,
138 &_d); 154 &_d);
139 if (!d) 155 if (!d)
@@ -146,10 +162,10 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
146 " offset must be on 32 bit boundaries\n"); 162 " offset must be on 32 bit boundaries\n");
147 goto bad; 163 goto bad;
148 } 164 }
149 if (offset > 0 && offset > skb->len) { 165
150 pr_info("tc filter pedit" 166 if (!offset_valid(skb, off + offset)) {
151 " offset %d can't exceed pkt length %d\n", 167 pr_info("tc filter pedit offset %d out of bounds\n",
152 offset, skb->len); 168 offset);
153 goto bad; 169 goto bad;
154 } 170 }
155 171
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 8e93d4afe5ea..b05d4a2155b0 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -112,7 +112,7 @@ static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
112 112
113 for (it_chain = chain; (tp = rtnl_dereference(*it_chain)) != NULL; 113 for (it_chain = chain; (tp = rtnl_dereference(*it_chain)) != NULL;
114 it_chain = &tp->next) 114 it_chain = &tp->next)
115 tfilter_notify(net, oskb, n, tp, n->nlmsg_flags, event, false); 115 tfilter_notify(net, oskb, n, tp, 0, event, false);
116} 116}
117 117
118/* Select new prio value from the range, managed by kernel. */ 118/* Select new prio value from the range, managed by kernel. */
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index eb219b78cd49..5877f6061b57 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -62,9 +62,6 @@ static unsigned long basic_get(struct tcf_proto *tp, u32 handle)
62 struct basic_head *head = rtnl_dereference(tp->root); 62 struct basic_head *head = rtnl_dereference(tp->root);
63 struct basic_filter *f; 63 struct basic_filter *f;
64 64
65 if (head == NULL)
66 return 0UL;
67
68 list_for_each_entry(f, &head->flist, link) { 65 list_for_each_entry(f, &head->flist, link) {
69 if (f->handle == handle) { 66 if (f->handle == handle) {
70 l = (unsigned long) f; 67 l = (unsigned long) f;
@@ -109,7 +106,6 @@ static bool basic_destroy(struct tcf_proto *tp, bool force)
109 tcf_unbind_filter(tp, &f->res); 106 tcf_unbind_filter(tp, &f->res);
110 call_rcu(&f->rcu, basic_delete_filter); 107 call_rcu(&f->rcu, basic_delete_filter);
111 } 108 }
112 RCU_INIT_POINTER(tp->root, NULL);
113 kfree_rcu(head, rcu); 109 kfree_rcu(head, rcu);
114 return true; 110 return true;
115} 111}
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index bb1d5a487081..0a47ba5e6109 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -292,7 +292,6 @@ static bool cls_bpf_destroy(struct tcf_proto *tp, bool force)
292 call_rcu(&prog->rcu, __cls_bpf_delete_prog); 292 call_rcu(&prog->rcu, __cls_bpf_delete_prog);
293 } 293 }
294 294
295 RCU_INIT_POINTER(tp->root, NULL);
296 kfree_rcu(head, rcu); 295 kfree_rcu(head, rcu);
297 return true; 296 return true;
298} 297}
@@ -303,9 +302,6 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
303 struct cls_bpf_prog *prog; 302 struct cls_bpf_prog *prog;
304 unsigned long ret = 0UL; 303 unsigned long ret = 0UL;
305 304
306 if (head == NULL)
307 return 0UL;
308
309 list_for_each_entry(prog, &head->plist, link) { 305 list_for_each_entry(prog, &head->plist, link) {
310 if (prog->handle == handle) { 306 if (prog->handle == handle) {
311 ret = (unsigned long) prog; 307 ret = (unsigned long) prog;
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 85233c470035..c1f20077837f 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -137,11 +137,10 @@ static bool cls_cgroup_destroy(struct tcf_proto *tp, bool force)
137 137
138 if (!force) 138 if (!force)
139 return false; 139 return false;
140 140 /* Head can still be NULL due to cls_cgroup_init(). */
141 if (head) { 141 if (head)
142 RCU_INIT_POINTER(tp->root, NULL);
143 call_rcu(&head->rcu, cls_cgroup_destroy_rcu); 142 call_rcu(&head->rcu, cls_cgroup_destroy_rcu);
144 } 143
145 return true; 144 return true;
146} 145}
147 146
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index e39672394c7b..6575aba87630 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -596,7 +596,6 @@ static bool flow_destroy(struct tcf_proto *tp, bool force)
596 list_del_rcu(&f->list); 596 list_del_rcu(&f->list);
597 call_rcu(&f->rcu, flow_destroy_filter); 597 call_rcu(&f->rcu, flow_destroy_filter);
598 } 598 }
599 RCU_INIT_POINTER(tp->root, NULL);
600 kfree_rcu(head, rcu); 599 kfree_rcu(head, rcu);
601 return true; 600 return true;
602} 601}
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index f6f40fba599b..904442421db3 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/rhashtable.h> 15#include <linux/rhashtable.h>
16#include <linux/workqueue.h>
16 17
17#include <linux/if_ether.h> 18#include <linux/if_ether.h>
18#include <linux/in6.h> 19#include <linux/in6.h>
@@ -64,7 +65,10 @@ struct cls_fl_head {
64 bool mask_assigned; 65 bool mask_assigned;
65 struct list_head filters; 66 struct list_head filters;
66 struct rhashtable_params ht_params; 67 struct rhashtable_params ht_params;
67 struct rcu_head rcu; 68 union {
69 struct work_struct work;
70 struct rcu_head rcu;
71 };
68}; 72};
69 73
70struct cls_fl_filter { 74struct cls_fl_filter {
@@ -269,6 +273,24 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
269 dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); 273 dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
270} 274}
271 275
276static void fl_destroy_sleepable(struct work_struct *work)
277{
278 struct cls_fl_head *head = container_of(work, struct cls_fl_head,
279 work);
280 if (head->mask_assigned)
281 rhashtable_destroy(&head->ht);
282 kfree(head);
283 module_put(THIS_MODULE);
284}
285
286static void fl_destroy_rcu(struct rcu_head *rcu)
287{
288 struct cls_fl_head *head = container_of(rcu, struct cls_fl_head, rcu);
289
290 INIT_WORK(&head->work, fl_destroy_sleepable);
291 schedule_work(&head->work);
292}
293
272static bool fl_destroy(struct tcf_proto *tp, bool force) 294static bool fl_destroy(struct tcf_proto *tp, bool force)
273{ 295{
274 struct cls_fl_head *head = rtnl_dereference(tp->root); 296 struct cls_fl_head *head = rtnl_dereference(tp->root);
@@ -282,10 +304,9 @@ static bool fl_destroy(struct tcf_proto *tp, bool force)
282 list_del_rcu(&f->list); 304 list_del_rcu(&f->list);
283 call_rcu(&f->rcu, fl_destroy_filter); 305 call_rcu(&f->rcu, fl_destroy_filter);
284 } 306 }
285 RCU_INIT_POINTER(tp->root, NULL); 307
286 if (head->mask_assigned) 308 __module_get(THIS_MODULE);
287 rhashtable_destroy(&head->ht); 309 call_rcu(&head->rcu, fl_destroy_rcu);
288 kfree_rcu(head, rcu);
289 return true; 310 return true;
290} 311}
291 312
@@ -711,8 +732,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
711 goto errout; 732 goto errout;
712 733
713 if (fold) { 734 if (fold) {
714 rhashtable_remove_fast(&head->ht, &fold->ht_node, 735 if (!tc_skip_sw(fold->flags))
715 head->ht_params); 736 rhashtable_remove_fast(&head->ht, &fold->ht_node,
737 head->ht_params);
716 fl_hw_destroy_filter(tp, (unsigned long)fold); 738 fl_hw_destroy_filter(tp, (unsigned long)fold);
717 } 739 }
718 740
@@ -739,8 +761,9 @@ static int fl_delete(struct tcf_proto *tp, unsigned long arg)
739 struct cls_fl_head *head = rtnl_dereference(tp->root); 761 struct cls_fl_head *head = rtnl_dereference(tp->root);
740 struct cls_fl_filter *f = (struct cls_fl_filter *) arg; 762 struct cls_fl_filter *f = (struct cls_fl_filter *) arg;
741 763
742 rhashtable_remove_fast(&head->ht, &f->ht_node, 764 if (!tc_skip_sw(f->flags))
743 head->ht_params); 765 rhashtable_remove_fast(&head->ht, &f->ht_node,
766 head->ht_params);
744 list_del_rcu(&f->list); 767 list_del_rcu(&f->list);
745 fl_hw_destroy_filter(tp, (unsigned long)f); 768 fl_hw_destroy_filter(tp, (unsigned long)f);
746 tcf_unbind_filter(tp, &f->res); 769 tcf_unbind_filter(tp, &f->res);
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index 25927b6c4436..f935429bd5ef 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -114,7 +114,6 @@ static bool mall_destroy(struct tcf_proto *tp, bool force)
114 114
115 call_rcu(&f->rcu, mall_destroy_filter); 115 call_rcu(&f->rcu, mall_destroy_filter);
116 } 116 }
117 RCU_INIT_POINTER(tp->root, NULL);
118 kfree_rcu(head, rcu); 117 kfree_rcu(head, rcu);
119 return true; 118 return true;
120} 119}
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 4f05a19fb073..322438fb3ffc 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -152,7 +152,8 @@ static int rsvp_classify(struct sk_buff *skb, const struct tcf_proto *tp,
152 return -1; 152 return -1;
153 nhptr = ip_hdr(skb); 153 nhptr = ip_hdr(skb);
154#endif 154#endif
155 155 if (unlikely(!head))
156 return -1;
156restart: 157restart:
157 158
158#if RSVP_DST_LEN == 4 159#if RSVP_DST_LEN == 4
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 96144bdf30db..0751245a6ace 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -543,7 +543,6 @@ static bool tcindex_destroy(struct tcf_proto *tp, bool force)
543 walker.fn = tcindex_destroy_element; 543 walker.fn = tcindex_destroy_element;
544 tcindex_walk(tp, &walker); 544 tcindex_walk(tp, &walker);
545 545
546 RCU_INIT_POINTER(tp->root, NULL);
547 call_rcu(&p->rcu, __tcindex_destroy); 546 call_rcu(&p->rcu, __tcindex_destroy);
548 return true; 547 return true;
549} 548}
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 975dbeb60ab0..52d74760fb68 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -421,6 +421,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
421 dev = dev_get_by_name(net, driver_name); 421 dev = dev_get_by_name(net, driver_name);
422 if (!dev) 422 if (!dev)
423 return -ENODEV; 423 return -ENODEV;
424 if (tipc_mtu_bad(dev, 0)) {
425 dev_put(dev);
426 return -EINVAL;
427 }
424 428
425 /* Associate TIPC bearer with L2 bearer */ 429 /* Associate TIPC bearer with L2 bearer */
426 rcu_assign_pointer(b->media_ptr, dev); 430 rcu_assign_pointer(b->media_ptr, dev);
@@ -610,8 +614,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
610 if (!b) 614 if (!b)
611 return NOTIFY_DONE; 615 return NOTIFY_DONE;
612 616
613 b->mtu = dev->mtu;
614
615 switch (evt) { 617 switch (evt) {
616 case NETDEV_CHANGE: 618 case NETDEV_CHANGE:
617 if (netif_carrier_ok(dev)) 619 if (netif_carrier_ok(dev))
@@ -624,6 +626,11 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
624 tipc_reset_bearer(net, b); 626 tipc_reset_bearer(net, b);
625 break; 627 break;
626 case NETDEV_CHANGEMTU: 628 case NETDEV_CHANGEMTU:
629 if (tipc_mtu_bad(dev, 0)) {
630 bearer_disable(net, b);
631 break;
632 }
633 b->mtu = dev->mtu;
627 tipc_reset_bearer(net, b); 634 tipc_reset_bearer(net, b);
628 break; 635 break;
629 case NETDEV_CHANGEADDR: 636 case NETDEV_CHANGEADDR:
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 78892e2f53e3..278ff7f616f9 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -39,6 +39,7 @@
39 39
40#include "netlink.h" 40#include "netlink.h"
41#include "core.h" 41#include "core.h"
42#include "msg.h"
42#include <net/genetlink.h> 43#include <net/genetlink.h>
43 44
44#define MAX_MEDIA 3 45#define MAX_MEDIA 3
@@ -59,6 +60,9 @@
59#define TIPC_MEDIA_TYPE_IB 2 60#define TIPC_MEDIA_TYPE_IB 2
60#define TIPC_MEDIA_TYPE_UDP 3 61#define TIPC_MEDIA_TYPE_UDP 3
61 62
63/* minimum bearer MTU */
64#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE)
65
62/** 66/**
63 * struct tipc_media_addr - destination address used by TIPC bearers 67 * struct tipc_media_addr - destination address used by TIPC bearers
64 * @value: address info (format defined by media) 68 * @value: address info (format defined by media)
@@ -215,4 +219,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id,
215void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, 219void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id,
216 struct sk_buff_head *xmitq); 220 struct sk_buff_head *xmitq);
217 221
222/* check if device MTU is too low for tipc headers */
223static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve)
224{
225 if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve)
226 return false;
227 netdev_warn(dev, "MTU too low for tipc bearer\n");
228 return true;
229}
230
218#endif /* _TIPC_BEARER_H */ 231#endif /* _TIPC_BEARER_H */
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 1055164c6232..bda89bf9f4ff 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -47,8 +47,8 @@
47#include <linux/pkt_sched.h> 47#include <linux/pkt_sched.h>
48 48
49struct tipc_stats { 49struct tipc_stats {
50 u32 sent_info; /* used in counting # sent packets */ 50 u32 sent_pkts;
51 u32 recv_info; /* used in counting # recv'd packets */ 51 u32 recv_pkts;
52 u32 sent_states; 52 u32 sent_states;
53 u32 recv_states; 53 u32 recv_states;
54 u32 sent_probes; 54 u32 sent_probes;
@@ -857,7 +857,6 @@ void tipc_link_reset(struct tipc_link *l)
857 l->acked = 0; 857 l->acked = 0;
858 l->silent_intv_cnt = 0; 858 l->silent_intv_cnt = 0;
859 l->rst_cnt = 0; 859 l->rst_cnt = 0;
860 l->stats.recv_info = 0;
861 l->stale_count = 0; 860 l->stale_count = 0;
862 l->bc_peer_is_up = false; 861 l->bc_peer_is_up = false;
863 memset(&l->mon_state, 0, sizeof(l->mon_state)); 862 memset(&l->mon_state, 0, sizeof(l->mon_state));
@@ -888,6 +887,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
888 struct sk_buff_head *transmq = &l->transmq; 887 struct sk_buff_head *transmq = &l->transmq;
889 struct sk_buff_head *backlogq = &l->backlogq; 888 struct sk_buff_head *backlogq = &l->backlogq;
890 struct sk_buff *skb, *_skb, *bskb; 889 struct sk_buff *skb, *_skb, *bskb;
890 int pkt_cnt = skb_queue_len(list);
891 891
892 /* Match msg importance against this and all higher backlog limits: */ 892 /* Match msg importance against this and all higher backlog limits: */
893 if (!skb_queue_empty(backlogq)) { 893 if (!skb_queue_empty(backlogq)) {
@@ -901,6 +901,11 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
901 return -EMSGSIZE; 901 return -EMSGSIZE;
902 } 902 }
903 903
904 if (pkt_cnt > 1) {
905 l->stats.sent_fragmented++;
906 l->stats.sent_fragments += pkt_cnt;
907 }
908
904 /* Prepare each packet for sending, and add to relevant queue: */ 909 /* Prepare each packet for sending, and add to relevant queue: */
905 while (skb_queue_len(list)) { 910 while (skb_queue_len(list)) {
906 skb = skb_peek(list); 911 skb = skb_peek(list);
@@ -920,6 +925,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
920 __skb_queue_tail(xmitq, _skb); 925 __skb_queue_tail(xmitq, _skb);
921 TIPC_SKB_CB(skb)->ackers = l->ackers; 926 TIPC_SKB_CB(skb)->ackers = l->ackers;
922 l->rcv_unacked = 0; 927 l->rcv_unacked = 0;
928 l->stats.sent_pkts++;
923 seqno++; 929 seqno++;
924 continue; 930 continue;
925 } 931 }
@@ -968,6 +974,7 @@ void tipc_link_advance_backlog(struct tipc_link *l, struct sk_buff_head *xmitq)
968 msg_set_ack(hdr, ack); 974 msg_set_ack(hdr, ack);
969 msg_set_bcast_ack(hdr, bc_ack); 975 msg_set_bcast_ack(hdr, bc_ack);
970 l->rcv_unacked = 0; 976 l->rcv_unacked = 0;
977 l->stats.sent_pkts++;
971 seqno++; 978 seqno++;
972 } 979 }
973 l->snd_nxt = seqno; 980 l->snd_nxt = seqno;
@@ -1260,7 +1267,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
1260 1267
1261 /* Deliver packet */ 1268 /* Deliver packet */
1262 l->rcv_nxt++; 1269 l->rcv_nxt++;
1263 l->stats.recv_info++; 1270 l->stats.recv_pkts++;
1264 if (!tipc_data_input(l, skb, l->inputq)) 1271 if (!tipc_data_input(l, skb, l->inputq))
1265 rc |= tipc_link_input(l, skb, l->inputq); 1272 rc |= tipc_link_input(l, skb, l->inputq);
1266 if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) 1273 if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN))
@@ -1492,8 +1499,9 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
1492 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) 1499 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL))
1493 l->tolerance = peers_tol; 1500 l->tolerance = peers_tol;
1494 1501
1495 if (peers_prio && in_range(peers_prio, TIPC_MIN_LINK_PRI, 1502 /* Update own prio if peer indicates a different value */
1496 TIPC_MAX_LINK_PRI)) { 1503 if ((peers_prio != l->priority) &&
1504 in_range(peers_prio, 1, TIPC_MAX_LINK_PRI)) {
1497 l->priority = peers_prio; 1505 l->priority = peers_prio;
1498 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT); 1506 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1499 } 1507 }
@@ -1799,10 +1807,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 win)
1799void tipc_link_reset_stats(struct tipc_link *l) 1807void tipc_link_reset_stats(struct tipc_link *l)
1800{ 1808{
1801 memset(&l->stats, 0, sizeof(l->stats)); 1809 memset(&l->stats, 0, sizeof(l->stats));
1802 if (!link_is_bc_sndlink(l)) {
1803 l->stats.sent_info = l->snd_nxt;
1804 l->stats.recv_info = l->rcv_nxt;
1805 }
1806} 1810}
1807 1811
1808static void link_print(struct tipc_link *l, const char *str) 1812static void link_print(struct tipc_link *l, const char *str)
@@ -1866,12 +1870,12 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)
1866 }; 1870 };
1867 1871
1868 struct nla_map map[] = { 1872 struct nla_map map[] = {
1869 {TIPC_NLA_STATS_RX_INFO, s->recv_info}, 1873 {TIPC_NLA_STATS_RX_INFO, 0},
1870 {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, 1874 {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments},
1871 {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, 1875 {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented},
1872 {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, 1876 {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles},
1873 {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, 1877 {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled},
1874 {TIPC_NLA_STATS_TX_INFO, s->sent_info}, 1878 {TIPC_NLA_STATS_TX_INFO, 0},
1875 {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, 1879 {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments},
1876 {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, 1880 {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented},
1877 {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, 1881 {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles},
@@ -1946,9 +1950,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
1946 goto attr_msg_full; 1950 goto attr_msg_full;
1947 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) 1951 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
1948 goto attr_msg_full; 1952 goto attr_msg_full;
1949 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->rcv_nxt)) 1953 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts))
1950 goto attr_msg_full; 1954 goto attr_msg_full;
1951 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->snd_nxt)) 1955 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts))
1952 goto attr_msg_full; 1956 goto attr_msg_full;
1953 1957
1954 if (tipc_link_is_up(link)) 1958 if (tipc_link_is_up(link))
@@ -2003,12 +2007,12 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb,
2003 }; 2007 };
2004 2008
2005 struct nla_map map[] = { 2009 struct nla_map map[] = {
2006 {TIPC_NLA_STATS_RX_INFO, stats->recv_info}, 2010 {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts},
2007 {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, 2011 {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments},
2008 {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, 2012 {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented},
2009 {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, 2013 {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles},
2010 {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, 2014 {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled},
2011 {TIPC_NLA_STATS_TX_INFO, stats->sent_info}, 2015 {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts},
2012 {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, 2016 {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments},
2013 {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, 2017 {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented},
2014 {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, 2018 {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles},
@@ -2075,9 +2079,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
2075 goto attr_msg_full; 2079 goto attr_msg_full;
2076 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) 2080 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name))
2077 goto attr_msg_full; 2081 goto attr_msg_full;
2078 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt)) 2082 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0))
2079 goto attr_msg_full; 2083 goto attr_msg_full;
2080 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt)) 2084 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0))
2081 goto attr_msg_full; 2085 goto attr_msg_full;
2082 2086
2083 prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); 2087 prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index ed97a5876ebe..9e109bb1a207 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -455,14 +455,14 @@ void tipc_mon_rcv(struct net *net, void *data, u16 dlen, u32 addr,
455 int i, applied_bef; 455 int i, applied_bef;
456 456
457 state->probing = false; 457 state->probing = false;
458 if (!dlen)
459 return;
460 458
461 /* Sanity check received domain record */ 459 /* Sanity check received domain record */
462 if ((dlen < new_dlen) || ntohs(arrv_dom->len) != new_dlen) { 460 if (dlen < dom_rec_len(arrv_dom, 0))
463 pr_warn_ratelimited("Received illegal domain record\n"); 461 return;
462 if (dlen != dom_rec_len(arrv_dom, new_member_cnt))
463 return;
464 if ((dlen < new_dlen) || ntohs(arrv_dom->len) != new_dlen)
464 return; 465 return;
465 }
466 466
467 /* Synch generation numbers with peer if link just came up */ 467 /* Synch generation numbers with peer if link just came up */
468 if (!state->synched) { 468 if (!state->synched) {
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index db32777ab591..41f013888f07 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -186,7 +186,7 @@ static struct tipc_sock *tipc_sk(const struct sock *sk)
186 186
187static bool tsk_conn_cong(struct tipc_sock *tsk) 187static bool tsk_conn_cong(struct tipc_sock *tsk)
188{ 188{
189 return tsk->snt_unacked >= tsk->snd_win; 189 return tsk->snt_unacked > tsk->snd_win;
190} 190}
191 191
192/* tsk_blocks(): translate a buffer size in bytes to number of 192/* tsk_blocks(): translate a buffer size in bytes to number of
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index 78cab9c5a445..b58dc95f3d35 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -697,6 +697,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
697 udp_conf.local_ip.s_addr = htonl(INADDR_ANY); 697 udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
698 udp_conf.use_udp_checksums = false; 698 udp_conf.use_udp_checksums = false;
699 ub->ifindex = dev->ifindex; 699 ub->ifindex = dev->ifindex;
700 if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
701 sizeof(struct udphdr))) {
702 err = -EINVAL;
703 goto err;
704 }
700 b->mtu = dev->mtu - sizeof(struct iphdr) 705 b->mtu = dev->mtu - sizeof(struct iphdr)
701 - sizeof(struct udphdr); 706 - sizeof(struct udphdr);
702#if IS_ENABLED(CONFIG_IPV6) 707#if IS_ENABLED(CONFIG_IPV6)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index fd6986634e6f..5bf7e1bfeac7 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
1268 err = security_xfrm_policy_lookup(pol->security, 1268 err = security_xfrm_policy_lookup(pol->security,
1269 fl->flowi_secid, 1269 fl->flowi_secid,
1270 policy_to_flow_dir(dir)); 1270 policy_to_flow_dir(dir));
1271 if (!err && !xfrm_pol_hold_rcu(pol)) 1271 if (!err) {
1272 goto again; 1272 if (!xfrm_pol_hold_rcu(pol))
1273 else if (err == -ESRCH) 1273 goto again;
1274 } else if (err == -ESRCH) {
1274 pol = NULL; 1275 pol = NULL;
1275 else 1276 } else {
1276 pol = ERR_PTR(err); 1277 pol = ERR_PTR(err);
1278 }
1277 } else 1279 } else
1278 pol = NULL; 1280 pol = NULL;
1279 } 1281 }
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 08892091cfe3..671a1d0333f0 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2450,7 +2450,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
2450 2450
2451#ifdef CONFIG_COMPAT 2451#ifdef CONFIG_COMPAT
2452 if (in_compat_syscall()) 2452 if (in_compat_syscall())
2453 return -ENOTSUPP; 2453 return -EOPNOTSUPP;
2454#endif 2454#endif
2455 2455
2456 type = nlh->nlmsg_type; 2456 type = nlh->nlmsg_type;
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index 90f44bd2045e..dadd5161bd91 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -113,7 +113,7 @@ static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) =
113#define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */ 113#define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */
114#define PT_REGS_RC(x) ((x)->gprs[2]) 114#define PT_REGS_RC(x) ((x)->gprs[2])
115#define PT_REGS_SP(x) ((x)->gprs[15]) 115#define PT_REGS_SP(x) ((x)->gprs[15])
116#define PT_REGS_IP(x) ((x)->ip) 116#define PT_REGS_IP(x) ((x)->psw.addr)
117 117
118#elif defined(__aarch64__) 118#elif defined(__aarch64__)
119 119
diff --git a/samples/bpf/sampleip_kern.c b/samples/bpf/sampleip_kern.c
index 774a681f374a..ceabf31079cf 100644
--- a/samples/bpf/sampleip_kern.c
+++ b/samples/bpf/sampleip_kern.c
@@ -25,7 +25,7 @@ int do_sample(struct bpf_perf_event_data *ctx)
25 u64 ip; 25 u64 ip;
26 u32 *value, init_val = 1; 26 u32 *value, init_val = 1;
27 27
28 ip = ctx->regs.ip; 28 ip = PT_REGS_IP(&ctx->regs);
29 value = bpf_map_lookup_elem(&ip_map, &ip); 29 value = bpf_map_lookup_elem(&ip_map, &ip);
30 if (value) 30 if (value)
31 *value += 1; 31 *value += 1;
diff --git a/samples/bpf/trace_event_kern.c b/samples/bpf/trace_event_kern.c
index 71a8ed32823e..41b6115a32eb 100644
--- a/samples/bpf/trace_event_kern.c
+++ b/samples/bpf/trace_event_kern.c
@@ -50,7 +50,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx)
50 key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS); 50 key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS);
51 if ((int)key.kernstack < 0 && (int)key.userstack < 0) { 51 if ((int)key.kernstack < 0 && (int)key.userstack < 0) {
52 bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period, 52 bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period,
53 ctx->regs.ip); 53 PT_REGS_IP(&ctx->regs));
54 return 0; 54 return 0;
55 } 55 }
56 56
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index ebced77deb9c..90a091b6ae4d 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -35,6 +35,8 @@ nconfig: $(obj)/nconf
35 35
36silentoldconfig: $(obj)/conf 36silentoldconfig: $(obj)/conf
37 $(Q)mkdir -p include/config include/generated 37 $(Q)mkdir -p include/config include/generated
38 $(Q)test -e include/generated/autoksyms.h || \
39 touch include/generated/autoksyms.h
38 $< $(silent) --$@ $(Kconfig) 40 $< $(silent) --$@ $(Kconfig)
39 41
40localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 42localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 0190cb6332f2..52063b262667 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -304,7 +304,7 @@ struct snd_dbri {
304 spinlock_t lock; 304 spinlock_t lock;
305 305
306 struct dbri_dma *dma; /* Pointer to our DMA block */ 306 struct dbri_dma *dma; /* Pointer to our DMA block */
307 u32 dma_dvma; /* DBRI visible DMA address */ 307 dma_addr_t dma_dvma; /* DBRI visible DMA address */
308 308
309 void __iomem *regs; /* dbri HW regs */ 309 void __iomem *regs; /* dbri HW regs */
310 int dbri_irqp; /* intr queue pointer */ 310 int dbri_irqp; /* intr queue pointer */
@@ -657,12 +657,14 @@ static void dbri_cmdwait(struct snd_dbri *dbri)
657 */ 657 */
658static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) 658static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
659{ 659{
660 u32 dvma_addr = (u32)dbri->dma_dvma;
661
660 /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */ 662 /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */
661 len += 2; 663 len += 2;
662 spin_lock(&dbri->cmdlock); 664 spin_lock(&dbri->cmdlock);
663 if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2) 665 if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2)
664 return dbri->cmdptr + 2; 666 return dbri->cmdptr + 2;
665 else if (len < sbus_readl(dbri->regs + REG8) - dbri->dma_dvma) 667 else if (len < sbus_readl(dbri->regs + REG8) - dvma_addr)
666 return dbri->dma->cmd; 668 return dbri->dma->cmd;
667 else 669 else
668 printk(KERN_ERR "DBRI: no space for commands."); 670 printk(KERN_ERR "DBRI: no space for commands.");
@@ -680,6 +682,7 @@ static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
680 */ 682 */
681static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) 683static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len)
682{ 684{
685 u32 dvma_addr = (u32)dbri->dma_dvma;
683 s32 tmp, addr; 686 s32 tmp, addr;
684 static int wait_id = 0; 687 static int wait_id = 0;
685 688
@@ -689,7 +692,7 @@ static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len)
689 *(cmd+1) = DBRI_CMD(D_WAIT, 1, wait_id); 692 *(cmd+1) = DBRI_CMD(D_WAIT, 1, wait_id);
690 693
691 /* Replace the last command with JUMP */ 694 /* Replace the last command with JUMP */
692 addr = dbri->dma_dvma + (cmd - len - dbri->dma->cmd) * sizeof(s32); 695 addr = dvma_addr + (cmd - len - dbri->dma->cmd) * sizeof(s32);
693 *(dbri->cmdptr+1) = addr; 696 *(dbri->cmdptr+1) = addr;
694 *(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0); 697 *(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0);
695 698
@@ -747,6 +750,7 @@ static void dbri_reset(struct snd_dbri *dbri)
747/* Lock must not be held before calling this */ 750/* Lock must not be held before calling this */
748static void dbri_initialize(struct snd_dbri *dbri) 751static void dbri_initialize(struct snd_dbri *dbri)
749{ 752{
753 u32 dvma_addr = (u32)dbri->dma_dvma;
750 s32 *cmd; 754 s32 *cmd;
751 u32 dma_addr; 755 u32 dma_addr;
752 unsigned long flags; 756 unsigned long flags;
@@ -764,7 +768,7 @@ static void dbri_initialize(struct snd_dbri *dbri)
764 /* 768 /*
765 * Initialize the interrupt ring buffer. 769 * Initialize the interrupt ring buffer.
766 */ 770 */
767 dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0); 771 dma_addr = dvma_addr + dbri_dma_off(intr, 0);
768 dbri->dma->intr[0] = dma_addr; 772 dbri->dma->intr[0] = dma_addr;
769 dbri->dbri_irqp = 1; 773 dbri->dbri_irqp = 1;
770 /* 774 /*
@@ -778,7 +782,7 @@ static void dbri_initialize(struct snd_dbri *dbri)
778 dbri->cmdptr = cmd; 782 dbri->cmdptr = cmd;
779 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); 783 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
780 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); 784 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
781 dma_addr = dbri->dma_dvma + dbri_dma_off(cmd, 0); 785 dma_addr = dvma_addr + dbri_dma_off(cmd, 0);
782 sbus_writel(dma_addr, dbri->regs + REG8); 786 sbus_writel(dma_addr, dbri->regs + REG8);
783 spin_unlock(&dbri->cmdlock); 787 spin_unlock(&dbri->cmdlock);
784 788
@@ -1077,6 +1081,7 @@ static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr)
1077static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) 1081static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
1078{ 1082{
1079 struct dbri_streaminfo *info = &dbri->stream_info[streamno]; 1083 struct dbri_streaminfo *info = &dbri->stream_info[streamno];
1084 u32 dvma_addr = (u32)dbri->dma_dvma;
1080 __u32 dvma_buffer; 1085 __u32 dvma_buffer;
1081 int desc; 1086 int desc;
1082 int len; 1087 int len;
@@ -1177,7 +1182,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
1177 else { 1182 else {
1178 dbri->next_desc[last_desc] = desc; 1183 dbri->next_desc[last_desc] = desc;
1179 dbri->dma->desc[last_desc].nda = 1184 dbri->dma->desc[last_desc].nda =
1180 dbri->dma_dvma + dbri_dma_off(desc, desc); 1185 dvma_addr + dbri_dma_off(desc, desc);
1181 } 1186 }
1182 1187
1183 last_desc = desc; 1188 last_desc = desc;
@@ -1192,7 +1197,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
1192 } 1197 }
1193 1198
1194 dbri->dma->desc[last_desc].nda = 1199 dbri->dma->desc[last_desc].nda =
1195 dbri->dma_dvma + dbri_dma_off(desc, first_desc); 1200 dvma_addr + dbri_dma_off(desc, first_desc);
1196 dbri->next_desc[last_desc] = first_desc; 1201 dbri->next_desc[last_desc] = first_desc;
1197 dbri->pipes[info->pipe].first_desc = first_desc; 1202 dbri->pipes[info->pipe].first_desc = first_desc;
1198 dbri->pipes[info->pipe].desc = first_desc; 1203 dbri->pipes[info->pipe].desc = first_desc;
@@ -1697,6 +1702,7 @@ interrupts are disabled.
1697static void xmit_descs(struct snd_dbri *dbri) 1702static void xmit_descs(struct snd_dbri *dbri)
1698{ 1703{
1699 struct dbri_streaminfo *info; 1704 struct dbri_streaminfo *info;
1705 u32 dvma_addr;
1700 s32 *cmd; 1706 s32 *cmd;
1701 unsigned long flags; 1707 unsigned long flags;
1702 int first_td; 1708 int first_td;
@@ -1704,6 +1710,7 @@ static void xmit_descs(struct snd_dbri *dbri)
1704 if (dbri == NULL) 1710 if (dbri == NULL)
1705 return; /* Disabled */ 1711 return; /* Disabled */
1706 1712
1713 dvma_addr = (u32)dbri->dma_dvma;
1707 info = &dbri->stream_info[DBRI_REC]; 1714 info = &dbri->stream_info[DBRI_REC];
1708 spin_lock_irqsave(&dbri->lock, flags); 1715 spin_lock_irqsave(&dbri->lock, flags);
1709 1716
@@ -1718,7 +1725,7 @@ static void xmit_descs(struct snd_dbri *dbri)
1718 *(cmd++) = DBRI_CMD(D_SDP, 0, 1725 *(cmd++) = DBRI_CMD(D_SDP, 0,
1719 dbri->pipes[info->pipe].sdp 1726 dbri->pipes[info->pipe].sdp
1720 | D_SDP_P | D_SDP_EVERY | D_SDP_C); 1727 | D_SDP_P | D_SDP_EVERY | D_SDP_C);
1721 *(cmd++) = dbri->dma_dvma + 1728 *(cmd++) = dvma_addr +
1722 dbri_dma_off(desc, first_td); 1729 dbri_dma_off(desc, first_td);
1723 dbri_cmdsend(dbri, cmd, 2); 1730 dbri_cmdsend(dbri, cmd, 2);
1724 1731
@@ -1740,7 +1747,7 @@ static void xmit_descs(struct snd_dbri *dbri)
1740 *(cmd++) = DBRI_CMD(D_SDP, 0, 1747 *(cmd++) = DBRI_CMD(D_SDP, 0,
1741 dbri->pipes[info->pipe].sdp 1748 dbri->pipes[info->pipe].sdp
1742 | D_SDP_P | D_SDP_EVERY | D_SDP_C); 1749 | D_SDP_P | D_SDP_EVERY | D_SDP_C);
1743 *(cmd++) = dbri->dma_dvma + 1750 *(cmd++) = dvma_addr +
1744 dbri_dma_off(desc, first_td); 1751 dbri_dma_off(desc, first_td);
1745 dbri_cmdsend(dbri, cmd, 2); 1752 dbri_cmdsend(dbri, cmd, 2);
1746 1753
@@ -2539,7 +2546,7 @@ static int snd_dbri_create(struct snd_card *card,
2539 if (!dbri->dma) 2546 if (!dbri->dma)
2540 return -ENOMEM; 2547 return -ENOMEM;
2541 2548
2542 dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n", 2549 dprintk(D_GEN, "DMA Cmd Block 0x%p (%pad)\n",
2543 dbri->dma, dbri->dma_dvma); 2550 dbri->dma, dbri->dma_dvma);
2544 2551
2545 /* Map the registers into memory. */ 2552 /* Map the registers into memory. */
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index b63a31be1218..5e0dea2cdc01 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -99,7 +99,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
99 break; 99 break;
100 100
101 case 0x8d: 101 case 0x8d:
102 if (insn.rex_prefix.bytes && 102 if (insn.rex_prefix.nbytes &&
103 insn.rex_prefix.bytes[0] == 0x48 && 103 insn.rex_prefix.bytes[0] == 0x48 &&
104 insn.modrm.nbytes && insn.modrm.bytes[0] == 0x2c && 104 insn.modrm.nbytes && insn.modrm.bytes[0] == 0x2c &&
105 insn.sib.nbytes && insn.sib.bytes[0] == 0x24) 105 insn.sib.nbytes && insn.sib.bytes[0] == 0x24)
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index 582db95127ed..405212be044a 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -14,6 +14,7 @@ ldflags-y += --wrap=devm_memremap_pages
14ldflags-y += --wrap=insert_resource 14ldflags-y += --wrap=insert_resource
15ldflags-y += --wrap=remove_resource 15ldflags-y += --wrap=remove_resource
16ldflags-y += --wrap=acpi_evaluate_object 16ldflags-y += --wrap=acpi_evaluate_object
17ldflags-y += --wrap=acpi_evaluate_dsm
17 18
18DRIVERS := ../../../drivers 19DRIVERS := ../../../drivers
19NVDIMM_SRC := $(DRIVERS)/nvdimm 20NVDIMM_SRC := $(DRIVERS)/nvdimm
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index 3ccef732fce9..64cae1a5deff 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -26,14 +26,17 @@ static LIST_HEAD(iomap_head);
26 26
27static struct iomap_ops { 27static struct iomap_ops {
28 nfit_test_lookup_fn nfit_test_lookup; 28 nfit_test_lookup_fn nfit_test_lookup;
29 nfit_test_evaluate_dsm_fn evaluate_dsm;
29 struct list_head list; 30 struct list_head list;
30} iomap_ops = { 31} iomap_ops = {
31 .list = LIST_HEAD_INIT(iomap_ops.list), 32 .list = LIST_HEAD_INIT(iomap_ops.list),
32}; 33};
33 34
34void nfit_test_setup(nfit_test_lookup_fn lookup) 35void nfit_test_setup(nfit_test_lookup_fn lookup,
36 nfit_test_evaluate_dsm_fn evaluate)
35{ 37{
36 iomap_ops.nfit_test_lookup = lookup; 38 iomap_ops.nfit_test_lookup = lookup;
39 iomap_ops.evaluate_dsm = evaluate;
37 list_add_rcu(&iomap_ops.list, &iomap_head); 40 list_add_rcu(&iomap_ops.list, &iomap_head);
38} 41}
39EXPORT_SYMBOL(nfit_test_setup); 42EXPORT_SYMBOL(nfit_test_setup);
@@ -367,4 +370,22 @@ acpi_status __wrap_acpi_evaluate_object(acpi_handle handle, acpi_string path,
367} 370}
368EXPORT_SYMBOL(__wrap_acpi_evaluate_object); 371EXPORT_SYMBOL(__wrap_acpi_evaluate_object);
369 372
373union acpi_object * __wrap_acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
374 u64 rev, u64 func, union acpi_object *argv4)
375{
376 union acpi_object *obj = ERR_PTR(-ENXIO);
377 struct iomap_ops *ops;
378
379 rcu_read_lock();
380 ops = list_first_or_null_rcu(&iomap_head, typeof(*ops), list);
381 if (ops)
382 obj = ops->evaluate_dsm(handle, uuid, rev, func, argv4);
383 rcu_read_unlock();
384
385 if (IS_ERR(obj))
386 return acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
387 return obj;
388}
389EXPORT_SYMBOL(__wrap_acpi_evaluate_dsm);
390
370MODULE_LICENSE("GPL v2"); 391MODULE_LICENSE("GPL v2");
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index c9a6458cb63e..71620fa95953 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -23,6 +23,7 @@
23#include <linux/sizes.h> 23#include <linux/sizes.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <nd-core.h>
26#include <nfit.h> 27#include <nfit.h>
27#include <nd.h> 28#include <nd.h>
28#include "nfit_test.h" 29#include "nfit_test.h"
@@ -1506,6 +1507,225 @@ static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,
1506 return 0; 1507 return 0;
1507} 1508}
1508 1509
1510static unsigned long nfit_ctl_handle;
1511
1512union acpi_object *result;
1513
1514static union acpi_object *nfit_test_evaluate_dsm(acpi_handle handle,
1515 const u8 *uuid, u64 rev, u64 func, union acpi_object *argv4)
1516{
1517 if (handle != &nfit_ctl_handle)
1518 return ERR_PTR(-ENXIO);
1519
1520 return result;
1521}
1522
1523static int setup_result(void *buf, size_t size)
1524{
1525 result = kmalloc(sizeof(union acpi_object) + size, GFP_KERNEL);
1526 if (!result)
1527 return -ENOMEM;
1528 result->package.type = ACPI_TYPE_BUFFER,
1529 result->buffer.pointer = (void *) (result + 1);
1530 result->buffer.length = size;
1531 memcpy(result->buffer.pointer, buf, size);
1532 memset(buf, 0, size);
1533 return 0;
1534}
1535
1536static int nfit_ctl_test(struct device *dev)
1537{
1538 int rc, cmd_rc;
1539 struct nvdimm *nvdimm;
1540 struct acpi_device *adev;
1541 struct nfit_mem *nfit_mem;
1542 struct nd_ars_record *record;
1543 struct acpi_nfit_desc *acpi_desc;
1544 const u64 test_val = 0x0123456789abcdefULL;
1545 unsigned long mask, cmd_size, offset;
1546 union {
1547 struct nd_cmd_get_config_size cfg_size;
1548 struct nd_cmd_ars_status ars_stat;
1549 struct nd_cmd_ars_cap ars_cap;
1550 char buf[sizeof(struct nd_cmd_ars_status)
1551 + sizeof(struct nd_ars_record)];
1552 } cmds;
1553
1554 adev = devm_kzalloc(dev, sizeof(*adev), GFP_KERNEL);
1555 if (!adev)
1556 return -ENOMEM;
1557 *adev = (struct acpi_device) {
1558 .handle = &nfit_ctl_handle,
1559 .dev = {
1560 .init_name = "test-adev",
1561 },
1562 };
1563
1564 acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL);
1565 if (!acpi_desc)
1566 return -ENOMEM;
1567 *acpi_desc = (struct acpi_nfit_desc) {
1568 .nd_desc = {
1569 .cmd_mask = 1UL << ND_CMD_ARS_CAP
1570 | 1UL << ND_CMD_ARS_START
1571 | 1UL << ND_CMD_ARS_STATUS
1572 | 1UL << ND_CMD_CLEAR_ERROR,
1573 .module = THIS_MODULE,
1574 .provider_name = "ACPI.NFIT",
1575 .ndctl = acpi_nfit_ctl,
1576 },
1577 .dev = &adev->dev,
1578 };
1579
1580 nfit_mem = devm_kzalloc(dev, sizeof(*nfit_mem), GFP_KERNEL);
1581 if (!nfit_mem)
1582 return -ENOMEM;
1583
1584 mask = 1UL << ND_CMD_SMART | 1UL << ND_CMD_SMART_THRESHOLD
1585 | 1UL << ND_CMD_DIMM_FLAGS | 1UL << ND_CMD_GET_CONFIG_SIZE
1586 | 1UL << ND_CMD_GET_CONFIG_DATA | 1UL << ND_CMD_SET_CONFIG_DATA
1587 | 1UL << ND_CMD_VENDOR;
1588 *nfit_mem = (struct nfit_mem) {
1589 .adev = adev,
1590 .family = NVDIMM_FAMILY_INTEL,
1591 .dsm_mask = mask,
1592 };
1593
1594 nvdimm = devm_kzalloc(dev, sizeof(*nvdimm), GFP_KERNEL);
1595 if (!nvdimm)
1596 return -ENOMEM;
1597 *nvdimm = (struct nvdimm) {
1598 .provider_data = nfit_mem,
1599 .cmd_mask = mask,
1600 .dev = {
1601 .init_name = "test-dimm",
1602 },
1603 };
1604
1605
1606 /* basic checkout of a typical 'get config size' command */
1607 cmd_size = sizeof(cmds.cfg_size);
1608 cmds.cfg_size = (struct nd_cmd_get_config_size) {
1609 .status = 0,
1610 .config_size = SZ_128K,
1611 .max_xfer = SZ_4K,
1612 };
1613 rc = setup_result(cmds.buf, cmd_size);
1614 if (rc)
1615 return rc;
1616 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, nvdimm, ND_CMD_GET_CONFIG_SIZE,
1617 cmds.buf, cmd_size, &cmd_rc);
1618
1619 if (rc < 0 || cmd_rc || cmds.cfg_size.status != 0
1620 || cmds.cfg_size.config_size != SZ_128K
1621 || cmds.cfg_size.max_xfer != SZ_4K) {
1622 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1623 __func__, __LINE__, rc, cmd_rc);
1624 return -EIO;
1625 }
1626
1627
1628 /* test ars_status with zero output */
1629 cmd_size = offsetof(struct nd_cmd_ars_status, address);
1630 cmds.ars_stat = (struct nd_cmd_ars_status) {
1631 .out_length = 0,
1632 };
1633 rc = setup_result(cmds.buf, cmd_size);
1634 if (rc)
1635 return rc;
1636 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1637 cmds.buf, cmd_size, &cmd_rc);
1638
1639 if (rc < 0 || cmd_rc) {
1640 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1641 __func__, __LINE__, rc, cmd_rc);
1642 return -EIO;
1643 }
1644
1645
1646 /* test ars_cap with benign extended status */
1647 cmd_size = sizeof(cmds.ars_cap);
1648 cmds.ars_cap = (struct nd_cmd_ars_cap) {
1649 .status = ND_ARS_PERSISTENT << 16,
1650 };
1651 offset = offsetof(struct nd_cmd_ars_cap, status);
1652 rc = setup_result(cmds.buf + offset, cmd_size - offset);
1653 if (rc)
1654 return rc;
1655 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_CAP,
1656 cmds.buf, cmd_size, &cmd_rc);
1657
1658 if (rc < 0 || cmd_rc) {
1659 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1660 __func__, __LINE__, rc, cmd_rc);
1661 return -EIO;
1662 }
1663
1664
1665 /* test ars_status with 'status' trimmed from 'out_length' */
1666 cmd_size = sizeof(cmds.ars_stat) + sizeof(struct nd_ars_record);
1667 cmds.ars_stat = (struct nd_cmd_ars_status) {
1668 .out_length = cmd_size - 4,
1669 };
1670 record = &cmds.ars_stat.records[0];
1671 *record = (struct nd_ars_record) {
1672 .length = test_val,
1673 };
1674 rc = setup_result(cmds.buf, cmd_size);
1675 if (rc)
1676 return rc;
1677 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1678 cmds.buf, cmd_size, &cmd_rc);
1679
1680 if (rc < 0 || cmd_rc || record->length != test_val) {
1681 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1682 __func__, __LINE__, rc, cmd_rc);
1683 return -EIO;
1684 }
1685
1686
1687 /* test ars_status with 'Output (Size)' including 'status' */
1688 cmd_size = sizeof(cmds.ars_stat) + sizeof(struct nd_ars_record);
1689 cmds.ars_stat = (struct nd_cmd_ars_status) {
1690 .out_length = cmd_size,
1691 };
1692 record = &cmds.ars_stat.records[0];
1693 *record = (struct nd_ars_record) {
1694 .length = test_val,
1695 };
1696 rc = setup_result(cmds.buf, cmd_size);
1697 if (rc)
1698 return rc;
1699 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1700 cmds.buf, cmd_size, &cmd_rc);
1701
1702 if (rc < 0 || cmd_rc || record->length != test_val) {
1703 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1704 __func__, __LINE__, rc, cmd_rc);
1705 return -EIO;
1706 }
1707
1708
1709 /* test extended status for get_config_size results in failure */
1710 cmd_size = sizeof(cmds.cfg_size);
1711 cmds.cfg_size = (struct nd_cmd_get_config_size) {
1712 .status = 1 << 16,
1713 };
1714 rc = setup_result(cmds.buf, cmd_size);
1715 if (rc)
1716 return rc;
1717 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, nvdimm, ND_CMD_GET_CONFIG_SIZE,
1718 cmds.buf, cmd_size, &cmd_rc);
1719
1720 if (rc < 0 || cmd_rc >= 0) {
1721 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1722 __func__, __LINE__, rc, cmd_rc);
1723 return -EIO;
1724 }
1725
1726 return 0;
1727}
1728
1509static int nfit_test_probe(struct platform_device *pdev) 1729static int nfit_test_probe(struct platform_device *pdev)
1510{ 1730{
1511 struct nvdimm_bus_descriptor *nd_desc; 1731 struct nvdimm_bus_descriptor *nd_desc;
@@ -1516,6 +1736,12 @@ static int nfit_test_probe(struct platform_device *pdev)
1516 union acpi_object *obj; 1736 union acpi_object *obj;
1517 int rc; 1737 int rc;
1518 1738
1739 if (strcmp(dev_name(&pdev->dev), "nfit_test.0") == 0) {
1740 rc = nfit_ctl_test(&pdev->dev);
1741 if (rc)
1742 return rc;
1743 }
1744
1519 nfit_test = to_nfit_test(&pdev->dev); 1745 nfit_test = to_nfit_test(&pdev->dev);
1520 1746
1521 /* common alloc */ 1747 /* common alloc */
@@ -1639,11 +1865,13 @@ static __init int nfit_test_init(void)
1639{ 1865{
1640 int rc, i; 1866 int rc, i;
1641 1867
1642 nfit_test_dimm = class_create(THIS_MODULE, "nfit_test_dimm"); 1868 nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
1643 if (IS_ERR(nfit_test_dimm))
1644 return PTR_ERR(nfit_test_dimm);
1645 1869
1646 nfit_test_setup(nfit_test_lookup); 1870 nfit_test_dimm = class_create(THIS_MODULE, "nfit_test_dimm");
1871 if (IS_ERR(nfit_test_dimm)) {
1872 rc = PTR_ERR(nfit_test_dimm);
1873 goto err_register;
1874 }
1647 1875
1648 for (i = 0; i < NUM_NFITS; i++) { 1876 for (i = 0; i < NUM_NFITS; i++) {
1649 struct nfit_test *nfit_test; 1877 struct nfit_test *nfit_test;
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index c281dd2e5e2d..f54c0032c6ff 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -31,11 +31,17 @@ struct nfit_test_resource {
31 void *buf; 31 void *buf;
32}; 32};
33 33
34union acpi_object;
35typedef void *acpi_handle;
36
34typedef struct nfit_test_resource *(*nfit_test_lookup_fn)(resource_size_t); 37typedef struct nfit_test_resource *(*nfit_test_lookup_fn)(resource_size_t);
38typedef union acpi_object *(*nfit_test_evaluate_dsm_fn)(acpi_handle handle,
39 const u8 *uuid, u64 rev, u64 func, union acpi_object *argv4);
35void __iomem *__wrap_ioremap_nocache(resource_size_t offset, 40void __iomem *__wrap_ioremap_nocache(resource_size_t offset,
36 unsigned long size); 41 unsigned long size);
37void __wrap_iounmap(volatile void __iomem *addr); 42void __wrap_iounmap(volatile void __iomem *addr);
38void nfit_test_setup(nfit_test_lookup_fn lookup); 43void nfit_test_setup(nfit_test_lookup_fn lookup,
44 nfit_test_evaluate_dsm_fn evaluate);
39void nfit_test_teardown(void); 45void nfit_test_teardown(void);
40struct nfit_test_resource *get_nfit_res(resource_size_t resource); 46struct nfit_test_resource *get_nfit_res(resource_size_t resource);
41#endif 47#endif
diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
index 0a063af40565..9bab86757fa4 100644
--- a/virt/kvm/arm/vgic/vgic-v2.c
+++ b/virt/kvm/arm/vgic/vgic-v2.c
@@ -50,8 +50,10 @@ void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu)
50 50
51 WARN_ON(cpuif->vgic_lr[lr] & GICH_LR_STATE); 51 WARN_ON(cpuif->vgic_lr[lr] & GICH_LR_STATE);
52 52
53 kvm_notify_acked_irq(vcpu->kvm, 0, 53 /* Only SPIs require notification */
54 intid - VGIC_NR_PRIVATE_IRQS); 54 if (vgic_valid_spi(vcpu->kvm, intid))
55 kvm_notify_acked_irq(vcpu->kvm, 0,
56 intid - VGIC_NR_PRIVATE_IRQS);
55 } 57 }
56 } 58 }
57 59
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 9f0dae397d9c..5c9f9745e6ca 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -41,8 +41,10 @@ void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu)
41 41
42 WARN_ON(cpuif->vgic_lr[lr] & ICH_LR_STATE); 42 WARN_ON(cpuif->vgic_lr[lr] & ICH_LR_STATE);
43 43
44 kvm_notify_acked_irq(vcpu->kvm, 0, 44 /* Only SPIs require notification */
45 intid - VGIC_NR_PRIVATE_IRQS); 45 if (vgic_valid_spi(vcpu->kvm, intid))
46 kvm_notify_acked_irq(vcpu->kvm, 0,
47 intid - VGIC_NR_PRIVATE_IRQS);
46 } 48 }
47 49
48 /* 50 /*
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2f38ce55016f..c55f5d6a7767 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2897,10 +2897,10 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
2897 2897
2898 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC); 2898 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
2899 if (ret < 0) { 2899 if (ret < 0) {
2900 ops->destroy(dev);
2901 mutex_lock(&kvm->lock); 2900 mutex_lock(&kvm->lock);
2902 list_del(&dev->vm_node); 2901 list_del(&dev->vm_node);
2903 mutex_unlock(&kvm->lock); 2902 mutex_unlock(&kvm->lock);
2903 ops->destroy(dev);
2904 return ret; 2904 return ret;
2905 } 2905 }
2906 2906