summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-11-04 05:32:04 -0500
committerThomas Gleixner <tglx@linutronix.de>2019-11-04 05:32:04 -0500
commitca8888d7ae6fa18454c9e4f192c56bc6c8ca9b33 (patch)
treec2b86b162f8fc2adf8a98f7e074500bee155d603
parentdb616173d787395787ecc93eef075fa975227b10 (diff)
parenta99d8080aaf358d5d23581244e5da23b35e340b9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
to pick up the KVM fix which is required for the NX series.
-rw-r--r--Documentation/arm64/silicon-errata.rst7
-rw-r--r--Documentation/networking/device_drivers/intel/e100.rst14
-rw-r--r--Documentation/networking/device_drivers/intel/e1000.rst12
-rw-r--r--Documentation/networking/device_drivers/intel/e1000e.rst14
-rw-r--r--Documentation/networking/device_drivers/intel/fm10k.rst10
-rw-r--r--Documentation/networking/device_drivers/intel/i40e.rst8
-rw-r--r--Documentation/networking/device_drivers/intel/iavf.rst8
-rw-r--r--Documentation/networking/device_drivers/intel/ice.rst6
-rw-r--r--Documentation/networking/device_drivers/intel/igb.rst12
-rw-r--r--Documentation/networking/device_drivers/intel/igbvf.rst6
-rw-r--r--Documentation/networking/device_drivers/intel/ixgbe.rst10
-rw-r--r--Documentation/networking/device_drivers/intel/ixgbevf.rst6
-rw-r--r--Documentation/networking/device_drivers/pensando/ionic.rst6
-rw-r--r--Documentation/networking/ip-sysctl.txt11
-rw-r--r--MAINTAINERS7
-rw-r--r--Makefile2
-rw-r--r--arch/arc/boot/dts/hsdk.dts23
-rw-r--r--arch/arc/configs/hsdk_defconfig6
-rw-r--r--arch/arc/kernel/perf_event.c4
-rw-r--r--arch/arm64/include/asm/cputype.h2
-rw-r--r--arch/arm64/include/asm/pgtable-prot.h15
-rw-r--r--arch/arm64/kernel/cpu_errata.c59
-rw-r--r--arch/parisc/kernel/entry.S2
-rw-r--r--arch/powerpc/include/asm/book3s/32/kup.h1
-rw-r--r--arch/powerpc/include/asm/elf.h3
-rw-r--r--arch/powerpc/kernel/prom_init.c13
-rw-r--r--arch/powerpc/kernel/prom_init_check.sh3
-rw-r--r--arch/powerpc/platforms/powernv/eeh-powernv.c2
-rw-r--r--arch/powerpc/platforms/powernv/smp.c53
-rw-r--r--arch/riscv/include/asm/io.h7
-rw-r--r--arch/riscv/include/asm/irq.h3
-rw-r--r--arch/riscv/include/asm/pgtable.h7
-rw-r--r--arch/riscv/include/asm/switch_to.h1
-rw-r--r--arch/riscv/kernel/cpufeature.c1
-rw-r--r--arch/riscv/kernel/head.h21
-rw-r--r--arch/riscv/kernel/irq.c2
-rw-r--r--arch/riscv/kernel/module-sections.c1
-rw-r--r--arch/riscv/kernel/process.c2
-rw-r--r--arch/riscv/kernel/ptrace.c4
-rw-r--r--arch/riscv/kernel/reset.c1
-rw-r--r--arch/riscv/kernel/setup.c2
-rw-r--r--arch/riscv/kernel/signal.c8
-rw-r--r--arch/riscv/kernel/smp.c2
-rw-r--r--arch/riscv/kernel/smpboot.c5
-rw-r--r--arch/riscv/kernel/syscall_table.c1
-rw-r--r--arch/riscv/kernel/time.c1
-rw-r--r--arch/riscv/kernel/traps.c5
-rw-r--r--arch/riscv/kernel/vdso.c3
-rw-r--r--arch/riscv/mm/context.c1
-rw-r--r--arch/riscv/mm/fault.c2
-rw-r--r--arch/riscv/mm/init.c5
-rw-r--r--arch/riscv/mm/sifive_l2_cache.c2
-rw-r--r--arch/s390/include/asm/unwind.h1
-rw-r--r--arch/s390/kernel/idle.c29
-rw-r--r--arch/s390/kernel/unwind_bc.c18
-rw-r--r--arch/s390/mm/cmm.c12
-rw-r--r--arch/um/drivers/ubd_kern.c8
-rw-r--r--arch/x86/boot/compressed/eboot.c4
-rw-r--r--arch/x86/events/amd/ibs.c8
-rw-r--r--arch/x86/events/intel/uncore.c44
-rw-r--r--arch/x86/events/intel/uncore.h12
-rw-r--r--arch/x86/kvm/svm.c10
-rw-r--r--arch/x86/kvm/vmx/vmx.c14
-rw-r--r--block/blk-iocost.c4
-rw-r--r--drivers/acpi/processor_perflib.c34
-rw-r--r--drivers/acpi/processor_thermal.c34
-rw-r--r--drivers/crypto/chelsio/chtls/chtls_cm.c2
-rw-r--r--drivers/crypto/chelsio/chtls/chtls_io.c2
-rw-r--r--drivers/dma/imx-sdma.c8
-rw-r--r--drivers/dma/qcom/bam_dma.c19
-rw-r--r--drivers/dma/sprd-dma.c27
-rw-r--r--drivers/dma/tegra210-adma.c7
-rw-r--r--drivers/dma/ti/cppi41.c21
-rw-r--r--drivers/dma/xilinx/xilinx_dma.c10
-rw-r--r--drivers/firmware/efi/Kconfig1
-rw-r--r--drivers/firmware/efi/efi.c2
-rw-r--r--drivers/firmware/efi/libstub/Makefile1
-rw-r--r--drivers/firmware/efi/libstub/arm32-stub.c16
-rw-r--r--drivers/firmware/efi/libstub/efi-stub-helper.c24
-rw-r--r--drivers/firmware/efi/test/efi_test.c8
-rw-r--r--drivers/firmware/efi/tpm.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_job.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c1
-rw-r--r--drivers/gpu/drm/amd/display/dc/calcs/Makefile19
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc.c4
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link.c9
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c24
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_resource.c6
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c22
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/Makefile19
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c2
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn21/Makefile19
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml/Makefile19
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c3
-rw-r--r--drivers/gpu/drm/amd/display/dc/dsc/Makefile19
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c4
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_dump.c4
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c6
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_mmu.c17
-rw-r--r--drivers/gpu/drm/i915/display/intel_display.c11
-rw-r--r--drivers/gpu/drm/i915/display/intel_dpll_mgr.c15
-rw-r--r--drivers/gpu/drm/i915/display/intel_dpll_mgr.h4
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_drv.c2
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_mmu.c15
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_perfcnt.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c14
-rw-r--r--drivers/gpu/drm/scheduler/sched_main.c19
-rw-r--r--drivers/gpu/drm/v3d/v3d_gem.c5
-rw-r--r--drivers/hid/hid-axff.c11
-rw-r--r--drivers/hid/hid-core.c7
-rw-r--r--drivers/hid/hid-dr.c12
-rw-r--r--drivers/hid/hid-emsff.c12
-rw-r--r--drivers/hid/hid-gaff.c12
-rw-r--r--drivers/hid/hid-google-hammer.c4
-rw-r--r--drivers/hid/hid-holtekff.c12
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-lg2ff.c12
-rw-r--r--drivers/hid/hid-lg3ff.c11
-rw-r--r--drivers/hid/hid-lg4ff.c11
-rw-r--r--drivers/hid/hid-lgff.c11
-rw-r--r--drivers/hid/hid-logitech-hidpp.c248
-rw-r--r--drivers/hid/hid-microsoft.c12
-rw-r--r--drivers/hid/hid-prodikeys.c4
-rw-r--r--drivers/hid/hid-sony.c12
-rw-r--r--drivers/hid/hid-tmff.c12
-rw-r--r--drivers/hid/hid-zpff.c12
-rw-r--r--drivers/hid/i2c-hid/i2c-hid-core.c118
-rw-r--r--drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c19
-rw-r--r--drivers/hid/intel-ish-hid/ishtp/client-buffers.c2
-rw-r--r--drivers/hwmon/ina3221.c2
-rw-r--r--drivers/hwmon/nct7904.c15
-rw-r--r--drivers/infiniband/core/core_priv.h1
-rw-r--r--drivers/infiniband/core/device.c2
-rw-r--r--drivers/infiniband/core/iwcm.c52
-rw-r--r--drivers/infiniband/core/netlink.c107
-rw-r--r--drivers/infiniband/core/nldev.c2
-rw-r--r--drivers/infiniband/core/uverbs.h2
-rw-r--r--drivers/infiniband/core/verbs.c9
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c30
-rw-r--r--drivers/infiniband/hw/hfi1/sdma.c5
-rw-r--r--drivers/infiniband/hw/hfi1/tid_rdma.c5
-rw-r--r--drivers/infiniband/hw/hfi1/verbs.c10
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_hw_v2.c6
-rw-r--r--drivers/infiniband/hw/mlx5/mr.c4
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c8
-rw-r--r--drivers/infiniband/hw/qedr/main.c2
-rw-r--r--drivers/infiniband/sw/siw/siw_qp.c2
-rw-r--r--drivers/infiniband/sw/siw/siw_verbs.c2
-rw-r--r--drivers/iommu/amd_iommu_quirks.c13
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--drivers/iommu/ipmmu-vmsa.c4
-rw-r--r--drivers/isdn/capi/capi.c2
-rw-r--r--drivers/net/bonding/bond_alb.c2
-rw-r--r--drivers/net/bonding/bond_main.c28
-rw-r--r--drivers/net/dsa/bcm_sf2.c36
-rw-r--r--drivers/net/dsa/sja1105/Kconfig4
-rw-r--r--drivers/net/ethernet/arc/emac_rockchip.c3
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c10
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c112
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h3
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c28
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c8
-rw-r--r--drivers/net/ethernet/cortina/gemini.h2
-rw-r--r--drivers/net/ethernet/faraday/ftgmac100.c25
-rw-r--r--drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h2
-rw-r--r--drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h2
-rw-r--r--drivers/net/ethernet/freescale/dpaa2/dprtc.h2
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c2
-rw-r--r--drivers/net/ethernet/freescale/fec_ptp.c4
-rw-r--r--drivers/net/ethernet/google/gve/gve_rx.c2
-rw-r--r--drivers/net/ethernet/google/gve/gve_tx.c24
-rw-r--r--drivers/net/ethernet/hisilicon/hip04_eth.c16
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_ethtool.c7
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_xsk.c5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c8
-rw-r--r--drivers/net/ethernet/intel/igc/igc_main.c3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c1
-rw-r--r--drivers/net/ethernet/marvell/mvneta_bm.h32
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c42
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h13
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h29
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c190
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.c16
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h10
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c36
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c35
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c4
-rw-r--r--drivers/net/ethernet/mscc/ocelot.c11
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_repr.c18
-rw-r--r--drivers/net/ethernet/pensando/ionic/ionic_lif.c2
-rw-r--r--drivers/net/ethernet/pensando/ionic/ionic_main.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_main.c27
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_sriov.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169_main.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c1
-rw-r--r--drivers/net/fjes/fjes_main.c15
-rw-r--r--drivers/net/hamradio/bpqether.c22
-rw-r--r--drivers/net/hyperv/netvsc_drv.c15
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c2
-rw-r--r--drivers/net/macsec.c18
-rw-r--r--drivers/net/macvlan.c19
-rw-r--r--drivers/net/netdevsim/dev.c5
-rw-r--r--drivers/net/phy/phylink.c16
-rw-r--r--drivers/net/phy/smsc.c1
-rw-r--r--drivers/net/ppp/ppp_generic.c2
-rw-r--r--drivers/net/team/team.c16
-rw-r--r--drivers/net/usb/cdc_ether.c7
-rw-r--r--drivers/net/usb/lan78xx.c5
-rw-r--r--drivers/net/usb/r8152.c1
-rw-r--r--drivers/net/vrf.c1
-rw-r--r--drivers/net/vxlan.c62
-rw-r--r--drivers/net/wimax/i2400m/op-rfkill.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/scan.h22
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/file.h3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-csr.h1
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-prph.h5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/scan.c40
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c140
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c131
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c25
-rw-r--r--drivers/net/wireless/intersil/hostap/hostap_hw.c25
-rw-r--r--drivers/net/wireless/mediatek/mt76/Makefile2
-rw-r--r--drivers/net/wireless/mediatek/mt76/dma.c6
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76.h6
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/pci.c2
-rw-r--r--drivers/net/wireless/mediatek/mt76/pci.c46
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/ps.c6
-rw-r--r--drivers/net/wireless/virt_wifi.c54
-rw-r--r--drivers/nvme/host/multipath.c9
-rw-r--r--drivers/nvme/host/tcp.c2
-rw-r--r--drivers/pwm/core.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c4
-rw-r--r--drivers/scsi/sd.c3
-rw-r--r--drivers/scsi/ufs/ufs_bsg.c4
-rw-r--r--drivers/target/iscsi/cxgbit/cxgbit_cm.c3
-rw-r--r--drivers/usb/cdns3/gadget.c37
-rw-r--r--drivers/usb/cdns3/host-export.h1
-rw-r--r--drivers/usb/cdns3/host.c1
-rw-r--r--drivers/usb/core/config.c5
-rw-r--r--drivers/usb/dwc3/Kconfig1
-rw-r--r--drivers/usb/dwc3/core.c3
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/gadget.c6
-rw-r--r--drivers/usb/gadget/composite.c4
-rw-r--r--drivers/usb/gadget/configfs.c110
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c6
-rw-r--r--drivers/usb/gadget/udc/core.c11
-rw-r--r--drivers/usb/gadget/udc/fsl_udc_core.c2
-rw-r--r--drivers/usb/gadget/udc/renesas_usb3.c11
-rw-r--r--drivers/usb/host/xhci-debugfs.c24
-rw-r--r--drivers/usb/host/xhci-ring.c2
-rw-r--r--drivers/usb/host/xhci.c54
-rw-r--r--drivers/usb/misc/ldusb.c13
-rw-r--r--drivers/usb/mtu3/mtu3_core.c1
-rw-r--r--drivers/usb/renesas_usbhs/common.c12
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c4
-rw-r--r--drivers/usb/serial/whiteheat.c13
-rw-r--r--drivers/usb/serial/whiteheat.h2
-rw-r--r--drivers/usb/storage/scsiglue.c10
-rw-r--r--drivers/usb/storage/uas.c20
-rw-r--r--drivers/usb/usbip/vhci_tx.c3
-rw-r--r--drivers/vhost/vringh.c8
-rw-r--r--drivers/virtio/virtio_ring.c7
-rw-r--r--fs/cifs/smb2ops.c3
-rw-r--r--fs/fuse/Makefile3
-rw-r--r--fs/fuse/dev.c4
-rw-r--r--fs/fuse/dir.c16
-rw-r--r--fs/fuse/file.c14
-rw-r--r--fs/fuse/fuse_i.h4
-rw-r--r--fs/fuse/inode.c4
-rw-r--r--fs/fuse/virtio_fs.c169
-rw-r--r--fs/gfs2/ops_fstype.c20
-rw-r--r--fs/io_uring.c14
-rw-r--r--fs/nfs/delegation.c12
-rw-r--r--fs/nfs/delegation.h1
-rw-r--r--fs/nfs/nfs4proc.c7
-rw-r--r--include/linux/dynamic_debug.h6
-rw-r--r--include/linux/efi.h18
-rw-r--r--include/linux/filter.h1
-rw-r--r--include/linux/gfp.h23
-rw-r--r--include/linux/if_macvlan.h1
-rw-r--r--include/linux/if_team.h1
-rw-r--r--include/linux/if_vlan.h11
-rw-r--r--include/linux/mlx5/mlx5_ifc.h3
-rw-r--r--include/linux/netdevice.h61
-rw-r--r--include/linux/perf_event.h2
-rw-r--r--include/linux/platform_data/dma-imx-sdma.h3
-rw-r--r--include/linux/security.h1
-rw-r--r--include/linux/skbuff.h36
-rw-r--r--include/linux/socket.h2
-rw-r--r--include/linux/sunrpc/bc_xprt.h5
-rw-r--r--include/linux/virtio_vsock.h1
-rw-r--r--include/net/bonding.h2
-rw-r--r--include/net/busy_poll.h6
-rw-r--r--include/net/flow_dissector.h3
-rw-r--r--include/net/fq.h2
-rw-r--r--include/net/fq_impl.h4
-rw-r--r--include/net/hwbm.h10
-rw-r--r--include/net/ip.h4
-rw-r--r--include/net/ip_vs.h1
-rw-r--r--include/net/net_namespace.h2
-rw-r--r--include/net/sock.h15
-rw-r--r--include/net/vxlan.h1
-rw-r--r--include/rdma/ib_verbs.h2
-rw-r--r--include/uapi/linux/fuse.h37
-rw-r--r--kernel/bpf/core.c2
-rw-r--r--kernel/bpf/devmap.c33
-rw-r--r--kernel/bpf/syscall.c31
-rw-r--r--kernel/cgroup/cpuset.c3
-rw-r--r--kernel/events/core.c2
-rw-r--r--kernel/sched/topology.c11
-rw-r--r--net/8021q/vlan.c1
-rw-r--r--net/8021q/vlan_dev.c33
-rw-r--r--net/atm/common.c2
-rw-r--r--net/batman-adv/bat_iv_ogm.c61
-rw-r--r--net/batman-adv/bat_v_ogm.c41
-rw-r--r--net/batman-adv/hard-interface.c2
-rw-r--r--net/batman-adv/soft-interface.c32
-rw-r--r--net/batman-adv/types.h7
-rw-r--r--net/bluetooth/6lowpan.c8
-rw-r--r--net/bluetooth/af_bluetooth.c4
-rw-r--r--net/bridge/br_device.c8
-rw-r--r--net/bridge/netfilter/nf_conntrack_bridge.c2
-rw-r--r--net/caif/caif_socket.c2
-rw-r--r--net/core/datagram.c8
-rw-r--r--net/core/dev.c623
-rw-r--r--net/core/dev_addr_lists.c12
-rw-r--r--net/core/ethtool.c4
-rw-r--r--net/core/flow_dissector.c38
-rw-r--r--net/core/lwt_bpf.c7
-rw-r--r--net/core/net_namespace.c18
-rw-r--r--net/core/rtnetlink.c17
-rw-r--r--net/core/sock.c6
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/decnet/af_decnet.c2
-rw-r--r--net/dsa/master.c5
-rw-r--r--net/dsa/slave.c12
-rw-r--r--net/ieee802154/6lowpan/core.c8
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv4/ip_gre.c4
-rw-r--r--net/ipv4/ip_output.c11
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv4/tcp_ipv4.c6
-rw-r--r--net/ipv4/udp.c29
-rw-r--r--net/ipv6/addrconf_core.c1
-rw-r--r--net/ipv6/inet6_hashtables.c2
-rw-r--r--net/ipv6/ip6_gre.c4
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/l2tp/l2tp_eth.c1
-rw-r--r--net/netfilter/ipvs/ip_vs_app.c12
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c29
-rw-r--r--net/netfilter/ipvs/ip_vs_pe.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_sched.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c13
-rw-r--r--net/netfilter/nf_flow_table_core.c3
-rw-r--r--net/netfilter/nf_tables_offload.c2
-rw-r--r--net/netfilter/nft_payload.c38
-rw-r--r--net/netrom/af_netrom.c23
-rw-r--r--net/nfc/llcp_sock.c4
-rw-r--r--net/openvswitch/datapath.c20
-rw-r--r--net/openvswitch/vport-internal_dev.c11
-rw-r--r--net/phonet/socket.c4
-rw-r--r--net/rose/af_rose.c23
-rw-r--r--net/rxrpc/ar-internal.h1
-rw-r--r--net/rxrpc/recvmsg.c18
-rw-r--r--net/sched/cls_bpf.c8
-rw-r--r--net/sched/sch_generic.c19
-rw-r--r--net/sched/sch_hhf.c8
-rw-r--r--net/sched/sch_sfb.c13
-rw-r--r--net/sched/sch_sfq.c14
-rw-r--r--net/sched/sch_taprio.c2
-rw-r--r--net/sctp/socket.c8
-rw-r--r--net/smc/af_smc.c13
-rw-r--r--net/smc/smc_core.c2
-rw-r--r--net/smc/smc_pnet.c2
-rw-r--r--net/sunrpc/backchannel_rqst.c7
-rw-r--r--net/sunrpc/xprt.c5
-rw-r--r--net/sunrpc/xprtrdma/backchannel.c2
-rw-r--r--net/tipc/socket.c4
-rw-r--r--net/unix/af_unix.c6
-rw-r--r--net/vmw_vsock/af_vsock.c2
-rw-r--r--net/wireless/chan.c5
-rw-r--r--net/wireless/nl80211.c2
-rw-r--r--net/wireless/util.c3
-rw-r--r--net/xdp/xdp_umem.c6
-rw-r--r--security/lockdown/lockdown.c1
-rw-r--r--sound/core/timer.c24
-rw-r--r--sound/firewire/bebob/bebob_stream.c3
-rw-r--r--sound/hda/hdac_controller.c2
-rw-r--r--sound/pci/hda/hda_intel.c2
-rw-r--r--sound/pci/hda/patch_hdmi.c10
-rw-r--r--sound/pci/hda/patch_realtek.c11
-rw-r--r--sound/usb/quirks.c1
-rwxr-xr-xtools/testing/selftests/bpf/test_offload.py5
-rwxr-xr-xtools/testing/selftests/bpf/test_tc_edt.sh2
-rwxr-xr-xtools/testing/selftests/net/fib_tests.sh21
-rwxr-xr-x[-rw-r--r--]tools/testing/selftests/net/l2tp.sh0
-rw-r--r--tools/testing/selftests/net/reuseport_dualstack.c3
-rw-r--r--tools/usb/usbip/libsrc/usbip_device_driver.c6
-rw-r--r--virt/kvm/kvm_main.c48
429 files changed, 3953 insertions, 2194 deletions
diff --git a/Documentation/arm64/silicon-errata.rst b/Documentation/arm64/silicon-errata.rst
index ab7ed2fd072f..5a09661330fc 100644
--- a/Documentation/arm64/silicon-errata.rst
+++ b/Documentation/arm64/silicon-errata.rst
@@ -91,6 +91,11 @@ stable kernels.
91| ARM | MMU-500 | #841119,826419 | N/A | 91| ARM | MMU-500 | #841119,826419 | N/A |
92+----------------+-----------------+-----------------+-----------------------------+ 92+----------------+-----------------+-----------------+-----------------------------+
93+----------------+-----------------+-----------------+-----------------------------+ 93+----------------+-----------------+-----------------+-----------------------------+
94| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_845719 |
95+----------------+-----------------+-----------------+-----------------------------+
96| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_843419 |
97+----------------+-----------------+-----------------+-----------------------------+
98+----------------+-----------------+-----------------+-----------------------------+
94| Cavium | ThunderX ITS | #22375,24313 | CAVIUM_ERRATUM_22375 | 99| Cavium | ThunderX ITS | #22375,24313 | CAVIUM_ERRATUM_22375 |
95+----------------+-----------------+-----------------+-----------------------------+ 100+----------------+-----------------+-----------------+-----------------------------+
96| Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 | 101| Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 |
@@ -126,7 +131,7 @@ stable kernels.
126+----------------+-----------------+-----------------+-----------------------------+ 131+----------------+-----------------+-----------------+-----------------------------+
127| Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | 132| Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 |
128+----------------+-----------------+-----------------+-----------------------------+ 133+----------------+-----------------+-----------------+-----------------------------+
129| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | 134| Qualcomm Tech. | Kryo/Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
130+----------------+-----------------+-----------------+-----------------------------+ 135+----------------+-----------------+-----------------+-----------------------------+
131| Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 | 136| Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 |
132+----------------+-----------------+-----------------+-----------------------------+ 137+----------------+-----------------+-----------------+-----------------------------+
diff --git a/Documentation/networking/device_drivers/intel/e100.rst b/Documentation/networking/device_drivers/intel/e100.rst
index 2b9f4887beda..caf023cc88de 100644
--- a/Documentation/networking/device_drivers/intel/e100.rst
+++ b/Documentation/networking/device_drivers/intel/e100.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3============================================================== 3=============================================================
4Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters 4Linux Base Driver for the Intel(R) PRO/100 Family of Adapters
5============================================================== 5=============================================================
6 6
7June 1, 2018 7June 1, 2018
8 8
@@ -21,7 +21,7 @@ Contents
21In This Release 21In This Release
22=============== 22===============
23 23
24This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of 24This file describes the Linux Base Driver for the Intel(R) PRO/100 Family of
25Adapters. This driver includes support for Itanium(R)2-based systems. 25Adapters. This driver includes support for Itanium(R)2-based systems.
26 26
27For questions related to hardware requirements, refer to the documentation 27For questions related to hardware requirements, refer to the documentation
@@ -138,9 +138,9 @@ version 1.6 or later is required for this functionality.
138The latest release of ethtool can be found from 138The latest release of ethtool can be found from
139https://www.kernel.org/pub/software/network/ethtool/ 139https://www.kernel.org/pub/software/network/ethtool/
140 140
141Enabling Wake on LAN* (WoL) 141Enabling Wake on LAN (WoL)
142--------------------------- 142--------------------------
143WoL is provided through the ethtool* utility. For instructions on 143WoL is provided through the ethtool utility. For instructions on
144enabling WoL with ethtool, refer to the ethtool man page. WoL will be 144enabling WoL with ethtool, refer to the ethtool man page. WoL will be
145enabled on the system during the next shut down or reboot. For this 145enabled on the system during the next shut down or reboot. For this
146driver version, in order to enable WoL, the e100 driver must be loaded 146driver version, in order to enable WoL, the e100 driver must be loaded
diff --git a/Documentation/networking/device_drivers/intel/e1000.rst b/Documentation/networking/device_drivers/intel/e1000.rst
index 956560b6e745..4aaae0f7d6ba 100644
--- a/Documentation/networking/device_drivers/intel/e1000.rst
+++ b/Documentation/networking/device_drivers/intel/e1000.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3=========================================================== 3==========================================================
4Linux* Base Driver for Intel(R) Ethernet Network Connection 4Linux Base Driver for Intel(R) Ethernet Network Connection
5=========================================================== 5==========================================================
6 6
7Intel Gigabit Linux driver. 7Intel Gigabit Linux driver.
8Copyright(c) 1999 - 2013 Intel Corporation. 8Copyright(c) 1999 - 2013 Intel Corporation.
@@ -438,10 +438,10 @@ ethtool
438 The latest release of ethtool can be found from 438 The latest release of ethtool can be found from
439 https://www.kernel.org/pub/software/network/ethtool/ 439 https://www.kernel.org/pub/software/network/ethtool/
440 440
441Enabling Wake on LAN* (WoL) 441Enabling Wake on LAN (WoL)
442--------------------------- 442--------------------------
443 443
444 WoL is configured through the ethtool* utility. 444 WoL is configured through the ethtool utility.
445 445
446 WoL will be enabled on the system during the next shut down or reboot. 446 WoL will be enabled on the system during the next shut down or reboot.
447 For this driver version, in order to enable WoL, the e1000 driver must be 447 For this driver version, in order to enable WoL, the e1000 driver must be
diff --git a/Documentation/networking/device_drivers/intel/e1000e.rst b/Documentation/networking/device_drivers/intel/e1000e.rst
index 01999f05509c..f49cd370e7bf 100644
--- a/Documentation/networking/device_drivers/intel/e1000e.rst
+++ b/Documentation/networking/device_drivers/intel/e1000e.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3====================================================== 3=====================================================
4Linux* Driver for Intel(R) Ethernet Network Connection 4Linux Driver for Intel(R) Ethernet Network Connection
5====================================================== 5=====================================================
6 6
7Intel Gigabit Linux driver. 7Intel Gigabit Linux driver.
8Copyright(c) 2008-2018 Intel Corporation. 8Copyright(c) 2008-2018 Intel Corporation.
@@ -338,7 +338,7 @@ and higher cannot be forced. Use the autonegotiation advertising setting to
338manually set devices for 1 Gbps and higher. 338manually set devices for 1 Gbps and higher.
339 339
340Speed, duplex, and autonegotiation advertising are configured through the 340Speed, duplex, and autonegotiation advertising are configured through the
341ethtool* utility. 341ethtool utility.
342 342
343Caution: Only experienced network administrators should force speed and duplex 343Caution: Only experienced network administrators should force speed and duplex
344or change autonegotiation advertising manually. The settings at the switch must 344or change autonegotiation advertising manually. The settings at the switch must
@@ -351,9 +351,9 @@ will not attempt to auto-negotiate with its link partner since those adapters
351operate only in full duplex and only at their native speed. 351operate only in full duplex and only at their native speed.
352 352
353 353
354Enabling Wake on LAN* (WoL) 354Enabling Wake on LAN (WoL)
355--------------------------- 355--------------------------
356WoL is configured through the ethtool* utility. 356WoL is configured through the ethtool utility.
357 357
358WoL will be enabled on the system during the next shut down or reboot. For 358WoL will be enabled on the system during the next shut down or reboot. For
359this driver version, in order to enable WoL, the e1000e driver must be loaded 359this driver version, in order to enable WoL, the e1000e driver must be loaded
diff --git a/Documentation/networking/device_drivers/intel/fm10k.rst b/Documentation/networking/device_drivers/intel/fm10k.rst
index ac3269e34f55..4d279e64e221 100644
--- a/Documentation/networking/device_drivers/intel/fm10k.rst
+++ b/Documentation/networking/device_drivers/intel/fm10k.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3============================================================== 3=============================================================
4Linux* Base Driver for Intel(R) Ethernet Multi-host Controller 4Linux Base Driver for Intel(R) Ethernet Multi-host Controller
5============================================================== 5=============================================================
6 6
7August 20, 2018 7August 20, 2018
8Copyright(c) 2015-2018 Intel Corporation. 8Copyright(c) 2015-2018 Intel Corporation.
@@ -120,8 +120,8 @@ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r
120Known Issues/Troubleshooting 120Known Issues/Troubleshooting
121============================ 121============================
122 122
123Enabling SR-IOV in a 64-bit Microsoft* Windows Server* 2012/R2 guest OS under Linux KVM 123Enabling SR-IOV in a 64-bit Microsoft Windows Server 2012/R2 guest OS under Linux KVM
124--------------------------------------------------------------------------------------- 124-------------------------------------------------------------------------------------
125KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM. This 125KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM. This
126includes traditional PCIe devices, as well as SR-IOV-capable devices based on 126includes traditional PCIe devices, as well as SR-IOV-capable devices based on
127the Intel Ethernet Controller XL710. 127the Intel Ethernet Controller XL710.
diff --git a/Documentation/networking/device_drivers/intel/i40e.rst b/Documentation/networking/device_drivers/intel/i40e.rst
index 848fd388fa6e..8a9b18573688 100644
--- a/Documentation/networking/device_drivers/intel/i40e.rst
+++ b/Documentation/networking/device_drivers/intel/i40e.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3================================================================== 3=================================================================
4Linux* Base Driver for the Intel(R) Ethernet Controller 700 Series 4Linux Base Driver for the Intel(R) Ethernet Controller 700 Series
5================================================================== 5=================================================================
6 6
7Intel 40 Gigabit Linux driver. 7Intel 40 Gigabit Linux driver.
8Copyright(c) 1999-2018 Intel Corporation. 8Copyright(c) 1999-2018 Intel Corporation.
@@ -384,7 +384,7 @@ NOTE: You cannot set the speed for devices based on the Intel(R) Ethernet
384Network Adapter XXV710 based devices. 384Network Adapter XXV710 based devices.
385 385
386Speed, duplex, and autonegotiation advertising are configured through the 386Speed, duplex, and autonegotiation advertising are configured through the
387ethtool* utility. 387ethtool utility.
388 388
389Caution: Only experienced network administrators should force speed and duplex 389Caution: Only experienced network administrators should force speed and duplex
390or change autonegotiation advertising manually. The settings at the switch must 390or change autonegotiation advertising manually. The settings at the switch must
diff --git a/Documentation/networking/device_drivers/intel/iavf.rst b/Documentation/networking/device_drivers/intel/iavf.rst
index cfc08842e32c..84ac7e75f363 100644
--- a/Documentation/networking/device_drivers/intel/iavf.rst
+++ b/Documentation/networking/device_drivers/intel/iavf.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3================================================================== 3=================================================================
4Linux* Base Driver for Intel(R) Ethernet Adaptive Virtual Function 4Linux Base Driver for Intel(R) Ethernet Adaptive Virtual Function
5================================================================== 5=================================================================
6 6
7Intel Ethernet Adaptive Virtual Function Linux driver. 7Intel Ethernet Adaptive Virtual Function Linux driver.
8Copyright(c) 2013-2018 Intel Corporation. 8Copyright(c) 2013-2018 Intel Corporation.
@@ -19,7 +19,7 @@ Contents
19Overview 19Overview
20======== 20========
21 21
22This file describes the iavf Linux* Base Driver. This driver was formerly 22This file describes the iavf Linux Base Driver. This driver was formerly
23called i40evf. 23called i40evf.
24 24
25The iavf driver supports the below mentioned virtual function devices and 25The iavf driver supports the below mentioned virtual function devices and
diff --git a/Documentation/networking/device_drivers/intel/ice.rst b/Documentation/networking/device_drivers/intel/ice.rst
index c220aa2711c6..ee43ea57d443 100644
--- a/Documentation/networking/device_drivers/intel/ice.rst
+++ b/Documentation/networking/device_drivers/intel/ice.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3=================================================================== 3==================================================================
4Linux* Base Driver for the Intel(R) Ethernet Connection E800 Series 4Linux Base Driver for the Intel(R) Ethernet Connection E800 Series
5=================================================================== 5==================================================================
6 6
7Intel ice Linux driver. 7Intel ice Linux driver.
8Copyright(c) 2018 Intel Corporation. 8Copyright(c) 2018 Intel Corporation.
diff --git a/Documentation/networking/device_drivers/intel/igb.rst b/Documentation/networking/device_drivers/intel/igb.rst
index fc8cfaa5dcfa..87e560fe5eaa 100644
--- a/Documentation/networking/device_drivers/intel/igb.rst
+++ b/Documentation/networking/device_drivers/intel/igb.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3=========================================================== 3==========================================================
4Linux* Base Driver for Intel(R) Ethernet Network Connection 4Linux Base Driver for Intel(R) Ethernet Network Connection
5=========================================================== 5==========================================================
6 6
7Intel Gigabit Linux driver. 7Intel Gigabit Linux driver.
8Copyright(c) 1999-2018 Intel Corporation. 8Copyright(c) 1999-2018 Intel Corporation.
@@ -129,9 +129,9 @@ version is required for this functionality. Download it at:
129https://www.kernel.org/pub/software/network/ethtool/ 129https://www.kernel.org/pub/software/network/ethtool/
130 130
131 131
132Enabling Wake on LAN* (WoL) 132Enabling Wake on LAN (WoL)
133--------------------------- 133--------------------------
134WoL is configured through the ethtool* utility. 134WoL is configured through the ethtool utility.
135 135
136WoL will be enabled on the system during the next shut down or reboot. For 136WoL will be enabled on the system during the next shut down or reboot. For
137this driver version, in order to enable WoL, the igb driver must be loaded 137this driver version, in order to enable WoL, the igb driver must be loaded
diff --git a/Documentation/networking/device_drivers/intel/igbvf.rst b/Documentation/networking/device_drivers/intel/igbvf.rst
index 9cddabe8108e..557fc020ef31 100644
--- a/Documentation/networking/device_drivers/intel/igbvf.rst
+++ b/Documentation/networking/device_drivers/intel/igbvf.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3============================================================ 3===========================================================
4Linux* Base Virtual Function Driver for Intel(R) 1G Ethernet 4Linux Base Virtual Function Driver for Intel(R) 1G Ethernet
5============================================================ 5===========================================================
6 6
7Intel Gigabit Virtual Function Linux driver. 7Intel Gigabit Virtual Function Linux driver.
8Copyright(c) 1999-2018 Intel Corporation. 8Copyright(c) 1999-2018 Intel Corporation.
diff --git a/Documentation/networking/device_drivers/intel/ixgbe.rst b/Documentation/networking/device_drivers/intel/ixgbe.rst
index c7d25483fedb..f1d5233e5e51 100644
--- a/Documentation/networking/device_drivers/intel/ixgbe.rst
+++ b/Documentation/networking/device_drivers/intel/ixgbe.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3============================================================================= 3===========================================================================
4Linux* Base Driver for the Intel(R) Ethernet 10 Gigabit PCI Express Adapters 4Linux Base Driver for the Intel(R) Ethernet 10 Gigabit PCI Express Adapters
5============================================================================= 5===========================================================================
6 6
7Intel 10 Gigabit Linux driver. 7Intel 10 Gigabit Linux driver.
8Copyright(c) 1999-2018 Intel Corporation. 8Copyright(c) 1999-2018 Intel Corporation.
@@ -519,8 +519,8 @@ The offload is also supported for ixgbe's VFs, but the VF must be set as
519Known Issues/Troubleshooting 519Known Issues/Troubleshooting
520============================ 520============================
521 521
522Enabling SR-IOV in a 64-bit Microsoft* Windows Server* 2012/R2 guest OS 522Enabling SR-IOV in a 64-bit Microsoft Windows Server 2012/R2 guest OS
523----------------------------------------------------------------------- 523---------------------------------------------------------------------
524Linux KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM. 524Linux KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM.
525This includes traditional PCIe devices, as well as SR-IOV-capable devices based 525This includes traditional PCIe devices, as well as SR-IOV-capable devices based
526on the Intel Ethernet Controller XL710. 526on the Intel Ethernet Controller XL710.
diff --git a/Documentation/networking/device_drivers/intel/ixgbevf.rst b/Documentation/networking/device_drivers/intel/ixgbevf.rst
index 5d4977360157..76bbde736f21 100644
--- a/Documentation/networking/device_drivers/intel/ixgbevf.rst
+++ b/Documentation/networking/device_drivers/intel/ixgbevf.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3============================================================= 3============================================================
4Linux* Base Virtual Function Driver for Intel(R) 10G Ethernet 4Linux Base Virtual Function Driver for Intel(R) 10G Ethernet
5============================================================= 5============================================================
6 6
7Intel 10 Gigabit Virtual Function Linux driver. 7Intel 10 Gigabit Virtual Function Linux driver.
8Copyright(c) 1999-2018 Intel Corporation. 8Copyright(c) 1999-2018 Intel Corporation.
diff --git a/Documentation/networking/device_drivers/pensando/ionic.rst b/Documentation/networking/device_drivers/pensando/ionic.rst
index 13935896bee6..c17d680cf334 100644
--- a/Documentation/networking/device_drivers/pensando/ionic.rst
+++ b/Documentation/networking/device_drivers/pensando/ionic.rst
@@ -1,8 +1,8 @@
1.. SPDX-License-Identifier: GPL-2.0+ 1.. SPDX-License-Identifier: GPL-2.0+
2 2
3========================================================== 3========================================================
4Linux* Driver for the Pensando(R) Ethernet adapter family 4Linux Driver for the Pensando(R) Ethernet adapter family
5========================================================== 5========================================================
6 6
7Pensando Linux Ethernet driver. 7Pensando Linux Ethernet driver.
8Copyright(c) 2019 Pensando Systems, Inc 8Copyright(c) 2019 Pensando Systems, Inc
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 49e95f438ed7..8d4ad1d1ae26 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -207,8 +207,8 @@ TCP variables:
207 207
208somaxconn - INTEGER 208somaxconn - INTEGER
209 Limit of socket listen() backlog, known in userspace as SOMAXCONN. 209 Limit of socket listen() backlog, known in userspace as SOMAXCONN.
210 Defaults to 128. See also tcp_max_syn_backlog for additional tuning 210 Defaults to 4096. (Was 128 before linux-5.4)
211 for TCP sockets. 211 See also tcp_max_syn_backlog for additional tuning for TCP sockets.
212 212
213tcp_abort_on_overflow - BOOLEAN 213tcp_abort_on_overflow - BOOLEAN
214 If listening service is too slow to accept new connections, 214 If listening service is too slow to accept new connections,
@@ -408,11 +408,14 @@ tcp_max_orphans - INTEGER
408 up to ~64K of unswappable memory. 408 up to ~64K of unswappable memory.
409 409
410tcp_max_syn_backlog - INTEGER 410tcp_max_syn_backlog - INTEGER
411 Maximal number of remembered connection requests, which have not 411 Maximal number of remembered connection requests (SYN_RECV),
412 received an acknowledgment from connecting client. 412 which have not received an acknowledgment from connecting client.
413 This is a per-listener limit.
413 The minimal value is 128 for low memory machines, and it will 414 The minimal value is 128 for low memory machines, and it will
414 increase in proportion to the memory of machine. 415 increase in proportion to the memory of machine.
415 If server suffers from overload, try increasing this number. 416 If server suffers from overload, try increasing this number.
417 Remember to also check /proc/sys/net/core/somaxconn
418 A SYN_RECV request socket consumes about 304 bytes of memory.
416 419
417tcp_max_tw_buckets - INTEGER 420tcp_max_tw_buckets - INTEGER
418 Maximal number of timewait sockets held by system simultaneously. 421 Maximal number of timewait sockets held by system simultaneously.
diff --git a/MAINTAINERS b/MAINTAINERS
index c6c34d04ce95..cba1095547fd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11408,7 +11408,6 @@ F: include/trace/events/tcp.h
11408NETWORKING [TLS] 11408NETWORKING [TLS]
11409M: Boris Pismenny <borisp@mellanox.com> 11409M: Boris Pismenny <borisp@mellanox.com>
11410M: Aviad Yehezkel <aviadye@mellanox.com> 11410M: Aviad Yehezkel <aviadye@mellanox.com>
11411M: Dave Watson <davejwatson@fb.com>
11412M: John Fastabend <john.fastabend@gmail.com> 11411M: John Fastabend <john.fastabend@gmail.com>
11413M: Daniel Borkmann <daniel@iogearbox.net> 11412M: Daniel Borkmann <daniel@iogearbox.net>
11414M: Jakub Kicinski <jakub.kicinski@netronome.com> 11413M: Jakub Kicinski <jakub.kicinski@netronome.com>
@@ -13906,7 +13905,7 @@ F: drivers/mtd/nand/raw/r852.h
13906 13905
13907RISC-V ARCHITECTURE 13906RISC-V ARCHITECTURE
13908M: Paul Walmsley <paul.walmsley@sifive.com> 13907M: Paul Walmsley <paul.walmsley@sifive.com>
13909M: Palmer Dabbelt <palmer@sifive.com> 13908M: Palmer Dabbelt <palmer@dabbelt.com>
13910M: Albert Ou <aou@eecs.berkeley.edu> 13909M: Albert Ou <aou@eecs.berkeley.edu>
13911L: linux-riscv@lists.infradead.org 13910L: linux-riscv@lists.infradead.org
13912T: git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 13911T: git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
@@ -14783,7 +14782,7 @@ F: drivers/media/usb/siano/
14783F: drivers/media/mmc/siano/ 14782F: drivers/media/mmc/siano/
14784 14783
14785SIFIVE DRIVERS 14784SIFIVE DRIVERS
14786M: Palmer Dabbelt <palmer@sifive.com> 14785M: Palmer Dabbelt <palmer@dabbelt.com>
14787M: Paul Walmsley <paul.walmsley@sifive.com> 14786M: Paul Walmsley <paul.walmsley@sifive.com>
14788L: linux-riscv@lists.infradead.org 14787L: linux-riscv@lists.infradead.org
14789T: git git://github.com/sifive/riscv-linux.git 14788T: git git://github.com/sifive/riscv-linux.git
@@ -14793,7 +14792,7 @@ N: sifive
14793 14792
14794SIFIVE FU540 SYSTEM-ON-CHIP 14793SIFIVE FU540 SYSTEM-ON-CHIP
14795M: Paul Walmsley <paul.walmsley@sifive.com> 14794M: Paul Walmsley <paul.walmsley@sifive.com>
14796M: Palmer Dabbelt <palmer@sifive.com> 14795M: Palmer Dabbelt <palmer@dabbelt.com>
14797L: linux-riscv@lists.infradead.org 14796L: linux-riscv@lists.infradead.org
14798T: git git://git.kernel.org/pub/scm/linux/kernel/git/pjw/sifive.git 14797T: git git://git.kernel.org/pub/scm/linux/kernel/git/pjw/sifive.git
14799S: Supported 14798S: Supported
diff --git a/Makefile b/Makefile
index 79be70bf2899..b37d0e8fc61d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2VERSION = 5 2VERSION = 5
3PATCHLEVEL = 4 3PATCHLEVEL = 4
4SUBLEVEL = 0 4SUBLEVEL = 0
5EXTRAVERSION = -rc5 5EXTRAVERSION = -rc6
6NAME = Kleptomaniac Octopus 6NAME = Kleptomaniac Octopus
7 7
8# *DOCUMENTATION* 8# *DOCUMENTATION*
diff --git a/arch/arc/boot/dts/hsdk.dts b/arch/arc/boot/dts/hsdk.dts
index bfc7f5f5d6f2..9acbeba832c0 100644
--- a/arch/arc/boot/dts/hsdk.dts
+++ b/arch/arc/boot/dts/hsdk.dts
@@ -65,6 +65,14 @@
65 clock-frequency = <33333333>; 65 clock-frequency = <33333333>;
66 }; 66 };
67 67
68 reg_5v0: regulator-5v0 {
69 compatible = "regulator-fixed";
70
71 regulator-name = "5v0-supply";
72 regulator-min-microvolt = <5000000>;
73 regulator-max-microvolt = <5000000>;
74 };
75
68 cpu_intc: cpu-interrupt-controller { 76 cpu_intc: cpu-interrupt-controller {
69 compatible = "snps,archs-intc"; 77 compatible = "snps,archs-intc";
70 interrupt-controller; 78 interrupt-controller;
@@ -264,6 +272,21 @@
264 clocks = <&input_clk>; 272 clocks = <&input_clk>;
265 cs-gpios = <&creg_gpio 0 GPIO_ACTIVE_LOW>, 273 cs-gpios = <&creg_gpio 0 GPIO_ACTIVE_LOW>,
266 <&creg_gpio 1 GPIO_ACTIVE_LOW>; 274 <&creg_gpio 1 GPIO_ACTIVE_LOW>;
275
276 spi-flash@0 {
277 compatible = "sst26wf016b", "jedec,spi-nor";
278 reg = <0>;
279 #address-cells = <1>;
280 #size-cells = <1>;
281 spi-max-frequency = <4000000>;
282 };
283
284 adc@1 {
285 compatible = "ti,adc108s102";
286 reg = <1>;
287 vref-supply = <&reg_5v0>;
288 spi-max-frequency = <1000000>;
289 };
267 }; 290 };
268 291
269 creg_gpio: gpio@14b0 { 292 creg_gpio: gpio@14b0 {
diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
index 9b9a74444ce2..0974226fab55 100644
--- a/arch/arc/configs/hsdk_defconfig
+++ b/arch/arc/configs/hsdk_defconfig
@@ -32,6 +32,8 @@ CONFIG_INET=y
32CONFIG_DEVTMPFS=y 32CONFIG_DEVTMPFS=y
33# CONFIG_STANDALONE is not set 33# CONFIG_STANDALONE is not set
34# CONFIG_PREVENT_FIRMWARE_BUILD is not set 34# CONFIG_PREVENT_FIRMWARE_BUILD is not set
35CONFIG_MTD=y
36CONFIG_MTD_SPI_NOR=y
35CONFIG_SCSI=y 37CONFIG_SCSI=y
36CONFIG_BLK_DEV_SD=y 38CONFIG_BLK_DEV_SD=y
37CONFIG_NETDEVICES=y 39CONFIG_NETDEVICES=y
@@ -55,6 +57,8 @@ CONFIG_GPIO_SYSFS=y
55CONFIG_GPIO_DWAPB=y 57CONFIG_GPIO_DWAPB=y
56CONFIG_GPIO_SNPS_CREG=y 58CONFIG_GPIO_SNPS_CREG=y
57# CONFIG_HWMON is not set 59# CONFIG_HWMON is not set
60CONFIG_REGULATOR=y
61CONFIG_REGULATOR_FIXED_VOLTAGE=y
58CONFIG_DRM=y 62CONFIG_DRM=y
59# CONFIG_DRM_FBDEV_EMULATION is not set 63# CONFIG_DRM_FBDEV_EMULATION is not set
60CONFIG_DRM_UDL=y 64CONFIG_DRM_UDL=y
@@ -72,6 +76,8 @@ CONFIG_MMC_SDHCI_PLTFM=y
72CONFIG_MMC_DW=y 76CONFIG_MMC_DW=y
73CONFIG_DMADEVICES=y 77CONFIG_DMADEVICES=y
74CONFIG_DW_AXI_DMAC=y 78CONFIG_DW_AXI_DMAC=y
79CONFIG_IIO=y
80CONFIG_TI_ADC108S102=y
75CONFIG_EXT3_FS=y 81CONFIG_EXT3_FS=y
76CONFIG_VFAT_FS=y 82CONFIG_VFAT_FS=y
77CONFIG_TMPFS=y 83CONFIG_TMPFS=y
diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index 861a8aea51f9..661fd842ea97 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -614,8 +614,8 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
614 /* loop thru all available h/w condition indexes */ 614 /* loop thru all available h/w condition indexes */
615 for (i = 0; i < cc_bcr.c; i++) { 615 for (i = 0; i < cc_bcr.c; i++) {
616 write_aux_reg(ARC_REG_CC_INDEX, i); 616 write_aux_reg(ARC_REG_CC_INDEX, i);
617 cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0); 617 cc_name.indiv.word0 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME0));
618 cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1); 618 cc_name.indiv.word1 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME1));
619 619
620 arc_pmu_map_hw_event(i, cc_name.str); 620 arc_pmu_map_hw_event(i, cc_name.str);
621 arc_pmu_add_raw_event_attr(i, cc_name.str); 621 arc_pmu_add_raw_event_attr(i, cc_name.str);
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index b1454d117cd2..aca07c2f6e6e 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -79,6 +79,7 @@
79#define CAVIUM_CPU_PART_THUNDERX_83XX 0x0A3 79#define CAVIUM_CPU_PART_THUNDERX_83XX 0x0A3
80#define CAVIUM_CPU_PART_THUNDERX2 0x0AF 80#define CAVIUM_CPU_PART_THUNDERX2 0x0AF
81 81
82#define BRCM_CPU_PART_BRAHMA_B53 0x100
82#define BRCM_CPU_PART_VULCAN 0x516 83#define BRCM_CPU_PART_VULCAN 0x516
83 84
84#define QCOM_CPU_PART_FALKOR_V1 0x800 85#define QCOM_CPU_PART_FALKOR_V1 0x800
@@ -105,6 +106,7 @@
105#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) 106#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)
106#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX) 107#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
107#define MIDR_CAVIUM_THUNDERX2 MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX2) 108#define MIDR_CAVIUM_THUNDERX2 MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX2)
109#define MIDR_BRAHMA_B53 MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_BRAHMA_B53)
108#define MIDR_BRCM_VULCAN MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN) 110#define MIDR_BRCM_VULCAN MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN)
109#define MIDR_QCOM_FALKOR_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR_V1) 111#define MIDR_QCOM_FALKOR_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR_V1)
110#define MIDR_QCOM_FALKOR MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR) 112#define MIDR_QCOM_FALKOR MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR)
diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
index 9a21b84536f2..8dc6c5cdabe6 100644
--- a/arch/arm64/include/asm/pgtable-prot.h
+++ b/arch/arm64/include/asm/pgtable-prot.h
@@ -32,11 +32,11 @@
32#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) 32#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG)
33#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) 33#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG)
34 34
35#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) 35#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE))
36#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) 36#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE))
37#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) 37#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC))
38#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT)) 38#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT))
39#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) 39#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL))
40 40
41#define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) 41#define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE))
42#define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) 42#define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL))
@@ -80,8 +80,9 @@
80#define PAGE_S2_DEVICE __pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_S2_XN) 80#define PAGE_S2_DEVICE __pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_S2_XN)
81 81
82#define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) 82#define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN)
83#define PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE) 83/* shared+writable pages are clean by default, hence PTE_RDONLY|PTE_WRITE */
84#define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_WRITE) 84#define PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE)
85#define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE)
85#define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) 86#define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN)
86#define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN) 87#define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN)
87#define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN) 88#define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN)
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 6c3b10a41bd8..93f34b4eca25 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -489,6 +489,7 @@ static const struct midr_range arm64_ssb_cpus[] = {
489 MIDR_ALL_VERSIONS(MIDR_CORTEX_A35), 489 MIDR_ALL_VERSIONS(MIDR_CORTEX_A35),
490 MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), 490 MIDR_ALL_VERSIONS(MIDR_CORTEX_A53),
491 MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), 491 MIDR_ALL_VERSIONS(MIDR_CORTEX_A55),
492 MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53),
492 {}, 493 {},
493}; 494};
494 495
@@ -573,6 +574,7 @@ static const struct midr_range spectre_v2_safe_list[] = {
573 MIDR_ALL_VERSIONS(MIDR_CORTEX_A35), 574 MIDR_ALL_VERSIONS(MIDR_CORTEX_A35),
574 MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), 575 MIDR_ALL_VERSIONS(MIDR_CORTEX_A53),
575 MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), 576 MIDR_ALL_VERSIONS(MIDR_CORTEX_A55),
577 MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53),
576 { /* sentinel */ } 578 { /* sentinel */ }
577}; 579};
578 580
@@ -659,17 +661,23 @@ static const struct midr_range arm64_harden_el2_vectors[] = {
659#endif 661#endif
660 662
661#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI 663#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
662 664static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = {
663static const struct midr_range arm64_repeat_tlbi_cpus[] = {
664#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009 665#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009
665 MIDR_RANGE(MIDR_QCOM_FALKOR_V1, 0, 0, 0, 0), 666 {
667 ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0)
668 },
669 {
670 .midr_range.model = MIDR_QCOM_KRYO,
671 .matches = is_kryo_midr,
672 },
666#endif 673#endif
667#ifdef CONFIG_ARM64_ERRATUM_1286807 674#ifdef CONFIG_ARM64_ERRATUM_1286807
668 MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0), 675 {
676 ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0),
677 },
669#endif 678#endif
670 {}, 679 {},
671}; 680};
672
673#endif 681#endif
674 682
675#ifdef CONFIG_CAVIUM_ERRATUM_27456 683#ifdef CONFIG_CAVIUM_ERRATUM_27456
@@ -737,6 +745,33 @@ static const struct midr_range erratum_1418040_list[] = {
737}; 745};
738#endif 746#endif
739 747
748#ifdef CONFIG_ARM64_ERRATUM_845719
749static const struct midr_range erratum_845719_list[] = {
750 /* Cortex-A53 r0p[01234] */
751 MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
752 /* Brahma-B53 r0p[0] */
753 MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
754 {},
755};
756#endif
757
758#ifdef CONFIG_ARM64_ERRATUM_843419
759static const struct arm64_cpu_capabilities erratum_843419_list[] = {
760 {
761 /* Cortex-A53 r0p[01234] */
762 .matches = is_affected_midr_range,
763 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
764 MIDR_FIXED(0x4, BIT(8)),
765 },
766 {
767 /* Brahma-B53 r0p[0] */
768 .matches = is_affected_midr_range,
769 ERRATA_MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
770 },
771 {},
772};
773#endif
774
740const struct arm64_cpu_capabilities arm64_errata[] = { 775const struct arm64_cpu_capabilities arm64_errata[] = {
741#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE 776#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
742 { 777 {
@@ -768,19 +803,18 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
768#endif 803#endif
769#ifdef CONFIG_ARM64_ERRATUM_843419 804#ifdef CONFIG_ARM64_ERRATUM_843419
770 { 805 {
771 /* Cortex-A53 r0p[01234] */
772 .desc = "ARM erratum 843419", 806 .desc = "ARM erratum 843419",
773 .capability = ARM64_WORKAROUND_843419, 807 .capability = ARM64_WORKAROUND_843419,
774 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), 808 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
775 MIDR_FIXED(0x4, BIT(8)), 809 .matches = cpucap_multi_entry_cap_matches,
810 .match_list = erratum_843419_list,
776 }, 811 },
777#endif 812#endif
778#ifdef CONFIG_ARM64_ERRATUM_845719 813#ifdef CONFIG_ARM64_ERRATUM_845719
779 { 814 {
780 /* Cortex-A53 r0p[01234] */
781 .desc = "ARM erratum 845719", 815 .desc = "ARM erratum 845719",
782 .capability = ARM64_WORKAROUND_845719, 816 .capability = ARM64_WORKAROUND_845719,
783 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), 817 ERRATA_MIDR_RANGE_LIST(erratum_845719_list),
784 }, 818 },
785#endif 819#endif
786#ifdef CONFIG_CAVIUM_ERRATUM_23154 820#ifdef CONFIG_CAVIUM_ERRATUM_23154
@@ -816,6 +850,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
816 { 850 {
817 .desc = "Qualcomm Technologies Falkor/Kryo erratum 1003", 851 .desc = "Qualcomm Technologies Falkor/Kryo erratum 1003",
818 .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003, 852 .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
853 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
819 .matches = cpucap_multi_entry_cap_matches, 854 .matches = cpucap_multi_entry_cap_matches,
820 .match_list = qcom_erratum_1003_list, 855 .match_list = qcom_erratum_1003_list,
821 }, 856 },
@@ -824,7 +859,9 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
824 { 859 {
825 .desc = "Qualcomm erratum 1009, ARM erratum 1286807", 860 .desc = "Qualcomm erratum 1009, ARM erratum 1286807",
826 .capability = ARM64_WORKAROUND_REPEAT_TLBI, 861 .capability = ARM64_WORKAROUND_REPEAT_TLBI,
827 ERRATA_MIDR_RANGE_LIST(arm64_repeat_tlbi_cpus), 862 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
863 .matches = cpucap_multi_entry_cap_matches,
864 .match_list = arm64_repeat_tlbi_list,
828 }, 865 },
829#endif 866#endif
830#ifdef CONFIG_ARM64_ERRATUM_858921 867#ifdef CONFIG_ARM64_ERRATUM_858921
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index 1d1d748c227f..b96d74496977 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -2125,7 +2125,7 @@ ftrace_regs_caller:
2125 copy %rp, %r26 2125 copy %rp, %r26
2126 LDREG -FTRACE_FRAME_SIZE-PT_SZ_ALGN(%sp), %r25 2126 LDREG -FTRACE_FRAME_SIZE-PT_SZ_ALGN(%sp), %r25
2127 ldo -8(%r25), %r25 2127 ldo -8(%r25), %r25
2128 copy %r3, %arg2 2128 ldo -FTRACE_FRAME_SIZE(%r1), %arg2
2129 b,l ftrace_function_trampoline, %rp 2129 b,l ftrace_function_trampoline, %rp
2130 copy %r1, %arg3 /* struct pt_regs */ 2130 copy %r1, %arg3 /* struct pt_regs */
2131 2131
diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h
index 677e9babef80..f9dc597b0b86 100644
--- a/arch/powerpc/include/asm/book3s/32/kup.h
+++ b/arch/powerpc/include/asm/book3s/32/kup.h
@@ -91,6 +91,7 @@
91 91
92static inline void kuap_update_sr(u32 sr, u32 addr, u32 end) 92static inline void kuap_update_sr(u32 sr, u32 addr, u32 end)
93{ 93{
94 addr &= 0xf0000000; /* align addr to start of segment */
94 barrier(); /* make sure thread.kuap is updated before playing with SRs */ 95 barrier(); /* make sure thread.kuap is updated before playing with SRs */
95 while (addr < end) { 96 while (addr < end) {
96 mtsrin(sr, addr); 97 mtsrin(sr, addr);
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 409c9bfb43d9..57c229a86f08 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -175,4 +175,7 @@ do { \
175 ARCH_DLINFO_CACHE_GEOMETRY; \ 175 ARCH_DLINFO_CACHE_GEOMETRY; \
176} while (0) 176} while (0)
177 177
178/* Relocate the kernel image to @final_address */
179void relocate(unsigned long final_address);
180
178#endif /* _ASM_POWERPC_ELF_H */ 181#endif /* _ASM_POWERPC_ELF_H */
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index a4e7762dd286..100f1b57ec2f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -3249,7 +3249,20 @@ static void setup_secure_guest(unsigned long kbase, unsigned long fdt)
3249 /* Switch to secure mode. */ 3249 /* Switch to secure mode. */
3250 prom_printf("Switching to secure mode.\n"); 3250 prom_printf("Switching to secure mode.\n");
3251 3251
3252 /*
3253 * The ultravisor will do an integrity check of the kernel image but we
3254 * relocated it so the check will fail. Restore the original image by
3255 * relocating it back to the kernel virtual base address.
3256 */
3257 if (IS_ENABLED(CONFIG_RELOCATABLE))
3258 relocate(KERNELBASE);
3259
3252 ret = enter_secure_mode(kbase, fdt); 3260 ret = enter_secure_mode(kbase, fdt);
3261
3262 /* Relocate the kernel again. */
3263 if (IS_ENABLED(CONFIG_RELOCATABLE))
3264 relocate(kbase);
3265
3253 if (ret != U_SUCCESS) { 3266 if (ret != U_SUCCESS) {
3254 prom_printf("Returned %d from switching to secure mode.\n", ret); 3267 prom_printf("Returned %d from switching to secure mode.\n", ret);
3255 prom_rtas_os_term("Switch to secure mode failed.\n"); 3268 prom_rtas_os_term("Switch to secure mode failed.\n");
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 78bab17b1396..b183ab9c5107 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -26,7 +26,8 @@ _end enter_prom $MEM_FUNCS reloc_offset __secondary_hold
26__secondary_hold_acknowledge __secondary_hold_spinloop __start 26__secondary_hold_acknowledge __secondary_hold_spinloop __start
27logo_linux_clut224 btext_prepare_BAT 27logo_linux_clut224 btext_prepare_BAT
28reloc_got2 kernstart_addr memstart_addr linux_banner _stext 28reloc_got2 kernstart_addr memstart_addr linux_banner _stext
29__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC." 29__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC.
30relocate"
30 31
31NM="$1" 32NM="$1"
32OBJ="$2" 33OBJ="$2"
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 6bc24a47e9ef..6f300ab7f0e9 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -42,7 +42,7 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev)
42{ 42{
43 struct pci_dn *pdn = pci_get_pdn(pdev); 43 struct pci_dn *pdn = pci_get_pdn(pdev);
44 44
45 if (eeh_has_flag(EEH_FORCE_DISABLED)) 45 if (!pdn || eeh_has_flag(EEH_FORCE_DISABLED))
46 return; 46 return;
47 47
48 dev_dbg(&pdev->dev, "EEH: Setting up device\n"); 48 dev_dbg(&pdev->dev, "EEH: Setting up device\n");
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index fbd6e6b7bbf2..13e251699346 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -146,20 +146,25 @@ static int pnv_smp_cpu_disable(void)
146 return 0; 146 return 0;
147} 147}
148 148
149static void pnv_flush_interrupts(void)
150{
151 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
152 if (xive_enabled())
153 xive_flush_interrupt();
154 else
155 icp_opal_flush_interrupt();
156 } else {
157 icp_native_flush_interrupt();
158 }
159}
160
149static void pnv_smp_cpu_kill_self(void) 161static void pnv_smp_cpu_kill_self(void)
150{ 162{
163 unsigned long srr1, unexpected_mask, wmask;
151 unsigned int cpu; 164 unsigned int cpu;
152 unsigned long srr1, wmask;
153 u64 lpcr_val; 165 u64 lpcr_val;
154 166
155 /* Standard hot unplug procedure */ 167 /* Standard hot unplug procedure */
156 /*
157 * This hard disables local interurpts, ensuring we have no lazy
158 * irqs pending.
159 */
160 WARN_ON(irqs_disabled());
161 hard_irq_disable();
162 WARN_ON(lazy_irq_pending());
163 168
164 idle_task_exit(); 169 idle_task_exit();
165 current->active_mm = NULL; /* for sanity */ 170 current->active_mm = NULL; /* for sanity */
@@ -173,6 +178,27 @@ static void pnv_smp_cpu_kill_self(void)
173 wmask = SRR1_WAKEMASK_P8; 178 wmask = SRR1_WAKEMASK_P8;
174 179
175 /* 180 /*
181 * This turns the irq soft-disabled state we're called with, into a
182 * hard-disabled state with pending irq_happened interrupts cleared.
183 *
184 * PACA_IRQ_DEC - Decrementer should be ignored.
185 * PACA_IRQ_HMI - Can be ignored, processing is done in real mode.
186 * PACA_IRQ_DBELL, EE, PMI - Unexpected.
187 */
188 hard_irq_disable();
189 if (generic_check_cpu_restart(cpu))
190 goto out;
191
192 unexpected_mask = ~(PACA_IRQ_DEC | PACA_IRQ_HMI | PACA_IRQ_HARD_DIS);
193 if (local_paca->irq_happened & unexpected_mask) {
194 if (local_paca->irq_happened & PACA_IRQ_EE)
195 pnv_flush_interrupts();
196 DBG("CPU%d Unexpected exit while offline irq_happened=%lx!\n",
197 cpu, local_paca->irq_happened);
198 }
199 local_paca->irq_happened = PACA_IRQ_HARD_DIS;
200
201 /*
176 * We don't want to take decrementer interrupts while we are 202 * We don't want to take decrementer interrupts while we are
177 * offline, so clear LPCR:PECE1. We keep PECE2 (and 203 * offline, so clear LPCR:PECE1. We keep PECE2 (and
178 * LPCR_PECE_HVEE on P9) enabled so as to let IPIs in. 204 * LPCR_PECE_HVEE on P9) enabled so as to let IPIs in.
@@ -197,6 +223,7 @@ static void pnv_smp_cpu_kill_self(void)
197 223
198 srr1 = pnv_cpu_offline(cpu); 224 srr1 = pnv_cpu_offline(cpu);
199 225
226 WARN_ON_ONCE(!irqs_disabled());
200 WARN_ON(lazy_irq_pending()); 227 WARN_ON(lazy_irq_pending());
201 228
202 /* 229 /*
@@ -212,13 +239,7 @@ static void pnv_smp_cpu_kill_self(void)
212 */ 239 */
213 if (((srr1 & wmask) == SRR1_WAKEEE) || 240 if (((srr1 & wmask) == SRR1_WAKEEE) ||
214 ((srr1 & wmask) == SRR1_WAKEHVI)) { 241 ((srr1 & wmask) == SRR1_WAKEHVI)) {
215 if (cpu_has_feature(CPU_FTR_ARCH_300)) { 242 pnv_flush_interrupts();
216 if (xive_enabled())
217 xive_flush_interrupt();
218 else
219 icp_opal_flush_interrupt();
220 } else
221 icp_native_flush_interrupt();
222 } else if ((srr1 & wmask) == SRR1_WAKEHDBELL) { 243 } else if ((srr1 & wmask) == SRR1_WAKEHDBELL) {
223 unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER); 244 unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER);
224 asm volatile(PPC_MSGCLR(%0) : : "r" (msg)); 245 asm volatile(PPC_MSGCLR(%0) : : "r" (msg));
@@ -266,7 +287,7 @@ static void pnv_smp_cpu_kill_self(void)
266 */ 287 */
267 lpcr_val = mfspr(SPRN_LPCR) | (u64)LPCR_PECE1; 288 lpcr_val = mfspr(SPRN_LPCR) | (u64)LPCR_PECE1;
268 pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val); 289 pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val);
269 290out:
270 DBG("CPU%d coming online...\n", cpu); 291 DBG("CPU%d coming online...\n", cpu);
271} 292}
272 293
diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h
index fc1189ad3777..3ba4d93721d3 100644
--- a/arch/riscv/include/asm/io.h
+++ b/arch/riscv/include/asm/io.h
@@ -13,6 +13,7 @@
13 13
14#include <linux/types.h> 14#include <linux/types.h>
15#include <asm/mmiowb.h> 15#include <asm/mmiowb.h>
16#include <asm/pgtable.h>
16 17
17extern void __iomem *ioremap(phys_addr_t offset, unsigned long size); 18extern void __iomem *ioremap(phys_addr_t offset, unsigned long size);
18 19
@@ -162,6 +163,12 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
162#endif 163#endif
163 164
164/* 165/*
166 * I/O port access constants.
167 */
168#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1)
169#define PCI_IOBASE ((void __iomem *)PCI_IO_START)
170
171/*
165 * Emulation routines for the port-mapped IO space used by some PCI drivers. 172 * Emulation routines for the port-mapped IO space used by some PCI drivers.
166 * These are defined as being "fully synchronous", but also "not guaranteed to 173 * These are defined as being "fully synchronous", but also "not guaranteed to
167 * be fully ordered with respect to other memory and I/O operations". We're 174 * be fully ordered with respect to other memory and I/O operations". We're
diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h
index 75576424c0f7..6e1b0e0325eb 100644
--- a/arch/riscv/include/asm/irq.h
+++ b/arch/riscv/include/asm/irq.h
@@ -7,6 +7,9 @@
7#ifndef _ASM_RISCV_IRQ_H 7#ifndef _ASM_RISCV_IRQ_H
8#define _ASM_RISCV_IRQ_H 8#define _ASM_RISCV_IRQ_H
9 9
10#include <linux/interrupt.h>
11#include <linux/linkage.h>
12
10#define NR_IRQS 0 13#define NR_IRQS 0
11 14
12void riscv_timer_interrupt(void); 15void riscv_timer_interrupt(void);
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 0352f20c29f4..d3221017194d 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -7,6 +7,7 @@
7#define _ASM_RISCV_PGTABLE_H 7#define _ASM_RISCV_PGTABLE_H
8 8
9#include <linux/mmzone.h> 9#include <linux/mmzone.h>
10#include <linux/sizes.h>
10 11
11#include <asm/pgtable-bits.h> 12#include <asm/pgtable-bits.h>
12 13
@@ -86,6 +87,7 @@ extern pgd_t swapper_pg_dir[];
86#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) 87#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
87#define VMALLOC_END (PAGE_OFFSET - 1) 88#define VMALLOC_END (PAGE_OFFSET - 1)
88#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) 89#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
90#define PCI_IO_SIZE SZ_16M
89 91
90/* 92/*
91 * Roughly size the vmemmap space to be large enough to fit enough 93 * Roughly size the vmemmap space to be large enough to fit enough
@@ -100,7 +102,10 @@ extern pgd_t swapper_pg_dir[];
100 102
101#define vmemmap ((struct page *)VMEMMAP_START) 103#define vmemmap ((struct page *)VMEMMAP_START)
102 104
103#define FIXADDR_TOP (VMEMMAP_START) 105#define PCI_IO_END VMEMMAP_START
106#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
107#define FIXADDR_TOP PCI_IO_START
108
104#ifdef CONFIG_64BIT 109#ifdef CONFIG_64BIT
105#define FIXADDR_SIZE PMD_SIZE 110#define FIXADDR_SIZE PMD_SIZE
106#else 111#else
diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h
index f0227bdce0f0..ee4f0ac62c9d 100644
--- a/arch/riscv/include/asm/switch_to.h
+++ b/arch/riscv/include/asm/switch_to.h
@@ -6,6 +6,7 @@
6#ifndef _ASM_RISCV_SWITCH_TO_H 6#ifndef _ASM_RISCV_SWITCH_TO_H
7#define _ASM_RISCV_SWITCH_TO_H 7#define _ASM_RISCV_SWITCH_TO_H
8 8
9#include <linux/sched/task_stack.h>
9#include <asm/processor.h> 10#include <asm/processor.h>
10#include <asm/ptrace.h> 11#include <asm/ptrace.h>
11#include <asm/csr.h> 12#include <asm/csr.h>
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index b1ade9a49347..a5ad00043104 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -10,6 +10,7 @@
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/hwcap.h> 11#include <asm/hwcap.h>
12#include <asm/smp.h> 12#include <asm/smp.h>
13#include <asm/switch_to.h>
13 14
14unsigned long elf_hwcap __read_mostly; 15unsigned long elf_hwcap __read_mostly;
15#ifdef CONFIG_FPU 16#ifdef CONFIG_FPU
diff --git a/arch/riscv/kernel/head.h b/arch/riscv/kernel/head.h
new file mode 100644
index 000000000000..105fb0496b24
--- /dev/null
+++ b/arch/riscv/kernel/head.h
@@ -0,0 +1,21 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2019 SiFive, Inc.
4 */
5#ifndef __ASM_HEAD_H
6#define __ASM_HEAD_H
7
8#include <linux/linkage.h>
9#include <linux/init.h>
10
11extern atomic_t hart_lottery;
12
13asmlinkage void do_page_fault(struct pt_regs *regs);
14asmlinkage void __init setup_vm(uintptr_t dtb_pa);
15
16extern void *__cpu_up_stack_pointer[];
17extern void *__cpu_up_task_pointer[];
18
19void __init parse_dtb(void);
20
21#endif /* __ASM_HEAD_H */
diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
index 6d8659388c49..fffac6ddb0e0 100644
--- a/arch/riscv/kernel/irq.c
+++ b/arch/riscv/kernel/irq.c
@@ -24,7 +24,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24 return 0; 24 return 0;
25} 25}
26 26
27asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs) 27asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs)
28{ 28{
29 struct pt_regs *old_regs = set_irq_regs(regs); 29 struct pt_regs *old_regs = set_irq_regs(regs);
30 30
diff --git a/arch/riscv/kernel/module-sections.c b/arch/riscv/kernel/module-sections.c
index c9ae48333114..e264e59e596e 100644
--- a/arch/riscv/kernel/module-sections.c
+++ b/arch/riscv/kernel/module-sections.c
@@ -8,6 +8,7 @@
8#include <linux/elf.h> 8#include <linux/elf.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/moduleloader.h>
11 12
12unsigned long module_emit_got_entry(struct module *mod, unsigned long val) 13unsigned long module_emit_got_entry(struct module *mod, unsigned long val)
13{ 14{
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index fb3a082362eb..85e3c39bb60b 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -7,6 +7,7 @@
7 * Copyright (C) 2017 SiFive 7 * Copyright (C) 2017 SiFive
8 */ 8 */
9 9
10#include <linux/cpu.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/sched/task_stack.h> 13#include <linux/sched/task_stack.h>
@@ -19,6 +20,7 @@
19#include <asm/csr.h> 20#include <asm/csr.h>
20#include <asm/string.h> 21#include <asm/string.h>
21#include <asm/switch_to.h> 22#include <asm/switch_to.h>
23#include <asm/thread_info.h>
22 24
23extern asmlinkage void ret_from_fork(void); 25extern asmlinkage void ret_from_fork(void);
24extern asmlinkage void ret_from_kernel_thread(void); 26extern asmlinkage void ret_from_kernel_thread(void);
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index 368751438366..1252113ef8b2 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -148,7 +148,7 @@ long arch_ptrace(struct task_struct *child, long request,
148 * Allows PTRACE_SYSCALL to work. These are called from entry.S in 148 * Allows PTRACE_SYSCALL to work. These are called from entry.S in
149 * {handle,ret_from}_syscall. 149 * {handle,ret_from}_syscall.
150 */ 150 */
151void do_syscall_trace_enter(struct pt_regs *regs) 151__visible void do_syscall_trace_enter(struct pt_regs *regs)
152{ 152{
153 if (test_thread_flag(TIF_SYSCALL_TRACE)) 153 if (test_thread_flag(TIF_SYSCALL_TRACE))
154 if (tracehook_report_syscall_entry(regs)) 154 if (tracehook_report_syscall_entry(regs))
@@ -162,7 +162,7 @@ void do_syscall_trace_enter(struct pt_regs *regs)
162 audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3); 162 audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3);
163} 163}
164 164
165void do_syscall_trace_exit(struct pt_regs *regs) 165__visible void do_syscall_trace_exit(struct pt_regs *regs)
166{ 166{
167 audit_syscall_exit(regs); 167 audit_syscall_exit(regs);
168 168
diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
index d0fe623bfb8f..aa56bb135ec4 100644
--- a/arch/riscv/kernel/reset.c
+++ b/arch/riscv/kernel/reset.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <linux/reboot.h> 6#include <linux/reboot.h>
7#include <linux/pm.h>
7#include <asm/sbi.h> 8#include <asm/sbi.h>
8 9
9static void default_power_off(void) 10static void default_power_off(void)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index a990a6cb184f..845ae0e12115 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -24,6 +24,8 @@
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
25#include <asm/thread_info.h> 25#include <asm/thread_info.h>
26 26
27#include "head.h"
28
27#ifdef CONFIG_DUMMY_CONSOLE 29#ifdef CONFIG_DUMMY_CONSOLE
28struct screen_info screen_info = { 30struct screen_info screen_info = {
29 .orig_video_lines = 30, 31 .orig_video_lines = 30,
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index b14d7647d800..d0f6f212f5df 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -26,7 +26,7 @@ struct rt_sigframe {
26 26
27#ifdef CONFIG_FPU 27#ifdef CONFIG_FPU
28static long restore_fp_state(struct pt_regs *regs, 28static long restore_fp_state(struct pt_regs *regs,
29 union __riscv_fp_state *sc_fpregs) 29 union __riscv_fp_state __user *sc_fpregs)
30{ 30{
31 long err; 31 long err;
32 struct __riscv_d_ext_state __user *state = &sc_fpregs->d; 32 struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
@@ -53,7 +53,7 @@ static long restore_fp_state(struct pt_regs *regs,
53} 53}
54 54
55static long save_fp_state(struct pt_regs *regs, 55static long save_fp_state(struct pt_regs *regs,
56 union __riscv_fp_state *sc_fpregs) 56 union __riscv_fp_state __user *sc_fpregs)
57{ 57{
58 long err; 58 long err;
59 struct __riscv_d_ext_state __user *state = &sc_fpregs->d; 59 struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
@@ -292,8 +292,8 @@ static void do_signal(struct pt_regs *regs)
292 * notification of userspace execution resumption 292 * notification of userspace execution resumption
293 * - triggered by the _TIF_WORK_MASK flags 293 * - triggered by the _TIF_WORK_MASK flags
294 */ 294 */
295asmlinkage void do_notify_resume(struct pt_regs *regs, 295asmlinkage __visible void do_notify_resume(struct pt_regs *regs,
296 unsigned long thread_info_flags) 296 unsigned long thread_info_flags)
297{ 297{
298 /* Handle pending signal delivery */ 298 /* Handle pending signal delivery */
299 if (thread_info_flags & _TIF_SIGPENDING) 299 if (thread_info_flags & _TIF_SIGPENDING)
diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index b18cd6c8e8fb..5c9ec78422c2 100644
--- a/arch/riscv/kernel/smp.c
+++ b/arch/riscv/kernel/smp.c
@@ -8,7 +8,9 @@
8 * Copyright (C) 2017 SiFive 8 * Copyright (C) 2017 SiFive
9 */ 9 */
10 10
11#include <linux/cpu.h>
11#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/profile.h>
12#include <linux/smp.h> 14#include <linux/smp.h>
13#include <linux/sched.h> 15#include <linux/sched.h>
14#include <linux/seq_file.h> 16#include <linux/seq_file.h>
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 18ae6da5115e..261f4087cc39 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -29,6 +29,9 @@
29#include <asm/tlbflush.h> 29#include <asm/tlbflush.h>
30#include <asm/sections.h> 30#include <asm/sections.h>
31#include <asm/sbi.h> 31#include <asm/sbi.h>
32#include <asm/smp.h>
33
34#include "head.h"
32 35
33void *__cpu_up_stack_pointer[NR_CPUS]; 36void *__cpu_up_stack_pointer[NR_CPUS];
34void *__cpu_up_task_pointer[NR_CPUS]; 37void *__cpu_up_task_pointer[NR_CPUS];
@@ -130,7 +133,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
130/* 133/*
131 * C entry point for a secondary processor. 134 * C entry point for a secondary processor.
132 */ 135 */
133asmlinkage void __init smp_callin(void) 136asmlinkage __visible void __init smp_callin(void)
134{ 137{
135 struct mm_struct *mm = &init_mm; 138 struct mm_struct *mm = &init_mm;
136 139
diff --git a/arch/riscv/kernel/syscall_table.c b/arch/riscv/kernel/syscall_table.c
index e5dd52d8f633..f1ead9df96ca 100644
--- a/arch/riscv/kernel/syscall_table.c
+++ b/arch/riscv/kernel/syscall_table.c
@@ -8,6 +8,7 @@
8#include <linux/syscalls.h> 8#include <linux/syscalls.h>
9#include <asm-generic/syscalls.h> 9#include <asm-generic/syscalls.h>
10#include <asm/vdso.h> 10#include <asm/vdso.h>
11#include <asm/syscall.h>
11 12
12#undef __SYSCALL 13#undef __SYSCALL
13#define __SYSCALL(nr, call) [nr] = (call), 14#define __SYSCALL(nr, call) [nr] = (call),
diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
index 9dd1f2e64db1..6a53c02e9c73 100644
--- a/arch/riscv/kernel/time.c
+++ b/arch/riscv/kernel/time.c
@@ -7,6 +7,7 @@
7#include <linux/clocksource.h> 7#include <linux/clocksource.h>
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <asm/sbi.h> 9#include <asm/sbi.h>
10#include <asm/processor.h>
10 11
11unsigned long riscv_timebase; 12unsigned long riscv_timebase;
12EXPORT_SYMBOL_GPL(riscv_timebase); 13EXPORT_SYMBOL_GPL(riscv_timebase);
diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 10a17e545f43..473de3ae8bb7 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -3,6 +3,7 @@
3 * Copyright (C) 2012 Regents of the University of California 3 * Copyright (C) 2012 Regents of the University of California
4 */ 4 */
5 5
6#include <linux/cpu.h>
6#include <linux/kernel.h> 7#include <linux/kernel.h>
7#include <linux/init.h> 8#include <linux/init.h>
8#include <linux/sched.h> 9#include <linux/sched.h>
@@ -83,7 +84,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code,
83} 84}
84 85
85#define DO_ERROR_INFO(name, signo, code, str) \ 86#define DO_ERROR_INFO(name, signo, code, str) \
86asmlinkage void name(struct pt_regs *regs) \ 87asmlinkage __visible void name(struct pt_regs *regs) \
87{ \ 88{ \
88 do_trap_error(regs, signo, code, regs->sepc, "Oops - " str); \ 89 do_trap_error(regs, signo, code, regs->sepc, "Oops - " str); \
89} 90}
@@ -120,7 +121,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
120 return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL); 121 return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
121} 122}
122 123
123asmlinkage void do_trap_break(struct pt_regs *regs) 124asmlinkage __visible void do_trap_break(struct pt_regs *regs)
124{ 125{
125 if (user_mode(regs)) 126 if (user_mode(regs))
126 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc); 127 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc);
diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index c9c21e0d5641..484d95a70907 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 2015 Regents of the University of California 6 * Copyright (C) 2015 Regents of the University of California
7 */ 7 */
8 8
9#include <linux/elf.h>
9#include <linux/mm.h> 10#include <linux/mm.h>
10#include <linux/slab.h> 11#include <linux/slab.h>
11#include <linux/binfmts.h> 12#include <linux/binfmts.h>
@@ -25,7 +26,7 @@ static union {
25 struct vdso_data data; 26 struct vdso_data data;
26 u8 page[PAGE_SIZE]; 27 u8 page[PAGE_SIZE];
27} vdso_data_store __page_aligned_data; 28} vdso_data_store __page_aligned_data;
28struct vdso_data *vdso_data = &vdso_data_store.data; 29static struct vdso_data *vdso_data = &vdso_data_store.data;
29 30
30static int __init vdso_init(void) 31static int __init vdso_init(void)
31{ 32{
diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
index beeb5d7f92ea..ca66d44156b6 100644
--- a/arch/riscv/mm/context.c
+++ b/arch/riscv/mm/context.c
@@ -7,6 +7,7 @@
7#include <linux/mm.h> 7#include <linux/mm.h>
8#include <asm/tlbflush.h> 8#include <asm/tlbflush.h>
9#include <asm/cacheflush.h> 9#include <asm/cacheflush.h>
10#include <asm/mmu_context.h>
10 11
11/* 12/*
12 * When necessary, performs a deferred icache flush for the given MM context, 13 * When necessary, performs a deferred icache flush for the given MM context,
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 96add1427a75..247b8c859c44 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -18,6 +18,8 @@
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
19#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
20 20
21#include "../kernel/head.h"
22
21/* 23/*
22 * This routine handles page faults. It determines the address and the 24 * This routine handles page faults. It determines the address and the
23 * problem, and then passes it off to one of the appropriate routines. 25 * problem, and then passes it off to one of the appropriate routines.
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index a1ca6200c31f..573463d1c799 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -19,6 +19,8 @@
19#include <asm/pgtable.h> 19#include <asm/pgtable.h>
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22#include "../kernel/head.h"
23
22unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] 24unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
23 __page_aligned_bss; 25 __page_aligned_bss;
24EXPORT_SYMBOL(empty_zero_page); 26EXPORT_SYMBOL(empty_zero_page);
@@ -337,8 +339,7 @@ static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
337 */ 339 */
338 340
339#ifndef __riscv_cmodel_medany 341#ifndef __riscv_cmodel_medany
340#error "setup_vm() is called from head.S before relocate so it should " 342#error "setup_vm() is called from head.S before relocate so it should not use absolute addressing."
341 "not use absolute addressing."
342#endif 343#endif
343 344
344asmlinkage void __init setup_vm(uintptr_t dtb_pa) 345asmlinkage void __init setup_vm(uintptr_t dtb_pa)
diff --git a/arch/riscv/mm/sifive_l2_cache.c b/arch/riscv/mm/sifive_l2_cache.c
index 2e637ad71c05..a9ffff3277c7 100644
--- a/arch/riscv/mm/sifive_l2_cache.c
+++ b/arch/riscv/mm/sifive_l2_cache.c
@@ -142,7 +142,7 @@ static irqreturn_t l2_int_handler(int irq, void *device)
142 return IRQ_HANDLED; 142 return IRQ_HANDLED;
143} 143}
144 144
145int __init sifive_l2_init(void) 145static int __init sifive_l2_init(void)
146{ 146{
147 struct device_node *np; 147 struct device_node *np;
148 struct resource res; 148 struct resource res;
diff --git a/arch/s390/include/asm/unwind.h b/arch/s390/include/asm/unwind.h
index d827b5b9a32c..eaaefeceef6f 100644
--- a/arch/s390/include/asm/unwind.h
+++ b/arch/s390/include/asm/unwind.h
@@ -35,6 +35,7 @@ struct unwind_state {
35 struct task_struct *task; 35 struct task_struct *task;
36 struct pt_regs *regs; 36 struct pt_regs *regs;
37 unsigned long sp, ip; 37 unsigned long sp, ip;
38 bool reuse_sp;
38 int graph_idx; 39 int graph_idx;
39 bool reliable; 40 bool reliable;
40 bool error; 41 bool error;
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index b9d8fe45737a..8f8456816d83 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -69,18 +69,26 @@ DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
69static ssize_t show_idle_time(struct device *dev, 69static ssize_t show_idle_time(struct device *dev,
70 struct device_attribute *attr, char *buf) 70 struct device_attribute *attr, char *buf)
71{ 71{
72 unsigned long long now, idle_time, idle_enter, idle_exit, in_idle;
72 struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id); 73 struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
73 unsigned long long now, idle_time, idle_enter, idle_exit;
74 unsigned int seq; 74 unsigned int seq;
75 75
76 do { 76 do {
77 now = get_tod_clock();
78 seq = read_seqcount_begin(&idle->seqcount); 77 seq = read_seqcount_begin(&idle->seqcount);
79 idle_time = READ_ONCE(idle->idle_time); 78 idle_time = READ_ONCE(idle->idle_time);
80 idle_enter = READ_ONCE(idle->clock_idle_enter); 79 idle_enter = READ_ONCE(idle->clock_idle_enter);
81 idle_exit = READ_ONCE(idle->clock_idle_exit); 80 idle_exit = READ_ONCE(idle->clock_idle_exit);
82 } while (read_seqcount_retry(&idle->seqcount, seq)); 81 } while (read_seqcount_retry(&idle->seqcount, seq));
83 idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0; 82 in_idle = 0;
83 now = get_tod_clock();
84 if (idle_enter) {
85 if (idle_exit) {
86 in_idle = idle_exit - idle_enter;
87 } else if (now > idle_enter) {
88 in_idle = now - idle_enter;
89 }
90 }
91 idle_time += in_idle;
84 return sprintf(buf, "%llu\n", idle_time >> 12); 92 return sprintf(buf, "%llu\n", idle_time >> 12);
85} 93}
86DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL); 94DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
@@ -88,17 +96,24 @@ DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
88u64 arch_cpu_idle_time(int cpu) 96u64 arch_cpu_idle_time(int cpu)
89{ 97{
90 struct s390_idle_data *idle = &per_cpu(s390_idle, cpu); 98 struct s390_idle_data *idle = &per_cpu(s390_idle, cpu);
91 unsigned long long now, idle_enter, idle_exit; 99 unsigned long long now, idle_enter, idle_exit, in_idle;
92 unsigned int seq; 100 unsigned int seq;
93 101
94 do { 102 do {
95 now = get_tod_clock();
96 seq = read_seqcount_begin(&idle->seqcount); 103 seq = read_seqcount_begin(&idle->seqcount);
97 idle_enter = READ_ONCE(idle->clock_idle_enter); 104 idle_enter = READ_ONCE(idle->clock_idle_enter);
98 idle_exit = READ_ONCE(idle->clock_idle_exit); 105 idle_exit = READ_ONCE(idle->clock_idle_exit);
99 } while (read_seqcount_retry(&idle->seqcount, seq)); 106 } while (read_seqcount_retry(&idle->seqcount, seq));
100 107 in_idle = 0;
101 return cputime_to_nsecs(idle_enter ? ((idle_exit ?: now) - idle_enter) : 0); 108 now = get_tod_clock();
109 if (idle_enter) {
110 if (idle_exit) {
111 in_idle = idle_exit - idle_enter;
112 } else if (now > idle_enter) {
113 in_idle = now - idle_enter;
114 }
115 }
116 return cputime_to_nsecs(in_idle);
102} 117}
103 118
104void arch_cpu_idle_enter(void) 119void arch_cpu_idle_enter(void)
diff --git a/arch/s390/kernel/unwind_bc.c b/arch/s390/kernel/unwind_bc.c
index 8fc9daae47a2..a8204f952315 100644
--- a/arch/s390/kernel/unwind_bc.c
+++ b/arch/s390/kernel/unwind_bc.c
@@ -46,10 +46,15 @@ bool unwind_next_frame(struct unwind_state *state)
46 46
47 regs = state->regs; 47 regs = state->regs;
48 if (unlikely(regs)) { 48 if (unlikely(regs)) {
49 sp = READ_ONCE_NOCHECK(regs->gprs[15]); 49 if (state->reuse_sp) {
50 if (unlikely(outside_of_stack(state, sp))) { 50 sp = state->sp;
51 if (!update_stack_info(state, sp)) 51 state->reuse_sp = false;
52 goto out_err; 52 } else {
53 sp = READ_ONCE_NOCHECK(regs->gprs[15]);
54 if (unlikely(outside_of_stack(state, sp))) {
55 if (!update_stack_info(state, sp))
56 goto out_err;
57 }
53 } 58 }
54 sf = (struct stack_frame *) sp; 59 sf = (struct stack_frame *) sp;
55 ip = READ_ONCE_NOCHECK(sf->gprs[8]); 60 ip = READ_ONCE_NOCHECK(sf->gprs[8]);
@@ -107,9 +112,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
107{ 112{
108 struct stack_info *info = &state->stack_info; 113 struct stack_info *info = &state->stack_info;
109 unsigned long *mask = &state->stack_mask; 114 unsigned long *mask = &state->stack_mask;
115 bool reliable, reuse_sp;
110 struct stack_frame *sf; 116 struct stack_frame *sf;
111 unsigned long ip; 117 unsigned long ip;
112 bool reliable;
113 118
114 memset(state, 0, sizeof(*state)); 119 memset(state, 0, sizeof(*state));
115 state->task = task; 120 state->task = task;
@@ -134,10 +139,12 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
134 if (regs) { 139 if (regs) {
135 ip = READ_ONCE_NOCHECK(regs->psw.addr); 140 ip = READ_ONCE_NOCHECK(regs->psw.addr);
136 reliable = true; 141 reliable = true;
142 reuse_sp = true;
137 } else { 143 } else {
138 sf = (struct stack_frame *) sp; 144 sf = (struct stack_frame *) sp;
139 ip = READ_ONCE_NOCHECK(sf->gprs[8]); 145 ip = READ_ONCE_NOCHECK(sf->gprs[8]);
140 reliable = false; 146 reliable = false;
147 reuse_sp = false;
141 } 148 }
142 149
143#ifdef CONFIG_FUNCTION_GRAPH_TRACER 150#ifdef CONFIG_FUNCTION_GRAPH_TRACER
@@ -151,5 +158,6 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
151 state->sp = sp; 158 state->sp = sp;
152 state->ip = ip; 159 state->ip = ip;
153 state->reliable = reliable; 160 state->reliable = reliable;
161 state->reuse_sp = reuse_sp;
154} 162}
155EXPORT_SYMBOL_GPL(__unwind_start); 163EXPORT_SYMBOL_GPL(__unwind_start);
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index 510a18299196..a51c892f14f3 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -298,16 +298,16 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
298 } 298 }
299 299
300 if (write) { 300 if (write) {
301 len = *lenp; 301 len = min(*lenp, sizeof(buf));
302 if (copy_from_user(buf, buffer, 302 if (copy_from_user(buf, buffer, len))
303 len > sizeof(buf) ? sizeof(buf) : len))
304 return -EFAULT; 303 return -EFAULT;
305 buf[sizeof(buf) - 1] = '\0'; 304 buf[len - 1] = '\0';
306 cmm_skip_blanks(buf, &p); 305 cmm_skip_blanks(buf, &p);
307 nr = simple_strtoul(p, &p, 0); 306 nr = simple_strtoul(p, &p, 0);
308 cmm_skip_blanks(p, &p); 307 cmm_skip_blanks(p, &p);
309 seconds = simple_strtoul(p, &p, 0); 308 seconds = simple_strtoul(p, &p, 0);
310 cmm_set_timeout(nr, seconds); 309 cmm_set_timeout(nr, seconds);
310 *ppos += *lenp;
311 } else { 311 } else {
312 len = sprintf(buf, "%ld %ld\n", 312 len = sprintf(buf, "%ld %ld\n",
313 cmm_timeout_pages, cmm_timeout_seconds); 313 cmm_timeout_pages, cmm_timeout_seconds);
@@ -315,9 +315,9 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
315 len = *lenp; 315 len = *lenp;
316 if (copy_to_user(buffer, buf, len)) 316 if (copy_to_user(buffer, buf, len))
317 return -EFAULT; 317 return -EFAULT;
318 *lenp = len;
319 *ppos += len;
318 } 320 }
319 *lenp = len;
320 *ppos += len;
321 return 0; 321 return 0;
322} 322}
323 323
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 612535cd9706..6627d7c30f37 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1403,8 +1403,12 @@ static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
1403 1403
1404 spin_unlock_irq(&ubd_dev->lock); 1404 spin_unlock_irq(&ubd_dev->lock);
1405 1405
1406 if (ret < 0) 1406 if (ret < 0) {
1407 blk_mq_requeue_request(req, true); 1407 if (ret == -ENOMEM)
1408 res = BLK_STS_RESOURCE;
1409 else
1410 res = BLK_STS_DEV_RESOURCE;
1411 }
1408 1412
1409 return res; 1413 return res;
1410} 1414}
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index d6662fdef300..82bc60c8acb2 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -13,6 +13,7 @@
13#include <asm/e820/types.h> 13#include <asm/e820/types.h>
14#include <asm/setup.h> 14#include <asm/setup.h>
15#include <asm/desc.h> 15#include <asm/desc.h>
16#include <asm/boot.h>
16 17
17#include "../string.h" 18#include "../string.h"
18#include "eboot.h" 19#include "eboot.h"
@@ -813,7 +814,8 @@ efi_main(struct efi_config *c, struct boot_params *boot_params)
813 status = efi_relocate_kernel(sys_table, &bzimage_addr, 814 status = efi_relocate_kernel(sys_table, &bzimage_addr,
814 hdr->init_size, hdr->init_size, 815 hdr->init_size, hdr->init_size,
815 hdr->pref_address, 816 hdr->pref_address,
816 hdr->kernel_alignment); 817 hdr->kernel_alignment,
818 LOAD_PHYSICAL_ADDR);
817 if (status != EFI_SUCCESS) { 819 if (status != EFI_SUCCESS) {
818 efi_printk(sys_table, "efi_relocate_kernel() failed!\n"); 820 efi_printk(sys_table, "efi_relocate_kernel() failed!\n");
819 goto fail; 821 goto fail;
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 5b35b7ea5d72..26c36357c4c9 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -377,7 +377,8 @@ static inline void perf_ibs_disable_event(struct perf_ibs *perf_ibs,
377 struct hw_perf_event *hwc, u64 config) 377 struct hw_perf_event *hwc, u64 config)
378{ 378{
379 config &= ~perf_ibs->cnt_mask; 379 config &= ~perf_ibs->cnt_mask;
380 wrmsrl(hwc->config_base, config); 380 if (boot_cpu_data.x86 == 0x10)
381 wrmsrl(hwc->config_base, config);
381 config &= ~perf_ibs->enable_mask; 382 config &= ~perf_ibs->enable_mask;
382 wrmsrl(hwc->config_base, config); 383 wrmsrl(hwc->config_base, config);
383} 384}
@@ -553,7 +554,8 @@ static struct perf_ibs perf_ibs_op = {
553 }, 554 },
554 .msr = MSR_AMD64_IBSOPCTL, 555 .msr = MSR_AMD64_IBSOPCTL,
555 .config_mask = IBS_OP_CONFIG_MASK, 556 .config_mask = IBS_OP_CONFIG_MASK,
556 .cnt_mask = IBS_OP_MAX_CNT, 557 .cnt_mask = IBS_OP_MAX_CNT | IBS_OP_CUR_CNT |
558 IBS_OP_CUR_CNT_RAND,
557 .enable_mask = IBS_OP_ENABLE, 559 .enable_mask = IBS_OP_ENABLE,
558 .valid_mask = IBS_OP_VAL, 560 .valid_mask = IBS_OP_VAL,
559 .max_period = IBS_OP_MAX_CNT << 4, 561 .max_period = IBS_OP_MAX_CNT << 4,
@@ -614,7 +616,7 @@ fail:
614 if (event->attr.sample_type & PERF_SAMPLE_RAW) 616 if (event->attr.sample_type & PERF_SAMPLE_RAW)
615 offset_max = perf_ibs->offset_max; 617 offset_max = perf_ibs->offset_max;
616 else if (check_rip) 618 else if (check_rip)
617 offset_max = 2; 619 offset_max = 3;
618 else 620 else
619 offset_max = 1; 621 offset_max = 1;
620 do { 622 do {
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 6fc2e06ab4c6..86467f85c383 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -502,10 +502,8 @@ void uncore_pmu_event_start(struct perf_event *event, int flags)
502 local64_set(&event->hw.prev_count, uncore_read_counter(box, event)); 502 local64_set(&event->hw.prev_count, uncore_read_counter(box, event));
503 uncore_enable_event(box, event); 503 uncore_enable_event(box, event);
504 504
505 if (box->n_active == 1) { 505 if (box->n_active == 1)
506 uncore_enable_box(box);
507 uncore_pmu_start_hrtimer(box); 506 uncore_pmu_start_hrtimer(box);
508 }
509} 507}
510 508
511void uncore_pmu_event_stop(struct perf_event *event, int flags) 509void uncore_pmu_event_stop(struct perf_event *event, int flags)
@@ -529,10 +527,8 @@ void uncore_pmu_event_stop(struct perf_event *event, int flags)
529 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED); 527 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
530 hwc->state |= PERF_HES_STOPPED; 528 hwc->state |= PERF_HES_STOPPED;
531 529
532 if (box->n_active == 0) { 530 if (box->n_active == 0)
533 uncore_disable_box(box);
534 uncore_pmu_cancel_hrtimer(box); 531 uncore_pmu_cancel_hrtimer(box);
535 }
536 } 532 }
537 533
538 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) { 534 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
@@ -778,6 +774,40 @@ static int uncore_pmu_event_init(struct perf_event *event)
778 return ret; 774 return ret;
779} 775}
780 776
777static void uncore_pmu_enable(struct pmu *pmu)
778{
779 struct intel_uncore_pmu *uncore_pmu;
780 struct intel_uncore_box *box;
781
782 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu);
783 if (!uncore_pmu)
784 return;
785
786 box = uncore_pmu_to_box(uncore_pmu, smp_processor_id());
787 if (!box)
788 return;
789
790 if (uncore_pmu->type->ops->enable_box)
791 uncore_pmu->type->ops->enable_box(box);
792}
793
794static void uncore_pmu_disable(struct pmu *pmu)
795{
796 struct intel_uncore_pmu *uncore_pmu;
797 struct intel_uncore_box *box;
798
799 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu);
800 if (!uncore_pmu)
801 return;
802
803 box = uncore_pmu_to_box(uncore_pmu, smp_processor_id());
804 if (!box)
805 return;
806
807 if (uncore_pmu->type->ops->disable_box)
808 uncore_pmu->type->ops->disable_box(box);
809}
810
781static ssize_t uncore_get_attr_cpumask(struct device *dev, 811static ssize_t uncore_get_attr_cpumask(struct device *dev,
782 struct device_attribute *attr, char *buf) 812 struct device_attribute *attr, char *buf)
783{ 813{
@@ -803,6 +833,8 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
803 pmu->pmu = (struct pmu) { 833 pmu->pmu = (struct pmu) {
804 .attr_groups = pmu->type->attr_groups, 834 .attr_groups = pmu->type->attr_groups,
805 .task_ctx_nr = perf_invalid_context, 835 .task_ctx_nr = perf_invalid_context,
836 .pmu_enable = uncore_pmu_enable,
837 .pmu_disable = uncore_pmu_disable,
806 .event_init = uncore_pmu_event_init, 838 .event_init = uncore_pmu_event_init,
807 .add = uncore_pmu_event_add, 839 .add = uncore_pmu_event_add,
808 .del = uncore_pmu_event_del, 840 .del = uncore_pmu_event_del,
diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
index f36f7bebbc1b..bbfdaa720b45 100644
--- a/arch/x86/events/intel/uncore.h
+++ b/arch/x86/events/intel/uncore.h
@@ -441,18 +441,6 @@ static inline int uncore_freerunning_hw_config(struct intel_uncore_box *box,
441 return -EINVAL; 441 return -EINVAL;
442} 442}
443 443
444static inline void uncore_disable_box(struct intel_uncore_box *box)
445{
446 if (box->pmu->type->ops->disable_box)
447 box->pmu->type->ops->disable_box(box);
448}
449
450static inline void uncore_enable_box(struct intel_uncore_box *box)
451{
452 if (box->pmu->type->ops->enable_box)
453 box->pmu->type->ops->enable_box(box);
454}
455
456static inline void uncore_disable_event(struct intel_uncore_box *box, 444static inline void uncore_disable_event(struct intel_uncore_box *box,
457 struct perf_event *event) 445 struct perf_event *event)
458{ 446{
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ca200b50cde4..c5673bda4b66 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -734,8 +734,14 @@ static int get_npt_level(struct kvm_vcpu *vcpu)
734static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer) 734static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
735{ 735{
736 vcpu->arch.efer = efer; 736 vcpu->arch.efer = efer;
737 if (!npt_enabled && !(efer & EFER_LMA)) 737
738 efer &= ~EFER_LME; 738 if (!npt_enabled) {
739 /* Shadow paging assumes NX to be available. */
740 efer |= EFER_NX;
741
742 if (!(efer & EFER_LMA))
743 efer &= ~EFER_LME;
744 }
739 745
740 to_svm(vcpu)->vmcb->save.efer = efer | EFER_SVME; 746 to_svm(vcpu)->vmcb->save.efer = efer | EFER_SVME;
741 mark_dirty(to_svm(vcpu)->vmcb, VMCB_CR); 747 mark_dirty(to_svm(vcpu)->vmcb, VMCB_CR);
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 8f01019295a1..5d21a4ab28cf 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -969,17 +969,9 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
969 u64 guest_efer = vmx->vcpu.arch.efer; 969 u64 guest_efer = vmx->vcpu.arch.efer;
970 u64 ignore_bits = 0; 970 u64 ignore_bits = 0;
971 971
972 if (!enable_ept) { 972 /* Shadow paging assumes NX to be available. */
973 /* 973 if (!enable_ept)
974 * NX is needed to handle CR0.WP=1, CR4.SMEP=1. Testing 974 guest_efer |= EFER_NX;
975 * host CPUID is more efficient than testing guest CPUID
976 * or CR4. Host SMEP is anyway a requirement for guest SMEP.
977 */
978 if (boot_cpu_has(X86_FEATURE_SMEP))
979 guest_efer |= EFER_NX;
980 else if (!(guest_efer & EFER_NX))
981 ignore_bits |= EFER_NX;
982 }
983 975
984 /* 976 /*
985 * LMA and LME handled by hardware; SCE meaningless outside long mode. 977 * LMA and LME handled by hardware; SCE meaningless outside long mode.
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 2a3db80c1dce..a7ed434eae03 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2110,10 +2110,10 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf,
2110 goto einval; 2110 goto einval;
2111 } 2111 }
2112 2112
2113 spin_lock_irq(&iocg->ioc->lock); 2113 spin_lock(&iocg->ioc->lock);
2114 iocg->cfg_weight = v; 2114 iocg->cfg_weight = v;
2115 weight_updated(iocg); 2115 weight_updated(iocg);
2116 spin_unlock_irq(&iocg->ioc->lock); 2116 spin_unlock(&iocg->ioc->lock);
2117 2117
2118 blkg_conf_finish(&ctx); 2118 blkg_conf_finish(&ctx);
2119 return nbytes; 2119 return nbytes;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 753e171de006..5909e8fa4013 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -159,26 +159,34 @@ void acpi_processor_ignore_ppc_init(void)
159 159
160void acpi_processor_ppc_init(struct cpufreq_policy *policy) 160void acpi_processor_ppc_init(struct cpufreq_policy *policy)
161{ 161{
162 int cpu = policy->cpu; 162 unsigned int cpu;
163 struct acpi_processor *pr = per_cpu(processors, cpu);
164 int ret;
165 163
166 if (!pr) 164 for_each_cpu(cpu, policy->related_cpus) {
167 return; 165 struct acpi_processor *pr = per_cpu(processors, cpu);
166 int ret;
167
168 if (!pr)
169 continue;
168 170
169 ret = freq_qos_add_request(&policy->constraints, &pr->perflib_req, 171 ret = freq_qos_add_request(&policy->constraints,
170 FREQ_QOS_MAX, INT_MAX); 172 &pr->perflib_req,
171 if (ret < 0) 173 FREQ_QOS_MAX, INT_MAX);
172 pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu, 174 if (ret < 0)
173 ret); 175 pr_err("Failed to add freq constraint for CPU%d (%d)\n",
176 cpu, ret);
177 }
174} 178}
175 179
176void acpi_processor_ppc_exit(struct cpufreq_policy *policy) 180void acpi_processor_ppc_exit(struct cpufreq_policy *policy)
177{ 181{
178 struct acpi_processor *pr = per_cpu(processors, policy->cpu); 182 unsigned int cpu;
179 183
180 if (pr) 184 for_each_cpu(cpu, policy->related_cpus) {
181 freq_qos_remove_request(&pr->perflib_req); 185 struct acpi_processor *pr = per_cpu(processors, cpu);
186
187 if (pr)
188 freq_qos_remove_request(&pr->perflib_req);
189 }
182} 190}
183 191
184static int acpi_processor_get_performance_control(struct acpi_processor *pr) 192static int acpi_processor_get_performance_control(struct acpi_processor *pr)
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index c77a5b1fb107..41feb88ee92d 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -127,26 +127,34 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
127 127
128void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy) 128void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)
129{ 129{
130 int cpu = policy->cpu; 130 unsigned int cpu;
131 struct acpi_processor *pr = per_cpu(processors, cpu);
132 int ret;
133 131
134 if (!pr) 132 for_each_cpu(cpu, policy->related_cpus) {
135 return; 133 struct acpi_processor *pr = per_cpu(processors, cpu);
134 int ret;
135
136 if (!pr)
137 continue;
136 138
137 ret = freq_qos_add_request(&policy->constraints, &pr->thermal_req, 139 ret = freq_qos_add_request(&policy->constraints,
138 FREQ_QOS_MAX, INT_MAX); 140 &pr->thermal_req,
139 if (ret < 0) 141 FREQ_QOS_MAX, INT_MAX);
140 pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu, 142 if (ret < 0)
141 ret); 143 pr_err("Failed to add freq constraint for CPU%d (%d)\n",
144 cpu, ret);
145 }
142} 146}
143 147
144void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy) 148void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)
145{ 149{
146 struct acpi_processor *pr = per_cpu(processors, policy->cpu); 150 unsigned int cpu;
151
152 for_each_cpu(cpu, policy->related_cpus) {
153 struct acpi_processor *pr = per_cpu(processors, policy->cpu);
147 154
148 if (pr) 155 if (pr)
149 freq_qos_remove_request(&pr->thermal_req); 156 freq_qos_remove_request(&pr->thermal_req);
157 }
150} 158}
151#else /* ! CONFIG_CPU_FREQ */ 159#else /* ! CONFIG_CPU_FREQ */
152static int cpufreq_get_max_state(unsigned int cpu) 160static int cpufreq_get_max_state(unsigned int cpu)
diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c b/drivers/crypto/chelsio/chtls/chtls_cm.c
index 774d991d7cca..aca75237bbcf 100644
--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
+++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
@@ -1297,7 +1297,7 @@ static void make_established(struct sock *sk, u32 snd_isn, unsigned int opt)
1297 tp->write_seq = snd_isn; 1297 tp->write_seq = snd_isn;
1298 tp->snd_nxt = snd_isn; 1298 tp->snd_nxt = snd_isn;
1299 tp->snd_una = snd_isn; 1299 tp->snd_una = snd_isn;
1300 inet_sk(sk)->inet_id = tp->write_seq ^ jiffies; 1300 inet_sk(sk)->inet_id = prandom_u32();
1301 assign_rxopt(sk, opt); 1301 assign_rxopt(sk, opt);
1302 1302
1303 if (tp->rcv_wnd > (RCV_BUFSIZ_M << 10)) 1303 if (tp->rcv_wnd > (RCV_BUFSIZ_M << 10))
diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
index 0891ab829b1b..98bc5a4cd5e7 100644
--- a/drivers/crypto/chelsio/chtls/chtls_io.c
+++ b/drivers/crypto/chelsio/chtls/chtls_io.c
@@ -1702,7 +1702,7 @@ int chtls_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
1702 return peekmsg(sk, msg, len, nonblock, flags); 1702 return peekmsg(sk, msg, len, nonblock, flags);
1703 1703
1704 if (sk_can_busy_loop(sk) && 1704 if (sk_can_busy_loop(sk) &&
1705 skb_queue_empty(&sk->sk_receive_queue) && 1705 skb_queue_empty_lockless(&sk->sk_receive_queue) &&
1706 sk->sk_state == TCP_ESTABLISHED) 1706 sk->sk_state == TCP_ESTABLISHED)
1707 sk_busy_loop(sk, nonblock); 1707 sk_busy_loop(sk, nonblock);
1708 1708
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 9ba74ab7e912..c27e206a764c 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1707,6 +1707,14 @@ static void sdma_add_scripts(struct sdma_engine *sdma,
1707 if (!sdma->script_number) 1707 if (!sdma->script_number)
1708 sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; 1708 sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1;
1709 1709
1710 if (sdma->script_number > sizeof(struct sdma_script_start_addrs)
1711 / sizeof(s32)) {
1712 dev_err(sdma->dev,
1713 "SDMA script number %d not match with firmware.\n",
1714 sdma->script_number);
1715 return;
1716 }
1717
1710 for (i = 0; i < sdma->script_number; i++) 1718 for (i = 0; i < sdma->script_number; i++)
1711 if (addr_arr[i] > 0) 1719 if (addr_arr[i] > 0)
1712 saddr_arr[i] = addr_arr[i]; 1720 saddr_arr[i] = addr_arr[i];
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 8e90a405939d..ef73f65224b1 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -694,6 +694,25 @@ static int bam_dma_terminate_all(struct dma_chan *chan)
694 694
695 /* remove all transactions, including active transaction */ 695 /* remove all transactions, including active transaction */
696 spin_lock_irqsave(&bchan->vc.lock, flag); 696 spin_lock_irqsave(&bchan->vc.lock, flag);
697 /*
698 * If we have transactions queued, then some might be committed to the
699 * hardware in the desc fifo. The only way to reset the desc fifo is
700 * to do a hardware reset (either by pipe or the entire block).
701 * bam_chan_init_hw() will trigger a pipe reset, and also reinit the
702 * pipe. If the pipe is left disabled (default state after pipe reset)
703 * and is accessed by a connected hardware engine, a fatal error in
704 * the BAM will occur. There is a small window where this could happen
705 * with bam_chan_init_hw(), but it is assumed that the caller has
706 * stopped activity on any attached hardware engine. Make sure to do
707 * this first so that the BAM hardware doesn't cause memory corruption
708 * by accessing freed resources.
709 */
710 if (!list_empty(&bchan->desc_list)) {
711 async_desc = list_first_entry(&bchan->desc_list,
712 struct bam_async_desc, desc_node);
713 bam_chan_init_hw(bchan, async_desc->dir);
714 }
715
697 list_for_each_entry_safe(async_desc, tmp, 716 list_for_each_entry_safe(async_desc, tmp,
698 &bchan->desc_list, desc_node) { 717 &bchan->desc_list, desc_node) {
699 list_add(&async_desc->vd.node, &bchan->vc.desc_issued); 718 list_add(&async_desc->vd.node, &bchan->vc.desc_issued);
diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 525dc7338fe3..8546ad034720 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -134,6 +134,10 @@
134#define SPRD_DMA_SRC_TRSF_STEP_OFFSET 0 134#define SPRD_DMA_SRC_TRSF_STEP_OFFSET 0
135#define SPRD_DMA_TRSF_STEP_MASK GENMASK(15, 0) 135#define SPRD_DMA_TRSF_STEP_MASK GENMASK(15, 0)
136 136
137/* SPRD DMA_SRC_BLK_STEP register definition */
138#define SPRD_DMA_LLIST_HIGH_MASK GENMASK(31, 28)
139#define SPRD_DMA_LLIST_HIGH_SHIFT 28
140
137/* define DMA channel mode & trigger mode mask */ 141/* define DMA channel mode & trigger mode mask */
138#define SPRD_DMA_CHN_MODE_MASK GENMASK(7, 0) 142#define SPRD_DMA_CHN_MODE_MASK GENMASK(7, 0)
139#define SPRD_DMA_TRG_MODE_MASK GENMASK(7, 0) 143#define SPRD_DMA_TRG_MODE_MASK GENMASK(7, 0)
@@ -208,6 +212,7 @@ struct sprd_dma_dev {
208 struct sprd_dma_chn channels[0]; 212 struct sprd_dma_chn channels[0];
209}; 213};
210 214
215static void sprd_dma_free_desc(struct virt_dma_desc *vd);
211static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param); 216static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param);
212static struct of_dma_filter_info sprd_dma_info = { 217static struct of_dma_filter_info sprd_dma_info = {
213 .filter_fn = sprd_dma_filter_fn, 218 .filter_fn = sprd_dma_filter_fn,
@@ -609,12 +614,19 @@ static int sprd_dma_alloc_chan_resources(struct dma_chan *chan)
609static void sprd_dma_free_chan_resources(struct dma_chan *chan) 614static void sprd_dma_free_chan_resources(struct dma_chan *chan)
610{ 615{
611 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); 616 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan);
617 struct virt_dma_desc *cur_vd = NULL;
612 unsigned long flags; 618 unsigned long flags;
613 619
614 spin_lock_irqsave(&schan->vc.lock, flags); 620 spin_lock_irqsave(&schan->vc.lock, flags);
621 if (schan->cur_desc)
622 cur_vd = &schan->cur_desc->vd;
623
615 sprd_dma_stop(schan); 624 sprd_dma_stop(schan);
616 spin_unlock_irqrestore(&schan->vc.lock, flags); 625 spin_unlock_irqrestore(&schan->vc.lock, flags);
617 626
627 if (cur_vd)
628 sprd_dma_free_desc(cur_vd);
629
618 vchan_free_chan_resources(&schan->vc); 630 vchan_free_chan_resources(&schan->vc);
619 pm_runtime_put(chan->device->dev); 631 pm_runtime_put(chan->device->dev);
620} 632}
@@ -717,6 +729,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan,
717 u32 int_mode = flags & SPRD_DMA_INT_MASK; 729 u32 int_mode = flags & SPRD_DMA_INT_MASK;
718 int src_datawidth, dst_datawidth, src_step, dst_step; 730 int src_datawidth, dst_datawidth, src_step, dst_step;
719 u32 temp, fix_mode = 0, fix_en = 0; 731 u32 temp, fix_mode = 0, fix_en = 0;
732 phys_addr_t llist_ptr;
720 733
721 if (dir == DMA_MEM_TO_DEV) { 734 if (dir == DMA_MEM_TO_DEV) {
722 src_step = sprd_dma_get_step(slave_cfg->src_addr_width); 735 src_step = sprd_dma_get_step(slave_cfg->src_addr_width);
@@ -814,13 +827,16 @@ static int sprd_dma_fill_desc(struct dma_chan *chan,
814 * Set the link-list pointer point to next link-list 827 * Set the link-list pointer point to next link-list
815 * configuration's physical address. 828 * configuration's physical address.
816 */ 829 */
817 hw->llist_ptr = schan->linklist.phy_addr + temp; 830 llist_ptr = schan->linklist.phy_addr + temp;
831 hw->llist_ptr = lower_32_bits(llist_ptr);
832 hw->src_blk_step = (upper_32_bits(llist_ptr) << SPRD_DMA_LLIST_HIGH_SHIFT) &
833 SPRD_DMA_LLIST_HIGH_MASK;
818 } else { 834 } else {
819 hw->llist_ptr = 0; 835 hw->llist_ptr = 0;
836 hw->src_blk_step = 0;
820 } 837 }
821 838
822 hw->frg_step = 0; 839 hw->frg_step = 0;
823 hw->src_blk_step = 0;
824 hw->des_blk_step = 0; 840 hw->des_blk_step = 0;
825 return 0; 841 return 0;
826} 842}
@@ -1023,15 +1039,22 @@ static int sprd_dma_resume(struct dma_chan *chan)
1023static int sprd_dma_terminate_all(struct dma_chan *chan) 1039static int sprd_dma_terminate_all(struct dma_chan *chan)
1024{ 1040{
1025 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); 1041 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan);
1042 struct virt_dma_desc *cur_vd = NULL;
1026 unsigned long flags; 1043 unsigned long flags;
1027 LIST_HEAD(head); 1044 LIST_HEAD(head);
1028 1045
1029 spin_lock_irqsave(&schan->vc.lock, flags); 1046 spin_lock_irqsave(&schan->vc.lock, flags);
1047 if (schan->cur_desc)
1048 cur_vd = &schan->cur_desc->vd;
1049
1030 sprd_dma_stop(schan); 1050 sprd_dma_stop(schan);
1031 1051
1032 vchan_get_all_descriptors(&schan->vc, &head); 1052 vchan_get_all_descriptors(&schan->vc, &head);
1033 spin_unlock_irqrestore(&schan->vc.lock, flags); 1053 spin_unlock_irqrestore(&schan->vc.lock, flags);
1034 1054
1055 if (cur_vd)
1056 sprd_dma_free_desc(cur_vd);
1057
1035 vchan_dma_desc_free_list(&schan->vc, &head); 1058 vchan_dma_desc_free_list(&schan->vc, &head);
1036 return 0; 1059 return 0;
1037} 1060}
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 5f8adf5c1f20..6e1268552f74 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -40,6 +40,7 @@
40#define ADMA_CH_CONFIG_MAX_BURST_SIZE 16 40#define ADMA_CH_CONFIG_MAX_BURST_SIZE 16
41#define ADMA_CH_CONFIG_WEIGHT_FOR_WRR(val) ((val) & 0xf) 41#define ADMA_CH_CONFIG_WEIGHT_FOR_WRR(val) ((val) & 0xf)
42#define ADMA_CH_CONFIG_MAX_BUFS 8 42#define ADMA_CH_CONFIG_MAX_BUFS 8
43#define TEGRA186_ADMA_CH_CONFIG_OUTSTANDING_REQS(reqs) (reqs << 4)
43 44
44#define ADMA_CH_FIFO_CTRL 0x2c 45#define ADMA_CH_FIFO_CTRL 0x2c
45#define TEGRA210_ADMA_CH_FIFO_CTRL_TXSIZE(val) (((val) & 0xf) << 8) 46#define TEGRA210_ADMA_CH_FIFO_CTRL_TXSIZE(val) (((val) & 0xf) << 8)
@@ -77,6 +78,7 @@ struct tegra_adma;
77 * @ch_req_tx_shift: Register offset for AHUB transmit channel select. 78 * @ch_req_tx_shift: Register offset for AHUB transmit channel select.
78 * @ch_req_rx_shift: Register offset for AHUB receive channel select. 79 * @ch_req_rx_shift: Register offset for AHUB receive channel select.
79 * @ch_base_offset: Register offset of DMA channel registers. 80 * @ch_base_offset: Register offset of DMA channel registers.
81 * @has_outstanding_reqs: If DMA channel can have outstanding requests.
80 * @ch_fifo_ctrl: Default value for channel FIFO CTRL register. 82 * @ch_fifo_ctrl: Default value for channel FIFO CTRL register.
81 * @ch_req_mask: Mask for Tx or Rx channel select. 83 * @ch_req_mask: Mask for Tx or Rx channel select.
82 * @ch_req_max: Maximum number of Tx or Rx channels available. 84 * @ch_req_max: Maximum number of Tx or Rx channels available.
@@ -95,6 +97,7 @@ struct tegra_adma_chip_data {
95 unsigned int ch_req_max; 97 unsigned int ch_req_max;
96 unsigned int ch_reg_size; 98 unsigned int ch_reg_size;
97 unsigned int nr_channels; 99 unsigned int nr_channels;
100 bool has_outstanding_reqs;
98}; 101};
99 102
100/* 103/*
@@ -594,6 +597,8 @@ static int tegra_adma_set_xfer_params(struct tegra_adma_chan *tdc,
594 ADMA_CH_CTRL_FLOWCTRL_EN; 597 ADMA_CH_CTRL_FLOWCTRL_EN;
595 ch_regs->config |= cdata->adma_get_burst_config(burst_size); 598 ch_regs->config |= cdata->adma_get_burst_config(burst_size);
596 ch_regs->config |= ADMA_CH_CONFIG_WEIGHT_FOR_WRR(1); 599 ch_regs->config |= ADMA_CH_CONFIG_WEIGHT_FOR_WRR(1);
600 if (cdata->has_outstanding_reqs)
601 ch_regs->config |= TEGRA186_ADMA_CH_CONFIG_OUTSTANDING_REQS(8);
597 ch_regs->fifo_ctrl = cdata->ch_fifo_ctrl; 602 ch_regs->fifo_ctrl = cdata->ch_fifo_ctrl;
598 ch_regs->tc = desc->period_len & ADMA_CH_TC_COUNT_MASK; 603 ch_regs->tc = desc->period_len & ADMA_CH_TC_COUNT_MASK;
599 604
@@ -778,6 +783,7 @@ static const struct tegra_adma_chip_data tegra210_chip_data = {
778 .ch_req_tx_shift = 28, 783 .ch_req_tx_shift = 28,
779 .ch_req_rx_shift = 24, 784 .ch_req_rx_shift = 24,
780 .ch_base_offset = 0, 785 .ch_base_offset = 0,
786 .has_outstanding_reqs = false,
781 .ch_fifo_ctrl = TEGRA210_FIFO_CTRL_DEFAULT, 787 .ch_fifo_ctrl = TEGRA210_FIFO_CTRL_DEFAULT,
782 .ch_req_mask = 0xf, 788 .ch_req_mask = 0xf,
783 .ch_req_max = 10, 789 .ch_req_max = 10,
@@ -792,6 +798,7 @@ static const struct tegra_adma_chip_data tegra186_chip_data = {
792 .ch_req_tx_shift = 27, 798 .ch_req_tx_shift = 27,
793 .ch_req_rx_shift = 22, 799 .ch_req_rx_shift = 22,
794 .ch_base_offset = 0x10000, 800 .ch_base_offset = 0x10000,
801 .has_outstanding_reqs = true,
795 .ch_fifo_ctrl = TEGRA186_FIFO_CTRL_DEFAULT, 802 .ch_fifo_ctrl = TEGRA186_FIFO_CTRL_DEFAULT,
796 .ch_req_mask = 0x1f, 803 .ch_req_mask = 0x1f,
797 .ch_req_max = 20, 804 .ch_req_max = 20,
diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
index 2f946f55076c..8c2f7ebe998c 100644
--- a/drivers/dma/ti/cppi41.c
+++ b/drivers/dma/ti/cppi41.c
@@ -586,9 +586,22 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg(
586 enum dma_transfer_direction dir, unsigned long tx_flags, void *context) 586 enum dma_transfer_direction dir, unsigned long tx_flags, void *context)
587{ 587{
588 struct cppi41_channel *c = to_cpp41_chan(chan); 588 struct cppi41_channel *c = to_cpp41_chan(chan);
589 struct dma_async_tx_descriptor *txd = NULL;
590 struct cppi41_dd *cdd = c->cdd;
589 struct cppi41_desc *d; 591 struct cppi41_desc *d;
590 struct scatterlist *sg; 592 struct scatterlist *sg;
591 unsigned int i; 593 unsigned int i;
594 int error;
595
596 error = pm_runtime_get(cdd->ddev.dev);
597 if (error < 0) {
598 pm_runtime_put_noidle(cdd->ddev.dev);
599
600 return NULL;
601 }
602
603 if (cdd->is_suspended)
604 goto err_out_not_ready;
592 605
593 d = c->desc; 606 d = c->desc;
594 for_each_sg(sgl, sg, sg_len, i) { 607 for_each_sg(sgl, sg, sg_len, i) {
@@ -611,7 +624,13 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg(
611 d++; 624 d++;
612 } 625 }
613 626
614 return &c->txd; 627 txd = &c->txd;
628
629err_out_not_ready:
630 pm_runtime_mark_last_busy(cdd->ddev.dev);
631 pm_runtime_put_autosuspend(cdd->ddev.dev);
632
633 return txd;
615} 634}
616 635
617static void cppi41_compute_td_desc(struct cppi41_desc *d) 636static void cppi41_compute_td_desc(struct cppi41_desc *d)
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index e7dc3c4dc8e0..5d56f1e4d332 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -68,6 +68,9 @@
68#define XILINX_DMA_DMACR_CIRC_EN BIT(1) 68#define XILINX_DMA_DMACR_CIRC_EN BIT(1)
69#define XILINX_DMA_DMACR_RUNSTOP BIT(0) 69#define XILINX_DMA_DMACR_RUNSTOP BIT(0)
70#define XILINX_DMA_DMACR_FSYNCSRC_MASK GENMASK(6, 5) 70#define XILINX_DMA_DMACR_FSYNCSRC_MASK GENMASK(6, 5)
71#define XILINX_DMA_DMACR_DELAY_MASK GENMASK(31, 24)
72#define XILINX_DMA_DMACR_FRAME_COUNT_MASK GENMASK(23, 16)
73#define XILINX_DMA_DMACR_MASTER_MASK GENMASK(11, 8)
71 74
72#define XILINX_DMA_REG_DMASR 0x0004 75#define XILINX_DMA_REG_DMASR 0x0004
73#define XILINX_DMA_DMASR_EOL_LATE_ERR BIT(15) 76#define XILINX_DMA_DMASR_EOL_LATE_ERR BIT(15)
@@ -1354,7 +1357,8 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan)
1354 node); 1357 node);
1355 hw = &segment->hw; 1358 hw = &segment->hw;
1356 1359
1357 xilinx_write(chan, XILINX_DMA_REG_SRCDSTADDR, hw->buf_addr); 1360 xilinx_write(chan, XILINX_DMA_REG_SRCDSTADDR,
1361 xilinx_prep_dma_addr_t(hw->buf_addr));
1358 1362
1359 /* Start the transfer */ 1363 /* Start the transfer */
1360 dma_ctrl_write(chan, XILINX_DMA_REG_BTT, 1364 dma_ctrl_write(chan, XILINX_DMA_REG_BTT,
@@ -2117,8 +2121,10 @@ int xilinx_vdma_channel_set_config(struct dma_chan *dchan,
2117 chan->config.gen_lock = cfg->gen_lock; 2121 chan->config.gen_lock = cfg->gen_lock;
2118 chan->config.master = cfg->master; 2122 chan->config.master = cfg->master;
2119 2123
2124 dmacr &= ~XILINX_DMA_DMACR_GENLOCK_EN;
2120 if (cfg->gen_lock && chan->genlock) { 2125 if (cfg->gen_lock && chan->genlock) {
2121 dmacr |= XILINX_DMA_DMACR_GENLOCK_EN; 2126 dmacr |= XILINX_DMA_DMACR_GENLOCK_EN;
2127 dmacr &= ~XILINX_DMA_DMACR_MASTER_MASK;
2122 dmacr |= cfg->master << XILINX_DMA_DMACR_MASTER_SHIFT; 2128 dmacr |= cfg->master << XILINX_DMA_DMACR_MASTER_SHIFT;
2123 } 2129 }
2124 2130
@@ -2134,11 +2140,13 @@ int xilinx_vdma_channel_set_config(struct dma_chan *dchan,
2134 chan->config.delay = cfg->delay; 2140 chan->config.delay = cfg->delay;
2135 2141
2136 if (cfg->coalesc <= XILINX_DMA_DMACR_FRAME_COUNT_MAX) { 2142 if (cfg->coalesc <= XILINX_DMA_DMACR_FRAME_COUNT_MAX) {
2143 dmacr &= ~XILINX_DMA_DMACR_FRAME_COUNT_MASK;
2137 dmacr |= cfg->coalesc << XILINX_DMA_DMACR_FRAME_COUNT_SHIFT; 2144 dmacr |= cfg->coalesc << XILINX_DMA_DMACR_FRAME_COUNT_SHIFT;
2138 chan->config.coalesc = cfg->coalesc; 2145 chan->config.coalesc = cfg->coalesc;
2139 } 2146 }
2140 2147
2141 if (cfg->delay <= XILINX_DMA_DMACR_DELAY_MAX) { 2148 if (cfg->delay <= XILINX_DMA_DMACR_DELAY_MAX) {
2149 dmacr &= ~XILINX_DMA_DMACR_DELAY_MASK;
2142 dmacr |= cfg->delay << XILINX_DMA_DMACR_DELAY_SHIFT; 2150 dmacr |= cfg->delay << XILINX_DMA_DMACR_DELAY_SHIFT;
2143 chan->config.delay = cfg->delay; 2151 chan->config.delay = cfg->delay;
2144 } 2152 }
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 178ee8106828..b248870a9806 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -182,6 +182,7 @@ config RESET_ATTACK_MITIGATION
182 182
183config EFI_RCI2_TABLE 183config EFI_RCI2_TABLE
184 bool "EFI Runtime Configuration Interface Table Version 2 Support" 184 bool "EFI Runtime Configuration Interface Table Version 2 Support"
185 depends on X86 || COMPILE_TEST
185 help 186 help
186 Displays the content of the Runtime Configuration Interface 187 Displays the content of the Runtime Configuration Interface
187 Table version 2 on Dell EMC PowerEdge systems as a binary 188 Table version 2 on Dell EMC PowerEdge systems as a binary
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 69f00f7453a3..e98bbf8e56d9 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -554,7 +554,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
554 sizeof(*seed) + size); 554 sizeof(*seed) + size);
555 if (seed != NULL) { 555 if (seed != NULL) {
556 pr_notice("seeding entropy pool\n"); 556 pr_notice("seeding entropy pool\n");
557 add_device_randomness(seed->bits, seed->size); 557 add_bootloader_randomness(seed->bits, seed->size);
558 early_memunmap(seed, sizeof(*seed) + size); 558 early_memunmap(seed, sizeof(*seed) + size);
559 } else { 559 } else {
560 pr_err("Could not map UEFI random seed!\n"); 560 pr_err("Could not map UEFI random seed!\n");
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 0460c7581220..ee0661ddb25b 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -52,6 +52,7 @@ lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \
52 52
53lib-$(CONFIG_ARM) += arm32-stub.o 53lib-$(CONFIG_ARM) += arm32-stub.o
54lib-$(CONFIG_ARM64) += arm64-stub.o 54lib-$(CONFIG_ARM64) += arm64-stub.o
55CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
55CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 56CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
56 57
57# 58#
diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index e8f7aefb6813..41213bf5fcf5 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -195,6 +195,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
195 unsigned long dram_base, 195 unsigned long dram_base,
196 efi_loaded_image_t *image) 196 efi_loaded_image_t *image)
197{ 197{
198 unsigned long kernel_base;
198 efi_status_t status; 199 efi_status_t status;
199 200
200 /* 201 /*
@@ -204,9 +205,18 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
204 * loaded. These assumptions are made by the decompressor, 205 * loaded. These assumptions are made by the decompressor,
205 * before any memory map is available. 206 * before any memory map is available.
206 */ 207 */
207 dram_base = round_up(dram_base, SZ_128M); 208 kernel_base = round_up(dram_base, SZ_128M);
208 209
209 status = reserve_kernel_base(sys_table, dram_base, reserve_addr, 210 /*
211 * Note that some platforms (notably, the Raspberry Pi 2) put
212 * spin-tables and other pieces of firmware at the base of RAM,
213 * abusing the fact that the window of TEXT_OFFSET bytes at the
214 * base of the kernel image is only partially used at the moment.
215 * (Up to 5 pages are used for the swapper page tables)
216 */
217 kernel_base += TEXT_OFFSET - 5 * PAGE_SIZE;
218
219 status = reserve_kernel_base(sys_table, kernel_base, reserve_addr,
210 reserve_size); 220 reserve_size);
211 if (status != EFI_SUCCESS) { 221 if (status != EFI_SUCCESS) {
212 pr_efi_err(sys_table, "Unable to allocate memory for uncompressed kernel.\n"); 222 pr_efi_err(sys_table, "Unable to allocate memory for uncompressed kernel.\n");
@@ -220,7 +230,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
220 *image_size = image->image_size; 230 *image_size = image->image_size;
221 status = efi_relocate_kernel(sys_table, image_addr, *image_size, 231 status = efi_relocate_kernel(sys_table, image_addr, *image_size,
222 *image_size, 232 *image_size,
223 dram_base + MAX_UNCOMP_KERNEL_SIZE, 0); 233 kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0);
224 if (status != EFI_SUCCESS) { 234 if (status != EFI_SUCCESS) {
225 pr_efi_err(sys_table, "Failed to relocate kernel.\n"); 235 pr_efi_err(sys_table, "Failed to relocate kernel.\n");
226 efi_free(sys_table, *reserve_size, *reserve_addr); 236 efi_free(sys_table, *reserve_size, *reserve_addr);
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 3caae7f2cf56..35dbc2791c97 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -260,11 +260,11 @@ fail:
260} 260}
261 261
262/* 262/*
263 * Allocate at the lowest possible address. 263 * Allocate at the lowest possible address that is not below 'min'.
264 */ 264 */
265efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, 265efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg,
266 unsigned long size, unsigned long align, 266 unsigned long size, unsigned long align,
267 unsigned long *addr) 267 unsigned long *addr, unsigned long min)
268{ 268{
269 unsigned long map_size, desc_size, buff_size; 269 unsigned long map_size, desc_size, buff_size;
270 efi_memory_desc_t *map; 270 efi_memory_desc_t *map;
@@ -311,13 +311,8 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
311 start = desc->phys_addr; 311 start = desc->phys_addr;
312 end = start + desc->num_pages * EFI_PAGE_SIZE; 312 end = start + desc->num_pages * EFI_PAGE_SIZE;
313 313
314 /* 314 if (start < min)
315 * Don't allocate at 0x0. It will confuse code that 315 start = min;
316 * checks pointers against NULL. Skip the first 8
317 * bytes so we start at a nice even number.
318 */
319 if (start == 0x0)
320 start += 8;
321 316
322 start = round_up(start, align); 317 start = round_up(start, align);
323 if ((start + size) > end) 318 if ((start + size) > end)
@@ -698,7 +693,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
698 unsigned long image_size, 693 unsigned long image_size,
699 unsigned long alloc_size, 694 unsigned long alloc_size,
700 unsigned long preferred_addr, 695 unsigned long preferred_addr,
701 unsigned long alignment) 696 unsigned long alignment,
697 unsigned long min_addr)
702{ 698{
703 unsigned long cur_image_addr; 699 unsigned long cur_image_addr;
704 unsigned long new_addr = 0; 700 unsigned long new_addr = 0;
@@ -731,8 +727,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
731 * possible. 727 * possible.
732 */ 728 */
733 if (status != EFI_SUCCESS) { 729 if (status != EFI_SUCCESS) {
734 status = efi_low_alloc(sys_table_arg, alloc_size, alignment, 730 status = efi_low_alloc_above(sys_table_arg, alloc_size,
735 &new_addr); 731 alignment, &new_addr, min_addr);
736 } 732 }
737 if (status != EFI_SUCCESS) { 733 if (status != EFI_SUCCESS) {
738 pr_efi_err(sys_table_arg, "Failed to allocate usable memory for kernel.\n"); 734 pr_efi_err(sys_table_arg, "Failed to allocate usable memory for kernel.\n");
diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 877745c3aaf2..7baf48c01e72 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/efi.h> 16#include <linux/efi.h>
17#include <linux/security.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
18#include <linux/uaccess.h> 19#include <linux/uaccess.h>
19 20
@@ -717,6 +718,13 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd,
717 718
718static int efi_test_open(struct inode *inode, struct file *file) 719static int efi_test_open(struct inode *inode, struct file *file)
719{ 720{
721 int ret = security_locked_down(LOCKDOWN_EFI_TEST);
722
723 if (ret)
724 return ret;
725
726 if (!capable(CAP_SYS_ADMIN))
727 return -EACCES;
720 /* 728 /*
721 * nothing special to do here 729 * nothing special to do here
722 * We do accept multiple open files at the same time as we 730 * We do accept multiple open files at the same time as we
diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index ebd7977653a8..31f9f0e369b9 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -88,6 +88,7 @@ int __init efi_tpm_eventlog_init(void)
88 88
89 if (tbl_size < 0) { 89 if (tbl_size < 0) {
90 pr_err(FW_BUG "Failed to parse event in TPM Final Events Log\n"); 90 pr_err(FW_BUG "Failed to parse event in TPM Final Events Log\n");
91 ret = -EINVAL;
91 goto out_calc; 92 goto out_calc;
92 } 93 }
93 94
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 9d76e0923a5a..96b2a31ccfed 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -218,7 +218,7 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)
218 struct amdgpu_ring *ring = to_amdgpu_ring(sched_job->sched); 218 struct amdgpu_ring *ring = to_amdgpu_ring(sched_job->sched);
219 struct dma_fence *fence = NULL, *finished; 219 struct dma_fence *fence = NULL, *finished;
220 struct amdgpu_job *job; 220 struct amdgpu_job *job;
221 int r; 221 int r = 0;
222 222
223 job = to_amdgpu_job(sched_job); 223 job = to_amdgpu_job(sched_job);
224 finished = &job->base.s_fence->finished; 224 finished = &job->base.s_fence->finished;
@@ -243,6 +243,8 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)
243 job->fence = dma_fence_get(fence); 243 job->fence = dma_fence_get(fence);
244 244
245 amdgpu_job_free_resources(job); 245 amdgpu_job_free_resources(job);
246
247 fence = r ? ERR_PTR(r) : fence;
246 return fence; 248 return fence;
247} 249}
248 250
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 957811b73672..8dfc775626a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -93,7 +93,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1[] =
93{ 93{
94 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x00400014), 94 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x00400014),
95 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_CPF_CLK_CTRL, 0xfcff8fff, 0xf8000100), 95 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_CPF_CLK_CTRL, 0xfcff8fff, 0xf8000100),
96 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xc0000000, 0xc0000100), 96 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xcd000000, 0x0d000100),
97 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0x60000ff0, 0x60000100), 97 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0x60000ff0, 0x60000100),
98 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000000, 0x40000100), 98 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000000, 0x40000100),
99 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), 99 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100),
@@ -140,7 +140,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_1[] =
140 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x003c0014), 140 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x003c0014),
141 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100), 141 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100),
142 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100), 142 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100),
143 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xc0000000, 0xc0000100), 143 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xcd000000, 0x0d000100),
144 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xf8ff0fff, 0x60000100), 144 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xf8ff0fff, 0x60000100),
145 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000ff0, 0x40000100), 145 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000ff0, 0x40000100),
146 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), 146 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100),
@@ -179,7 +179,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_2[] =
179 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x003e001f, 0x003c0014), 179 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x003e001f, 0x003c0014),
180 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100), 180 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100),
181 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100), 181 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100),
182 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 0xc0000100), 182 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 0x0d000100),
183 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xffffcfff, 0x60000100), 183 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xffffcfff, 0x60000100),
184 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0xffff0fff, 0x40000100), 184 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0xffff0fff, 0x40000100),
185 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), 185 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100),
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
index 8b789f750b72..db10640a3b2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
@@ -151,6 +151,15 @@ static void gfxhub_v2_0_init_cache_regs(struct amdgpu_device *adev)
151 WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL2, tmp); 151 WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL2, tmp);
152 152
153 tmp = mmGCVM_L2_CNTL3_DEFAULT; 153 tmp = mmGCVM_L2_CNTL3_DEFAULT;
154 if (adev->gmc.translate_further) {
155 tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, BANK_SELECT, 12);
156 tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3,
157 L2_CACHE_BIGK_FRAGMENT_SIZE, 9);
158 } else {
159 tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, BANK_SELECT, 9);
160 tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3,
161 L2_CACHE_BIGK_FRAGMENT_SIZE, 6);
162 }
154 WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL3, tmp); 163 WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL3, tmp);
155 164
156 tmp = mmGCVM_L2_CNTL4_DEFAULT; 165 tmp = mmGCVM_L2_CNTL4_DEFAULT;
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 241a4e57cf4a..354e6200ca9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -309,6 +309,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,
309 309
310 job->vm_pd_addr = amdgpu_gmc_pd_addr(adev->gart.bo); 310 job->vm_pd_addr = amdgpu_gmc_pd_addr(adev->gart.bo);
311 job->vm_needs_flush = true; 311 job->vm_needs_flush = true;
312 job->ibs->ptr[job->ibs->length_dw++] = ring->funcs->nop;
312 amdgpu_ring_pad_ib(ring, &job->ibs[0]); 313 amdgpu_ring_pad_ib(ring, &job->ibs[0]);
313 r = amdgpu_job_submit(job, &adev->mman.entity, 314 r = amdgpu_job_submit(job, &adev->mman.entity,
314 AMDGPU_FENCE_OWNER_UNDEFINED, &fence); 315 AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
index 3542c203c3c8..b39bea6f54e9 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
@@ -137,6 +137,15 @@ static void mmhub_v2_0_init_cache_regs(struct amdgpu_device *adev)
137 WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL2, tmp); 137 WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL2, tmp);
138 138
139 tmp = mmMMVM_L2_CNTL3_DEFAULT; 139 tmp = mmMMVM_L2_CNTL3_DEFAULT;
140 if (adev->gmc.translate_further) {
141 tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, BANK_SELECT, 12);
142 tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3,
143 L2_CACHE_BIGK_FRAGMENT_SIZE, 9);
144 } else {
145 tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, BANK_SELECT, 9);
146 tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3,
147 L2_CACHE_BIGK_FRAGMENT_SIZE, 6);
148 }
140 WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL3, tmp); 149 WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL3, tmp);
141 150
142 tmp = mmMMVM_L2_CNTL4_DEFAULT; 151 tmp = mmMMVM_L2_CNTL4_DEFAULT;
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index 78452cf0115d..4554e72c8378 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -254,6 +254,7 @@ static const struct soc15_reg_golden golden_settings_sdma_4_3[] = {
254 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), 254 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000),
255 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), 255 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000),
256 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), 256 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0),
257 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000)
257}; 258};
258 259
259static u32 sdma_v4_0_get_reg_offset(struct amdgpu_device *adev, 260static u32 sdma_v4_0_get_reg_offset(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
index 985633c08a26..26c6d735cdc7 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
@@ -24,15 +24,20 @@
24# It calculates Bandwidth and Watermarks values for HW programming 24# It calculates Bandwidth and Watermarks values for HW programming
25# 25#
26 26
27ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) 27calcs_ccflags := -mhard-float -msse
28 cc_stack_align := -mpreferred-stack-boundary=4
29else ifneq ($(call cc-option, -mstack-alignment=16),)
30 cc_stack_align := -mstack-alignment=16
31endif
32 28
33calcs_ccflags := -mhard-float -msse $(cc_stack_align) 29ifdef CONFIG_CC_IS_GCC
30ifeq ($(call cc-ifversion, -lt, 0701, y), y)
31IS_OLD_GCC = 1
32endif
33endif
34 34
35ifdef CONFIG_CC_IS_CLANG 35ifdef IS_OLD_GCC
36# Stack alignment mismatch, proceed with caution.
37# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
38# (8B stack alignment).
39calcs_ccflags += -mpreferred-stack-boundary=4
40else
36calcs_ccflags += -msse2 41calcs_ccflags += -msse2
37endif 42endif
38 43
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 5d1adeda4d90..4b8819c27fcd 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -580,6 +580,10 @@ static bool construct(struct dc *dc,
580#ifdef CONFIG_DRM_AMD_DC_DCN2_0 580#ifdef CONFIG_DRM_AMD_DC_DCN2_0
581 // Allocate memory for the vm_helper 581 // Allocate memory for the vm_helper
582 dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL); 582 dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL);
583 if (!dc->vm_helper) {
584 dm_error("%s: failed to create dc->vm_helper\n", __func__);
585 goto fail;
586 }
583 587
584#endif 588#endif
585 memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides)); 589 memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides));
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index ca20b150afcc..9c58670d5414 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -2767,6 +2767,15 @@ void core_link_enable_stream(
2767 CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, 2767 CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
2768 COLOR_DEPTH_UNDEFINED); 2768 COLOR_DEPTH_UNDEFINED);
2769 2769
2770 /* This second call is needed to reconfigure the DIG
2771 * as a workaround for the incorrect value being applied
2772 * from transmitter control.
2773 */
2774 if (!dc_is_virtual_signal(pipe_ctx->stream->signal))
2775 stream->link->link_enc->funcs->setup(
2776 stream->link->link_enc,
2777 pipe_ctx->stream->signal);
2778
2770#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT 2779#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
2771 if (pipe_ctx->stream->timing.flags.DSC) { 2780 if (pipe_ctx->stream->timing.flags.DSC) {
2772 if (dc_is_dp_signal(pipe_ctx->stream->signal) || 2781 if (dc_is_dp_signal(pipe_ctx->stream->signal) ||
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index 505967b48e14..51991bf26a93 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -374,6 +374,7 @@ void dal_ddc_service_i2c_query_dp_dual_mode_adaptor(
374 enum display_dongle_type *dongle = &sink_cap->dongle_type; 374 enum display_dongle_type *dongle = &sink_cap->dongle_type;
375 uint8_t type2_dongle_buf[DP_ADAPTOR_TYPE2_SIZE]; 375 uint8_t type2_dongle_buf[DP_ADAPTOR_TYPE2_SIZE];
376 bool is_type2_dongle = false; 376 bool is_type2_dongle = false;
377 int retry_count = 2;
377 struct dp_hdmi_dongle_signature_data *dongle_signature; 378 struct dp_hdmi_dongle_signature_data *dongle_signature;
378 379
379 /* Assume we have no valid DP passive dongle connected */ 380 /* Assume we have no valid DP passive dongle connected */
@@ -386,13 +387,24 @@ void dal_ddc_service_i2c_query_dp_dual_mode_adaptor(
386 DP_HDMI_DONGLE_ADDRESS, 387 DP_HDMI_DONGLE_ADDRESS,
387 type2_dongle_buf, 388 type2_dongle_buf,
388 sizeof(type2_dongle_buf))) { 389 sizeof(type2_dongle_buf))) {
389 *dongle = DISPLAY_DONGLE_DP_DVI_DONGLE; 390 /* Passive HDMI dongles can sometimes fail here without retrying*/
390 sink_cap->max_hdmi_pixel_clock = DP_ADAPTOR_DVI_MAX_TMDS_CLK; 391 while (retry_count > 0) {
392 if (i2c_read(ddc,
393 DP_HDMI_DONGLE_ADDRESS,
394 type2_dongle_buf,
395 sizeof(type2_dongle_buf)))
396 break;
397 retry_count--;
398 }
399 if (retry_count == 0) {
400 *dongle = DISPLAY_DONGLE_DP_DVI_DONGLE;
401 sink_cap->max_hdmi_pixel_clock = DP_ADAPTOR_DVI_MAX_TMDS_CLK;
391 402
392 CONN_DATA_DETECT(ddc->link, type2_dongle_buf, sizeof(type2_dongle_buf), 403 CONN_DATA_DETECT(ddc->link, type2_dongle_buf, sizeof(type2_dongle_buf),
393 "DP-DVI passive dongle %dMhz: ", 404 "DP-DVI passive dongle %dMhz: ",
394 DP_ADAPTOR_DVI_MAX_TMDS_CLK / 1000); 405 DP_ADAPTOR_DVI_MAX_TMDS_CLK / 1000);
395 return; 406 return;
407 }
396 } 408 }
397 409
398 /* Check if Type 2 dongle.*/ 410 /* Check if Type 2 dongle.*/
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 8f70295179ff..f25ac17f47fa 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -404,6 +404,9 @@ bool resource_are_streams_timing_synchronizable(
404 if (stream1->view_format != stream2->view_format) 404 if (stream1->view_format != stream2->view_format)
405 return false; 405 return false;
406 406
407 if (stream1->ignore_msa_timing_param || stream2->ignore_msa_timing_param)
408 return false;
409
407 return true; 410 return true;
408} 411}
409static bool is_dp_and_hdmi_sharable( 412static bool is_dp_and_hdmi_sharable(
@@ -1540,6 +1543,9 @@ bool dc_is_stream_unchanged(
1540 if (!are_stream_backends_same(old_stream, stream)) 1543 if (!are_stream_backends_same(old_stream, stream))
1541 return false; 1544 return false;
1542 1545
1546 if (old_stream->ignore_msa_timing_param != stream->ignore_msa_timing_param)
1547 return false;
1548
1543 return true; 1549 return true;
1544} 1550}
1545 1551
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c
index 01c7e30b9ce1..bbd6e01b3eca 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c
@@ -393,6 +393,10 @@ bool cm_helper_translate_curve_to_hw_format(
393 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; 393 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
394 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; 394 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
395 395
396 rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red;
397 rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green;
398 rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue;
399
396 // All 3 color channels have same x 400 // All 3 color channels have same x
397 corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), 401 corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2),
398 dc_fixpt_from_int(region_start)); 402 dc_fixpt_from_int(region_start));
@@ -464,13 +468,6 @@ bool cm_helper_translate_curve_to_hw_format(
464 468
465 i = 1; 469 i = 1;
466 while (i != hw_points + 1) { 470 while (i != hw_points + 1) {
467 if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
468 rgb_plus_1->red = rgb->red;
469 if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
470 rgb_plus_1->green = rgb->green;
471 if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
472 rgb_plus_1->blue = rgb->blue;
473
474 rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); 471 rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
475 rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); 472 rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
476 rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); 473 rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
@@ -562,6 +559,10 @@ bool cm_helper_translate_curve_to_degamma_hw_format(
562 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; 559 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
563 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; 560 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
564 561
562 rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red;
563 rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green;
564 rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue;
565
565 corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), 566 corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2),
566 dc_fixpt_from_int(region_start)); 567 dc_fixpt_from_int(region_start));
567 corner_points[0].green.x = corner_points[0].red.x; 568 corner_points[0].green.x = corner_points[0].red.x;
@@ -624,13 +625,6 @@ bool cm_helper_translate_curve_to_degamma_hw_format(
624 625
625 i = 1; 626 i = 1;
626 while (i != hw_points + 1) { 627 while (i != hw_points + 1) {
627 if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
628 rgb_plus_1->red = rgb->red;
629 if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
630 rgb_plus_1->green = rgb->green;
631 if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
632 rgb_plus_1->blue = rgb->blue;
633
634 rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); 628 rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
635 rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); 629 rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
636 rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); 630 rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
index ddb8d5649e79..63f3bddba7da 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
@@ -10,15 +10,20 @@ ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
10DCN20 += dcn20_dsc.o 10DCN20 += dcn20_dsc.o
11endif 11endif
12 12
13ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) 13CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse
14 cc_stack_align := -mpreferred-stack-boundary=4
15else ifneq ($(call cc-option, -mstack-alignment=16),)
16 cc_stack_align := -mstack-alignment=16
17endif
18 14
19CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align) 15ifdef CONFIG_CC_IS_GCC
16ifeq ($(call cc-ifversion, -lt, 0701, y), y)
17IS_OLD_GCC = 1
18endif
19endif
20 20
21ifdef CONFIG_CC_IS_CLANG 21ifdef IS_OLD_GCC
22# Stack alignment mismatch, proceed with caution.
23# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
24# (8B stack alignment).
25CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -mpreferred-stack-boundary=4
26else
22CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2 27CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2
23endif 28endif
24 29
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
index 5a2763daff4d..dfb208285a9c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -814,7 +814,7 @@ static const struct resource_caps res_cap_nv14 = {
814 .num_audio = 6, 814 .num_audio = 6,
815 .num_stream_encoder = 5, 815 .num_stream_encoder = 5,
816 .num_pll = 5, 816 .num_pll = 5,
817 .num_dwb = 0, 817 .num_dwb = 1,
818 .num_ddc = 5, 818 .num_ddc = 5,
819}; 819};
820 820
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index ef673bffc241..ff50ae71fe27 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -3,15 +3,20 @@
3 3
4DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o 4DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o
5 5
6ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) 6CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse
7 cc_stack_align := -mpreferred-stack-boundary=4
8else ifneq ($(call cc-option, -mstack-alignment=16),)
9 cc_stack_align := -mstack-alignment=16
10endif
11 7
12CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse $(cc_stack_align) 8ifdef CONFIG_CC_IS_GCC
9ifeq ($(call cc-ifversion, -lt, 0701, y), y)
10IS_OLD_GCC = 1
11endif
12endif
13 13
14ifdef CONFIG_CC_IS_CLANG 14ifdef IS_OLD_GCC
15# Stack alignment mismatch, proceed with caution.
16# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
17# (8B stack alignment).
18CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -mpreferred-stack-boundary=4
19else
15CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -msse2 20CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -msse2
16endif 21endif
17 22
diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index 5b2a65b42403..8df251626e22 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -24,15 +24,20 @@
24# It provides the general basic services required by other DAL 24# It provides the general basic services required by other DAL
25# subcomponents. 25# subcomponents.
26 26
27ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) 27dml_ccflags := -mhard-float -msse
28 cc_stack_align := -mpreferred-stack-boundary=4
29else ifneq ($(call cc-option, -mstack-alignment=16),)
30 cc_stack_align := -mstack-alignment=16
31endif
32 28
33dml_ccflags := -mhard-float -msse $(cc_stack_align) 29ifdef CONFIG_CC_IS_GCC
30ifeq ($(call cc-ifversion, -lt, 0701, y), y)
31IS_OLD_GCC = 1
32endif
33endif
34 34
35ifdef CONFIG_CC_IS_CLANG 35ifdef IS_OLD_GCC
36# Stack alignment mismatch, proceed with caution.
37# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
38# (8B stack alignment).
39dml_ccflags += -mpreferred-stack-boundary=4
40else
36dml_ccflags += -msse2 41dml_ccflags += -msse2
37endif 42endif
38 43
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
index 649883777f62..6c6c486b774a 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
@@ -2577,7 +2577,8 @@ static void dml20_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPer
2577 mode_lib->vba.MinActiveDRAMClockChangeMargin 2577 mode_lib->vba.MinActiveDRAMClockChangeMargin
2578 + mode_lib->vba.DRAMClockChangeLatency; 2578 + mode_lib->vba.DRAMClockChangeLatency;
2579 2579
2580 if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 0) { 2580 if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
2581 mode_lib->vba.DRAMClockChangeWatermark += 25;
2581 mode_lib->vba.DRAMClockChangeSupport[0][0] = dm_dram_clock_change_vactive; 2582 mode_lib->vba.DRAMClockChangeSupport[0][0] = dm_dram_clock_change_vactive;
2582 } else { 2583 } else {
2583 if (mode_lib->vba.SynchronizedVBlank || mode_lib->vba.NumberOfActivePlanes == 1) { 2584 if (mode_lib->vba.SynchronizedVBlank || mode_lib->vba.NumberOfActivePlanes == 1) {
diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/amd/display/dc/dsc/Makefile
index b456cd23c6fa..970737217e53 100644
--- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile
@@ -1,15 +1,20 @@
1# 1#
2# Makefile for the 'dsc' sub-component of DAL. 2# Makefile for the 'dsc' sub-component of DAL.
3 3
4ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) 4dsc_ccflags := -mhard-float -msse
5 cc_stack_align := -mpreferred-stack-boundary=4
6else ifneq ($(call cc-option, -mstack-alignment=16),)
7 cc_stack_align := -mstack-alignment=16
8endif
9 5
10dsc_ccflags := -mhard-float -msse $(cc_stack_align) 6ifdef CONFIG_CC_IS_GCC
7ifeq ($(call cc-ifversion, -lt, 0701, y), y)
8IS_OLD_GCC = 1
9endif
10endif
11 11
12ifdef CONFIG_CC_IS_CLANG 12ifdef IS_OLD_GCC
13# Stack alignment mismatch, proceed with caution.
14# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
15# (8B stack alignment).
16dsc_ccflags += -mpreferred-stack-boundary=4
17else
13dsc_ccflags += -msse2 18dsc_ccflags += -msse2
14endif 19endif
15 20
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index d08493b67b67..beacfffbdc3e 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5098,9 +5098,7 @@ static void vega10_odn_update_soc_table(struct pp_hwmgr *hwmgr,
5098 5098
5099 if (type == PP_OD_EDIT_SCLK_VDDC_TABLE) { 5099 if (type == PP_OD_EDIT_SCLK_VDDC_TABLE) {
5100 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_sclk; 5100 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_sclk;
5101 for (i = 0; i < podn_vdd_dep->count - 1; i++) 5101 for (i = 0; i < podn_vdd_dep->count; i++)
5102 od_vddc_lookup_table->entries[i].us_vdd = podn_vdd_dep->entries[i].vddc;
5103 if (od_vddc_lookup_table->entries[i].us_vdd < podn_vdd_dep->entries[i].vddc)
5104 od_vddc_lookup_table->entries[i].us_vdd = podn_vdd_dep->entries[i].vddc; 5102 od_vddc_lookup_table->entries[i].us_vdd = podn_vdd_dep->entries[i].vddc;
5105 } else if (type == PP_OD_EDIT_MCLK_VDDC_TABLE) { 5103 } else if (type == PP_OD_EDIT_MCLK_VDDC_TABLE) {
5106 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_mclk; 5104 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_mclk;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
index 698db540972c..648cf0207309 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
@@ -180,6 +180,8 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit)
180 etnaviv_cmdbuf_get_va(&submit->cmdbuf, 180 etnaviv_cmdbuf_get_va(&submit->cmdbuf,
181 &gpu->mmu_context->cmdbuf_mapping)); 181 &gpu->mmu_context->cmdbuf_mapping));
182 182
183 mutex_unlock(&gpu->mmu_context->lock);
184
183 /* Reserve space for the bomap */ 185 /* Reserve space for the bomap */
184 if (n_bomap_pages) { 186 if (n_bomap_pages) {
185 bomap_start = bomap = iter.data; 187 bomap_start = bomap = iter.data;
@@ -221,8 +223,6 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit)
221 obj->base.size); 223 obj->base.size);
222 } 224 }
223 225
224 mutex_unlock(&gpu->mmu_context->lock);
225
226 etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data); 226 etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data);
227 227
228 dev_coredumpv(gpu->dev, iter.start, iter.data - iter.start, GFP_KERNEL); 228 dev_coredumpv(gpu->dev, iter.start, iter.data - iter.start, GFP_KERNEL);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c b/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
index 043111a1d60c..f8bf488e9d71 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
@@ -155,9 +155,11 @@ static void etnaviv_iommuv2_dump(struct etnaviv_iommu_context *context, void *bu
155 155
156 memcpy(buf, v2_context->mtlb_cpu, SZ_4K); 156 memcpy(buf, v2_context->mtlb_cpu, SZ_4K);
157 buf += SZ_4K; 157 buf += SZ_4K;
158 for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++, buf += SZ_4K) 158 for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++)
159 if (v2_context->mtlb_cpu[i] & MMUv2_PTE_PRESENT) 159 if (v2_context->mtlb_cpu[i] & MMUv2_PTE_PRESENT) {
160 memcpy(buf, v2_context->stlb_cpu[i], SZ_4K); 160 memcpy(buf, v2_context->stlb_cpu[i], SZ_4K);
161 buf += SZ_4K;
162 }
161} 163}
162 164
163static void etnaviv_iommuv2_restore_nonsec(struct etnaviv_gpu *gpu, 165static void etnaviv_iommuv2_restore_nonsec(struct etnaviv_gpu *gpu,
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
index 35ebae6a1be7..3607d348c298 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
@@ -328,12 +328,23 @@ etnaviv_iommu_context_init(struct etnaviv_iommu_global *global,
328 328
329 ret = etnaviv_cmdbuf_suballoc_map(suballoc, ctx, &ctx->cmdbuf_mapping, 329 ret = etnaviv_cmdbuf_suballoc_map(suballoc, ctx, &ctx->cmdbuf_mapping,
330 global->memory_base); 330 global->memory_base);
331 if (ret) { 331 if (ret)
332 global->ops->free(ctx); 332 goto out_free;
333 return NULL; 333
334 if (global->version == ETNAVIV_IOMMU_V1 &&
335 ctx->cmdbuf_mapping.iova > 0x80000000) {
336 dev_err(global->dev,
337 "command buffer outside valid memory window\n");
338 goto out_unmap;
334 } 339 }
335 340
336 return ctx; 341 return ctx;
342
343out_unmap:
344 etnaviv_cmdbuf_suballoc_unmap(ctx, &ctx->cmdbuf_mapping);
345out_free:
346 global->ops->free(ctx);
347 return NULL;
337} 348}
338 349
339void etnaviv_iommu_restore(struct etnaviv_gpu *gpu, 350void etnaviv_iommu_restore(struct etnaviv_gpu *gpu,
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index aa54bb22796d..dfff6f4357b8 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -9315,7 +9315,6 @@ static bool wrpll_uses_pch_ssc(struct drm_i915_private *dev_priv,
9315static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv) 9315static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv)
9316{ 9316{
9317 struct intel_encoder *encoder; 9317 struct intel_encoder *encoder;
9318 bool pch_ssc_in_use = false;
9319 bool has_fdi = false; 9318 bool has_fdi = false;
9320 9319
9321 for_each_intel_encoder(&dev_priv->drm, encoder) { 9320 for_each_intel_encoder(&dev_priv->drm, encoder) {
@@ -9343,22 +9342,24 @@ static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv)
9343 * clock hierarchy. That would also allow us to do 9342 * clock hierarchy. That would also allow us to do
9344 * clock bending finally. 9343 * clock bending finally.
9345 */ 9344 */
9345 dev_priv->pch_ssc_use = 0;
9346
9346 if (spll_uses_pch_ssc(dev_priv)) { 9347 if (spll_uses_pch_ssc(dev_priv)) {
9347 DRM_DEBUG_KMS("SPLL using PCH SSC\n"); 9348 DRM_DEBUG_KMS("SPLL using PCH SSC\n");
9348 pch_ssc_in_use = true; 9349 dev_priv->pch_ssc_use |= BIT(DPLL_ID_SPLL);
9349 } 9350 }
9350 9351
9351 if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL1)) { 9352 if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL1)) {
9352 DRM_DEBUG_KMS("WRPLL1 using PCH SSC\n"); 9353 DRM_DEBUG_KMS("WRPLL1 using PCH SSC\n");
9353 pch_ssc_in_use = true; 9354 dev_priv->pch_ssc_use |= BIT(DPLL_ID_WRPLL1);
9354 } 9355 }
9355 9356
9356 if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL2)) { 9357 if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL2)) {
9357 DRM_DEBUG_KMS("WRPLL2 using PCH SSC\n"); 9358 DRM_DEBUG_KMS("WRPLL2 using PCH SSC\n");
9358 pch_ssc_in_use = true; 9359 dev_priv->pch_ssc_use |= BIT(DPLL_ID_WRPLL2);
9359 } 9360 }
9360 9361
9361 if (pch_ssc_in_use) 9362 if (dev_priv->pch_ssc_use)
9362 return; 9363 return;
9363 9364
9364 if (has_fdi) { 9365 if (has_fdi) {
diff --git a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
index b8148f838354..d5a298c3c83b 100644
--- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
+++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
@@ -525,16 +525,31 @@ static void hsw_ddi_wrpll_disable(struct drm_i915_private *dev_priv,
525 val = I915_READ(WRPLL_CTL(id)); 525 val = I915_READ(WRPLL_CTL(id));
526 I915_WRITE(WRPLL_CTL(id), val & ~WRPLL_PLL_ENABLE); 526 I915_WRITE(WRPLL_CTL(id), val & ~WRPLL_PLL_ENABLE);
527 POSTING_READ(WRPLL_CTL(id)); 527 POSTING_READ(WRPLL_CTL(id));
528
529 /*
530 * Try to set up the PCH reference clock once all DPLLs
531 * that depend on it have been shut down.
532 */
533 if (dev_priv->pch_ssc_use & BIT(id))
534 intel_init_pch_refclk(dev_priv);
528} 535}
529 536
530static void hsw_ddi_spll_disable(struct drm_i915_private *dev_priv, 537static void hsw_ddi_spll_disable(struct drm_i915_private *dev_priv,
531 struct intel_shared_dpll *pll) 538 struct intel_shared_dpll *pll)
532{ 539{
540 enum intel_dpll_id id = pll->info->id;
533 u32 val; 541 u32 val;
534 542
535 val = I915_READ(SPLL_CTL); 543 val = I915_READ(SPLL_CTL);
536 I915_WRITE(SPLL_CTL, val & ~SPLL_PLL_ENABLE); 544 I915_WRITE(SPLL_CTL, val & ~SPLL_PLL_ENABLE);
537 POSTING_READ(SPLL_CTL); 545 POSTING_READ(SPLL_CTL);
546
547 /*
548 * Try to set up the PCH reference clock once all DPLLs
549 * that depend on it have been shut down.
550 */
551 if (dev_priv->pch_ssc_use & BIT(id))
552 intel_init_pch_refclk(dev_priv);
538} 553}
539 554
540static bool hsw_ddi_wrpll_get_hw_state(struct drm_i915_private *dev_priv, 555static bool hsw_ddi_wrpll_get_hw_state(struct drm_i915_private *dev_priv,
diff --git a/drivers/gpu/drm/i915/display/intel_dpll_mgr.h b/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
index e7588799fce5..104cf6d42333 100644
--- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
+++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
@@ -147,11 +147,11 @@ enum intel_dpll_id {
147 */ 147 */
148 DPLL_ID_ICL_MGPLL4 = 6, 148 DPLL_ID_ICL_MGPLL4 = 6,
149 /** 149 /**
150 * @DPLL_ID_TGL_TCPLL5: TGL TC PLL port 5 (TC5) 150 * @DPLL_ID_TGL_MGPLL5: TGL TC PLL port 5 (TC5)
151 */ 151 */
152 DPLL_ID_TGL_MGPLL5 = 7, 152 DPLL_ID_TGL_MGPLL5 = 7,
153 /** 153 /**
154 * @DPLL_ID_TGL_TCPLL6: TGL TC PLL port 6 (TC6) 154 * @DPLL_ID_TGL_MGPLL6: TGL TC PLL port 6 (TC6)
155 */ 155 */
156 DPLL_ID_TGL_MGPLL6 = 8, 156 DPLL_ID_TGL_MGPLL6 = 8,
157}; 157};
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 772154e4073e..953e1d12c23c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1723,6 +1723,8 @@ struct drm_i915_private {
1723 struct work_struct idle_work; 1723 struct work_struct idle_work;
1724 } gem; 1724 } gem;
1725 1725
1726 u8 pch_ssc_use;
1727
1726 /* For i945gm vblank irq vs. C3 workaround */ 1728 /* For i945gm vblank irq vs. C3 workaround */
1727 struct { 1729 struct {
1728 struct work_struct work; 1730 struct work_struct work;
diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index bc2ddeb55f5d..f21bc8a7ee3a 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -556,11 +556,11 @@ static int panfrost_probe(struct platform_device *pdev)
556 return 0; 556 return 0;
557 557
558err_out2: 558err_out2:
559 pm_runtime_disable(pfdev->dev);
559 panfrost_devfreq_fini(pfdev); 560 panfrost_devfreq_fini(pfdev);
560err_out1: 561err_out1:
561 panfrost_device_fini(pfdev); 562 panfrost_device_fini(pfdev);
562err_out0: 563err_out0:
563 pm_runtime_disable(pfdev->dev);
564 drm_dev_put(ddev); 564 drm_dev_put(ddev);
565 return err; 565 return err;
566} 566}
diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
index bdd990568476..a3ed64a1f15e 100644
--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
@@ -224,9 +224,9 @@ static size_t get_pgsize(u64 addr, size_t size)
224 return SZ_2M; 224 return SZ_2M;
225} 225}
226 226
227void panfrost_mmu_flush_range(struct panfrost_device *pfdev, 227static void panfrost_mmu_flush_range(struct panfrost_device *pfdev,
228 struct panfrost_mmu *mmu, 228 struct panfrost_mmu *mmu,
229 u64 iova, size_t size) 229 u64 iova, size_t size)
230{ 230{
231 if (mmu->as < 0) 231 if (mmu->as < 0)
232 return; 232 return;
@@ -406,11 +406,11 @@ addr_to_drm_mm_node(struct panfrost_device *pfdev, int as, u64 addr)
406 spin_lock(&pfdev->as_lock); 406 spin_lock(&pfdev->as_lock);
407 list_for_each_entry(mmu, &pfdev->as_lru_list, list) { 407 list_for_each_entry(mmu, &pfdev->as_lru_list, list) {
408 if (as == mmu->as) 408 if (as == mmu->as)
409 break; 409 goto found_mmu;
410 } 410 }
411 if (as != mmu->as) 411 goto out;
412 goto out;
413 412
413found_mmu:
414 priv = container_of(mmu, struct panfrost_file_priv, mmu); 414 priv = container_of(mmu, struct panfrost_file_priv, mmu);
415 415
416 spin_lock(&priv->mm_lock); 416 spin_lock(&priv->mm_lock);
@@ -432,7 +432,8 @@ out:
432 432
433#define NUM_FAULT_PAGES (SZ_2M / PAGE_SIZE) 433#define NUM_FAULT_PAGES (SZ_2M / PAGE_SIZE)
434 434
435int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, u64 addr) 435static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
436 u64 addr)
436{ 437{
437 int ret, i; 438 int ret, i;
438 struct panfrost_gem_object *bo; 439 struct panfrost_gem_object *bo;
diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
index 83c57d325ca8..2dba192bf198 100644
--- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
+++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
@@ -16,6 +16,7 @@
16#include "panfrost_issues.h" 16#include "panfrost_issues.h"
17#include "panfrost_job.h" 17#include "panfrost_job.h"
18#include "panfrost_mmu.h" 18#include "panfrost_mmu.h"
19#include "panfrost_perfcnt.h"
19#include "panfrost_regs.h" 20#include "panfrost_regs.h"
20 21
21#define COUNTERS_PER_BLOCK 64 22#define COUNTERS_PER_BLOCK 64
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 9e55076578c6..4528f4dc0b2d 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -379,11 +379,25 @@ radeon_pci_remove(struct pci_dev *pdev)
379static void 379static void
380radeon_pci_shutdown(struct pci_dev *pdev) 380radeon_pci_shutdown(struct pci_dev *pdev)
381{ 381{
382#ifdef CONFIG_PPC64
383 struct drm_device *ddev = pci_get_drvdata(pdev);
384#endif
385
382 /* if we are running in a VM, make sure the device 386 /* if we are running in a VM, make sure the device
383 * torn down properly on reboot/shutdown 387 * torn down properly on reboot/shutdown
384 */ 388 */
385 if (radeon_device_is_virtual()) 389 if (radeon_device_is_virtual())
386 radeon_pci_remove(pdev); 390 radeon_pci_remove(pdev);
391
392#ifdef CONFIG_PPC64
393 /* Some adapters need to be suspended before a
394 * shutdown occurs in order to prevent an error
395 * during kexec.
396 * Make this power specific becauase it breaks
397 * some non-power boards.
398 */
399 radeon_suspend_kms(ddev, true, true, false);
400#endif
387} 401}
388 402
389static int radeon_pmops_suspend(struct device *dev) 403static int radeon_pmops_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 9a0ee74d82dc..f39b97ed4ade 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -479,6 +479,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
479 struct drm_sched_job *s_job, *tmp; 479 struct drm_sched_job *s_job, *tmp;
480 uint64_t guilty_context; 480 uint64_t guilty_context;
481 bool found_guilty = false; 481 bool found_guilty = false;
482 struct dma_fence *fence;
482 483
483 list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { 484 list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) {
484 struct drm_sched_fence *s_fence = s_job->s_fence; 485 struct drm_sched_fence *s_fence = s_job->s_fence;
@@ -492,7 +493,16 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
492 dma_fence_set_error(&s_fence->finished, -ECANCELED); 493 dma_fence_set_error(&s_fence->finished, -ECANCELED);
493 494
494 dma_fence_put(s_job->s_fence->parent); 495 dma_fence_put(s_job->s_fence->parent);
495 s_job->s_fence->parent = sched->ops->run_job(s_job); 496 fence = sched->ops->run_job(s_job);
497
498 if (IS_ERR_OR_NULL(fence)) {
499 s_job->s_fence->parent = NULL;
500 dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
501 } else {
502 s_job->s_fence->parent = fence;
503 }
504
505
496 } 506 }
497} 507}
498EXPORT_SYMBOL(drm_sched_resubmit_jobs); 508EXPORT_SYMBOL(drm_sched_resubmit_jobs);
@@ -720,7 +730,7 @@ static int drm_sched_main(void *param)
720 fence = sched->ops->run_job(sched_job); 730 fence = sched->ops->run_job(sched_job);
721 drm_sched_fence_scheduled(s_fence); 731 drm_sched_fence_scheduled(s_fence);
722 732
723 if (fence) { 733 if (!IS_ERR_OR_NULL(fence)) {
724 s_fence->parent = dma_fence_get(fence); 734 s_fence->parent = dma_fence_get(fence);
725 r = dma_fence_add_callback(fence, &sched_job->cb, 735 r = dma_fence_add_callback(fence, &sched_job->cb,
726 drm_sched_process_job); 736 drm_sched_process_job);
@@ -730,8 +740,11 @@ static int drm_sched_main(void *param)
730 DRM_ERROR("fence add callback failed (%d)\n", 740 DRM_ERROR("fence add callback failed (%d)\n",
731 r); 741 r);
732 dma_fence_put(fence); 742 dma_fence_put(fence);
733 } else 743 } else {
744
745 dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
734 drm_sched_process_job(NULL, &sched_job->cb); 746 drm_sched_process_job(NULL, &sched_job->cb);
747 }
735 748
736 wake_up(&sched->job_scheduled); 749 wake_up(&sched->job_scheduled);
737 } 750 }
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 5d80507b539b..19c092d75266 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
557 557
558 if (args->bcl_start != args->bcl_end) { 558 if (args->bcl_start != args->bcl_end) {
559 bin = kcalloc(1, sizeof(*bin), GFP_KERNEL); 559 bin = kcalloc(1, sizeof(*bin), GFP_KERNEL);
560 if (!bin) 560 if (!bin) {
561 v3d_job_put(&render->base);
561 return -ENOMEM; 562 return -ENOMEM;
563 }
562 564
563 ret = v3d_job_init(v3d, file_priv, &bin->base, 565 ret = v3d_job_init(v3d, file_priv, &bin->base,
564 v3d_job_free, args->in_sync_bcl); 566 v3d_job_free, args->in_sync_bcl);
565 if (ret) { 567 if (ret) {
566 v3d_job_put(&render->base); 568 v3d_job_put(&render->base);
569 kfree(bin);
567 return ret; 570 return ret;
568 } 571 }
569 572
diff --git a/drivers/hid/hid-axff.c b/drivers/hid/hid-axff.c
index 6654c1550e2e..fbe4e16ab029 100644
--- a/drivers/hid/hid-axff.c
+++ b/drivers/hid/hid-axff.c
@@ -63,13 +63,20 @@ static int axff_init(struct hid_device *hid)
63{ 63{
64 struct axff_device *axff; 64 struct axff_device *axff;
65 struct hid_report *report; 65 struct hid_report *report;
66 struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list); 66 struct hid_input *hidinput;
67 struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list; 67 struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list;
68 struct input_dev *dev = hidinput->input; 68 struct input_dev *dev;
69 int field_count = 0; 69 int field_count = 0;
70 int i, j; 70 int i, j;
71 int error; 71 int error;
72 72
73 if (list_empty(&hid->inputs)) {
74 hid_err(hid, "no inputs found\n");
75 return -ENODEV;
76 }
77 hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
78 dev = hidinput->input;
79
73 if (list_empty(report_list)) { 80 if (list_empty(report_list)) {
74 hid_err(hid, "no output reports found\n"); 81 hid_err(hid, "no output reports found\n");
75 return -ENODEV; 82 return -ENODEV;
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3eaee2c37931..63fdbf09b044 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1139,6 +1139,7 @@ int hid_open_report(struct hid_device *device)
1139 __u8 *start; 1139 __u8 *start;
1140 __u8 *buf; 1140 __u8 *buf;
1141 __u8 *end; 1141 __u8 *end;
1142 __u8 *next;
1142 int ret; 1143 int ret;
1143 static int (*dispatch_type[])(struct hid_parser *parser, 1144 static int (*dispatch_type[])(struct hid_parser *parser,
1144 struct hid_item *item) = { 1145 struct hid_item *item) = {
@@ -1192,7 +1193,8 @@ int hid_open_report(struct hid_device *device)
1192 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 1193 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
1193 1194
1194 ret = -EINVAL; 1195 ret = -EINVAL;
1195 while ((start = fetch_item(start, end, &item)) != NULL) { 1196 while ((next = fetch_item(start, end, &item)) != NULL) {
1197 start = next;
1196 1198
1197 if (item.format != HID_ITEM_FORMAT_SHORT) { 1199 if (item.format != HID_ITEM_FORMAT_SHORT) {
1198 hid_err(device, "unexpected long global item\n"); 1200 hid_err(device, "unexpected long global item\n");
@@ -1230,7 +1232,8 @@ int hid_open_report(struct hid_device *device)
1230 } 1232 }
1231 } 1233 }
1232 1234
1233 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 1235 hid_err(device, "item fetching failed at offset %u/%u\n",
1236 size - (unsigned int)(end - start), size);
1234err: 1237err:
1235 kfree(parser->collection_stack); 1238 kfree(parser->collection_stack);
1236alloc_err: 1239alloc_err:
diff --git a/drivers/hid/hid-dr.c b/drivers/hid/hid-dr.c
index 17e17f9a597b..947f19f8685f 100644
--- a/drivers/hid/hid-dr.c
+++ b/drivers/hid/hid-dr.c
@@ -75,13 +75,19 @@ static int drff_init(struct hid_device *hid)
75{ 75{
76 struct drff_device *drff; 76 struct drff_device *drff;
77 struct hid_report *report; 77 struct hid_report *report;
78 struct hid_input *hidinput = list_first_entry(&hid->inputs, 78 struct hid_input *hidinput;
79 struct hid_input, list);
80 struct list_head *report_list = 79 struct list_head *report_list =
81 &hid->report_enum[HID_OUTPUT_REPORT].report_list; 80 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
82 struct input_dev *dev = hidinput->input; 81 struct input_dev *dev;
83 int error; 82 int error;
84 83
84 if (list_empty(&hid->inputs)) {
85 hid_err(hid, "no inputs found\n");
86 return -ENODEV;
87 }
88 hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
89 dev = hidinput->input;
90
85 if (list_empty(report_list)) { 91 if (list_empty(report_list)) {
86 hid_err(hid, "no output reports found\n"); 92 hid_err(hid, "no output reports found\n");
87 return -ENODEV; 93 return -ENODEV;
diff --git a/drivers/hid/hid-emsff.c b/drivers/hid/hid-emsff.c
index 7cd5651872d3..c34f2e5a049f 100644
--- a/drivers/hid/hid-emsff.c
+++ b/drivers/hid/hid-emsff.c
@@ -47,13 +47,19 @@ static int emsff_init(struct hid_device *hid)
47{ 47{
48 struct emsff_device *emsff; 48 struct emsff_device *emsff;
49 struct hid_report *report; 49 struct hid_report *report;
50 struct hid_input *hidinput = list_first_entry(&hid->inputs, 50 struct hid_input *hidinput;
51 struct hid_input, list);
52 struct list_head *report_list = 51 struct list_head *report_list =
53 &hid->report_enum[HID_OUTPUT_REPORT].report_list; 52 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
54 struct input_dev *dev = hidinput->input; 53 struct input_dev *dev;
55 int error; 54 int error;
56 55
56 if (list_empty(&hid->inputs)) {
57 hid_err(hid, "no inputs found\n");
58 return -ENODEV;
59 }
60 hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
61 dev = hidinput->input;
62
57 if (list_empty(report_list)) { 63 if (list_empty(report_list)) {
58 hid_err(hid, "no output reports found\n"); 64 hid_err(hid, "no output reports found\n");
59 return -ENODEV; 65 return -ENODEV;
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
index 0f95c96b70f8..ecbd3995a4eb 100644
--- a/drivers/hid/hid-gaff.c
+++ b/drivers/hid/hid-gaff.c
@@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *hid)
64{ 64{
65 struct gaff_device *gaff; 65 struct gaff_device *gaff;
66 struct hid_report *report; 66 struct hid_report *report;
67 struct hid_input *hidinput = list_entry(hid->inputs.next, 67 struct hid_input *hidinput;
68 struct hid_input, list);
69 struct list_head *report_list = 68 struct list_head *report_list =
70 &hid->report_enum[HID_OUTPUT_REPORT].report_list; 69 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
71 struct list_head *report_ptr = report_list; 70 struct list_head *report_ptr = report_list;
72 struct input_dev *dev = hidinput->input; 71 struct input_dev *dev;
73 int error; 72 int error;
74 73
74 if (list_empty(&hid->inputs)) {
75 hid_err(hid, "no inputs found\n");
76 return -ENODEV;
77 }
78 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
79 dev = hidinput->input;
80
75 if (list_empty(report_list)) { 81 if (list_empty(report_list)) {
76 hid_err(hid, "no output reports found\n"); 82 hid_err(hid, "no output reports found\n");
77 return -ENODEV; 83 return -ENODEV;
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 84f8c127ebdc..d86a9189e88f 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -470,6 +470,10 @@ static const struct hid_device_id hammer_devices[] = {
470 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 470 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
471 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, 471 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) },
472 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 472 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
473 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) },
474 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
475 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) },
476 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
473 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) }, 477 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) },
474 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 478 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
475 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) }, 479 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) },
diff --git a/drivers/hid/hid-holtekff.c b/drivers/hid/hid-holtekff.c
index 10a720558830..8619b80c834c 100644
--- a/drivers/hid/hid-holtekff.c
+++ b/drivers/hid/hid-holtekff.c
@@ -124,13 +124,19 @@ static int holtekff_init(struct hid_device *hid)
124{ 124{
125 struct holtekff_device *holtekff; 125 struct holtekff_device *holtekff;
126 struct hid_report *report; 126 struct hid_report *report;
127 struct hid_input *hidinput = list_entry(hid->inputs.next, 127 struct hid_input *hidinput;
128 struct hid_input, list);
129 struct list_head *report_list = 128 struct list_head *report_list =
130 &hid->report_enum[HID_OUTPUT_REPORT].report_list; 129 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
131 struct input_dev *dev = hidinput->input; 130 struct input_dev *dev;
132 int error; 131 int error;
133 132
133 if (list_empty(&hid->inputs)) {
134 hid_err(hid, "no inputs found\n");
135 return -ENODEV;
136 }
137 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
138 dev = hidinput->input;
139
134 if (list_empty(report_list)) { 140 if (list_empty(report_list)) {
135 hid_err(hid, "no output report found\n"); 141 hid_err(hid, "no output report found\n");
136 return -ENODEV; 142 return -ENODEV;
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 76969a22b0f2..447e8db21174 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -476,6 +476,8 @@
476#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b 476#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b
477#define USB_DEVICE_ID_GOOGLE_WAND 0x502d 477#define USB_DEVICE_ID_GOOGLE_WAND 0x502d
478#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030 478#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030
479#define USB_DEVICE_ID_GOOGLE_MASTERBALL 0x503c
480#define USB_DEVICE_ID_GOOGLE_MAGNEMITE 0x503d
479 481
480#define USB_VENDOR_ID_GOTOP 0x08f2 482#define USB_VENDOR_ID_GOTOP 0x08f2
481#define USB_DEVICE_ID_SUPER_Q2 0x007f 483#define USB_DEVICE_ID_SUPER_Q2 0x007f
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
index dd1a6c3a7de6..73d07e35f12a 100644
--- a/drivers/hid/hid-lg2ff.c
+++ b/drivers/hid/hid-lg2ff.c
@@ -50,11 +50,17 @@ int lg2ff_init(struct hid_device *hid)
50{ 50{
51 struct lg2ff_device *lg2ff; 51 struct lg2ff_device *lg2ff;
52 struct hid_report *report; 52 struct hid_report *report;
53 struct hid_input *hidinput = list_entry(hid->inputs.next, 53 struct hid_input *hidinput;
54 struct hid_input, list); 54 struct input_dev *dev;
55 struct input_dev *dev = hidinput->input;
56 int error; 55 int error;
57 56
57 if (list_empty(&hid->inputs)) {
58 hid_err(hid, "no inputs found\n");
59 return -ENODEV;
60 }
61 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
62 dev = hidinput->input;
63
58 /* Check that the report looks ok */ 64 /* Check that the report looks ok */
59 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7); 65 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
60 if (!report) 66 if (!report)
diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
index 9ecb6fd06203..b7e1949f3cf7 100644
--- a/drivers/hid/hid-lg3ff.c
+++ b/drivers/hid/hid-lg3ff.c
@@ -117,12 +117,19 @@ static const signed short ff3_joystick_ac[] = {
117 117
118int lg3ff_init(struct hid_device *hid) 118int lg3ff_init(struct hid_device *hid)
119{ 119{
120 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 120 struct hid_input *hidinput;
121 struct input_dev *dev = hidinput->input; 121 struct input_dev *dev;
122 const signed short *ff_bits = ff3_joystick_ac; 122 const signed short *ff_bits = ff3_joystick_ac;
123 int error; 123 int error;
124 int i; 124 int i;
125 125
126 if (list_empty(&hid->inputs)) {
127 hid_err(hid, "no inputs found\n");
128 return -ENODEV;
129 }
130 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
131 dev = hidinput->input;
132
126 /* Check that the report looks ok */ 133 /* Check that the report looks ok */
127 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35)) 134 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
128 return -ENODEV; 135 return -ENODEV;
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 03f0220062ca..5e6a0cef2a06 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -1253,8 +1253,8 @@ static int lg4ff_handle_multimode_wheel(struct hid_device *hid, u16 *real_produc
1253 1253
1254int lg4ff_init(struct hid_device *hid) 1254int lg4ff_init(struct hid_device *hid)
1255{ 1255{
1256 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 1256 struct hid_input *hidinput;
1257 struct input_dev *dev = hidinput->input; 1257 struct input_dev *dev;
1258 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 1258 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
1259 struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 1259 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
1260 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); 1260 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
@@ -1266,6 +1266,13 @@ int lg4ff_init(struct hid_device *hid)
1266 int mmode_ret, mmode_idx = -1; 1266 int mmode_ret, mmode_idx = -1;
1267 u16 real_product_id; 1267 u16 real_product_id;
1268 1268
1269 if (list_empty(&hid->inputs)) {
1270 hid_err(hid, "no inputs found\n");
1271 return -ENODEV;
1272 }
1273 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
1274 dev = hidinput->input;
1275
1269 /* Check that the report looks ok */ 1276 /* Check that the report looks ok */
1270 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) 1277 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
1271 return -1; 1278 return -1;
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index c79a6ec43745..aed4ddc397a9 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -115,12 +115,19 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
115 115
116int lgff_init(struct hid_device* hid) 116int lgff_init(struct hid_device* hid)
117{ 117{
118 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 118 struct hid_input *hidinput;
119 struct input_dev *dev = hidinput->input; 119 struct input_dev *dev;
120 const signed short *ff_bits = ff_joystick; 120 const signed short *ff_bits = ff_joystick;
121 int error; 121 int error;
122 int i; 122 int i;
123 123
124 if (list_empty(&hid->inputs)) {
125 hid_err(hid, "no inputs found\n");
126 return -ENODEV;
127 }
128 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
129 dev = hidinput->input;
130
124 /* Check that the report looks ok */ 131 /* Check that the report looks ok */
125 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) 132 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
126 return -ENODEV; 133 return -ENODEV;
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 0179f7ed77e5..8e91e2f06cb4 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -1669,6 +1669,7 @@ static void hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev,
1669 1669
1670#define HIDPP_FF_EFFECTID_NONE -1 1670#define HIDPP_FF_EFFECTID_NONE -1
1671#define HIDPP_FF_EFFECTID_AUTOCENTER -2 1671#define HIDPP_FF_EFFECTID_AUTOCENTER -2
1672#define HIDPP_AUTOCENTER_PARAMS_LENGTH 18
1672 1673
1673#define HIDPP_FF_MAX_PARAMS 20 1674#define HIDPP_FF_MAX_PARAMS 20
1674#define HIDPP_FF_RESERVED_SLOTS 1 1675#define HIDPP_FF_RESERVED_SLOTS 1
@@ -2009,7 +2010,7 @@ static int hidpp_ff_erase_effect(struct input_dev *dev, int effect_id)
2009static void hidpp_ff_set_autocenter(struct input_dev *dev, u16 magnitude) 2010static void hidpp_ff_set_autocenter(struct input_dev *dev, u16 magnitude)
2010{ 2011{
2011 struct hidpp_ff_private_data *data = dev->ff->private; 2012 struct hidpp_ff_private_data *data = dev->ff->private;
2012 u8 params[18]; 2013 u8 params[HIDPP_AUTOCENTER_PARAMS_LENGTH];
2013 2014
2014 dbg_hid("Setting autocenter to %d.\n", magnitude); 2015 dbg_hid("Setting autocenter to %d.\n", magnitude);
2015 2016
@@ -2077,23 +2078,34 @@ static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, hidpp
2077static void hidpp_ff_destroy(struct ff_device *ff) 2078static void hidpp_ff_destroy(struct ff_device *ff)
2078{ 2079{
2079 struct hidpp_ff_private_data *data = ff->private; 2080 struct hidpp_ff_private_data *data = ff->private;
2081 struct hid_device *hid = data->hidpp->hid_dev;
2080 2082
2083 hid_info(hid, "Unloading HID++ force feedback.\n");
2084
2085 device_remove_file(&hid->dev, &dev_attr_range);
2086 destroy_workqueue(data->wq);
2081 kfree(data->effect_ids); 2087 kfree(data->effect_ids);
2082} 2088}
2083 2089
2084static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) 2090static int hidpp_ff_init(struct hidpp_device *hidpp,
2091 struct hidpp_ff_private_data *data)
2085{ 2092{
2086 struct hid_device *hid = hidpp->hid_dev; 2093 struct hid_device *hid = hidpp->hid_dev;
2087 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 2094 struct hid_input *hidinput;
2088 struct input_dev *dev = hidinput->input; 2095 struct input_dev *dev;
2089 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); 2096 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
2090 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); 2097 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
2091 struct ff_device *ff; 2098 struct ff_device *ff;
2092 struct hidpp_report response; 2099 int error, j, num_slots = data->num_effects;
2093 struct hidpp_ff_private_data *data;
2094 int error, j, num_slots;
2095 u8 version; 2100 u8 version;
2096 2101
2102 if (list_empty(&hid->inputs)) {
2103 hid_err(hid, "no inputs found\n");
2104 return -ENODEV;
2105 }
2106 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
2107 dev = hidinput->input;
2108
2097 if (!dev) { 2109 if (!dev) {
2098 hid_err(hid, "Struct input_dev not set!\n"); 2110 hid_err(hid, "Struct input_dev not set!\n");
2099 return -EINVAL; 2111 return -EINVAL;
@@ -2109,27 +2121,17 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
2109 for (j = 0; hidpp_ff_effects_v2[j] >= 0; j++) 2121 for (j = 0; hidpp_ff_effects_v2[j] >= 0; j++)
2110 set_bit(hidpp_ff_effects_v2[j], dev->ffbit); 2122 set_bit(hidpp_ff_effects_v2[j], dev->ffbit);
2111 2123
2112 /* Read number of slots available in device */
2113 error = hidpp_send_fap_command_sync(hidpp, feature_index,
2114 HIDPP_FF_GET_INFO, NULL, 0, &response);
2115 if (error) {
2116 if (error < 0)
2117 return error;
2118 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
2119 __func__, error);
2120 return -EPROTO;
2121 }
2122
2123 num_slots = response.fap.params[0] - HIDPP_FF_RESERVED_SLOTS;
2124
2125 error = input_ff_create(dev, num_slots); 2124 error = input_ff_create(dev, num_slots);
2126 2125
2127 if (error) { 2126 if (error) {
2128 hid_err(dev, "Failed to create FF device!\n"); 2127 hid_err(dev, "Failed to create FF device!\n");
2129 return error; 2128 return error;
2130 } 2129 }
2131 2130 /*
2132 data = kzalloc(sizeof(*data), GFP_KERNEL); 2131 * Create a copy of passed data, so we can transfer memory
2132 * ownership to FF core
2133 */
2134 data = kmemdup(data, sizeof(*data), GFP_KERNEL);
2133 if (!data) 2135 if (!data)
2134 return -ENOMEM; 2136 return -ENOMEM;
2135 data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL); 2137 data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL);
@@ -2145,10 +2147,7 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
2145 } 2147 }
2146 2148
2147 data->hidpp = hidpp; 2149 data->hidpp = hidpp;
2148 data->feature_index = feature_index;
2149 data->version = version; 2150 data->version = version;
2150 data->slot_autocenter = 0;
2151 data->num_effects = num_slots;
2152 for (j = 0; j < num_slots; j++) 2151 for (j = 0; j < num_slots; j++)
2153 data->effect_ids[j] = -1; 2152 data->effect_ids[j] = -1;
2154 2153
@@ -2162,68 +2161,20 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
2162 ff->set_autocenter = hidpp_ff_set_autocenter; 2161 ff->set_autocenter = hidpp_ff_set_autocenter;
2163 ff->destroy = hidpp_ff_destroy; 2162 ff->destroy = hidpp_ff_destroy;
2164 2163
2165
2166 /* reset all forces */
2167 error = hidpp_send_fap_command_sync(hidpp, feature_index,
2168 HIDPP_FF_RESET_ALL, NULL, 0, &response);
2169
2170 /* Read current Range */
2171 error = hidpp_send_fap_command_sync(hidpp, feature_index,
2172 HIDPP_FF_GET_APERTURE, NULL, 0, &response);
2173 if (error)
2174 hid_warn(hidpp->hid_dev, "Failed to read range from device!\n");
2175 data->range = error ? 900 : get_unaligned_be16(&response.fap.params[0]);
2176
2177 /* Create sysfs interface */ 2164 /* Create sysfs interface */
2178 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); 2165 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range);
2179 if (error) 2166 if (error)
2180 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); 2167 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error);
2181 2168
2182 /* Read the current gain values */
2183 error = hidpp_send_fap_command_sync(hidpp, feature_index,
2184 HIDPP_FF_GET_GLOBAL_GAINS, NULL, 0, &response);
2185 if (error)
2186 hid_warn(hidpp->hid_dev, "Failed to read gain values from device!\n");
2187 data->gain = error ? 0xffff : get_unaligned_be16(&response.fap.params[0]);
2188 /* ignore boost value at response.fap.params[2] */
2189
2190 /* init the hardware command queue */ 2169 /* init the hardware command queue */
2191 atomic_set(&data->workqueue_size, 0); 2170 atomic_set(&data->workqueue_size, 0);
2192 2171
2193 /* initialize with zero autocenter to get wheel in usable state */
2194 hidpp_ff_set_autocenter(dev, 0);
2195
2196 hid_info(hid, "Force feedback support loaded (firmware release %d).\n", 2172 hid_info(hid, "Force feedback support loaded (firmware release %d).\n",
2197 version); 2173 version);
2198 2174
2199 return 0; 2175 return 0;
2200} 2176}
2201 2177
2202static int hidpp_ff_deinit(struct hid_device *hid)
2203{
2204 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
2205 struct input_dev *dev = hidinput->input;
2206 struct hidpp_ff_private_data *data;
2207
2208 if (!dev) {
2209 hid_err(hid, "Struct input_dev not found!\n");
2210 return -EINVAL;
2211 }
2212
2213 hid_info(hid, "Unloading HID++ force feedback.\n");
2214 data = dev->ff->private;
2215 if (!data) {
2216 hid_err(hid, "Private data not found!\n");
2217 return -EINVAL;
2218 }
2219
2220 destroy_workqueue(data->wq);
2221 device_remove_file(&hid->dev, &dev_attr_range);
2222
2223 return 0;
2224}
2225
2226
2227/* ************************************************************************** */ 2178/* ************************************************************************** */
2228/* */ 2179/* */
2229/* Device Support */ 2180/* Device Support */
@@ -2725,24 +2676,93 @@ static int k400_connect(struct hid_device *hdev, bool connected)
2725 2676
2726#define HIDPP_PAGE_G920_FORCE_FEEDBACK 0x8123 2677#define HIDPP_PAGE_G920_FORCE_FEEDBACK 0x8123
2727 2678
2728static int g920_get_config(struct hidpp_device *hidpp) 2679static int g920_ff_set_autocenter(struct hidpp_device *hidpp,
2680 struct hidpp_ff_private_data *data)
2729{ 2681{
2682 struct hidpp_report response;
2683 u8 params[HIDPP_AUTOCENTER_PARAMS_LENGTH] = {
2684 [1] = HIDPP_FF_EFFECT_SPRING | HIDPP_FF_EFFECT_AUTOSTART,
2685 };
2686 int ret;
2687
2688 /* initialize with zero autocenter to get wheel in usable state */
2689
2690 dbg_hid("Setting autocenter to 0.\n");
2691 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index,
2692 HIDPP_FF_DOWNLOAD_EFFECT,
2693 params, ARRAY_SIZE(params),
2694 &response);
2695 if (ret)
2696 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n");
2697 else
2698 data->slot_autocenter = response.fap.params[0];
2699
2700 return ret;
2701}
2702
2703static int g920_get_config(struct hidpp_device *hidpp,
2704 struct hidpp_ff_private_data *data)
2705{
2706 struct hidpp_report response;
2730 u8 feature_type; 2707 u8 feature_type;
2731 u8 feature_index;
2732 int ret; 2708 int ret;
2733 2709
2710 memset(data, 0, sizeof(*data));
2711
2734 /* Find feature and store for later use */ 2712 /* Find feature and store for later use */
2735 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, 2713 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK,
2736 &feature_index, &feature_type); 2714 &data->feature_index, &feature_type);
2737 if (ret) 2715 if (ret)
2738 return ret; 2716 return ret;
2739 2717
2740 ret = hidpp_ff_init(hidpp, feature_index); 2718 /* Read number of slots available in device */
2719 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index,
2720 HIDPP_FF_GET_INFO,
2721 NULL, 0,
2722 &response);
2723 if (ret) {
2724 if (ret < 0)
2725 return ret;
2726 hid_err(hidpp->hid_dev,
2727 "%s: received protocol error 0x%02x\n", __func__, ret);
2728 return -EPROTO;
2729 }
2730
2731 data->num_effects = response.fap.params[0] - HIDPP_FF_RESERVED_SLOTS;
2732
2733 /* reset all forces */
2734 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index,
2735 HIDPP_FF_RESET_ALL,
2736 NULL, 0,
2737 &response);
2741 if (ret) 2738 if (ret)
2742 hid_warn(hidpp->hid_dev, "Unable to initialize force feedback support, errno %d\n", 2739 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n");
2743 ret);
2744 2740
2745 return 0; 2741 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index,
2742 HIDPP_FF_GET_APERTURE,
2743 NULL, 0,
2744 &response);
2745 if (ret) {
2746 hid_warn(hidpp->hid_dev,
2747 "Failed to read range from device!\n");
2748 }
2749 data->range = ret ?
2750 900 : get_unaligned_be16(&response.fap.params[0]);
2751
2752 /* Read the current gain values */
2753 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index,
2754 HIDPP_FF_GET_GLOBAL_GAINS,
2755 NULL, 0,
2756 &response);
2757 if (ret)
2758 hid_warn(hidpp->hid_dev,
2759 "Failed to read gain values from device!\n");
2760 data->gain = ret ?
2761 0xffff : get_unaligned_be16(&response.fap.params[0]);
2762
2763 /* ignore boost value at response.fap.params[2] */
2764
2765 return g920_ff_set_autocenter(hidpp, data);
2746} 2766}
2747 2767
2748/* -------------------------------------------------------------------------- */ 2768/* -------------------------------------------------------------------------- */
@@ -3458,34 +3478,45 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id)
3458 return report->field[0]->report_count + 1; 3478 return report->field[0]->report_count + 1;
3459} 3479}
3460 3480
3461static bool hidpp_validate_report(struct hid_device *hdev, int id, 3481static bool hidpp_validate_device(struct hid_device *hdev)
3462 int expected_length, bool optional)
3463{ 3482{
3464 int report_length; 3483 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
3484 int id, report_length, supported_reports = 0;
3465 3485
3466 if (id >= HID_MAX_IDS || id < 0) { 3486 id = REPORT_ID_HIDPP_SHORT;
3467 hid_err(hdev, "invalid HID report id %u\n", id); 3487 report_length = hidpp_get_report_length(hdev, id);
3468 return false; 3488 if (report_length) {
3489 if (report_length < HIDPP_REPORT_SHORT_LENGTH)
3490 goto bad_device;
3491
3492 supported_reports++;
3469 } 3493 }
3470 3494
3495 id = REPORT_ID_HIDPP_LONG;
3471 report_length = hidpp_get_report_length(hdev, id); 3496 report_length = hidpp_get_report_length(hdev, id);
3472 if (!report_length) 3497 if (report_length) {
3473 return optional; 3498 if (report_length < HIDPP_REPORT_LONG_LENGTH)
3499 goto bad_device;
3474 3500
3475 if (report_length < expected_length) { 3501 supported_reports++;
3476 hid_warn(hdev, "not enough values in hidpp report %d\n", id);
3477 return false;
3478 } 3502 }
3479 3503
3480 return true; 3504 id = REPORT_ID_HIDPP_VERY_LONG;
3481} 3505 report_length = hidpp_get_report_length(hdev, id);
3506 if (report_length) {
3507 if (report_length < HIDPP_REPORT_LONG_LENGTH ||
3508 report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
3509 goto bad_device;
3482 3510
3483static bool hidpp_validate_device(struct hid_device *hdev) 3511 supported_reports++;
3484{ 3512 hidpp->very_long_report_length = report_length;
3485 return hidpp_validate_report(hdev, REPORT_ID_HIDPP_SHORT, 3513 }
3486 HIDPP_REPORT_SHORT_LENGTH, false) && 3514
3487 hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG, 3515 return supported_reports;
3488 HIDPP_REPORT_LONG_LENGTH, true); 3516
3517bad_device:
3518 hid_warn(hdev, "not enough values in hidpp report %d\n", id);
3519 return false;
3489} 3520}
3490 3521
3491static bool hidpp_application_equals(struct hid_device *hdev, 3522static bool hidpp_application_equals(struct hid_device *hdev,
@@ -3505,6 +3536,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3505 int ret; 3536 int ret;
3506 bool connected; 3537 bool connected;
3507 unsigned int connect_mask = HID_CONNECT_DEFAULT; 3538 unsigned int connect_mask = HID_CONNECT_DEFAULT;
3539 struct hidpp_ff_private_data data;
3508 3540
3509 /* report_fixup needs drvdata to be set before we call hid_parse */ 3541 /* report_fixup needs drvdata to be set before we call hid_parse */
3510 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); 3542 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL);
@@ -3531,11 +3563,6 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3531 return hid_hw_start(hdev, HID_CONNECT_DEFAULT); 3563 return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
3532 } 3564 }
3533 3565
3534 hidpp->very_long_report_length =
3535 hidpp_get_report_length(hdev, REPORT_ID_HIDPP_VERY_LONG);
3536 if (hidpp->very_long_report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
3537 hidpp->very_long_report_length = HIDPP_REPORT_VERY_LONG_MAX_LENGTH;
3538
3539 if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE) 3566 if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE)
3540 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; 3567 hidpp->quirks |= HIDPP_QUIRK_UNIFYING;
3541 3568
@@ -3614,7 +3641,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3614 if (ret) 3641 if (ret)
3615 goto hid_hw_init_fail; 3642 goto hid_hw_init_fail;
3616 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { 3643 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) {
3617 ret = g920_get_config(hidpp); 3644 ret = g920_get_config(hidpp, &data);
3618 if (ret) 3645 if (ret)
3619 goto hid_hw_init_fail; 3646 goto hid_hw_init_fail;
3620 } 3647 }
@@ -3636,6 +3663,14 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3636 goto hid_hw_start_fail; 3663 goto hid_hw_start_fail;
3637 } 3664 }
3638 3665
3666 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
3667 ret = hidpp_ff_init(hidpp, &data);
3668 if (ret)
3669 hid_warn(hidpp->hid_dev,
3670 "Unable to initialize force feedback support, errno %d\n",
3671 ret);
3672 }
3673
3639 return ret; 3674 return ret;
3640 3675
3641hid_hw_init_fail: 3676hid_hw_init_fail:
@@ -3658,9 +3693,6 @@ static void hidpp_remove(struct hid_device *hdev)
3658 3693
3659 sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group); 3694 sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group);
3660 3695
3661 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)
3662 hidpp_ff_deinit(hdev);
3663
3664 hid_hw_stop(hdev); 3696 hid_hw_stop(hdev);
3665 cancel_work_sync(&hidpp->work); 3697 cancel_work_sync(&hidpp->work);
3666 mutex_destroy(&hidpp->send_mutex); 3698 mutex_destroy(&hidpp->send_mutex);
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 2cf83856f2e4..2d8b589201a4 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -328,11 +328,17 @@ static int ms_play_effect(struct input_dev *dev, void *data,
328 328
329static int ms_init_ff(struct hid_device *hdev) 329static int ms_init_ff(struct hid_device *hdev)
330{ 330{
331 struct hid_input *hidinput = list_entry(hdev->inputs.next, 331 struct hid_input *hidinput;
332 struct hid_input, list); 332 struct input_dev *input_dev;
333 struct input_dev *input_dev = hidinput->input;
334 struct ms_data *ms = hid_get_drvdata(hdev); 333 struct ms_data *ms = hid_get_drvdata(hdev);
335 334
335 if (list_empty(&hdev->inputs)) {
336 hid_err(hdev, "no inputs found\n");
337 return -ENODEV;
338 }
339 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
340 input_dev = hidinput->input;
341
336 if (!(ms->quirks & MS_QUIRK_FF)) 342 if (!(ms->quirks & MS_QUIRK_FF))
337 return 0; 343 return 0;
338 344
diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
index 5a3b3d974d84..2666af02d5c1 100644
--- a/drivers/hid/hid-prodikeys.c
+++ b/drivers/hid/hid-prodikeys.c
@@ -516,7 +516,7 @@ static void pcmidi_setup_extra_keys(
516 MY PICTURES => KEY_WORDPROCESSOR 516 MY PICTURES => KEY_WORDPROCESSOR
517 MY MUSIC=> KEY_SPREADSHEET 517 MY MUSIC=> KEY_SPREADSHEET
518 */ 518 */
519 unsigned int keys[] = { 519 static const unsigned int keys[] = {
520 KEY_FN, 520 KEY_FN,
521 KEY_MESSENGER, KEY_CALENDAR, 521 KEY_MESSENGER, KEY_CALENDAR,
522 KEY_ADDRESSBOOK, KEY_DOCUMENTS, 522 KEY_ADDRESSBOOK, KEY_DOCUMENTS,
@@ -532,7 +532,7 @@ static void pcmidi_setup_extra_keys(
532 0 532 0
533 }; 533 };
534 534
535 unsigned int *pkeys = &keys[0]; 535 const unsigned int *pkeys = &keys[0];
536 unsigned short i; 536 unsigned short i;
537 537
538 if (pm->ifnum != 1) /* only set up ONCE for interace 1 */ 538 if (pm->ifnum != 1) /* only set up ONCE for interace 1 */
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 73c0f7a95e2d..4c6ed6ef31f1 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -2254,9 +2254,15 @@ static int sony_play_effect(struct input_dev *dev, void *data,
2254 2254
2255static int sony_init_ff(struct sony_sc *sc) 2255static int sony_init_ff(struct sony_sc *sc)
2256{ 2256{
2257 struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, 2257 struct hid_input *hidinput;
2258 struct hid_input, list); 2258 struct input_dev *input_dev;
2259 struct input_dev *input_dev = hidinput->input; 2259
2260 if (list_empty(&sc->hdev->inputs)) {
2261 hid_err(sc->hdev, "no inputs found\n");
2262 return -ENODEV;
2263 }
2264 hidinput = list_entry(sc->hdev->inputs.next, struct hid_input, list);
2265 input_dev = hidinput->input;
2260 2266
2261 input_set_capability(input_dev, EV_FF, FF_RUMBLE); 2267 input_set_capability(input_dev, EV_FF, FF_RUMBLE);
2262 return input_ff_create_memless(input_dev, NULL, sony_play_effect); 2268 return input_ff_create_memless(input_dev, NULL, sony_play_effect);
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index bdfc5ff3b2c5..90acef304536 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -124,12 +124,18 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits)
124 struct tmff_device *tmff; 124 struct tmff_device *tmff;
125 struct hid_report *report; 125 struct hid_report *report;
126 struct list_head *report_list; 126 struct list_head *report_list;
127 struct hid_input *hidinput = list_entry(hid->inputs.next, 127 struct hid_input *hidinput;
128 struct hid_input, list); 128 struct input_dev *input_dev;
129 struct input_dev *input_dev = hidinput->input;
130 int error; 129 int error;
131 int i; 130 int i;
132 131
132 if (list_empty(&hid->inputs)) {
133 hid_err(hid, "no inputs found\n");
134 return -ENODEV;
135 }
136 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
137 input_dev = hidinput->input;
138
133 tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL); 139 tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL);
134 if (!tmff) 140 if (!tmff)
135 return -ENOMEM; 141 return -ENOMEM;
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index f90959e94028..3abaca045869 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -54,11 +54,17 @@ static int zpff_init(struct hid_device *hid)
54{ 54{
55 struct zpff_device *zpff; 55 struct zpff_device *zpff;
56 struct hid_report *report; 56 struct hid_report *report;
57 struct hid_input *hidinput = list_entry(hid->inputs.next, 57 struct hid_input *hidinput;
58 struct hid_input, list); 58 struct input_dev *dev;
59 struct input_dev *dev = hidinput->input;
60 int i, error; 59 int i, error;
61 60
61 if (list_empty(&hid->inputs)) {
62 hid_err(hid, "no inputs found\n");
63 return -ENODEV;
64 }
65 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
66 dev = hidinput->input;
67
62 for (i = 0; i < 4; i++) { 68 for (i = 0; i < 4; i++) {
63 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1); 69 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
64 if (!report) 70 if (!report)
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 2a7c6e33bb1c..d9c55e30f986 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -26,7 +26,6 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/pm_runtime.h>
30#include <linux/device.h> 29#include <linux/device.h>
31#include <linux/wait.h> 30#include <linux/wait.h>
32#include <linux/err.h> 31#include <linux/err.h>
@@ -48,8 +47,6 @@
48/* quirks to control the device */ 47/* quirks to control the device */
49#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) 48#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0)
50#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) 49#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1)
51#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2)
52#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3)
53#define I2C_HID_QUIRK_BOGUS_IRQ BIT(4) 50#define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
54 51
55/* flags */ 52/* flags */
@@ -172,14 +169,7 @@ static const struct i2c_hid_quirks {
172 { USB_VENDOR_ID_WEIDA, HID_ANY_ID, 169 { USB_VENDOR_ID_WEIDA, HID_ANY_ID,
173 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, 170 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
174 { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, 171 { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
175 I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | 172 I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
176 I2C_HID_QUIRK_NO_RUNTIME_PM },
177 { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_4B33,
178 I2C_HID_QUIRK_DELAY_AFTER_SLEEP },
179 { USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001,
180 I2C_HID_QUIRK_NO_RUNTIME_PM },
181 { I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_01F0,
182 I2C_HID_QUIRK_NO_RUNTIME_PM },
183 { USB_VENDOR_ID_ELAN, HID_ANY_ID, 173 { USB_VENDOR_ID_ELAN, HID_ANY_ID,
184 I2C_HID_QUIRK_BOGUS_IRQ }, 174 I2C_HID_QUIRK_BOGUS_IRQ },
185 { 0, 0 } 175 { 0, 0 }
@@ -397,7 +387,6 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
397{ 387{
398 struct i2c_hid *ihid = i2c_get_clientdata(client); 388 struct i2c_hid *ihid = i2c_get_clientdata(client);
399 int ret; 389 int ret;
400 unsigned long now, delay;
401 390
402 i2c_hid_dbg(ihid, "%s\n", __func__); 391 i2c_hid_dbg(ihid, "%s\n", __func__);
403 392
@@ -415,22 +404,9 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
415 goto set_pwr_exit; 404 goto set_pwr_exit;
416 } 405 }
417 406
418 if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP &&
419 power_state == I2C_HID_PWR_ON) {
420 now = jiffies;
421 if (time_after(ihid->sleep_delay, now)) {
422 delay = jiffies_to_usecs(ihid->sleep_delay - now);
423 usleep_range(delay, delay + 1);
424 }
425 }
426
427 ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, 407 ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state,
428 0, NULL, 0, NULL, 0); 408 0, NULL, 0, NULL, 0);
429 409
430 if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP &&
431 power_state == I2C_HID_PWR_SLEEP)
432 ihid->sleep_delay = jiffies + msecs_to_jiffies(20);
433
434 if (ret) 410 if (ret)
435 dev_err(&client->dev, "failed to change power setting.\n"); 411 dev_err(&client->dev, "failed to change power setting.\n");
436 412
@@ -791,11 +767,6 @@ static int i2c_hid_open(struct hid_device *hid)
791{ 767{
792 struct i2c_client *client = hid->driver_data; 768 struct i2c_client *client = hid->driver_data;
793 struct i2c_hid *ihid = i2c_get_clientdata(client); 769 struct i2c_hid *ihid = i2c_get_clientdata(client);
794 int ret = 0;
795
796 ret = pm_runtime_get_sync(&client->dev);
797 if (ret < 0)
798 return ret;
799 770
800 set_bit(I2C_HID_STARTED, &ihid->flags); 771 set_bit(I2C_HID_STARTED, &ihid->flags);
801 return 0; 772 return 0;
@@ -807,27 +778,6 @@ static void i2c_hid_close(struct hid_device *hid)
807 struct i2c_hid *ihid = i2c_get_clientdata(client); 778 struct i2c_hid *ihid = i2c_get_clientdata(client);
808 779
809 clear_bit(I2C_HID_STARTED, &ihid->flags); 780 clear_bit(I2C_HID_STARTED, &ihid->flags);
810
811 /* Save some power */
812 pm_runtime_put(&client->dev);
813}
814
815static int i2c_hid_power(struct hid_device *hid, int lvl)
816{
817 struct i2c_client *client = hid->driver_data;
818 struct i2c_hid *ihid = i2c_get_clientdata(client);
819
820 i2c_hid_dbg(ihid, "%s lvl:%d\n", __func__, lvl);
821
822 switch (lvl) {
823 case PM_HINT_FULLON:
824 pm_runtime_get_sync(&client->dev);
825 break;
826 case PM_HINT_NORMAL:
827 pm_runtime_put(&client->dev);
828 break;
829 }
830 return 0;
831} 781}
832 782
833struct hid_ll_driver i2c_hid_ll_driver = { 783struct hid_ll_driver i2c_hid_ll_driver = {
@@ -836,7 +786,6 @@ struct hid_ll_driver i2c_hid_ll_driver = {
836 .stop = i2c_hid_stop, 786 .stop = i2c_hid_stop,
837 .open = i2c_hid_open, 787 .open = i2c_hid_open,
838 .close = i2c_hid_close, 788 .close = i2c_hid_close,
839 .power = i2c_hid_power,
840 .output_report = i2c_hid_output_report, 789 .output_report = i2c_hid_output_report,
841 .raw_request = i2c_hid_raw_request, 790 .raw_request = i2c_hid_raw_request,
842}; 791};
@@ -1104,9 +1053,6 @@ static int i2c_hid_probe(struct i2c_client *client,
1104 1053
1105 i2c_hid_acpi_fix_up_power(&client->dev); 1054 i2c_hid_acpi_fix_up_power(&client->dev);
1106 1055
1107 pm_runtime_get_noresume(&client->dev);
1108 pm_runtime_set_active(&client->dev);
1109 pm_runtime_enable(&client->dev);
1110 device_enable_async_suspend(&client->dev); 1056 device_enable_async_suspend(&client->dev);
1111 1057
1112 /* Make sure there is something at this address */ 1058 /* Make sure there is something at this address */
@@ -1114,16 +1060,16 @@ static int i2c_hid_probe(struct i2c_client *client,
1114 if (ret < 0) { 1060 if (ret < 0) {
1115 dev_dbg(&client->dev, "nothing at this address: %d\n", ret); 1061 dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
1116 ret = -ENXIO; 1062 ret = -ENXIO;
1117 goto err_pm; 1063 goto err_regulator;
1118 } 1064 }
1119 1065
1120 ret = i2c_hid_fetch_hid_descriptor(ihid); 1066 ret = i2c_hid_fetch_hid_descriptor(ihid);
1121 if (ret < 0) 1067 if (ret < 0)
1122 goto err_pm; 1068 goto err_regulator;
1123 1069
1124 ret = i2c_hid_init_irq(client); 1070 ret = i2c_hid_init_irq(client);
1125 if (ret < 0) 1071 if (ret < 0)
1126 goto err_pm; 1072 goto err_regulator;
1127 1073
1128 hid = hid_allocate_device(); 1074 hid = hid_allocate_device();
1129 if (IS_ERR(hid)) { 1075 if (IS_ERR(hid)) {
@@ -1154,9 +1100,6 @@ static int i2c_hid_probe(struct i2c_client *client,
1154 goto err_mem_free; 1100 goto err_mem_free;
1155 } 1101 }
1156 1102
1157 if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM))
1158 pm_runtime_put(&client->dev);
1159
1160 return 0; 1103 return 0;
1161 1104
1162err_mem_free: 1105err_mem_free:
@@ -1165,10 +1108,6 @@ err_mem_free:
1165err_irq: 1108err_irq:
1166 free_irq(client->irq, ihid); 1109 free_irq(client->irq, ihid);
1167 1110
1168err_pm:
1169 pm_runtime_put_noidle(&client->dev);
1170 pm_runtime_disable(&client->dev);
1171
1172err_regulator: 1111err_regulator:
1173 regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), 1112 regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
1174 ihid->pdata.supplies); 1113 ihid->pdata.supplies);
@@ -1181,12 +1120,6 @@ static int i2c_hid_remove(struct i2c_client *client)
1181 struct i2c_hid *ihid = i2c_get_clientdata(client); 1120 struct i2c_hid *ihid = i2c_get_clientdata(client);
1182 struct hid_device *hid; 1121 struct hid_device *hid;
1183 1122
1184 if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM))
1185 pm_runtime_get_sync(&client->dev);
1186 pm_runtime_disable(&client->dev);
1187 pm_runtime_set_suspended(&client->dev);
1188 pm_runtime_put_noidle(&client->dev);
1189
1190 hid = ihid->hid; 1123 hid = ihid->hid;
1191 hid_destroy_device(hid); 1124 hid_destroy_device(hid);
1192 1125
@@ -1219,25 +1152,15 @@ static int i2c_hid_suspend(struct device *dev)
1219 int wake_status; 1152 int wake_status;
1220 1153
1221 if (hid->driver && hid->driver->suspend) { 1154 if (hid->driver && hid->driver->suspend) {
1222 /*
1223 * Wake up the device so that IO issues in
1224 * HID driver's suspend code can succeed.
1225 */
1226 ret = pm_runtime_resume(dev);
1227 if (ret < 0)
1228 return ret;
1229
1230 ret = hid->driver->suspend(hid, PMSG_SUSPEND); 1155 ret = hid->driver->suspend(hid, PMSG_SUSPEND);
1231 if (ret < 0) 1156 if (ret < 0)
1232 return ret; 1157 return ret;
1233 } 1158 }
1234 1159
1235 if (!pm_runtime_suspended(dev)) { 1160 /* Save some power */
1236 /* Save some power */ 1161 i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
1237 i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
1238 1162
1239 disable_irq(client->irq); 1163 disable_irq(client->irq);
1240 }
1241 1164
1242 if (device_may_wakeup(&client->dev)) { 1165 if (device_may_wakeup(&client->dev)) {
1243 wake_status = enable_irq_wake(client->irq); 1166 wake_status = enable_irq_wake(client->irq);
@@ -1279,11 +1202,6 @@ static int i2c_hid_resume(struct device *dev)
1279 wake_status); 1202 wake_status);
1280 } 1203 }
1281 1204
1282 /* We'll resume to full power */
1283 pm_runtime_disable(dev);
1284 pm_runtime_set_active(dev);
1285 pm_runtime_enable(dev);
1286
1287 enable_irq(client->irq); 1205 enable_irq(client->irq);
1288 1206
1289 /* Instead of resetting device, simply powers the device on. This 1207 /* Instead of resetting device, simply powers the device on. This
@@ -1304,30 +1222,8 @@ static int i2c_hid_resume(struct device *dev)
1304} 1222}
1305#endif 1223#endif
1306 1224
1307#ifdef CONFIG_PM
1308static int i2c_hid_runtime_suspend(struct device *dev)
1309{
1310 struct i2c_client *client = to_i2c_client(dev);
1311
1312 i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
1313 disable_irq(client->irq);
1314 return 0;
1315}
1316
1317static int i2c_hid_runtime_resume(struct device *dev)
1318{
1319 struct i2c_client *client = to_i2c_client(dev);
1320
1321 enable_irq(client->irq);
1322 i2c_hid_set_power(client, I2C_HID_PWR_ON);
1323 return 0;
1324}
1325#endif
1326
1327static const struct dev_pm_ops i2c_hid_pm = { 1225static const struct dev_pm_ops i2c_hid_pm = {
1328 SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_suspend, i2c_hid_resume) 1226 SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_suspend, i2c_hid_resume)
1329 SET_RUNTIME_PM_OPS(i2c_hid_runtime_suspend, i2c_hid_runtime_resume,
1330 NULL)
1331}; 1227};
1332 1228
1333static const struct i2c_device_id i2c_hid_id_table[] = { 1229static const struct i2c_device_id i2c_hid_id_table[] = {
diff --git a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c
index 75078c83be1a..d31ea82b84c1 100644
--- a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c
+++ b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c
@@ -323,6 +323,25 @@ static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = {
323 .driver_data = (void *)&sipodev_desc 323 .driver_data = (void *)&sipodev_desc
324 }, 324 },
325 { 325 {
326 /*
327 * There are at least 2 Primebook C11B versions, the older
328 * version has a product-name of "Primebook C11B", and a
329 * bios version / release / firmware revision of:
330 * V2.1.2 / 05/03/2018 / 18.2
331 * The new version has "PRIMEBOOK C11B" as product-name and a
332 * bios version / release / firmware revision of:
333 * CFALKSW05_BIOS_V1.1.2 / 11/19/2018 / 19.2
334 * Only the older version needs this quirk, note the newer
335 * version will not match as it has a different product-name.
336 */
337 .ident = "Trekstor Primebook C11B",
338 .matches = {
339 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
340 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C11B"),
341 },
342 .driver_data = (void *)&sipodev_desc
343 },
344 {
326 .ident = "Direkt-Tek DTLAPY116-2", 345 .ident = "Direkt-Tek DTLAPY116-2",
327 .matches = { 346 .matches = {
328 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Direkt-Tek"), 347 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Direkt-Tek"),
diff --git a/drivers/hid/intel-ish-hid/ishtp/client-buffers.c b/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
index 1b0a0cc605e7..513d7a4a1b8a 100644
--- a/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
+++ b/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
@@ -84,7 +84,7 @@ int ishtp_cl_alloc_tx_ring(struct ishtp_cl *cl)
84 return 0; 84 return 0;
85out: 85out:
86 dev_err(&cl->device->dev, "error in allocating Tx pool\n"); 86 dev_err(&cl->device->dev, "error in allocating Tx pool\n");
87 ishtp_cl_free_rx_ring(cl); 87 ishtp_cl_free_tx_ring(cl);
88 return -ENOMEM; 88 return -ENOMEM;
89} 89}
90 90
diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 0037e2bdacd6..8a51dcf055ea 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -170,7 +170,7 @@ static inline int ina3221_wait_for_data(struct ina3221_data *ina)
170 170
171 /* Polling the CVRF bit to make sure read data is ready */ 171 /* Polling the CVRF bit to make sure read data is ready */
172 return regmap_field_read_poll_timeout(ina->fields[F_CVRF], 172 return regmap_field_read_poll_timeout(ina->fields[F_CVRF],
173 cvrf, cvrf, wait, 100000); 173 cvrf, cvrf, wait, wait * 2);
174} 174}
175 175
176static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg, 176static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,
diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
index b26419dbe840..281c81edabc6 100644
--- a/drivers/hwmon/nct7904.c
+++ b/drivers/hwmon/nct7904.c
@@ -82,6 +82,10 @@
82#define FANCTL1_FMR_REG 0x00 /* Bank 3; 1 reg per channel */ 82#define FANCTL1_FMR_REG 0x00 /* Bank 3; 1 reg per channel */
83#define FANCTL1_OUT_REG 0x10 /* Bank 3; 1 reg per channel */ 83#define FANCTL1_OUT_REG 0x10 /* Bank 3; 1 reg per channel */
84 84
85#define VOLT_MONITOR_MODE 0x0
86#define THERMAL_DIODE_MODE 0x1
87#define THERMISTOR_MODE 0x3
88
85#define ENABLE_TSI BIT(1) 89#define ENABLE_TSI BIT(1)
86 90
87static const unsigned short normal_i2c[] = { 91static const unsigned short normal_i2c[] = {
@@ -935,11 +939,16 @@ static int nct7904_probe(struct i2c_client *client,
935 for (i = 0; i < 4; i++) { 939 for (i = 0; i < 4; i++) {
936 val = (ret >> (i * 2)) & 0x03; 940 val = (ret >> (i * 2)) & 0x03;
937 bit = (1 << i); 941 bit = (1 << i);
938 if (val == 0) { 942 if (val == VOLT_MONITOR_MODE) {
939 data->tcpu_mask &= ~bit; 943 data->tcpu_mask &= ~bit;
944 } else if (val == THERMAL_DIODE_MODE && i < 2) {
945 data->temp_mode |= bit;
946 data->vsen_mask &= ~(0x06 << (i * 2));
947 } else if (val == THERMISTOR_MODE) {
948 data->vsen_mask &= ~(0x02 << (i * 2));
940 } else { 949 } else {
941 if (val == 0x1 || val == 0x2) 950 /* Reserved */
942 data->temp_mode |= bit; 951 data->tcpu_mask &= ~bit;
943 data->vsen_mask &= ~(0x06 << (i * 2)); 952 data->vsen_mask &= ~(0x06 << (i * 2));
944 } 953 }
945 } 954 }
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index 3a8b0911c3bc..9d07378b5b42 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -199,6 +199,7 @@ void ib_mad_cleanup(void);
199int ib_sa_init(void); 199int ib_sa_init(void);
200void ib_sa_cleanup(void); 200void ib_sa_cleanup(void);
201 201
202void rdma_nl_init(void);
202void rdma_nl_exit(void); 203void rdma_nl_exit(void);
203 204
204int ib_nl_handle_resolve_resp(struct sk_buff *skb, 205int ib_nl_handle_resolve_resp(struct sk_buff *skb,
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 2dd2cfe9b561..50a92442c4f7 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2716,6 +2716,8 @@ static int __init ib_core_init(void)
2716 goto err_comp_unbound; 2716 goto err_comp_unbound;
2717 } 2717 }
2718 2718
2719 rdma_nl_init();
2720
2719 ret = addr_init(); 2721 ret = addr_init();
2720 if (ret) { 2722 if (ret) {
2721 pr_warn("Could't init IB address resolution\n"); 2723 pr_warn("Could't init IB address resolution\n");
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 72141c5b7c95..ade71823370f 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -372,6 +372,7 @@ EXPORT_SYMBOL(iw_cm_disconnect);
372static void destroy_cm_id(struct iw_cm_id *cm_id) 372static void destroy_cm_id(struct iw_cm_id *cm_id)
373{ 373{
374 struct iwcm_id_private *cm_id_priv; 374 struct iwcm_id_private *cm_id_priv;
375 struct ib_qp *qp;
375 unsigned long flags; 376 unsigned long flags;
376 377
377 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 378 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
@@ -389,6 +390,9 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
389 set_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags); 390 set_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags);
390 391
391 spin_lock_irqsave(&cm_id_priv->lock, flags); 392 spin_lock_irqsave(&cm_id_priv->lock, flags);
393 qp = cm_id_priv->qp;
394 cm_id_priv->qp = NULL;
395
392 switch (cm_id_priv->state) { 396 switch (cm_id_priv->state) {
393 case IW_CM_STATE_LISTEN: 397 case IW_CM_STATE_LISTEN:
394 cm_id_priv->state = IW_CM_STATE_DESTROYING; 398 cm_id_priv->state = IW_CM_STATE_DESTROYING;
@@ -401,7 +405,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
401 cm_id_priv->state = IW_CM_STATE_DESTROYING; 405 cm_id_priv->state = IW_CM_STATE_DESTROYING;
402 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 406 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
403 /* Abrupt close of the connection */ 407 /* Abrupt close of the connection */
404 (void)iwcm_modify_qp_err(cm_id_priv->qp); 408 (void)iwcm_modify_qp_err(qp);
405 spin_lock_irqsave(&cm_id_priv->lock, flags); 409 spin_lock_irqsave(&cm_id_priv->lock, flags);
406 break; 410 break;
407 case IW_CM_STATE_IDLE: 411 case IW_CM_STATE_IDLE:
@@ -426,11 +430,9 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
426 BUG(); 430 BUG();
427 break; 431 break;
428 } 432 }
429 if (cm_id_priv->qp) {
430 cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp);
431 cm_id_priv->qp = NULL;
432 }
433 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 433 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
434 if (qp)
435 cm_id_priv->id.device->ops.iw_rem_ref(qp);
434 436
435 if (cm_id->mapped) { 437 if (cm_id->mapped) {
436 iwpm_remove_mapinfo(&cm_id->local_addr, &cm_id->m_local_addr); 438 iwpm_remove_mapinfo(&cm_id->local_addr, &cm_id->m_local_addr);
@@ -671,11 +673,11 @@ int iw_cm_accept(struct iw_cm_id *cm_id,
671 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV); 673 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
672 cm_id_priv->state = IW_CM_STATE_IDLE; 674 cm_id_priv->state = IW_CM_STATE_IDLE;
673 spin_lock_irqsave(&cm_id_priv->lock, flags); 675 spin_lock_irqsave(&cm_id_priv->lock, flags);
674 if (cm_id_priv->qp) { 676 qp = cm_id_priv->qp;
675 cm_id->device->ops.iw_rem_ref(qp); 677 cm_id_priv->qp = NULL;
676 cm_id_priv->qp = NULL;
677 }
678 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 678 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
679 if (qp)
680 cm_id->device->ops.iw_rem_ref(qp);
679 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); 681 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
680 wake_up_all(&cm_id_priv->connect_wait); 682 wake_up_all(&cm_id_priv->connect_wait);
681 } 683 }
@@ -696,7 +698,7 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
696 struct iwcm_id_private *cm_id_priv; 698 struct iwcm_id_private *cm_id_priv;
697 int ret; 699 int ret;
698 unsigned long flags; 700 unsigned long flags;
699 struct ib_qp *qp; 701 struct ib_qp *qp = NULL;
700 702
701 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 703 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
702 704
@@ -730,13 +732,13 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
730 return 0; /* success */ 732 return 0; /* success */
731 733
732 spin_lock_irqsave(&cm_id_priv->lock, flags); 734 spin_lock_irqsave(&cm_id_priv->lock, flags);
733 if (cm_id_priv->qp) { 735 qp = cm_id_priv->qp;
734 cm_id->device->ops.iw_rem_ref(qp); 736 cm_id_priv->qp = NULL;
735 cm_id_priv->qp = NULL;
736 }
737 cm_id_priv->state = IW_CM_STATE_IDLE; 737 cm_id_priv->state = IW_CM_STATE_IDLE;
738err: 738err:
739 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 739 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
740 if (qp)
741 cm_id->device->ops.iw_rem_ref(qp);
740 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); 742 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
741 wake_up_all(&cm_id_priv->connect_wait); 743 wake_up_all(&cm_id_priv->connect_wait);
742 return ret; 744 return ret;
@@ -878,6 +880,7 @@ static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
878static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv, 880static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
879 struct iw_cm_event *iw_event) 881 struct iw_cm_event *iw_event)
880{ 882{
883 struct ib_qp *qp = NULL;
881 unsigned long flags; 884 unsigned long flags;
882 int ret; 885 int ret;
883 886
@@ -896,11 +899,13 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
896 cm_id_priv->state = IW_CM_STATE_ESTABLISHED; 899 cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
897 } else { 900 } else {
898 /* REJECTED or RESET */ 901 /* REJECTED or RESET */
899 cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp); 902 qp = cm_id_priv->qp;
900 cm_id_priv->qp = NULL; 903 cm_id_priv->qp = NULL;
901 cm_id_priv->state = IW_CM_STATE_IDLE; 904 cm_id_priv->state = IW_CM_STATE_IDLE;
902 } 905 }
903 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 906 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
907 if (qp)
908 cm_id_priv->id.device->ops.iw_rem_ref(qp);
904 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); 909 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
905 910
906 if (iw_event->private_data_len) 911 if (iw_event->private_data_len)
@@ -942,21 +947,18 @@ static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv,
942static int cm_close_handler(struct iwcm_id_private *cm_id_priv, 947static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
943 struct iw_cm_event *iw_event) 948 struct iw_cm_event *iw_event)
944{ 949{
950 struct ib_qp *qp;
945 unsigned long flags; 951 unsigned long flags;
946 int ret = 0; 952 int ret = 0, notify_event = 0;
947 spin_lock_irqsave(&cm_id_priv->lock, flags); 953 spin_lock_irqsave(&cm_id_priv->lock, flags);
954 qp = cm_id_priv->qp;
955 cm_id_priv->qp = NULL;
948 956
949 if (cm_id_priv->qp) {
950 cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp);
951 cm_id_priv->qp = NULL;
952 }
953 switch (cm_id_priv->state) { 957 switch (cm_id_priv->state) {
954 case IW_CM_STATE_ESTABLISHED: 958 case IW_CM_STATE_ESTABLISHED:
955 case IW_CM_STATE_CLOSING: 959 case IW_CM_STATE_CLOSING:
956 cm_id_priv->state = IW_CM_STATE_IDLE; 960 cm_id_priv->state = IW_CM_STATE_IDLE;
957 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 961 notify_event = 1;
958 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
959 spin_lock_irqsave(&cm_id_priv->lock, flags);
960 break; 962 break;
961 case IW_CM_STATE_DESTROYING: 963 case IW_CM_STATE_DESTROYING:
962 break; 964 break;
@@ -965,6 +967,10 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
965 } 967 }
966 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 968 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
967 969
970 if (qp)
971 cm_id_priv->id.device->ops.iw_rem_ref(qp);
972 if (notify_event)
973 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
968 return ret; 974 return ret;
969} 975}
970 976
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
index 81dbd5f41bed..8cd31ef25eff 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -42,9 +42,12 @@
42#include <linux/module.h> 42#include <linux/module.h>
43#include "core_priv.h" 43#include "core_priv.h"
44 44
45static DEFINE_MUTEX(rdma_nl_mutex);
46static struct { 45static struct {
47 const struct rdma_nl_cbs *cb_table; 46 const struct rdma_nl_cbs *cb_table;
47 /* Synchronizes between ongoing netlink commands and netlink client
48 * unregistration.
49 */
50 struct rw_semaphore sem;
48} rdma_nl_types[RDMA_NL_NUM_CLIENTS]; 51} rdma_nl_types[RDMA_NL_NUM_CLIENTS];
49 52
50bool rdma_nl_chk_listeners(unsigned int group) 53bool rdma_nl_chk_listeners(unsigned int group)
@@ -75,70 +78,53 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int op)
75 return (op < max_num_ops[type]) ? true : false; 78 return (op < max_num_ops[type]) ? true : false;
76} 79}
77 80
78static bool 81static const struct rdma_nl_cbs *
79is_nl_valid(const struct sk_buff *skb, unsigned int type, unsigned int op) 82get_cb_table(const struct sk_buff *skb, unsigned int type, unsigned int op)
80{ 83{
81 const struct rdma_nl_cbs *cb_table; 84 const struct rdma_nl_cbs *cb_table;
82 85
83 if (!is_nl_msg_valid(type, op))
84 return false;
85
86 /* 86 /*
87 * Currently only NLDEV client is supporting netlink commands in 87 * Currently only NLDEV client is supporting netlink commands in
88 * non init_net net namespace. 88 * non init_net net namespace.
89 */ 89 */
90 if (sock_net(skb->sk) != &init_net && type != RDMA_NL_NLDEV) 90 if (sock_net(skb->sk) != &init_net && type != RDMA_NL_NLDEV)
91 return false; 91 return NULL;
92 92
93 if (!rdma_nl_types[type].cb_table) { 93 cb_table = READ_ONCE(rdma_nl_types[type].cb_table);
94 mutex_unlock(&rdma_nl_mutex); 94 if (!cb_table) {
95 request_module("rdma-netlink-subsys-%d", type); 95 /*
96 mutex_lock(&rdma_nl_mutex); 96 * Didn't get valid reference of the table, attempt module
97 } 97 * load once.
98 */
99 up_read(&rdma_nl_types[type].sem);
98 100
99 cb_table = rdma_nl_types[type].cb_table; 101 request_module("rdma-netlink-subsys-%d", type);
100 102
103 down_read(&rdma_nl_types[type].sem);
104 cb_table = READ_ONCE(rdma_nl_types[type].cb_table);
105 }
101 if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit)) 106 if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit))
102 return false; 107 return NULL;
103 return true; 108 return cb_table;
104} 109}
105 110
106void rdma_nl_register(unsigned int index, 111void rdma_nl_register(unsigned int index,
107 const struct rdma_nl_cbs cb_table[]) 112 const struct rdma_nl_cbs cb_table[])
108{ 113{
109 mutex_lock(&rdma_nl_mutex); 114 if (WARN_ON(!is_nl_msg_valid(index, 0)) ||
110 if (!is_nl_msg_valid(index, 0)) { 115 WARN_ON(READ_ONCE(rdma_nl_types[index].cb_table)))
111 /*
112 * All clients are not interesting in success/failure of
113 * this call. They want to see the print to error log and
114 * continue their initialization. Print warning for them,
115 * because it is programmer's error to be here.
116 */
117 mutex_unlock(&rdma_nl_mutex);
118 WARN(true,
119 "The not-valid %u index was supplied to RDMA netlink\n",
120 index);
121 return; 116 return;
122 }
123
124 if (rdma_nl_types[index].cb_table) {
125 mutex_unlock(&rdma_nl_mutex);
126 WARN(true,
127 "The %u index is already registered in RDMA netlink\n",
128 index);
129 return;
130 }
131 117
132 rdma_nl_types[index].cb_table = cb_table; 118 /* Pairs with the READ_ONCE in is_nl_valid() */
133 mutex_unlock(&rdma_nl_mutex); 119 smp_store_release(&rdma_nl_types[index].cb_table, cb_table);
134} 120}
135EXPORT_SYMBOL(rdma_nl_register); 121EXPORT_SYMBOL(rdma_nl_register);
136 122
137void rdma_nl_unregister(unsigned int index) 123void rdma_nl_unregister(unsigned int index)
138{ 124{
139 mutex_lock(&rdma_nl_mutex); 125 down_write(&rdma_nl_types[index].sem);
140 rdma_nl_types[index].cb_table = NULL; 126 rdma_nl_types[index].cb_table = NULL;
141 mutex_unlock(&rdma_nl_mutex); 127 up_write(&rdma_nl_types[index].sem);
142} 128}
143EXPORT_SYMBOL(rdma_nl_unregister); 129EXPORT_SYMBOL(rdma_nl_unregister);
144 130
@@ -170,15 +156,21 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
170 unsigned int index = RDMA_NL_GET_CLIENT(type); 156 unsigned int index = RDMA_NL_GET_CLIENT(type);
171 unsigned int op = RDMA_NL_GET_OP(type); 157 unsigned int op = RDMA_NL_GET_OP(type);
172 const struct rdma_nl_cbs *cb_table; 158 const struct rdma_nl_cbs *cb_table;
159 int err = -EINVAL;
173 160
174 if (!is_nl_valid(skb, index, op)) 161 if (!is_nl_msg_valid(index, op))
175 return -EINVAL; 162 return -EINVAL;
176 163
177 cb_table = rdma_nl_types[index].cb_table; 164 down_read(&rdma_nl_types[index].sem);
165 cb_table = get_cb_table(skb, index, op);
166 if (!cb_table)
167 goto done;
178 168
179 if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) && 169 if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
180 !netlink_capable(skb, CAP_NET_ADMIN)) 170 !netlink_capable(skb, CAP_NET_ADMIN)) {
181 return -EPERM; 171 err = -EPERM;
172 goto done;
173 }
182 174
183 /* 175 /*
184 * LS responses overload the 0x100 (NLM_F_ROOT) flag. Don't 176 * LS responses overload the 0x100 (NLM_F_ROOT) flag. Don't
@@ -186,8 +178,8 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
186 */ 178 */
187 if (index == RDMA_NL_LS) { 179 if (index == RDMA_NL_LS) {
188 if (cb_table[op].doit) 180 if (cb_table[op].doit)
189 return cb_table[op].doit(skb, nlh, extack); 181 err = cb_table[op].doit(skb, nlh, extack);
190 return -EINVAL; 182 goto done;
191 } 183 }
192 /* FIXME: Convert IWCM to properly handle doit callbacks */ 184 /* FIXME: Convert IWCM to properly handle doit callbacks */
193 if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_IWCM) { 185 if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_IWCM) {
@@ -195,14 +187,15 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
195 .dump = cb_table[op].dump, 187 .dump = cb_table[op].dump,
196 }; 188 };
197 if (c.dump) 189 if (c.dump)
198 return netlink_dump_start(skb->sk, skb, nlh, &c); 190 err = netlink_dump_start(skb->sk, skb, nlh, &c);
199 return -EINVAL; 191 goto done;
200 } 192 }
201 193
202 if (cb_table[op].doit) 194 if (cb_table[op].doit)
203 return cb_table[op].doit(skb, nlh, extack); 195 err = cb_table[op].doit(skb, nlh, extack);
204 196done:
205 return 0; 197 up_read(&rdma_nl_types[index].sem);
198 return err;
206} 199}
207 200
208/* 201/*
@@ -263,9 +256,7 @@ skip:
263 256
264static void rdma_nl_rcv(struct sk_buff *skb) 257static void rdma_nl_rcv(struct sk_buff *skb)
265{ 258{
266 mutex_lock(&rdma_nl_mutex);
267 rdma_nl_rcv_skb(skb, &rdma_nl_rcv_msg); 259 rdma_nl_rcv_skb(skb, &rdma_nl_rcv_msg);
268 mutex_unlock(&rdma_nl_mutex);
269} 260}
270 261
271int rdma_nl_unicast(struct net *net, struct sk_buff *skb, u32 pid) 262int rdma_nl_unicast(struct net *net, struct sk_buff *skb, u32 pid)
@@ -297,6 +288,14 @@ int rdma_nl_multicast(struct net *net, struct sk_buff *skb,
297} 288}
298EXPORT_SYMBOL(rdma_nl_multicast); 289EXPORT_SYMBOL(rdma_nl_multicast);
299 290
291void rdma_nl_init(void)
292{
293 int idx;
294
295 for (idx = 0; idx < RDMA_NL_NUM_CLIENTS; idx++)
296 init_rwsem(&rdma_nl_types[idx].sem);
297}
298
300void rdma_nl_exit(void) 299void rdma_nl_exit(void)
301{ 300{
302 int idx; 301 int idx;
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 65b36548bc17..c03af08b80e7 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -778,7 +778,7 @@ static int fill_res_counter_entry(struct sk_buff *msg, bool has_cap_net_admin,
778 container_of(res, struct rdma_counter, res); 778 container_of(res, struct rdma_counter, res);
779 779
780 if (port && port != counter->port) 780 if (port && port != counter->port)
781 return 0; 781 return -EAGAIN;
782 782
783 /* Dump it even query failed */ 783 /* Dump it even query failed */
784 rdma_counter_query_stats(counter); 784 rdma_counter_query_stats(counter);
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 1e5aeb39f774..63f7f7db5902 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -98,7 +98,7 @@ ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata,
98 98
99struct ib_uverbs_device { 99struct ib_uverbs_device {
100 atomic_t refcount; 100 atomic_t refcount;
101 int num_comp_vectors; 101 u32 num_comp_vectors;
102 struct completion comp; 102 struct completion comp;
103 struct device dev; 103 struct device dev;
104 /* First group for device attributes, NULL terminated array */ 104 /* First group for device attributes, NULL terminated array */
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index f974b6854224..35c2841a569e 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -662,16 +662,17 @@ static bool find_gid_index(const union ib_gid *gid,
662 void *context) 662 void *context)
663{ 663{
664 struct find_gid_index_context *ctx = context; 664 struct find_gid_index_context *ctx = context;
665 u16 vlan_id = 0xffff;
666 int ret;
665 667
666 if (ctx->gid_type != gid_attr->gid_type) 668 if (ctx->gid_type != gid_attr->gid_type)
667 return false; 669 return false;
668 670
669 if ((!!(ctx->vlan_id != 0xffff) == !is_vlan_dev(gid_attr->ndev)) || 671 ret = rdma_read_gid_l2_fields(gid_attr, &vlan_id, NULL);
670 (is_vlan_dev(gid_attr->ndev) && 672 if (ret)
671 vlan_dev_vlan_id(gid_attr->ndev) != ctx->vlan_id))
672 return false; 673 return false;
673 674
674 return true; 675 return ctx->vlan_id == vlan_id;
675} 676}
676 677
677static const struct ib_gid_attr * 678static const struct ib_gid_attr *
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index e87fc0408470..347dc242fb88 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -495,7 +495,6 @@ static int _put_ep_safe(struct c4iw_dev *dev, struct sk_buff *skb)
495 495
496 ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *))); 496 ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *)));
497 release_ep_resources(ep); 497 release_ep_resources(ep);
498 kfree_skb(skb);
499 return 0; 498 return 0;
500} 499}
501 500
@@ -506,7 +505,6 @@ static int _put_pass_ep_safe(struct c4iw_dev *dev, struct sk_buff *skb)
506 ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *))); 505 ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *)));
507 c4iw_put_ep(&ep->parent_ep->com); 506 c4iw_put_ep(&ep->parent_ep->com);
508 release_ep_resources(ep); 507 release_ep_resources(ep);
509 kfree_skb(skb);
510 return 0; 508 return 0;
511} 509}
512 510
@@ -2424,20 +2422,6 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
2424 enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type; 2422 enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type;
2425 2423
2426 pr_debug("ep %p tid %u\n", ep, ep->hwtid); 2424 pr_debug("ep %p tid %u\n", ep, ep->hwtid);
2427
2428 skb_get(skb);
2429 rpl = cplhdr(skb);
2430 if (!is_t4(adapter_type)) {
2431 skb_trim(skb, roundup(sizeof(*rpl5), 16));
2432 rpl5 = (void *)rpl;
2433 INIT_TP_WR(rpl5, ep->hwtid);
2434 } else {
2435 skb_trim(skb, sizeof(*rpl));
2436 INIT_TP_WR(rpl, ep->hwtid);
2437 }
2438 OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
2439 ep->hwtid));
2440
2441 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx, 2425 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
2442 enable_tcp_timestamps && req->tcpopt.tstamp, 2426 enable_tcp_timestamps && req->tcpopt.tstamp,
2443 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); 2427 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
@@ -2483,6 +2467,20 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
2483 if (tcph->ece && tcph->cwr) 2467 if (tcph->ece && tcph->cwr)
2484 opt2 |= CCTRL_ECN_V(1); 2468 opt2 |= CCTRL_ECN_V(1);
2485 } 2469 }
2470
2471 skb_get(skb);
2472 rpl = cplhdr(skb);
2473 if (!is_t4(adapter_type)) {
2474 skb_trim(skb, roundup(sizeof(*rpl5), 16));
2475 rpl5 = (void *)rpl;
2476 INIT_TP_WR(rpl5, ep->hwtid);
2477 } else {
2478 skb_trim(skb, sizeof(*rpl));
2479 INIT_TP_WR(rpl, ep->hwtid);
2480 }
2481 OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
2482 ep->hwtid));
2483
2486 if (CHELSIO_CHIP_VERSION(adapter_type) > CHELSIO_T4) { 2484 if (CHELSIO_CHIP_VERSION(adapter_type) > CHELSIO_T4) {
2487 u32 isn = (prandom_u32() & ~7UL) - 1; 2485 u32 isn = (prandom_u32() & ~7UL) - 1;
2488 opt2 |= T5_OPT_2_VALID_F; 2486 opt2 |= T5_OPT_2_VALID_F;
diff --git a/drivers/infiniband/hw/hfi1/sdma.c b/drivers/infiniband/hw/hfi1/sdma.c
index 2ed7bfd5feea..c61b6022575e 100644
--- a/drivers/infiniband/hw/hfi1/sdma.c
+++ b/drivers/infiniband/hw/hfi1/sdma.c
@@ -65,6 +65,7 @@
65#define SDMA_DESCQ_CNT 2048 65#define SDMA_DESCQ_CNT 2048
66#define SDMA_DESC_INTR 64 66#define SDMA_DESC_INTR 64
67#define INVALID_TAIL 0xffff 67#define INVALID_TAIL 0xffff
68#define SDMA_PAD max_t(size_t, MAX_16B_PADDING, sizeof(u32))
68 69
69static uint sdma_descq_cnt = SDMA_DESCQ_CNT; 70static uint sdma_descq_cnt = SDMA_DESCQ_CNT;
70module_param(sdma_descq_cnt, uint, S_IRUGO); 71module_param(sdma_descq_cnt, uint, S_IRUGO);
@@ -1296,7 +1297,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
1296 struct sdma_engine *sde; 1297 struct sdma_engine *sde;
1297 1298
1298 if (dd->sdma_pad_dma) { 1299 if (dd->sdma_pad_dma) {
1299 dma_free_coherent(&dd->pcidev->dev, 4, 1300 dma_free_coherent(&dd->pcidev->dev, SDMA_PAD,
1300 (void *)dd->sdma_pad_dma, 1301 (void *)dd->sdma_pad_dma,
1301 dd->sdma_pad_phys); 1302 dd->sdma_pad_phys);
1302 dd->sdma_pad_dma = NULL; 1303 dd->sdma_pad_dma = NULL;
@@ -1491,7 +1492,7 @@ int sdma_init(struct hfi1_devdata *dd, u8 port)
1491 } 1492 }
1492 1493
1493 /* Allocate memory for pad */ 1494 /* Allocate memory for pad */
1494 dd->sdma_pad_dma = dma_alloc_coherent(&dd->pcidev->dev, sizeof(u32), 1495 dd->sdma_pad_dma = dma_alloc_coherent(&dd->pcidev->dev, SDMA_PAD,
1495 &dd->sdma_pad_phys, GFP_KERNEL); 1496 &dd->sdma_pad_phys, GFP_KERNEL);
1496 if (!dd->sdma_pad_dma) { 1497 if (!dd->sdma_pad_dma) {
1497 dd_dev_err(dd, "failed to allocate SendDMA pad memory\n"); 1498 dd_dev_err(dd, "failed to allocate SendDMA pad memory\n");
diff --git a/drivers/infiniband/hw/hfi1/tid_rdma.c b/drivers/infiniband/hw/hfi1/tid_rdma.c
index b4dcc4d29f84..f21fca3617d5 100644
--- a/drivers/infiniband/hw/hfi1/tid_rdma.c
+++ b/drivers/infiniband/hw/hfi1/tid_rdma.c
@@ -2736,11 +2736,6 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
2736 diff = cmp_psn(psn, 2736 diff = cmp_psn(psn,
2737 flow->flow_state.r_next_psn); 2737 flow->flow_state.r_next_psn);
2738 if (diff > 0) { 2738 if (diff > 0) {
2739 if (!(qp->r_flags & RVT_R_RDMAR_SEQ))
2740 restart_tid_rdma_read_req(rcd,
2741 qp,
2742 wqe);
2743
2744 /* Drop the packet.*/ 2739 /* Drop the packet.*/
2745 goto s_unlock; 2740 goto s_unlock;
2746 } else if (diff < 0) { 2741 } else if (diff < 0) {
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 7bff0a1e713d..089e201d7550 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -147,9 +147,6 @@ static int pio_wait(struct rvt_qp *qp,
147/* Length of buffer to create verbs txreq cache name */ 147/* Length of buffer to create verbs txreq cache name */
148#define TXREQ_NAME_LEN 24 148#define TXREQ_NAME_LEN 24
149 149
150/* 16B trailing buffer */
151static const u8 trail_buf[MAX_16B_PADDING];
152
153static uint wss_threshold = 80; 150static uint wss_threshold = 80;
154module_param(wss_threshold, uint, S_IRUGO); 151module_param(wss_threshold, uint, S_IRUGO);
155MODULE_PARM_DESC(wss_threshold, "Percentage (1-100) of LLC to use as a threshold for a cacheless copy"); 152MODULE_PARM_DESC(wss_threshold, "Percentage (1-100) of LLC to use as a threshold for a cacheless copy");
@@ -820,8 +817,8 @@ static int build_verbs_tx_desc(
820 817
821 /* add icrc, lt byte, and padding to flit */ 818 /* add icrc, lt byte, and padding to flit */
822 if (extra_bytes) 819 if (extra_bytes)
823 ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, 820 ret = sdma_txadd_daddr(sde->dd, &tx->txreq,
824 (void *)trail_buf, extra_bytes); 821 sde->dd->sdma_pad_phys, extra_bytes);
825 822
826bail_txadd: 823bail_txadd:
827 return ret; 824 return ret;
@@ -1089,7 +1086,8 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
1089 } 1086 }
1090 /* add icrc, lt byte, and padding to flit */ 1087 /* add icrc, lt byte, and padding to flit */
1091 if (extra_bytes) 1088 if (extra_bytes)
1092 seg_pio_copy_mid(pbuf, trail_buf, extra_bytes); 1089 seg_pio_copy_mid(pbuf, ppd->dd->sdma_pad_dma,
1090 extra_bytes);
1093 1091
1094 seg_pio_copy_end(pbuf); 1092 seg_pio_copy_end(pbuf);
1095 } 1093 }
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 7a89d669f8bf..e82567fcdeb7 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5389,9 +5389,9 @@ static void hns_roce_v2_free_eq(struct hns_roce_dev *hr_dev,
5389 return; 5389 return;
5390 } 5390 }
5391 5391
5392 if (eq->buf_list) 5392 dma_free_coherent(hr_dev->dev, buf_chk_sz, eq->buf_list->buf,
5393 dma_free_coherent(hr_dev->dev, buf_chk_sz, 5393 eq->buf_list->map);
5394 eq->buf_list->buf, eq->buf_list->map); 5394 kfree(eq->buf_list);
5395} 5395}
5396 5396
5397static void hns_roce_config_eqc(struct hns_roce_dev *hr_dev, 5397static void hns_roce_config_eqc(struct hns_roce_dev *hr_dev,
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 630599311586..7019c12005f4 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1967,8 +1967,8 @@ int mlx5_ib_dealloc_mw(struct ib_mw *mw)
1967 int err; 1967 int err;
1968 1968
1969 if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) { 1969 if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) {
1970 xa_erase(&dev->mdev->priv.mkey_table, 1970 xa_erase_irq(&dev->mdev->priv.mkey_table,
1971 mlx5_base_mkey(mmw->mmkey.key)); 1971 mlx5_base_mkey(mmw->mmkey.key));
1972 /* 1972 /*
1973 * pagefault_single_data_segment() may be accessing mmw under 1973 * pagefault_single_data_segment() may be accessing mmw under
1974 * SRCU if the user bound an ODP MR to this MW. 1974 * SRCU if the user bound an ODP MR to this MW.
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 8937d72ddcf6..5fd071c05944 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -3249,10 +3249,12 @@ static int modify_raw_packet_qp_sq(
3249 } 3249 }
3250 3250
3251 /* Only remove the old rate after new rate was set */ 3251 /* Only remove the old rate after new rate was set */
3252 if ((old_rl.rate && 3252 if ((old_rl.rate && !mlx5_rl_are_equal(&old_rl, &new_rl)) ||
3253 !mlx5_rl_are_equal(&old_rl, &new_rl)) || 3253 (new_state != MLX5_SQC_STATE_RDY)) {
3254 (new_state != MLX5_SQC_STATE_RDY))
3255 mlx5_rl_remove_rate(dev, &old_rl); 3254 mlx5_rl_remove_rate(dev, &old_rl);
3255 if (new_state != MLX5_SQC_STATE_RDY)
3256 memset(&new_rl, 0, sizeof(new_rl));
3257 }
3256 3258
3257 ibqp->rl = new_rl; 3259 ibqp->rl = new_rl;
3258 sq->state = new_state; 3260 sq->state = new_state;
diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c
index 5136b835e1ba..dc71b6e16a07 100644
--- a/drivers/infiniband/hw/qedr/main.c
+++ b/drivers/infiniband/hw/qedr/main.c
@@ -76,7 +76,7 @@ static void qedr_get_dev_fw_str(struct ib_device *ibdev, char *str)
76 struct qedr_dev *qedr = get_qedr_dev(ibdev); 76 struct qedr_dev *qedr = get_qedr_dev(ibdev);
77 u32 fw_ver = (u32)qedr->attr.fw_ver; 77 u32 fw_ver = (u32)qedr->attr.fw_ver;
78 78
79 snprintf(str, IB_FW_VERSION_NAME_MAX, "%d. %d. %d. %d", 79 snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d.%d",
80 (fw_ver >> 24) & 0xFF, (fw_ver >> 16) & 0xFF, 80 (fw_ver >> 24) & 0xFF, (fw_ver >> 16) & 0xFF,
81 (fw_ver >> 8) & 0xFF, fw_ver & 0xFF); 81 (fw_ver >> 8) & 0xFF, fw_ver & 0xFF);
82} 82}
diff --git a/drivers/infiniband/sw/siw/siw_qp.c b/drivers/infiniband/sw/siw/siw_qp.c
index 52d402f39df9..b4317480cee7 100644
--- a/drivers/infiniband/sw/siw/siw_qp.c
+++ b/drivers/infiniband/sw/siw/siw_qp.c
@@ -1312,6 +1312,7 @@ int siw_qp_add(struct siw_device *sdev, struct siw_qp *qp)
1312void siw_free_qp(struct kref *ref) 1312void siw_free_qp(struct kref *ref)
1313{ 1313{
1314 struct siw_qp *found, *qp = container_of(ref, struct siw_qp, ref); 1314 struct siw_qp *found, *qp = container_of(ref, struct siw_qp, ref);
1315 struct siw_base_qp *siw_base_qp = to_siw_base_qp(qp->ib_qp);
1315 struct siw_device *sdev = qp->sdev; 1316 struct siw_device *sdev = qp->sdev;
1316 unsigned long flags; 1317 unsigned long flags;
1317 1318
@@ -1334,4 +1335,5 @@ void siw_free_qp(struct kref *ref)
1334 atomic_dec(&sdev->num_qp); 1335 atomic_dec(&sdev->num_qp);
1335 siw_dbg_qp(qp, "free QP\n"); 1336 siw_dbg_qp(qp, "free QP\n");
1336 kfree_rcu(qp, rcu); 1337 kfree_rcu(qp, rcu);
1338 kfree(siw_base_qp);
1337} 1339}
diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index 869e02b69a01..b18a677832e1 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -604,7 +604,6 @@ out:
604int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata) 604int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata)
605{ 605{
606 struct siw_qp *qp = to_siw_qp(base_qp); 606 struct siw_qp *qp = to_siw_qp(base_qp);
607 struct siw_base_qp *siw_base_qp = to_siw_base_qp(base_qp);
608 struct siw_ucontext *uctx = 607 struct siw_ucontext *uctx =
609 rdma_udata_to_drv_context(udata, struct siw_ucontext, 608 rdma_udata_to_drv_context(udata, struct siw_ucontext,
610 base_ucontext); 609 base_ucontext);
@@ -641,7 +640,6 @@ int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata)
641 qp->scq = qp->rcq = NULL; 640 qp->scq = qp->rcq = NULL;
642 641
643 siw_qp_put(qp); 642 siw_qp_put(qp);
644 kfree(siw_base_qp);
645 643
646 return 0; 644 return 0;
647} 645}
diff --git a/drivers/iommu/amd_iommu_quirks.c b/drivers/iommu/amd_iommu_quirks.c
index c235f79b7a20..5120ce4fdce3 100644
--- a/drivers/iommu/amd_iommu_quirks.c
+++ b/drivers/iommu/amd_iommu_quirks.c
@@ -74,6 +74,19 @@ static const struct dmi_system_id ivrs_quirks[] __initconst = {
74 .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495], 74 .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495],
75 }, 75 },
76 { 76 {
77 /*
78 * Acer Aspire A315-41 requires the very same workaround as
79 * Dell Latitude 5495
80 */
81 .callback = ivrs_ioapic_quirk_cb,
82 .ident = "Acer Aspire A315-41",
83 .matches = {
84 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
85 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A315-41"),
86 },
87 .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495],
88 },
89 {
77 .callback = ivrs_ioapic_quirk_cb, 90 .callback = ivrs_ioapic_quirk_cb,
78 .ident = "Lenovo ideapad 330S-15ARR", 91 .ident = "Lenovo ideapad 330S-15ARR",
79 .matches = { 92 .matches = {
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 79e35b3180ac..6db6d969e31c 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2794,7 +2794,7 @@ static int identity_mapping(struct device *dev)
2794 struct device_domain_info *info; 2794 struct device_domain_info *info;
2795 2795
2796 info = dev->archdata.iommu; 2796 info = dev->archdata.iommu;
2797 if (info && info != DUMMY_DEVICE_DOMAIN_INFO) 2797 if (info && info != DUMMY_DEVICE_DOMAIN_INFO && info != DEFER_DEVICE_DOMAIN_INFO)
2798 return (info->domain == si_domain); 2798 return (info->domain == si_domain);
2799 2799
2800 return 0; 2800 return 0;
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 237103465b82..2639fc718117 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1105,10 +1105,8 @@ static int ipmmu_probe(struct platform_device *pdev)
1105 /* Root devices have mandatory IRQs */ 1105 /* Root devices have mandatory IRQs */
1106 if (ipmmu_is_root(mmu)) { 1106 if (ipmmu_is_root(mmu)) {
1107 irq = platform_get_irq(pdev, 0); 1107 irq = platform_get_irq(pdev, 0);
1108 if (irq < 0) { 1108 if (irq < 0)
1109 dev_err(&pdev->dev, "no IRQ found\n");
1110 return irq; 1109 return irq;
1111 }
1112 1110
1113 ret = devm_request_irq(&pdev->dev, irq, ipmmu_irq, 0, 1111 ret = devm_request_irq(&pdev->dev, irq, ipmmu_irq, 0,
1114 dev_name(&pdev->dev), mmu); 1112 dev_name(&pdev->dev), mmu);
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index c92b405b7646..ba8619524231 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -744,7 +744,7 @@ capi_poll(struct file *file, poll_table *wait)
744 744
745 poll_wait(file, &(cdev->recvwait), wait); 745 poll_wait(file, &(cdev->recvwait), wait);
746 mask = EPOLLOUT | EPOLLWRNORM; 746 mask = EPOLLOUT | EPOLLWRNORM;
747 if (!skb_queue_empty(&cdev->recvqueue)) 747 if (!skb_queue_empty_lockless(&cdev->recvqueue))
748 mask |= EPOLLIN | EPOLLRDNORM; 748 mask |= EPOLLIN | EPOLLRDNORM;
749 return mask; 749 return mask;
750} 750}
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 8c79bad2a9a5..4f2e6910c623 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -952,7 +952,7 @@ static int alb_upper_dev_walk(struct net_device *upper, void *_data)
952 struct bond_vlan_tag *tags; 952 struct bond_vlan_tag *tags;
953 953
954 if (is_vlan_dev(upper) && 954 if (is_vlan_dev(upper) &&
955 bond->nest_level == vlan_get_encap_level(upper) - 1) { 955 bond->dev->lower_level == upper->lower_level - 1) {
956 if (upper->addr_assign_type == NET_ADDR_STOLEN) { 956 if (upper->addr_assign_type == NET_ADDR_STOLEN) {
957 alb_send_lp_vid(slave, mac_addr, 957 alb_send_lp_vid(slave, mac_addr,
958 vlan_dev_vlan_proto(upper), 958 vlan_dev_vlan_proto(upper),
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 21d8fcc83c9c..480f9459b402 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1733,8 +1733,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
1733 goto err_upper_unlink; 1733 goto err_upper_unlink;
1734 } 1734 }
1735 1735
1736 bond->nest_level = dev_get_nest_level(bond_dev) + 1;
1737
1738 /* If the mode uses primary, then the following is handled by 1736 /* If the mode uses primary, then the following is handled by
1739 * bond_change_active_slave(). 1737 * bond_change_active_slave().
1740 */ 1738 */
@@ -1816,7 +1814,8 @@ err_detach:
1816 slave_disable_netpoll(new_slave); 1814 slave_disable_netpoll(new_slave);
1817 1815
1818err_close: 1816err_close:
1819 slave_dev->priv_flags &= ~IFF_BONDING; 1817 if (!netif_is_bond_master(slave_dev))
1818 slave_dev->priv_flags &= ~IFF_BONDING;
1820 dev_close(slave_dev); 1819 dev_close(slave_dev);
1821 1820
1822err_restore_mac: 1821err_restore_mac:
@@ -1956,9 +1955,6 @@ static int __bond_release_one(struct net_device *bond_dev,
1956 if (!bond_has_slaves(bond)) { 1955 if (!bond_has_slaves(bond)) {
1957 bond_set_carrier(bond); 1956 bond_set_carrier(bond);
1958 eth_hw_addr_random(bond_dev); 1957 eth_hw_addr_random(bond_dev);
1959 bond->nest_level = SINGLE_DEPTH_NESTING;
1960 } else {
1961 bond->nest_level = dev_get_nest_level(bond_dev) + 1;
1962 } 1958 }
1963 1959
1964 unblock_netpoll_tx(); 1960 unblock_netpoll_tx();
@@ -2017,7 +2013,8 @@ static int __bond_release_one(struct net_device *bond_dev,
2017 else 2013 else
2018 dev_set_mtu(slave_dev, slave->original_mtu); 2014 dev_set_mtu(slave_dev, slave->original_mtu);
2019 2015
2020 slave_dev->priv_flags &= ~IFF_BONDING; 2016 if (!netif_is_bond_master(slave_dev))
2017 slave_dev->priv_flags &= ~IFF_BONDING;
2021 2018
2022 bond_free_slave(slave); 2019 bond_free_slave(slave);
2023 2020
@@ -3442,13 +3439,6 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
3442 } 3439 }
3443} 3440}
3444 3441
3445static int bond_get_nest_level(struct net_device *bond_dev)
3446{
3447 struct bonding *bond = netdev_priv(bond_dev);
3448
3449 return bond->nest_level;
3450}
3451
3452static void bond_get_stats(struct net_device *bond_dev, 3442static void bond_get_stats(struct net_device *bond_dev,
3453 struct rtnl_link_stats64 *stats) 3443 struct rtnl_link_stats64 *stats)
3454{ 3444{
@@ -3457,7 +3447,7 @@ static void bond_get_stats(struct net_device *bond_dev,
3457 struct list_head *iter; 3447 struct list_head *iter;
3458 struct slave *slave; 3448 struct slave *slave;
3459 3449
3460 spin_lock_nested(&bond->stats_lock, bond_get_nest_level(bond_dev)); 3450 spin_lock(&bond->stats_lock);
3461 memcpy(stats, &bond->bond_stats, sizeof(*stats)); 3451 memcpy(stats, &bond->bond_stats, sizeof(*stats));
3462 3452
3463 rcu_read_lock(); 3453 rcu_read_lock();
@@ -4268,7 +4258,6 @@ static const struct net_device_ops bond_netdev_ops = {
4268 .ndo_neigh_setup = bond_neigh_setup, 4258 .ndo_neigh_setup = bond_neigh_setup,
4269 .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid, 4259 .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid,
4270 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, 4260 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid,
4271 .ndo_get_lock_subclass = bond_get_nest_level,
4272#ifdef CONFIG_NET_POLL_CONTROLLER 4261#ifdef CONFIG_NET_POLL_CONTROLLER
4273 .ndo_netpoll_setup = bond_netpoll_setup, 4262 .ndo_netpoll_setup = bond_netpoll_setup,
4274 .ndo_netpoll_cleanup = bond_netpoll_cleanup, 4263 .ndo_netpoll_cleanup = bond_netpoll_cleanup,
@@ -4296,7 +4285,6 @@ void bond_setup(struct net_device *bond_dev)
4296 struct bonding *bond = netdev_priv(bond_dev); 4285 struct bonding *bond = netdev_priv(bond_dev);
4297 4286
4298 spin_lock_init(&bond->mode_lock); 4287 spin_lock_init(&bond->mode_lock);
4299 spin_lock_init(&bond->stats_lock);
4300 bond->params = bonding_defaults; 4288 bond->params = bonding_defaults;
4301 4289
4302 /* Initialize pointers */ 4290 /* Initialize pointers */
@@ -4365,6 +4353,7 @@ static void bond_uninit(struct net_device *bond_dev)
4365 4353
4366 list_del(&bond->bond_list); 4354 list_del(&bond->bond_list);
4367 4355
4356 lockdep_unregister_key(&bond->stats_lock_key);
4368 bond_debug_unregister(bond); 4357 bond_debug_unregister(bond);
4369} 4358}
4370 4359
@@ -4768,8 +4757,9 @@ static int bond_init(struct net_device *bond_dev)
4768 if (!bond->wq) 4757 if (!bond->wq)
4769 return -ENOMEM; 4758 return -ENOMEM;
4770 4759
4771 bond->nest_level = SINGLE_DEPTH_NESTING; 4760 spin_lock_init(&bond->stats_lock);
4772 netdev_lockdep_set_classes(bond_dev); 4761 lockdep_register_key(&bond->stats_lock_key);
4762 lockdep_set_class(&bond->stats_lock, &bond->stats_lock_key);
4773 4763
4774 list_add_tail(&bond->bond_list, &bn->dev_list); 4764 list_add_tail(&bond->bond_list, &bn->dev_list);
4775 4765
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 26509fa37a50..d44651ad520c 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -37,22 +37,11 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port)
37 unsigned int i; 37 unsigned int i;
38 u32 reg, offset; 38 u32 reg, offset;
39 39
40 if (priv->type == BCM7445_DEVICE_ID)
41 offset = CORE_STS_OVERRIDE_IMP;
42 else
43 offset = CORE_STS_OVERRIDE_IMP2;
44
45 /* Enable the port memories */ 40 /* Enable the port memories */
46 reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL); 41 reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
47 reg &= ~P_TXQ_PSM_VDD(port); 42 reg &= ~P_TXQ_PSM_VDD(port);
48 core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL); 43 core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
49 44
50 /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */
51 reg = core_readl(priv, CORE_IMP_CTL);
52 reg |= (RX_BCST_EN | RX_MCST_EN | RX_UCST_EN);
53 reg &= ~(RX_DIS | TX_DIS);
54 core_writel(priv, reg, CORE_IMP_CTL);
55
56 /* Enable forwarding */ 45 /* Enable forwarding */
57 core_writel(priv, SW_FWDG_EN, CORE_SWMODE); 46 core_writel(priv, SW_FWDG_EN, CORE_SWMODE);
58 47
@@ -71,10 +60,27 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port)
71 60
72 b53_brcm_hdr_setup(ds, port); 61 b53_brcm_hdr_setup(ds, port);
73 62
74 /* Force link status for IMP port */ 63 if (port == 8) {
75 reg = core_readl(priv, offset); 64 if (priv->type == BCM7445_DEVICE_ID)
76 reg |= (MII_SW_OR | LINK_STS); 65 offset = CORE_STS_OVERRIDE_IMP;
77 core_writel(priv, reg, offset); 66 else
67 offset = CORE_STS_OVERRIDE_IMP2;
68
69 /* Force link status for IMP port */
70 reg = core_readl(priv, offset);
71 reg |= (MII_SW_OR | LINK_STS);
72 core_writel(priv, reg, offset);
73
74 /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */
75 reg = core_readl(priv, CORE_IMP_CTL);
76 reg |= (RX_BCST_EN | RX_MCST_EN | RX_UCST_EN);
77 reg &= ~(RX_DIS | TX_DIS);
78 core_writel(priv, reg, CORE_IMP_CTL);
79 } else {
80 reg = core_readl(priv, CORE_G_PCTL_PORT(port));
81 reg &= ~(RX_DIS | TX_DIS);
82 core_writel(priv, reg, CORE_G_PCTL_PORT(port));
83 }
78} 84}
79 85
80static void bcm_sf2_gphy_enable_set(struct dsa_switch *ds, bool enable) 86static void bcm_sf2_gphy_enable_set(struct dsa_switch *ds, bool enable)
diff --git a/drivers/net/dsa/sja1105/Kconfig b/drivers/net/dsa/sja1105/Kconfig
index f40b248f0b23..ffac0ea4e8d5 100644
--- a/drivers/net/dsa/sja1105/Kconfig
+++ b/drivers/net/dsa/sja1105/Kconfig
@@ -26,8 +26,8 @@ config NET_DSA_SJA1105_PTP
26 26
27config NET_DSA_SJA1105_TAS 27config NET_DSA_SJA1105_TAS
28 bool "Support for the Time-Aware Scheduler on NXP SJA1105" 28 bool "Support for the Time-Aware Scheduler on NXP SJA1105"
29 depends on NET_DSA_SJA1105 29 depends on NET_DSA_SJA1105 && NET_SCH_TAPRIO
30 depends on NET_SCH_TAPRIO 30 depends on NET_SCH_TAPRIO=y || NET_DSA_SJA1105=m
31 help 31 help
32 This enables support for the TTEthernet-based egress scheduling 32 This enables support for the TTEthernet-based egress scheduling
33 engine in the SJA1105 DSA driver, which is controlled using a 33 engine in the SJA1105 DSA driver, which is controlled using a
diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c
index 42d2e1b02c44..664d664e0925 100644
--- a/drivers/net/ethernet/arc/emac_rockchip.c
+++ b/drivers/net/ethernet/arc/emac_rockchip.c
@@ -256,6 +256,9 @@ static int emac_rockchip_remove(struct platform_device *pdev)
256 if (priv->regulator) 256 if (priv->regulator)
257 regulator_disable(priv->regulator); 257 regulator_disable(priv->regulator);
258 258
259 if (priv->soc_data->need_div_macclk)
260 clk_disable_unprepare(priv->macclk);
261
259 free_netdev(ndev); 262 free_netdev(ndev);
260 return err; 263 return err;
261} 264}
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index b4a8cf620a0c..04ec909e06df 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10382,7 +10382,8 @@ static void bnxt_cleanup_pci(struct bnxt *bp)
10382{ 10382{
10383 bnxt_unmap_bars(bp, bp->pdev); 10383 bnxt_unmap_bars(bp, bp->pdev);
10384 pci_release_regions(bp->pdev); 10384 pci_release_regions(bp->pdev);
10385 pci_disable_device(bp->pdev); 10385 if (pci_is_enabled(bp->pdev))
10386 pci_disable_device(bp->pdev);
10386} 10387}
10387 10388
10388static void bnxt_init_dflt_coal(struct bnxt *bp) 10389static void bnxt_init_dflt_coal(struct bnxt *bp)
@@ -10669,14 +10670,11 @@ static void bnxt_fw_reset_task(struct work_struct *work)
10669 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; 10670 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW;
10670 } 10671 }
10671 /* fall through */ 10672 /* fall through */
10672 case BNXT_FW_RESET_STATE_RESET_FW: { 10673 case BNXT_FW_RESET_STATE_RESET_FW:
10673 u32 wait_dsecs = bp->fw_health->post_reset_wait_dsecs;
10674
10675 bnxt_reset_all(bp); 10674 bnxt_reset_all(bp);
10676 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; 10675 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
10677 bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10); 10676 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10);
10678 return; 10677 return;
10679 }
10680 case BNXT_FW_RESET_STATE_ENABLE_DEV: 10678 case BNXT_FW_RESET_STATE_ENABLE_DEV:
10681 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && 10679 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) &&
10682 bp->fw_health) { 10680 bp->fw_health) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
index e664392dccc0..7151244f8c7d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
@@ -29,25 +29,20 @@ static int bnxt_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
29 val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); 29 val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
30 health_status = val & 0xffff; 30 health_status = val & 0xffff;
31 31
32 if (health_status == BNXT_FW_STATUS_HEALTHY) { 32 if (health_status < BNXT_FW_STATUS_HEALTHY) {
33 rc = devlink_fmsg_string_pair_put(fmsg, "FW status", 33 rc = devlink_fmsg_string_pair_put(fmsg, "Description",
34 "Healthy;"); 34 "Not yet completed initialization");
35 if (rc)
36 return rc;
37 } else if (health_status < BNXT_FW_STATUS_HEALTHY) {
38 rc = devlink_fmsg_string_pair_put(fmsg, "FW status",
39 "Not yet completed initialization;");
40 if (rc) 35 if (rc)
41 return rc; 36 return rc;
42 } else if (health_status > BNXT_FW_STATUS_HEALTHY) { 37 } else if (health_status > BNXT_FW_STATUS_HEALTHY) {
43 rc = devlink_fmsg_string_pair_put(fmsg, "FW status", 38 rc = devlink_fmsg_string_pair_put(fmsg, "Description",
44 "Encountered fatal error and cannot recover;"); 39 "Encountered fatal error and cannot recover");
45 if (rc) 40 if (rc)
46 return rc; 41 return rc;
47 } 42 }
48 43
49 if (val >> 16) { 44 if (val >> 16) {
50 rc = devlink_fmsg_u32_pair_put(fmsg, "Error", val >> 16); 45 rc = devlink_fmsg_u32_pair_put(fmsg, "Error code", val >> 16);
51 if (rc) 46 if (rc)
52 return rc; 47 return rc;
53 } 48 }
@@ -215,25 +210,68 @@ enum bnxt_dl_param_id {
215 210
216static const struct bnxt_dl_nvm_param nvm_params[] = { 211static const struct bnxt_dl_nvm_param nvm_params[] = {
217 {DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV, 212 {DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV,
218 BNXT_NVM_SHARED_CFG, 1}, 213 BNXT_NVM_SHARED_CFG, 1, 1},
219 {DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI, 214 {DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI,
220 BNXT_NVM_SHARED_CFG, 1}, 215 BNXT_NVM_SHARED_CFG, 1, 1},
221 {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, 216 {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
222 NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10}, 217 NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10, 4},
223 {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, 218 {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
224 NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7}, 219 NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7, 4},
225 {BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK, 220 {BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK,
226 BNXT_NVM_SHARED_CFG, 1}, 221 BNXT_NVM_SHARED_CFG, 1, 1},
227}; 222};
228 223
224union bnxt_nvm_data {
225 u8 val8;
226 __le32 val32;
227};
228
229static void bnxt_copy_to_nvm_data(union bnxt_nvm_data *dst,
230 union devlink_param_value *src,
231 int nvm_num_bits, int dl_num_bytes)
232{
233 u32 val32 = 0;
234
235 if (nvm_num_bits == 1) {
236 dst->val8 = src->vbool;
237 return;
238 }
239 if (dl_num_bytes == 4)
240 val32 = src->vu32;
241 else if (dl_num_bytes == 2)
242 val32 = (u32)src->vu16;
243 else if (dl_num_bytes == 1)
244 val32 = (u32)src->vu8;
245 dst->val32 = cpu_to_le32(val32);
246}
247
248static void bnxt_copy_from_nvm_data(union devlink_param_value *dst,
249 union bnxt_nvm_data *src,
250 int nvm_num_bits, int dl_num_bytes)
251{
252 u32 val32;
253
254 if (nvm_num_bits == 1) {
255 dst->vbool = src->val8;
256 return;
257 }
258 val32 = le32_to_cpu(src->val32);
259 if (dl_num_bytes == 4)
260 dst->vu32 = val32;
261 else if (dl_num_bytes == 2)
262 dst->vu16 = (u16)val32;
263 else if (dl_num_bytes == 1)
264 dst->vu8 = (u8)val32;
265}
266
229static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg, 267static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
230 int msg_len, union devlink_param_value *val) 268 int msg_len, union devlink_param_value *val)
231{ 269{
232 struct hwrm_nvm_get_variable_input *req = msg; 270 struct hwrm_nvm_get_variable_input *req = msg;
233 void *data_addr = NULL, *buf = NULL;
234 struct bnxt_dl_nvm_param nvm_param; 271 struct bnxt_dl_nvm_param nvm_param;
235 int bytesize, idx = 0, rc, i; 272 union bnxt_nvm_data *data;
236 dma_addr_t data_dma_addr; 273 dma_addr_t data_dma_addr;
274 int idx = 0, rc, i;
237 275
238 /* Get/Set NVM CFG parameter is supported only on PFs */ 276 /* Get/Set NVM CFG parameter is supported only on PFs */
239 if (BNXT_VF(bp)) 277 if (BNXT_VF(bp))
@@ -254,47 +292,31 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
254 else if (nvm_param.dir_type == BNXT_NVM_FUNC_CFG) 292 else if (nvm_param.dir_type == BNXT_NVM_FUNC_CFG)
255 idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID; 293 idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID;
256 294
257 bytesize = roundup(nvm_param.num_bits, BITS_PER_BYTE) / BITS_PER_BYTE; 295 data = dma_alloc_coherent(&bp->pdev->dev, sizeof(*data),
258 switch (bytesize) { 296 &data_dma_addr, GFP_KERNEL);
259 case 1: 297 if (!data)
260 if (nvm_param.num_bits == 1)
261 buf = &val->vbool;
262 else
263 buf = &val->vu8;
264 break;
265 case 2:
266 buf = &val->vu16;
267 break;
268 case 4:
269 buf = &val->vu32;
270 break;
271 default:
272 return -EFAULT;
273 }
274
275 data_addr = dma_alloc_coherent(&bp->pdev->dev, bytesize,
276 &data_dma_addr, GFP_KERNEL);
277 if (!data_addr)
278 return -ENOMEM; 298 return -ENOMEM;
279 299
280 req->dest_data_addr = cpu_to_le64(data_dma_addr); 300 req->dest_data_addr = cpu_to_le64(data_dma_addr);
281 req->data_len = cpu_to_le16(nvm_param.num_bits); 301 req->data_len = cpu_to_le16(nvm_param.nvm_num_bits);
282 req->option_num = cpu_to_le16(nvm_param.offset); 302 req->option_num = cpu_to_le16(nvm_param.offset);
283 req->index_0 = cpu_to_le16(idx); 303 req->index_0 = cpu_to_le16(idx);
284 if (idx) 304 if (idx)
285 req->dimensions = cpu_to_le16(1); 305 req->dimensions = cpu_to_le16(1);
286 306
287 if (req->req_type == cpu_to_le16(HWRM_NVM_SET_VARIABLE)) { 307 if (req->req_type == cpu_to_le16(HWRM_NVM_SET_VARIABLE)) {
288 memcpy(data_addr, buf, bytesize); 308 bnxt_copy_to_nvm_data(data, val, nvm_param.nvm_num_bits,
309 nvm_param.dl_num_bytes);
289 rc = hwrm_send_message(bp, msg, msg_len, HWRM_CMD_TIMEOUT); 310 rc = hwrm_send_message(bp, msg, msg_len, HWRM_CMD_TIMEOUT);
290 } else { 311 } else {
291 rc = hwrm_send_message_silent(bp, msg, msg_len, 312 rc = hwrm_send_message_silent(bp, msg, msg_len,
292 HWRM_CMD_TIMEOUT); 313 HWRM_CMD_TIMEOUT);
314 if (!rc)
315 bnxt_copy_from_nvm_data(val, data,
316 nvm_param.nvm_num_bits,
317 nvm_param.dl_num_bytes);
293 } 318 }
294 if (!rc && req->req_type == cpu_to_le16(HWRM_NVM_GET_VARIABLE)) 319 dma_free_coherent(&bp->pdev->dev, sizeof(*data), data, data_dma_addr);
295 memcpy(buf, data_addr, bytesize);
296
297 dma_free_coherent(&bp->pdev->dev, bytesize, data_addr, data_dma_addr);
298 if (rc == -EACCES) 320 if (rc == -EACCES)
299 netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n"); 321 netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n");
300 return rc; 322 return rc;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
index b97e0baeb42d..2f4fd0a7d04b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
@@ -52,7 +52,8 @@ struct bnxt_dl_nvm_param {
52 u16 id; 52 u16 id;
53 u16 offset; 53 u16 offset;
54 u16 dir_type; 54 u16 dir_type;
55 u16 num_bits; 55 u16 nvm_num_bits;
56 u8 dl_num_bytes;
56}; 57};
57 58
58void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event); 59void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index a4dead4ab0ed..86b528d8364c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -695,10 +695,10 @@ static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld)
695 lld->write_cmpl_support = adap->params.write_cmpl_support; 695 lld->write_cmpl_support = adap->params.write_cmpl_support;
696} 696}
697 697
698static void uld_attach(struct adapter *adap, unsigned int uld) 698static int uld_attach(struct adapter *adap, unsigned int uld)
699{ 699{
700 void *handle;
701 struct cxgb4_lld_info lli; 700 struct cxgb4_lld_info lli;
701 void *handle;
702 702
703 uld_init(adap, &lli); 703 uld_init(adap, &lli);
704 uld_queue_init(adap, uld, &lli); 704 uld_queue_init(adap, uld, &lli);
@@ -708,7 +708,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
708 dev_warn(adap->pdev_dev, 708 dev_warn(adap->pdev_dev,
709 "could not attach to the %s driver, error %ld\n", 709 "could not attach to the %s driver, error %ld\n",
710 adap->uld[uld].name, PTR_ERR(handle)); 710 adap->uld[uld].name, PTR_ERR(handle));
711 return; 711 return PTR_ERR(handle);
712 } 712 }
713 713
714 adap->uld[uld].handle = handle; 714 adap->uld[uld].handle = handle;
@@ -716,22 +716,22 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
716 716
717 if (adap->flags & CXGB4_FULL_INIT_DONE) 717 if (adap->flags & CXGB4_FULL_INIT_DONE)
718 adap->uld[uld].state_change(handle, CXGB4_STATE_UP); 718 adap->uld[uld].state_change(handle, CXGB4_STATE_UP);
719
720 return 0;
719} 721}
720 722
721/** 723/* cxgb4_register_uld - register an upper-layer driver
722 * cxgb4_register_uld - register an upper-layer driver 724 * @type: the ULD type
723 * @type: the ULD type 725 * @p: the ULD methods
724 * @p: the ULD methods
725 * 726 *
726 * Registers an upper-layer driver with this driver and notifies the ULD 727 * Registers an upper-layer driver with this driver and notifies the ULD
727 * about any presently available devices that support its type. Returns 728 * about any presently available devices that support its type.
728 * %-EBUSY if a ULD of the same type is already registered.
729 */ 729 */
730void cxgb4_register_uld(enum cxgb4_uld type, 730void cxgb4_register_uld(enum cxgb4_uld type,
731 const struct cxgb4_uld_info *p) 731 const struct cxgb4_uld_info *p)
732{ 732{
733 int ret = 0;
734 struct adapter *adap; 733 struct adapter *adap;
734 int ret = 0;
735 735
736 if (type >= CXGB4_ULD_MAX) 736 if (type >= CXGB4_ULD_MAX)
737 return; 737 return;
@@ -763,8 +763,12 @@ void cxgb4_register_uld(enum cxgb4_uld type,
763 if (ret) 763 if (ret)
764 goto free_irq; 764 goto free_irq;
765 adap->uld[type] = *p; 765 adap->uld[type] = *p;
766 uld_attach(adap, type); 766 ret = uld_attach(adap, type);
767 if (ret)
768 goto free_txq;
767 continue; 769 continue;
770free_txq:
771 release_sge_txq_uld(adap, type);
768free_irq: 772free_irq:
769 if (adap->flags & CXGB4_FULL_INIT_DONE) 773 if (adap->flags & CXGB4_FULL_INIT_DONE)
770 quiesce_rx_uld(adap, type); 774 quiesce_rx_uld(adap, type);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index b3da81e90132..928bfea5457b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -3791,15 +3791,11 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
3791 * write the CIDX Updates into the Status Page at the end of the 3791 * write the CIDX Updates into the Status Page at the end of the
3792 * TX Queue. 3792 * TX Queue.
3793 */ 3793 */
3794 c.autoequiqe_to_viid = htonl((dbqt 3794 c.autoequiqe_to_viid = htonl(FW_EQ_ETH_CMD_AUTOEQUEQE_F |
3795 ? FW_EQ_ETH_CMD_AUTOEQUIQE_F
3796 : FW_EQ_ETH_CMD_AUTOEQUEQE_F) |
3797 FW_EQ_ETH_CMD_VIID_V(pi->viid)); 3795 FW_EQ_ETH_CMD_VIID_V(pi->viid));
3798 3796
3799 c.fetchszm_to_iqid = 3797 c.fetchszm_to_iqid =
3800 htonl(FW_EQ_ETH_CMD_HOSTFCMODE_V(dbqt 3798 htonl(FW_EQ_ETH_CMD_HOSTFCMODE_V(HOSTFCMODE_STATUS_PAGE_X) |
3801 ? HOSTFCMODE_INGRESS_QUEUE_X
3802 : HOSTFCMODE_STATUS_PAGE_X) |
3803 FW_EQ_ETH_CMD_PCIECHN_V(pi->tx_chan) | 3799 FW_EQ_ETH_CMD_PCIECHN_V(pi->tx_chan) |
3804 FW_EQ_ETH_CMD_FETCHRO_F | FW_EQ_ETH_CMD_IQID_V(iqid)); 3800 FW_EQ_ETH_CMD_FETCHRO_F | FW_EQ_ETH_CMD_IQID_V(iqid));
3805 3801
diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/cortina/gemini.h
index 0b12f89bf89a..9fdf77d5eb37 100644
--- a/drivers/net/ethernet/cortina/gemini.h
+++ b/drivers/net/ethernet/cortina/gemini.h
@@ -1,4 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1/* SPDX-License-Identifier: GPL-2.0 */
2/* Register definitions for Gemini GMAC Ethernet device driver 2/* Register definitions for Gemini GMAC Ethernet device driver
3 * 3 *
4 * Copyright (C) 2006 Storlink, Corp. 4 * Copyright (C) 2006 Storlink, Corp.
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 9b7af94a40bb..96e9565f1e08 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -727,6 +727,18 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
727 */ 727 */
728 nfrags = skb_shinfo(skb)->nr_frags; 728 nfrags = skb_shinfo(skb)->nr_frags;
729 729
730 /* Setup HW checksumming */
731 csum_vlan = 0;
732 if (skb->ip_summed == CHECKSUM_PARTIAL &&
733 !ftgmac100_prep_tx_csum(skb, &csum_vlan))
734 goto drop;
735
736 /* Add VLAN tag */
737 if (skb_vlan_tag_present(skb)) {
738 csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
739 csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
740 }
741
730 /* Get header len */ 742 /* Get header len */
731 len = skb_headlen(skb); 743 len = skb_headlen(skb);
732 744
@@ -753,19 +765,6 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
753 if (nfrags == 0) 765 if (nfrags == 0)
754 f_ctl_stat |= FTGMAC100_TXDES0_LTS; 766 f_ctl_stat |= FTGMAC100_TXDES0_LTS;
755 txdes->txdes3 = cpu_to_le32(map); 767 txdes->txdes3 = cpu_to_le32(map);
756
757 /* Setup HW checksumming */
758 csum_vlan = 0;
759 if (skb->ip_summed == CHECKSUM_PARTIAL &&
760 !ftgmac100_prep_tx_csum(skb, &csum_vlan))
761 goto drop;
762
763 /* Add VLAN tag */
764 if (skb_vlan_tag_present(skb)) {
765 csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
766 csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
767 }
768
769 txdes->txdes1 = cpu_to_le32(csum_vlan); 768 txdes->txdes1 = cpu_to_le32(csum_vlan);
770 769
771 /* Next descriptor */ 770 /* Next descriptor */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h
index ff2e177395d4..df2458a5e9ef 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h
@@ -1,4 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1/* SPDX-License-Identifier: GPL-2.0 */
2/* 2/*
3 * Copyright 2018 NXP 3 * Copyright 2018 NXP
4 */ 4 */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
index 720cd50f5895..4ac05bfef338 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
@@ -1,4 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1/* SPDX-License-Identifier: GPL-2.0 */
2/* 2/*
3 * Copyright 2013-2016 Freescale Semiconductor Inc. 3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2018 NXP 4 * Copyright 2016-2018 NXP
diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc.h b/drivers/net/ethernet/freescale/dpaa2/dprtc.h
index be7914c1634d..311c184e1aef 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dprtc.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dprtc.h
@@ -1,4 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1/* SPDX-License-Identifier: GPL-2.0 */
2/* 2/*
3 * Copyright 2013-2016 Freescale Semiconductor Inc. 3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2018 NXP 4 * Copyright 2016-2018 NXP
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index d4d4c72adf49..22c01b224baa 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3558,7 +3558,7 @@ fec_probe(struct platform_device *pdev)
3558 3558
3559 for (i = 0; i < irq_cnt; i++) { 3559 for (i = 0; i < irq_cnt; i++) {
3560 snprintf(irq_name, sizeof(irq_name), "int%d", i); 3560 snprintf(irq_name, sizeof(irq_name), "int%d", i);
3561 irq = platform_get_irq_byname(pdev, irq_name); 3561 irq = platform_get_irq_byname_optional(pdev, irq_name);
3562 if (irq < 0) 3562 if (irq < 0)
3563 irq = platform_get_irq(pdev, i); 3563 irq = platform_get_irq(pdev, i);
3564 if (irq < 0) { 3564 if (irq < 0) {
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 19e2365be7d8..945643c02615 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -600,9 +600,9 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
600 600
601 INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep); 601 INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep);
602 602
603 irq = platform_get_irq_byname(pdev, "pps"); 603 irq = platform_get_irq_byname_optional(pdev, "pps");
604 if (irq < 0) 604 if (irq < 0)
605 irq = platform_get_irq(pdev, irq_idx); 605 irq = platform_get_irq_optional(pdev, irq_idx);
606 /* Failure to get an irq is not fatal, 606 /* Failure to get an irq is not fatal,
607 * only the PTP_CLOCK_PPS clock events should stop 607 * only the PTP_CLOCK_PPS clock events should stop
608 */ 608 */
diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/ethernet/google/gve/gve_rx.c
index 59564ac99d2a..edec61dfc868 100644
--- a/drivers/net/ethernet/google/gve/gve_rx.c
+++ b/drivers/net/ethernet/google/gve/gve_rx.c
@@ -289,6 +289,8 @@ static bool gve_rx(struct gve_rx_ring *rx, struct gve_rx_desc *rx_desc,
289 289
290 len = be16_to_cpu(rx_desc->len) - GVE_RX_PAD; 290 len = be16_to_cpu(rx_desc->len) - GVE_RX_PAD;
291 page_info = &rx->data.page_info[idx]; 291 page_info = &rx->data.page_info[idx];
292 dma_sync_single_for_cpu(&priv->pdev->dev, rx->data.qpl->page_buses[idx],
293 PAGE_SIZE, DMA_FROM_DEVICE);
292 294
293 /* gvnic can only receive into registered segments. If the buffer 295 /* gvnic can only receive into registered segments. If the buffer
294 * can't be recycled, our only choice is to copy the data out of 296 * can't be recycled, our only choice is to copy the data out of
diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c
index 778b87b5a06c..0a9a7ee2a866 100644
--- a/drivers/net/ethernet/google/gve/gve_tx.c
+++ b/drivers/net/ethernet/google/gve/gve_tx.c
@@ -390,7 +390,21 @@ static void gve_tx_fill_seg_desc(union gve_tx_desc *seg_desc,
390 seg_desc->seg.seg_addr = cpu_to_be64(addr); 390 seg_desc->seg.seg_addr = cpu_to_be64(addr);
391} 391}
392 392
393static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb) 393static void gve_dma_sync_for_device(struct device *dev, dma_addr_t *page_buses,
394 u64 iov_offset, u64 iov_len)
395{
396 dma_addr_t dma;
397 u64 addr;
398
399 for (addr = iov_offset; addr < iov_offset + iov_len;
400 addr += PAGE_SIZE) {
401 dma = page_buses[addr / PAGE_SIZE];
402 dma_sync_single_for_device(dev, dma, PAGE_SIZE, DMA_TO_DEVICE);
403 }
404}
405
406static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb,
407 struct device *dev)
394{ 408{
395 int pad_bytes, hlen, hdr_nfrags, payload_nfrags, l4_hdr_offset; 409 int pad_bytes, hlen, hdr_nfrags, payload_nfrags, l4_hdr_offset;
396 union gve_tx_desc *pkt_desc, *seg_desc; 410 union gve_tx_desc *pkt_desc, *seg_desc;
@@ -432,6 +446,9 @@ static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb)
432 skb_copy_bits(skb, 0, 446 skb_copy_bits(skb, 0,
433 tx->tx_fifo.base + info->iov[hdr_nfrags - 1].iov_offset, 447 tx->tx_fifo.base + info->iov[hdr_nfrags - 1].iov_offset,
434 hlen); 448 hlen);
449 gve_dma_sync_for_device(dev, tx->tx_fifo.qpl->page_buses,
450 info->iov[hdr_nfrags - 1].iov_offset,
451 info->iov[hdr_nfrags - 1].iov_len);
435 copy_offset = hlen; 452 copy_offset = hlen;
436 453
437 for (i = payload_iov; i < payload_nfrags + payload_iov; i++) { 454 for (i = payload_iov; i < payload_nfrags + payload_iov; i++) {
@@ -445,6 +462,9 @@ static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb)
445 skb_copy_bits(skb, copy_offset, 462 skb_copy_bits(skb, copy_offset,
446 tx->tx_fifo.base + info->iov[i].iov_offset, 463 tx->tx_fifo.base + info->iov[i].iov_offset,
447 info->iov[i].iov_len); 464 info->iov[i].iov_len);
465 gve_dma_sync_for_device(dev, tx->tx_fifo.qpl->page_buses,
466 info->iov[i].iov_offset,
467 info->iov[i].iov_len);
448 copy_offset += info->iov[i].iov_len; 468 copy_offset += info->iov[i].iov_len;
449 } 469 }
450 470
@@ -473,7 +493,7 @@ netdev_tx_t gve_tx(struct sk_buff *skb, struct net_device *dev)
473 gve_tx_put_doorbell(priv, tx->q_resources, tx->req); 493 gve_tx_put_doorbell(priv, tx->q_resources, tx->req);
474 return NETDEV_TX_BUSY; 494 return NETDEV_TX_BUSY;
475 } 495 }
476 nsegs = gve_tx_add_skb(tx, skb); 496 nsegs = gve_tx_add_skb(tx, skb, &priv->pdev->dev);
477 497
478 netdev_tx_sent_queue(tx->netdev_txq, skb->len); 498 netdev_tx_sent_queue(tx->netdev_txq, skb->len);
479 skb_tx_timestamp(skb); 499 skb_tx_timestamp(skb);
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index c84167447abe..4606a7e4a6d1 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -237,6 +237,7 @@ struct hip04_priv {
237 dma_addr_t rx_phys[RX_DESC_NUM]; 237 dma_addr_t rx_phys[RX_DESC_NUM];
238 unsigned int rx_head; 238 unsigned int rx_head;
239 unsigned int rx_buf_size; 239 unsigned int rx_buf_size;
240 unsigned int rx_cnt_remaining;
240 241
241 struct device_node *phy_node; 242 struct device_node *phy_node;
242 struct phy_device *phy; 243 struct phy_device *phy;
@@ -575,7 +576,6 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
575 struct hip04_priv *priv = container_of(napi, struct hip04_priv, napi); 576 struct hip04_priv *priv = container_of(napi, struct hip04_priv, napi);
576 struct net_device *ndev = priv->ndev; 577 struct net_device *ndev = priv->ndev;
577 struct net_device_stats *stats = &ndev->stats; 578 struct net_device_stats *stats = &ndev->stats;
578 unsigned int cnt = hip04_recv_cnt(priv);
579 struct rx_desc *desc; 579 struct rx_desc *desc;
580 struct sk_buff *skb; 580 struct sk_buff *skb;
581 unsigned char *buf; 581 unsigned char *buf;
@@ -588,8 +588,8 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
588 588
589 /* clean up tx descriptors */ 589 /* clean up tx descriptors */
590 tx_remaining = hip04_tx_reclaim(ndev, false); 590 tx_remaining = hip04_tx_reclaim(ndev, false);
591 591 priv->rx_cnt_remaining += hip04_recv_cnt(priv);
592 while (cnt && !last) { 592 while (priv->rx_cnt_remaining && !last) {
593 buf = priv->rx_buf[priv->rx_head]; 593 buf = priv->rx_buf[priv->rx_head];
594 skb = build_skb(buf, priv->rx_buf_size); 594 skb = build_skb(buf, priv->rx_buf_size);
595 if (unlikely(!skb)) { 595 if (unlikely(!skb)) {
@@ -635,11 +635,13 @@ refill:
635 hip04_set_recv_desc(priv, phys); 635 hip04_set_recv_desc(priv, phys);
636 636
637 priv->rx_head = RX_NEXT(priv->rx_head); 637 priv->rx_head = RX_NEXT(priv->rx_head);
638 if (rx >= budget) 638 if (rx >= budget) {
639 --priv->rx_cnt_remaining;
639 goto done; 640 goto done;
641 }
640 642
641 if (--cnt == 0) 643 if (--priv->rx_cnt_remaining == 0)
642 cnt = hip04_recv_cnt(priv); 644 priv->rx_cnt_remaining += hip04_recv_cnt(priv);
643 } 645 }
644 646
645 if (!(priv->reg_inten & RCV_INT)) { 647 if (!(priv->reg_inten & RCV_INT)) {
@@ -724,6 +726,7 @@ static int hip04_mac_open(struct net_device *ndev)
724 int i; 726 int i;
725 727
726 priv->rx_head = 0; 728 priv->rx_head = 0;
729 priv->rx_cnt_remaining = 0;
727 priv->tx_head = 0; 730 priv->tx_head = 0;
728 priv->tx_tail = 0; 731 priv->tx_tail = 0;
729 hip04_reset_ppe(priv); 732 hip04_reset_ppe(priv);
@@ -1038,7 +1041,6 @@ static int hip04_remove(struct platform_device *pdev)
1038 1041
1039 hip04_free_ring(ndev, d); 1042 hip04_free_ring(ndev, d);
1040 unregister_netdev(ndev); 1043 unregister_netdev(ndev);
1041 free_irq(ndev->irq, ndev);
1042 of_node_put(priv->phy_node); 1044 of_node_put(priv->phy_node);
1043 cancel_work_sync(&priv->tx_timeout_task); 1045 cancel_work_sync(&priv->tx_timeout_task);
1044 free_netdev(ndev); 1046 free_netdev(ndev);
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index 71d3d8854d8f..be56e631d693 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -607,6 +607,7 @@ static int e1000_set_ringparam(struct net_device *netdev,
607 for (i = 0; i < adapter->num_rx_queues; i++) 607 for (i = 0; i < adapter->num_rx_queues; i++)
608 rxdr[i].count = rxdr->count; 608 rxdr[i].count = rxdr->count;
609 609
610 err = 0;
610 if (netif_running(adapter->netdev)) { 611 if (netif_running(adapter->netdev)) {
611 /* Try to get new resources before deleting old */ 612 /* Try to get new resources before deleting old */
612 err = e1000_setup_all_rx_resources(adapter); 613 err = e1000_setup_all_rx_resources(adapter);
@@ -627,14 +628,13 @@ static int e1000_set_ringparam(struct net_device *netdev,
627 adapter->rx_ring = rxdr; 628 adapter->rx_ring = rxdr;
628 adapter->tx_ring = txdr; 629 adapter->tx_ring = txdr;
629 err = e1000_up(adapter); 630 err = e1000_up(adapter);
630 if (err)
631 goto err_setup;
632 } 631 }
633 kfree(tx_old); 632 kfree(tx_old);
634 kfree(rx_old); 633 kfree(rx_old);
635 634
636 clear_bit(__E1000_RESETTING, &adapter->flags); 635 clear_bit(__E1000_RESETTING, &adapter->flags);
637 return 0; 636 return err;
637
638err_setup_tx: 638err_setup_tx:
639 e1000_free_all_rx_resources(adapter); 639 e1000_free_all_rx_resources(adapter);
640err_setup_rx: 640err_setup_rx:
@@ -646,7 +646,6 @@ err_alloc_rx:
646err_alloc_tx: 646err_alloc_tx:
647 if (netif_running(adapter->netdev)) 647 if (netif_running(adapter->netdev))
648 e1000_up(adapter); 648 e1000_up(adapter);
649err_setup:
650 clear_bit(__E1000_RESETTING, &adapter->flags); 649 clear_bit(__E1000_RESETTING, &adapter->flags);
651 return err; 650 return err;
652} 651}
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index b1c3227ae4ab..a05dfecdd9b4 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -157,11 +157,6 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid)
157 err = i40e_queue_pair_enable(vsi, qid); 157 err = i40e_queue_pair_enable(vsi, qid);
158 if (err) 158 if (err)
159 return err; 159 return err;
160
161 /* Kick start the NAPI context so that receiving will start */
162 err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
163 if (err)
164 return err;
165 } 160 }
166 161
167 return 0; 162 return 0;
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index 3ec2ce0725d5..8a6ef3514129 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -466,7 +466,7 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw)
466 ? igb_setup_copper_link_82575 466 ? igb_setup_copper_link_82575
467 : igb_setup_serdes_link_82575; 467 : igb_setup_serdes_link_82575;
468 468
469 if (mac->type == e1000_82580) { 469 if (mac->type == e1000_82580 || mac->type == e1000_i350) {
470 switch (hw->device_id) { 470 switch (hw->device_id) {
471 /* feature not supported on these id's */ 471 /* feature not supported on these id's */
472 case E1000_DEV_ID_DH89XXCC_SGMII: 472 case E1000_DEV_ID_DH89XXCC_SGMII:
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 105b0624081a..9148c62d9ac5 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -753,7 +753,8 @@ u32 igb_rd32(struct e1000_hw *hw, u32 reg)
753 struct net_device *netdev = igb->netdev; 753 struct net_device *netdev = igb->netdev;
754 hw->hw_addr = NULL; 754 hw->hw_addr = NULL;
755 netdev_err(netdev, "PCIe link lost\n"); 755 netdev_err(netdev, "PCIe link lost\n");
756 WARN(1, "igb: Failed to read reg 0x%x!\n", reg); 756 WARN(pci_device_is_present(igb->pdev),
757 "igb: Failed to read reg 0x%x!\n", reg);
757 } 758 }
758 759
759 return value; 760 return value;
@@ -2064,7 +2065,8 @@ static void igb_check_swap_media(struct igb_adapter *adapter)
2064 if ((hw->phy.media_type == e1000_media_type_copper) && 2065 if ((hw->phy.media_type == e1000_media_type_copper) &&
2065 (!(connsw & E1000_CONNSW_AUTOSENSE_EN))) { 2066 (!(connsw & E1000_CONNSW_AUTOSENSE_EN))) {
2066 swap_now = true; 2067 swap_now = true;
2067 } else if (!(connsw & E1000_CONNSW_SERDESD)) { 2068 } else if ((hw->phy.media_type != e1000_media_type_copper) &&
2069 !(connsw & E1000_CONNSW_SERDESD)) {
2068 /* copper signal takes time to appear */ 2070 /* copper signal takes time to appear */
2069 if (adapter->copper_tries < 4) { 2071 if (adapter->copper_tries < 4) {
2070 adapter->copper_tries++; 2072 adapter->copper_tries++;
@@ -2370,7 +2372,7 @@ void igb_reset(struct igb_adapter *adapter)
2370 adapter->ei.get_invariants(hw); 2372 adapter->ei.get_invariants(hw);
2371 adapter->flags &= ~IGB_FLAG_MEDIA_RESET; 2373 adapter->flags &= ~IGB_FLAG_MEDIA_RESET;
2372 } 2374 }
2373 if ((mac->type == e1000_82575) && 2375 if ((mac->type == e1000_82575 || mac->type == e1000_i350) &&
2374 (adapter->flags & IGB_FLAG_MAS_ENABLE)) { 2376 (adapter->flags & IGB_FLAG_MAS_ENABLE)) {
2375 igb_enable_mas(adapter); 2377 igb_enable_mas(adapter);
2376 } 2378 }
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 63b62d74f961..8e424dfab12e 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -4047,7 +4047,8 @@ u32 igc_rd32(struct igc_hw *hw, u32 reg)
4047 hw->hw_addr = NULL; 4047 hw->hw_addr = NULL;
4048 netif_device_detach(netdev); 4048 netif_device_detach(netdev);
4049 netdev_err(netdev, "PCIe link lost, device now detached\n"); 4049 netdev_err(netdev, "PCIe link lost, device now detached\n");
4050 WARN(1, "igc: Failed to read reg 0x%x!\n", reg); 4050 WARN(pci_device_is_present(igc->pdev),
4051 "igc: Failed to read reg 0x%x!\n", reg);
4051 } 4052 }
4052 4053
4053 return value; 4054 return value;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 1ce2397306b9..91b3780ddb04 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -4310,7 +4310,6 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
4310 if (test_bit(__IXGBE_RX_FCOE, &rx_ring->state)) 4310 if (test_bit(__IXGBE_RX_FCOE, &rx_ring->state))
4311 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); 4311 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
4312 4312
4313 clear_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state);
4314 if (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) 4313 if (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY)
4315 continue; 4314 continue;
4316 4315
diff --git a/drivers/net/ethernet/marvell/mvneta_bm.h b/drivers/net/ethernet/marvell/mvneta_bm.h
index c8425d35c049..e47783ce77e0 100644
--- a/drivers/net/ethernet/marvell/mvneta_bm.h
+++ b/drivers/net/ethernet/marvell/mvneta_bm.h
@@ -160,16 +160,23 @@ static inline u32 mvneta_bm_pool_get_bp(struct mvneta_bm *priv,
160 (bm_pool->id << MVNETA_BM_POOL_ACCESS_OFFS)); 160 (bm_pool->id << MVNETA_BM_POOL_ACCESS_OFFS));
161} 161}
162#else 162#else
163void mvneta_bm_pool_destroy(struct mvneta_bm *priv, 163static inline void mvneta_bm_pool_destroy(struct mvneta_bm *priv,
164 struct mvneta_bm_pool *bm_pool, u8 port_map) {} 164 struct mvneta_bm_pool *bm_pool,
165void mvneta_bm_bufs_free(struct mvneta_bm *priv, struct mvneta_bm_pool *bm_pool, 165 u8 port_map) {}
166 u8 port_map) {} 166static inline void mvneta_bm_bufs_free(struct mvneta_bm *priv,
167int mvneta_bm_construct(struct hwbm_pool *hwbm_pool, void *buf) { return 0; } 167 struct mvneta_bm_pool *bm_pool,
168int mvneta_bm_pool_refill(struct mvneta_bm *priv, 168 u8 port_map) {}
169 struct mvneta_bm_pool *bm_pool) {return 0; } 169static inline int mvneta_bm_construct(struct hwbm_pool *hwbm_pool, void *buf)
170struct mvneta_bm_pool *mvneta_bm_pool_use(struct mvneta_bm *priv, u8 pool_id, 170{ return 0; }
171 enum mvneta_bm_type type, u8 port_id, 171static inline int mvneta_bm_pool_refill(struct mvneta_bm *priv,
172 int pkt_size) { return NULL; } 172 struct mvneta_bm_pool *bm_pool)
173{ return 0; }
174static inline struct mvneta_bm_pool *mvneta_bm_pool_use(struct mvneta_bm *priv,
175 u8 pool_id,
176 enum mvneta_bm_type type,
177 u8 port_id,
178 int pkt_size)
179{ return NULL; }
173 180
174static inline void mvneta_bm_pool_put_bp(struct mvneta_bm *priv, 181static inline void mvneta_bm_pool_put_bp(struct mvneta_bm *priv,
175 struct mvneta_bm_pool *bm_pool, 182 struct mvneta_bm_pool *bm_pool,
@@ -178,7 +185,8 @@ static inline void mvneta_bm_pool_put_bp(struct mvneta_bm *priv,
178static inline u32 mvneta_bm_pool_get_bp(struct mvneta_bm *priv, 185static inline u32 mvneta_bm_pool_get_bp(struct mvneta_bm *priv,
179 struct mvneta_bm_pool *bm_pool) 186 struct mvneta_bm_pool *bm_pool)
180{ return 0; } 187{ return 0; }
181struct mvneta_bm *mvneta_bm_get(struct device_node *node) { return NULL; } 188static inline struct mvneta_bm *mvneta_bm_get(struct device_node *node)
182void mvneta_bm_put(struct mvneta_bm *priv) {} 189{ return NULL; }
190static inline void mvneta_bm_put(struct mvneta_bm *priv) {}
183#endif /* CONFIG_MVNETA_BM */ 191#endif /* CONFIG_MVNETA_BM */
184#endif 192#endif
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 4356f3a58002..1187ef1375e2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -471,12 +471,31 @@ void mlx4_init_quotas(struct mlx4_dev *dev)
471 priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf]; 471 priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf];
472} 472}
473 473
474static int get_max_gauranteed_vfs_counter(struct mlx4_dev *dev) 474static int
475mlx4_calc_res_counter_guaranteed(struct mlx4_dev *dev,
476 struct resource_allocator *res_alloc,
477 int vf)
475{ 478{
476 /* reduce the sink counter */ 479 struct mlx4_active_ports actv_ports;
477 return (dev->caps.max_counters - 1 - 480 int ports, counters_guaranteed;
478 (MLX4_PF_COUNTERS_PER_PORT * MLX4_MAX_PORTS)) 481
479 / MLX4_MAX_PORTS; 482 /* For master, only allocate according to the number of phys ports */
483 if (vf == mlx4_master_func_num(dev))
484 return MLX4_PF_COUNTERS_PER_PORT * dev->caps.num_ports;
485
486 /* calculate real number of ports for the VF */
487 actv_ports = mlx4_get_active_ports(dev, vf);
488 ports = bitmap_weight(actv_ports.ports, dev->caps.num_ports);
489 counters_guaranteed = ports * MLX4_VF_COUNTERS_PER_PORT;
490
491 /* If we do not have enough counters for this VF, do not
492 * allocate any for it. '-1' to reduce the sink counter.
493 */
494 if ((res_alloc->res_reserved + counters_guaranteed) >
495 (dev->caps.max_counters - 1))
496 return 0;
497
498 return counters_guaranteed;
480} 499}
481 500
482int mlx4_init_resource_tracker(struct mlx4_dev *dev) 501int mlx4_init_resource_tracker(struct mlx4_dev *dev)
@@ -484,7 +503,6 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
484 struct mlx4_priv *priv = mlx4_priv(dev); 503 struct mlx4_priv *priv = mlx4_priv(dev);
485 int i, j; 504 int i, j;
486 int t; 505 int t;
487 int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
488 506
489 priv->mfunc.master.res_tracker.slave_list = 507 priv->mfunc.master.res_tracker.slave_list =
490 kcalloc(dev->num_slaves, sizeof(struct slave_list), 508 kcalloc(dev->num_slaves, sizeof(struct slave_list),
@@ -603,16 +621,8 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
603 break; 621 break;
604 case RES_COUNTER: 622 case RES_COUNTER:
605 res_alloc->quota[t] = dev->caps.max_counters; 623 res_alloc->quota[t] = dev->caps.max_counters;
606 if (t == mlx4_master_func_num(dev)) 624 res_alloc->guaranteed[t] =
607 res_alloc->guaranteed[t] = 625 mlx4_calc_res_counter_guaranteed(dev, res_alloc, t);
608 MLX4_PF_COUNTERS_PER_PORT *
609 MLX4_MAX_PORTS;
610 else if (t <= max_vfs_guarantee_counter)
611 res_alloc->guaranteed[t] =
612 MLX4_VF_COUNTERS_PER_PORT *
613 MLX4_MAX_PORTS;
614 else
615 res_alloc->guaranteed[t] = 0;
616 break; 626 break;
617 default: 627 default:
618 break; 628 break;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 8d76452cacdc..f1a7bc46f1c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -345,7 +345,7 @@ struct mlx5e_tx_wqe_info {
345 u8 num_wqebbs; 345 u8 num_wqebbs;
346 u8 num_dma; 346 u8 num_dma;
347#ifdef CONFIG_MLX5_EN_TLS 347#ifdef CONFIG_MLX5_EN_TLS
348 skb_frag_t *resync_dump_frag; 348 struct page *resync_dump_frag_page;
349#endif 349#endif
350}; 350};
351 351
@@ -410,6 +410,7 @@ struct mlx5e_txqsq {
410 struct device *pdev; 410 struct device *pdev;
411 __be32 mkey_be; 411 __be32 mkey_be;
412 unsigned long state; 412 unsigned long state;
413 unsigned int hw_mtu;
413 struct hwtstamp_config *tstamp; 414 struct hwtstamp_config *tstamp;
414 struct mlx5_clock *clock; 415 struct mlx5_clock *clock;
415 416
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
index b3a249b2a482..ac44bbe95c5c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
@@ -141,7 +141,7 @@ int mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv)
141 "Failed to create hv vhca stats agent, err = %ld\n", 141 "Failed to create hv vhca stats agent, err = %ld\n",
142 PTR_ERR(agent)); 142 PTR_ERR(agent));
143 143
144 kfree(priv->stats_agent.buf); 144 kvfree(priv->stats_agent.buf);
145 return IS_ERR_OR_NULL(agent); 145 return IS_ERR_OR_NULL(agent);
146 } 146 }
147 147
@@ -157,5 +157,5 @@ void mlx5e_hv_vhca_stats_destroy(struct mlx5e_priv *priv)
157 return; 157 return;
158 158
159 mlx5_hv_vhca_agent_destroy(priv->stats_agent.agent); 159 mlx5_hv_vhca_agent_destroy(priv->stats_agent.agent);
160 kfree(priv->stats_agent.buf); 160 kvfree(priv->stats_agent.buf);
161} 161}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index f8ee18b4da6f..13af72556987 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -97,15 +97,19 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
97 if (ret) 97 if (ret)
98 return ret; 98 return ret;
99 99
100 if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) 100 if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) {
101 ip_rt_put(rt);
101 return -ENETUNREACH; 102 return -ENETUNREACH;
103 }
102#else 104#else
103 return -EOPNOTSUPP; 105 return -EOPNOTSUPP;
104#endif 106#endif
105 107
106 ret = get_route_and_out_devs(priv, rt->dst.dev, route_dev, out_dev); 108 ret = get_route_and_out_devs(priv, rt->dst.dev, route_dev, out_dev);
107 if (ret < 0) 109 if (ret < 0) {
110 ip_rt_put(rt);
108 return ret; 111 return ret;
112 }
109 113
110 if (!(*out_ttl)) 114 if (!(*out_ttl))
111 *out_ttl = ip4_dst_hoplimit(&rt->dst); 115 *out_ttl = ip4_dst_hoplimit(&rt->dst);
@@ -149,8 +153,10 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
149 *out_ttl = ip6_dst_hoplimit(dst); 153 *out_ttl = ip6_dst_hoplimit(dst);
150 154
151 ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev); 155 ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev);
152 if (ret < 0) 156 if (ret < 0) {
157 dst_release(dst);
153 return ret; 158 return ret;
159 }
154#else 160#else
155 return -EOPNOTSUPP; 161 return -EOPNOTSUPP;
156#endif 162#endif
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
index 87be96747902..7c8796d9743f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
@@ -15,15 +15,14 @@
15#else 15#else
16/* TLS offload requires additional stop_room for: 16/* TLS offload requires additional stop_room for:
17 * - a resync SKB. 17 * - a resync SKB.
18 * kTLS offload requires additional stop_room for: 18 * kTLS offload requires fixed additional stop_room for:
19 * - static params WQE, 19 * - a static params WQE, and a progress params WQE.
20 * - progress params WQE, and 20 * The additional MTU-depending room for the resync DUMP WQEs
21 * - resync DUMP per frag. 21 * will be calculated and added in runtime.
22 */ 22 */
23#define MLX5E_SQ_TLS_ROOM \ 23#define MLX5E_SQ_TLS_ROOM \
24 (MLX5_SEND_WQE_MAX_WQEBBS + \ 24 (MLX5_SEND_WQE_MAX_WQEBBS + \
25 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + \ 25 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS)
26 MAX_SKB_FRAGS * MLX5E_KTLS_MAX_DUMP_WQEBBS)
27#endif 26#endif
28 27
29#define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start)) 28#define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start))
@@ -92,7 +91,7 @@ mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, struct mlx5_wq_cyc *wq,
92 91
93 /* fill sq frag edge with nops to avoid wqe wrapping two pages */ 92 /* fill sq frag edge with nops to avoid wqe wrapping two pages */
94 for (; wi < edge_wi; wi++) { 93 for (; wi < edge_wi; wi++) {
95 wi->skb = NULL; 94 memset(wi, 0, sizeof(*wi));
96 wi->num_wqebbs = 1; 95 wi->num_wqebbs = 1;
97 mlx5e_post_nop(wq, sq->sqn, &sq->pc); 96 mlx5e_post_nop(wq, sq->sqn, &sq->pc);
98 } 97 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
index d2ff74d52720..46725cd743a3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
@@ -38,7 +38,7 @@ static int mlx5e_ktls_add(struct net_device *netdev, struct sock *sk,
38 return -ENOMEM; 38 return -ENOMEM;
39 39
40 tx_priv->expected_seq = start_offload_tcp_sn; 40 tx_priv->expected_seq = start_offload_tcp_sn;
41 tx_priv->crypto_info = crypto_info; 41 tx_priv->crypto_info = *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
42 mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv); 42 mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv);
43 43
44 /* tc and underlay_qpn values are not in use for tls tis */ 44 /* tc and underlay_qpn values are not in use for tls tis */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
index b7298f9ee3d3..a3efa29a4629 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
@@ -21,7 +21,14 @@
21 MLX5_ST_SZ_BYTES(tls_progress_params)) 21 MLX5_ST_SZ_BYTES(tls_progress_params))
22#define MLX5E_KTLS_PROGRESS_WQEBBS \ 22#define MLX5E_KTLS_PROGRESS_WQEBBS \
23 (DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB)) 23 (DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB))
24#define MLX5E_KTLS_MAX_DUMP_WQEBBS 2 24
25struct mlx5e_dump_wqe {
26 struct mlx5_wqe_ctrl_seg ctrl;
27 struct mlx5_wqe_data_seg data;
28};
29
30#define MLX5E_KTLS_DUMP_WQEBBS \
31 (DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB))
25 32
26enum { 33enum {
27 MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0, 34 MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0,
@@ -37,7 +44,7 @@ enum {
37 44
38struct mlx5e_ktls_offload_context_tx { 45struct mlx5e_ktls_offload_context_tx {
39 struct tls_offload_context_tx *tx_ctx; 46 struct tls_offload_context_tx *tx_ctx;
40 struct tls_crypto_info *crypto_info; 47 struct tls12_crypto_info_aes_gcm_128 crypto_info;
41 u32 expected_seq; 48 u32 expected_seq;
42 u32 tisn; 49 u32 tisn;
43 u32 key_id; 50 u32 key_id;
@@ -86,14 +93,28 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
86 struct mlx5e_tx_wqe **wqe, u16 *pi); 93 struct mlx5e_tx_wqe **wqe, u16 *pi);
87void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, 94void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
88 struct mlx5e_tx_wqe_info *wi, 95 struct mlx5e_tx_wqe_info *wi,
89 struct mlx5e_sq_dma *dma); 96 u32 *dma_fifo_cc);
90 97static inline u8
98mlx5e_ktls_dumps_num_wqebbs(struct mlx5e_txqsq *sq, unsigned int nfrags,
99 unsigned int sync_len)
100{
101 /* Given the MTU and sync_len, calculates an upper bound for the
102 * number of WQEBBs needed for the TX resync DUMP WQEs of a record.
103 */
104 return MLX5E_KTLS_DUMP_WQEBBS *
105 (nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu));
106}
91#else 107#else
92 108
93static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv) 109static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv)
94{ 110{
95} 111}
96 112
113static inline void
114mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
115 struct mlx5e_tx_wqe_info *wi,
116 u32 *dma_fifo_cc) {}
117
97#endif 118#endif
98 119
99#endif /* __MLX5E_TLS_H__ */ 120#endif /* __MLX5E_TLS_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
index d195366461c9..778dab1af8fc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
@@ -24,17 +24,12 @@ enum {
24static void 24static void
25fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx) 25fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx)
26{ 26{
27 struct tls_crypto_info *crypto_info = priv_tx->crypto_info; 27 struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info;
28 struct tls12_crypto_info_aes_gcm_128 *info;
29 char *initial_rn, *gcm_iv; 28 char *initial_rn, *gcm_iv;
30 u16 salt_sz, rec_seq_sz; 29 u16 salt_sz, rec_seq_sz;
31 char *salt, *rec_seq; 30 char *salt, *rec_seq;
32 u8 tls_version; 31 u8 tls_version;
33 32
34 if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
35 return;
36
37 info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
38 EXTRACT_INFO_FIELDS; 33 EXTRACT_INFO_FIELDS;
39 34
40 gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv); 35 gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv);
@@ -108,16 +103,15 @@ build_progress_params(struct mlx5e_tx_wqe *wqe, u16 pc, u32 sqn,
108} 103}
109 104
110static void tx_fill_wi(struct mlx5e_txqsq *sq, 105static void tx_fill_wi(struct mlx5e_txqsq *sq,
111 u16 pi, u8 num_wqebbs, 106 u16 pi, u8 num_wqebbs, u32 num_bytes,
112 skb_frag_t *resync_dump_frag, 107 struct page *page)
113 u32 num_bytes)
114{ 108{
115 struct mlx5e_tx_wqe_info *wi = &sq->db.wqe_info[pi]; 109 struct mlx5e_tx_wqe_info *wi = &sq->db.wqe_info[pi];
116 110
117 wi->skb = NULL; 111 memset(wi, 0, sizeof(*wi));
118 wi->num_wqebbs = num_wqebbs; 112 wi->num_wqebbs = num_wqebbs;
119 wi->resync_dump_frag = resync_dump_frag; 113 wi->num_bytes = num_bytes;
120 wi->num_bytes = num_bytes; 114 wi->resync_dump_frag_page = page;
121} 115}
122 116
123void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx) 117void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx)
@@ -145,7 +139,7 @@ post_static_params(struct mlx5e_txqsq *sq,
145 139
146 umr_wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_STATIC_UMR_WQE_SZ, &pi); 140 umr_wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_STATIC_UMR_WQE_SZ, &pi);
147 build_static_params(umr_wqe, sq->pc, sq->sqn, priv_tx, fence); 141 build_static_params(umr_wqe, sq->pc, sq->sqn, priv_tx, fence);
148 tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, NULL, 0); 142 tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, 0, NULL);
149 sq->pc += MLX5E_KTLS_STATIC_WQEBBS; 143 sq->pc += MLX5E_KTLS_STATIC_WQEBBS;
150} 144}
151 145
@@ -159,7 +153,7 @@ post_progress_params(struct mlx5e_txqsq *sq,
159 153
160 wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_PROGRESS_WQE_SZ, &pi); 154 wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_PROGRESS_WQE_SZ, &pi);
161 build_progress_params(wqe, sq->pc, sq->sqn, priv_tx, fence); 155 build_progress_params(wqe, sq->pc, sq->sqn, priv_tx, fence);
162 tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, NULL, 0); 156 tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, 0, NULL);
163 sq->pc += MLX5E_KTLS_PROGRESS_WQEBBS; 157 sq->pc += MLX5E_KTLS_PROGRESS_WQEBBS;
164} 158}
165 159
@@ -169,6 +163,14 @@ mlx5e_ktls_tx_post_param_wqes(struct mlx5e_txqsq *sq,
169 bool skip_static_post, bool fence_first_post) 163 bool skip_static_post, bool fence_first_post)
170{ 164{
171 bool progress_fence = skip_static_post || !fence_first_post; 165 bool progress_fence = skip_static_post || !fence_first_post;
166 struct mlx5_wq_cyc *wq = &sq->wq;
167 u16 contig_wqebbs_room, pi;
168
169 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
170 contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
171 if (unlikely(contig_wqebbs_room <
172 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS))
173 mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room);
172 174
173 if (!skip_static_post) 175 if (!skip_static_post)
174 post_static_params(sq, priv_tx, fence_first_post); 176 post_static_params(sq, priv_tx, fence_first_post);
@@ -180,29 +182,36 @@ struct tx_sync_info {
180 u64 rcd_sn; 182 u64 rcd_sn;
181 s32 sync_len; 183 s32 sync_len;
182 int nr_frags; 184 int nr_frags;
183 skb_frag_t *frags[MAX_SKB_FRAGS]; 185 skb_frag_t frags[MAX_SKB_FRAGS];
186};
187
188enum mlx5e_ktls_sync_retval {
189 MLX5E_KTLS_SYNC_DONE,
190 MLX5E_KTLS_SYNC_FAIL,
191 MLX5E_KTLS_SYNC_SKIP_NO_DATA,
184}; 192};
185 193
186static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx, 194static enum mlx5e_ktls_sync_retval
187 u32 tcp_seq, struct tx_sync_info *info) 195tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
196 u32 tcp_seq, struct tx_sync_info *info)
188{ 197{
189 struct tls_offload_context_tx *tx_ctx = priv_tx->tx_ctx; 198 struct tls_offload_context_tx *tx_ctx = priv_tx->tx_ctx;
199 enum mlx5e_ktls_sync_retval ret = MLX5E_KTLS_SYNC_DONE;
190 struct tls_record_info *record; 200 struct tls_record_info *record;
191 int remaining, i = 0; 201 int remaining, i = 0;
192 unsigned long flags; 202 unsigned long flags;
193 bool ret = true;
194 203
195 spin_lock_irqsave(&tx_ctx->lock, flags); 204 spin_lock_irqsave(&tx_ctx->lock, flags);
196 record = tls_get_record(tx_ctx, tcp_seq, &info->rcd_sn); 205 record = tls_get_record(tx_ctx, tcp_seq, &info->rcd_sn);
197 206
198 if (unlikely(!record)) { 207 if (unlikely(!record)) {
199 ret = false; 208 ret = MLX5E_KTLS_SYNC_FAIL;
200 goto out; 209 goto out;
201 } 210 }
202 211
203 if (unlikely(tcp_seq < tls_record_start_seq(record))) { 212 if (unlikely(tcp_seq < tls_record_start_seq(record))) {
204 if (!tls_record_is_start_marker(record)) 213 ret = tls_record_is_start_marker(record) ?
205 ret = false; 214 MLX5E_KTLS_SYNC_SKIP_NO_DATA : MLX5E_KTLS_SYNC_FAIL;
206 goto out; 215 goto out;
207 } 216 }
208 217
@@ -211,13 +220,13 @@ static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
211 while (remaining > 0) { 220 while (remaining > 0) {
212 skb_frag_t *frag = &record->frags[i]; 221 skb_frag_t *frag = &record->frags[i];
213 222
214 __skb_frag_ref(frag); 223 get_page(skb_frag_page(frag));
215 remaining -= skb_frag_size(frag); 224 remaining -= skb_frag_size(frag);
216 info->frags[i++] = frag; 225 info->frags[i++] = *frag;
217 } 226 }
218 /* reduce the part which will be sent with the original SKB */ 227 /* reduce the part which will be sent with the original SKB */
219 if (remaining < 0) 228 if (remaining < 0)
220 skb_frag_size_add(info->frags[i - 1], remaining); 229 skb_frag_size_add(&info->frags[i - 1], remaining);
221 info->nr_frags = i; 230 info->nr_frags = i;
222out: 231out:
223 spin_unlock_irqrestore(&tx_ctx->lock, flags); 232 spin_unlock_irqrestore(&tx_ctx->lock, flags);
@@ -229,17 +238,12 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
229 struct mlx5e_ktls_offload_context_tx *priv_tx, 238 struct mlx5e_ktls_offload_context_tx *priv_tx,
230 u64 rcd_sn) 239 u64 rcd_sn)
231{ 240{
232 struct tls_crypto_info *crypto_info = priv_tx->crypto_info; 241 struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info;
233 struct tls12_crypto_info_aes_gcm_128 *info;
234 __be64 rn_be = cpu_to_be64(rcd_sn); 242 __be64 rn_be = cpu_to_be64(rcd_sn);
235 bool skip_static_post; 243 bool skip_static_post;
236 u16 rec_seq_sz; 244 u16 rec_seq_sz;
237 char *rec_seq; 245 char *rec_seq;
238 246
239 if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
240 return;
241
242 info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
243 rec_seq = info->rec_seq; 247 rec_seq = info->rec_seq;
244 rec_seq_sz = sizeof(info->rec_seq); 248 rec_seq_sz = sizeof(info->rec_seq);
245 249
@@ -250,11 +254,6 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
250 mlx5e_ktls_tx_post_param_wqes(sq, priv_tx, skip_static_post, true); 254 mlx5e_ktls_tx_post_param_wqes(sq, priv_tx, skip_static_post, true);
251} 255}
252 256
253struct mlx5e_dump_wqe {
254 struct mlx5_wqe_ctrl_seg ctrl;
255 struct mlx5_wqe_data_seg data;
256};
257
258static int 257static int
259tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool first) 258tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool first)
260{ 259{
@@ -262,7 +261,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
262 struct mlx5_wqe_data_seg *dseg; 261 struct mlx5_wqe_data_seg *dseg;
263 struct mlx5e_dump_wqe *wqe; 262 struct mlx5e_dump_wqe *wqe;
264 dma_addr_t dma_addr = 0; 263 dma_addr_t dma_addr = 0;
265 u8 num_wqebbs;
266 u16 ds_cnt; 264 u16 ds_cnt;
267 int fsz; 265 int fsz;
268 u16 pi; 266 u16 pi;
@@ -270,7 +268,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
270 wqe = mlx5e_sq_fetch_wqe(sq, sizeof(*wqe), &pi); 268 wqe = mlx5e_sq_fetch_wqe(sq, sizeof(*wqe), &pi);
271 269
272 ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS; 270 ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS;
273 num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS);
274 271
275 cseg = &wqe->ctrl; 272 cseg = &wqe->ctrl;
276 dseg = &wqe->data; 273 dseg = &wqe->data;
@@ -291,24 +288,27 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
291 dseg->byte_count = cpu_to_be32(fsz); 288 dseg->byte_count = cpu_to_be32(fsz);
292 mlx5e_dma_push(sq, dma_addr, fsz, MLX5E_DMA_MAP_PAGE); 289 mlx5e_dma_push(sq, dma_addr, fsz, MLX5E_DMA_MAP_PAGE);
293 290
294 tx_fill_wi(sq, pi, num_wqebbs, frag, fsz); 291 tx_fill_wi(sq, pi, MLX5E_KTLS_DUMP_WQEBBS, fsz, skb_frag_page(frag));
295 sq->pc += num_wqebbs; 292 sq->pc += MLX5E_KTLS_DUMP_WQEBBS;
296
297 WARN(num_wqebbs > MLX5E_KTLS_MAX_DUMP_WQEBBS,
298 "unexpected DUMP num_wqebbs, %d > %d",
299 num_wqebbs, MLX5E_KTLS_MAX_DUMP_WQEBBS);
300 293
301 return 0; 294 return 0;
302} 295}
303 296
304void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, 297void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
305 struct mlx5e_tx_wqe_info *wi, 298 struct mlx5e_tx_wqe_info *wi,
306 struct mlx5e_sq_dma *dma) 299 u32 *dma_fifo_cc)
307{ 300{
308 struct mlx5e_sq_stats *stats = sq->stats; 301 struct mlx5e_sq_stats *stats;
302 struct mlx5e_sq_dma *dma;
303
304 if (!wi->resync_dump_frag_page)
305 return;
306
307 dma = mlx5e_dma_get(sq, (*dma_fifo_cc)++);
308 stats = sq->stats;
309 309
310 mlx5e_tx_dma_unmap(sq->pdev, dma); 310 mlx5e_tx_dma_unmap(sq->pdev, dma);
311 __skb_frag_unref(wi->resync_dump_frag); 311 put_page(wi->resync_dump_frag_page);
312 stats->tls_dump_packets++; 312 stats->tls_dump_packets++;
313 stats->tls_dump_bytes += wi->num_bytes; 313 stats->tls_dump_bytes += wi->num_bytes;
314} 314}
@@ -318,25 +318,31 @@ static void tx_post_fence_nop(struct mlx5e_txqsq *sq)
318 struct mlx5_wq_cyc *wq = &sq->wq; 318 struct mlx5_wq_cyc *wq = &sq->wq;
319 u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); 319 u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
320 320
321 tx_fill_wi(sq, pi, 1, NULL, 0); 321 tx_fill_wi(sq, pi, 1, 0, NULL);
322 322
323 mlx5e_post_nop_fence(wq, sq->sqn, &sq->pc); 323 mlx5e_post_nop_fence(wq, sq->sqn, &sq->pc);
324} 324}
325 325
326static struct sk_buff * 326static enum mlx5e_ktls_sync_retval
327mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx, 327mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
328 struct mlx5e_txqsq *sq, 328 struct mlx5e_txqsq *sq,
329 struct sk_buff *skb, 329 int datalen,
330 u32 seq) 330 u32 seq)
331{ 331{
332 struct mlx5e_sq_stats *stats = sq->stats; 332 struct mlx5e_sq_stats *stats = sq->stats;
333 struct mlx5_wq_cyc *wq = &sq->wq; 333 struct mlx5_wq_cyc *wq = &sq->wq;
334 enum mlx5e_ktls_sync_retval ret;
334 struct tx_sync_info info = {}; 335 struct tx_sync_info info = {};
335 u16 contig_wqebbs_room, pi; 336 u16 contig_wqebbs_room, pi;
336 u8 num_wqebbs; 337 u8 num_wqebbs;
337 int i; 338 int i = 0;
338 339
339 if (!tx_sync_info_get(priv_tx, seq, &info)) { 340 ret = tx_sync_info_get(priv_tx, seq, &info);
341 if (unlikely(ret != MLX5E_KTLS_SYNC_DONE)) {
342 if (ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA) {
343 stats->tls_skip_no_sync_data++;
344 return MLX5E_KTLS_SYNC_SKIP_NO_DATA;
345 }
340 /* We might get here if a retransmission reaches the driver 346 /* We might get here if a retransmission reaches the driver
341 * after the relevant record is acked. 347 * after the relevant record is acked.
342 * It should be safe to drop the packet in this case 348 * It should be safe to drop the packet in this case
@@ -346,13 +352,8 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
346 } 352 }
347 353
348 if (unlikely(info.sync_len < 0)) { 354 if (unlikely(info.sync_len < 0)) {
349 u32 payload; 355 if (likely(datalen <= -info.sync_len))
350 int headln; 356 return MLX5E_KTLS_SYNC_DONE;
351
352 headln = skb_transport_offset(skb) + tcp_hdrlen(skb);
353 payload = skb->len - headln;
354 if (likely(payload <= -info.sync_len))
355 return skb;
356 357
357 stats->tls_drop_bypass_req++; 358 stats->tls_drop_bypass_req++;
358 goto err_out; 359 goto err_out;
@@ -360,30 +361,62 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
360 361
361 stats->tls_ooo++; 362 stats->tls_ooo++;
362 363
363 num_wqebbs = MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + 364 tx_post_resync_params(sq, priv_tx, info.rcd_sn);
364 (info.nr_frags ? info.nr_frags * MLX5E_KTLS_MAX_DUMP_WQEBBS : 1); 365
366 /* If no dump WQE was sent, we need to have a fence NOP WQE before the
367 * actual data xmit.
368 */
369 if (!info.nr_frags) {
370 tx_post_fence_nop(sq);
371 return MLX5E_KTLS_SYNC_DONE;
372 }
373
374 num_wqebbs = mlx5e_ktls_dumps_num_wqebbs(sq, info.nr_frags, info.sync_len);
365 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); 375 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
366 contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); 376 contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
377
367 if (unlikely(contig_wqebbs_room < num_wqebbs)) 378 if (unlikely(contig_wqebbs_room < num_wqebbs))
368 mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room); 379 mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room);
369 380
370 tx_post_resync_params(sq, priv_tx, info.rcd_sn); 381 tx_post_resync_params(sq, priv_tx, info.rcd_sn);
371 382
372 for (i = 0; i < info.nr_frags; i++) 383 for (; i < info.nr_frags; i++) {
373 if (tx_post_resync_dump(sq, info.frags[i], priv_tx->tisn, !i)) 384 unsigned int orig_fsz, frag_offset = 0, n = 0;
374 goto err_out; 385 skb_frag_t *f = &info.frags[i];
375 386
376 /* If no dump WQE was sent, we need to have a fence NOP WQE before the 387 orig_fsz = skb_frag_size(f);
377 * actual data xmit.
378 */
379 if (!info.nr_frags)
380 tx_post_fence_nop(sq);
381 388
382 return skb; 389 do {
390 bool fence = !(i || frag_offset);
391 unsigned int fsz;
392
393 n++;
394 fsz = min_t(unsigned int, sq->hw_mtu, orig_fsz - frag_offset);
395 skb_frag_size_set(f, fsz);
396 if (tx_post_resync_dump(sq, f, priv_tx->tisn, fence)) {
397 page_ref_add(skb_frag_page(f), n - 1);
398 goto err_out;
399 }
400
401 skb_frag_off_add(f, fsz);
402 frag_offset += fsz;
403 } while (frag_offset < orig_fsz);
404
405 page_ref_add(skb_frag_page(f), n - 1);
406 }
407
408 return MLX5E_KTLS_SYNC_DONE;
383 409
384err_out: 410err_out:
385 dev_kfree_skb_any(skb); 411 for (; i < info.nr_frags; i++)
386 return NULL; 412 /* The put_page() here undoes the page ref obtained in tx_sync_info_get().
413 * Page refs obtained for the DUMP WQEs above (by page_ref_add) will be
414 * released only upon their completions (or in mlx5e_free_txqsq_descs,
415 * if channel closes).
416 */
417 put_page(skb_frag_page(&info.frags[i]));
418
419 return MLX5E_KTLS_SYNC_FAIL;
387} 420}
388 421
389struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev, 422struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
@@ -419,10 +452,15 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
419 452
420 seq = ntohl(tcp_hdr(skb)->seq); 453 seq = ntohl(tcp_hdr(skb)->seq);
421 if (unlikely(priv_tx->expected_seq != seq)) { 454 if (unlikely(priv_tx->expected_seq != seq)) {
422 skb = mlx5e_ktls_tx_handle_ooo(priv_tx, sq, skb, seq); 455 enum mlx5e_ktls_sync_retval ret =
423 if (unlikely(!skb)) 456 mlx5e_ktls_tx_handle_ooo(priv_tx, sq, datalen, seq);
457
458 if (likely(ret == MLX5E_KTLS_SYNC_DONE))
459 *wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi);
460 else if (ret == MLX5E_KTLS_SYNC_FAIL)
461 goto err_out;
462 else /* ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA */
424 goto out; 463 goto out;
425 *wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi);
426 } 464 }
427 465
428 priv_tx->expected_seq = seq + datalen; 466 priv_tx->expected_seq = seq + datalen;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index c5a9c20d7f00..327c93a7bd55 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1021,7 +1021,7 @@ static bool ext_link_mode_requested(const unsigned long *adver)
1021{ 1021{
1022#define MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT ETHTOOL_LINK_MODE_50000baseKR_Full_BIT 1022#define MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT ETHTOOL_LINK_MODE_50000baseKR_Full_BIT
1023 int size = __ETHTOOL_LINK_MODE_MASK_NBITS - MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT; 1023 int size = __ETHTOOL_LINK_MODE_MASK_NBITS - MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT;
1024 __ETHTOOL_DECLARE_LINK_MODE_MASK(modes); 1024 __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = {0,};
1025 1025
1026 bitmap_set(modes, MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT, size); 1026 bitmap_set(modes, MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT, size);
1027 return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS); 1027 return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7569287f8f3c..772bfdbdeb9c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1128,6 +1128,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
1128 sq->txq_ix = txq_ix; 1128 sq->txq_ix = txq_ix;
1129 sq->uar_map = mdev->mlx5e_res.bfreg.map; 1129 sq->uar_map = mdev->mlx5e_res.bfreg.map;
1130 sq->min_inline_mode = params->tx_min_inline_mode; 1130 sq->min_inline_mode = params->tx_min_inline_mode;
1131 sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
1131 sq->stats = &c->priv->channel_stats[c->ix].sq[tc]; 1132 sq->stats = &c->priv->channel_stats[c->ix].sq[tc];
1132 sq->stop_room = MLX5E_SQ_STOP_ROOM; 1133 sq->stop_room = MLX5E_SQ_STOP_ROOM;
1133 INIT_WORK(&sq->recover_work, mlx5e_tx_err_cqe_work); 1134 INIT_WORK(&sq->recover_work, mlx5e_tx_err_cqe_work);
@@ -1135,10 +1136,14 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
1135 set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state); 1136 set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state);
1136 if (MLX5_IPSEC_DEV(c->priv->mdev)) 1137 if (MLX5_IPSEC_DEV(c->priv->mdev))
1137 set_bit(MLX5E_SQ_STATE_IPSEC, &sq->state); 1138 set_bit(MLX5E_SQ_STATE_IPSEC, &sq->state);
1139#ifdef CONFIG_MLX5_EN_TLS
1138 if (mlx5_accel_is_tls_device(c->priv->mdev)) { 1140 if (mlx5_accel_is_tls_device(c->priv->mdev)) {
1139 set_bit(MLX5E_SQ_STATE_TLS, &sq->state); 1141 set_bit(MLX5E_SQ_STATE_TLS, &sq->state);
1140 sq->stop_room += MLX5E_SQ_TLS_ROOM; 1142 sq->stop_room += MLX5E_SQ_TLS_ROOM +
1143 mlx5e_ktls_dumps_num_wqebbs(sq, MAX_SKB_FRAGS,
1144 TLS_MAX_PAYLOAD_SIZE);
1141 } 1145 }
1146#endif
1142 1147
1143 param->wq.db_numa_node = cpu_to_node(c->cpu); 1148 param->wq.db_numa_node = cpu_to_node(c->cpu);
1144 err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl); 1149 err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl);
@@ -1349,9 +1354,13 @@ static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq)
1349 /* last doorbell out, godspeed .. */ 1354 /* last doorbell out, godspeed .. */
1350 if (mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1)) { 1355 if (mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1)) {
1351 u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); 1356 u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
1357 struct mlx5e_tx_wqe_info *wi;
1352 struct mlx5e_tx_wqe *nop; 1358 struct mlx5e_tx_wqe *nop;
1353 1359
1354 sq->db.wqe_info[pi].skb = NULL; 1360 wi = &sq->db.wqe_info[pi];
1361
1362 memset(wi, 0, sizeof(*wi));
1363 wi->num_wqebbs = 1;
1355 nop = mlx5e_post_nop(wq, sq->sqn, &sq->pc); 1364 nop = mlx5e_post_nop(wq, sq->sqn, &sq->pc);
1356 mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nop->ctrl); 1365 mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nop->ctrl);
1357 } 1366 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 95892a3b63a1..cd9bb7c7b341 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -611,8 +611,8 @@ static void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
611 611
612 mutex_lock(&esw->offloads.encap_tbl_lock); 612 mutex_lock(&esw->offloads.encap_tbl_lock);
613 encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID); 613 encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID);
614 if (e->compl_result || (encap_connected == neigh_connected && 614 if (e->compl_result < 0 || (encap_connected == neigh_connected &&
615 ether_addr_equal(e->h_dest, ha))) 615 ether_addr_equal(e->h_dest, ha)))
616 goto unlock; 616 goto unlock;
617 617
618 mlx5e_take_all_encap_flows(e, &flow_list); 618 mlx5e_take_all_encap_flows(e, &flow_list);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index d6a547238de0..82cffb3a9964 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -1386,8 +1386,11 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
1386 if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) 1386 if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
1387 return 0; 1387 return 0;
1388 1388
1389 if (rq->cqd.left) 1389 if (rq->cqd.left) {
1390 work_done += mlx5e_decompress_cqes_cont(rq, cqwq, 0, budget); 1390 work_done += mlx5e_decompress_cqes_cont(rq, cqwq, 0, budget);
1391 if (rq->cqd.left || work_done >= budget)
1392 goto out;
1393 }
1391 1394
1392 cqe = mlx5_cqwq_get_cqe(cqwq); 1395 cqe = mlx5_cqwq_get_cqe(cqwq);
1393 if (!cqe) { 1396 if (!cqe) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c b/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
index 840ec945ccba..bbff8d8ded76 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
@@ -35,6 +35,7 @@
35#include <linux/udp.h> 35#include <linux/udp.h>
36#include <net/udp.h> 36#include <net/udp.h>
37#include "en.h" 37#include "en.h"
38#include "en/port.h"
38 39
39enum { 40enum {
40 MLX5E_ST_LINK_STATE, 41 MLX5E_ST_LINK_STATE,
@@ -80,22 +81,12 @@ static int mlx5e_test_link_state(struct mlx5e_priv *priv)
80 81
81static int mlx5e_test_link_speed(struct mlx5e_priv *priv) 82static int mlx5e_test_link_speed(struct mlx5e_priv *priv)
82{ 83{
83 u32 out[MLX5_ST_SZ_DW(ptys_reg)]; 84 u32 speed;
84 u32 eth_proto_oper;
85 int i;
86 85
87 if (!netif_carrier_ok(priv->netdev)) 86 if (!netif_carrier_ok(priv->netdev))
88 return 1; 87 return 1;
89 88
90 if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1)) 89 return mlx5e_port_linkspeed(priv->mdev, &speed);
91 return 1;
92
93 eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
94 for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) {
95 if (eth_proto_oper & MLX5E_PROT_MASK(i))
96 return 0;
97 }
98 return 1;
99} 90}
100 91
101struct mlx5ehdr { 92struct mlx5ehdr {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index ac6fdcda7019..7e6ebd0505cc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -52,11 +52,12 @@ static const struct counter_desc sw_stats_desc[] = {
52 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_encrypted_bytes) }, 52 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_encrypted_bytes) },
53 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ctx) }, 53 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ctx) },
54 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ooo) }, 54 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ooo) },
55 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) },
56 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) },
55 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_resync_bytes) }, 57 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_resync_bytes) },
58 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_skip_no_sync_data) },
56 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_no_sync_data) }, 59 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_no_sync_data) },
57 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_bypass_req) }, 60 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_bypass_req) },
58 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) },
59 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) },
60#endif 61#endif
61 62
62 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) }, 63 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) },
@@ -288,11 +289,12 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
288 s->tx_tls_encrypted_bytes += sq_stats->tls_encrypted_bytes; 289 s->tx_tls_encrypted_bytes += sq_stats->tls_encrypted_bytes;
289 s->tx_tls_ctx += sq_stats->tls_ctx; 290 s->tx_tls_ctx += sq_stats->tls_ctx;
290 s->tx_tls_ooo += sq_stats->tls_ooo; 291 s->tx_tls_ooo += sq_stats->tls_ooo;
292 s->tx_tls_dump_bytes += sq_stats->tls_dump_bytes;
293 s->tx_tls_dump_packets += sq_stats->tls_dump_packets;
291 s->tx_tls_resync_bytes += sq_stats->tls_resync_bytes; 294 s->tx_tls_resync_bytes += sq_stats->tls_resync_bytes;
295 s->tx_tls_skip_no_sync_data += sq_stats->tls_skip_no_sync_data;
292 s->tx_tls_drop_no_sync_data += sq_stats->tls_drop_no_sync_data; 296 s->tx_tls_drop_no_sync_data += sq_stats->tls_drop_no_sync_data;
293 s->tx_tls_drop_bypass_req += sq_stats->tls_drop_bypass_req; 297 s->tx_tls_drop_bypass_req += sq_stats->tls_drop_bypass_req;
294 s->tx_tls_dump_bytes += sq_stats->tls_dump_bytes;
295 s->tx_tls_dump_packets += sq_stats->tls_dump_packets;
296#endif 298#endif
297 s->tx_cqes += sq_stats->cqes; 299 s->tx_cqes += sq_stats->cqes;
298 } 300 }
@@ -1472,10 +1474,12 @@ static const struct counter_desc sq_stats_desc[] = {
1472 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_encrypted_bytes) }, 1474 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_encrypted_bytes) },
1473 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ctx) }, 1475 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ctx) },
1474 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ooo) }, 1476 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ooo) },
1475 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) },
1476 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) },
1477 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_packets) }, 1477 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_packets) },
1478 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_bytes) }, 1478 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_bytes) },
1479 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_resync_bytes) },
1480 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_skip_no_sync_data) },
1481 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) },
1482 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) },
1479#endif 1483#endif
1480 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) }, 1484 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },
1481 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, 1485 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) },
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 79f261bf86ac..869f3502f631 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -129,11 +129,12 @@ struct mlx5e_sw_stats {
129 u64 tx_tls_encrypted_bytes; 129 u64 tx_tls_encrypted_bytes;
130 u64 tx_tls_ctx; 130 u64 tx_tls_ctx;
131 u64 tx_tls_ooo; 131 u64 tx_tls_ooo;
132 u64 tx_tls_dump_packets;
133 u64 tx_tls_dump_bytes;
132 u64 tx_tls_resync_bytes; 134 u64 tx_tls_resync_bytes;
135 u64 tx_tls_skip_no_sync_data;
133 u64 tx_tls_drop_no_sync_data; 136 u64 tx_tls_drop_no_sync_data;
134 u64 tx_tls_drop_bypass_req; 137 u64 tx_tls_drop_bypass_req;
135 u64 tx_tls_dump_packets;
136 u64 tx_tls_dump_bytes;
137#endif 138#endif
138 139
139 u64 rx_xsk_packets; 140 u64 rx_xsk_packets;
@@ -273,11 +274,12 @@ struct mlx5e_sq_stats {
273 u64 tls_encrypted_bytes; 274 u64 tls_encrypted_bytes;
274 u64 tls_ctx; 275 u64 tls_ctx;
275 u64 tls_ooo; 276 u64 tls_ooo;
277 u64 tls_dump_packets;
278 u64 tls_dump_bytes;
276 u64 tls_resync_bytes; 279 u64 tls_resync_bytes;
280 u64 tls_skip_no_sync_data;
277 u64 tls_drop_no_sync_data; 281 u64 tls_drop_no_sync_data;
278 u64 tls_drop_bypass_req; 282 u64 tls_drop_bypass_req;
279 u64 tls_dump_packets;
280 u64 tls_dump_bytes;
281#endif 283#endif
282 /* less likely accessed in data path */ 284 /* less likely accessed in data path */
283 u64 csum_none; 285 u64 csum_none;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 3e78a727f3e6..fda0b37075e8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1278,8 +1278,10 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
1278 mlx5_eswitch_del_vlan_action(esw, attr); 1278 mlx5_eswitch_del_vlan_action(esw, attr);
1279 1279
1280 for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) 1280 for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++)
1281 if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) 1281 if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) {
1282 mlx5e_detach_encap(priv, flow, out_index); 1282 mlx5e_detach_encap(priv, flow, out_index);
1283 kfree(attr->parse_attr->tun_info[out_index]);
1284 }
1283 kvfree(attr->parse_attr); 1285 kvfree(attr->parse_attr);
1284 1286
1285 if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) 1287 if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
@@ -1559,6 +1561,7 @@ static void mlx5e_encap_dealloc(struct mlx5e_priv *priv, struct mlx5e_encap_entr
1559 mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat); 1561 mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat);
1560 } 1562 }
1561 1563
1564 kfree(e->tun_info);
1562 kfree(e->encap_header); 1565 kfree(e->encap_header);
1563 kfree_rcu(e, rcu); 1566 kfree_rcu(e, rcu);
1564} 1567}
@@ -2972,6 +2975,13 @@ mlx5e_encap_get(struct mlx5e_priv *priv, struct encap_key *key,
2972 return NULL; 2975 return NULL;
2973} 2976}
2974 2977
2978static struct ip_tunnel_info *dup_tun_info(const struct ip_tunnel_info *tun_info)
2979{
2980 size_t tun_size = sizeof(*tun_info) + tun_info->options_len;
2981
2982 return kmemdup(tun_info, tun_size, GFP_KERNEL);
2983}
2984
2975static int mlx5e_attach_encap(struct mlx5e_priv *priv, 2985static int mlx5e_attach_encap(struct mlx5e_priv *priv,
2976 struct mlx5e_tc_flow *flow, 2986 struct mlx5e_tc_flow *flow,
2977 struct net_device *mirred_dev, 2987 struct net_device *mirred_dev,
@@ -3028,13 +3038,15 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
3028 refcount_set(&e->refcnt, 1); 3038 refcount_set(&e->refcnt, 1);
3029 init_completion(&e->res_ready); 3039 init_completion(&e->res_ready);
3030 3040
3041 tun_info = dup_tun_info(tun_info);
3042 if (!tun_info) {
3043 err = -ENOMEM;
3044 goto out_err_init;
3045 }
3031 e->tun_info = tun_info; 3046 e->tun_info = tun_info;
3032 err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack); 3047 err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack);
3033 if (err) { 3048 if (err)
3034 kfree(e); 3049 goto out_err_init;
3035 e = NULL;
3036 goto out_err;
3037 }
3038 3050
3039 INIT_LIST_HEAD(&e->flows); 3051 INIT_LIST_HEAD(&e->flows);
3040 hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key); 3052 hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key);
@@ -3075,6 +3087,12 @@ out_err:
3075 if (e) 3087 if (e)
3076 mlx5e_encap_put(priv, e); 3088 mlx5e_encap_put(priv, e);
3077 return err; 3089 return err;
3090
3091out_err_init:
3092 mutex_unlock(&esw->offloads.encap_tbl_lock);
3093 kfree(tun_info);
3094 kfree(e);
3095 return err;
3078} 3096}
3079 3097
3080static int parse_tc_vlan_action(struct mlx5e_priv *priv, 3098static int parse_tc_vlan_action(struct mlx5e_priv *priv,
@@ -3160,7 +3178,7 @@ static int add_vlan_pop_action(struct mlx5e_priv *priv,
3160 struct mlx5_esw_flow_attr *attr, 3178 struct mlx5_esw_flow_attr *attr,
3161 u32 *action) 3179 u32 *action)
3162{ 3180{
3163 int nest_level = vlan_get_encap_level(attr->parse_attr->filter_dev); 3181 int nest_level = attr->parse_attr->filter_dev->lower_level;
3164 struct flow_action_entry vlan_act = { 3182 struct flow_action_entry vlan_act = {
3165 .id = FLOW_ACTION_VLAN_POP, 3183 .id = FLOW_ACTION_VLAN_POP,
3166 }; 3184 };
@@ -3295,7 +3313,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
3295 } else if (encap) { 3313 } else if (encap) {
3296 parse_attr->mirred_ifindex[attr->out_count] = 3314 parse_attr->mirred_ifindex[attr->out_count] =
3297 out_dev->ifindex; 3315 out_dev->ifindex;
3298 parse_attr->tun_info[attr->out_count] = info; 3316 parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
3317 if (!parse_attr->tun_info[attr->out_count])
3318 return -ENOMEM;
3299 encap = false; 3319 encap = false;
3300 attr->dests[attr->out_count].flags |= 3320 attr->dests[attr->out_count].flags |=
3301 MLX5_ESW_DEST_ENCAP; 3321 MLX5_ESW_DEST_ENCAP;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index d3a67a9b4eba..67dc4f0921b6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -403,7 +403,10 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
403static void mlx5e_dump_error_cqe(struct mlx5e_txqsq *sq, 403static void mlx5e_dump_error_cqe(struct mlx5e_txqsq *sq,
404 struct mlx5_err_cqe *err_cqe) 404 struct mlx5_err_cqe *err_cqe)
405{ 405{
406 u32 ci = mlx5_cqwq_get_ci(&sq->cq.wq); 406 struct mlx5_cqwq *wq = &sq->cq.wq;
407 u32 ci;
408
409 ci = mlx5_cqwq_ctr2ix(wq, wq->cc - 1);
407 410
408 netdev_err(sq->channel->netdev, 411 netdev_err(sq->channel->netdev,
409 "Error cqe on cqn 0x%x, ci 0x%x, sqn 0x%x, opcode 0x%x, syndrome 0x%x, vendor syndrome 0x%x\n", 412 "Error cqe on cqn 0x%x, ci 0x%x, sqn 0x%x, opcode 0x%x, syndrome 0x%x, vendor syndrome 0x%x\n",
@@ -479,14 +482,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
479 skb = wi->skb; 482 skb = wi->skb;
480 483
481 if (unlikely(!skb)) { 484 if (unlikely(!skb)) {
482#ifdef CONFIG_MLX5_EN_TLS 485 mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc);
483 if (wi->resync_dump_frag) {
484 struct mlx5e_sq_dma *dma =
485 mlx5e_dma_get(sq, dma_fifo_cc++);
486
487 mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, dma);
488 }
489#endif
490 sqcc += wi->num_wqebbs; 486 sqcc += wi->num_wqebbs;
491 continue; 487 continue;
492 } 488 }
@@ -542,29 +538,38 @@ void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq)
542{ 538{
543 struct mlx5e_tx_wqe_info *wi; 539 struct mlx5e_tx_wqe_info *wi;
544 struct sk_buff *skb; 540 struct sk_buff *skb;
541 u32 dma_fifo_cc;
542 u16 sqcc;
545 u16 ci; 543 u16 ci;
546 int i; 544 int i;
547 545
548 while (sq->cc != sq->pc) { 546 sqcc = sq->cc;
549 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc); 547 dma_fifo_cc = sq->dma_fifo_cc;
548
549 while (sqcc != sq->pc) {
550 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sqcc);
550 wi = &sq->db.wqe_info[ci]; 551 wi = &sq->db.wqe_info[ci];
551 skb = wi->skb; 552 skb = wi->skb;
552 553
553 if (!skb) { /* nop */ 554 if (!skb) {
554 sq->cc++; 555 mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc);
556 sqcc += wi->num_wqebbs;
555 continue; 557 continue;
556 } 558 }
557 559
558 for (i = 0; i < wi->num_dma; i++) { 560 for (i = 0; i < wi->num_dma; i++) {
559 struct mlx5e_sq_dma *dma = 561 struct mlx5e_sq_dma *dma =
560 mlx5e_dma_get(sq, sq->dma_fifo_cc++); 562 mlx5e_dma_get(sq, dma_fifo_cc++);
561 563
562 mlx5e_tx_dma_unmap(sq->pdev, dma); 564 mlx5e_tx_dma_unmap(sq->pdev, dma);
563 } 565 }
564 566
565 dev_kfree_skb_any(skb); 567 dev_kfree_skb_any(skb);
566 sq->cc += wi->num_wqebbs; 568 sqcc += wi->num_wqebbs;
567 } 569 }
570
571 sq->dma_fifo_cc = dma_fifo_cc;
572 sq->cc = sqcc;
568} 573}
569 574
570#ifdef CONFIG_MLX5_CORE_IPOIB 575#ifdef CONFIG_MLX5_CORE_IPOIB
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 00d71db15f22..369499e88fe8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -285,7 +285,6 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,
285 285
286 mlx5_eswitch_set_rule_source_port(esw, spec, attr); 286 mlx5_eswitch_set_rule_source_port(esw, spec, attr);
287 287
288 spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
289 if (attr->outer_match_level != MLX5_MATCH_NONE) 288 if (attr->outer_match_level != MLX5_MATCH_NONE)
290 spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS; 289 spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS;
291 290
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
index 1d55a324a17e..7879e1746297 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
@@ -177,22 +177,32 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
177 memset(&src->vlan[1], 0, sizeof(src->vlan[1])); 177 memset(&src->vlan[1], 0, sizeof(src->vlan[1]));
178} 178}
179 179
180static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
181 const struct mlx5_flow_spec *spec)
182{
183 u32 port_mask, port_value;
184
185 if (MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source))
186 return spec->flow_context.flow_source == MLX5_VPORT_UPLINK;
187
188 port_mask = MLX5_GET(fte_match_param, spec->match_criteria,
189 misc_parameters.source_port);
190 port_value = MLX5_GET(fte_match_param, spec->match_value,
191 misc_parameters.source_port);
192 return (port_mask & port_value & 0xffff) == MLX5_VPORT_UPLINK;
193}
194
180bool 195bool
181mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw, 196mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
182 struct mlx5_flow_act *flow_act, 197 struct mlx5_flow_act *flow_act,
183 struct mlx5_flow_spec *spec) 198 struct mlx5_flow_spec *spec)
184{ 199{
185 u32 port_mask = MLX5_GET(fte_match_param, spec->match_criteria,
186 misc_parameters.source_port);
187 u32 port_value = MLX5_GET(fte_match_param, spec->match_value,
188 misc_parameters.source_port);
189
190 if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table)) 200 if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table))
191 return false; 201 return false;
192 202
193 /* push vlan on RX */ 203 /* push vlan on RX */
194 return (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) && 204 return (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) &&
195 ((port_mask & port_value) == MLX5_VPORT_UPLINK); 205 mlx5_eswitch_offload_is_uplink_port(esw, spec);
196} 206}
197 207
198struct mlx5_flow_handle * 208struct mlx5_flow_handle *
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
index 4c50efe4e7f1..61021133029e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
@@ -464,8 +464,10 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
464 } 464 }
465 465
466 err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn); 466 err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn);
467 if (err) 467 if (err) {
468 kvfree(in);
468 goto err_cqwq; 469 goto err_cqwq;
470 }
469 471
470 cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context); 472 cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context);
471 MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size)); 473 MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size));
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index 579c306caa7b..3c816e81f8d9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -507,7 +507,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
507 MLX5_SET(dest_format_struct, in_dests, 507 MLX5_SET(dest_format_struct, in_dests,
508 destination_eswitch_owner_vhca_id, 508 destination_eswitch_owner_vhca_id,
509 dst->dest_attr.vport.vhca_id); 509 dst->dest_attr.vport.vhca_id);
510 if (extended_dest) { 510 if (extended_dest &&
511 dst->dest_attr.vport.pkt_reformat) {
511 MLX5_SET(dest_format_struct, in_dests, 512 MLX5_SET(dest_format_struct, in_dests,
512 packet_reformat, 513 packet_reformat,
513 !!(dst->dest_attr.vport.flags & 514 !!(dst->dest_attr.vport.flags &
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index d685122d9ff7..c07f3154437c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -572,7 +572,7 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
572 return -ENOMEM; 572 return -ENOMEM;
573 err = mlx5_crdump_collect(dev, cr_data); 573 err = mlx5_crdump_collect(dev, cr_data);
574 if (err) 574 if (err)
575 return err; 575 goto free_data;
576 576
577 if (priv_ctx) { 577 if (priv_ctx) {
578 struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx; 578 struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 14dcc786926d..4421ab22182f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1186,7 +1186,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
1186 if (err) 1186 if (err)
1187 goto err_thermal_init; 1187 goto err_thermal_init;
1188 1188
1189 if (mlxsw_driver->params_register && !reload) 1189 if (mlxsw_driver->params_register)
1190 devlink_params_publish(devlink); 1190 devlink_params_publish(devlink);
1191 1191
1192 return 0; 1192 return 0;
@@ -1259,7 +1259,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
1259 return; 1259 return;
1260 } 1260 }
1261 1261
1262 if (mlxsw_core->driver->params_unregister && !reload) 1262 if (mlxsw_core->driver->params_unregister)
1263 devlink_params_unpublish(devlink); 1263 devlink_params_unpublish(devlink);
1264 mlxsw_thermal_fini(mlxsw_core->thermal); 1264 mlxsw_thermal_fini(mlxsw_core->thermal);
1265 mlxsw_hwmon_fini(mlxsw_core->hwmon); 1265 mlxsw_hwmon_fini(mlxsw_core->hwmon);
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 4d1bce4389c7..344539c0d3aa 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -261,8 +261,15 @@ static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
261 port->pvid = vid; 261 port->pvid = vid;
262 262
263 /* Untagged egress vlan clasification */ 263 /* Untagged egress vlan clasification */
264 if (untagged) 264 if (untagged && port->vid != vid) {
265 if (port->vid) {
266 dev_err(ocelot->dev,
267 "Port already has a native VLAN: %d\n",
268 port->vid);
269 return -EBUSY;
270 }
265 port->vid = vid; 271 port->vid = vid;
272 }
266 273
267 ocelot_vlan_port_apply(ocelot, port); 274 ocelot_vlan_port_apply(ocelot, port);
268 275
@@ -934,7 +941,7 @@ end:
934static int ocelot_vlan_rx_add_vid(struct net_device *dev, __be16 proto, 941static int ocelot_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
935 u16 vid) 942 u16 vid)
936{ 943{
937 return ocelot_vlan_vid_add(dev, vid, false, true); 944 return ocelot_vlan_vid_add(dev, vid, false, false);
938} 945}
939 946
940static int ocelot_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, 947static int ocelot_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index 1eef446036d6..79d72c88bbef 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -299,22 +299,6 @@ static void nfp_repr_clean(struct nfp_repr *repr)
299 nfp_port_free(repr->port); 299 nfp_port_free(repr->port);
300} 300}
301 301
302static struct lock_class_key nfp_repr_netdev_xmit_lock_key;
303static struct lock_class_key nfp_repr_netdev_addr_lock_key;
304
305static void nfp_repr_set_lockdep_class_one(struct net_device *dev,
306 struct netdev_queue *txq,
307 void *_unused)
308{
309 lockdep_set_class(&txq->_xmit_lock, &nfp_repr_netdev_xmit_lock_key);
310}
311
312static void nfp_repr_set_lockdep_class(struct net_device *dev)
313{
314 lockdep_set_class(&dev->addr_list_lock, &nfp_repr_netdev_addr_lock_key);
315 netdev_for_each_tx_queue(dev, nfp_repr_set_lockdep_class_one, NULL);
316}
317
318int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, 302int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
319 u32 cmsg_port_id, struct nfp_port *port, 303 u32 cmsg_port_id, struct nfp_port *port,
320 struct net_device *pf_netdev) 304 struct net_device *pf_netdev)
@@ -324,8 +308,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
324 u32 repr_cap = nn->tlv_caps.repr_cap; 308 u32 repr_cap = nn->tlv_caps.repr_cap;
325 int err; 309 int err;
326 310
327 nfp_repr_set_lockdep_class(netdev);
328
329 repr->port = port; 311 repr->port = port;
330 repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL); 312 repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL);
331 if (!repr->dst) 313 if (!repr->dst)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index 72107a0627a9..20faa8d24c9f 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -1,6 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ 2/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
3 3
4#include <linux/printk.h>
5#include <linux/dynamic_debug.h>
4#include <linux/netdevice.h> 6#include <linux/netdevice.h>
5#include <linux/etherdevice.h> 7#include <linux/etherdevice.h>
6#include <linux/rtnetlink.h> 8#include <linux/rtnetlink.h>
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 15e432386b35..aab311413412 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -1,6 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ 2/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
3 3
4#include <linux/printk.h>
5#include <linux/dynamic_debug.h>
4#include <linux/module.h> 6#include <linux/module.h>
5#include <linux/netdevice.h> 7#include <linux/netdevice.h>
6#include <linux/utsname.h> 8#include <linux/utsname.h>
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 2ce70097d018..38f7f40b3a4d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -67,10 +67,9 @@
67#define QED_ROCE_QPS (8192) 67#define QED_ROCE_QPS (8192)
68#define QED_ROCE_DPIS (8) 68#define QED_ROCE_DPIS (8)
69#define QED_RDMA_SRQS QED_ROCE_QPS 69#define QED_RDMA_SRQS QED_ROCE_QPS
70#define QED_NVM_CFG_SET_FLAGS 0xE
71#define QED_NVM_CFG_SET_PF_FLAGS 0x1E
72#define QED_NVM_CFG_GET_FLAGS 0xA 70#define QED_NVM_CFG_GET_FLAGS 0xA
73#define QED_NVM_CFG_GET_PF_FLAGS 0x1A 71#define QED_NVM_CFG_GET_PF_FLAGS 0x1A
72#define QED_NVM_CFG_MAX_ATTRS 50
74 73
75static char version[] = 74static char version[] =
76 "QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n"; 75 "QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2255,6 +2254,7 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
2255{ 2254{
2256 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 2255 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2257 u8 entity_id, len, buf[32]; 2256 u8 entity_id, len, buf[32];
2257 bool need_nvm_init = true;
2258 struct qed_ptt *ptt; 2258 struct qed_ptt *ptt;
2259 u16 cfg_id, count; 2259 u16 cfg_id, count;
2260 int rc = 0, i; 2260 int rc = 0, i;
@@ -2271,8 +2271,10 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
2271 2271
2272 DP_VERBOSE(cdev, NETIF_MSG_DRV, 2272 DP_VERBOSE(cdev, NETIF_MSG_DRV,
2273 "Read config ids: num_attrs = %0d\n", count); 2273 "Read config ids: num_attrs = %0d\n", count);
2274 /* NVM CFG ID attributes */ 2274 /* NVM CFG ID attributes. Start loop index from 1 to avoid additional
2275 for (i = 0; i < count; i++) { 2275 * arithmetic operations in the implementation.
2276 */
2277 for (i = 1; i <= count; i++) {
2276 cfg_id = *((u16 *)*data); 2278 cfg_id = *((u16 *)*data);
2277 *data += 2; 2279 *data += 2;
2278 entity_id = **data; 2280 entity_id = **data;
@@ -2282,8 +2284,21 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
2282 memcpy(buf, *data, len); 2284 memcpy(buf, *data, len);
2283 *data += len; 2285 *data += len;
2284 2286
2285 flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS : 2287 flags = 0;
2286 QED_NVM_CFG_SET_FLAGS; 2288 if (need_nvm_init) {
2289 flags |= QED_NVM_CFG_OPTION_INIT;
2290 need_nvm_init = false;
2291 }
2292
2293 /* Commit to flash and free the resources */
2294 if (!(i % QED_NVM_CFG_MAX_ATTRS) || i == count) {
2295 flags |= QED_NVM_CFG_OPTION_COMMIT |
2296 QED_NVM_CFG_OPTION_FREE;
2297 need_nvm_init = true;
2298 }
2299
2300 if (entity_id)
2301 flags |= QED_NVM_CFG_OPTION_ENTITY_SEL;
2287 2302
2288 DP_VERBOSE(cdev, NETIF_MSG_DRV, 2303 DP_VERBOSE(cdev, NETIF_MSG_DRV,
2289 "cfg_id = %d entity = %d len = %d\n", cfg_id, 2304 "cfg_id = %d entity = %d len = %d\n", cfg_id,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index 78f77b712b10..dcb5c917f373 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -2005,7 +2005,7 @@ static void qed_iov_vf_mbx_stop_vport(struct qed_hwfn *p_hwfn,
2005 (qed_iov_validate_active_txq(p_hwfn, vf))) { 2005 (qed_iov_validate_active_txq(p_hwfn, vf))) {
2006 vf->b_malicious = true; 2006 vf->b_malicious = true;
2007 DP_NOTICE(p_hwfn, 2007 DP_NOTICE(p_hwfn,
2008 "VF [%02x] - considered malicious; Unable to stop RX/TX queuess\n", 2008 "VF [%02x] - considered malicious; Unable to stop RX/TX queues\n",
2009 vf->abs_vf_id); 2009 vf->abs_vf_id);
2010 status = PFVF_STATUS_MALICIOUS; 2010 status = PFVF_STATUS_MALICIOUS;
2011 goto out; 2011 goto out;
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 350b0d949611..5064c292b873 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -1029,6 +1029,10 @@ static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg)
1029{ 1029{
1030 int value; 1030 int value;
1031 1031
1032 /* Work around issue with chip reporting wrong PHY ID */
1033 if (reg == MII_PHYSID2)
1034 return 0xc912;
1035
1032 r8168dp_2_mdio_start(tp); 1036 r8168dp_2_mdio_start(tp);
1033 1037
1034 value = r8169_mdio_read(tp, reg); 1038 value = r8169_mdio_read(tp, reg);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 3dfd04e0506a..4e9c848c67cc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2995,6 +2995,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
2995 } else { 2995 } else {
2996 stmmac_set_desc_addr(priv, first, des); 2996 stmmac_set_desc_addr(priv, first, des);
2997 tmp_pay_len = pay_len; 2997 tmp_pay_len = pay_len;
2998 des += proto_hdr_len;
2998 } 2999 }
2999 3000
3000 stmmac_tso_allocator(priv, des, tmp_pay_len, (nfrags == 0), queue); 3001 stmmac_tso_allocator(priv, des, tmp_pay_len, (nfrags == 0), queue);
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index bbbc1dcb6ab5..b517c1af9de0 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1237,8 +1237,17 @@ static int fjes_probe(struct platform_device *plat_dev)
1237 adapter->open_guard = false; 1237 adapter->open_guard = false;
1238 1238
1239 adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); 1239 adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
1240 if (unlikely(!adapter->txrx_wq)) {
1241 err = -ENOMEM;
1242 goto err_free_netdev;
1243 }
1244
1240 adapter->control_wq = alloc_workqueue(DRV_NAME "/control", 1245 adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
1241 WQ_MEM_RECLAIM, 0); 1246 WQ_MEM_RECLAIM, 0);
1247 if (unlikely(!adapter->control_wq)) {
1248 err = -ENOMEM;
1249 goto err_free_txrx_wq;
1250 }
1242 1251
1243 INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task); 1252 INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
1244 INIT_WORK(&adapter->raise_intr_rxdata_task, 1253 INIT_WORK(&adapter->raise_intr_rxdata_task,
@@ -1255,7 +1264,7 @@ static int fjes_probe(struct platform_device *plat_dev)
1255 hw->hw_res.irq = platform_get_irq(plat_dev, 0); 1264 hw->hw_res.irq = platform_get_irq(plat_dev, 0);
1256 err = fjes_hw_init(&adapter->hw); 1265 err = fjes_hw_init(&adapter->hw);
1257 if (err) 1266 if (err)
1258 goto err_free_netdev; 1267 goto err_free_control_wq;
1259 1268
1260 /* setup MAC address (02:00:00:00:00:[epid])*/ 1269 /* setup MAC address (02:00:00:00:00:[epid])*/
1261 netdev->dev_addr[0] = 2; 1270 netdev->dev_addr[0] = 2;
@@ -1277,6 +1286,10 @@ static int fjes_probe(struct platform_device *plat_dev)
1277 1286
1278err_hw_exit: 1287err_hw_exit:
1279 fjes_hw_exit(&adapter->hw); 1288 fjes_hw_exit(&adapter->hw);
1289err_free_control_wq:
1290 destroy_workqueue(adapter->control_wq);
1291err_free_txrx_wq:
1292 destroy_workqueue(adapter->txrx_wq);
1280err_free_netdev: 1293err_free_netdev:
1281 free_netdev(netdev); 1294 free_netdev(netdev);
1282err_out: 1295err_out:
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index fbec711ff514..fbea6f232819 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -107,27 +107,6 @@ struct bpqdev {
107 107
108static LIST_HEAD(bpq_devices); 108static LIST_HEAD(bpq_devices);
109 109
110/*
111 * bpqether network devices are paired with ethernet devices below them, so
112 * form a special "super class" of normal ethernet devices; split their locks
113 * off into a separate class since they always nest.
114 */
115static struct lock_class_key bpq_netdev_xmit_lock_key;
116static struct lock_class_key bpq_netdev_addr_lock_key;
117
118static void bpq_set_lockdep_class_one(struct net_device *dev,
119 struct netdev_queue *txq,
120 void *_unused)
121{
122 lockdep_set_class(&txq->_xmit_lock, &bpq_netdev_xmit_lock_key);
123}
124
125static void bpq_set_lockdep_class(struct net_device *dev)
126{
127 lockdep_set_class(&dev->addr_list_lock, &bpq_netdev_addr_lock_key);
128 netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL);
129}
130
131/* ------------------------------------------------------------------------ */ 110/* ------------------------------------------------------------------------ */
132 111
133 112
@@ -498,7 +477,6 @@ static int bpq_new_device(struct net_device *edev)
498 err = register_netdevice(ndev); 477 err = register_netdevice(ndev);
499 if (err) 478 if (err)
500 goto error; 479 goto error;
501 bpq_set_lockdep_class(ndev);
502 480
503 /* List protected by RTNL */ 481 /* List protected by RTNL */
504 list_add_rcu(&bpq->bpq_list, &bpq_devices); 482 list_add_rcu(&bpq->bpq_list, &bpq_devices);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 39dddcd8b3cb..963509add611 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -982,7 +982,7 @@ static int netvsc_attach(struct net_device *ndev,
982 if (netif_running(ndev)) { 982 if (netif_running(ndev)) {
983 ret = rndis_filter_open(nvdev); 983 ret = rndis_filter_open(nvdev);
984 if (ret) 984 if (ret)
985 return ret; 985 goto err;
986 986
987 rdev = nvdev->extension; 987 rdev = nvdev->extension;
988 if (!rdev->link_state) 988 if (!rdev->link_state)
@@ -990,6 +990,13 @@ static int netvsc_attach(struct net_device *ndev,
990 } 990 }
991 991
992 return 0; 992 return 0;
993
994err:
995 netif_device_detach(ndev);
996
997 rndis_filter_device_remove(hdev, nvdev);
998
999 return ret;
993} 1000}
994 1001
995static int netvsc_set_channels(struct net_device *net, 1002static int netvsc_set_channels(struct net_device *net,
@@ -1807,8 +1814,10 @@ static int netvsc_set_features(struct net_device *ndev,
1807 1814
1808 ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads); 1815 ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads);
1809 1816
1810 if (ret) 1817 if (ret) {
1811 features ^= NETIF_F_LRO; 1818 features ^= NETIF_F_LRO;
1819 ndev->features = features;
1820 }
1812 1821
1813syncvf: 1822syncvf:
1814 if (!vf_netdev) 1823 if (!vf_netdev)
@@ -2335,8 +2344,6 @@ static int netvsc_probe(struct hv_device *dev,
2335 NETIF_F_HW_VLAN_CTAG_RX; 2344 NETIF_F_HW_VLAN_CTAG_RX;
2336 net->vlan_features = net->features; 2345 net->vlan_features = net->features;
2337 2346
2338 netdev_lockdep_set_classes(net);
2339
2340 /* MTU range: 68 - 1500 or 65521 */ 2347 /* MTU range: 68 - 1500 or 65521 */
2341 net->min_mtu = NETVSC_MTU_MIN; 2348 net->min_mtu = NETVSC_MTU_MIN;
2342 if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) 2349 if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 887bbba4631e..ba3dfac1d904 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -131,8 +131,6 @@ static int ipvlan_init(struct net_device *dev)
131 dev->gso_max_segs = phy_dev->gso_max_segs; 131 dev->gso_max_segs = phy_dev->gso_max_segs;
132 dev->hard_header_len = phy_dev->hard_header_len; 132 dev->hard_header_len = phy_dev->hard_header_len;
133 133
134 netdev_lockdep_set_classes(dev);
135
136 ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats); 134 ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats);
137 if (!ipvlan->pcpu_stats) 135 if (!ipvlan->pcpu_stats)
138 return -ENOMEM; 136 return -ENOMEM;
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index cb7637364b40..afd8b2a08245 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -267,7 +267,6 @@ struct macsec_dev {
267 struct pcpu_secy_stats __percpu *stats; 267 struct pcpu_secy_stats __percpu *stats;
268 struct list_head secys; 268 struct list_head secys;
269 struct gro_cells gro_cells; 269 struct gro_cells gro_cells;
270 unsigned int nest_level;
271}; 270};
272 271
273/** 272/**
@@ -2750,7 +2749,6 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
2750 2749
2751#define MACSEC_FEATURES \ 2750#define MACSEC_FEATURES \
2752 (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST) 2751 (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST)
2753static struct lock_class_key macsec_netdev_addr_lock_key;
2754 2752
2755static int macsec_dev_init(struct net_device *dev) 2753static int macsec_dev_init(struct net_device *dev)
2756{ 2754{
@@ -2958,11 +2956,6 @@ static int macsec_get_iflink(const struct net_device *dev)
2958 return macsec_priv(dev)->real_dev->ifindex; 2956 return macsec_priv(dev)->real_dev->ifindex;
2959} 2957}
2960 2958
2961static int macsec_get_nest_level(struct net_device *dev)
2962{
2963 return macsec_priv(dev)->nest_level;
2964}
2965
2966static const struct net_device_ops macsec_netdev_ops = { 2959static const struct net_device_ops macsec_netdev_ops = {
2967 .ndo_init = macsec_dev_init, 2960 .ndo_init = macsec_dev_init,
2968 .ndo_uninit = macsec_dev_uninit, 2961 .ndo_uninit = macsec_dev_uninit,
@@ -2976,7 +2969,6 @@ static const struct net_device_ops macsec_netdev_ops = {
2976 .ndo_start_xmit = macsec_start_xmit, 2969 .ndo_start_xmit = macsec_start_xmit,
2977 .ndo_get_stats64 = macsec_get_stats64, 2970 .ndo_get_stats64 = macsec_get_stats64,
2978 .ndo_get_iflink = macsec_get_iflink, 2971 .ndo_get_iflink = macsec_get_iflink,
2979 .ndo_get_lock_subclass = macsec_get_nest_level,
2980}; 2972};
2981 2973
2982static const struct device_type macsec_type = { 2974static const struct device_type macsec_type = {
@@ -3001,12 +2993,10 @@ static const struct nla_policy macsec_rtnl_policy[IFLA_MACSEC_MAX + 1] = {
3001static void macsec_free_netdev(struct net_device *dev) 2993static void macsec_free_netdev(struct net_device *dev)
3002{ 2994{
3003 struct macsec_dev *macsec = macsec_priv(dev); 2995 struct macsec_dev *macsec = macsec_priv(dev);
3004 struct net_device *real_dev = macsec->real_dev;
3005 2996
3006 free_percpu(macsec->stats); 2997 free_percpu(macsec->stats);
3007 free_percpu(macsec->secy.tx_sc.stats); 2998 free_percpu(macsec->secy.tx_sc.stats);
3008 2999
3009 dev_put(real_dev);
3010} 3000}
3011 3001
3012static void macsec_setup(struct net_device *dev) 3002static void macsec_setup(struct net_device *dev)
@@ -3261,14 +3251,6 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
3261 if (err < 0) 3251 if (err < 0)
3262 return err; 3252 return err;
3263 3253
3264 dev_hold(real_dev);
3265
3266 macsec->nest_level = dev_get_nest_level(real_dev) + 1;
3267 netdev_lockdep_set_classes(dev);
3268 lockdep_set_class_and_subclass(&dev->addr_list_lock,
3269 &macsec_netdev_addr_lock_key,
3270 macsec_get_nest_level(dev));
3271
3272 err = netdev_upper_dev_link(real_dev, dev, extack); 3254 err = netdev_upper_dev_link(real_dev, dev, extack);
3273 if (err < 0) 3255 if (err < 0)
3274 goto unregister; 3256 goto unregister;
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 940192c057b6..34fc59bd1e20 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -852,8 +852,6 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
852 * "super class" of normal network devices; split their locks off into a 852 * "super class" of normal network devices; split their locks off into a
853 * separate class since they always nest. 853 * separate class since they always nest.
854 */ 854 */
855static struct lock_class_key macvlan_netdev_addr_lock_key;
856
857#define ALWAYS_ON_OFFLOADS \ 855#define ALWAYS_ON_OFFLOADS \
858 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \ 856 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \
859 NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL) 857 NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL)
@@ -869,19 +867,6 @@ static struct lock_class_key macvlan_netdev_addr_lock_key;
869#define MACVLAN_STATE_MASK \ 867#define MACVLAN_STATE_MASK \
870 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT)) 868 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
871 869
872static int macvlan_get_nest_level(struct net_device *dev)
873{
874 return ((struct macvlan_dev *)netdev_priv(dev))->nest_level;
875}
876
877static void macvlan_set_lockdep_class(struct net_device *dev)
878{
879 netdev_lockdep_set_classes(dev);
880 lockdep_set_class_and_subclass(&dev->addr_list_lock,
881 &macvlan_netdev_addr_lock_key,
882 macvlan_get_nest_level(dev));
883}
884
885static int macvlan_init(struct net_device *dev) 870static int macvlan_init(struct net_device *dev)
886{ 871{
887 struct macvlan_dev *vlan = netdev_priv(dev); 872 struct macvlan_dev *vlan = netdev_priv(dev);
@@ -900,8 +885,6 @@ static int macvlan_init(struct net_device *dev)
900 dev->gso_max_segs = lowerdev->gso_max_segs; 885 dev->gso_max_segs = lowerdev->gso_max_segs;
901 dev->hard_header_len = lowerdev->hard_header_len; 886 dev->hard_header_len = lowerdev->hard_header_len;
902 887
903 macvlan_set_lockdep_class(dev);
904
905 vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); 888 vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
906 if (!vlan->pcpu_stats) 889 if (!vlan->pcpu_stats)
907 return -ENOMEM; 890 return -ENOMEM;
@@ -1161,7 +1144,6 @@ static const struct net_device_ops macvlan_netdev_ops = {
1161 .ndo_fdb_add = macvlan_fdb_add, 1144 .ndo_fdb_add = macvlan_fdb_add,
1162 .ndo_fdb_del = macvlan_fdb_del, 1145 .ndo_fdb_del = macvlan_fdb_del,
1163 .ndo_fdb_dump = ndo_dflt_fdb_dump, 1146 .ndo_fdb_dump = ndo_dflt_fdb_dump,
1164 .ndo_get_lock_subclass = macvlan_get_nest_level,
1165#ifdef CONFIG_NET_POLL_CONTROLLER 1147#ifdef CONFIG_NET_POLL_CONTROLLER
1166 .ndo_poll_controller = macvlan_dev_poll_controller, 1148 .ndo_poll_controller = macvlan_dev_poll_controller,
1167 .ndo_netpoll_setup = macvlan_dev_netpoll_setup, 1149 .ndo_netpoll_setup = macvlan_dev_netpoll_setup,
@@ -1445,7 +1427,6 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
1445 vlan->dev = dev; 1427 vlan->dev = dev;
1446 vlan->port = port; 1428 vlan->port = port;
1447 vlan->set_features = MACVLAN_FEATURES; 1429 vlan->set_features = MACVLAN_FEATURES;
1448 vlan->nest_level = dev_get_nest_level(lowerdev) + 1;
1449 1430
1450 vlan->mode = MACVLAN_MODE_VEPA; 1431 vlan->mode = MACVLAN_MODE_VEPA;
1451 if (data && data[IFLA_MACVLAN_MODE]) 1432 if (data && data[IFLA_MACVLAN_MODE])
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 56576d4f34a5..54ca6681ba31 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -806,9 +806,11 @@ static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev)
806{ 806{
807 struct nsim_dev_port *nsim_dev_port, *tmp; 807 struct nsim_dev_port *nsim_dev_port, *tmp;
808 808
809 mutex_lock(&nsim_dev->port_list_lock);
809 list_for_each_entry_safe(nsim_dev_port, tmp, 810 list_for_each_entry_safe(nsim_dev_port, tmp,
810 &nsim_dev->port_list, list) 811 &nsim_dev->port_list, list)
811 __nsim_dev_port_del(nsim_dev_port); 812 __nsim_dev_port_del(nsim_dev_port);
813 mutex_unlock(&nsim_dev->port_list_lock);
812} 814}
813 815
814int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) 816int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
@@ -822,14 +824,17 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
822 return PTR_ERR(nsim_dev); 824 return PTR_ERR(nsim_dev);
823 dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev); 825 dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
824 826
827 mutex_lock(&nsim_dev->port_list_lock);
825 for (i = 0; i < nsim_bus_dev->port_count; i++) { 828 for (i = 0; i < nsim_bus_dev->port_count; i++) {
826 err = __nsim_dev_port_add(nsim_dev, i); 829 err = __nsim_dev_port_add(nsim_dev, i);
827 if (err) 830 if (err)
828 goto err_port_del_all; 831 goto err_port_del_all;
829 } 832 }
833 mutex_unlock(&nsim_dev->port_list_lock);
830 return 0; 834 return 0;
831 835
832err_port_del_all: 836err_port_del_all:
837 mutex_unlock(&nsim_dev->port_list_lock);
833 nsim_dev_port_del_all(nsim_dev); 838 nsim_dev_port_del_all(nsim_dev);
834 nsim_dev_destroy(nsim_dev); 839 nsim_dev_destroy(nsim_dev);
835 return err; 840 return err;
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 20e2ebe458f2..a578f7ebf715 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -87,8 +87,24 @@ struct phylink {
87 phylink_printk(KERN_WARNING, pl, fmt, ##__VA_ARGS__) 87 phylink_printk(KERN_WARNING, pl, fmt, ##__VA_ARGS__)
88#define phylink_info(pl, fmt, ...) \ 88#define phylink_info(pl, fmt, ...) \
89 phylink_printk(KERN_INFO, pl, fmt, ##__VA_ARGS__) 89 phylink_printk(KERN_INFO, pl, fmt, ##__VA_ARGS__)
90#if defined(CONFIG_DYNAMIC_DEBUG)
90#define phylink_dbg(pl, fmt, ...) \ 91#define phylink_dbg(pl, fmt, ...) \
92do { \
93 if ((pl)->config->type == PHYLINK_NETDEV) \
94 netdev_dbg((pl)->netdev, fmt, ##__VA_ARGS__); \
95 else if ((pl)->config->type == PHYLINK_DEV) \
96 dev_dbg((pl)->dev, fmt, ##__VA_ARGS__); \
97} while (0)
98#elif defined(DEBUG)
99#define phylink_dbg(pl, fmt, ...) \
91 phylink_printk(KERN_DEBUG, pl, fmt, ##__VA_ARGS__) 100 phylink_printk(KERN_DEBUG, pl, fmt, ##__VA_ARGS__)
101#else
102#define phylink_dbg(pl, fmt, ...) \
103({ \
104 if (0) \
105 phylink_printk(KERN_DEBUG, pl, fmt, ##__VA_ARGS__); \
106})
107#endif
92 108
93/** 109/**
94 * phylink_set_port_modes() - set the port type modes in the ethtool mask 110 * phylink_set_port_modes() - set the port type modes in the ethtool mask
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index dc3d92d340c4..b73298250793 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -327,6 +327,7 @@ static struct phy_driver smsc_phy_driver[] = {
327 .name = "SMSC LAN8740", 327 .name = "SMSC LAN8740",
328 328
329 /* PHY_BASIC_FEATURES */ 329 /* PHY_BASIC_FEATURES */
330 .flags = PHY_RST_AFTER_CLK_EN,
330 331
331 .probe = smsc_phy_probe, 332 .probe = smsc_phy_probe,
332 333
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 9a1b006904a7..61824bbb5588 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1324,8 +1324,6 @@ static int ppp_dev_init(struct net_device *dev)
1324{ 1324{
1325 struct ppp *ppp; 1325 struct ppp *ppp;
1326 1326
1327 netdev_lockdep_set_classes(dev);
1328
1329 ppp = netdev_priv(dev); 1327 ppp = netdev_priv(dev);
1330 /* Let the netdevice take a reference on the ppp file. This ensures 1328 /* Let the netdevice take a reference on the ppp file. This ensures
1331 * that ppp_destroy_interface() won't run before the device gets 1329 * that ppp_destroy_interface() won't run before the device gets
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index e8089def5a46..8156b33ee3e7 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1615,7 +1615,6 @@ static int team_init(struct net_device *dev)
1615 int err; 1615 int err;
1616 1616
1617 team->dev = dev; 1617 team->dev = dev;
1618 mutex_init(&team->lock);
1619 team_set_no_mode(team); 1618 team_set_no_mode(team);
1620 1619
1621 team->pcpu_stats = netdev_alloc_pcpu_stats(struct team_pcpu_stats); 1620 team->pcpu_stats = netdev_alloc_pcpu_stats(struct team_pcpu_stats);
@@ -1642,7 +1641,8 @@ static int team_init(struct net_device *dev)
1642 goto err_options_register; 1641 goto err_options_register;
1643 netif_carrier_off(dev); 1642 netif_carrier_off(dev);
1644 1643
1645 netdev_lockdep_set_classes(dev); 1644 lockdep_register_key(&team->team_lock_key);
1645 __mutex_init(&team->lock, "team->team_lock_key", &team->team_lock_key);
1646 1646
1647 return 0; 1647 return 0;
1648 1648
@@ -1673,6 +1673,7 @@ static void team_uninit(struct net_device *dev)
1673 team_queue_override_fini(team); 1673 team_queue_override_fini(team);
1674 mutex_unlock(&team->lock); 1674 mutex_unlock(&team->lock);
1675 netdev_change_features(dev); 1675 netdev_change_features(dev);
1676 lockdep_unregister_key(&team->team_lock_key);
1676} 1677}
1677 1678
1678static void team_destructor(struct net_device *dev) 1679static void team_destructor(struct net_device *dev)
@@ -1976,8 +1977,15 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev)
1976 err = team_port_del(team, port_dev); 1977 err = team_port_del(team, port_dev);
1977 mutex_unlock(&team->lock); 1978 mutex_unlock(&team->lock);
1978 1979
1979 if (!err) 1980 if (err)
1980 netdev_change_features(dev); 1981 return err;
1982
1983 if (netif_is_team_master(port_dev)) {
1984 lockdep_unregister_key(&team->team_lock_key);
1985 lockdep_register_key(&team->team_lock_key);
1986 lockdep_set_class(&team->lock, &team->team_lock_key);
1987 }
1988 netdev_change_features(dev);
1981 1989
1982 return err; 1990 return err;
1983} 1991}
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 32f53de5b1fe..fe630438f67b 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -787,6 +787,13 @@ static const struct usb_device_id products[] = {
787 .driver_info = 0, 787 .driver_info = 0,
788}, 788},
789 789
790/* ThinkPad USB-C Dock Gen 2 (based on Realtek RTL8153) */
791{
792 USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0xa387, USB_CLASS_COMM,
793 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
794 .driver_info = 0,
795},
796
790/* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ 797/* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
791{ 798{
792 USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM, 799 USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM,
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 62948098191f..f24a1b0b801f 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1264,8 +1264,11 @@ static void lan78xx_status(struct lan78xx_net *dev, struct urb *urb)
1264 netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata); 1264 netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata);
1265 lan78xx_defer_kevent(dev, EVENT_LINK_RESET); 1265 lan78xx_defer_kevent(dev, EVENT_LINK_RESET);
1266 1266
1267 if (dev->domain_data.phyirq > 0) 1267 if (dev->domain_data.phyirq > 0) {
1268 local_irq_disable();
1268 generic_handle_irq(dev->domain_data.phyirq); 1269 generic_handle_irq(dev->domain_data.phyirq);
1270 local_irq_enable();
1271 }
1269 } else 1272 } else
1270 netdev_warn(dev->net, 1273 netdev_warn(dev->net,
1271 "unexpected interrupt: 0x%08x\n", intdata); 1274 "unexpected interrupt: 0x%08x\n", intdata);
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index cee9fef925cd..d4a95b50bda6 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -5755,6 +5755,7 @@ static const struct usb_device_id rtl8152_table[] = {
5755 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, 5755 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
5756 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)}, 5756 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)},
5757 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)}, 5757 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)},
5758 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387)},
5758 {REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041)}, 5759 {REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041)},
5759 {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)}, 5760 {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)},
5760 {REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601)}, 5761 {REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601)},
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index ee52bde058df..b8228f50bc94 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -865,7 +865,6 @@ static int vrf_dev_init(struct net_device *dev)
865 865
866 /* similarly, oper state is irrelevant; set to up to avoid confusion */ 866 /* similarly, oper state is irrelevant; set to up to avoid confusion */
867 dev->operstate = IF_OPER_UP; 867 dev->operstate = IF_OPER_UP;
868 netdev_lockdep_set_classes(dev);
869 return 0; 868 return 0;
870 869
871out_rth: 870out_rth:
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 3d9bcc957f7d..8869154fad88 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2487,9 +2487,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2487 vni = tunnel_id_to_key32(info->key.tun_id); 2487 vni = tunnel_id_to_key32(info->key.tun_id);
2488 ifindex = 0; 2488 ifindex = 0;
2489 dst_cache = &info->dst_cache; 2489 dst_cache = &info->dst_cache;
2490 if (info->options_len && 2490 if (info->key.tun_flags & TUNNEL_VXLAN_OPT) {
2491 info->key.tun_flags & TUNNEL_VXLAN_OPT) 2491 if (info->options_len < sizeof(*md))
2492 goto drop;
2492 md = ip_tunnel_info_opts(info); 2493 md = ip_tunnel_info_opts(info);
2494 }
2493 ttl = info->key.ttl; 2495 ttl = info->key.ttl;
2494 tos = info->key.tos; 2496 tos = info->key.tos;
2495 label = info->key.label; 2497 label = info->key.label;
@@ -3566,10 +3568,13 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3566{ 3568{
3567 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 3569 struct vxlan_net *vn = net_generic(net, vxlan_net_id);
3568 struct vxlan_dev *vxlan = netdev_priv(dev); 3570 struct vxlan_dev *vxlan = netdev_priv(dev);
3571 struct net_device *remote_dev = NULL;
3569 struct vxlan_fdb *f = NULL; 3572 struct vxlan_fdb *f = NULL;
3570 bool unregister = false; 3573 bool unregister = false;
3574 struct vxlan_rdst *dst;
3571 int err; 3575 int err;
3572 3576
3577 dst = &vxlan->default_dst;
3573 err = vxlan_dev_configure(net, dev, conf, false, extack); 3578 err = vxlan_dev_configure(net, dev, conf, false, extack);
3574 if (err) 3579 if (err)
3575 return err; 3580 return err;
@@ -3577,14 +3582,14 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3577 dev->ethtool_ops = &vxlan_ethtool_ops; 3582 dev->ethtool_ops = &vxlan_ethtool_ops;
3578 3583
3579 /* create an fdb entry for a valid default destination */ 3584 /* create an fdb entry for a valid default destination */
3580 if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) { 3585 if (!vxlan_addr_any(&dst->remote_ip)) {
3581 err = vxlan_fdb_create(vxlan, all_zeros_mac, 3586 err = vxlan_fdb_create(vxlan, all_zeros_mac,
3582 &vxlan->default_dst.remote_ip, 3587 &dst->remote_ip,
3583 NUD_REACHABLE | NUD_PERMANENT, 3588 NUD_REACHABLE | NUD_PERMANENT,
3584 vxlan->cfg.dst_port, 3589 vxlan->cfg.dst_port,
3585 vxlan->default_dst.remote_vni, 3590 dst->remote_vni,
3586 vxlan->default_dst.remote_vni, 3591 dst->remote_vni,
3587 vxlan->default_dst.remote_ifindex, 3592 dst->remote_ifindex,
3588 NTF_SELF, &f); 3593 NTF_SELF, &f);
3589 if (err) 3594 if (err)
3590 return err; 3595 return err;
@@ -3595,26 +3600,41 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3595 goto errout; 3600 goto errout;
3596 unregister = true; 3601 unregister = true;
3597 3602
3603 if (dst->remote_ifindex) {
3604 remote_dev = __dev_get_by_index(net, dst->remote_ifindex);
3605 if (!remote_dev)
3606 goto errout;
3607
3608 err = netdev_upper_dev_link(remote_dev, dev, extack);
3609 if (err)
3610 goto errout;
3611 }
3612
3598 err = rtnl_configure_link(dev, NULL); 3613 err = rtnl_configure_link(dev, NULL);
3599 if (err) 3614 if (err)
3600 goto errout; 3615 goto unlink;
3601 3616
3602 if (f) { 3617 if (f) {
3603 vxlan_fdb_insert(vxlan, all_zeros_mac, 3618 vxlan_fdb_insert(vxlan, all_zeros_mac, dst->remote_vni, f);
3604 vxlan->default_dst.remote_vni, f);
3605 3619
3606 /* notify default fdb entry */ 3620 /* notify default fdb entry */
3607 err = vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), 3621 err = vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f),
3608 RTM_NEWNEIGH, true, extack); 3622 RTM_NEWNEIGH, true, extack);
3609 if (err) { 3623 if (err) {
3610 vxlan_fdb_destroy(vxlan, f, false, false); 3624 vxlan_fdb_destroy(vxlan, f, false, false);
3625 if (remote_dev)
3626 netdev_upper_dev_unlink(remote_dev, dev);
3611 goto unregister; 3627 goto unregister;
3612 } 3628 }
3613 } 3629 }
3614 3630
3615 list_add(&vxlan->next, &vn->vxlan_list); 3631 list_add(&vxlan->next, &vn->vxlan_list);
3632 if (remote_dev)
3633 dst->remote_dev = remote_dev;
3616 return 0; 3634 return 0;
3617 3635unlink:
3636 if (remote_dev)
3637 netdev_upper_dev_unlink(remote_dev, dev);
3618errout: 3638errout:
3619 /* unregister_netdevice() destroys the default FDB entry with deletion 3639 /* unregister_netdevice() destroys the default FDB entry with deletion
3620 * notification. But the addition notification was not sent yet, so 3640 * notification. But the addition notification was not sent yet, so
@@ -3932,11 +3952,12 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3932 struct netlink_ext_ack *extack) 3952 struct netlink_ext_ack *extack)
3933{ 3953{
3934 struct vxlan_dev *vxlan = netdev_priv(dev); 3954 struct vxlan_dev *vxlan = netdev_priv(dev);
3935 struct vxlan_rdst *dst = &vxlan->default_dst;
3936 struct net_device *lowerdev; 3955 struct net_device *lowerdev;
3937 struct vxlan_config conf; 3956 struct vxlan_config conf;
3957 struct vxlan_rdst *dst;
3938 int err; 3958 int err;
3939 3959
3960 dst = &vxlan->default_dst;
3940 err = vxlan_nl2conf(tb, data, dev, &conf, true, extack); 3961 err = vxlan_nl2conf(tb, data, dev, &conf, true, extack);
3941 if (err) 3962 if (err)
3942 return err; 3963 return err;
@@ -3946,6 +3967,14 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3946 if (err) 3967 if (err)
3947 return err; 3968 return err;
3948 3969
3970 if (dst->remote_dev == lowerdev)
3971 lowerdev = NULL;
3972
3973 err = netdev_adjacent_change_prepare(dst->remote_dev, lowerdev, dev,
3974 extack);
3975 if (err)
3976 return err;
3977
3949 /* handle default dst entry */ 3978 /* handle default dst entry */
3950 if (!vxlan_addr_equal(&conf.remote_ip, &dst->remote_ip)) { 3979 if (!vxlan_addr_equal(&conf.remote_ip, &dst->remote_ip)) {
3951 u32 hash_index = fdb_head_index(vxlan, all_zeros_mac, conf.vni); 3980 u32 hash_index = fdb_head_index(vxlan, all_zeros_mac, conf.vni);
@@ -3962,6 +3991,8 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3962 NTF_SELF, true, extack); 3991 NTF_SELF, true, extack);
3963 if (err) { 3992 if (err) {
3964 spin_unlock_bh(&vxlan->hash_lock[hash_index]); 3993 spin_unlock_bh(&vxlan->hash_lock[hash_index]);
3994 netdev_adjacent_change_abort(dst->remote_dev,
3995 lowerdev, dev);
3965 return err; 3996 return err;
3966 } 3997 }
3967 } 3998 }
@@ -3979,6 +4010,11 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3979 if (conf.age_interval != vxlan->cfg.age_interval) 4010 if (conf.age_interval != vxlan->cfg.age_interval)
3980 mod_timer(&vxlan->age_timer, jiffies); 4011 mod_timer(&vxlan->age_timer, jiffies);
3981 4012
4013 netdev_adjacent_change_commit(dst->remote_dev, lowerdev, dev);
4014 if (lowerdev && lowerdev != dst->remote_dev) {
4015 dst->remote_dev = lowerdev;
4016 netdev_update_lockdep_key(lowerdev);
4017 }
3982 vxlan_config_apply(dev, &conf, lowerdev, vxlan->net, true); 4018 vxlan_config_apply(dev, &conf, lowerdev, vxlan->net, true);
3983 return 0; 4019 return 0;
3984} 4020}
@@ -3991,6 +4027,8 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head)
3991 4027
3992 list_del(&vxlan->next); 4028 list_del(&vxlan->next);
3993 unregister_netdevice_queue(dev, head); 4029 unregister_netdevice_queue(dev, head);
4030 if (vxlan->default_dst.remote_dev)
4031 netdev_upper_dev_unlink(vxlan->default_dst.remote_dev, dev);
3994} 4032}
3995 4033
3996static size_t vxlan_get_size(const struct net_device *dev) 4034static size_t vxlan_get_size(const struct net_device *dev)
diff --git a/drivers/net/wimax/i2400m/op-rfkill.c b/drivers/net/wimax/i2400m/op-rfkill.c
index 8efb493ceec2..5c79f052cad2 100644
--- a/drivers/net/wimax/i2400m/op-rfkill.c
+++ b/drivers/net/wimax/i2400m/op-rfkill.c
@@ -127,12 +127,12 @@ int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
127 "%d\n", result); 127 "%d\n", result);
128 result = 0; 128 result = 0;
129error_cmd: 129error_cmd:
130 kfree(cmd);
131 kfree_skb(ack_skb); 130 kfree_skb(ack_skb);
132error_msg_to_dev: 131error_msg_to_dev:
133error_alloc: 132error_alloc:
134 d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n", 133 d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n",
135 wimax_dev, state, result); 134 wimax_dev, state, result);
135 kfree(cmd);
136 return result; 136 return result;
137} 137}
138 138
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
index 39c64850cb6f..c0750ced5ac2 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
@@ -520,7 +520,7 @@ struct iwl_scan_dwell {
520} __packed; 520} __packed;
521 521
522/** 522/**
523 * struct iwl_scan_config 523 * struct iwl_scan_config_v1
524 * @flags: enum scan_config_flags 524 * @flags: enum scan_config_flags
525 * @tx_chains: valid_tx antenna - ANT_* definitions 525 * @tx_chains: valid_tx antenna - ANT_* definitions
526 * @rx_chains: valid_rx antenna - ANT_* definitions 526 * @rx_chains: valid_rx antenna - ANT_* definitions
@@ -552,7 +552,7 @@ struct iwl_scan_config_v1 {
552#define SCAN_LB_LMAC_IDX 0 552#define SCAN_LB_LMAC_IDX 0
553#define SCAN_HB_LMAC_IDX 1 553#define SCAN_HB_LMAC_IDX 1
554 554
555struct iwl_scan_config { 555struct iwl_scan_config_v2 {
556 __le32 flags; 556 __le32 flags;
557 __le32 tx_chains; 557 __le32 tx_chains;
558 __le32 rx_chains; 558 __le32 rx_chains;
@@ -564,6 +564,24 @@ struct iwl_scan_config {
564 u8 bcast_sta_id; 564 u8 bcast_sta_id;
565 u8 channel_flags; 565 u8 channel_flags;
566 u8 channel_array[]; 566 u8 channel_array[];
567} __packed; /* SCAN_CONFIG_DB_CMD_API_S_2 */
568
569/**
570 * struct iwl_scan_config
571 * @enable_cam_mode: whether to enable CAM mode.
572 * @enable_promiscouos_mode: whether to enable promiscouos mode
573 * @bcast_sta_id: the index of the station in the fw
574 * @reserved: reserved
575 * @tx_chains: valid_tx antenna - ANT_* definitions
576 * @rx_chains: valid_rx antenna - ANT_* definitions
577 */
578struct iwl_scan_config {
579 u8 enable_cam_mode;
580 u8 enable_promiscouos_mode;
581 u8 bcast_sta_id;
582 u8 reserved;
583 __le32 tx_chains;
584 __le32 rx_chains;
567} __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */ 585} __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */
568 586
569/** 587/**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 423cc0cf8e78..0d5bc4ce5c07 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -288,6 +288,8 @@ typedef unsigned int __bitwise iwl_ucode_tlv_api_t;
288 * STA_CONTEXT_DOT11AX_API_S 288 * STA_CONTEXT_DOT11AX_API_S
289 * @IWL_UCODE_TLV_CAPA_SAR_TABLE_VER: This ucode supports different sar 289 * @IWL_UCODE_TLV_CAPA_SAR_TABLE_VER: This ucode supports different sar
290 * version tables. 290 * version tables.
291 * @IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG: This ucode supports v3 of
292 * SCAN_CONFIG_DB_CMD_API_S.
291 * 293 *
292 * @NUM_IWL_UCODE_TLV_API: number of bits used 294 * @NUM_IWL_UCODE_TLV_API: number of bits used
293 */ 295 */
@@ -321,6 +323,7 @@ enum iwl_ucode_tlv_api {
321 IWL_UCODE_TLV_API_WOWLAN_TCP_SYN_WAKE = (__force iwl_ucode_tlv_api_t)53, 323 IWL_UCODE_TLV_API_WOWLAN_TCP_SYN_WAKE = (__force iwl_ucode_tlv_api_t)53,
322 IWL_UCODE_TLV_API_FTM_RTT_ACCURACY = (__force iwl_ucode_tlv_api_t)54, 324 IWL_UCODE_TLV_API_FTM_RTT_ACCURACY = (__force iwl_ucode_tlv_api_t)54,
323 IWL_UCODE_TLV_API_SAR_TABLE_VER = (__force iwl_ucode_tlv_api_t)55, 325 IWL_UCODE_TLV_API_SAR_TABLE_VER = (__force iwl_ucode_tlv_api_t)55,
326 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG = (__force iwl_ucode_tlv_api_t)56,
324 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = (__force iwl_ucode_tlv_api_t)57, 327 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = (__force iwl_ucode_tlv_api_t)57,
325 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER = (__force iwl_ucode_tlv_api_t)58, 328 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER = (__force iwl_ucode_tlv_api_t)58,
326 329
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index cb4c5514a556..695bbaa86273 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -279,6 +279,7 @@
279 * Indicates MAC is entering a power-saving sleep power-down. 279 * Indicates MAC is entering a power-saving sleep power-down.
280 * Not a good time to access device-internal resources. 280 * Not a good time to access device-internal resources.
281 */ 281 */
282#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
282#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) 283#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
283#define CSR_GP_CNTRL_REG_FLAG_XTAL_ON (0x00000400) 284#define CSR_GP_CNTRL_REG_FLAG_XTAL_ON (0x00000400)
284 285
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
index f47e0f97acf8..23c25a7665f2 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
@@ -449,6 +449,11 @@ enum {
449#define PERSISTENCE_BIT BIT(12) 449#define PERSISTENCE_BIT BIT(12)
450#define PREG_WFPM_ACCESS BIT(12) 450#define PREG_WFPM_ACCESS BIT(12)
451 451
452#define HPM_HIPM_GEN_CFG 0xA03458
453#define HPM_HIPM_GEN_CFG_CR_PG_EN BIT(0)
454#define HPM_HIPM_GEN_CFG_CR_SLP_EN BIT(1)
455#define HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE BIT(10)
456
452#define UREG_DOORBELL_TO_ISR6 0xA05C04 457#define UREG_DOORBELL_TO_ISR6 0xA05C04
453#define UREG_DOORBELL_TO_ISR6_NMI_BIT BIT(0) 458#define UREG_DOORBELL_TO_ISR6_NMI_BIT BIT(0)
454#define UREG_DOORBELL_TO_ISR6_SUSPEND BIT(18) 459#define UREG_DOORBELL_TO_ISR6_SUSPEND BIT(18)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 843d00bf2bd5..5ca50f39a023 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1405,6 +1405,12 @@ static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm)
1405 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER); 1405 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER);
1406} 1406}
1407 1407
1408static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm)
1409{
1410 return fw_has_api(&mvm->fw->ucode_capa,
1411 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG);
1412}
1413
1408static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm) 1414static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)
1409{ 1415{
1410 return fw_has_api(&mvm->fw->ucode_capa, 1416 return fw_has_api(&mvm->fw->ucode_capa,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
index f6b3045badbd..fcafa22ec6ce 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
@@ -1137,11 +1137,11 @@ static void iwl_mvm_fill_scan_config_v1(struct iwl_mvm *mvm, void *config,
1137 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); 1137 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels);
1138} 1138}
1139 1139
1140static void iwl_mvm_fill_scan_config(struct iwl_mvm *mvm, void *config, 1140static void iwl_mvm_fill_scan_config_v2(struct iwl_mvm *mvm, void *config,
1141 u32 flags, u8 channel_flags, 1141 u32 flags, u8 channel_flags,
1142 u32 max_channels) 1142 u32 max_channels)
1143{ 1143{
1144 struct iwl_scan_config *cfg = config; 1144 struct iwl_scan_config_v2 *cfg = config;
1145 1145
1146 cfg->flags = cpu_to_le32(flags); 1146 cfg->flags = cpu_to_le32(flags);
1147 cfg->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); 1147 cfg->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm));
@@ -1185,7 +1185,7 @@ static void iwl_mvm_fill_scan_config(struct iwl_mvm *mvm, void *config,
1185 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); 1185 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels);
1186} 1186}
1187 1187
1188int iwl_mvm_config_scan(struct iwl_mvm *mvm) 1188static int iwl_mvm_legacy_config_scan(struct iwl_mvm *mvm)
1189{ 1189{
1190 void *cfg; 1190 void *cfg;
1191 int ret, cmd_size; 1191 int ret, cmd_size;
@@ -1217,7 +1217,7 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm)
1217 } 1217 }
1218 1218
1219 if (iwl_mvm_cdb_scan_api(mvm)) 1219 if (iwl_mvm_cdb_scan_api(mvm))
1220 cmd_size = sizeof(struct iwl_scan_config); 1220 cmd_size = sizeof(struct iwl_scan_config_v2);
1221 else 1221 else
1222 cmd_size = sizeof(struct iwl_scan_config_v1); 1222 cmd_size = sizeof(struct iwl_scan_config_v1);
1223 cmd_size += num_channels; 1223 cmd_size += num_channels;
@@ -1254,8 +1254,8 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm)
1254 flags |= (iwl_mvm_is_scan_fragmented(hb_type)) ? 1254 flags |= (iwl_mvm_is_scan_fragmented(hb_type)) ?
1255 SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED : 1255 SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED :
1256 SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED; 1256 SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED;
1257 iwl_mvm_fill_scan_config(mvm, cfg, flags, channel_flags, 1257 iwl_mvm_fill_scan_config_v2(mvm, cfg, flags, channel_flags,
1258 num_channels); 1258 num_channels);
1259 } else { 1259 } else {
1260 iwl_mvm_fill_scan_config_v1(mvm, cfg, flags, channel_flags, 1260 iwl_mvm_fill_scan_config_v1(mvm, cfg, flags, channel_flags,
1261 num_channels); 1261 num_channels);
@@ -1277,6 +1277,30 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm)
1277 return ret; 1277 return ret;
1278} 1278}
1279 1279
1280int iwl_mvm_config_scan(struct iwl_mvm *mvm)
1281{
1282 struct iwl_scan_config cfg;
1283 struct iwl_host_cmd cmd = {
1284 .id = iwl_cmd_id(SCAN_CFG_CMD, IWL_ALWAYS_LONG_GROUP, 0),
1285 .len[0] = sizeof(cfg),
1286 .data[0] = &cfg,
1287 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
1288 };
1289
1290 if (!iwl_mvm_is_reduced_config_scan_supported(mvm))
1291 return iwl_mvm_legacy_config_scan(mvm);
1292
1293 memset(&cfg, 0, sizeof(cfg));
1294
1295 cfg.bcast_sta_id = mvm->aux_sta.sta_id;
1296 cfg.tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm));
1297 cfg.rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm));
1298
1299 IWL_DEBUG_SCAN(mvm, "Sending UMAC scan config\n");
1300
1301 return iwl_mvm_send_cmd(mvm, &cmd);
1302}
1303
1280static int iwl_mvm_scan_uid_by_status(struct iwl_mvm *mvm, int status) 1304static int iwl_mvm_scan_uid_by_status(struct iwl_mvm *mvm, int status)
1281{ 1305{
1282 int i; 1306 int i;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 0bedba4c61f2..b3768d5d852a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -1482,6 +1482,13 @@ static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm,
1482 mvm_sta->sta_id, i); 1482 mvm_sta->sta_id, i);
1483 txq_id = iwl_mvm_tvqm_enable_txq(mvm, mvm_sta->sta_id, 1483 txq_id = iwl_mvm_tvqm_enable_txq(mvm, mvm_sta->sta_id,
1484 i, wdg); 1484 i, wdg);
1485 /*
1486 * on failures, just set it to IWL_MVM_INVALID_QUEUE
1487 * to try again later, we have no other good way of
1488 * failing here
1489 */
1490 if (txq_id < 0)
1491 txq_id = IWL_MVM_INVALID_QUEUE;
1485 tid_data->txq_id = txq_id; 1492 tid_data->txq_id = txq_id;
1486 1493
1487 /* 1494 /*
@@ -1950,30 +1957,73 @@ void iwl_mvm_dealloc_int_sta(struct iwl_mvm *mvm, struct iwl_mvm_int_sta *sta)
1950 sta->sta_id = IWL_MVM_INVALID_STA; 1957 sta->sta_id = IWL_MVM_INVALID_STA;
1951} 1958}
1952 1959
1953static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 *queue, 1960static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 queue,
1954 u8 sta_id, u8 fifo) 1961 u8 sta_id, u8 fifo)
1955{ 1962{
1956 unsigned int wdg_timeout = iwlmvm_mod_params.tfd_q_hang_detect ? 1963 unsigned int wdg_timeout = iwlmvm_mod_params.tfd_q_hang_detect ?
1957 mvm->trans->trans_cfg->base_params->wd_timeout : 1964 mvm->trans->trans_cfg->base_params->wd_timeout :
1958 IWL_WATCHDOG_DISABLED; 1965 IWL_WATCHDOG_DISABLED;
1966 struct iwl_trans_txq_scd_cfg cfg = {
1967 .fifo = fifo,
1968 .sta_id = sta_id,
1969 .tid = IWL_MAX_TID_COUNT,
1970 .aggregate = false,
1971 .frame_limit = IWL_FRAME_LIMIT,
1972 };
1973
1974 WARN_ON(iwl_mvm_has_new_tx_api(mvm));
1975
1976 iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg, wdg_timeout);
1977}
1978
1979static int iwl_mvm_enable_aux_snif_queue_tvqm(struct iwl_mvm *mvm, u8 sta_id)
1980{
1981 unsigned int wdg_timeout = iwlmvm_mod_params.tfd_q_hang_detect ?
1982 mvm->trans->trans_cfg->base_params->wd_timeout :
1983 IWL_WATCHDOG_DISABLED;
1984
1985 WARN_ON(!iwl_mvm_has_new_tx_api(mvm));
1986
1987 return iwl_mvm_tvqm_enable_txq(mvm, sta_id, IWL_MAX_TID_COUNT,
1988 wdg_timeout);
1989}
1959 1990
1991static int iwl_mvm_add_int_sta_with_queue(struct iwl_mvm *mvm, int macidx,
1992 int maccolor,
1993 struct iwl_mvm_int_sta *sta,
1994 u16 *queue, int fifo)
1995{
1996 int ret;
1997
1998 /* Map queue to fifo - needs to happen before adding station */
1999 if (!iwl_mvm_has_new_tx_api(mvm))
2000 iwl_mvm_enable_aux_snif_queue(mvm, *queue, sta->sta_id, fifo);
2001
2002 ret = iwl_mvm_add_int_sta_common(mvm, sta, NULL, macidx, maccolor);
2003 if (ret) {
2004 if (!iwl_mvm_has_new_tx_api(mvm))
2005 iwl_mvm_disable_txq(mvm, NULL, *queue,
2006 IWL_MAX_TID_COUNT, 0);
2007 return ret;
2008 }
2009
2010 /*
2011 * For 22000 firmware and on we cannot add queue to a station unknown
2012 * to firmware so enable queue here - after the station was added
2013 */
1960 if (iwl_mvm_has_new_tx_api(mvm)) { 2014 if (iwl_mvm_has_new_tx_api(mvm)) {
1961 int tvqm_queue = 2015 int txq;
1962 iwl_mvm_tvqm_enable_txq(mvm, sta_id,
1963 IWL_MAX_TID_COUNT,
1964 wdg_timeout);
1965 *queue = tvqm_queue;
1966 } else {
1967 struct iwl_trans_txq_scd_cfg cfg = {
1968 .fifo = fifo,
1969 .sta_id = sta_id,
1970 .tid = IWL_MAX_TID_COUNT,
1971 .aggregate = false,
1972 .frame_limit = IWL_FRAME_LIMIT,
1973 };
1974 2016
1975 iwl_mvm_enable_txq(mvm, NULL, *queue, 0, &cfg, wdg_timeout); 2017 txq = iwl_mvm_enable_aux_snif_queue_tvqm(mvm, sta->sta_id);
2018 if (txq < 0) {
2019 iwl_mvm_rm_sta_common(mvm, sta->sta_id);
2020 return txq;
2021 }
2022
2023 *queue = txq;
1976 } 2024 }
2025
2026 return 0;
1977} 2027}
1978 2028
1979int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm) 2029int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm)
@@ -1989,59 +2039,26 @@ int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm)
1989 if (ret) 2039 if (ret)
1990 return ret; 2040 return ret;
1991 2041
1992 /* Map Aux queue to fifo - needs to happen before adding Aux station */ 2042 ret = iwl_mvm_add_int_sta_with_queue(mvm, MAC_INDEX_AUX, 0,
1993 if (!iwl_mvm_has_new_tx_api(mvm)) 2043 &mvm->aux_sta, &mvm->aux_queue,
1994 iwl_mvm_enable_aux_snif_queue(mvm, &mvm->aux_queue, 2044 IWL_MVM_TX_FIFO_MCAST);
1995 mvm->aux_sta.sta_id,
1996 IWL_MVM_TX_FIFO_MCAST);
1997
1998 ret = iwl_mvm_add_int_sta_common(mvm, &mvm->aux_sta, NULL,
1999 MAC_INDEX_AUX, 0);
2000 if (ret) { 2045 if (ret) {
2001 iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); 2046 iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta);
2002 return ret; 2047 return ret;
2003 } 2048 }
2004 2049
2005 /*
2006 * For 22000 firmware and on we cannot add queue to a station unknown
2007 * to firmware so enable queue here - after the station was added
2008 */
2009 if (iwl_mvm_has_new_tx_api(mvm))
2010 iwl_mvm_enable_aux_snif_queue(mvm, &mvm->aux_queue,
2011 mvm->aux_sta.sta_id,
2012 IWL_MVM_TX_FIFO_MCAST);
2013
2014 return 0; 2050 return 0;
2015} 2051}
2016 2052
2017int iwl_mvm_add_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2053int iwl_mvm_add_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2018{ 2054{
2019 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 2055 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2020 int ret;
2021 2056
2022 lockdep_assert_held(&mvm->mutex); 2057 lockdep_assert_held(&mvm->mutex);
2023 2058
2024 /* Map snif queue to fifo - must happen before adding snif station */ 2059 return iwl_mvm_add_int_sta_with_queue(mvm, mvmvif->id, mvmvif->color,
2025 if (!iwl_mvm_has_new_tx_api(mvm)) 2060 &mvm->snif_sta, &mvm->snif_queue,
2026 iwl_mvm_enable_aux_snif_queue(mvm, &mvm->snif_queue,
2027 mvm->snif_sta.sta_id,
2028 IWL_MVM_TX_FIFO_BE); 2061 IWL_MVM_TX_FIFO_BE);
2029
2030 ret = iwl_mvm_add_int_sta_common(mvm, &mvm->snif_sta, vif->addr,
2031 mvmvif->id, 0);
2032 if (ret)
2033 return ret;
2034
2035 /*
2036 * For 22000 firmware and on we cannot add queue to a station unknown
2037 * to firmware so enable queue here - after the station was added
2038 */
2039 if (iwl_mvm_has_new_tx_api(mvm))
2040 iwl_mvm_enable_aux_snif_queue(mvm, &mvm->snif_queue,
2041 mvm->snif_sta.sta_id,
2042 IWL_MVM_TX_FIFO_BE);
2043
2044 return 0;
2045} 2062}
2046 2063
2047int iwl_mvm_rm_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2064int iwl_mvm_rm_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
@@ -2133,6 +2150,10 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2133 queue = iwl_mvm_tvqm_enable_txq(mvm, bsta->sta_id, 2150 queue = iwl_mvm_tvqm_enable_txq(mvm, bsta->sta_id,
2134 IWL_MAX_TID_COUNT, 2151 IWL_MAX_TID_COUNT,
2135 wdg_timeout); 2152 wdg_timeout);
2153 if (queue < 0) {
2154 iwl_mvm_rm_sta_common(mvm, bsta->sta_id);
2155 return queue;
2156 }
2136 2157
2137 if (vif->type == NL80211_IFTYPE_AP || 2158 if (vif->type == NL80211_IFTYPE_AP ||
2138 vif->type == NL80211_IFTYPE_ADHOC) 2159 vif->type == NL80211_IFTYPE_ADHOC)
@@ -2307,10 +2328,8 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2307 } 2328 }
2308 ret = iwl_mvm_add_int_sta_common(mvm, msta, maddr, 2329 ret = iwl_mvm_add_int_sta_common(mvm, msta, maddr,
2309 mvmvif->id, mvmvif->color); 2330 mvmvif->id, mvmvif->color);
2310 if (ret) { 2331 if (ret)
2311 iwl_mvm_dealloc_int_sta(mvm, msta); 2332 goto err;
2312 return ret;
2313 }
2314 2333
2315 /* 2334 /*
2316 * Enable cab queue after the ADD_STA command is sent. 2335 * Enable cab queue after the ADD_STA command is sent.
@@ -2323,6 +2342,10 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2323 int queue = iwl_mvm_tvqm_enable_txq(mvm, msta->sta_id, 2342 int queue = iwl_mvm_tvqm_enable_txq(mvm, msta->sta_id,
2324 0, 2343 0,
2325 timeout); 2344 timeout);
2345 if (queue < 0) {
2346 ret = queue;
2347 goto err;
2348 }
2326 mvmvif->cab_queue = queue; 2349 mvmvif->cab_queue = queue;
2327 } else if (!fw_has_api(&mvm->fw->ucode_capa, 2350 } else if (!fw_has_api(&mvm->fw->ucode_capa,
2328 IWL_UCODE_TLV_API_STA_TYPE)) 2351 IWL_UCODE_TLV_API_STA_TYPE))
@@ -2330,6 +2353,9 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2330 timeout); 2353 timeout);
2331 2354
2332 return 0; 2355 return 0;
2356err:
2357 iwl_mvm_dealloc_int_sta(mvm, msta);
2358 return ret;
2333} 2359}
2334 2360
2335static int __iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, u8 sta_id, 2361static int __iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, u8 sta_id,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 6f4bb7ce71a5..040cec17d3ad 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -573,20 +573,20 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
573 {IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)}, 573 {IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)},
574 {IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_160_cfg)}, 574 {IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_160_cfg)},
575 {IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_160_cfg)}, 575 {IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_160_cfg)},
576 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, 576 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9461_2ac_cfg_soc)},
577 {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)}, 577 {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9461_2ac_cfg_soc)},
578 {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)}, 578 {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9462_2ac_cfg_soc)},
579 {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)}, 579 {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9462_2ac_cfg_soc)},
580 {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)}, 580 {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)},
581 {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)}, 581 {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)},
582 {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)}, 582 {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)},
583 {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)}, 583 {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)},
584 {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)}, 584 {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)},
585 {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)}, 585 {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)},
586 {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)}, 586 {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9461_2ac_cfg_soc)},
587 {IWL_PCI_DEVICE(0x2526, 0x0264, iwl9461_2ac_cfg_soc)}, 587 {IWL_PCI_DEVICE(0x2526, 0x0264, iwl9461_2ac_cfg_soc)},
588 {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)}, 588 {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9462_2ac_cfg_soc)},
589 {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)}, 589 {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9462_2ac_cfg_soc)},
590 {IWL_PCI_DEVICE(0x2526, 0x1010, iwl9260_2ac_cfg)}, 590 {IWL_PCI_DEVICE(0x2526, 0x1010, iwl9260_2ac_cfg)},
591 {IWL_PCI_DEVICE(0x2526, 0x1030, iwl9560_2ac_cfg)}, 591 {IWL_PCI_DEVICE(0x2526, 0x1030, iwl9560_2ac_cfg)},
592 {IWL_PCI_DEVICE(0x2526, 0x1210, iwl9260_2ac_cfg)}, 592 {IWL_PCI_DEVICE(0x2526, 0x1210, iwl9260_2ac_cfg)},
@@ -603,7 +603,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
603 {IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)}, 603 {IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)},
604 {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_160_cfg)}, 604 {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_160_cfg)},
605 {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)}, 605 {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)},
606 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)}, 606 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9462_2ac_cfg_soc)},
607 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)}, 607 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)},
608 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)}, 608 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)},
609 {IWL_PCI_DEVICE(0x2526, 0x6010, iwl9260_2ac_160_cfg)}, 609 {IWL_PCI_DEVICE(0x2526, 0x6010, iwl9260_2ac_160_cfg)},
@@ -618,60 +618,61 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
618 {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)}, 618 {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
619 {IWL_PCI_DEVICE(0x271B, 0x0214, iwl9260_2ac_cfg)}, 619 {IWL_PCI_DEVICE(0x271B, 0x0214, iwl9260_2ac_cfg)},
620 {IWL_PCI_DEVICE(0x271C, 0x0214, iwl9260_2ac_cfg)}, 620 {IWL_PCI_DEVICE(0x271C, 0x0214, iwl9260_2ac_cfg)},
621 {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_160_cfg)}, 621
622 {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_160_cfg)}, 622 {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)},
623 {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_160_cfg)}, 623 {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
624 {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_soc)}, 624 {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
625 {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_soc)}, 625 {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)},
626 {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_soc)}, 626 {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)},
627 {IWL_PCI_DEVICE(0x2720, 0x00A4, iwl9462_2ac_cfg_soc)}, 627 {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)},
628 {IWL_PCI_DEVICE(0x2720, 0x0230, iwl9560_2ac_cfg)}, 628 {IWL_PCI_DEVICE(0x2720, 0x00A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
629 {IWL_PCI_DEVICE(0x2720, 0x0234, iwl9560_2ac_cfg)}, 629 {IWL_PCI_DEVICE(0x2720, 0x0230, iwl9560_2ac_cfg_qu_b0_jf_b0)},
630 {IWL_PCI_DEVICE(0x2720, 0x0238, iwl9560_2ac_cfg)}, 630 {IWL_PCI_DEVICE(0x2720, 0x0234, iwl9560_2ac_cfg_qu_b0_jf_b0)},
631 {IWL_PCI_DEVICE(0x2720, 0x023C, iwl9560_2ac_cfg)}, 631 {IWL_PCI_DEVICE(0x2720, 0x0238, iwl9560_2ac_cfg_qu_b0_jf_b0)},
632 {IWL_PCI_DEVICE(0x2720, 0x0260, iwl9461_2ac_cfg_soc)}, 632 {IWL_PCI_DEVICE(0x2720, 0x023C, iwl9560_2ac_cfg_qu_b0_jf_b0)},
633 {IWL_PCI_DEVICE(0x2720, 0x0264, iwl9461_2ac_cfg_soc)}, 633 {IWL_PCI_DEVICE(0x2720, 0x0260, iwl9461_2ac_cfg_qu_b0_jf_b0)},
634 {IWL_PCI_DEVICE(0x2720, 0x02A0, iwl9462_2ac_cfg_soc)}, 634 {IWL_PCI_DEVICE(0x2720, 0x0264, iwl9461_2ac_cfg_qu_b0_jf_b0)},
635 {IWL_PCI_DEVICE(0x2720, 0x02A4, iwl9462_2ac_cfg_soc)}, 635 {IWL_PCI_DEVICE(0x2720, 0x02A0, iwl9462_2ac_cfg_qu_b0_jf_b0)},
636 {IWL_PCI_DEVICE(0x2720, 0x1010, iwl9260_2ac_cfg)}, 636 {IWL_PCI_DEVICE(0x2720, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
637 {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_soc)}, 637 {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_qu_b0_jf_b0)},
638 {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)}, 638 {IWL_PCI_DEVICE(0x2720, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)},
639 {IWL_PCI_DEVICE(0x2720, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, 639 {IWL_PCI_DEVICE(0x2720, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)},
640 {IWL_PCI_DEVICE(0x2720, 0x1552, iwl9560_killer_2ac_cfg_soc)}, 640 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
641 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_160_cfg_soc)}, 641 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
642 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_160_cfg_soc)}, 642 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
643 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_160_cfg)}, 643 {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)},
644 {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_160_cfg_soc)}, 644 {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
645 {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_soc)}, 645 {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)},
646 {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_soc)}, 646 {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)},
647 {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_soc)}, 647
648 648 {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_160_cfg_soc)},
649 {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 649 {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_soc)},
650 {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 650 {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_160_cfg_soc)},
651 {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 651 {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_160_cfg_soc)},
652 {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 652 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg_soc)},
653 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 653 {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_soc)},
654 {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 654 {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_soc)},
655 {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 655 {IWL_PCI_DEVICE(0x30DC, 0x00A4, iwl9462_2ac_cfg_soc)},
656 {IWL_PCI_DEVICE(0x30DC, 0x00A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 656 {IWL_PCI_DEVICE(0x30DC, 0x0230, iwl9560_2ac_cfg_soc)},
657 {IWL_PCI_DEVICE(0x30DC, 0x0230, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 657 {IWL_PCI_DEVICE(0x30DC, 0x0234, iwl9560_2ac_cfg_soc)},
658 {IWL_PCI_DEVICE(0x30DC, 0x0234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 658 {IWL_PCI_DEVICE(0x30DC, 0x0238, iwl9560_2ac_cfg_soc)},
659 {IWL_PCI_DEVICE(0x30DC, 0x0238, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 659 {IWL_PCI_DEVICE(0x30DC, 0x023C, iwl9560_2ac_cfg_soc)},
660 {IWL_PCI_DEVICE(0x30DC, 0x023C, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 660 {IWL_PCI_DEVICE(0x30DC, 0x0260, iwl9461_2ac_cfg_soc)},
661 {IWL_PCI_DEVICE(0x30DC, 0x0260, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 661 {IWL_PCI_DEVICE(0x30DC, 0x0264, iwl9461_2ac_cfg_soc)},
662 {IWL_PCI_DEVICE(0x30DC, 0x0264, iwl9461_2ac_cfg_qu_b0_jf_b0)}, 662 {IWL_PCI_DEVICE(0x30DC, 0x02A0, iwl9462_2ac_cfg_soc)},
663 {IWL_PCI_DEVICE(0x30DC, 0x02A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 663 {IWL_PCI_DEVICE(0x30DC, 0x02A4, iwl9462_2ac_cfg_soc)},
664 {IWL_PCI_DEVICE(0x30DC, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 664 {IWL_PCI_DEVICE(0x30DC, 0x1010, iwl9260_2ac_cfg)},
665 {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 665 {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_soc)},
666 {IWL_PCI_DEVICE(0x30DC, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)}, 666 {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)},
667 {IWL_PCI_DEVICE(0x30DC, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)}, 667 {IWL_PCI_DEVICE(0x30DC, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
668 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 668 {IWL_PCI_DEVICE(0x30DC, 0x1552, iwl9560_killer_2ac_cfg_soc)},
669 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 669 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_160_cfg_soc)},
670 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 670 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_160_cfg_soc)},
671 {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, 671 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_160_cfg_soc)},
672 {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 672 {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_160_cfg_soc)},
673 {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, 673 {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_soc)},
674 {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, 674 {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_soc)},
675 {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_soc)},
675 676
676 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_160_cfg_shared_clk)}, 677 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_160_cfg_shared_clk)},
677 {IWL_PCI_DEVICE(0x31DC, 0x0034, iwl9560_2ac_cfg_shared_clk)}, 678 {IWL_PCI_DEVICE(0x31DC, 0x0034, iwl9560_2ac_cfg_shared_clk)},
@@ -1067,11 +1068,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1067 } 1068 }
1068 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(iwl_trans->hw_rf_id) == 1069 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(iwl_trans->hw_rf_id) ==
1069 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) && 1070 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) &&
1070 ((cfg != &iwl_ax200_cfg_cc && 1071 iwl_trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0) {
1071 cfg != &killer1650x_2ax_cfg &&
1072 cfg != &killer1650w_2ax_cfg &&
1073 cfg != &iwl_ax201_cfg_quz_hr) ||
1074 iwl_trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0)) {
1075 u32 hw_status; 1072 u32 hw_status;
1076 1073
1077 hw_status = iwl_read_prph(iwl_trans, UMAG_GEN_HW_STATUS); 1074 hw_status = iwl_read_prph(iwl_trans, UMAG_GEN_HW_STATUS);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
index df8455f14e4d..ca3bb4d65b00 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
@@ -57,6 +57,24 @@
57#include "internal.h" 57#include "internal.h"
58#include "fw/dbg.h" 58#include "fw/dbg.h"
59 59
60static int iwl_pcie_gen2_force_power_gating(struct iwl_trans *trans)
61{
62 iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
63 HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
64 udelay(20);
65 iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
66 HPM_HIPM_GEN_CFG_CR_PG_EN |
67 HPM_HIPM_GEN_CFG_CR_SLP_EN);
68 udelay(20);
69 iwl_clear_bits_prph(trans, HPM_HIPM_GEN_CFG,
70 HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
71
72 iwl_trans_sw_reset(trans);
73 iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
74
75 return 0;
76}
77
60/* 78/*
61 * Start up NIC's basic functionality after it has been reset 79 * Start up NIC's basic functionality after it has been reset
62 * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop()) 80 * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop())
@@ -92,6 +110,13 @@ int iwl_pcie_gen2_apm_init(struct iwl_trans *trans)
92 110
93 iwl_pcie_apm_config(trans); 111 iwl_pcie_apm_config(trans);
94 112
113 if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000 &&
114 trans->cfg->integrated) {
115 ret = iwl_pcie_gen2_force_power_gating(trans);
116 if (ret)
117 return ret;
118 }
119
95 ret = iwl_finish_nic_init(trans, trans->trans_cfg); 120 ret = iwl_finish_nic_init(trans, trans->trans_cfg);
96 if (ret) 121 if (ret)
97 return ret; 122 return ret;
diff --git a/drivers/net/wireless/intersil/hostap/hostap_hw.c b/drivers/net/wireless/intersil/hostap/hostap_hw.c
index 158a3d762e55..e323e9a5999f 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_hw.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_hw.c
@@ -3041,30 +3041,6 @@ static void prism2_clear_set_tim_queue(local_info_t *local)
3041 } 3041 }
3042} 3042}
3043 3043
3044
3045/*
3046 * HostAP uses two layers of net devices, where the inner
3047 * layer gets called all the time from the outer layer.
3048 * This is a natural nesting, which needs a split lock type.
3049 */
3050static struct lock_class_key hostap_netdev_xmit_lock_key;
3051static struct lock_class_key hostap_netdev_addr_lock_key;
3052
3053static void prism2_set_lockdep_class_one(struct net_device *dev,
3054 struct netdev_queue *txq,
3055 void *_unused)
3056{
3057 lockdep_set_class(&txq->_xmit_lock,
3058 &hostap_netdev_xmit_lock_key);
3059}
3060
3061static void prism2_set_lockdep_class(struct net_device *dev)
3062{
3063 lockdep_set_class(&dev->addr_list_lock,
3064 &hostap_netdev_addr_lock_key);
3065 netdev_for_each_tx_queue(dev, prism2_set_lockdep_class_one, NULL);
3066}
3067
3068static struct net_device * 3044static struct net_device *
3069prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, 3045prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3070 struct device *sdev) 3046 struct device *sdev)
@@ -3223,7 +3199,6 @@ while (0)
3223 if (ret >= 0) 3199 if (ret >= 0)
3224 ret = register_netdevice(dev); 3200 ret = register_netdevice(dev);
3225 3201
3226 prism2_set_lockdep_class(dev);
3227 rtnl_unlock(); 3202 rtnl_unlock();
3228 if (ret < 0) { 3203 if (ret < 0) {
3229 printk(KERN_WARNING "%s: register netdevice failed!\n", 3204 printk(KERN_WARNING "%s: register netdevice failed!\n",
diff --git a/drivers/net/wireless/mediatek/mt76/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile
index 4d03596e891f..d7a1ddc9e407 100644
--- a/drivers/net/wireless/mediatek/mt76/Makefile
+++ b/drivers/net/wireless/mediatek/mt76/Makefile
@@ -8,6 +8,8 @@ mt76-y := \
8 mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ 8 mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
9 tx.o agg-rx.o mcu.o 9 tx.o agg-rx.o mcu.o
10 10
11mt76-$(CONFIG_PCI) += pci.o
12
11mt76-usb-y := usb.o usb_trace.o 13mt76-usb-y := usb.o usb_trace.o
12 14
13CFLAGS_trace.o := -I$(src) 15CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index c747eb24581c..8f69d00bd940 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -53,8 +53,10 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
53 u32 ctrl; 53 u32 ctrl;
54 int i, idx = -1; 54 int i, idx = -1;
55 55
56 if (txwi) 56 if (txwi) {
57 q->entry[q->head].txwi = DMA_DUMMY_DATA; 57 q->entry[q->head].txwi = DMA_DUMMY_DATA;
58 q->entry[q->head].skip_buf0 = true;
59 }
58 60
59 for (i = 0; i < nbufs; i += 2, buf += 2) { 61 for (i = 0; i < nbufs; i += 2, buf += 2) {
60 u32 buf0 = buf[0].addr, buf1 = 0; 62 u32 buf0 = buf[0].addr, buf1 = 0;
@@ -97,7 +99,7 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx,
97 __le32 __ctrl = READ_ONCE(q->desc[idx].ctrl); 99 __le32 __ctrl = READ_ONCE(q->desc[idx].ctrl);
98 u32 ctrl = le32_to_cpu(__ctrl); 100 u32 ctrl = le32_to_cpu(__ctrl);
99 101
100 if (!e->txwi || !e->skb) { 102 if (!e->skip_buf0) {
101 __le32 addr = READ_ONCE(q->desc[idx].buf0); 103 __le32 addr = READ_ONCE(q->desc[idx].buf0);
102 u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN0, ctrl); 104 u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN0, ctrl);
103 105
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 570c159515a0..8aec7ccf2d79 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -93,8 +93,9 @@ struct mt76_queue_entry {
93 struct urb *urb; 93 struct urb *urb;
94 }; 94 };
95 enum mt76_txq_id qid; 95 enum mt76_txq_id qid;
96 bool schedule; 96 bool skip_buf0:1;
97 bool done; 97 bool schedule:1;
98 bool done:1;
98}; 99};
99 100
100struct mt76_queue_regs { 101struct mt76_queue_regs {
@@ -578,6 +579,7 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
578#define mt76_poll_msec(dev, ...) __mt76_poll_msec(&((dev)->mt76), __VA_ARGS__) 579#define mt76_poll_msec(dev, ...) __mt76_poll_msec(&((dev)->mt76), __VA_ARGS__)
579 580
580void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs); 581void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs);
582void mt76_pci_disable_aspm(struct pci_dev *pdev);
581 583
582static inline u16 mt76_chip(struct mt76_dev *dev) 584static inline u16 mt76_chip(struct mt76_dev *dev)
583{ 585{
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
index 73c3104f8858..cf611d1b817c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
@@ -81,6 +81,8 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
81 /* RG_SSUSB_CDR_BR_PE1D = 0x3 */ 81 /* RG_SSUSB_CDR_BR_PE1D = 0x3 */
82 mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3); 82 mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3);
83 83
84 mt76_pci_disable_aspm(pdev);
85
84 return 0; 86 return 0;
85 87
86error: 88error:
diff --git a/drivers/net/wireless/mediatek/mt76/pci.c b/drivers/net/wireless/mediatek/mt76/pci.c
new file mode 100644
index 000000000000..04c5a692bc85
--- /dev/null
+++ b/drivers/net/wireless/mediatek/mt76/pci.c
@@ -0,0 +1,46 @@
1// SPDX-License-Identifier: ISC
2/*
3 * Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>
4 */
5
6#include <linux/pci.h>
7
8void mt76_pci_disable_aspm(struct pci_dev *pdev)
9{
10 struct pci_dev *parent = pdev->bus->self;
11 u16 aspm_conf, parent_aspm_conf = 0;
12
13 pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf);
14 aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
15 if (parent) {
16 pcie_capability_read_word(parent, PCI_EXP_LNKCTL,
17 &parent_aspm_conf);
18 parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
19 }
20
21 if (!aspm_conf && (!parent || !parent_aspm_conf)) {
22 /* aspm already disabled */
23 return;
24 }
25
26 dev_info(&pdev->dev, "disabling ASPM %s %s\n",
27 (aspm_conf & PCI_EXP_LNKCTL_ASPM_L0S) ? "L0s" : "",
28 (aspm_conf & PCI_EXP_LNKCTL_ASPM_L1) ? "L1" : "");
29
30 if (IS_ENABLED(CONFIG_PCIEASPM)) {
31 int err;
32
33 err = pci_disable_link_state(pdev, aspm_conf);
34 if (!err)
35 return;
36 }
37
38 /* both device and parent should have the same ASPM setting.
39 * disable ASPM in downstream component first and then upstream.
40 */
41 pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_conf);
42 if (parent)
43 pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
44 aspm_conf);
45}
46EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm);
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 6087ec7a90a6..f88d26535978 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -822,7 +822,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
822 hdr = rtl_get_hdr(skb); 822 hdr = rtl_get_hdr(skb);
823 fc = rtl_get_fc(skb); 823 fc = rtl_get_fc(skb);
824 824
825 if (!stats.crc && !stats.hwerror) { 825 if (!stats.crc && !stats.hwerror && (skb->len > FCS_LEN)) {
826 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, 826 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status,
827 sizeof(rx_status)); 827 sizeof(rx_status));
828 828
@@ -859,6 +859,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
859 _rtl_pci_rx_to_mac80211(hw, skb, rx_status); 859 _rtl_pci_rx_to_mac80211(hw, skb, rx_status);
860 } 860 }
861 } else { 861 } else {
862 /* drop packets with errors or those too short */
862 dev_kfree_skb_any(skb); 863 dev_kfree_skb_any(skb);
863 } 864 }
864new_trx_end: 865new_trx_end:
diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
index 70f04c2f5b17..fff8dda14023 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -754,6 +754,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data,
754 return; 754 return;
755 } else { 755 } else {
756 noa_num = (noa_len - 2) / 13; 756 noa_num = (noa_len - 2) / 13;
757 if (noa_num > P2P_MAX_NOA_NUM)
758 noa_num = P2P_MAX_NOA_NUM;
759
757 } 760 }
758 noa_index = ie[3]; 761 noa_index = ie[3];
759 if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == 762 if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode ==
@@ -848,6 +851,9 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data,
848 return; 851 return;
849 } else { 852 } else {
850 noa_num = (noa_len - 2) / 13; 853 noa_num = (noa_len - 2) / 13;
854 if (noa_num > P2P_MAX_NOA_NUM)
855 noa_num = P2P_MAX_NOA_NUM;
856
851 } 857 }
852 noa_index = ie[3]; 858 noa_index = ie[3];
853 if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == 859 if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode ==
diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c
index be92e1220284..7997cc6de334 100644
--- a/drivers/net/wireless/virt_wifi.c
+++ b/drivers/net/wireless/virt_wifi.c
@@ -548,6 +548,7 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev,
548 priv->is_connected = false; 548 priv->is_connected = false;
549 priv->is_up = false; 549 priv->is_up = false;
550 INIT_DELAYED_WORK(&priv->connect, virt_wifi_connect_complete); 550 INIT_DELAYED_WORK(&priv->connect, virt_wifi_connect_complete);
551 __module_get(THIS_MODULE);
551 552
552 return 0; 553 return 0;
553unregister_netdev: 554unregister_netdev:
@@ -578,6 +579,7 @@ static void virt_wifi_dellink(struct net_device *dev,
578 netdev_upper_dev_unlink(priv->lowerdev, dev); 579 netdev_upper_dev_unlink(priv->lowerdev, dev);
579 580
580 unregister_netdevice_queue(dev, head); 581 unregister_netdevice_queue(dev, head);
582 module_put(THIS_MODULE);
581 583
582 /* Deleting the wiphy is handled in the module destructor. */ 584 /* Deleting the wiphy is handled in the module destructor. */
583} 585}
@@ -590,6 +592,42 @@ static struct rtnl_link_ops virt_wifi_link_ops = {
590 .priv_size = sizeof(struct virt_wifi_netdev_priv), 592 .priv_size = sizeof(struct virt_wifi_netdev_priv),
591}; 593};
592 594
595static bool netif_is_virt_wifi_dev(const struct net_device *dev)
596{
597 return rcu_access_pointer(dev->rx_handler) == virt_wifi_rx_handler;
598}
599
600static int virt_wifi_event(struct notifier_block *this, unsigned long event,
601 void *ptr)
602{
603 struct net_device *lower_dev = netdev_notifier_info_to_dev(ptr);
604 struct virt_wifi_netdev_priv *priv;
605 struct net_device *upper_dev;
606 LIST_HEAD(list_kill);
607
608 if (!netif_is_virt_wifi_dev(lower_dev))
609 return NOTIFY_DONE;
610
611 switch (event) {
612 case NETDEV_UNREGISTER:
613 priv = rtnl_dereference(lower_dev->rx_handler_data);
614 if (!priv)
615 return NOTIFY_DONE;
616
617 upper_dev = priv->upperdev;
618
619 upper_dev->rtnl_link_ops->dellink(upper_dev, &list_kill);
620 unregister_netdevice_many(&list_kill);
621 break;
622 }
623
624 return NOTIFY_DONE;
625}
626
627static struct notifier_block virt_wifi_notifier = {
628 .notifier_call = virt_wifi_event,
629};
630
593/* Acquires and releases the rtnl lock. */ 631/* Acquires and releases the rtnl lock. */
594static int __init virt_wifi_init_module(void) 632static int __init virt_wifi_init_module(void)
595{ 633{
@@ -598,14 +636,25 @@ static int __init virt_wifi_init_module(void)
598 /* Guaranteed to be locallly-administered and not multicast. */ 636 /* Guaranteed to be locallly-administered and not multicast. */
599 eth_random_addr(fake_router_bssid); 637 eth_random_addr(fake_router_bssid);
600 638
639 err = register_netdevice_notifier(&virt_wifi_notifier);
640 if (err)
641 return err;
642
643 err = -ENOMEM;
601 common_wiphy = virt_wifi_make_wiphy(); 644 common_wiphy = virt_wifi_make_wiphy();
602 if (!common_wiphy) 645 if (!common_wiphy)
603 return -ENOMEM; 646 goto notifier;
604 647
605 err = rtnl_link_register(&virt_wifi_link_ops); 648 err = rtnl_link_register(&virt_wifi_link_ops);
606 if (err) 649 if (err)
607 virt_wifi_destroy_wiphy(common_wiphy); 650 goto destroy_wiphy;
608 651
652 return 0;
653
654destroy_wiphy:
655 virt_wifi_destroy_wiphy(common_wiphy);
656notifier:
657 unregister_netdevice_notifier(&virt_wifi_notifier);
609 return err; 658 return err;
610} 659}
611 660
@@ -615,6 +664,7 @@ static void __exit virt_wifi_cleanup_module(void)
615 /* Will delete any devices that depend on the wiphy. */ 664 /* Will delete any devices that depend on the wiphy. */
616 rtnl_link_unregister(&virt_wifi_link_ops); 665 rtnl_link_unregister(&virt_wifi_link_ops);
617 virt_wifi_destroy_wiphy(common_wiphy); 666 virt_wifi_destroy_wiphy(common_wiphy);
667 unregister_netdevice_notifier(&virt_wifi_notifier);
618} 668}
619 669
620module_init(virt_wifi_init_module); 670module_init(virt_wifi_init_module);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 30de7efef003..fc99a40c1ec4 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -522,14 +522,13 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,
522 return 0; 522 return 0;
523} 523}
524 524
525static int nvme_read_ana_log(struct nvme_ctrl *ctrl, bool groups_only) 525static int nvme_read_ana_log(struct nvme_ctrl *ctrl)
526{ 526{
527 u32 nr_change_groups = 0; 527 u32 nr_change_groups = 0;
528 int error; 528 int error;
529 529
530 mutex_lock(&ctrl->ana_lock); 530 mutex_lock(&ctrl->ana_lock);
531 error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA, 531 error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA, 0,
532 groups_only ? NVME_ANA_LOG_RGO : 0,
533 ctrl->ana_log_buf, ctrl->ana_log_size, 0); 532 ctrl->ana_log_buf, ctrl->ana_log_size, 0);
534 if (error) { 533 if (error) {
535 dev_warn(ctrl->device, "Failed to get ANA log: %d\n", error); 534 dev_warn(ctrl->device, "Failed to get ANA log: %d\n", error);
@@ -565,7 +564,7 @@ static void nvme_ana_work(struct work_struct *work)
565{ 564{
566 struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work); 565 struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work);
567 566
568 nvme_read_ana_log(ctrl, false); 567 nvme_read_ana_log(ctrl);
569} 568}
570 569
571static void nvme_anatt_timeout(struct timer_list *t) 570static void nvme_anatt_timeout(struct timer_list *t)
@@ -715,7 +714,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
715 goto out; 714 goto out;
716 } 715 }
717 716
718 error = nvme_read_ana_log(ctrl, true); 717 error = nvme_read_ana_log(ctrl);
719 if (error) 718 if (error)
720 goto out_free_ana_log_buf; 719 goto out_free_ana_log_buf;
721 return 0; 720 return 0;
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 770dbcbc999e..7544be84ab35 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2219,7 +2219,7 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx)
2219 struct nvme_tcp_queue *queue = hctx->driver_data; 2219 struct nvme_tcp_queue *queue = hctx->driver_data;
2220 struct sock *sk = queue->sock->sk; 2220 struct sock *sk = queue->sock->sk;
2221 2221
2222 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue)) 2222 if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue))
2223 sk_busy_loop(sk, true); 2223 sk_busy_loop(sk, true);
2224 nvme_tcp_try_recv(queue); 2224 nvme_tcp_try_recv(queue);
2225 return queue->nr_cqe; 2225 return queue->nr_cqe;
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 6ad51aa60c03..f877e77d9184 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -472,14 +472,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
472 if (err) 472 if (err)
473 return err; 473 return err;
474 474
475 /* 475 pwm->state = *state;
476 * .apply might have to round some values in *state, if possible
477 * read the actually implemented value back.
478 */
479 if (chip->ops->get_state)
480 chip->ops->get_state(chip, pwm, &pwm->state);
481 else
482 pwm->state = *state;
483 } else { 476 } else {
484 /* 477 /*
485 * FIXME: restore the initial state in case of error. 478 * FIXME: restore the initial state in case of error.
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index f4b879d25fe9..fc6e4546d738 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -851,9 +851,9 @@ lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
851 851
852 if (!(vport->fc_flag & FC_PT2PT)) { 852 if (!(vport->fc_flag & FC_PT2PT)) {
853 /* Check config parameter use-adisc or FCP-2 */ 853 /* Check config parameter use-adisc or FCP-2 */
854 if ((vport->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) || 854 if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) ||
855 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) && 855 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) &&
856 (ndlp->nlp_type & NLP_FCP_TARGET))) { 856 (ndlp->nlp_type & NLP_FCP_TARGET)))) {
857 spin_lock_irq(shost->host_lock); 857 spin_lock_irq(shost->host_lock);
858 ndlp->nlp_flag |= NLP_NPR_ADISC; 858 ndlp->nlp_flag |= NLP_NPR_ADISC;
859 spin_unlock_irq(shost->host_lock); 859 spin_unlock_irq(shost->host_lock);
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index a0c6945b8139..614f78dddafe 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -7866,7 +7866,7 @@ lpfc_sli4_process_missed_mbox_completions(struct lpfc_hba *phba)
7866 if (sli4_hba->hdwq) { 7866 if (sli4_hba->hdwq) {
7867 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { 7867 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) {
7868 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; 7868 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq;
7869 if (eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { 7869 if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) {
7870 fpeq = eq; 7870 fpeq = eq;
7871 break; 7871 break;
7872 } 7872 }
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 30bafd9d21e9..7259bce85e0e 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -440,9 +440,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
440 valid = 0; 440 valid = 0;
441 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) 441 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
442 valid = 1; 442 valid = 1;
443 else if (start == (ha->flt_region_boot * 4) ||
444 start == (ha->flt_region_fw * 4))
445 valid = 1;
446 else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)) 443 else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha))
447 valid = 1; 444 valid = 1;
448 if (!valid) { 445 if (!valid) {
@@ -489,8 +486,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
489 "Writing flash region -- 0x%x/0x%x.\n", 486 "Writing flash region -- 0x%x/0x%x.\n",
490 ha->optrom_region_start, ha->optrom_region_size); 487 ha->optrom_region_start, ha->optrom_region_size);
491 488
492 ha->isp_ops->write_optrom(vha, ha->optrom_buffer, 489 rval = ha->isp_ops->write_optrom(vha, ha->optrom_buffer,
493 ha->optrom_region_start, ha->optrom_region_size); 490 ha->optrom_region_start, ha->optrom_region_size);
491 if (rval)
492 rval = -EIO;
494 break; 493 break;
495 default: 494 default:
496 rval = -EINVAL; 495 rval = -EINVAL;
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 28d587a89ba6..99f0a1a08143 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -253,7 +253,7 @@ qla2x00_process_els(struct bsg_job *bsg_job)
253 srb_t *sp; 253 srb_t *sp;
254 const char *type; 254 const char *type;
255 int req_sg_cnt, rsp_sg_cnt; 255 int req_sg_cnt, rsp_sg_cnt;
256 int rval = (DRIVER_ERROR << 16); 256 int rval = (DID_ERROR << 16);
257 uint16_t nextlid = 0; 257 uint16_t nextlid = 0;
258 258
259 if (bsg_request->msgcode == FC_BSG_RPT_ELS) { 259 if (bsg_request->msgcode == FC_BSG_RPT_ELS) {
@@ -432,7 +432,7 @@ qla2x00_process_ct(struct bsg_job *bsg_job)
432 struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); 432 struct Scsi_Host *host = fc_bsg_to_shost(bsg_job);
433 scsi_qla_host_t *vha = shost_priv(host); 433 scsi_qla_host_t *vha = shost_priv(host);
434 struct qla_hw_data *ha = vha->hw; 434 struct qla_hw_data *ha = vha->hw;
435 int rval = (DRIVER_ERROR << 16); 435 int rval = (DID_ERROR << 16);
436 int req_sg_cnt, rsp_sg_cnt; 436 int req_sg_cnt, rsp_sg_cnt;
437 uint16_t loop_id; 437 uint16_t loop_id;
438 struct fc_port *fcport; 438 struct fc_port *fcport;
@@ -1950,7 +1950,7 @@ qlafx00_mgmt_cmd(struct bsg_job *bsg_job)
1950 struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); 1950 struct Scsi_Host *host = fc_bsg_to_shost(bsg_job);
1951 scsi_qla_host_t *vha = shost_priv(host); 1951 scsi_qla_host_t *vha = shost_priv(host);
1952 struct qla_hw_data *ha = vha->hw; 1952 struct qla_hw_data *ha = vha->hw;
1953 int rval = (DRIVER_ERROR << 16); 1953 int rval = (DID_ERROR << 16);
1954 struct qla_mt_iocb_rqst_fx00 *piocb_rqst; 1954 struct qla_mt_iocb_rqst_fx00 *piocb_rqst;
1955 srb_t *sp; 1955 srb_t *sp;
1956 int req_sg_cnt = 0, rsp_sg_cnt = 0; 1956 int req_sg_cnt = 0, rsp_sg_cnt = 0;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 1cc6913f76c4..4a1f21c11758 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -702,6 +702,7 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
702 mcp->mb[2] = LSW(risc_addr); 702 mcp->mb[2] = LSW(risc_addr);
703 mcp->mb[3] = 0; 703 mcp->mb[3] = 0;
704 mcp->mb[4] = 0; 704 mcp->mb[4] = 0;
705 mcp->mb[11] = 0;
705 ha->flags.using_lr_setting = 0; 706 ha->flags.using_lr_setting = 0;
706 if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || 707 if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) ||
707 IS_QLA27XX(ha) || IS_QLA28XX(ha)) { 708 IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
@@ -746,7 +747,7 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
746 if (ha->flags.exchoffld_enabled) 747 if (ha->flags.exchoffld_enabled)
747 mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; 748 mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD;
748 749
749 mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; 750 mcp->out_mb |= MBX_4 | MBX_3 | MBX_2 | MBX_1 | MBX_11;
750 mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; 751 mcp->in_mb |= MBX_3 | MBX_2 | MBX_1;
751 } else { 752 } else {
752 mcp->mb[1] = LSW(risc_addr); 753 mcp->mb[1] = LSW(risc_addr);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index bcb1e8598888..337162ac3a77 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3535,6 +3535,10 @@ qla2x00_shutdown(struct pci_dev *pdev)
3535 qla2x00_try_to_stop_firmware(vha); 3535 qla2x00_try_to_stop_firmware(vha);
3536 } 3536 }
3537 3537
3538 /* Disable timer */
3539 if (vha->timer_active)
3540 qla2x00_stop_timer(vha);
3541
3538 /* Turn adapter off line */ 3542 /* Turn adapter off line */
3539 vha->flags.online = 0; 3543 vha->flags.online = 0;
3540 3544
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 03163ac5fe95..ebb40160539f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1166,11 +1166,12 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
1166 sector_t lba = sectors_to_logical(sdp, blk_rq_pos(rq)); 1166 sector_t lba = sectors_to_logical(sdp, blk_rq_pos(rq));
1167 sector_t threshold; 1167 sector_t threshold;
1168 unsigned int nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); 1168 unsigned int nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
1169 bool dif, dix;
1170 unsigned int mask = logical_to_sectors(sdp, 1) - 1; 1169 unsigned int mask = logical_to_sectors(sdp, 1) - 1;
1171 bool write = rq_data_dir(rq) == WRITE; 1170 bool write = rq_data_dir(rq) == WRITE;
1172 unsigned char protect, fua; 1171 unsigned char protect, fua;
1173 blk_status_t ret; 1172 blk_status_t ret;
1173 unsigned int dif;
1174 bool dix;
1174 1175
1175 ret = scsi_init_io(cmd); 1176 ret = scsi_init_io(cmd);
1176 if (ret != BLK_STS_OK) 1177 if (ret != BLK_STS_OK)
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
index a9344eb4e047..dc2f6d2b46ed 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -98,6 +98,8 @@ static int ufs_bsg_request(struct bsg_job *job)
98 98
99 bsg_reply->reply_payload_rcv_len = 0; 99 bsg_reply->reply_payload_rcv_len = 0;
100 100
101 pm_runtime_get_sync(hba->dev);
102
101 msgcode = bsg_request->msgcode; 103 msgcode = bsg_request->msgcode;
102 switch (msgcode) { 104 switch (msgcode) {
103 case UPIU_TRANSACTION_QUERY_REQ: 105 case UPIU_TRANSACTION_QUERY_REQ:
@@ -135,6 +137,8 @@ static int ufs_bsg_request(struct bsg_job *job)
135 break; 137 break;
136 } 138 }
137 139
140 pm_runtime_put_sync(hba->dev);
141
138 if (!desc_buff) 142 if (!desc_buff)
139 goto out; 143 goto out;
140 144
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
index c70caf4ea490..a2b5c796bbc4 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
@@ -1831,7 +1831,7 @@ static void cxgbit_fw4_ack(struct cxgbit_sock *csk, struct sk_buff *skb)
1831 1831
1832 while (credits) { 1832 while (credits) {
1833 struct sk_buff *p = cxgbit_sock_peek_wr(csk); 1833 struct sk_buff *p = cxgbit_sock_peek_wr(csk);
1834 const u32 csum = (__force u32)p->csum; 1834 u32 csum;
1835 1835
1836 if (unlikely(!p)) { 1836 if (unlikely(!p)) {
1837 pr_err("csk 0x%p,%u, cr %u,%u+%u, empty.\n", 1837 pr_err("csk 0x%p,%u, cr %u,%u+%u, empty.\n",
@@ -1840,6 +1840,7 @@ static void cxgbit_fw4_ack(struct cxgbit_sock *csk, struct sk_buff *skb)
1840 break; 1840 break;
1841 } 1841 }
1842 1842
1843 csum = (__force u32)p->csum;
1843 if (unlikely(credits < csum)) { 1844 if (unlikely(credits < csum)) {
1844 pr_warn("csk 0x%p,%u, cr %u,%u+%u, < %u.\n", 1845 pr_warn("csk 0x%p,%u, cr %u,%u+%u, < %u.\n",
1845 csk, csk->tid, 1846 csk, csk->tid,
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 9050b380ab83..4c1e75509303 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2329,8 +2329,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
2329 writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf); 2329 writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
2330 2330
2331 cdns3_configure_dmult(priv_dev, NULL); 2331 cdns3_configure_dmult(priv_dev, NULL);
2332
2333 cdns3_gadget_pullup(&priv_dev->gadget, 1);
2334} 2332}
2335 2333
2336/** 2334/**
@@ -2345,9 +2343,35 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
2345{ 2343{
2346 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); 2344 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
2347 unsigned long flags; 2345 unsigned long flags;
2346 enum usb_device_speed max_speed = driver->max_speed;
2348 2347
2349 spin_lock_irqsave(&priv_dev->lock, flags); 2348 spin_lock_irqsave(&priv_dev->lock, flags);
2350 priv_dev->gadget_driver = driver; 2349 priv_dev->gadget_driver = driver;
2350
2351 /* limit speed if necessary */
2352 max_speed = min(driver->max_speed, gadget->max_speed);
2353
2354 switch (max_speed) {
2355 case USB_SPEED_FULL:
2356 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2357 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2358 break;
2359 case USB_SPEED_HIGH:
2360 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2361 break;
2362 case USB_SPEED_SUPER:
2363 break;
2364 default:
2365 dev_err(priv_dev->dev,
2366 "invalid maximum_speed parameter %d\n",
2367 max_speed);
2368 /* fall through */
2369 case USB_SPEED_UNKNOWN:
2370 /* default to superspeed */
2371 max_speed = USB_SPEED_SUPER;
2372 break;
2373 }
2374
2351 cdns3_gadget_config(priv_dev); 2375 cdns3_gadget_config(priv_dev);
2352 spin_unlock_irqrestore(&priv_dev->lock, flags); 2376 spin_unlock_irqrestore(&priv_dev->lock, flags);
2353 return 0; 2377 return 0;
@@ -2381,6 +2405,8 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
2381 writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd); 2405 writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
2382 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, 2406 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
2383 !(val & EP_CMD_EPRST), 1, 100); 2407 !(val & EP_CMD_EPRST), 1, 100);
2408
2409 priv_ep->flags &= ~EP_CLAIMED;
2384 } 2410 }
2385 2411
2386 /* disable interrupt for device */ 2412 /* disable interrupt for device */
@@ -2575,12 +2601,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
2575 /* Check the maximum_speed parameter */ 2601 /* Check the maximum_speed parameter */
2576 switch (max_speed) { 2602 switch (max_speed) {
2577 case USB_SPEED_FULL: 2603 case USB_SPEED_FULL:
2578 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2579 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2580 break;
2581 case USB_SPEED_HIGH: 2604 case USB_SPEED_HIGH:
2582 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2583 break;
2584 case USB_SPEED_SUPER: 2605 case USB_SPEED_SUPER:
2585 break; 2606 break;
2586 default: 2607 default:
@@ -2713,8 +2734,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
2713 /* disable interrupt for device */ 2734 /* disable interrupt for device */
2714 writel(0, &priv_dev->regs->usb_ien); 2735 writel(0, &priv_dev->regs->usb_ien);
2715 2736
2716 cdns3_gadget_pullup(&priv_dev->gadget, 0);
2717
2718 return 0; 2737 return 0;
2719} 2738}
2720 2739
diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h
index b498a170b7e8..ae11810f8826 100644
--- a/drivers/usb/cdns3/host-export.h
+++ b/drivers/usb/cdns3/host-export.h
@@ -12,7 +12,6 @@
12#ifdef CONFIG_USB_CDNS3_HOST 12#ifdef CONFIG_USB_CDNS3_HOST
13 13
14int cdns3_host_init(struct cdns3 *cdns); 14int cdns3_host_init(struct cdns3 *cdns);
15void cdns3_host_exit(struct cdns3 *cdns);
16 15
17#else 16#else
18 17
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index 2733a8f71fcd..ad788bf3fe4f 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include "core.h" 13#include "core.h"
14#include "drd.h" 14#include "drd.h"
15#include "host-export.h"
15 16
16static int __cdns3_host_init(struct cdns3 *cdns) 17static int __cdns3_host_init(struct cdns3 *cdns)
17{ 18{
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 151a74a54386..1ac1095bfeac 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -348,6 +348,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
348 348
349 /* Validate the wMaxPacketSize field */ 349 /* Validate the wMaxPacketSize field */
350 maxp = usb_endpoint_maxp(&endpoint->desc); 350 maxp = usb_endpoint_maxp(&endpoint->desc);
351 if (maxp == 0) {
352 dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n",
353 cfgno, inum, asnum, d->bEndpointAddress);
354 goto skip_to_next_endpoint_or_interface_descriptor;
355 }
351 356
352 /* Find the highest legal maxpacket size for this endpoint */ 357 /* Find the highest legal maxpacket size for this endpoint */
353 i = 0; /* additional transactions per microframe */ 358 i = 0; /* additional transactions per microframe */
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 89abc6078703..556a876c7896 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -102,6 +102,7 @@ config USB_DWC3_MESON_G12A
102 depends on ARCH_MESON || COMPILE_TEST 102 depends on ARCH_MESON || COMPILE_TEST
103 default USB_DWC3 103 default USB_DWC3
104 select USB_ROLE_SWITCH 104 select USB_ROLE_SWITCH
105 select REGMAP_MMIO
105 help 106 help
106 Support USB2/3 functionality in Amlogic G12A platforms. 107 Support USB2/3 functionality in Amlogic G12A platforms.
107 Say 'Y' or 'M' if you have one such device. 108 Say 'Y' or 'M' if you have one such device.
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 999ce5e84d3c..97d6ae3c4df2 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -312,8 +312,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
312 312
313 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); 313 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
314 dft = reg & DWC3_GFLADJ_30MHZ_MASK; 314 dft = reg & DWC3_GFLADJ_30MHZ_MASK;
315 if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj, 315 if (dft != dwc->fladj) {
316 "request value same as default, ignoring\n")) {
317 reg &= ~DWC3_GFLADJ_30MHZ_MASK; 316 reg &= ~DWC3_GFLADJ_30MHZ_MASK;
318 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; 317 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;
319 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); 318 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 5e8e18222f92..023f0357efd7 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -258,7 +258,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
258 258
259 ret = platform_device_add_properties(dwc->dwc3, p); 259 ret = platform_device_add_properties(dwc->dwc3, p);
260 if (ret < 0) 260 if (ret < 0)
261 return ret; 261 goto err;
262 262
263 ret = dwc3_pci_quirks(dwc); 263 ret = dwc3_pci_quirks(dwc);
264 if (ret) 264 if (ret)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 86dc1db788a9..a9aba716bf80 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -707,6 +707,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
707 707
708 dwc3_gadget_giveback(dep, req, -ESHUTDOWN); 708 dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
709 } 709 }
710
711 while (!list_empty(&dep->cancelled_list)) {
712 req = next_request(&dep->cancelled_list);
713
714 dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
715 }
710} 716}
711 717
712/** 718/**
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index d516e8d6cd7f..5ec54b69c29c 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2170,14 +2170,18 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev)
2170 usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req); 2170 usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req);
2171 2171
2172 kfree(cdev->os_desc_req->buf); 2172 kfree(cdev->os_desc_req->buf);
2173 cdev->os_desc_req->buf = NULL;
2173 usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req); 2174 usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req);
2175 cdev->os_desc_req = NULL;
2174 } 2176 }
2175 if (cdev->req) { 2177 if (cdev->req) {
2176 if (cdev->setup_pending) 2178 if (cdev->setup_pending)
2177 usb_ep_dequeue(cdev->gadget->ep0, cdev->req); 2179 usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
2178 2180
2179 kfree(cdev->req->buf); 2181 kfree(cdev->req->buf);
2182 cdev->req->buf = NULL;
2180 usb_ep_free_request(cdev->gadget->ep0, cdev->req); 2183 usb_ep_free_request(cdev->gadget->ep0, cdev->req);
2184 cdev->req = NULL;
2181 } 2185 }
2182 cdev->next_string_id = 0; 2186 cdev->next_string_id = 0;
2183 device_remove_file(&cdev->gadget->dev, &dev_attr_suspended); 2187 device_remove_file(&cdev->gadget->dev, &dev_attr_suspended);
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 025129942894..33852c2b29d1 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -61,6 +61,8 @@ struct gadget_info {
61 bool use_os_desc; 61 bool use_os_desc;
62 char b_vendor_code; 62 char b_vendor_code;
63 char qw_sign[OS_STRING_QW_SIGN_LEN]; 63 char qw_sign[OS_STRING_QW_SIGN_LEN];
64 spinlock_t spinlock;
65 bool unbind;
64}; 66};
65 67
66static inline struct gadget_info *to_gadget_info(struct config_item *item) 68static inline struct gadget_info *to_gadget_info(struct config_item *item)
@@ -1244,6 +1246,7 @@ static int configfs_composite_bind(struct usb_gadget *gadget,
1244 int ret; 1246 int ret;
1245 1247
1246 /* the gi->lock is hold by the caller */ 1248 /* the gi->lock is hold by the caller */
1249 gi->unbind = 0;
1247 cdev->gadget = gadget; 1250 cdev->gadget = gadget;
1248 set_gadget_data(gadget, cdev); 1251 set_gadget_data(gadget, cdev);
1249 ret = composite_dev_prepare(composite, cdev); 1252 ret = composite_dev_prepare(composite, cdev);
@@ -1376,31 +1379,128 @@ static void configfs_composite_unbind(struct usb_gadget *gadget)
1376{ 1379{
1377 struct usb_composite_dev *cdev; 1380 struct usb_composite_dev *cdev;
1378 struct gadget_info *gi; 1381 struct gadget_info *gi;
1382 unsigned long flags;
1379 1383
1380 /* the gi->lock is hold by the caller */ 1384 /* the gi->lock is hold by the caller */
1381 1385
1382 cdev = get_gadget_data(gadget); 1386 cdev = get_gadget_data(gadget);
1383 gi = container_of(cdev, struct gadget_info, cdev); 1387 gi = container_of(cdev, struct gadget_info, cdev);
1388 spin_lock_irqsave(&gi->spinlock, flags);
1389 gi->unbind = 1;
1390 spin_unlock_irqrestore(&gi->spinlock, flags);
1384 1391
1385 kfree(otg_desc[0]); 1392 kfree(otg_desc[0]);
1386 otg_desc[0] = NULL; 1393 otg_desc[0] = NULL;
1387 purge_configs_funcs(gi); 1394 purge_configs_funcs(gi);
1388 composite_dev_cleanup(cdev); 1395 composite_dev_cleanup(cdev);
1389 usb_ep_autoconfig_reset(cdev->gadget); 1396 usb_ep_autoconfig_reset(cdev->gadget);
1397 spin_lock_irqsave(&gi->spinlock, flags);
1390 cdev->gadget = NULL; 1398 cdev->gadget = NULL;
1391 set_gadget_data(gadget, NULL); 1399 set_gadget_data(gadget, NULL);
1400 spin_unlock_irqrestore(&gi->spinlock, flags);
1401}
1402
1403static int configfs_composite_setup(struct usb_gadget *gadget,
1404 const struct usb_ctrlrequest *ctrl)
1405{
1406 struct usb_composite_dev *cdev;
1407 struct gadget_info *gi;
1408 unsigned long flags;
1409 int ret;
1410
1411 cdev = get_gadget_data(gadget);
1412 if (!cdev)
1413 return 0;
1414
1415 gi = container_of(cdev, struct gadget_info, cdev);
1416 spin_lock_irqsave(&gi->spinlock, flags);
1417 cdev = get_gadget_data(gadget);
1418 if (!cdev || gi->unbind) {
1419 spin_unlock_irqrestore(&gi->spinlock, flags);
1420 return 0;
1421 }
1422
1423 ret = composite_setup(gadget, ctrl);
1424 spin_unlock_irqrestore(&gi->spinlock, flags);
1425 return ret;
1426}
1427
1428static void configfs_composite_disconnect(struct usb_gadget *gadget)
1429{
1430 struct usb_composite_dev *cdev;
1431 struct gadget_info *gi;
1432 unsigned long flags;
1433
1434 cdev = get_gadget_data(gadget);
1435 if (!cdev)
1436 return;
1437
1438 gi = container_of(cdev, struct gadget_info, cdev);
1439 spin_lock_irqsave(&gi->spinlock, flags);
1440 cdev = get_gadget_data(gadget);
1441 if (!cdev || gi->unbind) {
1442 spin_unlock_irqrestore(&gi->spinlock, flags);
1443 return;
1444 }
1445
1446 composite_disconnect(gadget);
1447 spin_unlock_irqrestore(&gi->spinlock, flags);
1448}
1449
1450static void configfs_composite_suspend(struct usb_gadget *gadget)
1451{
1452 struct usb_composite_dev *cdev;
1453 struct gadget_info *gi;
1454 unsigned long flags;
1455
1456 cdev = get_gadget_data(gadget);
1457 if (!cdev)
1458 return;
1459
1460 gi = container_of(cdev, struct gadget_info, cdev);
1461 spin_lock_irqsave(&gi->spinlock, flags);
1462 cdev = get_gadget_data(gadget);
1463 if (!cdev || gi->unbind) {
1464 spin_unlock_irqrestore(&gi->spinlock, flags);
1465 return;
1466 }
1467
1468 composite_suspend(gadget);
1469 spin_unlock_irqrestore(&gi->spinlock, flags);
1470}
1471
1472static void configfs_composite_resume(struct usb_gadget *gadget)
1473{
1474 struct usb_composite_dev *cdev;
1475 struct gadget_info *gi;
1476 unsigned long flags;
1477
1478 cdev = get_gadget_data(gadget);
1479 if (!cdev)
1480 return;
1481
1482 gi = container_of(cdev, struct gadget_info, cdev);
1483 spin_lock_irqsave(&gi->spinlock, flags);
1484 cdev = get_gadget_data(gadget);
1485 if (!cdev || gi->unbind) {
1486 spin_unlock_irqrestore(&gi->spinlock, flags);
1487 return;
1488 }
1489
1490 composite_resume(gadget);
1491 spin_unlock_irqrestore(&gi->spinlock, flags);
1392} 1492}
1393 1493
1394static const struct usb_gadget_driver configfs_driver_template = { 1494static const struct usb_gadget_driver configfs_driver_template = {
1395 .bind = configfs_composite_bind, 1495 .bind = configfs_composite_bind,
1396 .unbind = configfs_composite_unbind, 1496 .unbind = configfs_composite_unbind,
1397 1497
1398 .setup = composite_setup, 1498 .setup = configfs_composite_setup,
1399 .reset = composite_disconnect, 1499 .reset = configfs_composite_disconnect,
1400 .disconnect = composite_disconnect, 1500 .disconnect = configfs_composite_disconnect,
1401 1501
1402 .suspend = composite_suspend, 1502 .suspend = configfs_composite_suspend,
1403 .resume = composite_resume, 1503 .resume = configfs_composite_resume,
1404 1504
1405 .max_speed = USB_SPEED_SUPER, 1505 .max_speed = USB_SPEED_SUPER,
1406 .driver = { 1506 .driver = {
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 86ffc8307864..1d0d8952a74b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -449,9 +449,11 @@ static void submit_request(struct usba_ep *ep, struct usba_request *req)
449 next_fifo_transaction(ep, req); 449 next_fifo_transaction(ep, req);
450 if (req->last_transaction) { 450 if (req->last_transaction) {
451 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); 451 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY);
452 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); 452 if (ep_is_control(ep))
453 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE);
453 } else { 454 } else {
454 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); 455 if (ep_is_control(ep))
456 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE);
455 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); 457 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY);
456 } 458 }
457 } 459 }
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 92af8dc98c3d..51fa614b4079 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -98,6 +98,17 @@ int usb_ep_enable(struct usb_ep *ep)
98 if (ep->enabled) 98 if (ep->enabled)
99 goto out; 99 goto out;
100 100
101 /* UDC drivers can't handle endpoints with maxpacket size 0 */
102 if (usb_endpoint_maxp(ep->desc) == 0) {
103 /*
104 * We should log an error message here, but we can't call
105 * dev_err() because there's no way to find the gadget
106 * given only ep.
107 */
108 ret = -EINVAL;
109 goto out;
110 }
111
101 ret = ep->ops->enable(ep, ep->desc); 112 ret = ep->ops->enable(ep, ep->desc);
102 if (ret) 113 if (ret)
103 goto out; 114 goto out;
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 20141c3096f6..9a05863b2876 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2576,7 +2576,7 @@ static int fsl_udc_remove(struct platform_device *pdev)
2576 dma_pool_destroy(udc_controller->td_pool); 2576 dma_pool_destroy(udc_controller->td_pool);
2577 free_irq(udc_controller->irq, udc_controller); 2577 free_irq(udc_controller->irq, udc_controller);
2578 iounmap(dr_regs); 2578 iounmap(dr_regs);
2579 if (pdata->operating_mode == FSL_USB2_DR_DEVICE) 2579 if (res && (pdata->operating_mode == FSL_USB2_DR_DEVICE))
2580 release_mem_region(res->start, resource_size(res)); 2580 release_mem_region(res->start, resource_size(res));
2581 2581
2582 /* free udc --wait for the release() finished */ 2582 /* free udc --wait for the release() finished */
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index e098f16c01cb..33703140233a 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1544,10 +1544,10 @@ static void usb3_set_device_address(struct renesas_usb3 *usb3, u16 addr)
1544static bool usb3_std_req_set_address(struct renesas_usb3 *usb3, 1544static bool usb3_std_req_set_address(struct renesas_usb3 *usb3,
1545 struct usb_ctrlrequest *ctrl) 1545 struct usb_ctrlrequest *ctrl)
1546{ 1546{
1547 if (ctrl->wValue >= 128) 1547 if (le16_to_cpu(ctrl->wValue) >= 128)
1548 return true; /* stall */ 1548 return true; /* stall */
1549 1549
1550 usb3_set_device_address(usb3, ctrl->wValue); 1550 usb3_set_device_address(usb3, le16_to_cpu(ctrl->wValue));
1551 usb3_set_p0_con_for_no_data(usb3); 1551 usb3_set_p0_con_for_no_data(usb3);
1552 1552
1553 return false; 1553 return false;
@@ -1582,6 +1582,7 @@ static bool usb3_std_req_get_status(struct renesas_usb3 *usb3,
1582 struct renesas_usb3_ep *usb3_ep; 1582 struct renesas_usb3_ep *usb3_ep;
1583 int num; 1583 int num;
1584 u16 status = 0; 1584 u16 status = 0;
1585 __le16 tx_data;
1585 1586
1586 switch (ctrl->bRequestType & USB_RECIP_MASK) { 1587 switch (ctrl->bRequestType & USB_RECIP_MASK) {
1587 case USB_RECIP_DEVICE: 1588 case USB_RECIP_DEVICE:
@@ -1604,10 +1605,10 @@ static bool usb3_std_req_get_status(struct renesas_usb3 *usb3,
1604 } 1605 }
1605 1606
1606 if (!stall) { 1607 if (!stall) {
1607 status = cpu_to_le16(status); 1608 tx_data = cpu_to_le16(status);
1608 dev_dbg(usb3_to_dev(usb3), "get_status: req = %p\n", 1609 dev_dbg(usb3_to_dev(usb3), "get_status: req = %p\n",
1609 usb_req_to_usb3_req(usb3->ep0_req)); 1610 usb_req_to_usb3_req(usb3->ep0_req));
1610 usb3_pipe0_internal_xfer(usb3, &status, sizeof(status), 1611 usb3_pipe0_internal_xfer(usb3, &tx_data, sizeof(tx_data),
1611 usb3_pipe0_get_status_completion); 1612 usb3_pipe0_get_status_completion);
1612 } 1613 }
1613 1614
@@ -1772,7 +1773,7 @@ static bool usb3_std_req_set_sel(struct renesas_usb3 *usb3,
1772static bool usb3_std_req_set_configuration(struct renesas_usb3 *usb3, 1773static bool usb3_std_req_set_configuration(struct renesas_usb3 *usb3,
1773 struct usb_ctrlrequest *ctrl) 1774 struct usb_ctrlrequest *ctrl)
1774{ 1775{
1775 if (ctrl->wValue > 0) 1776 if (le16_to_cpu(ctrl->wValue) > 0)
1776 usb3_set_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON); 1777 usb3_set_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON);
1777 else 1778 else
1778 usb3_clear_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON); 1779 usb3_clear_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON);
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index 7ba6afc7ef23..76c3f29562d2 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -202,10 +202,10 @@ static void xhci_ring_dump_segment(struct seq_file *s,
202 trb = &seg->trbs[i]; 202 trb = &seg->trbs[i];
203 dma = seg->dma + i * sizeof(*trb); 203 dma = seg->dma + i * sizeof(*trb);
204 seq_printf(s, "%pad: %s\n", &dma, 204 seq_printf(s, "%pad: %s\n", &dma,
205 xhci_decode_trb(trb->generic.field[0], 205 xhci_decode_trb(le32_to_cpu(trb->generic.field[0]),
206 trb->generic.field[1], 206 le32_to_cpu(trb->generic.field[1]),
207 trb->generic.field[2], 207 le32_to_cpu(trb->generic.field[2]),
208 trb->generic.field[3])); 208 le32_to_cpu(trb->generic.field[3])));
209 } 209 }
210} 210}
211 211
@@ -263,10 +263,10 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused)
263 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus)); 263 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
264 slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx); 264 slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
265 seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma, 265 seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
266 xhci_decode_slot_context(slot_ctx->dev_info, 266 xhci_decode_slot_context(le32_to_cpu(slot_ctx->dev_info),
267 slot_ctx->dev_info2, 267 le32_to_cpu(slot_ctx->dev_info2),
268 slot_ctx->tt_info, 268 le32_to_cpu(slot_ctx->tt_info),
269 slot_ctx->dev_state)); 269 le32_to_cpu(slot_ctx->dev_state)));
270 270
271 return 0; 271 return 0;
272} 272}
@@ -286,10 +286,10 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
286 ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci); 286 ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci);
287 dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params); 287 dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params);
288 seq_printf(s, "%pad: %s\n", &dma, 288 seq_printf(s, "%pad: %s\n", &dma,
289 xhci_decode_ep_context(ep_ctx->ep_info, 289 xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info),
290 ep_ctx->ep_info2, 290 le32_to_cpu(ep_ctx->ep_info2),
291 ep_ctx->deq, 291 le64_to_cpu(ep_ctx->deq),
292 ep_ctx->tx_info)); 292 le32_to_cpu(ep_ctx->tx_info)));
293 } 293 }
294 294
295 return 0; 295 return 0;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 85ceb43e3405..e7aab31fd9a5 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3330,6 +3330,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3330 if (xhci_urb_suitable_for_idt(urb)) { 3330 if (xhci_urb_suitable_for_idt(urb)) {
3331 memcpy(&send_addr, urb->transfer_buffer, 3331 memcpy(&send_addr, urb->transfer_buffer,
3332 trb_buff_len); 3332 trb_buff_len);
3333 le64_to_cpus(&send_addr);
3333 field |= TRB_IDT; 3334 field |= TRB_IDT;
3334 } 3335 }
3335 } 3336 }
@@ -3475,6 +3476,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3475 if (xhci_urb_suitable_for_idt(urb)) { 3476 if (xhci_urb_suitable_for_idt(urb)) {
3476 memcpy(&addr, urb->transfer_buffer, 3477 memcpy(&addr, urb->transfer_buffer,
3477 urb->transfer_buffer_length); 3478 urb->transfer_buffer_length);
3479 le64_to_cpus(&addr);
3478 field |= TRB_IDT; 3480 field |= TRB_IDT;
3479 } else { 3481 } else {
3480 addr = (u64) urb->transfer_dma; 3482 addr = (u64) urb->transfer_dma;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 517ec3206f6e..6c17e3fe181a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3071,6 +3071,48 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int ep_index,
3071 } 3071 }
3072} 3072}
3073 3073
3074static void xhci_endpoint_disable(struct usb_hcd *hcd,
3075 struct usb_host_endpoint *host_ep)
3076{
3077 struct xhci_hcd *xhci;
3078 struct xhci_virt_device *vdev;
3079 struct xhci_virt_ep *ep;
3080 struct usb_device *udev;
3081 unsigned long flags;
3082 unsigned int ep_index;
3083
3084 xhci = hcd_to_xhci(hcd);
3085rescan:
3086 spin_lock_irqsave(&xhci->lock, flags);
3087
3088 udev = (struct usb_device *)host_ep->hcpriv;
3089 if (!udev || !udev->slot_id)
3090 goto done;
3091
3092 vdev = xhci->devs[udev->slot_id];
3093 if (!vdev)
3094 goto done;
3095
3096 ep_index = xhci_get_endpoint_index(&host_ep->desc);
3097 ep = &vdev->eps[ep_index];
3098 if (!ep)
3099 goto done;
3100
3101 /* wait for hub_tt_work to finish clearing hub TT */
3102 if (ep->ep_state & EP_CLEARING_TT) {
3103 spin_unlock_irqrestore(&xhci->lock, flags);
3104 schedule_timeout_uninterruptible(1);
3105 goto rescan;
3106 }
3107
3108 if (ep->ep_state)
3109 xhci_dbg(xhci, "endpoint disable with ep_state 0x%x\n",
3110 ep->ep_state);
3111done:
3112 host_ep->hcpriv = NULL;
3113 spin_unlock_irqrestore(&xhci->lock, flags);
3114}
3115
3074/* 3116/*
3075 * Called after usb core issues a clear halt control message. 3117 * Called after usb core issues a clear halt control message.
3076 * The host side of the halt should already be cleared by a reset endpoint 3118 * The host side of the halt should already be cleared by a reset endpoint
@@ -5238,20 +5280,13 @@ static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd,
5238 unsigned int ep_index; 5280 unsigned int ep_index;
5239 unsigned long flags; 5281 unsigned long flags;
5240 5282
5241 /*
5242 * udev might be NULL if tt buffer is cleared during a failed device
5243 * enumeration due to a halted control endpoint. Usb core might
5244 * have allocated a new udev for the next enumeration attempt.
5245 */
5246
5247 xhci = hcd_to_xhci(hcd); 5283 xhci = hcd_to_xhci(hcd);
5284
5285 spin_lock_irqsave(&xhci->lock, flags);
5248 udev = (struct usb_device *)ep->hcpriv; 5286 udev = (struct usb_device *)ep->hcpriv;
5249 if (!udev)
5250 return;
5251 slot_id = udev->slot_id; 5287 slot_id = udev->slot_id;
5252 ep_index = xhci_get_endpoint_index(&ep->desc); 5288 ep_index = xhci_get_endpoint_index(&ep->desc);
5253 5289
5254 spin_lock_irqsave(&xhci->lock, flags);
5255 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT; 5290 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT;
5256 xhci_ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 5291 xhci_ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
5257 spin_unlock_irqrestore(&xhci->lock, flags); 5292 spin_unlock_irqrestore(&xhci->lock, flags);
@@ -5288,6 +5323,7 @@ static const struct hc_driver xhci_hc_driver = {
5288 .free_streams = xhci_free_streams, 5323 .free_streams = xhci_free_streams,
5289 .add_endpoint = xhci_add_endpoint, 5324 .add_endpoint = xhci_add_endpoint,
5290 .drop_endpoint = xhci_drop_endpoint, 5325 .drop_endpoint = xhci_drop_endpoint,
5326 .endpoint_disable = xhci_endpoint_disable,
5291 .endpoint_reset = xhci_endpoint_reset, 5327 .endpoint_reset = xhci_endpoint_reset,
5292 .check_bandwidth = xhci_check_bandwidth, 5328 .check_bandwidth = xhci_check_bandwidth,
5293 .reset_bandwidth = xhci_reset_bandwidth, 5329 .reset_bandwidth = xhci_reset_bandwidth,
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 15b5f06fb0b3..8f86b4ebca89 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -487,7 +487,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
487 } 487 }
488 bytes_to_read = min(count, *actual_buffer); 488 bytes_to_read = min(count, *actual_buffer);
489 if (bytes_to_read < *actual_buffer) 489 if (bytes_to_read < *actual_buffer)
490 dev_warn(&dev->intf->dev, "Read buffer overflow, %zd bytes dropped\n", 490 dev_warn(&dev->intf->dev, "Read buffer overflow, %zu bytes dropped\n",
491 *actual_buffer-bytes_to_read); 491 *actual_buffer-bytes_to_read);
492 492
493 /* copy one interrupt_in_buffer from ring_buffer into userspace */ 493 /* copy one interrupt_in_buffer from ring_buffer into userspace */
@@ -495,11 +495,11 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
495 retval = -EFAULT; 495 retval = -EFAULT;
496 goto unlock_exit; 496 goto unlock_exit;
497 } 497 }
498 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
499
500 retval = bytes_to_read; 498 retval = bytes_to_read;
501 499
502 spin_lock_irq(&dev->rbsl); 500 spin_lock_irq(&dev->rbsl);
501 dev->ring_tail = (dev->ring_tail + 1) % ring_buffer_size;
502
503 if (dev->buffer_overflow) { 503 if (dev->buffer_overflow) {
504 dev->buffer_overflow = 0; 504 dev->buffer_overflow = 0;
505 spin_unlock_irq(&dev->rbsl); 505 spin_unlock_irq(&dev->rbsl);
@@ -562,8 +562,9 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
562 /* write the data into interrupt_out_buffer from userspace */ 562 /* write the data into interrupt_out_buffer from userspace */
563 bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); 563 bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size);
564 if (bytes_to_write < count) 564 if (bytes_to_write < count)
565 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n", count-bytes_to_write); 565 dev_warn(&dev->intf->dev, "Write buffer overflow, %zu bytes dropped\n",
566 dev_dbg(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", 566 count - bytes_to_write);
567 dev_dbg(&dev->intf->dev, "%s: count = %zu, bytes_to_write = %zu\n",
567 __func__, count, bytes_to_write); 568 __func__, count, bytes_to_write);
568 569
569 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { 570 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
@@ -580,7 +581,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
580 1 << 8, 0, 581 1 << 8, 0,
581 dev->interrupt_out_buffer, 582 dev->interrupt_out_buffer,
582 bytes_to_write, 583 bytes_to_write,
583 USB_CTRL_SET_TIMEOUT * HZ); 584 USB_CTRL_SET_TIMEOUT);
584 if (retval < 0) 585 if (retval < 0)
585 dev_err(&dev->intf->dev, 586 dev_err(&dev->intf->dev,
586 "Couldn't submit HID_REQ_SET_REPORT %d\n", 587 "Couldn't submit HID_REQ_SET_REPORT %d\n",
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index c3d5c1206eec..9dd02160cca9 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -16,6 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17 17
18#include "mtu3.h" 18#include "mtu3.h"
19#include "mtu3_dr.h"
19#include "mtu3_debug.h" 20#include "mtu3_debug.h"
20#include "mtu3_trace.h" 21#include "mtu3_trace.h"
21 22
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 4c3de777ef6c..a3c30b609433 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -162,17 +162,17 @@ void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
162 req->bRequest = (val >> 8) & 0xFF; 162 req->bRequest = (val >> 8) & 0xFF;
163 req->bRequestType = (val >> 0) & 0xFF; 163 req->bRequestType = (val >> 0) & 0xFF;
164 164
165 req->wValue = usbhs_read(priv, USBVAL); 165 req->wValue = cpu_to_le16(usbhs_read(priv, USBVAL));
166 req->wIndex = usbhs_read(priv, USBINDX); 166 req->wIndex = cpu_to_le16(usbhs_read(priv, USBINDX));
167 req->wLength = usbhs_read(priv, USBLENG); 167 req->wLength = cpu_to_le16(usbhs_read(priv, USBLENG));
168} 168}
169 169
170void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req) 170void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
171{ 171{
172 usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType); 172 usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType);
173 usbhs_write(priv, USBVAL, req->wValue); 173 usbhs_write(priv, USBVAL, le16_to_cpu(req->wValue));
174 usbhs_write(priv, USBINDX, req->wIndex); 174 usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex));
175 usbhs_write(priv, USBLENG, req->wLength); 175 usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength));
176 176
177 usbhs_bset(priv, DCPCTR, SUREQ, SUREQ); 177 usbhs_bset(priv, DCPCTR, SUREQ, SUREQ);
178} 178}
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index e5ef56991dba..cd38d74b3223 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -265,7 +265,7 @@ static int usbhsg_recip_handler_std_set_device(struct usbhs_priv *priv,
265 case USB_DEVICE_TEST_MODE: 265 case USB_DEVICE_TEST_MODE:
266 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); 266 usbhsg_recip_handler_std_control_done(priv, uep, ctrl);
267 udelay(100); 267 udelay(100);
268 usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex >> 8)); 268 usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex) >> 8);
269 break; 269 break;
270 default: 270 default:
271 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); 271 usbhsg_recip_handler_std_control_done(priv, uep, ctrl);
@@ -315,7 +315,7 @@ static void __usbhsg_recip_send_status(struct usbhsg_gpriv *gpriv,
315 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp); 315 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp);
316 struct device *dev = usbhsg_gpriv_to_dev(gpriv); 316 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
317 struct usb_request *req; 317 struct usb_request *req;
318 unsigned short *buf; 318 __le16 *buf;
319 319
320 /* alloc new usb_request for recip */ 320 /* alloc new usb_request for recip */
321 req = usb_ep_alloc_request(&dcp->ep, GFP_ATOMIC); 321 req = usb_ep_alloc_request(&dcp->ep, GFP_ATOMIC);
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 79314d8c94a4..ca3bd58f2025 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -559,6 +559,10 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
559 559
560 command_port = port->serial->port[COMMAND_PORT]; 560 command_port = port->serial->port[COMMAND_PORT];
561 command_info = usb_get_serial_port_data(command_port); 561 command_info = usb_get_serial_port_data(command_port);
562
563 if (command_port->bulk_out_size < datasize + 1)
564 return -EIO;
565
562 mutex_lock(&command_info->mutex); 566 mutex_lock(&command_info->mutex);
563 command_info->command_finished = false; 567 command_info->command_finished = false;
564 568
@@ -632,6 +636,7 @@ static void firm_setup_port(struct tty_struct *tty)
632 struct device *dev = &port->dev; 636 struct device *dev = &port->dev;
633 struct whiteheat_port_settings port_settings; 637 struct whiteheat_port_settings port_settings;
634 unsigned int cflag = tty->termios.c_cflag; 638 unsigned int cflag = tty->termios.c_cflag;
639 speed_t baud;
635 640
636 port_settings.port = port->port_number + 1; 641 port_settings.port = port->port_number + 1;
637 642
@@ -692,11 +697,13 @@ static void firm_setup_port(struct tty_struct *tty)
692 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff); 697 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
693 698
694 /* get the baud rate wanted */ 699 /* get the baud rate wanted */
695 port_settings.baud = tty_get_baud_rate(tty); 700 baud = tty_get_baud_rate(tty);
696 dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud); 701 port_settings.baud = cpu_to_le32(baud);
702 dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud);
697 703
698 /* fixme: should set validated settings */ 704 /* fixme: should set validated settings */
699 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); 705 tty_encode_baud_rate(tty, baud, baud);
706
700 /* handle any settings that aren't specified in the tty structure */ 707 /* handle any settings that aren't specified in the tty structure */
701 port_settings.lloop = 0; 708 port_settings.lloop = 0;
702 709
diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h
index 00398149cd8d..269e727a92f9 100644
--- a/drivers/usb/serial/whiteheat.h
+++ b/drivers/usb/serial/whiteheat.h
@@ -87,7 +87,7 @@ struct whiteheat_simple {
87 87
88struct whiteheat_port_settings { 88struct whiteheat_port_settings {
89 __u8 port; /* port number (1 to N) */ 89 __u8 port; /* port number (1 to N) */
90 __u32 baud; /* any value 7 - 460800, firmware calculates 90 __le32 baud; /* any value 7 - 460800, firmware calculates
91 best fit; arrives little endian */ 91 best fit; arrives little endian */
92 __u8 bits; /* 5, 6, 7, or 8 */ 92 __u8 bits; /* 5, 6, 7, or 8 */
93 __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */ 93 __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 6737fab94959..54a3c8195c96 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -68,7 +68,6 @@ static const char* host_info(struct Scsi_Host *host)
68static int slave_alloc (struct scsi_device *sdev) 68static int slave_alloc (struct scsi_device *sdev)
69{ 69{
70 struct us_data *us = host_to_us(sdev->host); 70 struct us_data *us = host_to_us(sdev->host);
71 int maxp;
72 71
73 /* 72 /*
74 * Set the INQUIRY transfer length to 36. We don't use any of 73 * Set the INQUIRY transfer length to 36. We don't use any of
@@ -78,15 +77,6 @@ static int slave_alloc (struct scsi_device *sdev)
78 sdev->inquiry_len = 36; 77 sdev->inquiry_len = 36;
79 78
80 /* 79 /*
81 * USB has unusual scatter-gather requirements: the length of each
82 * scatterlist element except the last must be divisible by the
83 * Bulk maxpacket value. Fortunately this value is always a
84 * power of 2. Inform the block layer about this requirement.
85 */
86 maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0);
87 blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
88
89 /*
90 * Some host controllers may have alignment requirements. 80 * Some host controllers may have alignment requirements.
91 * We'll play it safe by requiring 512-byte alignment always. 81 * We'll play it safe by requiring 512-byte alignment always.
92 */ 82 */
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index bf80d6f81f58..34538253f12c 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -789,30 +789,10 @@ static int uas_slave_alloc(struct scsi_device *sdev)
789{ 789{
790 struct uas_dev_info *devinfo = 790 struct uas_dev_info *devinfo =
791 (struct uas_dev_info *)sdev->host->hostdata; 791 (struct uas_dev_info *)sdev->host->hostdata;
792 int maxp;
793 792
794 sdev->hostdata = devinfo; 793 sdev->hostdata = devinfo;
795 794
796 /* 795 /*
797 * We have two requirements here. We must satisfy the requirements
798 * of the physical HC and the demands of the protocol, as we
799 * definitely want no additional memory allocation in this path
800 * ruling out using bounce buffers.
801 *
802 * For a transmission on USB to continue we must never send
803 * a package that is smaller than maxpacket. Hence the length of each
804 * scatterlist element except the last must be divisible by the
805 * Bulk maxpacket value.
806 * If the HC does not ensure that through SG,
807 * the upper layer must do that. We must assume nothing
808 * about the capabilities off the HC, so we use the most
809 * pessimistic requirement.
810 */
811
812 maxp = usb_maxpacket(devinfo->udev, devinfo->data_in_pipe, 0);
813 blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
814
815 /*
816 * The protocol has no requirements on alignment in the strict sense. 796 * The protocol has no requirements on alignment in the strict sense.
817 * Controllers may or may not have alignment restrictions. 797 * Controllers may or may not have alignment restrictions.
818 * As this is not exported, we use an extremely conservative guess. 798 * As this is not exported, we use an extremely conservative guess.
diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index c3803785f6ef..0ae40a13a9fe 100644
--- a/drivers/usb/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
@@ -147,7 +147,10 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
147 } 147 }
148 148
149 kfree(iov); 149 kfree(iov);
150 /* This is only for isochronous case */
150 kfree(iso_buffer); 151 kfree(iso_buffer);
152 iso_buffer = NULL;
153
151 usbip_dbg_vhci_tx("send txdata\n"); 154 usbip_dbg_vhci_tx("send txdata\n");
152 155
153 total_size += txsize; 156 total_size += txsize;
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 08ad0d1f0476..a0a2d74967ef 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len)
852 return 0; 852 return 0;
853} 853}
854 854
855static inline int kern_xfer(void *dst, void *src, size_t len)
856{
857 memcpy(dst, src, len);
858 return 0;
859}
860
855/** 861/**
856 * vringh_init_kern - initialize a vringh for a kernelspace vring. 862 * vringh_init_kern - initialize a vringh for a kernelspace vring.
857 * @vrh: the vringh to initialize. 863 * @vrh: the vringh to initialize.
@@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern);
958ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov, 964ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov,
959 const void *src, size_t len) 965 const void *src, size_t len)
960{ 966{
961 return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern); 967 return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer);
962} 968}
963EXPORT_SYMBOL(vringh_iov_push_kern); 969EXPORT_SYMBOL(vringh_iov_push_kern);
964 970
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index bdc08244a648..a8041e451e9e 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -1499,9 +1499,6 @@ static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq)
1499 * counter first before updating event flags. 1499 * counter first before updating event flags.
1500 */ 1500 */
1501 virtio_wmb(vq->weak_barriers); 1501 virtio_wmb(vq->weak_barriers);
1502 } else {
1503 used_idx = vq->last_used_idx;
1504 wrap_counter = vq->packed.used_wrap_counter;
1505 } 1502 }
1506 1503
1507 if (vq->packed.event_flags_shadow == VRING_PACKED_EVENT_FLAG_DISABLE) { 1504 if (vq->packed.event_flags_shadow == VRING_PACKED_EVENT_FLAG_DISABLE) {
@@ -1518,7 +1515,9 @@ static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq)
1518 */ 1515 */
1519 virtio_mb(vq->weak_barriers); 1516 virtio_mb(vq->weak_barriers);
1520 1517
1521 if (is_used_desc_packed(vq, used_idx, wrap_counter)) { 1518 if (is_used_desc_packed(vq,
1519 vq->last_used_idx,
1520 vq->packed.used_wrap_counter)) {
1522 END_USE(vq); 1521 END_USE(vq);
1523 return false; 1522 return false;
1524 } 1523 }
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 4c0922596467..cd55af9b7cc5 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -4084,6 +4084,7 @@ free_pages:
4084 4084
4085 kfree(dw->ppages); 4085 kfree(dw->ppages);
4086 cifs_small_buf_release(dw->buf); 4086 cifs_small_buf_release(dw->buf);
4087 kfree(dw);
4087} 4088}
4088 4089
4089 4090
@@ -4157,7 +4158,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
4157 dw->server = server; 4158 dw->server = server;
4158 dw->ppages = pages; 4159 dw->ppages = pages;
4159 dw->len = len; 4160 dw->len = len;
4160 queue_work(cifsiod_wq, &dw->decrypt); 4161 queue_work(decrypt_wq, &dw->decrypt);
4161 *num_mids = 0; /* worker thread takes care of finding mid */ 4162 *num_mids = 0; /* worker thread takes care of finding mid */
4162 return -1; 4163 return -1;
4163 } 4164 }
diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile
index 6419a2b3510d..3e8cebfb59b7 100644
--- a/fs/fuse/Makefile
+++ b/fs/fuse/Makefile
@@ -5,6 +5,7 @@
5 5
6obj-$(CONFIG_FUSE_FS) += fuse.o 6obj-$(CONFIG_FUSE_FS) += fuse.o
7obj-$(CONFIG_CUSE) += cuse.o 7obj-$(CONFIG_CUSE) += cuse.o
8obj-$(CONFIG_VIRTIO_FS) += virtio_fs.o 8obj-$(CONFIG_VIRTIO_FS) += virtiofs.o
9 9
10fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o 10fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o
11virtiofs-y += virtio_fs.o
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index dadd617d826c..ed1abc9e33cf 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -276,10 +276,12 @@ static void flush_bg_queue(struct fuse_conn *fc)
276void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req) 276void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req)
277{ 277{
278 struct fuse_iqueue *fiq = &fc->iq; 278 struct fuse_iqueue *fiq = &fc->iq;
279 bool async = req->args->end; 279 bool async;
280 280
281 if (test_and_set_bit(FR_FINISHED, &req->flags)) 281 if (test_and_set_bit(FR_FINISHED, &req->flags))
282 goto put_request; 282 goto put_request;
283
284 async = req->args->end;
283 /* 285 /*
284 * test_and_set_bit() implies smp_mb() between bit 286 * test_and_set_bit() implies smp_mb() between bit
285 * changing and below intr_entry check. Pairs with 287 * changing and below intr_entry check. Pairs with
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index d572c900bb0f..54d638f9ba1c 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -405,7 +405,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
405 else 405 else
406 fuse_invalidate_entry_cache(entry); 406 fuse_invalidate_entry_cache(entry);
407 407
408 fuse_advise_use_readdirplus(dir); 408 if (inode)
409 fuse_advise_use_readdirplus(dir);
409 return newent; 410 return newent;
410 411
411 out_iput: 412 out_iput:
@@ -1521,6 +1522,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1521 is_truncate = true; 1522 is_truncate = true;
1522 } 1523 }
1523 1524
1525 /* Flush dirty data/metadata before non-truncate SETATTR */
1526 if (is_wb && S_ISREG(inode->i_mode) &&
1527 attr->ia_valid &
1528 (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
1529 ATTR_TIMES_SET)) {
1530 err = write_inode_now(inode, true);
1531 if (err)
1532 return err;
1533
1534 fuse_set_nowrite(inode);
1535 fuse_release_nowrite(inode);
1536 }
1537
1524 if (is_truncate) { 1538 if (is_truncate) {
1525 fuse_set_nowrite(inode); 1539 fuse_set_nowrite(inode);
1526 set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); 1540 set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 0f0225686aee..db48a5cf8620 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -217,7 +217,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
217{ 217{
218 struct fuse_conn *fc = get_fuse_conn(inode); 218 struct fuse_conn *fc = get_fuse_conn(inode);
219 int err; 219 int err;
220 bool lock_inode = (file->f_flags & O_TRUNC) && 220 bool is_wb_truncate = (file->f_flags & O_TRUNC) &&
221 fc->atomic_o_trunc && 221 fc->atomic_o_trunc &&
222 fc->writeback_cache; 222 fc->writeback_cache;
223 223
@@ -225,16 +225,20 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
225 if (err) 225 if (err)
226 return err; 226 return err;
227 227
228 if (lock_inode) 228 if (is_wb_truncate) {
229 inode_lock(inode); 229 inode_lock(inode);
230 fuse_set_nowrite(inode);
231 }
230 232
231 err = fuse_do_open(fc, get_node_id(inode), file, isdir); 233 err = fuse_do_open(fc, get_node_id(inode), file, isdir);
232 234
233 if (!err) 235 if (!err)
234 fuse_finish_open(inode, file); 236 fuse_finish_open(inode, file);
235 237
236 if (lock_inode) 238 if (is_wb_truncate) {
239 fuse_release_nowrite(inode);
237 inode_unlock(inode); 240 inode_unlock(inode);
241 }
238 242
239 return err; 243 return err;
240} 244}
@@ -1997,7 +2001,7 @@ static int fuse_writepages_fill(struct page *page,
1997 2001
1998 if (!data->ff) { 2002 if (!data->ff) {
1999 err = -EIO; 2003 err = -EIO;
2000 data->ff = fuse_write_file_get(fc, get_fuse_inode(inode)); 2004 data->ff = fuse_write_file_get(fc, fi);
2001 if (!data->ff) 2005 if (!data->ff)
2002 goto out_unlock; 2006 goto out_unlock;
2003 } 2007 }
@@ -2042,8 +2046,6 @@ static int fuse_writepages_fill(struct page *page,
2042 * under writeback, so we can release the page lock. 2046 * under writeback, so we can release the page lock.
2043 */ 2047 */
2044 if (data->wpa == NULL) { 2048 if (data->wpa == NULL) {
2045 struct fuse_inode *fi = get_fuse_inode(inode);
2046
2047 err = -ENOMEM; 2049 err = -ENOMEM;
2048 wpa = fuse_writepage_args_alloc(); 2050 wpa = fuse_writepage_args_alloc();
2049 if (!wpa) { 2051 if (!wpa) {
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 956aeaf961ae..d148188cfca4 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -479,6 +479,7 @@ struct fuse_fs_context {
479 bool destroy:1; 479 bool destroy:1;
480 bool no_control:1; 480 bool no_control:1;
481 bool no_force_umount:1; 481 bool no_force_umount:1;
482 bool no_mount_options:1;
482 unsigned int max_read; 483 unsigned int max_read;
483 unsigned int blksize; 484 unsigned int blksize;
484 const char *subtype; 485 const char *subtype;
@@ -713,6 +714,9 @@ struct fuse_conn {
713 /** Do not allow MNT_FORCE umount */ 714 /** Do not allow MNT_FORCE umount */
714 unsigned int no_force_umount:1; 715 unsigned int no_force_umount:1;
715 716
717 /* Do not show mount options */
718 unsigned int no_mount_options:1;
719
716 /** The number of requests waiting for completion */ 720 /** The number of requests waiting for completion */
717 atomic_t num_waiting; 721 atomic_t num_waiting;
718 722
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index e040e2a2b621..16aec32f7f3d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -558,6 +558,9 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
558 struct super_block *sb = root->d_sb; 558 struct super_block *sb = root->d_sb;
559 struct fuse_conn *fc = get_fuse_conn_super(sb); 559 struct fuse_conn *fc = get_fuse_conn_super(sb);
560 560
561 if (fc->no_mount_options)
562 return 0;
563
561 seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id)); 564 seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id));
562 seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id)); 565 seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id));
563 if (fc->default_permissions) 566 if (fc->default_permissions)
@@ -1180,6 +1183,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
1180 fc->destroy = ctx->destroy; 1183 fc->destroy = ctx->destroy;
1181 fc->no_control = ctx->no_control; 1184 fc->no_control = ctx->no_control;
1182 fc->no_force_umount = ctx->no_force_umount; 1185 fc->no_force_umount = ctx->no_force_umount;
1186 fc->no_mount_options = ctx->no_mount_options;
1183 1187
1184 err = -ENOMEM; 1188 err = -ENOMEM;
1185 root = fuse_get_root_inode(sb, ctx->rootmode); 1189 root = fuse_get_root_inode(sb, ctx->rootmode);
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 6af3f131e468..a5c86048b96e 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -30,6 +30,7 @@ struct virtio_fs_vq {
30 struct virtqueue *vq; /* protected by ->lock */ 30 struct virtqueue *vq; /* protected by ->lock */
31 struct work_struct done_work; 31 struct work_struct done_work;
32 struct list_head queued_reqs; 32 struct list_head queued_reqs;
33 struct list_head end_reqs; /* End these requests */
33 struct delayed_work dispatch_work; 34 struct delayed_work dispatch_work;
34 struct fuse_dev *fud; 35 struct fuse_dev *fud;
35 bool connected; 36 bool connected;
@@ -54,6 +55,9 @@ struct virtio_fs_forget {
54 struct list_head list; 55 struct list_head list;
55}; 56};
56 57
58static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
59 struct fuse_req *req, bool in_flight);
60
57static inline struct virtio_fs_vq *vq_to_fsvq(struct virtqueue *vq) 61static inline struct virtio_fs_vq *vq_to_fsvq(struct virtqueue *vq)
58{ 62{
59 struct virtio_fs *fs = vq->vdev->priv; 63 struct virtio_fs *fs = vq->vdev->priv;
@@ -66,6 +70,19 @@ static inline struct fuse_pqueue *vq_to_fpq(struct virtqueue *vq)
66 return &vq_to_fsvq(vq)->fud->pq; 70 return &vq_to_fsvq(vq)->fud->pq;
67} 71}
68 72
73/* Should be called with fsvq->lock held. */
74static inline void inc_in_flight_req(struct virtio_fs_vq *fsvq)
75{
76 fsvq->in_flight++;
77}
78
79/* Should be called with fsvq->lock held. */
80static inline void dec_in_flight_req(struct virtio_fs_vq *fsvq)
81{
82 WARN_ON(fsvq->in_flight <= 0);
83 fsvq->in_flight--;
84}
85
69static void release_virtio_fs_obj(struct kref *ref) 86static void release_virtio_fs_obj(struct kref *ref)
70{ 87{
71 struct virtio_fs *vfs = container_of(ref, struct virtio_fs, refcount); 88 struct virtio_fs *vfs = container_of(ref, struct virtio_fs, refcount);
@@ -109,22 +126,6 @@ static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq)
109 flush_delayed_work(&fsvq->dispatch_work); 126 flush_delayed_work(&fsvq->dispatch_work);
110} 127}
111 128
112static inline void drain_hiprio_queued_reqs(struct virtio_fs_vq *fsvq)
113{
114 struct virtio_fs_forget *forget;
115
116 spin_lock(&fsvq->lock);
117 while (1) {
118 forget = list_first_entry_or_null(&fsvq->queued_reqs,
119 struct virtio_fs_forget, list);
120 if (!forget)
121 break;
122 list_del(&forget->list);
123 kfree(forget);
124 }
125 spin_unlock(&fsvq->lock);
126}
127
128static void virtio_fs_drain_all_queues(struct virtio_fs *fs) 129static void virtio_fs_drain_all_queues(struct virtio_fs *fs)
129{ 130{
130 struct virtio_fs_vq *fsvq; 131 struct virtio_fs_vq *fsvq;
@@ -132,9 +133,6 @@ static void virtio_fs_drain_all_queues(struct virtio_fs *fs)
132 133
133 for (i = 0; i < fs->nvqs; i++) { 134 for (i = 0; i < fs->nvqs; i++) {
134 fsvq = &fs->vqs[i]; 135 fsvq = &fs->vqs[i];
135 if (i == VQ_HIPRIO)
136 drain_hiprio_queued_reqs(fsvq);
137
138 virtio_fs_drain_queue(fsvq); 136 virtio_fs_drain_queue(fsvq);
139 } 137 }
140} 138}
@@ -253,14 +251,66 @@ static void virtio_fs_hiprio_done_work(struct work_struct *work)
253 251
254 while ((req = virtqueue_get_buf(vq, &len)) != NULL) { 252 while ((req = virtqueue_get_buf(vq, &len)) != NULL) {
255 kfree(req); 253 kfree(req);
256 fsvq->in_flight--; 254 dec_in_flight_req(fsvq);
257 } 255 }
258 } while (!virtqueue_enable_cb(vq) && likely(!virtqueue_is_broken(vq))); 256 } while (!virtqueue_enable_cb(vq) && likely(!virtqueue_is_broken(vq)));
259 spin_unlock(&fsvq->lock); 257 spin_unlock(&fsvq->lock);
260} 258}
261 259
262static void virtio_fs_dummy_dispatch_work(struct work_struct *work) 260static void virtio_fs_request_dispatch_work(struct work_struct *work)
263{ 261{
262 struct fuse_req *req;
263 struct virtio_fs_vq *fsvq = container_of(work, struct virtio_fs_vq,
264 dispatch_work.work);
265 struct fuse_conn *fc = fsvq->fud->fc;
266 int ret;
267
268 pr_debug("virtio-fs: worker %s called.\n", __func__);
269 while (1) {
270 spin_lock(&fsvq->lock);
271 req = list_first_entry_or_null(&fsvq->end_reqs, struct fuse_req,
272 list);
273 if (!req) {
274 spin_unlock(&fsvq->lock);
275 break;
276 }
277
278 list_del_init(&req->list);
279 spin_unlock(&fsvq->lock);
280 fuse_request_end(fc, req);
281 }
282
283 /* Dispatch pending requests */
284 while (1) {
285 spin_lock(&fsvq->lock);
286 req = list_first_entry_or_null(&fsvq->queued_reqs,
287 struct fuse_req, list);
288 if (!req) {
289 spin_unlock(&fsvq->lock);
290 return;
291 }
292 list_del_init(&req->list);
293 spin_unlock(&fsvq->lock);
294
295 ret = virtio_fs_enqueue_req(fsvq, req, true);
296 if (ret < 0) {
297 if (ret == -ENOMEM || ret == -ENOSPC) {
298 spin_lock(&fsvq->lock);
299 list_add_tail(&req->list, &fsvq->queued_reqs);
300 schedule_delayed_work(&fsvq->dispatch_work,
301 msecs_to_jiffies(1));
302 spin_unlock(&fsvq->lock);
303 return;
304 }
305 req->out.h.error = ret;
306 spin_lock(&fsvq->lock);
307 dec_in_flight_req(fsvq);
308 spin_unlock(&fsvq->lock);
309 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n",
310 ret);
311 fuse_request_end(fc, req);
312 }
313 }
264} 314}
265 315
266static void virtio_fs_hiprio_dispatch_work(struct work_struct *work) 316static void virtio_fs_hiprio_dispatch_work(struct work_struct *work)
@@ -286,6 +336,7 @@ static void virtio_fs_hiprio_dispatch_work(struct work_struct *work)
286 336
287 list_del(&forget->list); 337 list_del(&forget->list);
288 if (!fsvq->connected) { 338 if (!fsvq->connected) {
339 dec_in_flight_req(fsvq);
289 spin_unlock(&fsvq->lock); 340 spin_unlock(&fsvq->lock);
290 kfree(forget); 341 kfree(forget);
291 continue; 342 continue;
@@ -307,13 +358,13 @@ static void virtio_fs_hiprio_dispatch_work(struct work_struct *work)
307 } else { 358 } else {
308 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", 359 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n",
309 ret); 360 ret);
361 dec_in_flight_req(fsvq);
310 kfree(forget); 362 kfree(forget);
311 } 363 }
312 spin_unlock(&fsvq->lock); 364 spin_unlock(&fsvq->lock);
313 return; 365 return;
314 } 366 }
315 367
316 fsvq->in_flight++;
317 notify = virtqueue_kick_prepare(vq); 368 notify = virtqueue_kick_prepare(vq);
318 spin_unlock(&fsvq->lock); 369 spin_unlock(&fsvq->lock);
319 370
@@ -452,7 +503,7 @@ static void virtio_fs_requests_done_work(struct work_struct *work)
452 503
453 fuse_request_end(fc, req); 504 fuse_request_end(fc, req);
454 spin_lock(&fsvq->lock); 505 spin_lock(&fsvq->lock);
455 fsvq->in_flight--; 506 dec_in_flight_req(fsvq);
456 spin_unlock(&fsvq->lock); 507 spin_unlock(&fsvq->lock);
457 } 508 }
458} 509}
@@ -502,6 +553,7 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
502 names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name; 553 names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name;
503 INIT_WORK(&fs->vqs[VQ_HIPRIO].done_work, virtio_fs_hiprio_done_work); 554 INIT_WORK(&fs->vqs[VQ_HIPRIO].done_work, virtio_fs_hiprio_done_work);
504 INIT_LIST_HEAD(&fs->vqs[VQ_HIPRIO].queued_reqs); 555 INIT_LIST_HEAD(&fs->vqs[VQ_HIPRIO].queued_reqs);
556 INIT_LIST_HEAD(&fs->vqs[VQ_HIPRIO].end_reqs);
505 INIT_DELAYED_WORK(&fs->vqs[VQ_HIPRIO].dispatch_work, 557 INIT_DELAYED_WORK(&fs->vqs[VQ_HIPRIO].dispatch_work,
506 virtio_fs_hiprio_dispatch_work); 558 virtio_fs_hiprio_dispatch_work);
507 spin_lock_init(&fs->vqs[VQ_HIPRIO].lock); 559 spin_lock_init(&fs->vqs[VQ_HIPRIO].lock);
@@ -511,8 +563,9 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
511 spin_lock_init(&fs->vqs[i].lock); 563 spin_lock_init(&fs->vqs[i].lock);
512 INIT_WORK(&fs->vqs[i].done_work, virtio_fs_requests_done_work); 564 INIT_WORK(&fs->vqs[i].done_work, virtio_fs_requests_done_work);
513 INIT_DELAYED_WORK(&fs->vqs[i].dispatch_work, 565 INIT_DELAYED_WORK(&fs->vqs[i].dispatch_work,
514 virtio_fs_dummy_dispatch_work); 566 virtio_fs_request_dispatch_work);
515 INIT_LIST_HEAD(&fs->vqs[i].queued_reqs); 567 INIT_LIST_HEAD(&fs->vqs[i].queued_reqs);
568 INIT_LIST_HEAD(&fs->vqs[i].end_reqs);
516 snprintf(fs->vqs[i].name, sizeof(fs->vqs[i].name), 569 snprintf(fs->vqs[i].name, sizeof(fs->vqs[i].name),
517 "requests.%u", i - VQ_REQUEST); 570 "requests.%u", i - VQ_REQUEST);
518 callbacks[i] = virtio_fs_vq_done; 571 callbacks[i] = virtio_fs_vq_done;
@@ -708,6 +761,7 @@ __releases(fiq->lock)
708 list_add_tail(&forget->list, &fsvq->queued_reqs); 761 list_add_tail(&forget->list, &fsvq->queued_reqs);
709 schedule_delayed_work(&fsvq->dispatch_work, 762 schedule_delayed_work(&fsvq->dispatch_work,
710 msecs_to_jiffies(1)); 763 msecs_to_jiffies(1));
764 inc_in_flight_req(fsvq);
711 } else { 765 } else {
712 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", 766 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n",
713 ret); 767 ret);
@@ -717,7 +771,7 @@ __releases(fiq->lock)
717 goto out; 771 goto out;
718 } 772 }
719 773
720 fsvq->in_flight++; 774 inc_in_flight_req(fsvq);
721 notify = virtqueue_kick_prepare(vq); 775 notify = virtqueue_kick_prepare(vq);
722 776
723 spin_unlock(&fsvq->lock); 777 spin_unlock(&fsvq->lock);
@@ -819,7 +873,7 @@ static unsigned int sg_init_fuse_args(struct scatterlist *sg,
819 873
820/* Add a request to a virtqueue and kick the device */ 874/* Add a request to a virtqueue and kick the device */
821static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, 875static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
822 struct fuse_req *req) 876 struct fuse_req *req, bool in_flight)
823{ 877{
824 /* requests need at least 4 elements */ 878 /* requests need at least 4 elements */
825 struct scatterlist *stack_sgs[6]; 879 struct scatterlist *stack_sgs[6];
@@ -835,6 +889,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
835 unsigned int i; 889 unsigned int i;
836 int ret; 890 int ret;
837 bool notify; 891 bool notify;
892 struct fuse_pqueue *fpq;
838 893
839 /* Does the sglist fit on the stack? */ 894 /* Does the sglist fit on the stack? */
840 total_sgs = sg_count_fuse_req(req); 895 total_sgs = sg_count_fuse_req(req);
@@ -889,7 +944,17 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
889 goto out; 944 goto out;
890 } 945 }
891 946
892 fsvq->in_flight++; 947 /* Request successfully sent. */
948 fpq = &fsvq->fud->pq;
949 spin_lock(&fpq->lock);
950 list_add_tail(&req->list, fpq->processing);
951 spin_unlock(&fpq->lock);
952 set_bit(FR_SENT, &req->flags);
953 /* matches barrier in request_wait_answer() */
954 smp_mb__after_atomic();
955
956 if (!in_flight)
957 inc_in_flight_req(fsvq);
893 notify = virtqueue_kick_prepare(vq); 958 notify = virtqueue_kick_prepare(vq);
894 959
895 spin_unlock(&fsvq->lock); 960 spin_unlock(&fsvq->lock);
@@ -915,9 +980,8 @@ __releases(fiq->lock)
915{ 980{
916 unsigned int queue_id = VQ_REQUEST; /* TODO multiqueue */ 981 unsigned int queue_id = VQ_REQUEST; /* TODO multiqueue */
917 struct virtio_fs *fs; 982 struct virtio_fs *fs;
918 struct fuse_conn *fc;
919 struct fuse_req *req; 983 struct fuse_req *req;
920 struct fuse_pqueue *fpq; 984 struct virtio_fs_vq *fsvq;
921 int ret; 985 int ret;
922 986
923 WARN_ON(list_empty(&fiq->pending)); 987 WARN_ON(list_empty(&fiq->pending));
@@ -928,44 +992,36 @@ __releases(fiq->lock)
928 spin_unlock(&fiq->lock); 992 spin_unlock(&fiq->lock);
929 993
930 fs = fiq->priv; 994 fs = fiq->priv;
931 fc = fs->vqs[queue_id].fud->fc;
932 995
933 pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u\n", 996 pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u\n",
934 __func__, req->in.h.opcode, req->in.h.unique, 997 __func__, req->in.h.opcode, req->in.h.unique,
935 req->in.h.nodeid, req->in.h.len, 998 req->in.h.nodeid, req->in.h.len,
936 fuse_len_args(req->args->out_numargs, req->args->out_args)); 999 fuse_len_args(req->args->out_numargs, req->args->out_args));
937 1000
938 fpq = &fs->vqs[queue_id].fud->pq; 1001 fsvq = &fs->vqs[queue_id];
939 spin_lock(&fpq->lock); 1002 ret = virtio_fs_enqueue_req(fsvq, req, false);
940 if (!fpq->connected) {
941 spin_unlock(&fpq->lock);
942 req->out.h.error = -ENODEV;
943 pr_err("virtio-fs: %s disconnected\n", __func__);
944 fuse_request_end(fc, req);
945 return;
946 }
947 list_add_tail(&req->list, fpq->processing);
948 spin_unlock(&fpq->lock);
949 set_bit(FR_SENT, &req->flags);
950 /* matches barrier in request_wait_answer() */
951 smp_mb__after_atomic();
952
953retry:
954 ret = virtio_fs_enqueue_req(&fs->vqs[queue_id], req);
955 if (ret < 0) { 1003 if (ret < 0) {
956 if (ret == -ENOMEM || ret == -ENOSPC) { 1004 if (ret == -ENOMEM || ret == -ENOSPC) {
957 /* Virtqueue full. Retry submission */ 1005 /*
958 /* TODO use completion instead of timeout */ 1006 * Virtqueue full. Retry submission from worker
959 usleep_range(20, 30); 1007 * context as we might be holding fc->bg_lock.
960 goto retry; 1008 */
1009 spin_lock(&fsvq->lock);
1010 list_add_tail(&req->list, &fsvq->queued_reqs);
1011 inc_in_flight_req(fsvq);
1012 schedule_delayed_work(&fsvq->dispatch_work,
1013 msecs_to_jiffies(1));
1014 spin_unlock(&fsvq->lock);
1015 return;
961 } 1016 }
962 req->out.h.error = ret; 1017 req->out.h.error = ret;
963 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret); 1018 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret);
964 spin_lock(&fpq->lock); 1019
965 clear_bit(FR_SENT, &req->flags); 1020 /* Can't end request in submission context. Use a worker */
966 list_del_init(&req->list); 1021 spin_lock(&fsvq->lock);
967 spin_unlock(&fpq->lock); 1022 list_add_tail(&req->list, &fsvq->end_reqs);
968 fuse_request_end(fc, req); 1023 schedule_delayed_work(&fsvq->dispatch_work, 0);
1024 spin_unlock(&fsvq->lock);
969 return; 1025 return;
970 } 1026 }
971} 1027}
@@ -992,6 +1048,7 @@ static int virtio_fs_fill_super(struct super_block *sb)
992 .destroy = true, 1048 .destroy = true,
993 .no_control = true, 1049 .no_control = true,
994 .no_force_umount = true, 1050 .no_force_umount = true,
1051 .no_mount_options = true,
995 }; 1052 };
996 1053
997 mutex_lock(&virtio_fs_mutex); 1054 mutex_lock(&virtio_fs_mutex);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index dc61af2c4d5e..18daf494abab 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1540,17 +1540,23 @@ static int gfs2_init_fs_context(struct fs_context *fc)
1540{ 1540{
1541 struct gfs2_args *args; 1541 struct gfs2_args *args;
1542 1542
1543 args = kzalloc(sizeof(*args), GFP_KERNEL); 1543 args = kmalloc(sizeof(*args), GFP_KERNEL);
1544 if (args == NULL) 1544 if (args == NULL)
1545 return -ENOMEM; 1545 return -ENOMEM;
1546 1546
1547 args->ar_quota = GFS2_QUOTA_DEFAULT; 1547 if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
1548 args->ar_data = GFS2_DATA_DEFAULT; 1548 struct gfs2_sbd *sdp = fc->root->d_sb->s_fs_info;
1549 args->ar_commit = 30;
1550 args->ar_statfs_quantum = 30;
1551 args->ar_quota_quantum = 60;
1552 args->ar_errors = GFS2_ERRORS_DEFAULT;
1553 1549
1550 *args = sdp->sd_args;
1551 } else {
1552 memset(args, 0, sizeof(*args));
1553 args->ar_quota = GFS2_QUOTA_DEFAULT;
1554 args->ar_data = GFS2_DATA_DEFAULT;
1555 args->ar_commit = 30;
1556 args->ar_statfs_quantum = 30;
1557 args->ar_quota_quantum = 60;
1558 args->ar_errors = GFS2_ERRORS_DEFAULT;
1559 }
1554 fc->fs_private = args; 1560 fc->fs_private = args;
1555 fc->ops = &gfs2_context_ops; 1561 fc->ops = &gfs2_context_ops;
1556 return 0; 1562 return 0;
diff --git a/fs/io_uring.c b/fs/io_uring.c
index a30c4f622cb3..f9a38998f2fc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1124,6 +1124,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
1124 1124
1125 kiocb->ki_flags |= IOCB_HIPRI; 1125 kiocb->ki_flags |= IOCB_HIPRI;
1126 kiocb->ki_complete = io_complete_rw_iopoll; 1126 kiocb->ki_complete = io_complete_rw_iopoll;
1127 req->result = 0;
1127 } else { 1128 } else {
1128 if (kiocb->ki_flags & IOCB_HIPRI) 1129 if (kiocb->ki_flags & IOCB_HIPRI)
1129 return -EINVAL; 1130 return -EINVAL;
@@ -2413,6 +2414,7 @@ static int io_queue_link_head(struct io_ring_ctx *ctx, struct io_kiocb *req,
2413 if (ret) { 2414 if (ret) {
2414 if (ret != -EIOCBQUEUED) { 2415 if (ret != -EIOCBQUEUED) {
2415 io_free_req(req); 2416 io_free_req(req);
2417 __io_free_req(shadow);
2416 io_cqring_add_event(ctx, s->sqe->user_data, ret); 2418 io_cqring_add_event(ctx, s->sqe->user_data, ret);
2417 return 0; 2419 return 0;
2418 } 2420 }
@@ -3828,10 +3830,6 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
3828 if (ret) 3830 if (ret)
3829 goto err; 3831 goto err;
3830 3832
3831 ret = io_uring_get_fd(ctx);
3832 if (ret < 0)
3833 goto err;
3834
3835 memset(&p->sq_off, 0, sizeof(p->sq_off)); 3833 memset(&p->sq_off, 0, sizeof(p->sq_off));
3836 p->sq_off.head = offsetof(struct io_rings, sq.head); 3834 p->sq_off.head = offsetof(struct io_rings, sq.head);
3837 p->sq_off.tail = offsetof(struct io_rings, sq.tail); 3835 p->sq_off.tail = offsetof(struct io_rings, sq.tail);
@@ -3849,6 +3847,14 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
3849 p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); 3847 p->cq_off.overflow = offsetof(struct io_rings, cq_overflow);
3850 p->cq_off.cqes = offsetof(struct io_rings, cqes); 3848 p->cq_off.cqes = offsetof(struct io_rings, cqes);
3851 3849
3850 /*
3851 * Install ring fd as the very last thing, so we don't risk someone
3852 * having closed it before we finish setup
3853 */
3854 ret = io_uring_get_fd(ctx);
3855 if (ret < 0)
3856 goto err;
3857
3852 p->features = IORING_FEAT_SINGLE_MMAP; 3858 p->features = IORING_FEAT_SINGLE_MMAP;
3853 return ret; 3859 return ret;
3854err: 3860err:
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 071b90a45933..af549d70ec50 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -53,6 +53,16 @@ nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
53 return false; 53 return false;
54} 54}
55 55
56struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode)
57{
58 struct nfs_delegation *delegation;
59
60 delegation = rcu_dereference(NFS_I(inode)->delegation);
61 if (nfs4_is_valid_delegation(delegation, 0))
62 return delegation;
63 return NULL;
64}
65
56static int 66static int
57nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) 67nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark)
58{ 68{
@@ -1181,7 +1191,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode)
1181 if (delegation != NULL && 1191 if (delegation != NULL &&
1182 nfs4_stateid_match_other(dst, &delegation->stateid)) { 1192 nfs4_stateid_match_other(dst, &delegation->stateid)) {
1183 dst->seqid = delegation->stateid.seqid; 1193 dst->seqid = delegation->stateid.seqid;
1184 return ret; 1194 ret = true;
1185 } 1195 }
1186 rcu_read_unlock(); 1196 rcu_read_unlock();
1187out: 1197out:
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 9eb87ae4c982..8b14d441e699 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -68,6 +68,7 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state,
68bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); 68bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred);
69bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); 69bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
70 70
71struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode);
71void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); 72void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
72int nfs4_have_delegation(struct inode *inode, fmode_t flags); 73int nfs4_have_delegation(struct inode *inode, fmode_t flags);
73int nfs4_check_delegation(struct inode *inode, fmode_t flags); 74int nfs4_check_delegation(struct inode *inode, fmode_t flags);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ab8ca20fd579..caacf5e7f5e1 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1440,8 +1440,6 @@ static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode,
1440 return 0; 1440 return 0;
1441 if ((delegation->type & fmode) != fmode) 1441 if ((delegation->type & fmode) != fmode)
1442 return 0; 1442 return 0;
1443 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
1444 return 0;
1445 switch (claim) { 1443 switch (claim) {
1446 case NFS4_OPEN_CLAIM_NULL: 1444 case NFS4_OPEN_CLAIM_NULL:
1447 case NFS4_OPEN_CLAIM_FH: 1445 case NFS4_OPEN_CLAIM_FH:
@@ -1810,7 +1808,6 @@ static void nfs4_return_incompatible_delegation(struct inode *inode, fmode_t fmo
1810static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) 1808static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
1811{ 1809{
1812 struct nfs4_state *state = opendata->state; 1810 struct nfs4_state *state = opendata->state;
1813 struct nfs_inode *nfsi = NFS_I(state->inode);
1814 struct nfs_delegation *delegation; 1811 struct nfs_delegation *delegation;
1815 int open_mode = opendata->o_arg.open_flags; 1812 int open_mode = opendata->o_arg.open_flags;
1816 fmode_t fmode = opendata->o_arg.fmode; 1813 fmode_t fmode = opendata->o_arg.fmode;
@@ -1827,7 +1824,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
1827 } 1824 }
1828 spin_unlock(&state->owner->so_lock); 1825 spin_unlock(&state->owner->so_lock);
1829 rcu_read_lock(); 1826 rcu_read_lock();
1830 delegation = rcu_dereference(nfsi->delegation); 1827 delegation = nfs4_get_valid_delegation(state->inode);
1831 if (!can_open_delegated(delegation, fmode, claim)) { 1828 if (!can_open_delegated(delegation, fmode, claim)) {
1832 rcu_read_unlock(); 1829 rcu_read_unlock();
1833 break; 1830 break;
@@ -2371,7 +2368,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
2371 data->o_arg.open_flags, claim)) 2368 data->o_arg.open_flags, claim))
2372 goto out_no_action; 2369 goto out_no_action;
2373 rcu_read_lock(); 2370 rcu_read_lock();
2374 delegation = rcu_dereference(NFS_I(data->state->inode)->delegation); 2371 delegation = nfs4_get_valid_delegation(data->state->inode);
2375 if (can_open_delegated(delegation, data->o_arg.fmode, claim)) 2372 if (can_open_delegated(delegation, data->o_arg.fmode, claim))
2376 goto unlock_no_action; 2373 goto unlock_no_action;
2377 rcu_read_unlock(); 2374 rcu_read_unlock();
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 6c809440f319..4cf02ecd67de 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -204,6 +204,12 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
204 do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) 204 do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
205#define dynamic_dev_dbg(dev, fmt, ...) \ 205#define dynamic_dev_dbg(dev, fmt, ...) \
206 do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) 206 do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
207#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
208 groupsize, buf, len, ascii) \
209 do { if (0) \
210 print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \
211 rowsize, groupsize, buf, len, ascii); \
212 } while (0)
207#endif 213#endif
208 214
209#endif 215#endif
diff --git a/include/linux/efi.h b/include/linux/efi.h
index bd3837022307..d87acf62958e 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1579,9 +1579,22 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
1579efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, 1579efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
1580 struct efi_boot_memmap *map); 1580 struct efi_boot_memmap *map);
1581 1581
1582efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg,
1583 unsigned long size, unsigned long align,
1584 unsigned long *addr, unsigned long min);
1585
1586static inline
1582efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, 1587efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
1583 unsigned long size, unsigned long align, 1588 unsigned long size, unsigned long align,
1584 unsigned long *addr); 1589 unsigned long *addr)
1590{
1591 /*
1592 * Don't allocate at 0x0. It will confuse code that
1593 * checks pointers against NULL. Skip the first 8
1594 * bytes so we start at a nice even number.
1595 */
1596 return efi_low_alloc_above(sys_table_arg, size, align, addr, 0x8);
1597}
1585 1598
1586efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, 1599efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
1587 unsigned long size, unsigned long align, 1600 unsigned long size, unsigned long align,
@@ -1592,7 +1605,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
1592 unsigned long image_size, 1605 unsigned long image_size,
1593 unsigned long alloc_size, 1606 unsigned long alloc_size,
1594 unsigned long preferred_addr, 1607 unsigned long preferred_addr,
1595 unsigned long alignment); 1608 unsigned long alignment,
1609 unsigned long min_addr);
1596 1610
1597efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, 1611efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
1598 efi_loaded_image_t *image, 1612 efi_loaded_image_t *image,
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 2ce57645f3cd..0367a75f873b 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1099,7 +1099,6 @@ static inline void bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
1099 1099
1100#endif /* CONFIG_BPF_JIT */ 1100#endif /* CONFIG_BPF_JIT */
1101 1101
1102void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp);
1103void bpf_prog_kallsyms_del_all(struct bpf_prog *fp); 1102void bpf_prog_kallsyms_del_all(struct bpf_prog *fp);
1104 1103
1105#define BPF_ANC BIT(15) 1104#define BPF_ANC BIT(15)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index fb07b503dc45..61f2f6ff9467 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -325,6 +325,29 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
325 return !!(gfp_flags & __GFP_DIRECT_RECLAIM); 325 return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
326} 326}
327 327
328/**
329 * gfpflags_normal_context - is gfp_flags a normal sleepable context?
330 * @gfp_flags: gfp_flags to test
331 *
332 * Test whether @gfp_flags indicates that the allocation is from the
333 * %current context and allowed to sleep.
334 *
335 * An allocation being allowed to block doesn't mean it owns the %current
336 * context. When direct reclaim path tries to allocate memory, the
337 * allocation context is nested inside whatever %current was doing at the
338 * time of the original allocation. The nested allocation may be allowed
339 * to block but modifying anything %current owns can corrupt the outer
340 * context's expectations.
341 *
342 * %true result from this function indicates that the allocation context
343 * can sleep and use anything that's associated with %current.
344 */
345static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
346{
347 return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
348 __GFP_DIRECT_RECLAIM;
349}
350
328#ifdef CONFIG_HIGHMEM 351#ifdef CONFIG_HIGHMEM
329#define OPT_ZONE_HIGHMEM ZONE_HIGHMEM 352#define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
330#else 353#else
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index 2e55e4cdbd8a..a367ead4bf4b 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -29,7 +29,6 @@ struct macvlan_dev {
29 netdev_features_t set_features; 29 netdev_features_t set_features;
30 enum macvlan_mode mode; 30 enum macvlan_mode mode;
31 u16 flags; 31 u16 flags;
32 int nest_level;
33 unsigned int macaddr_count; 32 unsigned int macaddr_count;
34#ifdef CONFIG_NET_POLL_CONTROLLER 33#ifdef CONFIG_NET_POLL_CONTROLLER
35 struct netpoll *netpoll; 34 struct netpoll *netpoll;
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 06faa066496f..ec7e4bd07f82 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -223,6 +223,7 @@ struct team {
223 atomic_t count_pending; 223 atomic_t count_pending;
224 struct delayed_work dw; 224 struct delayed_work dw;
225 } mcast_rejoin; 225 } mcast_rejoin;
226 struct lock_class_key team_lock_key;
226 long mode_priv[TEAM_MODE_PRIV_LONGS]; 227 long mode_priv[TEAM_MODE_PRIV_LONGS];
227}; 228};
228 229
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 244278d5c222..b05e855f1ddd 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -182,7 +182,6 @@ struct vlan_dev_priv {
182#ifdef CONFIG_NET_POLL_CONTROLLER 182#ifdef CONFIG_NET_POLL_CONTROLLER
183 struct netpoll *netpoll; 183 struct netpoll *netpoll;
184#endif 184#endif
185 unsigned int nest_level;
186}; 185};
187 186
188static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev) 187static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev)
@@ -221,11 +220,6 @@ extern void vlan_vids_del_by_dev(struct net_device *dev,
221 220
222extern bool vlan_uses_dev(const struct net_device *dev); 221extern bool vlan_uses_dev(const struct net_device *dev);
223 222
224static inline int vlan_get_encap_level(struct net_device *dev)
225{
226 BUG_ON(!is_vlan_dev(dev));
227 return vlan_dev_priv(dev)->nest_level;
228}
229#else 223#else
230static inline struct net_device * 224static inline struct net_device *
231__vlan_find_dev_deep_rcu(struct net_device *real_dev, 225__vlan_find_dev_deep_rcu(struct net_device *real_dev,
@@ -295,11 +289,6 @@ static inline bool vlan_uses_dev(const struct net_device *dev)
295{ 289{
296 return false; 290 return false;
297} 291}
298static inline int vlan_get_encap_level(struct net_device *dev)
299{
300 BUG();
301 return 0;
302}
303#endif 292#endif
304 293
305/** 294/**
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 138c50d5a353..0836fe232f97 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1545,9 +1545,8 @@ struct mlx5_ifc_extended_dest_format_bits {
1545}; 1545};
1546 1546
1547union mlx5_ifc_dest_format_struct_flow_counter_list_auto_bits { 1547union mlx5_ifc_dest_format_struct_flow_counter_list_auto_bits {
1548 struct mlx5_ifc_dest_format_struct_bits dest_format_struct; 1548 struct mlx5_ifc_extended_dest_format_bits extended_dest_format;
1549 struct mlx5_ifc_flow_counter_list_bits flow_counter_list; 1549 struct mlx5_ifc_flow_counter_list_bits flow_counter_list;
1550 u8 reserved_at_0[0x40];
1551}; 1550};
1552 1551
1553struct mlx5_ifc_fte_match_param_bits { 1552struct mlx5_ifc_fte_match_param_bits {
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9eda1c31d1f7..c20f190b4c18 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -925,6 +925,7 @@ struct dev_ifalias {
925struct devlink; 925struct devlink;
926struct tlsdev_ops; 926struct tlsdev_ops;
927 927
928
928/* 929/*
929 * This structure defines the management hooks for network devices. 930 * This structure defines the management hooks for network devices.
930 * The following hooks can be defined; unless noted otherwise, they are 931 * The following hooks can be defined; unless noted otherwise, they are
@@ -1421,7 +1422,6 @@ struct net_device_ops {
1421 void (*ndo_dfwd_del_station)(struct net_device *pdev, 1422 void (*ndo_dfwd_del_station)(struct net_device *pdev,
1422 void *priv); 1423 void *priv);
1423 1424
1424 int (*ndo_get_lock_subclass)(struct net_device *dev);
1425 int (*ndo_set_tx_maxrate)(struct net_device *dev, 1425 int (*ndo_set_tx_maxrate)(struct net_device *dev,
1426 int queue_index, 1426 int queue_index,
1427 u32 maxrate); 1427 u32 maxrate);
@@ -1649,6 +1649,8 @@ enum netdev_priv_flags {
1649 * @perm_addr: Permanent hw address 1649 * @perm_addr: Permanent hw address
1650 * @addr_assign_type: Hw address assignment type 1650 * @addr_assign_type: Hw address assignment type
1651 * @addr_len: Hardware address length 1651 * @addr_len: Hardware address length
1652 * @upper_level: Maximum depth level of upper devices.
1653 * @lower_level: Maximum depth level of lower devices.
1652 * @neigh_priv_len: Used in neigh_alloc() 1654 * @neigh_priv_len: Used in neigh_alloc()
1653 * @dev_id: Used to differentiate devices that share 1655 * @dev_id: Used to differentiate devices that share
1654 * the same link layer address 1656 * the same link layer address
@@ -1758,9 +1760,13 @@ enum netdev_priv_flags {
1758 * @phydev: Physical device may attach itself 1760 * @phydev: Physical device may attach itself
1759 * for hardware timestamping 1761 * for hardware timestamping
1760 * @sfp_bus: attached &struct sfp_bus structure. 1762 * @sfp_bus: attached &struct sfp_bus structure.
1761 * 1763 * @qdisc_tx_busylock_key: lockdep class annotating Qdisc->busylock
1762 * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock 1764 spinlock
1763 * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount 1765 * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount
1766 * @qdisc_xmit_lock_key: lockdep class annotating
1767 * netdev_queue->_xmit_lock spinlock
1768 * @addr_list_lock_key: lockdep class annotating
1769 * net_device->addr_list_lock spinlock
1764 * 1770 *
1765 * @proto_down: protocol port state information can be sent to the 1771 * @proto_down: protocol port state information can be sent to the
1766 * switch driver and used to set the phys state of the 1772 * switch driver and used to set the phys state of the
@@ -1875,6 +1881,8 @@ struct net_device {
1875 unsigned char perm_addr[MAX_ADDR_LEN]; 1881 unsigned char perm_addr[MAX_ADDR_LEN];
1876 unsigned char addr_assign_type; 1882 unsigned char addr_assign_type;
1877 unsigned char addr_len; 1883 unsigned char addr_len;
1884 unsigned char upper_level;
1885 unsigned char lower_level;
1878 unsigned short neigh_priv_len; 1886 unsigned short neigh_priv_len;
1879 unsigned short dev_id; 1887 unsigned short dev_id;
1880 unsigned short dev_port; 1888 unsigned short dev_port;
@@ -2045,8 +2053,10 @@ struct net_device {
2045#endif 2053#endif
2046 struct phy_device *phydev; 2054 struct phy_device *phydev;
2047 struct sfp_bus *sfp_bus; 2055 struct sfp_bus *sfp_bus;
2048 struct lock_class_key *qdisc_tx_busylock; 2056 struct lock_class_key qdisc_tx_busylock_key;
2049 struct lock_class_key *qdisc_running_key; 2057 struct lock_class_key qdisc_running_key;
2058 struct lock_class_key qdisc_xmit_lock_key;
2059 struct lock_class_key addr_list_lock_key;
2050 bool proto_down; 2060 bool proto_down;
2051 unsigned wol_enabled:1; 2061 unsigned wol_enabled:1;
2052}; 2062};
@@ -2124,23 +2134,6 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
2124 f(dev, &dev->_tx[i], arg); 2134 f(dev, &dev->_tx[i], arg);
2125} 2135}
2126 2136
2127#define netdev_lockdep_set_classes(dev) \
2128{ \
2129 static struct lock_class_key qdisc_tx_busylock_key; \
2130 static struct lock_class_key qdisc_running_key; \
2131 static struct lock_class_key qdisc_xmit_lock_key; \
2132 static struct lock_class_key dev_addr_list_lock_key; \
2133 unsigned int i; \
2134 \
2135 (dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key; \
2136 (dev)->qdisc_running_key = &qdisc_running_key; \
2137 lockdep_set_class(&(dev)->addr_list_lock, \
2138 &dev_addr_list_lock_key); \
2139 for (i = 0; i < (dev)->num_tx_queues; i++) \
2140 lockdep_set_class(&(dev)->_tx[i]._xmit_lock, \
2141 &qdisc_xmit_lock_key); \
2142}
2143
2144u16 netdev_pick_tx(struct net_device *dev, struct sk_buff *skb, 2137u16 netdev_pick_tx(struct net_device *dev, struct sk_buff *skb,
2145 struct net_device *sb_dev); 2138 struct net_device *sb_dev);
2146struct netdev_queue *netdev_core_pick_tx(struct net_device *dev, 2139struct netdev_queue *netdev_core_pick_tx(struct net_device *dev,
@@ -3139,6 +3132,7 @@ static inline void netif_stop_queue(struct net_device *dev)
3139} 3132}
3140 3133
3141void netif_tx_stop_all_queues(struct net_device *dev); 3134void netif_tx_stop_all_queues(struct net_device *dev);
3135void netdev_update_lockdep_key(struct net_device *dev);
3142 3136
3143static inline bool netif_tx_queue_stopped(const struct netdev_queue *dev_queue) 3137static inline bool netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
3144{ 3138{
@@ -4056,16 +4050,6 @@ static inline void netif_addr_lock(struct net_device *dev)
4056 spin_lock(&dev->addr_list_lock); 4050 spin_lock(&dev->addr_list_lock);
4057} 4051}
4058 4052
4059static inline void netif_addr_lock_nested(struct net_device *dev)
4060{
4061 int subclass = SINGLE_DEPTH_NESTING;
4062
4063 if (dev->netdev_ops->ndo_get_lock_subclass)
4064 subclass = dev->netdev_ops->ndo_get_lock_subclass(dev);
4065
4066 spin_lock_nested(&dev->addr_list_lock, subclass);
4067}
4068
4069static inline void netif_addr_lock_bh(struct net_device *dev) 4053static inline void netif_addr_lock_bh(struct net_device *dev)
4070{ 4054{
4071 spin_lock_bh(&dev->addr_list_lock); 4055 spin_lock_bh(&dev->addr_list_lock);
@@ -4329,6 +4313,16 @@ int netdev_master_upper_dev_link(struct net_device *dev,
4329 struct netlink_ext_ack *extack); 4313 struct netlink_ext_ack *extack);
4330void netdev_upper_dev_unlink(struct net_device *dev, 4314void netdev_upper_dev_unlink(struct net_device *dev,
4331 struct net_device *upper_dev); 4315 struct net_device *upper_dev);
4316int netdev_adjacent_change_prepare(struct net_device *old_dev,
4317 struct net_device *new_dev,
4318 struct net_device *dev,
4319 struct netlink_ext_ack *extack);
4320void netdev_adjacent_change_commit(struct net_device *old_dev,
4321 struct net_device *new_dev,
4322 struct net_device *dev);
4323void netdev_adjacent_change_abort(struct net_device *old_dev,
4324 struct net_device *new_dev,
4325 struct net_device *dev);
4332void netdev_adjacent_rename_links(struct net_device *dev, char *oldname); 4326void netdev_adjacent_rename_links(struct net_device *dev, char *oldname);
4333void *netdev_lower_dev_get_private(struct net_device *dev, 4327void *netdev_lower_dev_get_private(struct net_device *dev,
4334 struct net_device *lower_dev); 4328 struct net_device *lower_dev);
@@ -4340,7 +4334,6 @@ void netdev_lower_state_changed(struct net_device *lower_dev,
4340extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly; 4334extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;
4341void netdev_rss_key_fill(void *buffer, size_t len); 4335void netdev_rss_key_fill(void *buffer, size_t len);
4342 4336
4343int dev_get_nest_level(struct net_device *dev);
4344int skb_checksum_help(struct sk_buff *skb); 4337int skb_checksum_help(struct sk_buff *skb);
4345int skb_crc32c_csum_help(struct sk_buff *skb); 4338int skb_crc32c_csum_help(struct sk_buff *skb);
4346int skb_csum_hwoffload_help(struct sk_buff *skb, 4339int skb_csum_hwoffload_help(struct sk_buff *skb,
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 61448c19a132..68ccc5b1913b 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -292,7 +292,7 @@ struct pmu {
292 * -EBUSY -- @event is for this PMU but PMU temporarily unavailable 292 * -EBUSY -- @event is for this PMU but PMU temporarily unavailable
293 * -EINVAL -- @event is for this PMU but @event is not valid 293 * -EINVAL -- @event is for this PMU but @event is not valid
294 * -EOPNOTSUPP -- @event is for this PMU, @event is valid, but not supported 294 * -EOPNOTSUPP -- @event is for this PMU, @event is valid, but not supported
295 * -EACCESS -- @event is for this PMU, @event is valid, but no privilidges 295 * -EACCES -- @event is for this PMU, @event is valid, but no privileges
296 * 296 *
297 * 0 -- @event is for this PMU and valid 297 * 0 -- @event is for this PMU and valid
298 * 298 *
diff --git a/include/linux/platform_data/dma-imx-sdma.h b/include/linux/platform_data/dma-imx-sdma.h
index 6eaa53cef0bd..30e676b36b24 100644
--- a/include/linux/platform_data/dma-imx-sdma.h
+++ b/include/linux/platform_data/dma-imx-sdma.h
@@ -51,7 +51,10 @@ struct sdma_script_start_addrs {
51 /* End of v2 array */ 51 /* End of v2 array */
52 s32 zcanfd_2_mcu_addr; 52 s32 zcanfd_2_mcu_addr;
53 s32 zqspi_2_mcu_addr; 53 s32 zqspi_2_mcu_addr;
54 s32 mcu_2_ecspi_addr;
54 /* End of v3 array */ 55 /* End of v3 array */
56 s32 mcu_2_zqspi_addr;
57 /* End of v4 array */
55}; 58};
56 59
57/** 60/**
diff --git a/include/linux/security.h b/include/linux/security.h
index a8d59d612d27..9df7547afc0c 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -105,6 +105,7 @@ enum lockdown_reason {
105 LOCKDOWN_NONE, 105 LOCKDOWN_NONE,
106 LOCKDOWN_MODULE_SIGNATURE, 106 LOCKDOWN_MODULE_SIGNATURE,
107 LOCKDOWN_DEV_MEM, 107 LOCKDOWN_DEV_MEM,
108 LOCKDOWN_EFI_TEST,
108 LOCKDOWN_KEXEC, 109 LOCKDOWN_KEXEC,
109 LOCKDOWN_HIBERNATION, 110 LOCKDOWN_HIBERNATION,
110 LOCKDOWN_PCI_ACCESS, 111 LOCKDOWN_PCI_ACCESS,
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 7914fdaf4226..64a395c7f689 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1354,7 +1354,8 @@ static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6
1354 return skb->hash; 1354 return skb->hash;
1355} 1355}
1356 1356
1357__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb); 1357__u32 skb_get_hash_perturb(const struct sk_buff *skb,
1358 const siphash_key_t *perturb);
1358 1359
1359static inline __u32 skb_get_hash_raw(const struct sk_buff *skb) 1360static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
1360{ 1361{
@@ -1495,6 +1496,19 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
1495} 1496}
1496 1497
1497/** 1498/**
1499 * skb_queue_empty_lockless - check if a queue is empty
1500 * @list: queue head
1501 *
1502 * Returns true if the queue is empty, false otherwise.
1503 * This variant can be used in lockless contexts.
1504 */
1505static inline bool skb_queue_empty_lockless(const struct sk_buff_head *list)
1506{
1507 return READ_ONCE(list->next) == (const struct sk_buff *) list;
1508}
1509
1510
1511/**
1498 * skb_queue_is_last - check if skb is the last entry in the queue 1512 * skb_queue_is_last - check if skb is the last entry in the queue
1499 * @list: queue head 1513 * @list: queue head
1500 * @skb: buffer 1514 * @skb: buffer
@@ -1847,9 +1861,11 @@ static inline void __skb_insert(struct sk_buff *newsk,
1847 struct sk_buff *prev, struct sk_buff *next, 1861 struct sk_buff *prev, struct sk_buff *next,
1848 struct sk_buff_head *list) 1862 struct sk_buff_head *list)
1849{ 1863{
1850 newsk->next = next; 1864 /* see skb_queue_empty_lockless() for the opposite READ_ONCE() */
1851 newsk->prev = prev; 1865 WRITE_ONCE(newsk->next, next);
1852 next->prev = prev->next = newsk; 1866 WRITE_ONCE(newsk->prev, prev);
1867 WRITE_ONCE(next->prev, newsk);
1868 WRITE_ONCE(prev->next, newsk);
1853 list->qlen++; 1869 list->qlen++;
1854} 1870}
1855 1871
@@ -1860,11 +1876,11 @@ static inline void __skb_queue_splice(const struct sk_buff_head *list,
1860 struct sk_buff *first = list->next; 1876 struct sk_buff *first = list->next;
1861 struct sk_buff *last = list->prev; 1877 struct sk_buff *last = list->prev;
1862 1878
1863 first->prev = prev; 1879 WRITE_ONCE(first->prev, prev);
1864 prev->next = first; 1880 WRITE_ONCE(prev->next, first);
1865 1881
1866 last->next = next; 1882 WRITE_ONCE(last->next, next);
1867 next->prev = last; 1883 WRITE_ONCE(next->prev, last);
1868} 1884}
1869 1885
1870/** 1886/**
@@ -2005,8 +2021,8 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
2005 next = skb->next; 2021 next = skb->next;
2006 prev = skb->prev; 2022 prev = skb->prev;
2007 skb->next = skb->prev = NULL; 2023 skb->next = skb->prev = NULL;
2008 next->prev = prev; 2024 WRITE_ONCE(next->prev, prev);
2009 prev->next = next; 2025 WRITE_ONCE(prev->next, next);
2010} 2026}
2011 2027
2012/** 2028/**
diff --git a/include/linux/socket.h b/include/linux/socket.h
index fc0bed59fc84..4049d9755cf1 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -263,7 +263,7 @@ struct ucred {
263#define PF_MAX AF_MAX 263#define PF_MAX AF_MAX
264 264
265/* Maximum queue length specifiable by listen. */ 265/* Maximum queue length specifiable by listen. */
266#define SOMAXCONN 128 266#define SOMAXCONN 4096
267 267
268/* Flags we can use with send/ and recv. 268/* Flags we can use with send/ and recv.
269 Added those for 1003.1g not all are supported yet 269 Added those for 1003.1g not all are supported yet
diff --git a/include/linux/sunrpc/bc_xprt.h b/include/linux/sunrpc/bc_xprt.h
index 87d27e13d885..d796058cdff2 100644
--- a/include/linux/sunrpc/bc_xprt.h
+++ b/include/linux/sunrpc/bc_xprt.h
@@ -64,6 +64,11 @@ static inline int xprt_setup_backchannel(struct rpc_xprt *xprt,
64 return 0; 64 return 0;
65} 65}
66 66
67static inline void xprt_destroy_backchannel(struct rpc_xprt *xprt,
68 unsigned int max_reqs)
69{
70}
71
67static inline bool svc_is_backchannel(const struct svc_rqst *rqstp) 72static inline bool svc_is_backchannel(const struct svc_rqst *rqstp)
68{ 73{
69 return false; 74 return false;
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
index 4c7781f4b29b..07875ccc7bb5 100644
--- a/include/linux/virtio_vsock.h
+++ b/include/linux/virtio_vsock.h
@@ -48,7 +48,6 @@ struct virtio_vsock_sock {
48 48
49struct virtio_vsock_pkt { 49struct virtio_vsock_pkt {
50 struct virtio_vsock_hdr hdr; 50 struct virtio_vsock_hdr hdr;
51 struct work_struct work;
52 struct list_head list; 51 struct list_head list;
53 /* socket refcnt not held, only use for cancellation */ 52 /* socket refcnt not held, only use for cancellation */
54 struct vsock_sock *vsk; 53 struct vsock_sock *vsk;
diff --git a/include/net/bonding.h b/include/net/bonding.h
index f7fe45689142..1afc125014da 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -203,7 +203,6 @@ struct bonding {
203 struct slave __rcu *primary_slave; 203 struct slave __rcu *primary_slave;
204 struct bond_up_slave __rcu *slave_arr; /* Array of usable slaves */ 204 struct bond_up_slave __rcu *slave_arr; /* Array of usable slaves */
205 bool force_primary; 205 bool force_primary;
206 u32 nest_level;
207 s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ 206 s32 slave_cnt; /* never change this value outside the attach/detach wrappers */
208 int (*recv_probe)(const struct sk_buff *, struct bonding *, 207 int (*recv_probe)(const struct sk_buff *, struct bonding *,
209 struct slave *); 208 struct slave *);
@@ -239,6 +238,7 @@ struct bonding {
239 struct dentry *debug_dir; 238 struct dentry *debug_dir;
240#endif /* CONFIG_DEBUG_FS */ 239#endif /* CONFIG_DEBUG_FS */
241 struct rtnl_link_stats64 bond_stats; 240 struct rtnl_link_stats64 bond_stats;
241 struct lock_class_key stats_lock_key;
242}; 242};
243 243
244#define bond_slave_get_rcu(dev) \ 244#define bond_slave_get_rcu(dev) \
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index 127a5c4e3699..86e028388bad 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -122,7 +122,7 @@ static inline void skb_mark_napi_id(struct sk_buff *skb,
122static inline void sk_mark_napi_id(struct sock *sk, const struct sk_buff *skb) 122static inline void sk_mark_napi_id(struct sock *sk, const struct sk_buff *skb)
123{ 123{
124#ifdef CONFIG_NET_RX_BUSY_POLL 124#ifdef CONFIG_NET_RX_BUSY_POLL
125 sk->sk_napi_id = skb->napi_id; 125 WRITE_ONCE(sk->sk_napi_id, skb->napi_id);
126#endif 126#endif
127 sk_rx_queue_set(sk, skb); 127 sk_rx_queue_set(sk, skb);
128} 128}
@@ -132,8 +132,8 @@ static inline void sk_mark_napi_id_once(struct sock *sk,
132 const struct sk_buff *skb) 132 const struct sk_buff *skb)
133{ 133{
134#ifdef CONFIG_NET_RX_BUSY_POLL 134#ifdef CONFIG_NET_RX_BUSY_POLL
135 if (!sk->sk_napi_id) 135 if (!READ_ONCE(sk->sk_napi_id))
136 sk->sk_napi_id = skb->napi_id; 136 WRITE_ONCE(sk->sk_napi_id, skb->napi_id);
137#endif 137#endif
138} 138}
139 139
diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
index 90bd210be060..5cd12276ae21 100644
--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -4,6 +4,7 @@
4 4
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/in6.h> 6#include <linux/in6.h>
7#include <linux/siphash.h>
7#include <uapi/linux/if_ether.h> 8#include <uapi/linux/if_ether.h>
8 9
9/** 10/**
@@ -276,7 +277,7 @@ struct flow_keys_basic {
276struct flow_keys { 277struct flow_keys {
277 struct flow_dissector_key_control control; 278 struct flow_dissector_key_control control;
278#define FLOW_KEYS_HASH_START_FIELD basic 279#define FLOW_KEYS_HASH_START_FIELD basic
279 struct flow_dissector_key_basic basic; 280 struct flow_dissector_key_basic basic __aligned(SIPHASH_ALIGNMENT);
280 struct flow_dissector_key_tags tags; 281 struct flow_dissector_key_tags tags;
281 struct flow_dissector_key_vlan vlan; 282 struct flow_dissector_key_vlan vlan;
282 struct flow_dissector_key_vlan cvlan; 283 struct flow_dissector_key_vlan cvlan;
diff --git a/include/net/fq.h b/include/net/fq.h
index d126b5d20261..2ad85e683041 100644
--- a/include/net/fq.h
+++ b/include/net/fq.h
@@ -69,7 +69,7 @@ struct fq {
69 struct list_head backlogs; 69 struct list_head backlogs;
70 spinlock_t lock; 70 spinlock_t lock;
71 u32 flows_cnt; 71 u32 flows_cnt;
72 u32 perturbation; 72 siphash_key_t perturbation;
73 u32 limit; 73 u32 limit;
74 u32 memory_limit; 74 u32 memory_limit;
75 u32 memory_usage; 75 u32 memory_usage;
diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
index be40a4b327e3..107c0d700ed6 100644
--- a/include/net/fq_impl.h
+++ b/include/net/fq_impl.h
@@ -108,7 +108,7 @@ begin:
108 108
109static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb) 109static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb)
110{ 110{
111 u32 hash = skb_get_hash_perturb(skb, fq->perturbation); 111 u32 hash = skb_get_hash_perturb(skb, &fq->perturbation);
112 112
113 return reciprocal_scale(hash, fq->flows_cnt); 113 return reciprocal_scale(hash, fq->flows_cnt);
114} 114}
@@ -308,7 +308,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
308 INIT_LIST_HEAD(&fq->backlogs); 308 INIT_LIST_HEAD(&fq->backlogs);
309 spin_lock_init(&fq->lock); 309 spin_lock_init(&fq->lock);
310 fq->flows_cnt = max_t(u32, flows_cnt, 1); 310 fq->flows_cnt = max_t(u32, flows_cnt, 1);
311 fq->perturbation = prandom_u32(); 311 get_random_bytes(&fq->perturbation, sizeof(fq->perturbation));
312 fq->quantum = 300; 312 fq->quantum = 300;
313 fq->limit = 8192; 313 fq->limit = 8192;
314 fq->memory_limit = 16 << 20; /* 16 MBytes */ 314 fq->memory_limit = 16 << 20; /* 16 MBytes */
diff --git a/include/net/hwbm.h b/include/net/hwbm.h
index 81643cf8a1c4..c81444611a22 100644
--- a/include/net/hwbm.h
+++ b/include/net/hwbm.h
@@ -21,9 +21,13 @@ void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
21int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp); 21int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
22int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num); 22int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
23#else 23#else
24void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} 24static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
25int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) { return 0; } 25
26int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num) 26static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
27{ return 0; }
28
29static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
30 unsigned int buf_num)
27{ return 0; } 31{ return 0; }
28#endif /* CONFIG_HWBM */ 32#endif /* CONFIG_HWBM */
29#endif /* _HWBM_H */ 33#endif /* _HWBM_H */
diff --git a/include/net/ip.h b/include/net/ip.h
index 95bb77f95bcc..a2c61c36dc4a 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -185,7 +185,7 @@ static inline struct sk_buff *ip_fraglist_next(struct ip_fraglist_iter *iter)
185} 185}
186 186
187struct ip_frag_state { 187struct ip_frag_state {
188 struct iphdr *iph; 188 bool DF;
189 unsigned int hlen; 189 unsigned int hlen;
190 unsigned int ll_rs; 190 unsigned int ll_rs;
191 unsigned int mtu; 191 unsigned int mtu;
@@ -196,7 +196,7 @@ struct ip_frag_state {
196}; 196};
197 197
198void ip_frag_init(struct sk_buff *skb, unsigned int hlen, unsigned int ll_rs, 198void ip_frag_init(struct sk_buff *skb, unsigned int hlen, unsigned int ll_rs,
199 unsigned int mtu, struct ip_frag_state *state); 199 unsigned int mtu, bool DF, struct ip_frag_state *state);
200struct sk_buff *ip_frag_next(struct sk_buff *skb, 200struct sk_buff *ip_frag_next(struct sk_buff *skb,
201 struct ip_frag_state *state); 201 struct ip_frag_state *state);
202 202
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 3759167f91f5..078887c8c586 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -889,6 +889,7 @@ struct netns_ipvs {
889 struct delayed_work defense_work; /* Work handler */ 889 struct delayed_work defense_work; /* Work handler */
890 int drop_rate; 890 int drop_rate;
891 int drop_counter; 891 int drop_counter;
892 int old_secure_tcp;
892 atomic_t dropentry; 893 atomic_t dropentry;
893 /* locks in ctl.c */ 894 /* locks in ctl.c */
894 spinlock_t dropentry_lock; /* drop entry handling */ 895 spinlock_t dropentry_lock; /* drop entry handling */
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 4c2cd9378699..c7e15a213ef2 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -342,7 +342,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
342#define __net_initconst __initconst 342#define __net_initconst __initconst
343#endif 343#endif
344 344
345int peernet2id_alloc(struct net *net, struct net *peer); 345int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp);
346int peernet2id(struct net *net, struct net *peer); 346int peernet2id(struct net *net, struct net *peer);
347bool peernet_has_id(struct net *net, struct net *peer); 347bool peernet_has_id(struct net *net, struct net *peer);
348struct net *get_net_ns_by_id(struct net *net, int id); 348struct net *get_net_ns_by_id(struct net *net, int id);
diff --git a/include/net/sock.h b/include/net/sock.h
index f69b58bff7e5..8f9adcfac41b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -954,8 +954,8 @@ static inline void sk_incoming_cpu_update(struct sock *sk)
954{ 954{
955 int cpu = raw_smp_processor_id(); 955 int cpu = raw_smp_processor_id();
956 956
957 if (unlikely(sk->sk_incoming_cpu != cpu)) 957 if (unlikely(READ_ONCE(sk->sk_incoming_cpu) != cpu))
958 sk->sk_incoming_cpu = cpu; 958 WRITE_ONCE(sk->sk_incoming_cpu, cpu);
959} 959}
960 960
961static inline void sock_rps_record_flow_hash(__u32 hash) 961static inline void sock_rps_record_flow_hash(__u32 hash)
@@ -2242,12 +2242,17 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
2242 * sk_page_frag - return an appropriate page_frag 2242 * sk_page_frag - return an appropriate page_frag
2243 * @sk: socket 2243 * @sk: socket
2244 * 2244 *
2245 * If socket allocation mode allows current thread to sleep, it means its 2245 * Use the per task page_frag instead of the per socket one for
2246 * safe to use the per task page_frag instead of the per socket one. 2246 * optimization when we know that we're in the normal context and owns
2247 * everything that's associated with %current.
2248 *
2249 * gfpflags_allow_blocking() isn't enough here as direct reclaim may nest
2250 * inside other socket operations and end up recursing into sk_page_frag()
2251 * while it's already in use.
2247 */ 2252 */
2248static inline struct page_frag *sk_page_frag(struct sock *sk) 2253static inline struct page_frag *sk_page_frag(struct sock *sk)
2249{ 2254{
2250 if (gfpflags_allow_blocking(sk->sk_allocation)) 2255 if (gfpflags_normal_context(sk->sk_allocation))
2251 return &current->task_frag; 2256 return &current->task_frag;
2252 2257
2253 return &sk->sk_frag; 2258 return &sk->sk_frag;
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 335283dbe9b3..373aadcfea21 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -197,6 +197,7 @@ struct vxlan_rdst {
197 u8 offloaded:1; 197 u8 offloaded:1;
198 __be32 remote_vni; 198 __be32 remote_vni;
199 u32 remote_ifindex; 199 u32 remote_ifindex;
200 struct net_device *remote_dev;
200 struct list_head list; 201 struct list_head list;
201 struct rcu_head rcu; 202 struct rcu_head rcu;
202 struct dst_cache dst_cache; 203 struct dst_cache dst_cache;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6a47ba85c54c..e7e733add99f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -366,7 +366,7 @@ struct ib_tm_caps {
366 366
367struct ib_cq_init_attr { 367struct ib_cq_init_attr {
368 unsigned int cqe; 368 unsigned int cqe;
369 int comp_vector; 369 u32 comp_vector;
370 u32 flags; 370 u32 flags;
371}; 371};
372 372
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 802b0377a49e..373cada89815 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -38,6 +38,43 @@
38 * 38 *
39 * Protocol changelog: 39 * Protocol changelog:
40 * 40 *
41 * 7.1:
42 * - add the following messages:
43 * FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK,
44 * FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE,
45 * FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR,
46 * FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR,
47 * FUSE_RELEASEDIR
48 * - add padding to messages to accommodate 32-bit servers on 64-bit kernels
49 *
50 * 7.2:
51 * - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags
52 * - add FUSE_FSYNCDIR message
53 *
54 * 7.3:
55 * - add FUSE_ACCESS message
56 * - add FUSE_CREATE message
57 * - add filehandle to fuse_setattr_in
58 *
59 * 7.4:
60 * - add frsize to fuse_kstatfs
61 * - clean up request size limit checking
62 *
63 * 7.5:
64 * - add flags and max_write to fuse_init_out
65 *
66 * 7.6:
67 * - add max_readahead to fuse_init_in and fuse_init_out
68 *
69 * 7.7:
70 * - add FUSE_INTERRUPT message
71 * - add POSIX file lock support
72 *
73 * 7.8:
74 * - add lock_owner and flags fields to fuse_release_in
75 * - add FUSE_BMAP message
76 * - add FUSE_DESTROY message
77 *
41 * 7.9: 78 * 7.9:
42 * - new fuse_getattr_in input argument of GETATTR 79 * - new fuse_getattr_in input argument of GETATTR
43 * - add lk_flags in fuse_lk_in 80 * - add lk_flags in fuse_lk_in
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 66088a9e9b9e..ef0e1e3e66f4 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -502,7 +502,7 @@ int bpf_remove_insns(struct bpf_prog *prog, u32 off, u32 cnt)
502 return WARN_ON_ONCE(bpf_adj_branches(prog, off, off + cnt, off, false)); 502 return WARN_ON_ONCE(bpf_adj_branches(prog, off, off + cnt, off, false));
503} 503}
504 504
505void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp) 505static void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp)
506{ 506{
507 int i; 507 int i;
508 508
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index d27f3b60ff6d..3867864cdc2f 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -128,7 +128,7 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
128 128
129 if (!dtab->n_buckets) /* Overflow check */ 129 if (!dtab->n_buckets) /* Overflow check */
130 return -EINVAL; 130 return -EINVAL;
131 cost += sizeof(struct hlist_head) * dtab->n_buckets; 131 cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets;
132 } 132 }
133 133
134 /* if map size is larger than memlock limit, reject it */ 134 /* if map size is larger than memlock limit, reject it */
@@ -719,6 +719,32 @@ const struct bpf_map_ops dev_map_hash_ops = {
719 .map_check_btf = map_check_no_btf, 719 .map_check_btf = map_check_no_btf,
720}; 720};
721 721
722static void dev_map_hash_remove_netdev(struct bpf_dtab *dtab,
723 struct net_device *netdev)
724{
725 unsigned long flags;
726 u32 i;
727
728 spin_lock_irqsave(&dtab->index_lock, flags);
729 for (i = 0; i < dtab->n_buckets; i++) {
730 struct bpf_dtab_netdev *dev;
731 struct hlist_head *head;
732 struct hlist_node *next;
733
734 head = dev_map_index_hash(dtab, i);
735
736 hlist_for_each_entry_safe(dev, next, head, index_hlist) {
737 if (netdev != dev->dev)
738 continue;
739
740 dtab->items--;
741 hlist_del_rcu(&dev->index_hlist);
742 call_rcu(&dev->rcu, __dev_map_entry_free);
743 }
744 }
745 spin_unlock_irqrestore(&dtab->index_lock, flags);
746}
747
722static int dev_map_notification(struct notifier_block *notifier, 748static int dev_map_notification(struct notifier_block *notifier,
723 ulong event, void *ptr) 749 ulong event, void *ptr)
724{ 750{
@@ -735,6 +761,11 @@ static int dev_map_notification(struct notifier_block *notifier,
735 */ 761 */
736 rcu_read_lock(); 762 rcu_read_lock();
737 list_for_each_entry_rcu(dtab, &dev_map_list, list) { 763 list_for_each_entry_rcu(dtab, &dev_map_list, list) {
764 if (dtab->map.map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
765 dev_map_hash_remove_netdev(dtab, netdev);
766 continue;
767 }
768
738 for (i = 0; i < dtab->map.max_entries; i++) { 769 for (i = 0; i < dtab->map.max_entries; i++) {
739 struct bpf_dtab_netdev *dev, *odev; 770 struct bpf_dtab_netdev *dev, *odev;
740 771
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 82eabd4e38ad..0937719b87e2 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1326,24 +1326,32 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)
1326{ 1326{
1327 struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu); 1327 struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu);
1328 1328
1329 kvfree(aux->func_info);
1329 free_used_maps(aux); 1330 free_used_maps(aux);
1330 bpf_prog_uncharge_memlock(aux->prog); 1331 bpf_prog_uncharge_memlock(aux->prog);
1331 security_bpf_prog_free(aux); 1332 security_bpf_prog_free(aux);
1332 bpf_prog_free(aux->prog); 1333 bpf_prog_free(aux->prog);
1333} 1334}
1334 1335
1336static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred)
1337{
1338 bpf_prog_kallsyms_del_all(prog);
1339 btf_put(prog->aux->btf);
1340 bpf_prog_free_linfo(prog);
1341
1342 if (deferred)
1343 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu);
1344 else
1345 __bpf_prog_put_rcu(&prog->aux->rcu);
1346}
1347
1335static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) 1348static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock)
1336{ 1349{
1337 if (atomic_dec_and_test(&prog->aux->refcnt)) { 1350 if (atomic_dec_and_test(&prog->aux->refcnt)) {
1338 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0); 1351 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0);
1339 /* bpf_prog_free_id() must be called first */ 1352 /* bpf_prog_free_id() must be called first */
1340 bpf_prog_free_id(prog, do_idr_lock); 1353 bpf_prog_free_id(prog, do_idr_lock);
1341 bpf_prog_kallsyms_del_all(prog); 1354 __bpf_prog_put_noref(prog, true);
1342 btf_put(prog->aux->btf);
1343 kvfree(prog->aux->func_info);
1344 bpf_prog_free_linfo(prog);
1345
1346 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu);
1347 } 1355 }
1348} 1356}
1349 1357
@@ -1741,11 +1749,12 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)
1741 return err; 1749 return err;
1742 1750
1743free_used_maps: 1751free_used_maps:
1744 bpf_prog_free_linfo(prog); 1752 /* In case we have subprogs, we need to wait for a grace
1745 kvfree(prog->aux->func_info); 1753 * period before we can tear down JIT memory since symbols
1746 btf_put(prog->aux->btf); 1754 * are already exposed under kallsyms.
1747 bpf_prog_kallsyms_del_subprogs(prog); 1755 */
1748 free_used_maps(prog->aux); 1756 __bpf_prog_put_noref(prog, prog->aux->func_cnt);
1757 return err;
1749free_prog: 1758free_prog:
1750 bpf_prog_uncharge_memlock(prog); 1759 bpf_prog_uncharge_memlock(prog);
1751free_prog_sec: 1760free_prog_sec:
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index c52bc91f882b..c87ee6412b36 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -798,7 +798,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
798 cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus)) 798 cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus))
799 continue; 799 continue;
800 800
801 if (is_sched_load_balance(cp)) 801 if (is_sched_load_balance(cp) &&
802 !cpumask_empty(cp->effective_cpus))
802 csa[csn++] = cp; 803 csa[csn++] = cp;
803 804
804 /* skip @cp's subtree if not a partition root */ 805 /* skip @cp's subtree if not a partition root */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index bb3748d29b04..aec8dba2bea4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10635,7 +10635,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
10635 10635
10636 attr->size = size; 10636 attr->size = size;
10637 10637
10638 if (attr->__reserved_1) 10638 if (attr->__reserved_1 || attr->__reserved_2)
10639 return -EINVAL; 10639 return -EINVAL;
10640 10640
10641 if (attr->sample_type & ~(PERF_SAMPLE_MAX-1)) 10641 if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index b5667a273bf6..49b835f1305f 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1948,7 +1948,7 @@ next_level:
1948static int 1948static int
1949build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *attr) 1949build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *attr)
1950{ 1950{
1951 enum s_alloc alloc_state; 1951 enum s_alloc alloc_state = sa_none;
1952 struct sched_domain *sd; 1952 struct sched_domain *sd;
1953 struct s_data d; 1953 struct s_data d;
1954 struct rq *rq = NULL; 1954 struct rq *rq = NULL;
@@ -1956,6 +1956,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
1956 struct sched_domain_topology_level *tl_asym; 1956 struct sched_domain_topology_level *tl_asym;
1957 bool has_asym = false; 1957 bool has_asym = false;
1958 1958
1959 if (WARN_ON(cpumask_empty(cpu_map)))
1960 goto error;
1961
1959 alloc_state = __visit_domain_allocation_hell(&d, cpu_map); 1962 alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
1960 if (alloc_state != sa_rootdomain) 1963 if (alloc_state != sa_rootdomain)
1961 goto error; 1964 goto error;
@@ -2026,7 +2029,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
2026 rcu_read_unlock(); 2029 rcu_read_unlock();
2027 2030
2028 if (has_asym) 2031 if (has_asym)
2029 static_branch_enable_cpuslocked(&sched_asym_cpucapacity); 2032 static_branch_inc_cpuslocked(&sched_asym_cpucapacity);
2030 2033
2031 if (rq && sched_debug_enabled) { 2034 if (rq && sched_debug_enabled) {
2032 pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n", 2035 pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n",
@@ -2121,8 +2124,12 @@ int sched_init_domains(const struct cpumask *cpu_map)
2121 */ 2124 */
2122static void detach_destroy_domains(const struct cpumask *cpu_map) 2125static void detach_destroy_domains(const struct cpumask *cpu_map)
2123{ 2126{
2127 unsigned int cpu = cpumask_any(cpu_map);
2124 int i; 2128 int i;
2125 2129
2130 if (rcu_access_pointer(per_cpu(sd_asym_cpucapacity, cpu)))
2131 static_branch_dec_cpuslocked(&sched_asym_cpucapacity);
2132
2126 rcu_read_lock(); 2133 rcu_read_lock();
2127 for_each_cpu(i, cpu_map) 2134 for_each_cpu(i, cpu_map)
2128 cpu_attach_domain(NULL, &def_root_domain, i); 2135 cpu_attach_domain(NULL, &def_root_domain, i);
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 54728d2eda18..d4bcfd8f95bf 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -172,7 +172,6 @@ int register_vlan_dev(struct net_device *dev, struct netlink_ext_ack *extack)
172 if (err < 0) 172 if (err < 0)
173 goto out_uninit_mvrp; 173 goto out_uninit_mvrp;
174 174
175 vlan->nest_level = dev_get_nest_level(real_dev) + 1;
176 err = register_netdevice(dev); 175 err = register_netdevice(dev);
177 if (err < 0) 176 if (err < 0)
178 goto out_uninit_mvrp; 177 goto out_uninit_mvrp;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 93eadf179123..e5bff5cc6f97 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -489,36 +489,6 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev)
489 dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); 489 dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev);
490} 490}
491 491
492/*
493 * vlan network devices have devices nesting below it, and are a special
494 * "super class" of normal network devices; split their locks off into a
495 * separate class since they always nest.
496 */
497static struct lock_class_key vlan_netdev_xmit_lock_key;
498static struct lock_class_key vlan_netdev_addr_lock_key;
499
500static void vlan_dev_set_lockdep_one(struct net_device *dev,
501 struct netdev_queue *txq,
502 void *_subclass)
503{
504 lockdep_set_class_and_subclass(&txq->_xmit_lock,
505 &vlan_netdev_xmit_lock_key,
506 *(int *)_subclass);
507}
508
509static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass)
510{
511 lockdep_set_class_and_subclass(&dev->addr_list_lock,
512 &vlan_netdev_addr_lock_key,
513 subclass);
514 netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass);
515}
516
517static int vlan_dev_get_lock_subclass(struct net_device *dev)
518{
519 return vlan_dev_priv(dev)->nest_level;
520}
521
522static const struct header_ops vlan_header_ops = { 492static const struct header_ops vlan_header_ops = {
523 .create = vlan_dev_hard_header, 493 .create = vlan_dev_hard_header,
524 .parse = eth_header_parse, 494 .parse = eth_header_parse,
@@ -609,8 +579,6 @@ static int vlan_dev_init(struct net_device *dev)
609 579
610 SET_NETDEV_DEVTYPE(dev, &vlan_type); 580 SET_NETDEV_DEVTYPE(dev, &vlan_type);
611 581
612 vlan_dev_set_lockdep_class(dev, vlan_dev_get_lock_subclass(dev));
613
614 vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); 582 vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
615 if (!vlan->vlan_pcpu_stats) 583 if (!vlan->vlan_pcpu_stats)
616 return -ENOMEM; 584 return -ENOMEM;
@@ -812,7 +780,6 @@ static const struct net_device_ops vlan_netdev_ops = {
812 .ndo_netpoll_cleanup = vlan_dev_netpoll_cleanup, 780 .ndo_netpoll_cleanup = vlan_dev_netpoll_cleanup,
813#endif 781#endif
814 .ndo_fix_features = vlan_dev_fix_features, 782 .ndo_fix_features = vlan_dev_fix_features,
815 .ndo_get_lock_subclass = vlan_dev_get_lock_subclass,
816 .ndo_get_iflink = vlan_dev_get_iflink, 783 .ndo_get_iflink = vlan_dev_get_iflink,
817}; 784};
818 785
diff --git a/net/atm/common.c b/net/atm/common.c
index b7528e77997c..0ce530af534d 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -668,7 +668,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
668 mask |= EPOLLHUP; 668 mask |= EPOLLHUP;
669 669
670 /* readable? */ 670 /* readable? */
671 if (!skb_queue_empty(&sk->sk_receive_queue)) 671 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
672 mask |= EPOLLIN | EPOLLRDNORM; 672 mask |= EPOLLIN | EPOLLRDNORM;
673 673
674 /* writable? */ 674 /* writable? */
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index d78938e3e008..5b0b20e6da95 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -22,6 +22,8 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/kref.h> 23#include <linux/kref.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/lockdep.h>
26#include <linux/mutex.h>
25#include <linux/netdevice.h> 27#include <linux/netdevice.h>
26#include <linux/netlink.h> 28#include <linux/netlink.h>
27#include <linux/pkt_sched.h> 29#include <linux/pkt_sched.h>
@@ -193,14 +195,18 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
193 unsigned char *ogm_buff; 195 unsigned char *ogm_buff;
194 u32 random_seqno; 196 u32 random_seqno;
195 197
198 mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
199
196 /* randomize initial seqno to avoid collision */ 200 /* randomize initial seqno to avoid collision */
197 get_random_bytes(&random_seqno, sizeof(random_seqno)); 201 get_random_bytes(&random_seqno, sizeof(random_seqno));
198 atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno); 202 atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
199 203
200 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN; 204 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
201 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC); 205 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
202 if (!ogm_buff) 206 if (!ogm_buff) {
207 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
203 return -ENOMEM; 208 return -ENOMEM;
209 }
204 210
205 hard_iface->bat_iv.ogm_buff = ogm_buff; 211 hard_iface->bat_iv.ogm_buff = ogm_buff;
206 212
@@ -212,35 +218,59 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
212 batadv_ogm_packet->reserved = 0; 218 batadv_ogm_packet->reserved = 0;
213 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; 219 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
214 220
221 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
222
215 return 0; 223 return 0;
216} 224}
217 225
218static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface) 226static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
219{ 227{
228 mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
229
220 kfree(hard_iface->bat_iv.ogm_buff); 230 kfree(hard_iface->bat_iv.ogm_buff);
221 hard_iface->bat_iv.ogm_buff = NULL; 231 hard_iface->bat_iv.ogm_buff = NULL;
232
233 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
222} 234}
223 235
224static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface) 236static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
225{ 237{
226 struct batadv_ogm_packet *batadv_ogm_packet; 238 struct batadv_ogm_packet *batadv_ogm_packet;
227 unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff; 239 void *ogm_buff;
228 240
229 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; 241 mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
242
243 ogm_buff = hard_iface->bat_iv.ogm_buff;
244 if (!ogm_buff)
245 goto unlock;
246
247 batadv_ogm_packet = ogm_buff;
230 ether_addr_copy(batadv_ogm_packet->orig, 248 ether_addr_copy(batadv_ogm_packet->orig,
231 hard_iface->net_dev->dev_addr); 249 hard_iface->net_dev->dev_addr);
232 ether_addr_copy(batadv_ogm_packet->prev_sender, 250 ether_addr_copy(batadv_ogm_packet->prev_sender,
233 hard_iface->net_dev->dev_addr); 251 hard_iface->net_dev->dev_addr);
252
253unlock:
254 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
234} 255}
235 256
236static void 257static void
237batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface) 258batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
238{ 259{
239 struct batadv_ogm_packet *batadv_ogm_packet; 260 struct batadv_ogm_packet *batadv_ogm_packet;
240 unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff; 261 void *ogm_buff;
241 262
242 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; 263 mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
264
265 ogm_buff = hard_iface->bat_iv.ogm_buff;
266 if (!ogm_buff)
267 goto unlock;
268
269 batadv_ogm_packet = ogm_buff;
243 batadv_ogm_packet->ttl = BATADV_TTL; 270 batadv_ogm_packet->ttl = BATADV_TTL;
271
272unlock:
273 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
244} 274}
245 275
246/* when do we schedule our own ogm to be sent */ 276/* when do we schedule our own ogm to be sent */
@@ -742,7 +772,11 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
742 } 772 }
743} 773}
744 774
745static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) 775/**
776 * batadv_iv_ogm_schedule_buff() - schedule submission of hardif ogm buffer
777 * @hard_iface: interface whose ogm buffer should be transmitted
778 */
779static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
746{ 780{
747 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 781 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
748 unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff; 782 unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff;
@@ -753,9 +787,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
753 u16 tvlv_len = 0; 787 u16 tvlv_len = 0;
754 unsigned long send_time; 788 unsigned long send_time;
755 789
756 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE || 790 lockdep_assert_held(&hard_iface->bat_iv.ogm_buff_mutex);
757 hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
758 return;
759 791
760 /* the interface gets activated here to avoid race conditions between 792 /* the interface gets activated here to avoid race conditions between
761 * the moment of activating the interface in 793 * the moment of activating the interface in
@@ -823,6 +855,17 @@ out:
823 batadv_hardif_put(primary_if); 855 batadv_hardif_put(primary_if);
824} 856}
825 857
858static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
859{
860 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
861 hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
862 return;
863
864 mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
865 batadv_iv_ogm_schedule_buff(hard_iface);
866 mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
867}
868
826/** 869/**
827 * batadv_iv_orig_ifinfo_sum() - Get bcast_own sum for originator over iterface 870 * batadv_iv_orig_ifinfo_sum() - Get bcast_own sum for originator over iterface
828 * @orig_node: originator which reproadcasted the OGMs directly 871 * @orig_node: originator which reproadcasted the OGMs directly
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index dc4f7430cb5a..8033f24f506c 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -18,6 +18,7 @@
18#include <linux/kref.h> 18#include <linux/kref.h>
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/lockdep.h> 20#include <linux/lockdep.h>
21#include <linux/mutex.h>
21#include <linux/netdevice.h> 22#include <linux/netdevice.h>
22#include <linux/random.h> 23#include <linux/random.h>
23#include <linux/rculist.h> 24#include <linux/rculist.h>
@@ -256,14 +257,12 @@ static void batadv_v_ogm_queue_on_if(struct sk_buff *skb,
256} 257}
257 258
258/** 259/**
259 * batadv_v_ogm_send() - periodic worker broadcasting the own OGM 260 * batadv_v_ogm_send_softif() - periodic worker broadcasting the own OGM
260 * @work: work queue item 261 * @bat_priv: the bat priv with all the soft interface information
261 */ 262 */
262static void batadv_v_ogm_send(struct work_struct *work) 263static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv)
263{ 264{
264 struct batadv_hard_iface *hard_iface; 265 struct batadv_hard_iface *hard_iface;
265 struct batadv_priv_bat_v *bat_v;
266 struct batadv_priv *bat_priv;
267 struct batadv_ogm2_packet *ogm_packet; 266 struct batadv_ogm2_packet *ogm_packet;
268 struct sk_buff *skb, *skb_tmp; 267 struct sk_buff *skb, *skb_tmp;
269 unsigned char *ogm_buff; 268 unsigned char *ogm_buff;
@@ -271,8 +270,7 @@ static void batadv_v_ogm_send(struct work_struct *work)
271 u16 tvlv_len = 0; 270 u16 tvlv_len = 0;
272 int ret; 271 int ret;
273 272
274 bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work); 273 lockdep_assert_held(&bat_priv->bat_v.ogm_buff_mutex);
275 bat_priv = container_of(bat_v, struct batadv_priv, bat_v);
276 274
277 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) 275 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING)
278 goto out; 276 goto out;
@@ -364,6 +362,23 @@ out:
364} 362}
365 363
366/** 364/**
365 * batadv_v_ogm_send() - periodic worker broadcasting the own OGM
366 * @work: work queue item
367 */
368static void batadv_v_ogm_send(struct work_struct *work)
369{
370 struct batadv_priv_bat_v *bat_v;
371 struct batadv_priv *bat_priv;
372
373 bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work);
374 bat_priv = container_of(bat_v, struct batadv_priv, bat_v);
375
376 mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
377 batadv_v_ogm_send_softif(bat_priv);
378 mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
379}
380
381/**
367 * batadv_v_ogm_aggr_work() - OGM queue periodic task per interface 382 * batadv_v_ogm_aggr_work() - OGM queue periodic task per interface
368 * @work: work queue item 383 * @work: work queue item
369 * 384 *
@@ -424,11 +439,15 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface)
424 struct batadv_priv *bat_priv = netdev_priv(primary_iface->soft_iface); 439 struct batadv_priv *bat_priv = netdev_priv(primary_iface->soft_iface);
425 struct batadv_ogm2_packet *ogm_packet; 440 struct batadv_ogm2_packet *ogm_packet;
426 441
442 mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
427 if (!bat_priv->bat_v.ogm_buff) 443 if (!bat_priv->bat_v.ogm_buff)
428 return; 444 goto unlock;
429 445
430 ogm_packet = (struct batadv_ogm2_packet *)bat_priv->bat_v.ogm_buff; 446 ogm_packet = (struct batadv_ogm2_packet *)bat_priv->bat_v.ogm_buff;
431 ether_addr_copy(ogm_packet->orig, primary_iface->net_dev->dev_addr); 447 ether_addr_copy(ogm_packet->orig, primary_iface->net_dev->dev_addr);
448
449unlock:
450 mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
432} 451}
433 452
434/** 453/**
@@ -1050,6 +1069,8 @@ int batadv_v_ogm_init(struct batadv_priv *bat_priv)
1050 atomic_set(&bat_priv->bat_v.ogm_seqno, random_seqno); 1069 atomic_set(&bat_priv->bat_v.ogm_seqno, random_seqno);
1051 INIT_DELAYED_WORK(&bat_priv->bat_v.ogm_wq, batadv_v_ogm_send); 1070 INIT_DELAYED_WORK(&bat_priv->bat_v.ogm_wq, batadv_v_ogm_send);
1052 1071
1072 mutex_init(&bat_priv->bat_v.ogm_buff_mutex);
1073
1053 return 0; 1074 return 0;
1054} 1075}
1055 1076
@@ -1061,7 +1082,11 @@ void batadv_v_ogm_free(struct batadv_priv *bat_priv)
1061{ 1082{
1062 cancel_delayed_work_sync(&bat_priv->bat_v.ogm_wq); 1083 cancel_delayed_work_sync(&bat_priv->bat_v.ogm_wq);
1063 1084
1085 mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
1086
1064 kfree(bat_priv->bat_v.ogm_buff); 1087 kfree(bat_priv->bat_v.ogm_buff);
1065 bat_priv->bat_v.ogm_buff = NULL; 1088 bat_priv->bat_v.ogm_buff = NULL;
1066 bat_priv->bat_v.ogm_buff_len = 0; 1089 bat_priv->bat_v.ogm_buff_len = 0;
1090
1091 mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
1067} 1092}
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index c90e47342bb0..afb52282d5bd 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -18,6 +18,7 @@
18#include <linux/kref.h> 18#include <linux/kref.h>
19#include <linux/limits.h> 19#include <linux/limits.h>
20#include <linux/list.h> 20#include <linux/list.h>
21#include <linux/mutex.h>
21#include <linux/netdevice.h> 22#include <linux/netdevice.h>
22#include <linux/printk.h> 23#include <linux/printk.h>
23#include <linux/rculist.h> 24#include <linux/rculist.h>
@@ -929,6 +930,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
929 INIT_LIST_HEAD(&hard_iface->list); 930 INIT_LIST_HEAD(&hard_iface->list);
930 INIT_HLIST_HEAD(&hard_iface->neigh_list); 931 INIT_HLIST_HEAD(&hard_iface->neigh_list);
931 932
933 mutex_init(&hard_iface->bat_iv.ogm_buff_mutex);
932 spin_lock_init(&hard_iface->neigh_list_lock); 934 spin_lock_init(&hard_iface->neigh_list_lock);
933 kref_init(&hard_iface->refcount); 935 kref_init(&hard_iface->refcount);
934 936
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 9cbed6f5a85a..5ee8e9a100f9 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -740,36 +740,6 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto,
740 return 0; 740 return 0;
741} 741}
742 742
743/* batman-adv network devices have devices nesting below it and are a special
744 * "super class" of normal network devices; split their locks off into a
745 * separate class since they always nest.
746 */
747static struct lock_class_key batadv_netdev_xmit_lock_key;
748static struct lock_class_key batadv_netdev_addr_lock_key;
749
750/**
751 * batadv_set_lockdep_class_one() - Set lockdep class for a single tx queue
752 * @dev: device which owns the tx queue
753 * @txq: tx queue to modify
754 * @_unused: always NULL
755 */
756static void batadv_set_lockdep_class_one(struct net_device *dev,
757 struct netdev_queue *txq,
758 void *_unused)
759{
760 lockdep_set_class(&txq->_xmit_lock, &batadv_netdev_xmit_lock_key);
761}
762
763/**
764 * batadv_set_lockdep_class() - Set txq and addr_list lockdep class
765 * @dev: network device to modify
766 */
767static void batadv_set_lockdep_class(struct net_device *dev)
768{
769 lockdep_set_class(&dev->addr_list_lock, &batadv_netdev_addr_lock_key);
770 netdev_for_each_tx_queue(dev, batadv_set_lockdep_class_one, NULL);
771}
772
773/** 743/**
774 * batadv_softif_init_late() - late stage initialization of soft interface 744 * batadv_softif_init_late() - late stage initialization of soft interface
775 * @dev: registered network device to modify 745 * @dev: registered network device to modify
@@ -783,8 +753,6 @@ static int batadv_softif_init_late(struct net_device *dev)
783 int ret; 753 int ret;
784 size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM; 754 size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM;
785 755
786 batadv_set_lockdep_class(dev);
787
788 bat_priv = netdev_priv(dev); 756 bat_priv = netdev_priv(dev);
789 bat_priv->soft_iface = dev; 757 bat_priv->soft_iface = dev;
790 758
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index be7c02aa91e2..4d7f1baee7b7 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -17,6 +17,7 @@
17#include <linux/if.h> 17#include <linux/if.h>
18#include <linux/if_ether.h> 18#include <linux/if_ether.h>
19#include <linux/kref.h> 19#include <linux/kref.h>
20#include <linux/mutex.h>
20#include <linux/netdevice.h> 21#include <linux/netdevice.h>
21#include <linux/netlink.h> 22#include <linux/netlink.h>
22#include <linux/sched.h> /* for linux/wait.h */ 23#include <linux/sched.h> /* for linux/wait.h */
@@ -81,6 +82,9 @@ struct batadv_hard_iface_bat_iv {
81 82
82 /** @ogm_seqno: OGM sequence number - used to identify each OGM */ 83 /** @ogm_seqno: OGM sequence number - used to identify each OGM */
83 atomic_t ogm_seqno; 84 atomic_t ogm_seqno;
85
86 /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
87 struct mutex ogm_buff_mutex;
84}; 88};
85 89
86/** 90/**
@@ -1539,6 +1543,9 @@ struct batadv_priv_bat_v {
1539 /** @ogm_seqno: OGM sequence number - used to identify each OGM */ 1543 /** @ogm_seqno: OGM sequence number - used to identify each OGM */
1540 atomic_t ogm_seqno; 1544 atomic_t ogm_seqno;
1541 1545
1546 /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
1547 struct mutex ogm_buff_mutex;
1548
1542 /** @ogm_wq: workqueue used to schedule OGM transmissions */ 1549 /** @ogm_wq: workqueue used to schedule OGM transmissions */
1543 struct delayed_work ogm_wq; 1550 struct delayed_work ogm_wq;
1544}; 1551};
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index bb55d92691b0..4febc82a7c76 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -571,15 +571,7 @@ static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev)
571 return err < 0 ? NET_XMIT_DROP : err; 571 return err < 0 ? NET_XMIT_DROP : err;
572} 572}
573 573
574static int bt_dev_init(struct net_device *dev)
575{
576 netdev_lockdep_set_classes(dev);
577
578 return 0;
579}
580
581static const struct net_device_ops netdev_ops = { 574static const struct net_device_ops netdev_ops = {
582 .ndo_init = bt_dev_init,
583 .ndo_start_xmit = bt_xmit, 575 .ndo_start_xmit = bt_xmit,
584}; 576};
585 577
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 94ddf19998c7..5f508c50649d 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -460,7 +460,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
460 if (sk->sk_state == BT_LISTEN) 460 if (sk->sk_state == BT_LISTEN)
461 return bt_accept_poll(sk); 461 return bt_accept_poll(sk);
462 462
463 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 463 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
464 mask |= EPOLLERR | 464 mask |= EPOLLERR |
465 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); 465 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
466 466
@@ -470,7 +470,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
470 if (sk->sk_shutdown == SHUTDOWN_MASK) 470 if (sk->sk_shutdown == SHUTDOWN_MASK)
471 mask |= EPOLLHUP; 471 mask |= EPOLLHUP;
472 472
473 if (!skb_queue_empty(&sk->sk_receive_queue)) 473 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
474 mask |= EPOLLIN | EPOLLRDNORM; 474 mask |= EPOLLIN | EPOLLRDNORM;
475 475
476 if (sk->sk_state == BT_CLOSED) 476 if (sk->sk_state == BT_CLOSED)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 681b72862c16..e804a3016902 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -24,8 +24,6 @@
24const struct nf_br_ops __rcu *nf_br_ops __read_mostly; 24const struct nf_br_ops __rcu *nf_br_ops __read_mostly;
25EXPORT_SYMBOL_GPL(nf_br_ops); 25EXPORT_SYMBOL_GPL(nf_br_ops);
26 26
27static struct lock_class_key bridge_netdev_addr_lock_key;
28
29/* net device transmit always called with BH disabled */ 27/* net device transmit always called with BH disabled */
30netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) 28netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
31{ 29{
@@ -108,11 +106,6 @@ out:
108 return NETDEV_TX_OK; 106 return NETDEV_TX_OK;
109} 107}
110 108
111static void br_set_lockdep_class(struct net_device *dev)
112{
113 lockdep_set_class(&dev->addr_list_lock, &bridge_netdev_addr_lock_key);
114}
115
116static int br_dev_init(struct net_device *dev) 109static int br_dev_init(struct net_device *dev)
117{ 110{
118 struct net_bridge *br = netdev_priv(dev); 111 struct net_bridge *br = netdev_priv(dev);
@@ -150,7 +143,6 @@ static int br_dev_init(struct net_device *dev)
150 br_mdb_hash_fini(br); 143 br_mdb_hash_fini(br);
151 br_fdb_hash_fini(br); 144 br_fdb_hash_fini(br);
152 } 145 }
153 br_set_lockdep_class(dev);
154 146
155 return err; 147 return err;
156} 148}
diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
index 506d6141e44e..809673222382 100644
--- a/net/bridge/netfilter/nf_conntrack_bridge.c
+++ b/net/bridge/netfilter/nf_conntrack_bridge.c
@@ -95,7 +95,7 @@ slow_path:
95 * This may also be a clone skbuff, we could preserve the geometry for 95 * This may also be a clone skbuff, we could preserve the geometry for
96 * the copies but probably not worth the effort. 96 * the copies but probably not worth the effort.
97 */ 97 */
98 ip_frag_init(skb, hlen, ll_rs, frag_max_size, &state); 98 ip_frag_init(skb, hlen, ll_rs, frag_max_size, false, &state);
99 99
100 while (state.left > 0) { 100 while (state.left > 0) {
101 struct sk_buff *skb2; 101 struct sk_buff *skb2;
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index 13ea920600ae..ef14da50a981 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -953,7 +953,7 @@ static __poll_t caif_poll(struct file *file,
953 mask |= EPOLLRDHUP; 953 mask |= EPOLLRDHUP;
954 954
955 /* readable? */ 955 /* readable? */
956 if (!skb_queue_empty(&sk->sk_receive_queue) || 956 if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
957 (sk->sk_shutdown & RCV_SHUTDOWN)) 957 (sk->sk_shutdown & RCV_SHUTDOWN))
958 mask |= EPOLLIN | EPOLLRDNORM; 958 mask |= EPOLLIN | EPOLLRDNORM;
959 959
diff --git a/net/core/datagram.c b/net/core/datagram.c
index c210fc116103..da3c24ed129c 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -97,7 +97,7 @@ int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p,
97 if (error) 97 if (error)
98 goto out_err; 98 goto out_err;
99 99
100 if (sk->sk_receive_queue.prev != skb) 100 if (READ_ONCE(sk->sk_receive_queue.prev) != skb)
101 goto out; 101 goto out;
102 102
103 /* Socket shut down? */ 103 /* Socket shut down? */
@@ -278,7 +278,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
278 break; 278 break;
279 279
280 sk_busy_loop(sk, flags & MSG_DONTWAIT); 280 sk_busy_loop(sk, flags & MSG_DONTWAIT);
281 } while (sk->sk_receive_queue.prev != *last); 281 } while (READ_ONCE(sk->sk_receive_queue.prev) != *last);
282 282
283 error = -EAGAIN; 283 error = -EAGAIN;
284 284
@@ -767,7 +767,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
767 mask = 0; 767 mask = 0;
768 768
769 /* exceptional events? */ 769 /* exceptional events? */
770 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 770 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
771 mask |= EPOLLERR | 771 mask |= EPOLLERR |
772 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); 772 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
773 773
@@ -777,7 +777,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
777 mask |= EPOLLHUP; 777 mask |= EPOLLHUP;
778 778
779 /* readable? */ 779 /* readable? */
780 if (!skb_queue_empty(&sk->sk_receive_queue)) 780 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
781 mask |= EPOLLIN | EPOLLRDNORM; 781 mask |= EPOLLIN | EPOLLRDNORM;
782 782
783 /* Connection-based need to check for termination and startup */ 783 /* Connection-based need to check for termination and startup */
diff --git a/net/core/dev.c b/net/core/dev.c
index bf3ed413abaf..99ac84ff398f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -146,6 +146,7 @@
146#include "net-sysfs.h" 146#include "net-sysfs.h"
147 147
148#define MAX_GRO_SKBS 8 148#define MAX_GRO_SKBS 8
149#define MAX_NEST_DEV 8
149 150
150/* This should be increased if a protocol with a bigger head is added. */ 151/* This should be increased if a protocol with a bigger head is added. */
151#define GRO_MAX_HEAD (MAX_HEADER + 128) 152#define GRO_MAX_HEAD (MAX_HEADER + 128)
@@ -276,88 +277,6 @@ static RAW_NOTIFIER_HEAD(netdev_chain);
276DEFINE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); 277DEFINE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
277EXPORT_PER_CPU_SYMBOL(softnet_data); 278EXPORT_PER_CPU_SYMBOL(softnet_data);
278 279
279#ifdef CONFIG_LOCKDEP
280/*
281 * register_netdevice() inits txq->_xmit_lock and sets lockdep class
282 * according to dev->type
283 */
284static const unsigned short netdev_lock_type[] = {
285 ARPHRD_NETROM, ARPHRD_ETHER, ARPHRD_EETHER, ARPHRD_AX25,
286 ARPHRD_PRONET, ARPHRD_CHAOS, ARPHRD_IEEE802, ARPHRD_ARCNET,
287 ARPHRD_APPLETLK, ARPHRD_DLCI, ARPHRD_ATM, ARPHRD_METRICOM,
288 ARPHRD_IEEE1394, ARPHRD_EUI64, ARPHRD_INFINIBAND, ARPHRD_SLIP,
289 ARPHRD_CSLIP, ARPHRD_SLIP6, ARPHRD_CSLIP6, ARPHRD_RSRVD,
290 ARPHRD_ADAPT, ARPHRD_ROSE, ARPHRD_X25, ARPHRD_HWX25,
291 ARPHRD_PPP, ARPHRD_CISCO, ARPHRD_LAPB, ARPHRD_DDCMP,
292 ARPHRD_RAWHDLC, ARPHRD_TUNNEL, ARPHRD_TUNNEL6, ARPHRD_FRAD,
293 ARPHRD_SKIP, ARPHRD_LOOPBACK, ARPHRD_LOCALTLK, ARPHRD_FDDI,
294 ARPHRD_BIF, ARPHRD_SIT, ARPHRD_IPDDP, ARPHRD_IPGRE,
295 ARPHRD_PIMREG, ARPHRD_HIPPI, ARPHRD_ASH, ARPHRD_ECONET,
296 ARPHRD_IRDA, ARPHRD_FCPP, ARPHRD_FCAL, ARPHRD_FCPL,
297 ARPHRD_FCFABRIC, ARPHRD_IEEE80211, ARPHRD_IEEE80211_PRISM,
298 ARPHRD_IEEE80211_RADIOTAP, ARPHRD_PHONET, ARPHRD_PHONET_PIPE,
299 ARPHRD_IEEE802154, ARPHRD_VOID, ARPHRD_NONE};
300
301static const char *const netdev_lock_name[] = {
302 "_xmit_NETROM", "_xmit_ETHER", "_xmit_EETHER", "_xmit_AX25",
303 "_xmit_PRONET", "_xmit_CHAOS", "_xmit_IEEE802", "_xmit_ARCNET",
304 "_xmit_APPLETLK", "_xmit_DLCI", "_xmit_ATM", "_xmit_METRICOM",
305 "_xmit_IEEE1394", "_xmit_EUI64", "_xmit_INFINIBAND", "_xmit_SLIP",
306 "_xmit_CSLIP", "_xmit_SLIP6", "_xmit_CSLIP6", "_xmit_RSRVD",
307 "_xmit_ADAPT", "_xmit_ROSE", "_xmit_X25", "_xmit_HWX25",
308 "_xmit_PPP", "_xmit_CISCO", "_xmit_LAPB", "_xmit_DDCMP",
309 "_xmit_RAWHDLC", "_xmit_TUNNEL", "_xmit_TUNNEL6", "_xmit_FRAD",
310 "_xmit_SKIP", "_xmit_LOOPBACK", "_xmit_LOCALTLK", "_xmit_FDDI",
311 "_xmit_BIF", "_xmit_SIT", "_xmit_IPDDP", "_xmit_IPGRE",
312 "_xmit_PIMREG", "_xmit_HIPPI", "_xmit_ASH", "_xmit_ECONET",
313 "_xmit_IRDA", "_xmit_FCPP", "_xmit_FCAL", "_xmit_FCPL",
314 "_xmit_FCFABRIC", "_xmit_IEEE80211", "_xmit_IEEE80211_PRISM",
315 "_xmit_IEEE80211_RADIOTAP", "_xmit_PHONET", "_xmit_PHONET_PIPE",
316 "_xmit_IEEE802154", "_xmit_VOID", "_xmit_NONE"};
317
318static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)];
319static struct lock_class_key netdev_addr_lock_key[ARRAY_SIZE(netdev_lock_type)];
320
321static inline unsigned short netdev_lock_pos(unsigned short dev_type)
322{
323 int i;
324
325 for (i = 0; i < ARRAY_SIZE(netdev_lock_type); i++)
326 if (netdev_lock_type[i] == dev_type)
327 return i;
328 /* the last key is used by default */
329 return ARRAY_SIZE(netdev_lock_type) - 1;
330}
331
332static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock,
333 unsigned short dev_type)
334{
335 int i;
336
337 i = netdev_lock_pos(dev_type);
338 lockdep_set_class_and_name(lock, &netdev_xmit_lock_key[i],
339 netdev_lock_name[i]);
340}
341
342static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
343{
344 int i;
345
346 i = netdev_lock_pos(dev->type);
347 lockdep_set_class_and_name(&dev->addr_list_lock,
348 &netdev_addr_lock_key[i],
349 netdev_lock_name[i]);
350}
351#else
352static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock,
353 unsigned short dev_type)
354{
355}
356static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
357{
358}
359#endif
360
361/******************************************************************************* 280/*******************************************************************************
362 * 281 *
363 * Protocol management and registration routines 282 * Protocol management and registration routines
@@ -6489,6 +6408,9 @@ struct netdev_adjacent {
6489 /* upper master flag, there can only be one master device per list */ 6408 /* upper master flag, there can only be one master device per list */
6490 bool master; 6409 bool master;
6491 6410
6411 /* lookup ignore flag */
6412 bool ignore;
6413
6492 /* counter for the number of times this device was added to us */ 6414 /* counter for the number of times this device was added to us */
6493 u16 ref_nr; 6415 u16 ref_nr;
6494 6416
@@ -6511,7 +6433,7 @@ static struct netdev_adjacent *__netdev_find_adj(struct net_device *adj_dev,
6511 return NULL; 6433 return NULL;
6512} 6434}
6513 6435
6514static int __netdev_has_upper_dev(struct net_device *upper_dev, void *data) 6436static int ____netdev_has_upper_dev(struct net_device *upper_dev, void *data)
6515{ 6437{
6516 struct net_device *dev = data; 6438 struct net_device *dev = data;
6517 6439
@@ -6532,7 +6454,7 @@ bool netdev_has_upper_dev(struct net_device *dev,
6532{ 6454{
6533 ASSERT_RTNL(); 6455 ASSERT_RTNL();
6534 6456
6535 return netdev_walk_all_upper_dev_rcu(dev, __netdev_has_upper_dev, 6457 return netdev_walk_all_upper_dev_rcu(dev, ____netdev_has_upper_dev,
6536 upper_dev); 6458 upper_dev);
6537} 6459}
6538EXPORT_SYMBOL(netdev_has_upper_dev); 6460EXPORT_SYMBOL(netdev_has_upper_dev);
@@ -6550,7 +6472,7 @@ EXPORT_SYMBOL(netdev_has_upper_dev);
6550bool netdev_has_upper_dev_all_rcu(struct net_device *dev, 6472bool netdev_has_upper_dev_all_rcu(struct net_device *dev,
6551 struct net_device *upper_dev) 6473 struct net_device *upper_dev)
6552{ 6474{
6553 return !!netdev_walk_all_upper_dev_rcu(dev, __netdev_has_upper_dev, 6475 return !!netdev_walk_all_upper_dev_rcu(dev, ____netdev_has_upper_dev,
6554 upper_dev); 6476 upper_dev);
6555} 6477}
6556EXPORT_SYMBOL(netdev_has_upper_dev_all_rcu); 6478EXPORT_SYMBOL(netdev_has_upper_dev_all_rcu);
@@ -6594,6 +6516,22 @@ struct net_device *netdev_master_upper_dev_get(struct net_device *dev)
6594} 6516}
6595EXPORT_SYMBOL(netdev_master_upper_dev_get); 6517EXPORT_SYMBOL(netdev_master_upper_dev_get);
6596 6518
6519static struct net_device *__netdev_master_upper_dev_get(struct net_device *dev)
6520{
6521 struct netdev_adjacent *upper;
6522
6523 ASSERT_RTNL();
6524
6525 if (list_empty(&dev->adj_list.upper))
6526 return NULL;
6527
6528 upper = list_first_entry(&dev->adj_list.upper,
6529 struct netdev_adjacent, list);
6530 if (likely(upper->master) && !upper->ignore)
6531 return upper->dev;
6532 return NULL;
6533}
6534
6597/** 6535/**
6598 * netdev_has_any_lower_dev - Check if device is linked to some device 6536 * netdev_has_any_lower_dev - Check if device is linked to some device
6599 * @dev: device 6537 * @dev: device
@@ -6644,6 +6582,23 @@ struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev,
6644} 6582}
6645EXPORT_SYMBOL(netdev_upper_get_next_dev_rcu); 6583EXPORT_SYMBOL(netdev_upper_get_next_dev_rcu);
6646 6584
6585static struct net_device *__netdev_next_upper_dev(struct net_device *dev,
6586 struct list_head **iter,
6587 bool *ignore)
6588{
6589 struct netdev_adjacent *upper;
6590
6591 upper = list_entry((*iter)->next, struct netdev_adjacent, list);
6592
6593 if (&upper->list == &dev->adj_list.upper)
6594 return NULL;
6595
6596 *iter = &upper->list;
6597 *ignore = upper->ignore;
6598
6599 return upper->dev;
6600}
6601
6647static struct net_device *netdev_next_upper_dev_rcu(struct net_device *dev, 6602static struct net_device *netdev_next_upper_dev_rcu(struct net_device *dev,
6648 struct list_head **iter) 6603 struct list_head **iter)
6649{ 6604{
@@ -6661,34 +6616,111 @@ static struct net_device *netdev_next_upper_dev_rcu(struct net_device *dev,
6661 return upper->dev; 6616 return upper->dev;
6662} 6617}
6663 6618
6619static int __netdev_walk_all_upper_dev(struct net_device *dev,
6620 int (*fn)(struct net_device *dev,
6621 void *data),
6622 void *data)
6623{
6624 struct net_device *udev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
6625 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
6626 int ret, cur = 0;
6627 bool ignore;
6628
6629 now = dev;
6630 iter = &dev->adj_list.upper;
6631
6632 while (1) {
6633 if (now != dev) {
6634 ret = fn(now, data);
6635 if (ret)
6636 return ret;
6637 }
6638
6639 next = NULL;
6640 while (1) {
6641 udev = __netdev_next_upper_dev(now, &iter, &ignore);
6642 if (!udev)
6643 break;
6644 if (ignore)
6645 continue;
6646
6647 next = udev;
6648 niter = &udev->adj_list.upper;
6649 dev_stack[cur] = now;
6650 iter_stack[cur++] = iter;
6651 break;
6652 }
6653
6654 if (!next) {
6655 if (!cur)
6656 return 0;
6657 next = dev_stack[--cur];
6658 niter = iter_stack[cur];
6659 }
6660
6661 now = next;
6662 iter = niter;
6663 }
6664
6665 return 0;
6666}
6667
6664int netdev_walk_all_upper_dev_rcu(struct net_device *dev, 6668int netdev_walk_all_upper_dev_rcu(struct net_device *dev,
6665 int (*fn)(struct net_device *dev, 6669 int (*fn)(struct net_device *dev,
6666 void *data), 6670 void *data),
6667 void *data) 6671 void *data)
6668{ 6672{
6669 struct net_device *udev; 6673 struct net_device *udev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
6670 struct list_head *iter; 6674 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
6671 int ret; 6675 int ret, cur = 0;
6672 6676
6673 for (iter = &dev->adj_list.upper, 6677 now = dev;
6674 udev = netdev_next_upper_dev_rcu(dev, &iter); 6678 iter = &dev->adj_list.upper;
6675 udev;
6676 udev = netdev_next_upper_dev_rcu(dev, &iter)) {
6677 /* first is the upper device itself */
6678 ret = fn(udev, data);
6679 if (ret)
6680 return ret;
6681 6679
6682 /* then look at all of its upper devices */ 6680 while (1) {
6683 ret = netdev_walk_all_upper_dev_rcu(udev, fn, data); 6681 if (now != dev) {
6684 if (ret) 6682 ret = fn(now, data);
6685 return ret; 6683 if (ret)
6684 return ret;
6685 }
6686
6687 next = NULL;
6688 while (1) {
6689 udev = netdev_next_upper_dev_rcu(now, &iter);
6690 if (!udev)
6691 break;
6692
6693 next = udev;
6694 niter = &udev->adj_list.upper;
6695 dev_stack[cur] = now;
6696 iter_stack[cur++] = iter;
6697 break;
6698 }
6699
6700 if (!next) {
6701 if (!cur)
6702 return 0;
6703 next = dev_stack[--cur];
6704 niter = iter_stack[cur];
6705 }
6706
6707 now = next;
6708 iter = niter;
6686 } 6709 }
6687 6710
6688 return 0; 6711 return 0;
6689} 6712}
6690EXPORT_SYMBOL_GPL(netdev_walk_all_upper_dev_rcu); 6713EXPORT_SYMBOL_GPL(netdev_walk_all_upper_dev_rcu);
6691 6714
6715static bool __netdev_has_upper_dev(struct net_device *dev,
6716 struct net_device *upper_dev)
6717{
6718 ASSERT_RTNL();
6719
6720 return __netdev_walk_all_upper_dev(dev, ____netdev_has_upper_dev,
6721 upper_dev);
6722}
6723
6692/** 6724/**
6693 * netdev_lower_get_next_private - Get the next ->private from the 6725 * netdev_lower_get_next_private - Get the next ->private from the
6694 * lower neighbour list 6726 * lower neighbour list
@@ -6785,34 +6817,119 @@ static struct net_device *netdev_next_lower_dev(struct net_device *dev,
6785 return lower->dev; 6817 return lower->dev;
6786} 6818}
6787 6819
6820static struct net_device *__netdev_next_lower_dev(struct net_device *dev,
6821 struct list_head **iter,
6822 bool *ignore)
6823{
6824 struct netdev_adjacent *lower;
6825
6826 lower = list_entry((*iter)->next, struct netdev_adjacent, list);
6827
6828 if (&lower->list == &dev->adj_list.lower)
6829 return NULL;
6830
6831 *iter = &lower->list;
6832 *ignore = lower->ignore;
6833
6834 return lower->dev;
6835}
6836
6788int netdev_walk_all_lower_dev(struct net_device *dev, 6837int netdev_walk_all_lower_dev(struct net_device *dev,
6789 int (*fn)(struct net_device *dev, 6838 int (*fn)(struct net_device *dev,
6790 void *data), 6839 void *data),
6791 void *data) 6840 void *data)
6792{ 6841{
6793 struct net_device *ldev; 6842 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
6794 struct list_head *iter; 6843 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
6795 int ret; 6844 int ret, cur = 0;
6796 6845
6797 for (iter = &dev->adj_list.lower, 6846 now = dev;
6798 ldev = netdev_next_lower_dev(dev, &iter); 6847 iter = &dev->adj_list.lower;
6799 ldev;
6800 ldev = netdev_next_lower_dev(dev, &iter)) {
6801 /* first is the lower device itself */
6802 ret = fn(ldev, data);
6803 if (ret)
6804 return ret;
6805 6848
6806 /* then look at all of its lower devices */ 6849 while (1) {
6807 ret = netdev_walk_all_lower_dev(ldev, fn, data); 6850 if (now != dev) {
6808 if (ret) 6851 ret = fn(now, data);
6809 return ret; 6852 if (ret)
6853 return ret;
6854 }
6855
6856 next = NULL;
6857 while (1) {
6858 ldev = netdev_next_lower_dev(now, &iter);
6859 if (!ldev)
6860 break;
6861
6862 next = ldev;
6863 niter = &ldev->adj_list.lower;
6864 dev_stack[cur] = now;
6865 iter_stack[cur++] = iter;
6866 break;
6867 }
6868
6869 if (!next) {
6870 if (!cur)
6871 return 0;
6872 next = dev_stack[--cur];
6873 niter = iter_stack[cur];
6874 }
6875
6876 now = next;
6877 iter = niter;
6810 } 6878 }
6811 6879
6812 return 0; 6880 return 0;
6813} 6881}
6814EXPORT_SYMBOL_GPL(netdev_walk_all_lower_dev); 6882EXPORT_SYMBOL_GPL(netdev_walk_all_lower_dev);
6815 6883
6884static int __netdev_walk_all_lower_dev(struct net_device *dev,
6885 int (*fn)(struct net_device *dev,
6886 void *data),
6887 void *data)
6888{
6889 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
6890 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
6891 int ret, cur = 0;
6892 bool ignore;
6893
6894 now = dev;
6895 iter = &dev->adj_list.lower;
6896
6897 while (1) {
6898 if (now != dev) {
6899 ret = fn(now, data);
6900 if (ret)
6901 return ret;
6902 }
6903
6904 next = NULL;
6905 while (1) {
6906 ldev = __netdev_next_lower_dev(now, &iter, &ignore);
6907 if (!ldev)
6908 break;
6909 if (ignore)
6910 continue;
6911
6912 next = ldev;
6913 niter = &ldev->adj_list.lower;
6914 dev_stack[cur] = now;
6915 iter_stack[cur++] = iter;
6916 break;
6917 }
6918
6919 if (!next) {
6920 if (!cur)
6921 return 0;
6922 next = dev_stack[--cur];
6923 niter = iter_stack[cur];
6924 }
6925
6926 now = next;
6927 iter = niter;
6928 }
6929
6930 return 0;
6931}
6932
6816static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev, 6933static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,
6817 struct list_head **iter) 6934 struct list_head **iter)
6818{ 6935{
@@ -6827,28 +6944,99 @@ static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,
6827 return lower->dev; 6944 return lower->dev;
6828} 6945}
6829 6946
6830int netdev_walk_all_lower_dev_rcu(struct net_device *dev, 6947static u8 __netdev_upper_depth(struct net_device *dev)
6831 int (*fn)(struct net_device *dev, 6948{
6832 void *data), 6949 struct net_device *udev;
6833 void *data) 6950 struct list_head *iter;
6951 u8 max_depth = 0;
6952 bool ignore;
6953
6954 for (iter = &dev->adj_list.upper,
6955 udev = __netdev_next_upper_dev(dev, &iter, &ignore);
6956 udev;
6957 udev = __netdev_next_upper_dev(dev, &iter, &ignore)) {
6958 if (ignore)
6959 continue;
6960 if (max_depth < udev->upper_level)
6961 max_depth = udev->upper_level;
6962 }
6963
6964 return max_depth;
6965}
6966
6967static u8 __netdev_lower_depth(struct net_device *dev)
6834{ 6968{
6835 struct net_device *ldev; 6969 struct net_device *ldev;
6836 struct list_head *iter; 6970 struct list_head *iter;
6837 int ret; 6971 u8 max_depth = 0;
6972 bool ignore;
6838 6973
6839 for (iter = &dev->adj_list.lower, 6974 for (iter = &dev->adj_list.lower,
6840 ldev = netdev_next_lower_dev_rcu(dev, &iter); 6975 ldev = __netdev_next_lower_dev(dev, &iter, &ignore);
6841 ldev; 6976 ldev;
6842 ldev = netdev_next_lower_dev_rcu(dev, &iter)) { 6977 ldev = __netdev_next_lower_dev(dev, &iter, &ignore)) {
6843 /* first is the lower device itself */ 6978 if (ignore)
6844 ret = fn(ldev, data); 6979 continue;
6845 if (ret) 6980 if (max_depth < ldev->lower_level)
6846 return ret; 6981 max_depth = ldev->lower_level;
6982 }
6847 6983
6848 /* then look at all of its lower devices */ 6984 return max_depth;
6849 ret = netdev_walk_all_lower_dev_rcu(ldev, fn, data); 6985}
6850 if (ret) 6986
6851 return ret; 6987static int __netdev_update_upper_level(struct net_device *dev, void *data)
6988{
6989 dev->upper_level = __netdev_upper_depth(dev) + 1;
6990 return 0;
6991}
6992
6993static int __netdev_update_lower_level(struct net_device *dev, void *data)
6994{
6995 dev->lower_level = __netdev_lower_depth(dev) + 1;
6996 return 0;
6997}
6998
6999int netdev_walk_all_lower_dev_rcu(struct net_device *dev,
7000 int (*fn)(struct net_device *dev,
7001 void *data),
7002 void *data)
7003{
7004 struct net_device *ldev, *next, *now, *dev_stack[MAX_NEST_DEV + 1];
7005 struct list_head *niter, *iter, *iter_stack[MAX_NEST_DEV + 1];
7006 int ret, cur = 0;
7007
7008 now = dev;
7009 iter = &dev->adj_list.lower;
7010
7011 while (1) {
7012 if (now != dev) {
7013 ret = fn(now, data);
7014 if (ret)
7015 return ret;
7016 }
7017
7018 next = NULL;
7019 while (1) {
7020 ldev = netdev_next_lower_dev_rcu(now, &iter);
7021 if (!ldev)
7022 break;
7023
7024 next = ldev;
7025 niter = &ldev->adj_list.lower;
7026 dev_stack[cur] = now;
7027 iter_stack[cur++] = iter;
7028 break;
7029 }
7030
7031 if (!next) {
7032 if (!cur)
7033 return 0;
7034 next = dev_stack[--cur];
7035 niter = iter_stack[cur];
7036 }
7037
7038 now = next;
7039 iter = niter;
6852 } 7040 }
6853 7041
6854 return 0; 7042 return 0;
@@ -6952,6 +7140,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
6952 adj->master = master; 7140 adj->master = master;
6953 adj->ref_nr = 1; 7141 adj->ref_nr = 1;
6954 adj->private = private; 7142 adj->private = private;
7143 adj->ignore = false;
6955 dev_hold(adj_dev); 7144 dev_hold(adj_dev);
6956 7145
6957 pr_debug("Insert adjacency: dev %s adj_dev %s adj->ref_nr %d; dev_hold on %s\n", 7146 pr_debug("Insert adjacency: dev %s adj_dev %s adj->ref_nr %d; dev_hold on %s\n",
@@ -7102,14 +7291,17 @@ static int __netdev_upper_dev_link(struct net_device *dev,
7102 return -EBUSY; 7291 return -EBUSY;
7103 7292
7104 /* To prevent loops, check if dev is not upper device to upper_dev. */ 7293 /* To prevent loops, check if dev is not upper device to upper_dev. */
7105 if (netdev_has_upper_dev(upper_dev, dev)) 7294 if (__netdev_has_upper_dev(upper_dev, dev))
7106 return -EBUSY; 7295 return -EBUSY;
7107 7296
7297 if ((dev->lower_level + upper_dev->upper_level) > MAX_NEST_DEV)
7298 return -EMLINK;
7299
7108 if (!master) { 7300 if (!master) {
7109 if (netdev_has_upper_dev(dev, upper_dev)) 7301 if (__netdev_has_upper_dev(dev, upper_dev))
7110 return -EEXIST; 7302 return -EEXIST;
7111 } else { 7303 } else {
7112 master_dev = netdev_master_upper_dev_get(dev); 7304 master_dev = __netdev_master_upper_dev_get(dev);
7113 if (master_dev) 7305 if (master_dev)
7114 return master_dev == upper_dev ? -EEXIST : -EBUSY; 7306 return master_dev == upper_dev ? -EEXIST : -EBUSY;
7115 } 7307 }
@@ -7131,6 +7323,13 @@ static int __netdev_upper_dev_link(struct net_device *dev,
7131 if (ret) 7323 if (ret)
7132 goto rollback; 7324 goto rollback;
7133 7325
7326 __netdev_update_upper_level(dev, NULL);
7327 __netdev_walk_all_lower_dev(dev, __netdev_update_upper_level, NULL);
7328
7329 __netdev_update_lower_level(upper_dev, NULL);
7330 __netdev_walk_all_upper_dev(upper_dev, __netdev_update_lower_level,
7331 NULL);
7332
7134 return 0; 7333 return 0;
7135 7334
7136rollback: 7335rollback:
@@ -7213,9 +7412,96 @@ void netdev_upper_dev_unlink(struct net_device *dev,
7213 7412
7214 call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, 7413 call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
7215 &changeupper_info.info); 7414 &changeupper_info.info);
7415
7416 __netdev_update_upper_level(dev, NULL);
7417 __netdev_walk_all_lower_dev(dev, __netdev_update_upper_level, NULL);
7418
7419 __netdev_update_lower_level(upper_dev, NULL);
7420 __netdev_walk_all_upper_dev(upper_dev, __netdev_update_lower_level,
7421 NULL);
7216} 7422}
7217EXPORT_SYMBOL(netdev_upper_dev_unlink); 7423EXPORT_SYMBOL(netdev_upper_dev_unlink);
7218 7424
7425static void __netdev_adjacent_dev_set(struct net_device *upper_dev,
7426 struct net_device *lower_dev,
7427 bool val)
7428{
7429 struct netdev_adjacent *adj;
7430
7431 adj = __netdev_find_adj(lower_dev, &upper_dev->adj_list.lower);
7432 if (adj)
7433 adj->ignore = val;
7434
7435 adj = __netdev_find_adj(upper_dev, &lower_dev->adj_list.upper);
7436 if (adj)
7437 adj->ignore = val;
7438}
7439
7440static void netdev_adjacent_dev_disable(struct net_device *upper_dev,
7441 struct net_device *lower_dev)
7442{
7443 __netdev_adjacent_dev_set(upper_dev, lower_dev, true);
7444}
7445
7446static void netdev_adjacent_dev_enable(struct net_device *upper_dev,
7447 struct net_device *lower_dev)
7448{
7449 __netdev_adjacent_dev_set(upper_dev, lower_dev, false);
7450}
7451
7452int netdev_adjacent_change_prepare(struct net_device *old_dev,
7453 struct net_device *new_dev,
7454 struct net_device *dev,
7455 struct netlink_ext_ack *extack)
7456{
7457 int err;
7458
7459 if (!new_dev)
7460 return 0;
7461
7462 if (old_dev && new_dev != old_dev)
7463 netdev_adjacent_dev_disable(dev, old_dev);
7464
7465 err = netdev_upper_dev_link(new_dev, dev, extack);
7466 if (err) {
7467 if (old_dev && new_dev != old_dev)
7468 netdev_adjacent_dev_enable(dev, old_dev);
7469 return err;
7470 }
7471
7472 return 0;
7473}
7474EXPORT_SYMBOL(netdev_adjacent_change_prepare);
7475
7476void netdev_adjacent_change_commit(struct net_device *old_dev,
7477 struct net_device *new_dev,
7478 struct net_device *dev)
7479{
7480 if (!new_dev || !old_dev)
7481 return;
7482
7483 if (new_dev == old_dev)
7484 return;
7485
7486 netdev_adjacent_dev_enable(dev, old_dev);
7487 netdev_upper_dev_unlink(old_dev, dev);
7488}
7489EXPORT_SYMBOL(netdev_adjacent_change_commit);
7490
7491void netdev_adjacent_change_abort(struct net_device *old_dev,
7492 struct net_device *new_dev,
7493 struct net_device *dev)
7494{
7495 if (!new_dev)
7496 return;
7497
7498 if (old_dev && new_dev != old_dev)
7499 netdev_adjacent_dev_enable(dev, old_dev);
7500
7501 netdev_upper_dev_unlink(new_dev, dev);
7502}
7503EXPORT_SYMBOL(netdev_adjacent_change_abort);
7504
7219/** 7505/**
7220 * netdev_bonding_info_change - Dispatch event about slave change 7506 * netdev_bonding_info_change - Dispatch event about slave change
7221 * @dev: device 7507 * @dev: device
@@ -7329,25 +7615,6 @@ void *netdev_lower_dev_get_private(struct net_device *dev,
7329EXPORT_SYMBOL(netdev_lower_dev_get_private); 7615EXPORT_SYMBOL(netdev_lower_dev_get_private);
7330 7616
7331 7617
7332int dev_get_nest_level(struct net_device *dev)
7333{
7334 struct net_device *lower = NULL;
7335 struct list_head *iter;
7336 int max_nest = -1;
7337 int nest;
7338
7339 ASSERT_RTNL();
7340
7341 netdev_for_each_lower_dev(dev, lower, iter) {
7342 nest = dev_get_nest_level(lower);
7343 if (max_nest < nest)
7344 max_nest = nest;
7345 }
7346
7347 return max_nest + 1;
7348}
7349EXPORT_SYMBOL(dev_get_nest_level);
7350
7351/** 7618/**
7352 * netdev_lower_change - Dispatch event about lower device state change 7619 * netdev_lower_change - Dispatch event about lower device state change
7353 * @lower_dev: device 7620 * @lower_dev: device
@@ -8154,7 +8421,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
8154 return -EINVAL; 8421 return -EINVAL;
8155 } 8422 }
8156 8423
8157 if (prog->aux->id == prog_id) { 8424 /* prog->aux->id may be 0 for orphaned device-bound progs */
8425 if (prog->aux->id && prog->aux->id == prog_id) {
8158 bpf_prog_put(prog); 8426 bpf_prog_put(prog);
8159 return 0; 8427 return 0;
8160 } 8428 }
@@ -8619,7 +8887,7 @@ static void netdev_init_one_queue(struct net_device *dev,
8619{ 8887{
8620 /* Initialize queue lock */ 8888 /* Initialize queue lock */
8621 spin_lock_init(&queue->_xmit_lock); 8889 spin_lock_init(&queue->_xmit_lock);
8622 netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); 8890 lockdep_set_class(&queue->_xmit_lock, &dev->qdisc_xmit_lock_key);
8623 queue->xmit_lock_owner = -1; 8891 queue->xmit_lock_owner = -1;
8624 netdev_queue_numa_node_write(queue, NUMA_NO_NODE); 8892 netdev_queue_numa_node_write(queue, NUMA_NO_NODE);
8625 queue->dev = dev; 8893 queue->dev = dev;
@@ -8666,6 +8934,43 @@ void netif_tx_stop_all_queues(struct net_device *dev)
8666} 8934}
8667EXPORT_SYMBOL(netif_tx_stop_all_queues); 8935EXPORT_SYMBOL(netif_tx_stop_all_queues);
8668 8936
8937static void netdev_register_lockdep_key(struct net_device *dev)
8938{
8939 lockdep_register_key(&dev->qdisc_tx_busylock_key);
8940 lockdep_register_key(&dev->qdisc_running_key);
8941 lockdep_register_key(&dev->qdisc_xmit_lock_key);
8942 lockdep_register_key(&dev->addr_list_lock_key);
8943}
8944
8945static void netdev_unregister_lockdep_key(struct net_device *dev)
8946{
8947 lockdep_unregister_key(&dev->qdisc_tx_busylock_key);
8948 lockdep_unregister_key(&dev->qdisc_running_key);
8949 lockdep_unregister_key(&dev->qdisc_xmit_lock_key);
8950 lockdep_unregister_key(&dev->addr_list_lock_key);
8951}
8952
8953void netdev_update_lockdep_key(struct net_device *dev)
8954{
8955 struct netdev_queue *queue;
8956 int i;
8957
8958 lockdep_unregister_key(&dev->qdisc_xmit_lock_key);
8959 lockdep_unregister_key(&dev->addr_list_lock_key);
8960
8961 lockdep_register_key(&dev->qdisc_xmit_lock_key);
8962 lockdep_register_key(&dev->addr_list_lock_key);
8963
8964 lockdep_set_class(&dev->addr_list_lock, &dev->addr_list_lock_key);
8965 for (i = 0; i < dev->num_tx_queues; i++) {
8966 queue = netdev_get_tx_queue(dev, i);
8967
8968 lockdep_set_class(&queue->_xmit_lock,
8969 &dev->qdisc_xmit_lock_key);
8970 }
8971}
8972EXPORT_SYMBOL(netdev_update_lockdep_key);
8973
8669/** 8974/**
8670 * register_netdevice - register a network device 8975 * register_netdevice - register a network device
8671 * @dev: device to register 8976 * @dev: device to register
@@ -8700,7 +9005,7 @@ int register_netdevice(struct net_device *dev)
8700 BUG_ON(!net); 9005 BUG_ON(!net);
8701 9006
8702 spin_lock_init(&dev->addr_list_lock); 9007 spin_lock_init(&dev->addr_list_lock);
8703 netdev_set_addr_lockdep_class(dev); 9008 lockdep_set_class(&dev->addr_list_lock, &dev->addr_list_lock_key);
8704 9009
8705 ret = dev_get_valid_name(net, dev, dev->name); 9010 ret = dev_get_valid_name(net, dev, dev->name);
8706 if (ret < 0) 9011 if (ret < 0)
@@ -9210,8 +9515,12 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
9210 9515
9211 dev_net_set(dev, &init_net); 9516 dev_net_set(dev, &init_net);
9212 9517
9518 netdev_register_lockdep_key(dev);
9519
9213 dev->gso_max_size = GSO_MAX_SIZE; 9520 dev->gso_max_size = GSO_MAX_SIZE;
9214 dev->gso_max_segs = GSO_MAX_SEGS; 9521 dev->gso_max_segs = GSO_MAX_SEGS;
9522 dev->upper_level = 1;
9523 dev->lower_level = 1;
9215 9524
9216 INIT_LIST_HEAD(&dev->napi_list); 9525 INIT_LIST_HEAD(&dev->napi_list);
9217 INIT_LIST_HEAD(&dev->unreg_list); 9526 INIT_LIST_HEAD(&dev->unreg_list);
@@ -9292,6 +9601,8 @@ void free_netdev(struct net_device *dev)
9292 free_percpu(dev->pcpu_refcnt); 9601 free_percpu(dev->pcpu_refcnt);
9293 dev->pcpu_refcnt = NULL; 9602 dev->pcpu_refcnt = NULL;
9294 9603
9604 netdev_unregister_lockdep_key(dev);
9605
9295 /* Compatibility with error handling in drivers */ 9606 /* Compatibility with error handling in drivers */
9296 if (dev->reg_state == NETREG_UNINITIALIZED) { 9607 if (dev->reg_state == NETREG_UNINITIALIZED) {
9297 netdev_freemem(dev); 9608 netdev_freemem(dev);
@@ -9460,7 +9771,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
9460 call_netdevice_notifiers(NETDEV_UNREGISTER, dev); 9771 call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
9461 rcu_barrier(); 9772 rcu_barrier();
9462 9773
9463 new_nsid = peernet2id_alloc(dev_net(dev), net); 9774 new_nsid = peernet2id_alloc(dev_net(dev), net, GFP_KERNEL);
9464 /* If there is an ifindex conflict assign a new one */ 9775 /* If there is an ifindex conflict assign a new one */
9465 if (__dev_get_by_index(net, dev->ifindex)) 9776 if (__dev_get_by_index(net, dev->ifindex))
9466 new_ifindex = dev_new_index(net); 9777 new_ifindex = dev_new_index(net);
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 6393ba930097..2f949b5a1eb9 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -637,7 +637,7 @@ int dev_uc_sync(struct net_device *to, struct net_device *from)
637 if (to->addr_len != from->addr_len) 637 if (to->addr_len != from->addr_len)
638 return -EINVAL; 638 return -EINVAL;
639 639
640 netif_addr_lock_nested(to); 640 netif_addr_lock(to);
641 err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len); 641 err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len);
642 if (!err) 642 if (!err)
643 __dev_set_rx_mode(to); 643 __dev_set_rx_mode(to);
@@ -667,7 +667,7 @@ int dev_uc_sync_multiple(struct net_device *to, struct net_device *from)
667 if (to->addr_len != from->addr_len) 667 if (to->addr_len != from->addr_len)
668 return -EINVAL; 668 return -EINVAL;
669 669
670 netif_addr_lock_nested(to); 670 netif_addr_lock(to);
671 err = __hw_addr_sync_multiple(&to->uc, &from->uc, to->addr_len); 671 err = __hw_addr_sync_multiple(&to->uc, &from->uc, to->addr_len);
672 if (!err) 672 if (!err)
673 __dev_set_rx_mode(to); 673 __dev_set_rx_mode(to);
@@ -691,7 +691,7 @@ void dev_uc_unsync(struct net_device *to, struct net_device *from)
691 return; 691 return;
692 692
693 netif_addr_lock_bh(from); 693 netif_addr_lock_bh(from);
694 netif_addr_lock_nested(to); 694 netif_addr_lock(to);
695 __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); 695 __hw_addr_unsync(&to->uc, &from->uc, to->addr_len);
696 __dev_set_rx_mode(to); 696 __dev_set_rx_mode(to);
697 netif_addr_unlock(to); 697 netif_addr_unlock(to);
@@ -858,7 +858,7 @@ int dev_mc_sync(struct net_device *to, struct net_device *from)
858 if (to->addr_len != from->addr_len) 858 if (to->addr_len != from->addr_len)
859 return -EINVAL; 859 return -EINVAL;
860 860
861 netif_addr_lock_nested(to); 861 netif_addr_lock(to);
862 err = __hw_addr_sync(&to->mc, &from->mc, to->addr_len); 862 err = __hw_addr_sync(&to->mc, &from->mc, to->addr_len);
863 if (!err) 863 if (!err)
864 __dev_set_rx_mode(to); 864 __dev_set_rx_mode(to);
@@ -888,7 +888,7 @@ int dev_mc_sync_multiple(struct net_device *to, struct net_device *from)
888 if (to->addr_len != from->addr_len) 888 if (to->addr_len != from->addr_len)
889 return -EINVAL; 889 return -EINVAL;
890 890
891 netif_addr_lock_nested(to); 891 netif_addr_lock(to);
892 err = __hw_addr_sync_multiple(&to->mc, &from->mc, to->addr_len); 892 err = __hw_addr_sync_multiple(&to->mc, &from->mc, to->addr_len);
893 if (!err) 893 if (!err)
894 __dev_set_rx_mode(to); 894 __dev_set_rx_mode(to);
@@ -912,7 +912,7 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
912 return; 912 return;
913 913
914 netif_addr_lock_bh(from); 914 netif_addr_lock_bh(from);
915 netif_addr_lock_nested(to); 915 netif_addr_lock(to);
916 __hw_addr_unsync(&to->mc, &from->mc, to->addr_len); 916 __hw_addr_unsync(&to->mc, &from->mc, to->addr_len);
917 __dev_set_rx_mode(to); 917 __dev_set_rx_mode(to);
918 netif_addr_unlock(to); 918 netif_addr_unlock(to);
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index c763106c73fc..cd9bc67381b2 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1396,11 +1396,13 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr)
1396 1396
1397static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) 1397static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
1398{ 1398{
1399 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; 1399 struct ethtool_wolinfo wol;
1400 1400
1401 if (!dev->ethtool_ops->get_wol) 1401 if (!dev->ethtool_ops->get_wol)
1402 return -EOPNOTSUPP; 1402 return -EOPNOTSUPP;
1403 1403
1404 memset(&wol, 0, sizeof(struct ethtool_wolinfo));
1405 wol.cmd = ETHTOOL_GWOL;
1404 dev->ethtool_ops->get_wol(dev, &wol); 1406 dev->ethtool_ops->get_wol(dev, &wol);
1405 1407
1406 if (copy_to_user(useraddr, &wol, sizeof(wol))) 1408 if (copy_to_user(useraddr, &wol, sizeof(wol)))
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 7c09d87d3269..68eda10d0680 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -1350,30 +1350,21 @@ out_bad:
1350} 1350}
1351EXPORT_SYMBOL(__skb_flow_dissect); 1351EXPORT_SYMBOL(__skb_flow_dissect);
1352 1352
1353static u32 hashrnd __read_mostly; 1353static siphash_key_t hashrnd __read_mostly;
1354static __always_inline void __flow_hash_secret_init(void) 1354static __always_inline void __flow_hash_secret_init(void)
1355{ 1355{
1356 net_get_random_once(&hashrnd, sizeof(hashrnd)); 1356 net_get_random_once(&hashrnd, sizeof(hashrnd));
1357} 1357}
1358 1358
1359static __always_inline u32 __flow_hash_words(const u32 *words, u32 length, 1359static const void *flow_keys_hash_start(const struct flow_keys *flow)
1360 u32 keyval)
1361{ 1360{
1362 return jhash2(words, length, keyval); 1361 BUILD_BUG_ON(FLOW_KEYS_HASH_OFFSET % SIPHASH_ALIGNMENT);
1363} 1362 return &flow->FLOW_KEYS_HASH_START_FIELD;
1364
1365static inline const u32 *flow_keys_hash_start(const struct flow_keys *flow)
1366{
1367 const void *p = flow;
1368
1369 BUILD_BUG_ON(FLOW_KEYS_HASH_OFFSET % sizeof(u32));
1370 return (const u32 *)(p + FLOW_KEYS_HASH_OFFSET);
1371} 1363}
1372 1364
1373static inline size_t flow_keys_hash_length(const struct flow_keys *flow) 1365static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
1374{ 1366{
1375 size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs); 1367 size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs);
1376 BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32));
1377 BUILD_BUG_ON(offsetof(typeof(*flow), addrs) != 1368 BUILD_BUG_ON(offsetof(typeof(*flow), addrs) !=
1378 sizeof(*flow) - sizeof(flow->addrs)); 1369 sizeof(*flow) - sizeof(flow->addrs));
1379 1370
@@ -1388,7 +1379,7 @@ static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
1388 diff -= sizeof(flow->addrs.tipckey); 1379 diff -= sizeof(flow->addrs.tipckey);
1389 break; 1380 break;
1390 } 1381 }
1391 return (sizeof(*flow) - diff) / sizeof(u32); 1382 return sizeof(*flow) - diff;
1392} 1383}
1393 1384
1394__be32 flow_get_u32_src(const struct flow_keys *flow) 1385__be32 flow_get_u32_src(const struct flow_keys *flow)
@@ -1454,14 +1445,15 @@ static inline void __flow_hash_consistentify(struct flow_keys *keys)
1454 } 1445 }
1455} 1446}
1456 1447
1457static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval) 1448static inline u32 __flow_hash_from_keys(struct flow_keys *keys,
1449 const siphash_key_t *keyval)
1458{ 1450{
1459 u32 hash; 1451 u32 hash;
1460 1452
1461 __flow_hash_consistentify(keys); 1453 __flow_hash_consistentify(keys);
1462 1454
1463 hash = __flow_hash_words(flow_keys_hash_start(keys), 1455 hash = siphash(flow_keys_hash_start(keys),
1464 flow_keys_hash_length(keys), keyval); 1456 flow_keys_hash_length(keys), keyval);
1465 if (!hash) 1457 if (!hash)
1466 hash = 1; 1458 hash = 1;
1467 1459
@@ -1471,12 +1463,13 @@ static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval)
1471u32 flow_hash_from_keys(struct flow_keys *keys) 1463u32 flow_hash_from_keys(struct flow_keys *keys)
1472{ 1464{
1473 __flow_hash_secret_init(); 1465 __flow_hash_secret_init();
1474 return __flow_hash_from_keys(keys, hashrnd); 1466 return __flow_hash_from_keys(keys, &hashrnd);
1475} 1467}
1476EXPORT_SYMBOL(flow_hash_from_keys); 1468EXPORT_SYMBOL(flow_hash_from_keys);
1477 1469
1478static inline u32 ___skb_get_hash(const struct sk_buff *skb, 1470static inline u32 ___skb_get_hash(const struct sk_buff *skb,
1479 struct flow_keys *keys, u32 keyval) 1471 struct flow_keys *keys,
1472 const siphash_key_t *keyval)
1480{ 1473{
1481 skb_flow_dissect_flow_keys(skb, keys, 1474 skb_flow_dissect_flow_keys(skb, keys,
1482 FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL); 1475 FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
@@ -1524,7 +1517,7 @@ u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
1524 &keys, NULL, 0, 0, 0, 1517 &keys, NULL, 0, 0, 0,
1525 FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL); 1518 FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
1526 1519
1527 return __flow_hash_from_keys(&keys, hashrnd); 1520 return __flow_hash_from_keys(&keys, &hashrnd);
1528} 1521}
1529EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric); 1522EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
1530 1523
@@ -1544,13 +1537,14 @@ void __skb_get_hash(struct sk_buff *skb)
1544 1537
1545 __flow_hash_secret_init(); 1538 __flow_hash_secret_init();
1546 1539
1547 hash = ___skb_get_hash(skb, &keys, hashrnd); 1540 hash = ___skb_get_hash(skb, &keys, &hashrnd);
1548 1541
1549 __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys)); 1542 __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
1550} 1543}
1551EXPORT_SYMBOL(__skb_get_hash); 1544EXPORT_SYMBOL(__skb_get_hash);
1552 1545
1553__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb) 1546__u32 skb_get_hash_perturb(const struct sk_buff *skb,
1547 const siphash_key_t *perturb)
1554{ 1548{
1555 struct flow_keys keys; 1549 struct flow_keys keys;
1556 1550
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index f93785e5833c..74cfb8b5ab33 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -88,11 +88,16 @@ static int bpf_lwt_input_reroute(struct sk_buff *skb)
88 int err = -EINVAL; 88 int err = -EINVAL;
89 89
90 if (skb->protocol == htons(ETH_P_IP)) { 90 if (skb->protocol == htons(ETH_P_IP)) {
91 struct net_device *dev = skb_dst(skb)->dev;
91 struct iphdr *iph = ip_hdr(skb); 92 struct iphdr *iph = ip_hdr(skb);
92 93
94 dev_hold(dev);
95 skb_dst_drop(skb);
93 err = ip_route_input_noref(skb, iph->daddr, iph->saddr, 96 err = ip_route_input_noref(skb, iph->daddr, iph->saddr,
94 iph->tos, skb_dst(skb)->dev); 97 iph->tos, dev);
98 dev_put(dev);
95 } else if (skb->protocol == htons(ETH_P_IPV6)) { 99 } else if (skb->protocol == htons(ETH_P_IPV6)) {
100 skb_dst_drop(skb);
96 err = ipv6_stub->ipv6_route_input(skb); 101 err = ipv6_stub->ipv6_route_input(skb);
97 } else { 102 } else {
98 err = -EAFNOSUPPORT; 103 err = -EAFNOSUPPORT;
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 6d3e4821b02d..39402840025e 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -246,11 +246,11 @@ static int __peernet2id(struct net *net, struct net *peer)
246} 246}
247 247
248static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid, 248static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
249 struct nlmsghdr *nlh); 249 struct nlmsghdr *nlh, gfp_t gfp);
250/* This function returns the id of a peer netns. If no id is assigned, one will 250/* This function returns the id of a peer netns. If no id is assigned, one will
251 * be allocated and returned. 251 * be allocated and returned.
252 */ 252 */
253int peernet2id_alloc(struct net *net, struct net *peer) 253int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp)
254{ 254{
255 bool alloc = false, alive = false; 255 bool alloc = false, alive = false;
256 int id; 256 int id;
@@ -269,7 +269,7 @@ int peernet2id_alloc(struct net *net, struct net *peer)
269 id = __peernet2id_alloc(net, peer, &alloc); 269 id = __peernet2id_alloc(net, peer, &alloc);
270 spin_unlock_bh(&net->nsid_lock); 270 spin_unlock_bh(&net->nsid_lock);
271 if (alloc && id >= 0) 271 if (alloc && id >= 0)
272 rtnl_net_notifyid(net, RTM_NEWNSID, id, 0, NULL); 272 rtnl_net_notifyid(net, RTM_NEWNSID, id, 0, NULL, gfp);
273 if (alive) 273 if (alive)
274 put_net(peer); 274 put_net(peer);
275 return id; 275 return id;
@@ -479,6 +479,7 @@ struct net *copy_net_ns(unsigned long flags,
479 479
480 if (rv < 0) { 480 if (rv < 0) {
481put_userns: 481put_userns:
482 key_remove_domain(net->key_domain);
482 put_user_ns(user_ns); 483 put_user_ns(user_ns);
483 net_drop_ns(net); 484 net_drop_ns(net);
484dec_ucounts: 485dec_ucounts:
@@ -533,7 +534,8 @@ static void unhash_nsid(struct net *net, struct net *last)
533 idr_remove(&tmp->netns_ids, id); 534 idr_remove(&tmp->netns_ids, id);
534 spin_unlock_bh(&tmp->nsid_lock); 535 spin_unlock_bh(&tmp->nsid_lock);
535 if (id >= 0) 536 if (id >= 0)
536 rtnl_net_notifyid(tmp, RTM_DELNSID, id, 0, NULL); 537 rtnl_net_notifyid(tmp, RTM_DELNSID, id, 0, NULL,
538 GFP_KERNEL);
537 if (tmp == last) 539 if (tmp == last)
538 break; 540 break;
539 } 541 }
@@ -766,7 +768,7 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
766 spin_unlock_bh(&net->nsid_lock); 768 spin_unlock_bh(&net->nsid_lock);
767 if (err >= 0) { 769 if (err >= 0) {
768 rtnl_net_notifyid(net, RTM_NEWNSID, err, NETLINK_CB(skb).portid, 770 rtnl_net_notifyid(net, RTM_NEWNSID, err, NETLINK_CB(skb).portid,
769 nlh); 771 nlh, GFP_KERNEL);
770 err = 0; 772 err = 0;
771 } else if (err == -ENOSPC && nsid >= 0) { 773 } else if (err == -ENOSPC && nsid >= 0) {
772 err = -EEXIST; 774 err = -EEXIST;
@@ -1054,7 +1056,7 @@ end:
1054} 1056}
1055 1057
1056static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid, 1058static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
1057 struct nlmsghdr *nlh) 1059 struct nlmsghdr *nlh, gfp_t gfp)
1058{ 1060{
1059 struct net_fill_args fillargs = { 1061 struct net_fill_args fillargs = {
1060 .portid = portid, 1062 .portid = portid,
@@ -1065,7 +1067,7 @@ static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
1065 struct sk_buff *msg; 1067 struct sk_buff *msg;
1066 int err = -ENOMEM; 1068 int err = -ENOMEM;
1067 1069
1068 msg = nlmsg_new(rtnl_net_get_size(), GFP_KERNEL); 1070 msg = nlmsg_new(rtnl_net_get_size(), gfp);
1069 if (!msg) 1071 if (!msg)
1070 goto out; 1072 goto out;
1071 1073
@@ -1073,7 +1075,7 @@ static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
1073 if (err < 0) 1075 if (err < 0)
1074 goto err_out; 1076 goto err_out;
1075 1077
1076 rtnl_notify(msg, net, portid, RTNLGRP_NSID, nlh, 0); 1078 rtnl_notify(msg, net, portid, RTNLGRP_NSID, nlh, gfp);
1077 return; 1079 return;
1078 1080
1079err_out: 1081err_out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 1ee6460f8275..c81cd80114d9 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1523,7 +1523,7 @@ static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb,
1523 1523
1524static int rtnl_fill_link_netnsid(struct sk_buff *skb, 1524static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1525 const struct net_device *dev, 1525 const struct net_device *dev,
1526 struct net *src_net) 1526 struct net *src_net, gfp_t gfp)
1527{ 1527{
1528 bool put_iflink = false; 1528 bool put_iflink = false;
1529 1529
@@ -1531,7 +1531,7 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1531 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev); 1531 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
1532 1532
1533 if (!net_eq(dev_net(dev), link_net)) { 1533 if (!net_eq(dev_net(dev), link_net)) {
1534 int id = peernet2id_alloc(src_net, link_net); 1534 int id = peernet2id_alloc(src_net, link_net, gfp);
1535 1535
1536 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id)) 1536 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
1537 return -EMSGSIZE; 1537 return -EMSGSIZE;
@@ -1589,7 +1589,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
1589 int type, u32 pid, u32 seq, u32 change, 1589 int type, u32 pid, u32 seq, u32 change,
1590 unsigned int flags, u32 ext_filter_mask, 1590 unsigned int flags, u32 ext_filter_mask,
1591 u32 event, int *new_nsid, int new_ifindex, 1591 u32 event, int *new_nsid, int new_ifindex,
1592 int tgt_netnsid) 1592 int tgt_netnsid, gfp_t gfp)
1593{ 1593{
1594 struct ifinfomsg *ifm; 1594 struct ifinfomsg *ifm;
1595 struct nlmsghdr *nlh; 1595 struct nlmsghdr *nlh;
@@ -1681,7 +1681,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
1681 goto nla_put_failure; 1681 goto nla_put_failure;
1682 } 1682 }
1683 1683
1684 if (rtnl_fill_link_netnsid(skb, dev, src_net)) 1684 if (rtnl_fill_link_netnsid(skb, dev, src_net, gfp))
1685 goto nla_put_failure; 1685 goto nla_put_failure;
1686 1686
1687 if (new_nsid && 1687 if (new_nsid &&
@@ -2001,7 +2001,7 @@ walk_entries:
2001 NETLINK_CB(cb->skb).portid, 2001 NETLINK_CB(cb->skb).portid,
2002 nlh->nlmsg_seq, 0, flags, 2002 nlh->nlmsg_seq, 0, flags,
2003 ext_filter_mask, 0, NULL, 0, 2003 ext_filter_mask, 0, NULL, 0,
2004 netnsid); 2004 netnsid, GFP_KERNEL);
2005 2005
2006 if (err < 0) { 2006 if (err < 0) {
2007 if (likely(skb->len)) 2007 if (likely(skb->len))
@@ -2355,6 +2355,7 @@ static int do_set_master(struct net_device *dev, int ifindex,
2355 err = ops->ndo_del_slave(upper_dev, dev); 2355 err = ops->ndo_del_slave(upper_dev, dev);
2356 if (err) 2356 if (err)
2357 return err; 2357 return err;
2358 netdev_update_lockdep_key(dev);
2358 } else { 2359 } else {
2359 return -EOPNOTSUPP; 2360 return -EOPNOTSUPP;
2360 } 2361 }
@@ -3359,7 +3360,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh,
3359 err = rtnl_fill_ifinfo(nskb, dev, net, 3360 err = rtnl_fill_ifinfo(nskb, dev, net,
3360 RTM_NEWLINK, NETLINK_CB(skb).portid, 3361 RTM_NEWLINK, NETLINK_CB(skb).portid,
3361 nlh->nlmsg_seq, 0, 0, ext_filter_mask, 3362 nlh->nlmsg_seq, 0, 0, ext_filter_mask,
3362 0, NULL, 0, netnsid); 3363 0, NULL, 0, netnsid, GFP_KERNEL);
3363 if (err < 0) { 3364 if (err < 0) {
3364 /* -EMSGSIZE implies BUG in if_nlmsg_size */ 3365 /* -EMSGSIZE implies BUG in if_nlmsg_size */
3365 WARN_ON(err == -EMSGSIZE); 3366 WARN_ON(err == -EMSGSIZE);
@@ -3471,7 +3472,7 @@ struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
3471 3472
3472 err = rtnl_fill_ifinfo(skb, dev, dev_net(dev), 3473 err = rtnl_fill_ifinfo(skb, dev, dev_net(dev),
3473 type, 0, 0, change, 0, 0, event, 3474 type, 0, 0, change, 0, 0, event,
3474 new_nsid, new_ifindex, -1); 3475 new_nsid, new_ifindex, -1, flags);
3475 if (err < 0) { 3476 if (err < 0) {
3476 /* -EMSGSIZE implies BUG in if_nlmsg_size() */ 3477 /* -EMSGSIZE implies BUG in if_nlmsg_size() */
3477 WARN_ON(err == -EMSGSIZE); 3478 WARN_ON(err == -EMSGSIZE);
@@ -3916,7 +3917,7 @@ static int valid_fdb_dump_strict(const struct nlmsghdr *nlh,
3916 ndm = nlmsg_data(nlh); 3917 ndm = nlmsg_data(nlh);
3917 if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_state || 3918 if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_state ||
3918 ndm->ndm_flags || ndm->ndm_type) { 3919 ndm->ndm_flags || ndm->ndm_type) {
3919 NL_SET_ERR_MSG(extack, "Invalid values in header for fbd dump request"); 3920 NL_SET_ERR_MSG(extack, "Invalid values in header for fdb dump request");
3920 return -EINVAL; 3921 return -EINVAL;
3921 } 3922 }
3922 3923
diff --git a/net/core/sock.c b/net/core/sock.c
index a515392ba84b..ac78a570e43a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1127,7 +1127,7 @@ set_rcvbuf:
1127 break; 1127 break;
1128 } 1128 }
1129 case SO_INCOMING_CPU: 1129 case SO_INCOMING_CPU:
1130 sk->sk_incoming_cpu = val; 1130 WRITE_ONCE(sk->sk_incoming_cpu, val);
1131 break; 1131 break;
1132 1132
1133 case SO_CNX_ADVICE: 1133 case SO_CNX_ADVICE:
@@ -1476,7 +1476,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
1476 break; 1476 break;
1477 1477
1478 case SO_INCOMING_CPU: 1478 case SO_INCOMING_CPU:
1479 v.val = sk->sk_incoming_cpu; 1479 v.val = READ_ONCE(sk->sk_incoming_cpu);
1480 break; 1480 break;
1481 1481
1482 case SO_MEMINFO: 1482 case SO_MEMINFO:
@@ -3600,7 +3600,7 @@ bool sk_busy_loop_end(void *p, unsigned long start_time)
3600{ 3600{
3601 struct sock *sk = p; 3601 struct sock *sk = p;
3602 3602
3603 return !skb_queue_empty(&sk->sk_receive_queue) || 3603 return !skb_queue_empty_lockless(&sk->sk_receive_queue) ||
3604 sk_busy_loop_timeout(sk, start_time); 3604 sk_busy_loop_timeout(sk, start_time);
3605} 3605}
3606EXPORT_SYMBOL(sk_busy_loop_end); 3606EXPORT_SYMBOL(sk_busy_loop_end);
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d9b4200ed12d..0d8f782c25cc 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -117,7 +117,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
117 inet->inet_daddr, 117 inet->inet_daddr,
118 inet->inet_sport, 118 inet->inet_sport,
119 inet->inet_dport); 119 inet->inet_dport);
120 inet->inet_id = dp->dccps_iss ^ jiffies; 120 inet->inet_id = prandom_u32();
121 121
122 err = dccp_connect(sk); 122 err = dccp_connect(sk);
123 rt = NULL; 123 rt = NULL;
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 0ea75286abf4..3349ea81f901 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1205,7 +1205,7 @@ static __poll_t dn_poll(struct file *file, struct socket *sock, poll_table *wai
1205 struct dn_scp *scp = DN_SK(sk); 1205 struct dn_scp *scp = DN_SK(sk);
1206 __poll_t mask = datagram_poll(file, sock, wait); 1206 __poll_t mask = datagram_poll(file, sock, wait);
1207 1207
1208 if (!skb_queue_empty(&scp->other_receive_queue)) 1208 if (!skb_queue_empty_lockless(&scp->other_receive_queue))
1209 mask |= EPOLLRDBAND; 1209 mask |= EPOLLRDBAND;
1210 1210
1211 return mask; 1211 return mask;
diff --git a/net/dsa/master.c b/net/dsa/master.c
index a8e52c9967f4..3255dfc97f86 100644
--- a/net/dsa/master.c
+++ b/net/dsa/master.c
@@ -310,8 +310,6 @@ static void dsa_master_reset_mtu(struct net_device *dev)
310 rtnl_unlock(); 310 rtnl_unlock();
311} 311}
312 312
313static struct lock_class_key dsa_master_addr_list_lock_key;
314
315int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) 313int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
316{ 314{
317 int ret; 315 int ret;
@@ -325,9 +323,6 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
325 wmb(); 323 wmb();
326 324
327 dev->dsa_ptr = cpu_dp; 325 dev->dsa_ptr = cpu_dp;
328 lockdep_set_class(&dev->addr_list_lock,
329 &dsa_master_addr_list_lock_key);
330
331 ret = dsa_master_ethtool_setup(dev); 326 ret = dsa_master_ethtool_setup(dev);
332 if (ret) 327 if (ret)
333 return ret; 328 return ret;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 75d58229a4bd..028e65f4b5ba 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1341,15 +1341,6 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
1341 return ret; 1341 return ret;
1342} 1342}
1343 1343
1344static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
1345static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
1346 struct netdev_queue *txq,
1347 void *_unused)
1348{
1349 lockdep_set_class(&txq->_xmit_lock,
1350 &dsa_slave_netdev_xmit_lock_key);
1351}
1352
1353int dsa_slave_suspend(struct net_device *slave_dev) 1344int dsa_slave_suspend(struct net_device *slave_dev)
1354{ 1345{
1355 struct dsa_port *dp = dsa_slave_to_port(slave_dev); 1346 struct dsa_port *dp = dsa_slave_to_port(slave_dev);
@@ -1433,9 +1424,6 @@ int dsa_slave_create(struct dsa_port *port)
1433 slave_dev->max_mtu = ETH_MAX_MTU; 1424 slave_dev->max_mtu = ETH_MAX_MTU;
1434 SET_NETDEV_DEVTYPE(slave_dev, &dsa_type); 1425 SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
1435 1426
1436 netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
1437 NULL);
1438
1439 SET_NETDEV_DEV(slave_dev, port->ds->dev); 1427 SET_NETDEV_DEV(slave_dev, port->ds->dev);
1440 slave_dev->dev.of_node = port->dn; 1428 slave_dev->dev.of_node = port->dn;
1441 slave_dev->vlan_features = master->vlan_features; 1429 slave_dev->vlan_features = master->vlan_features;
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index 3297e7fa9945..c0b107cdd715 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -58,13 +58,6 @@ static const struct header_ops lowpan_header_ops = {
58 .create = lowpan_header_create, 58 .create = lowpan_header_create,
59}; 59};
60 60
61static int lowpan_dev_init(struct net_device *ldev)
62{
63 netdev_lockdep_set_classes(ldev);
64
65 return 0;
66}
67
68static int lowpan_open(struct net_device *dev) 61static int lowpan_open(struct net_device *dev)
69{ 62{
70 if (!open_count) 63 if (!open_count)
@@ -96,7 +89,6 @@ static int lowpan_get_iflink(const struct net_device *dev)
96} 89}
97 90
98static const struct net_device_ops lowpan_netdev_ops = { 91static const struct net_device_ops lowpan_netdev_ops = {
99 .ndo_init = lowpan_dev_init,
100 .ndo_start_xmit = lowpan_xmit, 92 .ndo_start_xmit = lowpan_xmit,
101 .ndo_open = lowpan_open, 93 .ndo_open = lowpan_open,
102 .ndo_stop = lowpan_stop, 94 .ndo_stop = lowpan_stop,
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 9a0fe0c2fa02..4a8550c49202 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -73,7 +73,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
73 reuseport_has_conns(sk, true); 73 reuseport_has_conns(sk, true);
74 sk->sk_state = TCP_ESTABLISHED; 74 sk->sk_state = TCP_ESTABLISHED;
75 sk_set_txhash(sk); 75 sk_set_txhash(sk);
76 inet->inet_id = jiffies; 76 inet->inet_id = prandom_u32();
77 77
78 sk_dst_set(sk, &rt->dst); 78 sk_dst_set(sk, &rt->dst);
79 err = 0; 79 err = 0;
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index dde77f72e03e..71c78d223dfd 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1148,7 +1148,7 @@ void fib_modify_prefix_metric(struct in_ifaddr *ifa, u32 new_metric)
1148 if (!(dev->flags & IFF_UP) || 1148 if (!(dev->flags & IFF_UP) ||
1149 ifa->ifa_flags & (IFA_F_SECONDARY | IFA_F_NOPREFIXROUTE) || 1149 ifa->ifa_flags & (IFA_F_SECONDARY | IFA_F_NOPREFIXROUTE) ||
1150 ipv4_is_zeronet(prefix) || 1150 ipv4_is_zeronet(prefix) ||
1151 prefix == ifa->ifa_local || ifa->ifa_prefixlen == 32) 1151 (prefix == ifa->ifa_local && ifa->ifa_prefixlen == 32))
1152 return; 1152 return;
1153 1153
1154 /* add the new */ 1154 /* add the new */
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 97824864e40d..83fb00153018 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -240,7 +240,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
240 return -1; 240 return -1;
241 241
242 score = sk->sk_family == PF_INET ? 2 : 1; 242 score = sk->sk_family == PF_INET ? 2 : 1;
243 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 243 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
244 score++; 244 score++;
245 } 245 }
246 return score; 246 return score;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 52690bb3e40f..10636fb6093e 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -509,9 +509,9 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
509 key = &tun_info->key; 509 key = &tun_info->key;
510 if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT)) 510 if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT))
511 goto err_free_skb; 511 goto err_free_skb;
512 md = ip_tunnel_info_opts(tun_info); 512 if (tun_info->options_len < sizeof(*md))
513 if (!md)
514 goto err_free_skb; 513 goto err_free_skb;
514 md = ip_tunnel_info_opts(tun_info);
515 515
516 /* ERSPAN has fixed 8 byte GRE header */ 516 /* ERSPAN has fixed 8 byte GRE header */
517 version = md->version; 517 version = md->version;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 814b9b8882a0..3d8baaaf7086 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -645,11 +645,12 @@ void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter)
645EXPORT_SYMBOL(ip_fraglist_prepare); 645EXPORT_SYMBOL(ip_fraglist_prepare);
646 646
647void ip_frag_init(struct sk_buff *skb, unsigned int hlen, 647void ip_frag_init(struct sk_buff *skb, unsigned int hlen,
648 unsigned int ll_rs, unsigned int mtu, 648 unsigned int ll_rs, unsigned int mtu, bool DF,
649 struct ip_frag_state *state) 649 struct ip_frag_state *state)
650{ 650{
651 struct iphdr *iph = ip_hdr(skb); 651 struct iphdr *iph = ip_hdr(skb);
652 652
653 state->DF = DF;
653 state->hlen = hlen; 654 state->hlen = hlen;
654 state->ll_rs = ll_rs; 655 state->ll_rs = ll_rs;
655 state->mtu = mtu; 656 state->mtu = mtu;
@@ -668,9 +669,6 @@ static void ip_frag_ipcb(struct sk_buff *from, struct sk_buff *to,
668 /* Copy the flags to each fragment. */ 669 /* Copy the flags to each fragment. */
669 IPCB(to)->flags = IPCB(from)->flags; 670 IPCB(to)->flags = IPCB(from)->flags;
670 671
671 if (IPCB(from)->flags & IPSKB_FRAG_PMTU)
672 state->iph->frag_off |= htons(IP_DF);
673
674 /* ANK: dirty, but effective trick. Upgrade options only if 672 /* ANK: dirty, but effective trick. Upgrade options only if
675 * the segment to be fragmented was THE FIRST (otherwise, 673 * the segment to be fragmented was THE FIRST (otherwise,
676 * options are already fixed) and make it ONCE 674 * options are already fixed) and make it ONCE
@@ -738,6 +736,8 @@ struct sk_buff *ip_frag_next(struct sk_buff *skb, struct ip_frag_state *state)
738 */ 736 */
739 iph = ip_hdr(skb2); 737 iph = ip_hdr(skb2);
740 iph->frag_off = htons((state->offset >> 3)); 738 iph->frag_off = htons((state->offset >> 3));
739 if (state->DF)
740 iph->frag_off |= htons(IP_DF);
741 741
742 /* 742 /*
743 * Added AC : If we are fragmenting a fragment that's not the 743 * Added AC : If we are fragmenting a fragment that's not the
@@ -883,7 +883,8 @@ slow_path:
883 * Fragment the datagram. 883 * Fragment the datagram.
884 */ 884 */
885 885
886 ip_frag_init(skb, hlen, ll_rs, mtu, &state); 886 ip_frag_init(skb, hlen, ll_rs, mtu, IPCB(skb)->flags & IPSKB_FRAG_PMTU,
887 &state);
887 888
888 /* 889 /*
889 * Keep copying data until we run out. 890 * Keep copying data until we run out.
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 42187a3b82f4..d8876f0e9672 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -584,7 +584,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
584 } 584 }
585 /* This barrier is coupled with smp_wmb() in tcp_reset() */ 585 /* This barrier is coupled with smp_wmb() in tcp_reset() */
586 smp_rmb(); 586 smp_rmb();
587 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 587 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
588 mask |= EPOLLERR; 588 mask |= EPOLLERR;
589 589
590 return mask; 590 return mask;
@@ -1964,7 +1964,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
1964 if (unlikely(flags & MSG_ERRQUEUE)) 1964 if (unlikely(flags & MSG_ERRQUEUE))
1965 return inet_recv_error(sk, msg, len, addr_len); 1965 return inet_recv_error(sk, msg, len, addr_len);
1966 1966
1967 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) && 1967 if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue) &&
1968 (sk->sk_state == TCP_ESTABLISHED)) 1968 (sk->sk_state == TCP_ESTABLISHED))
1969 sk_busy_loop(sk, nonblock); 1969 sk_busy_loop(sk, nonblock);
1970 1970
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6be568334848..67b2dc7a1727 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -303,7 +303,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
303 inet->inet_daddr); 303 inet->inet_daddr);
304 } 304 }
305 305
306 inet->inet_id = tp->write_seq ^ jiffies; 306 inet->inet_id = prandom_u32();
307 307
308 if (tcp_fastopen_defer_connect(sk, &err)) 308 if (tcp_fastopen_defer_connect(sk, &err))
309 return err; 309 return err;
@@ -1450,7 +1450,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
1450 inet_csk(newsk)->icsk_ext_hdr_len = 0; 1450 inet_csk(newsk)->icsk_ext_hdr_len = 0;
1451 if (inet_opt) 1451 if (inet_opt)
1452 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 1452 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
1453 newinet->inet_id = newtp->write_seq ^ jiffies; 1453 newinet->inet_id = prandom_u32();
1454 1454
1455 if (!dst) { 1455 if (!dst) {
1456 dst = inet_csk_route_child_sock(sk, newsk, req); 1456 dst = inet_csk_route_child_sock(sk, newsk, req);
@@ -2681,7 +2681,7 @@ static int __net_init tcp_sk_init(struct net *net)
2681 net->ipv4.tcp_death_row.sysctl_max_tw_buckets = cnt / 2; 2681 net->ipv4.tcp_death_row.sysctl_max_tw_buckets = cnt / 2;
2682 net->ipv4.tcp_death_row.hashinfo = &tcp_hashinfo; 2682 net->ipv4.tcp_death_row.hashinfo = &tcp_hashinfo;
2683 2683
2684 net->ipv4.sysctl_max_syn_backlog = max(128, cnt / 256); 2684 net->ipv4.sysctl_max_syn_backlog = max(128, cnt / 128);
2685 net->ipv4.sysctl_tcp_sack = 1; 2685 net->ipv4.sysctl_tcp_sack = 1;
2686 net->ipv4.sysctl_tcp_window_scaling = 1; 2686 net->ipv4.sysctl_tcp_window_scaling = 1;
2687 net->ipv4.sysctl_tcp_timestamps = 1; 2687 net->ipv4.sysctl_tcp_timestamps = 1;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 14bc654b6842..1d58ce829dca 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -388,7 +388,7 @@ static int compute_score(struct sock *sk, struct net *net,
388 return -1; 388 return -1;
389 score += 4; 389 score += 4;
390 390
391 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 391 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
392 score++; 392 score++;
393 return score; 393 return score;
394} 394}
@@ -1316,6 +1316,20 @@ static void udp_set_dev_scratch(struct sk_buff *skb)
1316 scratch->_tsize_state |= UDP_SKB_IS_STATELESS; 1316 scratch->_tsize_state |= UDP_SKB_IS_STATELESS;
1317} 1317}
1318 1318
1319static void udp_skb_csum_unnecessary_set(struct sk_buff *skb)
1320{
1321 /* We come here after udp_lib_checksum_complete() returned 0.
1322 * This means that __skb_checksum_complete() might have
1323 * set skb->csum_valid to 1.
1324 * On 64bit platforms, we can set csum_unnecessary
1325 * to true, but only if the skb is not shared.
1326 */
1327#if BITS_PER_LONG == 64
1328 if (!skb_shared(skb))
1329 udp_skb_scratch(skb)->csum_unnecessary = true;
1330#endif
1331}
1332
1319static int udp_skb_truesize(struct sk_buff *skb) 1333static int udp_skb_truesize(struct sk_buff *skb)
1320{ 1334{
1321 return udp_skb_scratch(skb)->_tsize_state & ~UDP_SKB_IS_STATELESS; 1335 return udp_skb_scratch(skb)->_tsize_state & ~UDP_SKB_IS_STATELESS;
@@ -1550,10 +1564,7 @@ static struct sk_buff *__first_packet_length(struct sock *sk,
1550 *total += skb->truesize; 1564 *total += skb->truesize;
1551 kfree_skb(skb); 1565 kfree_skb(skb);
1552 } else { 1566 } else {
1553 /* the csum related bits could be changed, refresh 1567 udp_skb_csum_unnecessary_set(skb);
1554 * the scratch area
1555 */
1556 udp_set_dev_scratch(skb);
1557 break; 1568 break;
1558 } 1569 }
1559 } 1570 }
@@ -1577,7 +1588,7 @@ static int first_packet_length(struct sock *sk)
1577 1588
1578 spin_lock_bh(&rcvq->lock); 1589 spin_lock_bh(&rcvq->lock);
1579 skb = __first_packet_length(sk, rcvq, &total); 1590 skb = __first_packet_length(sk, rcvq, &total);
1580 if (!skb && !skb_queue_empty(sk_queue)) { 1591 if (!skb && !skb_queue_empty_lockless(sk_queue)) {
1581 spin_lock(&sk_queue->lock); 1592 spin_lock(&sk_queue->lock);
1582 skb_queue_splice_tail_init(sk_queue, rcvq); 1593 skb_queue_splice_tail_init(sk_queue, rcvq);
1583 spin_unlock(&sk_queue->lock); 1594 spin_unlock(&sk_queue->lock);
@@ -1650,7 +1661,7 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
1650 return skb; 1661 return skb;
1651 } 1662 }
1652 1663
1653 if (skb_queue_empty(sk_queue)) { 1664 if (skb_queue_empty_lockless(sk_queue)) {
1654 spin_unlock_bh(&queue->lock); 1665 spin_unlock_bh(&queue->lock);
1655 goto busy_check; 1666 goto busy_check;
1656 } 1667 }
@@ -1676,7 +1687,7 @@ busy_check:
1676 break; 1687 break;
1677 1688
1678 sk_busy_loop(sk, flags & MSG_DONTWAIT); 1689 sk_busy_loop(sk, flags & MSG_DONTWAIT);
1679 } while (!skb_queue_empty(sk_queue)); 1690 } while (!skb_queue_empty_lockless(sk_queue));
1680 1691
1681 /* sk_queue is empty, reader_queue may contain peeked packets */ 1692 /* sk_queue is empty, reader_queue may contain peeked packets */
1682 } while (timeo && 1693 } while (timeo &&
@@ -2712,7 +2723,7 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
2712 __poll_t mask = datagram_poll(file, sock, wait); 2723 __poll_t mask = datagram_poll(file, sock, wait);
2713 struct sock *sk = sock->sk; 2724 struct sock *sk = sock->sk;
2714 2725
2715 if (!skb_queue_empty(&udp_sk(sk)->reader_queue)) 2726 if (!skb_queue_empty_lockless(&udp_sk(sk)->reader_queue))
2716 mask |= EPOLLIN | EPOLLRDNORM; 2727 mask |= EPOLLIN | EPOLLRDNORM;
2717 2728
2718 /* Check for false positives due to checksum errors */ 2729 /* Check for false positives due to checksum errors */
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c
index 783f3c1466da..2fc079284ca4 100644
--- a/net/ipv6/addrconf_core.c
+++ b/net/ipv6/addrconf_core.c
@@ -7,6 +7,7 @@
7#include <linux/export.h> 7#include <linux/export.h>
8#include <net/ipv6.h> 8#include <net/ipv6.h>
9#include <net/ipv6_stubs.h> 9#include <net/ipv6_stubs.h>
10#include <net/addrconf.h>
10#include <net/ip.h> 11#include <net/ip.h>
11 12
12/* if ipv6 module registers this function is used by xfrm to force all 13/* if ipv6 module registers this function is used by xfrm to force all
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index cf60fae9533b..fbe9d4295eac 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -105,7 +105,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
105 return -1; 105 return -1;
106 106
107 score = 1; 107 score = 1;
108 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 108 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
109 score++; 109 score++;
110 } 110 }
111 return score; 111 return score;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 787d9f2a6e99..923034c52ce4 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -980,9 +980,9 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
980 dsfield = key->tos; 980 dsfield = key->tos;
981 if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT)) 981 if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT))
982 goto tx_err; 982 goto tx_err;
983 md = ip_tunnel_info_opts(tun_info); 983 if (tun_info->options_len < sizeof(*md))
984 if (!md)
985 goto tx_err; 984 goto tx_err;
985 md = ip_tunnel_info_opts(tun_info);
986 986
987 tun_id = tunnel_id_to_key32(key->tun_id); 987 tun_id = tunnel_id_to_key32(key->tun_id);
988 if (md->version == 1) { 988 if (md->version == 1) {
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 6324d3a8cb53..9fec580c968e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -135,7 +135,7 @@ static int compute_score(struct sock *sk, struct net *net,
135 return -1; 135 return -1;
136 score++; 136 score++;
137 137
138 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 138 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
139 score++; 139 score++;
140 140
141 return score; 141 return score;
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index fd5ac2788e45..d3b520b9b2c9 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -56,7 +56,6 @@ static int l2tp_eth_dev_init(struct net_device *dev)
56{ 56{
57 eth_hw_addr_random(dev); 57 eth_hw_addr_random(dev);
58 eth_broadcast_addr(dev->broadcast); 58 eth_broadcast_addr(dev->broadcast);
59 netdev_lockdep_set_classes(dev);
60 59
61 return 0; 60 return 0;
62} 61}
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
index 4515056ef1c2..f9b16f2b2219 100644
--- a/net/netfilter/ipvs/ip_vs_app.c
+++ b/net/netfilter/ipvs/ip_vs_app.c
@@ -193,21 +193,29 @@ struct ip_vs_app *register_ip_vs_app(struct netns_ipvs *ipvs, struct ip_vs_app *
193 193
194 mutex_lock(&__ip_vs_app_mutex); 194 mutex_lock(&__ip_vs_app_mutex);
195 195
196 /* increase the module use count */
197 if (!ip_vs_use_count_inc()) {
198 err = -ENOENT;
199 goto out_unlock;
200 }
201
196 list_for_each_entry(a, &ipvs->app_list, a_list) { 202 list_for_each_entry(a, &ipvs->app_list, a_list) {
197 if (!strcmp(app->name, a->name)) { 203 if (!strcmp(app->name, a->name)) {
198 err = -EEXIST; 204 err = -EEXIST;
205 /* decrease the module use count */
206 ip_vs_use_count_dec();
199 goto out_unlock; 207 goto out_unlock;
200 } 208 }
201 } 209 }
202 a = kmemdup(app, sizeof(*app), GFP_KERNEL); 210 a = kmemdup(app, sizeof(*app), GFP_KERNEL);
203 if (!a) { 211 if (!a) {
204 err = -ENOMEM; 212 err = -ENOMEM;
213 /* decrease the module use count */
214 ip_vs_use_count_dec();
205 goto out_unlock; 215 goto out_unlock;
206 } 216 }
207 INIT_LIST_HEAD(&a->incs_list); 217 INIT_LIST_HEAD(&a->incs_list);
208 list_add(&a->a_list, &ipvs->app_list); 218 list_add(&a->a_list, &ipvs->app_list);
209 /* increase the module use count */
210 ip_vs_use_count_inc();
211 219
212out_unlock: 220out_unlock:
213 mutex_unlock(&__ip_vs_app_mutex); 221 mutex_unlock(&__ip_vs_app_mutex);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 8b48e7ce1c2c..3cccc88ef817 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -93,7 +93,6 @@ static bool __ip_vs_addr_is_local_v6(struct net *net,
93static void update_defense_level(struct netns_ipvs *ipvs) 93static void update_defense_level(struct netns_ipvs *ipvs)
94{ 94{
95 struct sysinfo i; 95 struct sysinfo i;
96 static int old_secure_tcp = 0;
97 int availmem; 96 int availmem;
98 int nomem; 97 int nomem;
99 int to_change = -1; 98 int to_change = -1;
@@ -174,35 +173,35 @@ static void update_defense_level(struct netns_ipvs *ipvs)
174 spin_lock(&ipvs->securetcp_lock); 173 spin_lock(&ipvs->securetcp_lock);
175 switch (ipvs->sysctl_secure_tcp) { 174 switch (ipvs->sysctl_secure_tcp) {
176 case 0: 175 case 0:
177 if (old_secure_tcp >= 2) 176 if (ipvs->old_secure_tcp >= 2)
178 to_change = 0; 177 to_change = 0;
179 break; 178 break;
180 case 1: 179 case 1:
181 if (nomem) { 180 if (nomem) {
182 if (old_secure_tcp < 2) 181 if (ipvs->old_secure_tcp < 2)
183 to_change = 1; 182 to_change = 1;
184 ipvs->sysctl_secure_tcp = 2; 183 ipvs->sysctl_secure_tcp = 2;
185 } else { 184 } else {
186 if (old_secure_tcp >= 2) 185 if (ipvs->old_secure_tcp >= 2)
187 to_change = 0; 186 to_change = 0;
188 } 187 }
189 break; 188 break;
190 case 2: 189 case 2:
191 if (nomem) { 190 if (nomem) {
192 if (old_secure_tcp < 2) 191 if (ipvs->old_secure_tcp < 2)
193 to_change = 1; 192 to_change = 1;
194 } else { 193 } else {
195 if (old_secure_tcp >= 2) 194 if (ipvs->old_secure_tcp >= 2)
196 to_change = 0; 195 to_change = 0;
197 ipvs->sysctl_secure_tcp = 1; 196 ipvs->sysctl_secure_tcp = 1;
198 } 197 }
199 break; 198 break;
200 case 3: 199 case 3:
201 if (old_secure_tcp < 2) 200 if (ipvs->old_secure_tcp < 2)
202 to_change = 1; 201 to_change = 1;
203 break; 202 break;
204 } 203 }
205 old_secure_tcp = ipvs->sysctl_secure_tcp; 204 ipvs->old_secure_tcp = ipvs->sysctl_secure_tcp;
206 if (to_change >= 0) 205 if (to_change >= 0)
207 ip_vs_protocol_timeout_change(ipvs, 206 ip_vs_protocol_timeout_change(ipvs,
208 ipvs->sysctl_secure_tcp > 1); 207 ipvs->sysctl_secure_tcp > 1);
@@ -1275,7 +1274,8 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
1275 struct ip_vs_service *svc = NULL; 1274 struct ip_vs_service *svc = NULL;
1276 1275
1277 /* increase the module use count */ 1276 /* increase the module use count */
1278 ip_vs_use_count_inc(); 1277 if (!ip_vs_use_count_inc())
1278 return -ENOPROTOOPT;
1279 1279
1280 /* Lookup the scheduler by 'u->sched_name' */ 1280 /* Lookup the scheduler by 'u->sched_name' */
1281 if (strcmp(u->sched_name, "none")) { 1281 if (strcmp(u->sched_name, "none")) {
@@ -2435,9 +2435,6 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2435 if (copy_from_user(arg, user, len) != 0) 2435 if (copy_from_user(arg, user, len) != 0)
2436 return -EFAULT; 2436 return -EFAULT;
2437 2437
2438 /* increase the module use count */
2439 ip_vs_use_count_inc();
2440
2441 /* Handle daemons since they have another lock */ 2438 /* Handle daemons since they have another lock */
2442 if (cmd == IP_VS_SO_SET_STARTDAEMON || 2439 if (cmd == IP_VS_SO_SET_STARTDAEMON ||
2443 cmd == IP_VS_SO_SET_STOPDAEMON) { 2440 cmd == IP_VS_SO_SET_STOPDAEMON) {
@@ -2450,13 +2447,13 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2450 ret = -EINVAL; 2447 ret = -EINVAL;
2451 if (strscpy(cfg.mcast_ifn, dm->mcast_ifn, 2448 if (strscpy(cfg.mcast_ifn, dm->mcast_ifn,
2452 sizeof(cfg.mcast_ifn)) <= 0) 2449 sizeof(cfg.mcast_ifn)) <= 0)
2453 goto out_dec; 2450 return ret;
2454 cfg.syncid = dm->syncid; 2451 cfg.syncid = dm->syncid;
2455 ret = start_sync_thread(ipvs, &cfg, dm->state); 2452 ret = start_sync_thread(ipvs, &cfg, dm->state);
2456 } else { 2453 } else {
2457 ret = stop_sync_thread(ipvs, dm->state); 2454 ret = stop_sync_thread(ipvs, dm->state);
2458 } 2455 }
2459 goto out_dec; 2456 return ret;
2460 } 2457 }
2461 2458
2462 mutex_lock(&__ip_vs_mutex); 2459 mutex_lock(&__ip_vs_mutex);
@@ -2551,10 +2548,6 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2551 2548
2552 out_unlock: 2549 out_unlock:
2553 mutex_unlock(&__ip_vs_mutex); 2550 mutex_unlock(&__ip_vs_mutex);
2554 out_dec:
2555 /* decrease the module use count */
2556 ip_vs_use_count_dec();
2557
2558 return ret; 2551 return ret;
2559} 2552}
2560 2553
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
index 8e104dff7abc..166c669f0763 100644
--- a/net/netfilter/ipvs/ip_vs_pe.c
+++ b/net/netfilter/ipvs/ip_vs_pe.c
@@ -68,7 +68,8 @@ int register_ip_vs_pe(struct ip_vs_pe *pe)
68 struct ip_vs_pe *tmp; 68 struct ip_vs_pe *tmp;
69 69
70 /* increase the module use count */ 70 /* increase the module use count */
71 ip_vs_use_count_inc(); 71 if (!ip_vs_use_count_inc())
72 return -ENOENT;
72 73
73 mutex_lock(&ip_vs_pe_mutex); 74 mutex_lock(&ip_vs_pe_mutex);
74 /* Make sure that the pe with this name doesn't exist 75 /* Make sure that the pe with this name doesn't exist
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 2f9d5cd5daee..d4903723be7e 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -179,7 +179,8 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
179 } 179 }
180 180
181 /* increase the module use count */ 181 /* increase the module use count */
182 ip_vs_use_count_inc(); 182 if (!ip_vs_use_count_inc())
183 return -ENOENT;
183 184
184 mutex_lock(&ip_vs_sched_mutex); 185 mutex_lock(&ip_vs_sched_mutex);
185 186
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index a4a78c4b06de..8dc892a9dc91 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -1762,6 +1762,10 @@ int start_sync_thread(struct netns_ipvs *ipvs, struct ipvs_sync_daemon_cfg *c,
1762 IP_VS_DBG(7, "Each ip_vs_sync_conn entry needs %zd bytes\n", 1762 IP_VS_DBG(7, "Each ip_vs_sync_conn entry needs %zd bytes\n",
1763 sizeof(struct ip_vs_sync_conn_v0)); 1763 sizeof(struct ip_vs_sync_conn_v0));
1764 1764
1765 /* increase the module use count */
1766 if (!ip_vs_use_count_inc())
1767 return -ENOPROTOOPT;
1768
1765 /* Do not hold one mutex and then to block on another */ 1769 /* Do not hold one mutex and then to block on another */
1766 for (;;) { 1770 for (;;) {
1767 rtnl_lock(); 1771 rtnl_lock();
@@ -1892,9 +1896,6 @@ int start_sync_thread(struct netns_ipvs *ipvs, struct ipvs_sync_daemon_cfg *c,
1892 mutex_unlock(&ipvs->sync_mutex); 1896 mutex_unlock(&ipvs->sync_mutex);
1893 rtnl_unlock(); 1897 rtnl_unlock();
1894 1898
1895 /* increase the module use count */
1896 ip_vs_use_count_inc();
1897
1898 return 0; 1899 return 0;
1899 1900
1900out: 1901out:
@@ -1924,11 +1925,17 @@ out:
1924 } 1925 }
1925 kfree(ti); 1926 kfree(ti);
1926 } 1927 }
1928
1929 /* decrease the module use count */
1930 ip_vs_use_count_dec();
1927 return result; 1931 return result;
1928 1932
1929out_early: 1933out_early:
1930 mutex_unlock(&ipvs->sync_mutex); 1934 mutex_unlock(&ipvs->sync_mutex);
1931 rtnl_unlock(); 1935 rtnl_unlock();
1936
1937 /* decrease the module use count */
1938 ip_vs_use_count_dec();
1932 return result; 1939 return result;
1933} 1940}
1934 1941
diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index 132f5228b431..128245efe84a 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -202,6 +202,8 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow)
202{ 202{
203 int err; 203 int err;
204 204
205 flow->timeout = (u32)jiffies + NF_FLOW_TIMEOUT;
206
205 err = rhashtable_insert_fast(&flow_table->rhashtable, 207 err = rhashtable_insert_fast(&flow_table->rhashtable,
206 &flow->tuplehash[0].node, 208 &flow->tuplehash[0].node,
207 nf_flow_offload_rhash_params); 209 nf_flow_offload_rhash_params);
@@ -218,7 +220,6 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow)
218 return err; 220 return err;
219 } 221 }
220 222
221 flow->timeout = (u32)jiffies + NF_FLOW_TIMEOUT;
222 return 0; 223 return 0;
223} 224}
224EXPORT_SYMBOL_GPL(flow_offload_add); 225EXPORT_SYMBOL_GPL(flow_offload_add);
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index e546f759b7a7..ad783f4840ef 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -347,7 +347,7 @@ int nft_flow_rule_offload_commit(struct net *net)
347 347
348 policy = nft_trans_chain_policy(trans); 348 policy = nft_trans_chain_policy(trans);
349 err = nft_flow_offload_chain(trans->ctx.chain, &policy, 349 err = nft_flow_offload_chain(trans->ctx.chain, &policy,
350 FLOW_BLOCK_BIND); 350 FLOW_BLOCK_UNBIND);
351 break; 351 break;
352 case NFT_MSG_NEWRULE: 352 case NFT_MSG_NEWRULE:
353 if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD)) 353 if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 22a80eb60222..5cb2d8908d2a 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -161,13 +161,21 @@ static int nft_payload_offload_ll(struct nft_offload_ctx *ctx,
161 161
162 switch (priv->offset) { 162 switch (priv->offset) {
163 case offsetof(struct ethhdr, h_source): 163 case offsetof(struct ethhdr, h_source):
164 if (priv->len != ETH_ALEN)
165 return -EOPNOTSUPP;
166
164 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_ETH_ADDRS, eth_addrs, 167 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_ETH_ADDRS, eth_addrs,
165 src, ETH_ALEN, reg); 168 src, ETH_ALEN, reg);
166 break; 169 break;
167 case offsetof(struct ethhdr, h_dest): 170 case offsetof(struct ethhdr, h_dest):
171 if (priv->len != ETH_ALEN)
172 return -EOPNOTSUPP;
173
168 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_ETH_ADDRS, eth_addrs, 174 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_ETH_ADDRS, eth_addrs,
169 dst, ETH_ALEN, reg); 175 dst, ETH_ALEN, reg);
170 break; 176 break;
177 default:
178 return -EOPNOTSUPP;
171 } 179 }
172 180
173 return 0; 181 return 0;
@@ -181,14 +189,23 @@ static int nft_payload_offload_ip(struct nft_offload_ctx *ctx,
181 189
182 switch (priv->offset) { 190 switch (priv->offset) {
183 case offsetof(struct iphdr, saddr): 191 case offsetof(struct iphdr, saddr):
192 if (priv->len != sizeof(struct in_addr))
193 return -EOPNOTSUPP;
194
184 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4, src, 195 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4, src,
185 sizeof(struct in_addr), reg); 196 sizeof(struct in_addr), reg);
186 break; 197 break;
187 case offsetof(struct iphdr, daddr): 198 case offsetof(struct iphdr, daddr):
199 if (priv->len != sizeof(struct in_addr))
200 return -EOPNOTSUPP;
201
188 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4, dst, 202 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4, dst,
189 sizeof(struct in_addr), reg); 203 sizeof(struct in_addr), reg);
190 break; 204 break;
191 case offsetof(struct iphdr, protocol): 205 case offsetof(struct iphdr, protocol):
206 if (priv->len != sizeof(__u8))
207 return -EOPNOTSUPP;
208
192 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_BASIC, basic, ip_proto, 209 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_BASIC, basic, ip_proto,
193 sizeof(__u8), reg); 210 sizeof(__u8), reg);
194 nft_offload_set_dependency(ctx, NFT_OFFLOAD_DEP_TRANSPORT); 211 nft_offload_set_dependency(ctx, NFT_OFFLOAD_DEP_TRANSPORT);
@@ -208,14 +225,23 @@ static int nft_payload_offload_ip6(struct nft_offload_ctx *ctx,
208 225
209 switch (priv->offset) { 226 switch (priv->offset) {
210 case offsetof(struct ipv6hdr, saddr): 227 case offsetof(struct ipv6hdr, saddr):
228 if (priv->len != sizeof(struct in6_addr))
229 return -EOPNOTSUPP;
230
211 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6, src, 231 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6, src,
212 sizeof(struct in6_addr), reg); 232 sizeof(struct in6_addr), reg);
213 break; 233 break;
214 case offsetof(struct ipv6hdr, daddr): 234 case offsetof(struct ipv6hdr, daddr):
235 if (priv->len != sizeof(struct in6_addr))
236 return -EOPNOTSUPP;
237
215 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6, dst, 238 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6, dst,
216 sizeof(struct in6_addr), reg); 239 sizeof(struct in6_addr), reg);
217 break; 240 break;
218 case offsetof(struct ipv6hdr, nexthdr): 241 case offsetof(struct ipv6hdr, nexthdr):
242 if (priv->len != sizeof(__u8))
243 return -EOPNOTSUPP;
244
219 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_BASIC, basic, ip_proto, 245 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_BASIC, basic, ip_proto,
220 sizeof(__u8), reg); 246 sizeof(__u8), reg);
221 nft_offload_set_dependency(ctx, NFT_OFFLOAD_DEP_TRANSPORT); 247 nft_offload_set_dependency(ctx, NFT_OFFLOAD_DEP_TRANSPORT);
@@ -255,10 +281,16 @@ static int nft_payload_offload_tcp(struct nft_offload_ctx *ctx,
255 281
256 switch (priv->offset) { 282 switch (priv->offset) {
257 case offsetof(struct tcphdr, source): 283 case offsetof(struct tcphdr, source):
284 if (priv->len != sizeof(__be16))
285 return -EOPNOTSUPP;
286
258 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, src, 287 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, src,
259 sizeof(__be16), reg); 288 sizeof(__be16), reg);
260 break; 289 break;
261 case offsetof(struct tcphdr, dest): 290 case offsetof(struct tcphdr, dest):
291 if (priv->len != sizeof(__be16))
292 return -EOPNOTSUPP;
293
262 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, dst, 294 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, dst,
263 sizeof(__be16), reg); 295 sizeof(__be16), reg);
264 break; 296 break;
@@ -277,10 +309,16 @@ static int nft_payload_offload_udp(struct nft_offload_ctx *ctx,
277 309
278 switch (priv->offset) { 310 switch (priv->offset) {
279 case offsetof(struct udphdr, source): 311 case offsetof(struct udphdr, source):
312 if (priv->len != sizeof(__be16))
313 return -EOPNOTSUPP;
314
280 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, src, 315 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, src,
281 sizeof(__be16), reg); 316 sizeof(__be16), reg);
282 break; 317 break;
283 case offsetof(struct udphdr, dest): 318 case offsetof(struct udphdr, dest):
319 if (priv->len != sizeof(__be16))
320 return -EOPNOTSUPP;
321
284 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, dst, 322 NFT_OFFLOAD_MATCH(FLOW_DISSECTOR_KEY_PORTS, tp, dst,
285 sizeof(__be16), reg); 323 sizeof(__be16), reg);
286 break; 324 break;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index c4f54ad2b98a..58d5373c513c 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -64,28 +64,6 @@ static DEFINE_SPINLOCK(nr_list_lock);
64static const struct proto_ops nr_proto_ops; 64static const struct proto_ops nr_proto_ops;
65 65
66/* 66/*
67 * NETROM network devices are virtual network devices encapsulating NETROM
68 * frames into AX.25 which will be sent through an AX.25 device, so form a
69 * special "super class" of normal net devices; split their locks off into a
70 * separate class since they always nest.
71 */
72static struct lock_class_key nr_netdev_xmit_lock_key;
73static struct lock_class_key nr_netdev_addr_lock_key;
74
75static void nr_set_lockdep_one(struct net_device *dev,
76 struct netdev_queue *txq,
77 void *_unused)
78{
79 lockdep_set_class(&txq->_xmit_lock, &nr_netdev_xmit_lock_key);
80}
81
82static void nr_set_lockdep_key(struct net_device *dev)
83{
84 lockdep_set_class(&dev->addr_list_lock, &nr_netdev_addr_lock_key);
85 netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL);
86}
87
88/*
89 * Socket removal during an interrupt is now safe. 67 * Socket removal during an interrupt is now safe.
90 */ 68 */
91static void nr_remove_socket(struct sock *sk) 69static void nr_remove_socket(struct sock *sk)
@@ -1414,7 +1392,6 @@ static int __init nr_proto_init(void)
1414 free_netdev(dev); 1392 free_netdev(dev);
1415 goto fail; 1393 goto fail;
1416 } 1394 }
1417 nr_set_lockdep_key(dev);
1418 dev_nr[i] = dev; 1395 dev_nr[i] = dev;
1419 } 1396 }
1420 1397
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index ccdd790e163a..28604414dec1 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -554,11 +554,11 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
554 if (sk->sk_state == LLCP_LISTEN) 554 if (sk->sk_state == LLCP_LISTEN)
555 return llcp_accept_poll(sk); 555 return llcp_accept_poll(sk);
556 556
557 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 557 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
558 mask |= EPOLLERR | 558 mask |= EPOLLERR |
559 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); 559 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
560 560
561 if (!skb_queue_empty(&sk->sk_receive_queue)) 561 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
562 mask |= EPOLLIN | EPOLLRDNORM; 562 mask |= EPOLLIN | EPOLLRDNORM;
563 563
564 if (sk->sk_state == LLCP_CLOSED) 564 if (sk->sk_state == LLCP_CLOSED)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index f30e406fbec5..d8c364d637b1 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1881,7 +1881,7 @@ static struct genl_family dp_datapath_genl_family __ro_after_init = {
1881/* Called with ovs_mutex or RCU read lock. */ 1881/* Called with ovs_mutex or RCU read lock. */
1882static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, 1882static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,
1883 struct net *net, u32 portid, u32 seq, 1883 struct net *net, u32 portid, u32 seq,
1884 u32 flags, u8 cmd) 1884 u32 flags, u8 cmd, gfp_t gfp)
1885{ 1885{
1886 struct ovs_header *ovs_header; 1886 struct ovs_header *ovs_header;
1887 struct ovs_vport_stats vport_stats; 1887 struct ovs_vport_stats vport_stats;
@@ -1902,7 +1902,7 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,
1902 goto nla_put_failure; 1902 goto nla_put_failure;
1903 1903
1904 if (!net_eq(net, dev_net(vport->dev))) { 1904 if (!net_eq(net, dev_net(vport->dev))) {
1905 int id = peernet2id_alloc(net, dev_net(vport->dev)); 1905 int id = peernet2id_alloc(net, dev_net(vport->dev), gfp);
1906 1906
1907 if (nla_put_s32(skb, OVS_VPORT_ATTR_NETNSID, id)) 1907 if (nla_put_s32(skb, OVS_VPORT_ATTR_NETNSID, id))
1908 goto nla_put_failure; 1908 goto nla_put_failure;
@@ -1943,11 +1943,12 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *vport, struct net *net,
1943 struct sk_buff *skb; 1943 struct sk_buff *skb;
1944 int retval; 1944 int retval;
1945 1945
1946 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); 1946 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1947 if (!skb) 1947 if (!skb)
1948 return ERR_PTR(-ENOMEM); 1948 return ERR_PTR(-ENOMEM);
1949 1949
1950 retval = ovs_vport_cmd_fill_info(vport, skb, net, portid, seq, 0, cmd); 1950 retval = ovs_vport_cmd_fill_info(vport, skb, net, portid, seq, 0, cmd,
1951 GFP_KERNEL);
1951 BUG_ON(retval < 0); 1952 BUG_ON(retval < 0);
1952 1953
1953 return skb; 1954 return skb;
@@ -2089,7 +2090,7 @@ restart:
2089 2090
2090 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), 2091 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
2091 info->snd_portid, info->snd_seq, 0, 2092 info->snd_portid, info->snd_seq, 0,
2092 OVS_VPORT_CMD_NEW); 2093 OVS_VPORT_CMD_NEW, GFP_KERNEL);
2093 2094
2094 new_headroom = netdev_get_fwd_headroom(vport->dev); 2095 new_headroom = netdev_get_fwd_headroom(vport->dev);
2095 2096
@@ -2150,7 +2151,7 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
2150 2151
2151 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), 2152 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
2152 info->snd_portid, info->snd_seq, 0, 2153 info->snd_portid, info->snd_seq, 0,
2153 OVS_VPORT_CMD_SET); 2154 OVS_VPORT_CMD_SET, GFP_KERNEL);
2154 BUG_ON(err < 0); 2155 BUG_ON(err < 0);
2155 2156
2156 ovs_unlock(); 2157 ovs_unlock();
@@ -2190,7 +2191,7 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info)
2190 2191
2191 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), 2192 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
2192 info->snd_portid, info->snd_seq, 0, 2193 info->snd_portid, info->snd_seq, 0,
2193 OVS_VPORT_CMD_DEL); 2194 OVS_VPORT_CMD_DEL, GFP_KERNEL);
2194 BUG_ON(err < 0); 2195 BUG_ON(err < 0);
2195 2196
2196 /* the vport deletion may trigger dp headroom update */ 2197 /* the vport deletion may trigger dp headroom update */
@@ -2237,7 +2238,7 @@ static int ovs_vport_cmd_get(struct sk_buff *skb, struct genl_info *info)
2237 goto exit_unlock_free; 2238 goto exit_unlock_free;
2238 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), 2239 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
2239 info->snd_portid, info->snd_seq, 0, 2240 info->snd_portid, info->snd_seq, 0,
2240 OVS_VPORT_CMD_GET); 2241 OVS_VPORT_CMD_GET, GFP_ATOMIC);
2241 BUG_ON(err < 0); 2242 BUG_ON(err < 0);
2242 rcu_read_unlock(); 2243 rcu_read_unlock();
2243 2244
@@ -2273,7 +2274,8 @@ static int ovs_vport_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
2273 NETLINK_CB(cb->skb).portid, 2274 NETLINK_CB(cb->skb).portid,
2274 cb->nlh->nlmsg_seq, 2275 cb->nlh->nlmsg_seq,
2275 NLM_F_MULTI, 2276 NLM_F_MULTI,
2276 OVS_VPORT_CMD_GET) < 0) 2277 OVS_VPORT_CMD_GET,
2278 GFP_ATOMIC) < 0)
2277 goto out; 2279 goto out;
2278 2280
2279 j++; 2281 j++;
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 21c90d3a7ebf..58a7b8312c28 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -137,7 +137,7 @@ static void do_setup(struct net_device *netdev)
137 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_OPENVSWITCH | 137 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_OPENVSWITCH |
138 IFF_NO_QUEUE; 138 IFF_NO_QUEUE;
139 netdev->needs_free_netdev = true; 139 netdev->needs_free_netdev = true;
140 netdev->priv_destructor = internal_dev_destructor; 140 netdev->priv_destructor = NULL;
141 netdev->ethtool_ops = &internal_dev_ethtool_ops; 141 netdev->ethtool_ops = &internal_dev_ethtool_ops;
142 netdev->rtnl_link_ops = &internal_dev_link_ops; 142 netdev->rtnl_link_ops = &internal_dev_link_ops;
143 143
@@ -159,7 +159,6 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
159 struct internal_dev *internal_dev; 159 struct internal_dev *internal_dev;
160 struct net_device *dev; 160 struct net_device *dev;
161 int err; 161 int err;
162 bool free_vport = true;
163 162
164 vport = ovs_vport_alloc(0, &ovs_internal_vport_ops, parms); 163 vport = ovs_vport_alloc(0, &ovs_internal_vport_ops, parms);
165 if (IS_ERR(vport)) { 164 if (IS_ERR(vport)) {
@@ -190,10 +189,9 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
190 189
191 rtnl_lock(); 190 rtnl_lock();
192 err = register_netdevice(vport->dev); 191 err = register_netdevice(vport->dev);
193 if (err) { 192 if (err)
194 free_vport = false;
195 goto error_unlock; 193 goto error_unlock;
196 } 194 vport->dev->priv_destructor = internal_dev_destructor;
197 195
198 dev_set_promiscuity(vport->dev, 1); 196 dev_set_promiscuity(vport->dev, 1);
199 rtnl_unlock(); 197 rtnl_unlock();
@@ -207,8 +205,7 @@ error_unlock:
207error_free_netdev: 205error_free_netdev:
208 free_netdev(dev); 206 free_netdev(dev);
209error_free_vport: 207error_free_vport:
210 if (free_vport) 208 ovs_vport_free(vport);
211 ovs_vport_free(vport);
212error: 209error:
213 return ERR_PTR(err); 210 return ERR_PTR(err);
214} 211}
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 96ea9f254ae9..76d499f6af9a 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -338,9 +338,9 @@ static __poll_t pn_socket_poll(struct file *file, struct socket *sock,
338 338
339 if (sk->sk_state == TCP_CLOSE) 339 if (sk->sk_state == TCP_CLOSE)
340 return EPOLLERR; 340 return EPOLLERR;
341 if (!skb_queue_empty(&sk->sk_receive_queue)) 341 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
342 mask |= EPOLLIN | EPOLLRDNORM; 342 mask |= EPOLLIN | EPOLLRDNORM;
343 if (!skb_queue_empty(&pn->ctrlreq_queue)) 343 if (!skb_queue_empty_lockless(&pn->ctrlreq_queue))
344 mask |= EPOLLPRI; 344 mask |= EPOLLPRI;
345 if (!mask && sk->sk_state == TCP_CLOSE_WAIT) 345 if (!mask && sk->sk_state == TCP_CLOSE_WAIT)
346 return EPOLLHUP; 346 return EPOLLHUP;
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index f0e9ccf472a9..6a0df7c8a939 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -65,28 +65,6 @@ static const struct proto_ops rose_proto_ops;
65ax25_address rose_callsign; 65ax25_address rose_callsign;
66 66
67/* 67/*
68 * ROSE network devices are virtual network devices encapsulating ROSE
69 * frames into AX.25 which will be sent through an AX.25 device, so form a
70 * special "super class" of normal net devices; split their locks off into a
71 * separate class since they always nest.
72 */
73static struct lock_class_key rose_netdev_xmit_lock_key;
74static struct lock_class_key rose_netdev_addr_lock_key;
75
76static void rose_set_lockdep_one(struct net_device *dev,
77 struct netdev_queue *txq,
78 void *_unused)
79{
80 lockdep_set_class(&txq->_xmit_lock, &rose_netdev_xmit_lock_key);
81}
82
83static void rose_set_lockdep_key(struct net_device *dev)
84{
85 lockdep_set_class(&dev->addr_list_lock, &rose_netdev_addr_lock_key);
86 netdev_for_each_tx_queue(dev, rose_set_lockdep_one, NULL);
87}
88
89/*
90 * Convert a ROSE address into text. 68 * Convert a ROSE address into text.
91 */ 69 */
92char *rose2asc(char *buf, const rose_address *addr) 70char *rose2asc(char *buf, const rose_address *addr)
@@ -1533,7 +1511,6 @@ static int __init rose_proto_init(void)
1533 free_netdev(dev); 1511 free_netdev(dev);
1534 goto fail; 1512 goto fail;
1535 } 1513 }
1536 rose_set_lockdep_key(dev);
1537 dev_rose[i] = dev; 1514 dev_rose[i] = dev;
1538 } 1515 }
1539 1516
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index ecc17dabec8f..7c7d10f2e0c1 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -601,6 +601,7 @@ struct rxrpc_call {
601 int debug_id; /* debug ID for printks */ 601 int debug_id; /* debug ID for printks */
602 unsigned short rx_pkt_offset; /* Current recvmsg packet offset */ 602 unsigned short rx_pkt_offset; /* Current recvmsg packet offset */
603 unsigned short rx_pkt_len; /* Current recvmsg packet len */ 603 unsigned short rx_pkt_len; /* Current recvmsg packet len */
604 bool rx_pkt_last; /* Current recvmsg packet is last */
604 605
605 /* Rx/Tx circular buffer, depending on phase. 606 /* Rx/Tx circular buffer, depending on phase.
606 * 607 *
diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index a4090797c9b2..8578c39ec839 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -267,11 +267,13 @@ static int rxrpc_verify_packet(struct rxrpc_call *call, struct sk_buff *skb,
267 */ 267 */
268static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb, 268static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb,
269 u8 *_annotation, 269 u8 *_annotation,
270 unsigned int *_offset, unsigned int *_len) 270 unsigned int *_offset, unsigned int *_len,
271 bool *_last)
271{ 272{
272 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 273 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
273 unsigned int offset = sizeof(struct rxrpc_wire_header); 274 unsigned int offset = sizeof(struct rxrpc_wire_header);
274 unsigned int len; 275 unsigned int len;
276 bool last = false;
275 int ret; 277 int ret;
276 u8 annotation = *_annotation; 278 u8 annotation = *_annotation;
277 u8 subpacket = annotation & RXRPC_RX_ANNO_SUBPACKET; 279 u8 subpacket = annotation & RXRPC_RX_ANNO_SUBPACKET;
@@ -281,6 +283,8 @@ static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb,
281 len = skb->len - offset; 283 len = skb->len - offset;
282 if (subpacket < sp->nr_subpackets - 1) 284 if (subpacket < sp->nr_subpackets - 1)
283 len = RXRPC_JUMBO_DATALEN; 285 len = RXRPC_JUMBO_DATALEN;
286 else if (sp->rx_flags & RXRPC_SKB_INCL_LAST)
287 last = true;
284 288
285 if (!(annotation & RXRPC_RX_ANNO_VERIFIED)) { 289 if (!(annotation & RXRPC_RX_ANNO_VERIFIED)) {
286 ret = rxrpc_verify_packet(call, skb, annotation, offset, len); 290 ret = rxrpc_verify_packet(call, skb, annotation, offset, len);
@@ -291,6 +295,7 @@ static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb,
291 295
292 *_offset = offset; 296 *_offset = offset;
293 *_len = len; 297 *_len = len;
298 *_last = last;
294 call->security->locate_data(call, skb, _offset, _len); 299 call->security->locate_data(call, skb, _offset, _len);
295 return 0; 300 return 0;
296} 301}
@@ -309,7 +314,7 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
309 rxrpc_serial_t serial; 314 rxrpc_serial_t serial;
310 rxrpc_seq_t hard_ack, top, seq; 315 rxrpc_seq_t hard_ack, top, seq;
311 size_t remain; 316 size_t remain;
312 bool last; 317 bool rx_pkt_last;
313 unsigned int rx_pkt_offset, rx_pkt_len; 318 unsigned int rx_pkt_offset, rx_pkt_len;
314 int ix, copy, ret = -EAGAIN, ret2; 319 int ix, copy, ret = -EAGAIN, ret2;
315 320
@@ -319,6 +324,7 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
319 324
320 rx_pkt_offset = call->rx_pkt_offset; 325 rx_pkt_offset = call->rx_pkt_offset;
321 rx_pkt_len = call->rx_pkt_len; 326 rx_pkt_len = call->rx_pkt_len;
327 rx_pkt_last = call->rx_pkt_last;
322 328
323 if (call->state >= RXRPC_CALL_SERVER_ACK_REQUEST) { 329 if (call->state >= RXRPC_CALL_SERVER_ACK_REQUEST) {
324 seq = call->rx_hard_ack; 330 seq = call->rx_hard_ack;
@@ -329,6 +335,7 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
329 /* Barriers against rxrpc_input_data(). */ 335 /* Barriers against rxrpc_input_data(). */
330 hard_ack = call->rx_hard_ack; 336 hard_ack = call->rx_hard_ack;
331 seq = hard_ack + 1; 337 seq = hard_ack + 1;
338
332 while (top = smp_load_acquire(&call->rx_top), 339 while (top = smp_load_acquire(&call->rx_top),
333 before_eq(seq, top) 340 before_eq(seq, top)
334 ) { 341 ) {
@@ -356,7 +363,8 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
356 if (rx_pkt_offset == 0) { 363 if (rx_pkt_offset == 0) {
357 ret2 = rxrpc_locate_data(call, skb, 364 ret2 = rxrpc_locate_data(call, skb,
358 &call->rxtx_annotations[ix], 365 &call->rxtx_annotations[ix],
359 &rx_pkt_offset, &rx_pkt_len); 366 &rx_pkt_offset, &rx_pkt_len,
367 &rx_pkt_last);
360 trace_rxrpc_recvmsg(call, rxrpc_recvmsg_next, seq, 368 trace_rxrpc_recvmsg(call, rxrpc_recvmsg_next, seq,
361 rx_pkt_offset, rx_pkt_len, ret2); 369 rx_pkt_offset, rx_pkt_len, ret2);
362 if (ret2 < 0) { 370 if (ret2 < 0) {
@@ -396,13 +404,12 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
396 } 404 }
397 405
398 /* The whole packet has been transferred. */ 406 /* The whole packet has been transferred. */
399 last = sp->hdr.flags & RXRPC_LAST_PACKET;
400 if (!(flags & MSG_PEEK)) 407 if (!(flags & MSG_PEEK))
401 rxrpc_rotate_rx_window(call); 408 rxrpc_rotate_rx_window(call);
402 rx_pkt_offset = 0; 409 rx_pkt_offset = 0;
403 rx_pkt_len = 0; 410 rx_pkt_len = 0;
404 411
405 if (last) { 412 if (rx_pkt_last) {
406 ASSERTCMP(seq, ==, READ_ONCE(call->rx_top)); 413 ASSERTCMP(seq, ==, READ_ONCE(call->rx_top));
407 ret = 1; 414 ret = 1;
408 goto out; 415 goto out;
@@ -415,6 +422,7 @@ out:
415 if (!(flags & MSG_PEEK)) { 422 if (!(flags & MSG_PEEK)) {
416 call->rx_pkt_offset = rx_pkt_offset; 423 call->rx_pkt_offset = rx_pkt_offset;
417 call->rx_pkt_len = rx_pkt_len; 424 call->rx_pkt_len = rx_pkt_len;
425 call->rx_pkt_last = rx_pkt_last;
418 } 426 }
419done: 427done:
420 trace_rxrpc_recvmsg(call, rxrpc_recvmsg_data_return, seq, 428 trace_rxrpc_recvmsg(call, rxrpc_recvmsg_data_return, seq,
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index bf10bdaf5012..8229ed4a67be 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -162,16 +162,20 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
162 cls_bpf.name = obj->bpf_name; 162 cls_bpf.name = obj->bpf_name;
163 cls_bpf.exts_integrated = obj->exts_integrated; 163 cls_bpf.exts_integrated = obj->exts_integrated;
164 164
165 if (oldprog) 165 if (oldprog && prog)
166 err = tc_setup_cb_replace(block, tp, TC_SETUP_CLSBPF, &cls_bpf, 166 err = tc_setup_cb_replace(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
167 skip_sw, &oldprog->gen_flags, 167 skip_sw, &oldprog->gen_flags,
168 &oldprog->in_hw_count, 168 &oldprog->in_hw_count,
169 &prog->gen_flags, &prog->in_hw_count, 169 &prog->gen_flags, &prog->in_hw_count,
170 true); 170 true);
171 else 171 else if (prog)
172 err = tc_setup_cb_add(block, tp, TC_SETUP_CLSBPF, &cls_bpf, 172 err = tc_setup_cb_add(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
173 skip_sw, &prog->gen_flags, 173 skip_sw, &prog->gen_flags,
174 &prog->in_hw_count, true); 174 &prog->in_hw_count, true);
175 else
176 err = tc_setup_cb_destroy(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
177 skip_sw, &oldprog->gen_flags,
178 &oldprog->in_hw_count, true);
175 179
176 if (prog && err) { 180 if (prog && err) {
177 cls_bpf_offload_cmd(tp, oldprog, prog, extack); 181 cls_bpf_offload_cmd(tp, oldprog, prog, extack);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 17bd8f539bc7..8769b4b8807d 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -799,9 +799,6 @@ struct Qdisc_ops pfifo_fast_ops __read_mostly = {
799}; 799};
800EXPORT_SYMBOL(pfifo_fast_ops); 800EXPORT_SYMBOL(pfifo_fast_ops);
801 801
802static struct lock_class_key qdisc_tx_busylock;
803static struct lock_class_key qdisc_running_key;
804
805struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, 802struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
806 const struct Qdisc_ops *ops, 803 const struct Qdisc_ops *ops,
807 struct netlink_ext_ack *extack) 804 struct netlink_ext_ack *extack)
@@ -854,17 +851,9 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
854 } 851 }
855 852
856 spin_lock_init(&sch->busylock); 853 spin_lock_init(&sch->busylock);
857 lockdep_set_class(&sch->busylock,
858 dev->qdisc_tx_busylock ?: &qdisc_tx_busylock);
859
860 /* seqlock has the same scope of busylock, for NOLOCK qdisc */ 854 /* seqlock has the same scope of busylock, for NOLOCK qdisc */
861 spin_lock_init(&sch->seqlock); 855 spin_lock_init(&sch->seqlock);
862 lockdep_set_class(&sch->busylock,
863 dev->qdisc_tx_busylock ?: &qdisc_tx_busylock);
864
865 seqcount_init(&sch->running); 856 seqcount_init(&sch->running);
866 lockdep_set_class(&sch->running,
867 dev->qdisc_running_key ?: &qdisc_running_key);
868 857
869 sch->ops = ops; 858 sch->ops = ops;
870 sch->flags = ops->static_flags; 859 sch->flags = ops->static_flags;
@@ -875,6 +864,12 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
875 dev_hold(dev); 864 dev_hold(dev);
876 refcount_set(&sch->refcnt, 1); 865 refcount_set(&sch->refcnt, 1);
877 866
867 if (sch != &noop_qdisc) {
868 lockdep_set_class(&sch->busylock, &dev->qdisc_tx_busylock_key);
869 lockdep_set_class(&sch->seqlock, &dev->qdisc_tx_busylock_key);
870 lockdep_set_class(&sch->running, &dev->qdisc_running_key);
871 }
872
878 return sch; 873 return sch;
879errout1: 874errout1:
880 kfree(p); 875 kfree(p);
@@ -1043,6 +1038,8 @@ static void attach_one_default_qdisc(struct net_device *dev,
1043 1038
1044 if (dev->priv_flags & IFF_NO_QUEUE) 1039 if (dev->priv_flags & IFF_NO_QUEUE)
1045 ops = &noqueue_qdisc_ops; 1040 ops = &noqueue_qdisc_ops;
1041 else if(dev->type == ARPHRD_CAN)
1042 ops = &pfifo_fast_ops;
1046 1043
1047 qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL); 1044 qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL);
1048 if (!qdisc) { 1045 if (!qdisc) {
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c
index 23cd1c873a2c..be35f03b657b 100644
--- a/net/sched/sch_hhf.c
+++ b/net/sched/sch_hhf.c
@@ -5,11 +5,11 @@
5 * Copyright (C) 2013 Nandita Dukkipati <nanditad@google.com> 5 * Copyright (C) 2013 Nandita Dukkipati <nanditad@google.com>
6 */ 6 */
7 7
8#include <linux/jhash.h>
9#include <linux/jiffies.h> 8#include <linux/jiffies.h>
10#include <linux/module.h> 9#include <linux/module.h>
11#include <linux/skbuff.h> 10#include <linux/skbuff.h>
12#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
12#include <linux/siphash.h>
13#include <net/pkt_sched.h> 13#include <net/pkt_sched.h>
14#include <net/sock.h> 14#include <net/sock.h>
15 15
@@ -126,7 +126,7 @@ struct wdrr_bucket {
126 126
127struct hhf_sched_data { 127struct hhf_sched_data {
128 struct wdrr_bucket buckets[WDRR_BUCKET_CNT]; 128 struct wdrr_bucket buckets[WDRR_BUCKET_CNT];
129 u32 perturbation; /* hash perturbation */ 129 siphash_key_t perturbation; /* hash perturbation */
130 u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ 130 u32 quantum; /* psched_mtu(qdisc_dev(sch)); */
131 u32 drop_overlimit; /* number of times max qdisc packet 131 u32 drop_overlimit; /* number of times max qdisc packet
132 * limit was hit 132 * limit was hit
@@ -264,7 +264,7 @@ static enum wdrr_bucket_idx hhf_classify(struct sk_buff *skb, struct Qdisc *sch)
264 } 264 }
265 265
266 /* Get hashed flow-id of the skb. */ 266 /* Get hashed flow-id of the skb. */
267 hash = skb_get_hash_perturb(skb, q->perturbation); 267 hash = skb_get_hash_perturb(skb, &q->perturbation);
268 268
269 /* Check if this packet belongs to an already established HH flow. */ 269 /* Check if this packet belongs to an already established HH flow. */
270 flow_pos = hash & HHF_BIT_MASK; 270 flow_pos = hash & HHF_BIT_MASK;
@@ -582,7 +582,7 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,
582 582
583 sch->limit = 1000; 583 sch->limit = 1000;
584 q->quantum = psched_mtu(qdisc_dev(sch)); 584 q->quantum = psched_mtu(qdisc_dev(sch));
585 q->perturbation = prandom_u32(); 585 get_random_bytes(&q->perturbation, sizeof(q->perturbation));
586 INIT_LIST_HEAD(&q->new_buckets); 586 INIT_LIST_HEAD(&q->new_buckets);
587 INIT_LIST_HEAD(&q->old_buckets); 587 INIT_LIST_HEAD(&q->old_buckets);
588 588
diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
index d448fe3068e5..4074c50ac3d7 100644
--- a/net/sched/sch_sfb.c
+++ b/net/sched/sch_sfb.c
@@ -18,7 +18,7 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/skbuff.h> 19#include <linux/skbuff.h>
20#include <linux/random.h> 20#include <linux/random.h>
21#include <linux/jhash.h> 21#include <linux/siphash.h>
22#include <net/ip.h> 22#include <net/ip.h>
23#include <net/pkt_sched.h> 23#include <net/pkt_sched.h>
24#include <net/pkt_cls.h> 24#include <net/pkt_cls.h>
@@ -45,7 +45,7 @@ struct sfb_bucket {
45 * (Section 4.4 of SFB reference : moving hash functions) 45 * (Section 4.4 of SFB reference : moving hash functions)
46 */ 46 */
47struct sfb_bins { 47struct sfb_bins {
48 u32 perturbation; /* jhash perturbation */ 48 siphash_key_t perturbation; /* siphash key */
49 struct sfb_bucket bins[SFB_LEVELS][SFB_NUMBUCKETS]; 49 struct sfb_bucket bins[SFB_LEVELS][SFB_NUMBUCKETS];
50}; 50};
51 51
@@ -217,7 +217,8 @@ static u32 sfb_compute_qlen(u32 *prob_r, u32 *avgpm_r, const struct sfb_sched_da
217 217
218static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q) 218static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q)
219{ 219{
220 q->bins[slot].perturbation = prandom_u32(); 220 get_random_bytes(&q->bins[slot].perturbation,
221 sizeof(q->bins[slot].perturbation));
221} 222}
222 223
223static void sfb_swap_slot(struct sfb_sched_data *q) 224static void sfb_swap_slot(struct sfb_sched_data *q)
@@ -314,9 +315,9 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
314 /* If using external classifiers, get result and record it. */ 315 /* If using external classifiers, get result and record it. */
315 if (!sfb_classify(skb, fl, &ret, &salt)) 316 if (!sfb_classify(skb, fl, &ret, &salt))
316 goto other_drop; 317 goto other_drop;
317 sfbhash = jhash_1word(salt, q->bins[slot].perturbation); 318 sfbhash = siphash_1u32(salt, &q->bins[slot].perturbation);
318 } else { 319 } else {
319 sfbhash = skb_get_hash_perturb(skb, q->bins[slot].perturbation); 320 sfbhash = skb_get_hash_perturb(skb, &q->bins[slot].perturbation);
320 } 321 }
321 322
322 323
@@ -352,7 +353,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
352 /* Inelastic flow */ 353 /* Inelastic flow */
353 if (q->double_buffering) { 354 if (q->double_buffering) {
354 sfbhash = skb_get_hash_perturb(skb, 355 sfbhash = skb_get_hash_perturb(skb,
355 q->bins[slot].perturbation); 356 &q->bins[slot].perturbation);
356 if (!sfbhash) 357 if (!sfbhash)
357 sfbhash = 1; 358 sfbhash = 1;
358 sfb_skb_cb(skb)->hashes[slot] = sfbhash; 359 sfb_skb_cb(skb)->hashes[slot] = sfbhash;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 68404a9d2ce4..c787d4d46017 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -14,7 +14,7 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/skbuff.h> 16#include <linux/skbuff.h>
17#include <linux/jhash.h> 17#include <linux/siphash.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
20#include <net/netlink.h> 20#include <net/netlink.h>
@@ -117,7 +117,7 @@ struct sfq_sched_data {
117 u8 headdrop; 117 u8 headdrop;
118 u8 maxdepth; /* limit of packets per flow */ 118 u8 maxdepth; /* limit of packets per flow */
119 119
120 u32 perturbation; 120 siphash_key_t perturbation;
121 u8 cur_depth; /* depth of longest slot */ 121 u8 cur_depth; /* depth of longest slot */
122 u8 flags; 122 u8 flags;
123 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */ 123 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */
@@ -157,7 +157,7 @@ static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index
157static unsigned int sfq_hash(const struct sfq_sched_data *q, 157static unsigned int sfq_hash(const struct sfq_sched_data *q,
158 const struct sk_buff *skb) 158 const struct sk_buff *skb)
159{ 159{
160 return skb_get_hash_perturb(skb, q->perturbation) & (q->divisor - 1); 160 return skb_get_hash_perturb(skb, &q->perturbation) & (q->divisor - 1);
161} 161}
162 162
163static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch, 163static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
@@ -607,9 +607,11 @@ static void sfq_perturbation(struct timer_list *t)
607 struct sfq_sched_data *q = from_timer(q, t, perturb_timer); 607 struct sfq_sched_data *q = from_timer(q, t, perturb_timer);
608 struct Qdisc *sch = q->sch; 608 struct Qdisc *sch = q->sch;
609 spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch)); 609 spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch));
610 siphash_key_t nkey;
610 611
612 get_random_bytes(&nkey, sizeof(nkey));
611 spin_lock(root_lock); 613 spin_lock(root_lock);
612 q->perturbation = prandom_u32(); 614 q->perturbation = nkey;
613 if (!q->filter_list && q->tail) 615 if (!q->filter_list && q->tail)
614 sfq_rehash(sch); 616 sfq_rehash(sch);
615 spin_unlock(root_lock); 617 spin_unlock(root_lock);
@@ -688,7 +690,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
688 del_timer(&q->perturb_timer); 690 del_timer(&q->perturb_timer);
689 if (q->perturb_period) { 691 if (q->perturb_period) {
690 mod_timer(&q->perturb_timer, jiffies + q->perturb_period); 692 mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
691 q->perturbation = prandom_u32(); 693 get_random_bytes(&q->perturbation, sizeof(q->perturbation));
692 } 694 }
693 sch_tree_unlock(sch); 695 sch_tree_unlock(sch);
694 kfree(p); 696 kfree(p);
@@ -745,7 +747,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt,
745 q->quantum = psched_mtu(qdisc_dev(sch)); 747 q->quantum = psched_mtu(qdisc_dev(sch));
746 q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); 748 q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum);
747 q->perturb_period = 0; 749 q->perturb_period = 0;
748 q->perturbation = prandom_u32(); 750 get_random_bytes(&q->perturbation, sizeof(q->perturbation));
749 751
750 if (opt) { 752 if (opt) {
751 int err = sfq_change(sch, opt); 753 int err = sfq_change(sch, opt);
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 6719a65169d4..2121187229cd 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1152,7 +1152,7 @@ EXPORT_SYMBOL_GPL(taprio_offload_free);
1152 * offload state (PENDING, ACTIVE, INACTIVE) so it can be visible in dump(). 1152 * offload state (PENDING, ACTIVE, INACTIVE) so it can be visible in dump().
1153 * This is left as TODO. 1153 * This is left as TODO.
1154 */ 1154 */
1155void taprio_offload_config_changed(struct taprio_sched *q) 1155static void taprio_offload_config_changed(struct taprio_sched *q)
1156{ 1156{
1157 struct sched_gate_list *oper, *admin; 1157 struct sched_gate_list *oper, *admin;
1158 1158
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 5ca0ec0e823c..ffd3262b7a41 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -8476,7 +8476,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
8476 mask = 0; 8476 mask = 0;
8477 8477
8478 /* Is there any exceptional events? */ 8478 /* Is there any exceptional events? */
8479 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 8479 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
8480 mask |= EPOLLERR | 8480 mask |= EPOLLERR |
8481 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); 8481 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
8482 if (sk->sk_shutdown & RCV_SHUTDOWN) 8482 if (sk->sk_shutdown & RCV_SHUTDOWN)
@@ -8485,7 +8485,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
8485 mask |= EPOLLHUP; 8485 mask |= EPOLLHUP;
8486 8486
8487 /* Is it readable? Reconsider this code with TCP-style support. */ 8487 /* Is it readable? Reconsider this code with TCP-style support. */
8488 if (!skb_queue_empty(&sk->sk_receive_queue)) 8488 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
8489 mask |= EPOLLIN | EPOLLRDNORM; 8489 mask |= EPOLLIN | EPOLLRDNORM;
8490 8490
8491 /* The association is either gone or not ready. */ 8491 /* The association is either gone or not ready. */
@@ -8871,7 +8871,7 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,
8871 if (sk_can_busy_loop(sk)) { 8871 if (sk_can_busy_loop(sk)) {
8872 sk_busy_loop(sk, noblock); 8872 sk_busy_loop(sk, noblock);
8873 8873
8874 if (!skb_queue_empty(&sk->sk_receive_queue)) 8874 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
8875 continue; 8875 continue;
8876 } 8876 }
8877 8877
@@ -9306,7 +9306,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
9306 newinet->inet_rcv_saddr = inet->inet_rcv_saddr; 9306 newinet->inet_rcv_saddr = inet->inet_rcv_saddr;
9307 newinet->inet_dport = htons(asoc->peer.port); 9307 newinet->inet_dport = htons(asoc->peer.port);
9308 newinet->pmtudisc = inet->pmtudisc; 9308 newinet->pmtudisc = inet->pmtudisc;
9309 newinet->inet_id = asoc->next_tsn ^ jiffies; 9309 newinet->inet_id = prandom_u32();
9310 9310
9311 newinet->uc_ttl = inet->uc_ttl; 9311 newinet->uc_ttl = inet->uc_ttl;
9312 newinet->mc_loop = 1; 9312 newinet->mc_loop = 1;
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 5b932583e407..47946f489fd4 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -123,6 +123,12 @@ struct proto smc_proto6 = {
123}; 123};
124EXPORT_SYMBOL_GPL(smc_proto6); 124EXPORT_SYMBOL_GPL(smc_proto6);
125 125
126static void smc_restore_fallback_changes(struct smc_sock *smc)
127{
128 smc->clcsock->file->private_data = smc->sk.sk_socket;
129 smc->clcsock->file = NULL;
130}
131
126static int __smc_release(struct smc_sock *smc) 132static int __smc_release(struct smc_sock *smc)
127{ 133{
128 struct sock *sk = &smc->sk; 134 struct sock *sk = &smc->sk;
@@ -141,6 +147,7 @@ static int __smc_release(struct smc_sock *smc)
141 } 147 }
142 sk->sk_state = SMC_CLOSED; 148 sk->sk_state = SMC_CLOSED;
143 sk->sk_state_change(sk); 149 sk->sk_state_change(sk);
150 smc_restore_fallback_changes(smc);
144 } 151 }
145 152
146 sk->sk_prot->unhash(sk); 153 sk->sk_prot->unhash(sk);
@@ -700,8 +707,6 @@ static int __smc_connect(struct smc_sock *smc)
700 int smc_type; 707 int smc_type;
701 int rc = 0; 708 int rc = 0;
702 709
703 sock_hold(&smc->sk); /* sock put in passive closing */
704
705 if (smc->use_fallback) 710 if (smc->use_fallback)
706 return smc_connect_fallback(smc, smc->fallback_rsn); 711 return smc_connect_fallback(smc, smc->fallback_rsn);
707 712
@@ -846,6 +851,8 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
846 rc = kernel_connect(smc->clcsock, addr, alen, flags); 851 rc = kernel_connect(smc->clcsock, addr, alen, flags);
847 if (rc && rc != -EINPROGRESS) 852 if (rc && rc != -EINPROGRESS)
848 goto out; 853 goto out;
854
855 sock_hold(&smc->sk); /* sock put in passive closing */
849 if (flags & O_NONBLOCK) { 856 if (flags & O_NONBLOCK) {
850 if (schedule_work(&smc->connect_work)) 857 if (schedule_work(&smc->connect_work))
851 smc->connect_nonblock = 1; 858 smc->connect_nonblock = 1;
@@ -1291,8 +1298,8 @@ static void smc_listen_work(struct work_struct *work)
1291 /* check if RDMA is available */ 1298 /* check if RDMA is available */
1292 if (!ism_supported) { /* SMC_TYPE_R or SMC_TYPE_B */ 1299 if (!ism_supported) { /* SMC_TYPE_R or SMC_TYPE_B */
1293 /* prepare RDMA check */ 1300 /* prepare RDMA check */
1294 memset(&ini, 0, sizeof(ini));
1295 ini.is_smcd = false; 1301 ini.is_smcd = false;
1302 ini.ism_dev = NULL;
1296 ini.ib_lcl = &pclc->lcl; 1303 ini.ib_lcl = &pclc->lcl;
1297 rc = smc_find_rdma_device(new_smc, &ini); 1304 rc = smc_find_rdma_device(new_smc, &ini);
1298 if (rc) { 1305 if (rc) {
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 88556f0251ab..2ba97ff325a5 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -561,7 +561,7 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini)
561 } 561 }
562 562
563 rtnl_lock(); 563 rtnl_lock();
564 nest_lvl = dev_get_nest_level(ndev); 564 nest_lvl = ndev->lower_level;
565 for (i = 0; i < nest_lvl; i++) { 565 for (i = 0; i < nest_lvl; i++) {
566 struct list_head *lower = &ndev->adj_list.lower; 566 struct list_head *lower = &ndev->adj_list.lower;
567 567
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index bab2da8cf17a..2920b006f65c 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -718,7 +718,7 @@ static struct net_device *pnet_find_base_ndev(struct net_device *ndev)
718 int i, nest_lvl; 718 int i, nest_lvl;
719 719
720 rtnl_lock(); 720 rtnl_lock();
721 nest_lvl = dev_get_nest_level(ndev); 721 nest_lvl = ndev->lower_level;
722 for (i = 0; i < nest_lvl; i++) { 722 for (i = 0; i < nest_lvl; i++) {
723 struct list_head *lower = &ndev->adj_list.lower; 723 struct list_head *lower = &ndev->adj_list.lower;
724 724
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index 339e8c077c2d..195b40c5dae4 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -220,7 +220,7 @@ void xprt_destroy_bc(struct rpc_xprt *xprt, unsigned int max_reqs)
220 goto out; 220 goto out;
221 221
222 spin_lock_bh(&xprt->bc_pa_lock); 222 spin_lock_bh(&xprt->bc_pa_lock);
223 xprt->bc_alloc_max -= max_reqs; 223 xprt->bc_alloc_max -= min(max_reqs, xprt->bc_alloc_max);
224 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) { 224 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) {
225 dprintk("RPC: req=%p\n", req); 225 dprintk("RPC: req=%p\n", req);
226 list_del(&req->rq_bc_pa_list); 226 list_del(&req->rq_bc_pa_list);
@@ -307,8 +307,8 @@ void xprt_free_bc_rqst(struct rpc_rqst *req)
307 */ 307 */
308 dprintk("RPC: Last session removed req=%p\n", req); 308 dprintk("RPC: Last session removed req=%p\n", req);
309 xprt_free_allocation(req); 309 xprt_free_allocation(req);
310 return;
311 } 310 }
311 xprt_put(xprt);
312} 312}
313 313
314/* 314/*
@@ -339,7 +339,7 @@ found:
339 spin_unlock(&xprt->bc_pa_lock); 339 spin_unlock(&xprt->bc_pa_lock);
340 if (new) { 340 if (new) {
341 if (req != new) 341 if (req != new)
342 xprt_free_bc_rqst(new); 342 xprt_free_allocation(new);
343 break; 343 break;
344 } else if (req) 344 } else if (req)
345 break; 345 break;
@@ -368,6 +368,7 @@ void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied)
368 set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); 368 set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
369 369
370 dprintk("RPC: add callback request to list\n"); 370 dprintk("RPC: add callback request to list\n");
371 xprt_get(xprt);
371 spin_lock(&bc_serv->sv_cb_lock); 372 spin_lock(&bc_serv->sv_cb_lock);
372 list_add(&req->rq_bc_list, &bc_serv->sv_cb_list); 373 list_add(&req->rq_bc_list, &bc_serv->sv_cb_list);
373 wake_up(&bc_serv->sv_cb_waitq); 374 wake_up(&bc_serv->sv_cb_waitq);
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 8a45b3ccc313..41df4c507193 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1943,6 +1943,11 @@ static void xprt_destroy_cb(struct work_struct *work)
1943 rpc_destroy_wait_queue(&xprt->backlog); 1943 rpc_destroy_wait_queue(&xprt->backlog);
1944 kfree(xprt->servername); 1944 kfree(xprt->servername);
1945 /* 1945 /*
1946 * Destroy any existing back channel
1947 */
1948 xprt_destroy_backchannel(xprt, UINT_MAX);
1949
1950 /*
1946 * Tear down transport state and free the rpc_xprt 1951 * Tear down transport state and free the rpc_xprt
1947 */ 1952 */
1948 xprt->ops->destroy(xprt); 1953 xprt->ops->destroy(xprt);
diff --git a/net/sunrpc/xprtrdma/backchannel.c b/net/sunrpc/xprtrdma/backchannel.c
index 50e075fcdd8f..b458bf53ca69 100644
--- a/net/sunrpc/xprtrdma/backchannel.c
+++ b/net/sunrpc/xprtrdma/backchannel.c
@@ -163,6 +163,7 @@ void xprt_rdma_bc_free_rqst(struct rpc_rqst *rqst)
163 spin_lock(&xprt->bc_pa_lock); 163 spin_lock(&xprt->bc_pa_lock);
164 list_add_tail(&rqst->rq_bc_pa_list, &xprt->bc_pa_list); 164 list_add_tail(&rqst->rq_bc_pa_list, &xprt->bc_pa_list);
165 spin_unlock(&xprt->bc_pa_lock); 165 spin_unlock(&xprt->bc_pa_lock);
166 xprt_put(xprt);
166} 167}
167 168
168static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt) 169static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt)
@@ -259,6 +260,7 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt,
259 260
260 /* Queue rqst for ULP's callback service */ 261 /* Queue rqst for ULP's callback service */
261 bc_serv = xprt->bc_serv; 262 bc_serv = xprt->bc_serv;
263 xprt_get(xprt);
262 spin_lock(&bc_serv->sv_cb_lock); 264 spin_lock(&bc_serv->sv_cb_lock);
263 list_add(&rqst->rq_bc_list, &bc_serv->sv_cb_list); 265 list_add(&rqst->rq_bc_list, &bc_serv->sv_cb_list);
264 spin_unlock(&bc_serv->sv_cb_lock); 266 spin_unlock(&bc_serv->sv_cb_lock);
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index f8bbc4aab213..4b92b196cfa6 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -740,7 +740,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
740 /* fall through */ 740 /* fall through */
741 case TIPC_LISTEN: 741 case TIPC_LISTEN:
742 case TIPC_CONNECTING: 742 case TIPC_CONNECTING:
743 if (!skb_queue_empty(&sk->sk_receive_queue)) 743 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
744 revents |= EPOLLIN | EPOLLRDNORM; 744 revents |= EPOLLIN | EPOLLRDNORM;
745 break; 745 break;
746 case TIPC_OPEN: 746 case TIPC_OPEN:
@@ -748,7 +748,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
748 revents |= EPOLLOUT; 748 revents |= EPOLLOUT;
749 if (!tipc_sk_type_connectionless(sk)) 749 if (!tipc_sk_type_connectionless(sk))
750 break; 750 break;
751 if (skb_queue_empty(&sk->sk_receive_queue)) 751 if (skb_queue_empty_lockless(&sk->sk_receive_queue))
752 break; 752 break;
753 revents |= EPOLLIN | EPOLLRDNORM; 753 revents |= EPOLLIN | EPOLLRDNORM;
754 break; 754 break;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 67e87db5877f..0d8da809bea2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2599,7 +2599,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
2599 mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM; 2599 mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;
2600 2600
2601 /* readable? */ 2601 /* readable? */
2602 if (!skb_queue_empty(&sk->sk_receive_queue)) 2602 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
2603 mask |= EPOLLIN | EPOLLRDNORM; 2603 mask |= EPOLLIN | EPOLLRDNORM;
2604 2604
2605 /* Connection-based need to check for termination and startup */ 2605 /* Connection-based need to check for termination and startup */
@@ -2628,7 +2628,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
2628 mask = 0; 2628 mask = 0;
2629 2629
2630 /* exceptional events? */ 2630 /* exceptional events? */
2631 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 2631 if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
2632 mask |= EPOLLERR | 2632 mask |= EPOLLERR |
2633 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); 2633 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
2634 2634
@@ -2638,7 +2638,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
2638 mask |= EPOLLHUP; 2638 mask |= EPOLLHUP;
2639 2639
2640 /* readable? */ 2640 /* readable? */
2641 if (!skb_queue_empty(&sk->sk_receive_queue)) 2641 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
2642 mask |= EPOLLIN | EPOLLRDNORM; 2642 mask |= EPOLLIN | EPOLLRDNORM;
2643 2643
2644 /* Connection-based need to check for termination and startup */ 2644 /* Connection-based need to check for termination and startup */
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 2ab43b2bba31..582a3e4dfce2 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -870,7 +870,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock,
870 * the queue and write as long as the socket isn't shutdown for 870 * the queue and write as long as the socket isn't shutdown for
871 * sending. 871 * sending.
872 */ 872 */
873 if (!skb_queue_empty(&sk->sk_receive_queue) || 873 if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
874 (sk->sk_shutdown & RCV_SHUTDOWN)) { 874 (sk->sk_shutdown & RCV_SHUTDOWN)) {
875 mask |= EPOLLIN | EPOLLRDNORM; 875 mask |= EPOLLIN | EPOLLRDNORM;
876 } 876 }
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index e851cafd8e2f..fcac5c6366e1 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -204,6 +204,11 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
204 return false; 204 return false;
205 } 205 }
206 206
207 /* channel 14 is only for IEEE 802.11b */
208 if (chandef->center_freq1 == 2484 &&
209 chandef->width != NL80211_CHAN_WIDTH_20_NOHT)
210 return false;
211
207 if (cfg80211_chandef_is_edmg(chandef) && 212 if (cfg80211_chandef_is_edmg(chandef) &&
208 !cfg80211_edmg_chandef_valid(chandef)) 213 !cfg80211_edmg_chandef_valid(chandef))
209 return false; 214 return false;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4453dd375de9..7b72286922f7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -393,7 +393,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
393 [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ }, 393 [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ },
394 [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY, 394 [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
395 .len = IEEE80211_MAX_MESH_ID_LEN }, 395 .len = IEEE80211_MAX_MESH_ID_LEN },
396 [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 }, 396 [NL80211_ATTR_MPATH_NEXT_HOP] = NLA_POLICY_ETH_ADDR_COMPAT,
397 397
398 [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 }, 398 [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 },
399 [NL80211_ATTR_REG_RULES] = { .type = NLA_NESTED }, 399 [NL80211_ATTR_REG_RULES] = { .type = NLA_NESTED },
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 419eb12c1e93..5b4ed5bbc542 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1559,7 +1559,8 @@ bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
1559 } 1559 }
1560 1560
1561 if (freq == 2484) { 1561 if (freq == 2484) {
1562 if (chandef->width > NL80211_CHAN_WIDTH_40) 1562 /* channel 14 is only for IEEE 802.11b */
1563 if (chandef->width != NL80211_CHAN_WIDTH_20_NOHT)
1563 return false; 1564 return false;
1564 1565
1565 *op_class = 82; /* channel 14 */ 1566 *op_class = 82; /* channel 14 */
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 16d5f353163a..3049af269fbf 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -27,6 +27,9 @@ void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
27{ 27{
28 unsigned long flags; 28 unsigned long flags;
29 29
30 if (!xs->tx)
31 return;
32
30 spin_lock_irqsave(&umem->xsk_list_lock, flags); 33 spin_lock_irqsave(&umem->xsk_list_lock, flags);
31 list_add_rcu(&xs->list, &umem->xsk_list); 34 list_add_rcu(&xs->list, &umem->xsk_list);
32 spin_unlock_irqrestore(&umem->xsk_list_lock, flags); 35 spin_unlock_irqrestore(&umem->xsk_list_lock, flags);
@@ -36,6 +39,9 @@ void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
36{ 39{
37 unsigned long flags; 40 unsigned long flags;
38 41
42 if (!xs->tx)
43 return;
44
39 spin_lock_irqsave(&umem->xsk_list_lock, flags); 45 spin_lock_irqsave(&umem->xsk_list_lock, flags);
40 list_del_rcu(&xs->list); 46 list_del_rcu(&xs->list);
41 spin_unlock_irqrestore(&umem->xsk_list_lock, flags); 47 spin_unlock_irqrestore(&umem->xsk_list_lock, flags);
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index 8a10b43daf74..40b790536def 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -20,6 +20,7 @@ static const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
20 [LOCKDOWN_NONE] = "none", 20 [LOCKDOWN_NONE] = "none",
21 [LOCKDOWN_MODULE_SIGNATURE] = "unsigned module loading", 21 [LOCKDOWN_MODULE_SIGNATURE] = "unsigned module loading",
22 [LOCKDOWN_DEV_MEM] = "/dev/mem,kmem,port", 22 [LOCKDOWN_DEV_MEM] = "/dev/mem,kmem,port",
23 [LOCKDOWN_EFI_TEST] = "/dev/efi_test access",
23 [LOCKDOWN_KEXEC] = "kexec of unsigned images", 24 [LOCKDOWN_KEXEC] = "kexec of unsigned images",
24 [LOCKDOWN_HIBERNATION] = "hibernation", 25 [LOCKDOWN_HIBERNATION] = "hibernation",
25 [LOCKDOWN_PCI_ACCESS] = "direct PCI access", 26 [LOCKDOWN_PCI_ACCESS] = "direct PCI access",
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 5c9fbf3f4340..6b724d2ee2de 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -226,7 +226,8 @@ static int snd_timer_check_master(struct snd_timer_instance *master)
226 return 0; 226 return 0;
227} 227}
228 228
229static int snd_timer_close_locked(struct snd_timer_instance *timeri); 229static int snd_timer_close_locked(struct snd_timer_instance *timeri,
230 struct device **card_devp_to_put);
230 231
231/* 232/*
232 * open a timer instance 233 * open a timer instance
@@ -238,6 +239,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
238{ 239{
239 struct snd_timer *timer; 240 struct snd_timer *timer;
240 struct snd_timer_instance *timeri = NULL; 241 struct snd_timer_instance *timeri = NULL;
242 struct device *card_dev_to_put = NULL;
241 int err; 243 int err;
242 244
243 mutex_lock(&register_mutex); 245 mutex_lock(&register_mutex);
@@ -261,7 +263,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
261 list_add_tail(&timeri->open_list, &snd_timer_slave_list); 263 list_add_tail(&timeri->open_list, &snd_timer_slave_list);
262 err = snd_timer_check_slave(timeri); 264 err = snd_timer_check_slave(timeri);
263 if (err < 0) { 265 if (err < 0) {
264 snd_timer_close_locked(timeri); 266 snd_timer_close_locked(timeri, &card_dev_to_put);
265 timeri = NULL; 267 timeri = NULL;
266 } 268 }
267 goto unlock; 269 goto unlock;
@@ -313,7 +315,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
313 timeri = NULL; 315 timeri = NULL;
314 316
315 if (timer->card) 317 if (timer->card)
316 put_device(&timer->card->card_dev); 318 card_dev_to_put = &timer->card->card_dev;
317 module_put(timer->module); 319 module_put(timer->module);
318 goto unlock; 320 goto unlock;
319 } 321 }
@@ -323,12 +325,15 @@ int snd_timer_open(struct snd_timer_instance **ti,
323 timer->num_instances++; 325 timer->num_instances++;
324 err = snd_timer_check_master(timeri); 326 err = snd_timer_check_master(timeri);
325 if (err < 0) { 327 if (err < 0) {
326 snd_timer_close_locked(timeri); 328 snd_timer_close_locked(timeri, &card_dev_to_put);
327 timeri = NULL; 329 timeri = NULL;
328 } 330 }
329 331
330 unlock: 332 unlock:
331 mutex_unlock(&register_mutex); 333 mutex_unlock(&register_mutex);
334 /* put_device() is called after unlock for avoiding deadlock */
335 if (card_dev_to_put)
336 put_device(card_dev_to_put);
332 *ti = timeri; 337 *ti = timeri;
333 return err; 338 return err;
334} 339}
@@ -338,7 +343,8 @@ EXPORT_SYMBOL(snd_timer_open);
338 * close a timer instance 343 * close a timer instance
339 * call this with register_mutex down. 344 * call this with register_mutex down.
340 */ 345 */
341static int snd_timer_close_locked(struct snd_timer_instance *timeri) 346static int snd_timer_close_locked(struct snd_timer_instance *timeri,
347 struct device **card_devp_to_put)
342{ 348{
343 struct snd_timer *timer = timeri->timer; 349 struct snd_timer *timer = timeri->timer;
344 struct snd_timer_instance *slave, *tmp; 350 struct snd_timer_instance *slave, *tmp;
@@ -395,7 +401,7 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri)
395 timer->hw.close(timer); 401 timer->hw.close(timer);
396 /* release a card refcount for safe disconnection */ 402 /* release a card refcount for safe disconnection */
397 if (timer->card) 403 if (timer->card)
398 put_device(&timer->card->card_dev); 404 *card_devp_to_put = &timer->card->card_dev;
399 module_put(timer->module); 405 module_put(timer->module);
400 } 406 }
401 407
@@ -407,14 +413,18 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri)
407 */ 413 */
408int snd_timer_close(struct snd_timer_instance *timeri) 414int snd_timer_close(struct snd_timer_instance *timeri)
409{ 415{
416 struct device *card_dev_to_put = NULL;
410 int err; 417 int err;
411 418
412 if (snd_BUG_ON(!timeri)) 419 if (snd_BUG_ON(!timeri))
413 return -ENXIO; 420 return -ENXIO;
414 421
415 mutex_lock(&register_mutex); 422 mutex_lock(&register_mutex);
416 err = snd_timer_close_locked(timeri); 423 err = snd_timer_close_locked(timeri, &card_dev_to_put);
417 mutex_unlock(&register_mutex); 424 mutex_unlock(&register_mutex);
425 /* put_device() is called after unlock for avoiding deadlock */
426 if (card_dev_to_put)
427 put_device(card_dev_to_put);
418 return err; 428 return err;
419} 429}
420EXPORT_SYMBOL(snd_timer_close); 430EXPORT_SYMBOL(snd_timer_close);
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index 73fee991bd75..6c1497d9f52b 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -252,8 +252,7 @@ end:
252 return err; 252 return err;
253} 253}
254 254
255static unsigned int 255static int map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
256map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
257{ 256{
258 unsigned int sec, sections, ch, channels; 257 unsigned int sec, sections, ch, channels;
259 unsigned int pcm, midi, location; 258 unsigned int pcm, midi, location;
diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c
index d3999e7b0705..7e7be8e4dcf9 100644
--- a/sound/hda/hdac_controller.c
+++ b/sound/hda/hdac_controller.c
@@ -447,8 +447,6 @@ static void azx_int_disable(struct hdac_bus *bus)
447 list_for_each_entry(azx_dev, &bus->stream_list, list) 447 list_for_each_entry(azx_dev, &bus->stream_list, list)
448 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0); 448 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0);
449 449
450 synchronize_irq(bus->irq);
451
452 /* disable SIE for all streams */ 450 /* disable SIE for all streams */
453 snd_hdac_chip_writeb(bus, INTCTL, 0); 451 snd_hdac_chip_writeb(bus, INTCTL, 0);
454 452
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index a815bc811799..cf53fbd872ee 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1348,9 +1348,9 @@ static int azx_free(struct azx *chip)
1348 } 1348 }
1349 1349
1350 if (bus->chip_init) { 1350 if (bus->chip_init) {
1351 azx_stop_chip(chip);
1352 azx_clear_irq_pending(chip); 1351 azx_clear_irq_pending(chip);
1353 azx_stop_all_streams(chip); 1352 azx_stop_all_streams(chip);
1353 azx_stop_chip(chip);
1354 } 1354 }
1355 1355
1356 if (bus->irq >= 0) 1356 if (bus->irq >= 0)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 795cbda32cbb..b72553710ffb 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -145,6 +145,7 @@ struct hdmi_spec {
145 struct snd_array pins; /* struct hdmi_spec_per_pin */ 145 struct snd_array pins; /* struct hdmi_spec_per_pin */
146 struct hdmi_pcm pcm_rec[16]; 146 struct hdmi_pcm pcm_rec[16];
147 struct mutex pcm_lock; 147 struct mutex pcm_lock;
148 struct mutex bind_lock; /* for audio component binding */
148 /* pcm_bitmap means which pcms have been assigned to pins*/ 149 /* pcm_bitmap means which pcms have been assigned to pins*/
149 unsigned long pcm_bitmap; 150 unsigned long pcm_bitmap;
150 int pcm_used; /* counter of pcm_rec[] */ 151 int pcm_used; /* counter of pcm_rec[] */
@@ -2258,7 +2259,7 @@ static int generic_hdmi_init(struct hda_codec *codec)
2258 struct hdmi_spec *spec = codec->spec; 2259 struct hdmi_spec *spec = codec->spec;
2259 int pin_idx; 2260 int pin_idx;
2260 2261
2261 mutex_lock(&spec->pcm_lock); 2262 mutex_lock(&spec->bind_lock);
2262 spec->use_jack_detect = !codec->jackpoll_interval; 2263 spec->use_jack_detect = !codec->jackpoll_interval;
2263 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2264 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2264 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 2265 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
@@ -2275,7 +2276,7 @@ static int generic_hdmi_init(struct hda_codec *codec)
2275 snd_hda_jack_detect_enable_callback(codec, pin_nid, 2276 snd_hda_jack_detect_enable_callback(codec, pin_nid,
2276 jack_callback); 2277 jack_callback);
2277 } 2278 }
2278 mutex_unlock(&spec->pcm_lock); 2279 mutex_unlock(&spec->bind_lock);
2279 return 0; 2280 return 0;
2280} 2281}
2281 2282
@@ -2382,6 +2383,7 @@ static int alloc_generic_hdmi(struct hda_codec *codec)
2382 spec->ops = generic_standard_hdmi_ops; 2383 spec->ops = generic_standard_hdmi_ops;
2383 spec->dev_num = 1; /* initialize to 1 */ 2384 spec->dev_num = 1; /* initialize to 1 */
2384 mutex_init(&spec->pcm_lock); 2385 mutex_init(&spec->pcm_lock);
2386 mutex_init(&spec->bind_lock);
2385 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); 2387 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap);
2386 2388
2387 spec->chmap.ops.get_chmap = hdmi_get_chmap; 2389 spec->chmap.ops.get_chmap = hdmi_get_chmap;
@@ -2451,7 +2453,7 @@ static void generic_acomp_notifier_set(struct drm_audio_component *acomp,
2451 int i; 2453 int i;
2452 2454
2453 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); 2455 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops);
2454 mutex_lock(&spec->pcm_lock); 2456 mutex_lock(&spec->bind_lock);
2455 spec->use_acomp_notifier = use_acomp; 2457 spec->use_acomp_notifier = use_acomp;
2456 spec->codec->relaxed_resume = use_acomp; 2458 spec->codec->relaxed_resume = use_acomp;
2457 /* reprogram each jack detection logic depending on the notifier */ 2459 /* reprogram each jack detection logic depending on the notifier */
@@ -2461,7 +2463,7 @@ static void generic_acomp_notifier_set(struct drm_audio_component *acomp,
2461 get_pin(spec, i)->pin_nid, 2463 get_pin(spec, i)->pin_nid,
2462 use_acomp); 2464 use_acomp);
2463 } 2465 }
2464 mutex_unlock(&spec->pcm_lock); 2466 mutex_unlock(&spec->bind_lock);
2465} 2467}
2466 2468
2467/* enable / disable the notifier via master bind / unbind */ 2469/* enable / disable the notifier via master bind / unbind */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 085a2f95e076..80f66ba85f87 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -409,6 +409,9 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
409 case 0x10ec0672: 409 case 0x10ec0672:
410 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */ 410 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
411 break; 411 break;
412 case 0x10ec0623:
413 alc_update_coef_idx(codec, 0x19, 1<<13, 0);
414 break;
412 case 0x10ec0668: 415 case 0x10ec0668:
413 alc_update_coef_idx(codec, 0x7, 3<<13, 0); 416 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
414 break; 417 break;
@@ -2920,6 +2923,7 @@ enum {
2920 ALC269_TYPE_ALC225, 2923 ALC269_TYPE_ALC225,
2921 ALC269_TYPE_ALC294, 2924 ALC269_TYPE_ALC294,
2922 ALC269_TYPE_ALC300, 2925 ALC269_TYPE_ALC300,
2926 ALC269_TYPE_ALC623,
2923 ALC269_TYPE_ALC700, 2927 ALC269_TYPE_ALC700,
2924}; 2928};
2925 2929
@@ -2955,6 +2959,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
2955 case ALC269_TYPE_ALC225: 2959 case ALC269_TYPE_ALC225:
2956 case ALC269_TYPE_ALC294: 2960 case ALC269_TYPE_ALC294:
2957 case ALC269_TYPE_ALC300: 2961 case ALC269_TYPE_ALC300:
2962 case ALC269_TYPE_ALC623:
2958 case ALC269_TYPE_ALC700: 2963 case ALC269_TYPE_ALC700:
2959 ssids = alc269_ssids; 2964 ssids = alc269_ssids;
2960 break; 2965 break;
@@ -7216,6 +7221,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7216 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 7221 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7217 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 7222 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7218 SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 7223 SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7224 SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7225 SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
7219 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 7226 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
7220 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), 7227 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
7221 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 7228 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
@@ -8017,6 +8024,9 @@ static int patch_alc269(struct hda_codec *codec)
8017 spec->codec_variant = ALC269_TYPE_ALC300; 8024 spec->codec_variant = ALC269_TYPE_ALC300;
8018 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */ 8025 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
8019 break; 8026 break;
8027 case 0x10ec0623:
8028 spec->codec_variant = ALC269_TYPE_ALC623;
8029 break;
8020 case 0x10ec0700: 8030 case 0x10ec0700:
8021 case 0x10ec0701: 8031 case 0x10ec0701:
8022 case 0x10ec0703: 8032 case 0x10ec0703:
@@ -9218,6 +9228,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
9218 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269), 9228 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
9219 HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269), 9229 HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
9220 HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269), 9230 HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
9231 HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
9221 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861), 9232 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
9222 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd), 9233 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
9223 HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861), 9234 HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index fbfde996fee7..0bbe1201a6ac 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1657,6 +1657,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1657 case 0x23ba: /* Playback Designs */ 1657 case 0x23ba: /* Playback Designs */
1658 case 0x25ce: /* Mytek devices */ 1658 case 0x25ce: /* Mytek devices */
1659 case 0x278b: /* Rotel? */ 1659 case 0x278b: /* Rotel? */
1660 case 0x292b: /* Gustard/Ess based devices */
1660 case 0x2ab6: /* T+A devices */ 1661 case 0x2ab6: /* T+A devices */
1661 case 0x3842: /* EVGA */ 1662 case 0x3842: /* EVGA */
1662 case 0xc502: /* HiBy devices */ 1663 case 0xc502: /* HiBy devices */
diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
index 15a666329a34..1afa22c88e42 100755
--- a/tools/testing/selftests/bpf/test_offload.py
+++ b/tools/testing/selftests/bpf/test_offload.py
@@ -22,6 +22,7 @@ import os
22import pprint 22import pprint
23import random 23import random
24import re 24import re
25import stat
25import string 26import string
26import struct 27import struct
27import subprocess 28import subprocess
@@ -311,7 +312,11 @@ class DebugfsDir:
311 for f in out.split(): 312 for f in out.split():
312 if f == "ports": 313 if f == "ports":
313 continue 314 continue
315
314 p = os.path.join(path, f) 316 p = os.path.join(path, f)
317 if not os.stat(p).st_mode & stat.S_IRUSR:
318 continue
319
315 if os.path.isfile(p): 320 if os.path.isfile(p):
316 _, out = cmd('cat %s/%s' % (path, f)) 321 _, out = cmd('cat %s/%s' % (path, f))
317 dfs[f] = out.strip() 322 dfs[f] = out.strip()
diff --git a/tools/testing/selftests/bpf/test_tc_edt.sh b/tools/testing/selftests/bpf/test_tc_edt.sh
index f38567ef694b..daa7d1b8d309 100755
--- a/tools/testing/selftests/bpf/test_tc_edt.sh
+++ b/tools/testing/selftests/bpf/test_tc_edt.sh
@@ -59,7 +59,7 @@ ip netns exec ${NS_SRC} tc filter add dev veth_src egress \
59 59
60# start the listener 60# start the listener
61ip netns exec ${NS_DST} bash -c \ 61ip netns exec ${NS_DST} bash -c \
62 "nc -4 -l -s ${IP_DST} -p 9000 >/dev/null &" 62 "nc -4 -l -p 9000 >/dev/null &"
63declare -i NC_PID=$! 63declare -i NC_PID=$!
64sleep 1 64sleep 1
65 65
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index c4ba0ff4a53f..76c1897e6352 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -1438,6 +1438,27 @@ ipv4_addr_metric_test()
1438 fi 1438 fi
1439 log_test $rc 0 "Prefix route with metric on link up" 1439 log_test $rc 0 "Prefix route with metric on link up"
1440 1440
1441 # explicitly check for metric changes on edge scenarios
1442 run_cmd "$IP addr flush dev dummy2"
1443 run_cmd "$IP addr add dev dummy2 172.16.104.0/24 metric 259"
1444 run_cmd "$IP addr change dev dummy2 172.16.104.0/24 metric 260"
1445 rc=$?
1446 if [ $rc -eq 0 ]; then
1447 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.0 metric 260"
1448 rc=$?
1449 fi
1450 log_test $rc 0 "Modify metric of .0/24 address"
1451
1452 run_cmd "$IP addr flush dev dummy2"
1453 run_cmd "$IP addr add dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 260"
1454 run_cmd "$IP addr change dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 261"
1455 rc=$?
1456 if [ $rc -eq 0 ]; then
1457 check_route "172.16.104.2 dev dummy2 proto kernel scope link src 172.16.104.1 metric 261"
1458 rc=$?
1459 fi
1460 log_test $rc 0 "Modify metric of address with peer route"
1461
1441 $IP li del dummy1 1462 $IP li del dummy1
1442 $IP li del dummy2 1463 $IP li del dummy2
1443 cleanup 1464 cleanup
diff --git a/tools/testing/selftests/net/l2tp.sh b/tools/testing/selftests/net/l2tp.sh
index 5782433886fc..5782433886fc 100644..100755
--- a/tools/testing/selftests/net/l2tp.sh
+++ b/tools/testing/selftests/net/l2tp.sh
diff --git a/tools/testing/selftests/net/reuseport_dualstack.c b/tools/testing/selftests/net/reuseport_dualstack.c
index fe3230c55986..fb7a59ed759e 100644
--- a/tools/testing/selftests/net/reuseport_dualstack.c
+++ b/tools/testing/selftests/net/reuseport_dualstack.c
@@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count, int proto)
129{ 129{
130 struct epoll_event ev; 130 struct epoll_event ev;
131 int epfd, i, test_fd; 131 int epfd, i, test_fd;
132 uint16_t test_family; 132 int test_family;
133 socklen_t len; 133 socklen_t len;
134 134
135 epfd = epoll_create(1); 135 epfd = epoll_create(1);
@@ -146,6 +146,7 @@ static void test(int *rcv_fds, int count, int proto)
146 send_from_v4(proto); 146 send_from_v4(proto);
147 147
148 test_fd = receive_once(epfd, proto); 148 test_fd = receive_once(epfd, proto);
149 len = sizeof(test_family);
149 if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len)) 150 if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len))
150 error(1, errno, "failed to read socket domain"); 151 error(1, errno, "failed to read socket domain");
151 if (test_family != AF_INET) 152 if (test_family != AF_INET)
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
index 051d7d3f443b..927a151fa9aa 100644
--- a/tools/usb/usbip/libsrc/usbip_device_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
@@ -69,7 +69,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
69 FILE *fd = NULL; 69 FILE *fd = NULL;
70 struct udev_device *plat; 70 struct udev_device *plat;
71 const char *speed; 71 const char *speed;
72 int ret = 0; 72 size_t ret;
73 73
74 plat = udev_device_get_parent(sdev); 74 plat = udev_device_get_parent(sdev);
75 path = udev_device_get_syspath(plat); 75 path = udev_device_get_syspath(plat);
@@ -79,8 +79,10 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
79 if (!fd) 79 if (!fd)
80 return -1; 80 return -1;
81 ret = fread((char *) &descr, sizeof(descr), 1, fd); 81 ret = fread((char *) &descr, sizeof(descr), 1, fd);
82 if (ret < 0) 82 if (ret != 1) {
83 err("Cannot read vudc device descr file: %s", strerror(errno));
83 goto err; 84 goto err;
85 }
84 fclose(fd); 86 fclose(fd);
85 87
86 copy_descr_attr(dev, &descr, bDeviceClass); 88 copy_descr_attr(dev, &descr, bDeviceClass);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 67ef3f2e19e8..d6f0696d98ef 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -627,8 +627,9 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
627 627
628static struct kvm *kvm_create_vm(unsigned long type) 628static struct kvm *kvm_create_vm(unsigned long type)
629{ 629{
630 int r, i;
631 struct kvm *kvm = kvm_arch_alloc_vm(); 630 struct kvm *kvm = kvm_arch_alloc_vm();
631 int r = -ENOMEM;
632 int i;
632 633
633 if (!kvm) 634 if (!kvm)
634 return ERR_PTR(-ENOMEM); 635 return ERR_PTR(-ENOMEM);
@@ -640,44 +641,45 @@ static struct kvm *kvm_create_vm(unsigned long type)
640 mutex_init(&kvm->lock); 641 mutex_init(&kvm->lock);
641 mutex_init(&kvm->irq_lock); 642 mutex_init(&kvm->irq_lock);
642 mutex_init(&kvm->slots_lock); 643 mutex_init(&kvm->slots_lock);
643 refcount_set(&kvm->users_count, 1);
644 INIT_LIST_HEAD(&kvm->devices); 644 INIT_LIST_HEAD(&kvm->devices);
645 645
646 r = kvm_arch_init_vm(kvm, type);
647 if (r)
648 goto out_err_no_disable;
649
650 r = hardware_enable_all();
651 if (r)
652 goto out_err_no_disable;
653
654#ifdef CONFIG_HAVE_KVM_IRQFD
655 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
656#endif
657
658 BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); 646 BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
659 647
660 r = -ENOMEM;
661 for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) { 648 for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
662 struct kvm_memslots *slots = kvm_alloc_memslots(); 649 struct kvm_memslots *slots = kvm_alloc_memslots();
650
663 if (!slots) 651 if (!slots)
664 goto out_err_no_srcu; 652 goto out_err_no_arch_destroy_vm;
665 /* Generations must be different for each address space. */ 653 /* Generations must be different for each address space. */
666 slots->generation = i; 654 slots->generation = i;
667 rcu_assign_pointer(kvm->memslots[i], slots); 655 rcu_assign_pointer(kvm->memslots[i], slots);
668 } 656 }
669 657
670 if (init_srcu_struct(&kvm->srcu))
671 goto out_err_no_srcu;
672 if (init_srcu_struct(&kvm->irq_srcu))
673 goto out_err_no_irq_srcu;
674 for (i = 0; i < KVM_NR_BUSES; i++) { 658 for (i = 0; i < KVM_NR_BUSES; i++) {
675 rcu_assign_pointer(kvm->buses[i], 659 rcu_assign_pointer(kvm->buses[i],
676 kzalloc(sizeof(struct kvm_io_bus), GFP_KERNEL_ACCOUNT)); 660 kzalloc(sizeof(struct kvm_io_bus), GFP_KERNEL_ACCOUNT));
677 if (!kvm->buses[i]) 661 if (!kvm->buses[i])
678 goto out_err; 662 goto out_err_no_arch_destroy_vm;
679 } 663 }
680 664
665 refcount_set(&kvm->users_count, 1);
666 r = kvm_arch_init_vm(kvm, type);
667 if (r)
668 goto out_err_no_arch_destroy_vm;
669
670 r = hardware_enable_all();
671 if (r)
672 goto out_err_no_disable;
673
674#ifdef CONFIG_HAVE_KVM_IRQFD
675 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
676#endif
677
678 if (init_srcu_struct(&kvm->srcu))
679 goto out_err_no_srcu;
680 if (init_srcu_struct(&kvm->irq_srcu))
681 goto out_err_no_irq_srcu;
682
681 r = kvm_init_mmu_notifier(kvm); 683 r = kvm_init_mmu_notifier(kvm);
682 if (r) 684 if (r)
683 goto out_err; 685 goto out_err;
@@ -697,7 +699,9 @@ out_err_no_irq_srcu:
697out_err_no_srcu: 699out_err_no_srcu:
698 hardware_disable_all(); 700 hardware_disable_all();
699out_err_no_disable: 701out_err_no_disable:
700 refcount_set(&kvm->users_count, 0); 702 kvm_arch_destroy_vm(kvm);
703 WARN_ON_ONCE(!refcount_dec_and_test(&kvm->users_count));
704out_err_no_arch_destroy_vm:
701 for (i = 0; i < KVM_NR_BUSES; i++) 705 for (i = 0; i < KVM_NR_BUSES; i++)
702 kfree(kvm_get_bus(kvm, i)); 706 kfree(kvm_get_bus(kvm, i));
703 for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) 707 for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++)