aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-07-21 05:14:30 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2016-07-21 05:14:30 -0400
commit0f7d93416d97f3a943d6add836ec0d681ae030f5 (patch)
treec1d612d00f93b0e98c616bc9a40123c4af97a764
parent7879c4e58b7c884ee62b9306721dd1106e624b52 (diff)
parent7d3a07fcb8a0d5c06718de14fb91fdf1ef20a0e2 (diff)
Merge branch 'for-miklos' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into for-next
-rw-r--r--MAINTAINERS7
-rw-r--r--Makefile4
-rw-r--r--arch/arc/Makefile2
-rw-r--r--arch/arc/kernel/stacktrace.c2
-rw-r--r--arch/arm/kvm/arm.c1
-rw-r--r--arch/mips/include/asm/pgtable.h10
-rw-r--r--arch/powerpc/include/asm/book3s/64/pgtable.h1
-rw-r--r--arch/powerpc/kernel/eeh_driver.c2
-rw-r--r--arch/powerpc/kernel/pci_64.c1
-rw-r--r--arch/powerpc/kernel/process.c10
-rw-r--r--arch/powerpc/kernel/tm.S61
-rw-r--r--arch/powerpc/mm/hash_utils_64.c4
-rw-r--r--arch/powerpc/mm/pgtable-radix.c5
-rw-r--r--arch/s390/include/asm/fpu/api.h2
-rw-r--r--arch/s390/kernel/ipl.c7
-rw-r--r--arch/x86/include/asm/pvclock.h25
-rw-r--r--arch/x86/kernel/pvclock.c11
-rw-r--r--arch/x86/kvm/lapic.c3
-rw-r--r--arch/x86/kvm/vmx.c23
-rw-r--r--arch/x86/kvm/x86.c6
-rw-r--r--arch/x86/kvm/x86.h7
-rw-r--r--crypto/crypto_user.c1
-rw-r--r--drivers/acpi/nfit.c12
-rw-r--r--drivers/acpi/nfit.h10
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/utils.c6
-rw-r--r--drivers/ata/ahci_seattle.c2
-rw-r--r--drivers/ata/sata_mv.c2
-rw-r--r--drivers/clk/clk-oxnas.c4
-rw-r--r--drivers/clk/rockchip/clk-cpu.c4
-rw-r--r--drivers/clk/rockchip/clk-mmc-phase.c12
-rw-r--r--drivers/clk/rockchip/clk-rk3399.c8
-rw-r--r--drivers/connector/cn_proc.c43
-rw-r--r--drivers/cpufreq/cpufreq-dt-platdev.c7
-rw-r--r--drivers/cpufreq/cpufreq.c4
-rw-r--r--drivers/cpufreq/intel_pstate.c5
-rw-r--r--drivers/crypto/ux500/hash/hash_core.c4
-rw-r--r--drivers/crypto/vmx/aes_cbc.c2
-rw-r--r--drivers/crypto/vmx/aes_ctr.c2
-rw-r--r--drivers/crypto/vmx/ppc-xlate.pl2
-rw-r--r--drivers/gpio/gpio-tegra.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c179
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h1
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/polaris10_ppsmc.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/smu74_discrete.h3
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c4
-rw-r--r--drivers/gpu/drm/i915/intel_display.c16
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c10
-rw-r--r--drivers/gpu/drm/i915/intel_dpll_mgr.c4
-rw-r--r--drivers/hid/hid-multitouch.c21
-rw-r--r--drivers/iio/accel/kxsd9.c4
-rw-r--r--drivers/iio/adc/ad7266.c7
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c5
-rw-r--r--drivers/input/joystick/xpad.c39
-rw-r--r--drivers/input/mouse/elantech.c8
-rw-r--r--drivers/input/mouse/vmmouse.c22
-rw-r--r--drivers/input/touchscreen/wacom_w8001.c11
-rw-r--r--drivers/iommu/amd_iommu_init.c2
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--drivers/iommu/iova.c8
-rw-r--r--drivers/mfd/max77620.c2
-rw-r--r--drivers/net/bonding/bond_3ad.c64
-rw-r--r--drivers/net/can/at91_can.c5
-rw-r--r--drivers/net/can/c_can/c_can.c38
-rw-r--r--drivers/net/can/dev.c9
-rw-r--r--drivers/net/can/usb/Kconfig5
-rw-r--r--drivers/net/can/usb/gs_usb.c14
-rw-r--r--drivers/net/can/usb/kvaser_usb.c8
-rw-r--r--drivers/net/ethernet/amd/au1000_eth.c4
-rw-r--r--drivers/net/ethernet/atheros/alx/alx.h4
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c61
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.c8
-rw-r--r--drivers/net/ethernet/cavium/thunder/nic_main.c16
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c91
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.h2
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c14
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c15
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c61
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c46
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c34
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c35
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h228
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/vxlan.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/wq.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/switchx2.c5
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_common.c6
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_hsi.h1
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_l2.c8
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_main.c1
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_spq.c31
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede_main.c7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c2
-rw-r--r--drivers/net/ethernet/sfc/farch.c3
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c4
-rw-r--r--drivers/net/ethernet/tile/tilegx.c6
-rw-r--r--drivers/net/fddi/skfp/Makefile2
-rw-r--r--drivers/net/geneve.c22
-rw-r--r--drivers/net/macsec.c49
-rw-r--r--drivers/net/phy/fixed_phy.c22
-rw-r--r--drivers/net/phy/marvell.c82
-rw-r--r--drivers/net/phy/smsc.c17
-rw-r--r--drivers/net/team/team.c2
-rw-r--r--drivers/net/usb/r8152.c37
-rw-r--r--drivers/net/vrf.c4
-rw-r--r--drivers/net/vxlan.c58
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c2
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c1
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/scan.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c16
-rw-r--r--drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c2
-rw-r--r--drivers/nvdimm/pfn_devs.c51
-rw-r--r--drivers/phy/phy-bcm-ns-usb2.c4
-rw-r--r--drivers/phy/phy-miphy28lp.c3
-rw-r--r--drivers/phy/phy-rcar-gen3-usb2.c14
-rw-r--r--drivers/phy/phy-rockchip-dp.c2
-rw-r--r--drivers/phy/phy-stih407-usb.c4
-rw-r--r--drivers/phy/phy-sun4i-usb.c14
-rw-r--r--drivers/pinctrl/Makefile2
-rw-r--r--drivers/pinctrl/freescale/pinctrl-imx.c4
-rw-r--r--drivers/pinctrl/intel/pinctrl-baytrail.c6
-rw-r--r--drivers/pinctrl/pinctrl-single.c3
-rw-r--r--drivers/pinctrl/tegra/Makefile2
-rw-r--r--drivers/power/power_supply_core.c27
-rw-r--r--drivers/power/tps65217_charger.c6
-rw-r--r--drivers/regulator/anatop-regulator.c2
-rw-r--r--drivers/regulator/max77620-regulator.c7
-rw-r--r--drivers/spi/spi-rockchip.c4
-rw-r--r--drivers/spi/spi-sun4i.c23
-rw-r--r--drivers/spi/spi-sun6i.c10
-rw-r--r--drivers/spi/spi-ti-qspi.c7
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c2
-rw-r--r--drivers/staging/iio/adc/ad7606_spi.c2
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c6
-rw-r--r--drivers/tty/pty.c7
-rw-r--r--drivers/tty/vt/vt.c1
-rw-r--r--drivers/usb/common/usb-otg-fsm.c2
-rw-r--r--drivers/usb/core/hcd.c17
-rw-r--r--drivers/usb/dwc3/dwc3-st.c6
-rw-r--r--drivers/usb/host/ehci-st.c6
-rw-r--r--drivers/usb/host/ohci-st.c6
-rw-r--r--fs/9p/vfs_file.c6
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/9p/vfs_inode_dotl.c2
-rw-r--r--fs/ceph/export.c10
-rw-r--r--fs/ceph/file.c2
-rw-r--r--fs/cifs/cifs_unicode.c33
-rw-r--r--fs/cifs/cifs_unicode.h2
-rw-r--r--fs/cifs/cifsfs.c3
-rw-r--r--fs/cifs/cifsglob.h1
-rw-r--r--fs/cifs/connect.c4
-rw-r--r--fs/cifs/dir.c2
-rw-r--r--fs/cifs/file.c14
-rw-r--r--fs/cifs/ntlmssp.h2
-rw-r--r--fs/cifs/sess.c80
-rw-r--r--fs/cifs/smb2pdu.c37
-rw-r--r--fs/dax.c7
-rw-r--r--fs/fuse/dev.c30
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/gfs2/inode.c2
-rw-r--r--fs/libfs.c109
-rw-r--r--fs/lockd/svc.c13
-rw-r--r--fs/locks.c2
-rw-r--r--fs/namespace.c1
-rw-r--r--fs/nfs/dir.c41
-rw-r--r--fs/nfs/direct.c10
-rw-r--r--fs/nfs/inode.c1
-rw-r--r--fs/nfs/nfs4proc.c18
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/pnfs.c10
-rw-r--r--fs/nfs/pnfs_nfs.c12
-rw-r--r--fs/nfs/read.c4
-rw-r--r--fs/overlayfs/inode.c29
-rw-r--r--fs/overlayfs/super.c12
-rw-r--r--include/drm/i915_pciids.h10
-rw-r--r--include/kvm/arm_pmu.h4
-rw-r--r--include/linux/audit.h24
-rw-r--r--include/linux/bpf.h32
-rw-r--r--include/linux/inet_diag.h6
-rw-r--r--include/linux/mfd/da9052/da9052.h2
-rw-r--r--include/linux/mlx4/device.h1
-rw-r--r--include/linux/net.h3
-rw-r--r--include/linux/posix_acl.h6
-rw-r--r--include/linux/pwm.h16
-rw-r--r--include/linux/qed/qed_eth_if.h1
-rw-r--r--include/linux/reset.h211
-rw-r--r--include/linux/sock_diag.h6
-rw-r--r--include/linux/usb/ehci_def.h4
-rw-r--r--include/linux/wait.h13
-rw-r--r--include/net/gre.h2
-rw-r--r--include/net/netfilter/nf_tables.h1
-rw-r--r--include/net/tc_act/tc_ife.h6
-rw-r--r--include/uapi/linux/input-event-codes.h31
-rw-r--r--include/uapi/linux/input.h1
-rw-r--r--include/uapi/linux/netfilter/Kbuild1
-rw-r--r--include/uapi/linux/netfilter/xt_SYNPROXY.h2
-rw-r--r--kernel/audit.c17
-rw-r--r--kernel/audit.h4
-rw-r--r--kernel/auditsc.c8
-rw-r--r--kernel/bpf/verifier.c41
-rw-r--r--kernel/cgroup.c148
-rw-r--r--kernel/events/core.c2
-rw-r--r--kernel/trace/bpf_trace.c10
-rw-r--r--net/ax25/af_ax25.c3
-rw-r--r--net/ax25/ax25_ds_timer.c5
-rw-r--r--net/ax25/ax25_std_timer.c5
-rw-r--r--net/ax25/ax25_subr.c3
-rw-r--r--net/batman-adv/routing.c1
-rw-r--r--net/batman-adv/soft-interface.c9
-rw-r--r--net/batman-adv/translation-table.c50
-rw-r--r--net/batman-adv/types.h2
-rw-r--r--net/bridge/br_input.c15
-rw-r--r--net/bridge/br_multicast.c4
-rw-r--r--net/bridge/br_netlink.c2
-rw-r--r--net/bridge/br_private.h23
-rw-r--r--net/core/filter.c16
-rw-r--r--net/core/neighbour.c6
-rw-r--r--net/ipv4/esp4.c52
-rw-r--r--net/ipv4/gre_demux.c10
-rw-r--r--net/ipv4/ip_gre.c26
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/tcp_output.c7
-rw-r--r--net/ipv4/udp.c80
-rw-r--r--net/ipv6/icmp.c2
-rw-r--r--net/ipv6/ip6_checksum.c7
-rw-r--r--net/ipv6/ip6_gre.c2
-rw-r--r--net/ipv6/ip6mr.c1
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/sit.c4
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/ipv6/udp.c71
-rw-r--r--net/kcm/kcmproc.c1
-rw-r--r--net/mac80211/mesh.c7
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_tables_api.c24
-rw-r--r--net/netfilter/nf_tables_core.c2
-rw-r--r--net/netfilter/nft_hash.c3
-rw-r--r--net/netfilter/nft_rbtree.c3
-rw-r--r--net/openvswitch/conntrack.c14
-rw-r--r--net/rds/ib_cm.c2
-rw-r--r--net/rds/loop.c5
-rw-r--r--net/rds/sysctl.c3
-rw-r--r--net/rds/tcp.h2
-rw-r--r--net/rds/tcp_connect.c26
-rw-r--r--net/rds/tcp_listen.c2
-rw-r--r--net/rds/tcp_recv.c2
-rw-r--r--net/rds/tcp_send.c14
-rw-r--r--net/rds/transport.c3
-rw-r--r--net/sched/act_api.c2
-rw-r--r--net/sched/act_ife.c53
-rw-r--r--net/sched/act_ipt.c7
-rw-r--r--net/sched/sch_fifo.c4
-rw-r--r--net/sched/sch_htb.c2
-rw-r--r--net/sched/sch_netem.c12
-rw-r--r--net/sched/sch_prio.c67
-rw-r--r--net/sctp/sctp_diag.c6
-rw-r--r--net/tipc/bearer.c2
-rw-r--r--net/tipc/link.c3
-rw-r--r--net/tipc/msg.c6
-rw-r--r--net/tipc/msg.h11
-rw-r--r--net/tipc/socket.c54
-rw-r--r--net/vmw_vsock/af_vsock.c12
-rw-r--r--net/wireless/util.c2
280 files changed, 2495 insertions, 1571 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 952fd2aba7b7..1209323b7e43 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -595,6 +595,10 @@ S: Odd Fixes
595L: linux-alpha@vger.kernel.org 595L: linux-alpha@vger.kernel.org
596F: arch/alpha/ 596F: arch/alpha/
597 597
598ALPS PS/2 TOUCHPAD DRIVER
599R: Pali Rohár <pali.rohar@gmail.com>
600F: drivers/input/mouse/alps.*
601
598ALTERA MAILBOX DRIVER 602ALTERA MAILBOX DRIVER
599M: Ley Foon Tan <lftan@altera.com> 603M: Ley Foon Tan <lftan@altera.com>
600L: nios2-dev@lists.rocketboards.org (moderated for non-subscribers) 604L: nios2-dev@lists.rocketboards.org (moderated for non-subscribers)
@@ -7420,7 +7424,7 @@ F: drivers/scsi/megaraid.*
7420F: drivers/scsi/megaraid/ 7424F: drivers/scsi/megaraid/
7421 7425
7422MELLANOX ETHERNET DRIVER (mlx4_en) 7426MELLANOX ETHERNET DRIVER (mlx4_en)
7423M: Eugenia Emantayev <eugenia@mellanox.com> 7427M: Tariq Toukan <tariqt@mellanox.com>
7424L: netdev@vger.kernel.org 7428L: netdev@vger.kernel.org
7425S: Supported 7429S: Supported
7426W: http://www.mellanox.com 7430W: http://www.mellanox.com
@@ -8959,6 +8963,7 @@ L: linux-gpio@vger.kernel.org
8959T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git 8963T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
8960S: Maintained 8964S: Maintained
8961F: Documentation/devicetree/bindings/pinctrl/ 8965F: Documentation/devicetree/bindings/pinctrl/
8966F: Documentation/pinctrl.txt
8962F: drivers/pinctrl/ 8967F: drivers/pinctrl/
8963F: include/linux/pinctrl/ 8968F: include/linux/pinctrl/
8964 8969
diff --git a/Makefile b/Makefile
index 6471f20ca400..0d504893df6e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 7 2PATCHLEVEL = 7
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Psychotic Stoned Sheep 5NAME = Psychotic Stoned Sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -363,11 +363,13 @@ CHECK = sparse
363 363
364CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 364CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
365 -Wbitwise -Wno-return-void $(CF) 365 -Wbitwise -Wno-return-void $(CF)
366NOSTDINC_FLAGS =
366CFLAGS_MODULE = 367CFLAGS_MODULE =
367AFLAGS_MODULE = 368AFLAGS_MODULE =
368LDFLAGS_MODULE = 369LDFLAGS_MODULE =
369CFLAGS_KERNEL = 370CFLAGS_KERNEL =
370AFLAGS_KERNEL = 371AFLAGS_KERNEL =
372LDFLAGS_vmlinux =
371CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized 373CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
372CFLAGS_KCOV = -fsanitize-coverage=trace-pc 374CFLAGS_KCOV = -fsanitize-coverage=trace-pc
373 375
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index d4df6be66d58..85814e74677d 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -66,8 +66,6 @@ endif
66 66
67endif 67endif
68 68
69cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables
70
71# By default gcc 4.8 generates dwarf4 which kernel unwinder can't grok 69# By default gcc 4.8 generates dwarf4 which kernel unwinder can't grok
72ifeq ($(atleast_gcc48),y) 70ifeq ($(atleast_gcc48),y)
73cflags-$(CONFIG_ARC_DW2_UNWIND) += -gdwarf-2 71cflags-$(CONFIG_ARC_DW2_UNWIND) += -gdwarf-2
diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c
index e0efff15a5ae..b9192a653b7e 100644
--- a/arch/arc/kernel/stacktrace.c
+++ b/arch/arc/kernel/stacktrace.c
@@ -142,7 +142,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
142 * prelogue is setup (callee regs saved and then fp set and not other 142 * prelogue is setup (callee regs saved and then fp set and not other
143 * way around 143 * way around
144 */ 144 */
145 pr_warn("CONFIG_ARC_DW2_UNWIND needs to be enabled\n"); 145 pr_warn_once("CONFIG_ARC_DW2_UNWIND needs to be enabled\n");
146 return 0; 146 return 0;
147 147
148#endif 148#endif
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 893941ec98dc..f1bde7c4e736 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -263,6 +263,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
263 kvm_timer_vcpu_terminate(vcpu); 263 kvm_timer_vcpu_terminate(vcpu);
264 kvm_vgic_vcpu_destroy(vcpu); 264 kvm_vgic_vcpu_destroy(vcpu);
265 kvm_pmu_vcpu_destroy(vcpu); 265 kvm_pmu_vcpu_destroy(vcpu);
266 kvm_vcpu_uninit(vcpu);
266 kmem_cache_free(kvm_vcpu_cache, vcpu); 267 kmem_cache_free(kvm_vcpu_cache, vcpu);
267} 268}
268 269
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index a6b611f1da43..f53816744d60 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -24,7 +24,7 @@ struct mm_struct;
24struct vm_area_struct; 24struct vm_area_struct;
25 25
26#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_NO_READ | \ 26#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_NO_READ | \
27 _CACHE_CACHABLE_NONCOHERENT) 27 _page_cachable_default)
28#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \ 28#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \
29 _page_cachable_default) 29 _page_cachable_default)
30#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_NO_EXEC | \ 30#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_NO_EXEC | \
@@ -476,7 +476,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
476 pte.pte_low &= (_PAGE_MODIFIED | _PAGE_ACCESSED | _PFNX_MASK); 476 pte.pte_low &= (_PAGE_MODIFIED | _PAGE_ACCESSED | _PFNX_MASK);
477 pte.pte_high &= (_PFN_MASK | _CACHE_MASK); 477 pte.pte_high &= (_PFN_MASK | _CACHE_MASK);
478 pte.pte_low |= pgprot_val(newprot) & ~_PFNX_MASK; 478 pte.pte_low |= pgprot_val(newprot) & ~_PFNX_MASK;
479 pte.pte_high |= pgprot_val(newprot) & ~_PFN_MASK; 479 pte.pte_high |= pgprot_val(newprot) & ~(_PFN_MASK | _CACHE_MASK);
480 return pte; 480 return pte;
481} 481}
482#elif defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32) 482#elif defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
@@ -491,7 +491,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
491#else 491#else
492static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 492static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
493{ 493{
494 return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot)); 494 return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
495 (pgprot_val(newprot) & ~_PAGE_CHG_MASK));
495} 496}
496#endif 497#endif
497 498
@@ -632,7 +633,8 @@ static inline struct page *pmd_page(pmd_t pmd)
632 633
633static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) 634static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
634{ 635{
635 pmd_val(pmd) = (pmd_val(pmd) & _PAGE_CHG_MASK) | pgprot_val(newprot); 636 pmd_val(pmd) = (pmd_val(pmd) & _PAGE_CHG_MASK) |
637 (pgprot_val(newprot) & ~_PAGE_CHG_MASK);
636 return pmd; 638 return pmd;
637} 639}
638 640
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 88a5ecaa157b..ab84c89c9e98 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -230,6 +230,7 @@ extern unsigned long __kernel_virt_size;
230#define KERN_VIRT_SIZE __kernel_virt_size 230#define KERN_VIRT_SIZE __kernel_virt_size
231extern struct page *vmemmap; 231extern struct page *vmemmap;
232extern unsigned long ioremap_bot; 232extern unsigned long ioremap_bot;
233extern unsigned long pci_io_base;
233#endif /* __ASSEMBLY__ */ 234#endif /* __ASSEMBLY__ */
234 235
235#include <asm/book3s/64/hash.h> 236#include <asm/book3s/64/hash.h>
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index b5f73cb5eeb6..d70101e1e25c 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -647,7 +647,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
647 pci_unlock_rescan_remove(); 647 pci_unlock_rescan_remove();
648 } 648 }
649 } else if (frozen_bus) { 649 } else if (frozen_bus) {
650 eeh_pe_dev_traverse(pe, eeh_rmv_device, &rmv_data); 650 eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data);
651 } 651 }
652 652
653 /* 653 /*
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 3759df52bd67..a5ae49a2dcc4 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -47,7 +47,6 @@ static int __init pcibios_init(void)
47 47
48 printk(KERN_INFO "PCI: Probing PCI hardware\n"); 48 printk(KERN_INFO "PCI: Probing PCI hardware\n");
49 49
50 pci_io_base = ISA_IO_BASE;
51 /* For now, override phys_mem_access_prot. If we need it,g 50 /* For now, override phys_mem_access_prot. If we need it,g
52 * later, we may move that initialization to each ppc_md 51 * later, we may move that initialization to each ppc_md
53 */ 52 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index e2f12cbcade9..0b93893424f5 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1505,6 +1505,16 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
1505 current->thread.regs = regs - 1; 1505 current->thread.regs = regs - 1;
1506 } 1506 }
1507 1507
1508#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1509 /*
1510 * Clear any transactional state, we're exec()ing. The cause is
1511 * not important as there will never be a recheckpoint so it's not
1512 * user visible.
1513 */
1514 if (MSR_TM_SUSPENDED(mfmsr()))
1515 tm_reclaim_current(0);
1516#endif
1517
1508 memset(regs->gpr, 0, sizeof(regs->gpr)); 1518 memset(regs->gpr, 0, sizeof(regs->gpr));
1509 regs->ctr = 0; 1519 regs->ctr = 0;
1510 regs->link = 0; 1520 regs->link = 0;
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index bf8f34a58670..b7019b559ddb 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -110,17 +110,11 @@ _GLOBAL(tm_reclaim)
110 std r3, STK_PARAM(R3)(r1) 110 std r3, STK_PARAM(R3)(r1)
111 SAVE_NVGPRS(r1) 111 SAVE_NVGPRS(r1)
112 112
113 /* We need to setup MSR for VSX register save instructions. Here we 113 /* We need to setup MSR for VSX register save instructions. */
114 * also clear the MSR RI since when we do the treclaim, we won't have a
115 * valid kernel pointer for a while. We clear RI here as it avoids
116 * adding another mtmsr closer to the treclaim. This makes the region
117 * maked as non-recoverable wider than it needs to be but it saves on
118 * inserting another mtmsrd later.
119 */
120 mfmsr r14 114 mfmsr r14
121 mr r15, r14 115 mr r15, r14
122 ori r15, r15, MSR_FP 116 ori r15, r15, MSR_FP
123 li r16, MSR_RI 117 li r16, 0
124 ori r16, r16, MSR_EE /* IRQs hard off */ 118 ori r16, r16, MSR_EE /* IRQs hard off */
125 andc r15, r15, r16 119 andc r15, r15, r16
126 oris r15, r15, MSR_VEC@h 120 oris r15, r15, MSR_VEC@h
@@ -176,7 +170,17 @@ dont_backup_fp:
1761: tdeqi r6, 0 1701: tdeqi r6, 0
177 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0 171 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0
178 172
179 /* The moment we treclaim, ALL of our GPRs will switch 173 /* Clear MSR RI since we are about to change r1, EE is already off. */
174 li r4, 0
175 mtmsrd r4, 1
176
177 /*
178 * BE CAREFUL HERE:
179 * At this point we can't take an SLB miss since we have MSR_RI
180 * off. Load only to/from the stack/paca which are in SLB bolted regions
181 * until we turn MSR RI back on.
182 *
183 * The moment we treclaim, ALL of our GPRs will switch
180 * to user register state. (FPRs, CCR etc. also!) 184 * to user register state. (FPRs, CCR etc. also!)
181 * Use an sprg and a tm_scratch in the PACA to shuffle. 185 * Use an sprg and a tm_scratch in the PACA to shuffle.
182 */ 186 */
@@ -197,6 +201,11 @@ dont_backup_fp:
197 201
198 /* Store the PPR in r11 and reset to decent value */ 202 /* Store the PPR in r11 and reset to decent value */
199 std r11, GPR11(r1) /* Temporary stash */ 203 std r11, GPR11(r1) /* Temporary stash */
204
205 /* Reset MSR RI so we can take SLB faults again */
206 li r11, MSR_RI
207 mtmsrd r11, 1
208
200 mfspr r11, SPRN_PPR 209 mfspr r11, SPRN_PPR
201 HMT_MEDIUM 210 HMT_MEDIUM
202 211
@@ -397,11 +406,6 @@ restore_gprs:
397 ld r5, THREAD_TM_DSCR(r3) 406 ld r5, THREAD_TM_DSCR(r3)
398 ld r6, THREAD_TM_PPR(r3) 407 ld r6, THREAD_TM_PPR(r3)
399 408
400 /* Clear the MSR RI since we are about to change R1. EE is already off
401 */
402 li r4, 0
403 mtmsrd r4, 1
404
405 REST_GPR(0, r7) /* GPR0 */ 409 REST_GPR(0, r7) /* GPR0 */
406 REST_2GPRS(2, r7) /* GPR2-3 */ 410 REST_2GPRS(2, r7) /* GPR2-3 */
407 REST_GPR(4, r7) /* GPR4 */ 411 REST_GPR(4, r7) /* GPR4 */
@@ -439,10 +443,33 @@ restore_gprs:
439 ld r6, _CCR(r7) 443 ld r6, _CCR(r7)
440 mtcr r6 444 mtcr r6
441 445
442 REST_GPR(1, r7) /* GPR1 */
443 REST_GPR(5, r7) /* GPR5-7 */
444 REST_GPR(6, r7) 446 REST_GPR(6, r7)
445 ld r7, GPR7(r7) 447
448 /*
449 * Store r1 and r5 on the stack so that we can access them
450 * after we clear MSR RI.
451 */
452
453 REST_GPR(5, r7)
454 std r5, -8(r1)
455 ld r5, GPR1(r7)
456 std r5, -16(r1)
457
458 REST_GPR(7, r7)
459
460 /* Clear MSR RI since we are about to change r1. EE is already off */
461 li r5, 0
462 mtmsrd r5, 1
463
464 /*
465 * BE CAREFUL HERE:
466 * At this point we can't take an SLB miss since we have MSR_RI
467 * off. Load only to/from the stack/paca which are in SLB bolted regions
468 * until we turn MSR RI back on.
469 */
470
471 ld r5, -8(r1)
472 ld r1, -16(r1)
446 473
447 /* Commit register state as checkpointed state: */ 474 /* Commit register state as checkpointed state: */
448 TRECHKPT 475 TRECHKPT
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 5b22ba0b58bc..2971ea18c768 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -922,6 +922,10 @@ void __init hash__early_init_mmu(void)
922 vmemmap = (struct page *)H_VMEMMAP_BASE; 922 vmemmap = (struct page *)H_VMEMMAP_BASE;
923 ioremap_bot = IOREMAP_BASE; 923 ioremap_bot = IOREMAP_BASE;
924 924
925#ifdef CONFIG_PCI
926 pci_io_base = ISA_IO_BASE;
927#endif
928
925 /* Initialize the MMU Hash table and create the linear mapping 929 /* Initialize the MMU Hash table and create the linear mapping
926 * of memory. Has to be done before SLB initialization as this is 930 * of memory. Has to be done before SLB initialization as this is
927 * currently where the page size encoding is obtained. 931 * currently where the page size encoding is obtained.
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index e58707deef5c..7931e1496f0d 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -328,6 +328,11 @@ void __init radix__early_init_mmu(void)
328 __vmalloc_end = RADIX_VMALLOC_END; 328 __vmalloc_end = RADIX_VMALLOC_END;
329 vmemmap = (struct page *)RADIX_VMEMMAP_BASE; 329 vmemmap = (struct page *)RADIX_VMEMMAP_BASE;
330 ioremap_bot = IOREMAP_BASE; 330 ioremap_bot = IOREMAP_BASE;
331
332#ifdef CONFIG_PCI
333 pci_io_base = ISA_IO_BASE;
334#endif
335
331 /* 336 /*
332 * For now radix also use the same frag size 337 * For now radix also use the same frag size
333 */ 338 */
diff --git a/arch/s390/include/asm/fpu/api.h b/arch/s390/include/asm/fpu/api.h
index 5e04f3cbd320..8ae236b0f80b 100644
--- a/arch/s390/include/asm/fpu/api.h
+++ b/arch/s390/include/asm/fpu/api.h
@@ -22,7 +22,7 @@ static inline int test_fp_ctl(u32 fpc)
22 " la %0,0\n" 22 " la %0,0\n"
23 "1:\n" 23 "1:\n"
24 EX_TABLE(0b,1b) 24 EX_TABLE(0b,1b)
25 : "=d" (rc), "=d" (orig_fpc) 25 : "=d" (rc), "=&d" (orig_fpc)
26 : "d" (fpc), "0" (-EINVAL)); 26 : "d" (fpc), "0" (-EINVAL));
27 return rc; 27 return rc;
28} 28}
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index f20abdb5630a..d14069d4b88d 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -2064,12 +2064,5 @@ void s390_reset_system(void)
2064 S390_lowcore.program_new_psw.addr = 2064 S390_lowcore.program_new_psw.addr =
2065 (unsigned long) s390_base_pgm_handler; 2065 (unsigned long) s390_base_pgm_handler;
2066 2066
2067 /*
2068 * Clear subchannel ID and number to signal new kernel that no CCW or
2069 * SCSI IPL has been done (for kexec and kdump)
2070 */
2071 S390_lowcore.subchannel_id = 0;
2072 S390_lowcore.subchannel_nr = 0;
2073
2074 do_reset_calls(); 2067 do_reset_calls();
2075} 2068}
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index fdcc04020636..7c1c89598688 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -69,29 +69,22 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
69} 69}
70 70
71static __always_inline 71static __always_inline
72u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src)
73{
74 u64 delta = rdtsc_ordered() - src->tsc_timestamp;
75 return pvclock_scale_delta(delta, src->tsc_to_system_mul,
76 src->tsc_shift);
77}
78
79static __always_inline
80unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, 72unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
81 cycle_t *cycles, u8 *flags) 73 cycle_t *cycles, u8 *flags)
82{ 74{
83 unsigned version; 75 unsigned version;
84 cycle_t ret, offset; 76 cycle_t offset;
85 u8 ret_flags; 77 u64 delta;
86 78
87 version = src->version; 79 version = src->version;
80 /* Make the latest version visible */
81 smp_rmb();
88 82
89 offset = pvclock_get_nsec_offset(src); 83 delta = rdtsc_ordered() - src->tsc_timestamp;
90 ret = src->system_time + offset; 84 offset = pvclock_scale_delta(delta, src->tsc_to_system_mul,
91 ret_flags = src->flags; 85 src->tsc_shift);
92 86 *cycles = src->system_time + offset;
93 *cycles = ret; 87 *flags = src->flags;
94 *flags = ret_flags;
95 return version; 88 return version;
96} 89}
97 90
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 99bfc025111d..06c58ce46762 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -61,11 +61,16 @@ void pvclock_resume(void)
61u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src) 61u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
62{ 62{
63 unsigned version; 63 unsigned version;
64 cycle_t ret;
65 u8 flags; 64 u8 flags;
66 65
67 do { 66 do {
68 version = __pvclock_read_cycles(src, &ret, &flags); 67 version = src->version;
68 /* Make the latest version visible */
69 smp_rmb();
70
71 flags = src->flags;
72 /* Make sure that the version double-check is last. */
73 smp_rmb();
69 } while ((src->version & 1) || version != src->version); 74 } while ((src->version & 1) || version != src->version);
70 75
71 return flags & valid_flags; 76 return flags & valid_flags;
@@ -80,6 +85,8 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
80 85
81 do { 86 do {
82 version = __pvclock_read_cycles(src, &ret, &flags); 87 version = __pvclock_read_cycles(src, &ret, &flags);
88 /* Make sure that the version double-check is last. */
89 smp_rmb();
83 } while ((src->version & 1) || version != src->version); 90 } while ((src->version & 1) || version != src->version);
84 91
85 if (unlikely((flags & PVCLOCK_GUEST_STOPPED) != 0)) { 92 if (unlikely((flags & PVCLOCK_GUEST_STOPPED) != 0)) {
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index bbb5b283ff63..a397200281c1 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1310,7 +1310,8 @@ void wait_lapic_expire(struct kvm_vcpu *vcpu)
1310 1310
1311 /* __delay is delay_tsc whenever the hardware has TSC, thus always. */ 1311 /* __delay is delay_tsc whenever the hardware has TSC, thus always. */
1312 if (guest_tsc < tsc_deadline) 1312 if (guest_tsc < tsc_deadline)
1313 __delay(tsc_deadline - guest_tsc); 1313 __delay(min(tsc_deadline - guest_tsc,
1314 nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
1314} 1315}
1315 1316
1316static void start_apic_timer(struct kvm_lapic *apic) 1317static void start_apic_timer(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 003618e324ce..64a79f271276 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6671,7 +6671,13 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
6671 6671
6672 /* Checks for #GP/#SS exceptions. */ 6672 /* Checks for #GP/#SS exceptions. */
6673 exn = false; 6673 exn = false;
6674 if (is_protmode(vcpu)) { 6674 if (is_long_mode(vcpu)) {
6675 /* Long mode: #GP(0)/#SS(0) if the memory address is in a
6676 * non-canonical form. This is the only check on the memory
6677 * destination for long mode!
6678 */
6679 exn = is_noncanonical_address(*ret);
6680 } else if (is_protmode(vcpu)) {
6675 /* Protected mode: apply checks for segment validity in the 6681 /* Protected mode: apply checks for segment validity in the
6676 * following order: 6682 * following order:
6677 * - segment type check (#GP(0) may be thrown) 6683 * - segment type check (#GP(0) may be thrown)
@@ -6688,17 +6694,10 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
6688 * execute-only code segment 6694 * execute-only code segment
6689 */ 6695 */
6690 exn = ((s.type & 0xa) == 8); 6696 exn = ((s.type & 0xa) == 8);
6691 } 6697 if (exn) {
6692 if (exn) { 6698 kvm_queue_exception_e(vcpu, GP_VECTOR, 0);
6693 kvm_queue_exception_e(vcpu, GP_VECTOR, 0); 6699 return 1;
6694 return 1; 6700 }
6695 }
6696 if (is_long_mode(vcpu)) {
6697 /* Long mode: #GP(0)/#SS(0) if the memory address is in a
6698 * non-canonical form. This is an only check for long mode.
6699 */
6700 exn = is_noncanonical_address(*ret);
6701 } else if (is_protmode(vcpu)) {
6702 /* Protected mode: #GP(0)/#SS(0) if the segment is unusable. 6701 /* Protected mode: #GP(0)/#SS(0) if the segment is unusable.
6703 */ 6702 */
6704 exn = (s.unusable != 0); 6703 exn = (s.unusable != 0);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 902d9da12392..7da5dd2057a9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1244,12 +1244,6 @@ static atomic_t kvm_guest_has_master_clock = ATOMIC_INIT(0);
1244static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz); 1244static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz);
1245static unsigned long max_tsc_khz; 1245static unsigned long max_tsc_khz;
1246 1246
1247static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
1248{
1249 return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult,
1250 vcpu->arch.virtual_tsc_shift);
1251}
1252
1253static u32 adjust_tsc_khz(u32 khz, s32 ppm) 1247static u32 adjust_tsc_khz(u32 khz, s32 ppm)
1254{ 1248{
1255 u64 v = (u64)khz * (1000000 + ppm); 1249 u64 v = (u64)khz * (1000000 + ppm);
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 7ce3634ab5fe..a82ca466b62e 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -2,6 +2,7 @@
2#define ARCH_X86_KVM_X86_H 2#define ARCH_X86_KVM_X86_H
3 3
4#include <linux/kvm_host.h> 4#include <linux/kvm_host.h>
5#include <asm/pvclock.h>
5#include "kvm_cache_regs.h" 6#include "kvm_cache_regs.h"
6 7
7#define MSR_IA32_CR_PAT_DEFAULT 0x0007040600070406ULL 8#define MSR_IA32_CR_PAT_DEFAULT 0x0007040600070406ULL
@@ -195,6 +196,12 @@ extern unsigned int lapic_timer_advance_ns;
195 196
196extern struct static_key kvm_no_apic_vcpu; 197extern struct static_key kvm_no_apic_vcpu;
197 198
199static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
200{
201 return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult,
202 vcpu->arch.virtual_tsc_shift);
203}
204
198/* Same "calling convention" as do_div: 205/* Same "calling convention" as do_div:
199 * - divide (n << 32) by base 206 * - divide (n << 32) by base
200 * - put result in n 207 * - put result in n
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 43fe85f20d57..7097a3395b25 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -455,6 +455,7 @@ static const int crypto_msg_min[CRYPTO_NR_MSGTYPES] = {
455 [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 455 [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
456 [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 456 [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
457 [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 457 [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
458 [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
458 [CRYPTO_MSG_DELRNG - CRYPTO_MSG_BASE] = 0, 459 [CRYPTO_MSG_DELRNG - CRYPTO_MSG_BASE] = 0,
459}; 460};
460 461
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index 2215fc847fa9..ac6ddcc080d4 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -928,7 +928,7 @@ static ssize_t format_show(struct device *dev,
928{ 928{
929 struct acpi_nfit_control_region *dcr = to_nfit_dcr(dev); 929 struct acpi_nfit_control_region *dcr = to_nfit_dcr(dev);
930 930
931 return sprintf(buf, "0x%04x\n", be16_to_cpu(dcr->code)); 931 return sprintf(buf, "0x%04x\n", le16_to_cpu(dcr->code));
932} 932}
933static DEVICE_ATTR_RO(format); 933static DEVICE_ATTR_RO(format);
934 934
@@ -961,8 +961,8 @@ static ssize_t format1_show(struct device *dev,
961 continue; 961 continue;
962 if (nfit_dcr->dcr->code == dcr->code) 962 if (nfit_dcr->dcr->code == dcr->code)
963 continue; 963 continue;
964 rc = sprintf(buf, "%#x\n", 964 rc = sprintf(buf, "0x%04x\n",
965 be16_to_cpu(nfit_dcr->dcr->code)); 965 le16_to_cpu(nfit_dcr->dcr->code));
966 break; 966 break;
967 } 967 }
968 if (rc != ENXIO) 968 if (rc != ENXIO)
@@ -1131,11 +1131,11 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
1131 1131
1132 /* 1132 /*
1133 * Until standardization materializes we need to consider up to 3 1133 * Until standardization materializes we need to consider up to 3
1134 * different command sets. Note, that checking for function0 (bit0) 1134 * different command sets. Note, that checking for zero functions
1135 * tells us if any commands are reachable through this uuid. 1135 * tells us if any commands might be reachable through this uuid.
1136 */ 1136 */
1137 for (i = NVDIMM_FAMILY_INTEL; i <= NVDIMM_FAMILY_HPE2; i++) 1137 for (i = NVDIMM_FAMILY_INTEL; i <= NVDIMM_FAMILY_HPE2; i++)
1138 if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 1)) 1138 if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 0))
1139 break; 1139 break;
1140 1140
1141 /* limit the supported commands to those that are publicly documented */ 1141 /* limit the supported commands to those that are publicly documented */
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index 11cb38348aef..02b9ea1e8d2e 100644
--- a/drivers/acpi/nfit.h
+++ b/drivers/acpi/nfit.h
@@ -53,12 +53,12 @@ enum nfit_uuids {
53}; 53};
54 54
55/* 55/*
56 * Region format interface codes are stored as an array of bytes in the 56 * Region format interface codes are stored with the interface as the
57 * NFIT DIMM Control Region structure 57 * LSB and the function as the MSB.
58 */ 58 */
59#define NFIT_FIC_BYTE cpu_to_be16(0x101) /* byte-addressable energy backed */ 59#define NFIT_FIC_BYTE cpu_to_le16(0x101) /* byte-addressable energy backed */
60#define NFIT_FIC_BLK cpu_to_be16(0x201) /* block-addressable non-energy backed */ 60#define NFIT_FIC_BLK cpu_to_le16(0x201) /* block-addressable non-energy backed */
61#define NFIT_FIC_BYTEN cpu_to_be16(0x301) /* byte-addressable non-energy backed */ 61#define NFIT_FIC_BYTEN cpu_to_le16(0x301) /* byte-addressable non-energy backed */
62 62
63enum { 63enum {
64 NFIT_BLK_READ_FLUSH = 1, 64 NFIT_BLK_READ_FLUSH = 1,
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 8fc7323ed3e8..4ed4061813e6 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -839,7 +839,7 @@ void acpi_penalize_isa_irq(int irq, int active)
839{ 839{
840 if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty))) 840 if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
841 acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) + 841 acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
842 active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING; 842 (active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
843} 843}
844 844
845bool acpi_isa_irq_available(int irq) 845bool acpi_isa_irq_available(int irq)
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 22c09952e177..b4de130f2d57 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -680,9 +680,6 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs)
680 u64 mask = 0; 680 u64 mask = 0;
681 union acpi_object *obj; 681 union acpi_object *obj;
682 682
683 if (funcs == 0)
684 return false;
685
686 obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL); 683 obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
687 if (!obj) 684 if (!obj)
688 return false; 685 return false;
@@ -695,6 +692,9 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs)
695 mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); 692 mask |= (((u64)obj->buffer.pointer[i]) << (i * 8));
696 ACPI_FREE(obj); 693 ACPI_FREE(obj);
697 694
695 if (funcs == 0)
696 return true;
697
698 /* 698 /*
699 * Bit 0 indicates whether there's support for any functions other than 699 * Bit 0 indicates whether there's support for any functions other than
700 * function 0 for the specified UUID and revision. 700 * function 0 for the specified UUID and revision.
diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c
index 6e702ab57220..1d31c0c0fc20 100644
--- a/drivers/ata/ahci_seattle.c
+++ b/drivers/ata/ahci_seattle.c
@@ -137,7 +137,7 @@ static const struct ata_port_info *ahci_seattle_get_port_info(
137 u32 val; 137 u32 val;
138 138
139 plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL); 139 plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL);
140 if (IS_ERR(plat_data)) 140 if (!plat_data)
141 return &ahci_port_info; 141 return &ahci_port_info;
142 142
143 plat_data->sgpio_ctrl = devm_ioremap_resource(dev, 143 plat_data->sgpio_ctrl = devm_ioremap_resource(dev,
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index bd74ee555278..745489a1c86a 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -986,7 +986,7 @@ static inline void mv_write_cached_reg(void __iomem *addr, u32 *old, u32 new)
986 * Looks like a lot of fuss, but it avoids an unnecessary 986 * Looks like a lot of fuss, but it avoids an unnecessary
987 * +1 usec read-after-write delay for unaffected registers. 987 * +1 usec read-after-write delay for unaffected registers.
988 */ 988 */
989 laddr = (long)addr & 0xffff; 989 laddr = (unsigned long)addr & 0xffff;
990 if (laddr >= 0x300 && laddr <= 0x33c) { 990 if (laddr >= 0x300 && laddr <= 0x33c) {
991 laddr &= 0x000f; 991 laddr &= 0x000f;
992 if (laddr == 0x4 || laddr == 0xc) { 992 if (laddr == 0x4 || laddr == 0xc) {
diff --git a/drivers/clk/clk-oxnas.c b/drivers/clk/clk-oxnas.c
index efba7d4dbcfc..79bcb2e42060 100644
--- a/drivers/clk/clk-oxnas.c
+++ b/drivers/clk/clk-oxnas.c
@@ -144,9 +144,9 @@ static int oxnas_stdclk_probe(struct platform_device *pdev)
144 return -ENOMEM; 144 return -ENOMEM;
145 145
146 regmap = syscon_node_to_regmap(of_get_parent(np)); 146 regmap = syscon_node_to_regmap(of_get_parent(np));
147 if (!regmap) { 147 if (IS_ERR(regmap)) {
148 dev_err(&pdev->dev, "failed to have parent regmap\n"); 148 dev_err(&pdev->dev, "failed to have parent regmap\n");
149 return -EINVAL; 149 return PTR_ERR(regmap);
150 } 150 }
151 151
152 for (i = 0; i < ARRAY_SIZE(clk_oxnas_init); i++) { 152 for (i = 0; i < ARRAY_SIZE(clk_oxnas_init); i++) {
diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
index 4bb130cd0062..05b3d73bfefa 100644
--- a/drivers/clk/rockchip/clk-cpu.c
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -321,9 +321,9 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
321 } 321 }
322 322
323 cclk = clk_register(NULL, &cpuclk->hw); 323 cclk = clk_register(NULL, &cpuclk->hw);
324 if (IS_ERR(clk)) { 324 if (IS_ERR(cclk)) {
325 pr_err("%s: could not register cpuclk %s\n", __func__, name); 325 pr_err("%s: could not register cpuclk %s\n", __func__, name);
326 ret = PTR_ERR(clk); 326 ret = PTR_ERR(cclk);
327 goto free_rate_table; 327 goto free_rate_table;
328 } 328 }
329 329
diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c
index bc856f21f6b2..077fcdc7908b 100644
--- a/drivers/clk/rockchip/clk-mmc-phase.c
+++ b/drivers/clk/rockchip/clk-mmc-phase.c
@@ -41,8 +41,6 @@ static unsigned long rockchip_mmc_recalc(struct clk_hw *hw,
41#define ROCKCHIP_MMC_DEGREE_MASK 0x3 41#define ROCKCHIP_MMC_DEGREE_MASK 0x3
42#define ROCKCHIP_MMC_DELAYNUM_OFFSET 2 42#define ROCKCHIP_MMC_DELAYNUM_OFFSET 2
43#define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET) 43#define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET)
44#define ROCKCHIP_MMC_INIT_STATE_RESET 0x1
45#define ROCKCHIP_MMC_INIT_STATE_SHIFT 1
46 44
47#define PSECS_PER_SEC 1000000000000LL 45#define PSECS_PER_SEC 1000000000000LL
48 46
@@ -154,6 +152,7 @@ struct clk *rockchip_clk_register_mmc(const char *name,
154 return ERR_PTR(-ENOMEM); 152 return ERR_PTR(-ENOMEM);
155 153
156 init.name = name; 154 init.name = name;
155 init.flags = 0;
157 init.num_parents = num_parents; 156 init.num_parents = num_parents;
158 init.parent_names = parent_names; 157 init.parent_names = parent_names;
159 init.ops = &rockchip_mmc_clk_ops; 158 init.ops = &rockchip_mmc_clk_ops;
@@ -162,15 +161,6 @@ struct clk *rockchip_clk_register_mmc(const char *name,
162 mmc_clock->reg = reg; 161 mmc_clock->reg = reg;
163 mmc_clock->shift = shift; 162 mmc_clock->shift = shift;
164 163
165 /*
166 * Assert init_state to soft reset the CLKGEN
167 * for mmc tuning phase and degree
168 */
169 if (mmc_clock->shift == ROCKCHIP_MMC_INIT_STATE_SHIFT)
170 writel(HIWORD_UPDATE(ROCKCHIP_MMC_INIT_STATE_RESET,
171 ROCKCHIP_MMC_INIT_STATE_RESET,
172 mmc_clock->shift), mmc_clock->reg);
173
174 clk = clk_register(NULL, &mmc_clock->hw); 164 clk = clk_register(NULL, &mmc_clock->hw);
175 if (IS_ERR(clk)) 165 if (IS_ERR(clk))
176 kfree(mmc_clock); 166 kfree(mmc_clock);
diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
index 291543f52caa..8059a8d3ea36 100644
--- a/drivers/clk/rockchip/clk-rk3399.c
+++ b/drivers/clk/rockchip/clk-rk3399.c
@@ -832,9 +832,9 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
832 RK3399_CLKGATE_CON(13), 1, GFLAGS), 832 RK3399_CLKGATE_CON(13), 1, GFLAGS),
833 833
834 /* perihp */ 834 /* perihp */
835 GATE(0, "cpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED, 835 GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED,
836 RK3399_CLKGATE_CON(5), 0, GFLAGS), 836 RK3399_CLKGATE_CON(5), 0, GFLAGS),
837 GATE(0, "gpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED, 837 GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED,
838 RK3399_CLKGATE_CON(5), 1, GFLAGS), 838 RK3399_CLKGATE_CON(5), 1, GFLAGS),
839 COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED, 839 COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED,
840 RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS, 840 RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS,
@@ -1466,6 +1466,8 @@ static struct rockchip_clk_branch rk3399_clk_pmu_branches[] __initdata = {
1466 1466
1467static const char *const rk3399_cru_critical_clocks[] __initconst = { 1467static const char *const rk3399_cru_critical_clocks[] __initconst = {
1468 "aclk_cci_pre", 1468 "aclk_cci_pre",
1469 "aclk_gic",
1470 "aclk_gic_noc",
1469 "pclk_perilp0", 1471 "pclk_perilp0",
1470 "pclk_perilp0", 1472 "pclk_perilp0",
1471 "hclk_perilp0", 1473 "hclk_perilp0",
@@ -1508,6 +1510,7 @@ static void __init rk3399_clk_init(struct device_node *np)
1508 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 1510 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
1509 if (IS_ERR(ctx)) { 1511 if (IS_ERR(ctx)) {
1510 pr_err("%s: rockchip clk init failed\n", __func__); 1512 pr_err("%s: rockchip clk init failed\n", __func__);
1513 iounmap(reg_base);
1511 return; 1514 return;
1512 } 1515 }
1513 1516
@@ -1553,6 +1556,7 @@ static void __init rk3399_pmu_clk_init(struct device_node *np)
1553 ctx = rockchip_clk_init(np, reg_base, CLKPMU_NR_CLKS); 1556 ctx = rockchip_clk_init(np, reg_base, CLKPMU_NR_CLKS);
1554 if (IS_ERR(ctx)) { 1557 if (IS_ERR(ctx)) {
1555 pr_err("%s: rockchip pmu clk init failed\n", __func__); 1558 pr_err("%s: rockchip pmu clk init failed\n", __func__);
1559 iounmap(reg_base);
1556 return; 1560 return;
1557 } 1561 }
1558 1562
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 15d06fcf0b50..b02f9c606e0b 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -56,11 +56,21 @@ static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC };
56/* proc_event_counts is used as the sequence number of the netlink message */ 56/* proc_event_counts is used as the sequence number of the netlink message */
57static DEFINE_PER_CPU(__u32, proc_event_counts) = { 0 }; 57static DEFINE_PER_CPU(__u32, proc_event_counts) = { 0 };
58 58
59static inline void get_seq(__u32 *ts, int *cpu) 59static inline void send_msg(struct cn_msg *msg)
60{ 60{
61 preempt_disable(); 61 preempt_disable();
62 *ts = __this_cpu_inc_return(proc_event_counts) - 1; 62
63 *cpu = smp_processor_id(); 63 msg->seq = __this_cpu_inc_return(proc_event_counts) - 1;
64 ((struct proc_event *)msg->data)->cpu = smp_processor_id();
65
66 /*
67 * Preemption remains disabled during send to ensure the messages are
68 * ordered according to their sequence numbers.
69 *
70 * If cn_netlink_send() fails, the data is not sent.
71 */
72 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_NOWAIT);
73
64 preempt_enable(); 74 preempt_enable();
65} 75}
66 76
@@ -77,7 +87,6 @@ void proc_fork_connector(struct task_struct *task)
77 msg = buffer_to_cn_msg(buffer); 87 msg = buffer_to_cn_msg(buffer);
78 ev = (struct proc_event *)msg->data; 88 ev = (struct proc_event *)msg->data;
79 memset(&ev->event_data, 0, sizeof(ev->event_data)); 89 memset(&ev->event_data, 0, sizeof(ev->event_data));
80 get_seq(&msg->seq, &ev->cpu);
81 ev->timestamp_ns = ktime_get_ns(); 90 ev->timestamp_ns = ktime_get_ns();
82 ev->what = PROC_EVENT_FORK; 91 ev->what = PROC_EVENT_FORK;
83 rcu_read_lock(); 92 rcu_read_lock();
@@ -92,8 +101,7 @@ void proc_fork_connector(struct task_struct *task)
92 msg->ack = 0; /* not used */ 101 msg->ack = 0; /* not used */
93 msg->len = sizeof(*ev); 102 msg->len = sizeof(*ev);
94 msg->flags = 0; /* not used */ 103 msg->flags = 0; /* not used */
95 /* If cn_netlink_send() failed, the data is not sent */ 104 send_msg(msg);
96 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL);
97} 105}
98 106
99void proc_exec_connector(struct task_struct *task) 107void proc_exec_connector(struct task_struct *task)
@@ -108,7 +116,6 @@ void proc_exec_connector(struct task_struct *task)
108 msg = buffer_to_cn_msg(buffer); 116 msg = buffer_to_cn_msg(buffer);
109 ev = (struct proc_event *)msg->data; 117 ev = (struct proc_event *)msg->data;
110 memset(&ev->event_data, 0, sizeof(ev->event_data)); 118 memset(&ev->event_data, 0, sizeof(ev->event_data));
111 get_seq(&msg->seq, &ev->cpu);
112 ev->timestamp_ns = ktime_get_ns(); 119 ev->timestamp_ns = ktime_get_ns();
113 ev->what = PROC_EVENT_EXEC; 120 ev->what = PROC_EVENT_EXEC;
114 ev->event_data.exec.process_pid = task->pid; 121 ev->event_data.exec.process_pid = task->pid;
@@ -118,7 +125,7 @@ void proc_exec_connector(struct task_struct *task)
118 msg->ack = 0; /* not used */ 125 msg->ack = 0; /* not used */
119 msg->len = sizeof(*ev); 126 msg->len = sizeof(*ev);
120 msg->flags = 0; /* not used */ 127 msg->flags = 0; /* not used */
121 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 128 send_msg(msg);
122} 129}
123 130
124void proc_id_connector(struct task_struct *task, int which_id) 131void proc_id_connector(struct task_struct *task, int which_id)
@@ -150,14 +157,13 @@ void proc_id_connector(struct task_struct *task, int which_id)
150 return; 157 return;
151 } 158 }
152 rcu_read_unlock(); 159 rcu_read_unlock();
153 get_seq(&msg->seq, &ev->cpu);
154 ev->timestamp_ns = ktime_get_ns(); 160 ev->timestamp_ns = ktime_get_ns();
155 161
156 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); 162 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
157 msg->ack = 0; /* not used */ 163 msg->ack = 0; /* not used */
158 msg->len = sizeof(*ev); 164 msg->len = sizeof(*ev);
159 msg->flags = 0; /* not used */ 165 msg->flags = 0; /* not used */
160 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 166 send_msg(msg);
161} 167}
162 168
163void proc_sid_connector(struct task_struct *task) 169void proc_sid_connector(struct task_struct *task)
@@ -172,7 +178,6 @@ void proc_sid_connector(struct task_struct *task)
172 msg = buffer_to_cn_msg(buffer); 178 msg = buffer_to_cn_msg(buffer);
173 ev = (struct proc_event *)msg->data; 179 ev = (struct proc_event *)msg->data;
174 memset(&ev->event_data, 0, sizeof(ev->event_data)); 180 memset(&ev->event_data, 0, sizeof(ev->event_data));
175 get_seq(&msg->seq, &ev->cpu);
176 ev->timestamp_ns = ktime_get_ns(); 181 ev->timestamp_ns = ktime_get_ns();
177 ev->what = PROC_EVENT_SID; 182 ev->what = PROC_EVENT_SID;
178 ev->event_data.sid.process_pid = task->pid; 183 ev->event_data.sid.process_pid = task->pid;
@@ -182,7 +187,7 @@ void proc_sid_connector(struct task_struct *task)
182 msg->ack = 0; /* not used */ 187 msg->ack = 0; /* not used */
183 msg->len = sizeof(*ev); 188 msg->len = sizeof(*ev);
184 msg->flags = 0; /* not used */ 189 msg->flags = 0; /* not used */
185 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 190 send_msg(msg);
186} 191}
187 192
188void proc_ptrace_connector(struct task_struct *task, int ptrace_id) 193void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
@@ -197,7 +202,6 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
197 msg = buffer_to_cn_msg(buffer); 202 msg = buffer_to_cn_msg(buffer);
198 ev = (struct proc_event *)msg->data; 203 ev = (struct proc_event *)msg->data;
199 memset(&ev->event_data, 0, sizeof(ev->event_data)); 204 memset(&ev->event_data, 0, sizeof(ev->event_data));
200 get_seq(&msg->seq, &ev->cpu);
201 ev->timestamp_ns = ktime_get_ns(); 205 ev->timestamp_ns = ktime_get_ns();
202 ev->what = PROC_EVENT_PTRACE; 206 ev->what = PROC_EVENT_PTRACE;
203 ev->event_data.ptrace.process_pid = task->pid; 207 ev->event_data.ptrace.process_pid = task->pid;
@@ -215,7 +219,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
215 msg->ack = 0; /* not used */ 219 msg->ack = 0; /* not used */
216 msg->len = sizeof(*ev); 220 msg->len = sizeof(*ev);
217 msg->flags = 0; /* not used */ 221 msg->flags = 0; /* not used */
218 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 222 send_msg(msg);
219} 223}
220 224
221void proc_comm_connector(struct task_struct *task) 225void proc_comm_connector(struct task_struct *task)
@@ -230,7 +234,6 @@ void proc_comm_connector(struct task_struct *task)
230 msg = buffer_to_cn_msg(buffer); 234 msg = buffer_to_cn_msg(buffer);
231 ev = (struct proc_event *)msg->data; 235 ev = (struct proc_event *)msg->data;
232 memset(&ev->event_data, 0, sizeof(ev->event_data)); 236 memset(&ev->event_data, 0, sizeof(ev->event_data));
233 get_seq(&msg->seq, &ev->cpu);
234 ev->timestamp_ns = ktime_get_ns(); 237 ev->timestamp_ns = ktime_get_ns();
235 ev->what = PROC_EVENT_COMM; 238 ev->what = PROC_EVENT_COMM;
236 ev->event_data.comm.process_pid = task->pid; 239 ev->event_data.comm.process_pid = task->pid;
@@ -241,7 +244,7 @@ void proc_comm_connector(struct task_struct *task)
241 msg->ack = 0; /* not used */ 244 msg->ack = 0; /* not used */
242 msg->len = sizeof(*ev); 245 msg->len = sizeof(*ev);
243 msg->flags = 0; /* not used */ 246 msg->flags = 0; /* not used */
244 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 247 send_msg(msg);
245} 248}
246 249
247void proc_coredump_connector(struct task_struct *task) 250void proc_coredump_connector(struct task_struct *task)
@@ -256,7 +259,6 @@ void proc_coredump_connector(struct task_struct *task)
256 msg = buffer_to_cn_msg(buffer); 259 msg = buffer_to_cn_msg(buffer);
257 ev = (struct proc_event *)msg->data; 260 ev = (struct proc_event *)msg->data;
258 memset(&ev->event_data, 0, sizeof(ev->event_data)); 261 memset(&ev->event_data, 0, sizeof(ev->event_data));
259 get_seq(&msg->seq, &ev->cpu);
260 ev->timestamp_ns = ktime_get_ns(); 262 ev->timestamp_ns = ktime_get_ns();
261 ev->what = PROC_EVENT_COREDUMP; 263 ev->what = PROC_EVENT_COREDUMP;
262 ev->event_data.coredump.process_pid = task->pid; 264 ev->event_data.coredump.process_pid = task->pid;
@@ -266,7 +268,7 @@ void proc_coredump_connector(struct task_struct *task)
266 msg->ack = 0; /* not used */ 268 msg->ack = 0; /* not used */
267 msg->len = sizeof(*ev); 269 msg->len = sizeof(*ev);
268 msg->flags = 0; /* not used */ 270 msg->flags = 0; /* not used */
269 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 271 send_msg(msg);
270} 272}
271 273
272void proc_exit_connector(struct task_struct *task) 274void proc_exit_connector(struct task_struct *task)
@@ -281,7 +283,6 @@ void proc_exit_connector(struct task_struct *task)
281 msg = buffer_to_cn_msg(buffer); 283 msg = buffer_to_cn_msg(buffer);
282 ev = (struct proc_event *)msg->data; 284 ev = (struct proc_event *)msg->data;
283 memset(&ev->event_data, 0, sizeof(ev->event_data)); 285 memset(&ev->event_data, 0, sizeof(ev->event_data));
284 get_seq(&msg->seq, &ev->cpu);
285 ev->timestamp_ns = ktime_get_ns(); 286 ev->timestamp_ns = ktime_get_ns();
286 ev->what = PROC_EVENT_EXIT; 287 ev->what = PROC_EVENT_EXIT;
287 ev->event_data.exit.process_pid = task->pid; 288 ev->event_data.exit.process_pid = task->pid;
@@ -293,7 +294,7 @@ void proc_exit_connector(struct task_struct *task)
293 msg->ack = 0; /* not used */ 294 msg->ack = 0; /* not used */
294 msg->len = sizeof(*ev); 295 msg->len = sizeof(*ev);
295 msg->flags = 0; /* not used */ 296 msg->flags = 0; /* not used */
296 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 297 send_msg(msg);
297} 298}
298 299
299/* 300/*
@@ -325,7 +326,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
325 msg->ack = rcvd_ack + 1; 326 msg->ack = rcvd_ack + 1;
326 msg->len = sizeof(*ev); 327 msg->len = sizeof(*ev);
327 msg->flags = 0; /* not used */ 328 msg->flags = 0; /* not used */
328 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_KERNEL); 329 send_msg(msg);
329} 330}
330 331
331/** 332/**
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index 3646b143bbf5..0bb44d5b5df4 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -79,15 +79,16 @@ static const struct of_device_id machines[] __initconst = {
79static int __init cpufreq_dt_platdev_init(void) 79static int __init cpufreq_dt_platdev_init(void)
80{ 80{
81 struct device_node *np = of_find_node_by_path("/"); 81 struct device_node *np = of_find_node_by_path("/");
82 const struct of_device_id *match;
82 83
83 if (!np) 84 if (!np)
84 return -ENODEV; 85 return -ENODEV;
85 86
86 if (!of_match_node(machines, np)) 87 match = of_match_node(machines, np);
88 of_node_put(np);
89 if (!match)
87 return -ENODEV; 90 return -ENODEV;
88 91
89 of_node_put(of_root);
90
91 return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1, 92 return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1,
92 NULL, 0)); 93 NULL, 0));
93} 94}
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9009295f5134..5617c7087d77 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2261,6 +2261,10 @@ int cpufreq_update_policy(unsigned int cpu)
2261 * -> ask driver for current freq and notify governors about a change 2261 * -> ask driver for current freq and notify governors about a change
2262 */ 2262 */
2263 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { 2263 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
2264 if (cpufreq_suspended) {
2265 ret = -EAGAIN;
2266 goto unlock;
2267 }
2264 new_policy.cur = cpufreq_update_current_freq(policy); 2268 new_policy.cur = cpufreq_update_current_freq(policy);
2265 if (WARN_ON(!new_policy.cur)) { 2269 if (WARN_ON(!new_policy.cur)) {
2266 ret = -EIO; 2270 ret = -EIO;
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index fe9dc17ea873..1fa1a32928d7 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1400,6 +1400,9 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
1400{ 1400{
1401 struct cpudata *cpu = all_cpu_data[cpu_num]; 1401 struct cpudata *cpu = all_cpu_data[cpu_num];
1402 1402
1403 if (cpu->update_util_set)
1404 return;
1405
1403 /* Prevent intel_pstate_update_util() from using stale data. */ 1406 /* Prevent intel_pstate_update_util() from using stale data. */
1404 cpu->sample.time = 0; 1407 cpu->sample.time = 0;
1405 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, 1408 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util,
@@ -1440,8 +1443,6 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
1440 if (!policy->cpuinfo.max_freq) 1443 if (!policy->cpuinfo.max_freq)
1441 return -ENODEV; 1444 return -ENODEV;
1442 1445
1443 intel_pstate_clear_update_util_hook(policy->cpu);
1444
1445 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", 1446 pr_debug("set_policy cpuinfo.max %u policy->max %u\n",
1446 policy->cpuinfo.max_freq, policy->max); 1447 policy->cpuinfo.max_freq, policy->max);
1447 1448
diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
index 574e87c7f2b8..9acccad26928 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -781,7 +781,7 @@ static int hash_process_data(struct hash_device_data *device_data,
781 &device_data->state); 781 &device_data->state);
782 memmove(req_ctx->state.buffer, 782 memmove(req_ctx->state.buffer,
783 device_data->state.buffer, 783 device_data->state.buffer,
784 HASH_BLOCK_SIZE / sizeof(u32)); 784 HASH_BLOCK_SIZE);
785 if (ret) { 785 if (ret) {
786 dev_err(device_data->dev, 786 dev_err(device_data->dev,
787 "%s: hash_resume_state() failed!\n", 787 "%s: hash_resume_state() failed!\n",
@@ -832,7 +832,7 @@ static int hash_process_data(struct hash_device_data *device_data,
832 832
833 memmove(device_data->state.buffer, 833 memmove(device_data->state.buffer,
834 req_ctx->state.buffer, 834 req_ctx->state.buffer,
835 HASH_BLOCK_SIZE / sizeof(u32)); 835 HASH_BLOCK_SIZE);
836 if (ret) { 836 if (ret) {
837 dev_err(device_data->dev, "%s: hash_save_state() failed!\n", 837 dev_err(device_data->dev, "%s: hash_save_state() failed!\n",
838 __func__); 838 __func__);
diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c
index 495577b6d31b..94ad5c0adbcb 100644
--- a/drivers/crypto/vmx/aes_cbc.c
+++ b/drivers/crypto/vmx/aes_cbc.c
@@ -182,7 +182,7 @@ struct crypto_alg p8_aes_cbc_alg = {
182 .cra_name = "cbc(aes)", 182 .cra_name = "cbc(aes)",
183 .cra_driver_name = "p8_aes_cbc", 183 .cra_driver_name = "p8_aes_cbc",
184 .cra_module = THIS_MODULE, 184 .cra_module = THIS_MODULE,
185 .cra_priority = 1000, 185 .cra_priority = 2000,
186 .cra_type = &crypto_blkcipher_type, 186 .cra_type = &crypto_blkcipher_type,
187 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_NEED_FALLBACK, 187 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_NEED_FALLBACK,
188 .cra_alignmask = 0, 188 .cra_alignmask = 0,
diff --git a/drivers/crypto/vmx/aes_ctr.c b/drivers/crypto/vmx/aes_ctr.c
index 0a3c1b04cf3c..38ed10d761d0 100644
--- a/drivers/crypto/vmx/aes_ctr.c
+++ b/drivers/crypto/vmx/aes_ctr.c
@@ -166,7 +166,7 @@ struct crypto_alg p8_aes_ctr_alg = {
166 .cra_name = "ctr(aes)", 166 .cra_name = "ctr(aes)",
167 .cra_driver_name = "p8_aes_ctr", 167 .cra_driver_name = "p8_aes_ctr",
168 .cra_module = THIS_MODULE, 168 .cra_module = THIS_MODULE,
169 .cra_priority = 1000, 169 .cra_priority = 2000,
170 .cra_type = &crypto_blkcipher_type, 170 .cra_type = &crypto_blkcipher_type,
171 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_NEED_FALLBACK, 171 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_NEED_FALLBACK,
172 .cra_alignmask = 0, 172 .cra_alignmask = 0,
diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl
index 9f4994cabcc7..b18e67d0e065 100644
--- a/drivers/crypto/vmx/ppc-xlate.pl
+++ b/drivers/crypto/vmx/ppc-xlate.pl
@@ -141,7 +141,7 @@ my $vmr = sub {
141 141
142# Some ABIs specify vrsave, special-purpose register #256, as reserved 142# Some ABIs specify vrsave, special-purpose register #256, as reserved
143# for system use. 143# for system use.
144my $no_vrsave = ($flavour =~ /aix|linux64le/); 144my $no_vrsave = ($flavour =~ /linux-ppc64le/);
145my $mtspr = sub { 145my $mtspr = sub {
146 my ($f,$idx,$ra) = @_; 146 my ($f,$idx,$ra) = @_;
147 if ($idx == 256 && $no_vrsave) { 147 if ($idx == 256 && $no_vrsave) {
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index ec891a27952f..661b0e34e067 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -98,7 +98,6 @@ struct tegra_gpio_info {
98 const struct tegra_gpio_soc_config *soc; 98 const struct tegra_gpio_soc_config *soc;
99 struct gpio_chip gc; 99 struct gpio_chip gc;
100 struct irq_chip ic; 100 struct irq_chip ic;
101 struct lock_class_key lock_class;
102 u32 bank_count; 101 u32 bank_count;
103}; 102};
104 103
@@ -547,6 +546,12 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = {
547 SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) 546 SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume)
548}; 547};
549 548
549/*
550 * This lock class tells lockdep that GPIO irqs are in a different category
551 * than their parents, so it won't report false recursion.
552 */
553static struct lock_class_key gpio_lock_class;
554
550static int tegra_gpio_probe(struct platform_device *pdev) 555static int tegra_gpio_probe(struct platform_device *pdev)
551{ 556{
552 const struct tegra_gpio_soc_config *config; 557 const struct tegra_gpio_soc_config *config;
@@ -660,7 +665,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
660 665
661 bank = &tgi->bank_info[GPIO_BANK(gpio)]; 666 bank = &tgi->bank_info[GPIO_BANK(gpio)];
662 667
663 irq_set_lockdep_class(irq, &tgi->lock_class); 668 irq_set_lockdep_class(irq, &gpio_lock_class);
664 irq_set_chip_data(irq, bank); 669 irq_set_chip_data(irq, bank);
665 irq_set_chip_and_handler(irq, &tgi->ic, handle_simple_irq); 670 irq_set_chip_and_handler(irq, &tgi->ic, handle_simple_irq);
666 } 671 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index e19520c4b4b6..d9c88d13f8db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -1106,6 +1106,10 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work)
1106 if (fences == 0 && handles == 0) { 1106 if (fences == 0 && handles == 0) {
1107 if (adev->pm.dpm_enabled) { 1107 if (adev->pm.dpm_enabled) {
1108 amdgpu_dpm_enable_uvd(adev, false); 1108 amdgpu_dpm_enable_uvd(adev, false);
1109 /* just work around for uvd clock remain high even
1110 * when uvd dpm disabled on Polaris10 */
1111 if (adev->asic_type == CHIP_POLARIS10)
1112 amdgpu_asic_set_uvd_clocks(adev, 0, 0);
1109 } else { 1113 } else {
1110 amdgpu_asic_set_uvd_clocks(adev, 0, 0); 1114 amdgpu_asic_set_uvd_clocks(adev, 0, 0);
1111 } 1115 }
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 1a5cbaff1e34..b2ebd4fef6cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -47,6 +47,8 @@
47#include "dce/dce_10_0_d.h" 47#include "dce/dce_10_0_d.h"
48#include "dce/dce_10_0_sh_mask.h" 48#include "dce/dce_10_0_sh_mask.h"
49 49
50#include "smu/smu_7_1_3_d.h"
51
50#define GFX8_NUM_GFX_RINGS 1 52#define GFX8_NUM_GFX_RINGS 1
51#define GFX8_NUM_COMPUTE_RINGS 8 53#define GFX8_NUM_COMPUTE_RINGS 8
52 54
@@ -693,6 +695,7 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
693 amdgpu_program_register_sequence(adev, 695 amdgpu_program_register_sequence(adev,
694 polaris10_golden_common_all, 696 polaris10_golden_common_all,
695 (const u32)ARRAY_SIZE(polaris10_golden_common_all)); 697 (const u32)ARRAY_SIZE(polaris10_golden_common_all));
698 WREG32_SMC(ixCG_ACLK_CNTL, 0x0000001C);
696 break; 699 break;
697 case CHIP_CARRIZO: 700 case CHIP_CARRIZO:
698 amdgpu_program_register_sequence(adev, 701 amdgpu_program_register_sequence(adev,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
index 64ee78f7d41e..ec2a7ada346a 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
@@ -98,6 +98,7 @@
98#define PCIE_BUS_CLK 10000 98#define PCIE_BUS_CLK 10000
99#define TCLK (PCIE_BUS_CLK / 10) 99#define TCLK (PCIE_BUS_CLK / 10)
100 100
101#define CEILING_UCHAR(double) ((double-(uint8_t)(double)) > 0 ? (uint8_t)(double+1) : (uint8_t)(double))
101 102
102static const uint16_t polaris10_clock_stretcher_lookup_table[2][4] = 103static const uint16_t polaris10_clock_stretcher_lookup_table[2][4] =
103{ {600, 1050, 3, 0}, {600, 1050, 6, 1} }; 104{ {600, 1050, 3, 0}, {600, 1050, 6, 1} };
@@ -1422,22 +1423,19 @@ static int polaris10_populate_smc_acpi_level(struct pp_hwmgr *hwmgr,
1422 1423
1423 table->ACPILevel.Flags &= ~PPSMC_SWSTATE_FLAG_DC; 1424 table->ACPILevel.Flags &= ~PPSMC_SWSTATE_FLAG_DC;
1424 1425
1425 if (!data->sclk_dpm_key_disabled) { 1426
1426 /* Get MinVoltage and Frequency from DPM0, 1427 /* Get MinVoltage and Frequency from DPM0,
1427 * already converted to SMC_UL */ 1428 * already converted to SMC_UL */
1428 sclk_frequency = data->dpm_table.sclk_table.dpm_levels[0].value; 1429 sclk_frequency = data->dpm_table.sclk_table.dpm_levels[0].value;
1429 result = polaris10_get_dependency_volt_by_clk(hwmgr, 1430 result = polaris10_get_dependency_volt_by_clk(hwmgr,
1430 table_info->vdd_dep_on_sclk, 1431 table_info->vdd_dep_on_sclk,
1431 table->ACPILevel.SclkFrequency, 1432 sclk_frequency,
1432 &table->ACPILevel.MinVoltage, &mvdd); 1433 &table->ACPILevel.MinVoltage, &mvdd);
1433 PP_ASSERT_WITH_CODE((0 == result), 1434 PP_ASSERT_WITH_CODE((0 == result),
1434 "Cannot find ACPI VDDC voltage value " 1435 "Cannot find ACPI VDDC voltage value "
1435 "in Clock Dependency Table", ); 1436 "in Clock Dependency Table",
1436 } else { 1437 );
1437 sclk_frequency = data->vbios_boot_state.sclk_bootup_value; 1438
1438 table->ACPILevel.MinVoltage =
1439 data->vbios_boot_state.vddc_bootup_value * VOLTAGE_SCALE;
1440 }
1441 1439
1442 result = polaris10_calculate_sclk_params(hwmgr, sclk_frequency, &(table->ACPILevel.SclkSetting)); 1440 result = polaris10_calculate_sclk_params(hwmgr, sclk_frequency, &(table->ACPILevel.SclkSetting));
1443 PP_ASSERT_WITH_CODE(result == 0, "Error retrieving Engine Clock dividers from VBIOS.", return result); 1441 PP_ASSERT_WITH_CODE(result == 0, "Error retrieving Engine Clock dividers from VBIOS.", return result);
@@ -1462,24 +1460,18 @@ static int polaris10_populate_smc_acpi_level(struct pp_hwmgr *hwmgr,
1462 CONVERT_FROM_HOST_TO_SMC_US(table->ACPILevel.SclkSetting.Fcw1_frac); 1460 CONVERT_FROM_HOST_TO_SMC_US(table->ACPILevel.SclkSetting.Fcw1_frac);
1463 CONVERT_FROM_HOST_TO_SMC_US(table->ACPILevel.SclkSetting.Sclk_ss_slew_rate); 1461 CONVERT_FROM_HOST_TO_SMC_US(table->ACPILevel.SclkSetting.Sclk_ss_slew_rate);
1464 1462
1465 if (!data->mclk_dpm_key_disabled) { 1463
1466 /* Get MinVoltage and Frequency from DPM0, already converted to SMC_UL */ 1464 /* Get MinVoltage and Frequency from DPM0, already converted to SMC_UL */
1467 table->MemoryACPILevel.MclkFrequency = 1465 table->MemoryACPILevel.MclkFrequency =
1468 data->dpm_table.mclk_table.dpm_levels[0].value; 1466 data->dpm_table.mclk_table.dpm_levels[0].value;
1469 result = polaris10_get_dependency_volt_by_clk(hwmgr, 1467 result = polaris10_get_dependency_volt_by_clk(hwmgr,
1470 table_info->vdd_dep_on_mclk, 1468 table_info->vdd_dep_on_mclk,
1471 table->MemoryACPILevel.MclkFrequency, 1469 table->MemoryACPILevel.MclkFrequency,
1472 &table->MemoryACPILevel.MinVoltage, &mvdd); 1470 &table->MemoryACPILevel.MinVoltage, &mvdd);
1473 PP_ASSERT_WITH_CODE((0 == result), 1471 PP_ASSERT_WITH_CODE((0 == result),
1474 "Cannot find ACPI VDDCI voltage value " 1472 "Cannot find ACPI VDDCI voltage value "
1475 "in Clock Dependency Table", 1473 "in Clock Dependency Table",
1476 ); 1474 );
1477 } else {
1478 table->MemoryACPILevel.MclkFrequency =
1479 data->vbios_boot_state.mclk_bootup_value;
1480 table->MemoryACPILevel.MinVoltage =
1481 data->vbios_boot_state.vddci_bootup_value * VOLTAGE_SCALE;
1482 }
1483 1475
1484 us_mvdd = 0; 1476 us_mvdd = 0;
1485 if ((POLARIS10_VOLTAGE_CONTROL_NONE == data->mvdd_control) || 1477 if ((POLARIS10_VOLTAGE_CONTROL_NONE == data->mvdd_control) ||
@@ -1524,6 +1516,7 @@ static int polaris10_populate_smc_vce_level(struct pp_hwmgr *hwmgr,
1524 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table = 1516 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table =
1525 table_info->mm_dep_table; 1517 table_info->mm_dep_table;
1526 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); 1518 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
1519 uint32_t vddci;
1527 1520
1528 table->VceLevelCount = (uint8_t)(mm_table->count); 1521 table->VceLevelCount = (uint8_t)(mm_table->count);
1529 table->VceBootLevel = 0; 1522 table->VceBootLevel = 0;
@@ -1533,9 +1526,18 @@ static int polaris10_populate_smc_vce_level(struct pp_hwmgr *hwmgr,
1533 table->VceLevel[count].MinVoltage = 0; 1526 table->VceLevel[count].MinVoltage = 0;
1534 table->VceLevel[count].MinVoltage |= 1527 table->VceLevel[count].MinVoltage |=
1535 (mm_table->entries[count].vddc * VOLTAGE_SCALE) << VDDC_SHIFT; 1528 (mm_table->entries[count].vddc * VOLTAGE_SCALE) << VDDC_SHIFT;
1529
1530 if (POLARIS10_VOLTAGE_CONTROL_BY_GPIO == data->vddci_control)
1531 vddci = (uint32_t)phm_find_closest_vddci(&(data->vddci_voltage_table),
1532 mm_table->entries[count].vddc - VDDC_VDDCI_DELTA);
1533 else if (POLARIS10_VOLTAGE_CONTROL_BY_SVID2 == data->vddci_control)
1534 vddci = mm_table->entries[count].vddc - VDDC_VDDCI_DELTA;
1535 else
1536 vddci = (data->vbios_boot_state.vddci_bootup_value * VOLTAGE_SCALE) << VDDCI_SHIFT;
1537
1538
1536 table->VceLevel[count].MinVoltage |= 1539 table->VceLevel[count].MinVoltage |=
1537 ((mm_table->entries[count].vddc - data->vddc_vddci_delta) * 1540 (vddci * VOLTAGE_SCALE) << VDDCI_SHIFT;
1538 VOLTAGE_SCALE) << VDDCI_SHIFT;
1539 table->VceLevel[count].MinVoltage |= 1 << PHASES_SHIFT; 1541 table->VceLevel[count].MinVoltage |= 1 << PHASES_SHIFT;
1540 1542
1541 /*retrieve divider value for VBIOS */ 1543 /*retrieve divider value for VBIOS */
@@ -1564,6 +1566,7 @@ static int polaris10_populate_smc_samu_level(struct pp_hwmgr *hwmgr,
1564 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table = 1566 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table =
1565 table_info->mm_dep_table; 1567 table_info->mm_dep_table;
1566 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); 1568 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
1569 uint32_t vddci;
1567 1570
1568 table->SamuBootLevel = 0; 1571 table->SamuBootLevel = 0;
1569 table->SamuLevelCount = (uint8_t)(mm_table->count); 1572 table->SamuLevelCount = (uint8_t)(mm_table->count);
@@ -1574,8 +1577,16 @@ static int polaris10_populate_smc_samu_level(struct pp_hwmgr *hwmgr,
1574 table->SamuLevel[count].Frequency = mm_table->entries[count].samclock; 1577 table->SamuLevel[count].Frequency = mm_table->entries[count].samclock;
1575 table->SamuLevel[count].MinVoltage |= (mm_table->entries[count].vddc * 1578 table->SamuLevel[count].MinVoltage |= (mm_table->entries[count].vddc *
1576 VOLTAGE_SCALE) << VDDC_SHIFT; 1579 VOLTAGE_SCALE) << VDDC_SHIFT;
1577 table->SamuLevel[count].MinVoltage |= ((mm_table->entries[count].vddc - 1580
1578 data->vddc_vddci_delta) * VOLTAGE_SCALE) << VDDCI_SHIFT; 1581 if (POLARIS10_VOLTAGE_CONTROL_BY_GPIO == data->vddci_control)
1582 vddci = (uint32_t)phm_find_closest_vddci(&(data->vddci_voltage_table),
1583 mm_table->entries[count].vddc - VDDC_VDDCI_DELTA);
1584 else if (POLARIS10_VOLTAGE_CONTROL_BY_SVID2 == data->vddci_control)
1585 vddci = mm_table->entries[count].vddc - VDDC_VDDCI_DELTA;
1586 else
1587 vddci = (data->vbios_boot_state.vddci_bootup_value * VOLTAGE_SCALE) << VDDCI_SHIFT;
1588
1589 table->SamuLevel[count].MinVoltage |= (vddci * VOLTAGE_SCALE) << VDDCI_SHIFT;
1579 table->SamuLevel[count].MinVoltage |= 1 << PHASES_SHIFT; 1590 table->SamuLevel[count].MinVoltage |= 1 << PHASES_SHIFT;
1580 1591
1581 /* retrieve divider value for VBIOS */ 1592 /* retrieve divider value for VBIOS */
@@ -1658,6 +1669,7 @@ static int polaris10_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
1658 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table = 1669 struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table =
1659 table_info->mm_dep_table; 1670 table_info->mm_dep_table;
1660 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); 1671 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
1672 uint32_t vddci;
1661 1673
1662 table->UvdLevelCount = (uint8_t)(mm_table->count); 1674 table->UvdLevelCount = (uint8_t)(mm_table->count);
1663 table->UvdBootLevel = 0; 1675 table->UvdBootLevel = 0;
@@ -1668,8 +1680,16 @@ static int polaris10_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
1668 table->UvdLevel[count].DclkFrequency = mm_table->entries[count].dclk; 1680 table->UvdLevel[count].DclkFrequency = mm_table->entries[count].dclk;
1669 table->UvdLevel[count].MinVoltage |= (mm_table->entries[count].vddc * 1681 table->UvdLevel[count].MinVoltage |= (mm_table->entries[count].vddc *
1670 VOLTAGE_SCALE) << VDDC_SHIFT; 1682 VOLTAGE_SCALE) << VDDC_SHIFT;
1671 table->UvdLevel[count].MinVoltage |= ((mm_table->entries[count].vddc - 1683
1672 data->vddc_vddci_delta) * VOLTAGE_SCALE) << VDDCI_SHIFT; 1684 if (POLARIS10_VOLTAGE_CONTROL_BY_GPIO == data->vddci_control)
1685 vddci = (uint32_t)phm_find_closest_vddci(&(data->vddci_voltage_table),
1686 mm_table->entries[count].vddc - VDDC_VDDCI_DELTA);
1687 else if (POLARIS10_VOLTAGE_CONTROL_BY_SVID2 == data->vddci_control)
1688 vddci = mm_table->entries[count].vddc - VDDC_VDDCI_DELTA;
1689 else
1690 vddci = (data->vbios_boot_state.vddci_bootup_value * VOLTAGE_SCALE) << VDDCI_SHIFT;
1691
1692 table->UvdLevel[count].MinVoltage |= (vddci * VOLTAGE_SCALE) << VDDCI_SHIFT;
1673 table->UvdLevel[count].MinVoltage |= 1 << PHASES_SHIFT; 1693 table->UvdLevel[count].MinVoltage |= 1 << PHASES_SHIFT;
1674 1694
1675 /* retrieve divider value for VBIOS */ 1695 /* retrieve divider value for VBIOS */
@@ -1690,8 +1710,8 @@ static int polaris10_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
1690 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].VclkFrequency); 1710 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].VclkFrequency);
1691 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].DclkFrequency); 1711 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].DclkFrequency);
1692 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].MinVoltage); 1712 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].MinVoltage);
1693
1694 } 1713 }
1714
1695 return result; 1715 return result;
1696} 1716}
1697 1717
@@ -1787,24 +1807,32 @@ static int polaris10_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr)
1787 1807
1788 ro = efuse * (max -min)/255 + min; 1808 ro = efuse * (max -min)/255 + min;
1789 1809
1790 /* Populate Sclk_CKS_masterEn0_7 and Sclk_voltageOffset */ 1810 /* Populate Sclk_CKS_masterEn0_7 and Sclk_voltageOffset
1811 * there is a little difference in calculating
1812 * volt_with_cks with windows */
1791 for (i = 0; i < sclk_table->count; i++) { 1813 for (i = 0; i < sclk_table->count; i++) {
1792 data->smc_state_table.Sclk_CKS_masterEn0_7 |= 1814 data->smc_state_table.Sclk_CKS_masterEn0_7 |=
1793 sclk_table->entries[i].cks_enable << i; 1815 sclk_table->entries[i].cks_enable << i;
1794 1816 if (hwmgr->chip_id == CHIP_POLARIS10) {
1795 volt_without_cks = (uint32_t)(((ro - 40) * 1000 - 2753594 - sclk_table->entries[i].clk/100 * 136418 /1000) / \ 1817 volt_without_cks = (uint32_t)((2753594000 + (sclk_table->entries[i].clk/100) * 136418 -(ro - 70) * 1000000) / \
1796 (sclk_table->entries[i].clk/100 * 1132925 /10000 - 242418)/100); 1818 (2424180 - (sclk_table->entries[i].clk/100) * 1132925/1000));
1797 1819 volt_with_cks = (uint32_t)((279720200 + sclk_table->entries[i].clk * 3232 - (ro - 65) * 100000000) / \
1798 volt_with_cks = (uint32_t)((ro * 1000 -2396351 - sclk_table->entries[i].clk/100 * 329021/1000) / \ 1820 (252248000 - sclk_table->entries[i].clk/100 * 115764));
1799 (sclk_table->entries[i].clk/10000 * 649434 /1000 - 18005)/10); 1821 } else {
1822 volt_without_cks = (uint32_t)((2416794800 + (sclk_table->entries[i].clk/100) * 1476925/10 -(ro - 50) * 1000000) / \
1823 (2625416 - (sclk_table->entries[i].clk/100) * 12586807/10000));
1824 volt_with_cks = (uint32_t)((2999656000 + sclk_table->entries[i].clk * 392803/100 - (ro - 44) * 1000000) / \
1825 (3422454 - sclk_table->entries[i].clk/100 * 18886376/10000));
1826 }
1800 1827
1801 if (volt_without_cks >= volt_with_cks) 1828 if (volt_without_cks >= volt_with_cks)
1802 volt_offset = (uint8_t)(((volt_without_cks - volt_with_cks + 1829 volt_offset = (uint8_t)CEILING_UCHAR((volt_without_cks - volt_with_cks +
1803 sclk_table->entries[i].cks_voffset) * 100 / 625) + 1); 1830 sclk_table->entries[i].cks_voffset) * 100 / 625);
1804 1831
1805 data->smc_state_table.Sclk_voltageOffset[i] = volt_offset; 1832 data->smc_state_table.Sclk_voltageOffset[i] = volt_offset;
1806 } 1833 }
1807 1834
1835 data->smc_state_table.LdoRefSel = (table_info->cac_dtp_table->ucCKS_LDO_REFSEL != 0) ? table_info->cac_dtp_table->ucCKS_LDO_REFSEL : 6;
1808 /* Populate CKS Lookup Table */ 1836 /* Populate CKS Lookup Table */
1809 if (stretch_amount == 1 || stretch_amount == 2 || stretch_amount == 5) 1837 if (stretch_amount == 1 || stretch_amount == 2 || stretch_amount == 5)
1810 stretch_amount2 = 0; 1838 stretch_amount2 = 0;
@@ -2487,6 +2515,8 @@ int polaris10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
2487 PP_ASSERT_WITH_CODE((0 == tmp_result), 2515 PP_ASSERT_WITH_CODE((0 == tmp_result),
2488 "Failed to enable VR hot GPIO interrupt!", result = tmp_result); 2516 "Failed to enable VR hot GPIO interrupt!", result = tmp_result);
2489 2517
2518 smum_send_msg_to_smc(hwmgr->smumgr, (PPSMC_Msg)PPSMC_HasDisplay);
2519
2490 tmp_result = polaris10_enable_sclk_control(hwmgr); 2520 tmp_result = polaris10_enable_sclk_control(hwmgr);
2491 PP_ASSERT_WITH_CODE((0 == tmp_result), 2521 PP_ASSERT_WITH_CODE((0 == tmp_result),
2492 "Failed to enable SCLK control!", result = tmp_result); 2522 "Failed to enable SCLK control!", result = tmp_result);
@@ -2913,6 +2943,31 @@ static int polaris10_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr)
2913 return 0; 2943 return 0;
2914} 2944}
2915 2945
2946int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr)
2947{
2948 struct phm_ppt_v1_information *table_info =
2949 (struct phm_ppt_v1_information *)(hwmgr->pptable);
2950 struct phm_ppt_v1_clock_voltage_dependency_table *dep_mclk_table =
2951 table_info->vdd_dep_on_mclk;
2952 struct phm_ppt_v1_voltage_lookup_table *lookup_table =
2953 table_info->vddc_lookup_table;
2954 uint32_t i;
2955
2956 if (hwmgr->chip_id == CHIP_POLARIS10 && hwmgr->hw_revision == 0xC7) {
2957 if (lookup_table->entries[dep_mclk_table->entries[dep_mclk_table->count-1].vddInd].us_vdd >= 1000)
2958 return 0;
2959
2960 for (i = 0; i < lookup_table->count; i++) {
2961 if (lookup_table->entries[i].us_vdd < 0xff01 && lookup_table->entries[i].us_vdd >= 1000) {
2962 dep_mclk_table->entries[dep_mclk_table->count-1].vddInd = (uint8_t) i;
2963 return 0;
2964 }
2965 }
2966 }
2967 return 0;
2968}
2969
2970
2916int polaris10_hwmgr_backend_init(struct pp_hwmgr *hwmgr) 2971int polaris10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
2917{ 2972{
2918 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); 2973 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
@@ -2990,6 +3045,7 @@ int polaris10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
2990 3045
2991 polaris10_set_features_platform_caps(hwmgr); 3046 polaris10_set_features_platform_caps(hwmgr);
2992 3047
3048 polaris10_patch_voltage_workaround(hwmgr);
2993 polaris10_init_dpm_defaults(hwmgr); 3049 polaris10_init_dpm_defaults(hwmgr);
2994 3050
2995 /* Get leakage voltage based on leakage ID. */ 3051 /* Get leakage voltage based on leakage ID. */
@@ -4359,6 +4415,15 @@ static int polaris10_notify_link_speed_change_after_state_change(
4359 return 0; 4415 return 0;
4360} 4416}
4361 4417
4418static int polaris10_notify_smc_display(struct pp_hwmgr *hwmgr)
4419{
4420 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
4421
4422 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
4423 (PPSMC_Msg)PPSMC_MSG_SetVBITimeout, data->frame_time_x2);
4424 return (smum_send_msg_to_smc(hwmgr->smumgr, (PPSMC_Msg)PPSMC_HasDisplay) == 0) ? 0 : -EINVAL;
4425}
4426
4362static int polaris10_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input) 4427static int polaris10_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
4363{ 4428{
4364 int tmp_result, result = 0; 4429 int tmp_result, result = 0;
@@ -4407,6 +4472,11 @@ static int polaris10_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *i
4407 "Failed to program memory timing parameters!", 4472 "Failed to program memory timing parameters!",
4408 result = tmp_result); 4473 result = tmp_result);
4409 4474
4475 tmp_result = polaris10_notify_smc_display(hwmgr);
4476 PP_ASSERT_WITH_CODE((0 == tmp_result),
4477 "Failed to notify smc display settings!",
4478 result = tmp_result);
4479
4410 tmp_result = polaris10_unfreeze_sclk_mclk_dpm(hwmgr); 4480 tmp_result = polaris10_unfreeze_sclk_mclk_dpm(hwmgr);
4411 PP_ASSERT_WITH_CODE((0 == tmp_result), 4481 PP_ASSERT_WITH_CODE((0 == tmp_result),
4412 "Failed to unfreeze SCLK MCLK DPM!", 4482 "Failed to unfreeze SCLK MCLK DPM!",
@@ -4441,6 +4511,7 @@ static int polaris10_set_max_fan_pwm_output(struct pp_hwmgr *hwmgr, uint16_t us_
4441 PPSMC_MSG_SetFanPwmMax, us_max_fan_pwm); 4511 PPSMC_MSG_SetFanPwmMax, us_max_fan_pwm);
4442} 4512}
4443 4513
4514
4444int polaris10_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display) 4515int polaris10_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display)
4445{ 4516{
4446 PPSMC_Msg msg = has_display ? (PPSMC_Msg)PPSMC_HasDisplay : (PPSMC_Msg)PPSMC_NoDisplay; 4517 PPSMC_Msg msg = has_display ? (PPSMC_Msg)PPSMC_HasDisplay : (PPSMC_Msg)PPSMC_NoDisplay;
@@ -4460,8 +4531,6 @@ int polaris10_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwm
4460 4531
4461 if (num_active_displays > 1) /* to do && (pHwMgr->pPECI->displayConfiguration.bMultiMonitorInSync != TRUE)) */ 4532 if (num_active_displays > 1) /* to do && (pHwMgr->pPECI->displayConfiguration.bMultiMonitorInSync != TRUE)) */
4462 polaris10_notify_smc_display_change(hwmgr, false); 4533 polaris10_notify_smc_display_change(hwmgr, false);
4463 else
4464 polaris10_notify_smc_display_change(hwmgr, true);
4465 4534
4466 return 0; 4535 return 0;
4467} 4536}
@@ -4502,6 +4571,8 @@ int polaris10_program_display_gap(struct pp_hwmgr *hwmgr)
4502 frame_time_in_us = 1000000 / refresh_rate; 4571 frame_time_in_us = 1000000 / refresh_rate;
4503 4572
4504 pre_vbi_time_in_us = frame_time_in_us - 200 - mode_info.vblank_time_us; 4573 pre_vbi_time_in_us = frame_time_in_us - 200 - mode_info.vblank_time_us;
4574 data->frame_time_x2 = frame_time_in_us * 2 / 100;
4575
4505 display_gap2 = pre_vbi_time_in_us * (ref_clock / 100); 4576 display_gap2 = pre_vbi_time_in_us * (ref_clock / 100);
4506 4577
4507 cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixCG_DISPLAY_GAP_CNTL2, display_gap2); 4578 cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixCG_DISPLAY_GAP_CNTL2, display_gap2);
@@ -4510,8 +4581,6 @@ int polaris10_program_display_gap(struct pp_hwmgr *hwmgr)
4510 4581
4511 cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, data->soft_regs_start + offsetof(SMU74_SoftRegisters, VBlankTimeout), (frame_time_in_us - pre_vbi_time_in_us)); 4582 cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, data->soft_regs_start + offsetof(SMU74_SoftRegisters, VBlankTimeout), (frame_time_in_us - pre_vbi_time_in_us));
4512 4583
4513 polaris10_notify_smc_display_change(hwmgr, num_active_displays != 0);
4514
4515 return 0; 4584 return 0;
4516} 4585}
4517 4586
@@ -4623,7 +4692,7 @@ int polaris10_upload_mc_firmware(struct pp_hwmgr *hwmgr)
4623 return 0; 4692 return 0;
4624 } 4693 }
4625 4694
4626 data->need_long_memory_training = true; 4695 data->need_long_memory_training = false;
4627 4696
4628/* 4697/*
4629 * PPMCME_FirmwareDescriptorEntry *pfd = NULL; 4698 * PPMCME_FirmwareDescriptorEntry *pfd = NULL;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h
index d717789441f5..afc3434822d1 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.h
@@ -315,6 +315,7 @@ struct polaris10_hwmgr {
315 315
316 uint32_t avfs_vdroop_override_setting; 316 uint32_t avfs_vdroop_override_setting;
317 bool apply_avfs_cks_off_voltage; 317 bool apply_avfs_cks_off_voltage;
318 uint32_t frame_time_x2;
318}; 319};
319 320
320/* To convert to Q8.8 format for firmware */ 321/* To convert to Q8.8 format for firmware */
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 28f571449495..77e8e33d5870 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -411,6 +411,8 @@ struct phm_cac_tdp_table {
411 uint8_t ucVr_I2C_Line; 411 uint8_t ucVr_I2C_Line;
412 uint8_t ucPlx_I2C_address; 412 uint8_t ucPlx_I2C_address;
413 uint8_t ucPlx_I2C_Line; 413 uint8_t ucPlx_I2C_Line;
414 uint32_t usBoostPowerLimit;
415 uint8_t ucCKS_LDO_REFSEL;
414}; 416};
415 417
416struct phm_ppm_table { 418struct phm_ppm_table {
diff --git a/drivers/gpu/drm/amd/powerplay/inc/polaris10_ppsmc.h b/drivers/gpu/drm/amd/powerplay/inc/polaris10_ppsmc.h
index d41d37ab5b7c..b8f4b73c322e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/polaris10_ppsmc.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/polaris10_ppsmc.h
@@ -392,6 +392,8 @@ typedef uint16_t PPSMC_Result;
392#define PPSMC_MSG_SetGpuPllDfsForSclk ((uint16_t) 0x300) 392#define PPSMC_MSG_SetGpuPllDfsForSclk ((uint16_t) 0x300)
393#define PPSMC_MSG_Didt_Block_Function ((uint16_t) 0x301) 393#define PPSMC_MSG_Didt_Block_Function ((uint16_t) 0x301)
394 394
395#define PPSMC_MSG_SetVBITimeout ((uint16_t) 0x306)
396
395#define PPSMC_MSG_SecureSRBMWrite ((uint16_t) 0x600) 397#define PPSMC_MSG_SecureSRBMWrite ((uint16_t) 0x600)
396#define PPSMC_MSG_SecureSRBMRead ((uint16_t) 0x601) 398#define PPSMC_MSG_SecureSRBMRead ((uint16_t) 0x601)
397#define PPSMC_MSG_SetAddress ((uint16_t) 0x800) 399#define PPSMC_MSG_SetAddress ((uint16_t) 0x800)
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu74_discrete.h b/drivers/gpu/drm/amd/powerplay/inc/smu74_discrete.h
index b85ff5400e57..899d6d8108c2 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu74_discrete.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu74_discrete.h
@@ -270,7 +270,8 @@ struct SMU74_Discrete_DpmTable {
270 uint8_t BootPhases; 270 uint8_t BootPhases;
271 271
272 uint8_t VRHotLevel; 272 uint8_t VRHotLevel;
273 uint8_t Reserved1[3]; 273 uint8_t LdoRefSel;
274 uint8_t Reserved1[2];
274 uint16_t FanStartTemperature; 275 uint16_t FanStartTemperature;
275 uint16_t FanStopTemperature; 276 uint16_t FanStopTemperature;
276 uint16_t MaxVoltage; 277 uint16_t MaxVoltage;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 32690332d441..103546834b60 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2365,16 +2365,16 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
2365 task = get_pid_task(file->pid, PIDTYPE_PID); 2365 task = get_pid_task(file->pid, PIDTYPE_PID);
2366 if (!task) { 2366 if (!task) {
2367 ret = -ESRCH; 2367 ret = -ESRCH;
2368 goto out_put; 2368 goto out_unlock;
2369 } 2369 }
2370 seq_printf(m, "\nproc: %s\n", task->comm); 2370 seq_printf(m, "\nproc: %s\n", task->comm);
2371 put_task_struct(task); 2371 put_task_struct(task);
2372 idr_for_each(&file_priv->context_idr, per_file_ctx, 2372 idr_for_each(&file_priv->context_idr, per_file_ctx,
2373 (void *)(unsigned long)m); 2373 (void *)(unsigned long)m);
2374 } 2374 }
2375out_unlock:
2375 mutex_unlock(&dev->filelist_mutex); 2376 mutex_unlock(&dev->filelist_mutex);
2376 2377
2377out_put:
2378 intel_runtime_pm_put(dev_priv); 2378 intel_runtime_pm_put(dev_priv);
2379 mutex_unlock(&dev->struct_mutex); 2379 mutex_unlock(&dev->struct_mutex);
2380 2380
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 56a1637c864f..04452cf3eae8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8447,16 +8447,16 @@ static void lpt_reset_fdi_mphy(struct drm_i915_private *dev_priv)
8447 tmp |= FDI_MPHY_IOSFSB_RESET_CTL; 8447 tmp |= FDI_MPHY_IOSFSB_RESET_CTL;
8448 I915_WRITE(SOUTH_CHICKEN2, tmp); 8448 I915_WRITE(SOUTH_CHICKEN2, tmp);
8449 8449
8450 if (wait_for_atomic_us(I915_READ(SOUTH_CHICKEN2) & 8450 if (wait_for_us(I915_READ(SOUTH_CHICKEN2) &
8451 FDI_MPHY_IOSFSB_RESET_STATUS, 100)) 8451 FDI_MPHY_IOSFSB_RESET_STATUS, 100))
8452 DRM_ERROR("FDI mPHY reset assert timeout\n"); 8452 DRM_ERROR("FDI mPHY reset assert timeout\n");
8453 8453
8454 tmp = I915_READ(SOUTH_CHICKEN2); 8454 tmp = I915_READ(SOUTH_CHICKEN2);
8455 tmp &= ~FDI_MPHY_IOSFSB_RESET_CTL; 8455 tmp &= ~FDI_MPHY_IOSFSB_RESET_CTL;
8456 I915_WRITE(SOUTH_CHICKEN2, tmp); 8456 I915_WRITE(SOUTH_CHICKEN2, tmp);
8457 8457
8458 if (wait_for_atomic_us((I915_READ(SOUTH_CHICKEN2) & 8458 if (wait_for_us((I915_READ(SOUTH_CHICKEN2) &
8459 FDI_MPHY_IOSFSB_RESET_STATUS) == 0, 100)) 8459 FDI_MPHY_IOSFSB_RESET_STATUS) == 0, 100))
8460 DRM_ERROR("FDI mPHY reset de-assert timeout\n"); 8460 DRM_ERROR("FDI mPHY reset de-assert timeout\n");
8461} 8461}
8462 8462
@@ -9440,8 +9440,8 @@ static void hsw_disable_lcpll(struct drm_i915_private *dev_priv,
9440 val |= LCPLL_CD_SOURCE_FCLK; 9440 val |= LCPLL_CD_SOURCE_FCLK;
9441 I915_WRITE(LCPLL_CTL, val); 9441 I915_WRITE(LCPLL_CTL, val);
9442 9442
9443 if (wait_for_atomic_us(I915_READ(LCPLL_CTL) & 9443 if (wait_for_us(I915_READ(LCPLL_CTL) &
9444 LCPLL_CD_SOURCE_FCLK_DONE, 1)) 9444 LCPLL_CD_SOURCE_FCLK_DONE, 1))
9445 DRM_ERROR("Switching to FCLK failed\n"); 9445 DRM_ERROR("Switching to FCLK failed\n");
9446 9446
9447 val = I915_READ(LCPLL_CTL); 9447 val = I915_READ(LCPLL_CTL);
@@ -9514,8 +9514,8 @@ static void hsw_restore_lcpll(struct drm_i915_private *dev_priv)
9514 val &= ~LCPLL_CD_SOURCE_FCLK; 9514 val &= ~LCPLL_CD_SOURCE_FCLK;
9515 I915_WRITE(LCPLL_CTL, val); 9515 I915_WRITE(LCPLL_CTL, val);
9516 9516
9517 if (wait_for_atomic_us((I915_READ(LCPLL_CTL) & 9517 if (wait_for_us((I915_READ(LCPLL_CTL) &
9518 LCPLL_CD_SOURCE_FCLK_DONE) == 0, 1)) 9518 LCPLL_CD_SOURCE_FCLK_DONE) == 0, 1))
9519 DRM_ERROR("Switching back to LCPLL failed\n"); 9519 DRM_ERROR("Switching back to LCPLL failed\n");
9520 } 9520 }
9521 9521
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 79cf2d5f5a20..40745e38d438 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -663,7 +663,7 @@ intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq)
663 done = wait_event_timeout(dev_priv->gmbus_wait_queue, C, 663 done = wait_event_timeout(dev_priv->gmbus_wait_queue, C,
664 msecs_to_jiffies_timeout(10)); 664 msecs_to_jiffies_timeout(10));
665 else 665 else
666 done = wait_for_atomic(C, 10) == 0; 666 done = wait_for(C, 10) == 0;
667 if (!done) 667 if (!done)
668 DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n", 668 DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n",
669 has_aux_irq); 669 has_aux_irq);
@@ -4899,13 +4899,15 @@ static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp)
4899 4899
4900void intel_dp_encoder_reset(struct drm_encoder *encoder) 4900void intel_dp_encoder_reset(struct drm_encoder *encoder)
4901{ 4901{
4902 struct intel_dp *intel_dp; 4902 struct drm_i915_private *dev_priv = to_i915(encoder->dev);
4903 struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
4904
4905 if (!HAS_DDI(dev_priv))
4906 intel_dp->DP = I915_READ(intel_dp->output_reg);
4903 4907
4904 if (to_intel_encoder(encoder)->type != INTEL_OUTPUT_EDP) 4908 if (to_intel_encoder(encoder)->type != INTEL_OUTPUT_EDP)
4905 return; 4909 return;
4906 4910
4907 intel_dp = enc_to_intel_dp(encoder);
4908
4909 pps_lock(intel_dp); 4911 pps_lock(intel_dp);
4910 4912
4911 /* 4913 /*
diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
index baf6f5584cbd..58f60b27837e 100644
--- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
+++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
@@ -1377,8 +1377,8 @@ static void bxt_ddi_pll_enable(struct drm_i915_private *dev_priv,
1377 I915_WRITE(BXT_PORT_PLL_ENABLE(port), temp); 1377 I915_WRITE(BXT_PORT_PLL_ENABLE(port), temp);
1378 POSTING_READ(BXT_PORT_PLL_ENABLE(port)); 1378 POSTING_READ(BXT_PORT_PLL_ENABLE(port));
1379 1379
1380 if (wait_for_atomic_us((I915_READ(BXT_PORT_PLL_ENABLE(port)) & 1380 if (wait_for_us((I915_READ(BXT_PORT_PLL_ENABLE(port)) & PORT_PLL_LOCK),
1381 PORT_PLL_LOCK), 200)) 1381 200))
1382 DRM_ERROR("PLL %d not locked\n", port); 1382 DRM_ERROR("PLL %d not locked\n", port);
1383 1383
1384 /* 1384 /*
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 95b7d61d9910..fb6f1f447279 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -61,6 +61,7 @@ MODULE_LICENSE("GPL");
61#define MT_QUIRK_ALWAYS_VALID (1 << 4) 61#define MT_QUIRK_ALWAYS_VALID (1 << 4)
62#define MT_QUIRK_VALID_IS_INRANGE (1 << 5) 62#define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
63#define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) 63#define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
64#define MT_QUIRK_CONFIDENCE (1 << 7)
64#define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) 65#define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
65#define MT_QUIRK_NO_AREA (1 << 9) 66#define MT_QUIRK_NO_AREA (1 << 9)
66#define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) 67#define MT_QUIRK_IGNORE_DUPLICATES (1 << 10)
@@ -78,6 +79,7 @@ struct mt_slot {
78 __s32 contactid; /* the device ContactID assigned to this slot */ 79 __s32 contactid; /* the device ContactID assigned to this slot */
79 bool touch_state; /* is the touch valid? */ 80 bool touch_state; /* is the touch valid? */
80 bool inrange_state; /* is the finger in proximity of the sensor? */ 81 bool inrange_state; /* is the finger in proximity of the sensor? */
82 bool confidence_state; /* is the touch made by a finger? */
81}; 83};
82 84
83struct mt_class { 85struct mt_class {
@@ -503,10 +505,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
503 return 1; 505 return 1;
504 case HID_DG_CONFIDENCE: 506 case HID_DG_CONFIDENCE:
505 if (cls->name == MT_CLS_WIN_8 && 507 if (cls->name == MT_CLS_WIN_8 &&
506 field->application == HID_DG_TOUCHPAD) { 508 field->application == HID_DG_TOUCHPAD)
507 cls->quirks &= ~MT_QUIRK_ALWAYS_VALID; 509 cls->quirks |= MT_QUIRK_CONFIDENCE;
508 cls->quirks |= MT_QUIRK_VALID_IS_CONFIDENCE;
509 }
510 mt_store_field(usage, td, hi); 510 mt_store_field(usage, td, hi);
511 return 1; 511 return 1;
512 case HID_DG_TIPSWITCH: 512 case HID_DG_TIPSWITCH:
@@ -619,6 +619,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
619 return; 619 return;
620 620
621 if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { 621 if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) {
622 int active;
622 int slotnum = mt_compute_slot(td, input); 623 int slotnum = mt_compute_slot(td, input);
623 struct mt_slot *s = &td->curdata; 624 struct mt_slot *s = &td->curdata;
624 struct input_mt *mt = input->mt; 625 struct input_mt *mt = input->mt;
@@ -633,10 +634,14 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
633 return; 634 return;
634 } 635 }
635 636
637 if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE))
638 s->confidence_state = 1;
639 active = (s->touch_state || s->inrange_state) &&
640 s->confidence_state;
641
636 input_mt_slot(input, slotnum); 642 input_mt_slot(input, slotnum);
637 input_mt_report_slot_state(input, MT_TOOL_FINGER, 643 input_mt_report_slot_state(input, MT_TOOL_FINGER, active);
638 s->touch_state || s->inrange_state); 644 if (active) {
639 if (s->touch_state || s->inrange_state) {
640 /* this finger is in proximity of the sensor */ 645 /* this finger is in proximity of the sensor */
641 int wide = (s->w > s->h); 646 int wide = (s->w > s->h);
642 /* divided by two to match visual scale of touch */ 647 /* divided by two to match visual scale of touch */
@@ -701,6 +706,8 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
701 td->curdata.touch_state = value; 706 td->curdata.touch_state = value;
702 break; 707 break;
703 case HID_DG_CONFIDENCE: 708 case HID_DG_CONFIDENCE:
709 if (quirks & MT_QUIRK_CONFIDENCE)
710 td->curdata.confidence_state = value;
704 if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) 711 if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
705 td->curvalid = value; 712 td->curvalid = value;
706 break; 713 break;
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 923f56598d4b..3a9f106787d2 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -81,7 +81,7 @@ static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro)
81 81
82 mutex_lock(&st->buf_lock); 82 mutex_lock(&st->buf_lock);
83 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); 83 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
84 if (ret) 84 if (ret < 0)
85 goto error_ret; 85 goto error_ret;
86 st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C); 86 st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C);
87 st->tx[1] = (ret & ~KXSD9_FS_MASK) | i; 87 st->tx[1] = (ret & ~KXSD9_FS_MASK) | i;
@@ -163,7 +163,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
163 break; 163 break;
164 case IIO_CHAN_INFO_SCALE: 164 case IIO_CHAN_INFO_SCALE:
165 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); 165 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
166 if (ret) 166 if (ret < 0)
167 goto error_ret; 167 goto error_ret;
168 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; 168 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];
169 ret = IIO_VAL_INT_PLUS_MICRO; 169 ret = IIO_VAL_INT_PLUS_MICRO;
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 21e19b60e2b9..2123f0ac2e2a 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -396,8 +396,8 @@ static int ad7266_probe(struct spi_device *spi)
396 396
397 st = iio_priv(indio_dev); 397 st = iio_priv(indio_dev);
398 398
399 st->reg = devm_regulator_get(&spi->dev, "vref"); 399 st->reg = devm_regulator_get_optional(&spi->dev, "vref");
400 if (!IS_ERR_OR_NULL(st->reg)) { 400 if (!IS_ERR(st->reg)) {
401 ret = regulator_enable(st->reg); 401 ret = regulator_enable(st->reg);
402 if (ret) 402 if (ret)
403 return ret; 403 return ret;
@@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_device *spi)
408 408
409 st->vref_mv = ret / 1000; 409 st->vref_mv = ret / 1000;
410 } else { 410 } else {
411 /* Any other error indicates that the regulator does exist */
412 if (PTR_ERR(st->reg) != -ENODEV)
413 return PTR_ERR(st->reg);
411 /* Use internal reference */ 414 /* Use internal reference */
412 st->vref_mv = 2500; 415 st->vref_mv = 2500;
413 } 416 }
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
index f62b8bd9ad7e..dd6fc6d21f9d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -56,6 +56,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
56 int i; 56 int i;
57 acpi_status status; 57 acpi_status status;
58 union acpi_object *cpm; 58 union acpi_object *cpm;
59 int ret;
59 60
60 status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer); 61 status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
61 if (ACPI_FAILURE(status)) 62 if (ACPI_FAILURE(status))
@@ -82,10 +83,10 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
82 } 83 }
83 } 84 }
84 } 85 }
85 86 ret = cpm->package.count;
86 kfree(buffer.pointer); 87 kfree(buffer.pointer);
87 88
88 return cpm->package.count; 89 return ret;
89} 90}
90 91
91static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data) 92static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 804dbcc37d3f..3438e98c145a 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1031,17 +1031,17 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
1031 1031
1032 case XTYPE_XBOXONE: 1032 case XTYPE_XBOXONE:
1033 packet->data[0] = 0x09; /* activate rumble */ 1033 packet->data[0] = 0x09; /* activate rumble */
1034 packet->data[1] = 0x08; 1034 packet->data[1] = 0x00;
1035 packet->data[2] = xpad->odata_serial++; 1035 packet->data[2] = xpad->odata_serial++;
1036 packet->data[3] = 0x08; /* continuous effect */ 1036 packet->data[3] = 0x09;
1037 packet->data[4] = 0x00; /* simple rumble mode */ 1037 packet->data[4] = 0x00;
1038 packet->data[5] = 0x03; /* L and R actuator only */ 1038 packet->data[5] = 0x0F;
1039 packet->data[6] = 0x00; /* TODO: LT actuator */ 1039 packet->data[6] = 0x00;
1040 packet->data[7] = 0x00; /* TODO: RT actuator */ 1040 packet->data[7] = 0x00;
1041 packet->data[8] = strong / 512; /* left actuator */ 1041 packet->data[8] = strong / 512; /* left actuator */
1042 packet->data[9] = weak / 512; /* right actuator */ 1042 packet->data[9] = weak / 512; /* right actuator */
1043 packet->data[10] = 0x80; /* length of pulse */ 1043 packet->data[10] = 0xFF;
1044 packet->data[11] = 0x00; /* stop period of pulse */ 1044 packet->data[11] = 0x00;
1045 packet->data[12] = 0x00; 1045 packet->data[12] = 0x00;
1046 packet->len = 13; 1046 packet->len = 13;
1047 packet->pending = true; 1047 packet->pending = true;
@@ -1437,16 +1437,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
1437 break; 1437 break;
1438 } 1438 }
1439 1439
1440 if (xpad_device[i].xtype == XTYPE_XBOXONE &&
1441 intf->cur_altsetting->desc.bInterfaceNumber != 0) {
1442 /*
1443 * The Xbox One controller lists three interfaces all with the
1444 * same interface class, subclass and protocol. Differentiate by
1445 * interface number.
1446 */
1447 return -ENODEV;
1448 }
1449
1450 xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); 1440 xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
1451 if (!xpad) 1441 if (!xpad)
1452 return -ENOMEM; 1442 return -ENOMEM;
@@ -1478,6 +1468,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
1478 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 1468 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
1479 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) 1469 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
1480 xpad->xtype = XTYPE_XBOX360W; 1470 xpad->xtype = XTYPE_XBOX360W;
1471 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208)
1472 xpad->xtype = XTYPE_XBOXONE;
1481 else 1473 else
1482 xpad->xtype = XTYPE_XBOX360; 1474 xpad->xtype = XTYPE_XBOX360;
1483 } else { 1475 } else {
@@ -1492,6 +1484,17 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
1492 xpad->mapping |= MAP_STICKS_TO_NULL; 1484 xpad->mapping |= MAP_STICKS_TO_NULL;
1493 } 1485 }
1494 1486
1487 if (xpad->xtype == XTYPE_XBOXONE &&
1488 intf->cur_altsetting->desc.bInterfaceNumber != 0) {
1489 /*
1490 * The Xbox One controller lists three interfaces all with the
1491 * same interface class, subclass and protocol. Differentiate by
1492 * interface number.
1493 */
1494 error = -ENODEV;
1495 goto err_free_in_urb;
1496 }
1497
1495 error = xpad_init_output(intf, xpad); 1498 error = xpad_init_output(intf, xpad);
1496 if (error) 1499 if (error)
1497 goto err_free_in_urb; 1500 goto err_free_in_urb;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 78f93cf68840..be5b399da5d3 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1568,13 +1568,7 @@ static int elantech_set_properties(struct elantech_data *etd)
1568 case 5: 1568 case 5:
1569 etd->hw_version = 3; 1569 etd->hw_version = 3;
1570 break; 1570 break;
1571 case 6: 1571 case 6 ... 14:
1572 case 7:
1573 case 8:
1574 case 9:
1575 case 10:
1576 case 13:
1577 case 14:
1578 etd->hw_version = 4; 1572 etd->hw_version = 4;
1579 break; 1573 break;
1580 default: 1574 default:
diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index a3f0f5a47490..0f586780ceb4 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -355,18 +355,11 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
355 return -ENXIO; 355 return -ENXIO;
356 } 356 }
357 357
358 if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
359 psmouse_dbg(psmouse, "VMMouse port in use.\n");
360 return -EBUSY;
361 }
362
363 /* Check if the device is present */ 358 /* Check if the device is present */
364 response = ~VMMOUSE_PROTO_MAGIC; 359 response = ~VMMOUSE_PROTO_MAGIC;
365 VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2); 360 VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);
366 if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) { 361 if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU)
367 release_region(VMMOUSE_PROTO_PORT, 4);
368 return -ENXIO; 362 return -ENXIO;
369 }
370 363
371 if (set_properties) { 364 if (set_properties) {
372 psmouse->vendor = VMMOUSE_VENDOR; 365 psmouse->vendor = VMMOUSE_VENDOR;
@@ -374,8 +367,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
374 psmouse->model = version; 367 psmouse->model = version;
375 } 368 }
376 369
377 release_region(VMMOUSE_PROTO_PORT, 4);
378
379 return 0; 370 return 0;
380} 371}
381 372
@@ -394,7 +385,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse)
394 psmouse_reset(psmouse); 385 psmouse_reset(psmouse);
395 input_unregister_device(priv->abs_dev); 386 input_unregister_device(priv->abs_dev);
396 kfree(priv); 387 kfree(priv);
397 release_region(VMMOUSE_PROTO_PORT, 4);
398} 388}
399 389
400/** 390/**
@@ -438,15 +428,10 @@ int vmmouse_init(struct psmouse *psmouse)
438 struct input_dev *rel_dev = psmouse->dev, *abs_dev; 428 struct input_dev *rel_dev = psmouse->dev, *abs_dev;
439 int error; 429 int error;
440 430
441 if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
442 psmouse_dbg(psmouse, "VMMouse port in use.\n");
443 return -EBUSY;
444 }
445
446 psmouse_reset(psmouse); 431 psmouse_reset(psmouse);
447 error = vmmouse_enable(psmouse); 432 error = vmmouse_enable(psmouse);
448 if (error) 433 if (error)
449 goto release_region; 434 return error;
450 435
451 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 436 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
452 abs_dev = input_allocate_device(); 437 abs_dev = input_allocate_device();
@@ -502,8 +487,5 @@ init_fail:
502 kfree(priv); 487 kfree(priv);
503 psmouse->private = NULL; 488 psmouse->private = NULL;
504 489
505release_region:
506 release_region(VMMOUSE_PROTO_PORT, 4);
507
508 return error; 490 return error;
509} 491}
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index bab3c6acf6a2..0c9191cf324d 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -27,7 +27,7 @@ MODULE_AUTHOR("Jaya Kumar <jayakumar.lkml@gmail.com>");
27MODULE_DESCRIPTION(DRIVER_DESC); 27MODULE_DESCRIPTION(DRIVER_DESC);
28MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
29 29
30#define W8001_MAX_LENGTH 11 30#define W8001_MAX_LENGTH 13
31#define W8001_LEAD_MASK 0x80 31#define W8001_LEAD_MASK 0x80
32#define W8001_LEAD_BYTE 0x80 32#define W8001_LEAD_BYTE 0x80
33#define W8001_TAB_MASK 0x40 33#define W8001_TAB_MASK 0x40
@@ -339,6 +339,15 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
339 w8001->idx = 0; 339 w8001->idx = 0;
340 parse_multi_touch(w8001); 340 parse_multi_touch(w8001);
341 break; 341 break;
342
343 default:
344 /*
345 * ThinkPad X60 Tablet PC (pen only device) sometimes
346 * sends invalid data packets that are larger than
347 * W8001_PKTLEN_TPCPEN. Let's start over again.
348 */
349 if (!w8001->touch_dev && w8001->idx > W8001_PKTLEN_TPCPEN - 1)
350 w8001->idx = 0;
342 } 351 }
343 352
344 return IRQ_HANDLED; 353 return IRQ_HANDLED;
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 9e0034196e10..d091defc3426 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1107,13 +1107,13 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
1107 break; 1107 break;
1108 } 1108 }
1109 1109
1110 devid = e->devid;
1110 DUMP_printk(" DEV_ACPI_HID(%s[%s])\t\tdevid: %02x:%02x.%x\n", 1111 DUMP_printk(" DEV_ACPI_HID(%s[%s])\t\tdevid: %02x:%02x.%x\n",
1111 hid, uid, 1112 hid, uid,
1112 PCI_BUS_NUM(devid), 1113 PCI_BUS_NUM(devid),
1113 PCI_SLOT(devid), 1114 PCI_SLOT(devid),
1114 PCI_FUNC(devid)); 1115 PCI_FUNC(devid));
1115 1116
1116 devid = e->devid;
1117 flags = e->flags; 1117 flags = e->flags;
1118 1118
1119 ret = add_acpi_hid_device(hid, uid, &devid, false); 1119 ret = add_acpi_hid_device(hid, uid, &devid, false);
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 10700945994e..cfe410eedaf0 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4607,7 +4607,7 @@ static void free_all_cpu_cached_iovas(unsigned int cpu)
4607 if (!iommu) 4607 if (!iommu)
4608 continue; 4608 continue;
4609 4609
4610 for (did = 0; did < 0xffff; did++) { 4610 for (did = 0; did < cap_ndoms(iommu->cap); did++) {
4611 domain = get_iommu_domain(iommu, did); 4611 domain = get_iommu_domain(iommu, did);
4612 4612
4613 if (!domain) 4613 if (!domain)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index ba764a0835d3..e23001bfcfee 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -420,8 +420,10 @@ retry:
420 420
421 /* Try replenishing IOVAs by flushing rcache. */ 421 /* Try replenishing IOVAs by flushing rcache. */
422 flushed_rcache = true; 422 flushed_rcache = true;
423 preempt_disable();
423 for_each_online_cpu(cpu) 424 for_each_online_cpu(cpu)
424 free_cpu_cached_iovas(cpu, iovad); 425 free_cpu_cached_iovas(cpu, iovad);
426 preempt_enable();
425 goto retry; 427 goto retry;
426 } 428 }
427 429
@@ -749,7 +751,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
749 bool can_insert = false; 751 bool can_insert = false;
750 unsigned long flags; 752 unsigned long flags;
751 753
752 cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches); 754 cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
753 spin_lock_irqsave(&cpu_rcache->lock, flags); 755 spin_lock_irqsave(&cpu_rcache->lock, flags);
754 756
755 if (!iova_magazine_full(cpu_rcache->loaded)) { 757 if (!iova_magazine_full(cpu_rcache->loaded)) {
@@ -779,6 +781,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
779 iova_magazine_push(cpu_rcache->loaded, iova_pfn); 781 iova_magazine_push(cpu_rcache->loaded, iova_pfn);
780 782
781 spin_unlock_irqrestore(&cpu_rcache->lock, flags); 783 spin_unlock_irqrestore(&cpu_rcache->lock, flags);
784 put_cpu_ptr(rcache->cpu_rcaches);
782 785
783 if (mag_to_free) { 786 if (mag_to_free) {
784 iova_magazine_free_pfns(mag_to_free, iovad); 787 iova_magazine_free_pfns(mag_to_free, iovad);
@@ -812,7 +815,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
812 bool has_pfn = false; 815 bool has_pfn = false;
813 unsigned long flags; 816 unsigned long flags;
814 817
815 cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches); 818 cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
816 spin_lock_irqsave(&cpu_rcache->lock, flags); 819 spin_lock_irqsave(&cpu_rcache->lock, flags);
817 820
818 if (!iova_magazine_empty(cpu_rcache->loaded)) { 821 if (!iova_magazine_empty(cpu_rcache->loaded)) {
@@ -834,6 +837,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
834 iova_pfn = iova_magazine_pop(cpu_rcache->loaded, limit_pfn); 837 iova_pfn = iova_magazine_pop(cpu_rcache->loaded, limit_pfn);
835 838
836 spin_unlock_irqrestore(&cpu_rcache->lock, flags); 839 spin_unlock_irqrestore(&cpu_rcache->lock, flags);
840 put_cpu_ptr(rcache->cpu_rcaches);
837 841
838 return iova_pfn; 842 return iova_pfn;
839} 843}
diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
index 199d261990be..f32fbb8e8129 100644
--- a/drivers/mfd/max77620.c
+++ b/drivers/mfd/max77620.c
@@ -203,6 +203,7 @@ static int max77620_get_fps_period_reg_value(struct max77620_chip *chip,
203 break; 203 break;
204 case MAX77620: 204 case MAX77620:
205 fps_min_period = MAX77620_FPS_PERIOD_MIN_US; 205 fps_min_period = MAX77620_FPS_PERIOD_MIN_US;
206 break;
206 default: 207 default:
207 return -EINVAL; 208 return -EINVAL;
208 } 209 }
@@ -236,6 +237,7 @@ static int max77620_config_fps(struct max77620_chip *chip,
236 break; 237 break;
237 case MAX77620: 238 case MAX77620:
238 fps_max_period = MAX77620_FPS_PERIOD_MAX_US; 239 fps_max_period = MAX77620_FPS_PERIOD_MAX_US;
240 break;
239 default: 241 default:
240 return -EINVAL; 242 return -EINVAL;
241 } 243 }
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index b9304a295f86..ca81f46ea1aa 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -657,6 +657,20 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
657 } 657 }
658} 658}
659 659
660static int __agg_active_ports(struct aggregator *agg)
661{
662 struct port *port;
663 int active = 0;
664
665 for (port = agg->lag_ports; port;
666 port = port->next_port_in_aggregator) {
667 if (port->is_enabled)
668 active++;
669 }
670
671 return active;
672}
673
660/** 674/**
661 * __get_agg_bandwidth - get the total bandwidth of an aggregator 675 * __get_agg_bandwidth - get the total bandwidth of an aggregator
662 * @aggregator: the aggregator we're looking at 676 * @aggregator: the aggregator we're looking at
@@ -664,39 +678,40 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
664 */ 678 */
665static u32 __get_agg_bandwidth(struct aggregator *aggregator) 679static u32 __get_agg_bandwidth(struct aggregator *aggregator)
666{ 680{
681 int nports = __agg_active_ports(aggregator);
667 u32 bandwidth = 0; 682 u32 bandwidth = 0;
668 683
669 if (aggregator->num_of_ports) { 684 if (nports) {
670 switch (__get_link_speed(aggregator->lag_ports)) { 685 switch (__get_link_speed(aggregator->lag_ports)) {
671 case AD_LINK_SPEED_1MBPS: 686 case AD_LINK_SPEED_1MBPS:
672 bandwidth = aggregator->num_of_ports; 687 bandwidth = nports;
673 break; 688 break;
674 case AD_LINK_SPEED_10MBPS: 689 case AD_LINK_SPEED_10MBPS:
675 bandwidth = aggregator->num_of_ports * 10; 690 bandwidth = nports * 10;
676 break; 691 break;
677 case AD_LINK_SPEED_100MBPS: 692 case AD_LINK_SPEED_100MBPS:
678 bandwidth = aggregator->num_of_ports * 100; 693 bandwidth = nports * 100;
679 break; 694 break;
680 case AD_LINK_SPEED_1000MBPS: 695 case AD_LINK_SPEED_1000MBPS:
681 bandwidth = aggregator->num_of_ports * 1000; 696 bandwidth = nports * 1000;
682 break; 697 break;
683 case AD_LINK_SPEED_2500MBPS: 698 case AD_LINK_SPEED_2500MBPS:
684 bandwidth = aggregator->num_of_ports * 2500; 699 bandwidth = nports * 2500;
685 break; 700 break;
686 case AD_LINK_SPEED_10000MBPS: 701 case AD_LINK_SPEED_10000MBPS:
687 bandwidth = aggregator->num_of_ports * 10000; 702 bandwidth = nports * 10000;
688 break; 703 break;
689 case AD_LINK_SPEED_20000MBPS: 704 case AD_LINK_SPEED_20000MBPS:
690 bandwidth = aggregator->num_of_ports * 20000; 705 bandwidth = nports * 20000;
691 break; 706 break;
692 case AD_LINK_SPEED_40000MBPS: 707 case AD_LINK_SPEED_40000MBPS:
693 bandwidth = aggregator->num_of_ports * 40000; 708 bandwidth = nports * 40000;
694 break; 709 break;
695 case AD_LINK_SPEED_56000MBPS: 710 case AD_LINK_SPEED_56000MBPS:
696 bandwidth = aggregator->num_of_ports * 56000; 711 bandwidth = nports * 56000;
697 break; 712 break;
698 case AD_LINK_SPEED_100000MBPS: 713 case AD_LINK_SPEED_100000MBPS:
699 bandwidth = aggregator->num_of_ports * 100000; 714 bandwidth = nports * 100000;
700 break; 715 break;
701 default: 716 default:
702 bandwidth = 0; /* to silence the compiler */ 717 bandwidth = 0; /* to silence the compiler */
@@ -1530,10 +1545,10 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
1530 1545
1531 switch (__get_agg_selection_mode(curr->lag_ports)) { 1546 switch (__get_agg_selection_mode(curr->lag_ports)) {
1532 case BOND_AD_COUNT: 1547 case BOND_AD_COUNT:
1533 if (curr->num_of_ports > best->num_of_ports) 1548 if (__agg_active_ports(curr) > __agg_active_ports(best))
1534 return curr; 1549 return curr;
1535 1550
1536 if (curr->num_of_ports < best->num_of_ports) 1551 if (__agg_active_ports(curr) < __agg_active_ports(best))
1537 return best; 1552 return best;
1538 1553
1539 /*FALLTHROUGH*/ 1554 /*FALLTHROUGH*/
@@ -1561,8 +1576,14 @@ static int agg_device_up(const struct aggregator *agg)
1561 if (!port) 1576 if (!port)
1562 return 0; 1577 return 0;
1563 1578
1564 return netif_running(port->slave->dev) && 1579 for (port = agg->lag_ports; port;
1565 netif_carrier_ok(port->slave->dev); 1580 port = port->next_port_in_aggregator) {
1581 if (netif_running(port->slave->dev) &&
1582 netif_carrier_ok(port->slave->dev))
1583 return 1;
1584 }
1585
1586 return 0;
1566} 1587}
1567 1588
1568/** 1589/**
@@ -1610,7 +1631,7 @@ static void ad_agg_selection_logic(struct aggregator *agg,
1610 1631
1611 agg->is_active = 0; 1632 agg->is_active = 0;
1612 1633
1613 if (agg->num_of_ports && agg_device_up(agg)) 1634 if (__agg_active_ports(agg) && agg_device_up(agg))
1614 best = ad_agg_selection_test(best, agg); 1635 best = ad_agg_selection_test(best, agg);
1615 } 1636 }
1616 1637
@@ -1622,7 +1643,7 @@ static void ad_agg_selection_logic(struct aggregator *agg,
1622 * answering partner. 1643 * answering partner.
1623 */ 1644 */
1624 if (active && active->lag_ports && 1645 if (active && active->lag_ports &&
1625 active->lag_ports->is_enabled && 1646 __agg_active_ports(active) &&
1626 (__agg_has_partner(active) || 1647 (__agg_has_partner(active) ||
1627 (!__agg_has_partner(active) && 1648 (!__agg_has_partner(active) &&
1628 !__agg_has_partner(best)))) { 1649 !__agg_has_partner(best)))) {
@@ -2133,7 +2154,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2133 else 2154 else
2134 temp_aggregator->lag_ports = temp_port->next_port_in_aggregator; 2155 temp_aggregator->lag_ports = temp_port->next_port_in_aggregator;
2135 temp_aggregator->num_of_ports--; 2156 temp_aggregator->num_of_ports--;
2136 if (temp_aggregator->num_of_ports == 0) { 2157 if (__agg_active_ports(temp_aggregator) == 0) {
2137 select_new_active_agg = temp_aggregator->is_active; 2158 select_new_active_agg = temp_aggregator->is_active;
2138 ad_clear_agg(temp_aggregator); 2159 ad_clear_agg(temp_aggregator);
2139 if (select_new_active_agg) { 2160 if (select_new_active_agg) {
@@ -2432,7 +2453,9 @@ void bond_3ad_adapter_speed_duplex_changed(struct slave *slave)
2432 */ 2453 */
2433void bond_3ad_handle_link_change(struct slave *slave, char link) 2454void bond_3ad_handle_link_change(struct slave *slave, char link)
2434{ 2455{
2456 struct aggregator *agg;
2435 struct port *port; 2457 struct port *port;
2458 bool dummy;
2436 2459
2437 port = &(SLAVE_AD_INFO(slave)->port); 2460 port = &(SLAVE_AD_INFO(slave)->port);
2438 2461
@@ -2459,6 +2482,9 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2459 port->is_enabled = false; 2482 port->is_enabled = false;
2460 ad_update_actor_keys(port, true); 2483 ad_update_actor_keys(port, true);
2461 } 2484 }
2485 agg = __get_first_agg(port);
2486 ad_agg_selection_logic(agg, &dummy);
2487
2462 netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n", 2488 netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n",
2463 port->actor_port_number, 2489 port->actor_port_number,
2464 link == BOND_LINK_UP ? "UP" : "DOWN"); 2490 link == BOND_LINK_UP ? "UP" : "DOWN");
@@ -2499,7 +2525,7 @@ int bond_3ad_set_carrier(struct bonding *bond)
2499 active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator)); 2525 active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator));
2500 if (active) { 2526 if (active) {
2501 /* are enough slaves available to consider link up? */ 2527 /* are enough slaves available to consider link up? */
2502 if (active->num_of_ports < bond->params.min_links) { 2528 if (__agg_active_ports(active) < bond->params.min_links) {
2503 if (netif_carrier_ok(bond->dev)) { 2529 if (netif_carrier_ok(bond->dev)) {
2504 netif_carrier_off(bond->dev); 2530 netif_carrier_off(bond->dev);
2505 goto out; 2531 goto out;
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 8b3275d7792a..8f5e93cb7975 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -712,9 +712,10 @@ static int at91_poll_rx(struct net_device *dev, int quota)
712 712
713 /* upper group completed, look again in lower */ 713 /* upper group completed, look again in lower */
714 if (priv->rx_next > get_mb_rx_low_last(priv) && 714 if (priv->rx_next > get_mb_rx_low_last(priv) &&
715 quota > 0 && mb > get_mb_rx_last(priv)) { 715 mb > get_mb_rx_last(priv)) {
716 priv->rx_next = get_mb_rx_first(priv); 716 priv->rx_next = get_mb_rx_first(priv);
717 goto again; 717 if (quota > 0)
718 goto again;
718 } 719 }
719 720
720 return received; 721 return received;
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index f91b094288da..e3dccd3200d5 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -332,9 +332,23 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface,
332 332
333 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl); 333 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl);
334 334
335 for (i = 0; i < frame->can_dlc; i += 2) { 335 if (priv->type == BOSCH_D_CAN) {
336 priv->write_reg(priv, C_CAN_IFACE(DATA1_REG, iface) + i / 2, 336 u32 data = 0, dreg = C_CAN_IFACE(DATA1_REG, iface);
337 frame->data[i] | (frame->data[i + 1] << 8)); 337
338 for (i = 0; i < frame->can_dlc; i += 4, dreg += 2) {
339 data = (u32)frame->data[i];
340 data |= (u32)frame->data[i + 1] << 8;
341 data |= (u32)frame->data[i + 2] << 16;
342 data |= (u32)frame->data[i + 3] << 24;
343 priv->write_reg32(priv, dreg, data);
344 }
345 } else {
346 for (i = 0; i < frame->can_dlc; i += 2) {
347 priv->write_reg(priv,
348 C_CAN_IFACE(DATA1_REG, iface) + i / 2,
349 frame->data[i] |
350 (frame->data[i + 1] << 8));
351 }
338 } 352 }
339} 353}
340 354
@@ -402,10 +416,20 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
402 } else { 416 } else {
403 int i, dreg = C_CAN_IFACE(DATA1_REG, iface); 417 int i, dreg = C_CAN_IFACE(DATA1_REG, iface);
404 418
405 for (i = 0; i < frame->can_dlc; i += 2, dreg ++) { 419 if (priv->type == BOSCH_D_CAN) {
406 data = priv->read_reg(priv, dreg); 420 for (i = 0; i < frame->can_dlc; i += 4, dreg += 2) {
407 frame->data[i] = data; 421 data = priv->read_reg32(priv, dreg);
408 frame->data[i + 1] = data >> 8; 422 frame->data[i] = data;
423 frame->data[i + 1] = data >> 8;
424 frame->data[i + 2] = data >> 16;
425 frame->data[i + 3] = data >> 24;
426 }
427 } else {
428 for (i = 0; i < frame->can_dlc; i += 2, dreg++) {
429 data = priv->read_reg(priv, dreg);
430 frame->data[i] = data;
431 frame->data[i + 1] = data >> 8;
432 }
409 } 433 }
410 } 434 }
411 435
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 910c12e2638e..ad535a854e5c 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -798,6 +798,9 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[])
798 * - control mode with CAN_CTRLMODE_FD set 798 * - control mode with CAN_CTRLMODE_FD set
799 */ 799 */
800 800
801 if (!data)
802 return 0;
803
801 if (data[IFLA_CAN_CTRLMODE]) { 804 if (data[IFLA_CAN_CTRLMODE]) {
802 struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]); 805 struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]);
803 806
@@ -1008,6 +1011,11 @@ static int can_newlink(struct net *src_net, struct net_device *dev,
1008 return -EOPNOTSUPP; 1011 return -EOPNOTSUPP;
1009} 1012}
1010 1013
1014static void can_dellink(struct net_device *dev, struct list_head *head)
1015{
1016 return;
1017}
1018
1011static struct rtnl_link_ops can_link_ops __read_mostly = { 1019static struct rtnl_link_ops can_link_ops __read_mostly = {
1012 .kind = "can", 1020 .kind = "can",
1013 .maxtype = IFLA_CAN_MAX, 1021 .maxtype = IFLA_CAN_MAX,
@@ -1016,6 +1024,7 @@ static struct rtnl_link_ops can_link_ops __read_mostly = {
1016 .validate = can_validate, 1024 .validate = can_validate,
1017 .newlink = can_newlink, 1025 .newlink = can_newlink,
1018 .changelink = can_changelink, 1026 .changelink = can_changelink,
1027 .dellink = can_dellink,
1019 .get_size = can_get_size, 1028 .get_size = can_get_size,
1020 .fill_info = can_fill_info, 1029 .fill_info = can_fill_info,
1021 .get_xstats_size = can_get_xstats_size, 1030 .get_xstats_size = can_get_xstats_size,
diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index bcb272f6c68a..8483a40e7e9e 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -16,7 +16,8 @@ config CAN_ESD_USB2
16config CAN_GS_USB 16config CAN_GS_USB
17 tristate "Geschwister Schneider UG interfaces" 17 tristate "Geschwister Schneider UG interfaces"
18 ---help--- 18 ---help---
19 This driver supports the Geschwister Schneider USB/CAN devices. 19 This driver supports the Geschwister Schneider and bytewerk.org
20 candleLight USB CAN interfaces USB/CAN devices
20 If unsure choose N, 21 If unsure choose N,
21 choose Y for built in support, 22 choose Y for built in support,
22 M to compile as module (module will be named: gs_usb). 23 M to compile as module (module will be named: gs_usb).
@@ -46,6 +47,8 @@ config CAN_KVASER_USB
46 - Kvaser USBcan R 47 - Kvaser USBcan R
47 - Kvaser Leaf Light v2 48 - Kvaser Leaf Light v2
48 - Kvaser Mini PCI Express HS 49 - Kvaser Mini PCI Express HS
50 - Kvaser Mini PCI Express 2xHS
51 - Kvaser USBcan Light 2xHS
49 - Kvaser USBcan II HS/HS 52 - Kvaser USBcan II HS/HS
50 - Kvaser USBcan II HS/LS 53 - Kvaser USBcan II HS/LS
51 - Kvaser USBcan Rugged ("USBcan Rev B") 54 - Kvaser USBcan Rugged ("USBcan Rev B")
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 1556d4286235..acb0c8490673 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -1,7 +1,9 @@
1/* CAN driver for Geschwister Schneider USB/CAN devices. 1/* CAN driver for Geschwister Schneider USB/CAN devices
2 * and bytewerk.org candleLight USB CAN interfaces.
2 * 3 *
3 * Copyright (C) 2013 Geschwister Schneider Technologie-, 4 * Copyright (C) 2013-2016 Geschwister Schneider Technologie-,
4 * Entwicklungs- und Vertriebs UG (Haftungsbeschränkt). 5 * Entwicklungs- und Vertriebs UG (Haftungsbeschränkt).
6 * Copyright (C) 2016 Hubert Denkmair
5 * 7 *
6 * Many thanks to all socketcan devs! 8 * Many thanks to all socketcan devs!
7 * 9 *
@@ -29,6 +31,9 @@
29#define USB_GSUSB_1_VENDOR_ID 0x1d50 31#define USB_GSUSB_1_VENDOR_ID 0x1d50
30#define USB_GSUSB_1_PRODUCT_ID 0x606f 32#define USB_GSUSB_1_PRODUCT_ID 0x606f
31 33
34#define USB_CANDLELIGHT_VENDOR_ID 0x1209
35#define USB_CANDLELIGHT_PRODUCT_ID 0x2323
36
32#define GSUSB_ENDPOINT_IN 1 37#define GSUSB_ENDPOINT_IN 1
33#define GSUSB_ENDPOINT_OUT 2 38#define GSUSB_ENDPOINT_OUT 2
34 39
@@ -952,6 +957,8 @@ static void gs_usb_disconnect(struct usb_interface *intf)
952static const struct usb_device_id gs_usb_table[] = { 957static const struct usb_device_id gs_usb_table[] = {
953 { USB_DEVICE_INTERFACE_NUMBER(USB_GSUSB_1_VENDOR_ID, 958 { USB_DEVICE_INTERFACE_NUMBER(USB_GSUSB_1_VENDOR_ID,
954 USB_GSUSB_1_PRODUCT_ID, 0) }, 959 USB_GSUSB_1_PRODUCT_ID, 0) },
960 { USB_DEVICE_INTERFACE_NUMBER(USB_CANDLELIGHT_VENDOR_ID,
961 USB_CANDLELIGHT_PRODUCT_ID, 0) },
955 {} /* Terminating entry */ 962 {} /* Terminating entry */
956}; 963};
957 964
@@ -969,5 +976,6 @@ module_usb_driver(gs_usb_driver);
969MODULE_AUTHOR("Maximilian Schneider <mws@schneidersoft.net>"); 976MODULE_AUTHOR("Maximilian Schneider <mws@schneidersoft.net>");
970MODULE_DESCRIPTION( 977MODULE_DESCRIPTION(
971"Socket CAN device driver for Geschwister Schneider Technologie-, " 978"Socket CAN device driver for Geschwister Schneider Technologie-, "
972"Entwicklungs- und Vertriebs UG. USB2.0 to CAN interfaces."); 979"Entwicklungs- und Vertriebs UG. USB2.0 to CAN interfaces\n"
980"and bytewerk.org candleLight USB CAN interfaces.");
973MODULE_LICENSE("GPL v2"); 981MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 022bfa13ebfa..6f1f3b675ff5 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -59,11 +59,14 @@
59#define USB_CAN_R_PRODUCT_ID 39 59#define USB_CAN_R_PRODUCT_ID 39
60#define USB_LEAF_LITE_V2_PRODUCT_ID 288 60#define USB_LEAF_LITE_V2_PRODUCT_ID 288
61#define USB_MINI_PCIE_HS_PRODUCT_ID 289 61#define USB_MINI_PCIE_HS_PRODUCT_ID 289
62#define USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID 290
63#define USB_USBCAN_LIGHT_2HS_PRODUCT_ID 291
64#define USB_MINI_PCIE_2HS_PRODUCT_ID 292
62 65
63static inline bool kvaser_is_leaf(const struct usb_device_id *id) 66static inline bool kvaser_is_leaf(const struct usb_device_id *id)
64{ 67{
65 return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID && 68 return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
66 id->idProduct <= USB_MINI_PCIE_HS_PRODUCT_ID; 69 id->idProduct <= USB_MINI_PCIE_2HS_PRODUCT_ID;
67} 70}
68 71
69/* Kvaser USBCan-II devices */ 72/* Kvaser USBCan-II devices */
@@ -537,6 +540,9 @@ static const struct usb_device_id kvaser_usb_table[] = {
537 .driver_info = KVASER_HAS_TXRX_ERRORS }, 540 .driver_info = KVASER_HAS_TXRX_ERRORS },
538 { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID) }, 541 { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID) },
539 { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID) }, 542 { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID) },
543 { USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID) },
544 { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN_LIGHT_2HS_PRODUCT_ID) },
545 { USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_2HS_PRODUCT_ID) },
540 546
541 /* USBCANII family IDs */ 547 /* USBCANII family IDs */
542 { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN2_PRODUCT_ID), 548 { USB_DEVICE(KVASER_VENDOR_ID, USB_USBCAN2_PRODUCT_ID),
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index e0fb0f1122db..20760e10211a 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -509,8 +509,8 @@ static int au1000_mii_probe(struct net_device *dev)
509 * on the current MAC's MII bus 509 * on the current MAC's MII bus
510 */ 510 */
511 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) 511 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
512 if (mdiobus_get_phy(aup->mii_bus, aup->phy_addr)) { 512 if (mdiobus_get_phy(aup->mii_bus, phy_addr)) {
513 phydev = mdiobus_get_phy(aup->mii_bus, aup->phy_addr); 513 phydev = mdiobus_get_phy(aup->mii_bus, phy_addr);
514 if (!aup->phy_search_highest_addr) 514 if (!aup->phy_search_highest_addr)
515 /* break out with first one found */ 515 /* break out with first one found */
516 break; 516 break;
diff --git a/drivers/net/ethernet/atheros/alx/alx.h b/drivers/net/ethernet/atheros/alx/alx.h
index d02c4240b7df..8fc93c5f6abc 100644
--- a/drivers/net/ethernet/atheros/alx/alx.h
+++ b/drivers/net/ethernet/atheros/alx/alx.h
@@ -96,10 +96,6 @@ struct alx_priv {
96 unsigned int rx_ringsz; 96 unsigned int rx_ringsz;
97 unsigned int rxbuf_size; 97 unsigned int rxbuf_size;
98 98
99 struct page *rx_page;
100 unsigned int rx_page_offset;
101 unsigned int rx_frag_size;
102
103 struct napi_struct napi; 99 struct napi_struct napi;
104 struct alx_tx_queue txq; 100 struct alx_tx_queue txq;
105 struct alx_rx_queue rxq; 101 struct alx_rx_queue rxq;
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index c98acdc0d14f..e708e360a9e3 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -70,35 +70,6 @@ static void alx_free_txbuf(struct alx_priv *alx, int entry)
70 } 70 }
71} 71}
72 72
73static struct sk_buff *alx_alloc_skb(struct alx_priv *alx, gfp_t gfp)
74{
75 struct sk_buff *skb;
76 struct page *page;
77
78 if (alx->rx_frag_size > PAGE_SIZE)
79 return __netdev_alloc_skb(alx->dev, alx->rxbuf_size, gfp);
80
81 page = alx->rx_page;
82 if (!page) {
83 alx->rx_page = page = alloc_page(gfp);
84 if (unlikely(!page))
85 return NULL;
86 alx->rx_page_offset = 0;
87 }
88
89 skb = build_skb(page_address(page) + alx->rx_page_offset,
90 alx->rx_frag_size);
91 if (likely(skb)) {
92 alx->rx_page_offset += alx->rx_frag_size;
93 if (alx->rx_page_offset >= PAGE_SIZE)
94 alx->rx_page = NULL;
95 else
96 get_page(page);
97 }
98 return skb;
99}
100
101
102static int alx_refill_rx_ring(struct alx_priv *alx, gfp_t gfp) 73static int alx_refill_rx_ring(struct alx_priv *alx, gfp_t gfp)
103{ 74{
104 struct alx_rx_queue *rxq = &alx->rxq; 75 struct alx_rx_queue *rxq = &alx->rxq;
@@ -115,9 +86,22 @@ static int alx_refill_rx_ring(struct alx_priv *alx, gfp_t gfp)
115 while (!cur_buf->skb && next != rxq->read_idx) { 86 while (!cur_buf->skb && next != rxq->read_idx) {
116 struct alx_rfd *rfd = &rxq->rfd[cur]; 87 struct alx_rfd *rfd = &rxq->rfd[cur];
117 88
118 skb = alx_alloc_skb(alx, gfp); 89 /*
90 * When DMA RX address is set to something like
91 * 0x....fc0, it will be very likely to cause DMA
92 * RFD overflow issue.
93 *
94 * To work around it, we apply rx skb with 64 bytes
95 * longer space, and offset the address whenever
96 * 0x....fc0 is detected.
97 */
98 skb = __netdev_alloc_skb(alx->dev, alx->rxbuf_size + 64, gfp);
119 if (!skb) 99 if (!skb)
120 break; 100 break;
101
102 if (((unsigned long)skb->data & 0xfff) == 0xfc0)
103 skb_reserve(skb, 64);
104
121 dma = dma_map_single(&alx->hw.pdev->dev, 105 dma = dma_map_single(&alx->hw.pdev->dev,
122 skb->data, alx->rxbuf_size, 106 skb->data, alx->rxbuf_size,
123 DMA_FROM_DEVICE); 107 DMA_FROM_DEVICE);
@@ -153,7 +137,6 @@ static int alx_refill_rx_ring(struct alx_priv *alx, gfp_t gfp)
153 alx_write_mem16(&alx->hw, ALX_RFD_PIDX, cur); 137 alx_write_mem16(&alx->hw, ALX_RFD_PIDX, cur);
154 } 138 }
155 139
156
157 return count; 140 return count;
158} 141}
159 142
@@ -622,11 +605,6 @@ static void alx_free_rings(struct alx_priv *alx)
622 kfree(alx->txq.bufs); 605 kfree(alx->txq.bufs);
623 kfree(alx->rxq.bufs); 606 kfree(alx->rxq.bufs);
624 607
625 if (alx->rx_page) {
626 put_page(alx->rx_page);
627 alx->rx_page = NULL;
628 }
629
630 dma_free_coherent(&alx->hw.pdev->dev, 608 dma_free_coherent(&alx->hw.pdev->dev,
631 alx->descmem.size, 609 alx->descmem.size,
632 alx->descmem.virt, 610 alx->descmem.virt,
@@ -681,7 +659,6 @@ static int alx_request_irq(struct alx_priv *alx)
681 alx->dev->name, alx); 659 alx->dev->name, alx);
682 if (!err) 660 if (!err)
683 goto out; 661 goto out;
684
685 /* fall back to legacy interrupt */ 662 /* fall back to legacy interrupt */
686 pci_disable_msi(alx->hw.pdev); 663 pci_disable_msi(alx->hw.pdev);
687 } 664 }
@@ -725,7 +702,6 @@ static int alx_init_sw(struct alx_priv *alx)
725 struct pci_dev *pdev = alx->hw.pdev; 702 struct pci_dev *pdev = alx->hw.pdev;
726 struct alx_hw *hw = &alx->hw; 703 struct alx_hw *hw = &alx->hw;
727 int err; 704 int err;
728 unsigned int head_size;
729 705
730 err = alx_identify_hw(alx); 706 err = alx_identify_hw(alx);
731 if (err) { 707 if (err) {
@@ -741,12 +717,7 @@ static int alx_init_sw(struct alx_priv *alx)
741 717
742 hw->smb_timer = 400; 718 hw->smb_timer = 400;
743 hw->mtu = alx->dev->mtu; 719 hw->mtu = alx->dev->mtu;
744
745 alx->rxbuf_size = ALX_MAX_FRAME_LEN(hw->mtu); 720 alx->rxbuf_size = ALX_MAX_FRAME_LEN(hw->mtu);
746 head_size = SKB_DATA_ALIGN(alx->rxbuf_size + NET_SKB_PAD) +
747 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
748 alx->rx_frag_size = roundup_pow_of_two(head_size);
749
750 alx->tx_ringsz = 256; 721 alx->tx_ringsz = 256;
751 alx->rx_ringsz = 512; 722 alx->rx_ringsz = 512;
752 hw->imt = 200; 723 hw->imt = 200;
@@ -848,7 +819,6 @@ static int alx_change_mtu(struct net_device *netdev, int mtu)
848{ 819{
849 struct alx_priv *alx = netdev_priv(netdev); 820 struct alx_priv *alx = netdev_priv(netdev);
850 int max_frame = ALX_MAX_FRAME_LEN(mtu); 821 int max_frame = ALX_MAX_FRAME_LEN(mtu);
851 unsigned int head_size;
852 822
853 if ((max_frame < ALX_MIN_FRAME_SIZE) || 823 if ((max_frame < ALX_MIN_FRAME_SIZE) ||
854 (max_frame > ALX_MAX_FRAME_SIZE)) 824 (max_frame > ALX_MAX_FRAME_SIZE))
@@ -860,9 +830,6 @@ static int alx_change_mtu(struct net_device *netdev, int mtu)
860 netdev->mtu = mtu; 830 netdev->mtu = mtu;
861 alx->hw.mtu = mtu; 831 alx->hw.mtu = mtu;
862 alx->rxbuf_size = max(max_frame, ALX_DEF_RXBUF_SIZE); 832 alx->rxbuf_size = max(max_frame, ALX_DEF_RXBUF_SIZE);
863 head_size = SKB_DATA_ALIGN(alx->rxbuf_size + NET_SKB_PAD) +
864 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
865 alx->rx_frag_size = roundup_pow_of_two(head_size);
866 netdev_update_features(netdev); 833 netdev_update_features(netdev);
867 if (netif_running(netdev)) 834 if (netif_running(netdev))
868 alx_reinit(alx); 835 alx_reinit(alx);
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index ee5f431ab32a..a6333d38ecc0 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -267,15 +267,16 @@ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
267 while (ring->start != ring->end) { 267 while (ring->start != ring->end) {
268 int slot_idx = ring->start % BGMAC_TX_RING_SLOTS; 268 int slot_idx = ring->start % BGMAC_TX_RING_SLOTS;
269 struct bgmac_slot_info *slot = &ring->slots[slot_idx]; 269 struct bgmac_slot_info *slot = &ring->slots[slot_idx];
270 u32 ctl1; 270 u32 ctl0, ctl1;
271 int len; 271 int len;
272 272
273 if (slot_idx == empty_slot) 273 if (slot_idx == empty_slot)
274 break; 274 break;
275 275
276 ctl0 = le32_to_cpu(ring->cpu_base[slot_idx].ctl0);
276 ctl1 = le32_to_cpu(ring->cpu_base[slot_idx].ctl1); 277 ctl1 = le32_to_cpu(ring->cpu_base[slot_idx].ctl1);
277 len = ctl1 & BGMAC_DESC_CTL1_LEN; 278 len = ctl1 & BGMAC_DESC_CTL1_LEN;
278 if (ctl1 & BGMAC_DESC_CTL0_SOF) 279 if (ctl0 & BGMAC_DESC_CTL0_SOF)
279 /* Unmap no longer used buffer */ 280 /* Unmap no longer used buffer */
280 dma_unmap_single(dma_dev, slot->dma_addr, len, 281 dma_unmap_single(dma_dev, slot->dma_addr, len,
281 DMA_TO_DEVICE); 282 DMA_TO_DEVICE);
@@ -1312,7 +1313,8 @@ static int bgmac_open(struct net_device *net_dev)
1312 1313
1313 phy_start(bgmac->phy_dev); 1314 phy_start(bgmac->phy_dev);
1314 1315
1315 netif_carrier_on(net_dev); 1316 netif_start_queue(net_dev);
1317
1316 return 0; 1318 return 0;
1317} 1319}
1318 1320
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
index 95f17f8cadac..16ed20357c5c 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -499,6 +499,7 @@ static void nic_tx_channel_cfg(struct nicpf *nic, u8 vnic,
499 u32 rr_quantum; 499 u32 rr_quantum;
500 u8 sq_idx = sq->sq_num; 500 u8 sq_idx = sq->sq_num;
501 u8 pqs_vnic; 501 u8 pqs_vnic;
502 int svf;
502 503
503 if (sq->sqs_mode) 504 if (sq->sqs_mode)
504 pqs_vnic = nic->pqs_vf[vnic]; 505 pqs_vnic = nic->pqs_vf[vnic];
@@ -511,10 +512,19 @@ static void nic_tx_channel_cfg(struct nicpf *nic, u8 vnic,
511 /* 24 bytes for FCS, IPG and preamble */ 512 /* 24 bytes for FCS, IPG and preamble */
512 rr_quantum = ((NIC_HW_MAX_FRS + 24) / 4); 513 rr_quantum = ((NIC_HW_MAX_FRS + 24) / 4);
513 514
514 tl4 = (lmac * NIC_TL4_PER_LMAC) + (bgx * NIC_TL4_PER_BGX); 515 if (!sq->sqs_mode) {
516 tl4 = (lmac * NIC_TL4_PER_LMAC) + (bgx * NIC_TL4_PER_BGX);
517 } else {
518 for (svf = 0; svf < MAX_SQS_PER_VF; svf++) {
519 if (nic->vf_sqs[pqs_vnic][svf] == vnic)
520 break;
521 }
522 tl4 = (MAX_LMAC_PER_BGX * NIC_TL4_PER_LMAC);
523 tl4 += (lmac * NIC_TL4_PER_LMAC * MAX_SQS_PER_VF);
524 tl4 += (svf * NIC_TL4_PER_LMAC);
525 tl4 += (bgx * NIC_TL4_PER_BGX);
526 }
515 tl4 += sq_idx; 527 tl4 += sq_idx;
516 if (sq->sqs_mode)
517 tl4 += vnic * 8;
518 528
519 tl3 = tl4 / (NIC_MAX_TL4 / NIC_MAX_TL3); 529 tl3 = tl4 / (NIC_MAX_TL4 / NIC_MAX_TL3);
520 nic_reg_write(nic, NIC_PF_QSET_0_127_SQ_0_7_CFG2 | 530 nic_reg_write(nic, NIC_PF_QSET_0_127_SQ_0_7_CFG2 |
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 3ed21988626b..63a39ac97d53 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -551,7 +551,9 @@ static int bgx_xaui_check_link(struct lmac *lmac)
551 } 551 }
552 552
553 /* Clear rcvflt bit (latching high) and read it back */ 553 /* Clear rcvflt bit (latching high) and read it back */
554 bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT); 554 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT)
555 bgx_reg_modify(bgx, lmacid,
556 BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT);
555 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { 557 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) {
556 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n"); 558 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n");
557 if (bgx->use_training) { 559 if (bgx->use_training) {
@@ -570,13 +572,6 @@ static int bgx_xaui_check_link(struct lmac *lmac)
570 return -1; 572 return -1;
571 } 573 }
572 574
573 /* Wait for MAC RX to be ready */
574 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_RX_CTL,
575 SMU_RX_CTL_STATUS, true)) {
576 dev_err(&bgx->pdev->dev, "SMU RX link not okay\n");
577 return -1;
578 }
579
580 /* Wait for BGX RX to be idle */ 575 /* Wait for BGX RX to be idle */
581 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) { 576 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) {
582 dev_err(&bgx->pdev->dev, "SMU RX not idle\n"); 577 dev_err(&bgx->pdev->dev, "SMU RX not idle\n");
@@ -589,29 +584,30 @@ static int bgx_xaui_check_link(struct lmac *lmac)
589 return -1; 584 return -1;
590 } 585 }
591 586
592 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { 587 /* Clear receive packet disable */
593 dev_err(&bgx->pdev->dev, "Receive fault\n");
594 return -1;
595 }
596
597 /* Receive link is latching low. Force it high and verify it */
598 bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS1, SPU_STATUS1_RCV_LNK);
599 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_STATUS1,
600 SPU_STATUS1_RCV_LNK, false)) {
601 dev_err(&bgx->pdev->dev, "SPU receive link down\n");
602 return -1;
603 }
604
605 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL); 588 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL);
606 cfg &= ~SPU_MISC_CTL_RX_DIS; 589 cfg &= ~SPU_MISC_CTL_RX_DIS;
607 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg); 590 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg);
608 return 0; 591
592 /* Check for MAC RX faults */
593 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_CTL);
594 /* 0 - Link is okay, 1 - Local fault, 2 - Remote fault */
595 cfg &= SMU_RX_CTL_STATUS;
596 if (!cfg)
597 return 0;
598
599 /* Rx local/remote fault seen.
600 * Do lmac reinit to see if condition recovers
601 */
602 bgx_lmac_xaui_init(bgx, lmacid, bgx->lmac_type);
603
604 return -1;
609} 605}
610 606
611static void bgx_poll_for_link(struct work_struct *work) 607static void bgx_poll_for_link(struct work_struct *work)
612{ 608{
613 struct lmac *lmac; 609 struct lmac *lmac;
614 u64 link; 610 u64 spu_link, smu_link;
615 611
616 lmac = container_of(work, struct lmac, dwork.work); 612 lmac = container_of(work, struct lmac, dwork.work);
617 613
@@ -621,8 +617,11 @@ static void bgx_poll_for_link(struct work_struct *work)
621 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1, 617 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1,
622 SPU_STATUS1_RCV_LNK, false); 618 SPU_STATUS1_RCV_LNK, false);
623 619
624 link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); 620 spu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1);
625 if (link & SPU_STATUS1_RCV_LNK) { 621 smu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SMUX_RX_CTL);
622
623 if ((spu_link & SPU_STATUS1_RCV_LNK) &&
624 !(smu_link & SMU_RX_CTL_STATUS)) {
626 lmac->link_up = 1; 625 lmac->link_up = 1;
627 if (lmac->bgx->lmac_type == BGX_MODE_XLAUI) 626 if (lmac->bgx->lmac_type == BGX_MODE_XLAUI)
628 lmac->last_speed = 40000; 627 lmac->last_speed = 40000;
@@ -636,9 +635,15 @@ static void bgx_poll_for_link(struct work_struct *work)
636 } 635 }
637 636
638 if (lmac->last_link != lmac->link_up) { 637 if (lmac->last_link != lmac->link_up) {
638 if (lmac->link_up) {
639 if (bgx_xaui_check_link(lmac)) {
640 /* Errors, clear link_up state */
641 lmac->link_up = 0;
642 lmac->last_speed = SPEED_UNKNOWN;
643 lmac->last_duplex = DUPLEX_UNKNOWN;
644 }
645 }
639 lmac->last_link = lmac->link_up; 646 lmac->last_link = lmac->link_up;
640 if (lmac->link_up)
641 bgx_xaui_check_link(lmac);
642 } 647 }
643 648
644 queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2); 649 queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2);
@@ -710,7 +715,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
710static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) 715static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
711{ 716{
712 struct lmac *lmac; 717 struct lmac *lmac;
713 u64 cmrx_cfg; 718 u64 cfg;
714 719
715 lmac = &bgx->lmac[lmacid]; 720 lmac = &bgx->lmac[lmacid];
716 if (lmac->check_link) { 721 if (lmac->check_link) {
@@ -719,9 +724,33 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
719 destroy_workqueue(lmac->check_link); 724 destroy_workqueue(lmac->check_link);
720 } 725 }
721 726
722 cmrx_cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); 727 /* Disable packet reception */
723 cmrx_cfg &= ~(1 << 15); 728 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
724 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cmrx_cfg); 729 cfg &= ~CMR_PKT_RX_EN;
730 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
731
732 /* Give chance for Rx/Tx FIFO to get drained */
733 bgx_poll_reg(bgx, lmacid, BGX_CMRX_RX_FIFO_LEN, (u64)0x1FFF, true);
734 bgx_poll_reg(bgx, lmacid, BGX_CMRX_TX_FIFO_LEN, (u64)0x3FFF, true);
735
736 /* Disable packet transmission */
737 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
738 cfg &= ~CMR_PKT_TX_EN;
739 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
740
741 /* Disable serdes lanes */
742 if (!lmac->is_sgmii)
743 bgx_reg_modify(bgx, lmacid,
744 BGX_SPUX_CONTROL1, SPU_CTL_LOW_POWER);
745 else
746 bgx_reg_modify(bgx, lmacid,
747 BGX_GMP_PCS_MRX_CTL, PCS_MRX_CTL_PWR_DN);
748
749 /* Disable LMAC */
750 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
751 cfg &= ~CMR_EN;
752 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
753
725 bgx_flush_dmac_addrs(bgx, lmacid); 754 bgx_flush_dmac_addrs(bgx, lmacid);
726 755
727 if ((bgx->lmac_type != BGX_MODE_XFI) && 756 if ((bgx->lmac_type != BGX_MODE_XFI) &&
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index 149e179363a1..42010d2e5ddf 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -41,6 +41,7 @@
41#define BGX_CMRX_RX_STAT10 0xC0 41#define BGX_CMRX_RX_STAT10 0xC0
42#define BGX_CMRX_RX_BP_DROP 0xC8 42#define BGX_CMRX_RX_BP_DROP 0xC8
43#define BGX_CMRX_RX_DMAC_CTL 0x0E8 43#define BGX_CMRX_RX_DMAC_CTL 0x0E8
44#define BGX_CMRX_RX_FIFO_LEN 0x108
44#define BGX_CMR_RX_DMACX_CAM 0x200 45#define BGX_CMR_RX_DMACX_CAM 0x200
45#define RX_DMACX_CAM_EN BIT_ULL(48) 46#define RX_DMACX_CAM_EN BIT_ULL(48)
46#define RX_DMACX_CAM_LMACID(x) (x << 49) 47#define RX_DMACX_CAM_LMACID(x) (x << 49)
@@ -50,6 +51,7 @@
50#define BGX_CMR_CHAN_MSK_AND 0x450 51#define BGX_CMR_CHAN_MSK_AND 0x450
51#define BGX_CMR_BIST_STATUS 0x460 52#define BGX_CMR_BIST_STATUS 0x460
52#define BGX_CMR_RX_LMACS 0x468 53#define BGX_CMR_RX_LMACS 0x468
54#define BGX_CMRX_TX_FIFO_LEN 0x518
53#define BGX_CMRX_TX_STAT0 0x600 55#define BGX_CMRX_TX_STAT0 0x600
54#define BGX_CMRX_TX_STAT1 0x608 56#define BGX_CMRX_TX_STAT1 0x608
55#define BGX_CMRX_TX_STAT2 0x610 57#define BGX_CMRX_TX_STAT2 0x610
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 864cb21351a4..ecdb6854a898 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2121,7 +2121,7 @@ static void handle_error_info_rsp(union ibmvnic_crq *crq,
2121 struct ibmvnic_adapter *adapter) 2121 struct ibmvnic_adapter *adapter)
2122{ 2122{
2123 struct device *dev = &adapter->vdev->dev; 2123 struct device *dev = &adapter->vdev->dev;
2124 struct ibmvnic_error_buff *error_buff; 2124 struct ibmvnic_error_buff *error_buff, *tmp;
2125 unsigned long flags; 2125 unsigned long flags;
2126 bool found = false; 2126 bool found = false;
2127 int i; 2127 int i;
@@ -2133,7 +2133,7 @@ static void handle_error_info_rsp(union ibmvnic_crq *crq,
2133 } 2133 }
2134 2134
2135 spin_lock_irqsave(&adapter->error_list_lock, flags); 2135 spin_lock_irqsave(&adapter->error_list_lock, flags);
2136 list_for_each_entry(error_buff, &adapter->errors, list) 2136 list_for_each_entry_safe(error_buff, tmp, &adapter->errors, list)
2137 if (error_buff->error_id == crq->request_error_rsp.error_id) { 2137 if (error_buff->error_id == crq->request_error_rsp.error_id) {
2138 found = true; 2138 found = true;
2139 list_del(&error_buff->list); 2139 list_del(&error_buff->list);
@@ -3141,14 +3141,14 @@ static void handle_request_ras_comp_num_rsp(union ibmvnic_crq *crq,
3141 3141
3142static void ibmvnic_free_inflight(struct ibmvnic_adapter *adapter) 3142static void ibmvnic_free_inflight(struct ibmvnic_adapter *adapter)
3143{ 3143{
3144 struct ibmvnic_inflight_cmd *inflight_cmd; 3144 struct ibmvnic_inflight_cmd *inflight_cmd, *tmp1;
3145 struct device *dev = &adapter->vdev->dev; 3145 struct device *dev = &adapter->vdev->dev;
3146 struct ibmvnic_error_buff *error_buff; 3146 struct ibmvnic_error_buff *error_buff, *tmp2;
3147 unsigned long flags; 3147 unsigned long flags;
3148 unsigned long flags2; 3148 unsigned long flags2;
3149 3149
3150 spin_lock_irqsave(&adapter->inflight_lock, flags); 3150 spin_lock_irqsave(&adapter->inflight_lock, flags);
3151 list_for_each_entry(inflight_cmd, &adapter->inflight, list) { 3151 list_for_each_entry_safe(inflight_cmd, tmp1, &adapter->inflight, list) {
3152 switch (inflight_cmd->crq.generic.cmd) { 3152 switch (inflight_cmd->crq.generic.cmd) {
3153 case LOGIN: 3153 case LOGIN:
3154 dma_unmap_single(dev, adapter->login_buf_token, 3154 dma_unmap_single(dev, adapter->login_buf_token,
@@ -3165,8 +3165,8 @@ static void ibmvnic_free_inflight(struct ibmvnic_adapter *adapter)
3165 break; 3165 break;
3166 case REQUEST_ERROR_INFO: 3166 case REQUEST_ERROR_INFO:
3167 spin_lock_irqsave(&adapter->error_list_lock, flags2); 3167 spin_lock_irqsave(&adapter->error_list_lock, flags2);
3168 list_for_each_entry(error_buff, &adapter->errors, 3168 list_for_each_entry_safe(error_buff, tmp2,
3169 list) { 3169 &adapter->errors, list) {
3170 dma_unmap_single(dev, error_buff->dma, 3170 dma_unmap_single(dev, error_buff->dma,
3171 error_buff->len, 3171 error_buff->len,
3172 DMA_FROM_DEVICE); 3172 DMA_FROM_DEVICE);
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 75e60897b7e7..73f745205a1c 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
154 writel(val, hw->hw_addr + reg); 154 writel(val, hw->hw_addr + reg);
155} 155}
156 156
157static bool e1000e_vlan_used(struct e1000_adapter *adapter)
158{
159 u16 vid;
160
161 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
162 return true;
163
164 return false;
165}
166
157/** 167/**
158 * e1000_regdump - register printout routine 168 * e1000_regdump - register printout routine
159 * @hw: pointer to the HW structure 169 * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
2789} 2799}
2790 2800
2791/** 2801/**
2792 * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping 2802 * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
2793 * @adapter: board private structure to initialize 2803 * @adapter: board private structure to initialize
2794 **/ 2804 **/
2795static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter) 2805static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
3443 3453
3444 ew32(RCTL, rctl); 3454 ew32(RCTL, rctl);
3445 3455
3446 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) 3456 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
3457 e1000e_vlan_used(adapter))
3447 e1000e_vlan_strip_enable(adapter); 3458 e1000e_vlan_strip_enable(adapter);
3448 else 3459 else
3449 e1000e_vlan_strip_disable(adapter); 3460 e1000e_vlan_strip_disable(adapter);
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 4763252bbf85..d1cdc2d76151 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -481,20 +481,23 @@ static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd,
481/* the qdma core needs scratch memory to be setup */ 481/* the qdma core needs scratch memory to be setup */
482static int mtk_init_fq_dma(struct mtk_eth *eth) 482static int mtk_init_fq_dma(struct mtk_eth *eth)
483{ 483{
484 dma_addr_t phy_ring_head, phy_ring_tail; 484 dma_addr_t phy_ring_tail;
485 int cnt = MTK_DMA_SIZE; 485 int cnt = MTK_DMA_SIZE;
486 dma_addr_t dma_addr; 486 dma_addr_t dma_addr;
487 int i; 487 int i;
488 488
489 eth->scratch_ring = dma_alloc_coherent(eth->dev, 489 eth->scratch_ring = dma_alloc_coherent(eth->dev,
490 cnt * sizeof(struct mtk_tx_dma), 490 cnt * sizeof(struct mtk_tx_dma),
491 &phy_ring_head, 491 &eth->phy_scratch_ring,
492 GFP_ATOMIC | __GFP_ZERO); 492 GFP_ATOMIC | __GFP_ZERO);
493 if (unlikely(!eth->scratch_ring)) 493 if (unlikely(!eth->scratch_ring))
494 return -ENOMEM; 494 return -ENOMEM;
495 495
496 eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, 496 eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
497 GFP_KERNEL); 497 GFP_KERNEL);
498 if (unlikely(!eth->scratch_head))
499 return -ENOMEM;
500
498 dma_addr = dma_map_single(eth->dev, 501 dma_addr = dma_map_single(eth->dev,
499 eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE, 502 eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
500 DMA_FROM_DEVICE); 503 DMA_FROM_DEVICE);
@@ -502,19 +505,19 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
502 return -ENOMEM; 505 return -ENOMEM;
503 506
504 memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt); 507 memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt);
505 phy_ring_tail = phy_ring_head + 508 phy_ring_tail = eth->phy_scratch_ring +
506 (sizeof(struct mtk_tx_dma) * (cnt - 1)); 509 (sizeof(struct mtk_tx_dma) * (cnt - 1));
507 510
508 for (i = 0; i < cnt; i++) { 511 for (i = 0; i < cnt; i++) {
509 eth->scratch_ring[i].txd1 = 512 eth->scratch_ring[i].txd1 =
510 (dma_addr + (i * MTK_QDMA_PAGE_SIZE)); 513 (dma_addr + (i * MTK_QDMA_PAGE_SIZE));
511 if (i < cnt - 1) 514 if (i < cnt - 1)
512 eth->scratch_ring[i].txd2 = (phy_ring_head + 515 eth->scratch_ring[i].txd2 = (eth->phy_scratch_ring +
513 ((i + 1) * sizeof(struct mtk_tx_dma))); 516 ((i + 1) * sizeof(struct mtk_tx_dma)));
514 eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE); 517 eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE);
515 } 518 }
516 519
517 mtk_w32(eth, phy_ring_head, MTK_QDMA_FQ_HEAD); 520 mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD);
518 mtk_w32(eth, phy_ring_tail, MTK_QDMA_FQ_TAIL); 521 mtk_w32(eth, phy_ring_tail, MTK_QDMA_FQ_TAIL);
519 mtk_w32(eth, (cnt << 16) | cnt, MTK_QDMA_FQ_CNT); 522 mtk_w32(eth, (cnt << 16) | cnt, MTK_QDMA_FQ_CNT);
520 mtk_w32(eth, MTK_QDMA_PAGE_SIZE << 16, MTK_QDMA_FQ_BLEN); 523 mtk_w32(eth, MTK_QDMA_PAGE_SIZE << 16, MTK_QDMA_FQ_BLEN);
@@ -671,7 +674,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
671 674
672err_dma: 675err_dma:
673 do { 676 do {
674 tx_buf = mtk_desc_to_tx_buf(ring, txd); 677 tx_buf = mtk_desc_to_tx_buf(ring, itxd);
675 678
676 /* unmap dma */ 679 /* unmap dma */
677 mtk_tx_unmap(&dev->dev, tx_buf); 680 mtk_tx_unmap(&dev->dev, tx_buf);
@@ -701,6 +704,20 @@ static inline int mtk_cal_txd_req(struct sk_buff *skb)
701 return nfrags; 704 return nfrags;
702} 705}
703 706
707static int mtk_queue_stopped(struct mtk_eth *eth)
708{
709 int i;
710
711 for (i = 0; i < MTK_MAC_COUNT; i++) {
712 if (!eth->netdev[i])
713 continue;
714 if (netif_queue_stopped(eth->netdev[i]))
715 return 1;
716 }
717
718 return 0;
719}
720
704static void mtk_wake_queue(struct mtk_eth *eth) 721static void mtk_wake_queue(struct mtk_eth *eth)
705{ 722{
706 int i; 723 int i;
@@ -766,12 +783,9 @@ static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
766 if (mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) 783 if (mtk_tx_map(skb, dev, tx_num, ring, gso) < 0)
767 goto drop; 784 goto drop;
768 785
769 if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) { 786 if (unlikely(atomic_read(&ring->free_count) <= ring->thresh))
770 mtk_stop_queue(eth); 787 mtk_stop_queue(eth);
771 if (unlikely(atomic_read(&ring->free_count) > 788
772 ring->thresh))
773 mtk_wake_queue(eth);
774 }
775 spin_unlock_irqrestore(&eth->page_lock, flags); 789 spin_unlock_irqrestore(&eth->page_lock, flags);
776 790
777 return NETDEV_TX_OK; 791 return NETDEV_TX_OK;
@@ -826,6 +840,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
826 DMA_FROM_DEVICE); 840 DMA_FROM_DEVICE);
827 if (unlikely(dma_mapping_error(&netdev->dev, dma_addr))) { 841 if (unlikely(dma_mapping_error(&netdev->dev, dma_addr))) {
828 skb_free_frag(new_data); 842 skb_free_frag(new_data);
843 netdev->stats.rx_dropped++;
829 goto release_desc; 844 goto release_desc;
830 } 845 }
831 846
@@ -833,6 +848,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
833 skb = build_skb(data, ring->frag_size); 848 skb = build_skb(data, ring->frag_size);
834 if (unlikely(!skb)) { 849 if (unlikely(!skb)) {
835 put_page(virt_to_head_page(new_data)); 850 put_page(virt_to_head_page(new_data));
851 netdev->stats.rx_dropped++;
836 goto release_desc; 852 goto release_desc;
837 } 853 }
838 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); 854 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
@@ -921,7 +937,6 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
921 } 937 }
922 mtk_tx_unmap(eth->dev, tx_buf); 938 mtk_tx_unmap(eth->dev, tx_buf);
923 939
924 ring->last_free->txd2 = next_cpu;
925 ring->last_free = desc; 940 ring->last_free = desc;
926 atomic_inc(&ring->free_count); 941 atomic_inc(&ring->free_count);
927 942
@@ -946,7 +961,8 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
946 if (!total) 961 if (!total)
947 return 0; 962 return 0;
948 963
949 if (atomic_read(&ring->free_count) > ring->thresh) 964 if (mtk_queue_stopped(eth) &&
965 (atomic_read(&ring->free_count) > ring->thresh))
950 mtk_wake_queue(eth); 966 mtk_wake_queue(eth);
951 967
952 return total; 968 return total;
@@ -1027,9 +1043,8 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
1027 1043
1028 atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); 1044 atomic_set(&ring->free_count, MTK_DMA_SIZE - 2);
1029 ring->next_free = &ring->dma[0]; 1045 ring->next_free = &ring->dma[0];
1030 ring->last_free = &ring->dma[MTK_DMA_SIZE - 2]; 1046 ring->last_free = &ring->dma[MTK_DMA_SIZE - 1];
1031 ring->thresh = max((unsigned long)MTK_DMA_SIZE >> 2, 1047 ring->thresh = MAX_SKB_FRAGS;
1032 MAX_SKB_FRAGS);
1033 1048
1034 /* make sure that all changes to the dma ring are flushed before we 1049 /* make sure that all changes to the dma ring are flushed before we
1035 * continue 1050 * continue
@@ -1207,6 +1222,14 @@ static void mtk_dma_free(struct mtk_eth *eth)
1207 for (i = 0; i < MTK_MAC_COUNT; i++) 1222 for (i = 0; i < MTK_MAC_COUNT; i++)
1208 if (eth->netdev[i]) 1223 if (eth->netdev[i])
1209 netdev_reset_queue(eth->netdev[i]); 1224 netdev_reset_queue(eth->netdev[i]);
1225 if (eth->scratch_ring) {
1226 dma_free_coherent(eth->dev,
1227 MTK_DMA_SIZE * sizeof(struct mtk_tx_dma),
1228 eth->scratch_ring,
1229 eth->phy_scratch_ring);
1230 eth->scratch_ring = NULL;
1231 eth->phy_scratch_ring = 0;
1232 }
1210 mtk_tx_clean(eth); 1233 mtk_tx_clean(eth);
1211 mtk_rx_clean(eth); 1234 mtk_rx_clean(eth);
1212 kfree(eth->scratch_head); 1235 kfree(eth->scratch_head);
@@ -1269,7 +1292,7 @@ static int mtk_start_dma(struct mtk_eth *eth)
1269 mtk_w32(eth, 1292 mtk_w32(eth,
1270 MTK_TX_WB_DDONE | MTK_RX_DMA_EN | MTK_TX_DMA_EN | 1293 MTK_TX_WB_DDONE | MTK_RX_DMA_EN | MTK_TX_DMA_EN |
1271 MTK_RX_2B_OFFSET | MTK_DMA_SIZE_16DWORDS | 1294 MTK_RX_2B_OFFSET | MTK_DMA_SIZE_16DWORDS |
1272 MTK_RX_BT_32DWORDS, 1295 MTK_RX_BT_32DWORDS | MTK_NDP_CO_PRO,
1273 MTK_QDMA_GLO_CFG); 1296 MTK_QDMA_GLO_CFG);
1274 1297
1275 return 0; 1298 return 0;
@@ -1383,7 +1406,7 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
1383 1406
1384 /* disable delay and normal interrupt */ 1407 /* disable delay and normal interrupt */
1385 mtk_w32(eth, 0, MTK_QDMA_DELAY_INT); 1408 mtk_w32(eth, 0, MTK_QDMA_DELAY_INT);
1386 mtk_irq_disable(eth, MTK_TX_DONE_INT | MTK_RX_DONE_INT); 1409 mtk_irq_disable(eth, ~0);
1387 mtk_w32(eth, RST_GL_PSE, MTK_RST_GL); 1410 mtk_w32(eth, RST_GL_PSE, MTK_RST_GL);
1388 mtk_w32(eth, 0, MTK_RST_GL); 1411 mtk_w32(eth, 0, MTK_RST_GL);
1389 1412
@@ -1697,7 +1720,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
1697 mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; 1720 mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET;
1698 1721
1699 SET_NETDEV_DEV(eth->netdev[id], eth->dev); 1722 SET_NETDEV_DEV(eth->netdev[id], eth->dev);
1700 eth->netdev[id]->watchdog_timeo = HZ; 1723 eth->netdev[id]->watchdog_timeo = 5 * HZ;
1701 eth->netdev[id]->netdev_ops = &mtk_netdev_ops; 1724 eth->netdev[id]->netdev_ops = &mtk_netdev_ops;
1702 eth->netdev[id]->base_addr = (unsigned long)eth->base; 1725 eth->netdev[id]->base_addr = (unsigned long)eth->base;
1703 eth->netdev[id]->vlan_features = MTK_HW_FEATURES & 1726 eth->netdev[id]->vlan_features = MTK_HW_FEATURES &
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index eed626d56ea4..a5eb7c62306b 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -91,6 +91,7 @@
91#define MTK_QDMA_GLO_CFG 0x1A04 91#define MTK_QDMA_GLO_CFG 0x1A04
92#define MTK_RX_2B_OFFSET BIT(31) 92#define MTK_RX_2B_OFFSET BIT(31)
93#define MTK_RX_BT_32DWORDS (3 << 11) 93#define MTK_RX_BT_32DWORDS (3 << 11)
94#define MTK_NDP_CO_PRO BIT(10)
94#define MTK_TX_WB_DDONE BIT(6) 95#define MTK_TX_WB_DDONE BIT(6)
95#define MTK_DMA_SIZE_16DWORDS (2 << 4) 96#define MTK_DMA_SIZE_16DWORDS (2 << 4)
96#define MTK_RX_DMA_BUSY BIT(3) 97#define MTK_RX_DMA_BUSY BIT(3)
@@ -357,6 +358,7 @@ struct mtk_rx_ring {
357 * @rx_ring: Pointer to the memore holding info about the RX ring 358 * @rx_ring: Pointer to the memore holding info about the RX ring
358 * @rx_napi: The NAPI struct 359 * @rx_napi: The NAPI struct
359 * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring 360 * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring
361 * @phy_scratch_ring: physical address of scratch_ring
360 * @scratch_head: The scratch memory that scratch_ring points to. 362 * @scratch_head: The scratch memory that scratch_ring points to.
361 * @clk_ethif: The ethif clock 363 * @clk_ethif: The ethif clock
362 * @clk_esw: The switch clock 364 * @clk_esw: The switch clock
@@ -384,6 +386,7 @@ struct mtk_eth {
384 struct mtk_rx_ring rx_ring; 386 struct mtk_rx_ring rx_ring;
385 struct napi_struct rx_napi; 387 struct napi_struct rx_napi;
386 struct mtk_tx_dma *scratch_ring; 388 struct mtk_tx_dma *scratch_ring;
389 dma_addr_t phy_scratch_ring;
387 void *scratch_head; 390 void *scratch_head;
388 struct clk *clk_ethif; 391 struct clk *clk_ethif;
389 struct clk *clk_esw; 392 struct clk *clk_esw;
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e94ca1c3fc7c..f04a423ff79d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2597,7 +2597,6 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
2597 priv->cmd.free_head = 0; 2597 priv->cmd.free_head = 0;
2598 2598
2599 sema_init(&priv->cmd.event_sem, priv->cmd.max_cmds); 2599 sema_init(&priv->cmd.event_sem, priv->cmd.max_cmds);
2600 spin_lock_init(&priv->cmd.context_lock);
2601 2600
2602 for (priv->cmd.token_mask = 1; 2601 for (priv->cmd.token_mask = 1;
2603 priv->cmd.token_mask < priv->cmd.max_cmds; 2602 priv->cmd.token_mask < priv->cmd.max_cmds;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 19ceced6736c..0c0dfd6cdca6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -406,14 +406,18 @@ static int mlx4_en_vlan_rx_add_vid(struct net_device *dev,
406 mutex_lock(&mdev->state_lock); 406 mutex_lock(&mdev->state_lock);
407 if (mdev->device_up && priv->port_up) { 407 if (mdev->device_up && priv->port_up) {
408 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); 408 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
409 if (err) 409 if (err) {
410 en_err(priv, "Failed configuring VLAN filter\n"); 410 en_err(priv, "Failed configuring VLAN filter\n");
411 goto out;
412 }
411 } 413 }
412 if (mlx4_register_vlan(mdev->dev, priv->port, vid, &idx)) 414 err = mlx4_register_vlan(mdev->dev, priv->port, vid, &idx);
413 en_dbg(HW, priv, "failed adding vlan %d\n", vid); 415 if (err)
414 mutex_unlock(&mdev->state_lock); 416 en_dbg(HW, priv, "Failed adding vlan %d\n", vid);
415 417
416 return 0; 418out:
419 mutex_unlock(&mdev->state_lock);
420 return err;
417} 421}
418 422
419static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev, 423static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
@@ -421,7 +425,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
421{ 425{
422 struct mlx4_en_priv *priv = netdev_priv(dev); 426 struct mlx4_en_priv *priv = netdev_priv(dev);
423 struct mlx4_en_dev *mdev = priv->mdev; 427 struct mlx4_en_dev *mdev = priv->mdev;
424 int err; 428 int err = 0;
425 429
426 en_dbg(HW, priv, "Killing VID:%d\n", vid); 430 en_dbg(HW, priv, "Killing VID:%d\n", vid);
427 431
@@ -438,7 +442,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
438 } 442 }
439 mutex_unlock(&mdev->state_lock); 443 mutex_unlock(&mdev->state_lock);
440 444
441 return 0; 445 return err;
442} 446}
443 447
444static void mlx4_en_u64_to_mac(unsigned char dst_mac[ETH_ALEN + 2], u64 src_mac) 448static void mlx4_en_u64_to_mac(unsigned char dst_mac[ETH_ALEN + 2], u64 src_mac)
@@ -2032,11 +2036,20 @@ err:
2032 return -ENOMEM; 2036 return -ENOMEM;
2033} 2037}
2034 2038
2039static void mlx4_en_shutdown(struct net_device *dev)
2040{
2041 rtnl_lock();
2042 netif_device_detach(dev);
2043 mlx4_en_close(dev);
2044 rtnl_unlock();
2045}
2035 2046
2036void mlx4_en_destroy_netdev(struct net_device *dev) 2047void mlx4_en_destroy_netdev(struct net_device *dev)
2037{ 2048{
2038 struct mlx4_en_priv *priv = netdev_priv(dev); 2049 struct mlx4_en_priv *priv = netdev_priv(dev);
2039 struct mlx4_en_dev *mdev = priv->mdev; 2050 struct mlx4_en_dev *mdev = priv->mdev;
2051 bool shutdown = mdev->dev->persist->interface_state &
2052 MLX4_INTERFACE_STATE_SHUTDOWN;
2040 2053
2041 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); 2054 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
2042 2055
@@ -2044,7 +2057,10 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2044 if (priv->registered) { 2057 if (priv->registered) {
2045 devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, 2058 devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
2046 priv->port)); 2059 priv->port));
2047 unregister_netdev(dev); 2060 if (shutdown)
2061 mlx4_en_shutdown(dev);
2062 else
2063 unregister_netdev(dev);
2048 } 2064 }
2049 2065
2050 if (priv->allocated) 2066 if (priv->allocated)
@@ -2069,7 +2085,8 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2069 kfree(priv->tx_ring); 2085 kfree(priv->tx_ring);
2070 kfree(priv->tx_cq); 2086 kfree(priv->tx_cq);
2071 2087
2072 free_netdev(dev); 2088 if (!shutdown)
2089 free_netdev(dev);
2073} 2090}
2074 2091
2075static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) 2092static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
@@ -2447,9 +2464,14 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
2447 * strip that feature if this is an IPv6 encapsulated frame. 2464 * strip that feature if this is an IPv6 encapsulated frame.
2448 */ 2465 */
2449 if (skb->encapsulation && 2466 if (skb->encapsulation &&
2450 (skb->ip_summed == CHECKSUM_PARTIAL) && 2467 (skb->ip_summed == CHECKSUM_PARTIAL)) {
2451 (ip_hdr(skb)->version != 4)) 2468 struct mlx4_en_priv *priv = netdev_priv(dev);
2452 features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 2469
2470 if (!priv->vxlan_port ||
2471 (ip_hdr(skb)->version != 4) ||
2472 (udp_hdr(skb)->dest != priv->vxlan_port))
2473 features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
2474 }
2453 2475
2454 return features; 2476 return features;
2455} 2477}
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 12c77a70abdb..546fab0ecc3b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3222,6 +3222,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
3222 3222
3223 INIT_LIST_HEAD(&priv->pgdir_list); 3223 INIT_LIST_HEAD(&priv->pgdir_list);
3224 mutex_init(&priv->pgdir_mutex); 3224 mutex_init(&priv->pgdir_mutex);
3225 spin_lock_init(&priv->cmd.context_lock);
3225 3226
3226 INIT_LIST_HEAD(&priv->bf_list); 3227 INIT_LIST_HEAD(&priv->bf_list);
3227 mutex_init(&priv->bf_mutex); 3228 mutex_init(&priv->bf_mutex);
@@ -4134,8 +4135,11 @@ static void mlx4_shutdown(struct pci_dev *pdev)
4134 4135
4135 mlx4_info(persist->dev, "mlx4_shutdown was called\n"); 4136 mlx4_info(persist->dev, "mlx4_shutdown was called\n");
4136 mutex_lock(&persist->interface_state_mutex); 4137 mutex_lock(&persist->interface_state_mutex);
4137 if (persist->interface_state & MLX4_INTERFACE_STATE_UP) 4138 if (persist->interface_state & MLX4_INTERFACE_STATE_UP) {
4139 /* Notify mlx4 clients that the kernel is being shut down */
4140 persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN;
4138 mlx4_unload_one(pdev); 4141 mlx4_unload_one(pdev);
4142 }
4139 mutex_unlock(&persist->interface_state_mutex); 4143 mutex_unlock(&persist->interface_state_mutex);
4140} 4144}
4141 4145
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index dcd2df6518de..0b4986268cc9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -545,6 +545,7 @@ const char *mlx5_command_str(int command)
545 MLX5_COMMAND_STR_CASE(ALLOC_FLOW_COUNTER); 545 MLX5_COMMAND_STR_CASE(ALLOC_FLOW_COUNTER);
546 MLX5_COMMAND_STR_CASE(DEALLOC_FLOW_COUNTER); 546 MLX5_COMMAND_STR_CASE(DEALLOC_FLOW_COUNTER);
547 MLX5_COMMAND_STR_CASE(QUERY_FLOW_COUNTER); 547 MLX5_COMMAND_STR_CASE(QUERY_FLOW_COUNTER);
548 MLX5_COMMAND_STR_CASE(MODIFY_FLOW_TABLE);
548 default: return "unknown command opcode"; 549 default: return "unknown command opcode";
549 } 550 }
550} 551}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index e8a6c3325b39..baa991a23475 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -401,7 +401,7 @@ enum mlx5e_traffic_types {
401}; 401};
402 402
403enum { 403enum {
404 MLX5E_STATE_ASYNC_EVENTS_ENABLE, 404 MLX5E_STATE_ASYNC_EVENTS_ENABLED,
405 MLX5E_STATE_OPENED, 405 MLX5E_STATE_OPENED,
406 MLX5E_STATE_DESTROYING, 406 MLX5E_STATE_DESTROYING,
407}; 407};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index fc7dcc03b1de..e667a870e0c2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -184,7 +184,9 @@ static unsigned long mlx5e_query_pfc_combined(struct mlx5e_priv *priv)
184#define MLX5E_NUM_SQ_STATS(priv) \ 184#define MLX5E_NUM_SQ_STATS(priv) \
185 (NUM_SQ_STATS * priv->params.num_channels * priv->params.num_tc * \ 185 (NUM_SQ_STATS * priv->params.num_channels * priv->params.num_tc * \
186 test_bit(MLX5E_STATE_OPENED, &priv->state)) 186 test_bit(MLX5E_STATE_OPENED, &priv->state))
187#define MLX5E_NUM_PFC_COUNTERS(priv) hweight8(mlx5e_query_pfc_combined(priv)) 187#define MLX5E_NUM_PFC_COUNTERS(priv) \
188 (hweight8(mlx5e_query_pfc_combined(priv)) * \
189 NUM_PPORT_PER_PRIO_PFC_COUNTERS)
188 190
189static int mlx5e_get_sset_count(struct net_device *dev, int sset) 191static int mlx5e_get_sset_count(struct net_device *dev, int sset)
190{ 192{
@@ -211,42 +213,41 @@ static void mlx5e_fill_stats_strings(struct mlx5e_priv *priv, uint8_t *data)
211 213
212 /* SW counters */ 214 /* SW counters */
213 for (i = 0; i < NUM_SW_COUNTERS; i++) 215 for (i = 0; i < NUM_SW_COUNTERS; i++)
214 strcpy(data + (idx++) * ETH_GSTRING_LEN, sw_stats_desc[i].name); 216 strcpy(data + (idx++) * ETH_GSTRING_LEN, sw_stats_desc[i].format);
215 217
216 /* Q counters */ 218 /* Q counters */
217 for (i = 0; i < MLX5E_NUM_Q_CNTRS(priv); i++) 219 for (i = 0; i < MLX5E_NUM_Q_CNTRS(priv); i++)
218 strcpy(data + (idx++) * ETH_GSTRING_LEN, q_stats_desc[i].name); 220 strcpy(data + (idx++) * ETH_GSTRING_LEN, q_stats_desc[i].format);
219 221
220 /* VPORT counters */ 222 /* VPORT counters */
221 for (i = 0; i < NUM_VPORT_COUNTERS; i++) 223 for (i = 0; i < NUM_VPORT_COUNTERS; i++)
222 strcpy(data + (idx++) * ETH_GSTRING_LEN, 224 strcpy(data + (idx++) * ETH_GSTRING_LEN,
223 vport_stats_desc[i].name); 225 vport_stats_desc[i].format);
224 226
225 /* PPORT counters */ 227 /* PPORT counters */
226 for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++) 228 for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++)
227 strcpy(data + (idx++) * ETH_GSTRING_LEN, 229 strcpy(data + (idx++) * ETH_GSTRING_LEN,
228 pport_802_3_stats_desc[i].name); 230 pport_802_3_stats_desc[i].format);
229 231
230 for (i = 0; i < NUM_PPORT_2863_COUNTERS; i++) 232 for (i = 0; i < NUM_PPORT_2863_COUNTERS; i++)
231 strcpy(data + (idx++) * ETH_GSTRING_LEN, 233 strcpy(data + (idx++) * ETH_GSTRING_LEN,
232 pport_2863_stats_desc[i].name); 234 pport_2863_stats_desc[i].format);
233 235
234 for (i = 0; i < NUM_PPORT_2819_COUNTERS; i++) 236 for (i = 0; i < NUM_PPORT_2819_COUNTERS; i++)
235 strcpy(data + (idx++) * ETH_GSTRING_LEN, 237 strcpy(data + (idx++) * ETH_GSTRING_LEN,
236 pport_2819_stats_desc[i].name); 238 pport_2819_stats_desc[i].format);
237 239
238 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { 240 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
239 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) 241 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
240 sprintf(data + (idx++) * ETH_GSTRING_LEN, "prio%d_%s", 242 sprintf(data + (idx++) * ETH_GSTRING_LEN,
241 prio, 243 pport_per_prio_traffic_stats_desc[i].format, prio);
242 pport_per_prio_traffic_stats_desc[i].name);
243 } 244 }
244 245
245 pfc_combined = mlx5e_query_pfc_combined(priv); 246 pfc_combined = mlx5e_query_pfc_combined(priv);
246 for_each_set_bit(prio, &pfc_combined, NUM_PPORT_PRIO) { 247 for_each_set_bit(prio, &pfc_combined, NUM_PPORT_PRIO) {
247 for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) { 248 for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) {
248 sprintf(data + (idx++) * ETH_GSTRING_LEN, "prio%d_%s", 249 sprintf(data + (idx++) * ETH_GSTRING_LEN,
249 prio, pport_per_prio_pfc_stats_desc[i].name); 250 pport_per_prio_pfc_stats_desc[i].format, prio);
250 } 251 }
251 } 252 }
252 253
@@ -256,16 +257,15 @@ static void mlx5e_fill_stats_strings(struct mlx5e_priv *priv, uint8_t *data)
256 /* per channel counters */ 257 /* per channel counters */
257 for (i = 0; i < priv->params.num_channels; i++) 258 for (i = 0; i < priv->params.num_channels; i++)
258 for (j = 0; j < NUM_RQ_STATS; j++) 259 for (j = 0; j < NUM_RQ_STATS; j++)
259 sprintf(data + (idx++) * ETH_GSTRING_LEN, "rx%d_%s", i, 260 sprintf(data + (idx++) * ETH_GSTRING_LEN,
260 rq_stats_desc[j].name); 261 rq_stats_desc[j].format, i);
261 262
262 for (tc = 0; tc < priv->params.num_tc; tc++) 263 for (tc = 0; tc < priv->params.num_tc; tc++)
263 for (i = 0; i < priv->params.num_channels; i++) 264 for (i = 0; i < priv->params.num_channels; i++)
264 for (j = 0; j < NUM_SQ_STATS; j++) 265 for (j = 0; j < NUM_SQ_STATS; j++)
265 sprintf(data + (idx++) * ETH_GSTRING_LEN, 266 sprintf(data + (idx++) * ETH_GSTRING_LEN,
266 "tx%d_%s", 267 sq_stats_desc[j].format,
267 priv->channeltc_to_txq_map[i][tc], 268 priv->channeltc_to_txq_map[i][tc]);
268 sq_stats_desc[j].name);
269} 269}
270 270
271static void mlx5e_get_strings(struct net_device *dev, 271static void mlx5e_get_strings(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f5c8d5db25a8..cb6defd71fc1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -105,11 +105,11 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
105 105
106 s->rx_packets += rq_stats->packets; 106 s->rx_packets += rq_stats->packets;
107 s->rx_bytes += rq_stats->bytes; 107 s->rx_bytes += rq_stats->bytes;
108 s->lro_packets += rq_stats->lro_packets; 108 s->rx_lro_packets += rq_stats->lro_packets;
109 s->lro_bytes += rq_stats->lro_bytes; 109 s->rx_lro_bytes += rq_stats->lro_bytes;
110 s->rx_csum_none += rq_stats->csum_none; 110 s->rx_csum_none += rq_stats->csum_none;
111 s->rx_csum_sw += rq_stats->csum_sw; 111 s->rx_csum_complete += rq_stats->csum_complete;
112 s->rx_csum_inner += rq_stats->csum_inner; 112 s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;
113 s->rx_wqe_err += rq_stats->wqe_err; 113 s->rx_wqe_err += rq_stats->wqe_err;
114 s->rx_mpwqe_filler += rq_stats->mpwqe_filler; 114 s->rx_mpwqe_filler += rq_stats->mpwqe_filler;
115 s->rx_mpwqe_frag += rq_stats->mpwqe_frag; 115 s->rx_mpwqe_frag += rq_stats->mpwqe_frag;
@@ -122,24 +122,23 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
122 122
123 s->tx_packets += sq_stats->packets; 123 s->tx_packets += sq_stats->packets;
124 s->tx_bytes += sq_stats->bytes; 124 s->tx_bytes += sq_stats->bytes;
125 s->tso_packets += sq_stats->tso_packets; 125 s->tx_tso_packets += sq_stats->tso_packets;
126 s->tso_bytes += sq_stats->tso_bytes; 126 s->tx_tso_bytes += sq_stats->tso_bytes;
127 s->tso_inner_packets += sq_stats->tso_inner_packets; 127 s->tx_tso_inner_packets += sq_stats->tso_inner_packets;
128 s->tso_inner_bytes += sq_stats->tso_inner_bytes; 128 s->tx_tso_inner_bytes += sq_stats->tso_inner_bytes;
129 s->tx_queue_stopped += sq_stats->stopped; 129 s->tx_queue_stopped += sq_stats->stopped;
130 s->tx_queue_wake += sq_stats->wake; 130 s->tx_queue_wake += sq_stats->wake;
131 s->tx_queue_dropped += sq_stats->dropped; 131 s->tx_queue_dropped += sq_stats->dropped;
132 s->tx_csum_inner += sq_stats->csum_offload_inner; 132 s->tx_csum_partial_inner += sq_stats->csum_partial_inner;
133 tx_offload_none += sq_stats->csum_offload_none; 133 tx_offload_none += sq_stats->csum_none;
134 } 134 }
135 } 135 }
136 136
137 /* Update calculated offload counters */ 137 /* Update calculated offload counters */
138 s->tx_csum_offload = s->tx_packets - tx_offload_none - s->tx_csum_inner; 138 s->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;
139 s->rx_csum_good = s->rx_packets - s->rx_csum_none - 139 s->rx_csum_unnecessary = s->rx_packets - s->rx_csum_none - s->rx_csum_complete;
140 s->rx_csum_sw;
141 140
142 s->link_down_events = MLX5_GET(ppcnt_reg, 141 s->link_down_events_phy = MLX5_GET(ppcnt_reg,
143 priv->stats.pport.phy_counters, 142 priv->stats.pport.phy_counters,
144 counter_set.phys_layer_cntrs.link_down_events); 143 counter_set.phys_layer_cntrs.link_down_events);
145} 144}
@@ -244,7 +243,7 @@ static void mlx5e_async_event(struct mlx5_core_dev *mdev, void *vpriv,
244{ 243{
245 struct mlx5e_priv *priv = vpriv; 244 struct mlx5e_priv *priv = vpriv;
246 245
247 if (!test_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLE, &priv->state)) 246 if (!test_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state))
248 return; 247 return;
249 248
250 switch (event) { 249 switch (event) {
@@ -260,12 +259,12 @@ static void mlx5e_async_event(struct mlx5_core_dev *mdev, void *vpriv,
260 259
261static void mlx5e_enable_async_events(struct mlx5e_priv *priv) 260static void mlx5e_enable_async_events(struct mlx5e_priv *priv)
262{ 261{
263 set_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLE, &priv->state); 262 set_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state);
264} 263}
265 264
266static void mlx5e_disable_async_events(struct mlx5e_priv *priv) 265static void mlx5e_disable_async_events(struct mlx5e_priv *priv)
267{ 266{
268 clear_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLE, &priv->state); 267 clear_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state);
269 synchronize_irq(mlx5_get_msix_vec(priv->mdev, MLX5_EQ_VEC_ASYNC)); 268 synchronize_irq(mlx5_get_msix_vec(priv->mdev, MLX5_EQ_VEC_ASYNC));
270} 269}
271 270
@@ -580,7 +579,7 @@ static int mlx5e_create_sq(struct mlx5e_channel *c,
580 void *sqc_wq = MLX5_ADDR_OF(sqc, sqc, wq); 579 void *sqc_wq = MLX5_ADDR_OF(sqc, sqc, wq);
581 int err; 580 int err;
582 581
583 err = mlx5_alloc_map_uar(mdev, &sq->uar, true); 582 err = mlx5_alloc_map_uar(mdev, &sq->uar, !!MLX5_CAP_GEN(mdev, bf));
584 if (err) 583 if (err)
585 return err; 584 return err;
586 585
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index bd947704b59c..022acc2e8922 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -689,7 +689,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
689 if (is_first_ethertype_ip(skb)) { 689 if (is_first_ethertype_ip(skb)) {
690 skb->ip_summed = CHECKSUM_COMPLETE; 690 skb->ip_summed = CHECKSUM_COMPLETE;
691 skb->csum = csum_unfold((__force __sum16)cqe->check_sum); 691 skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
692 rq->stats.csum_sw++; 692 rq->stats.csum_complete++;
693 return; 693 return;
694 } 694 }
695 695
@@ -699,7 +699,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
699 if (cqe_is_tunneled(cqe)) { 699 if (cqe_is_tunneled(cqe)) {
700 skb->csum_level = 1; 700 skb->csum_level = 1;
701 skb->encapsulation = 1; 701 skb->encapsulation = 1;
702 rq->stats.csum_inner++; 702 rq->stats.csum_unnecessary_inner++;
703 } 703 }
704 return; 704 return;
705 } 705 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 83bc32b25849..fcd490cc5610 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -42,9 +42,11 @@
42 be64_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset)) 42 be64_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
43 43
44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld) 44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld)
46#define MLX5E_DECLARE_TX_STAT(type, fld) "tx%d_"#fld, offsetof(type, fld)
45 47
46struct counter_desc { 48struct counter_desc {
47 char name[ETH_GSTRING_LEN]; 49 char format[ETH_GSTRING_LEN];
48 int offset; /* Byte offset */ 50 int offset; /* Byte offset */
49}; 51};
50 52
@@ -53,18 +55,18 @@ struct mlx5e_sw_stats {
53 u64 rx_bytes; 55 u64 rx_bytes;
54 u64 tx_packets; 56 u64 tx_packets;
55 u64 tx_bytes; 57 u64 tx_bytes;
56 u64 tso_packets; 58 u64 tx_tso_packets;
57 u64 tso_bytes; 59 u64 tx_tso_bytes;
58 u64 tso_inner_packets; 60 u64 tx_tso_inner_packets;
59 u64 tso_inner_bytes; 61 u64 tx_tso_inner_bytes;
60 u64 lro_packets; 62 u64 rx_lro_packets;
61 u64 lro_bytes; 63 u64 rx_lro_bytes;
62 u64 rx_csum_good; 64 u64 rx_csum_unnecessary;
63 u64 rx_csum_none; 65 u64 rx_csum_none;
64 u64 rx_csum_sw; 66 u64 rx_csum_complete;
65 u64 rx_csum_inner; 67 u64 rx_csum_unnecessary_inner;
66 u64 tx_csum_offload; 68 u64 tx_csum_partial;
67 u64 tx_csum_inner; 69 u64 tx_csum_partial_inner;
68 u64 tx_queue_stopped; 70 u64 tx_queue_stopped;
69 u64 tx_queue_wake; 71 u64 tx_queue_wake;
70 u64 tx_queue_dropped; 72 u64 tx_queue_dropped;
@@ -76,7 +78,7 @@ struct mlx5e_sw_stats {
76 u64 rx_cqe_compress_pkts; 78 u64 rx_cqe_compress_pkts;
77 79
78 /* Special handling counters */ 80 /* Special handling counters */
79 u64 link_down_events; 81 u64 link_down_events_phy;
80}; 82};
81 83
82static const struct counter_desc sw_stats_desc[] = { 84static const struct counter_desc sw_stats_desc[] = {
@@ -84,18 +86,18 @@ static const struct counter_desc sw_stats_desc[] = {
84 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) }, 86 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) },
85 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) }, 87 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) },
86 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) }, 88 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) },
87 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_packets) }, 89 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_packets) },
88 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_bytes) }, 90 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_bytes) },
89 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_inner_packets) }, 91 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_packets) },
90 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_inner_bytes) }, 92 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_bytes) },
91 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, lro_packets) }, 93 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) },
92 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, lro_bytes) }, 94 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_bytes) },
93 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_good) }, 95 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) },
94 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) }, 96 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) },
95 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_sw) }, 97 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) },
96 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_inner) }, 98 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) },
97 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_offload) }, 99 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) },
98 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_inner) }, 100 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) },
99 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 101 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },
100 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, 102 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) },
101 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, 103 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) },
@@ -105,7 +107,7 @@ static const struct counter_desc sw_stats_desc[] = {
105 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_buff_alloc_err) }, 107 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_buff_alloc_err) },
106 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_blks) }, 108 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_blks) },
107 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_pkts) }, 109 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_pkts) },
108 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, link_down_events) }, 110 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, link_down_events_phy) },
109}; 111};
110 112
111struct mlx5e_qcounter_stats { 113struct mlx5e_qcounter_stats {
@@ -125,12 +127,6 @@ struct mlx5e_vport_stats {
125}; 127};
126 128
127static const struct counter_desc vport_stats_desc[] = { 129static const struct counter_desc vport_stats_desc[] = {
128 { "rx_vport_error_packets",
129 VPORT_COUNTER_OFF(received_errors.packets) },
130 { "rx_vport_error_bytes", VPORT_COUNTER_OFF(received_errors.octets) },
131 { "tx_vport_error_packets",
132 VPORT_COUNTER_OFF(transmit_errors.packets) },
133 { "tx_vport_error_bytes", VPORT_COUNTER_OFF(transmit_errors.octets) },
134 { "rx_vport_unicast_packets", 130 { "rx_vport_unicast_packets",
135 VPORT_COUNTER_OFF(received_eth_unicast.packets) }, 131 VPORT_COUNTER_OFF(received_eth_unicast.packets) },
136 { "rx_vport_unicast_bytes", 132 { "rx_vport_unicast_bytes",
@@ -192,94 +188,68 @@ struct mlx5e_pport_stats {
192}; 188};
193 189
194static const struct counter_desc pport_802_3_stats_desc[] = { 190static const struct counter_desc pport_802_3_stats_desc[] = {
195 { "frames_tx", PPORT_802_3_OFF(a_frames_transmitted_ok) }, 191 { "tx_packets_phy", PPORT_802_3_OFF(a_frames_transmitted_ok) },
196 { "frames_rx", PPORT_802_3_OFF(a_frames_received_ok) }, 192 { "rx_packets_phy", PPORT_802_3_OFF(a_frames_received_ok) },
197 { "check_seq_err", PPORT_802_3_OFF(a_frame_check_sequence_errors) }, 193 { "rx_crc_errors_phy", PPORT_802_3_OFF(a_frame_check_sequence_errors) },
198 { "alignment_err", PPORT_802_3_OFF(a_alignment_errors) }, 194 { "tx_bytes_phy", PPORT_802_3_OFF(a_octets_transmitted_ok) },
199 { "octets_tx", PPORT_802_3_OFF(a_octets_transmitted_ok) }, 195 { "rx_bytes_phy", PPORT_802_3_OFF(a_octets_received_ok) },
200 { "octets_received", PPORT_802_3_OFF(a_octets_received_ok) }, 196 { "tx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_xmitted_ok) },
201 { "multicast_xmitted", PPORT_802_3_OFF(a_multicast_frames_xmitted_ok) }, 197 { "tx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_xmitted_ok) },
202 { "broadcast_xmitted", PPORT_802_3_OFF(a_broadcast_frames_xmitted_ok) }, 198 { "rx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_received_ok) },
203 { "multicast_rx", PPORT_802_3_OFF(a_multicast_frames_received_ok) }, 199 { "rx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_received_ok) },
204 { "broadcast_rx", PPORT_802_3_OFF(a_broadcast_frames_received_ok) }, 200 { "rx_in_range_len_errors_phy", PPORT_802_3_OFF(a_in_range_length_errors) },
205 { "in_range_len_errors", PPORT_802_3_OFF(a_in_range_length_errors) }, 201 { "rx_out_of_range_len_phy", PPORT_802_3_OFF(a_out_of_range_length_field) },
206 { "out_of_range_len", PPORT_802_3_OFF(a_out_of_range_length_field) }, 202 { "rx_oversize_pkts_phy", PPORT_802_3_OFF(a_frame_too_long_errors) },
207 { "too_long_errors", PPORT_802_3_OFF(a_frame_too_long_errors) }, 203 { "rx_symbol_err_phy", PPORT_802_3_OFF(a_symbol_error_during_carrier) },
208 { "symbol_err", PPORT_802_3_OFF(a_symbol_error_during_carrier) }, 204 { "tx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_transmitted) },
209 { "mac_control_tx", PPORT_802_3_OFF(a_mac_control_frames_transmitted) }, 205 { "rx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_received) },
210 { "mac_control_rx", PPORT_802_3_OFF(a_mac_control_frames_received) }, 206 { "rx_unsupported_op_phy", PPORT_802_3_OFF(a_unsupported_opcodes_received) },
211 { "unsupported_op_rx", 207 { "rx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_received) },
212 PPORT_802_3_OFF(a_unsupported_opcodes_received) }, 208 { "tx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_transmitted) },
213 { "pause_ctrl_rx", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_received) },
214 { "pause_ctrl_tx",
215 PPORT_802_3_OFF(a_pause_mac_ctrl_frames_transmitted) },
216}; 209};
217 210
218static const struct counter_desc pport_2863_stats_desc[] = { 211static const struct counter_desc pport_2863_stats_desc[] = {
219 { "in_octets", PPORT_2863_OFF(if_in_octets) }, 212 { "rx_discards_phy", PPORT_2863_OFF(if_in_discards) },
220 { "in_ucast_pkts", PPORT_2863_OFF(if_in_ucast_pkts) }, 213 { "tx_discards_phy", PPORT_2863_OFF(if_out_discards) },
221 { "in_discards", PPORT_2863_OFF(if_in_discards) }, 214 { "tx_errors_phy", PPORT_2863_OFF(if_out_errors) },
222 { "in_errors", PPORT_2863_OFF(if_in_errors) },
223 { "in_unknown_protos", PPORT_2863_OFF(if_in_unknown_protos) },
224 { "out_octets", PPORT_2863_OFF(if_out_octets) },
225 { "out_ucast_pkts", PPORT_2863_OFF(if_out_ucast_pkts) },
226 { "out_discards", PPORT_2863_OFF(if_out_discards) },
227 { "out_errors", PPORT_2863_OFF(if_out_errors) },
228 { "in_multicast_pkts", PPORT_2863_OFF(if_in_multicast_pkts) },
229 { "in_broadcast_pkts", PPORT_2863_OFF(if_in_broadcast_pkts) },
230 { "out_multicast_pkts", PPORT_2863_OFF(if_out_multicast_pkts) },
231 { "out_broadcast_pkts", PPORT_2863_OFF(if_out_broadcast_pkts) },
232}; 215};
233 216
234static const struct counter_desc pport_2819_stats_desc[] = { 217static const struct counter_desc pport_2819_stats_desc[] = {
235 { "drop_events", PPORT_2819_OFF(ether_stats_drop_events) }, 218 { "rx_undersize_pkts_phy", PPORT_2819_OFF(ether_stats_undersize_pkts) },
236 { "octets", PPORT_2819_OFF(ether_stats_octets) }, 219 { "rx_fragments_phy", PPORT_2819_OFF(ether_stats_fragments) },
237 { "pkts", PPORT_2819_OFF(ether_stats_pkts) }, 220 { "rx_jabbers_phy", PPORT_2819_OFF(ether_stats_jabbers) },
238 { "broadcast_pkts", PPORT_2819_OFF(ether_stats_broadcast_pkts) }, 221 { "rx_64_bytes_phy", PPORT_2819_OFF(ether_stats_pkts64octets) },
239 { "multicast_pkts", PPORT_2819_OFF(ether_stats_multicast_pkts) }, 222 { "rx_65_to_127_bytes_phy", PPORT_2819_OFF(ether_stats_pkts65to127octets) },
240 { "crc_align_errors", PPORT_2819_OFF(ether_stats_crc_align_errors) }, 223 { "rx_128_to_255_bytes_phy", PPORT_2819_OFF(ether_stats_pkts128to255octets) },
241 { "undersize_pkts", PPORT_2819_OFF(ether_stats_undersize_pkts) }, 224 { "rx_256_to_511_bytes_phy", PPORT_2819_OFF(ether_stats_pkts256to511octets) },
242 { "oversize_pkts", PPORT_2819_OFF(ether_stats_oversize_pkts) }, 225 { "rx_512_to_1023_bytes_phy", PPORT_2819_OFF(ether_stats_pkts512to1023octets) },
243 { "fragments", PPORT_2819_OFF(ether_stats_fragments) }, 226 { "rx_1024_to_1518_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1024to1518octets) },
244 { "jabbers", PPORT_2819_OFF(ether_stats_jabbers) }, 227 { "rx_1519_to_2047_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1519to2047octets) },
245 { "collisions", PPORT_2819_OFF(ether_stats_collisions) }, 228 { "rx_2048_to_4095_bytes_phy", PPORT_2819_OFF(ether_stats_pkts2048to4095octets) },
246 { "p64octets", PPORT_2819_OFF(ether_stats_pkts64octets) }, 229 { "rx_4096_to_8191_bytes_phy", PPORT_2819_OFF(ether_stats_pkts4096to8191octets) },
247 { "p65to127octets", PPORT_2819_OFF(ether_stats_pkts65to127octets) }, 230 { "rx_8192_to_10239_bytes_phy", PPORT_2819_OFF(ether_stats_pkts8192to10239octets) },
248 { "p128to255octets", PPORT_2819_OFF(ether_stats_pkts128to255octets) },
249 { "p256to511octets", PPORT_2819_OFF(ether_stats_pkts256to511octets) },
250 { "p512to1023octets", PPORT_2819_OFF(ether_stats_pkts512to1023octets) },
251 { "p1024to1518octets",
252 PPORT_2819_OFF(ether_stats_pkts1024to1518octets) },
253 { "p1519to2047octets",
254 PPORT_2819_OFF(ether_stats_pkts1519to2047octets) },
255 { "p2048to4095octets",
256 PPORT_2819_OFF(ether_stats_pkts2048to4095octets) },
257 { "p4096to8191octets",
258 PPORT_2819_OFF(ether_stats_pkts4096to8191octets) },
259 { "p8192to10239octets",
260 PPORT_2819_OFF(ether_stats_pkts8192to10239octets) },
261}; 231};
262 232
263static const struct counter_desc pport_per_prio_traffic_stats_desc[] = { 233static const struct counter_desc pport_per_prio_traffic_stats_desc[] = {
264 { "rx_octets", PPORT_PER_PRIO_OFF(rx_octets) }, 234 { "rx_prio%d_bytes", PPORT_PER_PRIO_OFF(rx_octets) },
265 { "rx_frames", PPORT_PER_PRIO_OFF(rx_frames) }, 235 { "rx_prio%d_packets", PPORT_PER_PRIO_OFF(rx_frames) },
266 { "tx_octets", PPORT_PER_PRIO_OFF(tx_octets) }, 236 { "tx_prio%d_bytes", PPORT_PER_PRIO_OFF(tx_octets) },
267 { "tx_frames", PPORT_PER_PRIO_OFF(tx_frames) }, 237 { "tx_prio%d_packets", PPORT_PER_PRIO_OFF(tx_frames) },
268}; 238};
269 239
270static const struct counter_desc pport_per_prio_pfc_stats_desc[] = { 240static const struct counter_desc pport_per_prio_pfc_stats_desc[] = {
271 { "rx_pause", PPORT_PER_PRIO_OFF(rx_pause) }, 241 { "rx_prio%d_pause", PPORT_PER_PRIO_OFF(rx_pause) },
272 { "rx_pause_duration", PPORT_PER_PRIO_OFF(rx_pause_duration) }, 242 { "rx_prio%d_pause_duration", PPORT_PER_PRIO_OFF(rx_pause_duration) },
273 { "tx_pause", PPORT_PER_PRIO_OFF(tx_pause) }, 243 { "tx_prio%d_pause", PPORT_PER_PRIO_OFF(tx_pause) },
274 { "tx_pause_duration", PPORT_PER_PRIO_OFF(tx_pause_duration) }, 244 { "tx_prio%d_pause_duration", PPORT_PER_PRIO_OFF(tx_pause_duration) },
275 { "rx_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) }, 245 { "rx_prio%d_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) },
276}; 246};
277 247
278struct mlx5e_rq_stats { 248struct mlx5e_rq_stats {
279 u64 packets; 249 u64 packets;
280 u64 bytes; 250 u64 bytes;
281 u64 csum_sw; 251 u64 csum_complete;
282 u64 csum_inner; 252 u64 csum_unnecessary_inner;
283 u64 csum_none; 253 u64 csum_none;
284 u64 lro_packets; 254 u64 lro_packets;
285 u64 lro_bytes; 255 u64 lro_bytes;
@@ -292,19 +262,19 @@ struct mlx5e_rq_stats {
292}; 262};
293 263
294static const struct counter_desc rq_stats_desc[] = { 264static const struct counter_desc rq_stats_desc[] = {
295 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, packets) }, 265 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
296 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, bytes) }, 266 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
297 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_sw) }, 267 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },
298 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_inner) }, 268 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },
299 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_none) }, 269 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
300 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, lro_packets) }, 270 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_packets) },
301 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, lro_bytes) }, 271 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_bytes) },
302 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, wqe_err) }, 272 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, wqe_err) },
303 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, mpwqe_filler) }, 273 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, mpwqe_filler) },
304 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, mpwqe_frag) }, 274 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, mpwqe_frag) },
305 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, buff_alloc_err) }, 275 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, buff_alloc_err) },
306 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, cqe_compress_blks) }, 276 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_blks) },
307 { MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, cqe_compress_pkts) }, 277 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_pkts) },
308}; 278};
309 279
310struct mlx5e_sq_stats { 280struct mlx5e_sq_stats {
@@ -315,28 +285,28 @@ struct mlx5e_sq_stats {
315 u64 tso_bytes; 285 u64 tso_bytes;
316 u64 tso_inner_packets; 286 u64 tso_inner_packets;
317 u64 tso_inner_bytes; 287 u64 tso_inner_bytes;
318 u64 csum_offload_inner; 288 u64 csum_partial_inner;
319 u64 nop; 289 u64 nop;
320 /* less likely accessed in data path */ 290 /* less likely accessed in data path */
321 u64 csum_offload_none; 291 u64 csum_none;
322 u64 stopped; 292 u64 stopped;
323 u64 wake; 293 u64 wake;
324 u64 dropped; 294 u64 dropped;
325}; 295};
326 296
327static const struct counter_desc sq_stats_desc[] = { 297static const struct counter_desc sq_stats_desc[] = {
328 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, packets) }, 298 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, packets) },
329 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, bytes) }, 299 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, bytes) },
330 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_packets) }, 300 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_packets) },
331 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_bytes) }, 301 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) },
332 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_inner_packets) }, 302 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) },
333 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_inner_bytes) }, 303 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) },
334 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, csum_offload_inner) }, 304 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },
335 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, nop) }, 305 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) },
336 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, csum_offload_none) }, 306 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },
337 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, stopped) }, 307 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) },
338 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, wake) }, 308 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) },
339 { MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, dropped) }, 309 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) },
340}; 310};
341 311
342#define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) 312#define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index b000ddc29553..5a750b9cd006 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -192,12 +192,12 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
192 if (skb->encapsulation) { 192 if (skb->encapsulation) {
193 eseg->cs_flags |= MLX5_ETH_WQE_L3_INNER_CSUM | 193 eseg->cs_flags |= MLX5_ETH_WQE_L3_INNER_CSUM |
194 MLX5_ETH_WQE_L4_INNER_CSUM; 194 MLX5_ETH_WQE_L4_INNER_CSUM;
195 sq->stats.csum_offload_inner++; 195 sq->stats.csum_partial_inner++;
196 } else { 196 } else {
197 eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM; 197 eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM;
198 } 198 }
199 } else 199 } else
200 sq->stats.csum_offload_none++; 200 sq->stats.csum_none++;
201 201
202 if (sq->cc != sq->prev_cc) { 202 if (sq->cc != sq->prev_cc) {
203 sq->prev_cc = sq->cc; 203 sq->prev_cc = sq->cc;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index a19b59348dd6..c65f4a13e17e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1508,8 +1508,9 @@ static const struct pci_device_id mlx5_core_pci_table[] = {
1508 { PCI_VDEVICE(MELLANOX, 0x1014), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4 VF */ 1508 { PCI_VDEVICE(MELLANOX, 0x1014), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4 VF */
1509 { PCI_VDEVICE(MELLANOX, 0x1015) }, /* ConnectX-4LX */ 1509 { PCI_VDEVICE(MELLANOX, 0x1015) }, /* ConnectX-4LX */
1510 { PCI_VDEVICE(MELLANOX, 0x1016), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4LX VF */ 1510 { PCI_VDEVICE(MELLANOX, 0x1016), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4LX VF */
1511 { PCI_VDEVICE(MELLANOX, 0x1017) }, /* ConnectX-5 */ 1511 { PCI_VDEVICE(MELLANOX, 0x1017) }, /* ConnectX-5, PCIe 3.0 */
1512 { PCI_VDEVICE(MELLANOX, 0x1018), MLX5_PCI_DEV_IS_VF}, /* ConnectX-5 VF */ 1512 { PCI_VDEVICE(MELLANOX, 0x1018), MLX5_PCI_DEV_IS_VF}, /* ConnectX-5 VF */
1513 { PCI_VDEVICE(MELLANOX, 0x1019) }, /* ConnectX-5, PCIe 4.0 */
1513 { 0, } 1514 { 0, }
1514}; 1515};
1515 1516
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
index f2fd1ef16da7..05de77267d58 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
@@ -105,6 +105,9 @@ static void mlx5e_vxlan_add_port(struct work_struct *work)
105 struct mlx5e_vxlan *vxlan; 105 struct mlx5e_vxlan *vxlan;
106 int err; 106 int err;
107 107
108 if (mlx5e_vxlan_lookup_port(priv, port))
109 goto free_work;
110
108 if (mlx5e_vxlan_core_add_port_cmd(priv->mdev, port)) 111 if (mlx5e_vxlan_core_add_port_cmd(priv->mdev, port))
109 goto free_work; 112 goto free_work;
110 113
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
index ce21ee5b2357..821a087c7ae2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
@@ -75,14 +75,14 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
75 75
76 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node); 76 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
77 if (err) { 77 if (err) {
78 mlx5_core_warn(mdev, "mlx5_db_alloc() failed, %d\n", err); 78 mlx5_core_warn(mdev, "mlx5_db_alloc_node() failed, %d\n", err);
79 return err; 79 return err;
80 } 80 }
81 81
82 err = mlx5_buf_alloc_node(mdev, mlx5_wq_cyc_get_byte_size(wq), 82 err = mlx5_buf_alloc_node(mdev, mlx5_wq_cyc_get_byte_size(wq),
83 &wq_ctrl->buf, param->buf_numa_node); 83 &wq_ctrl->buf, param->buf_numa_node);
84 if (err) { 84 if (err) {
85 mlx5_core_warn(mdev, "mlx5_buf_alloc() failed, %d\n", err); 85 mlx5_core_warn(mdev, "mlx5_buf_alloc_node() failed, %d\n", err);
86 goto err_db_free; 86 goto err_db_free;
87 } 87 }
88 88
@@ -111,14 +111,14 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
111 111
112 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node); 112 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
113 if (err) { 113 if (err) {
114 mlx5_core_warn(mdev, "mlx5_db_alloc() failed, %d\n", err); 114 mlx5_core_warn(mdev, "mlx5_db_alloc_node() failed, %d\n", err);
115 return err; 115 return err;
116 } 116 }
117 117
118 err = mlx5_buf_alloc_node(mdev, mlx5_cqwq_get_byte_size(wq), 118 err = mlx5_buf_alloc_node(mdev, mlx5_cqwq_get_byte_size(wq),
119 &wq_ctrl->buf, param->buf_numa_node); 119 &wq_ctrl->buf, param->buf_numa_node);
120 if (err) { 120 if (err) {
121 mlx5_core_warn(mdev, "mlx5_buf_alloc() failed, %d\n", err); 121 mlx5_core_warn(mdev, "mlx5_buf_alloc_node() failed, %d\n", err);
122 goto err_db_free; 122 goto err_db_free;
123 } 123 }
124 124
@@ -148,13 +148,14 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
148 148
149 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node); 149 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
150 if (err) { 150 if (err) {
151 mlx5_core_warn(mdev, "mlx5_db_alloc() failed, %d\n", err); 151 mlx5_core_warn(mdev, "mlx5_db_alloc_node() failed, %d\n", err);
152 return err; 152 return err;
153 } 153 }
154 154
155 err = mlx5_buf_alloc(mdev, mlx5_wq_ll_get_byte_size(wq), &wq_ctrl->buf); 155 err = mlx5_buf_alloc_node(mdev, mlx5_wq_ll_get_byte_size(wq),
156 &wq_ctrl->buf, param->buf_numa_node);
156 if (err) { 157 if (err) {
157 mlx5_core_warn(mdev, "mlx5_buf_alloc() failed, %d\n", err); 158 mlx5_core_warn(mdev, "mlx5_buf_alloc_node() failed, %d\n", err);
158 goto err_db_free; 159 goto err_db_free;
159 } 160 }
160 161
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 6f9e3ddff4a8..660429ebfbe1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -408,7 +408,11 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
408 } 408 }
409 409
410 mlxsw_sp_txhdr_construct(skb, &tx_info); 410 mlxsw_sp_txhdr_construct(skb, &tx_info);
411 len = skb->len; 411 /* TX header is consumed by HW on the way so we shouldn't count its
412 * bytes as being sent.
413 */
414 len = skb->len - MLXSW_TXHDR_LEN;
415
412 /* Due to a race we might fail here because of a full queue. In that 416 /* Due to a race we might fail here because of a full queue. In that
413 * unlikely case we simply drop the packet. 417 * unlikely case we simply drop the packet.
414 */ 418 */
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 3842eab9449a..25f658b3849a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -316,7 +316,10 @@ static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb,
316 } 316 }
317 } 317 }
318 mlxsw_sx_txhdr_construct(skb, &tx_info); 318 mlxsw_sx_txhdr_construct(skb, &tx_info);
319 len = skb->len; 319 /* TX header is consumed by HW on the way so we shouldn't count its
320 * bytes as being sent.
321 */
322 len = skb->len - MLXSW_TXHDR_LEN;
320 /* Due to a race we might fail here because of a full queue. In that 323 /* Due to a race we might fail here because of a full queue. In that
321 * unlikely case we simply drop the packet. 324 * unlikely case we simply drop the packet.
322 */ 325 */
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index fa47c14c743a..ba26bb356b8d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2015,7 +2015,7 @@ static void nfp_net_open_stack(struct nfp_net *nn)
2015 2015
2016 netif_tx_wake_all_queues(nn->netdev); 2016 netif_tx_wake_all_queues(nn->netdev);
2017 2017
2018 enable_irq(nn->irq_entries[NFP_NET_CFG_LSC].vector); 2018 enable_irq(nn->irq_entries[NFP_NET_IRQ_LSC_IDX].vector);
2019 nfp_net_read_link_status(nn); 2019 nfp_net_read_link_status(nn);
2020} 2020}
2021 2021
@@ -2044,7 +2044,7 @@ static int nfp_net_netdev_open(struct net_device *netdev)
2044 NFP_NET_IRQ_LSC_IDX, nn->lsc_handler); 2044 NFP_NET_IRQ_LSC_IDX, nn->lsc_handler);
2045 if (err) 2045 if (err)
2046 goto err_free_exn; 2046 goto err_free_exn;
2047 disable_irq(nn->irq_entries[NFP_NET_CFG_LSC].vector); 2047 disable_irq(nn->irq_entries[NFP_NET_IRQ_LSC_IDX].vector);
2048 2048
2049 nn->rx_rings = kcalloc(nn->num_rx_rings, sizeof(*nn->rx_rings), 2049 nn->rx_rings = kcalloc(nn->num_rx_rings, sizeof(*nn->rx_rings),
2050 GFP_KERNEL); 2050 GFP_KERNEL);
@@ -2133,7 +2133,7 @@ static void nfp_net_close_stack(struct nfp_net *nn)
2133{ 2133{
2134 unsigned int r; 2134 unsigned int r;
2135 2135
2136 disable_irq(nn->irq_entries[NFP_NET_CFG_LSC].vector); 2136 disable_irq(nn->irq_entries[NFP_NET_IRQ_LSC_IDX].vector);
2137 netif_carrier_off(nn->netdev); 2137 netif_carrier_off(nn->netdev);
2138 nn->link_up = false; 2138 nn->link_up = false;
2139 2139
diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index 9afc15fdbb02..e29ed5a69566 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -3700,6 +3700,7 @@ struct public_port {
3700#define MEDIA_DA_TWINAX 0x3 3700#define MEDIA_DA_TWINAX 0x3
3701#define MEDIA_BASE_T 0x4 3701#define MEDIA_BASE_T 0x4
3702#define MEDIA_SFP_1G_FIBER 0x5 3702#define MEDIA_SFP_1G_FIBER 0x5
3703#define MEDIA_MODULE_FIBER 0x6
3703#define MEDIA_KR 0xf0 3704#define MEDIA_KR 0xf0
3704#define MEDIA_NOT_PRESENT 0xff 3705#define MEDIA_NOT_PRESENT 0xff
3705 3706
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 8fba87dd48af..aada4c7e095f 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -72,6 +72,7 @@ int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
72 p_ramrod->mtu = cpu_to_le16(p_params->mtu); 72 p_ramrod->mtu = cpu_to_le16(p_params->mtu);
73 p_ramrod->inner_vlan_removal_en = p_params->remove_inner_vlan; 73 p_ramrod->inner_vlan_removal_en = p_params->remove_inner_vlan;
74 p_ramrod->drop_ttl0_en = p_params->drop_ttl0; 74 p_ramrod->drop_ttl0_en = p_params->drop_ttl0;
75 p_ramrod->untagged = p_params->only_untagged;
75 76
76 SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_UCAST_DROP_ALL, 1); 77 SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_UCAST_DROP_ALL, 1);
77 SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_MCAST_DROP_ALL, 1); 78 SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_MCAST_DROP_ALL, 1);
@@ -247,10 +248,6 @@ qed_sp_update_accept_mode(struct qed_hwfn *p_hwfn,
247 SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_DROP_ALL, 248 SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_DROP_ALL,
248 !!(accept_filter & QED_ACCEPT_NONE)); 249 !!(accept_filter & QED_ACCEPT_NONE));
249 250
250 SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_ACCEPT_ALL,
251 (!!(accept_filter & QED_ACCEPT_UCAST_MATCHED) &&
252 !!(accept_filter & QED_ACCEPT_UCAST_UNMATCHED)));
253
254 SET_FIELD(state, ETH_VPORT_TX_MODE_MCAST_DROP_ALL, 251 SET_FIELD(state, ETH_VPORT_TX_MODE_MCAST_DROP_ALL,
255 !!(accept_filter & QED_ACCEPT_NONE)); 252 !!(accept_filter & QED_ACCEPT_NONE));
256 253
@@ -1748,7 +1745,8 @@ static int qed_start_vport(struct qed_dev *cdev,
1748 start.vport_id, start.mtu); 1745 start.vport_id, start.mtu);
1749 } 1746 }
1750 1747
1751 qed_reset_vport_stats(cdev); 1748 if (params->clear_stats)
1749 qed_reset_vport_stats(cdev);
1752 1750
1753 return 0; 1751 return 0;
1754} 1752}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 61cc6869fa65..c7e01b303540 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -1085,6 +1085,7 @@ static int qed_get_port_type(u32 media_type)
1085 case MEDIA_SFPP_10G_FIBER: 1085 case MEDIA_SFPP_10G_FIBER:
1086 case MEDIA_SFP_1G_FIBER: 1086 case MEDIA_SFP_1G_FIBER:
1087 case MEDIA_XFP_FIBER: 1087 case MEDIA_XFP_FIBER:
1088 case MEDIA_MODULE_FIBER:
1088 case MEDIA_KR: 1089 case MEDIA_KR:
1089 port_type = PORT_FIBRE; 1090 port_type = PORT_FIBRE;
1090 break; 1091 break;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c
index acac6626a1b2..b122f6013b6c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_spq.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c
@@ -213,19 +213,15 @@ static int qed_spq_hw_post(struct qed_hwfn *p_hwfn,
213 SET_FIELD(db.params, CORE_DB_DATA_AGG_VAL_SEL, 213 SET_FIELD(db.params, CORE_DB_DATA_AGG_VAL_SEL,
214 DQ_XCM_CORE_SPQ_PROD_CMD); 214 DQ_XCM_CORE_SPQ_PROD_CMD);
215 db.agg_flags = DQ_XCM_CORE_DQ_CF_CMD; 215 db.agg_flags = DQ_XCM_CORE_DQ_CF_CMD;
216
217 /* validate producer is up to-date */
218 rmb();
219
220 db.spq_prod = cpu_to_le16(qed_chain_get_prod_idx(p_chain)); 216 db.spq_prod = cpu_to_le16(qed_chain_get_prod_idx(p_chain));
221 217
222 /* do not reorder */ 218 /* make sure the SPQE is updated before the doorbell */
223 barrier(); 219 wmb();
224 220
225 DOORBELL(p_hwfn, qed_db_addr(p_spq->cid, DQ_DEMS_LEGACY), *(u32 *)&db); 221 DOORBELL(p_hwfn, qed_db_addr(p_spq->cid, DQ_DEMS_LEGACY), *(u32 *)&db);
226 222
227 /* make sure doorbell is rang */ 223 /* make sure doorbell is rang */
228 mmiowb(); 224 wmb();
229 225
230 DP_VERBOSE(p_hwfn, QED_MSG_SPQ, 226 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
231 "Doorbelled [0x%08x, CID 0x%08x] with Flags: %02x agg_params: %02x, prod: %04x\n", 227 "Doorbelled [0x%08x, CID 0x%08x] with Flags: %02x agg_params: %02x, prod: %04x\n",
@@ -614,7 +610,9 @@ qed_spq_add_entry(struct qed_hwfn *p_hwfn,
614 610
615 *p_en2 = *p_ent; 611 *p_en2 = *p_ent;
616 612
617 kfree(p_ent); 613 /* EBLOCK responsible to free the allocated p_ent */
614 if (p_ent->comp_mode != QED_SPQ_MODE_EBLOCK)
615 kfree(p_ent);
618 616
619 p_ent = p_en2; 617 p_ent = p_en2;
620 } 618 }
@@ -749,6 +747,15 @@ int qed_spq_post(struct qed_hwfn *p_hwfn,
749 * Thus, after gaining the answer perform the cleanup here. 747 * Thus, after gaining the answer perform the cleanup here.
750 */ 748 */
751 rc = qed_spq_block(p_hwfn, p_ent, fw_return_code); 749 rc = qed_spq_block(p_hwfn, p_ent, fw_return_code);
750
751 if (p_ent->queue == &p_spq->unlimited_pending) {
752 /* This is an allocated p_ent which does not need to
753 * return to pool.
754 */
755 kfree(p_ent);
756 return rc;
757 }
758
752 if (rc) 759 if (rc)
753 goto spq_post_fail2; 760 goto spq_post_fail2;
754 761
@@ -844,8 +851,12 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,
844 found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data, 851 found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data,
845 fw_return_code); 852 fw_return_code);
846 853
847 if (found->comp_mode != QED_SPQ_MODE_EBLOCK) 854 if ((found->comp_mode != QED_SPQ_MODE_EBLOCK) ||
848 /* EBLOCK is responsible for freeing its own entry */ 855 (found->queue == &p_spq->unlimited_pending))
856 /* EBLOCK is responsible for returning its own entry into the
857 * free list, unless it originally added the entry into the
858 * unlimited pending list.
859 */
849 qed_spq_return_entry(p_hwfn, found); 860 qed_spq_return_entry(p_hwfn, found);
850 861
851 /* Attempt to post pending requests */ 862 /* Attempt to post pending requests */
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 5733d1888223..f8e11f953acb 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -3231,7 +3231,7 @@ static int qede_stop_queues(struct qede_dev *edev)
3231 return rc; 3231 return rc;
3232} 3232}
3233 3233
3234static int qede_start_queues(struct qede_dev *edev) 3234static int qede_start_queues(struct qede_dev *edev, bool clear_stats)
3235{ 3235{
3236 int rc, tc, i; 3236 int rc, tc, i;
3237 int vlan_removal_en = 1; 3237 int vlan_removal_en = 1;
@@ -3462,6 +3462,7 @@ out:
3462 3462
3463enum qede_load_mode { 3463enum qede_load_mode {
3464 QEDE_LOAD_NORMAL, 3464 QEDE_LOAD_NORMAL,
3465 QEDE_LOAD_RELOAD,
3465}; 3466};
3466 3467
3467static int qede_load(struct qede_dev *edev, enum qede_load_mode mode) 3468static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
@@ -3500,7 +3501,7 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
3500 goto err3; 3501 goto err3;
3501 DP_INFO(edev, "Setup IRQs succeeded\n"); 3502 DP_INFO(edev, "Setup IRQs succeeded\n");
3502 3503
3503 rc = qede_start_queues(edev); 3504 rc = qede_start_queues(edev, mode != QEDE_LOAD_RELOAD);
3504 if (rc) 3505 if (rc)
3505 goto err4; 3506 goto err4;
3506 DP_INFO(edev, "Start VPORT, RXQ and TXQ succeeded\n"); 3507 DP_INFO(edev, "Start VPORT, RXQ and TXQ succeeded\n");
@@ -3555,7 +3556,7 @@ void qede_reload(struct qede_dev *edev,
3555 if (func) 3556 if (func)
3556 func(edev, args); 3557 func(edev, args);
3557 3558
3558 qede_load(edev, QEDE_LOAD_NORMAL); 3559 qede_load(edev, QEDE_LOAD_RELOAD);
3559 3560
3560 mutex_lock(&edev->qede_lock); 3561 mutex_lock(&edev->qede_lock);
3561 qede_config_rx_mode(edev->ndev); 3562 qede_config_rx_mode(edev->ndev);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index 7bd6f25b4625..607bb7d4514d 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -2220,7 +2220,7 @@ void qlcnic_83xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring)
2220 if (!opcode) 2220 if (!opcode)
2221 return; 2221 return;
2222 2222
2223 ring = QLCNIC_FETCH_RING_ID(qlcnic_83xx_hndl(sts_data[0])); 2223 ring = QLCNIC_FETCH_RING_ID(sts_data[0]);
2224 qlcnic_83xx_process_rcv_diag(adapter, ring, sts_data); 2224 qlcnic_83xx_process_rcv_diag(adapter, ring, sts_data);
2225 desc = &sds_ring->desc_head[consumer]; 2225 desc = &sds_ring->desc_head[consumer];
2226 desc->status_desc_data[0] = cpu_to_le64(STATUS_OWNER_PHANTOM); 2226 desc->status_desc_data[0] = cpu_to_le64(STATUS_OWNER_PHANTOM);
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c
index 133e9e35be9e..4c83739d158f 100644
--- a/drivers/net/ethernet/sfc/farch.c
+++ b/drivers/net/ethernet/sfc/farch.c
@@ -104,7 +104,8 @@ int efx_farch_test_registers(struct efx_nic *efx,
104 const struct efx_farch_register_test *regs, 104 const struct efx_farch_register_test *regs,
105 size_t n_regs) 105 size_t n_regs)
106{ 106{
107 unsigned address = 0, i, j; 107 unsigned address = 0;
108 int i, j;
108 efx_oword_t mask, imask, original, reg, buf; 109 efx_oword_t mask, imask, original, reg, buf;
109 110
110 for (i = 0; i < n_regs; ++i) { 111 for (i = 0; i < n_regs; ++i) {
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 8af25563f627..b5ab5e120bca 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -116,7 +116,6 @@ struct smsc911x_data {
116 116
117 struct phy_device *phy_dev; 117 struct phy_device *phy_dev;
118 struct mii_bus *mii_bus; 118 struct mii_bus *mii_bus;
119 int phy_irq[PHY_MAX_ADDR];
120 unsigned int using_extphy; 119 unsigned int using_extphy;
121 int last_duplex; 120 int last_duplex;
122 int last_carrier; 121 int last_carrier;
@@ -1073,7 +1072,6 @@ static int smsc911x_mii_init(struct platform_device *pdev,
1073 pdata->mii_bus->priv = pdata; 1072 pdata->mii_bus->priv = pdata;
1074 pdata->mii_bus->read = smsc911x_mii_read; 1073 pdata->mii_bus->read = smsc911x_mii_read;
1075 pdata->mii_bus->write = smsc911x_mii_write; 1074 pdata->mii_bus->write = smsc911x_mii_write;
1076 memcpy(pdata->mii_bus->irq, pdata->phy_irq, sizeof(pdata->mii_bus));
1077 1075
1078 pdata->mii_bus->parent = &pdev->dev; 1076 pdata->mii_bus->parent = &pdev->dev;
1079 1077
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index e6bb0ecb12c7..53190894f17a 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2505,8 +2505,6 @@ static int cpsw_probe(struct platform_device *pdev)
2505clean_ale_ret: 2505clean_ale_ret:
2506 cpsw_ale_destroy(priv->ale); 2506 cpsw_ale_destroy(priv->ale);
2507clean_dma_ret: 2507clean_dma_ret:
2508 cpdma_chan_destroy(priv->txch);
2509 cpdma_chan_destroy(priv->rxch);
2510 cpdma_ctlr_destroy(priv->dma); 2508 cpdma_ctlr_destroy(priv->dma);
2511clean_runtime_disable_ret: 2509clean_runtime_disable_ret:
2512 pm_runtime_disable(&pdev->dev); 2510 pm_runtime_disable(&pdev->dev);
@@ -2534,8 +2532,6 @@ static int cpsw_remove(struct platform_device *pdev)
2534 unregister_netdev(ndev); 2532 unregister_netdev(ndev);
2535 2533
2536 cpsw_ale_destroy(priv->ale); 2534 cpsw_ale_destroy(priv->ale);
2537 cpdma_chan_destroy(priv->txch);
2538 cpdma_chan_destroy(priv->rxch);
2539 cpdma_ctlr_destroy(priv->dma); 2535 cpdma_ctlr_destroy(priv->dma);
2540 pm_runtime_disable(&pdev->dev); 2536 pm_runtime_disable(&pdev->dev);
2541 device_for_each_child(&pdev->dev, NULL, cpsw_remove_child_device); 2537 device_for_each_child(&pdev->dev, NULL, cpsw_remove_child_device);
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 0a15acc075b3..11213a38c795 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -462,7 +462,7 @@ static void tile_tx_timestamp(struct sk_buff *skb, int instance)
462 if (unlikely((shtx->tx_flags & SKBTX_HW_TSTAMP) != 0)) { 462 if (unlikely((shtx->tx_flags & SKBTX_HW_TSTAMP) != 0)) {
463 struct mpipe_data *md = &mpipe_data[instance]; 463 struct mpipe_data *md = &mpipe_data[instance];
464 struct skb_shared_hwtstamps shhwtstamps; 464 struct skb_shared_hwtstamps shhwtstamps;
465 struct timespec ts; 465 struct timespec64 ts;
466 466
467 shtx->tx_flags |= SKBTX_IN_PROGRESS; 467 shtx->tx_flags |= SKBTX_IN_PROGRESS;
468 gxio_mpipe_get_timestamp(&md->context, &ts); 468 gxio_mpipe_get_timestamp(&md->context, &ts);
@@ -886,9 +886,9 @@ static struct ptp_clock_info ptp_mpipe_caps = {
886/* Sync mPIPE's timestamp up with Linux system time and register PTP clock. */ 886/* Sync mPIPE's timestamp up with Linux system time and register PTP clock. */
887static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md) 887static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md)
888{ 888{
889 struct timespec ts; 889 struct timespec64 ts;
890 890
891 getnstimeofday(&ts); 891 ktime_get_ts64(&ts);
892 gxio_mpipe_set_timestamp(&md->context, &ts); 892 gxio_mpipe_set_timestamp(&md->context, &ts);
893 893
894 mutex_init(&md->ptp_lock); 894 mutex_init(&md->ptp_lock);
diff --git a/drivers/net/fddi/skfp/Makefile b/drivers/net/fddi/skfp/Makefile
index b0be0234abf6..a957a1c7e5ba 100644
--- a/drivers/net/fddi/skfp/Makefile
+++ b/drivers/net/fddi/skfp/Makefile
@@ -17,4 +17,4 @@ skfp-objs := skfddi.o hwmtm.o fplustm.o smt.o cfm.o \
17# projects. To keep the source common for all those drivers (and 17# projects. To keep the source common for all those drivers (and
18# thus simplify fixes to it), please do not clean it up! 18# thus simplify fixes to it), please do not clean it up!
19 19
20ccflags-y := -Idrivers/net/skfp -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes 20ccflags-y := -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index cadefe4fdaa2..cc39cefeae45 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -958,8 +958,8 @@ tx_error:
958 dev->stats.collisions++; 958 dev->stats.collisions++;
959 else if (err == -ENETUNREACH) 959 else if (err == -ENETUNREACH)
960 dev->stats.tx_carrier_errors++; 960 dev->stats.tx_carrier_errors++;
961 else 961
962 dev->stats.tx_errors++; 962 dev->stats.tx_errors++;
963 return NETDEV_TX_OK; 963 return NETDEV_TX_OK;
964} 964}
965 965
@@ -1048,8 +1048,8 @@ tx_error:
1048 dev->stats.collisions++; 1048 dev->stats.collisions++;
1049 else if (err == -ENETUNREACH) 1049 else if (err == -ENETUNREACH)
1050 dev->stats.tx_carrier_errors++; 1050 dev->stats.tx_carrier_errors++;
1051 else 1051
1052 dev->stats.tx_errors++; 1052 dev->stats.tx_errors++;
1053 return NETDEV_TX_OK; 1053 return NETDEV_TX_OK;
1054} 1054}
1055#endif 1055#endif
@@ -1508,6 +1508,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
1508{ 1508{
1509 struct nlattr *tb[IFLA_MAX + 1]; 1509 struct nlattr *tb[IFLA_MAX + 1];
1510 struct net_device *dev; 1510 struct net_device *dev;
1511 LIST_HEAD(list_kill);
1511 int err; 1512 int err;
1512 1513
1513 memset(tb, 0, sizeof(tb)); 1514 memset(tb, 0, sizeof(tb));
@@ -1519,8 +1520,10 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
1519 err = geneve_configure(net, dev, &geneve_remote_unspec, 1520 err = geneve_configure(net, dev, &geneve_remote_unspec,
1520 0, 0, 0, 0, htons(dst_port), true, 1521 0, 0, 0, 0, htons(dst_port), true,
1521 GENEVE_F_UDP_ZERO_CSUM6_RX); 1522 GENEVE_F_UDP_ZERO_CSUM6_RX);
1522 if (err) 1523 if (err) {
1523 goto err; 1524 free_netdev(dev);
1525 return ERR_PTR(err);
1526 }
1524 1527
1525 /* openvswitch users expect packet sizes to be unrestricted, 1528 /* openvswitch users expect packet sizes to be unrestricted,
1526 * so set the largest MTU we can. 1529 * so set the largest MTU we can.
@@ -1529,10 +1532,15 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
1529 if (err) 1532 if (err)
1530 goto err; 1533 goto err;
1531 1534
1535 err = rtnl_configure_link(dev, NULL);
1536 if (err < 0)
1537 goto err;
1538
1532 return dev; 1539 return dev;
1533 1540
1534 err: 1541 err:
1535 free_netdev(dev); 1542 geneve_dellink(dev, &list_kill);
1543 unregister_netdevice_many(&list_kill);
1536 return ERR_PTR(err); 1544 return ERR_PTR(err);
1537} 1545}
1538EXPORT_SYMBOL_GPL(geneve_dev_create_fb); 1546EXPORT_SYMBOL_GPL(geneve_dev_create_fb);
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 47ee2c840b55..0e7eff7f1cd2 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -605,12 +605,41 @@ static void macsec_encrypt_done(struct crypto_async_request *base, int err)
605 dev_put(dev); 605 dev_put(dev);
606} 606}
607 607
608static struct aead_request *macsec_alloc_req(struct crypto_aead *tfm,
609 unsigned char **iv,
610 struct scatterlist **sg)
611{
612 size_t size, iv_offset, sg_offset;
613 struct aead_request *req;
614 void *tmp;
615
616 size = sizeof(struct aead_request) + crypto_aead_reqsize(tfm);
617 iv_offset = size;
618 size += GCM_AES_IV_LEN;
619
620 size = ALIGN(size, __alignof__(struct scatterlist));
621 sg_offset = size;
622 size += sizeof(struct scatterlist) * (MAX_SKB_FRAGS + 1);
623
624 tmp = kmalloc(size, GFP_ATOMIC);
625 if (!tmp)
626 return NULL;
627
628 *iv = (unsigned char *)(tmp + iv_offset);
629 *sg = (struct scatterlist *)(tmp + sg_offset);
630 req = tmp;
631
632 aead_request_set_tfm(req, tfm);
633
634 return req;
635}
636
608static struct sk_buff *macsec_encrypt(struct sk_buff *skb, 637static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
609 struct net_device *dev) 638 struct net_device *dev)
610{ 639{
611 int ret; 640 int ret;
612 struct scatterlist sg[MAX_SKB_FRAGS + 1]; 641 struct scatterlist *sg;
613 unsigned char iv[GCM_AES_IV_LEN]; 642 unsigned char *iv;
614 struct ethhdr *eth; 643 struct ethhdr *eth;
615 struct macsec_eth_header *hh; 644 struct macsec_eth_header *hh;
616 size_t unprotected_len; 645 size_t unprotected_len;
@@ -668,8 +697,6 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
668 macsec_fill_sectag(hh, secy, pn); 697 macsec_fill_sectag(hh, secy, pn);
669 macsec_set_shortlen(hh, unprotected_len - 2 * ETH_ALEN); 698 macsec_set_shortlen(hh, unprotected_len - 2 * ETH_ALEN);
670 699
671 macsec_fill_iv(iv, secy->sci, pn);
672
673 skb_put(skb, secy->icv_len); 700 skb_put(skb, secy->icv_len);
674 701
675 if (skb->len - ETH_HLEN > macsec_priv(dev)->real_dev->mtu) { 702 if (skb->len - ETH_HLEN > macsec_priv(dev)->real_dev->mtu) {
@@ -684,13 +711,15 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
684 return ERR_PTR(-EINVAL); 711 return ERR_PTR(-EINVAL);
685 } 712 }
686 713
687 req = aead_request_alloc(tx_sa->key.tfm, GFP_ATOMIC); 714 req = macsec_alloc_req(tx_sa->key.tfm, &iv, &sg);
688 if (!req) { 715 if (!req) {
689 macsec_txsa_put(tx_sa); 716 macsec_txsa_put(tx_sa);
690 kfree_skb(skb); 717 kfree_skb(skb);
691 return ERR_PTR(-ENOMEM); 718 return ERR_PTR(-ENOMEM);
692 } 719 }
693 720
721 macsec_fill_iv(iv, secy->sci, pn);
722
694 sg_init_table(sg, MAX_SKB_FRAGS + 1); 723 sg_init_table(sg, MAX_SKB_FRAGS + 1);
695 skb_to_sgvec(skb, sg, 0, skb->len); 724 skb_to_sgvec(skb, sg, 0, skb->len);
696 725
@@ -861,7 +890,6 @@ static void macsec_decrypt_done(struct crypto_async_request *base, int err)
861out: 890out:
862 macsec_rxsa_put(rx_sa); 891 macsec_rxsa_put(rx_sa);
863 dev_put(dev); 892 dev_put(dev);
864 return;
865} 893}
866 894
867static struct sk_buff *macsec_decrypt(struct sk_buff *skb, 895static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
@@ -871,8 +899,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
871 struct macsec_secy *secy) 899 struct macsec_secy *secy)
872{ 900{
873 int ret; 901 int ret;
874 struct scatterlist sg[MAX_SKB_FRAGS + 1]; 902 struct scatterlist *sg;
875 unsigned char iv[GCM_AES_IV_LEN]; 903 unsigned char *iv;
876 struct aead_request *req; 904 struct aead_request *req;
877 struct macsec_eth_header *hdr; 905 struct macsec_eth_header *hdr;
878 u16 icv_len = secy->icv_len; 906 u16 icv_len = secy->icv_len;
@@ -882,7 +910,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
882 if (!skb) 910 if (!skb)
883 return ERR_PTR(-ENOMEM); 911 return ERR_PTR(-ENOMEM);
884 912
885 req = aead_request_alloc(rx_sa->key.tfm, GFP_ATOMIC); 913 req = macsec_alloc_req(rx_sa->key.tfm, &iv, &sg);
886 if (!req) { 914 if (!req) {
887 kfree_skb(skb); 915 kfree_skb(skb);
888 return ERR_PTR(-ENOMEM); 916 return ERR_PTR(-ENOMEM);
@@ -1234,7 +1262,7 @@ static struct crypto_aead *macsec_alloc_tfm(char *key, int key_len, int icv_len)
1234 struct crypto_aead *tfm; 1262 struct crypto_aead *tfm;
1235 int ret; 1263 int ret;
1236 1264
1237 tfm = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC); 1265 tfm = crypto_alloc_aead("gcm(aes)", 0, 0);
1238 if (!tfm || IS_ERR(tfm)) 1266 if (!tfm || IS_ERR(tfm))
1239 return NULL; 1267 return NULL;
1240 1268
@@ -3361,6 +3389,7 @@ static void __exit macsec_exit(void)
3361 genl_unregister_family(&macsec_fam); 3389 genl_unregister_family(&macsec_fam);
3362 rtnl_link_unregister(&macsec_link_ops); 3390 rtnl_link_unregister(&macsec_link_ops);
3363 unregister_netdevice_notifier(&macsec_notifier); 3391 unregister_netdevice_notifier(&macsec_notifier);
3392 rcu_barrier();
3364} 3393}
3365 3394
3366module_init(macsec_init); 3395module_init(macsec_init);
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 2d2e4339f0df..9ec7f7353434 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -23,6 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/of.h> 24#include <linux/of.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/idr.h>
26 27
27#define MII_REGS_NUM 29 28#define MII_REGS_NUM 29
28 29
@@ -286,6 +287,8 @@ err_regs:
286} 287}
287EXPORT_SYMBOL_GPL(fixed_phy_add); 288EXPORT_SYMBOL_GPL(fixed_phy_add);
288 289
290static DEFINE_IDA(phy_fixed_ida);
291
289static void fixed_phy_del(int phy_addr) 292static void fixed_phy_del(int phy_addr)
290{ 293{
291 struct fixed_mdio_bus *fmb = &platform_fmb; 294 struct fixed_mdio_bus *fmb = &platform_fmb;
@@ -297,14 +300,12 @@ static void fixed_phy_del(int phy_addr)
297 if (gpio_is_valid(fp->link_gpio)) 300 if (gpio_is_valid(fp->link_gpio))
298 gpio_free(fp->link_gpio); 301 gpio_free(fp->link_gpio);
299 kfree(fp); 302 kfree(fp);
303 ida_simple_remove(&phy_fixed_ida, phy_addr);
300 return; 304 return;
301 } 305 }
302 } 306 }
303} 307}
304 308
305static int phy_fixed_addr;
306static DEFINE_SPINLOCK(phy_fixed_addr_lock);
307
308struct phy_device *fixed_phy_register(unsigned int irq, 309struct phy_device *fixed_phy_register(unsigned int irq,
309 struct fixed_phy_status *status, 310 struct fixed_phy_status *status,
310 int link_gpio, 311 int link_gpio,
@@ -319,17 +320,15 @@ struct phy_device *fixed_phy_register(unsigned int irq,
319 return ERR_PTR(-EPROBE_DEFER); 320 return ERR_PTR(-EPROBE_DEFER);
320 321
321 /* Get the next available PHY address, up to PHY_MAX_ADDR */ 322 /* Get the next available PHY address, up to PHY_MAX_ADDR */
322 spin_lock(&phy_fixed_addr_lock); 323 phy_addr = ida_simple_get(&phy_fixed_ida, 0, PHY_MAX_ADDR, GFP_KERNEL);
323 if (phy_fixed_addr == PHY_MAX_ADDR) { 324 if (phy_addr < 0)
324 spin_unlock(&phy_fixed_addr_lock); 325 return ERR_PTR(phy_addr);
325 return ERR_PTR(-ENOSPC);
326 }
327 phy_addr = phy_fixed_addr++;
328 spin_unlock(&phy_fixed_addr_lock);
329 326
330 ret = fixed_phy_add(irq, phy_addr, status, link_gpio); 327 ret = fixed_phy_add(irq, phy_addr, status, link_gpio);
331 if (ret < 0) 328 if (ret < 0) {
329 ida_simple_remove(&phy_fixed_ida, phy_addr);
332 return ERR_PTR(ret); 330 return ERR_PTR(ret);
331 }
333 332
334 phy = get_phy_device(fmb->mii_bus, phy_addr, false); 333 phy = get_phy_device(fmb->mii_bus, phy_addr, false);
335 if (IS_ERR(phy)) { 334 if (IS_ERR(phy)) {
@@ -434,6 +433,7 @@ static void __exit fixed_mdio_bus_exit(void)
434 list_del(&fp->node); 433 list_del(&fp->node);
435 kfree(fp); 434 kfree(fp);
436 } 435 }
436 ida_destroy(&phy_fixed_ida);
437} 437}
438module_exit(fixed_mdio_bus_exit); 438module_exit(fixed_mdio_bus_exit);
439 439
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 280e8795b463..ec2c1eee6405 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -285,6 +285,48 @@ static int marvell_config_aneg(struct phy_device *phydev)
285 return 0; 285 return 0;
286} 286}
287 287
288static int m88e1111_config_aneg(struct phy_device *phydev)
289{
290 int err;
291
292 /* The Marvell PHY has an errata which requires
293 * that certain registers get written in order
294 * to restart autonegotiation
295 */
296 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
297
298 err = marvell_set_polarity(phydev, phydev->mdix);
299 if (err < 0)
300 return err;
301
302 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
303 MII_M1111_PHY_LED_DIRECT);
304 if (err < 0)
305 return err;
306
307 err = genphy_config_aneg(phydev);
308 if (err < 0)
309 return err;
310
311 if (phydev->autoneg != AUTONEG_ENABLE) {
312 int bmcr;
313
314 /* A write to speed/duplex bits (that is performed by
315 * genphy_config_aneg() call above) must be followed by
316 * a software reset. Otherwise, the write has no effect.
317 */
318 bmcr = phy_read(phydev, MII_BMCR);
319 if (bmcr < 0)
320 return bmcr;
321
322 err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
323 if (err < 0)
324 return err;
325 }
326
327 return 0;
328}
329
288#ifdef CONFIG_OF_MDIO 330#ifdef CONFIG_OF_MDIO
289/* 331/*
290 * Set and/or override some configuration registers based on the 332 * Set and/or override some configuration registers based on the
@@ -407,15 +449,7 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
407 if (err < 0) 449 if (err < 0)
408 return err; 450 return err;
409 451
410 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE); 452 return genphy_config_aneg(phydev);
411
412 phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
413 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
414 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
415
416 err = genphy_config_aneg(phydev);
417
418 return err;
419} 453}
420 454
421static int m88e1318_config_aneg(struct phy_device *phydev) 455static int m88e1318_config_aneg(struct phy_device *phydev)
@@ -636,6 +670,28 @@ static int m88e1111_config_init(struct phy_device *phydev)
636 return phy_write(phydev, MII_BMCR, BMCR_RESET); 670 return phy_write(phydev, MII_BMCR, BMCR_RESET);
637} 671}
638 672
673static int m88e1121_config_init(struct phy_device *phydev)
674{
675 int err, oldpage;
676
677 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
678
679 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
680 if (err < 0)
681 return err;
682
683 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
684 err = phy_write(phydev, MII_88E1121_PHY_LED_CTRL,
685 MII_88E1121_PHY_LED_DEF);
686 if (err < 0)
687 return err;
688
689 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
690
691 /* Set marvell,reg-init configuration from device tree */
692 return marvell_config_init(phydev);
693}
694
639static int m88e1510_config_init(struct phy_device *phydev) 695static int m88e1510_config_init(struct phy_device *phydev)
640{ 696{
641 int err; 697 int err;
@@ -668,7 +724,7 @@ static int m88e1510_config_init(struct phy_device *phydev)
668 return err; 724 return err;
669 } 725 }
670 726
671 return marvell_config_init(phydev); 727 return m88e1121_config_init(phydev);
672} 728}
673 729
674static int m88e1118_config_aneg(struct phy_device *phydev) 730static int m88e1118_config_aneg(struct phy_device *phydev)
@@ -1161,7 +1217,7 @@ static struct phy_driver marvell_drivers[] = {
1161 .flags = PHY_HAS_INTERRUPT, 1217 .flags = PHY_HAS_INTERRUPT,
1162 .probe = marvell_probe, 1218 .probe = marvell_probe,
1163 .config_init = &m88e1111_config_init, 1219 .config_init = &m88e1111_config_init,
1164 .config_aneg = &marvell_config_aneg, 1220 .config_aneg = &m88e1111_config_aneg,
1165 .read_status = &marvell_read_status, 1221 .read_status = &marvell_read_status,
1166 .ack_interrupt = &marvell_ack_interrupt, 1222 .ack_interrupt = &marvell_ack_interrupt,
1167 .config_intr = &marvell_config_intr, 1223 .config_intr = &marvell_config_intr,
@@ -1196,7 +1252,7 @@ static struct phy_driver marvell_drivers[] = {
1196 .features = PHY_GBIT_FEATURES, 1252 .features = PHY_GBIT_FEATURES,
1197 .flags = PHY_HAS_INTERRUPT, 1253 .flags = PHY_HAS_INTERRUPT,
1198 .probe = marvell_probe, 1254 .probe = marvell_probe,
1199 .config_init = &marvell_config_init, 1255 .config_init = &m88e1121_config_init,
1200 .config_aneg = &m88e1121_config_aneg, 1256 .config_aneg = &m88e1121_config_aneg,
1201 .read_status = &marvell_read_status, 1257 .read_status = &marvell_read_status,
1202 .ack_interrupt = &marvell_ack_interrupt, 1258 .ack_interrupt = &marvell_ack_interrupt,
@@ -1215,7 +1271,7 @@ static struct phy_driver marvell_drivers[] = {
1215 .features = PHY_GBIT_FEATURES, 1271 .features = PHY_GBIT_FEATURES,
1216 .flags = PHY_HAS_INTERRUPT, 1272 .flags = PHY_HAS_INTERRUPT,
1217 .probe = marvell_probe, 1273 .probe = marvell_probe,
1218 .config_init = &marvell_config_init, 1274 .config_init = &m88e1121_config_init,
1219 .config_aneg = &m88e1318_config_aneg, 1275 .config_aneg = &m88e1318_config_aneg,
1220 .read_status = &marvell_read_status, 1276 .read_status = &marvell_read_status,
1221 .ack_interrupt = &marvell_ack_interrupt, 1277 .ack_interrupt = &marvell_ack_interrupt,
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 2e21e9366f76..b62c4aaee40b 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -75,22 +75,13 @@ static int smsc_phy_reset(struct phy_device *phydev)
75 * in all capable mode before using it. 75 * in all capable mode before using it.
76 */ 76 */
77 if ((rc & MII_LAN83C185_MODE_MASK) == MII_LAN83C185_MODE_POWERDOWN) { 77 if ((rc & MII_LAN83C185_MODE_MASK) == MII_LAN83C185_MODE_POWERDOWN) {
78 int timeout = 50000; 78 /* set "all capable" mode */
79
80 /* set "all capable" mode and reset the phy */
81 rc |= MII_LAN83C185_MODE_ALL; 79 rc |= MII_LAN83C185_MODE_ALL;
82 phy_write(phydev, MII_LAN83C185_SPECIAL_MODES, rc); 80 phy_write(phydev, MII_LAN83C185_SPECIAL_MODES, rc);
83 phy_write(phydev, MII_BMCR, BMCR_RESET);
84
85 /* wait end of reset (max 500 ms) */
86 do {
87 udelay(10);
88 if (timeout-- == 0)
89 return -1;
90 rc = phy_read(phydev, MII_BMCR);
91 } while (rc & BMCR_RESET);
92 } 81 }
93 return 0; 82
83 /* reset the phy */
84 return genphy_soft_reset(phydev);
94} 85}
95 86
96static int lan911x_config_init(struct phy_device *phydev) 87static int lan911x_config_init(struct phy_device *phydev)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 2ace126533cd..fdee77207323 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1203,8 +1203,10 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
1203 goto err_dev_open; 1203 goto err_dev_open;
1204 } 1204 }
1205 1205
1206 netif_addr_lock_bh(dev);
1206 dev_uc_sync_multiple(port_dev, dev); 1207 dev_uc_sync_multiple(port_dev, dev);
1207 dev_mc_sync_multiple(port_dev, dev); 1208 dev_mc_sync_multiple(port_dev, dev);
1209 netif_addr_unlock_bh(dev);
1208 1210
1209 err = vlan_vids_add_by_dev(port_dev, dev); 1211 err = vlan_vids_add_by_dev(port_dev, dev);
1210 if (err) { 1212 if (err) {
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 3f9f6ed3eec4..4e257b8d8f3e 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -31,7 +31,7 @@
31#define NETNEXT_VERSION "08" 31#define NETNEXT_VERSION "08"
32 32
33/* Information for net */ 33/* Information for net */
34#define NET_VERSION "3" 34#define NET_VERSION "4"
35 35
36#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 36#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
37#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" 37#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
@@ -116,6 +116,7 @@
116#define USB_TX_DMA 0xd434 116#define USB_TX_DMA 0xd434
117#define USB_TOLERANCE 0xd490 117#define USB_TOLERANCE 0xd490
118#define USB_LPM_CTRL 0xd41a 118#define USB_LPM_CTRL 0xd41a
119#define USB_BMU_RESET 0xd4b0
119#define USB_UPS_CTRL 0xd800 120#define USB_UPS_CTRL 0xd800
120#define USB_MISC_0 0xd81a 121#define USB_MISC_0 0xd81a
121#define USB_POWER_CUT 0xd80a 122#define USB_POWER_CUT 0xd80a
@@ -338,6 +339,10 @@
338#define TEST_MODE_DISABLE 0x00000001 339#define TEST_MODE_DISABLE 0x00000001
339#define TX_SIZE_ADJUST1 0x00000100 340#define TX_SIZE_ADJUST1 0x00000100
340 341
342/* USB_BMU_RESET */
343#define BMU_RESET_EP_IN 0x01
344#define BMU_RESET_EP_OUT 0x02
345
341/* USB_UPS_CTRL */ 346/* USB_UPS_CTRL */
342#define POWER_CUT 0x0100 347#define POWER_CUT 0x0100
343 348
@@ -2169,7 +2174,7 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp)
2169static void r8153_set_rx_early_size(struct r8152 *tp) 2174static void r8153_set_rx_early_size(struct r8152 *tp)
2170{ 2175{
2171 u32 mtu = tp->netdev->mtu; 2176 u32 mtu = tp->netdev->mtu;
2172 u32 ocp_data = (agg_buf_sz - mtu - VLAN_ETH_HLEN - VLAN_HLEN) / 4; 2177 u32 ocp_data = (agg_buf_sz - mtu - VLAN_ETH_HLEN - VLAN_HLEN) / 8;
2173 2178
2174 ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data); 2179 ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data);
2175} 2180}
@@ -2456,6 +2461,17 @@ static void r8153_teredo_off(struct r8152 *tp)
2456 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TEREDO_TIMER, 0); 2461 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TEREDO_TIMER, 0);
2457} 2462}
2458 2463
2464static void rtl_reset_bmu(struct r8152 *tp)
2465{
2466 u32 ocp_data;
2467
2468 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_BMU_RESET);
2469 ocp_data &= ~(BMU_RESET_EP_IN | BMU_RESET_EP_OUT);
2470 ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_RESET, ocp_data);
2471 ocp_data |= BMU_RESET_EP_IN | BMU_RESET_EP_OUT;
2472 ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_RESET, ocp_data);
2473}
2474
2459static void r8152_aldps_en(struct r8152 *tp, bool enable) 2475static void r8152_aldps_en(struct r8152 *tp, bool enable)
2460{ 2476{
2461 if (enable) { 2477 if (enable) {
@@ -2681,6 +2697,7 @@ static void r8153_first_init(struct r8152 *tp)
2681 r8153_hw_phy_cfg(tp); 2697 r8153_hw_phy_cfg(tp);
2682 2698
2683 rtl8152_nic_reset(tp); 2699 rtl8152_nic_reset(tp);
2700 rtl_reset_bmu(tp);
2684 2701
2685 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 2702 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
2686 ocp_data &= ~NOW_IS_OOB; 2703 ocp_data &= ~NOW_IS_OOB;
@@ -2742,6 +2759,7 @@ static void r8153_enter_oob(struct r8152 *tp)
2742 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); 2759 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
2743 2760
2744 rtl_disable(tp); 2761 rtl_disable(tp);
2762 rtl_reset_bmu(tp);
2745 2763
2746 for (i = 0; i < 1000; i++) { 2764 for (i = 0; i < 1000; i++) {
2747 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 2765 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -2803,6 +2821,7 @@ static void rtl8153_disable(struct r8152 *tp)
2803{ 2821{
2804 r8153_aldps_en(tp, false); 2822 r8153_aldps_en(tp, false);
2805 rtl_disable(tp); 2823 rtl_disable(tp);
2824 rtl_reset_bmu(tp);
2806 r8153_aldps_en(tp, true); 2825 r8153_aldps_en(tp, true);
2807 usb_enable_lpm(tp->udev); 2826 usb_enable_lpm(tp->udev);
2808} 2827}
@@ -3382,15 +3401,11 @@ static void r8153_init(struct r8152 *tp)
3382 r8153_power_cut_en(tp, false); 3401 r8153_power_cut_en(tp, false);
3383 r8153_u1u2en(tp, true); 3402 r8153_u1u2en(tp, true);
3384 3403
3385 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, ALDPS_SPDWN_RATIO); 3404 /* MAC clock speed down */
3386 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, EEE_SPDWN_RATIO); 3405 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, 0);
3387 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 3406 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, 0);
3388 PKT_AVAIL_SPDWN_EN | SUSPEND_SPDWN_EN | 3407 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 0);
3389 U1U2_SPDWN_EN | L1_SPDWN_EN); 3408 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, 0);
3390 ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4,
3391 PWRSAVE_SPDWN_EN | RXDV_SPDWN_EN | TX10MIDLE_EN |
3392 TP100_SPDWN_EN | TP500_SPDWN_EN | TP1000_SPDWN_EN |
3393 EEE_SPDWN_EN);
3394 3409
3395 r8153_enable_eee(tp); 3410 r8153_enable_eee(tp);
3396 r8153_aldps_en(tp, true); 3411 r8153_aldps_en(tp, true);
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index dff08842f26d..8bd8c7e1ee87 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -304,7 +304,7 @@ static int vrf_rt6_create(struct net_device *dev)
304 dst_hold(&rt6->dst); 304 dst_hold(&rt6->dst);
305 305
306 rt6->rt6i_table = rt6i_table; 306 rt6->rt6i_table = rt6i_table;
307 rt6->dst.output = vrf_output6; 307 rt6->dst.output = vrf_output6;
308 rcu_assign_pointer(vrf->rt6, rt6); 308 rcu_assign_pointer(vrf->rt6, rt6);
309 309
310 rc = 0; 310 rc = 0;
@@ -403,7 +403,7 @@ static int vrf_rtable_create(struct net_device *dev)
403 if (!rth) 403 if (!rth)
404 return -ENOMEM; 404 return -ENOMEM;
405 405
406 rth->dst.output = vrf_output; 406 rth->dst.output = vrf_output;
407 rth->rt_table_id = vrf->tb_id; 407 rth->rt_table_id = vrf->tb_id;
408 408
409 rcu_assign_pointer(vrf->rth, rth); 409 rcu_assign_pointer(vrf->rth, rth);
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index f999db2f97b4..b3b9db68f758 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2952,30 +2952,6 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
2952 return 0; 2952 return 0;
2953} 2953}
2954 2954
2955struct net_device *vxlan_dev_create(struct net *net, const char *name,
2956 u8 name_assign_type, struct vxlan_config *conf)
2957{
2958 struct nlattr *tb[IFLA_MAX+1];
2959 struct net_device *dev;
2960 int err;
2961
2962 memset(&tb, 0, sizeof(tb));
2963
2964 dev = rtnl_create_link(net, name, name_assign_type,
2965 &vxlan_link_ops, tb);
2966 if (IS_ERR(dev))
2967 return dev;
2968
2969 err = vxlan_dev_configure(net, dev, conf);
2970 if (err < 0) {
2971 free_netdev(dev);
2972 return ERR_PTR(err);
2973 }
2974
2975 return dev;
2976}
2977EXPORT_SYMBOL_GPL(vxlan_dev_create);
2978
2979static int vxlan_newlink(struct net *src_net, struct net_device *dev, 2955static int vxlan_newlink(struct net *src_net, struct net_device *dev,
2980 struct nlattr *tb[], struct nlattr *data[]) 2956 struct nlattr *tb[], struct nlattr *data[])
2981{ 2957{
@@ -3268,6 +3244,40 @@ static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
3268 .get_link_net = vxlan_get_link_net, 3244 .get_link_net = vxlan_get_link_net,
3269}; 3245};
3270 3246
3247struct net_device *vxlan_dev_create(struct net *net, const char *name,
3248 u8 name_assign_type,
3249 struct vxlan_config *conf)
3250{
3251 struct nlattr *tb[IFLA_MAX + 1];
3252 struct net_device *dev;
3253 int err;
3254
3255 memset(&tb, 0, sizeof(tb));
3256
3257 dev = rtnl_create_link(net, name, name_assign_type,
3258 &vxlan_link_ops, tb);
3259 if (IS_ERR(dev))
3260 return dev;
3261
3262 err = vxlan_dev_configure(net, dev, conf);
3263 if (err < 0) {
3264 free_netdev(dev);
3265 return ERR_PTR(err);
3266 }
3267
3268 err = rtnl_configure_link(dev, NULL);
3269 if (err < 0) {
3270 LIST_HEAD(list_kill);
3271
3272 vxlan_dellink(dev, &list_kill);
3273 unregister_netdevice_many(&list_kill);
3274 return ERR_PTR(err);
3275 }
3276
3277 return dev;
3278}
3279EXPORT_SYMBOL_GPL(vxlan_dev_create);
3280
3271static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn, 3281static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,
3272 struct net_device *dev) 3282 struct net_device *dev)
3273{ 3283{
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 49af62428c88..a92a0ba829f5 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1083,7 +1083,7 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
1083 } 1083 }
1084 1084
1085 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "features", "", 1085 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "features", "",
1086 ar->running_fw->fw_file.fw_features, 1086 fw_file->fw_features,
1087 sizeof(fw_file->fw_features)); 1087 sizeof(fw_file->fw_features));
1088 break; 1088 break;
1089 case ATH10K_FW_IE_FW_IMAGE: 1089 case ATH10K_FW_IE_FW_IMAGE:
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index cc979a4faeb0..813cdd2621a1 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1904,7 +1904,6 @@ static void ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb)
1904 return; 1904 return;
1905 } 1905 }
1906 } 1906 }
1907 ath10k_htt_rx_msdu_buff_replenish(htt);
1908} 1907}
1909 1908
1910static void ath10k_htt_rx_tx_fetch_resp_id_confirm(struct ath10k *ar, 1909static void ath10k_htt_rx_tx_fetch_resp_id_confirm(struct ath10k *ar,
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 6dd1d26b357f..4040f9413e86 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -679,10 +679,10 @@ static int ath10k_peer_create(struct ath10k *ar,
679 679
680 peer = ath10k_peer_find(ar, vdev_id, addr); 680 peer = ath10k_peer_find(ar, vdev_id, addr);
681 if (!peer) { 681 if (!peer) {
682 spin_unlock_bh(&ar->data_lock);
682 ath10k_warn(ar, "failed to find peer %pM on vdev %i after creation\n", 683 ath10k_warn(ar, "failed to find peer %pM on vdev %i after creation\n",
683 addr, vdev_id); 684 addr, vdev_id);
684 ath10k_wmi_peer_delete(ar, vdev_id, addr); 685 ath10k_wmi_peer_delete(ar, vdev_id, addr);
685 spin_unlock_bh(&ar->data_lock);
686 return -ENOENT; 686 return -ENOENT;
687 } 687 }
688 688
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 9272ca90632b..80ff69f99229 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -1122,12 +1122,12 @@ enum {
1122#define AR9300_NUM_GPIO 16 1122#define AR9300_NUM_GPIO 16
1123#define AR9330_NUM_GPIO 16 1123#define AR9330_NUM_GPIO 16
1124#define AR9340_NUM_GPIO 23 1124#define AR9340_NUM_GPIO 23
1125#define AR9462_NUM_GPIO 10 1125#define AR9462_NUM_GPIO 14
1126#define AR9485_NUM_GPIO 12 1126#define AR9485_NUM_GPIO 12
1127#define AR9531_NUM_GPIO 18 1127#define AR9531_NUM_GPIO 18
1128#define AR9550_NUM_GPIO 24 1128#define AR9550_NUM_GPIO 24
1129#define AR9561_NUM_GPIO 23 1129#define AR9561_NUM_GPIO 23
1130#define AR9565_NUM_GPIO 12 1130#define AR9565_NUM_GPIO 14
1131#define AR9580_NUM_GPIO 16 1131#define AR9580_NUM_GPIO 16
1132#define AR7010_NUM_GPIO 16 1132#define AR7010_NUM_GPIO 16
1133 1133
@@ -1139,12 +1139,12 @@ enum {
1139#define AR9300_GPIO_MASK 0x0000F4FF 1139#define AR9300_GPIO_MASK 0x0000F4FF
1140#define AR9330_GPIO_MASK 0x0000F4FF 1140#define AR9330_GPIO_MASK 0x0000F4FF
1141#define AR9340_GPIO_MASK 0x0000000F 1141#define AR9340_GPIO_MASK 0x0000000F
1142#define AR9462_GPIO_MASK 0x000003FF 1142#define AR9462_GPIO_MASK 0x00003FFF
1143#define AR9485_GPIO_MASK 0x00000FFF 1143#define AR9485_GPIO_MASK 0x00000FFF
1144#define AR9531_GPIO_MASK 0x0000000F 1144#define AR9531_GPIO_MASK 0x0000000F
1145#define AR9550_GPIO_MASK 0x0000000F 1145#define AR9550_GPIO_MASK 0x0000000F
1146#define AR9561_GPIO_MASK 0x0000000F 1146#define AR9561_GPIO_MASK 0x0000000F
1147#define AR9565_GPIO_MASK 0x00000FFF 1147#define AR9565_GPIO_MASK 0x00003FFF
1148#define AR9580_GPIO_MASK 0x0000F4FF 1148#define AR9580_GPIO_MASK 0x0000F4FF
1149#define AR7010_GPIO_MASK 0x0000FFFF 1149#define AR7010_GPIO_MASK 0x0000FFFF
1150 1150
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index e5f267b21316..18a8474b5760 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -3851,8 +3851,8 @@ static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
3851 if (idx != 0) 3851 if (idx != 0)
3852 return -ENOENT; 3852 return -ENOENT;
3853 3853
3854 if (fw_has_capa(&mvm->fw->ucode_capa, 3854 if (!fw_has_capa(&mvm->fw->ucode_capa,
3855 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) 3855 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS))
3856 return -ENOENT; 3856 return -ENOENT;
3857 3857
3858 mutex_lock(&mvm->mutex); 3858 mutex_lock(&mvm->mutex);
@@ -3898,8 +3898,8 @@ static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw,
3898 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 3898 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
3899 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 3899 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
3900 3900
3901 if (fw_has_capa(&mvm->fw->ucode_capa, 3901 if (!fw_has_capa(&mvm->fw->ucode_capa,
3902 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) 3902 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS))
3903 return; 3903 return;
3904 3904
3905 /* if beacon filtering isn't on mac80211 does it anyway */ 3905 /* if beacon filtering isn't on mac80211 does it anyway */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index ac2c5718e454..2c61516d06ff 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -581,7 +581,7 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
581 struct iwl_rx_mpdu_desc *desc) 581 struct iwl_rx_mpdu_desc *desc)
582{ 582{
583 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 583 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
584 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); 584 struct iwl_mvm_sta *mvm_sta;
585 struct iwl_mvm_baid_data *baid_data; 585 struct iwl_mvm_baid_data *baid_data;
586 struct iwl_mvm_reorder_buffer *buffer; 586 struct iwl_mvm_reorder_buffer *buffer;
587 struct sk_buff *tail; 587 struct sk_buff *tail;
@@ -604,6 +604,8 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
604 if (WARN_ON(IS_ERR_OR_NULL(sta))) 604 if (WARN_ON(IS_ERR_OR_NULL(sta)))
605 return false; 605 return false;
606 606
607 mvm_sta = iwl_mvm_sta_from_mac80211(sta);
608
607 /* not a data packet */ 609 /* not a data packet */
608 if (!ieee80211_is_data_qos(hdr->frame_control) || 610 if (!ieee80211_is_data_qos(hdr->frame_control) ||
609 is_multicast_ether_addr(hdr->addr1)) 611 is_multicast_ether_addr(hdr->addr1))
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
index 6f609dd5c222..e78fc567ff7d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
@@ -1222,7 +1222,7 @@ static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
1222 return -EIO; 1222 return -EIO;
1223} 1223}
1224 1224
1225#define SCAN_TIMEOUT (16 * HZ) 1225#define SCAN_TIMEOUT (20 * HZ)
1226 1226
1227void iwl_mvm_scan_timeout(unsigned long data) 1227void iwl_mvm_scan_timeout(unsigned long data)
1228{ 1228{
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index fea4d3437e2f..b23ab4a4504f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -1852,12 +1852,18 @@ static struct iwl_mvm_sta *iwl_mvm_get_key_sta(struct iwl_mvm *mvm,
1852 mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { 1852 mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
1853 u8 sta_id = mvmvif->ap_sta_id; 1853 u8 sta_id = mvmvif->ap_sta_id;
1854 1854
1855 sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id],
1856 lockdep_is_held(&mvm->mutex));
1857
1855 /* 1858 /*
1856 * It is possible that the 'sta' parameter is NULL, 1859 * It is possible that the 'sta' parameter is NULL,
1857 * for example when a GTK is removed - the sta_id will then 1860 * for example when a GTK is removed - the sta_id will then
1858 * be the AP ID, and no station was passed by mac80211. 1861 * be the AP ID, and no station was passed by mac80211.
1859 */ 1862 */
1860 return iwl_mvm_sta_from_staid_protected(mvm, sta_id); 1863 if (IS_ERR_OR_NULL(sta))
1864 return NULL;
1865
1866 return iwl_mvm_sta_from_mac80211(sta);
1861 } 1867 }
1862 1868
1863 return NULL; 1869 return NULL;
@@ -1955,6 +1961,14 @@ static int iwl_mvm_send_sta_igtk(struct iwl_mvm *mvm,
1955 struct ieee80211_key_seq seq; 1961 struct ieee80211_key_seq seq;
1956 const u8 *pn; 1962 const u8 *pn;
1957 1963
1964 switch (keyconf->cipher) {
1965 case WLAN_CIPHER_SUITE_AES_CMAC:
1966 igtk_cmd.ctrl_flags |= cpu_to_le32(STA_KEY_FLG_CCM);
1967 break;
1968 default:
1969 return -EINVAL;
1970 }
1971
1958 memcpy(igtk_cmd.IGTK, keyconf->key, keyconf->keylen); 1972 memcpy(igtk_cmd.IGTK, keyconf->key, keyconf->keylen);
1959 ieee80211_get_key_rx_seq(keyconf, 0, &seq); 1973 ieee80211_get_key_rx_seq(keyconf, 0, &seq);
1960 pn = seq.aes_cmac.pn; 1974 pn = seq.aes_cmac.pn;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index fe19ace0d6a0..b04cf30f3959 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -1149,7 +1149,7 @@ static void rtl8192eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv,
1149 1149
1150 for (i = 0; i < retry; i++) { 1150 for (i = 0; i < retry; i++) {
1151 path_b_ok = rtl8192eu_rx_iqk_path_b(priv); 1151 path_b_ok = rtl8192eu_rx_iqk_path_b(priv);
1152 if (path_a_ok == 0x03) { 1152 if (path_b_ok == 0x03) {
1153 val32 = rtl8xxxu_read32(priv, 1153 val32 = rtl8xxxu_read32(priv,
1154 REG_RX_POWER_BEFORE_IQK_B_2); 1154 REG_RX_POWER_BEFORE_IQK_B_2);
1155 result[t][6] = (val32 >> 16) & 0x3ff; 1155 result[t][6] = (val32 >> 16) & 0x3ff;
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index f7718ec685fa..cea8350fbc7e 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -344,6 +344,8 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
344int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) 344int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
345{ 345{
346 u64 checksum, offset; 346 u64 checksum, offset;
347 unsigned long align;
348 enum nd_pfn_mode mode;
347 struct nd_namespace_io *nsio; 349 struct nd_namespace_io *nsio;
348 struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; 350 struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
349 struct nd_namespace_common *ndns = nd_pfn->ndns; 351 struct nd_namespace_common *ndns = nd_pfn->ndns;
@@ -386,22 +388,50 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
386 return -ENXIO; 388 return -ENXIO;
387 } 389 }
388 390
391 align = le32_to_cpu(pfn_sb->align);
392 offset = le64_to_cpu(pfn_sb->dataoff);
393 if (align == 0)
394 align = 1UL << ilog2(offset);
395 mode = le32_to_cpu(pfn_sb->mode);
396
389 if (!nd_pfn->uuid) { 397 if (!nd_pfn->uuid) {
390 /* from probe we allocate */ 398 /*
399 * When probing a namepace via nd_pfn_probe() the uuid
400 * is NULL (see: nd_pfn_devinit()) we init settings from
401 * pfn_sb
402 */
391 nd_pfn->uuid = kmemdup(pfn_sb->uuid, 16, GFP_KERNEL); 403 nd_pfn->uuid = kmemdup(pfn_sb->uuid, 16, GFP_KERNEL);
392 if (!nd_pfn->uuid) 404 if (!nd_pfn->uuid)
393 return -ENOMEM; 405 return -ENOMEM;
406 nd_pfn->align = align;
407 nd_pfn->mode = mode;
394 } else { 408 } else {
395 /* from init we validate */ 409 /*
410 * When probing a pfn / dax instance we validate the
411 * live settings against the pfn_sb
412 */
396 if (memcmp(nd_pfn->uuid, pfn_sb->uuid, 16) != 0) 413 if (memcmp(nd_pfn->uuid, pfn_sb->uuid, 16) != 0)
397 return -ENODEV; 414 return -ENODEV;
415
416 /*
417 * If the uuid validates, but other settings mismatch
418 * return EINVAL because userspace has managed to change
419 * the configuration without specifying new
420 * identification.
421 */
422 if (nd_pfn->align != align || nd_pfn->mode != mode) {
423 dev_err(&nd_pfn->dev,
424 "init failed, settings mismatch\n");
425 dev_dbg(&nd_pfn->dev, "align: %lx:%lx mode: %d:%d\n",
426 nd_pfn->align, align, nd_pfn->mode,
427 mode);
428 return -EINVAL;
429 }
398 } 430 }
399 431
400 if (nd_pfn->align == 0) 432 if (align > nvdimm_namespace_capacity(ndns)) {
401 nd_pfn->align = le32_to_cpu(pfn_sb->align);
402 if (nd_pfn->align > nvdimm_namespace_capacity(ndns)) {
403 dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n", 433 dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n",
404 nd_pfn->align, nvdimm_namespace_capacity(ndns)); 434 align, nvdimm_namespace_capacity(ndns));
405 return -EINVAL; 435 return -EINVAL;
406 } 436 }
407 437
@@ -411,7 +441,6 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
411 * namespace has changed since the pfn superblock was 441 * namespace has changed since the pfn superblock was
412 * established. 442 * established.
413 */ 443 */
414 offset = le64_to_cpu(pfn_sb->dataoff);
415 nsio = to_nd_namespace_io(&ndns->dev); 444 nsio = to_nd_namespace_io(&ndns->dev);
416 if (offset >= resource_size(&nsio->res)) { 445 if (offset >= resource_size(&nsio->res)) {
417 dev_err(&nd_pfn->dev, "pfn array size exceeds capacity of %s\n", 446 dev_err(&nd_pfn->dev, "pfn array size exceeds capacity of %s\n",
@@ -419,10 +448,11 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
419 return -EBUSY; 448 return -EBUSY;
420 } 449 }
421 450
422 if ((nd_pfn->align && !IS_ALIGNED(offset, nd_pfn->align)) 451 if ((align && !IS_ALIGNED(offset, align))
423 || !IS_ALIGNED(offset, PAGE_SIZE)) { 452 || !IS_ALIGNED(offset, PAGE_SIZE)) {
424 dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n", 453 dev_err(&nd_pfn->dev,
425 offset); 454 "bad offset: %#llx dax disabled align: %#lx\n",
455 offset, align);
426 return -ENXIO; 456 return -ENXIO;
427 } 457 }
428 458
@@ -502,7 +532,6 @@ static struct vmem_altmap *__nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
502 res->start += start_pad; 532 res->start += start_pad;
503 res->end -= end_trunc; 533 res->end -= end_trunc;
504 534
505 nd_pfn->mode = le32_to_cpu(nd_pfn->pfn_sb->mode);
506 if (nd_pfn->mode == PFN_MODE_RAM) { 535 if (nd_pfn->mode == PFN_MODE_RAM) {
507 if (offset < SZ_8K) 536 if (offset < SZ_8K)
508 return ERR_PTR(-EINVAL); 537 return ERR_PTR(-EINVAL);
diff --git a/drivers/phy/phy-bcm-ns-usb2.c b/drivers/phy/phy-bcm-ns-usb2.c
index 95ab6b2a0de5..58dff80e9386 100644
--- a/drivers/phy/phy-bcm-ns-usb2.c
+++ b/drivers/phy/phy-bcm-ns-usb2.c
@@ -109,8 +109,8 @@ static int bcm_ns_usb2_probe(struct platform_device *pdev)
109 } 109 }
110 110
111 usb2->phy = devm_phy_create(dev, NULL, &ops); 111 usb2->phy = devm_phy_create(dev, NULL, &ops);
112 if (IS_ERR(dev)) 112 if (IS_ERR(usb2->phy))
113 return PTR_ERR(dev); 113 return PTR_ERR(usb2->phy);
114 114
115 phy_set_drvdata(usb2->phy, usb2); 115 phy_set_drvdata(usb2->phy, usb2);
116 platform_set_drvdata(pdev, usb2); 116 platform_set_drvdata(pdev, usb2);
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 3acd2a1808df..213e2e15339c 100644
--- a/drivers/phy/phy-miphy28lp.c
+++ b/drivers/phy/phy-miphy28lp.c
@@ -1143,7 +1143,8 @@ static int miphy28lp_probe_resets(struct device_node *node,
1143 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; 1143 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
1144 int err; 1144 int err;
1145 1145
1146 miphy_phy->miphy_rst = of_reset_control_get(node, "miphy-sw-rst"); 1146 miphy_phy->miphy_rst =
1147 of_reset_control_get_shared(node, "miphy-sw-rst");
1147 1148
1148 if (IS_ERR(miphy_phy->miphy_rst)) { 1149 if (IS_ERR(miphy_phy->miphy_rst)) {
1149 dev_err(miphy_dev->dev, 1150 dev_err(miphy_dev->dev,
diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
index 76bb88f0700a..4be3f5dbbc9f 100644
--- a/drivers/phy/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/phy-rcar-gen3-usb2.c
@@ -144,12 +144,6 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch)
144 extcon_set_cable_state_(ch->extcon, EXTCON_USB, true); 144 extcon_set_cable_state_(ch->extcon, EXTCON_USB, true);
145} 145}
146 146
147static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch)
148{
149 return !!(readl(ch->base + USB2_ADPCTRL) &
150 USB2_ADPCTRL_OTGSESSVLD);
151}
152
153static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) 147static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
154{ 148{
155 return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); 149 return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
@@ -157,13 +151,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
157 151
158static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch) 152static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
159{ 153{
160 bool is_host = true; 154 if (!rcar_gen3_check_id(ch))
161
162 /* B-device? */
163 if (rcar_gen3_check_id(ch) && rcar_gen3_check_vbus(ch))
164 is_host = false;
165
166 if (is_host)
167 rcar_gen3_init_for_host(ch); 155 rcar_gen3_init_for_host(ch);
168 else 156 else
169 rcar_gen3_init_for_peri(ch); 157 rcar_gen3_init_for_peri(ch);
diff --git a/drivers/phy/phy-rockchip-dp.c b/drivers/phy/phy-rockchip-dp.c
index 793ecb6d87bc..8b267a746576 100644
--- a/drivers/phy/phy-rockchip-dp.c
+++ b/drivers/phy/phy-rockchip-dp.c
@@ -90,7 +90,7 @@ static int rockchip_dp_phy_probe(struct platform_device *pdev)
90 return -ENODEV; 90 return -ENODEV;
91 91
92 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL); 92 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
93 if (IS_ERR(dp)) 93 if (!dp)
94 return -ENOMEM; 94 return -ENOMEM;
95 95
96 dp->dev = dev; 96 dp->dev = dev;
diff --git a/drivers/phy/phy-stih407-usb.c b/drivers/phy/phy-stih407-usb.c
index 1d5ae5f8ef69..b1f44ab669fb 100644
--- a/drivers/phy/phy-stih407-usb.c
+++ b/drivers/phy/phy-stih407-usb.c
@@ -105,13 +105,13 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
105 phy_dev->dev = dev; 105 phy_dev->dev = dev;
106 dev_set_drvdata(dev, phy_dev); 106 dev_set_drvdata(dev, phy_dev);
107 107
108 phy_dev->rstc = devm_reset_control_get(dev, "global"); 108 phy_dev->rstc = devm_reset_control_get_shared(dev, "global");
109 if (IS_ERR(phy_dev->rstc)) { 109 if (IS_ERR(phy_dev->rstc)) {
110 dev_err(dev, "failed to ctrl picoPHY reset\n"); 110 dev_err(dev, "failed to ctrl picoPHY reset\n");
111 return PTR_ERR(phy_dev->rstc); 111 return PTR_ERR(phy_dev->rstc);
112 } 112 }
113 113
114 phy_dev->rstport = devm_reset_control_get(dev, "port"); 114 phy_dev->rstport = devm_reset_control_get_exclusive(dev, "port");
115 if (IS_ERR(phy_dev->rstport)) { 115 if (IS_ERR(phy_dev->rstport)) {
116 dev_err(dev, "failed to ctrl picoPHY reset\n"); 116 dev_err(dev, "failed to ctrl picoPHY reset\n");
117 return PTR_ERR(phy_dev->rstport); 117 return PTR_ERR(phy_dev->rstport);
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index bae54f7a1f48..de3101fbbf40 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -175,7 +175,7 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data,
175{ 175{
176 struct sun4i_usb_phy_data *phy_data = to_sun4i_usb_phy_data(phy); 176 struct sun4i_usb_phy_data *phy_data = to_sun4i_usb_phy_data(phy);
177 u32 temp, usbc_bit = BIT(phy->index * 2); 177 u32 temp, usbc_bit = BIT(phy->index * 2);
178 void *phyctl = phy_data->base + phy_data->cfg->phyctl_offset; 178 void __iomem *phyctl = phy_data->base + phy_data->cfg->phyctl_offset;
179 int i; 179 int i;
180 180
181 mutex_lock(&phy_data->mutex); 181 mutex_lock(&phy_data->mutex);
@@ -514,9 +514,9 @@ static int sun4i_usb_phy_remove(struct platform_device *pdev)
514 514
515 if (data->vbus_power_nb_registered) 515 if (data->vbus_power_nb_registered)
516 power_supply_unreg_notifier(&data->vbus_power_nb); 516 power_supply_unreg_notifier(&data->vbus_power_nb);
517 if (data->id_det_irq >= 0) 517 if (data->id_det_irq > 0)
518 devm_free_irq(dev, data->id_det_irq, data); 518 devm_free_irq(dev, data->id_det_irq, data);
519 if (data->vbus_det_irq >= 0) 519 if (data->vbus_det_irq > 0)
520 devm_free_irq(dev, data->vbus_det_irq, data); 520 devm_free_irq(dev, data->vbus_det_irq, data);
521 521
522 cancel_delayed_work_sync(&data->detect); 522 cancel_delayed_work_sync(&data->detect);
@@ -645,11 +645,11 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
645 645
646 data->id_det_irq = gpiod_to_irq(data->id_det_gpio); 646 data->id_det_irq = gpiod_to_irq(data->id_det_gpio);
647 data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio); 647 data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio);
648 if ((data->id_det_gpio && data->id_det_irq < 0) || 648 if ((data->id_det_gpio && data->id_det_irq <= 0) ||
649 (data->vbus_det_gpio && data->vbus_det_irq < 0)) 649 (data->vbus_det_gpio && data->vbus_det_irq <= 0))
650 data->phy0_poll = true; 650 data->phy0_poll = true;
651 651
652 if (data->id_det_irq >= 0) { 652 if (data->id_det_irq > 0) {
653 ret = devm_request_irq(dev, data->id_det_irq, 653 ret = devm_request_irq(dev, data->id_det_irq,
654 sun4i_usb_phy0_id_vbus_det_irq, 654 sun4i_usb_phy0_id_vbus_det_irq,
655 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 655 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
@@ -660,7 +660,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
660 } 660 }
661 } 661 }
662 662
663 if (data->vbus_det_irq >= 0) { 663 if (data->vbus_det_irq > 0) {
664 ret = devm_request_irq(dev, data->vbus_det_irq, 664 ret = devm_request_irq(dev, data->vbus_det_irq,
665 sun4i_usb_phy0_id_vbus_det_irq, 665 sun4i_usb_phy0_id_vbus_det_irq,
666 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 666 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index e4bc1151e04f..42a5c1dddfef 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o
23obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o 23obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o
24obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o 24obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o
25obj-$(CONFIG_PINCTRL_SIRF) += sirf/ 25obj-$(CONFIG_PINCTRL_SIRF) += sirf/
26obj-$(CONFIG_PINCTRL_TEGRA) += tegra/ 26obj-$(CONFIG_ARCH_TEGRA) += tegra/
27obj-$(CONFIG_PINCTRL_TZ1090) += pinctrl-tz1090.o 27obj-$(CONFIG_PINCTRL_TZ1090) += pinctrl-tz1090.o
28obj-$(CONFIG_PINCTRL_TZ1090_PDC) += pinctrl-tz1090-pdc.o 28obj-$(CONFIG_PINCTRL_TZ1090_PDC) += pinctrl-tz1090-pdc.o
29obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o 29obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 47ccfcc8a647..eccb47480e1d 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -209,9 +209,9 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
209 pin_reg = &info->pin_regs[pin_id]; 209 pin_reg = &info->pin_regs[pin_id];
210 210
211 if (pin_reg->mux_reg == -1) { 211 if (pin_reg->mux_reg == -1) {
212 dev_err(ipctl->dev, "Pin(%s) does not support mux function\n", 212 dev_dbg(ipctl->dev, "Pin(%s) does not support mux function\n",
213 info->pins[pin_id].name); 213 info->pins[pin_id].name);
214 return -EINVAL; 214 continue;
215 } 215 }
216 216
217 if (info->flags & SHARE_MUX_CONF_REG) { 217 if (info->flags & SHARE_MUX_CONF_REG) {
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 677a811b3a6f..7abfd42e8ffd 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -401,9 +401,9 @@ static const struct byt_simple_func_mux byt_score_sata_mux[] = {
401static const unsigned int byt_score_plt_clk0_pins[] = { 96 }; 401static const unsigned int byt_score_plt_clk0_pins[] = { 96 };
402static const unsigned int byt_score_plt_clk1_pins[] = { 97 }; 402static const unsigned int byt_score_plt_clk1_pins[] = { 97 };
403static const unsigned int byt_score_plt_clk2_pins[] = { 98 }; 403static const unsigned int byt_score_plt_clk2_pins[] = { 98 };
404static const unsigned int byt_score_plt_clk4_pins[] = { 99 }; 404static const unsigned int byt_score_plt_clk3_pins[] = { 99 };
405static const unsigned int byt_score_plt_clk5_pins[] = { 100 }; 405static const unsigned int byt_score_plt_clk4_pins[] = { 100 };
406static const unsigned int byt_score_plt_clk3_pins[] = { 101 }; 406static const unsigned int byt_score_plt_clk5_pins[] = { 101 };
407static const struct byt_simple_func_mux byt_score_plt_clk_mux[] = { 407static const struct byt_simple_func_mux byt_score_plt_clk_mux[] = {
408 SIMPLE_FUNC("plt_clk", 1), 408 SIMPLE_FUNC("plt_clk", 1),
409}; 409};
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index cf9bafa10acf..bfdf720db270 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1580,6 +1580,9 @@ static inline void pcs_irq_set(struct pcs_soc_data *pcs_soc,
1580 else 1580 else
1581 mask &= ~soc_mask; 1581 mask &= ~soc_mask;
1582 pcs->write(mask, pcswi->reg); 1582 pcs->write(mask, pcswi->reg);
1583
1584 /* flush posted write */
1585 mask = pcs->read(pcswi->reg);
1583 raw_spin_unlock(&pcs->lock); 1586 raw_spin_unlock(&pcs->lock);
1584 } 1587 }
1585 1588
diff --git a/drivers/pinctrl/tegra/Makefile b/drivers/pinctrl/tegra/Makefile
index a927379b6794..d9ea2be69cc4 100644
--- a/drivers/pinctrl/tegra/Makefile
+++ b/drivers/pinctrl/tegra/Makefile
@@ -1,4 +1,4 @@
1obj-y += pinctrl-tegra.o 1obj-$(CONFIG_PINCTRL_TEGRA) += pinctrl-tegra.o
2obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o 2obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o
3obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o 3obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o
4obj-$(CONFIG_PINCTRL_TEGRA114) += pinctrl-tegra114.o 4obj-$(CONFIG_PINCTRL_TEGRA114) += pinctrl-tegra114.o
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 456987c88baa..b13cd074c52a 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,
565 565
566 WARN_ON(tzd == NULL); 566 WARN_ON(tzd == NULL);
567 psy = tzd->devdata; 567 psy = tzd->devdata;
568 ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); 568 ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
569 if (ret)
570 return ret;
569 571
570 /* Convert tenths of degree Celsius to milli degree Celsius. */ 572 /* Convert tenths of degree Celsius to milli degree Celsius. */
571 if (!ret) 573 *temp = val.intval * 100;
572 *temp = val.intval * 100;
573 574
574 return ret; 575 return ret;
575} 576}
@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd,
612 int ret; 613 int ret;
613 614
614 psy = tcd->devdata; 615 psy = tcd->devdata;
615 ret = psy->desc->get_property(psy, 616 ret = power_supply_get_property(psy,
616 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); 617 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
617 if (!ret) 618 if (ret)
618 *state = val.intval; 619 return ret;
620
621 *state = val.intval;
619 622
620 return ret; 623 return ret;
621} 624}
@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd,
628 int ret; 631 int ret;
629 632
630 psy = tcd->devdata; 633 psy = tcd->devdata;
631 ret = psy->desc->get_property(psy, 634 ret = power_supply_get_property(psy,
632 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); 635 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
633 if (!ret) 636 if (ret)
634 *state = val.intval; 637 return ret;
638
639 *state = val.intval;
635 640
636 return ret; 641 return ret;
637} 642}
diff --git a/drivers/power/tps65217_charger.c b/drivers/power/tps65217_charger.c
index d9f56730c735..73dfae41def8 100644
--- a/drivers/power/tps65217_charger.c
+++ b/drivers/power/tps65217_charger.c
@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
197{ 197{
198 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); 198 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
199 struct tps65217_charger *charger; 199 struct tps65217_charger *charger;
200 struct power_supply_config cfg = {};
200 int ret; 201 int ret;
201 202
202 dev_dbg(&pdev->dev, "%s\n", __func__); 203 dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev)
208 charger->tps = tps; 209 charger->tps = tps;
209 charger->dev = &pdev->dev; 210 charger->dev = &pdev->dev;
210 211
212 cfg.of_node = pdev->dev.of_node;
213 cfg.drv_data = charger;
214
211 charger->ac = devm_power_supply_register(&pdev->dev, 215 charger->ac = devm_power_supply_register(&pdev->dev,
212 &tps65217_charger_desc, 216 &tps65217_charger_desc,
213 NULL); 217 &cfg);
214 if (IS_ERR(charger->ac)) { 218 if (IS_ERR(charger->ac)) {
215 dev_err(&pdev->dev, "failed: power supply register\n"); 219 dev_err(&pdev->dev, "failed: power supply register\n");
216 return PTR_ERR(charger->ac); 220 return PTR_ERR(charger->ac);
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 63cd5e68c864..3a6d0290c54c 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -296,7 +296,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
296 if (!sreg->sel && !strcmp(sreg->name, "vddpu")) 296 if (!sreg->sel && !strcmp(sreg->name, "vddpu"))
297 sreg->sel = 22; 297 sreg->sel = 22;
298 298
299 if (!sreg->sel) { 299 if (!sreg->bypass && !sreg->sel) {
300 dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n"); 300 dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n");
301 return -EINVAL; 301 return -EINVAL;
302 } 302 }
diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
index 321e804aeab0..a1b49a6d538f 100644
--- a/drivers/regulator/max77620-regulator.c
+++ b/drivers/regulator/max77620-regulator.c
@@ -123,6 +123,9 @@ static int max77620_regulator_set_fps_src(struct max77620_regulator *pmic,
123 unsigned int val; 123 unsigned int val;
124 int ret; 124 int ret;
125 125
126 if (!rinfo)
127 return 0;
128
126 switch (fps_src) { 129 switch (fps_src) {
127 case MAX77620_FPS_SRC_0: 130 case MAX77620_FPS_SRC_0:
128 case MAX77620_FPS_SRC_1: 131 case MAX77620_FPS_SRC_1:
@@ -171,6 +174,9 @@ static int max77620_regulator_set_fps_slots(struct max77620_regulator *pmic,
171 int pd = rpdata->active_fps_pd_slot; 174 int pd = rpdata->active_fps_pd_slot;
172 int ret = 0; 175 int ret = 0;
173 176
177 if (!rinfo)
178 return 0;
179
174 if (is_suspend) { 180 if (is_suspend) {
175 pu = rpdata->suspend_fps_pu_slot; 181 pu = rpdata->suspend_fps_pu_slot;
176 pd = rpdata->suspend_fps_pd_slot; 182 pd = rpdata->suspend_fps_pd_slot;
@@ -680,7 +686,6 @@ static struct max77620_regulator_info max77620_regs_info[MAX77620_NUM_REGS] = {
680 RAIL_SD(SD1, sd1, "in-sd1", SD1, 600000, 1550000, 12500, 0x22, SD1), 686 RAIL_SD(SD1, sd1, "in-sd1", SD1, 600000, 1550000, 12500, 0x22, SD1),
681 RAIL_SD(SD2, sd2, "in-sd2", SDX, 600000, 3787500, 12500, 0xFF, NONE), 687 RAIL_SD(SD2, sd2, "in-sd2", SDX, 600000, 3787500, 12500, 0xFF, NONE),
682 RAIL_SD(SD3, sd3, "in-sd3", SDX, 600000, 3787500, 12500, 0xFF, NONE), 688 RAIL_SD(SD3, sd3, "in-sd3", SDX, 600000, 3787500, 12500, 0xFF, NONE),
683 RAIL_SD(SD4, sd4, "in-sd4", SDX, 600000, 3787500, 12500, 0xFF, NONE),
684 689
685 RAIL_LDO(LDO0, ldo0, "in-ldo0-1", N, 800000, 2375000, 25000), 690 RAIL_LDO(LDO0, ldo0, "in-ldo0-1", N, 800000, 2375000, 25000),
686 RAIL_LDO(LDO1, ldo1, "in-ldo0-1", N, 800000, 2375000, 25000), 691 RAIL_LDO(LDO1, ldo1, "in-ldo0-1", N, 800000, 2375000, 25000),
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index cd89682065b9..1026e180eed7 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -578,7 +578,7 @@ static int rockchip_spi_transfer_one(
578 struct spi_device *spi, 578 struct spi_device *spi,
579 struct spi_transfer *xfer) 579 struct spi_transfer *xfer)
580{ 580{
581 int ret = 1; 581 int ret = 0;
582 struct rockchip_spi *rs = spi_master_get_devdata(master); 582 struct rockchip_spi *rs = spi_master_get_devdata(master);
583 583
584 WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && 584 WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -627,6 +627,8 @@ static int rockchip_spi_transfer_one(
627 spi_enable_chip(rs, 1); 627 spi_enable_chip(rs, 1);
628 ret = rockchip_spi_prepare_dma(rs); 628 ret = rockchip_spi_prepare_dma(rs);
629 } 629 }
630 /* successful DMA prepare means the transfer is in progress */
631 ret = ret ? ret : 1;
630 } else { 632 } else {
631 spi_enable_chip(rs, 1); 633 spi_enable_chip(rs, 1);
632 ret = rockchip_spi_pio_transfer(rs); 634 ret = rockchip_spi_pio_transfer(rs);
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c
index 1ddd9e2309b6..cf007f3b83ec 100644
--- a/drivers/spi/spi-sun4i.c
+++ b/drivers/spi/spi-sun4i.c
@@ -173,13 +173,17 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
173{ 173{
174 struct sun4i_spi *sspi = spi_master_get_devdata(master); 174 struct sun4i_spi *sspi = spi_master_get_devdata(master);
175 unsigned int mclk_rate, div, timeout; 175 unsigned int mclk_rate, div, timeout;
176 unsigned int start, end, tx_time;
176 unsigned int tx_len = 0; 177 unsigned int tx_len = 0;
177 int ret = 0; 178 int ret = 0;
178 u32 reg; 179 u32 reg;
179 180
180 /* We don't support transfer larger than the FIFO */ 181 /* We don't support transfer larger than the FIFO */
181 if (tfr->len > SUN4I_FIFO_DEPTH) 182 if (tfr->len > SUN4I_FIFO_DEPTH)
182 return -EINVAL; 183 return -EMSGSIZE;
184
185 if (tfr->tx_buf && tfr->len >= SUN4I_FIFO_DEPTH)
186 return -EMSGSIZE;
183 187
184 reinit_completion(&sspi->done); 188 reinit_completion(&sspi->done);
185 sspi->tx_buf = tfr->tx_buf; 189 sspi->tx_buf = tfr->tx_buf;
@@ -269,8 +273,12 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
269 sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len)); 273 sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len));
270 sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len)); 274 sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len));
271 275
272 /* Fill the TX FIFO */ 276 /*
273 sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH); 277 * Fill the TX FIFO
278 * Filling the FIFO fully causes timeout for some reason
279 * at least on spi2 on A10s
280 */
281 sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH - 1);
274 282
275 /* Enable the interrupts */ 283 /* Enable the interrupts */
276 sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC); 284 sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC);
@@ -279,9 +287,16 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
279 reg = sun4i_spi_read(sspi, SUN4I_CTL_REG); 287 reg = sun4i_spi_read(sspi, SUN4I_CTL_REG);
280 sun4i_spi_write(sspi, SUN4I_CTL_REG, reg | SUN4I_CTL_XCH); 288 sun4i_spi_write(sspi, SUN4I_CTL_REG, reg | SUN4I_CTL_XCH);
281 289
290 tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U);
291 start = jiffies;
282 timeout = wait_for_completion_timeout(&sspi->done, 292 timeout = wait_for_completion_timeout(&sspi->done,
283 msecs_to_jiffies(1000)); 293 msecs_to_jiffies(tx_time));
294 end = jiffies;
284 if (!timeout) { 295 if (!timeout) {
296 dev_warn(&master->dev,
297 "%s: timeout transferring %u bytes@%iHz for %i(%i)ms",
298 dev_name(&spi->dev), tfr->len, tfr->speed_hz,
299 jiffies_to_msecs(end - start), tx_time);
285 ret = -ETIMEDOUT; 300 ret = -ETIMEDOUT;
286 goto out; 301 goto out;
287 } 302 }
diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index 42e2c4bd690a..7fce79a60608 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -160,6 +160,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
160{ 160{
161 struct sun6i_spi *sspi = spi_master_get_devdata(master); 161 struct sun6i_spi *sspi = spi_master_get_devdata(master);
162 unsigned int mclk_rate, div, timeout; 162 unsigned int mclk_rate, div, timeout;
163 unsigned int start, end, tx_time;
163 unsigned int tx_len = 0; 164 unsigned int tx_len = 0;
164 int ret = 0; 165 int ret = 0;
165 u32 reg; 166 u32 reg;
@@ -269,9 +270,16 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
269 reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG); 270 reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG);
270 sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg | SUN6I_TFR_CTL_XCH); 271 sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg | SUN6I_TFR_CTL_XCH);
271 272
273 tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U);
274 start = jiffies;
272 timeout = wait_for_completion_timeout(&sspi->done, 275 timeout = wait_for_completion_timeout(&sspi->done,
273 msecs_to_jiffies(1000)); 276 msecs_to_jiffies(tx_time));
277 end = jiffies;
274 if (!timeout) { 278 if (!timeout) {
279 dev_warn(&master->dev,
280 "%s: timeout transferring %u bytes@%iHz for %i(%i)ms",
281 dev_name(&spi->dev), tfr->len, tfr->speed_hz,
282 jiffies_to_msecs(end - start), tx_time);
275 ret = -ETIMEDOUT; 283 ret = -ETIMEDOUT;
276 goto out; 284 goto out;
277 } 285 }
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 443f664534e1..29ea8d2f9824 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -646,6 +646,13 @@ free_master:
646 646
647static int ti_qspi_remove(struct platform_device *pdev) 647static int ti_qspi_remove(struct platform_device *pdev)
648{ 648{
649 struct ti_qspi *qspi = platform_get_drvdata(pdev);
650 int rc;
651
652 rc = spi_master_suspend(qspi->master);
653 if (rc)
654 return rc;
655
649 pm_runtime_put_sync(&pdev->dev); 656 pm_runtime_put_sync(&pdev->dev);
650 pm_runtime_disable(&pdev->dev); 657 pm_runtime_disable(&pdev->dev);
651 658
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index a8f533af9eca..ec12181822e6 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -594,7 +594,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
594 goto error_ret_mut; 594 goto error_ret_mut;
595 ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL); 595 ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
596 mutex_unlock(&st->lock); 596 mutex_unlock(&st->lock);
597 if (ret) 597 if (ret < 0)
598 goto error_ret; 598 goto error_ret;
599 val = ret; 599 val = ret;
600 if (base_freq > 0) 600 if (base_freq > 0)
diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c
index 825da0769936..9587fa86dc69 100644
--- a/drivers/staging/iio/adc/ad7606_spi.c
+++ b/drivers/staging/iio/adc/ad7606_spi.c
@@ -21,7 +21,7 @@ static int ad7606_spi_read_block(struct device *dev,
21{ 21{
22 struct spi_device *spi = to_spi_device(dev); 22 struct spi_device *spi = to_spi_device(dev);
23 int i, ret; 23 int i, ret;
24 unsigned short *data; 24 unsigned short *data = buf;
25 __be16 *bdata = buf; 25 __be16 *bdata = buf;
26 26
27 ret = spi_read(spi, buf, count * 2); 27 ret = spi_read(spi, buf, count * 2);
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 9f43976f4ef2..170ac980abcb 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -444,10 +444,10 @@ static ssize_t ad5933_store(struct device *dev,
444 st->settling_cycles = val; 444 st->settling_cycles = val;
445 445
446 /* 2x, 4x handling, see datasheet */ 446 /* 2x, 4x handling, see datasheet */
447 if (val > 511) 447 if (val > 1022)
448 val = (val >> 1) | (1 << 9);
449 else if (val > 1022)
450 val = (val >> 2) | (3 << 9); 448 val = (val >> 2) | (3 << 9);
449 else if (val > 511)
450 val = (val >> 1) | (1 << 9);
451 451
452 dat = cpu_to_be16(val); 452 dat = cpu_to_be16(val);
453 ret = ad5933_i2c_write(st->client, 453 ret = ad5933_i2c_write(st->client,
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index f856c4544eea..51e0d32883ba 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -667,8 +667,11 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
667 fsi = tty->driver_data; 667 fsi = tty->driver_data;
668 else 668 else
669 fsi = tty->link->driver_data; 669 fsi = tty->link->driver_data;
670 devpts_kill_index(fsi, tty->index); 670
671 devpts_release(fsi); 671 if (fsi) {
672 devpts_kill_index(fsi, tty->index);
673 devpts_release(fsi);
674 }
672} 675}
673 676
674static const struct tty_operations ptm_unix98_ops = { 677static const struct tty_operations ptm_unix98_ops = {
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index dc125322f48f..5b0fe97c46ca 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -750,6 +750,7 @@ static void visual_init(struct vc_data *vc, int num, int init)
750 vc->vc_complement_mask = 0; 750 vc->vc_complement_mask = 0;
751 vc->vc_can_do_color = 0; 751 vc->vc_can_do_color = 0;
752 vc->vc_panic_force_write = false; 752 vc->vc_panic_force_write = false;
753 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
753 vc->vc_sw->con_init(vc, init); 754 vc->vc_sw->con_init(vc, init);
754 if (!vc->vc_complement_mask) 755 if (!vc->vc_complement_mask)
755 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; 756 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 9059b7dc185e..2f537bbdda09 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -21,6 +21,7 @@
21 * 675 Mass Ave, Cambridge, MA 02139, USA. 21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <linux/module.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/types.h> 26#include <linux/types.h>
26#include <linux/mutex.h> 27#include <linux/mutex.h>
@@ -450,3 +451,4 @@ int otg_statemachine(struct otg_fsm *fsm)
450 return fsm->state_changed; 451 return fsm->state_changed;
451} 452}
452EXPORT_SYMBOL_GPL(otg_statemachine); 453EXPORT_SYMBOL_GPL(otg_statemachine);
454MODULE_LICENSE("GPL");
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 34b837ae1ed7..d2e3f655c26f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2598,26 +2598,23 @@ EXPORT_SYMBOL_GPL(usb_create_hcd);
2598 * Don't deallocate the bandwidth_mutex until the last shared usb_hcd is 2598 * Don't deallocate the bandwidth_mutex until the last shared usb_hcd is
2599 * deallocated. 2599 * deallocated.
2600 * 2600 *
2601 * Make sure to only deallocate the bandwidth_mutex when the primary HCD is 2601 * Make sure to deallocate the bandwidth_mutex only when the last HCD is
2602 * freed. When hcd_release() is called for either hcd in a peer set 2602 * freed. When hcd_release() is called for either hcd in a peer set,
2603 * invalidate the peer's ->shared_hcd and ->primary_hcd pointers to 2603 * invalidate the peer's ->shared_hcd and ->primary_hcd pointers.
2604 * block new peering attempts
2605 */ 2604 */
2606static void hcd_release(struct kref *kref) 2605static void hcd_release(struct kref *kref)
2607{ 2606{
2608 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); 2607 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
2609 2608
2610 mutex_lock(&usb_port_peer_mutex); 2609 mutex_lock(&usb_port_peer_mutex);
2611 if (usb_hcd_is_primary_hcd(hcd)) {
2612 kfree(hcd->address0_mutex);
2613 kfree(hcd->bandwidth_mutex);
2614 }
2615 if (hcd->shared_hcd) { 2610 if (hcd->shared_hcd) {
2616 struct usb_hcd *peer = hcd->shared_hcd; 2611 struct usb_hcd *peer = hcd->shared_hcd;
2617 2612
2618 peer->shared_hcd = NULL; 2613 peer->shared_hcd = NULL;
2619 if (peer->primary_hcd == hcd) 2614 peer->primary_hcd = NULL;
2620 peer->primary_hcd = NULL; 2615 } else {
2616 kfree(hcd->address0_mutex);
2617 kfree(hcd->bandwidth_mutex);
2621 } 2618 }
2622 mutex_unlock(&usb_port_peer_mutex); 2619 mutex_unlock(&usb_port_peer_mutex);
2623 kfree(hcd); 2620 kfree(hcd);
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 50d6ae6f88bc..89a2f712fdfe 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -233,7 +233,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
233 dev_vdbg(&pdev->dev, "glue-logic addr 0x%p, syscfg-reg offset 0x%x\n", 233 dev_vdbg(&pdev->dev, "glue-logic addr 0x%p, syscfg-reg offset 0x%x\n",
234 dwc3_data->glue_base, dwc3_data->syscfg_reg_off); 234 dwc3_data->glue_base, dwc3_data->syscfg_reg_off);
235 235
236 dwc3_data->rstc_pwrdn = devm_reset_control_get(dev, "powerdown"); 236 dwc3_data->rstc_pwrdn =
237 devm_reset_control_get_exclusive(dev, "powerdown");
237 if (IS_ERR(dwc3_data->rstc_pwrdn)) { 238 if (IS_ERR(dwc3_data->rstc_pwrdn)) {
238 dev_err(&pdev->dev, "could not get power controller\n"); 239 dev_err(&pdev->dev, "could not get power controller\n");
239 ret = PTR_ERR(dwc3_data->rstc_pwrdn); 240 ret = PTR_ERR(dwc3_data->rstc_pwrdn);
@@ -243,7 +244,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
243 /* Manage PowerDown */ 244 /* Manage PowerDown */
244 reset_control_deassert(dwc3_data->rstc_pwrdn); 245 reset_control_deassert(dwc3_data->rstc_pwrdn);
245 246
246 dwc3_data->rstc_rst = devm_reset_control_get(dev, "softreset"); 247 dwc3_data->rstc_rst =
248 devm_reset_control_get_shared(dev, "softreset");
247 if (IS_ERR(dwc3_data->rstc_rst)) { 249 if (IS_ERR(dwc3_data->rstc_rst)) {
248 dev_err(&pdev->dev, "could not get reset controller\n"); 250 dev_err(&pdev->dev, "could not get reset controller\n");
249 ret = PTR_ERR(dwc3_data->rstc_rst); 251 ret = PTR_ERR(dwc3_data->rstc_rst);
diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index a94ed677d937..be4a2788fc58 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -206,7 +206,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
206 priv->clk48 = NULL; 206 priv->clk48 = NULL;
207 } 207 }
208 208
209 priv->pwr = devm_reset_control_get_optional(&dev->dev, "power"); 209 priv->pwr =
210 devm_reset_control_get_optional_shared(&dev->dev, "power");
210 if (IS_ERR(priv->pwr)) { 211 if (IS_ERR(priv->pwr)) {
211 err = PTR_ERR(priv->pwr); 212 err = PTR_ERR(priv->pwr);
212 if (err == -EPROBE_DEFER) 213 if (err == -EPROBE_DEFER)
@@ -214,7 +215,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
214 priv->pwr = NULL; 215 priv->pwr = NULL;
215 } 216 }
216 217
217 priv->rst = devm_reset_control_get_optional(&dev->dev, "softreset"); 218 priv->rst =
219 devm_reset_control_get_optional_shared(&dev->dev, "softreset");
218 if (IS_ERR(priv->rst)) { 220 if (IS_ERR(priv->rst)) {
219 err = PTR_ERR(priv->rst); 221 err = PTR_ERR(priv->rst);
220 if (err == -EPROBE_DEFER) 222 if (err == -EPROBE_DEFER)
diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index acf2eb2a5676..02816a1515a1 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -188,13 +188,15 @@ static int st_ohci_platform_probe(struct platform_device *dev)
188 priv->clk48 = NULL; 188 priv->clk48 = NULL;
189 } 189 }
190 190
191 priv->pwr = devm_reset_control_get_optional(&dev->dev, "power"); 191 priv->pwr =
192 devm_reset_control_get_optional_shared(&dev->dev, "power");
192 if (IS_ERR(priv->pwr)) { 193 if (IS_ERR(priv->pwr)) {
193 err = PTR_ERR(priv->pwr); 194 err = PTR_ERR(priv->pwr);
194 goto err_put_clks; 195 goto err_put_clks;
195 } 196 }
196 197
197 priv->rst = devm_reset_control_get_optional(&dev->dev, "softreset"); 198 priv->rst =
199 devm_reset_control_get_optional_shared(&dev->dev, "softreset");
198 if (IS_ERR(priv->rst)) { 200 if (IS_ERR(priv->rst)) {
199 err = PTR_ERR(priv->rst); 201 err = PTR_ERR(priv->rst);
200 goto err_put_clks; 202 goto err_put_clks;
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index b84c291ba1eb..d7b78d531e63 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -74,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
74 v9fs_proto_dotu(v9ses)); 74 v9fs_proto_dotu(v9ses));
75 fid = file->private_data; 75 fid = file->private_data;
76 if (!fid) { 76 if (!fid) {
77 fid = v9fs_fid_clone(file->f_path.dentry); 77 fid = v9fs_fid_clone(file_dentry(file));
78 if (IS_ERR(fid)) 78 if (IS_ERR(fid))
79 return PTR_ERR(fid); 79 return PTR_ERR(fid);
80 80
@@ -100,7 +100,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
100 * because we want write after unlink usecase 100 * because we want write after unlink usecase
101 * to work. 101 * to work.
102 */ 102 */
103 fid = v9fs_writeback_fid(file->f_path.dentry); 103 fid = v9fs_writeback_fid(file_dentry(file));
104 if (IS_ERR(fid)) { 104 if (IS_ERR(fid)) {
105 err = PTR_ERR(fid); 105 err = PTR_ERR(fid);
106 mutex_unlock(&v9inode->v_mutex); 106 mutex_unlock(&v9inode->v_mutex);
@@ -516,7 +516,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
516 * because we want write after unlink usecase 516 * because we want write after unlink usecase
517 * to work. 517 * to work.
518 */ 518 */
519 fid = v9fs_writeback_fid(filp->f_path.dentry); 519 fid = v9fs_writeback_fid(file_dentry(filp));
520 if (IS_ERR(fid)) { 520 if (IS_ERR(fid)) {
521 retval = PTR_ERR(fid); 521 retval = PTR_ERR(fid);
522 mutex_unlock(&v9inode->v_mutex); 522 mutex_unlock(&v9inode->v_mutex);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index f4645c515262..e2e7c749925a 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -853,7 +853,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
853 struct p9_fid *fid, *inode_fid; 853 struct p9_fid *fid, *inode_fid;
854 struct dentry *res = NULL; 854 struct dentry *res = NULL;
855 855
856 if (d_unhashed(dentry)) { 856 if (d_in_lookup(dentry)) {
857 res = v9fs_vfs_lookup(dir, dentry, 0); 857 res = v9fs_vfs_lookup(dir, dentry, 0);
858 if (IS_ERR(res)) 858 if (IS_ERR(res))
859 return PTR_ERR(res); 859 return PTR_ERR(res);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index a34702c998f5..1b51eaa5e2dd 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -254,7 +254,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
254 struct posix_acl *pacl = NULL, *dacl = NULL; 254 struct posix_acl *pacl = NULL, *dacl = NULL;
255 struct dentry *res = NULL; 255 struct dentry *res = NULL;
256 256
257 if (d_unhashed(dentry)) { 257 if (d_in_lookup(dentry)) {
258 res = v9fs_vfs_lookup(dir, dentry, 0); 258 res = v9fs_vfs_lookup(dir, dentry, 0);
259 if (IS_ERR(res)) 259 if (IS_ERR(res))
260 return PTR_ERR(res); 260 return PTR_ERR(res);
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 6e72c98162d5..1780218a48f0 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -95,10 +95,8 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
95 } 95 }
96 96
97 dentry = d_obtain_alias(inode); 97 dentry = d_obtain_alias(inode);
98 if (IS_ERR(dentry)) { 98 if (IS_ERR(dentry))
99 iput(inode);
100 return dentry; 99 return dentry;
101 }
102 err = ceph_init_dentry(dentry); 100 err = ceph_init_dentry(dentry);
103 if (err < 0) { 101 if (err < 0) {
104 dput(dentry); 102 dput(dentry);
@@ -167,10 +165,8 @@ static struct dentry *__get_parent(struct super_block *sb,
167 return ERR_PTR(-ENOENT); 165 return ERR_PTR(-ENOENT);
168 166
169 dentry = d_obtain_alias(inode); 167 dentry = d_obtain_alias(inode);
170 if (IS_ERR(dentry)) { 168 if (IS_ERR(dentry))
171 iput(inode);
172 return dentry; 169 return dentry;
173 }
174 err = ceph_init_dentry(dentry); 170 err = ceph_init_dentry(dentry);
175 if (err < 0) { 171 if (err < 0) {
176 dput(dentry); 172 dput(dentry);
@@ -210,7 +206,7 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
210 206
211 dout("fh_to_parent %llx\n", cfh->parent_ino); 207 dout("fh_to_parent %llx\n", cfh->parent_ino);
212 dentry = __get_parent(sb, NULL, cfh->ino); 208 dentry = __get_parent(sb, NULL, cfh->ino);
213 if (IS_ERR(dentry) && PTR_ERR(dentry) == -ENOENT) 209 if (unlikely(dentry == ERR_PTR(-ENOENT)))
214 dentry = __fh_to_dentry(sb, cfh->parent_ino); 210 dentry = __fh_to_dentry(sb, cfh->parent_ino);
215 return dentry; 211 return dentry;
216} 212}
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ce2f5795e44b..0daaf7ceedc5 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -394,7 +394,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
394 if ((flags & O_CREAT) && !req->r_reply_info.head->is_dentry) 394 if ((flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
395 err = ceph_handle_notrace_create(dir, dentry); 395 err = ceph_handle_notrace_create(dir, dentry);
396 396
397 if (d_unhashed(dentry)) { 397 if (d_in_lookup(dentry)) {
398 dn = ceph_finish_lookup(req, dentry, err); 398 dn = ceph_finish_lookup(req, dentry, err);
399 if (IS_ERR(dn)) 399 if (IS_ERR(dn))
400 err = PTR_ERR(dn); 400 err = PTR_ERR(dn);
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 5a53ac6b1e02..02b071bf3732 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -101,6 +101,12 @@ convert_sfm_char(const __u16 src_char, char *target)
101 case SFM_SLASH: 101 case SFM_SLASH:
102 *target = '\\'; 102 *target = '\\';
103 break; 103 break;
104 case SFM_SPACE:
105 *target = ' ';
106 break;
107 case SFM_PERIOD:
108 *target = '.';
109 break;
104 default: 110 default:
105 return false; 111 return false;
106 } 112 }
@@ -404,7 +410,7 @@ static __le16 convert_to_sfu_char(char src_char)
404 return dest_char; 410 return dest_char;
405} 411}
406 412
407static __le16 convert_to_sfm_char(char src_char) 413static __le16 convert_to_sfm_char(char src_char, bool end_of_string)
408{ 414{
409 __le16 dest_char; 415 __le16 dest_char;
410 416
@@ -427,6 +433,18 @@ static __le16 convert_to_sfm_char(char src_char)
427 case '|': 433 case '|':
428 dest_char = cpu_to_le16(SFM_PIPE); 434 dest_char = cpu_to_le16(SFM_PIPE);
429 break; 435 break;
436 case '.':
437 if (end_of_string)
438 dest_char = cpu_to_le16(SFM_PERIOD);
439 else
440 dest_char = 0;
441 break;
442 case ' ':
443 if (end_of_string)
444 dest_char = cpu_to_le16(SFM_SPACE);
445 else
446 dest_char = 0;
447 break;
430 default: 448 default:
431 dest_char = 0; 449 dest_char = 0;
432 } 450 }
@@ -469,9 +487,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
469 /* see if we must remap this char */ 487 /* see if we must remap this char */
470 if (map_chars == SFU_MAP_UNI_RSVD) 488 if (map_chars == SFU_MAP_UNI_RSVD)
471 dst_char = convert_to_sfu_char(src_char); 489 dst_char = convert_to_sfu_char(src_char);
472 else if (map_chars == SFM_MAP_UNI_RSVD) 490 else if (map_chars == SFM_MAP_UNI_RSVD) {
473 dst_char = convert_to_sfm_char(src_char); 491 bool end_of_string;
474 else 492
493 if (i == srclen - 1)
494 end_of_string = true;
495 else
496 end_of_string = false;
497
498 dst_char = convert_to_sfm_char(src_char, end_of_string);
499 } else
475 dst_char = 0; 500 dst_char = 0;
476 /* 501 /*
477 * FIXME: We can not handle remapping backslash (UNI_SLASH) 502 * FIXME: We can not handle remapping backslash (UNI_SLASH)
diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h
index bdc52cb9a676..479bc0a941f3 100644
--- a/fs/cifs/cifs_unicode.h
+++ b/fs/cifs/cifs_unicode.h
@@ -64,6 +64,8 @@
64#define SFM_LESSTHAN ((__u16) 0xF023) 64#define SFM_LESSTHAN ((__u16) 0xF023)
65#define SFM_PIPE ((__u16) 0xF027) 65#define SFM_PIPE ((__u16) 0xF027)
66#define SFM_SLASH ((__u16) 0xF026) 66#define SFM_SLASH ((__u16) 0xF026)
67#define SFM_PERIOD ((__u16) 0xF028)
68#define SFM_SPACE ((__u16) 0xF029)
67 69
68/* 70/*
69 * Mapping mechanism to use when one of the seven reserved characters is 71 * Mapping mechanism to use when one of the seven reserved characters is
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 5d8b7edf8a8f..5d841f39c4b7 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -87,6 +87,7 @@ extern mempool_t *cifs_req_poolp;
87extern mempool_t *cifs_mid_poolp; 87extern mempool_t *cifs_mid_poolp;
88 88
89struct workqueue_struct *cifsiod_wq; 89struct workqueue_struct *cifsiod_wq;
90__u32 cifs_lock_secret;
90 91
91/* 92/*
92 * Bumps refcount for cifs super block. 93 * Bumps refcount for cifs super block.
@@ -1266,6 +1267,8 @@ init_cifs(void)
1266 spin_lock_init(&cifs_file_list_lock); 1267 spin_lock_init(&cifs_file_list_lock);
1267 spin_lock_init(&GlobalMid_Lock); 1268 spin_lock_init(&GlobalMid_Lock);
1268 1269
1270 get_random_bytes(&cifs_lock_secret, sizeof(cifs_lock_secret));
1271
1269 if (cifs_max_pending < 2) { 1272 if (cifs_max_pending < 2) {
1270 cifs_max_pending = 2; 1273 cifs_max_pending = 2;
1271 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n"); 1274 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index bba106cdc43c..8f1d8c1e72be 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1619,6 +1619,7 @@ void cifs_oplock_break(struct work_struct *work);
1619 1619
1620extern const struct slow_work_ops cifs_oplock_break_ops; 1620extern const struct slow_work_ops cifs_oplock_break_ops;
1621extern struct workqueue_struct *cifsiod_wq; 1621extern struct workqueue_struct *cifsiod_wq;
1622extern __u32 cifs_lock_secret;
1622 1623
1623extern mempool_t *cifs_mid_poolp; 1624extern mempool_t *cifs_mid_poolp;
1624 1625
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 66736f57b5ab..7d2b15c06090 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -428,7 +428,9 @@ cifs_echo_request(struct work_struct *work)
428 * server->ops->need_neg() == true. Also, no need to ping if 428 * server->ops->need_neg() == true. Also, no need to ping if
429 * we got a response recently. 429 * we got a response recently.
430 */ 430 */
431 if (!server->ops->need_neg || server->ops->need_neg(server) || 431
432 if (server->tcpStatus == CifsNeedReconnect ||
433 server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
432 (server->ops->can_echo && !server->ops->can_echo(server)) || 434 (server->ops->can_echo && !server->ops->can_echo(server)) ||
433 time_before(jiffies, server->lstrp + echo_interval - HZ)) 435 time_before(jiffies, server->lstrp + echo_interval - HZ))
434 goto requeue_echo; 436 goto requeue_echo;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index c3eb998a99bd..fb0903fffc22 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -445,7 +445,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
445 * Check for hashed negative dentry. We have already revalidated 445 * Check for hashed negative dentry. We have already revalidated
446 * the dentry and it is fine. No need to perform another lookup. 446 * the dentry and it is fine. No need to perform another lookup.
447 */ 447 */
448 if (!d_unhashed(direntry)) 448 if (!d_in_lookup(direntry))
449 return -ENOENT; 449 return -ENOENT;
450 450
451 res = cifs_lookup(inode, direntry, 0); 451 res = cifs_lookup(inode, direntry, 0);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9793ae0bcaa2..d4890b6dc22d 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1112,6 +1112,12 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
1112 return rc; 1112 return rc;
1113} 1113}
1114 1114
1115static __u32
1116hash_lockowner(fl_owner_t owner)
1117{
1118 return cifs_lock_secret ^ hash32_ptr((const void *)owner);
1119}
1120
1115struct lock_to_push { 1121struct lock_to_push {
1116 struct list_head llist; 1122 struct list_head llist;
1117 __u64 offset; 1123 __u64 offset;
@@ -1178,7 +1184,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
1178 else 1184 else
1179 type = CIFS_WRLCK; 1185 type = CIFS_WRLCK;
1180 lck = list_entry(el, struct lock_to_push, llist); 1186 lck = list_entry(el, struct lock_to_push, llist);
1181 lck->pid = flock->fl_pid; 1187 lck->pid = hash_lockowner(flock->fl_owner);
1182 lck->netfid = cfile->fid.netfid; 1188 lck->netfid = cfile->fid.netfid;
1183 lck->length = length; 1189 lck->length = length;
1184 lck->type = type; 1190 lck->type = type;
@@ -1305,7 +1311,8 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1305 posix_lock_type = CIFS_RDLCK; 1311 posix_lock_type = CIFS_RDLCK;
1306 else 1312 else
1307 posix_lock_type = CIFS_WRLCK; 1313 posix_lock_type = CIFS_WRLCK;
1308 rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, 1314 rc = CIFSSMBPosixLock(xid, tcon, netfid,
1315 hash_lockowner(flock->fl_owner),
1309 flock->fl_start, length, flock, 1316 flock->fl_start, length, flock,
1310 posix_lock_type, wait_flag); 1317 posix_lock_type, wait_flag);
1311 return rc; 1318 return rc;
@@ -1505,7 +1512,8 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1505 posix_lock_type = CIFS_UNLCK; 1512 posix_lock_type = CIFS_UNLCK;
1506 1513
1507 rc = CIFSSMBPosixLock(xid, tcon, cfile->fid.netfid, 1514 rc = CIFSSMBPosixLock(xid, tcon, cfile->fid.netfid,
1508 current->tgid, flock->fl_start, length, 1515 hash_lockowner(flock->fl_owner),
1516 flock->fl_start, length,
1509 NULL, posix_lock_type, wait_flag); 1517 NULL, posix_lock_type, wait_flag);
1510 goto out; 1518 goto out;
1511 } 1519 }
diff --git a/fs/cifs/ntlmssp.h b/fs/cifs/ntlmssp.h
index 848249fa120f..3079b38f0afb 100644
--- a/fs/cifs/ntlmssp.h
+++ b/fs/cifs/ntlmssp.h
@@ -133,6 +133,6 @@ typedef struct _AUTHENTICATE_MESSAGE {
133 133
134int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses); 134int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
135void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses); 135void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses);
136int build_ntlmssp_auth_blob(unsigned char *pbuffer, u16 *buflen, 136int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
137 struct cifs_ses *ses, 137 struct cifs_ses *ses,
138 const struct nls_table *nls_cp); 138 const struct nls_table *nls_cp);
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index af0ec2d5ad0e..538d9b55699a 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -364,19 +364,43 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
364 sec_blob->DomainName.MaximumLength = 0; 364 sec_blob->DomainName.MaximumLength = 0;
365} 365}
366 366
367/* We do not malloc the blob, it is passed in pbuffer, because its 367static int size_of_ntlmssp_blob(struct cifs_ses *ses)
368 maximum possible size is fixed and small, making this approach cleaner. 368{
369 This function returns the length of the data in the blob */ 369 int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len
370int build_ntlmssp_auth_blob(unsigned char *pbuffer, 370 - CIFS_SESS_KEY_SIZE + CIFS_CPHTXT_SIZE + 2;
371
372 if (ses->domainName)
373 sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
374 else
375 sz += 2;
376
377 if (ses->user_name)
378 sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN);
379 else
380 sz += 2;
381
382 return sz;
383}
384
385int build_ntlmssp_auth_blob(unsigned char **pbuffer,
371 u16 *buflen, 386 u16 *buflen,
372 struct cifs_ses *ses, 387 struct cifs_ses *ses,
373 const struct nls_table *nls_cp) 388 const struct nls_table *nls_cp)
374{ 389{
375 int rc; 390 int rc;
376 AUTHENTICATE_MESSAGE *sec_blob = (AUTHENTICATE_MESSAGE *)pbuffer; 391 AUTHENTICATE_MESSAGE *sec_blob;
377 __u32 flags; 392 __u32 flags;
378 unsigned char *tmp; 393 unsigned char *tmp;
379 394
395 rc = setup_ntlmv2_rsp(ses, nls_cp);
396 if (rc) {
397 cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
398 *buflen = 0;
399 goto setup_ntlmv2_ret;
400 }
401 *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL);
402 sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer;
403
380 memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); 404 memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);
381 sec_blob->MessageType = NtLmAuthenticate; 405 sec_blob->MessageType = NtLmAuthenticate;
382 406
@@ -391,7 +415,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
391 flags |= NTLMSSP_NEGOTIATE_KEY_XCH; 415 flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
392 } 416 }
393 417
394 tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE); 418 tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE);
395 sec_blob->NegotiateFlags = cpu_to_le32(flags); 419 sec_blob->NegotiateFlags = cpu_to_le32(flags);
396 420
397 sec_blob->LmChallengeResponse.BufferOffset = 421 sec_blob->LmChallengeResponse.BufferOffset =
@@ -399,13 +423,9 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
399 sec_blob->LmChallengeResponse.Length = 0; 423 sec_blob->LmChallengeResponse.Length = 0;
400 sec_blob->LmChallengeResponse.MaximumLength = 0; 424 sec_blob->LmChallengeResponse.MaximumLength = 0;
401 425
402 sec_blob->NtChallengeResponse.BufferOffset = cpu_to_le32(tmp - pbuffer); 426 sec_blob->NtChallengeResponse.BufferOffset =
427 cpu_to_le32(tmp - *pbuffer);
403 if (ses->user_name != NULL) { 428 if (ses->user_name != NULL) {
404 rc = setup_ntlmv2_rsp(ses, nls_cp);
405 if (rc) {
406 cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
407 goto setup_ntlmv2_ret;
408 }
409 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, 429 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
410 ses->auth_key.len - CIFS_SESS_KEY_SIZE); 430 ses->auth_key.len - CIFS_SESS_KEY_SIZE);
411 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; 431 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
@@ -423,23 +443,23 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
423 } 443 }
424 444
425 if (ses->domainName == NULL) { 445 if (ses->domainName == NULL) {
426 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); 446 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
427 sec_blob->DomainName.Length = 0; 447 sec_blob->DomainName.Length = 0;
428 sec_blob->DomainName.MaximumLength = 0; 448 sec_blob->DomainName.MaximumLength = 0;
429 tmp += 2; 449 tmp += 2;
430 } else { 450 } else {
431 int len; 451 int len;
432 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, 452 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName,
433 CIFS_MAX_USERNAME_LEN, nls_cp); 453 CIFS_MAX_DOMAINNAME_LEN, nls_cp);
434 len *= 2; /* unicode is 2 bytes each */ 454 len *= 2; /* unicode is 2 bytes each */
435 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); 455 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
436 sec_blob->DomainName.Length = cpu_to_le16(len); 456 sec_blob->DomainName.Length = cpu_to_le16(len);
437 sec_blob->DomainName.MaximumLength = cpu_to_le16(len); 457 sec_blob->DomainName.MaximumLength = cpu_to_le16(len);
438 tmp += len; 458 tmp += len;
439 } 459 }
440 460
441 if (ses->user_name == NULL) { 461 if (ses->user_name == NULL) {
442 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); 462 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
443 sec_blob->UserName.Length = 0; 463 sec_blob->UserName.Length = 0;
444 sec_blob->UserName.MaximumLength = 0; 464 sec_blob->UserName.MaximumLength = 0;
445 tmp += 2; 465 tmp += 2;
@@ -448,13 +468,13 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
448 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, 468 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name,
449 CIFS_MAX_USERNAME_LEN, nls_cp); 469 CIFS_MAX_USERNAME_LEN, nls_cp);
450 len *= 2; /* unicode is 2 bytes each */ 470 len *= 2; /* unicode is 2 bytes each */
451 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); 471 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
452 sec_blob->UserName.Length = cpu_to_le16(len); 472 sec_blob->UserName.Length = cpu_to_le16(len);
453 sec_blob->UserName.MaximumLength = cpu_to_le16(len); 473 sec_blob->UserName.MaximumLength = cpu_to_le16(len);
454 tmp += len; 474 tmp += len;
455 } 475 }
456 476
457 sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - pbuffer); 477 sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
458 sec_blob->WorkstationName.Length = 0; 478 sec_blob->WorkstationName.Length = 0;
459 sec_blob->WorkstationName.MaximumLength = 0; 479 sec_blob->WorkstationName.MaximumLength = 0;
460 tmp += 2; 480 tmp += 2;
@@ -463,19 +483,19 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
463 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) 483 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC))
464 && !calc_seckey(ses)) { 484 && !calc_seckey(ses)) {
465 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); 485 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE);
466 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer); 486 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer);
467 sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); 487 sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE);
468 sec_blob->SessionKey.MaximumLength = 488 sec_blob->SessionKey.MaximumLength =
469 cpu_to_le16(CIFS_CPHTXT_SIZE); 489 cpu_to_le16(CIFS_CPHTXT_SIZE);
470 tmp += CIFS_CPHTXT_SIZE; 490 tmp += CIFS_CPHTXT_SIZE;
471 } else { 491 } else {
472 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer); 492 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer);
473 sec_blob->SessionKey.Length = 0; 493 sec_blob->SessionKey.Length = 0;
474 sec_blob->SessionKey.MaximumLength = 0; 494 sec_blob->SessionKey.MaximumLength = 0;
475 } 495 }
476 496
497 *buflen = tmp - *pbuffer;
477setup_ntlmv2_ret: 498setup_ntlmv2_ret:
478 *buflen = tmp - pbuffer;
479 return rc; 499 return rc;
480} 500}
481 501
@@ -690,6 +710,8 @@ sess_auth_lanman(struct sess_data *sess_data)
690 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, 710 rc = calc_lanman_hash(ses->password, ses->server->cryptkey,
691 ses->server->sec_mode & SECMODE_PW_ENCRYPT ? 711 ses->server->sec_mode & SECMODE_PW_ENCRYPT ?
692 true : false, lnm_session_key); 712 true : false, lnm_session_key);
713 if (rc)
714 goto out;
693 715
694 memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE); 716 memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
695 bcc_ptr += CIFS_AUTH_RESP_SIZE; 717 bcc_ptr += CIFS_AUTH_RESP_SIZE;
@@ -1266,7 +1288,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
1266 struct cifs_ses *ses = sess_data->ses; 1288 struct cifs_ses *ses = sess_data->ses;
1267 __u16 bytes_remaining; 1289 __u16 bytes_remaining;
1268 char *bcc_ptr; 1290 char *bcc_ptr;
1269 char *ntlmsspblob = NULL; 1291 unsigned char *ntlmsspblob = NULL;
1270 u16 blob_len; 1292 u16 blob_len;
1271 1293
1272 cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n"); 1294 cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n");
@@ -1279,19 +1301,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
1279 /* Build security blob before we assemble the request */ 1301 /* Build security blob before we assemble the request */
1280 pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; 1302 pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
1281 smb_buf = (struct smb_hdr *)pSMB; 1303 smb_buf = (struct smb_hdr *)pSMB;
1282 /* 1304 rc = build_ntlmssp_auth_blob(&ntlmsspblob,
1283 * 5 is an empirical value, large enough to hold
1284 * authenticate message plus max 10 of av paris,
1285 * domain, user, workstation names, flags, etc.
1286 */
1287 ntlmsspblob = kzalloc(5*sizeof(struct _AUTHENTICATE_MESSAGE),
1288 GFP_KERNEL);
1289 if (!ntlmsspblob) {
1290 rc = -ENOMEM;
1291 goto out;
1292 }
1293
1294 rc = build_ntlmssp_auth_blob(ntlmsspblob,
1295 &blob_len, ses, sess_data->nls_cp); 1305 &blob_len, ses, sess_data->nls_cp);
1296 if (rc) 1306 if (rc)
1297 goto out_free_ntlmsspblob; 1307 goto out_free_ntlmsspblob;
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8f38e33d365b..29e06db5f187 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -588,7 +588,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
588 u16 blob_length = 0; 588 u16 blob_length = 0;
589 struct key *spnego_key = NULL; 589 struct key *spnego_key = NULL;
590 char *security_blob = NULL; 590 char *security_blob = NULL;
591 char *ntlmssp_blob = NULL; 591 unsigned char *ntlmssp_blob = NULL;
592 bool use_spnego = false; /* else use raw ntlmssp */ 592 bool use_spnego = false; /* else use raw ntlmssp */
593 593
594 cifs_dbg(FYI, "Session Setup\n"); 594 cifs_dbg(FYI, "Session Setup\n");
@@ -713,13 +713,7 @@ ssetup_ntlmssp_authenticate:
713 iov[1].iov_len = blob_length; 713 iov[1].iov_len = blob_length;
714 } else if (phase == NtLmAuthenticate) { 714 } else if (phase == NtLmAuthenticate) {
715 req->hdr.SessionId = ses->Suid; 715 req->hdr.SessionId = ses->Suid;
716 ntlmssp_blob = kzalloc(sizeof(struct _NEGOTIATE_MESSAGE) + 500, 716 rc = build_ntlmssp_auth_blob(&ntlmssp_blob, &blob_length, ses,
717 GFP_KERNEL);
718 if (ntlmssp_blob == NULL) {
719 rc = -ENOMEM;
720 goto ssetup_exit;
721 }
722 rc = build_ntlmssp_auth_blob(ntlmssp_blob, &blob_length, ses,
723 nls_cp); 717 nls_cp);
724 if (rc) { 718 if (rc) {
725 cifs_dbg(FYI, "build_ntlmssp_auth_blob failed %d\n", 719 cifs_dbg(FYI, "build_ntlmssp_auth_blob failed %d\n",
@@ -1818,6 +1812,33 @@ SMB2_echo(struct TCP_Server_Info *server)
1818 1812
1819 cifs_dbg(FYI, "In echo request\n"); 1813 cifs_dbg(FYI, "In echo request\n");
1820 1814
1815 if (server->tcpStatus == CifsNeedNegotiate) {
1816 struct list_head *tmp, *tmp2;
1817 struct cifs_ses *ses;
1818 struct cifs_tcon *tcon;
1819
1820 cifs_dbg(FYI, "Need negotiate, reconnecting tcons\n");
1821 spin_lock(&cifs_tcp_ses_lock);
1822 list_for_each(tmp, &server->smb_ses_list) {
1823 ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
1824 list_for_each(tmp2, &ses->tcon_list) {
1825 tcon = list_entry(tmp2, struct cifs_tcon,
1826 tcon_list);
1827 /* add check for persistent handle reconnect */
1828 if (tcon && tcon->need_reconnect) {
1829 spin_unlock(&cifs_tcp_ses_lock);
1830 rc = smb2_reconnect(SMB2_ECHO, tcon);
1831 spin_lock(&cifs_tcp_ses_lock);
1832 }
1833 }
1834 }
1835 spin_unlock(&cifs_tcp_ses_lock);
1836 }
1837
1838 /* if no session, renegotiate failed above */
1839 if (server->tcpStatus == CifsNeedNegotiate)
1840 return -EIO;
1841
1821 rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req); 1842 rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req);
1822 if (rc) 1843 if (rc)
1823 return rc; 1844 return rc;
diff --git a/fs/dax.c b/fs/dax.c
index 761495bf5eb9..e207f8f9b700 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -208,7 +208,12 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
208 dax.addr += first; 208 dax.addr += first;
209 size = map_len - first; 209 size = map_len - first;
210 } 210 }
211 max = min(pos + size, end); 211 /*
212 * pos + size is one past the last offset for IO,
213 * so pos + size can overflow loff_t at extreme offsets.
214 * Cast to u64 to catch this and get the true minimum.
215 */
216 max = min_t(u64, pos + size, end);
212 } 217 }
213 218
214 if (iov_iter_rw(iter) == WRITE) { 219 if (iov_iter_rw(iter) == WRITE) {
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index cbece1221417..9406f35d1a1e 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -99,19 +99,6 @@ void fuse_request_free(struct fuse_req *req)
99 kmem_cache_free(fuse_req_cachep, req); 99 kmem_cache_free(fuse_req_cachep, req);
100} 100}
101 101
102static void block_sigs(sigset_t *oldset)
103{
104 sigset_t mask;
105
106 siginitsetinv(&mask, sigmask(SIGKILL));
107 sigprocmask(SIG_BLOCK, &mask, oldset);
108}
109
110static void restore_sigs(sigset_t *oldset)
111{
112 sigprocmask(SIG_SETMASK, oldset, NULL);
113}
114
115void __fuse_get_request(struct fuse_req *req) 102void __fuse_get_request(struct fuse_req *req)
116{ 103{
117 atomic_inc(&req->count); 104 atomic_inc(&req->count);
@@ -151,15 +138,9 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
151 atomic_inc(&fc->num_waiting); 138 atomic_inc(&fc->num_waiting);
152 139
153 if (fuse_block_alloc(fc, for_background)) { 140 if (fuse_block_alloc(fc, for_background)) {
154 sigset_t oldset;
155 int intr;
156
157 block_sigs(&oldset);
158 intr = wait_event_interruptible_exclusive(fc->blocked_waitq,
159 !fuse_block_alloc(fc, for_background));
160 restore_sigs(&oldset);
161 err = -EINTR; 141 err = -EINTR;
162 if (intr) 142 if (wait_event_killable_exclusive(fc->blocked_waitq,
143 !fuse_block_alloc(fc, for_background)))
163 goto out; 144 goto out;
164 } 145 }
165 /* Matches smp_wmb() in fuse_set_initialized() */ 146 /* Matches smp_wmb() in fuse_set_initialized() */
@@ -446,14 +427,9 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
446 } 427 }
447 428
448 if (!test_bit(FR_FORCE, &req->flags)) { 429 if (!test_bit(FR_FORCE, &req->flags)) {
449 sigset_t oldset;
450
451 /* Only fatal signals may interrupt this */ 430 /* Only fatal signals may interrupt this */
452 block_sigs(&oldset); 431 err = wait_event_killable(req->waitq,
453 err = wait_event_interruptible(req->waitq,
454 test_bit(FR_FINISHED, &req->flags)); 432 test_bit(FR_FINISHED, &req->flags));
455 restore_sigs(&oldset);
456
457 if (!err) 433 if (!err)
458 return; 434 return;
459 435
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 264f07c7754e..cca7b048c07b 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -480,7 +480,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
480 struct fuse_conn *fc = get_fuse_conn(dir); 480 struct fuse_conn *fc = get_fuse_conn(dir);
481 struct dentry *res = NULL; 481 struct dentry *res = NULL;
482 482
483 if (d_unhashed(entry)) { 483 if (d_in_lookup(entry)) {
484 res = fuse_lookup(dir, entry, 0); 484 res = fuse_lookup(dir, entry, 0);
485 if (IS_ERR(res)) 485 if (IS_ERR(res))
486 return PTR_ERR(res); 486 return PTR_ERR(res);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 21dc784f66c2..9bad79fede37 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1189,7 +1189,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
1189 struct dentry *d; 1189 struct dentry *d;
1190 bool excl = !!(flags & O_EXCL); 1190 bool excl = !!(flags & O_EXCL);
1191 1191
1192 if (!d_unhashed(dentry)) 1192 if (!d_in_lookup(dentry))
1193 goto skip_lookup; 1193 goto skip_lookup;
1194 1194
1195 d = __gfs2_lookup(dir, dentry, file, opened); 1195 d = __gfs2_lookup(dir, dentry, file, opened);
diff --git a/fs/libfs.c b/fs/libfs.c
index cedeacbae303..74dc8b9e7f53 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -84,6 +84,61 @@ int dcache_dir_close(struct inode *inode, struct file *file)
84} 84}
85EXPORT_SYMBOL(dcache_dir_close); 85EXPORT_SYMBOL(dcache_dir_close);
86 86
87/* parent is locked at least shared */
88static struct dentry *next_positive(struct dentry *parent,
89 struct list_head *from,
90 int count)
91{
92 unsigned *seq = &parent->d_inode->i_dir_seq, n;
93 struct dentry *res;
94 struct list_head *p;
95 bool skipped;
96 int i;
97
98retry:
99 i = count;
100 skipped = false;
101 n = smp_load_acquire(seq) & ~1;
102 res = NULL;
103 rcu_read_lock();
104 for (p = from->next; p != &parent->d_subdirs; p = p->next) {
105 struct dentry *d = list_entry(p, struct dentry, d_child);
106 if (!simple_positive(d)) {
107 skipped = true;
108 } else if (!--i) {
109 res = d;
110 break;
111 }
112 }
113 rcu_read_unlock();
114 if (skipped) {
115 smp_rmb();
116 if (unlikely(*seq != n))
117 goto retry;
118 }
119 return res;
120}
121
122static void move_cursor(struct dentry *cursor, struct list_head *after)
123{
124 struct dentry *parent = cursor->d_parent;
125 unsigned n, *seq = &parent->d_inode->i_dir_seq;
126 spin_lock(&parent->d_lock);
127 for (;;) {
128 n = *seq;
129 if (!(n & 1) && cmpxchg(seq, n, n + 1) == n)
130 break;
131 cpu_relax();
132 }
133 __list_del(cursor->d_child.prev, cursor->d_child.next);
134 if (after)
135 list_add(&cursor->d_child, after);
136 else
137 list_add_tail(&cursor->d_child, &parent->d_subdirs);
138 smp_store_release(seq, n + 2);
139 spin_unlock(&parent->d_lock);
140}
141
87loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) 142loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
88{ 143{
89 struct dentry *dentry = file->f_path.dentry; 144 struct dentry *dentry = file->f_path.dentry;
@@ -99,25 +154,14 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
99 if (offset != file->f_pos) { 154 if (offset != file->f_pos) {
100 file->f_pos = offset; 155 file->f_pos = offset;
101 if (file->f_pos >= 2) { 156 if (file->f_pos >= 2) {
102 struct list_head *p;
103 struct dentry *cursor = file->private_data; 157 struct dentry *cursor = file->private_data;
158 struct dentry *to;
104 loff_t n = file->f_pos - 2; 159 loff_t n = file->f_pos - 2;
105 160
106 spin_lock(&dentry->d_lock); 161 inode_lock_shared(dentry->d_inode);
107 /* d_lock not required for cursor */ 162 to = next_positive(dentry, &dentry->d_subdirs, n);
108 list_del(&cursor->d_child); 163 move_cursor(cursor, to ? &to->d_child : NULL);
109 p = dentry->d_subdirs.next; 164 inode_unlock_shared(dentry->d_inode);
110 while (n && p != &dentry->d_subdirs) {
111 struct dentry *next;
112 next = list_entry(p, struct dentry, d_child);
113 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
114 if (simple_positive(next))
115 n--;
116 spin_unlock(&next->d_lock);
117 p = p->next;
118 }
119 list_add_tail(&cursor->d_child, p);
120 spin_unlock(&dentry->d_lock);
121 } 165 }
122 } 166 }
123 return offset; 167 return offset;
@@ -140,36 +184,25 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
140{ 184{
141 struct dentry *dentry = file->f_path.dentry; 185 struct dentry *dentry = file->f_path.dentry;
142 struct dentry *cursor = file->private_data; 186 struct dentry *cursor = file->private_data;
143 struct list_head *p, *q = &cursor->d_child; 187 struct list_head *p = &cursor->d_child;
188 struct dentry *next;
189 bool moved = false;
144 190
145 if (!dir_emit_dots(file, ctx)) 191 if (!dir_emit_dots(file, ctx))
146 return 0; 192 return 0;
147 spin_lock(&dentry->d_lock);
148 if (ctx->pos == 2)
149 list_move(q, &dentry->d_subdirs);
150 193
151 for (p = q->next; p != &dentry->d_subdirs; p = p->next) { 194 if (ctx->pos == 2)
152 struct dentry *next = list_entry(p, struct dentry, d_child); 195 p = &dentry->d_subdirs;
153 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); 196 while ((next = next_positive(dentry, p, 1)) != NULL) {
154 if (!simple_positive(next)) {
155 spin_unlock(&next->d_lock);
156 continue;
157 }
158
159 spin_unlock(&next->d_lock);
160 spin_unlock(&dentry->d_lock);
161 if (!dir_emit(ctx, next->d_name.name, next->d_name.len, 197 if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
162 d_inode(next)->i_ino, dt_type(d_inode(next)))) 198 d_inode(next)->i_ino, dt_type(d_inode(next))))
163 return 0; 199 break;
164 spin_lock(&dentry->d_lock); 200 moved = true;
165 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); 201 p = &next->d_child;
166 /* next is still alive */
167 list_move(q, p);
168 spin_unlock(&next->d_lock);
169 p = q;
170 ctx->pos++; 202 ctx->pos++;
171 } 203 }
172 spin_unlock(&dentry->d_lock); 204 if (moved)
205 move_cursor(cursor, p);
173 return 0; 206 return 0;
174} 207}
175EXPORT_SYMBOL(dcache_readdir); 208EXPORT_SYMBOL(dcache_readdir);
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 154a107cd376..fc4084ef4736 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -335,12 +335,17 @@ static struct notifier_block lockd_inet6addr_notifier = {
335}; 335};
336#endif 336#endif
337 337
338static void lockd_svc_exit_thread(void) 338static void lockd_unregister_notifiers(void)
339{ 339{
340 unregister_inetaddr_notifier(&lockd_inetaddr_notifier); 340 unregister_inetaddr_notifier(&lockd_inetaddr_notifier);
341#if IS_ENABLED(CONFIG_IPV6) 341#if IS_ENABLED(CONFIG_IPV6)
342 unregister_inet6addr_notifier(&lockd_inet6addr_notifier); 342 unregister_inet6addr_notifier(&lockd_inet6addr_notifier);
343#endif 343#endif
344}
345
346static void lockd_svc_exit_thread(void)
347{
348 lockd_unregister_notifiers();
344 svc_exit_thread(nlmsvc_rqst); 349 svc_exit_thread(nlmsvc_rqst);
345} 350}
346 351
@@ -462,7 +467,7 @@ int lockd_up(struct net *net)
462 * Note: svc_serv structures have an initial use count of 1, 467 * Note: svc_serv structures have an initial use count of 1,
463 * so we exit through here on both success and failure. 468 * so we exit through here on both success and failure.
464 */ 469 */
465err_net: 470err_put:
466 svc_destroy(serv); 471 svc_destroy(serv);
467err_create: 472err_create:
468 mutex_unlock(&nlmsvc_mutex); 473 mutex_unlock(&nlmsvc_mutex);
@@ -470,7 +475,9 @@ err_create:
470 475
471err_start: 476err_start:
472 lockd_down_net(serv, net); 477 lockd_down_net(serv, net);
473 goto err_net; 478err_net:
479 lockd_unregister_notifiers();
480 goto err_put;
474} 481}
475EXPORT_SYMBOL_GPL(lockd_up); 482EXPORT_SYMBOL_GPL(lockd_up);
476 483
diff --git a/fs/locks.c b/fs/locks.c
index 7c5f91be9b65..ee1b15f6fc13 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1628,7 +1628,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
1628{ 1628{
1629 struct file_lock *fl, *my_fl = NULL, *lease; 1629 struct file_lock *fl, *my_fl = NULL, *lease;
1630 struct dentry *dentry = filp->f_path.dentry; 1630 struct dentry *dentry = filp->f_path.dentry;
1631 struct inode *inode = dentry->d_inode; 1631 struct inode *inode = file_inode(filp);
1632 struct file_lock_context *ctx; 1632 struct file_lock_context *ctx;
1633 bool is_deleg = (*flp)->fl_flags & FL_DELEG; 1633 bool is_deleg = (*flp)->fl_flags & FL_DELEG;
1634 int error; 1634 int error;
diff --git a/fs/namespace.c b/fs/namespace.c
index 783004af5707..419f746d851d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1562,6 +1562,7 @@ void __detach_mounts(struct dentry *dentry)
1562 goto out_unlock; 1562 goto out_unlock;
1563 1563
1564 lock_mount_hash(); 1564 lock_mount_hash();
1565 event++;
1565 while (!hlist_empty(&mp->m_list)) { 1566 while (!hlist_empty(&mp->m_list)) {
1566 mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list); 1567 mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
1567 if (mnt->mnt.mnt_flags & MNT_UMOUNT) { 1568 if (mnt->mnt.mnt_flags & MNT_UMOUNT) {
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index aaf7bd0cbae2..19d93d0cd400 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -424,12 +424,17 @@ static int xdr_decode(nfs_readdir_descriptor_t *desc,
424static 424static
425int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry) 425int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
426{ 426{
427 struct inode *inode;
427 struct nfs_inode *nfsi; 428 struct nfs_inode *nfsi;
428 429
429 if (d_really_is_negative(dentry)) 430 if (d_really_is_negative(dentry))
430 return 0; 431 return 0;
431 432
432 nfsi = NFS_I(d_inode(dentry)); 433 inode = d_inode(dentry);
434 if (is_bad_inode(inode) || NFS_STALE(inode))
435 return 0;
436
437 nfsi = NFS_I(inode);
433 if (entry->fattr->fileid == nfsi->fileid) 438 if (entry->fattr->fileid == nfsi->fileid)
434 return 1; 439 return 1;
435 if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0) 440 if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0)
@@ -1363,7 +1368,6 @@ EXPORT_SYMBOL_GPL(nfs_dentry_operations);
1363struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags) 1368struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
1364{ 1369{
1365 struct dentry *res; 1370 struct dentry *res;
1366 struct dentry *parent;
1367 struct inode *inode = NULL; 1371 struct inode *inode = NULL;
1368 struct nfs_fh *fhandle = NULL; 1372 struct nfs_fh *fhandle = NULL;
1369 struct nfs_fattr *fattr = NULL; 1373 struct nfs_fattr *fattr = NULL;
@@ -1393,7 +1397,6 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
1393 if (IS_ERR(label)) 1397 if (IS_ERR(label))
1394 goto out; 1398 goto out;
1395 1399
1396 parent = dentry->d_parent;
1397 /* Protect against concurrent sillydeletes */ 1400 /* Protect against concurrent sillydeletes */
1398 trace_nfs_lookup_enter(dir, dentry, flags); 1401 trace_nfs_lookup_enter(dir, dentry, flags);
1399 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); 1402 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
@@ -1482,11 +1485,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1482 struct file *file, unsigned open_flags, 1485 struct file *file, unsigned open_flags,
1483 umode_t mode, int *opened) 1486 umode_t mode, int *opened)
1484{ 1487{
1488 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
1485 struct nfs_open_context *ctx; 1489 struct nfs_open_context *ctx;
1486 struct dentry *res; 1490 struct dentry *res;
1487 struct iattr attr = { .ia_valid = ATTR_OPEN }; 1491 struct iattr attr = { .ia_valid = ATTR_OPEN };
1488 struct inode *inode; 1492 struct inode *inode;
1489 unsigned int lookup_flags = 0; 1493 unsigned int lookup_flags = 0;
1494 bool switched = false;
1490 int err; 1495 int err;
1491 1496
1492 /* Expect a negative dentry */ 1497 /* Expect a negative dentry */
@@ -1501,7 +1506,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1501 1506
1502 /* NFS only supports OPEN on regular files */ 1507 /* NFS only supports OPEN on regular files */
1503 if ((open_flags & O_DIRECTORY)) { 1508 if ((open_flags & O_DIRECTORY)) {
1504 if (!d_unhashed(dentry)) { 1509 if (!d_in_lookup(dentry)) {
1505 /* 1510 /*
1506 * Hashed negative dentry with O_DIRECTORY: dentry was 1511 * Hashed negative dentry with O_DIRECTORY: dentry was
1507 * revalidated and is fine, no need to perform lookup 1512 * revalidated and is fine, no need to perform lookup
@@ -1525,6 +1530,17 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1525 attr.ia_size = 0; 1530 attr.ia_size = 0;
1526 } 1531 }
1527 1532
1533 if (!(open_flags & O_CREAT) && !d_in_lookup(dentry)) {
1534 d_drop(dentry);
1535 switched = true;
1536 dentry = d_alloc_parallel(dentry->d_parent,
1537 &dentry->d_name, &wq);
1538 if (IS_ERR(dentry))
1539 return PTR_ERR(dentry);
1540 if (unlikely(!d_in_lookup(dentry)))
1541 return finish_no_open(file, dentry);
1542 }
1543
1528 ctx = create_nfs_open_context(dentry, open_flags); 1544 ctx = create_nfs_open_context(dentry, open_flags);
1529 err = PTR_ERR(ctx); 1545 err = PTR_ERR(ctx);
1530 if (IS_ERR(ctx)) 1546 if (IS_ERR(ctx))
@@ -1536,9 +1552,9 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1536 err = PTR_ERR(inode); 1552 err = PTR_ERR(inode);
1537 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); 1553 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
1538 put_nfs_open_context(ctx); 1554 put_nfs_open_context(ctx);
1555 d_drop(dentry);
1539 switch (err) { 1556 switch (err) {
1540 case -ENOENT: 1557 case -ENOENT:
1541 d_drop(dentry);
1542 d_add(dentry, NULL); 1558 d_add(dentry, NULL);
1543 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1559 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1544 break; 1560 break;
@@ -1560,14 +1576,23 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1560 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); 1576 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
1561 put_nfs_open_context(ctx); 1577 put_nfs_open_context(ctx);
1562out: 1578out:
1579 if (unlikely(switched)) {
1580 d_lookup_done(dentry);
1581 dput(dentry);
1582 }
1563 return err; 1583 return err;
1564 1584
1565no_open: 1585no_open:
1566 res = nfs_lookup(dir, dentry, lookup_flags); 1586 res = nfs_lookup(dir, dentry, lookup_flags);
1567 err = PTR_ERR(res); 1587 if (switched) {
1588 d_lookup_done(dentry);
1589 if (!res)
1590 res = dentry;
1591 else
1592 dput(dentry);
1593 }
1568 if (IS_ERR(res)) 1594 if (IS_ERR(res))
1569 goto out; 1595 return PTR_ERR(res);
1570
1571 return finish_no_open(file, res); 1596 return finish_no_open(file, res);
1572} 1597}
1573EXPORT_SYMBOL_GPL(nfs_atomic_open); 1598EXPORT_SYMBOL_GPL(nfs_atomic_open);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 979b3c4dee6a..c7326c2af2c3 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -353,10 +353,12 @@ static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
353 353
354 result = wait_for_completion_killable(&dreq->completion); 354 result = wait_for_completion_killable(&dreq->completion);
355 355
356 if (!result) {
357 result = dreq->count;
358 WARN_ON_ONCE(dreq->count < 0);
359 }
356 if (!result) 360 if (!result)
357 result = dreq->error; 361 result = dreq->error;
358 if (!result)
359 result = dreq->count;
360 362
361out: 363out:
362 return (ssize_t) result; 364 return (ssize_t) result;
@@ -386,8 +388,10 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
386 388
387 if (dreq->iocb) { 389 if (dreq->iocb) {
388 long res = (long) dreq->error; 390 long res = (long) dreq->error;
389 if (!res) 391 if (dreq->count != 0) {
390 res = (long) dreq->count; 392 res = (long) dreq->count;
393 WARN_ON_ONCE(dreq->count < 0);
394 }
391 dreq->iocb->ki_complete(dreq->iocb, res, 0); 395 dreq->iocb->ki_complete(dreq->iocb, res, 0);
392 } 396 }
393 397
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 52e7d6869e3b..dda689d7a8a7 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -282,6 +282,7 @@ nfs_init_locked(struct inode *inode, void *opaque)
282 struct nfs_fattr *fattr = desc->fattr; 282 struct nfs_fattr *fattr = desc->fattr;
283 283
284 set_nfs_fileid(inode, fattr->fileid); 284 set_nfs_fileid(inode, fattr->fileid);
285 inode->i_mode = fattr->mode;
285 nfs_copy_fh(NFS_FH(inode), desc->fh); 286 nfs_copy_fh(NFS_FH(inode), desc->fh);
286 return 0; 287 return 0;
287} 288}
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index de97567795a5..ff416d0e24bc 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2882,12 +2882,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2882 call_close |= is_wronly; 2882 call_close |= is_wronly;
2883 else if (is_wronly) 2883 else if (is_wronly)
2884 calldata->arg.fmode |= FMODE_WRITE; 2884 calldata->arg.fmode |= FMODE_WRITE;
2885 if (calldata->arg.fmode != (FMODE_READ|FMODE_WRITE))
2886 call_close |= is_rdwr;
2885 } else if (is_rdwr) 2887 } else if (is_rdwr)
2886 calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; 2888 calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
2887 2889
2888 if (calldata->arg.fmode == 0)
2889 call_close |= is_rdwr;
2890
2891 if (!nfs4_valid_open_stateid(state)) 2890 if (!nfs4_valid_open_stateid(state))
2892 call_close = 0; 2891 call_close = 0;
2893 spin_unlock(&state->owner->so_lock); 2892 spin_unlock(&state->owner->so_lock);
@@ -7924,8 +7923,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
7924 break; 7923 break;
7925 } 7924 }
7926 lo = NFS_I(inode)->layout; 7925 lo = NFS_I(inode)->layout;
7927 if (lo && nfs4_stateid_match(&lgp->args.stateid, 7926 if (lo && !test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) &&
7928 &lo->plh_stateid)) { 7927 nfs4_stateid_match_other(&lgp->args.stateid, &lo->plh_stateid)) {
7929 LIST_HEAD(head); 7928 LIST_HEAD(head);
7930 7929
7931 /* 7930 /*
@@ -7936,10 +7935,10 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
7936 pnfs_mark_matching_lsegs_invalid(lo, &head, NULL, 0); 7935 pnfs_mark_matching_lsegs_invalid(lo, &head, NULL, 0);
7937 spin_unlock(&inode->i_lock); 7936 spin_unlock(&inode->i_lock);
7938 pnfs_free_lseg_list(&head); 7937 pnfs_free_lseg_list(&head);
7938 status = -EAGAIN;
7939 goto out;
7939 } else 7940 } else
7940 spin_unlock(&inode->i_lock); 7941 spin_unlock(&inode->i_lock);
7941 status = -EAGAIN;
7942 goto out;
7943 } 7942 }
7944 7943
7945 status = nfs4_handle_exception(server, status, exception); 7944 status = nfs4_handle_exception(server, status, exception);
@@ -8036,7 +8035,10 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
8036 .flags = RPC_TASK_ASYNC, 8035 .flags = RPC_TASK_ASYNC,
8037 }; 8036 };
8038 struct pnfs_layout_segment *lseg = NULL; 8037 struct pnfs_layout_segment *lseg = NULL;
8039 struct nfs4_exception exception = { .timeout = *timeout }; 8038 struct nfs4_exception exception = {
8039 .inode = inode,
8040 .timeout = *timeout,
8041 };
8040 int status = 0; 8042 int status = 0;
8041 8043
8042 dprintk("--> %s\n", __func__); 8044 dprintk("--> %s\n", __func__);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 9679f4749364..834b875900d6 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1488,9 +1488,9 @@ restart:
1488 } 1488 }
1489 spin_unlock(&state->state_lock); 1489 spin_unlock(&state->state_lock);
1490 } 1490 }
1491 nfs4_put_open_state(state);
1492 clear_bit(NFS_STATE_RECLAIM_NOGRACE, 1491 clear_bit(NFS_STATE_RECLAIM_NOGRACE,
1493 &state->flags); 1492 &state->flags);
1493 nfs4_put_open_state(state);
1494 spin_lock(&sp->so_lock); 1494 spin_lock(&sp->so_lock);
1495 goto restart; 1495 goto restart;
1496 } 1496 }
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 0c7e0d45a4de..0fbe734cc38c 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -361,8 +361,10 @@ pnfs_layout_remove_lseg(struct pnfs_layout_hdr *lo,
361 list_del_init(&lseg->pls_list); 361 list_del_init(&lseg->pls_list);
362 /* Matched by pnfs_get_layout_hdr in pnfs_layout_insert_lseg */ 362 /* Matched by pnfs_get_layout_hdr in pnfs_layout_insert_lseg */
363 atomic_dec(&lo->plh_refcount); 363 atomic_dec(&lo->plh_refcount);
364 if (list_empty(&lo->plh_segs)) 364 if (list_empty(&lo->plh_segs)) {
365 set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
365 clear_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); 366 clear_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
367 }
366 rpc_wake_up(&NFS_SERVER(inode)->roc_rpcwaitq); 368 rpc_wake_up(&NFS_SERVER(inode)->roc_rpcwaitq);
367} 369}
368 370
@@ -1290,6 +1292,7 @@ alloc_init_layout_hdr(struct inode *ino,
1290 INIT_LIST_HEAD(&lo->plh_bulk_destroy); 1292 INIT_LIST_HEAD(&lo->plh_bulk_destroy);
1291 lo->plh_inode = ino; 1293 lo->plh_inode = ino;
1292 lo->plh_lc_cred = get_rpccred(ctx->cred); 1294 lo->plh_lc_cred = get_rpccred(ctx->cred);
1295 lo->plh_flags |= 1 << NFS_LAYOUT_INVALID_STID;
1293 return lo; 1296 return lo;
1294} 1297}
1295 1298
@@ -1297,6 +1300,8 @@ static struct pnfs_layout_hdr *
1297pnfs_find_alloc_layout(struct inode *ino, 1300pnfs_find_alloc_layout(struct inode *ino,
1298 struct nfs_open_context *ctx, 1301 struct nfs_open_context *ctx,
1299 gfp_t gfp_flags) 1302 gfp_t gfp_flags)
1303 __releases(&ino->i_lock)
1304 __acquires(&ino->i_lock)
1300{ 1305{
1301 struct nfs_inode *nfsi = NFS_I(ino); 1306 struct nfs_inode *nfsi = NFS_I(ino);
1302 struct pnfs_layout_hdr *new = NULL; 1307 struct pnfs_layout_hdr *new = NULL;
@@ -1565,8 +1570,7 @@ lookup_again:
1565 * stateid, or it has been invalidated, then we must use the open 1570 * stateid, or it has been invalidated, then we must use the open
1566 * stateid. 1571 * stateid.
1567 */ 1572 */
1568 if (lo->plh_stateid.seqid == 0 || 1573 if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) {
1569 test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) {
1570 1574
1571 /* 1575 /*
1572 * The first layoutget for the file. Need to serialize per 1576 * The first layoutget for the file. Need to serialize per
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 0dfc476da3e1..b38e3c0dc790 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -247,7 +247,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages,
247} 247}
248 248
249/* Helper function for pnfs_generic_commit_pagelist to catch an empty 249/* Helper function for pnfs_generic_commit_pagelist to catch an empty
250 * page list. This can happen when two commits race. */ 250 * page list. This can happen when two commits race.
251 *
252 * This must be called instead of nfs_init_commit - call one or the other, but
253 * not both!
254 */
251static bool 255static bool
252pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages, 256pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages,
253 struct nfs_commit_data *data, 257 struct nfs_commit_data *data,
@@ -256,7 +260,11 @@ pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages,
256 if (list_empty(pages)) { 260 if (list_empty(pages)) {
257 if (atomic_dec_and_test(&cinfo->mds->rpcs_out)) 261 if (atomic_dec_and_test(&cinfo->mds->rpcs_out))
258 wake_up_atomic_t(&cinfo->mds->rpcs_out); 262 wake_up_atomic_t(&cinfo->mds->rpcs_out);
259 nfs_commitdata_release(data); 263 /* don't call nfs_commitdata_release - it tries to put
264 * the open_context which is not acquired until nfs_init_commit
265 * which has not been called on @data */
266 WARN_ON_ONCE(data->context);
267 nfs_commit_free(data);
260 return true; 268 return true;
261 } 269 }
262 270
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6776d7a7839e..572e5b3b06f1 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -367,13 +367,13 @@ readpage_async_filler(void *data, struct page *page)
367 nfs_list_remove_request(new); 367 nfs_list_remove_request(new);
368 nfs_readpage_release(new); 368 nfs_readpage_release(new);
369 error = desc->pgio->pg_error; 369 error = desc->pgio->pg_error;
370 goto out_unlock; 370 goto out;
371 } 371 }
372 return 0; 372 return 0;
373out_error: 373out_error:
374 error = PTR_ERR(new); 374 error = PTR_ERR(new);
375out_unlock:
376 unlock_page(page); 375 unlock_page(page);
376out:
377 return error; 377 return error;
378} 378}
379 379
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 1dbeab6cf96e..c831c2e5f803 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -59,16 +59,37 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
59 if (err) 59 if (err)
60 goto out; 60 goto out;
61 61
62 if (attr->ia_valid & ATTR_SIZE) {
63 struct inode *realinode = d_inode(ovl_dentry_real(dentry));
64
65 err = -ETXTBSY;
66 if (atomic_read(&realinode->i_writecount) < 0)
67 goto out_drop_write;
68 }
69
62 err = ovl_copy_up(dentry); 70 err = ovl_copy_up(dentry);
63 if (!err) { 71 if (!err) {
72 struct inode *winode = NULL;
73
64 upperdentry = ovl_dentry_upper(dentry); 74 upperdentry = ovl_dentry_upper(dentry);
65 75
76 if (attr->ia_valid & ATTR_SIZE) {
77 winode = d_inode(upperdentry);
78 err = get_write_access(winode);
79 if (err)
80 goto out_drop_write;
81 }
82
66 inode_lock(upperdentry->d_inode); 83 inode_lock(upperdentry->d_inode);
67 err = notify_change(upperdentry, attr, NULL); 84 err = notify_change(upperdentry, attr, NULL);
68 if (!err) 85 if (!err)
69 ovl_copyattr(upperdentry->d_inode, dentry->d_inode); 86 ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
70 inode_unlock(upperdentry->d_inode); 87 inode_unlock(upperdentry->d_inode);
88
89 if (winode)
90 put_write_access(winode);
71 } 91 }
92out_drop_write:
72 ovl_drop_write(dentry); 93 ovl_drop_write(dentry);
73out: 94out:
74 return err; 95 return err;
@@ -121,16 +142,18 @@ int ovl_permission(struct inode *inode, int mask)
121 142
122 err = vfs_getattr(&realpath, &stat); 143 err = vfs_getattr(&realpath, &stat);
123 if (err) 144 if (err)
124 return err; 145 goto out_dput;
125 146
147 err = -ESTALE;
126 if ((stat.mode ^ inode->i_mode) & S_IFMT) 148 if ((stat.mode ^ inode->i_mode) & S_IFMT)
127 return -ESTALE; 149 goto out_dput;
128 150
129 inode->i_mode = stat.mode; 151 inode->i_mode = stat.mode;
130 inode->i_uid = stat.uid; 152 inode->i_uid = stat.uid;
131 inode->i_gid = stat.gid; 153 inode->i_gid = stat.gid;
132 154
133 return generic_permission(inode, mask); 155 err = generic_permission(inode, mask);
156 goto out_dput;
134 } 157 }
135 158
136 /* Careful in RCU walk mode */ 159 /* Careful in RCU walk mode */
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index ce02f46029da..9a7693d5f8ff 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1082,11 +1082,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1082 if (err < 0) 1082 if (err < 0)
1083 goto out_put_workdir; 1083 goto out_put_workdir;
1084 1084
1085 if (!err) { 1085 /*
1086 pr_err("overlayfs: upper fs needs to support d_type.\n"); 1086 * We allowed this configuration and don't want to
1087 err = -EINVAL; 1087 * break users over kernel upgrade. So warn instead
1088 goto out_put_workdir; 1088 * of erroring out.
1089 } 1089 */
1090 if (!err)
1091 pr_warn("overlayfs: upper fs needs to support d_type.\n");
1090 } 1092 }
1091 } 1093 }
1092 1094
diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
index 9094599a1150..33466bfc6440 100644
--- a/include/drm/i915_pciids.h
+++ b/include/drm/i915_pciids.h
@@ -309,6 +309,7 @@
309 INTEL_VGA_DEVICE(0x5906, info), /* ULT GT1 */ \ 309 INTEL_VGA_DEVICE(0x5906, info), /* ULT GT1 */ \
310 INTEL_VGA_DEVICE(0x590E, info), /* ULX GT1 */ \ 310 INTEL_VGA_DEVICE(0x590E, info), /* ULX GT1 */ \
311 INTEL_VGA_DEVICE(0x5902, info), /* DT GT1 */ \ 311 INTEL_VGA_DEVICE(0x5902, info), /* DT GT1 */ \
312 INTEL_VGA_DEVICE(0x5908, info), /* Halo GT1 */ \
312 INTEL_VGA_DEVICE(0x590B, info), /* Halo GT1 */ \ 313 INTEL_VGA_DEVICE(0x590B, info), /* Halo GT1 */ \
313 INTEL_VGA_DEVICE(0x590A, info) /* SRV GT1 */ 314 INTEL_VGA_DEVICE(0x590A, info) /* SRV GT1 */
314 315
@@ -322,15 +323,12 @@
322 INTEL_VGA_DEVICE(0x591D, info) /* WKS GT2 */ 323 INTEL_VGA_DEVICE(0x591D, info) /* WKS GT2 */
323 324
324#define INTEL_KBL_GT3_IDS(info) \ 325#define INTEL_KBL_GT3_IDS(info) \
326 INTEL_VGA_DEVICE(0x5923, info), /* ULT GT3 */ \
325 INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \ 327 INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \
326 INTEL_VGA_DEVICE(0x592B, info), /* Halo GT3 */ \ 328 INTEL_VGA_DEVICE(0x5927, info) /* ULT GT3 */
327 INTEL_VGA_DEVICE(0x592A, info) /* SRV GT3 */
328 329
329#define INTEL_KBL_GT4_IDS(info) \ 330#define INTEL_KBL_GT4_IDS(info) \
330 INTEL_VGA_DEVICE(0x5932, info), /* DT GT4 */ \ 331 INTEL_VGA_DEVICE(0x593B, info) /* Halo GT4 */
331 INTEL_VGA_DEVICE(0x593B, info), /* Halo GT4 */ \
332 INTEL_VGA_DEVICE(0x593A, info), /* SRV GT4 */ \
333 INTEL_VGA_DEVICE(0x593D, info) /* WKS GT4 */
334 332
335#define INTEL_KBL_IDS(info) \ 333#define INTEL_KBL_IDS(info) \
336 INTEL_KBL_GT1_IDS(info), \ 334 INTEL_KBL_GT1_IDS(info), \
diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h
index fe389ac31489..92e7e97ca8ff 100644
--- a/include/kvm/arm_pmu.h
+++ b/include/kvm/arm_pmu.h
@@ -18,13 +18,13 @@
18#ifndef __ASM_ARM_KVM_PMU_H 18#ifndef __ASM_ARM_KVM_PMU_H
19#define __ASM_ARM_KVM_PMU_H 19#define __ASM_ARM_KVM_PMU_H
20 20
21#ifdef CONFIG_KVM_ARM_PMU
22
23#include <linux/perf_event.h> 21#include <linux/perf_event.h>
24#include <asm/perf_event.h> 22#include <asm/perf_event.h>
25 23
26#define ARMV8_PMU_CYCLE_IDX (ARMV8_PMU_MAX_COUNTERS - 1) 24#define ARMV8_PMU_CYCLE_IDX (ARMV8_PMU_MAX_COUNTERS - 1)
27 25
26#ifdef CONFIG_KVM_ARM_PMU
27
28struct kvm_pmc { 28struct kvm_pmc {
29 u8 idx; /* index into the pmu->pmc array */ 29 u8 idx; /* index into the pmu->pmc array */
30 struct perf_event *perf_event; 30 struct perf_event *perf_event;
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 961a417d641e..e38e3fc13ea8 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -26,7 +26,6 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/ptrace.h> 27#include <linux/ptrace.h>
28#include <uapi/linux/audit.h> 28#include <uapi/linux/audit.h>
29#include <linux/tty.h>
30 29
31#define AUDIT_INO_UNSET ((unsigned long)-1) 30#define AUDIT_INO_UNSET ((unsigned long)-1)
32#define AUDIT_DEV_UNSET ((dev_t)-1) 31#define AUDIT_DEV_UNSET ((dev_t)-1)
@@ -348,23 +347,6 @@ static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
348 return tsk->sessionid; 347 return tsk->sessionid;
349} 348}
350 349
351static inline struct tty_struct *audit_get_tty(struct task_struct *tsk)
352{
353 struct tty_struct *tty = NULL;
354 unsigned long flags;
355
356 spin_lock_irqsave(&tsk->sighand->siglock, flags);
357 if (tsk->signal)
358 tty = tty_kref_get(tsk->signal->tty);
359 spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
360 return tty;
361}
362
363static inline void audit_put_tty(struct tty_struct *tty)
364{
365 tty_kref_put(tty);
366}
367
368extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 350extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
369extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); 351extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
370extern void __audit_bprm(struct linux_binprm *bprm); 352extern void __audit_bprm(struct linux_binprm *bprm);
@@ -522,12 +504,6 @@ static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
522{ 504{
523 return -1; 505 return -1;
524} 506}
525static inline struct tty_struct *audit_get_tty(struct task_struct *tsk)
526{
527 return NULL;
528}
529static inline void audit_put_tty(struct tty_struct *tty)
530{ }
531static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) 507static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
532{ } 508{ }
533static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, 509static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8ee27b8afe81..0de4de6dd43e 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -111,6 +111,31 @@ enum bpf_access_type {
111 BPF_WRITE = 2 111 BPF_WRITE = 2
112}; 112};
113 113
114/* types of values stored in eBPF registers */
115enum bpf_reg_type {
116 NOT_INIT = 0, /* nothing was written into register */
117 UNKNOWN_VALUE, /* reg doesn't contain a valid pointer */
118 PTR_TO_CTX, /* reg points to bpf_context */
119 CONST_PTR_TO_MAP, /* reg points to struct bpf_map */
120 PTR_TO_MAP_VALUE, /* reg points to map element value */
121 PTR_TO_MAP_VALUE_OR_NULL,/* points to map elem value or NULL */
122 FRAME_PTR, /* reg == frame_pointer */
123 PTR_TO_STACK, /* reg == frame_pointer + imm */
124 CONST_IMM, /* constant integer value */
125
126 /* PTR_TO_PACKET represents:
127 * skb->data
128 * skb->data + imm
129 * skb->data + (u16) var
130 * skb->data + (u16) var + imm
131 * if (range > 0) then [ptr, ptr + range - off) is safe to access
132 * if (id > 0) means that some 'var' was added
133 * if (off > 0) menas that 'imm' was added
134 */
135 PTR_TO_PACKET,
136 PTR_TO_PACKET_END, /* skb->data + headlen */
137};
138
114struct bpf_prog; 139struct bpf_prog;
115 140
116struct bpf_verifier_ops { 141struct bpf_verifier_ops {
@@ -120,7 +145,8 @@ struct bpf_verifier_ops {
120 /* return true if 'size' wide access at offset 'off' within bpf_context 145 /* return true if 'size' wide access at offset 'off' within bpf_context
121 * with 'type' (read or write) is allowed 146 * with 'type' (read or write) is allowed
122 */ 147 */
123 bool (*is_valid_access)(int off, int size, enum bpf_access_type type); 148 bool (*is_valid_access)(int off, int size, enum bpf_access_type type,
149 enum bpf_reg_type *reg_type);
124 150
125 u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg, 151 u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg,
126 int src_reg, int ctx_off, 152 int src_reg, int ctx_off,
@@ -238,6 +264,10 @@ static inline struct bpf_prog *bpf_prog_get(u32 ufd)
238static inline void bpf_prog_put(struct bpf_prog *prog) 264static inline void bpf_prog_put(struct bpf_prog *prog)
239{ 265{
240} 266}
267
268static inline void bpf_prog_put_rcu(struct bpf_prog *prog)
269{
270}
241#endif /* CONFIG_BPF_SYSCALL */ 271#endif /* CONFIG_BPF_SYSCALL */
242 272
243/* verifier prototypes for helper functions called from eBPF programs */ 273/* verifier prototypes for helper functions called from eBPF programs */
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 7c27fa1030e8..feb04ea20f11 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -52,6 +52,12 @@ struct sock *inet_diag_find_one_icsk(struct net *net,
52 52
53int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk); 53int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
54 54
55void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
56
57int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
58 struct inet_diag_msg *r, int ext,
59 struct user_namespace *user_ns);
60
55extern int inet_diag_register(const struct inet_diag_handler *handler); 61extern int inet_diag_register(const struct inet_diag_handler *handler);
56extern void inet_diag_unregister(const struct inet_diag_handler *handler); 62extern void inet_diag_unregister(const struct inet_diag_handler *handler);
57#endif /* _INET_DIAG_H_ */ 63#endif /* _INET_DIAG_H_ */
diff --git a/include/linux/mfd/da9052/da9052.h b/include/linux/mfd/da9052/da9052.h
index c18a4c19d6fc..ce9230af09c2 100644
--- a/include/linux/mfd/da9052/da9052.h
+++ b/include/linux/mfd/da9052/da9052.h
@@ -171,7 +171,7 @@ static inline int da9052_group_read(struct da9052 *da9052, unsigned char reg,
171static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg, 171static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg,
172 unsigned reg_cnt, unsigned char *val) 172 unsigned reg_cnt, unsigned char *val)
173{ 173{
174 int ret; 174 int ret = 0;
175 int i; 175 int i;
176 176
177 for (i = 0; i < reg_cnt; i++) { 177 for (i = 0; i < reg_cnt; i++) {
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 80dec87a94f8..d46a0e7f144d 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -466,6 +466,7 @@ enum {
466enum { 466enum {
467 MLX4_INTERFACE_STATE_UP = 1 << 0, 467 MLX4_INTERFACE_STATE_UP = 1 << 0,
468 MLX4_INTERFACE_STATE_DELETION = 1 << 1, 468 MLX4_INTERFACE_STATE_DELETION = 1 << 1,
469 MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2,
469}; 470};
470 471
471#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ 472#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
diff --git a/include/linux/net.h b/include/linux/net.h
index 9aa49a05fe38..25aa03b51c4e 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -251,7 +251,8 @@ do { \
251 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ 251 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
252 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ 252 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
253 net_ratelimit()) \ 253 net_ratelimit()) \
254 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \ 254 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
255 ##__VA_ARGS__); \
255} while (0) 256} while (0)
256#elif defined(DEBUG) 257#elif defined(DEBUG)
257#define net_dbg_ratelimited(fmt, ...) \ 258#define net_dbg_ratelimited(fmt, ...) \
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 5b5a80cc5926..c818772d9f9d 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -43,10 +43,8 @@ struct posix_acl_entry {
43}; 43};
44 44
45struct posix_acl { 45struct posix_acl {
46 union { 46 atomic_t a_refcount;
47 atomic_t a_refcount; 47 struct rcu_head a_rcu;
48 struct rcu_head a_rcu;
49 };
50 unsigned int a_count; 48 unsigned int a_count;
51 struct posix_acl_entry a_entries[0]; 49 struct posix_acl_entry a_entries[0];
52}; 50};
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 908b67c847cd..c038ae36b10e 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -464,6 +464,8 @@ static inline bool pwm_can_sleep(struct pwm_device *pwm)
464 464
465static inline void pwm_apply_args(struct pwm_device *pwm) 465static inline void pwm_apply_args(struct pwm_device *pwm)
466{ 466{
467 struct pwm_state state = { };
468
467 /* 469 /*
468 * PWM users calling pwm_apply_args() expect to have a fresh config 470 * PWM users calling pwm_apply_args() expect to have a fresh config
469 * where the polarity and period are set according to pwm_args info. 471 * where the polarity and period are set according to pwm_args info.
@@ -476,18 +478,20 @@ static inline void pwm_apply_args(struct pwm_device *pwm)
476 * at startup (even if they are actually enabled), thus authorizing 478 * at startup (even if they are actually enabled), thus authorizing
477 * polarity setting. 479 * polarity setting.
478 * 480 *
479 * Instead of setting ->enabled to false, we call pwm_disable() 481 * To fulfill this requirement, we apply a new state which disables
480 * before pwm_set_polarity() to ensure that everything is configured 482 * the PWM device and set the reference period and polarity config.
481 * as expected, and the PWM is really disabled when the user request
482 * it.
483 * 483 *
484 * Note that PWM users requiring a smooth handover between the 484 * Note that PWM users requiring a smooth handover between the
485 * bootloader and the kernel (like critical regulators controlled by 485 * bootloader and the kernel (like critical regulators controlled by
486 * PWM devices) will have to switch to the atomic API and avoid calling 486 * PWM devices) will have to switch to the atomic API and avoid calling
487 * pwm_apply_args(). 487 * pwm_apply_args().
488 */ 488 */
489 pwm_disable(pwm); 489
490 pwm_set_polarity(pwm, pwm->args.polarity); 490 state.enabled = false;
491 state.polarity = pwm->args.polarity;
492 state.period = pwm->args.period;
493
494 pwm_apply_state(pwm, &state);
491} 495}
492 496
493struct pwm_lookup { 497struct pwm_lookup {
diff --git a/include/linux/qed/qed_eth_if.h b/include/linux/qed/qed_eth_if.h
index 6ae8cb4a61d3..6c876a63558d 100644
--- a/include/linux/qed/qed_eth_if.h
+++ b/include/linux/qed/qed_eth_if.h
@@ -49,6 +49,7 @@ struct qed_start_vport_params {
49 bool drop_ttl0; 49 bool drop_ttl0;
50 u8 vport_id; 50 u8 vport_id;
51 u16 mtu; 51 u16 mtu;
52 bool clear_stats;
52}; 53};
53 54
54struct qed_stop_rxq_params { 55struct qed_stop_rxq_params {
diff --git a/include/linux/reset.h b/include/linux/reset.h
index ec0306ce7b92..45a4abeb6acb 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -84,8 +84,8 @@ static inline struct reset_control *__devm_reset_control_get(
84#endif /* CONFIG_RESET_CONTROLLER */ 84#endif /* CONFIG_RESET_CONTROLLER */
85 85
86/** 86/**
87 * reset_control_get - Lookup and obtain an exclusive reference to a 87 * reset_control_get_exclusive - Lookup and obtain an exclusive reference
88 * reset controller. 88 * to a reset controller.
89 * @dev: device to be reset by the controller 89 * @dev: device to be reset by the controller
90 * @id: reset line name 90 * @id: reset line name
91 * 91 *
@@ -98,8 +98,8 @@ static inline struct reset_control *__devm_reset_control_get(
98 * 98 *
99 * Use of id names is optional. 99 * Use of id names is optional.
100 */ 100 */
101static inline struct reset_control *__must_check reset_control_get( 101static inline struct reset_control *
102 struct device *dev, const char *id) 102__must_check reset_control_get_exclusive(struct device *dev, const char *id)
103{ 103{
104#ifndef CONFIG_RESET_CONTROLLER 104#ifndef CONFIG_RESET_CONTROLLER
105 WARN_ON(1); 105 WARN_ON(1);
@@ -107,12 +107,6 @@ static inline struct reset_control *__must_check reset_control_get(
107 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0); 107 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
108} 108}
109 109
110static inline struct reset_control *reset_control_get_optional(
111 struct device *dev, const char *id)
112{
113 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
114}
115
116/** 110/**
117 * reset_control_get_shared - Lookup and obtain a shared reference to a 111 * reset_control_get_shared - Lookup and obtain a shared reference to a
118 * reset controller. 112 * reset controller.
@@ -141,9 +135,21 @@ static inline struct reset_control *reset_control_get_shared(
141 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1); 135 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1);
142} 136}
143 137
138static inline struct reset_control *reset_control_get_optional_exclusive(
139 struct device *dev, const char *id)
140{
141 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
142}
143
144static inline struct reset_control *reset_control_get_optional_shared(
145 struct device *dev, const char *id)
146{
147 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1);
148}
149
144/** 150/**
145 * of_reset_control_get - Lookup and obtain an exclusive reference to a 151 * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
146 * reset controller. 152 * to a reset controller.
147 * @node: device to be reset by the controller 153 * @node: device to be reset by the controller
148 * @id: reset line name 154 * @id: reset line name
149 * 155 *
@@ -151,15 +157,41 @@ static inline struct reset_control *reset_control_get_shared(
151 * 157 *
152 * Use of id names is optional. 158 * Use of id names is optional.
153 */ 159 */
154static inline struct reset_control *of_reset_control_get( 160static inline struct reset_control *of_reset_control_get_exclusive(
155 struct device_node *node, const char *id) 161 struct device_node *node, const char *id)
156{ 162{
157 return __of_reset_control_get(node, id, 0, 0); 163 return __of_reset_control_get(node, id, 0, 0);
158} 164}
159 165
160/** 166/**
161 * of_reset_control_get_by_index - Lookup and obtain an exclusive reference to 167 * of_reset_control_get_shared - Lookup and obtain an shared reference
162 * a reset controller by index. 168 * to a reset controller.
169 * @node: device to be reset by the controller
170 * @id: reset line name
171 *
172 * When a reset-control is shared, the behavior of reset_control_assert /
173 * deassert is changed, the reset-core will keep track of a deassert_count
174 * and only (re-)assert the reset after reset_control_assert has been called
175 * as many times as reset_control_deassert was called. Also see the remark
176 * about shared reset-controls in the reset_control_assert docs.
177 *
178 * Calling reset_control_assert without first calling reset_control_deassert
179 * is not allowed on a shared reset control. Calling reset_control_reset is
180 * also not allowed on a shared reset control.
181 * Returns a struct reset_control or IS_ERR() condition containing errno.
182 *
183 * Use of id names is optional.
184 */
185static inline struct reset_control *of_reset_control_get_shared(
186 struct device_node *node, const char *id)
187{
188 return __of_reset_control_get(node, id, 0, 1);
189}
190
191/**
192 * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
193 * reference to a reset controller
194 * by index.
163 * @node: device to be reset by the controller 195 * @node: device to be reset by the controller
164 * @index: index of the reset controller 196 * @index: index of the reset controller
165 * 197 *
@@ -167,49 +199,60 @@ static inline struct reset_control *of_reset_control_get(
167 * in whatever order. Returns a struct reset_control or IS_ERR() condition 199 * in whatever order. Returns a struct reset_control or IS_ERR() condition
168 * containing errno. 200 * containing errno.
169 */ 201 */
170static inline struct reset_control *of_reset_control_get_by_index( 202static inline struct reset_control *of_reset_control_get_exclusive_by_index(
171 struct device_node *node, int index) 203 struct device_node *node, int index)
172{ 204{
173 return __of_reset_control_get(node, NULL, index, 0); 205 return __of_reset_control_get(node, NULL, index, 0);
174} 206}
175 207
176/** 208/**
177 * devm_reset_control_get - resource managed reset_control_get() 209 * of_reset_control_get_shared_by_index - Lookup and obtain an shared
178 * @dev: device to be reset by the controller 210 * reference to a reset controller
179 * @id: reset line name 211 * by index.
212 * @node: device to be reset by the controller
213 * @index: index of the reset controller
214 *
215 * When a reset-control is shared, the behavior of reset_control_assert /
216 * deassert is changed, the reset-core will keep track of a deassert_count
217 * and only (re-)assert the reset after reset_control_assert has been called
218 * as many times as reset_control_deassert was called. Also see the remark
219 * about shared reset-controls in the reset_control_assert docs.
220 *
221 * Calling reset_control_assert without first calling reset_control_deassert
222 * is not allowed on a shared reset control. Calling reset_control_reset is
223 * also not allowed on a shared reset control.
224 * Returns a struct reset_control or IS_ERR() condition containing errno.
180 * 225 *
181 * Managed reset_control_get(). For reset controllers returned from this 226 * This is to be used to perform a list of resets for a device or power domain
182 * function, reset_control_put() is called automatically on driver detach. 227 * in whatever order. Returns a struct reset_control or IS_ERR() condition
183 * See reset_control_get() for more information. 228 * containing errno.
184 */ 229 */
185static inline struct reset_control *__must_check devm_reset_control_get( 230static inline struct reset_control *of_reset_control_get_shared_by_index(
186 struct device *dev, const char *id) 231 struct device_node *node, int index)
187{
188#ifndef CONFIG_RESET_CONTROLLER
189 WARN_ON(1);
190#endif
191 return __devm_reset_control_get(dev, id, 0, 0);
192}
193
194static inline struct reset_control *devm_reset_control_get_optional(
195 struct device *dev, const char *id)
196{ 232{
197 return __devm_reset_control_get(dev, id, 0, 0); 233 return __of_reset_control_get(node, NULL, index, 1);
198} 234}
199 235
200/** 236/**
201 * devm_reset_control_get_by_index - resource managed reset_control_get 237 * devm_reset_control_get_exclusive - resource managed
238 * reset_control_get_exclusive()
202 * @dev: device to be reset by the controller 239 * @dev: device to be reset by the controller
203 * @index: index of the reset controller 240 * @id: reset line name
204 * 241 *
205 * Managed reset_control_get(). For reset controllers returned from this 242 * Managed reset_control_get_exclusive(). For reset controllers returned
206 * function, reset_control_put() is called automatically on driver detach. 243 * from this function, reset_control_put() is called automatically on driver
207 * See reset_control_get() for more information. 244 * detach.
245 *
246 * See reset_control_get_exclusive() for more information.
208 */ 247 */
209static inline struct reset_control *devm_reset_control_get_by_index( 248static inline struct reset_control *
210 struct device *dev, int index) 249__must_check devm_reset_control_get_exclusive(struct device *dev,
250 const char *id)
211{ 251{
212 return __devm_reset_control_get(dev, NULL, index, 0); 252#ifndef CONFIG_RESET_CONTROLLER
253 WARN_ON(1);
254#endif
255 return __devm_reset_control_get(dev, id, 0, 0);
213} 256}
214 257
215/** 258/**
@@ -227,6 +270,36 @@ static inline struct reset_control *devm_reset_control_get_shared(
227 return __devm_reset_control_get(dev, id, 0, 1); 270 return __devm_reset_control_get(dev, id, 0, 1);
228} 271}
229 272
273static inline struct reset_control *devm_reset_control_get_optional_exclusive(
274 struct device *dev, const char *id)
275{
276 return __devm_reset_control_get(dev, id, 0, 0);
277}
278
279static inline struct reset_control *devm_reset_control_get_optional_shared(
280 struct device *dev, const char *id)
281{
282 return __devm_reset_control_get(dev, id, 0, 1);
283}
284
285/**
286 * devm_reset_control_get_exclusive_by_index - resource managed
287 * reset_control_get_exclusive()
288 * @dev: device to be reset by the controller
289 * @index: index of the reset controller
290 *
291 * Managed reset_control_get_exclusive(). For reset controllers returned from
292 * this function, reset_control_put() is called automatically on driver
293 * detach.
294 *
295 * See reset_control_get_exclusive() for more information.
296 */
297static inline struct reset_control *
298devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
299{
300 return __devm_reset_control_get(dev, NULL, index, 0);
301}
302
230/** 303/**
231 * devm_reset_control_get_shared_by_index - resource managed 304 * devm_reset_control_get_shared_by_index - resource managed
232 * reset_control_get_shared 305 * reset_control_get_shared
@@ -237,10 +310,60 @@ static inline struct reset_control *devm_reset_control_get_shared(
237 * this function, reset_control_put() is called automatically on driver detach. 310 * this function, reset_control_put() is called automatically on driver detach.
238 * See reset_control_get_shared() for more information. 311 * See reset_control_get_shared() for more information.
239 */ 312 */
240static inline struct reset_control *devm_reset_control_get_shared_by_index( 313static inline struct reset_control *
241 struct device *dev, int index) 314devm_reset_control_get_shared_by_index(struct device *dev, int index)
242{ 315{
243 return __devm_reset_control_get(dev, NULL, index, 1); 316 return __devm_reset_control_get(dev, NULL, index, 1);
244} 317}
245 318
319/*
320 * TEMPORARY calls to use during transition:
321 *
322 * of_reset_control_get() => of_reset_control_get_exclusive()
323 *
324 * These inline function calls will be removed once all consumers
325 * have been moved over to the new explicit API.
326 */
327static inline struct reset_control *reset_control_get(
328 struct device *dev, const char *id)
329{
330 return reset_control_get_exclusive(dev, id);
331}
332
333static inline struct reset_control *reset_control_get_optional(
334 struct device *dev, const char *id)
335{
336 return reset_control_get_optional_exclusive(dev, id);
337}
338
339static inline struct reset_control *of_reset_control_get(
340 struct device_node *node, const char *id)
341{
342 return of_reset_control_get_exclusive(node, id);
343}
344
345static inline struct reset_control *of_reset_control_get_by_index(
346 struct device_node *node, int index)
347{
348 return of_reset_control_get_exclusive_by_index(node, index);
349}
350
351static inline struct reset_control *devm_reset_control_get(
352 struct device *dev, const char *id)
353{
354 return devm_reset_control_get_exclusive(dev, id);
355}
356
357static inline struct reset_control *devm_reset_control_get_optional(
358 struct device *dev, const char *id)
359{
360 return devm_reset_control_get_optional_exclusive(dev, id);
361
362}
363
364static inline struct reset_control *devm_reset_control_get_by_index(
365 struct device *dev, int index)
366{
367 return devm_reset_control_get_exclusive_by_index(dev, index);
368}
246#endif 369#endif
diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
index 4018b48f2b3b..a0596ca0e80a 100644
--- a/include/linux/sock_diag.h
+++ b/include/linux/sock_diag.h
@@ -36,6 +36,9 @@ enum sknetlink_groups sock_diag_destroy_group(const struct sock *sk)
36{ 36{
37 switch (sk->sk_family) { 37 switch (sk->sk_family) {
38 case AF_INET: 38 case AF_INET:
39 if (sk->sk_type == SOCK_RAW)
40 return SKNLGRP_NONE;
41
39 switch (sk->sk_protocol) { 42 switch (sk->sk_protocol) {
40 case IPPROTO_TCP: 43 case IPPROTO_TCP:
41 return SKNLGRP_INET_TCP_DESTROY; 44 return SKNLGRP_INET_TCP_DESTROY;
@@ -45,6 +48,9 @@ enum sknetlink_groups sock_diag_destroy_group(const struct sock *sk)
45 return SKNLGRP_NONE; 48 return SKNLGRP_NONE;
46 } 49 }
47 case AF_INET6: 50 case AF_INET6:
51 if (sk->sk_type == SOCK_RAW)
52 return SKNLGRP_NONE;
53
48 switch (sk->sk_protocol) { 54 switch (sk->sk_protocol) {
49 case IPPROTO_TCP: 55 case IPPROTO_TCP:
50 return SKNLGRP_INET6_TCP_DESTROY; 56 return SKNLGRP_INET6_TCP_DESTROY;
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index 966889a20ea3..e479033bd782 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -180,11 +180,11 @@ struct ehci_regs {
180 * PORTSCx 180 * PORTSCx
181 */ 181 */
182 /* HOSTPC: offset 0x84 */ 182 /* HOSTPC: offset 0x84 */
183 u32 hostpc[1]; /* HOSTPC extension */ 183 u32 hostpc[0]; /* HOSTPC extension */
184#define HOSTPC_PHCD (1<<22) /* Phy clock disable */ 184#define HOSTPC_PHCD (1<<22) /* Phy clock disable */
185#define HOSTPC_PSPD (3<<25) /* Port speed detection */ 185#define HOSTPC_PSPD (3<<25) /* Port speed detection */
186 186
187 u32 reserved5[16]; 187 u32 reserved5[17];
188 188
189 /* USBMODE_EX: offset 0xc8 */ 189 /* USBMODE_EX: offset 0xc8 */
190 u32 usbmode_ex; /* USB Device mode extension */ 190 u32 usbmode_ex; /* USB Device mode extension */
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 27d7a0ab5da3..c3ff74d764fa 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -600,6 +600,19 @@ do { \
600 __ret; \ 600 __ret; \
601}) 601})
602 602
603#define __wait_event_killable_exclusive(wq, condition) \
604 ___wait_event(wq, condition, TASK_KILLABLE, 1, 0, \
605 schedule())
606
607#define wait_event_killable_exclusive(wq, condition) \
608({ \
609 int __ret = 0; \
610 might_sleep(); \
611 if (!(condition)) \
612 __ret = __wait_event_killable_exclusive(wq, condition); \
613 __ret; \
614})
615
603 616
604#define __wait_event_freezable_exclusive(wq, condition) \ 617#define __wait_event_freezable_exclusive(wq, condition) \
605 ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \ 618 ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
diff --git a/include/net/gre.h b/include/net/gre.h
index 5dce30a6abe3..7a54a31d1d4c 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -26,7 +26,7 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version);
26struct net_device *gretap_fb_dev_create(struct net *net, const char *name, 26struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
27 u8 name_assign_type); 27 u8 name_assign_type);
28int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, 28int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
29 bool *csum_err, __be16 proto); 29 bool *csum_err, __be16 proto, int nhs);
30 30
31static inline int gre_calc_hlen(__be16 o_flags) 31static inline int gre_calc_hlen(__be16 o_flags)
32{ 32{
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 092235458691..f7c291ff4074 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -167,6 +167,7 @@ struct nft_set_elem {
167 167
168struct nft_set; 168struct nft_set;
169struct nft_set_iter { 169struct nft_set_iter {
170 u8 genmask;
170 unsigned int count; 171 unsigned int count;
171 unsigned int skip; 172 unsigned int skip;
172 int err; 173 int err;
diff --git a/include/net/tc_act/tc_ife.h b/include/net/tc_act/tc_ife.h
index dc9a09aefb33..c55facd17b7e 100644
--- a/include/net/tc_act/tc_ife.h
+++ b/include/net/tc_act/tc_ife.h
@@ -36,7 +36,7 @@ struct tcf_meta_ops {
36 int (*encode)(struct sk_buff *, void *, struct tcf_meta_info *); 36 int (*encode)(struct sk_buff *, void *, struct tcf_meta_info *);
37 int (*decode)(struct sk_buff *, void *, u16 len); 37 int (*decode)(struct sk_buff *, void *, u16 len);
38 int (*get)(struct sk_buff *skb, struct tcf_meta_info *mi); 38 int (*get)(struct sk_buff *skb, struct tcf_meta_info *mi);
39 int (*alloc)(struct tcf_meta_info *, void *); 39 int (*alloc)(struct tcf_meta_info *, void *, gfp_t);
40 void (*release)(struct tcf_meta_info *); 40 void (*release)(struct tcf_meta_info *);
41 int (*validate)(void *val, int len); 41 int (*validate)(void *val, int len);
42 struct module *owner; 42 struct module *owner;
@@ -48,8 +48,8 @@ int ife_get_meta_u32(struct sk_buff *skb, struct tcf_meta_info *mi);
48int ife_get_meta_u16(struct sk_buff *skb, struct tcf_meta_info *mi); 48int ife_get_meta_u16(struct sk_buff *skb, struct tcf_meta_info *mi);
49int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen, 49int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen,
50 const void *dval); 50 const void *dval);
51int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval); 51int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval, gfp_t gfp);
52int ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval); 52int ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval, gfp_t gfp);
53int ife_check_meta_u32(u32 metaval, struct tcf_meta_info *mi); 53int ife_check_meta_u32(u32 metaval, struct tcf_meta_info *mi);
54int ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi); 54int ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi);
55int ife_validate_meta_u32(void *val, int len); 55int ife_validate_meta_u32(void *val, int len);
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 87cf351bab03..737fa32faad4 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -611,6 +611,37 @@
611#define KEY_KBDINPUTASSIST_ACCEPT 0x264 611#define KEY_KBDINPUTASSIST_ACCEPT 0x264
612#define KEY_KBDINPUTASSIST_CANCEL 0x265 612#define KEY_KBDINPUTASSIST_CANCEL 0x265
613 613
614/* Diagonal movement keys */
615#define KEY_RIGHT_UP 0x266
616#define KEY_RIGHT_DOWN 0x267
617#define KEY_LEFT_UP 0x268
618#define KEY_LEFT_DOWN 0x269
619
620#define KEY_ROOT_MENU 0x26a /* Show Device's Root Menu */
621/* Show Top Menu of the Media (e.g. DVD) */
622#define KEY_MEDIA_TOP_MENU 0x26b
623#define KEY_NUMERIC_11 0x26c
624#define KEY_NUMERIC_12 0x26d
625/*
626 * Toggle Audio Description: refers to an audio service that helps blind and
627 * visually impaired consumers understand the action in a program. Note: in
628 * some countries this is referred to as "Video Description".
629 */
630#define KEY_AUDIO_DESC 0x26e
631#define KEY_3D_MODE 0x26f
632#define KEY_NEXT_FAVORITE 0x270
633#define KEY_STOP_RECORD 0x271
634#define KEY_PAUSE_RECORD 0x272
635#define KEY_VOD 0x273 /* Video on Demand */
636#define KEY_UNMUTE 0x274
637#define KEY_FASTREVERSE 0x275
638#define KEY_SLOWREVERSE 0x276
639/*
640 * Control a data application associated with the currently viewed channel,
641 * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
642 */
643#define KEY_DATA 0x275
644
614#define BTN_TRIGGER_HAPPY 0x2c0 645#define BTN_TRIGGER_HAPPY 0x2c0
615#define BTN_TRIGGER_HAPPY1 0x2c0 646#define BTN_TRIGGER_HAPPY1 0x2c0
616#define BTN_TRIGGER_HAPPY2 0x2c1 647#define BTN_TRIGGER_HAPPY2 0x2c1
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 01113841190d..c51494119817 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -247,6 +247,7 @@ struct input_mask {
247#define BUS_ATARI 0x1B 247#define BUS_ATARI 0x1B
248#define BUS_SPI 0x1C 248#define BUS_SPI 0x1C
249#define BUS_RMI 0x1D 249#define BUS_RMI 0x1D
250#define BUS_CEC 0x1E
250 251
251/* 252/*
252 * MT_TOOL types 253 * MT_TOOL types
diff --git a/include/uapi/linux/netfilter/Kbuild b/include/uapi/linux/netfilter/Kbuild
index 1d973d2ba417..cd26d7a0fd07 100644
--- a/include/uapi/linux/netfilter/Kbuild
+++ b/include/uapi/linux/netfilter/Kbuild
@@ -33,6 +33,7 @@ header-y += xt_NFLOG.h
33header-y += xt_NFQUEUE.h 33header-y += xt_NFQUEUE.h
34header-y += xt_RATEEST.h 34header-y += xt_RATEEST.h
35header-y += xt_SECMARK.h 35header-y += xt_SECMARK.h
36header-y += xt_SYNPROXY.h
36header-y += xt_TCPMSS.h 37header-y += xt_TCPMSS.h
37header-y += xt_TCPOPTSTRIP.h 38header-y += xt_TCPOPTSTRIP.h
38header-y += xt_TEE.h 39header-y += xt_TEE.h
diff --git a/include/uapi/linux/netfilter/xt_SYNPROXY.h b/include/uapi/linux/netfilter/xt_SYNPROXY.h
index 2d59fbaa93c6..ca67e61d2a61 100644
--- a/include/uapi/linux/netfilter/xt_SYNPROXY.h
+++ b/include/uapi/linux/netfilter/xt_SYNPROXY.h
@@ -1,6 +1,8 @@
1#ifndef _XT_SYNPROXY_H 1#ifndef _XT_SYNPROXY_H
2#define _XT_SYNPROXY_H 2#define _XT_SYNPROXY_H
3 3
4#include <linux/types.h>
5
4#define XT_SYNPROXY_OPT_MSS 0x01 6#define XT_SYNPROXY_OPT_MSS 0x01
5#define XT_SYNPROXY_OPT_WSCALE 0x02 7#define XT_SYNPROXY_OPT_WSCALE 0x02
6#define XT_SYNPROXY_OPT_SACK_PERM 0x04 8#define XT_SYNPROXY_OPT_SACK_PERM 0x04
diff --git a/kernel/audit.c b/kernel/audit.c
index 22bb4f24f071..8d528f9930da 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1883,6 +1883,23 @@ out_null:
1883 audit_log_format(ab, " exe=(null)"); 1883 audit_log_format(ab, " exe=(null)");
1884} 1884}
1885 1885
1886struct tty_struct *audit_get_tty(struct task_struct *tsk)
1887{
1888 struct tty_struct *tty = NULL;
1889 unsigned long flags;
1890
1891 spin_lock_irqsave(&tsk->sighand->siglock, flags);
1892 if (tsk->signal)
1893 tty = tty_kref_get(tsk->signal->tty);
1894 spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
1895 return tty;
1896}
1897
1898void audit_put_tty(struct tty_struct *tty)
1899{
1900 tty_kref_put(tty);
1901}
1902
1886void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) 1903void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1887{ 1904{
1888 const struct cred *cred; 1905 const struct cred *cred;
diff --git a/kernel/audit.h b/kernel/audit.h
index cbbe6bb6496e..a492f4c4e710 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -23,6 +23,7 @@
23#include <linux/audit.h> 23#include <linux/audit.h>
24#include <linux/skbuff.h> 24#include <linux/skbuff.h>
25#include <uapi/linux/mqueue.h> 25#include <uapi/linux/mqueue.h>
26#include <linux/tty.h>
26 27
27/* AUDIT_NAMES is the number of slots we reserve in the audit_context 28/* AUDIT_NAMES is the number of slots we reserve in the audit_context
28 * for saving names from getname(). If we get more names we will allocate 29 * for saving names from getname(). If we get more names we will allocate
@@ -262,6 +263,9 @@ extern struct audit_entry *audit_dupe_rule(struct audit_krule *old);
262extern void audit_log_d_path_exe(struct audit_buffer *ab, 263extern void audit_log_d_path_exe(struct audit_buffer *ab,
263 struct mm_struct *mm); 264 struct mm_struct *mm);
264 265
266extern struct tty_struct *audit_get_tty(struct task_struct *tsk);
267extern void audit_put_tty(struct tty_struct *tty);
268
265/* audit watch functions */ 269/* audit watch functions */
266#ifdef CONFIG_AUDIT_WATCH 270#ifdef CONFIG_AUDIT_WATCH
267extern void audit_put_watch(struct audit_watch *watch); 271extern void audit_put_watch(struct audit_watch *watch);
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 62ab53d7619c..2672d105cffc 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -63,7 +63,6 @@
63#include <asm/unistd.h> 63#include <asm/unistd.h>
64#include <linux/security.h> 64#include <linux/security.h>
65#include <linux/list.h> 65#include <linux/list.h>
66#include <linux/tty.h>
67#include <linux/binfmts.h> 66#include <linux/binfmts.h>
68#include <linux/highmem.h> 67#include <linux/highmem.h>
69#include <linux/syscalls.h> 68#include <linux/syscalls.h>
@@ -1985,14 +1984,15 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
1985 if (!audit_enabled) 1984 if (!audit_enabled)
1986 return; 1985 return;
1987 1986
1987 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1988 if (!ab)
1989 return;
1990
1988 uid = from_kuid(&init_user_ns, task_uid(current)); 1991 uid = from_kuid(&init_user_ns, task_uid(current));
1989 oldloginuid = from_kuid(&init_user_ns, koldloginuid); 1992 oldloginuid = from_kuid(&init_user_ns, koldloginuid);
1990 loginuid = from_kuid(&init_user_ns, kloginuid), 1993 loginuid = from_kuid(&init_user_ns, kloginuid),
1991 tty = audit_get_tty(current); 1994 tty = audit_get_tty(current);
1992 1995
1993 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1994 if (!ab)
1995 return;
1996 audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid); 1996 audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
1997 audit_log_task_context(ab); 1997 audit_log_task_context(ab);
1998 audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d", 1998 audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 668e07903c8f..eec9f90ba030 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -126,31 +126,6 @@
126 * are set to NOT_INIT to indicate that they are no longer readable. 126 * are set to NOT_INIT to indicate that they are no longer readable.
127 */ 127 */
128 128
129/* types of values stored in eBPF registers */
130enum bpf_reg_type {
131 NOT_INIT = 0, /* nothing was written into register */
132 UNKNOWN_VALUE, /* reg doesn't contain a valid pointer */
133 PTR_TO_CTX, /* reg points to bpf_context */
134 CONST_PTR_TO_MAP, /* reg points to struct bpf_map */
135 PTR_TO_MAP_VALUE, /* reg points to map element value */
136 PTR_TO_MAP_VALUE_OR_NULL,/* points to map elem value or NULL */
137 FRAME_PTR, /* reg == frame_pointer */
138 PTR_TO_STACK, /* reg == frame_pointer + imm */
139 CONST_IMM, /* constant integer value */
140
141 /* PTR_TO_PACKET represents:
142 * skb->data
143 * skb->data + imm
144 * skb->data + (u16) var
145 * skb->data + (u16) var + imm
146 * if (range > 0) then [ptr, ptr + range - off) is safe to access
147 * if (id > 0) means that some 'var' was added
148 * if (off > 0) menas that 'imm' was added
149 */
150 PTR_TO_PACKET,
151 PTR_TO_PACKET_END, /* skb->data + headlen */
152};
153
154struct reg_state { 129struct reg_state {
155 enum bpf_reg_type type; 130 enum bpf_reg_type type;
156 union { 131 union {
@@ -695,10 +670,10 @@ static int check_packet_access(struct verifier_env *env, u32 regno, int off,
695 670
696/* check access to 'struct bpf_context' fields */ 671/* check access to 'struct bpf_context' fields */
697static int check_ctx_access(struct verifier_env *env, int off, int size, 672static int check_ctx_access(struct verifier_env *env, int off, int size,
698 enum bpf_access_type t) 673 enum bpf_access_type t, enum bpf_reg_type *reg_type)
699{ 674{
700 if (env->prog->aux->ops->is_valid_access && 675 if (env->prog->aux->ops->is_valid_access &&
701 env->prog->aux->ops->is_valid_access(off, size, t)) { 676 env->prog->aux->ops->is_valid_access(off, size, t, reg_type)) {
702 /* remember the offset of last byte accessed in ctx */ 677 /* remember the offset of last byte accessed in ctx */
703 if (env->prog->aux->max_ctx_offset < off + size) 678 if (env->prog->aux->max_ctx_offset < off + size)
704 env->prog->aux->max_ctx_offset = off + size; 679 env->prog->aux->max_ctx_offset = off + size;
@@ -798,21 +773,19 @@ static int check_mem_access(struct verifier_env *env, u32 regno, int off,
798 mark_reg_unknown_value(state->regs, value_regno); 773 mark_reg_unknown_value(state->regs, value_regno);
799 774
800 } else if (reg->type == PTR_TO_CTX) { 775 } else if (reg->type == PTR_TO_CTX) {
776 enum bpf_reg_type reg_type = UNKNOWN_VALUE;
777
801 if (t == BPF_WRITE && value_regno >= 0 && 778 if (t == BPF_WRITE && value_regno >= 0 &&
802 is_pointer_value(env, value_regno)) { 779 is_pointer_value(env, value_regno)) {
803 verbose("R%d leaks addr into ctx\n", value_regno); 780 verbose("R%d leaks addr into ctx\n", value_regno);
804 return -EACCES; 781 return -EACCES;
805 } 782 }
806 err = check_ctx_access(env, off, size, t); 783 err = check_ctx_access(env, off, size, t, &reg_type);
807 if (!err && t == BPF_READ && value_regno >= 0) { 784 if (!err && t == BPF_READ && value_regno >= 0) {
808 mark_reg_unknown_value(state->regs, value_regno); 785 mark_reg_unknown_value(state->regs, value_regno);
809 if (off == offsetof(struct __sk_buff, data) && 786 if (env->allow_ptr_leaks)
810 env->allow_ptr_leaks)
811 /* note that reg.[id|off|range] == 0 */ 787 /* note that reg.[id|off|range] == 0 */
812 state->regs[value_regno].type = PTR_TO_PACKET; 788 state->regs[value_regno].type = reg_type;
813 else if (off == offsetof(struct __sk_buff, data_end) &&
814 env->allow_ptr_leaks)
815 state->regs[value_regno].type = PTR_TO_PACKET_END;
816 } 789 }
817 790
818 } else if (reg->type == FRAME_PTR || reg->type == PTR_TO_STACK) { 791 } else if (reg->type == FRAME_PTR || reg->type == PTR_TO_STACK) {
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 86cb5c6e8932..75c0ff00aca6 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -837,6 +837,8 @@ static void put_css_set_locked(struct css_set *cset)
837 837
838static void put_css_set(struct css_set *cset) 838static void put_css_set(struct css_set *cset)
839{ 839{
840 unsigned long flags;
841
840 /* 842 /*
841 * Ensure that the refcount doesn't hit zero while any readers 843 * Ensure that the refcount doesn't hit zero while any readers
842 * can see it. Similar to atomic_dec_and_lock(), but for an 844 * can see it. Similar to atomic_dec_and_lock(), but for an
@@ -845,9 +847,9 @@ static void put_css_set(struct css_set *cset)
845 if (atomic_add_unless(&cset->refcount, -1, 1)) 847 if (atomic_add_unless(&cset->refcount, -1, 1))
846 return; 848 return;
847 849
848 spin_lock_bh(&css_set_lock); 850 spin_lock_irqsave(&css_set_lock, flags);
849 put_css_set_locked(cset); 851 put_css_set_locked(cset);
850 spin_unlock_bh(&css_set_lock); 852 spin_unlock_irqrestore(&css_set_lock, flags);
851} 853}
852 854
853/* 855/*
@@ -1070,11 +1072,11 @@ static struct css_set *find_css_set(struct css_set *old_cset,
1070 1072
1071 /* First see if we already have a cgroup group that matches 1073 /* First see if we already have a cgroup group that matches
1072 * the desired set */ 1074 * the desired set */
1073 spin_lock_bh(&css_set_lock); 1075 spin_lock_irq(&css_set_lock);
1074 cset = find_existing_css_set(old_cset, cgrp, template); 1076 cset = find_existing_css_set(old_cset, cgrp, template);
1075 if (cset) 1077 if (cset)
1076 get_css_set(cset); 1078 get_css_set(cset);
1077 spin_unlock_bh(&css_set_lock); 1079 spin_unlock_irq(&css_set_lock);
1078 1080
1079 if (cset) 1081 if (cset)
1080 return cset; 1082 return cset;
@@ -1102,7 +1104,7 @@ static struct css_set *find_css_set(struct css_set *old_cset,
1102 * find_existing_css_set() */ 1104 * find_existing_css_set() */
1103 memcpy(cset->subsys, template, sizeof(cset->subsys)); 1105 memcpy(cset->subsys, template, sizeof(cset->subsys));
1104 1106
1105 spin_lock_bh(&css_set_lock); 1107 spin_lock_irq(&css_set_lock);
1106 /* Add reference counts and links from the new css_set. */ 1108 /* Add reference counts and links from the new css_set. */
1107 list_for_each_entry(link, &old_cset->cgrp_links, cgrp_link) { 1109 list_for_each_entry(link, &old_cset->cgrp_links, cgrp_link) {
1108 struct cgroup *c = link->cgrp; 1110 struct cgroup *c = link->cgrp;
@@ -1128,7 +1130,7 @@ static struct css_set *find_css_set(struct css_set *old_cset,
1128 css_get(css); 1130 css_get(css);
1129 } 1131 }
1130 1132
1131 spin_unlock_bh(&css_set_lock); 1133 spin_unlock_irq(&css_set_lock);
1132 1134
1133 return cset; 1135 return cset;
1134} 1136}
@@ -1192,7 +1194,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)
1192 * Release all the links from cset_links to this hierarchy's 1194 * Release all the links from cset_links to this hierarchy's
1193 * root cgroup 1195 * root cgroup
1194 */ 1196 */
1195 spin_lock_bh(&css_set_lock); 1197 spin_lock_irq(&css_set_lock);
1196 1198
1197 list_for_each_entry_safe(link, tmp_link, &cgrp->cset_links, cset_link) { 1199 list_for_each_entry_safe(link, tmp_link, &cgrp->cset_links, cset_link) {
1198 list_del(&link->cset_link); 1200 list_del(&link->cset_link);
@@ -1200,7 +1202,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)
1200 kfree(link); 1202 kfree(link);
1201 } 1203 }
1202 1204
1203 spin_unlock_bh(&css_set_lock); 1205 spin_unlock_irq(&css_set_lock);
1204 1206
1205 if (!list_empty(&root->root_list)) { 1207 if (!list_empty(&root->root_list)) {
1206 list_del(&root->root_list); 1208 list_del(&root->root_list);
@@ -1600,11 +1602,11 @@ static int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
1600 ss->root = dst_root; 1602 ss->root = dst_root;
1601 css->cgroup = dcgrp; 1603 css->cgroup = dcgrp;
1602 1604
1603 spin_lock_bh(&css_set_lock); 1605 spin_lock_irq(&css_set_lock);
1604 hash_for_each(css_set_table, i, cset, hlist) 1606 hash_for_each(css_set_table, i, cset, hlist)
1605 list_move_tail(&cset->e_cset_node[ss->id], 1607 list_move_tail(&cset->e_cset_node[ss->id],
1606 &dcgrp->e_csets[ss->id]); 1608 &dcgrp->e_csets[ss->id]);
1607 spin_unlock_bh(&css_set_lock); 1609 spin_unlock_irq(&css_set_lock);
1608 1610
1609 /* default hierarchy doesn't enable controllers by default */ 1611 /* default hierarchy doesn't enable controllers by default */
1610 dst_root->subsys_mask |= 1 << ssid; 1612 dst_root->subsys_mask |= 1 << ssid;
@@ -1640,10 +1642,10 @@ static int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
1640 if (!buf) 1642 if (!buf)
1641 return -ENOMEM; 1643 return -ENOMEM;
1642 1644
1643 spin_lock_bh(&css_set_lock); 1645 spin_lock_irq(&css_set_lock);
1644 ns_cgroup = current_cgns_cgroup_from_root(kf_cgroot); 1646 ns_cgroup = current_cgns_cgroup_from_root(kf_cgroot);
1645 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX); 1647 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
1646 spin_unlock_bh(&css_set_lock); 1648 spin_unlock_irq(&css_set_lock);
1647 1649
1648 if (len >= PATH_MAX) 1650 if (len >= PATH_MAX)
1649 len = -ERANGE; 1651 len = -ERANGE;
@@ -1897,7 +1899,7 @@ static void cgroup_enable_task_cg_lists(void)
1897{ 1899{
1898 struct task_struct *p, *g; 1900 struct task_struct *p, *g;
1899 1901
1900 spin_lock_bh(&css_set_lock); 1902 spin_lock_irq(&css_set_lock);
1901 1903
1902 if (use_task_css_set_links) 1904 if (use_task_css_set_links)
1903 goto out_unlock; 1905 goto out_unlock;
@@ -1922,8 +1924,12 @@ static void cgroup_enable_task_cg_lists(void)
1922 * entry won't be deleted though the process has exited. 1924 * entry won't be deleted though the process has exited.
1923 * Do it while holding siglock so that we don't end up 1925 * Do it while holding siglock so that we don't end up
1924 * racing against cgroup_exit(). 1926 * racing against cgroup_exit().
1927 *
1928 * Interrupts were already disabled while acquiring
1929 * the css_set_lock, so we do not need to disable it
1930 * again when acquiring the sighand->siglock here.
1925 */ 1931 */
1926 spin_lock_irq(&p->sighand->siglock); 1932 spin_lock(&p->sighand->siglock);
1927 if (!(p->flags & PF_EXITING)) { 1933 if (!(p->flags & PF_EXITING)) {
1928 struct css_set *cset = task_css_set(p); 1934 struct css_set *cset = task_css_set(p);
1929 1935
@@ -1932,11 +1938,11 @@ static void cgroup_enable_task_cg_lists(void)
1932 list_add_tail(&p->cg_list, &cset->tasks); 1938 list_add_tail(&p->cg_list, &cset->tasks);
1933 get_css_set(cset); 1939 get_css_set(cset);
1934 } 1940 }
1935 spin_unlock_irq(&p->sighand->siglock); 1941 spin_unlock(&p->sighand->siglock);
1936 } while_each_thread(g, p); 1942 } while_each_thread(g, p);
1937 read_unlock(&tasklist_lock); 1943 read_unlock(&tasklist_lock);
1938out_unlock: 1944out_unlock:
1939 spin_unlock_bh(&css_set_lock); 1945 spin_unlock_irq(&css_set_lock);
1940} 1946}
1941 1947
1942static void init_cgroup_housekeeping(struct cgroup *cgrp) 1948static void init_cgroup_housekeeping(struct cgroup *cgrp)
@@ -2043,13 +2049,13 @@ static int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
2043 * Link the root cgroup in this hierarchy into all the css_set 2049 * Link the root cgroup in this hierarchy into all the css_set
2044 * objects. 2050 * objects.
2045 */ 2051 */
2046 spin_lock_bh(&css_set_lock); 2052 spin_lock_irq(&css_set_lock);
2047 hash_for_each(css_set_table, i, cset, hlist) { 2053 hash_for_each(css_set_table, i, cset, hlist) {
2048 link_css_set(&tmp_links, cset, root_cgrp); 2054 link_css_set(&tmp_links, cset, root_cgrp);
2049 if (css_set_populated(cset)) 2055 if (css_set_populated(cset))
2050 cgroup_update_populated(root_cgrp, true); 2056 cgroup_update_populated(root_cgrp, true);
2051 } 2057 }
2052 spin_unlock_bh(&css_set_lock); 2058 spin_unlock_irq(&css_set_lock);
2053 2059
2054 BUG_ON(!list_empty(&root_cgrp->self.children)); 2060 BUG_ON(!list_empty(&root_cgrp->self.children));
2055 BUG_ON(atomic_read(&root->nr_cgrps) != 1); 2061 BUG_ON(atomic_read(&root->nr_cgrps) != 1);
@@ -2256,11 +2262,11 @@ out_mount:
2256 struct cgroup *cgrp; 2262 struct cgroup *cgrp;
2257 2263
2258 mutex_lock(&cgroup_mutex); 2264 mutex_lock(&cgroup_mutex);
2259 spin_lock_bh(&css_set_lock); 2265 spin_lock_irq(&css_set_lock);
2260 2266
2261 cgrp = cset_cgroup_from_root(ns->root_cset, root); 2267 cgrp = cset_cgroup_from_root(ns->root_cset, root);
2262 2268
2263 spin_unlock_bh(&css_set_lock); 2269 spin_unlock_irq(&css_set_lock);
2264 mutex_unlock(&cgroup_mutex); 2270 mutex_unlock(&cgroup_mutex);
2265 2271
2266 nsdentry = kernfs_node_dentry(cgrp->kn, dentry->d_sb); 2272 nsdentry = kernfs_node_dentry(cgrp->kn, dentry->d_sb);
@@ -2337,11 +2343,11 @@ char *cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
2337 char *ret; 2343 char *ret;
2338 2344
2339 mutex_lock(&cgroup_mutex); 2345 mutex_lock(&cgroup_mutex);
2340 spin_lock_bh(&css_set_lock); 2346 spin_lock_irq(&css_set_lock);
2341 2347
2342 ret = cgroup_path_ns_locked(cgrp, buf, buflen, ns); 2348 ret = cgroup_path_ns_locked(cgrp, buf, buflen, ns);
2343 2349
2344 spin_unlock_bh(&css_set_lock); 2350 spin_unlock_irq(&css_set_lock);
2345 mutex_unlock(&cgroup_mutex); 2351 mutex_unlock(&cgroup_mutex);
2346 2352
2347 return ret; 2353 return ret;
@@ -2369,7 +2375,7 @@ char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
2369 char *path = NULL; 2375 char *path = NULL;
2370 2376
2371 mutex_lock(&cgroup_mutex); 2377 mutex_lock(&cgroup_mutex);
2372 spin_lock_bh(&css_set_lock); 2378 spin_lock_irq(&css_set_lock);
2373 2379
2374 root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id); 2380 root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id);
2375 2381
@@ -2382,7 +2388,7 @@ char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
2382 path = buf; 2388 path = buf;
2383 } 2389 }
2384 2390
2385 spin_unlock_bh(&css_set_lock); 2391 spin_unlock_irq(&css_set_lock);
2386 mutex_unlock(&cgroup_mutex); 2392 mutex_unlock(&cgroup_mutex);
2387 return path; 2393 return path;
2388} 2394}
@@ -2557,7 +2563,7 @@ static int cgroup_taskset_migrate(struct cgroup_taskset *tset,
2557 * the new cgroup. There are no failure cases after here, so this 2563 * the new cgroup. There are no failure cases after here, so this
2558 * is the commit point. 2564 * is the commit point.
2559 */ 2565 */
2560 spin_lock_bh(&css_set_lock); 2566 spin_lock_irq(&css_set_lock);
2561 list_for_each_entry(cset, &tset->src_csets, mg_node) { 2567 list_for_each_entry(cset, &tset->src_csets, mg_node) {
2562 list_for_each_entry_safe(task, tmp_task, &cset->mg_tasks, cg_list) { 2568 list_for_each_entry_safe(task, tmp_task, &cset->mg_tasks, cg_list) {
2563 struct css_set *from_cset = task_css_set(task); 2569 struct css_set *from_cset = task_css_set(task);
@@ -2568,7 +2574,7 @@ static int cgroup_taskset_migrate(struct cgroup_taskset *tset,
2568 put_css_set_locked(from_cset); 2574 put_css_set_locked(from_cset);
2569 } 2575 }
2570 } 2576 }
2571 spin_unlock_bh(&css_set_lock); 2577 spin_unlock_irq(&css_set_lock);
2572 2578
2573 /* 2579 /*
2574 * Migration is committed, all target tasks are now on dst_csets. 2580 * Migration is committed, all target tasks are now on dst_csets.
@@ -2597,13 +2603,13 @@ out_cancel_attach:
2597 } 2603 }
2598 } while_each_subsys_mask(); 2604 } while_each_subsys_mask();
2599out_release_tset: 2605out_release_tset:
2600 spin_lock_bh(&css_set_lock); 2606 spin_lock_irq(&css_set_lock);
2601 list_splice_init(&tset->dst_csets, &tset->src_csets); 2607 list_splice_init(&tset->dst_csets, &tset->src_csets);
2602 list_for_each_entry_safe(cset, tmp_cset, &tset->src_csets, mg_node) { 2608 list_for_each_entry_safe(cset, tmp_cset, &tset->src_csets, mg_node) {
2603 list_splice_tail_init(&cset->mg_tasks, &cset->tasks); 2609 list_splice_tail_init(&cset->mg_tasks, &cset->tasks);
2604 list_del_init(&cset->mg_node); 2610 list_del_init(&cset->mg_node);
2605 } 2611 }
2606 spin_unlock_bh(&css_set_lock); 2612 spin_unlock_irq(&css_set_lock);
2607 return ret; 2613 return ret;
2608} 2614}
2609 2615
@@ -2634,7 +2640,7 @@ static void cgroup_migrate_finish(struct list_head *preloaded_csets)
2634 2640
2635 lockdep_assert_held(&cgroup_mutex); 2641 lockdep_assert_held(&cgroup_mutex);
2636 2642
2637 spin_lock_bh(&css_set_lock); 2643 spin_lock_irq(&css_set_lock);
2638 list_for_each_entry_safe(cset, tmp_cset, preloaded_csets, mg_preload_node) { 2644 list_for_each_entry_safe(cset, tmp_cset, preloaded_csets, mg_preload_node) {
2639 cset->mg_src_cgrp = NULL; 2645 cset->mg_src_cgrp = NULL;
2640 cset->mg_dst_cgrp = NULL; 2646 cset->mg_dst_cgrp = NULL;
@@ -2642,7 +2648,7 @@ static void cgroup_migrate_finish(struct list_head *preloaded_csets)
2642 list_del_init(&cset->mg_preload_node); 2648 list_del_init(&cset->mg_preload_node);
2643 put_css_set_locked(cset); 2649 put_css_set_locked(cset);
2644 } 2650 }
2645 spin_unlock_bh(&css_set_lock); 2651 spin_unlock_irq(&css_set_lock);
2646} 2652}
2647 2653
2648/** 2654/**
@@ -2783,7 +2789,7 @@ static int cgroup_migrate(struct task_struct *leader, bool threadgroup,
2783 * already PF_EXITING could be freed from underneath us unless we 2789 * already PF_EXITING could be freed from underneath us unless we
2784 * take an rcu_read_lock. 2790 * take an rcu_read_lock.
2785 */ 2791 */
2786 spin_lock_bh(&css_set_lock); 2792 spin_lock_irq(&css_set_lock);
2787 rcu_read_lock(); 2793 rcu_read_lock();
2788 task = leader; 2794 task = leader;
2789 do { 2795 do {
@@ -2792,7 +2798,7 @@ static int cgroup_migrate(struct task_struct *leader, bool threadgroup,
2792 break; 2798 break;
2793 } while_each_thread(leader, task); 2799 } while_each_thread(leader, task);
2794 rcu_read_unlock(); 2800 rcu_read_unlock();
2795 spin_unlock_bh(&css_set_lock); 2801 spin_unlock_irq(&css_set_lock);
2796 2802
2797 return cgroup_taskset_migrate(&tset, root); 2803 return cgroup_taskset_migrate(&tset, root);
2798} 2804}
@@ -2816,7 +2822,7 @@ static int cgroup_attach_task(struct cgroup *dst_cgrp,
2816 return -EBUSY; 2822 return -EBUSY;
2817 2823
2818 /* look up all src csets */ 2824 /* look up all src csets */
2819 spin_lock_bh(&css_set_lock); 2825 spin_lock_irq(&css_set_lock);
2820 rcu_read_lock(); 2826 rcu_read_lock();
2821 task = leader; 2827 task = leader;
2822 do { 2828 do {
@@ -2826,7 +2832,7 @@ static int cgroup_attach_task(struct cgroup *dst_cgrp,
2826 break; 2832 break;
2827 } while_each_thread(leader, task); 2833 } while_each_thread(leader, task);
2828 rcu_read_unlock(); 2834 rcu_read_unlock();
2829 spin_unlock_bh(&css_set_lock); 2835 spin_unlock_irq(&css_set_lock);
2830 2836
2831 /* prepare dst csets and commit */ 2837 /* prepare dst csets and commit */
2832 ret = cgroup_migrate_prepare_dst(&preloaded_csets); 2838 ret = cgroup_migrate_prepare_dst(&preloaded_csets);
@@ -2859,9 +2865,9 @@ static int cgroup_procs_write_permission(struct task_struct *task,
2859 struct cgroup *cgrp; 2865 struct cgroup *cgrp;
2860 struct inode *inode; 2866 struct inode *inode;
2861 2867
2862 spin_lock_bh(&css_set_lock); 2868 spin_lock_irq(&css_set_lock);
2863 cgrp = task_cgroup_from_root(task, &cgrp_dfl_root); 2869 cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
2864 spin_unlock_bh(&css_set_lock); 2870 spin_unlock_irq(&css_set_lock);
2865 2871
2866 while (!cgroup_is_descendant(dst_cgrp, cgrp)) 2872 while (!cgroup_is_descendant(dst_cgrp, cgrp))
2867 cgrp = cgroup_parent(cgrp); 2873 cgrp = cgroup_parent(cgrp);
@@ -2962,9 +2968,9 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
2962 if (root == &cgrp_dfl_root) 2968 if (root == &cgrp_dfl_root)
2963 continue; 2969 continue;
2964 2970
2965 spin_lock_bh(&css_set_lock); 2971 spin_lock_irq(&css_set_lock);
2966 from_cgrp = task_cgroup_from_root(from, root); 2972 from_cgrp = task_cgroup_from_root(from, root);
2967 spin_unlock_bh(&css_set_lock); 2973 spin_unlock_irq(&css_set_lock);
2968 2974
2969 retval = cgroup_attach_task(from_cgrp, tsk, false); 2975 retval = cgroup_attach_task(from_cgrp, tsk, false);
2970 if (retval) 2976 if (retval)
@@ -3080,7 +3086,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
3080 percpu_down_write(&cgroup_threadgroup_rwsem); 3086 percpu_down_write(&cgroup_threadgroup_rwsem);
3081 3087
3082 /* look up all csses currently attached to @cgrp's subtree */ 3088 /* look up all csses currently attached to @cgrp's subtree */
3083 spin_lock_bh(&css_set_lock); 3089 spin_lock_irq(&css_set_lock);
3084 cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) { 3090 cgroup_for_each_live_descendant_pre(dsct, d_css, cgrp) {
3085 struct cgrp_cset_link *link; 3091 struct cgrp_cset_link *link;
3086 3092
@@ -3088,14 +3094,14 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
3088 cgroup_migrate_add_src(link->cset, dsct, 3094 cgroup_migrate_add_src(link->cset, dsct,
3089 &preloaded_csets); 3095 &preloaded_csets);
3090 } 3096 }
3091 spin_unlock_bh(&css_set_lock); 3097 spin_unlock_irq(&css_set_lock);
3092 3098
3093 /* NULL dst indicates self on default hierarchy */ 3099 /* NULL dst indicates self on default hierarchy */
3094 ret = cgroup_migrate_prepare_dst(&preloaded_csets); 3100 ret = cgroup_migrate_prepare_dst(&preloaded_csets);
3095 if (ret) 3101 if (ret)
3096 goto out_finish; 3102 goto out_finish;
3097 3103
3098 spin_lock_bh(&css_set_lock); 3104 spin_lock_irq(&css_set_lock);
3099 list_for_each_entry(src_cset, &preloaded_csets, mg_preload_node) { 3105 list_for_each_entry(src_cset, &preloaded_csets, mg_preload_node) {
3100 struct task_struct *task, *ntask; 3106 struct task_struct *task, *ntask;
3101 3107
@@ -3107,7 +3113,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
3107 list_for_each_entry_safe(task, ntask, &src_cset->tasks, cg_list) 3113 list_for_each_entry_safe(task, ntask, &src_cset->tasks, cg_list)
3108 cgroup_taskset_add(task, &tset); 3114 cgroup_taskset_add(task, &tset);
3109 } 3115 }
3110 spin_unlock_bh(&css_set_lock); 3116 spin_unlock_irq(&css_set_lock);
3111 3117
3112 ret = cgroup_taskset_migrate(&tset, cgrp->root); 3118 ret = cgroup_taskset_migrate(&tset, cgrp->root);
3113out_finish: 3119out_finish:
@@ -3908,10 +3914,10 @@ static int cgroup_task_count(const struct cgroup *cgrp)
3908 int count = 0; 3914 int count = 0;
3909 struct cgrp_cset_link *link; 3915 struct cgrp_cset_link *link;
3910 3916
3911 spin_lock_bh(&css_set_lock); 3917 spin_lock_irq(&css_set_lock);
3912 list_for_each_entry(link, &cgrp->cset_links, cset_link) 3918 list_for_each_entry(link, &cgrp->cset_links, cset_link)
3913 count += atomic_read(&link->cset->refcount); 3919 count += atomic_read(&link->cset->refcount);
3914 spin_unlock_bh(&css_set_lock); 3920 spin_unlock_irq(&css_set_lock);
3915 return count; 3921 return count;
3916} 3922}
3917 3923
@@ -4249,7 +4255,7 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
4249 4255
4250 memset(it, 0, sizeof(*it)); 4256 memset(it, 0, sizeof(*it));
4251 4257
4252 spin_lock_bh(&css_set_lock); 4258 spin_lock_irq(&css_set_lock);
4253 4259
4254 it->ss = css->ss; 4260 it->ss = css->ss;
4255 4261
@@ -4262,7 +4268,7 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
4262 4268
4263 css_task_iter_advance_css_set(it); 4269 css_task_iter_advance_css_set(it);
4264 4270
4265 spin_unlock_bh(&css_set_lock); 4271 spin_unlock_irq(&css_set_lock);
4266} 4272}
4267 4273
4268/** 4274/**
@@ -4280,7 +4286,7 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it)
4280 it->cur_task = NULL; 4286 it->cur_task = NULL;
4281 } 4287 }
4282 4288
4283 spin_lock_bh(&css_set_lock); 4289 spin_lock_irq(&css_set_lock);
4284 4290
4285 if (it->task_pos) { 4291 if (it->task_pos) {
4286 it->cur_task = list_entry(it->task_pos, struct task_struct, 4292 it->cur_task = list_entry(it->task_pos, struct task_struct,
@@ -4289,7 +4295,7 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it)
4289 css_task_iter_advance(it); 4295 css_task_iter_advance(it);
4290 } 4296 }
4291 4297
4292 spin_unlock_bh(&css_set_lock); 4298 spin_unlock_irq(&css_set_lock);
4293 4299
4294 return it->cur_task; 4300 return it->cur_task;
4295} 4301}
@@ -4303,10 +4309,10 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it)
4303void css_task_iter_end(struct css_task_iter *it) 4309void css_task_iter_end(struct css_task_iter *it)
4304{ 4310{
4305 if (it->cur_cset) { 4311 if (it->cur_cset) {
4306 spin_lock_bh(&css_set_lock); 4312 spin_lock_irq(&css_set_lock);
4307 list_del(&it->iters_node); 4313 list_del(&it->iters_node);
4308 put_css_set_locked(it->cur_cset); 4314 put_css_set_locked(it->cur_cset);
4309 spin_unlock_bh(&css_set_lock); 4315 spin_unlock_irq(&css_set_lock);
4310 } 4316 }
4311 4317
4312 if (it->cur_task) 4318 if (it->cur_task)
@@ -4338,10 +4344,10 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
4338 mutex_lock(&cgroup_mutex); 4344 mutex_lock(&cgroup_mutex);
4339 4345
4340 /* all tasks in @from are being moved, all csets are source */ 4346 /* all tasks in @from are being moved, all csets are source */
4341 spin_lock_bh(&css_set_lock); 4347 spin_lock_irq(&css_set_lock);
4342 list_for_each_entry(link, &from->cset_links, cset_link) 4348 list_for_each_entry(link, &from->cset_links, cset_link)
4343 cgroup_migrate_add_src(link->cset, to, &preloaded_csets); 4349 cgroup_migrate_add_src(link->cset, to, &preloaded_csets);
4344 spin_unlock_bh(&css_set_lock); 4350 spin_unlock_irq(&css_set_lock);
4345 4351
4346 ret = cgroup_migrate_prepare_dst(&preloaded_csets); 4352 ret = cgroup_migrate_prepare_dst(&preloaded_csets);
4347 if (ret) 4353 if (ret)
@@ -5063,6 +5069,7 @@ static void init_and_link_css(struct cgroup_subsys_state *css,
5063 memset(css, 0, sizeof(*css)); 5069 memset(css, 0, sizeof(*css));
5064 css->cgroup = cgrp; 5070 css->cgroup = cgrp;
5065 css->ss = ss; 5071 css->ss = ss;
5072 css->id = -1;
5066 INIT_LIST_HEAD(&css->sibling); 5073 INIT_LIST_HEAD(&css->sibling);
5067 INIT_LIST_HEAD(&css->children); 5074 INIT_LIST_HEAD(&css->children);
5068 css->serial_nr = css_serial_nr_next++; 5075 css->serial_nr = css_serial_nr_next++;
@@ -5150,7 +5157,7 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
5150 5157
5151 err = cgroup_idr_alloc(&ss->css_idr, NULL, 2, 0, GFP_KERNEL); 5158 err = cgroup_idr_alloc(&ss->css_idr, NULL, 2, 0, GFP_KERNEL);
5152 if (err < 0) 5159 if (err < 0)
5153 goto err_free_percpu_ref; 5160 goto err_free_css;
5154 css->id = err; 5161 css->id = err;
5155 5162
5156 /* @css is ready to be brought online now, make it visible */ 5163 /* @css is ready to be brought online now, make it visible */
@@ -5174,9 +5181,6 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
5174 5181
5175err_list_del: 5182err_list_del:
5176 list_del_rcu(&css->sibling); 5183 list_del_rcu(&css->sibling);
5177 cgroup_idr_remove(&ss->css_idr, css->id);
5178err_free_percpu_ref:
5179 percpu_ref_exit(&css->refcnt);
5180err_free_css: 5184err_free_css:
5181 call_rcu(&css->rcu_head, css_free_rcu_fn); 5185 call_rcu(&css->rcu_head, css_free_rcu_fn);
5182 return ERR_PTR(err); 5186 return ERR_PTR(err);
@@ -5451,10 +5455,10 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
5451 */ 5455 */
5452 cgrp->self.flags &= ~CSS_ONLINE; 5456 cgrp->self.flags &= ~CSS_ONLINE;
5453 5457
5454 spin_lock_bh(&css_set_lock); 5458 spin_lock_irq(&css_set_lock);
5455 list_for_each_entry(link, &cgrp->cset_links, cset_link) 5459 list_for_each_entry(link, &cgrp->cset_links, cset_link)
5456 link->cset->dead = true; 5460 link->cset->dead = true;
5457 spin_unlock_bh(&css_set_lock); 5461 spin_unlock_irq(&css_set_lock);
5458 5462
5459 /* initiate massacre of all css's */ 5463 /* initiate massacre of all css's */
5460 for_each_css(css, ssid, cgrp) 5464 for_each_css(css, ssid, cgrp)
@@ -5725,7 +5729,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
5725 goto out; 5729 goto out;
5726 5730
5727 mutex_lock(&cgroup_mutex); 5731 mutex_lock(&cgroup_mutex);
5728 spin_lock_bh(&css_set_lock); 5732 spin_lock_irq(&css_set_lock);
5729 5733
5730 for_each_root(root) { 5734 for_each_root(root) {
5731 struct cgroup_subsys *ss; 5735 struct cgroup_subsys *ss;
@@ -5778,7 +5782,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
5778 5782
5779 retval = 0; 5783 retval = 0;
5780out_unlock: 5784out_unlock:
5781 spin_unlock_bh(&css_set_lock); 5785 spin_unlock_irq(&css_set_lock);
5782 mutex_unlock(&cgroup_mutex); 5786 mutex_unlock(&cgroup_mutex);
5783 kfree(buf); 5787 kfree(buf);
5784out: 5788out:
@@ -5923,13 +5927,13 @@ void cgroup_post_fork(struct task_struct *child)
5923 if (use_task_css_set_links) { 5927 if (use_task_css_set_links) {
5924 struct css_set *cset; 5928 struct css_set *cset;
5925 5929
5926 spin_lock_bh(&css_set_lock); 5930 spin_lock_irq(&css_set_lock);
5927 cset = task_css_set(current); 5931 cset = task_css_set(current);
5928 if (list_empty(&child->cg_list)) { 5932 if (list_empty(&child->cg_list)) {
5929 get_css_set(cset); 5933 get_css_set(cset);
5930 css_set_move_task(child, NULL, cset, false); 5934 css_set_move_task(child, NULL, cset, false);
5931 } 5935 }
5932 spin_unlock_bh(&css_set_lock); 5936 spin_unlock_irq(&css_set_lock);
5933 } 5937 }
5934 5938
5935 /* 5939 /*
@@ -5974,9 +5978,9 @@ void cgroup_exit(struct task_struct *tsk)
5974 cset = task_css_set(tsk); 5978 cset = task_css_set(tsk);
5975 5979
5976 if (!list_empty(&tsk->cg_list)) { 5980 if (!list_empty(&tsk->cg_list)) {
5977 spin_lock_bh(&css_set_lock); 5981 spin_lock_irq(&css_set_lock);
5978 css_set_move_task(tsk, cset, NULL, false); 5982 css_set_move_task(tsk, cset, NULL, false);
5979 spin_unlock_bh(&css_set_lock); 5983 spin_unlock_irq(&css_set_lock);
5980 } else { 5984 } else {
5981 get_css_set(cset); 5985 get_css_set(cset);
5982 } 5986 }
@@ -6044,9 +6048,9 @@ static void cgroup_release_agent(struct work_struct *work)
6044 if (!pathbuf || !agentbuf) 6048 if (!pathbuf || !agentbuf)
6045 goto out; 6049 goto out;
6046 6050
6047 spin_lock_bh(&css_set_lock); 6051 spin_lock_irq(&css_set_lock);
6048 path = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns); 6052 path = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);
6049 spin_unlock_bh(&css_set_lock); 6053 spin_unlock_irq(&css_set_lock);
6050 if (!path) 6054 if (!path)
6051 goto out; 6055 goto out;
6052 6056
@@ -6306,12 +6310,12 @@ struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
6306 return ERR_PTR(-EPERM); 6310 return ERR_PTR(-EPERM);
6307 6311
6308 mutex_lock(&cgroup_mutex); 6312 mutex_lock(&cgroup_mutex);
6309 spin_lock_bh(&css_set_lock); 6313 spin_lock_irq(&css_set_lock);
6310 6314
6311 cset = task_css_set(current); 6315 cset = task_css_set(current);
6312 get_css_set(cset); 6316 get_css_set(cset);
6313 6317
6314 spin_unlock_bh(&css_set_lock); 6318 spin_unlock_irq(&css_set_lock);
6315 mutex_unlock(&cgroup_mutex); 6319 mutex_unlock(&cgroup_mutex);
6316 6320
6317 new_ns = alloc_cgroup_ns(); 6321 new_ns = alloc_cgroup_ns();
@@ -6435,7 +6439,7 @@ static int current_css_set_cg_links_read(struct seq_file *seq, void *v)
6435 if (!name_buf) 6439 if (!name_buf)
6436 return -ENOMEM; 6440 return -ENOMEM;
6437 6441
6438 spin_lock_bh(&css_set_lock); 6442 spin_lock_irq(&css_set_lock);
6439 rcu_read_lock(); 6443 rcu_read_lock();
6440 cset = rcu_dereference(current->cgroups); 6444 cset = rcu_dereference(current->cgroups);
6441 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) { 6445 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
@@ -6446,7 +6450,7 @@ static int current_css_set_cg_links_read(struct seq_file *seq, void *v)
6446 c->root->hierarchy_id, name_buf); 6450 c->root->hierarchy_id, name_buf);
6447 } 6451 }
6448 rcu_read_unlock(); 6452 rcu_read_unlock();
6449 spin_unlock_bh(&css_set_lock); 6453 spin_unlock_irq(&css_set_lock);
6450 kfree(name_buf); 6454 kfree(name_buf);
6451 return 0; 6455 return 0;
6452} 6456}
@@ -6457,7 +6461,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
6457 struct cgroup_subsys_state *css = seq_css(seq); 6461 struct cgroup_subsys_state *css = seq_css(seq);
6458 struct cgrp_cset_link *link; 6462 struct cgrp_cset_link *link;
6459 6463
6460 spin_lock_bh(&css_set_lock); 6464 spin_lock_irq(&css_set_lock);
6461 list_for_each_entry(link, &css->cgroup->cset_links, cset_link) { 6465 list_for_each_entry(link, &css->cgroup->cset_links, cset_link) {
6462 struct css_set *cset = link->cset; 6466 struct css_set *cset = link->cset;
6463 struct task_struct *task; 6467 struct task_struct *task;
@@ -6480,7 +6484,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
6480 overflow: 6484 overflow:
6481 seq_puts(seq, " ...\n"); 6485 seq_puts(seq, " ...\n");
6482 } 6486 }
6483 spin_unlock_bh(&css_set_lock); 6487 spin_unlock_irq(&css_set_lock);
6484 return 0; 6488 return 0;
6485} 6489}
6486 6490
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9c51ec3f0f44..85cd41878a74 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7529,7 +7529,7 @@ static void perf_event_free_bpf_prog(struct perf_event *event)
7529 prog = event->tp_event->prog; 7529 prog = event->tp_event->prog;
7530 if (prog) { 7530 if (prog) {
7531 event->tp_event->prog = NULL; 7531 event->tp_event->prog = NULL;
7532 bpf_prog_put(prog); 7532 bpf_prog_put_rcu(prog);
7533 } 7533 }
7534} 7534}
7535 7535
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 720b7bb01d43..26f603da7e26 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -209,6 +209,10 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5)
209 event->pmu->count) 209 event->pmu->count)
210 return -EINVAL; 210 return -EINVAL;
211 211
212 if (unlikely(event->attr.type != PERF_TYPE_HARDWARE &&
213 event->attr.type != PERF_TYPE_RAW))
214 return -EINVAL;
215
212 /* 216 /*
213 * we don't know if the function is run successfully by the 217 * we don't know if the function is run successfully by the
214 * return value. It can be judged in other places, such as 218 * return value. It can be judged in other places, such as
@@ -349,7 +353,8 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func
349} 353}
350 354
351/* bpf+kprobe programs can access fields of 'struct pt_regs' */ 355/* bpf+kprobe programs can access fields of 'struct pt_regs' */
352static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type) 356static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type,
357 enum bpf_reg_type *reg_type)
353{ 358{
354 /* check bounds */ 359 /* check bounds */
355 if (off < 0 || off >= sizeof(struct pt_regs)) 360 if (off < 0 || off >= sizeof(struct pt_regs))
@@ -427,7 +432,8 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)
427 } 432 }
428} 433}
429 434
430static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type) 435static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type,
436 enum bpf_reg_type *reg_type)
431{ 437{
432 if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE) 438 if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE)
433 return false; 439 return false;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index fbd0acf80b13..2fdebabbfacd 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -976,7 +976,8 @@ static int ax25_release(struct socket *sock)
976 release_sock(sk); 976 release_sock(sk);
977 ax25_disconnect(ax25, 0); 977 ax25_disconnect(ax25, 0);
978 lock_sock(sk); 978 lock_sock(sk);
979 ax25_destroy_socket(ax25); 979 if (!sock_flag(ax25->sk, SOCK_DESTROY))
980 ax25_destroy_socket(ax25);
980 break; 981 break;
981 982
982 case AX25_STATE_3: 983 case AX25_STATE_3:
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
index 951cd57bb07d..5237dff6941d 100644
--- a/net/ax25/ax25_ds_timer.c
+++ b/net/ax25/ax25_ds_timer.c
@@ -102,6 +102,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
102 switch (ax25->state) { 102 switch (ax25->state) {
103 103
104 case AX25_STATE_0: 104 case AX25_STATE_0:
105 case AX25_STATE_2:
105 /* Magic here: If we listen() and a new link dies before it 106 /* Magic here: If we listen() and a new link dies before it
106 is accepted() it isn't 'dead' so doesn't get removed. */ 107 is accepted() it isn't 'dead' so doesn't get removed. */
107 if (!sk || sock_flag(sk, SOCK_DESTROY) || 108 if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -111,6 +112,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
111 sock_hold(sk); 112 sock_hold(sk);
112 ax25_destroy_socket(ax25); 113 ax25_destroy_socket(ax25);
113 bh_unlock_sock(sk); 114 bh_unlock_sock(sk);
115 /* Ungrab socket and destroy it */
114 sock_put(sk); 116 sock_put(sk);
115 } else 117 } else
116 ax25_destroy_socket(ax25); 118 ax25_destroy_socket(ax25);
@@ -213,7 +215,8 @@ void ax25_ds_t1_timeout(ax25_cb *ax25)
213 case AX25_STATE_2: 215 case AX25_STATE_2:
214 if (ax25->n2count == ax25->n2) { 216 if (ax25->n2count == ax25->n2) {
215 ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); 217 ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
216 ax25_disconnect(ax25, ETIMEDOUT); 218 if (!sock_flag(ax25->sk, SOCK_DESTROY))
219 ax25_disconnect(ax25, ETIMEDOUT);
217 return; 220 return;
218 } else { 221 } else {
219 ax25->n2count++; 222 ax25->n2count++;
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index 004467c9e6e1..2c0d6ef66f9d 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -38,6 +38,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
38 38
39 switch (ax25->state) { 39 switch (ax25->state) {
40 case AX25_STATE_0: 40 case AX25_STATE_0:
41 case AX25_STATE_2:
41 /* Magic here: If we listen() and a new link dies before it 42 /* Magic here: If we listen() and a new link dies before it
42 is accepted() it isn't 'dead' so doesn't get removed. */ 43 is accepted() it isn't 'dead' so doesn't get removed. */
43 if (!sk || sock_flag(sk, SOCK_DESTROY) || 44 if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -47,6 +48,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
47 sock_hold(sk); 48 sock_hold(sk);
48 ax25_destroy_socket(ax25); 49 ax25_destroy_socket(ax25);
49 bh_unlock_sock(sk); 50 bh_unlock_sock(sk);
51 /* Ungrab socket and destroy it */
50 sock_put(sk); 52 sock_put(sk);
51 } else 53 } else
52 ax25_destroy_socket(ax25); 54 ax25_destroy_socket(ax25);
@@ -144,7 +146,8 @@ void ax25_std_t1timer_expiry(ax25_cb *ax25)
144 case AX25_STATE_2: 146 case AX25_STATE_2:
145 if (ax25->n2count == ax25->n2) { 147 if (ax25->n2count == ax25->n2) {
146 ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); 148 ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
147 ax25_disconnect(ax25, ETIMEDOUT); 149 if (!sock_flag(ax25->sk, SOCK_DESTROY))
150 ax25_disconnect(ax25, ETIMEDOUT);
148 return; 151 return;
149 } else { 152 } else {
150 ax25->n2count++; 153 ax25->n2count++;
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 3b78e8473a01..655a7d4c96e1 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -264,7 +264,8 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
264{ 264{
265 ax25_clear_queues(ax25); 265 ax25_clear_queues(ax25);
266 266
267 ax25_stop_heartbeat(ax25); 267 if (!sock_flag(ax25->sk, SOCK_DESTROY))
268 ax25_stop_heartbeat(ax25);
268 ax25_stop_t1timer(ax25); 269 ax25_stop_t1timer(ax25);
269 ax25_stop_t2timer(ax25); 270 ax25_stop_t2timer(ax25);
270 ax25_stop_t3timer(ax25); 271 ax25_stop_t3timer(ax25);
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index e3857ed4057f..6c2901a86230 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -374,6 +374,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
374 if (skb_cow(skb, ETH_HLEN) < 0) 374 if (skb_cow(skb, ETH_HLEN) < 0)
375 goto out; 375 goto out;
376 376
377 ethhdr = eth_hdr(skb);
377 icmph = (struct batadv_icmp_header *)skb->data; 378 icmph = (struct batadv_icmp_header *)skb->data;
378 icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph; 379 icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph;
379 if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN) 380 if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 343d2c904399..287a3879ed7e 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -1033,7 +1033,9 @@ void batadv_softif_destroy_sysfs(struct net_device *soft_iface)
1033static void batadv_softif_destroy_netlink(struct net_device *soft_iface, 1033static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
1034 struct list_head *head) 1034 struct list_head *head)
1035{ 1035{
1036 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
1036 struct batadv_hard_iface *hard_iface; 1037 struct batadv_hard_iface *hard_iface;
1038 struct batadv_softif_vlan *vlan;
1037 1039
1038 list_for_each_entry(hard_iface, &batadv_hardif_list, list) { 1040 list_for_each_entry(hard_iface, &batadv_hardif_list, list) {
1039 if (hard_iface->soft_iface == soft_iface) 1041 if (hard_iface->soft_iface == soft_iface)
@@ -1041,6 +1043,13 @@ static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
1041 BATADV_IF_CLEANUP_KEEP); 1043 BATADV_IF_CLEANUP_KEEP);
1042 } 1044 }
1043 1045
1046 /* destroy the "untagged" VLAN */
1047 vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
1048 if (vlan) {
1049 batadv_softif_destroy_vlan(bat_priv, vlan);
1050 batadv_softif_vlan_put(vlan);
1051 }
1052
1044 batadv_sysfs_del_meshif(soft_iface); 1053 batadv_sysfs_del_meshif(soft_iface);
1045 unregister_netdevice_queue(soft_iface, head); 1054 unregister_netdevice_queue(soft_iface, head);
1046} 1055}
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index feaf492b01ca..57ec87f37050 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -650,8 +650,10 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
650 650
651 /* increase the refcounter of the related vlan */ 651 /* increase the refcounter of the related vlan */
652 vlan = batadv_softif_vlan_get(bat_priv, vid); 652 vlan = batadv_softif_vlan_get(bat_priv, vid);
653 if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d", 653 if (!vlan) {
654 addr, BATADV_PRINT_VID(vid))) { 654 net_ratelimited_function(batadv_info, soft_iface,
655 "adding TT local entry %pM to non-existent VLAN %d\n",
656 addr, BATADV_PRINT_VID(vid));
655 kfree(tt_local); 657 kfree(tt_local);
656 tt_local = NULL; 658 tt_local = NULL;
657 goto out; 659 goto out;
@@ -691,7 +693,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
691 if (unlikely(hash_added != 0)) { 693 if (unlikely(hash_added != 0)) {
692 /* remove the reference for the hash */ 694 /* remove the reference for the hash */
693 batadv_tt_local_entry_put(tt_local); 695 batadv_tt_local_entry_put(tt_local);
694 batadv_softif_vlan_put(vlan);
695 goto out; 696 goto out;
696 } 697 }
697 698
@@ -2269,6 +2270,29 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
2269 return crc; 2270 return crc;
2270} 2271}
2271 2272
2273/**
2274 * batadv_tt_req_node_release - free tt_req node entry
2275 * @ref: kref pointer of the tt req_node entry
2276 */
2277static void batadv_tt_req_node_release(struct kref *ref)
2278{
2279 struct batadv_tt_req_node *tt_req_node;
2280
2281 tt_req_node = container_of(ref, struct batadv_tt_req_node, refcount);
2282
2283 kfree(tt_req_node);
2284}
2285
2286/**
2287 * batadv_tt_req_node_put - decrement the tt_req_node refcounter and
2288 * possibly release it
2289 * @tt_req_node: tt_req_node to be free'd
2290 */
2291static void batadv_tt_req_node_put(struct batadv_tt_req_node *tt_req_node)
2292{
2293 kref_put(&tt_req_node->refcount, batadv_tt_req_node_release);
2294}
2295
2272static void batadv_tt_req_list_free(struct batadv_priv *bat_priv) 2296static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
2273{ 2297{
2274 struct batadv_tt_req_node *node; 2298 struct batadv_tt_req_node *node;
@@ -2278,7 +2302,7 @@ static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
2278 2302
2279 hlist_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) { 2303 hlist_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
2280 hlist_del_init(&node->list); 2304 hlist_del_init(&node->list);
2281 kfree(node); 2305 batadv_tt_req_node_put(node);
2282 } 2306 }
2283 2307
2284 spin_unlock_bh(&bat_priv->tt.req_list_lock); 2308 spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2315,7 +2339,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
2315 if (batadv_has_timed_out(node->issued_at, 2339 if (batadv_has_timed_out(node->issued_at,
2316 BATADV_TT_REQUEST_TIMEOUT)) { 2340 BATADV_TT_REQUEST_TIMEOUT)) {
2317 hlist_del_init(&node->list); 2341 hlist_del_init(&node->list);
2318 kfree(node); 2342 batadv_tt_req_node_put(node);
2319 } 2343 }
2320 } 2344 }
2321 spin_unlock_bh(&bat_priv->tt.req_list_lock); 2345 spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2347,9 +2371,11 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv,
2347 if (!tt_req_node) 2371 if (!tt_req_node)
2348 goto unlock; 2372 goto unlock;
2349 2373
2374 kref_init(&tt_req_node->refcount);
2350 ether_addr_copy(tt_req_node->addr, orig_node->orig); 2375 ether_addr_copy(tt_req_node->addr, orig_node->orig);
2351 tt_req_node->issued_at = jiffies; 2376 tt_req_node->issued_at = jiffies;
2352 2377
2378 kref_get(&tt_req_node->refcount);
2353 hlist_add_head(&tt_req_node->list, &bat_priv->tt.req_list); 2379 hlist_add_head(&tt_req_node->list, &bat_priv->tt.req_list);
2354unlock: 2380unlock:
2355 spin_unlock_bh(&bat_priv->tt.req_list_lock); 2381 spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2613,13 +2639,19 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv,
2613out: 2639out:
2614 if (primary_if) 2640 if (primary_if)
2615 batadv_hardif_put(primary_if); 2641 batadv_hardif_put(primary_if);
2642
2616 if (ret && tt_req_node) { 2643 if (ret && tt_req_node) {
2617 spin_lock_bh(&bat_priv->tt.req_list_lock); 2644 spin_lock_bh(&bat_priv->tt.req_list_lock);
2618 /* hlist_del_init() verifies tt_req_node still is in the list */ 2645 if (!hlist_unhashed(&tt_req_node->list)) {
2619 hlist_del_init(&tt_req_node->list); 2646 hlist_del_init(&tt_req_node->list);
2647 batadv_tt_req_node_put(tt_req_node);
2648 }
2620 spin_unlock_bh(&bat_priv->tt.req_list_lock); 2649 spin_unlock_bh(&bat_priv->tt.req_list_lock);
2621 kfree(tt_req_node);
2622 } 2650 }
2651
2652 if (tt_req_node)
2653 batadv_tt_req_node_put(tt_req_node);
2654
2623 kfree(tvlv_tt_data); 2655 kfree(tvlv_tt_data);
2624 return ret; 2656 return ret;
2625} 2657}
@@ -3055,7 +3087,7 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv,
3055 if (!batadv_compare_eth(node->addr, resp_src)) 3087 if (!batadv_compare_eth(node->addr, resp_src))
3056 continue; 3088 continue;
3057 hlist_del_init(&node->list); 3089 hlist_del_init(&node->list);
3058 kfree(node); 3090 batadv_tt_req_node_put(node);
3059 } 3091 }
3060 3092
3061 spin_unlock_bh(&bat_priv->tt.req_list_lock); 3093 spin_unlock_bh(&bat_priv->tt.req_list_lock);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 6a577f4f8ba7..ba846b078af8 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1137,11 +1137,13 @@ struct batadv_tt_change_node {
1137 * struct batadv_tt_req_node - data to keep track of the tt requests in flight 1137 * struct batadv_tt_req_node - data to keep track of the tt requests in flight
1138 * @addr: mac address address of the originator this request was sent to 1138 * @addr: mac address address of the originator this request was sent to
1139 * @issued_at: timestamp used for purging stale tt requests 1139 * @issued_at: timestamp used for purging stale tt requests
1140 * @refcount: number of contexts the object is used by
1140 * @list: list node for batadv_priv_tt::req_list 1141 * @list: list node for batadv_priv_tt::req_list
1141 */ 1142 */
1142struct batadv_tt_req_node { 1143struct batadv_tt_req_node {
1143 u8 addr[ETH_ALEN]; 1144 u8 addr[ETH_ALEN];
1144 unsigned long issued_at; 1145 unsigned long issued_at;
1146 struct kref refcount;
1145 struct hlist_node list; 1147 struct hlist_node list;
1146}; 1148};
1147 1149
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 160797722228..43d2cd862bc2 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -213,8 +213,7 @@ drop:
213} 213}
214EXPORT_SYMBOL_GPL(br_handle_frame_finish); 214EXPORT_SYMBOL_GPL(br_handle_frame_finish);
215 215
216/* note: already called with rcu_read_lock */ 216static void __br_handle_local_finish(struct sk_buff *skb)
217static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
218{ 217{
219 struct net_bridge_port *p = br_port_get_rcu(skb->dev); 218 struct net_bridge_port *p = br_port_get_rcu(skb->dev);
220 u16 vid = 0; 219 u16 vid = 0;
@@ -222,6 +221,14 @@ static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_bu
222 /* check if vlan is allowed, to avoid spoofing */ 221 /* check if vlan is allowed, to avoid spoofing */
223 if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid)) 222 if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
224 br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false); 223 br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
224}
225
226/* note: already called with rcu_read_lock */
227static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
228{
229 struct net_bridge_port *p = br_port_get_rcu(skb->dev);
230
231 __br_handle_local_finish(skb);
225 232
226 BR_INPUT_SKB_CB(skb)->brdev = p->br->dev; 233 BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
227 br_pass_frame_up(skb); 234 br_pass_frame_up(skb);
@@ -274,7 +281,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
274 if (p->br->stp_enabled == BR_NO_STP || 281 if (p->br->stp_enabled == BR_NO_STP ||
275 fwd_mask & (1u << dest[5])) 282 fwd_mask & (1u << dest[5]))
276 goto forward; 283 goto forward;
277 break; 284 *pskb = skb;
285 __br_handle_local_finish(skb);
286 return RX_HANDLER_PASS;
278 287
279 case 0x01: /* IEEE MAC (Pause) */ 288 case 0x01: /* IEEE MAC (Pause) */
280 goto drop; 289 goto drop;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 6852f3c7009c..43844144c9c4 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -464,8 +464,11 @@ static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br,
464 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0, 464 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
465 &ip6h->saddr)) { 465 &ip6h->saddr)) {
466 kfree_skb(skb); 466 kfree_skb(skb);
467 br->has_ipv6_addr = 0;
467 return NULL; 468 return NULL;
468 } 469 }
470
471 br->has_ipv6_addr = 1;
469 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); 472 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
470 473
471 hopopt = (u8 *)(ip6h + 1); 474 hopopt = (u8 *)(ip6h + 1);
@@ -1745,6 +1748,7 @@ void br_multicast_init(struct net_bridge *br)
1745 br->ip6_other_query.delay_time = 0; 1748 br->ip6_other_query.delay_time = 0;
1746 br->ip6_querier.port = NULL; 1749 br->ip6_querier.port = NULL;
1747#endif 1750#endif
1751 br->has_ipv6_addr = 1;
1748 1752
1749 spin_lock_init(&br->multicast_lock); 1753 spin_lock_init(&br->multicast_lock);
1750 setup_timer(&br->multicast_router_timer, 1754 setup_timer(&br->multicast_router_timer,
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index a5343c7232bf..85e89f693589 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1273,7 +1273,7 @@ static int br_fill_linkxstats(struct sk_buff *skb, const struct net_device *dev,
1273 struct bridge_vlan_xstats vxi; 1273 struct bridge_vlan_xstats vxi;
1274 struct br_vlan_stats stats; 1274 struct br_vlan_stats stats;
1275 1275
1276 if (vl_idx++ < *prividx) 1276 if (++vl_idx < *prividx)
1277 continue; 1277 continue;
1278 memset(&vxi, 0, sizeof(vxi)); 1278 memset(&vxi, 0, sizeof(vxi));
1279 vxi.vid = v->vid; 1279 vxi.vid = v->vid;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index c7fb5d7a7218..52edecf3c294 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -314,6 +314,7 @@ struct net_bridge
314 u8 multicast_disabled:1; 314 u8 multicast_disabled:1;
315 u8 multicast_querier:1; 315 u8 multicast_querier:1;
316 u8 multicast_query_use_ifaddr:1; 316 u8 multicast_query_use_ifaddr:1;
317 u8 has_ipv6_addr:1;
317 318
318 u32 hash_elasticity; 319 u32 hash_elasticity;
319 u32 hash_max; 320 u32 hash_max;
@@ -588,10 +589,22 @@ static inline bool br_multicast_is_router(struct net_bridge *br)
588 589
589static inline bool 590static inline bool
590__br_multicast_querier_exists(struct net_bridge *br, 591__br_multicast_querier_exists(struct net_bridge *br,
591 struct bridge_mcast_other_query *querier) 592 struct bridge_mcast_other_query *querier,
593 const bool is_ipv6)
592{ 594{
595 bool own_querier_enabled;
596
597 if (br->multicast_querier) {
598 if (is_ipv6 && !br->has_ipv6_addr)
599 own_querier_enabled = false;
600 else
601 own_querier_enabled = true;
602 } else {
603 own_querier_enabled = false;
604 }
605
593 return time_is_before_jiffies(querier->delay_time) && 606 return time_is_before_jiffies(querier->delay_time) &&
594 (br->multicast_querier || timer_pending(&querier->timer)); 607 (own_querier_enabled || timer_pending(&querier->timer));
595} 608}
596 609
597static inline bool br_multicast_querier_exists(struct net_bridge *br, 610static inline bool br_multicast_querier_exists(struct net_bridge *br,
@@ -599,10 +612,12 @@ static inline bool br_multicast_querier_exists(struct net_bridge *br,
599{ 612{
600 switch (eth->h_proto) { 613 switch (eth->h_proto) {
601 case (htons(ETH_P_IP)): 614 case (htons(ETH_P_IP)):
602 return __br_multicast_querier_exists(br, &br->ip4_other_query); 615 return __br_multicast_querier_exists(br,
616 &br->ip4_other_query, false);
603#if IS_ENABLED(CONFIG_IPV6) 617#if IS_ENABLED(CONFIG_IPV6)
604 case (htons(ETH_P_IPV6)): 618 case (htons(ETH_P_IPV6)):
605 return __br_multicast_querier_exists(br, &br->ip6_other_query); 619 return __br_multicast_querier_exists(br,
620 &br->ip6_other_query, true);
606#endif 621#endif
607 default: 622 default:
608 return false; 623 return false;
diff --git a/net/core/filter.c b/net/core/filter.c
index 68adb5f52110..c4b330c85c02 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2085,7 +2085,8 @@ static bool __is_valid_access(int off, int size, enum bpf_access_type type)
2085} 2085}
2086 2086
2087static bool sk_filter_is_valid_access(int off, int size, 2087static bool sk_filter_is_valid_access(int off, int size,
2088 enum bpf_access_type type) 2088 enum bpf_access_type type,
2089 enum bpf_reg_type *reg_type)
2089{ 2090{
2090 switch (off) { 2091 switch (off) {
2091 case offsetof(struct __sk_buff, tc_classid): 2092 case offsetof(struct __sk_buff, tc_classid):
@@ -2108,7 +2109,8 @@ static bool sk_filter_is_valid_access(int off, int size,
2108} 2109}
2109 2110
2110static bool tc_cls_act_is_valid_access(int off, int size, 2111static bool tc_cls_act_is_valid_access(int off, int size,
2111 enum bpf_access_type type) 2112 enum bpf_access_type type,
2113 enum bpf_reg_type *reg_type)
2112{ 2114{
2113 if (type == BPF_WRITE) { 2115 if (type == BPF_WRITE) {
2114 switch (off) { 2116 switch (off) {
@@ -2123,6 +2125,16 @@ static bool tc_cls_act_is_valid_access(int off, int size,
2123 return false; 2125 return false;
2124 } 2126 }
2125 } 2127 }
2128
2129 switch (off) {
2130 case offsetof(struct __sk_buff, data):
2131 *reg_type = PTR_TO_PACKET;
2132 break;
2133 case offsetof(struct __sk_buff, data_end):
2134 *reg_type = PTR_TO_PACKET_END;
2135 break;
2136 }
2137
2126 return __is_valid_access(off, size, type); 2138 return __is_valid_access(off, size, type);
2127} 2139}
2128 2140
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 29dd8cc22bbf..510cd62fcb99 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2469,13 +2469,17 @@ int neigh_xmit(int index, struct net_device *dev,
2469 tbl = neigh_tables[index]; 2469 tbl = neigh_tables[index];
2470 if (!tbl) 2470 if (!tbl)
2471 goto out; 2471 goto out;
2472 rcu_read_lock_bh();
2472 neigh = __neigh_lookup_noref(tbl, addr, dev); 2473 neigh = __neigh_lookup_noref(tbl, addr, dev);
2473 if (!neigh) 2474 if (!neigh)
2474 neigh = __neigh_create(tbl, addr, dev, false); 2475 neigh = __neigh_create(tbl, addr, dev, false);
2475 err = PTR_ERR(neigh); 2476 err = PTR_ERR(neigh);
2476 if (IS_ERR(neigh)) 2477 if (IS_ERR(neigh)) {
2478 rcu_read_unlock_bh();
2477 goto out_kfree_skb; 2479 goto out_kfree_skb;
2480 }
2478 err = neigh->output(neigh, skb); 2481 err = neigh->output(neigh, skb);
2482 rcu_read_unlock_bh();
2479 } 2483 }
2480 else if (index == NEIGH_LINK_TABLE) { 2484 else if (index == NEIGH_LINK_TABLE) {
2481 err = dev_hard_header(skb, dev, ntohs(skb->protocol), 2485 err = dev_hard_header(skb, dev, ntohs(skb->protocol),
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 477937465a20..d95631d09248 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -23,6 +23,11 @@ struct esp_skb_cb {
23 void *tmp; 23 void *tmp;
24}; 24};
25 25
26struct esp_output_extra {
27 __be32 seqhi;
28 u32 esphoff;
29};
30
26#define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0])) 31#define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0]))
27 32
28static u32 esp4_get_mtu(struct xfrm_state *x, int mtu); 33static u32 esp4_get_mtu(struct xfrm_state *x, int mtu);
@@ -35,11 +40,11 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu);
35 * 40 *
36 * TODO: Use spare space in skb for this where possible. 41 * TODO: Use spare space in skb for this where possible.
37 */ 42 */
38static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqhilen) 43static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int extralen)
39{ 44{
40 unsigned int len; 45 unsigned int len;
41 46
42 len = seqhilen; 47 len = extralen;
43 48
44 len += crypto_aead_ivsize(aead); 49 len += crypto_aead_ivsize(aead);
45 50
@@ -57,15 +62,16 @@ static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqhilen)
57 return kmalloc(len, GFP_ATOMIC); 62 return kmalloc(len, GFP_ATOMIC);
58} 63}
59 64
60static inline __be32 *esp_tmp_seqhi(void *tmp) 65static inline void *esp_tmp_extra(void *tmp)
61{ 66{
62 return PTR_ALIGN((__be32 *)tmp, __alignof__(__be32)); 67 return PTR_ALIGN(tmp, __alignof__(struct esp_output_extra));
63} 68}
64static inline u8 *esp_tmp_iv(struct crypto_aead *aead, void *tmp, int seqhilen) 69
70static inline u8 *esp_tmp_iv(struct crypto_aead *aead, void *tmp, int extralen)
65{ 71{
66 return crypto_aead_ivsize(aead) ? 72 return crypto_aead_ivsize(aead) ?
67 PTR_ALIGN((u8 *)tmp + seqhilen, 73 PTR_ALIGN((u8 *)tmp + extralen,
68 crypto_aead_alignmask(aead) + 1) : tmp + seqhilen; 74 crypto_aead_alignmask(aead) + 1) : tmp + extralen;
69} 75}
70 76
71static inline struct aead_request *esp_tmp_req(struct crypto_aead *aead, u8 *iv) 77static inline struct aead_request *esp_tmp_req(struct crypto_aead *aead, u8 *iv)
@@ -99,7 +105,7 @@ static void esp_restore_header(struct sk_buff *skb, unsigned int offset)
99{ 105{
100 struct ip_esp_hdr *esph = (void *)(skb->data + offset); 106 struct ip_esp_hdr *esph = (void *)(skb->data + offset);
101 void *tmp = ESP_SKB_CB(skb)->tmp; 107 void *tmp = ESP_SKB_CB(skb)->tmp;
102 __be32 *seqhi = esp_tmp_seqhi(tmp); 108 __be32 *seqhi = esp_tmp_extra(tmp);
103 109
104 esph->seq_no = esph->spi; 110 esph->seq_no = esph->spi;
105 esph->spi = *seqhi; 111 esph->spi = *seqhi;
@@ -107,7 +113,11 @@ static void esp_restore_header(struct sk_buff *skb, unsigned int offset)
107 113
108static void esp_output_restore_header(struct sk_buff *skb) 114static void esp_output_restore_header(struct sk_buff *skb)
109{ 115{
110 esp_restore_header(skb, skb_transport_offset(skb) - sizeof(__be32)); 116 void *tmp = ESP_SKB_CB(skb)->tmp;
117 struct esp_output_extra *extra = esp_tmp_extra(tmp);
118
119 esp_restore_header(skb, skb_transport_offset(skb) + extra->esphoff -
120 sizeof(__be32));
111} 121}
112 122
113static void esp_output_done_esn(struct crypto_async_request *base, int err) 123static void esp_output_done_esn(struct crypto_async_request *base, int err)
@@ -121,6 +131,7 @@ static void esp_output_done_esn(struct crypto_async_request *base, int err)
121static int esp_output(struct xfrm_state *x, struct sk_buff *skb) 131static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
122{ 132{
123 int err; 133 int err;
134 struct esp_output_extra *extra;
124 struct ip_esp_hdr *esph; 135 struct ip_esp_hdr *esph;
125 struct crypto_aead *aead; 136 struct crypto_aead *aead;
126 struct aead_request *req; 137 struct aead_request *req;
@@ -137,8 +148,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
137 int tfclen; 148 int tfclen;
138 int nfrags; 149 int nfrags;
139 int assoclen; 150 int assoclen;
140 int seqhilen; 151 int extralen;
141 __be32 *seqhi;
142 __be64 seqno; 152 __be64 seqno;
143 153
144 /* skb is pure payload to encrypt */ 154 /* skb is pure payload to encrypt */
@@ -166,21 +176,21 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
166 nfrags = err; 176 nfrags = err;
167 177
168 assoclen = sizeof(*esph); 178 assoclen = sizeof(*esph);
169 seqhilen = 0; 179 extralen = 0;
170 180
171 if (x->props.flags & XFRM_STATE_ESN) { 181 if (x->props.flags & XFRM_STATE_ESN) {
172 seqhilen += sizeof(__be32); 182 extralen += sizeof(*extra);
173 assoclen += seqhilen; 183 assoclen += sizeof(__be32);
174 } 184 }
175 185
176 tmp = esp_alloc_tmp(aead, nfrags, seqhilen); 186 tmp = esp_alloc_tmp(aead, nfrags, extralen);
177 if (!tmp) { 187 if (!tmp) {
178 err = -ENOMEM; 188 err = -ENOMEM;
179 goto error; 189 goto error;
180 } 190 }
181 191
182 seqhi = esp_tmp_seqhi(tmp); 192 extra = esp_tmp_extra(tmp);
183 iv = esp_tmp_iv(aead, tmp, seqhilen); 193 iv = esp_tmp_iv(aead, tmp, extralen);
184 req = esp_tmp_req(aead, iv); 194 req = esp_tmp_req(aead, iv);
185 sg = esp_req_sg(aead, req); 195 sg = esp_req_sg(aead, req);
186 196
@@ -247,8 +257,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
247 * encryption. 257 * encryption.
248 */ 258 */
249 if ((x->props.flags & XFRM_STATE_ESN)) { 259 if ((x->props.flags & XFRM_STATE_ESN)) {
250 esph = (void *)(skb_transport_header(skb) - sizeof(__be32)); 260 extra->esphoff = (unsigned char *)esph -
251 *seqhi = esph->spi; 261 skb_transport_header(skb);
262 esph = (struct ip_esp_hdr *)((unsigned char *)esph - 4);
263 extra->seqhi = esph->spi;
252 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.hi); 264 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.hi);
253 aead_request_set_callback(req, 0, esp_output_done_esn, skb); 265 aead_request_set_callback(req, 0, esp_output_done_esn, skb);
254 } 266 }
@@ -445,7 +457,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
445 goto out; 457 goto out;
446 458
447 ESP_SKB_CB(skb)->tmp = tmp; 459 ESP_SKB_CB(skb)->tmp = tmp;
448 seqhi = esp_tmp_seqhi(tmp); 460 seqhi = esp_tmp_extra(tmp);
449 iv = esp_tmp_iv(aead, tmp, seqhilen); 461 iv = esp_tmp_iv(aead, tmp, seqhilen);
450 req = esp_tmp_req(aead, iv); 462 req = esp_tmp_req(aead, iv);
451 sg = esp_req_sg(aead, req); 463 sg = esp_req_sg(aead, req);
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 4c39f4fd332a..de1d119a4497 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -62,26 +62,26 @@ EXPORT_SYMBOL_GPL(gre_del_protocol);
62 62
63/* Fills in tpi and returns header length to be pulled. */ 63/* Fills in tpi and returns header length to be pulled. */
64int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, 64int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
65 bool *csum_err, __be16 proto) 65 bool *csum_err, __be16 proto, int nhs)
66{ 66{
67 const struct gre_base_hdr *greh; 67 const struct gre_base_hdr *greh;
68 __be32 *options; 68 __be32 *options;
69 int hdr_len; 69 int hdr_len;
70 70
71 if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr)))) 71 if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
72 return -EINVAL; 72 return -EINVAL;
73 73
74 greh = (struct gre_base_hdr *)skb_transport_header(skb); 74 greh = (struct gre_base_hdr *)(skb->data + nhs);
75 if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING))) 75 if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
76 return -EINVAL; 76 return -EINVAL;
77 77
78 tpi->flags = gre_flags_to_tnl_flags(greh->flags); 78 tpi->flags = gre_flags_to_tnl_flags(greh->flags);
79 hdr_len = gre_calc_hlen(tpi->flags); 79 hdr_len = gre_calc_hlen(tpi->flags);
80 80
81 if (!pskb_may_pull(skb, hdr_len)) 81 if (!pskb_may_pull(skb, nhs + hdr_len))
82 return -EINVAL; 82 return -EINVAL;
83 83
84 greh = (struct gre_base_hdr *)skb_transport_header(skb); 84 greh = (struct gre_base_hdr *)(skb->data + nhs);
85 tpi->proto = greh->protocol; 85 tpi->proto = greh->protocol;
86 86
87 options = (__be32 *)(greh + 1); 87 options = (__be32 *)(greh + 1);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 4d2025f7ec57..1d000af7f561 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -49,12 +49,6 @@
49#include <net/gre.h> 49#include <net/gre.h>
50#include <net/dst_metadata.h> 50#include <net/dst_metadata.h>
51 51
52#if IS_ENABLED(CONFIG_IPV6)
53#include <net/ipv6.h>
54#include <net/ip6_fib.h>
55#include <net/ip6_route.h>
56#endif
57
58/* 52/*
59 Problems & solutions 53 Problems & solutions
60 -------------------- 54 --------------------
@@ -217,12 +211,14 @@ static void gre_err(struct sk_buff *skb, u32 info)
217 * by themselves??? 211 * by themselves???
218 */ 212 */
219 213
214 const struct iphdr *iph = (struct iphdr *)skb->data;
220 const int type = icmp_hdr(skb)->type; 215 const int type = icmp_hdr(skb)->type;
221 const int code = icmp_hdr(skb)->code; 216 const int code = icmp_hdr(skb)->code;
222 struct tnl_ptk_info tpi; 217 struct tnl_ptk_info tpi;
223 bool csum_err = false; 218 bool csum_err = false;
224 219
225 if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)) < 0) { 220 if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP),
221 iph->ihl * 4) < 0) {
226 if (!csum_err) /* ignore csum errors. */ 222 if (!csum_err) /* ignore csum errors. */
227 return; 223 return;
228 } 224 }
@@ -338,7 +334,7 @@ static int gre_rcv(struct sk_buff *skb)
338 } 334 }
339#endif 335#endif
340 336
341 hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)); 337 hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
342 if (hdr_len < 0) 338 if (hdr_len < 0)
343 goto drop; 339 goto drop;
344 340
@@ -1121,6 +1117,7 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
1121{ 1117{
1122 struct nlattr *tb[IFLA_MAX + 1]; 1118 struct nlattr *tb[IFLA_MAX + 1];
1123 struct net_device *dev; 1119 struct net_device *dev;
1120 LIST_HEAD(list_kill);
1124 struct ip_tunnel *t; 1121 struct ip_tunnel *t;
1125 int err; 1122 int err;
1126 1123
@@ -1136,8 +1133,10 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
1136 t->collect_md = true; 1133 t->collect_md = true;
1137 1134
1138 err = ipgre_newlink(net, dev, tb, NULL); 1135 err = ipgre_newlink(net, dev, tb, NULL);
1139 if (err < 0) 1136 if (err < 0) {
1140 goto out; 1137 free_netdev(dev);
1138 return ERR_PTR(err);
1139 }
1141 1140
1142 /* openvswitch users expect packet sizes to be unrestricted, 1141 /* openvswitch users expect packet sizes to be unrestricted,
1143 * so set the largest MTU we can. 1142 * so set the largest MTU we can.
@@ -1146,9 +1145,14 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
1146 if (err) 1145 if (err)
1147 goto out; 1146 goto out;
1148 1147
1148 err = rtnl_configure_link(dev, NULL);
1149 if (err < 0)
1150 goto out;
1151
1149 return dev; 1152 return dev;
1150out: 1153out:
1151 free_netdev(dev); 1154 ip_tunnel_dellink(dev, &list_kill);
1155 unregister_netdevice_many(&list_kill);
1152 return ERR_PTR(err); 1156 return ERR_PTR(err);
1153} 1157}
1154EXPORT_SYMBOL_GPL(gretap_fb_dev_create); 1158EXPORT_SYMBOL_GPL(gretap_fb_dev_create);
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 2ed9dd2b5f2f..1d71c40eaaf3 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -127,7 +127,9 @@ __be32 ic_myaddr = NONE; /* My IP address */
127static __be32 ic_netmask = NONE; /* Netmask for local subnet */ 127static __be32 ic_netmask = NONE; /* Netmask for local subnet */
128__be32 ic_gateway = NONE; /* Gateway IP address */ 128__be32 ic_gateway = NONE; /* Gateway IP address */
129 129
130__be32 ic_addrservaddr = NONE; /* IP Address of the IP addresses'server */ 130#ifdef IPCONFIG_DYNAMIC
131static __be32 ic_addrservaddr = NONE; /* IP Address of the IP addresses'server */
132#endif
131 133
132__be32 ic_servaddr = NONE; /* Boot server IP address */ 134__be32 ic_servaddr = NONE; /* Boot server IP address */
133 135
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 21a38e296fe2..5ad48ec77710 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -891,8 +891,10 @@ static struct mfc_cache *ipmr_cache_alloc(void)
891{ 891{
892 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); 892 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
893 893
894 if (c) 894 if (c) {
895 c->mfc_un.res.last_assert = jiffies - MFC_ASSERT_THRESH - 1;
895 c->mfc_un.res.minvif = MAXVIFS; 896 c->mfc_un.res.minvif = MAXVIFS;
897 }
896 return c; 898 return c;
897} 899}
898 900
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 8bd9911fdd16..e00e972c4e6a 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2751,7 +2751,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
2751 struct tcp_sock *tp = tcp_sk(sk); 2751 struct tcp_sock *tp = tcp_sk(sk);
2752 struct sk_buff *skb; 2752 struct sk_buff *skb;
2753 struct sk_buff *hole = NULL; 2753 struct sk_buff *hole = NULL;
2754 u32 last_lost; 2754 u32 max_segs, last_lost;
2755 int mib_idx; 2755 int mib_idx;
2756 int fwd_rexmitting = 0; 2756 int fwd_rexmitting = 0;
2757 2757
@@ -2771,6 +2771,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
2771 last_lost = tp->snd_una; 2771 last_lost = tp->snd_una;
2772 } 2772 }
2773 2773
2774 max_segs = tcp_tso_autosize(sk, tcp_current_mss(sk));
2774 tcp_for_write_queue_from(skb, sk) { 2775 tcp_for_write_queue_from(skb, sk) {
2775 __u8 sacked = TCP_SKB_CB(skb)->sacked; 2776 __u8 sacked = TCP_SKB_CB(skb)->sacked;
2776 int segs; 2777 int segs;
@@ -2784,6 +2785,10 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
2784 segs = tp->snd_cwnd - tcp_packets_in_flight(tp); 2785 segs = tp->snd_cwnd - tcp_packets_in_flight(tp);
2785 if (segs <= 0) 2786 if (segs <= 0)
2786 return; 2787 return;
2788 /* In case tcp_shift_skb_data() have aggregated large skbs,
2789 * we need to make sure not sending too bigs TSO packets
2790 */
2791 segs = min_t(int, segs, max_segs);
2787 2792
2788 if (fwd_rexmitting) { 2793 if (fwd_rexmitting) {
2789begin_fwd: 2794begin_fwd:
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 0ff31d97d485..ca5e8ea29538 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -391,9 +391,9 @@ int udp_v4_get_port(struct sock *sk, unsigned short snum)
391 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal, hash2_nulladdr); 391 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal, hash2_nulladdr);
392} 392}
393 393
394static inline int compute_score(struct sock *sk, struct net *net, 394static int compute_score(struct sock *sk, struct net *net,
395 __be32 saddr, unsigned short hnum, __be16 sport, 395 __be32 saddr, __be16 sport,
396 __be32 daddr, __be16 dport, int dif) 396 __be32 daddr, unsigned short hnum, int dif)
397{ 397{
398 int score; 398 int score;
399 struct inet_sock *inet; 399 struct inet_sock *inet;
@@ -434,52 +434,6 @@ static inline int compute_score(struct sock *sk, struct net *net,
434 return score; 434 return score;
435} 435}
436 436
437/*
438 * In this second variant, we check (daddr, dport) matches (inet_rcv_sadd, inet_num)
439 */
440static inline int compute_score2(struct sock *sk, struct net *net,
441 __be32 saddr, __be16 sport,
442 __be32 daddr, unsigned int hnum, int dif)
443{
444 int score;
445 struct inet_sock *inet;
446
447 if (!net_eq(sock_net(sk), net) ||
448 ipv6_only_sock(sk))
449 return -1;
450
451 inet = inet_sk(sk);
452
453 if (inet->inet_rcv_saddr != daddr ||
454 inet->inet_num != hnum)
455 return -1;
456
457 score = (sk->sk_family == PF_INET) ? 2 : 1;
458
459 if (inet->inet_daddr) {
460 if (inet->inet_daddr != saddr)
461 return -1;
462 score += 4;
463 }
464
465 if (inet->inet_dport) {
466 if (inet->inet_dport != sport)
467 return -1;
468 score += 4;
469 }
470
471 if (sk->sk_bound_dev_if) {
472 if (sk->sk_bound_dev_if != dif)
473 return -1;
474 score += 4;
475 }
476
477 if (sk->sk_incoming_cpu == raw_smp_processor_id())
478 score++;
479
480 return score;
481}
482
483static u32 udp_ehashfn(const struct net *net, const __be32 laddr, 437static u32 udp_ehashfn(const struct net *net, const __be32 laddr,
484 const __u16 lport, const __be32 faddr, 438 const __u16 lport, const __be32 faddr,
485 const __be16 fport) 439 const __be16 fport)
@@ -492,11 +446,11 @@ static u32 udp_ehashfn(const struct net *net, const __be32 laddr,
492 udp_ehash_secret + net_hash_mix(net)); 446 udp_ehash_secret + net_hash_mix(net));
493} 447}
494 448
495/* called with read_rcu_lock() */ 449/* called with rcu_read_lock() */
496static struct sock *udp4_lib_lookup2(struct net *net, 450static struct sock *udp4_lib_lookup2(struct net *net,
497 __be32 saddr, __be16 sport, 451 __be32 saddr, __be16 sport,
498 __be32 daddr, unsigned int hnum, int dif, 452 __be32 daddr, unsigned int hnum, int dif,
499 struct udp_hslot *hslot2, unsigned int slot2, 453 struct udp_hslot *hslot2,
500 struct sk_buff *skb) 454 struct sk_buff *skb)
501{ 455{
502 struct sock *sk, *result; 456 struct sock *sk, *result;
@@ -506,7 +460,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
506 result = NULL; 460 result = NULL;
507 badness = 0; 461 badness = 0;
508 udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) { 462 udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
509 score = compute_score2(sk, net, saddr, sport, 463 score = compute_score(sk, net, saddr, sport,
510 daddr, hnum, dif); 464 daddr, hnum, dif);
511 if (score > badness) { 465 if (score > badness) {
512 reuseport = sk->sk_reuseport; 466 reuseport = sk->sk_reuseport;
@@ -554,17 +508,22 @@ struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
554 508
555 result = udp4_lib_lookup2(net, saddr, sport, 509 result = udp4_lib_lookup2(net, saddr, sport,
556 daddr, hnum, dif, 510 daddr, hnum, dif,
557 hslot2, slot2, skb); 511 hslot2, skb);
558 if (!result) { 512 if (!result) {
513 unsigned int old_slot2 = slot2;
559 hash2 = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum); 514 hash2 = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum);
560 slot2 = hash2 & udptable->mask; 515 slot2 = hash2 & udptable->mask;
516 /* avoid searching the same slot again. */
517 if (unlikely(slot2 == old_slot2))
518 return result;
519
561 hslot2 = &udptable->hash2[slot2]; 520 hslot2 = &udptable->hash2[slot2];
562 if (hslot->count < hslot2->count) 521 if (hslot->count < hslot2->count)
563 goto begin; 522 goto begin;
564 523
565 result = udp4_lib_lookup2(net, saddr, sport, 524 result = udp4_lib_lookup2(net, saddr, sport,
566 htonl(INADDR_ANY), hnum, dif, 525 daddr, hnum, dif,
567 hslot2, slot2, skb); 526 hslot2, skb);
568 } 527 }
569 return result; 528 return result;
570 } 529 }
@@ -572,8 +531,8 @@ begin:
572 result = NULL; 531 result = NULL;
573 badness = 0; 532 badness = 0;
574 sk_for_each_rcu(sk, &hslot->head) { 533 sk_for_each_rcu(sk, &hslot->head) {
575 score = compute_score(sk, net, saddr, hnum, sport, 534 score = compute_score(sk, net, saddr, sport,
576 daddr, dport, dif); 535 daddr, hnum, dif);
577 if (score > badness) { 536 if (score > badness) {
578 reuseport = sk->sk_reuseport; 537 reuseport = sk->sk_reuseport;
579 if (reuseport) { 538 if (reuseport) {
@@ -1755,8 +1714,11 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
1755 return err; 1714 return err;
1756 } 1715 }
1757 1716
1758 return skb_checksum_init_zero_check(skb, proto, uh->check, 1717 /* Note, we are only interested in != 0 or == 0, thus the
1759 inet_compute_pseudo); 1718 * force to int.
1719 */
1720 return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
1721 inet_compute_pseudo);
1760} 1722}
1761 1723
1762/* 1724/*
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 4527285fcaa2..a4fa84076969 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -98,7 +98,7 @@ static void icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
98 98
99 if (!(type & ICMPV6_INFOMSG_MASK)) 99 if (!(type & ICMPV6_INFOMSG_MASK))
100 if (icmp6->icmp6_type == ICMPV6_ECHO_REQUEST) 100 if (icmp6->icmp6_type == ICMPV6_ECHO_REQUEST)
101 ping_err(skb, offset, info); 101 ping_err(skb, offset, ntohl(info));
102} 102}
103 103
104static int icmpv6_rcv(struct sk_buff *skb); 104static int icmpv6_rcv(struct sk_buff *skb);
diff --git a/net/ipv6/ip6_checksum.c b/net/ipv6/ip6_checksum.c
index b2025bf3da4a..c0cbcb259f5a 100644
--- a/net/ipv6/ip6_checksum.c
+++ b/net/ipv6/ip6_checksum.c
@@ -78,9 +78,12 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
78 * we accept a checksum of zero here. When we find the socket 78 * we accept a checksum of zero here. When we find the socket
79 * for the UDP packet we'll check if that socket allows zero checksum 79 * for the UDP packet we'll check if that socket allows zero checksum
80 * for IPv6 (set by socket option). 80 * for IPv6 (set by socket option).
81 *
82 * Note, we are only interested in != 0 or == 0, thus the
83 * force to int.
81 */ 84 */
82 return skb_checksum_init_zero_check(skb, proto, uh->check, 85 return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
83 ip6_compute_pseudo); 86 ip6_compute_pseudo);
84} 87}
85EXPORT_SYMBOL(udp6_csum_init); 88EXPORT_SYMBOL(udp6_csum_init);
86 89
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index fdc9de276ab1..776d145113e1 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -468,7 +468,7 @@ static int gre_rcv(struct sk_buff *skb)
468 bool csum_err = false; 468 bool csum_err = false;
469 int hdr_len; 469 int hdr_len;
470 470
471 hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6)); 471 hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6), 0);
472 if (hdr_len < 0) 472 if (hdr_len < 0)
473 goto drop; 473 goto drop;
474 474
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index f2e2013f8346..487ef3bc7bbc 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1074,6 +1074,7 @@ static struct mfc6_cache *ip6mr_cache_alloc(void)
1074 struct mfc6_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); 1074 struct mfc6_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
1075 if (!c) 1075 if (!c)
1076 return NULL; 1076 return NULL;
1077 c->mfc_un.res.last_assert = jiffies - MFC_ASSERT_THRESH - 1;
1077 c->mfc_un.res.minvif = MAXMIFS; 1078 c->mfc_un.res.minvif = MAXMIFS;
1078 return c; 1079 return c;
1079} 1080}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 969913da494f..520b7884d0c2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1782,7 +1782,7 @@ static struct rt6_info *ip6_nh_lookup_table(struct net *net,
1782 }; 1782 };
1783 struct fib6_table *table; 1783 struct fib6_table *table;
1784 struct rt6_info *rt; 1784 struct rt6_info *rt;
1785 int flags = 0; 1785 int flags = RT6_LOOKUP_F_IFACE;
1786 1786
1787 table = fib6_get_table(net, cfg->fc_table); 1787 table = fib6_get_table(net, cfg->fc_table);
1788 if (!table) 1788 if (!table)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 0a5a255277e5..0619ac70836d 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -560,13 +560,13 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
560 560
561 if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { 561 if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
562 ipv4_update_pmtu(skb, dev_net(skb->dev), info, 562 ipv4_update_pmtu(skb, dev_net(skb->dev), info,
563 t->parms.link, 0, IPPROTO_IPV6, 0); 563 t->parms.link, 0, iph->protocol, 0);
564 err = 0; 564 err = 0;
565 goto out; 565 goto out;
566 } 566 }
567 if (type == ICMP_REDIRECT) { 567 if (type == ICMP_REDIRECT) {
568 ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, 568 ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0,
569 IPPROTO_IPV6, 0); 569 iph->protocol, 0);
570 err = 0; 570 err = 0;
571 goto out; 571 goto out;
572 } 572 }
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index f36c2d076fce..2255d2bf5f6b 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -738,7 +738,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
738static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 seq, 738static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 seq,
739 u32 ack, u32 win, u32 tsval, u32 tsecr, 739 u32 ack, u32 win, u32 tsval, u32 tsecr,
740 int oif, struct tcp_md5sig_key *key, int rst, 740 int oif, struct tcp_md5sig_key *key, int rst,
741 u8 tclass, u32 label) 741 u8 tclass, __be32 label)
742{ 742{
743 const struct tcphdr *th = tcp_hdr(skb); 743 const struct tcphdr *th = tcp_hdr(skb);
744 struct tcphdr *t1; 744 struct tcphdr *t1;
@@ -911,7 +911,7 @@ out:
911static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq, 911static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq,
912 u32 ack, u32 win, u32 tsval, u32 tsecr, int oif, 912 u32 ack, u32 win, u32 tsval, u32 tsecr, int oif,
913 struct tcp_md5sig_key *key, u8 tclass, 913 struct tcp_md5sig_key *key, u8 tclass,
914 u32 label) 914 __be32 label)
915{ 915{
916 tcp_v6_send_response(sk, skb, seq, ack, win, tsval, tsecr, oif, key, 0, 916 tcp_v6_send_response(sk, skb, seq, ack, win, tsval, tsecr, oif, key, 0,
917 tclass, label); 917 tclass, label);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index f421c9f23c5b..005dc82c2138 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -115,11 +115,10 @@ static void udp_v6_rehash(struct sock *sk)
115 udp_lib_rehash(sk, new_hash); 115 udp_lib_rehash(sk, new_hash);
116} 116}
117 117
118static inline int compute_score(struct sock *sk, struct net *net, 118static int compute_score(struct sock *sk, struct net *net,
119 unsigned short hnum, 119 const struct in6_addr *saddr, __be16 sport,
120 const struct in6_addr *saddr, __be16 sport, 120 const struct in6_addr *daddr, unsigned short hnum,
121 const struct in6_addr *daddr, __be16 dport, 121 int dif)
122 int dif)
123{ 122{
124 int score; 123 int score;
125 struct inet_sock *inet; 124 struct inet_sock *inet;
@@ -162,54 +161,11 @@ static inline int compute_score(struct sock *sk, struct net *net,
162 return score; 161 return score;
163} 162}
164 163
165static inline int compute_score2(struct sock *sk, struct net *net, 164/* called with rcu_read_lock() */
166 const struct in6_addr *saddr, __be16 sport,
167 const struct in6_addr *daddr,
168 unsigned short hnum, int dif)
169{
170 int score;
171 struct inet_sock *inet;
172
173 if (!net_eq(sock_net(sk), net) ||
174 udp_sk(sk)->udp_port_hash != hnum ||
175 sk->sk_family != PF_INET6)
176 return -1;
177
178 if (!ipv6_addr_equal(&sk->sk_v6_rcv_saddr, daddr))
179 return -1;
180
181 score = 0;
182 inet = inet_sk(sk);
183
184 if (inet->inet_dport) {
185 if (inet->inet_dport != sport)
186 return -1;
187 score++;
188 }
189
190 if (!ipv6_addr_any(&sk->sk_v6_daddr)) {
191 if (!ipv6_addr_equal(&sk->sk_v6_daddr, saddr))
192 return -1;
193 score++;
194 }
195
196 if (sk->sk_bound_dev_if) {
197 if (sk->sk_bound_dev_if != dif)
198 return -1;
199 score++;
200 }
201
202 if (sk->sk_incoming_cpu == raw_smp_processor_id())
203 score++;
204
205 return score;
206}
207
208/* called with read_rcu_lock() */
209static struct sock *udp6_lib_lookup2(struct net *net, 165static struct sock *udp6_lib_lookup2(struct net *net,
210 const struct in6_addr *saddr, __be16 sport, 166 const struct in6_addr *saddr, __be16 sport,
211 const struct in6_addr *daddr, unsigned int hnum, int dif, 167 const struct in6_addr *daddr, unsigned int hnum, int dif,
212 struct udp_hslot *hslot2, unsigned int slot2, 168 struct udp_hslot *hslot2,
213 struct sk_buff *skb) 169 struct sk_buff *skb)
214{ 170{
215 struct sock *sk, *result; 171 struct sock *sk, *result;
@@ -219,7 +175,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
219 result = NULL; 175 result = NULL;
220 badness = -1; 176 badness = -1;
221 udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) { 177 udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
222 score = compute_score2(sk, net, saddr, sport, 178 score = compute_score(sk, net, saddr, sport,
223 daddr, hnum, dif); 179 daddr, hnum, dif);
224 if (score > badness) { 180 if (score > badness) {
225 reuseport = sk->sk_reuseport; 181 reuseport = sk->sk_reuseport;
@@ -268,17 +224,22 @@ struct sock *__udp6_lib_lookup(struct net *net,
268 224
269 result = udp6_lib_lookup2(net, saddr, sport, 225 result = udp6_lib_lookup2(net, saddr, sport,
270 daddr, hnum, dif, 226 daddr, hnum, dif,
271 hslot2, slot2, skb); 227 hslot2, skb);
272 if (!result) { 228 if (!result) {
229 unsigned int old_slot2 = slot2;
273 hash2 = udp6_portaddr_hash(net, &in6addr_any, hnum); 230 hash2 = udp6_portaddr_hash(net, &in6addr_any, hnum);
274 slot2 = hash2 & udptable->mask; 231 slot2 = hash2 & udptable->mask;
232 /* avoid searching the same slot again. */
233 if (unlikely(slot2 == old_slot2))
234 return result;
235
275 hslot2 = &udptable->hash2[slot2]; 236 hslot2 = &udptable->hash2[slot2];
276 if (hslot->count < hslot2->count) 237 if (hslot->count < hslot2->count)
277 goto begin; 238 goto begin;
278 239
279 result = udp6_lib_lookup2(net, saddr, sport, 240 result = udp6_lib_lookup2(net, saddr, sport,
280 &in6addr_any, hnum, dif, 241 daddr, hnum, dif,
281 hslot2, slot2, skb); 242 hslot2, skb);
282 } 243 }
283 return result; 244 return result;
284 } 245 }
@@ -286,7 +247,7 @@ begin:
286 result = NULL; 247 result = NULL;
287 badness = -1; 248 badness = -1;
288 sk_for_each_rcu(sk, &hslot->head) { 249 sk_for_each_rcu(sk, &hslot->head) {
289 score = compute_score(sk, net, hnum, saddr, sport, daddr, dport, dif); 250 score = compute_score(sk, net, saddr, sport, daddr, hnum, dif);
290 if (score > badness) { 251 if (score > badness) {
291 reuseport = sk->sk_reuseport; 252 reuseport = sk->sk_reuseport;
292 if (reuseport) { 253 if (reuseport) {
diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c
index 738008726cc6..fda7f4715c58 100644
--- a/net/kcm/kcmproc.c
+++ b/net/kcm/kcmproc.c
@@ -241,6 +241,7 @@ static const struct file_operations kcm_seq_fops = {
241 .open = kcm_seq_open, 241 .open = kcm_seq_open,
242 .read = seq_read, 242 .read = seq_read,
243 .llseek = seq_lseek, 243 .llseek = seq_lseek,
244 .release = seq_release_net,
244}; 245};
245 246
246static struct kcm_seq_muxinfo kcm_seq_muxinfo = { 247static struct kcm_seq_muxinfo kcm_seq_muxinfo = {
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 21b1fdf5d01d..6a1603bcdced 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -148,14 +148,17 @@ u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
148void mesh_sta_cleanup(struct sta_info *sta) 148void mesh_sta_cleanup(struct sta_info *sta)
149{ 149{
150 struct ieee80211_sub_if_data *sdata = sta->sdata; 150 struct ieee80211_sub_if_data *sdata = sta->sdata;
151 u32 changed; 151 u32 changed = 0;
152 152
153 /* 153 /*
154 * maybe userspace handles peer allocation and peering, but in either 154 * maybe userspace handles peer allocation and peering, but in either
155 * case the beacon is still generated by the kernel and we might need 155 * case the beacon is still generated by the kernel and we might need
156 * an update. 156 * an update.
157 */ 157 */
158 changed = mesh_accept_plinks_update(sdata); 158 if (sdata->u.mesh.user_mpm &&
159 sta->mesh->plink_state == NL80211_PLINK_ESTAB)
160 changed |= mesh_plink_dec_estab_count(sdata);
161 changed |= mesh_accept_plinks_update(sdata);
159 if (!sdata->u.mesh.user_mpm) { 162 if (!sdata->u.mesh.user_mpm) {
160 changed |= mesh_plink_deactivate(sta); 163 changed |= mesh_plink_deactivate(sta);
161 del_timer_sync(&sta->mesh->plink_timer); 164 del_timer_sync(&sta->mesh->plink_timer);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index db2312eeb2a4..f204274a9b6b 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1544,6 +1544,8 @@ void nf_conntrack_cleanup_end(void)
1544 nf_conntrack_tstamp_fini(); 1544 nf_conntrack_tstamp_fini();
1545 nf_conntrack_acct_fini(); 1545 nf_conntrack_acct_fini();
1546 nf_conntrack_expect_fini(); 1546 nf_conntrack_expect_fini();
1547
1548 kmem_cache_destroy(nf_conntrack_cachep);
1547} 1549}
1548 1550
1549/* 1551/*
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 7b7aa871a174..2c881871db38 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2946,24 +2946,20 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
2946 * jumps are already validated for that chain. 2946 * jumps are already validated for that chain.
2947 */ 2947 */
2948 list_for_each_entry(i, &set->bindings, list) { 2948 list_for_each_entry(i, &set->bindings, list) {
2949 if (binding->flags & NFT_SET_MAP && 2949 if (i->flags & NFT_SET_MAP &&
2950 i->chain == binding->chain) 2950 i->chain == binding->chain)
2951 goto bind; 2951 goto bind;
2952 } 2952 }
2953 2953
2954 iter.genmask = nft_genmask_next(ctx->net);
2954 iter.skip = 0; 2955 iter.skip = 0;
2955 iter.count = 0; 2956 iter.count = 0;
2956 iter.err = 0; 2957 iter.err = 0;
2957 iter.fn = nf_tables_bind_check_setelem; 2958 iter.fn = nf_tables_bind_check_setelem;
2958 2959
2959 set->ops->walk(ctx, set, &iter); 2960 set->ops->walk(ctx, set, &iter);
2960 if (iter.err < 0) { 2961 if (iter.err < 0)
2961 /* Destroy anonymous sets if binding fails */
2962 if (set->flags & NFT_SET_ANONYMOUS)
2963 nf_tables_set_destroy(ctx, set);
2964
2965 return iter.err; 2962 return iter.err;
2966 }
2967 } 2963 }
2968bind: 2964bind:
2969 binding->chain = ctx->chain; 2965 binding->chain = ctx->chain;
@@ -3192,12 +3188,13 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3192 if (nest == NULL) 3188 if (nest == NULL)
3193 goto nla_put_failure; 3189 goto nla_put_failure;
3194 3190
3195 args.cb = cb; 3191 args.cb = cb;
3196 args.skb = skb; 3192 args.skb = skb;
3197 args.iter.skip = cb->args[0]; 3193 args.iter.genmask = nft_genmask_cur(ctx.net);
3198 args.iter.count = 0; 3194 args.iter.skip = cb->args[0];
3199 args.iter.err = 0; 3195 args.iter.count = 0;
3200 args.iter.fn = nf_tables_dump_setelem; 3196 args.iter.err = 0;
3197 args.iter.fn = nf_tables_dump_setelem;
3201 set->ops->walk(&ctx, set, &args.iter); 3198 set->ops->walk(&ctx, set, &args.iter);
3202 3199
3203 nla_nest_end(skb, nest); 3200 nla_nest_end(skb, nest);
@@ -4284,6 +4281,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
4284 binding->chain != chain) 4281 binding->chain != chain)
4285 continue; 4282 continue;
4286 4283
4284 iter.genmask = nft_genmask_next(ctx->net);
4287 iter.skip = 0; 4285 iter.skip = 0;
4288 iter.count = 0; 4286 iter.count = 0;
4289 iter.err = 0; 4287 iter.err = 0;
diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index e9f8dffcc244..fb8b5892b5ff 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -143,7 +143,7 @@ next_rule:
143 list_for_each_entry_continue_rcu(rule, &chain->rules, list) { 143 list_for_each_entry_continue_rcu(rule, &chain->rules, list) {
144 144
145 /* This rule is not active, skip. */ 145 /* This rule is not active, skip. */
146 if (unlikely(rule->genmask & (1 << gencursor))) 146 if (unlikely(rule->genmask & gencursor))
147 continue; 147 continue;
148 148
149 rulenum++; 149 rulenum++;
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 6fa016564f90..f39c53a159eb 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -189,7 +189,6 @@ static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set,
189 struct nft_hash_elem *he; 189 struct nft_hash_elem *he;
190 struct rhashtable_iter hti; 190 struct rhashtable_iter hti;
191 struct nft_set_elem elem; 191 struct nft_set_elem elem;
192 u8 genmask = nft_genmask_cur(read_pnet(&set->pnet));
193 int err; 192 int err;
194 193
195 err = rhashtable_walk_init(&priv->ht, &hti, GFP_KERNEL); 194 err = rhashtable_walk_init(&priv->ht, &hti, GFP_KERNEL);
@@ -218,7 +217,7 @@ static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set,
218 goto cont; 217 goto cont;
219 if (nft_set_elem_expired(&he->ext)) 218 if (nft_set_elem_expired(&he->ext))
220 goto cont; 219 goto cont;
221 if (!nft_set_elem_active(&he->ext, genmask)) 220 if (!nft_set_elem_active(&he->ext, iter->genmask))
222 goto cont; 221 goto cont;
223 222
224 elem.priv = he; 223 elem.priv = he;
diff --git a/net/netfilter/nft_rbtree.c b/net/netfilter/nft_rbtree.c
index f762094af7c1..7201d57b5a93 100644
--- a/net/netfilter/nft_rbtree.c
+++ b/net/netfilter/nft_rbtree.c
@@ -211,7 +211,6 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx,
211 struct nft_rbtree_elem *rbe; 211 struct nft_rbtree_elem *rbe;
212 struct nft_set_elem elem; 212 struct nft_set_elem elem;
213 struct rb_node *node; 213 struct rb_node *node;
214 u8 genmask = nft_genmask_cur(read_pnet(&set->pnet));
215 214
216 spin_lock_bh(&nft_rbtree_lock); 215 spin_lock_bh(&nft_rbtree_lock);
217 for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) { 216 for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) {
@@ -219,7 +218,7 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx,
219 218
220 if (iter->count < iter->skip) 219 if (iter->count < iter->skip)
221 goto cont; 220 goto cont;
222 if (!nft_set_elem_active(&rbe->ext, genmask)) 221 if (!nft_set_elem_active(&rbe->ext, iter->genmask))
223 goto cont; 222 goto cont;
224 223
225 elem.priv = rbe; 224 elem.priv = rbe;
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 3d5feede962d..d84312584ee4 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -818,8 +818,18 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
818 */ 818 */
819 state = OVS_CS_F_TRACKED | OVS_CS_F_NEW | OVS_CS_F_RELATED; 819 state = OVS_CS_F_TRACKED | OVS_CS_F_NEW | OVS_CS_F_RELATED;
820 __ovs_ct_update_key(key, state, &info->zone, exp->master); 820 __ovs_ct_update_key(key, state, &info->zone, exp->master);
821 } else 821 } else {
822 return __ovs_ct_lookup(net, key, info, skb); 822 struct nf_conn *ct;
823 int err;
824
825 err = __ovs_ct_lookup(net, key, info, skb);
826 if (err)
827 return err;
828
829 ct = (struct nf_conn *)skb->nfct;
830 if (ct)
831 nf_ct_deliver_cached_events(ct);
832 }
823 833
824 return 0; 834 return 0;
825} 835}
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 310cabce2311..7c2a65a6af5c 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -111,7 +111,7 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even
111 } 111 }
112 } 112 }
113 113
114 if (conn->c_version < RDS_PROTOCOL(3,1)) { 114 if (conn->c_version < RDS_PROTOCOL(3, 1)) {
115 printk(KERN_NOTICE "RDS/IB: Connection to %pI4 version %u.%u failed," 115 printk(KERN_NOTICE "RDS/IB: Connection to %pI4 version %u.%u failed,"
116 " no longer supported\n", 116 " no longer supported\n",
117 &conn->c_faddr, 117 &conn->c_faddr,
diff --git a/net/rds/loop.c b/net/rds/loop.c
index 6b12b68541ae..814173b466d9 100644
--- a/net/rds/loop.c
+++ b/net/rds/loop.c
@@ -95,8 +95,9 @@ out:
95 */ 95 */
96static void rds_loop_inc_free(struct rds_incoming *inc) 96static void rds_loop_inc_free(struct rds_incoming *inc)
97{ 97{
98 struct rds_message *rm = container_of(inc, struct rds_message, m_inc); 98 struct rds_message *rm = container_of(inc, struct rds_message, m_inc);
99 rds_message_put(rm); 99
100 rds_message_put(rm);
100} 101}
101 102
102/* we need to at least give the thread something to succeed */ 103/* we need to at least give the thread something to succeed */
diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
index c173f69e1479..e381bbcd9cc1 100644
--- a/net/rds/sysctl.c
+++ b/net/rds/sysctl.c
@@ -102,7 +102,8 @@ int rds_sysctl_init(void)
102 rds_sysctl_reconnect_min = msecs_to_jiffies(1); 102 rds_sysctl_reconnect_min = msecs_to_jiffies(1);
103 rds_sysctl_reconnect_min_jiffies = rds_sysctl_reconnect_min; 103 rds_sysctl_reconnect_min_jiffies = rds_sysctl_reconnect_min;
104 104
105 rds_sysctl_reg_table = register_net_sysctl(&init_net,"net/rds", rds_sysctl_rds_table); 105 rds_sysctl_reg_table =
106 register_net_sysctl(&init_net, "net/rds", rds_sysctl_rds_table);
106 if (!rds_sysctl_reg_table) 107 if (!rds_sysctl_reg_table)
107 return -ENOMEM; 108 return -ENOMEM;
108 return 0; 109 return 0;
diff --git a/net/rds/tcp.h b/net/rds/tcp.h
index ec0602b0dc24..7940babf6c71 100644
--- a/net/rds/tcp.h
+++ b/net/rds/tcp.h
@@ -83,7 +83,7 @@ int rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to);
83void rds_tcp_xmit_prepare(struct rds_connection *conn); 83void rds_tcp_xmit_prepare(struct rds_connection *conn);
84void rds_tcp_xmit_complete(struct rds_connection *conn); 84void rds_tcp_xmit_complete(struct rds_connection *conn);
85int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, 85int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
86 unsigned int hdr_off, unsigned int sg, unsigned int off); 86 unsigned int hdr_off, unsigned int sg, unsigned int off);
87void rds_tcp_write_space(struct sock *sk); 87void rds_tcp_write_space(struct sock *sk);
88 88
89/* tcp_stats.c */ 89/* tcp_stats.c */
diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c
index fba13d0305fb..f6e95d60db54 100644
--- a/net/rds/tcp_connect.c
+++ b/net/rds/tcp_connect.c
@@ -54,19 +54,19 @@ void rds_tcp_state_change(struct sock *sk)
54 54
55 rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state); 55 rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state);
56 56
57 switch(sk->sk_state) { 57 switch (sk->sk_state) {
58 /* ignore connecting sockets as they make progress */ 58 /* ignore connecting sockets as they make progress */
59 case TCP_SYN_SENT: 59 case TCP_SYN_SENT:
60 case TCP_SYN_RECV: 60 case TCP_SYN_RECV:
61 break; 61 break;
62 case TCP_ESTABLISHED: 62 case TCP_ESTABLISHED:
63 rds_connect_path_complete(conn, RDS_CONN_CONNECTING); 63 rds_connect_path_complete(conn, RDS_CONN_CONNECTING);
64 break; 64 break;
65 case TCP_CLOSE_WAIT: 65 case TCP_CLOSE_WAIT:
66 case TCP_CLOSE: 66 case TCP_CLOSE:
67 rds_conn_drop(conn); 67 rds_conn_drop(conn);
68 default: 68 default:
69 break; 69 break;
70 } 70 }
71out: 71out:
72 read_unlock_bh(&sk->sk_callback_lock); 72 read_unlock_bh(&sk->sk_callback_lock);
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index 686b1d03a558..245542ca4718 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -138,7 +138,7 @@ int rds_tcp_accept_one(struct socket *sock)
138 rds_tcp_reset_callbacks(new_sock, conn); 138 rds_tcp_reset_callbacks(new_sock, conn);
139 conn->c_outgoing = 0; 139 conn->c_outgoing = 0;
140 /* rds_connect_path_complete() marks RDS_CONN_UP */ 140 /* rds_connect_path_complete() marks RDS_CONN_UP */
141 rds_connect_path_complete(conn, RDS_CONN_DISCONNECTING); 141 rds_connect_path_complete(conn, RDS_CONN_RESETTING);
142 } 142 }
143 } else { 143 } else {
144 rds_tcp_set_callbacks(new_sock, conn); 144 rds_tcp_set_callbacks(new_sock, conn);
diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c
index c3196f9d070a..6e6a7111a034 100644
--- a/net/rds/tcp_recv.c
+++ b/net/rds/tcp_recv.c
@@ -171,7 +171,7 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
171 while (left) { 171 while (left) {
172 if (!tinc) { 172 if (!tinc) {
173 tinc = kmem_cache_alloc(rds_tcp_incoming_slab, 173 tinc = kmem_cache_alloc(rds_tcp_incoming_slab,
174 arg->gfp); 174 arg->gfp);
175 if (!tinc) { 175 if (!tinc) {
176 desc->error = -ENOMEM; 176 desc->error = -ENOMEM;
177 goto out; 177 goto out;
diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
index 22d0f2020a79..618be69c9c3b 100644
--- a/net/rds/tcp_send.c
+++ b/net/rds/tcp_send.c
@@ -66,19 +66,19 @@ void rds_tcp_xmit_complete(struct rds_connection *conn)
66static int rds_tcp_sendmsg(struct socket *sock, void *data, unsigned int len) 66static int rds_tcp_sendmsg(struct socket *sock, void *data, unsigned int len)
67{ 67{
68 struct kvec vec = { 68 struct kvec vec = {
69 .iov_base = data, 69 .iov_base = data,
70 .iov_len = len, 70 .iov_len = len,
71 };
72 struct msghdr msg = {
73 .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL,
71 }; 74 };
72 struct msghdr msg = {
73 .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL,
74 };
75 75
76 return kernel_sendmsg(sock, &msg, &vec, 1, vec.iov_len); 76 return kernel_sendmsg(sock, &msg, &vec, 1, vec.iov_len);
77} 77}
78 78
79/* the core send_sem serializes this with other xmit and shutdown */ 79/* the core send_sem serializes this with other xmit and shutdown */
80int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, 80int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
81 unsigned int hdr_off, unsigned int sg, unsigned int off) 81 unsigned int hdr_off, unsigned int sg, unsigned int off)
82{ 82{
83 struct rds_tcp_connection *tc = conn->c_transport_data; 83 struct rds_tcp_connection *tc = conn->c_transport_data;
84 int done = 0; 84 int done = 0;
@@ -196,7 +196,7 @@ void rds_tcp_write_space(struct sock *sk)
196 tc->t_last_seen_una = rds_tcp_snd_una(tc); 196 tc->t_last_seen_una = rds_tcp_snd_una(tc);
197 rds_send_drop_acked(conn, rds_tcp_snd_una(tc), rds_tcp_is_acked); 197 rds_send_drop_acked(conn, rds_tcp_snd_una(tc), rds_tcp_is_acked);
198 198
199 if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) 199 if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf)
200 queue_delayed_work(rds_wq, &conn->c_send_w, 0); 200 queue_delayed_work(rds_wq, &conn->c_send_w, 0);
201 201
202out: 202out:
diff --git a/net/rds/transport.c b/net/rds/transport.c
index f3afd1d60d3c..2ffd3e30c643 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -140,8 +140,7 @@ unsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter,
140 rds_info_iter_unmap(iter); 140 rds_info_iter_unmap(iter);
141 down_read(&rds_trans_sem); 141 down_read(&rds_trans_sem);
142 142
143 for (i = 0; i < RDS_TRANS_COUNT; i++) 143 for (i = 0; i < RDS_TRANS_COUNT; i++) {
144 {
145 trans = transports[i]; 144 trans = transports[i];
146 if (!trans || !trans->stats_info_copy) 145 if (!trans || !trans->stats_info_copy)
147 continue; 146 continue;
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 336774a535c3..c7a0b0d481c0 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -1118,7 +1118,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1118 nla_nest_end(skb, nest); 1118 nla_nest_end(skb, nest);
1119 ret = skb->len; 1119 ret = skb->len;
1120 } else 1120 } else
1121 nla_nest_cancel(skb, nest); 1121 nlmsg_trim(skb, b);
1122 1122
1123 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 1123 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1124 if (NETLINK_CB(cb->skb).portid && ret) 1124 if (NETLINK_CB(cb->skb).portid && ret)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 658046dfe02d..ea4a2fef1b71 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -106,9 +106,9 @@ int ife_get_meta_u16(struct sk_buff *skb, struct tcf_meta_info *mi)
106} 106}
107EXPORT_SYMBOL_GPL(ife_get_meta_u16); 107EXPORT_SYMBOL_GPL(ife_get_meta_u16);
108 108
109int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval) 109int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval, gfp_t gfp)
110{ 110{
111 mi->metaval = kmemdup(metaval, sizeof(u32), GFP_KERNEL); 111 mi->metaval = kmemdup(metaval, sizeof(u32), gfp);
112 if (!mi->metaval) 112 if (!mi->metaval)
113 return -ENOMEM; 113 return -ENOMEM;
114 114
@@ -116,9 +116,9 @@ int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval)
116} 116}
117EXPORT_SYMBOL_GPL(ife_alloc_meta_u32); 117EXPORT_SYMBOL_GPL(ife_alloc_meta_u32);
118 118
119int ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval) 119int ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval, gfp_t gfp)
120{ 120{
121 mi->metaval = kmemdup(metaval, sizeof(u16), GFP_KERNEL); 121 mi->metaval = kmemdup(metaval, sizeof(u16), gfp);
122 if (!mi->metaval) 122 if (!mi->metaval)
123 return -ENOMEM; 123 return -ENOMEM;
124 124
@@ -240,10 +240,10 @@ static int ife_validate_metatype(struct tcf_meta_ops *ops, void *val, int len)
240} 240}
241 241
242/* called when adding new meta information 242/* called when adding new meta information
243 * under ife->tcf_lock 243 * under ife->tcf_lock for existing action
244*/ 244*/
245static int load_metaops_and_vet(struct tcf_ife_info *ife, u32 metaid, 245static int load_metaops_and_vet(struct tcf_ife_info *ife, u32 metaid,
246 void *val, int len) 246 void *val, int len, bool exists)
247{ 247{
248 struct tcf_meta_ops *ops = find_ife_oplist(metaid); 248 struct tcf_meta_ops *ops = find_ife_oplist(metaid);
249 int ret = 0; 249 int ret = 0;
@@ -251,11 +251,13 @@ static int load_metaops_and_vet(struct tcf_ife_info *ife, u32 metaid,
251 if (!ops) { 251 if (!ops) {
252 ret = -ENOENT; 252 ret = -ENOENT;
253#ifdef CONFIG_MODULES 253#ifdef CONFIG_MODULES
254 spin_unlock_bh(&ife->tcf_lock); 254 if (exists)
255 spin_unlock_bh(&ife->tcf_lock);
255 rtnl_unlock(); 256 rtnl_unlock();
256 request_module("ifemeta%u", metaid); 257 request_module("ifemeta%u", metaid);
257 rtnl_lock(); 258 rtnl_lock();
258 spin_lock_bh(&ife->tcf_lock); 259 if (exists)
260 spin_lock_bh(&ife->tcf_lock);
259 ops = find_ife_oplist(metaid); 261 ops = find_ife_oplist(metaid);
260#endif 262#endif
261 } 263 }
@@ -272,10 +274,10 @@ static int load_metaops_and_vet(struct tcf_ife_info *ife, u32 metaid,
272} 274}
273 275
274/* called when adding new meta information 276/* called when adding new meta information
275 * under ife->tcf_lock 277 * under ife->tcf_lock for existing action
276*/ 278*/
277static int add_metainfo(struct tcf_ife_info *ife, u32 metaid, void *metaval, 279static int add_metainfo(struct tcf_ife_info *ife, u32 metaid, void *metaval,
278 int len) 280 int len, bool atomic)
279{ 281{
280 struct tcf_meta_info *mi = NULL; 282 struct tcf_meta_info *mi = NULL;
281 struct tcf_meta_ops *ops = find_ife_oplist(metaid); 283 struct tcf_meta_ops *ops = find_ife_oplist(metaid);
@@ -284,7 +286,7 @@ static int add_metainfo(struct tcf_ife_info *ife, u32 metaid, void *metaval,
284 if (!ops) 286 if (!ops)
285 return -ENOENT; 287 return -ENOENT;
286 288
287 mi = kzalloc(sizeof(*mi), GFP_KERNEL); 289 mi = kzalloc(sizeof(*mi), atomic ? GFP_ATOMIC : GFP_KERNEL);
288 if (!mi) { 290 if (!mi) {
289 /*put back what find_ife_oplist took */ 291 /*put back what find_ife_oplist took */
290 module_put(ops->owner); 292 module_put(ops->owner);
@@ -294,7 +296,7 @@ static int add_metainfo(struct tcf_ife_info *ife, u32 metaid, void *metaval,
294 mi->metaid = metaid; 296 mi->metaid = metaid;
295 mi->ops = ops; 297 mi->ops = ops;
296 if (len > 0) { 298 if (len > 0) {
297 ret = ops->alloc(mi, metaval); 299 ret = ops->alloc(mi, metaval, atomic ? GFP_ATOMIC : GFP_KERNEL);
298 if (ret != 0) { 300 if (ret != 0) {
299 kfree(mi); 301 kfree(mi);
300 module_put(ops->owner); 302 module_put(ops->owner);
@@ -313,11 +315,13 @@ static int use_all_metadata(struct tcf_ife_info *ife)
313 int rc = 0; 315 int rc = 0;
314 int installed = 0; 316 int installed = 0;
315 317
318 read_lock(&ife_mod_lock);
316 list_for_each_entry(o, &ifeoplist, list) { 319 list_for_each_entry(o, &ifeoplist, list) {
317 rc = add_metainfo(ife, o->metaid, NULL, 0); 320 rc = add_metainfo(ife, o->metaid, NULL, 0, true);
318 if (rc == 0) 321 if (rc == 0)
319 installed += 1; 322 installed += 1;
320 } 323 }
324 read_unlock(&ife_mod_lock);
321 325
322 if (installed) 326 if (installed)
323 return 0; 327 return 0;
@@ -385,8 +389,9 @@ static void tcf_ife_cleanup(struct tc_action *a, int bind)
385 spin_unlock_bh(&ife->tcf_lock); 389 spin_unlock_bh(&ife->tcf_lock);
386} 390}
387 391
388/* under ife->tcf_lock */ 392/* under ife->tcf_lock for existing action */
389static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb) 393static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb,
394 bool exists)
390{ 395{
391 int len = 0; 396 int len = 0;
392 int rc = 0; 397 int rc = 0;
@@ -398,11 +403,11 @@ static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb)
398 val = nla_data(tb[i]); 403 val = nla_data(tb[i]);
399 len = nla_len(tb[i]); 404 len = nla_len(tb[i]);
400 405
401 rc = load_metaops_and_vet(ife, i, val, len); 406 rc = load_metaops_and_vet(ife, i, val, len, exists);
402 if (rc != 0) 407 if (rc != 0)
403 return rc; 408 return rc;
404 409
405 rc = add_metainfo(ife, i, val, len); 410 rc = add_metainfo(ife, i, val, len, exists);
406 if (rc) 411 if (rc)
407 return rc; 412 return rc;
408 } 413 }
@@ -474,7 +479,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
474 saddr = nla_data(tb[TCA_IFE_SMAC]); 479 saddr = nla_data(tb[TCA_IFE_SMAC]);
475 } 480 }
476 481
477 spin_lock_bh(&ife->tcf_lock); 482 if (exists)
483 spin_lock_bh(&ife->tcf_lock);
478 ife->tcf_action = parm->action; 484 ife->tcf_action = parm->action;
479 485
480 if (parm->flags & IFE_ENCODE) { 486 if (parm->flags & IFE_ENCODE) {
@@ -504,11 +510,12 @@ metadata_parse_err:
504 if (ret == ACT_P_CREATED) 510 if (ret == ACT_P_CREATED)
505 _tcf_ife_cleanup(a, bind); 511 _tcf_ife_cleanup(a, bind);
506 512
507 spin_unlock_bh(&ife->tcf_lock); 513 if (exists)
514 spin_unlock_bh(&ife->tcf_lock);
508 return err; 515 return err;
509 } 516 }
510 517
511 err = populate_metalist(ife, tb2); 518 err = populate_metalist(ife, tb2, exists);
512 if (err) 519 if (err)
513 goto metadata_parse_err; 520 goto metadata_parse_err;
514 521
@@ -523,12 +530,14 @@ metadata_parse_err:
523 if (ret == ACT_P_CREATED) 530 if (ret == ACT_P_CREATED)
524 _tcf_ife_cleanup(a, bind); 531 _tcf_ife_cleanup(a, bind);
525 532
526 spin_unlock_bh(&ife->tcf_lock); 533 if (exists)
534 spin_unlock_bh(&ife->tcf_lock);
527 return err; 535 return err;
528 } 536 }
529 } 537 }
530 538
531 spin_unlock_bh(&ife->tcf_lock); 539 if (exists)
540 spin_unlock_bh(&ife->tcf_lock);
532 541
533 if (ret == ACT_P_CREATED) 542 if (ret == ACT_P_CREATED)
534 tcf_hash_insert(tn, a); 543 tcf_hash_insert(tn, a);
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 9f002ada7074..d4bd19ee5822 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -121,10 +121,13 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
121 } 121 }
122 122
123 td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); 123 td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]);
124 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) 124 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) {
125 if (exists)
126 tcf_hash_release(a, bind);
125 return -EINVAL; 127 return -EINVAL;
128 }
126 129
127 if (!tcf_hash_check(tn, index, a, bind)) { 130 if (!exists) {
128 ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind, 131 ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind,
129 false); 132 false);
130 if (ret) 133 if (ret)
diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
index 2177eac0a61e..2e4bd2c0a50c 100644
--- a/net/sched/sch_fifo.c
+++ b/net/sched/sch_fifo.c
@@ -37,14 +37,18 @@ static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch)
37 37
38static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch) 38static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch)
39{ 39{
40 unsigned int prev_backlog;
41
40 if (likely(skb_queue_len(&sch->q) < sch->limit)) 42 if (likely(skb_queue_len(&sch->q) < sch->limit))
41 return qdisc_enqueue_tail(skb, sch); 43 return qdisc_enqueue_tail(skb, sch);
42 44
45 prev_backlog = sch->qstats.backlog;
43 /* queue full, remove one skb to fulfill the limit */ 46 /* queue full, remove one skb to fulfill the limit */
44 __qdisc_queue_drop_head(sch, &sch->q); 47 __qdisc_queue_drop_head(sch, &sch->q);
45 qdisc_qstats_drop(sch); 48 qdisc_qstats_drop(sch);
46 qdisc_enqueue_tail(skb, sch); 49 qdisc_enqueue_tail(skb, sch);
47 50
51 qdisc_tree_reduce_backlog(sch, 0, prev_backlog - sch->qstats.backlog);
48 return NET_XMIT_CN; 52 return NET_XMIT_CN;
49} 53}
50 54
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index d4b4218af6b1..62f9d8100c6e 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1007,7 +1007,9 @@ static void htb_work_func(struct work_struct *work)
1007 struct htb_sched *q = container_of(work, struct htb_sched, work); 1007 struct htb_sched *q = container_of(work, struct htb_sched, work);
1008 struct Qdisc *sch = q->watchdog.qdisc; 1008 struct Qdisc *sch = q->watchdog.qdisc;
1009 1009
1010 rcu_read_lock();
1010 __netif_schedule(qdisc_root(sch)); 1011 __netif_schedule(qdisc_root(sch));
1012 rcu_read_unlock();
1011} 1013}
1012 1014
1013static int htb_init(struct Qdisc *sch, struct nlattr *opt) 1015static int htb_init(struct Qdisc *sch, struct nlattr *opt)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 205bed00dd34..178f1630a036 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -650,14 +650,14 @@ deliver:
650#endif 650#endif
651 651
652 if (q->qdisc) { 652 if (q->qdisc) {
653 unsigned int pkt_len = qdisc_pkt_len(skb);
653 int err = qdisc_enqueue(skb, q->qdisc); 654 int err = qdisc_enqueue(skb, q->qdisc);
654 655
655 if (unlikely(err != NET_XMIT_SUCCESS)) { 656 if (err != NET_XMIT_SUCCESS &&
656 if (net_xmit_drop_count(err)) { 657 net_xmit_drop_count(err)) {
657 qdisc_qstats_drop(sch); 658 qdisc_qstats_drop(sch);
658 qdisc_tree_reduce_backlog(sch, 1, 659 qdisc_tree_reduce_backlog(sch, 1,
659 qdisc_pkt_len(skb)); 660 pkt_len);
660 }
661 } 661 }
662 goto tfifo_dequeue; 662 goto tfifo_dequeue;
663 } 663 }
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 4b0a82191bc4..a356450b747b 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -172,8 +172,9 @@ prio_destroy(struct Qdisc *sch)
172static int prio_tune(struct Qdisc *sch, struct nlattr *opt) 172static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
173{ 173{
174 struct prio_sched_data *q = qdisc_priv(sch); 174 struct prio_sched_data *q = qdisc_priv(sch);
175 struct Qdisc *queues[TCQ_PRIO_BANDS];
176 int oldbands = q->bands, i;
175 struct tc_prio_qopt *qopt; 177 struct tc_prio_qopt *qopt;
176 int i;
177 178
178 if (nla_len(opt) < sizeof(*qopt)) 179 if (nla_len(opt) < sizeof(*qopt))
179 return -EINVAL; 180 return -EINVAL;
@@ -187,62 +188,42 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
187 return -EINVAL; 188 return -EINVAL;
188 } 189 }
189 190
191 /* Before commit, make sure we can allocate all new qdiscs */
192 for (i = oldbands; i < qopt->bands; i++) {
193 queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
194 TC_H_MAKE(sch->handle, i + 1));
195 if (!queues[i]) {
196 while (i > oldbands)
197 qdisc_destroy(queues[--i]);
198 return -ENOMEM;
199 }
200 }
201
190 sch_tree_lock(sch); 202 sch_tree_lock(sch);
191 q->bands = qopt->bands; 203 q->bands = qopt->bands;
192 memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1); 204 memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);
193 205
194 for (i = q->bands; i < TCQ_PRIO_BANDS; i++) { 206 for (i = q->bands; i < oldbands; i++) {
195 struct Qdisc *child = q->queues[i]; 207 struct Qdisc *child = q->queues[i];
196 q->queues[i] = &noop_qdisc;
197 if (child != &noop_qdisc) {
198 qdisc_tree_reduce_backlog(child, child->q.qlen, child->qstats.backlog);
199 qdisc_destroy(child);
200 }
201 }
202 sch_tree_unlock(sch);
203 208
204 for (i = 0; i < q->bands; i++) { 209 qdisc_tree_reduce_backlog(child, child->q.qlen,
205 if (q->queues[i] == &noop_qdisc) { 210 child->qstats.backlog);
206 struct Qdisc *child, *old; 211 qdisc_destroy(child);
207
208 child = qdisc_create_dflt(sch->dev_queue,
209 &pfifo_qdisc_ops,
210 TC_H_MAKE(sch->handle, i + 1));
211 if (child) {
212 sch_tree_lock(sch);
213 old = q->queues[i];
214 q->queues[i] = child;
215
216 if (old != &noop_qdisc) {
217 qdisc_tree_reduce_backlog(old,
218 old->q.qlen,
219 old->qstats.backlog);
220 qdisc_destroy(old);
221 }
222 sch_tree_unlock(sch);
223 }
224 }
225 } 212 }
213
214 for (i = oldbands; i < q->bands; i++)
215 q->queues[i] = queues[i];
216
217 sch_tree_unlock(sch);
226 return 0; 218 return 0;
227} 219}
228 220
229static int prio_init(struct Qdisc *sch, struct nlattr *opt) 221static int prio_init(struct Qdisc *sch, struct nlattr *opt)
230{ 222{
231 struct prio_sched_data *q = qdisc_priv(sch); 223 if (!opt)
232 int i;
233
234 for (i = 0; i < TCQ_PRIO_BANDS; i++)
235 q->queues[i] = &noop_qdisc;
236
237 if (opt == NULL) {
238 return -EINVAL; 224 return -EINVAL;
239 } else {
240 int err;
241 225
242 if ((err = prio_tune(sch, opt)) != 0) 226 return prio_tune(sch, opt);
243 return err;
244 }
245 return 0;
246} 227}
247 228
248static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) 229static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index 1ce724b87618..f69edcf219e5 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -3,12 +3,6 @@
3#include <linux/sock_diag.h> 3#include <linux/sock_diag.h>
4#include <net/sctp/sctp.h> 4#include <net/sctp/sctp.h>
5 5
6extern void inet_diag_msg_common_fill(struct inet_diag_msg *r,
7 struct sock *sk);
8extern int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
9 struct inet_diag_msg *r, int ext,
10 struct user_namespace *user_ns);
11
12static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, 6static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
13 void *info); 7 void *info);
14 8
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 6f11c62bc8f9..bf8f05c3eb82 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -405,7 +405,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *skb,
405 return 0; 405 return 0;
406 406
407 /* Send RESET message even if bearer is detached from device */ 407 /* Send RESET message even if bearer is detached from device */
408 tipc_ptr = rtnl_dereference(dev->tipc_ptr); 408 tipc_ptr = rcu_dereference_rtnl(dev->tipc_ptr);
409 if (unlikely(!tipc_ptr && !msg_is_reset(buf_msg(skb)))) 409 if (unlikely(!tipc_ptr && !msg_is_reset(buf_msg(skb))))
410 goto drop; 410 goto drop;
411 411
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 7059c94f33c5..67b6ab9f4c8d 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -704,7 +704,8 @@ static void link_profile_stats(struct tipc_link *l)
704 */ 704 */
705int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq) 705int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
706{ 706{
707 int mtyp, rc = 0; 707 int mtyp = 0;
708 int rc = 0;
708 bool state = false; 709 bool state = false;
709 bool probe = false; 710 bool probe = false;
710 bool setup = false; 711 bool setup = false;
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 8740930f0787..17201aa8423d 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -41,6 +41,8 @@
41#include "name_table.h" 41#include "name_table.h"
42 42
43#define MAX_FORWARD_SIZE 1024 43#define MAX_FORWARD_SIZE 1024
44#define BUF_HEADROOM (LL_MAX_HEADER + 48)
45#define BUF_TAILROOM 16
44 46
45static unsigned int align(unsigned int i) 47static unsigned int align(unsigned int i)
46{ 48{
@@ -505,6 +507,10 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
505 msg_set_hdr_sz(hdr, BASIC_H_SIZE); 507 msg_set_hdr_sz(hdr, BASIC_H_SIZE);
506 } 508 }
507 509
510 if (skb_cloned(_skb) &&
511 pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_KERNEL))
512 goto exit;
513
508 /* Now reverse the concerned fields */ 514 /* Now reverse the concerned fields */
509 msg_set_errcode(hdr, err); 515 msg_set_errcode(hdr, err);
510 msg_set_origport(hdr, msg_destport(&ohdr)); 516 msg_set_origport(hdr, msg_destport(&ohdr));
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 024da8af91f0..7cf52fb39bee 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -94,17 +94,6 @@ struct plist;
94 94
95#define TIPC_MEDIA_INFO_OFFSET 5 95#define TIPC_MEDIA_INFO_OFFSET 5
96 96
97/**
98 * TIPC message buffer code
99 *
100 * TIPC message buffer headroom reserves space for the worst-case
101 * link-level device header (in case the message is sent off-node).
102 *
103 * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
104 * are word aligned for quicker access
105 */
106#define BUF_HEADROOM (LL_MAX_HEADER + 48)
107
108struct tipc_skb_cb { 97struct tipc_skb_cb {
109 void *handle; 98 void *handle;
110 struct sk_buff *tail; 99 struct sk_buff *tail;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 88bfcd707064..c49b8df438cb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -796,9 +796,11 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
796 * @tsk: receiving socket 796 * @tsk: receiving socket
797 * @skb: pointer to message buffer. 797 * @skb: pointer to message buffer.
798 */ 798 */
799static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb) 799static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
800 struct sk_buff_head *xmitq)
800{ 801{
801 struct sock *sk = &tsk->sk; 802 struct sock *sk = &tsk->sk;
803 u32 onode = tsk_own_node(tsk);
802 struct tipc_msg *hdr = buf_msg(skb); 804 struct tipc_msg *hdr = buf_msg(skb);
803 int mtyp = msg_type(hdr); 805 int mtyp = msg_type(hdr);
804 bool conn_cong; 806 bool conn_cong;
@@ -811,7 +813,8 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb)
811 813
812 if (mtyp == CONN_PROBE) { 814 if (mtyp == CONN_PROBE) {
813 msg_set_type(hdr, CONN_PROBE_REPLY); 815 msg_set_type(hdr, CONN_PROBE_REPLY);
814 tipc_sk_respond(sk, skb, TIPC_OK); 816 if (tipc_msg_reverse(onode, &skb, TIPC_OK))
817 __skb_queue_tail(xmitq, skb);
815 return; 818 return;
816 } else if (mtyp == CONN_ACK) { 819 } else if (mtyp == CONN_ACK) {
817 conn_cong = tsk_conn_cong(tsk); 820 conn_cong = tsk_conn_cong(tsk);
@@ -1686,7 +1689,8 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *skb)
1686 * 1689 *
1687 * Returns true if message was added to socket receive queue, otherwise false 1690 * Returns true if message was added to socket receive queue, otherwise false
1688 */ 1691 */
1689static bool filter_rcv(struct sock *sk, struct sk_buff *skb) 1692static bool filter_rcv(struct sock *sk, struct sk_buff *skb,
1693 struct sk_buff_head *xmitq)
1690{ 1694{
1691 struct socket *sock = sk->sk_socket; 1695 struct socket *sock = sk->sk_socket;
1692 struct tipc_sock *tsk = tipc_sk(sk); 1696 struct tipc_sock *tsk = tipc_sk(sk);
@@ -1696,7 +1700,7 @@ static bool filter_rcv(struct sock *sk, struct sk_buff *skb)
1696 int usr = msg_user(hdr); 1700 int usr = msg_user(hdr);
1697 1701
1698 if (unlikely(msg_user(hdr) == CONN_MANAGER)) { 1702 if (unlikely(msg_user(hdr) == CONN_MANAGER)) {
1699 tipc_sk_proto_rcv(tsk, skb); 1703 tipc_sk_proto_rcv(tsk, skb, xmitq);
1700 return false; 1704 return false;
1701 } 1705 }
1702 1706
@@ -1739,7 +1743,8 @@ static bool filter_rcv(struct sock *sk, struct sk_buff *skb)
1739 return true; 1743 return true;
1740 1744
1741reject: 1745reject:
1742 tipc_sk_respond(sk, skb, err); 1746 if (tipc_msg_reverse(tsk_own_node(tsk), &skb, err))
1747 __skb_queue_tail(xmitq, skb);
1743 return false; 1748 return false;
1744} 1749}
1745 1750
@@ -1755,9 +1760,24 @@ reject:
1755static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) 1760static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
1756{ 1761{
1757 unsigned int truesize = skb->truesize; 1762 unsigned int truesize = skb->truesize;
1763 struct sk_buff_head xmitq;
1764 u32 dnode, selector;
1758 1765
1759 if (likely(filter_rcv(sk, skb))) 1766 __skb_queue_head_init(&xmitq);
1767
1768 if (likely(filter_rcv(sk, skb, &xmitq))) {
1760 atomic_add(truesize, &tipc_sk(sk)->dupl_rcvcnt); 1769 atomic_add(truesize, &tipc_sk(sk)->dupl_rcvcnt);
1770 return 0;
1771 }
1772
1773 if (skb_queue_empty(&xmitq))
1774 return 0;
1775
1776 /* Send response/rejected message */
1777 skb = __skb_dequeue(&xmitq);
1778 dnode = msg_destnode(buf_msg(skb));
1779 selector = msg_origport(buf_msg(skb));
1780 tipc_node_xmit_skb(sock_net(sk), skb, dnode, selector);
1761 return 0; 1781 return 0;
1762} 1782}
1763 1783
@@ -1771,12 +1791,13 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
1771 * Caller must hold socket lock 1791 * Caller must hold socket lock
1772 */ 1792 */
1773static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk, 1793static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
1774 u32 dport) 1794 u32 dport, struct sk_buff_head *xmitq)
1775{ 1795{
1796 unsigned long time_limit = jiffies + 2;
1797 struct sk_buff *skb;
1776 unsigned int lim; 1798 unsigned int lim;
1777 atomic_t *dcnt; 1799 atomic_t *dcnt;
1778 struct sk_buff *skb; 1800 u32 onode;
1779 unsigned long time_limit = jiffies + 2;
1780 1801
1781 while (skb_queue_len(inputq)) { 1802 while (skb_queue_len(inputq)) {
1782 if (unlikely(time_after_eq(jiffies, time_limit))) 1803 if (unlikely(time_after_eq(jiffies, time_limit)))
@@ -1788,7 +1809,7 @@ static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
1788 1809
1789 /* Add message directly to receive queue if possible */ 1810 /* Add message directly to receive queue if possible */
1790 if (!sock_owned_by_user(sk)) { 1811 if (!sock_owned_by_user(sk)) {
1791 filter_rcv(sk, skb); 1812 filter_rcv(sk, skb, xmitq);
1792 continue; 1813 continue;
1793 } 1814 }
1794 1815
@@ -1801,7 +1822,9 @@ static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
1801 continue; 1822 continue;
1802 1823
1803 /* Overload => reject message back to sender */ 1824 /* Overload => reject message back to sender */
1804 tipc_sk_respond(sk, skb, TIPC_ERR_OVERLOAD); 1825 onode = tipc_own_addr(sock_net(sk));
1826 if (tipc_msg_reverse(onode, &skb, TIPC_ERR_OVERLOAD))
1827 __skb_queue_tail(xmitq, skb);
1805 break; 1828 break;
1806 } 1829 }
1807} 1830}
@@ -1814,12 +1837,14 @@ static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
1814 */ 1837 */
1815void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq) 1838void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq)
1816{ 1839{
1840 struct sk_buff_head xmitq;
1817 u32 dnode, dport = 0; 1841 u32 dnode, dport = 0;
1818 int err; 1842 int err;
1819 struct tipc_sock *tsk; 1843 struct tipc_sock *tsk;
1820 struct sock *sk; 1844 struct sock *sk;
1821 struct sk_buff *skb; 1845 struct sk_buff *skb;
1822 1846
1847 __skb_queue_head_init(&xmitq);
1823 while (skb_queue_len(inputq)) { 1848 while (skb_queue_len(inputq)) {
1824 dport = tipc_skb_peek_port(inputq, dport); 1849 dport = tipc_skb_peek_port(inputq, dport);
1825 tsk = tipc_sk_lookup(net, dport); 1850 tsk = tipc_sk_lookup(net, dport);
@@ -1827,9 +1852,14 @@ void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq)
1827 if (likely(tsk)) { 1852 if (likely(tsk)) {
1828 sk = &tsk->sk; 1853 sk = &tsk->sk;
1829 if (likely(spin_trylock_bh(&sk->sk_lock.slock))) { 1854 if (likely(spin_trylock_bh(&sk->sk_lock.slock))) {
1830 tipc_sk_enqueue(inputq, sk, dport); 1855 tipc_sk_enqueue(inputq, sk, dport, &xmitq);
1831 spin_unlock_bh(&sk->sk_lock.slock); 1856 spin_unlock_bh(&sk->sk_lock.slock);
1832 } 1857 }
1858 /* Send pending response/rejected messages, if any */
1859 while ((skb = __skb_dequeue(&xmitq))) {
1860 dnode = msg_destnode(buf_msg(skb));
1861 tipc_node_xmit_skb(net, skb, dnode, dport);
1862 }
1833 sock_put(sk); 1863 sock_put(sk);
1834 continue; 1864 continue;
1835 } 1865 }
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index b5f1221f48d4..b96ac918e0ba 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -61,6 +61,14 @@
61 * function will also cleanup rejected sockets, those that reach the connected 61 * function will also cleanup rejected sockets, those that reach the connected
62 * state but leave it before they have been accepted. 62 * state but leave it before they have been accepted.
63 * 63 *
64 * - Lock ordering for pending or accept queue sockets is:
65 *
66 * lock_sock(listener);
67 * lock_sock_nested(pending, SINGLE_DEPTH_NESTING);
68 *
69 * Using explicit nested locking keeps lockdep happy since normally only one
70 * lock of a given class may be taken at a time.
71 *
64 * - Sockets created by user action will be cleaned up when the user process 72 * - Sockets created by user action will be cleaned up when the user process
65 * calls close(2), causing our release implementation to be called. Our release 73 * calls close(2), causing our release implementation to be called. Our release
66 * implementation will perform some cleanup then drop the last reference so our 74 * implementation will perform some cleanup then drop the last reference so our
@@ -443,7 +451,7 @@ void vsock_pending_work(struct work_struct *work)
443 cleanup = true; 451 cleanup = true;
444 452
445 lock_sock(listener); 453 lock_sock(listener);
446 lock_sock(sk); 454 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
447 455
448 if (vsock_is_pending(sk)) { 456 if (vsock_is_pending(sk)) {
449 vsock_remove_pending(listener, sk); 457 vsock_remove_pending(listener, sk);
@@ -1292,7 +1300,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags)
1292 if (connected) { 1300 if (connected) {
1293 listener->sk_ack_backlog--; 1301 listener->sk_ack_backlog--;
1294 1302
1295 lock_sock(connected); 1303 lock_sock_nested(connected, SINGLE_DEPTH_NESTING);
1296 vconnected = vsock_sk(connected); 1304 vconnected = vsock_sk(connected);
1297 1305
1298 /* If the listener socket has received an error, then we should 1306 /* If the listener socket has received an error, then we should
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 4e809e978b7d..2443ee30ba5b 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -509,7 +509,7 @@ static int __ieee80211_data_to_8023(struct sk_buff *skb, struct ethhdr *ehdr,
509 * replace EtherType */ 509 * replace EtherType */
510 hdrlen += ETH_ALEN + 2; 510 hdrlen += ETH_ALEN + 2;
511 else 511 else
512 tmp.h_proto = htons(skb->len); 512 tmp.h_proto = htons(skb->len - hdrlen);
513 513
514 pskb_pull(skb, hdrlen); 514 pskb_pull(skb, hdrlen);
515 515