summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-01-27 13:43:17 -0500
committerDavid S. Miller <davem@davemloft.net>2019-01-27 13:43:17 -0500
commit1d68101367a92336e633d0c3681bf8c86644e124 (patch)
tree8fdacef561481c25c71641b8fa91a5dfa0ba7f96
parent085c4c7dd2b6558fb079fad07d6e9064f5e0b4c2 (diff)
parent1fc7f56db7a7c467e46a5d2e2a009d2f337e0338 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
-rw-r--r--Documentation/core-api/xarray.rst15
-rw-r--r--Documentation/devicetree/bindings/display/msm/gpu.txt1
-rw-r--r--MAINTAINERS45
-rw-r--r--arch/arc/include/asm/Kbuild4
-rw-r--r--arch/arc/include/asm/arcregs.h12
-rw-r--r--arch/arc/include/asm/bitops.h6
-rw-r--r--arch/arc/include/asm/perf_event.h3
-rw-r--r--arch/arc/kernel/perf_event.c241
-rw-r--r--arch/arc/kernel/setup.c27
-rw-r--r--arch/arc/kernel/troubleshoot.c30
-rw-r--r--arch/arc/lib/memset-archs.S40
-rw-r--r--arch/arc/mm/fault.c13
-rw-r--r--arch/arc/mm/init.c3
-rw-r--r--arch/arm/include/asm/xen/page-coherent.h94
-rw-r--r--arch/arm64/include/asm/device.h3
-rw-r--r--arch/arm64/include/asm/xen/page-coherent.h76
-rw-r--r--arch/arm64/mm/dma-mapping.c4
-rw-r--r--arch/s390/include/asm/mmu_context.h7
-rw-r--r--arch/s390/kernel/early.c4
-rw-r--r--arch/s390/kernel/setup.c2
-rw-r--r--arch/s390/kernel/smp.c11
-rw-r--r--arch/s390/kernel/vdso.c5
-rw-r--r--arch/x86/kernel/kvm.c7
-rw-r--r--arch/x86/kvm/Makefile4
-rw-r--r--arch/x86/kvm/hyperv.c7
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/kvm/mmu.c1
-rw-r--r--arch/x86/kvm/svm.c31
-rw-r--r--arch/x86/kvm/trace.h2
-rw-r--r--arch/x86/kvm/vmx/evmcs.c7
-rw-r--r--arch/x86/kvm/vmx/nested.c14
-rw-r--r--arch/x86/kvm/vmx/vmx.c147
-rw-r--r--arch/x86/kvm/x86.c8
-rw-r--r--block/blk-core.c11
-rw-r--r--block/blk-merge.c10
-rw-r--r--block/blk-mq-debugfs.c3
-rw-r--r--block/blk-wbt.c4
-rw-r--r--drivers/acpi/nfit/core.c66
-rw-r--r--drivers/android/binderfs.c282
-rw-r--r--drivers/ata/pata_macio.c9
-rw-r--r--drivers/ata/sata_inic162x.c22
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c173
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c25
-rw-r--r--drivers/char/mwave/mwavedd.c7
-rw-r--r--drivers/clk/Kconfig1
-rw-r--r--drivers/clk/clk-versaclock5.c4
-rw-r--r--drivers/clk/clk.c2
-rw-r--r--drivers/clk/imx/clk-imx8qxp-lpcg.c2
-rw-r--r--drivers/clk/qcom/Kconfig1
-rw-r--r--drivers/clk/socfpga/clk-pll-s10.c2
-rw-r--r--drivers/clk/socfpga/clk-s10.c20
-rw-r--r--drivers/clk/tegra/clk-tegra124-dfll-fcpu.c4
-rw-r--r--drivers/clk/zynqmp/clkc.c4
-rw-r--r--drivers/firewire/sbp2.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c1
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c22
-rw-r--r--drivers/gpu/drm/i915/gvt/scheduler.c11
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c4
-rw-r--r--drivers/gpu/drm/msm/adreno/a6xx_gmu.c2
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c1
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c26
-rw-r--r--drivers/gpu/drm/msm/msm_drv.h6
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c8
-rw-r--r--drivers/gpu/drm/msm/msm_gem_vma.c5
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.c2
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.h3
-rw-r--r--drivers/gpu/drm/msm/msm_rd.c7
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c4
-rw-r--r--drivers/hid/hid-core.c23
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/i2c-hid/i2c-hid-core.c2
-rw-r--r--drivers/hv/channel.c9
-rw-r--r--drivers/hv/hv_balloon.c10
-rw-r--r--drivers/hv/ring_buffer.c31
-rw-r--r--drivers/hv/vmbus_drv.c91
-rw-r--r--drivers/ide/ide-proc.c2
-rw-r--r--drivers/input/joystick/xpad.c3
-rw-r--r--drivers/input/misc/uinput.c5
-rw-r--r--drivers/input/serio/olpc_apsp.c3
-rw-r--r--drivers/input/touchscreen/Kconfig2
-rw-r--r--drivers/iommu/of_iommu.c2
-rw-r--r--drivers/md/dm-crypt.c25
-rw-r--r--drivers/md/dm-thin-metadata.c4
-rw-r--r--drivers/md/dm-thin-metadata.h2
-rw-r--r--drivers/md/dm-thin.c10
-rw-r--r--drivers/md/dm.c43
-rw-r--r--drivers/misc/ibmvmc.c7
-rw-r--r--drivers/misc/mei/hbm.c12
-rw-r--r--drivers/misc/mei/hw-me-regs.h2
-rw-r--r--drivers/misc/mei/pci-me.c4
-rw-r--r--drivers/misc/pvpanic.c4
-rw-r--r--drivers/mmc/host/Kconfig4
-rw-r--r--drivers/mmc/host/dw_mmc-bluefield.c5
-rw-r--r--drivers/mmc/host/meson-gx-mmc.c32
-rw-r--r--drivers/mmc/host/sdhci-iproc.c5
-rw-r--r--drivers/net/can/dev.c27
-rw-r--r--drivers/net/can/flexcan.c4
-rw-r--r--drivers/net/ethernet/altera/altera_tse_main.c4
-rw-r--r--drivers/net/ethernet/freescale/dpaa2/Kconfig5
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c2
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cq.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c75
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c12
-rw-r--r--drivers/net/ethernet/sfc/ef10.c29
-rw-r--r--drivers/net/ethernet/sun/cassini.c15
-rw-r--r--drivers/net/ethernet/sun/cassini.h15
-rw-r--r--drivers/net/hyperv/hyperv_net.h12
-rw-r--r--drivers/net/hyperv/netvsc.c4
-rw-r--r--drivers/net/hyperv/netvsc_drv.c145
-rw-r--r--drivers/net/hyperv/rndis_filter.c36
-rw-r--r--drivers/net/phy/asix.c8
-rw-r--r--drivers/net/phy/mdio-hisi-femac.c16
-rw-r--r--drivers/net/phy/rockchip.c9
-rw-r--r--drivers/net/usb/asix_devices.c9
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c5
-rw-r--r--drivers/net/wireless/virt_wifi.c4
-rw-r--r--drivers/nvdimm/dimm.c6
-rw-r--r--drivers/nvdimm/dimm_devs.c22
-rw-r--r--drivers/nvdimm/nd.h1
-rw-r--r--drivers/nvme/host/multipath.c3
-rw-r--r--drivers/nvme/host/rdma.c64
-rw-r--r--drivers/nvme/host/tcp.c19
-rw-r--r--drivers/nvme/target/rdma.c15
-rw-r--r--drivers/phy/qualcomm/phy-ath79-usb.c4
-rw-r--r--drivers/phy/ti/phy-gmii-sel.c4
-rw-r--r--drivers/s390/char/sclp_config.c2
-rw-r--r--drivers/scsi/aacraid/linit.c9
-rw-r--r--drivers/scsi/csiostor/csio_attr.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_nvme.c16
-rw-r--r--drivers/scsi/lpfc/lpfc_nvme.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_nvmet.c8
-rw-r--r--drivers/scsi/lpfc/lpfc_nvmet.h2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/ufs/ufshcd.c10
-rw-r--r--drivers/staging/android/ion/ion.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c1
-rw-r--r--drivers/staging/rtl8723bs/include/ieee80211.h6
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c1
-rw-r--r--drivers/staging/wilc1000/host_interface.c5
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.c7
-rw-r--r--drivers/target/target_core_user.c3
-rw-r--r--drivers/thermal/intel/int340x_thermal/processor_thermal_device.c30
-rw-r--r--drivers/tty/n_hdlc.c1
-rw-r--r--drivers/tty/serial/8250/8250_core.c17
-rw-r--r--drivers/tty/serial/fsl_lpuart.c2
-rw-r--r--drivers/tty/serial/qcom_geni_serial.c4
-rw-r--r--drivers/tty/serial/serial_core.c12
-rw-r--r--drivers/tty/tty_io.c3
-rw-r--r--drivers/tty/vt/vt.c50
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c3
-rw-r--r--drivers/usb/core/ledtrig-usbport.c17
-rw-r--r--drivers/usb/dwc2/gadget.c2
-rw-r--r--drivers/usb/dwc3/gadget.c4
-rw-r--r--drivers/usb/gadget/function/f_sourcesink.c2
-rw-r--r--drivers/usb/host/ehci-mv.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c15
-rw-r--r--drivers/usb/serial/keyspan_usa26msg.h1
-rw-r--r--drivers/usb/serial/keyspan_usa28msg.h1
-rw-r--r--drivers/usb/serial/keyspan_usa49msg.h1
-rw-r--r--drivers/usb/serial/keyspan_usa67msg.h1
-rw-r--r--drivers/usb/serial/keyspan_usa90msg.h1
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h2
-rw-r--r--drivers/usb/serial/usb-serial-simple.c3
-rw-r--r--drivers/usb/usbip/README7
-rw-r--r--drivers/vfio/pci/trace.h6
-rw-r--r--drivers/vfio/pci/vfio_pci_nvlink2.c36
-rw-r--r--drivers/video/console/vgacon.c7
-rw-r--r--drivers/xen/swiotlb-xen.c4
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/quota.c13
-rw-r--r--fs/cifs/cifs_debug.c1
-rw-r--r--fs/cifs/cifssmb.c35
-rw-r--r--fs/cifs/connect.c21
-rw-r--r--fs/cifs/smb2inode.c17
-rw-r--r--fs/cifs/smb2misc.c7
-rw-r--r--fs/cifs/smb2ops.c68
-rw-r--r--fs/cifs/smb2pdu.c23
-rw-r--r--fs/cifs/trace.c10
-rw-r--r--fs/cifs/trace.h10
-rw-r--r--fs/cifs/transport.c11
-rw-r--r--fs/direct-io.c5
-rw-r--r--fs/fs-writeback.c40
-rw-r--r--fs/notify/inotify/inotify_user.c6
-rw-r--r--include/linux/backing-dev-defs.h1
-rw-r--r--include/linux/blk_types.h2
-rw-r--r--include/linux/hid.h3
-rw-r--r--include/linux/hyperv.h5
-rw-r--r--include/linux/if_arp.h1
-rw-r--r--include/linux/libnvdimm.h1
-rw-r--r--include/linux/xarray.h227
-rw-r--r--include/net/ax25.h12
-rw-r--r--include/sound/soc.h6
-rw-r--r--include/uapi/linux/android/binderfs.h (renamed from include/uapi/linux/android/binder_ctl.h)10
-rw-r--r--include/uapi/linux/blkzoned.h1
-rw-r--r--include/uapi/linux/input.h6
-rw-r--r--include/xen/arm/page-coherent.h97
-rw-r--r--lib/test_xarray.c57
-rw-r--r--lib/xarray.c92
-rw-r--r--mm/backing-dev.c1
-rw-r--r--mm/mincore.c94
-rw-r--r--net/ax25/ax25_ip.c4
-rw-r--r--net/ax25/ax25_route.c19
-rw-r--r--net/can/bcm.c27
-rw-r--r--net/ceph/messenger.c5
-rw-r--r--net/ipv4/gre_demux.c17
-rw-r--r--net/ipv4/ip_gre.c9
-rw-r--r--net/ipv4/ip_tunnel.c8
-rw-r--r--net/ipv6/addrconf.c6
-rw-r--r--net/ipv6/ip6_gre.c4
-rw-r--r--net/mac80211/cfg.c4
-rw-r--r--net/mac80211/rx.c6
-rw-r--r--net/sctp/ipv6.c3
-rw-r--r--net/sctp/protocol.c3
-rw-r--r--net/sctp/sm_make_chunk.c11
-rw-r--r--net/sctp/stream.c58
-rw-r--r--net/wireless/nl80211.c2
-rw-r--r--net/wireless/reg.c13
-rw-r--r--sound/core/compress_offload.c3
-rw-r--r--sound/pci/hda/patch_conexant.c1
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/soc/amd/raven/acp3x-pcm-dma.c6
-rw-r--r--sound/soc/codecs/hdac_hdmi.c116
-rw-r--r--sound/soc/codecs/pcm512x.c11
-rw-r--r--sound/soc/codecs/rt274.c5
-rw-r--r--sound/soc/codecs/rt5514-spi.c2
-rw-r--r--sound/soc/codecs/rt5682.c1
-rw-r--r--sound/soc/codecs/rt5682.h24
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c4
-rw-r--r--sound/soc/fsl/imx-audmux.c24
-rw-r--r--sound/soc/intel/Kconfig2
-rw-r--r--sound/soc/intel/atom/sst-mfld-platform-pcm.c8
-rw-r--r--sound/soc/intel/boards/broadwell.c2
-rw-r--r--sound/soc/intel/boards/glk_rt5682_max98357a.c45
-rw-r--r--sound/soc/intel/boards/haswell.c2
-rw-r--r--sound/soc/intel/skylake/skl.c13
-rw-r--r--sound/soc/qcom/qdsp6/q6asm-dai.c17
-rw-r--r--sound/soc/qcom/sdm845.c31
-rw-r--r--sound/soc/sh/dma-sh7760.c2
-rw-r--r--sound/soc/soc-core.c34
-rw-r--r--sound/soc/soc-dapm.c10
-rw-r--r--sound/soc/ti/davinci-mcasp.c136
-rw-r--r--sound/soc/xilinx/Kconfig2
-rw-r--r--sound/soc/xilinx/xlnx_i2s.c15
-rw-r--r--tools/testing/nvdimm/dimm_devs.c4
-rw-r--r--tools/testing/selftests/gpio/gpio-mockup-chardev.c9
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c9
-rw-r--r--tools/testing/selftests/kvm/x86_64/evmcs_test.c6
-rw-r--r--tools/testing/selftests/rtc/rtctest.c109
-rw-r--r--tools/testing/selftests/seccomp/Makefile2
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c10
-rw-r--r--tools/testing/selftests/vm/gup_benchmark.c1
-rw-r--r--tools/testing/selftests/x86/mpx-mini-test.c2
-rw-r--r--tools/testing/selftests/x86/unwind_vdso.c1
255 files changed, 2845 insertions, 1786 deletions
diff --git a/Documentation/core-api/xarray.rst b/Documentation/core-api/xarray.rst
index 6a6d67acaf69..5d54b27c6eba 100644
--- a/Documentation/core-api/xarray.rst
+++ b/Documentation/core-api/xarray.rst
@@ -108,12 +108,13 @@ some, but not all of the other indices changing.
108 108
109Sometimes you need to ensure that a subsequent call to :c:func:`xa_store` 109Sometimes you need to ensure that a subsequent call to :c:func:`xa_store`
110will not need to allocate memory. The :c:func:`xa_reserve` function 110will not need to allocate memory. The :c:func:`xa_reserve` function
111will store a reserved entry at the indicated index. Users of the normal 111will store a reserved entry at the indicated index. Users of the
112API will see this entry as containing ``NULL``. If you do not need to 112normal API will see this entry as containing ``NULL``. If you do
113use the reserved entry, you can call :c:func:`xa_release` to remove the 113not need to use the reserved entry, you can call :c:func:`xa_release`
114unused entry. If another user has stored to the entry in the meantime, 114to remove the unused entry. If another user has stored to the entry
115:c:func:`xa_release` will do nothing; if instead you want the entry to 115in the meantime, :c:func:`xa_release` will do nothing; if instead you
116become ``NULL``, you should use :c:func:`xa_erase`. 116want the entry to become ``NULL``, you should use :c:func:`xa_erase`.
117Using :c:func:`xa_insert` on a reserved entry will fail.
117 118
118If all entries in the array are ``NULL``, the :c:func:`xa_empty` function 119If all entries in the array are ``NULL``, the :c:func:`xa_empty` function
119will return ``true``. 120will return ``true``.
@@ -183,6 +184,8 @@ Takes xa_lock internally:
183 * :c:func:`xa_store_bh` 184 * :c:func:`xa_store_bh`
184 * :c:func:`xa_store_irq` 185 * :c:func:`xa_store_irq`
185 * :c:func:`xa_insert` 186 * :c:func:`xa_insert`
187 * :c:func:`xa_insert_bh`
188 * :c:func:`xa_insert_irq`
186 * :c:func:`xa_erase` 189 * :c:func:`xa_erase`
187 * :c:func:`xa_erase_bh` 190 * :c:func:`xa_erase_bh`
188 * :c:func:`xa_erase_irq` 191 * :c:func:`xa_erase_irq`
diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt b/Documentation/devicetree/bindings/display/msm/gpu.txt
index ac8df3b871f9..f8759145ce1a 100644
--- a/Documentation/devicetree/bindings/display/msm/gpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
@@ -27,7 +27,6 @@ Example:
27 reg = <0x04300000 0x20000>; 27 reg = <0x04300000 0x20000>;
28 reg-names = "kgsl_3d0_reg_memory"; 28 reg-names = "kgsl_3d0_reg_memory";
29 interrupts = <GIC_SPI 80 0>; 29 interrupts = <GIC_SPI 80 0>;
30 interrupt-names = "kgsl_3d0_irq";
31 clock-names = 30 clock-names =
32 "core", 31 "core",
33 "iface", 32 "iface",
diff --git a/MAINTAINERS b/MAINTAINERS
index a0245fd1b09a..ecbc22ec2699 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3052,8 +3052,8 @@ F: include/linux/bcm963xx_nvram.h
3052F: include/linux/bcm963xx_tag.h 3052F: include/linux/bcm963xx_tag.h
3053 3053
3054BROADCOM BNX2 GIGABIT ETHERNET DRIVER 3054BROADCOM BNX2 GIGABIT ETHERNET DRIVER
3055M: Rasesh Mody <rasesh.mody@cavium.com> 3055M: Rasesh Mody <rmody@marvell.com>
3056M: Dept-GELinuxNICDev@cavium.com 3056M: GR-Linux-NIC-Dev@marvell.com
3057L: netdev@vger.kernel.org 3057L: netdev@vger.kernel.org
3058S: Supported 3058S: Supported
3059F: drivers/net/ethernet/broadcom/bnx2.* 3059F: drivers/net/ethernet/broadcom/bnx2.*
@@ -3072,9 +3072,9 @@ S: Supported
3072F: drivers/scsi/bnx2i/ 3072F: drivers/scsi/bnx2i/
3073 3073
3074BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER 3074BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER
3075M: Ariel Elior <ariel.elior@cavium.com> 3075M: Ariel Elior <aelior@marvell.com>
3076M: Sudarsana Kalluru <sudarsana.kalluru@cavium.com> 3076M: Sudarsana Kalluru <skalluru@marvell.com>
3077M: everest-linux-l2@cavium.com 3077M: GR-everest-linux-l2@marvell.com
3078L: netdev@vger.kernel.org 3078L: netdev@vger.kernel.org
3079S: Supported 3079S: Supported
3080F: drivers/net/ethernet/broadcom/bnx2x/ 3080F: drivers/net/ethernet/broadcom/bnx2x/
@@ -3249,9 +3249,9 @@ S: Supported
3249F: drivers/scsi/bfa/ 3249F: drivers/scsi/bfa/
3250 3250
3251BROCADE BNA 10 GIGABIT ETHERNET DRIVER 3251BROCADE BNA 10 GIGABIT ETHERNET DRIVER
3252M: Rasesh Mody <rasesh.mody@cavium.com> 3252M: Rasesh Mody <rmody@marvell.com>
3253M: Sudarsana Kalluru <sudarsana.kalluru@cavium.com> 3253M: Sudarsana Kalluru <skalluru@marvell.com>
3254M: Dept-GELinuxNICDev@cavium.com 3254M: GR-Linux-NIC-Dev@marvell.com
3255L: netdev@vger.kernel.org 3255L: netdev@vger.kernel.org
3256S: Supported 3256S: Supported
3257F: drivers/net/ethernet/brocade/bna/ 3257F: drivers/net/ethernet/brocade/bna/
@@ -3978,6 +3978,7 @@ F: drivers/cpufreq/arm_big_little.c
3978CPU POWER MONITORING SUBSYSTEM 3978CPU POWER MONITORING SUBSYSTEM
3979M: Thomas Renninger <trenn@suse.com> 3979M: Thomas Renninger <trenn@suse.com>
3980M: Shuah Khan <shuah@kernel.org> 3980M: Shuah Khan <shuah@kernel.org>
3981M: Shuah Khan <skhan@linuxfoundation.org>
3981L: linux-pm@vger.kernel.org 3982L: linux-pm@vger.kernel.org
3982S: Maintained 3983S: Maintained
3983F: tools/power/cpupower/ 3984F: tools/power/cpupower/
@@ -8265,6 +8266,7 @@ F: include/uapi/linux/sunrpc/
8265 8266
8266KERNEL SELFTEST FRAMEWORK 8267KERNEL SELFTEST FRAMEWORK
8267M: Shuah Khan <shuah@kernel.org> 8268M: Shuah Khan <shuah@kernel.org>
8269M: Shuah Khan <skhan@linuxfoundation.org>
8268L: linux-kselftest@vger.kernel.org 8270L: linux-kselftest@vger.kernel.org
8269T: git git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git 8271T: git git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
8270Q: https://patchwork.kernel.org/project/linux-kselftest/list/ 8272Q: https://patchwork.kernel.org/project/linux-kselftest/list/
@@ -10696,9 +10698,9 @@ S: Maintained
10696F: drivers/net/netdevsim/* 10698F: drivers/net/netdevsim/*
10697 10699
10698NETXEN (1/10) GbE SUPPORT 10700NETXEN (1/10) GbE SUPPORT
10699M: Manish Chopra <manish.chopra@cavium.com> 10701M: Manish Chopra <manishc@marvell.com>
10700M: Rahul Verma <rahul.verma@cavium.com> 10702M: Rahul Verma <rahulv@marvell.com>
10701M: Dept-GELinuxNICDev@cavium.com 10703M: GR-Linux-NIC-Dev@marvell.com
10702L: netdev@vger.kernel.org 10704L: netdev@vger.kernel.org
10703S: Supported 10705S: Supported
10704F: drivers/net/ethernet/qlogic/netxen/ 10706F: drivers/net/ethernet/qlogic/netxen/
@@ -12482,8 +12484,8 @@ S: Supported
12482F: drivers/scsi/qedi/ 12484F: drivers/scsi/qedi/
12483 12485
12484QLOGIC QL4xxx ETHERNET DRIVER 12486QLOGIC QL4xxx ETHERNET DRIVER
12485M: Ariel Elior <Ariel.Elior@cavium.com> 12487M: Ariel Elior <aelior@marvell.com>
12486M: everest-linux-l2@cavium.com 12488M: GR-everest-linux-l2@marvell.com
12487L: netdev@vger.kernel.org 12489L: netdev@vger.kernel.org
12488S: Supported 12490S: Supported
12489F: drivers/net/ethernet/qlogic/qed/ 12491F: drivers/net/ethernet/qlogic/qed/
@@ -12491,8 +12493,8 @@ F: include/linux/qed/
12491F: drivers/net/ethernet/qlogic/qede/ 12493F: drivers/net/ethernet/qlogic/qede/
12492 12494
12493QLOGIC QL4xxx RDMA DRIVER 12495QLOGIC QL4xxx RDMA DRIVER
12494M: Michal Kalderon <Michal.Kalderon@cavium.com> 12496M: Michal Kalderon <mkalderon@marvell.com>
12495M: Ariel Elior <Ariel.Elior@cavium.com> 12497M: Ariel Elior <aelior@marvell.com>
12496L: linux-rdma@vger.kernel.org 12498L: linux-rdma@vger.kernel.org
12497S: Supported 12499S: Supported
12498F: drivers/infiniband/hw/qedr/ 12500F: drivers/infiniband/hw/qedr/
@@ -12512,7 +12514,7 @@ F: Documentation/scsi/LICENSE.qla2xxx
12512F: drivers/scsi/qla2xxx/ 12514F: drivers/scsi/qla2xxx/
12513 12515
12514QLOGIC QLA3XXX NETWORK DRIVER 12516QLOGIC QLA3XXX NETWORK DRIVER
12515M: Dept-GELinuxNICDev@cavium.com 12517M: GR-Linux-NIC-Dev@marvell.com
12516L: netdev@vger.kernel.org 12518L: netdev@vger.kernel.org
12517S: Supported 12519S: Supported
12518F: Documentation/networking/device_drivers/qlogic/LICENSE.qla3xxx 12520F: Documentation/networking/device_drivers/qlogic/LICENSE.qla3xxx
@@ -12526,16 +12528,16 @@ F: Documentation/scsi/LICENSE.qla4xxx
12526F: drivers/scsi/qla4xxx/ 12528F: drivers/scsi/qla4xxx/
12527 12529
12528QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER 12530QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER
12529M: Shahed Shaikh <Shahed.Shaikh@cavium.com> 12531M: Shahed Shaikh <shshaikh@marvell.com>
12530M: Manish Chopra <manish.chopra@cavium.com> 12532M: Manish Chopra <manishc@marvell.com>
12531M: Dept-GELinuxNICDev@cavium.com 12533M: GR-Linux-NIC-Dev@marvell.com
12532L: netdev@vger.kernel.org 12534L: netdev@vger.kernel.org
12533S: Supported 12535S: Supported
12534F: drivers/net/ethernet/qlogic/qlcnic/ 12536F: drivers/net/ethernet/qlogic/qlcnic/
12535 12537
12536QLOGIC QLGE 10Gb ETHERNET DRIVER 12538QLOGIC QLGE 10Gb ETHERNET DRIVER
12537M: Manish Chopra <manish.chopra@cavium.com> 12539M: Manish Chopra <manishc@marvell.com>
12538M: Dept-GELinuxNICDev@cavium.com 12540M: GR-Linux-NIC-Dev@marvell.com
12539L: netdev@vger.kernel.org 12541L: netdev@vger.kernel.org
12540S: Supported 12542S: Supported
12541F: drivers/net/ethernet/qlogic/qlge/ 12543F: drivers/net/ethernet/qlogic/qlge/
@@ -15857,6 +15859,7 @@ F: drivers/usb/common/usb-otg-fsm.c
15857USB OVER IP DRIVER 15859USB OVER IP DRIVER
15858M: Valentina Manea <valentina.manea.m@gmail.com> 15860M: Valentina Manea <valentina.manea.m@gmail.com>
15859M: Shuah Khan <shuah@kernel.org> 15861M: Shuah Khan <shuah@kernel.org>
15862M: Shuah Khan <skhan@linuxfoundation.org>
15860L: linux-usb@vger.kernel.org 15863L: linux-usb@vger.kernel.org
15861S: Maintained 15864S: Maintained
15862F: Documentation/usb/usbip_protocol.txt 15865F: Documentation/usb/usbip_protocol.txt
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index feed50ce89fa..caa270261521 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -3,23 +3,19 @@ generic-y += bugs.h
3generic-y += compat.h 3generic-y += compat.h
4generic-y += device.h 4generic-y += device.h
5generic-y += div64.h 5generic-y += div64.h
6generic-y += dma-mapping.h
7generic-y += emergency-restart.h 6generic-y += emergency-restart.h
8generic-y += extable.h 7generic-y += extable.h
9generic-y += fb.h
10generic-y += ftrace.h 8generic-y += ftrace.h
11generic-y += hardirq.h 9generic-y += hardirq.h
12generic-y += hw_irq.h 10generic-y += hw_irq.h
13generic-y += irq_regs.h 11generic-y += irq_regs.h
14generic-y += irq_work.h 12generic-y += irq_work.h
15generic-y += kmap_types.h
16generic-y += local.h 13generic-y += local.h
17generic-y += local64.h 14generic-y += local64.h
18generic-y += mcs_spinlock.h 15generic-y += mcs_spinlock.h
19generic-y += mm-arch-hooks.h 16generic-y += mm-arch-hooks.h
20generic-y += msi.h 17generic-y += msi.h
21generic-y += parport.h 18generic-y += parport.h
22generic-y += pci.h
23generic-y += percpu.h 19generic-y += percpu.h
24generic-y += preempt.h 20generic-y += preempt.h
25generic-y += topology.h 21generic-y += topology.h
diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 49bfbd879caa..f1b86cef0905 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -216,6 +216,14 @@ struct bcr_fp_arcv2 {
216#endif 216#endif
217}; 217};
218 218
219struct bcr_actionpoint {
220#ifdef CONFIG_CPU_BIG_ENDIAN
221 unsigned int pad:21, min:1, num:2, ver:8;
222#else
223 unsigned int ver:8, num:2, min:1, pad:21;
224#endif
225};
226
219#include <soc/arc/timers.h> 227#include <soc/arc/timers.h>
220 228
221struct bcr_bpu_arcompact { 229struct bcr_bpu_arcompact {
@@ -283,7 +291,7 @@ struct cpuinfo_arc_cache {
283}; 291};
284 292
285struct cpuinfo_arc_bpu { 293struct cpuinfo_arc_bpu {
286 unsigned int ver, full, num_cache, num_pred; 294 unsigned int ver, full, num_cache, num_pred, ret_stk;
287}; 295};
288 296
289struct cpuinfo_arc_ccm { 297struct cpuinfo_arc_ccm {
@@ -302,7 +310,7 @@ struct cpuinfo_arc {
302 struct { 310 struct {
303 unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2, 311 unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2,
304 fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4, 312 fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4,
305 debug:1, ap:1, smart:1, rtt:1, pad3:4, 313 ap_num:4, ap_full:1, smart:1, rtt:1, pad3:1,
306 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4; 314 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
307 } extn; 315 } extn;
308 struct bcr_mpy extn_mpy; 316 struct bcr_mpy extn_mpy;
diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index ee9246184033..202b74c339f0 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -340,7 +340,7 @@ static inline __attribute__ ((const)) int __fls(unsigned long x)
340/* 340/*
341 * __ffs: Similar to ffs, but zero based (0-31) 341 * __ffs: Similar to ffs, but zero based (0-31)
342 */ 342 */
343static inline __attribute__ ((const)) int __ffs(unsigned long word) 343static inline __attribute__ ((const)) unsigned long __ffs(unsigned long word)
344{ 344{
345 if (!word) 345 if (!word)
346 return word; 346 return word;
@@ -400,9 +400,9 @@ static inline __attribute__ ((const)) int ffs(unsigned long x)
400/* 400/*
401 * __ffs: Similar to ffs, but zero based (0-31) 401 * __ffs: Similar to ffs, but zero based (0-31)
402 */ 402 */
403static inline __attribute__ ((const)) int __ffs(unsigned long x) 403static inline __attribute__ ((const)) unsigned long __ffs(unsigned long x)
404{ 404{
405 int n; 405 unsigned long n;
406 406
407 asm volatile( 407 asm volatile(
408 " ffs.f %0, %1 \n" /* 0:31; 31(Z) if src 0 */ 408 " ffs.f %0, %1 \n" /* 0:31; 31(Z) if src 0 */
diff --git a/arch/arc/include/asm/perf_event.h b/arch/arc/include/asm/perf_event.h
index 9185541035cc..6958545390f0 100644
--- a/arch/arc/include/asm/perf_event.h
+++ b/arch/arc/include/asm/perf_event.h
@@ -103,7 +103,8 @@ static const char * const arc_pmu_ev_hw_map[] = {
103 103
104 /* counts condition */ 104 /* counts condition */
105 [PERF_COUNT_HW_INSTRUCTIONS] = "iall", 105 [PERF_COUNT_HW_INSTRUCTIONS] = "iall",
106 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = "ijmp", /* Excludes ZOL jumps */ 106 /* All jump instructions that are taken */
107 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = "ijmptak",
107 [PERF_COUNT_ARC_BPOK] = "bpok", /* NP-NT, PT-T, PNT-NT */ 108 [PERF_COUNT_ARC_BPOK] = "bpok", /* NP-NT, PT-T, PNT-NT */
108#ifdef CONFIG_ISA_ARCV2 109#ifdef CONFIG_ISA_ARCV2
109 [PERF_COUNT_HW_BRANCH_MISSES] = "bpmp", 110 [PERF_COUNT_HW_BRANCH_MISSES] = "bpmp",
diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index 8aec462d90fb..861a8aea51f9 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -1,15 +1,10 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Linux performance counter support for ARC700 series 2//
3 * 3// Linux performance counter support for ARC CPUs.
4 * Copyright (C) 2013-2015 Synopsys, Inc. (www.synopsys.com) 4// This code is inspired by the perf support of various other architectures.
5 * 5//
6 * This code is inspired by the perf support of various other architectures. 6// Copyright (C) 2013-2018 Synopsys, Inc. (www.synopsys.com)
7 * 7
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13#include <linux/errno.h> 8#include <linux/errno.h>
14#include <linux/interrupt.h> 9#include <linux/interrupt.h>
15#include <linux/module.h> 10#include <linux/module.h>
@@ -19,12 +14,31 @@
19#include <asm/arcregs.h> 14#include <asm/arcregs.h>
20#include <asm/stacktrace.h> 15#include <asm/stacktrace.h>
21 16
17/* HW holds 8 symbols + one for null terminator */
18#define ARCPMU_EVENT_NAME_LEN 9
19
20enum arc_pmu_attr_groups {
21 ARCPMU_ATTR_GR_EVENTS,
22 ARCPMU_ATTR_GR_FORMATS,
23 ARCPMU_NR_ATTR_GR
24};
25
26struct arc_pmu_raw_event_entry {
27 char name[ARCPMU_EVENT_NAME_LEN];
28};
29
22struct arc_pmu { 30struct arc_pmu {
23 struct pmu pmu; 31 struct pmu pmu;
24 unsigned int irq; 32 unsigned int irq;
25 int n_counters; 33 int n_counters;
34 int n_events;
26 u64 max_period; 35 u64 max_period;
27 int ev_hw_idx[PERF_COUNT_ARC_HW_MAX]; 36 int ev_hw_idx[PERF_COUNT_ARC_HW_MAX];
37
38 struct arc_pmu_raw_event_entry *raw_entry;
39 struct attribute **attrs;
40 struct perf_pmu_events_attr *attr;
41 const struct attribute_group *attr_groups[ARCPMU_NR_ATTR_GR + 1];
28}; 42};
29 43
30struct arc_pmu_cpu { 44struct arc_pmu_cpu {
@@ -49,6 +63,7 @@ static int callchain_trace(unsigned int addr, void *data)
49{ 63{
50 struct arc_callchain_trace *ctrl = data; 64 struct arc_callchain_trace *ctrl = data;
51 struct perf_callchain_entry_ctx *entry = ctrl->perf_stuff; 65 struct perf_callchain_entry_ctx *entry = ctrl->perf_stuff;
66
52 perf_callchain_store(entry, addr); 67 perf_callchain_store(entry, addr);
53 68
54 if (ctrl->depth++ < 3) 69 if (ctrl->depth++ < 3)
@@ -57,8 +72,8 @@ static int callchain_trace(unsigned int addr, void *data)
57 return -1; 72 return -1;
58} 73}
59 74
60void 75void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
61perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs) 76 struct pt_regs *regs)
62{ 77{
63 struct arc_callchain_trace ctrl = { 78 struct arc_callchain_trace ctrl = {
64 .depth = 0, 79 .depth = 0,
@@ -68,8 +83,8 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
68 arc_unwind_core(NULL, regs, callchain_trace, &ctrl); 83 arc_unwind_core(NULL, regs, callchain_trace, &ctrl);
69} 84}
70 85
71void 86void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
72perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs) 87 struct pt_regs *regs)
73{ 88{
74 /* 89 /*
75 * User stack can't be unwound trivially with kernel dwarf unwinder 90 * User stack can't be unwound trivially with kernel dwarf unwinder
@@ -82,10 +97,10 @@ static struct arc_pmu *arc_pmu;
82static DEFINE_PER_CPU(struct arc_pmu_cpu, arc_pmu_cpu); 97static DEFINE_PER_CPU(struct arc_pmu_cpu, arc_pmu_cpu);
83 98
84/* read counter #idx; note that counter# != event# on ARC! */ 99/* read counter #idx; note that counter# != event# on ARC! */
85static uint64_t arc_pmu_read_counter(int idx) 100static u64 arc_pmu_read_counter(int idx)
86{ 101{
87 uint32_t tmp; 102 u32 tmp;
88 uint64_t result; 103 u64 result;
89 104
90 /* 105 /*
91 * ARC supports making 'snapshots' of the counters, so we don't 106 * ARC supports making 'snapshots' of the counters, so we don't
@@ -94,7 +109,7 @@ static uint64_t arc_pmu_read_counter(int idx)
94 write_aux_reg(ARC_REG_PCT_INDEX, idx); 109 write_aux_reg(ARC_REG_PCT_INDEX, idx);
95 tmp = read_aux_reg(ARC_REG_PCT_CONTROL); 110 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
96 write_aux_reg(ARC_REG_PCT_CONTROL, tmp | ARC_REG_PCT_CONTROL_SN); 111 write_aux_reg(ARC_REG_PCT_CONTROL, tmp | ARC_REG_PCT_CONTROL_SN);
97 result = (uint64_t) (read_aux_reg(ARC_REG_PCT_SNAPH)) << 32; 112 result = (u64) (read_aux_reg(ARC_REG_PCT_SNAPH)) << 32;
98 result |= read_aux_reg(ARC_REG_PCT_SNAPL); 113 result |= read_aux_reg(ARC_REG_PCT_SNAPL);
99 114
100 return result; 115 return result;
@@ -103,9 +118,9 @@ static uint64_t arc_pmu_read_counter(int idx)
103static void arc_perf_event_update(struct perf_event *event, 118static void arc_perf_event_update(struct perf_event *event,
104 struct hw_perf_event *hwc, int idx) 119 struct hw_perf_event *hwc, int idx)
105{ 120{
106 uint64_t prev_raw_count = local64_read(&hwc->prev_count); 121 u64 prev_raw_count = local64_read(&hwc->prev_count);
107 uint64_t new_raw_count = arc_pmu_read_counter(idx); 122 u64 new_raw_count = arc_pmu_read_counter(idx);
108 int64_t delta = new_raw_count - prev_raw_count; 123 s64 delta = new_raw_count - prev_raw_count;
109 124
110 /* 125 /*
111 * We aren't afraid of hwc->prev_count changing beneath our feet 126 * We aren't afraid of hwc->prev_count changing beneath our feet
@@ -155,7 +170,7 @@ static int arc_pmu_event_init(struct perf_event *event)
155 int ret; 170 int ret;
156 171
157 if (!is_sampling_event(event)) { 172 if (!is_sampling_event(event)) {
158 hwc->sample_period = arc_pmu->max_period; 173 hwc->sample_period = arc_pmu->max_period;
159 hwc->last_period = hwc->sample_period; 174 hwc->last_period = hwc->sample_period;
160 local64_set(&hwc->period_left, hwc->sample_period); 175 local64_set(&hwc->period_left, hwc->sample_period);
161 } 176 }
@@ -192,6 +207,18 @@ static int arc_pmu_event_init(struct perf_event *event)
192 pr_debug("init cache event with h/w %08x \'%s\'\n", 207 pr_debug("init cache event with h/w %08x \'%s\'\n",
193 (int)hwc->config, arc_pmu_ev_hw_map[ret]); 208 (int)hwc->config, arc_pmu_ev_hw_map[ret]);
194 return 0; 209 return 0;
210
211 case PERF_TYPE_RAW:
212 if (event->attr.config >= arc_pmu->n_events)
213 return -ENOENT;
214
215 hwc->config |= event->attr.config;
216 pr_debug("init raw event with idx %lld \'%s\'\n",
217 event->attr.config,
218 arc_pmu->raw_entry[event->attr.config].name);
219
220 return 0;
221
195 default: 222 default:
196 return -ENOENT; 223 return -ENOENT;
197 } 224 }
@@ -200,7 +227,7 @@ static int arc_pmu_event_init(struct perf_event *event)
200/* starts all counters */ 227/* starts all counters */
201static void arc_pmu_enable(struct pmu *pmu) 228static void arc_pmu_enable(struct pmu *pmu)
202{ 229{
203 uint32_t tmp; 230 u32 tmp;
204 tmp = read_aux_reg(ARC_REG_PCT_CONTROL); 231 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
205 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x1); 232 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x1);
206} 233}
@@ -208,7 +235,7 @@ static void arc_pmu_enable(struct pmu *pmu)
208/* stops all counters */ 235/* stops all counters */
209static void arc_pmu_disable(struct pmu *pmu) 236static void arc_pmu_disable(struct pmu *pmu)
210{ 237{
211 uint32_t tmp; 238 u32 tmp;
212 tmp = read_aux_reg(ARC_REG_PCT_CONTROL); 239 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
213 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x0); 240 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x0);
214} 241}
@@ -228,7 +255,7 @@ static int arc_pmu_event_set_period(struct perf_event *event)
228 local64_set(&hwc->period_left, left); 255 local64_set(&hwc->period_left, left);
229 hwc->last_period = period; 256 hwc->last_period = period;
230 overflow = 1; 257 overflow = 1;
231 } else if (unlikely(left <= 0)) { 258 } else if (unlikely(left <= 0)) {
232 /* left underflowed by less than period. */ 259 /* left underflowed by less than period. */
233 left += period; 260 left += period;
234 local64_set(&hwc->period_left, left); 261 local64_set(&hwc->period_left, left);
@@ -246,8 +273,8 @@ static int arc_pmu_event_set_period(struct perf_event *event)
246 write_aux_reg(ARC_REG_PCT_INDEX, idx); 273 write_aux_reg(ARC_REG_PCT_INDEX, idx);
247 274
248 /* Write value */ 275 /* Write value */
249 write_aux_reg(ARC_REG_PCT_COUNTL, (u32)value); 276 write_aux_reg(ARC_REG_PCT_COUNTL, lower_32_bits(value));
250 write_aux_reg(ARC_REG_PCT_COUNTH, (value >> 32)); 277 write_aux_reg(ARC_REG_PCT_COUNTH, upper_32_bits(value));
251 278
252 perf_event_update_userpage(event); 279 perf_event_update_userpage(event);
253 280
@@ -277,7 +304,7 @@ static void arc_pmu_start(struct perf_event *event, int flags)
277 /* Enable interrupt for this counter */ 304 /* Enable interrupt for this counter */
278 if (is_sampling_event(event)) 305 if (is_sampling_event(event))
279 write_aux_reg(ARC_REG_PCT_INT_CTRL, 306 write_aux_reg(ARC_REG_PCT_INT_CTRL,
280 read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx)); 307 read_aux_reg(ARC_REG_PCT_INT_CTRL) | BIT(idx));
281 308
282 /* enable ARC pmu here */ 309 /* enable ARC pmu here */
283 write_aux_reg(ARC_REG_PCT_INDEX, idx); /* counter # */ 310 write_aux_reg(ARC_REG_PCT_INDEX, idx); /* counter # */
@@ -295,9 +322,9 @@ static void arc_pmu_stop(struct perf_event *event, int flags)
295 * Reset interrupt flag by writing of 1. This is required 322 * Reset interrupt flag by writing of 1. This is required
296 * to make sure pending interrupt was not left. 323 * to make sure pending interrupt was not left.
297 */ 324 */
298 write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx); 325 write_aux_reg(ARC_REG_PCT_INT_ACT, BIT(idx));
299 write_aux_reg(ARC_REG_PCT_INT_CTRL, 326 write_aux_reg(ARC_REG_PCT_INT_CTRL,
300 read_aux_reg(ARC_REG_PCT_INT_CTRL) & ~(1 << idx)); 327 read_aux_reg(ARC_REG_PCT_INT_CTRL) & ~BIT(idx));
301 } 328 }
302 329
303 if (!(event->hw.state & PERF_HES_STOPPED)) { 330 if (!(event->hw.state & PERF_HES_STOPPED)) {
@@ -349,9 +376,10 @@ static int arc_pmu_add(struct perf_event *event, int flags)
349 376
350 if (is_sampling_event(event)) { 377 if (is_sampling_event(event)) {
351 /* Mimic full counter overflow as other arches do */ 378 /* Mimic full counter overflow as other arches do */
352 write_aux_reg(ARC_REG_PCT_INT_CNTL, (u32)arc_pmu->max_period); 379 write_aux_reg(ARC_REG_PCT_INT_CNTL,
380 lower_32_bits(arc_pmu->max_period));
353 write_aux_reg(ARC_REG_PCT_INT_CNTH, 381 write_aux_reg(ARC_REG_PCT_INT_CNTH,
354 (arc_pmu->max_period >> 32)); 382 upper_32_bits(arc_pmu->max_period));
355 } 383 }
356 384
357 write_aux_reg(ARC_REG_PCT_CONFIG, 0); 385 write_aux_reg(ARC_REG_PCT_CONFIG, 0);
@@ -392,7 +420,7 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev)
392 idx = __ffs(active_ints); 420 idx = __ffs(active_ints);
393 421
394 /* Reset interrupt flag by writing of 1 */ 422 /* Reset interrupt flag by writing of 1 */
395 write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx); 423 write_aux_reg(ARC_REG_PCT_INT_ACT, BIT(idx));
396 424
397 /* 425 /*
398 * On reset of "interrupt active" bit corresponding 426 * On reset of "interrupt active" bit corresponding
@@ -400,7 +428,7 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev)
400 * Now we need to re-enable interrupt for the counter. 428 * Now we need to re-enable interrupt for the counter.
401 */ 429 */
402 write_aux_reg(ARC_REG_PCT_INT_CTRL, 430 write_aux_reg(ARC_REG_PCT_INT_CTRL,
403 read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx)); 431 read_aux_reg(ARC_REG_PCT_INT_CTRL) | BIT(idx));
404 432
405 event = pmu_cpu->act_counter[idx]; 433 event = pmu_cpu->act_counter[idx];
406 hwc = &event->hw; 434 hwc = &event->hw;
@@ -414,7 +442,7 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev)
414 arc_pmu_stop(event, 0); 442 arc_pmu_stop(event, 0);
415 } 443 }
416 444
417 active_ints &= ~(1U << idx); 445 active_ints &= ~BIT(idx);
418 } while (active_ints); 446 } while (active_ints);
419 447
420done: 448done:
@@ -441,19 +469,108 @@ static void arc_cpu_pmu_irq_init(void *data)
441 write_aux_reg(ARC_REG_PCT_INT_ACT, 0xffffffff); 469 write_aux_reg(ARC_REG_PCT_INT_ACT, 0xffffffff);
442} 470}
443 471
472/* Event field occupies the bottom 15 bits of our config field */
473PMU_FORMAT_ATTR(event, "config:0-14");
474static struct attribute *arc_pmu_format_attrs[] = {
475 &format_attr_event.attr,
476 NULL,
477};
478
479static struct attribute_group arc_pmu_format_attr_gr = {
480 .name = "format",
481 .attrs = arc_pmu_format_attrs,
482};
483
484static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
485 struct device_attribute *attr,
486 char *page)
487{
488 struct perf_pmu_events_attr *pmu_attr;
489
490 pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
491 return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
492}
493
494/*
495 * We don't add attrs here as we don't have pre-defined list of perf events.
496 * We will generate and add attrs dynamically in probe() after we read HW
497 * configuration.
498 */
499static struct attribute_group arc_pmu_events_attr_gr = {
500 .name = "events",
501};
502
503static void arc_pmu_add_raw_event_attr(int j, char *str)
504{
505 memmove(arc_pmu->raw_entry[j].name, str, ARCPMU_EVENT_NAME_LEN - 1);
506 arc_pmu->attr[j].attr.attr.name = arc_pmu->raw_entry[j].name;
507 arc_pmu->attr[j].attr.attr.mode = VERIFY_OCTAL_PERMISSIONS(0444);
508 arc_pmu->attr[j].attr.show = arc_pmu_events_sysfs_show;
509 arc_pmu->attr[j].id = j;
510 arc_pmu->attrs[j] = &(arc_pmu->attr[j].attr.attr);
511}
512
513static int arc_pmu_raw_alloc(struct device *dev)
514{
515 arc_pmu->attr = devm_kmalloc_array(dev, arc_pmu->n_events + 1,
516 sizeof(*arc_pmu->attr), GFP_KERNEL | __GFP_ZERO);
517 if (!arc_pmu->attr)
518 return -ENOMEM;
519
520 arc_pmu->attrs = devm_kmalloc_array(dev, arc_pmu->n_events + 1,
521 sizeof(*arc_pmu->attrs), GFP_KERNEL | __GFP_ZERO);
522 if (!arc_pmu->attrs)
523 return -ENOMEM;
524
525 arc_pmu->raw_entry = devm_kmalloc_array(dev, arc_pmu->n_events,
526 sizeof(*arc_pmu->raw_entry), GFP_KERNEL | __GFP_ZERO);
527 if (!arc_pmu->raw_entry)
528 return -ENOMEM;
529
530 return 0;
531}
532
533static inline bool event_in_hw_event_map(int i, char *name)
534{
535 if (!arc_pmu_ev_hw_map[i])
536 return false;
537
538 if (!strlen(arc_pmu_ev_hw_map[i]))
539 return false;
540
541 if (strcmp(arc_pmu_ev_hw_map[i], name))
542 return false;
543
544 return true;
545}
546
547static void arc_pmu_map_hw_event(int j, char *str)
548{
549 int i;
550
551 /* See if HW condition has been mapped to a perf event_id */
552 for (i = 0; i < ARRAY_SIZE(arc_pmu_ev_hw_map); i++) {
553 if (event_in_hw_event_map(i, str)) {
554 pr_debug("mapping perf event %2d to h/w event \'%8s\' (idx %d)\n",
555 i, str, j);
556 arc_pmu->ev_hw_idx[i] = j;
557 }
558 }
559}
560
444static int arc_pmu_device_probe(struct platform_device *pdev) 561static int arc_pmu_device_probe(struct platform_device *pdev)
445{ 562{
446 struct arc_reg_pct_build pct_bcr; 563 struct arc_reg_pct_build pct_bcr;
447 struct arc_reg_cc_build cc_bcr; 564 struct arc_reg_cc_build cc_bcr;
448 int i, j, has_interrupts; 565 int i, has_interrupts;
449 int counter_size; /* in bits */ 566 int counter_size; /* in bits */
450 567
451 union cc_name { 568 union cc_name {
452 struct { 569 struct {
453 uint32_t word0, word1; 570 u32 word0, word1;
454 char sentinel; 571 char sentinel;
455 } indiv; 572 } indiv;
456 char str[9]; 573 char str[ARCPMU_EVENT_NAME_LEN];
457 } cc_name; 574 } cc_name;
458 575
459 576
@@ -463,15 +580,22 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
463 return -ENODEV; 580 return -ENODEV;
464 } 581 }
465 BUILD_BUG_ON(ARC_PERF_MAX_COUNTERS > 32); 582 BUILD_BUG_ON(ARC_PERF_MAX_COUNTERS > 32);
466 BUG_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS); 583 if (WARN_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS))
584 return -EINVAL;
467 585
468 READ_BCR(ARC_REG_CC_BUILD, cc_bcr); 586 READ_BCR(ARC_REG_CC_BUILD, cc_bcr);
469 BUG_ON(!cc_bcr.v); /* Counters exist but No countable conditions ? */ 587 if (WARN(!cc_bcr.v, "Counters exist but No countable conditions?"))
588 return -EINVAL;
470 589
471 arc_pmu = devm_kzalloc(&pdev->dev, sizeof(struct arc_pmu), GFP_KERNEL); 590 arc_pmu = devm_kzalloc(&pdev->dev, sizeof(struct arc_pmu), GFP_KERNEL);
472 if (!arc_pmu) 591 if (!arc_pmu)
473 return -ENOMEM; 592 return -ENOMEM;
474 593
594 arc_pmu->n_events = cc_bcr.c;
595
596 if (arc_pmu_raw_alloc(&pdev->dev))
597 return -ENOMEM;
598
475 has_interrupts = is_isa_arcv2() ? pct_bcr.i : 0; 599 has_interrupts = is_isa_arcv2() ? pct_bcr.i : 0;
476 600
477 arc_pmu->n_counters = pct_bcr.c; 601 arc_pmu->n_counters = pct_bcr.c;
@@ -481,30 +605,26 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
481 605
482 pr_info("ARC perf\t: %d counters (%d bits), %d conditions%s\n", 606 pr_info("ARC perf\t: %d counters (%d bits), %d conditions%s\n",
483 arc_pmu->n_counters, counter_size, cc_bcr.c, 607 arc_pmu->n_counters, counter_size, cc_bcr.c,
484 has_interrupts ? ", [overflow IRQ support]":""); 608 has_interrupts ? ", [overflow IRQ support]" : "");
485 609
486 cc_name.str[8] = 0; 610 cc_name.str[ARCPMU_EVENT_NAME_LEN - 1] = 0;
487 for (i = 0; i < PERF_COUNT_ARC_HW_MAX; i++) 611 for (i = 0; i < PERF_COUNT_ARC_HW_MAX; i++)
488 arc_pmu->ev_hw_idx[i] = -1; 612 arc_pmu->ev_hw_idx[i] = -1;
489 613
490 /* loop thru all available h/w condition indexes */ 614 /* loop thru all available h/w condition indexes */
491 for (j = 0; j < cc_bcr.c; j++) { 615 for (i = 0; i < cc_bcr.c; i++) {
492 write_aux_reg(ARC_REG_CC_INDEX, j); 616 write_aux_reg(ARC_REG_CC_INDEX, i);
493 cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0); 617 cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0);
494 cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1); 618 cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1);
495 619
496 /* See if it has been mapped to a perf event_id */ 620 arc_pmu_map_hw_event(i, cc_name.str);
497 for (i = 0; i < ARRAY_SIZE(arc_pmu_ev_hw_map); i++) { 621 arc_pmu_add_raw_event_attr(i, cc_name.str);
498 if (arc_pmu_ev_hw_map[i] &&
499 !strcmp(arc_pmu_ev_hw_map[i], cc_name.str) &&
500 strlen(arc_pmu_ev_hw_map[i])) {
501 pr_debug("mapping perf event %2d to h/w event \'%8s\' (idx %d)\n",
502 i, cc_name.str, j);
503 arc_pmu->ev_hw_idx[i] = j;
504 }
505 }
506 } 622 }
507 623
624 arc_pmu_events_attr_gr.attrs = arc_pmu->attrs;
625 arc_pmu->attr_groups[ARCPMU_ATTR_GR_EVENTS] = &arc_pmu_events_attr_gr;
626 arc_pmu->attr_groups[ARCPMU_ATTR_GR_FORMATS] = &arc_pmu_format_attr_gr;
627
508 arc_pmu->pmu = (struct pmu) { 628 arc_pmu->pmu = (struct pmu) {
509 .pmu_enable = arc_pmu_enable, 629 .pmu_enable = arc_pmu_enable,
510 .pmu_disable = arc_pmu_disable, 630 .pmu_disable = arc_pmu_disable,
@@ -514,6 +634,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
514 .start = arc_pmu_start, 634 .start = arc_pmu_start,
515 .stop = arc_pmu_stop, 635 .stop = arc_pmu_stop,
516 .read = arc_pmu_read, 636 .read = arc_pmu_read,
637 .attr_groups = arc_pmu->attr_groups,
517 }; 638 };
518 639
519 if (has_interrupts) { 640 if (has_interrupts) {
@@ -535,17 +656,19 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
535 } else 656 } else
536 arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; 657 arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
537 658
538 return perf_pmu_register(&arc_pmu->pmu, pdev->name, PERF_TYPE_RAW); 659 /*
660 * perf parser doesn't really like '-' symbol in events name, so let's
661 * use '_' in arc pct name as it goes to kernel PMU event prefix.
662 */
663 return perf_pmu_register(&arc_pmu->pmu, "arc_pct", PERF_TYPE_RAW);
539} 664}
540 665
541#ifdef CONFIG_OF
542static const struct of_device_id arc_pmu_match[] = { 666static const struct of_device_id arc_pmu_match[] = {
543 { .compatible = "snps,arc700-pct" }, 667 { .compatible = "snps,arc700-pct" },
544 { .compatible = "snps,archs-pct" }, 668 { .compatible = "snps,archs-pct" },
545 {}, 669 {},
546}; 670};
547MODULE_DEVICE_TABLE(of, arc_pmu_match); 671MODULE_DEVICE_TABLE(of, arc_pmu_match);
548#endif
549 672
550static struct platform_driver arc_pmu_driver = { 673static struct platform_driver arc_pmu_driver = {
551 .driver = { 674 .driver = {
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 2e018b8c2e19..feb90093e6b1 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -123,6 +123,7 @@ static void read_arc_build_cfg_regs(void)
123 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; 123 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
124 const struct id_to_str *tbl; 124 const struct id_to_str *tbl;
125 struct bcr_isa_arcv2 isa; 125 struct bcr_isa_arcv2 isa;
126 struct bcr_actionpoint ap;
126 127
127 FIX_PTR(cpu); 128 FIX_PTR(cpu);
128 129
@@ -195,6 +196,7 @@ static void read_arc_build_cfg_regs(void)
195 cpu->bpu.full = bpu.ft; 196 cpu->bpu.full = bpu.ft;
196 cpu->bpu.num_cache = 256 << bpu.bce; 197 cpu->bpu.num_cache = 256 << bpu.bce;
197 cpu->bpu.num_pred = 2048 << bpu.pte; 198 cpu->bpu.num_pred = 2048 << bpu.pte;
199 cpu->bpu.ret_stk = 4 << bpu.rse;
198 200
199 if (cpu->core.family >= 0x54) { 201 if (cpu->core.family >= 0x54) {
200 unsigned int exec_ctrl; 202 unsigned int exec_ctrl;
@@ -207,8 +209,11 @@ static void read_arc_build_cfg_regs(void)
207 } 209 }
208 } 210 }
209 211
210 READ_BCR(ARC_REG_AP_BCR, bcr); 212 READ_BCR(ARC_REG_AP_BCR, ap);
211 cpu->extn.ap = bcr.ver ? 1 : 0; 213 if (ap.ver) {
214 cpu->extn.ap_num = 2 << ap.num;
215 cpu->extn.ap_full = !!ap.min;
216 }
212 217
213 READ_BCR(ARC_REG_SMART_BCR, bcr); 218 READ_BCR(ARC_REG_SMART_BCR, bcr);
214 cpu->extn.smart = bcr.ver ? 1 : 0; 219 cpu->extn.smart = bcr.ver ? 1 : 0;
@@ -216,8 +221,6 @@ static void read_arc_build_cfg_regs(void)
216 READ_BCR(ARC_REG_RTT_BCR, bcr); 221 READ_BCR(ARC_REG_RTT_BCR, bcr);
217 cpu->extn.rtt = bcr.ver ? 1 : 0; 222 cpu->extn.rtt = bcr.ver ? 1 : 0;
218 223
219 cpu->extn.debug = cpu->extn.ap | cpu->extn.smart | cpu->extn.rtt;
220
221 READ_BCR(ARC_REG_ISA_CFG_BCR, isa); 224 READ_BCR(ARC_REG_ISA_CFG_BCR, isa);
222 225
223 /* some hacks for lack of feature BCR info in old ARC700 cores */ 226 /* some hacks for lack of feature BCR info in old ARC700 cores */
@@ -299,10 +302,10 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
299 302
300 if (cpu->bpu.ver) 303 if (cpu->bpu.ver)
301 n += scnprintf(buf + n, len - n, 304 n += scnprintf(buf + n, len - n,
302 "BPU\t\t: %s%s match, cache:%d, Predict Table:%d", 305 "BPU\t\t: %s%s match, cache:%d, Predict Table:%d Return stk: %d",
303 IS_AVAIL1(cpu->bpu.full, "full"), 306 IS_AVAIL1(cpu->bpu.full, "full"),
304 IS_AVAIL1(!cpu->bpu.full, "partial"), 307 IS_AVAIL1(!cpu->bpu.full, "partial"),
305 cpu->bpu.num_cache, cpu->bpu.num_pred); 308 cpu->bpu.num_cache, cpu->bpu.num_pred, cpu->bpu.ret_stk);
306 309
307 if (is_isa_arcv2()) { 310 if (is_isa_arcv2()) {
308 struct bcr_lpb lpb; 311 struct bcr_lpb lpb;
@@ -336,11 +339,17 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
336 IS_AVAIL1(cpu->extn.fpu_sp, "SP "), 339 IS_AVAIL1(cpu->extn.fpu_sp, "SP "),
337 IS_AVAIL1(cpu->extn.fpu_dp, "DP ")); 340 IS_AVAIL1(cpu->extn.fpu_dp, "DP "));
338 341
339 if (cpu->extn.debug) 342 if (cpu->extn.ap_num | cpu->extn.smart | cpu->extn.rtt) {
340 n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s%s\n", 343 n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s",
341 IS_AVAIL1(cpu->extn.ap, "ActionPoint "),
342 IS_AVAIL1(cpu->extn.smart, "smaRT "), 344 IS_AVAIL1(cpu->extn.smart, "smaRT "),
343 IS_AVAIL1(cpu->extn.rtt, "RTT ")); 345 IS_AVAIL1(cpu->extn.rtt, "RTT "));
346 if (cpu->extn.ap_num) {
347 n += scnprintf(buf + n, len - n, "ActionPoint %d/%s",
348 cpu->extn.ap_num,
349 cpu->extn.ap_full ? "full":"min");
350 }
351 n += scnprintf(buf + n, len - n, "\n");
352 }
344 353
345 if (cpu->dccm.sz || cpu->iccm.sz) 354 if (cpu->dccm.sz || cpu->iccm.sz)
346 n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d KB / ICCM: @ %x, %d KB\n", 355 n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d KB / ICCM: @ %x, %d KB\n",
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index e8d9fb452346..215f515442e0 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -18,6 +18,8 @@
18#include <asm/arcregs.h> 18#include <asm/arcregs.h>
19#include <asm/irqflags.h> 19#include <asm/irqflags.h>
20 20
21#define ARC_PATH_MAX 256
22
21/* 23/*
22 * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25) 24 * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25)
23 * -Prints 3 regs per line and a CR. 25 * -Prints 3 regs per line and a CR.
@@ -58,11 +60,12 @@ static void show_callee_regs(struct callee_regs *cregs)
58 print_reg_file(&(cregs->r13), 13); 60 print_reg_file(&(cregs->r13), 13);
59} 61}
60 62
61static void print_task_path_n_nm(struct task_struct *tsk, char *buf) 63static void print_task_path_n_nm(struct task_struct *tsk)
62{ 64{
63 char *path_nm = NULL; 65 char *path_nm = NULL;
64 struct mm_struct *mm; 66 struct mm_struct *mm;
65 struct file *exe_file; 67 struct file *exe_file;
68 char buf[ARC_PATH_MAX];
66 69
67 mm = get_task_mm(tsk); 70 mm = get_task_mm(tsk);
68 if (!mm) 71 if (!mm)
@@ -72,7 +75,7 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf)
72 mmput(mm); 75 mmput(mm);
73 76
74 if (exe_file) { 77 if (exe_file) {
75 path_nm = file_path(exe_file, buf, 255); 78 path_nm = file_path(exe_file, buf, ARC_PATH_MAX-1);
76 fput(exe_file); 79 fput(exe_file);
77 } 80 }
78 81
@@ -80,10 +83,9 @@ done:
80 pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?"); 83 pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
81} 84}
82 85
83static void show_faulting_vma(unsigned long address, char *buf) 86static void show_faulting_vma(unsigned long address)
84{ 87{
85 struct vm_area_struct *vma; 88 struct vm_area_struct *vma;
86 char *nm = buf;
87 struct mm_struct *active_mm = current->active_mm; 89 struct mm_struct *active_mm = current->active_mm;
88 90
89 /* can't use print_vma_addr() yet as it doesn't check for 91 /* can't use print_vma_addr() yet as it doesn't check for
@@ -96,8 +98,11 @@ static void show_faulting_vma(unsigned long address, char *buf)
96 * if the container VMA is not found 98 * if the container VMA is not found
97 */ 99 */
98 if (vma && (vma->vm_start <= address)) { 100 if (vma && (vma->vm_start <= address)) {
101 char buf[ARC_PATH_MAX];
102 char *nm = "?";
103
99 if (vma->vm_file) { 104 if (vma->vm_file) {
100 nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1); 105 nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1);
101 if (IS_ERR(nm)) 106 if (IS_ERR(nm))
102 nm = "?"; 107 nm = "?";
103 } 108 }
@@ -173,13 +178,14 @@ void show_regs(struct pt_regs *regs)
173{ 178{
174 struct task_struct *tsk = current; 179 struct task_struct *tsk = current;
175 struct callee_regs *cregs; 180 struct callee_regs *cregs;
176 char *buf;
177 181
178 buf = (char *)__get_free_page(GFP_KERNEL); 182 /*
179 if (!buf) 183 * generic code calls us with preemption disabled, but some calls
180 return; 184 * here could sleep, so re-enable to avoid lockdep splat
185 */
186 preempt_enable();
181 187
182 print_task_path_n_nm(tsk, buf); 188 print_task_path_n_nm(tsk);
183 show_regs_print_info(KERN_INFO); 189 show_regs_print_info(KERN_INFO);
184 190
185 show_ecr_verbose(regs); 191 show_ecr_verbose(regs);
@@ -189,7 +195,7 @@ void show_regs(struct pt_regs *regs)
189 (void *)regs->blink, (void *)regs->ret); 195 (void *)regs->blink, (void *)regs->ret);
190 196
191 if (user_mode(regs)) 197 if (user_mode(regs))
192 show_faulting_vma(regs->ret, buf); /* faulting code, not data */ 198 show_faulting_vma(regs->ret); /* faulting code, not data */
193 199
194 pr_info("[STAT32]: 0x%08lx", regs->status32); 200 pr_info("[STAT32]: 0x%08lx", regs->status32);
195 201
@@ -222,7 +228,7 @@ void show_regs(struct pt_regs *regs)
222 if (cregs) 228 if (cregs)
223 show_callee_regs(cregs); 229 show_callee_regs(cregs);
224 230
225 free_page((unsigned long)buf); 231 preempt_disable();
226} 232}
227 233
228void show_kernel_fault_diag(const char *str, struct pt_regs *regs, 234void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
diff --git a/arch/arc/lib/memset-archs.S b/arch/arc/lib/memset-archs.S
index 62ad4bcb841a..f230bb7092fd 100644
--- a/arch/arc/lib/memset-archs.S
+++ b/arch/arc/lib/memset-archs.S
@@ -7,11 +7,39 @@
7 */ 7 */
8 8
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/cache.h>
10 11
11#undef PREALLOC_NOT_AVAIL 12/*
13 * The memset implementation below is optimized to use prefetchw and prealloc
14 * instruction in case of CPU with 64B L1 data cache line (L1_CACHE_SHIFT == 6)
15 * If you want to implement optimized memset for other possible L1 data cache
16 * line lengths (32B and 128B) you should rewrite code carefully checking
17 * we don't call any prefetchw/prealloc instruction for L1 cache lines which
18 * don't belongs to memset area.
19 */
20
21#if L1_CACHE_SHIFT == 6
22
23.macro PREALLOC_INSTR reg, off
24 prealloc [\reg, \off]
25.endm
26
27.macro PREFETCHW_INSTR reg, off
28 prefetchw [\reg, \off]
29.endm
30
31#else
32
33.macro PREALLOC_INSTR
34.endm
35
36.macro PREFETCHW_INSTR
37.endm
38
39#endif
12 40
13ENTRY_CFI(memset) 41ENTRY_CFI(memset)
14 prefetchw [r0] ; Prefetch the write location 42 PREFETCHW_INSTR r0, 0 ; Prefetch the first write location
15 mov.f 0, r2 43 mov.f 0, r2
16;;; if size is zero 44;;; if size is zero
17 jz.d [blink] 45 jz.d [blink]
@@ -48,11 +76,8 @@ ENTRY_CFI(memset)
48 76
49 lpnz @.Lset64bytes 77 lpnz @.Lset64bytes
50 ;; LOOP START 78 ;; LOOP START
51#ifdef PREALLOC_NOT_AVAIL 79 PREALLOC_INSTR r3, 64 ; alloc next line w/o fetching
52 prefetchw [r3, 64] ;Prefetch the next write location 80
53#else
54 prealloc [r3, 64]
55#endif
56#ifdef CONFIG_ARC_HAS_LL64 81#ifdef CONFIG_ARC_HAS_LL64
57 std.ab r4, [r3, 8] 82 std.ab r4, [r3, 8]
58 std.ab r4, [r3, 8] 83 std.ab r4, [r3, 8]
@@ -85,7 +110,6 @@ ENTRY_CFI(memset)
85 lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes 110 lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
86 lpnz .Lset32bytes 111 lpnz .Lset32bytes
87 ;; LOOP START 112 ;; LOOP START
88 prefetchw [r3, 32] ;Prefetch the next write location
89#ifdef CONFIG_ARC_HAS_LL64 113#ifdef CONFIG_ARC_HAS_LL64
90 std.ab r4, [r3, 8] 114 std.ab r4, [r3, 8]
91 std.ab r4, [r3, 8] 115 std.ab r4, [r3, 8]
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index a1d723197084..8df1638259f3 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -141,12 +141,17 @@ good_area:
141 */ 141 */
142 fault = handle_mm_fault(vma, address, flags); 142 fault = handle_mm_fault(vma, address, flags);
143 143
144 /* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
145 if (fatal_signal_pending(current)) { 144 if (fatal_signal_pending(current)) {
146 if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY)) 145
147 up_read(&mm->mmap_sem); 146 /*
148 if (user_mode(regs)) 147 * if fault retry, mmap_sem already relinquished by core mm
148 * so OK to return to user mode (with signal handled first)
149 */
150 if (fault & VM_FAULT_RETRY) {
151 if (!user_mode(regs))
152 goto no_context;
149 return; 153 return;
154 }
150 } 155 }
151 156
152 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); 157 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 43bf4c3a1290..e1ab2d7f1d64 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -119,7 +119,8 @@ void __init setup_arch_memory(void)
119 */ 119 */
120 120
121 memblock_add_node(low_mem_start, low_mem_sz, 0); 121 memblock_add_node(low_mem_start, low_mem_sz, 0);
122 memblock_reserve(low_mem_start, __pa(_end) - low_mem_start); 122 memblock_reserve(CONFIG_LINUX_LINK_BASE,
123 __pa(_end) - CONFIG_LINUX_LINK_BASE);
123 124
124#ifdef CONFIG_BLK_DEV_INITRD 125#ifdef CONFIG_BLK_DEV_INITRD
125 if (phys_initrd_size) { 126 if (phys_initrd_size) {
diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
index b3ef061d8b74..2c403e7c782d 100644
--- a/arch/arm/include/asm/xen/page-coherent.h
+++ b/arch/arm/include/asm/xen/page-coherent.h
@@ -1 +1,95 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_ARM_XEN_PAGE_COHERENT_H
3#define _ASM_ARM_XEN_PAGE_COHERENT_H
4
5#include <linux/dma-mapping.h>
6#include <asm/page.h>
1#include <xen/arm/page-coherent.h> 7#include <xen/arm/page-coherent.h>
8
9static inline const struct dma_map_ops *xen_get_dma_ops(struct device *dev)
10{
11 if (dev && dev->archdata.dev_dma_ops)
12 return dev->archdata.dev_dma_ops;
13 return get_arch_dma_ops(NULL);
14}
15
16static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
17 dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs)
18{
19 return xen_get_dma_ops(hwdev)->alloc(hwdev, size, dma_handle, flags, attrs);
20}
21
22static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
23 void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
24{
25 xen_get_dma_ops(hwdev)->free(hwdev, size, cpu_addr, dma_handle, attrs);
26}
27
28static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
29 dma_addr_t dev_addr, unsigned long offset, size_t size,
30 enum dma_data_direction dir, unsigned long attrs)
31{
32 unsigned long page_pfn = page_to_xen_pfn(page);
33 unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr);
34 unsigned long compound_pages =
35 (1<<compound_order(page)) * XEN_PFN_PER_PAGE;
36 bool local = (page_pfn <= dev_pfn) &&
37 (dev_pfn - page_pfn < compound_pages);
38
39 /*
40 * Dom0 is mapped 1:1, while the Linux page can span across
41 * multiple Xen pages, it's not possible for it to contain a
42 * mix of local and foreign Xen pages. So if the first xen_pfn
43 * == mfn the page is local otherwise it's a foreign page
44 * grant-mapped in dom0. If the page is local we can safely
45 * call the native dma_ops function, otherwise we call the xen
46 * specific function.
47 */
48 if (local)
49 xen_get_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
50 else
51 __xen_dma_map_page(hwdev, page, dev_addr, offset, size, dir, attrs);
52}
53
54static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
55 size_t size, enum dma_data_direction dir, unsigned long attrs)
56{
57 unsigned long pfn = PFN_DOWN(handle);
58 /*
59 * Dom0 is mapped 1:1, while the Linux page can be spanned accross
60 * multiple Xen page, it's not possible to have a mix of local and
61 * foreign Xen page. Dom0 is mapped 1:1, so calling pfn_valid on a
62 * foreign mfn will always return false. If the page is local we can
63 * safely call the native dma_ops function, otherwise we call the xen
64 * specific function.
65 */
66 if (pfn_valid(pfn)) {
67 if (xen_get_dma_ops(hwdev)->unmap_page)
68 xen_get_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);
69 } else
70 __xen_dma_unmap_page(hwdev, handle, size, dir, attrs);
71}
72
73static inline void xen_dma_sync_single_for_cpu(struct device *hwdev,
74 dma_addr_t handle, size_t size, enum dma_data_direction dir)
75{
76 unsigned long pfn = PFN_DOWN(handle);
77 if (pfn_valid(pfn)) {
78 if (xen_get_dma_ops(hwdev)->sync_single_for_cpu)
79 xen_get_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir);
80 } else
81 __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir);
82}
83
84static inline void xen_dma_sync_single_for_device(struct device *hwdev,
85 dma_addr_t handle, size_t size, enum dma_data_direction dir)
86{
87 unsigned long pfn = PFN_DOWN(handle);
88 if (pfn_valid(pfn)) {
89 if (xen_get_dma_ops(hwdev)->sync_single_for_device)
90 xen_get_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir);
91 } else
92 __xen_dma_sync_single_for_device(hwdev, handle, size, dir);
93}
94
95#endif /* _ASM_ARM_XEN_PAGE_COHERENT_H */
diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
index 3dd3d664c5c5..4658c937e173 100644
--- a/arch/arm64/include/asm/device.h
+++ b/arch/arm64/include/asm/device.h
@@ -20,9 +20,6 @@ struct dev_archdata {
20#ifdef CONFIG_IOMMU_API 20#ifdef CONFIG_IOMMU_API
21 void *iommu; /* private IOMMU data */ 21 void *iommu; /* private IOMMU data */
22#endif 22#endif
23#ifdef CONFIG_XEN
24 const struct dma_map_ops *dev_dma_ops;
25#endif
26}; 23};
27 24
28struct pdev_archdata { 25struct pdev_archdata {
diff --git a/arch/arm64/include/asm/xen/page-coherent.h b/arch/arm64/include/asm/xen/page-coherent.h
index b3ef061d8b74..d88e56b90b93 100644
--- a/arch/arm64/include/asm/xen/page-coherent.h
+++ b/arch/arm64/include/asm/xen/page-coherent.h
@@ -1 +1,77 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_ARM64_XEN_PAGE_COHERENT_H
3#define _ASM_ARM64_XEN_PAGE_COHERENT_H
4
5#include <linux/dma-mapping.h>
6#include <asm/page.h>
1#include <xen/arm/page-coherent.h> 7#include <xen/arm/page-coherent.h>
8
9static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
10 dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs)
11{
12 return dma_direct_alloc(hwdev, size, dma_handle, flags, attrs);
13}
14
15static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
16 void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
17{
18 dma_direct_free(hwdev, size, cpu_addr, dma_handle, attrs);
19}
20
21static inline void xen_dma_sync_single_for_cpu(struct device *hwdev,
22 dma_addr_t handle, size_t size, enum dma_data_direction dir)
23{
24 unsigned long pfn = PFN_DOWN(handle);
25
26 if (pfn_valid(pfn))
27 dma_direct_sync_single_for_cpu(hwdev, handle, size, dir);
28 else
29 __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir);
30}
31
32static inline void xen_dma_sync_single_for_device(struct device *hwdev,
33 dma_addr_t handle, size_t size, enum dma_data_direction dir)
34{
35 unsigned long pfn = PFN_DOWN(handle);
36 if (pfn_valid(pfn))
37 dma_direct_sync_single_for_device(hwdev, handle, size, dir);
38 else
39 __xen_dma_sync_single_for_device(hwdev, handle, size, dir);
40}
41
42static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
43 dma_addr_t dev_addr, unsigned long offset, size_t size,
44 enum dma_data_direction dir, unsigned long attrs)
45{
46 unsigned long page_pfn = page_to_xen_pfn(page);
47 unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr);
48 unsigned long compound_pages =
49 (1<<compound_order(page)) * XEN_PFN_PER_PAGE;
50 bool local = (page_pfn <= dev_pfn) &&
51 (dev_pfn - page_pfn < compound_pages);
52
53 if (local)
54 dma_direct_map_page(hwdev, page, offset, size, dir, attrs);
55 else
56 __xen_dma_map_page(hwdev, page, dev_addr, offset, size, dir, attrs);
57}
58
59static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
60 size_t size, enum dma_data_direction dir, unsigned long attrs)
61{
62 unsigned long pfn = PFN_DOWN(handle);
63 /*
64 * Dom0 is mapped 1:1, while the Linux page can be spanned accross
65 * multiple Xen page, it's not possible to have a mix of local and
66 * foreign Xen page. Dom0 is mapped 1:1, so calling pfn_valid on a
67 * foreign mfn will always return false. If the page is local we can
68 * safely call the native dma_ops function, otherwise we call the xen
69 * specific function.
70 */
71 if (pfn_valid(pfn))
72 dma_direct_unmap_page(hwdev, handle, size, dir, attrs);
73 else
74 __xen_dma_unmap_page(hwdev, handle, size, dir, attrs);
75}
76
77#endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index fb0908456a1f..78c0a72f822c 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -466,9 +466,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
466 __iommu_setup_dma_ops(dev, dma_base, size, iommu); 466 __iommu_setup_dma_ops(dev, dma_base, size, iommu);
467 467
468#ifdef CONFIG_XEN 468#ifdef CONFIG_XEN
469 if (xen_initial_domain()) { 469 if (xen_initial_domain())
470 dev->archdata.dev_dma_ops = dev->dma_ops;
471 dev->dma_ops = xen_dma_ops; 470 dev->dma_ops = xen_dma_ops;
472 }
473#endif 471#endif
474} 472}
diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
index ccbb53e22024..8d04e6f3f796 100644
--- a/arch/s390/include/asm/mmu_context.h
+++ b/arch/s390/include/asm/mmu_context.h
@@ -25,7 +25,7 @@ static inline int init_new_context(struct task_struct *tsk,
25 atomic_set(&mm->context.flush_count, 0); 25 atomic_set(&mm->context.flush_count, 0);
26 mm->context.gmap_asce = 0; 26 mm->context.gmap_asce = 0;
27 mm->context.flush_mm = 0; 27 mm->context.flush_mm = 0;
28 mm->context.compat_mm = 0; 28 mm->context.compat_mm = test_thread_flag(TIF_31BIT);
29#ifdef CONFIG_PGSTE 29#ifdef CONFIG_PGSTE
30 mm->context.alloc_pgste = page_table_allocate_pgste || 30 mm->context.alloc_pgste = page_table_allocate_pgste ||
31 test_thread_flag(TIF_PGSTE) || 31 test_thread_flag(TIF_PGSTE) ||
@@ -90,8 +90,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
90{ 90{
91 int cpu = smp_processor_id(); 91 int cpu = smp_processor_id();
92 92
93 if (prev == next)
94 return;
95 S390_lowcore.user_asce = next->context.asce; 93 S390_lowcore.user_asce = next->context.asce;
96 cpumask_set_cpu(cpu, &next->context.cpu_attach_mask); 94 cpumask_set_cpu(cpu, &next->context.cpu_attach_mask);
97 /* Clear previous user-ASCE from CR1 and CR7 */ 95 /* Clear previous user-ASCE from CR1 and CR7 */
@@ -103,7 +101,8 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
103 __ctl_load(S390_lowcore.vdso_asce, 7, 7); 101 __ctl_load(S390_lowcore.vdso_asce, 7, 7);
104 clear_cpu_flag(CIF_ASCE_SECONDARY); 102 clear_cpu_flag(CIF_ASCE_SECONDARY);
105 } 103 }
106 cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask); 104 if (prev != next)
105 cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask);
107} 106}
108 107
109#define finish_arch_post_lock_switch finish_arch_post_lock_switch 108#define finish_arch_post_lock_switch finish_arch_post_lock_switch
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index af5c2b3f7065..a8c7789b246b 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -63,10 +63,10 @@ static noinline __init void detect_machine_type(void)
63 if (stsi(vmms, 3, 2, 2) || !vmms->count) 63 if (stsi(vmms, 3, 2, 2) || !vmms->count)
64 return; 64 return;
65 65
66 /* Running under KVM? If not we assume z/VM */ 66 /* Detect known hypervisors */
67 if (!memcmp(vmms->vm[0].cpi, "\xd2\xe5\xd4", 3)) 67 if (!memcmp(vmms->vm[0].cpi, "\xd2\xe5\xd4", 3))
68 S390_lowcore.machine_flags |= MACHINE_FLAG_KVM; 68 S390_lowcore.machine_flags |= MACHINE_FLAG_KVM;
69 else 69 else if (!memcmp(vmms->vm[0].cpi, "\xa9\x61\xe5\xd4", 4))
70 S390_lowcore.machine_flags |= MACHINE_FLAG_VM; 70 S390_lowcore.machine_flags |= MACHINE_FLAG_VM;
71} 71}
72 72
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 72dd23ef771b..7ed90a759135 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -1006,6 +1006,8 @@ void __init setup_arch(char **cmdline_p)
1006 pr_info("Linux is running under KVM in 64-bit mode\n"); 1006 pr_info("Linux is running under KVM in 64-bit mode\n");
1007 else if (MACHINE_IS_LPAR) 1007 else if (MACHINE_IS_LPAR)
1008 pr_info("Linux is running natively in 64-bit mode\n"); 1008 pr_info("Linux is running natively in 64-bit mode\n");
1009 else
1010 pr_info("Linux is running as a guest in 64-bit mode\n");
1009 1011
1010 /* Have one command line that is parsed and saved in /proc/cmdline */ 1012 /* Have one command line that is parsed and saved in /proc/cmdline */
1011 /* boot_command_line has been already set up in early.c */ 1013 /* boot_command_line has been already set up in early.c */
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index f82b3d3c36e2..b198ece2aad6 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -381,8 +381,13 @@ void smp_call_online_cpu(void (*func)(void *), void *data)
381 */ 381 */
382void smp_call_ipl_cpu(void (*func)(void *), void *data) 382void smp_call_ipl_cpu(void (*func)(void *), void *data)
383{ 383{
384 struct lowcore *lc = pcpu_devices->lowcore;
385
386 if (pcpu_devices[0].address == stap())
387 lc = &S390_lowcore;
388
384 pcpu_delegate(&pcpu_devices[0], func, data, 389 pcpu_delegate(&pcpu_devices[0], func, data,
385 pcpu_devices->lowcore->nodat_stack); 390 lc->nodat_stack);
386} 391}
387 392
388int smp_find_processor_id(u16 address) 393int smp_find_processor_id(u16 address)
@@ -1166,7 +1171,11 @@ static ssize_t __ref rescan_store(struct device *dev,
1166{ 1171{
1167 int rc; 1172 int rc;
1168 1173
1174 rc = lock_device_hotplug_sysfs();
1175 if (rc)
1176 return rc;
1169 rc = smp_rescan_cpus(); 1177 rc = smp_rescan_cpus();
1178 unlock_device_hotplug();
1170 return rc ? rc : count; 1179 return rc ? rc : count;
1171} 1180}
1172static DEVICE_ATTR_WO(rescan); 1181static DEVICE_ATTR_WO(rescan);
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index ebe748a9f472..4ff354887db4 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -224,10 +224,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
224 224
225 vdso_pages = vdso64_pages; 225 vdso_pages = vdso64_pages;
226#ifdef CONFIG_COMPAT 226#ifdef CONFIG_COMPAT
227 if (is_compat_task()) { 227 mm->context.compat_mm = is_compat_task();
228 if (mm->context.compat_mm)
228 vdso_pages = vdso32_pages; 229 vdso_pages = vdso32_pages;
229 mm->context.compat_mm = 1;
230 }
231#endif 230#endif
232 /* 231 /*
233 * vDSO has a problem and was disabled, just don't "enable" it for 232 * vDSO has a problem and was disabled, just don't "enable" it for
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index ba4bfb7f6a36..5c93a65ee1e5 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -457,6 +457,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
457#else 457#else
458 u64 ipi_bitmap = 0; 458 u64 ipi_bitmap = 0;
459#endif 459#endif
460 long ret;
460 461
461 if (cpumask_empty(mask)) 462 if (cpumask_empty(mask))
462 return; 463 return;
@@ -482,8 +483,9 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
482 } else if (apic_id < min + KVM_IPI_CLUSTER_SIZE) { 483 } else if (apic_id < min + KVM_IPI_CLUSTER_SIZE) {
483 max = apic_id < max ? max : apic_id; 484 max = apic_id < max ? max : apic_id;
484 } else { 485 } else {
485 kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap, 486 ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
486 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr); 487 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr);
488 WARN_ONCE(ret < 0, "KVM: failed to send PV IPI: %ld", ret);
487 min = max = apic_id; 489 min = max = apic_id;
488 ipi_bitmap = 0; 490 ipi_bitmap = 0;
489 } 491 }
@@ -491,8 +493,9 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
491 } 493 }
492 494
493 if (ipi_bitmap) { 495 if (ipi_bitmap) {
494 kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap, 496 ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
495 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr); 497 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr);
498 WARN_ONCE(ret < 0, "KVM: failed to send PV IPI: %ld", ret);
496 } 499 }
497 500
498 local_irq_restore(flags); 501 local_irq_restore(flags);
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 69b3a7c30013..31ecf7a76d5a 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -2,10 +2,6 @@
2 2
3ccflags-y += -Iarch/x86/kvm 3ccflags-y += -Iarch/x86/kvm
4 4
5CFLAGS_x86.o := -I.
6CFLAGS_svm.o := -I.
7CFLAGS_vmx.o := -I.
8
9KVM := ../../../virt/kvm 5KVM := ../../../virt/kvm
10 6
11kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ 7kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c90a5352d158..89d20ed1d2e8 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1636,7 +1636,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
1636 ret = kvm_hvcall_signal_event(vcpu, fast, ingpa); 1636 ret = kvm_hvcall_signal_event(vcpu, fast, ingpa);
1637 if (ret != HV_STATUS_INVALID_PORT_ID) 1637 if (ret != HV_STATUS_INVALID_PORT_ID)
1638 break; 1638 break;
1639 /* maybe userspace knows this conn_id: fall through */ 1639 /* fall through - maybe userspace knows this conn_id. */
1640 case HVCALL_POST_MESSAGE: 1640 case HVCALL_POST_MESSAGE:
1641 /* don't bother userspace if it has no way to handle it */ 1641 /* don't bother userspace if it has no way to handle it */
1642 if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) { 1642 if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) {
@@ -1832,7 +1832,6 @@ int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
1832 ent->eax |= HV_X64_MSR_VP_INDEX_AVAILABLE; 1832 ent->eax |= HV_X64_MSR_VP_INDEX_AVAILABLE;
1833 ent->eax |= HV_X64_MSR_RESET_AVAILABLE; 1833 ent->eax |= HV_X64_MSR_RESET_AVAILABLE;
1834 ent->eax |= HV_MSR_REFERENCE_TSC_AVAILABLE; 1834 ent->eax |= HV_MSR_REFERENCE_TSC_AVAILABLE;
1835 ent->eax |= HV_X64_MSR_GUEST_IDLE_AVAILABLE;
1836 ent->eax |= HV_X64_ACCESS_FREQUENCY_MSRS; 1835 ent->eax |= HV_X64_ACCESS_FREQUENCY_MSRS;
1837 ent->eax |= HV_X64_ACCESS_REENLIGHTENMENT; 1836 ent->eax |= HV_X64_ACCESS_REENLIGHTENMENT;
1838 1837
@@ -1848,11 +1847,11 @@ int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
1848 case HYPERV_CPUID_ENLIGHTMENT_INFO: 1847 case HYPERV_CPUID_ENLIGHTMENT_INFO:
1849 ent->eax |= HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED; 1848 ent->eax |= HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED;
1850 ent->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; 1849 ent->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
1851 ent->eax |= HV_X64_SYSTEM_RESET_RECOMMENDED;
1852 ent->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; 1850 ent->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
1853 ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED; 1851 ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED;
1854 ent->eax |= HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED; 1852 ent->eax |= HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED;
1855 ent->eax |= HV_X64_ENLIGHTENED_VMCS_RECOMMENDED; 1853 if (evmcs_ver)
1854 ent->eax |= HV_X64_ENLIGHTENED_VMCS_RECOMMENDED;
1856 1855
1857 /* 1856 /*
1858 * Default number of spinlock retry attempts, matches 1857 * Default number of spinlock retry attempts, matches
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 9f089e2e09d0..4b6c2da7265c 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1035,6 +1035,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
1035 switch (delivery_mode) { 1035 switch (delivery_mode) {
1036 case APIC_DM_LOWEST: 1036 case APIC_DM_LOWEST:
1037 vcpu->arch.apic_arb_prio++; 1037 vcpu->arch.apic_arb_prio++;
1038 /* fall through */
1038 case APIC_DM_FIXED: 1039 case APIC_DM_FIXED:
1039 if (unlikely(trig_mode && !level)) 1040 if (unlikely(trig_mode && !level))
1040 break; 1041 break;
@@ -1874,6 +1875,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1874 1875
1875 case APIC_LVT0: 1876 case APIC_LVT0:
1876 apic_manage_nmi_watchdog(apic, val); 1877 apic_manage_nmi_watchdog(apic, val);
1878 /* fall through */
1877 case APIC_LVTTHMR: 1879 case APIC_LVTTHMR:
1878 case APIC_LVTPC: 1880 case APIC_LVTPC:
1879 case APIC_LVT1: 1881 case APIC_LVT1:
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ce770b446238..da9c42349b1f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4371,6 +4371,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
4371 rsvd_bits(maxphyaddr, 51); 4371 rsvd_bits(maxphyaddr, 51);
4372 rsvd_check->rsvd_bits_mask[1][4] = 4372 rsvd_check->rsvd_bits_mask[1][4] =
4373 rsvd_check->rsvd_bits_mask[0][4]; 4373 rsvd_check->rsvd_bits_mask[0][4];
4374 /* fall through */
4374 case PT64_ROOT_4LEVEL: 4375 case PT64_ROOT_4LEVEL:
4375 rsvd_check->rsvd_bits_mask[0][3] = exb_bit_rsvd | 4376 rsvd_check->rsvd_bits_mask[0][3] = exb_bit_rsvd |
4376 nonleaf_bit8_rsvd | rsvd_bits(7, 7) | 4377 nonleaf_bit8_rsvd | rsvd_bits(7, 7) |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a157ca5b6869..f13a3a24d360 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3414,6 +3414,14 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
3414 kvm_mmu_reset_context(&svm->vcpu); 3414 kvm_mmu_reset_context(&svm->vcpu);
3415 kvm_mmu_load(&svm->vcpu); 3415 kvm_mmu_load(&svm->vcpu);
3416 3416
3417 /*
3418 * Drop what we picked up for L2 via svm_complete_interrupts() so it
3419 * doesn't end up in L1.
3420 */
3421 svm->vcpu.arch.nmi_injected = false;
3422 kvm_clear_exception_queue(&svm->vcpu);
3423 kvm_clear_interrupt_queue(&svm->vcpu);
3424
3417 return 0; 3425 return 0;
3418} 3426}
3419 3427
@@ -4395,7 +4403,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
4395 case MSR_IA32_APICBASE: 4403 case MSR_IA32_APICBASE:
4396 if (kvm_vcpu_apicv_active(vcpu)) 4404 if (kvm_vcpu_apicv_active(vcpu))
4397 avic_update_vapic_bar(to_svm(vcpu), data); 4405 avic_update_vapic_bar(to_svm(vcpu), data);
4398 /* Follow through */ 4406 /* Fall through */
4399 default: 4407 default:
4400 return kvm_set_msr_common(vcpu, msr); 4408 return kvm_set_msr_common(vcpu, msr);
4401 } 4409 }
@@ -4504,28 +4512,19 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm)
4504 kvm_lapic_reg_write(apic, APIC_ICR, icrl); 4512 kvm_lapic_reg_write(apic, APIC_ICR, icrl);
4505 break; 4513 break;
4506 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: { 4514 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: {
4507 int i;
4508 struct kvm_vcpu *vcpu;
4509 struct kvm *kvm = svm->vcpu.kvm;
4510 struct kvm_lapic *apic = svm->vcpu.arch.apic; 4515 struct kvm_lapic *apic = svm->vcpu.arch.apic;
4511 4516
4512 /* 4517 /*
4513 * At this point, we expect that the AVIC HW has already 4518 * Update ICR high and low, then emulate sending IPI,
4514 * set the appropriate IRR bits on the valid target 4519 * which is handled when writing APIC_ICR.
4515 * vcpus. So, we just need to kick the appropriate vcpu.
4516 */ 4520 */
4517 kvm_for_each_vcpu(i, vcpu, kvm) { 4521 kvm_lapic_reg_write(apic, APIC_ICR2, icrh);
4518 bool m = kvm_apic_match_dest(vcpu, apic, 4522 kvm_lapic_reg_write(apic, APIC_ICR, icrl);
4519 icrl & KVM_APIC_SHORT_MASK,
4520 GET_APIC_DEST_FIELD(icrh),
4521 icrl & KVM_APIC_DEST_MASK);
4522
4523 if (m && !avic_vcpu_is_running(vcpu))
4524 kvm_vcpu_wake_up(vcpu);
4525 }
4526 break; 4523 break;
4527 } 4524 }
4528 case AVIC_IPI_FAILURE_INVALID_TARGET: 4525 case AVIC_IPI_FAILURE_INVALID_TARGET:
4526 WARN_ONCE(1, "Invalid IPI target: index=%u, vcpu=%d, icr=%#0x:%#0x\n",
4527 index, svm->vcpu.vcpu_id, icrh, icrl);
4529 break; 4528 break;
4530 case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE: 4529 case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE:
4531 WARN_ONCE(1, "Invalid backing page\n"); 4530 WARN_ONCE(1, "Invalid backing page\n");
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 705f40ae2532..6432d08c7de7 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1465,7 +1465,7 @@ TRACE_EVENT(kvm_hv_send_ipi_ex,
1465#endif /* _TRACE_KVM_H */ 1465#endif /* _TRACE_KVM_H */
1466 1466
1467#undef TRACE_INCLUDE_PATH 1467#undef TRACE_INCLUDE_PATH
1468#define TRACE_INCLUDE_PATH arch/x86/kvm 1468#define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1469#undef TRACE_INCLUDE_FILE 1469#undef TRACE_INCLUDE_FILE
1470#define TRACE_INCLUDE_FILE trace 1470#define TRACE_INCLUDE_FILE trace
1471 1471
diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c
index 95bc2247478d..5466c6d85cf3 100644
--- a/arch/x86/kvm/vmx/evmcs.c
+++ b/arch/x86/kvm/vmx/evmcs.c
@@ -332,16 +332,17 @@ int nested_enable_evmcs(struct kvm_vcpu *vcpu,
332 uint16_t *vmcs_version) 332 uint16_t *vmcs_version)
333{ 333{
334 struct vcpu_vmx *vmx = to_vmx(vcpu); 334 struct vcpu_vmx *vmx = to_vmx(vcpu);
335 bool evmcs_already_enabled = vmx->nested.enlightened_vmcs_enabled;
336
337 vmx->nested.enlightened_vmcs_enabled = true;
335 338
336 if (vmcs_version) 339 if (vmcs_version)
337 *vmcs_version = nested_get_evmcs_version(vcpu); 340 *vmcs_version = nested_get_evmcs_version(vcpu);
338 341
339 /* We don't support disabling the feature for simplicity. */ 342 /* We don't support disabling the feature for simplicity. */
340 if (vmx->nested.enlightened_vmcs_enabled) 343 if (evmcs_already_enabled)
341 return 0; 344 return 0;
342 345
343 vmx->nested.enlightened_vmcs_enabled = true;
344
345 vmx->nested.msrs.pinbased_ctls_high &= ~EVMCS1_UNSUPPORTED_PINCTRL; 346 vmx->nested.msrs.pinbased_ctls_high &= ~EVMCS1_UNSUPPORTED_PINCTRL;
346 vmx->nested.msrs.entry_ctls_high &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL; 347 vmx->nested.msrs.entry_ctls_high &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL;
347 vmx->nested.msrs.exit_ctls_high &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL; 348 vmx->nested.msrs.exit_ctls_high &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL;
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 2616bd2c7f2c..8ff20523661b 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -55,7 +55,7 @@ static u16 shadow_read_write_fields[] = {
55static int max_shadow_read_write_fields = 55static int max_shadow_read_write_fields =
56 ARRAY_SIZE(shadow_read_write_fields); 56 ARRAY_SIZE(shadow_read_write_fields);
57 57
58void init_vmcs_shadow_fields(void) 58static void init_vmcs_shadow_fields(void)
59{ 59{
60 int i, j; 60 int i, j;
61 61
@@ -4140,11 +4140,11 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
4140 if (r < 0) 4140 if (r < 0)
4141 goto out_vmcs02; 4141 goto out_vmcs02;
4142 4142
4143 vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); 4143 vmx->nested.cached_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL);
4144 if (!vmx->nested.cached_vmcs12) 4144 if (!vmx->nested.cached_vmcs12)
4145 goto out_cached_vmcs12; 4145 goto out_cached_vmcs12;
4146 4146
4147 vmx->nested.cached_shadow_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); 4147 vmx->nested.cached_shadow_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL);
4148 if (!vmx->nested.cached_shadow_vmcs12) 4148 if (!vmx->nested.cached_shadow_vmcs12)
4149 goto out_cached_shadow_vmcs12; 4149 goto out_cached_shadow_vmcs12;
4150 4150
@@ -5263,13 +5263,17 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
5263 copy_shadow_to_vmcs12(vmx); 5263 copy_shadow_to_vmcs12(vmx);
5264 } 5264 }
5265 5265
5266 if (copy_to_user(user_kvm_nested_state->data, vmcs12, sizeof(*vmcs12))) 5266 /*
5267 * Copy over the full allocated size of vmcs12 rather than just the size
5268 * of the struct.
5269 */
5270 if (copy_to_user(user_kvm_nested_state->data, vmcs12, VMCS12_SIZE))
5267 return -EFAULT; 5271 return -EFAULT;
5268 5272
5269 if (nested_cpu_has_shadow_vmcs(vmcs12) && 5273 if (nested_cpu_has_shadow_vmcs(vmcs12) &&
5270 vmcs12->vmcs_link_pointer != -1ull) { 5274 vmcs12->vmcs_link_pointer != -1ull) {
5271 if (copy_to_user(user_kvm_nested_state->data + VMCS12_SIZE, 5275 if (copy_to_user(user_kvm_nested_state->data + VMCS12_SIZE,
5272 get_shadow_vmcs12(vcpu), sizeof(*vmcs12))) 5276 get_shadow_vmcs12(vcpu), VMCS12_SIZE))
5273 return -EFAULT; 5277 return -EFAULT;
5274 } 5278 }
5275 5279
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index f6915f10e584..4341175339f3 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -423,7 +423,7 @@ static void check_ept_pointer_match(struct kvm *kvm)
423 to_kvm_vmx(kvm)->ept_pointers_match = EPT_POINTERS_MATCH; 423 to_kvm_vmx(kvm)->ept_pointers_match = EPT_POINTERS_MATCH;
424} 424}
425 425
426int kvm_fill_hv_flush_list_func(struct hv_guest_mapping_flush_list *flush, 426static int kvm_fill_hv_flush_list_func(struct hv_guest_mapping_flush_list *flush,
427 void *data) 427 void *data)
428{ 428{
429 struct kvm_tlb_range *range = data; 429 struct kvm_tlb_range *range = data;
@@ -1773,7 +1773,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
1773 if (!msr_info->host_initiated && 1773 if (!msr_info->host_initiated &&
1774 !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) 1774 !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
1775 return 1; 1775 return 1;
1776 /* Otherwise falls through */ 1776 /* Else, falls through */
1777 default: 1777 default:
1778 msr = find_msr_entry(vmx, msr_info->index); 1778 msr = find_msr_entry(vmx, msr_info->index);
1779 if (msr) { 1779 if (msr) {
@@ -2014,7 +2014,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
2014 /* Check reserved bit, higher 32 bits should be zero */ 2014 /* Check reserved bit, higher 32 bits should be zero */
2015 if ((data >> 32) != 0) 2015 if ((data >> 32) != 0)
2016 return 1; 2016 return 1;
2017 /* Otherwise falls through */ 2017 /* Else, falls through */
2018 default: 2018 default:
2019 msr = find_msr_entry(vmx, msr_index); 2019 msr = find_msr_entry(vmx, msr_index);
2020 if (msr) { 2020 if (msr) {
@@ -2344,7 +2344,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
2344 case 37: /* AAT100 */ 2344 case 37: /* AAT100 */
2345 case 44: /* BC86,AAY89,BD102 */ 2345 case 44: /* BC86,AAY89,BD102 */
2346 case 46: /* BA97 */ 2346 case 46: /* BA97 */
2347 _vmexit_control &= ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL; 2347 _vmentry_control &= ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
2348 _vmexit_control &= ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL; 2348 _vmexit_control &= ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
2349 pr_warn_once("kvm: VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL " 2349 pr_warn_once("kvm: VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL "
2350 "does not work properly. Using workaround\n"); 2350 "does not work properly. Using workaround\n");
@@ -6362,72 +6362,9 @@ static void vmx_update_hv_timer(struct kvm_vcpu *vcpu)
6362 vmx->loaded_vmcs->hv_timer_armed = false; 6362 vmx->loaded_vmcs->hv_timer_armed = false;
6363} 6363}
6364 6364
6365static void vmx_vcpu_run(struct kvm_vcpu *vcpu) 6365static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
6366{ 6366{
6367 struct vcpu_vmx *vmx = to_vmx(vcpu); 6367 unsigned long evmcs_rsp;
6368 unsigned long cr3, cr4, evmcs_rsp;
6369
6370 /* Record the guest's net vcpu time for enforced NMI injections. */
6371 if (unlikely(!enable_vnmi &&
6372 vmx->loaded_vmcs->soft_vnmi_blocked))
6373 vmx->loaded_vmcs->entry_time = ktime_get();
6374
6375 /* Don't enter VMX if guest state is invalid, let the exit handler
6376 start emulation until we arrive back to a valid state */
6377 if (vmx->emulation_required)
6378 return;
6379
6380 if (vmx->ple_window_dirty) {
6381 vmx->ple_window_dirty = false;
6382 vmcs_write32(PLE_WINDOW, vmx->ple_window);
6383 }
6384
6385 if (vmx->nested.need_vmcs12_sync)
6386 nested_sync_from_vmcs12(vcpu);
6387
6388 if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty))
6389 vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]);
6390 if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty))
6391 vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]);
6392
6393 cr3 = __get_current_cr3_fast();
6394 if (unlikely(cr3 != vmx->loaded_vmcs->host_state.cr3)) {
6395 vmcs_writel(HOST_CR3, cr3);
6396 vmx->loaded_vmcs->host_state.cr3 = cr3;
6397 }
6398
6399 cr4 = cr4_read_shadow();
6400 if (unlikely(cr4 != vmx->loaded_vmcs->host_state.cr4)) {
6401 vmcs_writel(HOST_CR4, cr4);
6402 vmx->loaded_vmcs->host_state.cr4 = cr4;
6403 }
6404
6405 /* When single-stepping over STI and MOV SS, we must clear the
6406 * corresponding interruptibility bits in the guest state. Otherwise
6407 * vmentry fails as it then expects bit 14 (BS) in pending debug
6408 * exceptions being set, but that's not correct for the guest debugging
6409 * case. */
6410 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
6411 vmx_set_interrupt_shadow(vcpu, 0);
6412
6413 if (static_cpu_has(X86_FEATURE_PKU) &&
6414 kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
6415 vcpu->arch.pkru != vmx->host_pkru)
6416 __write_pkru(vcpu->arch.pkru);
6417
6418 pt_guest_enter(vmx);
6419
6420 atomic_switch_perf_msrs(vmx);
6421
6422 vmx_update_hv_timer(vcpu);
6423
6424 /*
6425 * If this vCPU has touched SPEC_CTRL, restore the guest's value if
6426 * it's non-zero. Since vmentry is serialising on affected CPUs, there
6427 * is no need to worry about the conditional branch over the wrmsr
6428 * being speculatively taken.
6429 */
6430 x86_spec_ctrl_set_guest(vmx->spec_ctrl, 0);
6431 6368
6432 vmx->__launched = vmx->loaded_vmcs->launched; 6369 vmx->__launched = vmx->loaded_vmcs->launched;
6433 6370
@@ -6567,6 +6504,77 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
6567 , "eax", "ebx", "edi" 6504 , "eax", "ebx", "edi"
6568#endif 6505#endif
6569 ); 6506 );
6507}
6508STACK_FRAME_NON_STANDARD(__vmx_vcpu_run);
6509
6510static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
6511{
6512 struct vcpu_vmx *vmx = to_vmx(vcpu);
6513 unsigned long cr3, cr4;
6514
6515 /* Record the guest's net vcpu time for enforced NMI injections. */
6516 if (unlikely(!enable_vnmi &&
6517 vmx->loaded_vmcs->soft_vnmi_blocked))
6518 vmx->loaded_vmcs->entry_time = ktime_get();
6519
6520 /* Don't enter VMX if guest state is invalid, let the exit handler
6521 start emulation until we arrive back to a valid state */
6522 if (vmx->emulation_required)
6523 return;
6524
6525 if (vmx->ple_window_dirty) {
6526 vmx->ple_window_dirty = false;
6527 vmcs_write32(PLE_WINDOW, vmx->ple_window);
6528 }
6529
6530 if (vmx->nested.need_vmcs12_sync)
6531 nested_sync_from_vmcs12(vcpu);
6532
6533 if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty))
6534 vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]);
6535 if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty))
6536 vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]);
6537
6538 cr3 = __get_current_cr3_fast();
6539 if (unlikely(cr3 != vmx->loaded_vmcs->host_state.cr3)) {
6540 vmcs_writel(HOST_CR3, cr3);
6541 vmx->loaded_vmcs->host_state.cr3 = cr3;
6542 }
6543
6544 cr4 = cr4_read_shadow();
6545 if (unlikely(cr4 != vmx->loaded_vmcs->host_state.cr4)) {
6546 vmcs_writel(HOST_CR4, cr4);
6547 vmx->loaded_vmcs->host_state.cr4 = cr4;
6548 }
6549
6550 /* When single-stepping over STI and MOV SS, we must clear the
6551 * corresponding interruptibility bits in the guest state. Otherwise
6552 * vmentry fails as it then expects bit 14 (BS) in pending debug
6553 * exceptions being set, but that's not correct for the guest debugging
6554 * case. */
6555 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
6556 vmx_set_interrupt_shadow(vcpu, 0);
6557
6558 if (static_cpu_has(X86_FEATURE_PKU) &&
6559 kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
6560 vcpu->arch.pkru != vmx->host_pkru)
6561 __write_pkru(vcpu->arch.pkru);
6562
6563 pt_guest_enter(vmx);
6564
6565 atomic_switch_perf_msrs(vmx);
6566
6567 vmx_update_hv_timer(vcpu);
6568
6569 /*
6570 * If this vCPU has touched SPEC_CTRL, restore the guest's value if
6571 * it's non-zero. Since vmentry is serialising on affected CPUs, there
6572 * is no need to worry about the conditional branch over the wrmsr
6573 * being speculatively taken.
6574 */
6575 x86_spec_ctrl_set_guest(vmx->spec_ctrl, 0);
6576
6577 __vmx_vcpu_run(vcpu, vmx);
6570 6578
6571 /* 6579 /*
6572 * We do not use IBRS in the kernel. If this vCPU has used the 6580 * We do not use IBRS in the kernel. If this vCPU has used the
@@ -6648,7 +6656,6 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
6648 vmx_recover_nmi_blocking(vmx); 6656 vmx_recover_nmi_blocking(vmx);
6649 vmx_complete_interrupts(vmx); 6657 vmx_complete_interrupts(vmx);
6650} 6658}
6651STACK_FRAME_NON_STANDARD(vmx_vcpu_run);
6652 6659
6653static struct kvm *vmx_vm_alloc(void) 6660static struct kvm *vmx_vm_alloc(void)
6654{ 6661{
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 02c8e095a239..3d27206f6c01 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3834,6 +3834,8 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
3834 case KVM_CAP_HYPERV_SYNIC2: 3834 case KVM_CAP_HYPERV_SYNIC2:
3835 if (cap->args[0]) 3835 if (cap->args[0])
3836 return -EINVAL; 3836 return -EINVAL;
3837 /* fall through */
3838
3837 case KVM_CAP_HYPERV_SYNIC: 3839 case KVM_CAP_HYPERV_SYNIC:
3838 if (!irqchip_in_kernel(vcpu->kvm)) 3840 if (!irqchip_in_kernel(vcpu->kvm))
3839 return -EINVAL; 3841 return -EINVAL;
@@ -6480,8 +6482,7 @@ restart:
6480 toggle_interruptibility(vcpu, ctxt->interruptibility); 6482 toggle_interruptibility(vcpu, ctxt->interruptibility);
6481 vcpu->arch.emulate_regs_need_sync_to_vcpu = false; 6483 vcpu->arch.emulate_regs_need_sync_to_vcpu = false;
6482 kvm_rip_write(vcpu, ctxt->eip); 6484 kvm_rip_write(vcpu, ctxt->eip);
6483 if (r == EMULATE_DONE && 6485 if (r == EMULATE_DONE && ctxt->tf)
6484 (ctxt->tf || (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)))
6485 kvm_vcpu_do_singlestep(vcpu, &r); 6486 kvm_vcpu_do_singlestep(vcpu, &r);
6486 if (!ctxt->have_exception || 6487 if (!ctxt->have_exception ||
6487 exception_type(ctxt->exception.vector) == EXCPT_TRAP) 6488 exception_type(ctxt->exception.vector) == EXCPT_TRAP)
@@ -7093,10 +7094,10 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
7093 case KVM_HC_CLOCK_PAIRING: 7094 case KVM_HC_CLOCK_PAIRING:
7094 ret = kvm_pv_clock_pairing(vcpu, a0, a1); 7095 ret = kvm_pv_clock_pairing(vcpu, a0, a1);
7095 break; 7096 break;
7097#endif
7096 case KVM_HC_SEND_IPI: 7098 case KVM_HC_SEND_IPI:
7097 ret = kvm_pv_send_ipi(vcpu->kvm, a0, a1, a2, a3, op_64_bit); 7099 ret = kvm_pv_send_ipi(vcpu->kvm, a0, a1, a2, a3, op_64_bit);
7098 break; 7100 break;
7099#endif
7100 default: 7101 default:
7101 ret = -KVM_ENOSYS; 7102 ret = -KVM_ENOSYS;
7102 break; 7103 break;
@@ -7937,6 +7938,7 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
7937 vcpu->arch.pv.pv_unhalted = false; 7938 vcpu->arch.pv.pv_unhalted = false;
7938 vcpu->arch.mp_state = 7939 vcpu->arch.mp_state =
7939 KVM_MP_STATE_RUNNABLE; 7940 KVM_MP_STATE_RUNNABLE;
7941 /* fall through */
7940 case KVM_MP_STATE_RUNNABLE: 7942 case KVM_MP_STATE_RUNNABLE:
7941 vcpu->arch.apf.halted = false; 7943 vcpu->arch.apf.halted = false;
7942 break; 7944 break;
diff --git a/block/blk-core.c b/block/blk-core.c
index 3c5f61ceeb67..1ccec27d20c3 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1083,7 +1083,18 @@ blk_qc_t generic_make_request(struct bio *bio)
1083 /* Create a fresh bio_list for all subordinate requests */ 1083 /* Create a fresh bio_list for all subordinate requests */
1084 bio_list_on_stack[1] = bio_list_on_stack[0]; 1084 bio_list_on_stack[1] = bio_list_on_stack[0];
1085 bio_list_init(&bio_list_on_stack[0]); 1085 bio_list_init(&bio_list_on_stack[0]);
1086
1087 /*
1088 * Since we're recursing into make_request here, ensure
1089 * that we mark this bio as already having entered the queue.
1090 * If not, and the queue is going away, we can get stuck
1091 * forever on waiting for the queue reference to drop. But
1092 * that will never happen, as we're already holding a
1093 * reference to it.
1094 */
1095 bio_set_flag(bio, BIO_QUEUE_ENTERED);
1086 ret = q->make_request_fn(q, bio); 1096 ret = q->make_request_fn(q, bio);
1097 bio_clear_flag(bio, BIO_QUEUE_ENTERED);
1087 1098
1088 /* sort new bios into those for a lower level 1099 /* sort new bios into those for a lower level
1089 * and those for the same level 1100 * and those for the same level
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 71e9ac03f621..d79a22f111d1 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -272,16 +272,6 @@ void blk_queue_split(struct request_queue *q, struct bio **bio)
272 /* there isn't chance to merge the splitted bio */ 272 /* there isn't chance to merge the splitted bio */
273 split->bi_opf |= REQ_NOMERGE; 273 split->bi_opf |= REQ_NOMERGE;
274 274
275 /*
276 * Since we're recursing into make_request here, ensure
277 * that we mark this bio as already having entered the queue.
278 * If not, and the queue is going away, we can get stuck
279 * forever on waiting for the queue reference to drop. But
280 * that will never happen, as we're already holding a
281 * reference to it.
282 */
283 bio_set_flag(*bio, BIO_QUEUE_ENTERED);
284
285 bio_chain(split, *bio); 275 bio_chain(split, *bio);
286 trace_block_split(q, split, (*bio)->bi_iter.bi_sector); 276 trace_block_split(q, split, (*bio)->bi_iter.bi_sector);
287 generic_make_request(*bio); 277 generic_make_request(*bio);
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 90d68760af08..f8120832ca7b 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -308,8 +308,9 @@ static const char *const cmd_flag_name[] = {
308 CMD_FLAG_NAME(PREFLUSH), 308 CMD_FLAG_NAME(PREFLUSH),
309 CMD_FLAG_NAME(RAHEAD), 309 CMD_FLAG_NAME(RAHEAD),
310 CMD_FLAG_NAME(BACKGROUND), 310 CMD_FLAG_NAME(BACKGROUND),
311 CMD_FLAG_NAME(NOUNMAP),
312 CMD_FLAG_NAME(NOWAIT), 311 CMD_FLAG_NAME(NOWAIT),
312 CMD_FLAG_NAME(NOUNMAP),
313 CMD_FLAG_NAME(HIPRI),
313}; 314};
314#undef CMD_FLAG_NAME 315#undef CMD_FLAG_NAME
315 316
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index f0c56649775f..fd166fbb0f65 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -597,7 +597,7 @@ static void wbt_track(struct rq_qos *rqos, struct request *rq, struct bio *bio)
597 rq->wbt_flags |= bio_to_wbt_flags(rwb, bio); 597 rq->wbt_flags |= bio_to_wbt_flags(rwb, bio);
598} 598}
599 599
600void wbt_issue(struct rq_qos *rqos, struct request *rq) 600static void wbt_issue(struct rq_qos *rqos, struct request *rq)
601{ 601{
602 struct rq_wb *rwb = RQWB(rqos); 602 struct rq_wb *rwb = RQWB(rqos);
603 603
@@ -617,7 +617,7 @@ void wbt_issue(struct rq_qos *rqos, struct request *rq)
617 } 617 }
618} 618}
619 619
620void wbt_requeue(struct rq_qos *rqos, struct request *rq) 620static void wbt_requeue(struct rq_qos *rqos, struct request *rq)
621{ 621{
622 struct rq_wb *rwb = RQWB(rqos); 622 struct rq_wb *rwb = RQWB(rqos);
623 if (!rwb_enabled(rwb)) 623 if (!rwb_enabled(rwb))
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 5143e11e3b0f..e18ade5d74e9 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -409,6 +409,32 @@ static bool payload_dumpable(struct nvdimm *nvdimm, unsigned int func)
409 return true; 409 return true;
410} 410}
411 411
412static int cmd_to_func(struct nfit_mem *nfit_mem, unsigned int cmd,
413 struct nd_cmd_pkg *call_pkg)
414{
415 if (call_pkg) {
416 int i;
417
418 if (nfit_mem->family != call_pkg->nd_family)
419 return -ENOTTY;
420
421 for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++)
422 if (call_pkg->nd_reserved2[i])
423 return -EINVAL;
424 return call_pkg->nd_command;
425 }
426
427 /* Linux ND commands == NVDIMM_FAMILY_INTEL function numbers */
428 if (nfit_mem->family == NVDIMM_FAMILY_INTEL)
429 return cmd;
430
431 /*
432 * Force function number validation to fail since 0 is never
433 * published as a valid function in dsm_mask.
434 */
435 return 0;
436}
437
412int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, 438int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
413 unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc) 439 unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc)
414{ 440{
@@ -422,30 +448,23 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
422 unsigned long cmd_mask, dsm_mask; 448 unsigned long cmd_mask, dsm_mask;
423 u32 offset, fw_status = 0; 449 u32 offset, fw_status = 0;
424 acpi_handle handle; 450 acpi_handle handle;
425 unsigned int func;
426 const guid_t *guid; 451 const guid_t *guid;
427 int rc, i; 452 int func, rc, i;
428 453
429 if (cmd_rc) 454 if (cmd_rc)
430 *cmd_rc = -EINVAL; 455 *cmd_rc = -EINVAL;
431 func = cmd;
432 if (cmd == ND_CMD_CALL) {
433 call_pkg = buf;
434 func = call_pkg->nd_command;
435
436 for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++)
437 if (call_pkg->nd_reserved2[i])
438 return -EINVAL;
439 }
440 456
441 if (nvdimm) { 457 if (nvdimm) {
442 struct acpi_device *adev = nfit_mem->adev; 458 struct acpi_device *adev = nfit_mem->adev;
443 459
444 if (!adev) 460 if (!adev)
445 return -ENOTTY; 461 return -ENOTTY;
446 if (call_pkg && nfit_mem->family != call_pkg->nd_family)
447 return -ENOTTY;
448 462
463 if (cmd == ND_CMD_CALL)
464 call_pkg = buf;
465 func = cmd_to_func(nfit_mem, cmd, call_pkg);
466 if (func < 0)
467 return func;
449 dimm_name = nvdimm_name(nvdimm); 468 dimm_name = nvdimm_name(nvdimm);
450 cmd_name = nvdimm_cmd_name(cmd); 469 cmd_name = nvdimm_cmd_name(cmd);
451 cmd_mask = nvdimm_cmd_mask(nvdimm); 470 cmd_mask = nvdimm_cmd_mask(nvdimm);
@@ -456,6 +475,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
456 } else { 475 } else {
457 struct acpi_device *adev = to_acpi_dev(acpi_desc); 476 struct acpi_device *adev = to_acpi_dev(acpi_desc);
458 477
478 func = cmd;
459 cmd_name = nvdimm_bus_cmd_name(cmd); 479 cmd_name = nvdimm_bus_cmd_name(cmd);
460 cmd_mask = nd_desc->cmd_mask; 480 cmd_mask = nd_desc->cmd_mask;
461 dsm_mask = cmd_mask; 481 dsm_mask = cmd_mask;
@@ -470,7 +490,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
470 if (!desc || (cmd && (desc->out_num + desc->in_num == 0))) 490 if (!desc || (cmd && (desc->out_num + desc->in_num == 0)))
471 return -ENOTTY; 491 return -ENOTTY;
472 492
473 if (!test_bit(cmd, &cmd_mask) || !test_bit(func, &dsm_mask)) 493 /*
494 * Check for a valid command. For ND_CMD_CALL, we also have to
495 * make sure that the DSM function is supported.
496 */
497 if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
498 return -ENOTTY;
499 else if (!test_bit(cmd, &cmd_mask))
474 return -ENOTTY; 500 return -ENOTTY;
475 501
476 in_obj.type = ACPI_TYPE_PACKAGE; 502 in_obj.type = ACPI_TYPE_PACKAGE;
@@ -1867,6 +1893,13 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
1867 return 0; 1893 return 0;
1868 } 1894 }
1869 1895
1896 /*
1897 * Function 0 is the command interrogation function, don't
1898 * export it to potential userspace use, and enable it to be
1899 * used as an error value in acpi_nfit_ctl().
1900 */
1901 dsm_mask &= ~1UL;
1902
1870 guid = to_nfit_uuid(nfit_mem->family); 1903 guid = to_nfit_uuid(nfit_mem->family);
1871 for_each_set_bit(i, &dsm_mask, BITS_PER_LONG) 1904 for_each_set_bit(i, &dsm_mask, BITS_PER_LONG)
1872 if (acpi_check_dsm(adev_dimm->handle, guid, 1905 if (acpi_check_dsm(adev_dimm->handle, guid,
@@ -2042,11 +2075,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
2042 if (!nvdimm) 2075 if (!nvdimm)
2043 continue; 2076 continue;
2044 2077
2045 rc = nvdimm_security_setup_events(nvdimm);
2046 if (rc < 0)
2047 dev_warn(acpi_desc->dev,
2048 "security event setup failed: %d\n", rc);
2049
2050 nfit_kernfs = sysfs_get_dirent(nvdimm_kobj(nvdimm)->sd, "nfit"); 2078 nfit_kernfs = sysfs_get_dirent(nvdimm_kobj(nvdimm)->sd, "nfit");
2051 if (nfit_kernfs) 2079 if (nfit_kernfs)
2052 nfit_mem->flags_attr = sysfs_get_dirent(nfit_kernfs, 2080 nfit_mem->flags_attr = sysfs_get_dirent(nfit_kernfs,
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 7496b10532aa..6a2185eb66c5 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -11,6 +11,7 @@
11#include <linux/kdev_t.h> 11#include <linux/kdev_t.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/namei.h>
14#include <linux/magic.h> 15#include <linux/magic.h>
15#include <linux/major.h> 16#include <linux/major.h>
16#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
@@ -20,6 +21,7 @@
20#include <linux/parser.h> 21#include <linux/parser.h>
21#include <linux/radix-tree.h> 22#include <linux/radix-tree.h>
22#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/seq_file.h>
23#include <linux/slab.h> 25#include <linux/slab.h>
24#include <linux/spinlock_types.h> 26#include <linux/spinlock_types.h>
25#include <linux/stddef.h> 27#include <linux/stddef.h>
@@ -30,7 +32,7 @@
30#include <linux/xarray.h> 32#include <linux/xarray.h>
31#include <uapi/asm-generic/errno-base.h> 33#include <uapi/asm-generic/errno-base.h>
32#include <uapi/linux/android/binder.h> 34#include <uapi/linux/android/binder.h>
33#include <uapi/linux/android/binder_ctl.h> 35#include <uapi/linux/android/binderfs.h>
34 36
35#include "binder_internal.h" 37#include "binder_internal.h"
36 38
@@ -39,14 +41,32 @@
39#define INODE_OFFSET 3 41#define INODE_OFFSET 3
40#define INTSTRLEN 21 42#define INTSTRLEN 21
41#define BINDERFS_MAX_MINOR (1U << MINORBITS) 43#define BINDERFS_MAX_MINOR (1U << MINORBITS)
42 44/* Ensure that the initial ipc namespace always has devices available. */
43static struct vfsmount *binderfs_mnt; 45#define BINDERFS_MAX_MINOR_CAPPED (BINDERFS_MAX_MINOR - 4)
44 46
45static dev_t binderfs_dev; 47static dev_t binderfs_dev;
46static DEFINE_MUTEX(binderfs_minors_mutex); 48static DEFINE_MUTEX(binderfs_minors_mutex);
47static DEFINE_IDA(binderfs_minors); 49static DEFINE_IDA(binderfs_minors);
48 50
49/** 51/**
52 * binderfs_mount_opts - mount options for binderfs
53 * @max: maximum number of allocatable binderfs binder devices
54 */
55struct binderfs_mount_opts {
56 int max;
57};
58
59enum {
60 Opt_max,
61 Opt_err
62};
63
64static const match_table_t tokens = {
65 { Opt_max, "max=%d" },
66 { Opt_err, NULL }
67};
68
69/**
50 * binderfs_info - information about a binderfs mount 70 * binderfs_info - information about a binderfs mount
51 * @ipc_ns: The ipc namespace the binderfs mount belongs to. 71 * @ipc_ns: The ipc namespace the binderfs mount belongs to.
52 * @control_dentry: This records the dentry of this binderfs mount 72 * @control_dentry: This records the dentry of this binderfs mount
@@ -55,13 +75,16 @@ static DEFINE_IDA(binderfs_minors);
55 * created. 75 * created.
56 * @root_gid: gid that needs to be used when a new binder device is 76 * @root_gid: gid that needs to be used when a new binder device is
57 * created. 77 * created.
78 * @mount_opts: The mount options in use.
79 * @device_count: The current number of allocated binder devices.
58 */ 80 */
59struct binderfs_info { 81struct binderfs_info {
60 struct ipc_namespace *ipc_ns; 82 struct ipc_namespace *ipc_ns;
61 struct dentry *control_dentry; 83 struct dentry *control_dentry;
62 kuid_t root_uid; 84 kuid_t root_uid;
63 kgid_t root_gid; 85 kgid_t root_gid;
64 86 struct binderfs_mount_opts mount_opts;
87 int device_count;
65}; 88};
66 89
67static inline struct binderfs_info *BINDERFS_I(const struct inode *inode) 90static inline struct binderfs_info *BINDERFS_I(const struct inode *inode)
@@ -84,7 +107,7 @@ bool is_binderfs_device(const struct inode *inode)
84 * @userp: buffer to copy information about new device for userspace to 107 * @userp: buffer to copy information about new device for userspace to
85 * @req: struct binderfs_device as copied from userspace 108 * @req: struct binderfs_device as copied from userspace
86 * 109 *
87 * This function allocated a new binder_device and reserves a new minor 110 * This function allocates a new binder_device and reserves a new minor
88 * number for it. 111 * number for it.
89 * Minor numbers are limited and tracked globally in binderfs_minors. The 112 * Minor numbers are limited and tracked globally in binderfs_minors. The
90 * function will stash a struct binder_device for the specific binder 113 * function will stash a struct binder_device for the specific binder
@@ -100,20 +123,34 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
100 struct binderfs_device *req) 123 struct binderfs_device *req)
101{ 124{
102 int minor, ret; 125 int minor, ret;
103 struct dentry *dentry, *dup, *root; 126 struct dentry *dentry, *root;
104 struct binder_device *device; 127 struct binder_device *device;
105 size_t name_len = BINDERFS_MAX_NAME + 1;
106 char *name = NULL; 128 char *name = NULL;
129 size_t name_len;
107 struct inode *inode = NULL; 130 struct inode *inode = NULL;
108 struct super_block *sb = ref_inode->i_sb; 131 struct super_block *sb = ref_inode->i_sb;
109 struct binderfs_info *info = sb->s_fs_info; 132 struct binderfs_info *info = sb->s_fs_info;
133#if defined(CONFIG_IPC_NS)
134 bool use_reserve = (info->ipc_ns == &init_ipc_ns);
135#else
136 bool use_reserve = true;
137#endif
110 138
111 /* Reserve new minor number for the new device. */ 139 /* Reserve new minor number for the new device. */
112 mutex_lock(&binderfs_minors_mutex); 140 mutex_lock(&binderfs_minors_mutex);
113 minor = ida_alloc_max(&binderfs_minors, BINDERFS_MAX_MINOR, GFP_KERNEL); 141 if (++info->device_count <= info->mount_opts.max)
114 mutex_unlock(&binderfs_minors_mutex); 142 minor = ida_alloc_max(&binderfs_minors,
115 if (minor < 0) 143 use_reserve ? BINDERFS_MAX_MINOR :
144 BINDERFS_MAX_MINOR_CAPPED,
145 GFP_KERNEL);
146 else
147 minor = -ENOSPC;
148 if (minor < 0) {
149 --info->device_count;
150 mutex_unlock(&binderfs_minors_mutex);
116 return minor; 151 return minor;
152 }
153 mutex_unlock(&binderfs_minors_mutex);
117 154
118 ret = -ENOMEM; 155 ret = -ENOMEM;
119 device = kzalloc(sizeof(*device), GFP_KERNEL); 156 device = kzalloc(sizeof(*device), GFP_KERNEL);
@@ -132,12 +169,13 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
132 inode->i_uid = info->root_uid; 169 inode->i_uid = info->root_uid;
133 inode->i_gid = info->root_gid; 170 inode->i_gid = info->root_gid;
134 171
135 name = kmalloc(name_len, GFP_KERNEL); 172 req->name[BINDERFS_MAX_NAME] = '\0'; /* NUL-terminate */
173 name_len = strlen(req->name);
174 /* Make sure to include terminating NUL byte */
175 name = kmemdup(req->name, name_len + 1, GFP_KERNEL);
136 if (!name) 176 if (!name)
137 goto err; 177 goto err;
138 178
139 strscpy(name, req->name, name_len);
140
141 device->binderfs_inode = inode; 179 device->binderfs_inode = inode;
142 device->context.binder_context_mgr_uid = INVALID_UID; 180 device->context.binder_context_mgr_uid = INVALID_UID;
143 device->context.name = name; 181 device->context.name = name;
@@ -156,28 +194,25 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
156 194
157 root = sb->s_root; 195 root = sb->s_root;
158 inode_lock(d_inode(root)); 196 inode_lock(d_inode(root));
159 dentry = d_alloc_name(root, name); 197
160 if (!dentry) { 198 /* look it up */
199 dentry = lookup_one_len(name, root, name_len);
200 if (IS_ERR(dentry)) {
161 inode_unlock(d_inode(root)); 201 inode_unlock(d_inode(root));
162 ret = -ENOMEM; 202 ret = PTR_ERR(dentry);
163 goto err; 203 goto err;
164 } 204 }
165 205
166 /* Verify that the name userspace gave us is not already in use. */ 206 if (d_really_is_positive(dentry)) {
167 dup = d_lookup(root, &dentry->d_name); 207 /* already exists */
168 if (dup) { 208 dput(dentry);
169 if (d_really_is_positive(dup)) { 209 inode_unlock(d_inode(root));
170 dput(dup); 210 ret = -EEXIST;
171 dput(dentry); 211 goto err;
172 inode_unlock(d_inode(root));
173 ret = -EEXIST;
174 goto err;
175 }
176 dput(dup);
177 } 212 }
178 213
179 inode->i_private = device; 214 inode->i_private = device;
180 d_add(dentry, inode); 215 d_instantiate(dentry, inode);
181 fsnotify_create(root->d_inode, dentry); 216 fsnotify_create(root->d_inode, dentry);
182 inode_unlock(d_inode(root)); 217 inode_unlock(d_inode(root));
183 218
@@ -187,6 +222,7 @@ err:
187 kfree(name); 222 kfree(name);
188 kfree(device); 223 kfree(device);
189 mutex_lock(&binderfs_minors_mutex); 224 mutex_lock(&binderfs_minors_mutex);
225 --info->device_count;
190 ida_free(&binderfs_minors, minor); 226 ida_free(&binderfs_minors, minor);
191 mutex_unlock(&binderfs_minors_mutex); 227 mutex_unlock(&binderfs_minors_mutex);
192 iput(inode); 228 iput(inode);
@@ -232,6 +268,7 @@ static long binder_ctl_ioctl(struct file *file, unsigned int cmd,
232static void binderfs_evict_inode(struct inode *inode) 268static void binderfs_evict_inode(struct inode *inode)
233{ 269{
234 struct binder_device *device = inode->i_private; 270 struct binder_device *device = inode->i_private;
271 struct binderfs_info *info = BINDERFS_I(inode);
235 272
236 clear_inode(inode); 273 clear_inode(inode);
237 274
@@ -239,6 +276,7 @@ static void binderfs_evict_inode(struct inode *inode)
239 return; 276 return;
240 277
241 mutex_lock(&binderfs_minors_mutex); 278 mutex_lock(&binderfs_minors_mutex);
279 --info->device_count;
242 ida_free(&binderfs_minors, device->miscdev.minor); 280 ida_free(&binderfs_minors, device->miscdev.minor);
243 mutex_unlock(&binderfs_minors_mutex); 281 mutex_unlock(&binderfs_minors_mutex);
244 282
@@ -246,43 +284,87 @@ static void binderfs_evict_inode(struct inode *inode)
246 kfree(device); 284 kfree(device);
247} 285}
248 286
287/**
288 * binderfs_parse_mount_opts - parse binderfs mount options
289 * @data: options to set (can be NULL in which case defaults are used)
290 */
291static int binderfs_parse_mount_opts(char *data,
292 struct binderfs_mount_opts *opts)
293{
294 char *p;
295 opts->max = BINDERFS_MAX_MINOR;
296
297 while ((p = strsep(&data, ",")) != NULL) {
298 substring_t args[MAX_OPT_ARGS];
299 int token;
300 int max_devices;
301
302 if (!*p)
303 continue;
304
305 token = match_token(p, tokens, args);
306 switch (token) {
307 case Opt_max:
308 if (match_int(&args[0], &max_devices) ||
309 (max_devices < 0 ||
310 (max_devices > BINDERFS_MAX_MINOR)))
311 return -EINVAL;
312
313 opts->max = max_devices;
314 break;
315 default:
316 pr_err("Invalid mount options\n");
317 return -EINVAL;
318 }
319 }
320
321 return 0;
322}
323
324static int binderfs_remount(struct super_block *sb, int *flags, char *data)
325{
326 struct binderfs_info *info = sb->s_fs_info;
327 return binderfs_parse_mount_opts(data, &info->mount_opts);
328}
329
330static int binderfs_show_mount_opts(struct seq_file *seq, struct dentry *root)
331{
332 struct binderfs_info *info;
333
334 info = root->d_sb->s_fs_info;
335 if (info->mount_opts.max <= BINDERFS_MAX_MINOR)
336 seq_printf(seq, ",max=%d", info->mount_opts.max);
337
338 return 0;
339}
340
249static const struct super_operations binderfs_super_ops = { 341static const struct super_operations binderfs_super_ops = {
250 .statfs = simple_statfs, 342 .evict_inode = binderfs_evict_inode,
251 .evict_inode = binderfs_evict_inode, 343 .remount_fs = binderfs_remount,
344 .show_options = binderfs_show_mount_opts,
345 .statfs = simple_statfs,
252}; 346};
253 347
348static inline bool is_binderfs_control_device(const struct dentry *dentry)
349{
350 struct binderfs_info *info = dentry->d_sb->s_fs_info;
351 return info->control_dentry == dentry;
352}
353
254static int binderfs_rename(struct inode *old_dir, struct dentry *old_dentry, 354static int binderfs_rename(struct inode *old_dir, struct dentry *old_dentry,
255 struct inode *new_dir, struct dentry *new_dentry, 355 struct inode *new_dir, struct dentry *new_dentry,
256 unsigned int flags) 356 unsigned int flags)
257{ 357{
258 struct inode *inode = d_inode(old_dentry); 358 if (is_binderfs_control_device(old_dentry) ||
259 359 is_binderfs_control_device(new_dentry))
260 /* binderfs doesn't support directories. */
261 if (d_is_dir(old_dentry))
262 return -EPERM; 360 return -EPERM;
263 361
264 if (flags & ~RENAME_NOREPLACE) 362 return simple_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
265 return -EINVAL;
266
267 if (!simple_empty(new_dentry))
268 return -ENOTEMPTY;
269
270 if (d_really_is_positive(new_dentry))
271 simple_unlink(new_dir, new_dentry);
272
273 old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
274 new_dir->i_mtime = inode->i_ctime = current_time(old_dir);
275
276 return 0;
277} 363}
278 364
279static int binderfs_unlink(struct inode *dir, struct dentry *dentry) 365static int binderfs_unlink(struct inode *dir, struct dentry *dentry)
280{ 366{
281 /* 367 if (is_binderfs_control_device(dentry))
282 * The control dentry is only ever touched during mount so checking it
283 * here should not require us to take lock.
284 */
285 if (BINDERFS_I(dir)->control_dentry == dentry)
286 return -EPERM; 368 return -EPERM;
287 369
288 return simple_unlink(dir, dentry); 370 return simple_unlink(dir, dentry);
@@ -318,8 +400,6 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
318 if (!device) 400 if (!device)
319 return -ENOMEM; 401 return -ENOMEM;
320 402
321 inode_lock(d_inode(root));
322
323 /* If we have already created a binder-control node, return. */ 403 /* If we have already created a binder-control node, return. */
324 if (info->control_dentry) { 404 if (info->control_dentry) {
325 ret = 0; 405 ret = 0;
@@ -358,12 +438,10 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
358 inode->i_private = device; 438 inode->i_private = device;
359 info->control_dentry = dentry; 439 info->control_dentry = dentry;
360 d_add(dentry, inode); 440 d_add(dentry, inode);
361 inode_unlock(d_inode(root));
362 441
363 return 0; 442 return 0;
364 443
365out: 444out:
366 inode_unlock(d_inode(root));
367 kfree(device); 445 kfree(device);
368 iput(inode); 446 iput(inode);
369 447
@@ -378,12 +456,9 @@ static const struct inode_operations binderfs_dir_inode_operations = {
378 456
379static int binderfs_fill_super(struct super_block *sb, void *data, int silent) 457static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
380{ 458{
459 int ret;
381 struct binderfs_info *info; 460 struct binderfs_info *info;
382 int ret = -ENOMEM;
383 struct inode *inode = NULL; 461 struct inode *inode = NULL;
384 struct ipc_namespace *ipc_ns = sb->s_fs_info;
385
386 get_ipc_ns(ipc_ns);
387 462
388 sb->s_blocksize = PAGE_SIZE; 463 sb->s_blocksize = PAGE_SIZE;
389 sb->s_blocksize_bits = PAGE_SHIFT; 464 sb->s_blocksize_bits = PAGE_SHIFT;
@@ -405,11 +480,17 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
405 sb->s_op = &binderfs_super_ops; 480 sb->s_op = &binderfs_super_ops;
406 sb->s_time_gran = 1; 481 sb->s_time_gran = 1;
407 482
408 info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL); 483 sb->s_fs_info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL);
409 if (!info) 484 if (!sb->s_fs_info)
410 goto err_without_dentry; 485 return -ENOMEM;
486 info = sb->s_fs_info;
487
488 info->ipc_ns = get_ipc_ns(current->nsproxy->ipc_ns);
489
490 ret = binderfs_parse_mount_opts(data, &info->mount_opts);
491 if (ret)
492 return ret;
411 493
412 info->ipc_ns = ipc_ns;
413 info->root_gid = make_kgid(sb->s_user_ns, 0); 494 info->root_gid = make_kgid(sb->s_user_ns, 0);
414 if (!gid_valid(info->root_gid)) 495 if (!gid_valid(info->root_gid))
415 info->root_gid = GLOBAL_ROOT_GID; 496 info->root_gid = GLOBAL_ROOT_GID;
@@ -417,11 +498,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
417 if (!uid_valid(info->root_uid)) 498 if (!uid_valid(info->root_uid))
418 info->root_uid = GLOBAL_ROOT_UID; 499 info->root_uid = GLOBAL_ROOT_UID;
419 500
420 sb->s_fs_info = info;
421
422 inode = new_inode(sb); 501 inode = new_inode(sb);
423 if (!inode) 502 if (!inode)
424 goto err_without_dentry; 503 return -ENOMEM;
425 504
426 inode->i_ino = FIRST_INODE; 505 inode->i_ino = FIRST_INODE;
427 inode->i_fop = &simple_dir_operations; 506 inode->i_fop = &simple_dir_operations;
@@ -432,79 +511,28 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
432 511
433 sb->s_root = d_make_root(inode); 512 sb->s_root = d_make_root(inode);
434 if (!sb->s_root) 513 if (!sb->s_root)
435 goto err_without_dentry; 514 return -ENOMEM;
436
437 ret = binderfs_binder_ctl_create(sb);
438 if (ret)
439 goto err_with_dentry;
440
441 return 0;
442
443err_with_dentry:
444 dput(sb->s_root);
445 sb->s_root = NULL;
446
447err_without_dentry:
448 put_ipc_ns(ipc_ns);
449 iput(inode);
450 kfree(info);
451
452 return ret;
453}
454
455static int binderfs_test_super(struct super_block *sb, void *data)
456{
457 struct binderfs_info *info = sb->s_fs_info;
458
459 if (info)
460 return info->ipc_ns == data;
461
462 return 0;
463}
464 515
465static int binderfs_set_super(struct super_block *sb, void *data) 516 return binderfs_binder_ctl_create(sb);
466{
467 sb->s_fs_info = data;
468 return set_anon_super(sb, NULL);
469} 517}
470 518
471static struct dentry *binderfs_mount(struct file_system_type *fs_type, 519static struct dentry *binderfs_mount(struct file_system_type *fs_type,
472 int flags, const char *dev_name, 520 int flags, const char *dev_name,
473 void *data) 521 void *data)
474{ 522{
475 struct super_block *sb; 523 return mount_nodev(fs_type, flags, data, binderfs_fill_super);
476 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
477
478 if (!ns_capable(ipc_ns->user_ns, CAP_SYS_ADMIN))
479 return ERR_PTR(-EPERM);
480
481 sb = sget_userns(fs_type, binderfs_test_super, binderfs_set_super,
482 flags, ipc_ns->user_ns, ipc_ns);
483 if (IS_ERR(sb))
484 return ERR_CAST(sb);
485
486 if (!sb->s_root) {
487 int ret = binderfs_fill_super(sb, data, flags & SB_SILENT ? 1 : 0);
488 if (ret) {
489 deactivate_locked_super(sb);
490 return ERR_PTR(ret);
491 }
492
493 sb->s_flags |= SB_ACTIVE;
494 }
495
496 return dget(sb->s_root);
497} 524}
498 525
499static void binderfs_kill_super(struct super_block *sb) 526static void binderfs_kill_super(struct super_block *sb)
500{ 527{
501 struct binderfs_info *info = sb->s_fs_info; 528 struct binderfs_info *info = sb->s_fs_info;
502 529
530 kill_litter_super(sb);
531
503 if (info && info->ipc_ns) 532 if (info && info->ipc_ns)
504 put_ipc_ns(info->ipc_ns); 533 put_ipc_ns(info->ipc_ns);
505 534
506 kfree(info); 535 kfree(info);
507 kill_litter_super(sb);
508} 536}
509 537
510static struct file_system_type binder_fs_type = { 538static struct file_system_type binder_fs_type = {
@@ -530,14 +558,6 @@ static int __init init_binderfs(void)
530 return ret; 558 return ret;
531 } 559 }
532 560
533 binderfs_mnt = kern_mount(&binder_fs_type);
534 if (IS_ERR(binderfs_mnt)) {
535 ret = PTR_ERR(binderfs_mnt);
536 binderfs_mnt = NULL;
537 unregister_filesystem(&binder_fs_type);
538 unregister_chrdev_region(binderfs_dev, BINDERFS_MAX_MINOR);
539 }
540
541 return ret; 561 return ret;
542} 562}
543 563
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 8cc9c429ad95..9e7fc302430f 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -915,6 +915,10 @@ static struct scsi_host_template pata_macio_sht = {
915 .sg_tablesize = MAX_DCMDS, 915 .sg_tablesize = MAX_DCMDS,
916 /* We may not need that strict one */ 916 /* We may not need that strict one */
917 .dma_boundary = ATA_DMA_BOUNDARY, 917 .dma_boundary = ATA_DMA_BOUNDARY,
918 /* Not sure what the real max is but we know it's less than 64K, let's
919 * use 64K minus 256
920 */
921 .max_segment_size = MAX_DBDMA_SEG,
918 .slave_configure = pata_macio_slave_config, 922 .slave_configure = pata_macio_slave_config,
919}; 923};
920 924
@@ -1044,11 +1048,6 @@ static int pata_macio_common_init(struct pata_macio_priv *priv,
1044 /* Make sure we have sane initial timings in the cache */ 1048 /* Make sure we have sane initial timings in the cache */
1045 pata_macio_default_timings(priv); 1049 pata_macio_default_timings(priv);
1046 1050
1047 /* Not sure what the real max is but we know it's less than 64K, let's
1048 * use 64K minus 256
1049 */
1050 dma_set_max_seg_size(priv->dev, MAX_DBDMA_SEG);
1051
1052 /* Allocate libata host for 1 port */ 1051 /* Allocate libata host for 1 port */
1053 memset(&pinfo, 0, sizeof(struct ata_port_info)); 1052 memset(&pinfo, 0, sizeof(struct ata_port_info));
1054 pmac_macio_calc_timing_masks(priv, &pinfo); 1053 pmac_macio_calc_timing_masks(priv, &pinfo);
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index e0bcf9b2dab0..174e84ce4379 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -245,8 +245,15 @@ struct inic_port_priv {
245 245
246static struct scsi_host_template inic_sht = { 246static struct scsi_host_template inic_sht = {
247 ATA_BASE_SHT(DRV_NAME), 247 ATA_BASE_SHT(DRV_NAME),
248 .sg_tablesize = LIBATA_MAX_PRD, /* maybe it can be larger? */ 248 .sg_tablesize = LIBATA_MAX_PRD, /* maybe it can be larger? */
249 .dma_boundary = INIC_DMA_BOUNDARY, 249
250 /*
251 * This controller is braindamaged. dma_boundary is 0xffff like others
252 * but it will lock up the whole machine HARD if 65536 byte PRD entry
253 * is fed. Reduce maximum segment size.
254 */
255 .dma_boundary = INIC_DMA_BOUNDARY,
256 .max_segment_size = 65536 - 512,
250}; 257};
251 258
252static const int scr_map[] = { 259static const int scr_map[] = {
@@ -868,17 +875,6 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
868 return rc; 875 return rc;
869 } 876 }
870 877
871 /*
872 * This controller is braindamaged. dma_boundary is 0xffff
873 * like others but it will lock up the whole machine HARD if
874 * 65536 byte PRD entry is fed. Reduce maximum segment size.
875 */
876 rc = dma_set_max_seg_size(&pdev->dev, 65536 - 512);
877 if (rc) {
878 dev_err(&pdev->dev, "failed to set the maximum segment size\n");
879 return rc;
880 }
881
882 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl); 878 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl);
883 if (rc) { 879 if (rc) {
884 dev_err(&pdev->dev, "failed to initialize controller\n"); 880 dev_err(&pdev->dev, "failed to initialize controller\n");
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index a74ce885b541..c518659b4d9f 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -32,6 +32,7 @@
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/uuid.h> 34#include <linux/uuid.h>
35#include <linux/nospec.h>
35 36
36#define IPMI_DRIVER_VERSION "39.2" 37#define IPMI_DRIVER_VERSION "39.2"
37 38
@@ -62,7 +63,8 @@ static void ipmi_debug_msg(const char *title, unsigned char *data,
62{ } 63{ }
63#endif 64#endif
64 65
65static int initialized; 66static bool initialized;
67static bool drvregistered;
66 68
67enum ipmi_panic_event_op { 69enum ipmi_panic_event_op {
68 IPMI_SEND_PANIC_EVENT_NONE, 70 IPMI_SEND_PANIC_EVENT_NONE,
@@ -612,7 +614,7 @@ static DEFINE_MUTEX(ipmidriver_mutex);
612 614
613static LIST_HEAD(ipmi_interfaces); 615static LIST_HEAD(ipmi_interfaces);
614static DEFINE_MUTEX(ipmi_interfaces_mutex); 616static DEFINE_MUTEX(ipmi_interfaces_mutex);
615DEFINE_STATIC_SRCU(ipmi_interfaces_srcu); 617struct srcu_struct ipmi_interfaces_srcu;
616 618
617/* 619/*
618 * List of watchers that want to know when smi's are added and deleted. 620 * List of watchers that want to know when smi's are added and deleted.
@@ -720,7 +722,15 @@ struct watcher_entry {
720int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) 722int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
721{ 723{
722 struct ipmi_smi *intf; 724 struct ipmi_smi *intf;
723 int index; 725 int index, rv;
726
727 /*
728 * Make sure the driver is actually initialized, this handles
729 * problems with initialization order.
730 */
731 rv = ipmi_init_msghandler();
732 if (rv)
733 return rv;
724 734
725 mutex_lock(&smi_watchers_mutex); 735 mutex_lock(&smi_watchers_mutex);
726 736
@@ -884,7 +894,7 @@ static int deliver_response(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)
884 894
885 if (user) { 895 if (user) {
886 user->handler->ipmi_recv_hndl(msg, user->handler_data); 896 user->handler->ipmi_recv_hndl(msg, user->handler_data);
887 release_ipmi_user(msg->user, index); 897 release_ipmi_user(user, index);
888 } else { 898 } else {
889 /* User went away, give up. */ 899 /* User went away, give up. */
890 ipmi_free_recv_msg(msg); 900 ipmi_free_recv_msg(msg);
@@ -1076,7 +1086,7 @@ int ipmi_create_user(unsigned int if_num,
1076{ 1086{
1077 unsigned long flags; 1087 unsigned long flags;
1078 struct ipmi_user *new_user; 1088 struct ipmi_user *new_user;
1079 int rv = 0, index; 1089 int rv, index;
1080 struct ipmi_smi *intf; 1090 struct ipmi_smi *intf;
1081 1091
1082 /* 1092 /*
@@ -1094,18 +1104,9 @@ int ipmi_create_user(unsigned int if_num,
1094 * Make sure the driver is actually initialized, this handles 1104 * Make sure the driver is actually initialized, this handles
1095 * problems with initialization order. 1105 * problems with initialization order.
1096 */ 1106 */
1097 if (!initialized) { 1107 rv = ipmi_init_msghandler();
1098 rv = ipmi_init_msghandler(); 1108 if (rv)
1099 if (rv) 1109 return rv;
1100 return rv;
1101
1102 /*
1103 * The init code doesn't return an error if it was turned
1104 * off, but it won't initialize. Check that.
1105 */
1106 if (!initialized)
1107 return -ENODEV;
1108 }
1109 1110
1110 new_user = kmalloc(sizeof(*new_user), GFP_KERNEL); 1111 new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
1111 if (!new_user) 1112 if (!new_user)
@@ -1183,6 +1184,7 @@ EXPORT_SYMBOL(ipmi_get_smi_info);
1183static void free_user(struct kref *ref) 1184static void free_user(struct kref *ref)
1184{ 1185{
1185 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount); 1186 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount);
1187 cleanup_srcu_struct(&user->release_barrier);
1186 kfree(user); 1188 kfree(user);
1187} 1189}
1188 1190
@@ -1259,7 +1261,6 @@ int ipmi_destroy_user(struct ipmi_user *user)
1259{ 1261{
1260 _ipmi_destroy_user(user); 1262 _ipmi_destroy_user(user);
1261 1263
1262 cleanup_srcu_struct(&user->release_barrier);
1263 kref_put(&user->refcount, free_user); 1264 kref_put(&user->refcount, free_user);
1264 1265
1265 return 0; 1266 return 0;
@@ -1298,10 +1299,12 @@ int ipmi_set_my_address(struct ipmi_user *user,
1298 if (!user) 1299 if (!user)
1299 return -ENODEV; 1300 return -ENODEV;
1300 1301
1301 if (channel >= IPMI_MAX_CHANNELS) 1302 if (channel >= IPMI_MAX_CHANNELS) {
1302 rv = -EINVAL; 1303 rv = -EINVAL;
1303 else 1304 } else {
1305 channel = array_index_nospec(channel, IPMI_MAX_CHANNELS);
1304 user->intf->addrinfo[channel].address = address; 1306 user->intf->addrinfo[channel].address = address;
1307 }
1305 release_ipmi_user(user, index); 1308 release_ipmi_user(user, index);
1306 1309
1307 return rv; 1310 return rv;
@@ -1318,10 +1321,12 @@ int ipmi_get_my_address(struct ipmi_user *user,
1318 if (!user) 1321 if (!user)
1319 return -ENODEV; 1322 return -ENODEV;
1320 1323
1321 if (channel >= IPMI_MAX_CHANNELS) 1324 if (channel >= IPMI_MAX_CHANNELS) {
1322 rv = -EINVAL; 1325 rv = -EINVAL;
1323 else 1326 } else {
1327 channel = array_index_nospec(channel, IPMI_MAX_CHANNELS);
1324 *address = user->intf->addrinfo[channel].address; 1328 *address = user->intf->addrinfo[channel].address;
1329 }
1325 release_ipmi_user(user, index); 1330 release_ipmi_user(user, index);
1326 1331
1327 return rv; 1332 return rv;
@@ -1338,10 +1343,12 @@ int ipmi_set_my_LUN(struct ipmi_user *user,
1338 if (!user) 1343 if (!user)
1339 return -ENODEV; 1344 return -ENODEV;
1340 1345
1341 if (channel >= IPMI_MAX_CHANNELS) 1346 if (channel >= IPMI_MAX_CHANNELS) {
1342 rv = -EINVAL; 1347 rv = -EINVAL;
1343 else 1348 } else {
1349 channel = array_index_nospec(channel, IPMI_MAX_CHANNELS);
1344 user->intf->addrinfo[channel].lun = LUN & 0x3; 1350 user->intf->addrinfo[channel].lun = LUN & 0x3;
1351 }
1345 release_ipmi_user(user, index); 1352 release_ipmi_user(user, index);
1346 1353
1347 return rv; 1354 return rv;
@@ -1358,10 +1365,12 @@ int ipmi_get_my_LUN(struct ipmi_user *user,
1358 if (!user) 1365 if (!user)
1359 return -ENODEV; 1366 return -ENODEV;
1360 1367
1361 if (channel >= IPMI_MAX_CHANNELS) 1368 if (channel >= IPMI_MAX_CHANNELS) {
1362 rv = -EINVAL; 1369 rv = -EINVAL;
1363 else 1370 } else {
1371 channel = array_index_nospec(channel, IPMI_MAX_CHANNELS);
1364 *address = user->intf->addrinfo[channel].lun; 1372 *address = user->intf->addrinfo[channel].lun;
1373 }
1365 release_ipmi_user(user, index); 1374 release_ipmi_user(user, index);
1366 1375
1367 return rv; 1376 return rv;
@@ -2184,6 +2193,7 @@ static int check_addr(struct ipmi_smi *intf,
2184{ 2193{
2185 if (addr->channel >= IPMI_MAX_CHANNELS) 2194 if (addr->channel >= IPMI_MAX_CHANNELS)
2186 return -EINVAL; 2195 return -EINVAL;
2196 addr->channel = array_index_nospec(addr->channel, IPMI_MAX_CHANNELS);
2187 *lun = intf->addrinfo[addr->channel].lun; 2197 *lun = intf->addrinfo[addr->channel].lun;
2188 *saddr = intf->addrinfo[addr->channel].address; 2198 *saddr = intf->addrinfo[addr->channel].address;
2189 return 0; 2199 return 0;
@@ -3291,17 +3301,9 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
3291 * Make sure the driver is actually initialized, this handles 3301 * Make sure the driver is actually initialized, this handles
3292 * problems with initialization order. 3302 * problems with initialization order.
3293 */ 3303 */
3294 if (!initialized) { 3304 rv = ipmi_init_msghandler();
3295 rv = ipmi_init_msghandler(); 3305 if (rv)
3296 if (rv) 3306 return rv;
3297 return rv;
3298 /*
3299 * The init code doesn't return an error if it was turned
3300 * off, but it won't initialize. Check that.
3301 */
3302 if (!initialized)
3303 return -ENODEV;
3304 }
3305 3307
3306 intf = kzalloc(sizeof(*intf), GFP_KERNEL); 3308 intf = kzalloc(sizeof(*intf), GFP_KERNEL);
3307 if (!intf) 3309 if (!intf)
@@ -5017,6 +5019,22 @@ static int panic_event(struct notifier_block *this,
5017 return NOTIFY_DONE; 5019 return NOTIFY_DONE;
5018} 5020}
5019 5021
5022/* Must be called with ipmi_interfaces_mutex held. */
5023static int ipmi_register_driver(void)
5024{
5025 int rv;
5026
5027 if (drvregistered)
5028 return 0;
5029
5030 rv = driver_register(&ipmidriver.driver);
5031 if (rv)
5032 pr_err("Could not register IPMI driver\n");
5033 else
5034 drvregistered = true;
5035 return rv;
5036}
5037
5020static struct notifier_block panic_block = { 5038static struct notifier_block panic_block = {
5021 .notifier_call = panic_event, 5039 .notifier_call = panic_event,
5022 .next = NULL, 5040 .next = NULL,
@@ -5027,66 +5045,75 @@ static int ipmi_init_msghandler(void)
5027{ 5045{
5028 int rv; 5046 int rv;
5029 5047
5048 mutex_lock(&ipmi_interfaces_mutex);
5049 rv = ipmi_register_driver();
5050 if (rv)
5051 goto out;
5030 if (initialized) 5052 if (initialized)
5031 return 0; 5053 goto out;
5032
5033 rv = driver_register(&ipmidriver.driver);
5034 if (rv) {
5035 pr_err("Could not register IPMI driver\n");
5036 return rv;
5037 }
5038 5054
5039 pr_info("version " IPMI_DRIVER_VERSION "\n"); 5055 init_srcu_struct(&ipmi_interfaces_srcu);
5040 5056
5041 timer_setup(&ipmi_timer, ipmi_timeout, 0); 5057 timer_setup(&ipmi_timer, ipmi_timeout, 0);
5042 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES); 5058 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
5043 5059
5044 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 5060 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
5045 5061
5046 initialized = 1; 5062 initialized = true;
5047 5063
5048 return 0; 5064out:
5065 mutex_unlock(&ipmi_interfaces_mutex);
5066 return rv;
5049} 5067}
5050 5068
5051static int __init ipmi_init_msghandler_mod(void) 5069static int __init ipmi_init_msghandler_mod(void)
5052{ 5070{
5053 ipmi_init_msghandler(); 5071 int rv;
5054 return 0; 5072
5073 pr_info("version " IPMI_DRIVER_VERSION "\n");
5074
5075 mutex_lock(&ipmi_interfaces_mutex);
5076 rv = ipmi_register_driver();
5077 mutex_unlock(&ipmi_interfaces_mutex);
5078
5079 return rv;
5055} 5080}
5056 5081
5057static void __exit cleanup_ipmi(void) 5082static void __exit cleanup_ipmi(void)
5058{ 5083{
5059 int count; 5084 int count;
5060 5085
5061 if (!initialized) 5086 if (initialized) {
5062 return; 5087 atomic_notifier_chain_unregister(&panic_notifier_list,
5063 5088 &panic_block);
5064 atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
5065 5089
5066 /* 5090 /*
5067 * This can't be called if any interfaces exist, so no worry 5091 * This can't be called if any interfaces exist, so no worry
5068 * about shutting down the interfaces. 5092 * about shutting down the interfaces.
5069 */ 5093 */
5070 5094
5071 /* 5095 /*
5072 * Tell the timer to stop, then wait for it to stop. This 5096 * Tell the timer to stop, then wait for it to stop. This
5073 * avoids problems with race conditions removing the timer 5097 * avoids problems with race conditions removing the timer
5074 * here. 5098 * here.
5075 */ 5099 */
5076 atomic_inc(&stop_operation); 5100 atomic_inc(&stop_operation);
5077 del_timer_sync(&ipmi_timer); 5101 del_timer_sync(&ipmi_timer);
5078 5102
5079 driver_unregister(&ipmidriver.driver); 5103 initialized = false;
5080 5104
5081 initialized = 0; 5105 /* Check for buffer leaks. */
5106 count = atomic_read(&smi_msg_inuse_count);
5107 if (count != 0)
5108 pr_warn("SMI message count %d at exit\n", count);
5109 count = atomic_read(&recv_msg_inuse_count);
5110 if (count != 0)
5111 pr_warn("recv message count %d at exit\n", count);
5082 5112
5083 /* Check for buffer leaks. */ 5113 cleanup_srcu_struct(&ipmi_interfaces_srcu);
5084 count = atomic_read(&smi_msg_inuse_count); 5114 }
5085 if (count != 0) 5115 if (drvregistered)
5086 pr_warn("SMI message count %d at exit\n", count); 5116 driver_unregister(&ipmidriver.driver);
5087 count = atomic_read(&recv_msg_inuse_count);
5088 if (count != 0)
5089 pr_warn("recv message count %d at exit\n", count);
5090} 5117}
5091module_exit(cleanup_ipmi); 5118module_exit(cleanup_ipmi);
5092 5119
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index ca9528c4f183..b7a1ae2afaea 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -632,8 +632,9 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
632 632
633 /* Remove the multi-part read marker. */ 633 /* Remove the multi-part read marker. */
634 len -= 2; 634 len -= 2;
635 data += 2;
635 for (i = 0; i < len; i++) 636 for (i = 0; i < len; i++)
636 ssif_info->data[i] = data[i+2]; 637 ssif_info->data[i] = data[i];
637 ssif_info->multi_len = len; 638 ssif_info->multi_len = len;
638 ssif_info->multi_pos = 1; 639 ssif_info->multi_pos = 1;
639 640
@@ -661,8 +662,19 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
661 } 662 }
662 663
663 blocknum = data[0]; 664 blocknum = data[0];
665 len--;
666 data++;
667
668 if (blocknum != 0xff && len != 31) {
669 /* All blocks but the last must have 31 data bytes. */
670 result = -EIO;
671 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
672 pr_info("Received middle message <31\n");
664 673
665 if (ssif_info->multi_len + len - 1 > IPMI_MAX_MSG_LENGTH) { 674 goto continue_op;
675 }
676
677 if (ssif_info->multi_len + len > IPMI_MAX_MSG_LENGTH) {
666 /* Received message too big, abort the operation. */ 678 /* Received message too big, abort the operation. */
667 result = -E2BIG; 679 result = -E2BIG;
668 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 680 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
@@ -671,16 +683,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
671 goto continue_op; 683 goto continue_op;
672 } 684 }
673 685
674 /* Remove the blocknum from the data. */
675 len--;
676 for (i = 0; i < len; i++) 686 for (i = 0; i < len; i++)
677 ssif_info->data[i + ssif_info->multi_len] = data[i + 1]; 687 ssif_info->data[i + ssif_info->multi_len] = data[i];
678 ssif_info->multi_len += len; 688 ssif_info->multi_len += len;
679 if (blocknum == 0xff) { 689 if (blocknum == 0xff) {
680 /* End of read */ 690 /* End of read */
681 len = ssif_info->multi_len; 691 len = ssif_info->multi_len;
682 data = ssif_info->data; 692 data = ssif_info->data;
683 } else if (blocknum + 1 != ssif_info->multi_pos) { 693 } else if (blocknum != ssif_info->multi_pos) {
684 /* 694 /*
685 * Out of sequence block, just abort. Block 695 * Out of sequence block, just abort. Block
686 * numbers start at zero for the second block, 696 * numbers start at zero for the second block,
@@ -707,6 +717,7 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
707 } 717 }
708 } 718 }
709 719
720 continue_op:
710 if (result < 0) { 721 if (result < 0) {
711 ssif_inc_stat(ssif_info, receive_errors); 722 ssif_inc_stat(ssif_info, receive_errors);
712 } else { 723 } else {
@@ -714,8 +725,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
714 ssif_inc_stat(ssif_info, received_message_parts); 725 ssif_inc_stat(ssif_info, received_message_parts);
715 } 726 }
716 727
717
718 continue_op:
719 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) 728 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE)
720 pr_info("DONE 1: state = %d, result=%d\n", 729 pr_info("DONE 1: state = %d, result=%d\n",
721 ssif_info->ssif_state, result); 730 ssif_info->ssif_state, result);
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
index b5e3103c1175..e43c876a9223 100644
--- a/drivers/char/mwave/mwavedd.c
+++ b/drivers/char/mwave/mwavedd.c
@@ -59,6 +59,7 @@
59#include <linux/mutex.h> 59#include <linux/mutex.h>
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <linux/serial_8250.h> 61#include <linux/serial_8250.h>
62#include <linux/nospec.h>
62#include "smapi.h" 63#include "smapi.h"
63#include "mwavedd.h" 64#include "mwavedd.h"
64#include "3780i.h" 65#include "3780i.h"
@@ -289,6 +290,8 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
289 ipcnum); 290 ipcnum);
290 return -EINVAL; 291 return -EINVAL;
291 } 292 }
293 ipcnum = array_index_nospec(ipcnum,
294 ARRAY_SIZE(pDrvData->IPCs));
292 PRINTK_3(TRACE_MWAVE, 295 PRINTK_3(TRACE_MWAVE,
293 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 296 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
294 " ipcnum %x entry usIntCount %x\n", 297 " ipcnum %x entry usIntCount %x\n",
@@ -317,6 +320,8 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
317 " Invalid ipcnum %x\n", ipcnum); 320 " Invalid ipcnum %x\n", ipcnum);
318 return -EINVAL; 321 return -EINVAL;
319 } 322 }
323 ipcnum = array_index_nospec(ipcnum,
324 ARRAY_SIZE(pDrvData->IPCs));
320 PRINTK_3(TRACE_MWAVE, 325 PRINTK_3(TRACE_MWAVE,
321 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC" 326 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC"
322 " ipcnum %x, usIntCount %x\n", 327 " ipcnum %x, usIntCount %x\n",
@@ -383,6 +388,8 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
383 ipcnum); 388 ipcnum);
384 return -EINVAL; 389 return -EINVAL;
385 } 390 }
391 ipcnum = array_index_nospec(ipcnum,
392 ARRAY_SIZE(pDrvData->IPCs));
386 mutex_lock(&mwave_mutex); 393 mutex_lock(&mwave_mutex);
387 if (pDrvData->IPCs[ipcnum].bIsEnabled == true) { 394 if (pDrvData->IPCs[ipcnum].bIsEnabled == true) {
388 pDrvData->IPCs[ipcnum].bIsEnabled = false; 395 pDrvData->IPCs[ipcnum].bIsEnabled = false;
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index e5b2fe80eab4..d2f0bb5ba47e 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -293,7 +293,6 @@ config COMMON_CLK_BD718XX
293source "drivers/clk/actions/Kconfig" 293source "drivers/clk/actions/Kconfig"
294source "drivers/clk/bcm/Kconfig" 294source "drivers/clk/bcm/Kconfig"
295source "drivers/clk/hisilicon/Kconfig" 295source "drivers/clk/hisilicon/Kconfig"
296source "drivers/clk/imx/Kconfig"
297source "drivers/clk/imgtec/Kconfig" 296source "drivers/clk/imgtec/Kconfig"
298source "drivers/clk/imx/Kconfig" 297source "drivers/clk/imx/Kconfig"
299source "drivers/clk/ingenic/Kconfig" 298source "drivers/clk/ingenic/Kconfig"
diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 5b393e711e94..7d16ab0784ec 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -262,8 +262,10 @@ static int vc5_mux_set_parent(struct clk_hw *hw, u8 index)
262 262
263 if (vc5->clk_mux_ins == VC5_MUX_IN_XIN) 263 if (vc5->clk_mux_ins == VC5_MUX_IN_XIN)
264 src = VC5_PRIM_SRC_SHDN_EN_XTAL; 264 src = VC5_PRIM_SRC_SHDN_EN_XTAL;
265 if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN) 265 else if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN)
266 src = VC5_PRIM_SRC_SHDN_EN_CLKIN; 266 src = VC5_PRIM_SRC_SHDN_EN_CLKIN;
267 else /* Invalid; should have been caught by vc5_probe() */
268 return -EINVAL;
267 } 269 }
268 270
269 return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src); 271 return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src);
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 75d13c0eff12..6ccdbedb02f3 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2779,7 +2779,7 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
2779 seq_printf(s, "\"protect_count\": %d,", c->protect_count); 2779 seq_printf(s, "\"protect_count\": %d,", c->protect_count);
2780 seq_printf(s, "\"rate\": %lu,", clk_core_get_rate(c)); 2780 seq_printf(s, "\"rate\": %lu,", clk_core_get_rate(c));
2781 seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c)); 2781 seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c));
2782 seq_printf(s, "\"phase\": %d", clk_core_get_phase(c)); 2782 seq_printf(s, "\"phase\": %d,", clk_core_get_phase(c));
2783 seq_printf(s, "\"duty_cycle\": %u", 2783 seq_printf(s, "\"duty_cycle\": %u",
2784 clk_core_get_scaled_duty_cycle(c, 100000)); 2784 clk_core_get_scaled_duty_cycle(c, 100000));
2785} 2785}
diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
index 99c2508de8e5..fb6edf1b8aa2 100644
--- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
+++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
@@ -169,6 +169,8 @@ static int imx8qxp_lpcg_clk_probe(struct platform_device *pdev)
169 return -ENODEV; 169 return -ENODEV;
170 170
171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172 if (!res)
173 return -EINVAL;
172 base = devm_ioremap(dev, res->start, resource_size(res)); 174 base = devm_ioremap(dev, res->start, resource_size(res));
173 if (!base) 175 if (!base)
174 return -ENOMEM; 176 return -ENOMEM;
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 1b1ba54e33dd..1c04575c118f 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -215,6 +215,7 @@ config MSM_MMCC_8996
215 215
216config MSM_GCC_8998 216config MSM_GCC_8998
217 tristate "MSM8998 Global Clock Controller" 217 tristate "MSM8998 Global Clock Controller"
218 select QCOM_GDSC
218 help 219 help
219 Support for the global clock controller on msm8998 devices. 220 Support for the global clock controller on msm8998 devices.
220 Say Y if you want to use peripheral devices such as UART, SPI, 221 Say Y if you want to use peripheral devices such as UART, SPI,
diff --git a/drivers/clk/socfpga/clk-pll-s10.c b/drivers/clk/socfpga/clk-pll-s10.c
index 2d5d8b43727e..c4d0b6f6abf2 100644
--- a/drivers/clk/socfpga/clk-pll-s10.c
+++ b/drivers/clk/socfpga/clk-pll-s10.c
@@ -43,7 +43,7 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
43 /* Read mdiv and fdiv from the fdbck register */ 43 /* Read mdiv and fdiv from the fdbck register */
44 reg = readl(socfpgaclk->hw.reg + 0x4); 44 reg = readl(socfpgaclk->hw.reg + 0x4);
45 mdiv = (reg & SOCFPGA_PLL_MDIV_MASK) >> SOCFPGA_PLL_MDIV_SHIFT; 45 mdiv = (reg & SOCFPGA_PLL_MDIV_MASK) >> SOCFPGA_PLL_MDIV_SHIFT;
46 vco_freq = (unsigned long long)parent_rate * (mdiv + 6); 46 vco_freq = (unsigned long long)vco_freq * (mdiv + 6);
47 47
48 return (unsigned long)vco_freq; 48 return (unsigned long)vco_freq;
49} 49}
diff --git a/drivers/clk/socfpga/clk-s10.c b/drivers/clk/socfpga/clk-s10.c
index 5b238fc314ac..8281dfbf38c2 100644
--- a/drivers/clk/socfpga/clk-s10.c
+++ b/drivers/clk/socfpga/clk-s10.c
@@ -12,17 +12,17 @@
12 12
13#include "stratix10-clk.h" 13#include "stratix10-clk.h"
14 14
15static const char * const pll_mux[] = { "osc1", "cb_intosc_hs_div2_clk", 15static const char * const pll_mux[] = { "osc1", "cb-intosc-hs-div2-clk",
16 "f2s_free_clk",}; 16 "f2s-free-clk",};
17static const char * const cntr_mux[] = { "main_pll", "periph_pll", 17static const char * const cntr_mux[] = { "main_pll", "periph_pll",
18 "osc1", "cb_intosc_hs_div2_clk", 18 "osc1", "cb-intosc-hs-div2-clk",
19 "f2s_free_clk"}; 19 "f2s-free-clk"};
20static const char * const boot_mux[] = { "osc1", "cb_intosc_hs_div2_clk",}; 20static const char * const boot_mux[] = { "osc1", "cb-intosc-hs-div2-clk",};
21 21
22static const char * const noc_free_mux[] = {"main_noc_base_clk", 22static const char * const noc_free_mux[] = {"main_noc_base_clk",
23 "peri_noc_base_clk", 23 "peri_noc_base_clk",
24 "osc1", "cb_intosc_hs_div2_clk", 24 "osc1", "cb-intosc-hs-div2-clk",
25 "f2s_free_clk"}; 25 "f2s-free-clk"};
26 26
27static const char * const emaca_free_mux[] = {"peri_emaca_clk", "boot_clk"}; 27static const char * const emaca_free_mux[] = {"peri_emaca_clk", "boot_clk"};
28static const char * const emacb_free_mux[] = {"peri_emacb_clk", "boot_clk"}; 28static const char * const emacb_free_mux[] = {"peri_emacb_clk", "boot_clk"};
@@ -33,14 +33,14 @@ static const char * const s2f_usr1_free_mux[] = {"peri_s2f_usr1_clk", "boot_clk"
33static const char * const psi_ref_free_mux[] = {"peri_psi_ref_clk", "boot_clk"}; 33static const char * const psi_ref_free_mux[] = {"peri_psi_ref_clk", "boot_clk"};
34static const char * const mpu_mux[] = { "mpu_free_clk", "boot_clk",}; 34static const char * const mpu_mux[] = { "mpu_free_clk", "boot_clk",};
35 35
36static const char * const s2f_usr0_mux[] = {"f2s_free_clk", "boot_clk"}; 36static const char * const s2f_usr0_mux[] = {"f2s-free-clk", "boot_clk"};
37static const char * const emac_mux[] = {"emaca_free_clk", "emacb_free_clk"}; 37static const char * const emac_mux[] = {"emaca_free_clk", "emacb_free_clk"};
38static const char * const noc_mux[] = {"noc_free_clk", "boot_clk"}; 38static const char * const noc_mux[] = {"noc_free_clk", "boot_clk"};
39 39
40static const char * const mpu_free_mux[] = {"main_mpu_base_clk", 40static const char * const mpu_free_mux[] = {"main_mpu_base_clk",
41 "peri_mpu_base_clk", 41 "peri_mpu_base_clk",
42 "osc1", "cb_intosc_hs_div2_clk", 42 "osc1", "cb-intosc-hs-div2-clk",
43 "f2s_free_clk"}; 43 "f2s-free-clk"};
44 44
45/* clocks in AO (always on) controller */ 45/* clocks in AO (always on) controller */
46static const struct stratix10_pll_clock s10_pll_clks[] = { 46static const struct stratix10_pll_clock s10_pll_clks[] = {
diff --git a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c b/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
index 269d3595758b..edc31bb56674 100644
--- a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
+++ b/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
@@ -133,9 +133,11 @@ static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)
133 struct tegra_dfll_soc_data *soc; 133 struct tegra_dfll_soc_data *soc;
134 134
135 soc = tegra_dfll_unregister(pdev); 135 soc = tegra_dfll_unregister(pdev);
136 if (IS_ERR(soc)) 136 if (IS_ERR(soc)) {
137 dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n", 137 dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n",
138 PTR_ERR(soc)); 138 PTR_ERR(soc));
139 return PTR_ERR(soc);
140 }
139 141
140 tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq); 142 tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);
141 143
diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index f65cc0ff76ab..b0908ec62f73 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -669,8 +669,8 @@ static int zynqmp_clk_setup(struct device_node *np)
669 if (ret) 669 if (ret)
670 return ret; 670 return ret;
671 671
672 zynqmp_data = kzalloc(sizeof(*zynqmp_data) + sizeof(*zynqmp_data) * 672 zynqmp_data = kzalloc(struct_size(zynqmp_data, hws, clock_max_idx),
673 clock_max_idx, GFP_KERNEL); 673 GFP_KERNEL);
674 if (!zynqmp_data) 674 if (!zynqmp_data)
675 return -ENOMEM; 675 return -ENOMEM;
676 676
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 09b845e90114..a785ffd5af89 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1144,10 +1144,6 @@ static int sbp2_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
1144 if (device->is_local) 1144 if (device->is_local)
1145 return -ENODEV; 1145 return -ENODEV;
1146 1146
1147 if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE)
1148 WARN_ON(dma_set_max_seg_size(device->card->device,
1149 SBP2_MAX_SEG_SIZE));
1150
1151 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt)); 1147 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt));
1152 if (shost == NULL) 1148 if (shost == NULL)
1153 return -ENOMEM; 1149 return -ENOMEM;
@@ -1610,6 +1606,7 @@ static struct scsi_host_template scsi_driver_template = {
1610 .eh_abort_handler = sbp2_scsi_abort, 1606 .eh_abort_handler = sbp2_scsi_abort,
1611 .this_id = -1, 1607 .this_id = -1,
1612 .sg_tablesize = SG_ALL, 1608 .sg_tablesize = SG_ALL,
1609 .max_segment_size = SBP2_MAX_SEG_SIZE,
1613 .can_queue = 1, 1610 .can_queue = 1,
1614 .sdev_attrs = sbp2_scsi_sysfs_attrs, 1611 .sdev_attrs = sbp2_scsi_sysfs_attrs,
1615}; 1612};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index a028661d9e20..92b11de19581 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -576,6 +576,7 @@ static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = {
576 { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, 576 { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX },
577 { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX }, 577 { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX },
578 { 0x1002, 0x6900, 0x1025, 0x125A, AMDGPU_PX_QUIRK_FORCE_ATPX }, 578 { 0x1002, 0x6900, 0x1025, 0x125A, AMDGPU_PX_QUIRK_FORCE_ATPX },
579 { 0x1002, 0x6900, 0x17AA, 0x3806, AMDGPU_PX_QUIRK_FORCE_ATPX },
579 { 0, 0, 0, 0, 0 }, 580 { 0, 0, 0, 0, 0 },
580}; 581};
581 582
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index b8747a5c9204..99d596dc0e89 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -32,6 +32,7 @@
32#include "vega10_pptable.h" 32#include "vega10_pptable.h"
33 33
34#define NUM_DSPCLK_LEVELS 8 34#define NUM_DSPCLK_LEVELS 8
35#define VEGA10_ENGINECLOCK_HARDMAX 198000
35 36
36static void set_hw_cap(struct pp_hwmgr *hwmgr, bool enable, 37static void set_hw_cap(struct pp_hwmgr *hwmgr, bool enable,
37 enum phm_platform_caps cap) 38 enum phm_platform_caps cap)
@@ -258,7 +259,26 @@ static int init_over_drive_limits(
258 struct pp_hwmgr *hwmgr, 259 struct pp_hwmgr *hwmgr,
259 const ATOM_Vega10_POWERPLAYTABLE *powerplay_table) 260 const ATOM_Vega10_POWERPLAYTABLE *powerplay_table)
260{ 261{
261 hwmgr->platform_descriptor.overdriveLimit.engineClock = 262 const ATOM_Vega10_GFXCLK_Dependency_Table *gfxclk_dep_table =
263 (const ATOM_Vega10_GFXCLK_Dependency_Table *)
264 (((unsigned long) powerplay_table) +
265 le16_to_cpu(powerplay_table->usGfxclkDependencyTableOffset));
266 bool is_acg_enabled = false;
267 ATOM_Vega10_GFXCLK_Dependency_Record_V2 *patom_record_v2;
268
269 if (gfxclk_dep_table->ucRevId == 1) {
270 patom_record_v2 =
271 (ATOM_Vega10_GFXCLK_Dependency_Record_V2 *)gfxclk_dep_table->entries;
272 is_acg_enabled =
273 (bool)patom_record_v2[gfxclk_dep_table->ucNumEntries-1].ucACGEnable;
274 }
275
276 if (powerplay_table->ulMaxODEngineClock > VEGA10_ENGINECLOCK_HARDMAX &&
277 !is_acg_enabled)
278 hwmgr->platform_descriptor.overdriveLimit.engineClock =
279 VEGA10_ENGINECLOCK_HARDMAX;
280 else
281 hwmgr->platform_descriptor.overdriveLimit.engineClock =
262 le32_to_cpu(powerplay_table->ulMaxODEngineClock); 282 le32_to_cpu(powerplay_table->ulMaxODEngineClock);
263 hwmgr->platform_descriptor.overdriveLimit.memoryClock = 283 hwmgr->platform_descriptor.overdriveLimit.memoryClock =
264 le32_to_cpu(powerplay_table->ulMaxODMemoryClock); 284 le32_to_cpu(powerplay_table->ulMaxODMemoryClock);
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 5567ddc7760f..55bb7885e228 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -332,6 +332,9 @@ static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
332 332
333 i915_gem_object_unpin_map(wa_ctx->indirect_ctx.obj); 333 i915_gem_object_unpin_map(wa_ctx->indirect_ctx.obj);
334 i915_gem_object_put(wa_ctx->indirect_ctx.obj); 334 i915_gem_object_put(wa_ctx->indirect_ctx.obj);
335
336 wa_ctx->indirect_ctx.obj = NULL;
337 wa_ctx->indirect_ctx.shadow_va = NULL;
335} 338}
336 339
337static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload, 340static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
@@ -911,11 +914,6 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
911 914
912 list_del_init(&workload->list); 915 list_del_init(&workload->list);
913 916
914 if (!workload->status) {
915 release_shadow_batch_buffer(workload);
916 release_shadow_wa_ctx(&workload->wa_ctx);
917 }
918
919 if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) { 917 if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) {
920 /* if workload->status is not successful means HW GPU 918 /* if workload->status is not successful means HW GPU
921 * has occurred GPU hang or something wrong with i915/GVT, 919 * has occurred GPU hang or something wrong with i915/GVT,
@@ -1283,6 +1281,9 @@ void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
1283{ 1281{
1284 struct intel_vgpu_submission *s = &workload->vgpu->submission; 1282 struct intel_vgpu_submission *s = &workload->vgpu->submission;
1285 1283
1284 release_shadow_batch_buffer(workload);
1285 release_shadow_wa_ctx(&workload->wa_ctx);
1286
1286 if (workload->shadow_mm) 1287 if (workload->shadow_mm)
1287 intel_vgpu_mm_put(workload->shadow_mm); 1288 intel_vgpu_mm_put(workload->shadow_mm);
1288 1289
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 4796f40a6d4f..eab9341a5152 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -303,6 +303,7 @@ static void __unwind_incomplete_requests(struct intel_engine_cs *engine)
303 */ 303 */
304 if (!(prio & I915_PRIORITY_NEWCLIENT)) { 304 if (!(prio & I915_PRIORITY_NEWCLIENT)) {
305 prio |= I915_PRIORITY_NEWCLIENT; 305 prio |= I915_PRIORITY_NEWCLIENT;
306 active->sched.attr.priority = prio;
306 list_move_tail(&active->sched.link, 307 list_move_tail(&active->sched.link,
307 i915_sched_lookup_priolist(engine, prio)); 308 i915_sched_lookup_priolist(engine, prio));
308 } 309 }
@@ -645,6 +646,9 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
645 int i; 646 int i;
646 647
647 priolist_for_each_request_consume(rq, rn, p, i) { 648 priolist_for_each_request_consume(rq, rn, p, i) {
649 GEM_BUG_ON(last &&
650 need_preempt(engine, last, rq_prio(rq)));
651
648 /* 652 /*
649 * Can we combine this request with the current port? 653 * Can we combine this request with the current port?
650 * It has to be the same context/ringbuffer and not 654 * It has to be the same context/ringbuffer and not
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 5beb83d1cf87..ce1b3cc4bf6d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -944,7 +944,7 @@ static u32 a6xx_gmu_get_arc_level(struct device *dev, unsigned long freq)
944 np = dev_pm_opp_get_of_node(opp); 944 np = dev_pm_opp_get_of_node(opp);
945 945
946 if (np) { 946 if (np) {
947 of_property_read_u32(np, "qcom,level", &val); 947 of_property_read_u32(np, "opp-level", &val);
948 of_node_put(np); 948 of_node_put(np);
949 } 949 }
950 950
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 2e4372ef17a3..2cfee1a4fe0b 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -765,7 +765,6 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
765 adreno_gpu->rev = config->rev; 765 adreno_gpu->rev = config->rev;
766 766
767 adreno_gpu_config.ioname = "kgsl_3d0_reg_memory"; 767 adreno_gpu_config.ioname = "kgsl_3d0_reg_memory";
768 adreno_gpu_config.irqname = "kgsl_3d0_irq";
769 768
770 adreno_gpu_config.va_start = SZ_16M; 769 adreno_gpu_config.va_start = SZ_16M;
771 adreno_gpu_config.va_end = 0xffffffff; 770 adreno_gpu_config.va_end = 0xffffffff;
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index fd75870eb17f..6aefcd6db46b 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -365,19 +365,6 @@ static void _dpu_plane_set_qos_ctrl(struct drm_plane *plane,
365 &pdpu->pipe_qos_cfg); 365 &pdpu->pipe_qos_cfg);
366} 366}
367 367
368static void dpu_plane_danger_signal_ctrl(struct drm_plane *plane, bool enable)
369{
370 struct dpu_plane *pdpu = to_dpu_plane(plane);
371 struct dpu_kms *dpu_kms = _dpu_plane_get_kms(plane);
372
373 if (!pdpu->is_rt_pipe)
374 return;
375
376 pm_runtime_get_sync(&dpu_kms->pdev->dev);
377 _dpu_plane_set_qos_ctrl(plane, enable, DPU_PLANE_QOS_PANIC_CTRL);
378 pm_runtime_put_sync(&dpu_kms->pdev->dev);
379}
380
381/** 368/**
382 * _dpu_plane_set_ot_limit - set OT limit for the given plane 369 * _dpu_plane_set_ot_limit - set OT limit for the given plane
383 * @plane: Pointer to drm plane 370 * @plane: Pointer to drm plane
@@ -1248,6 +1235,19 @@ static void dpu_plane_reset(struct drm_plane *plane)
1248} 1235}
1249 1236
1250#ifdef CONFIG_DEBUG_FS 1237#ifdef CONFIG_DEBUG_FS
1238static void dpu_plane_danger_signal_ctrl(struct drm_plane *plane, bool enable)
1239{
1240 struct dpu_plane *pdpu = to_dpu_plane(plane);
1241 struct dpu_kms *dpu_kms = _dpu_plane_get_kms(plane);
1242
1243 if (!pdpu->is_rt_pipe)
1244 return;
1245
1246 pm_runtime_get_sync(&dpu_kms->pdev->dev);
1247 _dpu_plane_set_qos_ctrl(plane, enable, DPU_PLANE_QOS_PANIC_CTRL);
1248 pm_runtime_put_sync(&dpu_kms->pdev->dev);
1249}
1250
1251static ssize_t _dpu_plane_danger_read(struct file *file, 1251static ssize_t _dpu_plane_danger_read(struct file *file,
1252 char __user *buff, size_t count, loff_t *ppos) 1252 char __user *buff, size_t count, loff_t *ppos)
1253{ 1253{
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 9cd6a96c6bf2..927e5d86f7c1 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -250,7 +250,8 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
250void msm_gem_unmap_vma(struct msm_gem_address_space *aspace, 250void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
251 struct msm_gem_vma *vma); 251 struct msm_gem_vma *vma);
252int msm_gem_map_vma(struct msm_gem_address_space *aspace, 252int msm_gem_map_vma(struct msm_gem_address_space *aspace,
253 struct msm_gem_vma *vma, struct sg_table *sgt, int npages); 253 struct msm_gem_vma *vma, int prot,
254 struct sg_table *sgt, int npages);
254void msm_gem_close_vma(struct msm_gem_address_space *aspace, 255void msm_gem_close_vma(struct msm_gem_address_space *aspace,
255 struct msm_gem_vma *vma); 256 struct msm_gem_vma *vma);
256 257
@@ -333,6 +334,7 @@ void msm_gem_kernel_put(struct drm_gem_object *bo,
333struct drm_gem_object *msm_gem_import(struct drm_device *dev, 334struct drm_gem_object *msm_gem_import(struct drm_device *dev,
334 struct dma_buf *dmabuf, struct sg_table *sgt); 335 struct dma_buf *dmabuf, struct sg_table *sgt);
335 336
337__printf(2, 3)
336void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...); 338void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...);
337 339
338int msm_framebuffer_prepare(struct drm_framebuffer *fb, 340int msm_framebuffer_prepare(struct drm_framebuffer *fb,
@@ -396,12 +398,14 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
396int msm_debugfs_late_init(struct drm_device *dev); 398int msm_debugfs_late_init(struct drm_device *dev);
397int msm_rd_debugfs_init(struct drm_minor *minor); 399int msm_rd_debugfs_init(struct drm_minor *minor);
398void msm_rd_debugfs_cleanup(struct msm_drm_private *priv); 400void msm_rd_debugfs_cleanup(struct msm_drm_private *priv);
401__printf(3, 4)
399void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit, 402void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
400 const char *fmt, ...); 403 const char *fmt, ...);
401int msm_perf_debugfs_init(struct drm_minor *minor); 404int msm_perf_debugfs_init(struct drm_minor *minor);
402void msm_perf_debugfs_cleanup(struct msm_drm_private *priv); 405void msm_perf_debugfs_cleanup(struct msm_drm_private *priv);
403#else 406#else
404static inline int msm_debugfs_late_init(struct drm_device *dev) { return 0; } 407static inline int msm_debugfs_late_init(struct drm_device *dev) { return 0; }
408__printf(3, 4)
405static inline void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit, 409static inline void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
406 const char *fmt, ...) {} 410 const char *fmt, ...) {}
407static inline void msm_rd_debugfs_cleanup(struct msm_drm_private *priv) {} 411static inline void msm_rd_debugfs_cleanup(struct msm_drm_private *priv) {}
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 51a95da694d8..c8886d3071fa 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -391,6 +391,10 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
391 struct msm_gem_object *msm_obj = to_msm_bo(obj); 391 struct msm_gem_object *msm_obj = to_msm_bo(obj);
392 struct msm_gem_vma *vma; 392 struct msm_gem_vma *vma;
393 struct page **pages; 393 struct page **pages;
394 int prot = IOMMU_READ;
395
396 if (!(msm_obj->flags & MSM_BO_GPU_READONLY))
397 prot |= IOMMU_WRITE;
394 398
395 WARN_ON(!mutex_is_locked(&msm_obj->lock)); 399 WARN_ON(!mutex_is_locked(&msm_obj->lock));
396 400
@@ -405,8 +409,8 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
405 if (IS_ERR(pages)) 409 if (IS_ERR(pages))
406 return PTR_ERR(pages); 410 return PTR_ERR(pages);
407 411
408 return msm_gem_map_vma(aspace, vma, msm_obj->sgt, 412 return msm_gem_map_vma(aspace, vma, prot,
409 obj->size >> PAGE_SHIFT); 413 msm_obj->sgt, obj->size >> PAGE_SHIFT);
410} 414}
411 415
412/* get iova and pin it. Should have a matching put */ 416/* get iova and pin it. Should have a matching put */
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index 557360788084..49c04829cf34 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -68,7 +68,8 @@ void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
68 68
69int 69int
70msm_gem_map_vma(struct msm_gem_address_space *aspace, 70msm_gem_map_vma(struct msm_gem_address_space *aspace,
71 struct msm_gem_vma *vma, struct sg_table *sgt, int npages) 71 struct msm_gem_vma *vma, int prot,
72 struct sg_table *sgt, int npages)
72{ 73{
73 unsigned size = npages << PAGE_SHIFT; 74 unsigned size = npages << PAGE_SHIFT;
74 int ret = 0; 75 int ret = 0;
@@ -86,7 +87,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace,
86 87
87 if (aspace->mmu) 88 if (aspace->mmu)
88 ret = aspace->mmu->funcs->map(aspace->mmu, vma->iova, sgt, 89 ret = aspace->mmu->funcs->map(aspace->mmu, vma->iova, sgt,
89 size, IOMMU_READ | IOMMU_WRITE); 90 size, prot);
90 91
91 if (ret) 92 if (ret)
92 vma->mapped = false; 93 vma->mapped = false;
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 5f3eff304355..10babd18e286 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -900,7 +900,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
900 } 900 }
901 901
902 /* Get Interrupt: */ 902 /* Get Interrupt: */
903 gpu->irq = platform_get_irq_byname(pdev, config->irqname); 903 gpu->irq = platform_get_irq(pdev, 0);
904 if (gpu->irq < 0) { 904 if (gpu->irq < 0) {
905 ret = gpu->irq; 905 ret = gpu->irq;
906 DRM_DEV_ERROR(drm->dev, "failed to get irq: %d\n", ret); 906 DRM_DEV_ERROR(drm->dev, "failed to get irq: %d\n", ret);
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index efb49bb64191..ca17086f72c9 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -31,7 +31,6 @@ struct msm_gpu_state;
31 31
32struct msm_gpu_config { 32struct msm_gpu_config {
33 const char *ioname; 33 const char *ioname;
34 const char *irqname;
35 uint64_t va_start; 34 uint64_t va_start;
36 uint64_t va_end; 35 uint64_t va_end;
37 unsigned int nr_rings; 36 unsigned int nr_rings;
@@ -63,7 +62,7 @@ struct msm_gpu_funcs {
63 struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu); 62 struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu);
64 void (*recover)(struct msm_gpu *gpu); 63 void (*recover)(struct msm_gpu *gpu);
65 void (*destroy)(struct msm_gpu *gpu); 64 void (*destroy)(struct msm_gpu *gpu);
66#ifdef CONFIG_DEBUG_FS 65#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP)
67 /* show GPU status in debugfs: */ 66 /* show GPU status in debugfs: */
68 void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state, 67 void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state,
69 struct drm_printer *p); 68 struct drm_printer *p);
diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
index 90e9d0a48dc0..d21172933d92 100644
--- a/drivers/gpu/drm/msm/msm_rd.c
+++ b/drivers/gpu/drm/msm/msm_rd.c
@@ -115,7 +115,9 @@ static void rd_write(struct msm_rd_state *rd, const void *buf, int sz)
115 char *fptr = &fifo->buf[fifo->head]; 115 char *fptr = &fifo->buf[fifo->head];
116 int n; 116 int n;
117 117
118 wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0); 118 wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0 || !rd->open);
119 if (!rd->open)
120 return;
119 121
120 /* Note that smp_load_acquire() is not strictly required 122 /* Note that smp_load_acquire() is not strictly required
121 * as CIRC_SPACE_TO_END() does not access the tail more 123 * as CIRC_SPACE_TO_END() does not access the tail more
@@ -213,7 +215,10 @@ out:
213static int rd_release(struct inode *inode, struct file *file) 215static int rd_release(struct inode *inode, struct file *file)
214{ 216{
215 struct msm_rd_state *rd = inode->i_private; 217 struct msm_rd_state *rd = inode->i_private;
218
216 rd->open = false; 219 rd->open = false;
220 wake_up_all(&rd->fifo_event);
221
217 return 0; 222 return 0;
218} 223}
219 224
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 061d2e0d9011..416da5376701 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -92,6 +92,8 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder)
92 val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG); 92 val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
93 val &= ~SUN4I_HDMI_VID_CTRL_ENABLE; 93 val &= ~SUN4I_HDMI_VID_CTRL_ENABLE;
94 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); 94 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
95
96 clk_disable_unprepare(hdmi->tmds_clk);
95} 97}
96 98
97static void sun4i_hdmi_enable(struct drm_encoder *encoder) 99static void sun4i_hdmi_enable(struct drm_encoder *encoder)
@@ -102,6 +104,8 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder)
102 104
103 DRM_DEBUG_DRIVER("Enabling the HDMI Output\n"); 105 DRM_DEBUG_DRIVER("Enabling the HDMI Output\n");
104 106
107 clk_prepare_enable(hdmi->tmds_clk);
108
105 sun4i_hdmi_setup_avi_infoframes(hdmi, mode); 109 sun4i_hdmi_setup_avi_infoframes(hdmi, mode);
106 val |= SUN4I_HDMI_PKT_CTRL_TYPE(0, SUN4I_HDMI_PKT_AVI); 110 val |= SUN4I_HDMI_PKT_CTRL_TYPE(0, SUN4I_HDMI_PKT_AVI);
107 val |= SUN4I_HDMI_PKT_CTRL_TYPE(1, SUN4I_HDMI_PKT_END); 111 val |= SUN4I_HDMI_PKT_CTRL_TYPE(1, SUN4I_HDMI_PKT_END);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f41d5fe51abe..9993b692598f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -125,6 +125,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
125{ 125{
126 struct hid_collection *collection; 126 struct hid_collection *collection;
127 unsigned usage; 127 unsigned usage;
128 int collection_index;
128 129
129 usage = parser->local.usage[0]; 130 usage = parser->local.usage[0];
130 131
@@ -167,13 +168,13 @@ static int open_collection(struct hid_parser *parser, unsigned type)
167 parser->collection_stack[parser->collection_stack_ptr++] = 168 parser->collection_stack[parser->collection_stack_ptr++] =
168 parser->device->maxcollection; 169 parser->device->maxcollection;
169 170
170 collection = parser->device->collection + 171 collection_index = parser->device->maxcollection++;
171 parser->device->maxcollection++; 172 collection = parser->device->collection + collection_index;
172 collection->type = type; 173 collection->type = type;
173 collection->usage = usage; 174 collection->usage = usage;
174 collection->level = parser->collection_stack_ptr - 1; 175 collection->level = parser->collection_stack_ptr - 1;
175 collection->parent = parser->active_collection; 176 collection->parent_idx = (collection->level == 0) ? -1 :
176 parser->active_collection = collection; 177 parser->collection_stack[collection->level - 1];
177 178
178 if (type == HID_COLLECTION_APPLICATION) 179 if (type == HID_COLLECTION_APPLICATION)
179 parser->device->maxapplication++; 180 parser->device->maxapplication++;
@@ -192,8 +193,6 @@ static int close_collection(struct hid_parser *parser)
192 return -EINVAL; 193 return -EINVAL;
193 } 194 }
194 parser->collection_stack_ptr--; 195 parser->collection_stack_ptr--;
195 if (parser->active_collection)
196 parser->active_collection = parser->active_collection->parent;
197 return 0; 196 return 0;
198} 197}
199 198
@@ -1006,10 +1005,12 @@ static void hid_apply_multiplier_to_field(struct hid_device *hid,
1006 usage = &field->usage[i]; 1005 usage = &field->usage[i];
1007 1006
1008 collection = &hid->collection[usage->collection_index]; 1007 collection = &hid->collection[usage->collection_index];
1009 while (collection && collection != multiplier_collection) 1008 while (collection->parent_idx != -1 &&
1010 collection = collection->parent; 1009 collection != multiplier_collection)
1010 collection = &hid->collection[collection->parent_idx];
1011 1011
1012 if (collection || multiplier_collection == NULL) 1012 if (collection->parent_idx != -1 ||
1013 multiplier_collection == NULL)
1013 usage->resolution_multiplier = effective_multiplier; 1014 usage->resolution_multiplier = effective_multiplier;
1014 1015
1015 } 1016 }
@@ -1044,9 +1045,9 @@ static void hid_apply_multiplier(struct hid_device *hid,
1044 * applicable fields later. 1045 * applicable fields later.
1045 */ 1046 */
1046 multiplier_collection = &hid->collection[multiplier->usage->collection_index]; 1047 multiplier_collection = &hid->collection[multiplier->usage->collection_index];
1047 while (multiplier_collection && 1048 while (multiplier_collection->parent_idx != -1 &&
1048 multiplier_collection->type != HID_COLLECTION_LOGICAL) 1049 multiplier_collection->type != HID_COLLECTION_LOGICAL)
1049 multiplier_collection = multiplier_collection->parent; 1050 multiplier_collection = &hid->collection[multiplier_collection->parent_idx];
1050 1051
1051 effective_multiplier = hid_calculate_multiplier(hid, multiplier); 1052 effective_multiplier = hid_calculate_multiplier(hid, multiplier);
1052 1053
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 518fa76414f5..24f846d67478 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -461,6 +461,9 @@
461#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a 461#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
462#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100 462#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
463 463
464#define I2C_VENDOR_ID_GOODIX 0x27c6
465#define I2C_DEVICE_ID_GOODIX_01F0 0x01f0
466
464#define USB_VENDOR_ID_GOODTOUCH 0x1aad 467#define USB_VENDOR_ID_GOODTOUCH 0x1aad
465#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f 468#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f
466 469
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 8555ce7e737b..c5edfa966343 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -179,6 +179,8 @@ static const struct i2c_hid_quirks {
179 I2C_HID_QUIRK_DELAY_AFTER_SLEEP }, 179 I2C_HID_QUIRK_DELAY_AFTER_SLEEP },
180 { USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001, 180 { USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001,
181 I2C_HID_QUIRK_NO_RUNTIME_PM }, 181 I2C_HID_QUIRK_NO_RUNTIME_PM },
182 { I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_01F0,
183 I2C_HID_QUIRK_NO_RUNTIME_PM },
182 { 0, 0 } 184 { 0, 0 }
183}; 185};
184 186
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index ce0ba2062723..bea4c9850247 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -701,19 +701,12 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
701int vmbus_disconnect_ring(struct vmbus_channel *channel) 701int vmbus_disconnect_ring(struct vmbus_channel *channel)
702{ 702{
703 struct vmbus_channel *cur_channel, *tmp; 703 struct vmbus_channel *cur_channel, *tmp;
704 unsigned long flags;
705 LIST_HEAD(list);
706 int ret; 704 int ret;
707 705
708 if (channel->primary_channel != NULL) 706 if (channel->primary_channel != NULL)
709 return -EINVAL; 707 return -EINVAL;
710 708
711 /* Snapshot the list of subchannels */ 709 list_for_each_entry_safe(cur_channel, tmp, &channel->sc_list, sc_list) {
712 spin_lock_irqsave(&channel->lock, flags);
713 list_splice_init(&channel->sc_list, &list);
714 spin_unlock_irqrestore(&channel->lock, flags);
715
716 list_for_each_entry_safe(cur_channel, tmp, &list, sc_list) {
717 if (cur_channel->rescind) 710 if (cur_channel->rescind)
718 wait_for_completion(&cur_channel->rescind_event); 711 wait_for_completion(&cur_channel->rescind_event);
719 712
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 5301fef16c31..7c6349a50ef1 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -888,12 +888,14 @@ static unsigned long handle_pg_range(unsigned long pg_start,
888 pfn_cnt -= pgs_ol; 888 pfn_cnt -= pgs_ol;
889 /* 889 /*
890 * Check if the corresponding memory block is already 890 * Check if the corresponding memory block is already
891 * online by checking its last previously backed page. 891 * online. It is possible to observe struct pages still
892 * In case it is we need to bring rest (which was not 892 * being uninitialized here so check section instead.
893 * backed previously) online too. 893 * In case the section is online we need to bring the
894 * rest of pfns (which were not backed previously)
895 * online too.
894 */ 896 */
895 if (start_pfn > has->start_pfn && 897 if (start_pfn > has->start_pfn &&
896 !PageReserved(pfn_to_page(start_pfn - 1))) 898 online_section_nr(pfn_to_section_nr(start_pfn)))
897 hv_bring_pgs_online(has, start_pfn, pgs_ol); 899 hv_bring_pgs_online(has, start_pfn, pgs_ol);
898 900
899 } 901 }
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 64d0c85d5161..1f1a55e07733 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -164,26 +164,25 @@ hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
164} 164}
165 165
166/* Get various debug metrics for the specified ring buffer. */ 166/* Get various debug metrics for the specified ring buffer. */
167void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info, 167int hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
168 struct hv_ring_buffer_debug_info *debug_info) 168 struct hv_ring_buffer_debug_info *debug_info)
169{ 169{
170 u32 bytes_avail_towrite; 170 u32 bytes_avail_towrite;
171 u32 bytes_avail_toread; 171 u32 bytes_avail_toread;
172 172
173 if (ring_info->ring_buffer) { 173 if (!ring_info->ring_buffer)
174 hv_get_ringbuffer_availbytes(ring_info, 174 return -EINVAL;
175 &bytes_avail_toread, 175
176 &bytes_avail_towrite); 176 hv_get_ringbuffer_availbytes(ring_info,
177 177 &bytes_avail_toread,
178 debug_info->bytes_avail_toread = bytes_avail_toread; 178 &bytes_avail_towrite);
179 debug_info->bytes_avail_towrite = bytes_avail_towrite; 179 debug_info->bytes_avail_toread = bytes_avail_toread;
180 debug_info->current_read_index = 180 debug_info->bytes_avail_towrite = bytes_avail_towrite;
181 ring_info->ring_buffer->read_index; 181 debug_info->current_read_index = ring_info->ring_buffer->read_index;
182 debug_info->current_write_index = 182 debug_info->current_write_index = ring_info->ring_buffer->write_index;
183 ring_info->ring_buffer->write_index; 183 debug_info->current_interrupt_mask
184 debug_info->current_interrupt_mask = 184 = ring_info->ring_buffer->interrupt_mask;
185 ring_info->ring_buffer->interrupt_mask; 185 return 0;
186 }
187} 186}
188EXPORT_SYMBOL_GPL(hv_ringbuffer_get_debuginfo); 187EXPORT_SYMBOL_GPL(hv_ringbuffer_get_debuginfo);
189 188
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index d0ff65675292..403fee01572c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -313,12 +313,16 @@ static ssize_t out_intr_mask_show(struct device *dev,
313{ 313{
314 struct hv_device *hv_dev = device_to_hv_device(dev); 314 struct hv_device *hv_dev = device_to_hv_device(dev);
315 struct hv_ring_buffer_debug_info outbound; 315 struct hv_ring_buffer_debug_info outbound;
316 int ret;
316 317
317 if (!hv_dev->channel) 318 if (!hv_dev->channel)
318 return -ENODEV; 319 return -ENODEV;
319 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 320
320 return -EINVAL; 321 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
321 hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); 322 &outbound);
323 if (ret < 0)
324 return ret;
325
322 return sprintf(buf, "%d\n", outbound.current_interrupt_mask); 326 return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
323} 327}
324static DEVICE_ATTR_RO(out_intr_mask); 328static DEVICE_ATTR_RO(out_intr_mask);
@@ -328,12 +332,15 @@ static ssize_t out_read_index_show(struct device *dev,
328{ 332{
329 struct hv_device *hv_dev = device_to_hv_device(dev); 333 struct hv_device *hv_dev = device_to_hv_device(dev);
330 struct hv_ring_buffer_debug_info outbound; 334 struct hv_ring_buffer_debug_info outbound;
335 int ret;
331 336
332 if (!hv_dev->channel) 337 if (!hv_dev->channel)
333 return -ENODEV; 338 return -ENODEV;
334 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 339
335 return -EINVAL; 340 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
336 hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); 341 &outbound);
342 if (ret < 0)
343 return ret;
337 return sprintf(buf, "%d\n", outbound.current_read_index); 344 return sprintf(buf, "%d\n", outbound.current_read_index);
338} 345}
339static DEVICE_ATTR_RO(out_read_index); 346static DEVICE_ATTR_RO(out_read_index);
@@ -344,12 +351,15 @@ static ssize_t out_write_index_show(struct device *dev,
344{ 351{
345 struct hv_device *hv_dev = device_to_hv_device(dev); 352 struct hv_device *hv_dev = device_to_hv_device(dev);
346 struct hv_ring_buffer_debug_info outbound; 353 struct hv_ring_buffer_debug_info outbound;
354 int ret;
347 355
348 if (!hv_dev->channel) 356 if (!hv_dev->channel)
349 return -ENODEV; 357 return -ENODEV;
350 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 358
351 return -EINVAL; 359 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
352 hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); 360 &outbound);
361 if (ret < 0)
362 return ret;
353 return sprintf(buf, "%d\n", outbound.current_write_index); 363 return sprintf(buf, "%d\n", outbound.current_write_index);
354} 364}
355static DEVICE_ATTR_RO(out_write_index); 365static DEVICE_ATTR_RO(out_write_index);
@@ -360,12 +370,15 @@ static ssize_t out_read_bytes_avail_show(struct device *dev,
360{ 370{
361 struct hv_device *hv_dev = device_to_hv_device(dev); 371 struct hv_device *hv_dev = device_to_hv_device(dev);
362 struct hv_ring_buffer_debug_info outbound; 372 struct hv_ring_buffer_debug_info outbound;
373 int ret;
363 374
364 if (!hv_dev->channel) 375 if (!hv_dev->channel)
365 return -ENODEV; 376 return -ENODEV;
366 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 377
367 return -EINVAL; 378 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
368 hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); 379 &outbound);
380 if (ret < 0)
381 return ret;
369 return sprintf(buf, "%d\n", outbound.bytes_avail_toread); 382 return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
370} 383}
371static DEVICE_ATTR_RO(out_read_bytes_avail); 384static DEVICE_ATTR_RO(out_read_bytes_avail);
@@ -376,12 +389,15 @@ static ssize_t out_write_bytes_avail_show(struct device *dev,
376{ 389{
377 struct hv_device *hv_dev = device_to_hv_device(dev); 390 struct hv_device *hv_dev = device_to_hv_device(dev);
378 struct hv_ring_buffer_debug_info outbound; 391 struct hv_ring_buffer_debug_info outbound;
392 int ret;
379 393
380 if (!hv_dev->channel) 394 if (!hv_dev->channel)
381 return -ENODEV; 395 return -ENODEV;
382 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 396
383 return -EINVAL; 397 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
384 hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); 398 &outbound);
399 if (ret < 0)
400 return ret;
385 return sprintf(buf, "%d\n", outbound.bytes_avail_towrite); 401 return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
386} 402}
387static DEVICE_ATTR_RO(out_write_bytes_avail); 403static DEVICE_ATTR_RO(out_write_bytes_avail);
@@ -391,12 +407,15 @@ static ssize_t in_intr_mask_show(struct device *dev,
391{ 407{
392 struct hv_device *hv_dev = device_to_hv_device(dev); 408 struct hv_device *hv_dev = device_to_hv_device(dev);
393 struct hv_ring_buffer_debug_info inbound; 409 struct hv_ring_buffer_debug_info inbound;
410 int ret;
394 411
395 if (!hv_dev->channel) 412 if (!hv_dev->channel)
396 return -ENODEV; 413 return -ENODEV;
397 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 414
398 return -EINVAL; 415 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
399 hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); 416 if (ret < 0)
417 return ret;
418
400 return sprintf(buf, "%d\n", inbound.current_interrupt_mask); 419 return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
401} 420}
402static DEVICE_ATTR_RO(in_intr_mask); 421static DEVICE_ATTR_RO(in_intr_mask);
@@ -406,12 +425,15 @@ static ssize_t in_read_index_show(struct device *dev,
406{ 425{
407 struct hv_device *hv_dev = device_to_hv_device(dev); 426 struct hv_device *hv_dev = device_to_hv_device(dev);
408 struct hv_ring_buffer_debug_info inbound; 427 struct hv_ring_buffer_debug_info inbound;
428 int ret;
409 429
410 if (!hv_dev->channel) 430 if (!hv_dev->channel)
411 return -ENODEV; 431 return -ENODEV;
412 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 432
413 return -EINVAL; 433 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
414 hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); 434 if (ret < 0)
435 return ret;
436
415 return sprintf(buf, "%d\n", inbound.current_read_index); 437 return sprintf(buf, "%d\n", inbound.current_read_index);
416} 438}
417static DEVICE_ATTR_RO(in_read_index); 439static DEVICE_ATTR_RO(in_read_index);
@@ -421,12 +443,15 @@ static ssize_t in_write_index_show(struct device *dev,
421{ 443{
422 struct hv_device *hv_dev = device_to_hv_device(dev); 444 struct hv_device *hv_dev = device_to_hv_device(dev);
423 struct hv_ring_buffer_debug_info inbound; 445 struct hv_ring_buffer_debug_info inbound;
446 int ret;
424 447
425 if (!hv_dev->channel) 448 if (!hv_dev->channel)
426 return -ENODEV; 449 return -ENODEV;
427 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 450
428 return -EINVAL; 451 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
429 hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); 452 if (ret < 0)
453 return ret;
454
430 return sprintf(buf, "%d\n", inbound.current_write_index); 455 return sprintf(buf, "%d\n", inbound.current_write_index);
431} 456}
432static DEVICE_ATTR_RO(in_write_index); 457static DEVICE_ATTR_RO(in_write_index);
@@ -437,12 +462,15 @@ static ssize_t in_read_bytes_avail_show(struct device *dev,
437{ 462{
438 struct hv_device *hv_dev = device_to_hv_device(dev); 463 struct hv_device *hv_dev = device_to_hv_device(dev);
439 struct hv_ring_buffer_debug_info inbound; 464 struct hv_ring_buffer_debug_info inbound;
465 int ret;
440 466
441 if (!hv_dev->channel) 467 if (!hv_dev->channel)
442 return -ENODEV; 468 return -ENODEV;
443 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 469
444 return -EINVAL; 470 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
445 hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); 471 if (ret < 0)
472 return ret;
473
446 return sprintf(buf, "%d\n", inbound.bytes_avail_toread); 474 return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
447} 475}
448static DEVICE_ATTR_RO(in_read_bytes_avail); 476static DEVICE_ATTR_RO(in_read_bytes_avail);
@@ -453,12 +481,15 @@ static ssize_t in_write_bytes_avail_show(struct device *dev,
453{ 481{
454 struct hv_device *hv_dev = device_to_hv_device(dev); 482 struct hv_device *hv_dev = device_to_hv_device(dev);
455 struct hv_ring_buffer_debug_info inbound; 483 struct hv_ring_buffer_debug_info inbound;
484 int ret;
456 485
457 if (!hv_dev->channel) 486 if (!hv_dev->channel)
458 return -ENODEV; 487 return -ENODEV;
459 if (hv_dev->channel->state != CHANNEL_OPENED_STATE) 488
460 return -EINVAL; 489 ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
461 hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); 490 if (ret < 0)
491 return ret;
492
462 return sprintf(buf, "%d\n", inbound.bytes_avail_towrite); 493 return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
463} 494}
464static DEVICE_ATTR_RO(in_write_bytes_avail); 495static DEVICE_ATTR_RO(in_write_bytes_avail);
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 4c8c7a620d08..a5dc13576394 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -544,7 +544,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif)
544 drive->proc = proc_mkdir(drive->name, parent); 544 drive->proc = proc_mkdir(drive->name, parent);
545 if (drive->proc) { 545 if (drive->proc) {
546 ide_add_proc_entries(drive->proc, generic_drive_entries, drive); 546 ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
547 proc_create_data("setting", S_IFREG|S_IRUSR|S_IWUSR, 547 proc_create_data("settings", S_IFREG|S_IRUSR|S_IWUSR,
548 drive->proc, &ide_settings_proc_fops, 548 drive->proc, &ide_settings_proc_fops,
549 drive); 549 drive);
550 } 550 }
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index cfc8b94527b9..aa4e431cbcd3 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -252,6 +252,8 @@ static const struct xpad_device {
252 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, 252 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
253 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, 253 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
254 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX }, 254 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
255 { 0x1038, 0x1430, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 },
256 { 0x1038, 0x1431, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 },
255 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 }, 257 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
256 { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 258 { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
257 { 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 }, 259 { 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 },
@@ -428,6 +430,7 @@ static const struct usb_device_id xpad_table[] = {
428 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ 430 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */
429 XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ 431 XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */
430 XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */ 432 XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */
433 XPAD_XBOX360_VENDOR(0x1038), /* SteelSeries Controllers */
431 XPAD_XBOX360_VENDOR(0x11c9), /* Nacon GC100XF */ 434 XPAD_XBOX360_VENDOR(0x11c9), /* Nacon GC100XF */
432 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ 435 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
433 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ 436 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 8ec483e8688b..26ec603fe220 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -39,6 +39,7 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/miscdevice.h> 41#include <linux/miscdevice.h>
42#include <linux/overflow.h>
42#include <linux/input/mt.h> 43#include <linux/input/mt.h>
43#include "../input-compat.h" 44#include "../input-compat.h"
44 45
@@ -405,7 +406,7 @@ static int uinput_open(struct inode *inode, struct file *file)
405static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code, 406static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code,
406 const struct input_absinfo *abs) 407 const struct input_absinfo *abs)
407{ 408{
408 int min, max; 409 int min, max, range;
409 410
410 min = abs->minimum; 411 min = abs->minimum;
411 max = abs->maximum; 412 max = abs->maximum;
@@ -417,7 +418,7 @@ static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code,
417 return -EINVAL; 418 return -EINVAL;
418 } 419 }
419 420
420 if (abs->flat > max - min) { 421 if (!check_sub_overflow(max, min, &range) && abs->flat > range) {
421 printk(KERN_DEBUG 422 printk(KERN_DEBUG
422 "%s: abs_flat #%02x out of range: %d (min:%d/max:%d)\n", 423 "%s: abs_flat #%02x out of range: %d (min:%d/max:%d)\n",
423 UINPUT_NAME, code, abs->flat, min, max); 424 UINPUT_NAME, code, abs->flat, min, max);
diff --git a/drivers/input/serio/olpc_apsp.c b/drivers/input/serio/olpc_apsp.c
index b36084710f69..bae08226e3d9 100644
--- a/drivers/input/serio/olpc_apsp.c
+++ b/drivers/input/serio/olpc_apsp.c
@@ -195,6 +195,8 @@ static int olpc_apsp_probe(struct platform_device *pdev)
195 if (!priv) 195 if (!priv)
196 return -ENOMEM; 196 return -ENOMEM;
197 197
198 priv->dev = &pdev->dev;
199
198 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 200 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
199 priv->base = devm_ioremap_resource(&pdev->dev, res); 201 priv->base = devm_ioremap_resource(&pdev->dev, res);
200 if (IS_ERR(priv->base)) { 202 if (IS_ERR(priv->base)) {
@@ -248,7 +250,6 @@ static int olpc_apsp_probe(struct platform_device *pdev)
248 goto err_irq; 250 goto err_irq;
249 } 251 }
250 252
251 priv->dev = &pdev->dev;
252 device_init_wakeup(priv->dev, 1); 253 device_init_wakeup(priv->dev, 1);
253 platform_set_drvdata(pdev, priv); 254 platform_set_drvdata(pdev, priv);
254 255
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index af6027cc7bbf..068dbbc610fc 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -698,7 +698,7 @@ config TOUCHSCREEN_EDT_FT5X06
698 698
699config TOUCHSCREEN_RASPBERRYPI_FW 699config TOUCHSCREEN_RASPBERRYPI_FW
700 tristate "Raspberry Pi's firmware base touch screen support" 700 tristate "Raspberry Pi's firmware base touch screen support"
701 depends on RASPBERRYPI_FIRMWARE || COMPILE_TEST 701 depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && COMPILE_TEST)
702 help 702 help
703 Say Y here if you have the official Raspberry Pi 7 inch screen on 703 Say Y here if you have the official Raspberry Pi 7 inch screen on
704 your system. 704 your system.
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index d8947b28db2d..f04a6df65eb8 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -224,7 +224,7 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
224 * If we have reason to believe the IOMMU driver missed the initial 224 * If we have reason to believe the IOMMU driver missed the initial
225 * probe for dev, replay it to get things in order. 225 * probe for dev, replay it to get things in order.
226 */ 226 */
227 if (dev->bus && !device_iommu_mapped(dev)) 227 if (!err && dev->bus && !device_iommu_mapped(dev))
228 err = iommu_probe_device(dev); 228 err = iommu_probe_device(dev);
229 229
230 /* Ignore all other errors apart from EPROBE_DEFER */ 230 /* Ignore all other errors apart from EPROBE_DEFER */
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0ff22159a0ca..47d4e0d30bf0 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2414,9 +2414,21 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key
2414 * capi:cipher_api_spec-iv:ivopts 2414 * capi:cipher_api_spec-iv:ivopts
2415 */ 2415 */
2416 tmp = &cipher_in[strlen("capi:")]; 2416 tmp = &cipher_in[strlen("capi:")];
2417 cipher_api = strsep(&tmp, "-"); 2417
2418 *ivmode = strsep(&tmp, ":"); 2418 /* Separate IV options if present, it can contain another '-' in hash name */
2419 *ivopts = tmp; 2419 *ivopts = strrchr(tmp, ':');
2420 if (*ivopts) {
2421 **ivopts = '\0';
2422 (*ivopts)++;
2423 }
2424 /* Parse IV mode */
2425 *ivmode = strrchr(tmp, '-');
2426 if (*ivmode) {
2427 **ivmode = '\0';
2428 (*ivmode)++;
2429 }
2430 /* The rest is crypto API spec */
2431 cipher_api = tmp;
2420 2432
2421 if (*ivmode && !strcmp(*ivmode, "lmk")) 2433 if (*ivmode && !strcmp(*ivmode, "lmk"))
2422 cc->tfms_count = 64; 2434 cc->tfms_count = 64;
@@ -2486,11 +2498,8 @@ static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *key
2486 goto bad_mem; 2498 goto bad_mem;
2487 2499
2488 chainmode = strsep(&tmp, "-"); 2500 chainmode = strsep(&tmp, "-");
2489 *ivopts = strsep(&tmp, "-"); 2501 *ivmode = strsep(&tmp, ":");
2490 *ivmode = strsep(&*ivopts, ":"); 2502 *ivopts = tmp;
2491
2492 if (tmp)
2493 DMWARN("Ignoring unexpected additional cipher options");
2494 2503
2495 /* 2504 /*
2496 * For compatibility with the original dm-crypt mapping format, if 2505 * For compatibility with the original dm-crypt mapping format, if
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 20b0776e39ef..ed3caceaed07 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -1678,7 +1678,7 @@ int dm_thin_remove_range(struct dm_thin_device *td,
1678 return r; 1678 return r;
1679} 1679}
1680 1680
1681int dm_pool_block_is_used(struct dm_pool_metadata *pmd, dm_block_t b, bool *result) 1681int dm_pool_block_is_shared(struct dm_pool_metadata *pmd, dm_block_t b, bool *result)
1682{ 1682{
1683 int r; 1683 int r;
1684 uint32_t ref_count; 1684 uint32_t ref_count;
@@ -1686,7 +1686,7 @@ int dm_pool_block_is_used(struct dm_pool_metadata *pmd, dm_block_t b, bool *resu
1686 down_read(&pmd->root_lock); 1686 down_read(&pmd->root_lock);
1687 r = dm_sm_get_count(pmd->data_sm, b, &ref_count); 1687 r = dm_sm_get_count(pmd->data_sm, b, &ref_count);
1688 if (!r) 1688 if (!r)
1689 *result = (ref_count != 0); 1689 *result = (ref_count > 1);
1690 up_read(&pmd->root_lock); 1690 up_read(&pmd->root_lock);
1691 1691
1692 return r; 1692 return r;
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index 35e954ea20a9..f6be0d733c20 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -195,7 +195,7 @@ int dm_pool_get_metadata_dev_size(struct dm_pool_metadata *pmd,
195 195
196int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result); 196int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result);
197 197
198int dm_pool_block_is_used(struct dm_pool_metadata *pmd, dm_block_t b, bool *result); 198int dm_pool_block_is_shared(struct dm_pool_metadata *pmd, dm_block_t b, bool *result);
199 199
200int dm_pool_inc_data_range(struct dm_pool_metadata *pmd, dm_block_t b, dm_block_t e); 200int dm_pool_inc_data_range(struct dm_pool_metadata *pmd, dm_block_t b, dm_block_t e);
201int dm_pool_dec_data_range(struct dm_pool_metadata *pmd, dm_block_t b, dm_block_t e); 201int dm_pool_dec_data_range(struct dm_pool_metadata *pmd, dm_block_t b, dm_block_t e);
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index dadd9696340c..ca8af21bf644 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1048,7 +1048,7 @@ static void passdown_double_checking_shared_status(struct dm_thin_new_mapping *m
1048 * passdown we have to check that these blocks are now unused. 1048 * passdown we have to check that these blocks are now unused.
1049 */ 1049 */
1050 int r = 0; 1050 int r = 0;
1051 bool used = true; 1051 bool shared = true;
1052 struct thin_c *tc = m->tc; 1052 struct thin_c *tc = m->tc;
1053 struct pool *pool = tc->pool; 1053 struct pool *pool = tc->pool;
1054 dm_block_t b = m->data_block, e, end = m->data_block + m->virt_end - m->virt_begin; 1054 dm_block_t b = m->data_block, e, end = m->data_block + m->virt_end - m->virt_begin;
@@ -1058,11 +1058,11 @@ static void passdown_double_checking_shared_status(struct dm_thin_new_mapping *m
1058 while (b != end) { 1058 while (b != end) {
1059 /* find start of unmapped run */ 1059 /* find start of unmapped run */
1060 for (; b < end; b++) { 1060 for (; b < end; b++) {
1061 r = dm_pool_block_is_used(pool->pmd, b, &used); 1061 r = dm_pool_block_is_shared(pool->pmd, b, &shared);
1062 if (r) 1062 if (r)
1063 goto out; 1063 goto out;
1064 1064
1065 if (!used) 1065 if (!shared)
1066 break; 1066 break;
1067 } 1067 }
1068 1068
@@ -1071,11 +1071,11 @@ static void passdown_double_checking_shared_status(struct dm_thin_new_mapping *m
1071 1071
1072 /* find end of run */ 1072 /* find end of run */
1073 for (e = b + 1; e != end; e++) { 1073 for (e = b + 1; e != end; e++) {
1074 r = dm_pool_block_is_used(pool->pmd, e, &used); 1074 r = dm_pool_block_is_shared(pool->pmd, e, &shared);
1075 if (r) 1075 if (r)
1076 goto out; 1076 goto out;
1077 1077
1078 if (used) 1078 if (shared)
1079 break; 1079 break;
1080 } 1080 }
1081 1081
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d67c95ef8d7e..2b53c3841b53 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1320,7 +1320,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
1320 1320
1321 __bio_clone_fast(clone, bio); 1321 __bio_clone_fast(clone, bio);
1322 1322
1323 if (unlikely(bio_integrity(bio) != NULL)) { 1323 if (bio_integrity(bio)) {
1324 int r; 1324 int r;
1325 1325
1326 if (unlikely(!dm_target_has_integrity(tio->ti->type) && 1326 if (unlikely(!dm_target_has_integrity(tio->ti->type) &&
@@ -1336,11 +1336,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
1336 return r; 1336 return r;
1337 } 1337 }
1338 1338
1339 bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector)); 1339 bio_trim(clone, sector - clone->bi_iter.bi_sector, len);
1340 clone->bi_iter.bi_size = to_bytes(len);
1341
1342 if (unlikely(bio_integrity(bio) != NULL))
1343 bio_integrity_trim(clone);
1344 1340
1345 return 0; 1341 return 0;
1346} 1342}
@@ -1588,6 +1584,9 @@ static void init_clone_info(struct clone_info *ci, struct mapped_device *md,
1588 ci->sector = bio->bi_iter.bi_sector; 1584 ci->sector = bio->bi_iter.bi_sector;
1589} 1585}
1590 1586
1587#define __dm_part_stat_sub(part, field, subnd) \
1588 (part_stat_get(part, field) -= (subnd))
1589
1591/* 1590/*
1592 * Entry point to split a bio into clones and submit them to the targets. 1591 * Entry point to split a bio into clones and submit them to the targets.
1593 */ 1592 */
@@ -1642,7 +1641,21 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md,
1642 struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count, 1641 struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
1643 GFP_NOIO, &md->queue->bio_split); 1642 GFP_NOIO, &md->queue->bio_split);
1644 ci.io->orig_bio = b; 1643 ci.io->orig_bio = b;
1644
1645 /*
1646 * Adjust IO stats for each split, otherwise upon queue
1647 * reentry there will be redundant IO accounting.
1648 * NOTE: this is a stop-gap fix, a proper fix involves
1649 * significant refactoring of DM core's bio splitting
1650 * (by eliminating DM's splitting and just using bio_split)
1651 */
1652 part_stat_lock();
1653 __dm_part_stat_sub(&dm_disk(md)->part0,
1654 sectors[op_stat_group(bio_op(bio))], ci.sector_count);
1655 part_stat_unlock();
1656
1645 bio_chain(b, bio); 1657 bio_chain(b, bio);
1658 trace_block_split(md->queue, b, bio->bi_iter.bi_sector);
1646 ret = generic_make_request(bio); 1659 ret = generic_make_request(bio);
1647 break; 1660 break;
1648 } 1661 }
@@ -1713,6 +1726,15 @@ out:
1713 return ret; 1726 return ret;
1714} 1727}
1715 1728
1729static blk_qc_t dm_process_bio(struct mapped_device *md,
1730 struct dm_table *map, struct bio *bio)
1731{
1732 if (dm_get_md_type(md) == DM_TYPE_NVME_BIO_BASED)
1733 return __process_bio(md, map, bio);
1734 else
1735 return __split_and_process_bio(md, map, bio);
1736}
1737
1716static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio) 1738static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio)
1717{ 1739{
1718 struct mapped_device *md = q->queuedata; 1740 struct mapped_device *md = q->queuedata;
@@ -1733,10 +1755,7 @@ static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio)
1733 return ret; 1755 return ret;
1734 } 1756 }
1735 1757
1736 if (dm_get_md_type(md) == DM_TYPE_NVME_BIO_BASED) 1758 ret = dm_process_bio(md, map, bio);
1737 ret = __process_bio(md, map, bio);
1738 else
1739 ret = __split_and_process_bio(md, map, bio);
1740 1759
1741 dm_put_live_table(md, srcu_idx); 1760 dm_put_live_table(md, srcu_idx);
1742 return ret; 1761 return ret;
@@ -2415,9 +2434,9 @@ static void dm_wq_work(struct work_struct *work)
2415 break; 2434 break;
2416 2435
2417 if (dm_request_based(md)) 2436 if (dm_request_based(md))
2418 generic_make_request(c); 2437 (void) generic_make_request(c);
2419 else 2438 else
2420 __split_and_process_bio(md, map, c); 2439 (void) dm_process_bio(md, map, c);
2421 } 2440 }
2422 2441
2423 dm_put_live_table(md, srcu_idx); 2442 dm_put_live_table(md, srcu_idx);
diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index b8aaa684c397..2ed23c99f59f 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -820,21 +820,24 @@ static int ibmvmc_send_msg(struct crq_server_adapter *adapter,
820 * 820 *
821 * Return: 821 * Return:
822 * 0 - Success 822 * 0 - Success
823 * Non-zero - Failure
823 */ 824 */
824static int ibmvmc_open(struct inode *inode, struct file *file) 825static int ibmvmc_open(struct inode *inode, struct file *file)
825{ 826{
826 struct ibmvmc_file_session *session; 827 struct ibmvmc_file_session *session;
827 int rc = 0;
828 828
829 pr_debug("%s: inode = 0x%lx, file = 0x%lx, state = 0x%x\n", __func__, 829 pr_debug("%s: inode = 0x%lx, file = 0x%lx, state = 0x%x\n", __func__,
830 (unsigned long)inode, (unsigned long)file, 830 (unsigned long)inode, (unsigned long)file,
831 ibmvmc.state); 831 ibmvmc.state);
832 832
833 session = kzalloc(sizeof(*session), GFP_KERNEL); 833 session = kzalloc(sizeof(*session), GFP_KERNEL);
834 if (!session)
835 return -ENOMEM;
836
834 session->file = file; 837 session->file = file;
835 file->private_data = session; 838 file->private_data = session;
836 839
837 return rc; 840 return 0;
838} 841}
839 842
840/** 843/**
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 78c26cebf5d4..8f7616557c97 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -1187,9 +1187,15 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
1187 dma_setup_res = (struct hbm_dma_setup_response *)mei_msg; 1187 dma_setup_res = (struct hbm_dma_setup_response *)mei_msg;
1188 1188
1189 if (dma_setup_res->status) { 1189 if (dma_setup_res->status) {
1190 dev_info(dev->dev, "hbm: dma setup response: failure = %d %s\n", 1190 u8 status = dma_setup_res->status;
1191 dma_setup_res->status, 1191
1192 mei_hbm_status_str(dma_setup_res->status)); 1192 if (status == MEI_HBMS_NOT_ALLOWED) {
1193 dev_dbg(dev->dev, "hbm: dma setup not allowed\n");
1194 } else {
1195 dev_info(dev->dev, "hbm: dma setup response: failure = %d %s\n",
1196 status,
1197 mei_hbm_status_str(status));
1198 }
1193 dev->hbm_f_dr_supported = 0; 1199 dev->hbm_f_dr_supported = 0;
1194 mei_dmam_ring_free(dev); 1200 mei_dmam_ring_free(dev);
1195 } 1201 }
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
index e4b10b2d1a08..23739a60517f 100644
--- a/drivers/misc/mei/hw-me-regs.h
+++ b/drivers/misc/mei/hw-me-regs.h
@@ -127,6 +127,8 @@
127#define MEI_DEV_ID_BXT_M 0x1A9A /* Broxton M */ 127#define MEI_DEV_ID_BXT_M 0x1A9A /* Broxton M */
128#define MEI_DEV_ID_APL_I 0x5A9A /* Apollo Lake I */ 128#define MEI_DEV_ID_APL_I 0x5A9A /* Apollo Lake I */
129 129
130#define MEI_DEV_ID_DNV_IE 0x19E5 /* Denverton IE */
131
130#define MEI_DEV_ID_GLK 0x319A /* Gemini Lake */ 132#define MEI_DEV_ID_GLK 0x319A /* Gemini Lake */
131 133
132#define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */ 134#define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 73ace2d59dea..e89497f858ae 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -88,11 +88,13 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
88 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, MEI_ME_PCH8_CFG)}, 88 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, MEI_ME_PCH8_CFG)},
89 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, MEI_ME_PCH8_SPS_CFG)}, 89 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, MEI_ME_PCH8_SPS_CFG)},
90 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, MEI_ME_PCH8_SPS_CFG)}, 90 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, MEI_ME_PCH8_SPS_CFG)},
91 {MEI_PCI_DEVICE(MEI_DEV_ID_LBG, MEI_ME_PCH8_CFG)}, 91 {MEI_PCI_DEVICE(MEI_DEV_ID_LBG, MEI_ME_PCH12_CFG)},
92 92
93 {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, MEI_ME_PCH8_CFG)}, 93 {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, MEI_ME_PCH8_CFG)},
94 {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, MEI_ME_PCH8_CFG)}, 94 {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, MEI_ME_PCH8_CFG)},
95 95
96 {MEI_PCI_DEVICE(MEI_DEV_ID_DNV_IE, MEI_ME_PCH8_CFG)},
97
96 {MEI_PCI_DEVICE(MEI_DEV_ID_GLK, MEI_ME_PCH8_CFG)}, 98 {MEI_PCI_DEVICE(MEI_DEV_ID_GLK, MEI_ME_PCH8_CFG)},
97 99
98 {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)}, 100 {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)},
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index 595ac065b401..95ff7c5a1dfb 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -70,8 +70,12 @@ pvpanic_walk_resources(struct acpi_resource *res, void *context)
70 struct resource r; 70 struct resource r;
71 71
72 if (acpi_dev_resource_io(res, &r)) { 72 if (acpi_dev_resource_io(res, &r)) {
73#ifdef CONFIG_HAS_IOPORT_MAP
73 base = ioport_map(r.start, resource_size(&r)); 74 base = ioport_map(r.start, resource_size(&r));
74 return AE_OK; 75 return AE_OK;
76#else
77 return AE_ERROR;
78#endif
75 } else if (acpi_dev_resource_memory(res, &r)) { 79 } else if (acpi_dev_resource_memory(res, &r)) {
76 base = ioremap(r.start, resource_size(&r)); 80 base = ioremap(r.start, resource_size(&r));
77 return AE_OK; 81 return AE_OK;
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index e26b8145efb3..a44ec8bb5418 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -116,7 +116,7 @@ config MMC_RICOH_MMC
116 116
117config MMC_SDHCI_ACPI 117config MMC_SDHCI_ACPI
118 tristate "SDHCI support for ACPI enumerated SDHCI controllers" 118 tristate "SDHCI support for ACPI enumerated SDHCI controllers"
119 depends on MMC_SDHCI && ACPI 119 depends on MMC_SDHCI && ACPI && PCI
120 select IOSF_MBI if X86 120 select IOSF_MBI if X86
121 help 121 help
122 This selects support for ACPI enumerated SDHCI controllers, 122 This selects support for ACPI enumerated SDHCI controllers,
@@ -978,7 +978,7 @@ config MMC_SDHCI_OMAP
978 tristate "TI SDHCI Controller Support" 978 tristate "TI SDHCI Controller Support"
979 depends on MMC_SDHCI_PLTFM && OF 979 depends on MMC_SDHCI_PLTFM && OF
980 select THERMAL 980 select THERMAL
981 select TI_SOC_THERMAL 981 imply TI_SOC_THERMAL
982 help 982 help
983 This selects the Secure Digital Host Controller Interface (SDHCI) 983 This selects the Secure Digital Host Controller Interface (SDHCI)
984 support present in TI's DRA7 SOCs. The controller supports 984 support present in TI's DRA7 SOCs. The controller supports
diff --git a/drivers/mmc/host/dw_mmc-bluefield.c b/drivers/mmc/host/dw_mmc-bluefield.c
index ed8f2254b66a..aa38b1a8017e 100644
--- a/drivers/mmc/host/dw_mmc-bluefield.c
+++ b/drivers/mmc/host/dw_mmc-bluefield.c
@@ -1,11 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* 2/*
3 * Copyright (C) 2018 Mellanox Technologies. 3 * Copyright (C) 2018 Mellanox Technologies.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */ 4 */
10 5
11#include <linux/bitfield.h> 6#include <linux/bitfield.h>
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index c2690c1a50ff..f19ec60bcbdc 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -179,6 +179,8 @@ struct meson_host {
179 struct sd_emmc_desc *descs; 179 struct sd_emmc_desc *descs;
180 dma_addr_t descs_dma_addr; 180 dma_addr_t descs_dma_addr;
181 181
182 int irq;
183
182 bool vqmmc_enabled; 184 bool vqmmc_enabled;
183}; 185};
184 186
@@ -738,6 +740,11 @@ static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode,
738static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) 740static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
739{ 741{
740 struct meson_host *host = mmc_priv(mmc); 742 struct meson_host *host = mmc_priv(mmc);
743 int adj = 0;
744
745 /* enable signal resampling w/o delay */
746 adj = ADJUST_ADJ_EN;
747 writel(adj, host->regs + host->data->adjust);
741 748
742 return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); 749 return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk);
743} 750}
@@ -768,6 +775,9 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
768 if (!IS_ERR(mmc->supply.vmmc)) 775 if (!IS_ERR(mmc->supply.vmmc))
769 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); 776 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
770 777
778 /* disable signal resampling */
779 writel(0, host->regs + host->data->adjust);
780
771 /* Reset rx phase */ 781 /* Reset rx phase */
772 clk_set_phase(host->rx_clk, 0); 782 clk_set_phase(host->rx_clk, 0);
773 783
@@ -1166,7 +1176,7 @@ static int meson_mmc_get_cd(struct mmc_host *mmc)
1166 1176
1167static void meson_mmc_cfg_init(struct meson_host *host) 1177static void meson_mmc_cfg_init(struct meson_host *host)
1168{ 1178{
1169 u32 cfg = 0, adj = 0; 1179 u32 cfg = 0;
1170 1180
1171 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK, 1181 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK,
1172 ilog2(SD_EMMC_CFG_RESP_TIMEOUT)); 1182 ilog2(SD_EMMC_CFG_RESP_TIMEOUT));
@@ -1177,10 +1187,6 @@ static void meson_mmc_cfg_init(struct meson_host *host)
1177 cfg |= CFG_ERR_ABORT; 1187 cfg |= CFG_ERR_ABORT;
1178 1188
1179 writel(cfg, host->regs + SD_EMMC_CFG); 1189 writel(cfg, host->regs + SD_EMMC_CFG);
1180
1181 /* enable signal resampling w/o delay */
1182 adj = ADJUST_ADJ_EN;
1183 writel(adj, host->regs + host->data->adjust);
1184} 1190}
1185 1191
1186static int meson_mmc_card_busy(struct mmc_host *mmc) 1192static int meson_mmc_card_busy(struct mmc_host *mmc)
@@ -1231,7 +1237,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
1231 struct resource *res; 1237 struct resource *res;
1232 struct meson_host *host; 1238 struct meson_host *host;
1233 struct mmc_host *mmc; 1239 struct mmc_host *mmc;
1234 int ret, irq; 1240 int ret;
1235 1241
1236 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev); 1242 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev);
1237 if (!mmc) 1243 if (!mmc)
@@ -1276,8 +1282,8 @@ static int meson_mmc_probe(struct platform_device *pdev)
1276 goto free_host; 1282 goto free_host;
1277 } 1283 }
1278 1284
1279 irq = platform_get_irq(pdev, 0); 1285 host->irq = platform_get_irq(pdev, 0);
1280 if (irq <= 0) { 1286 if (host->irq <= 0) {
1281 dev_err(&pdev->dev, "failed to get interrupt resource.\n"); 1287 dev_err(&pdev->dev, "failed to get interrupt resource.\n");
1282 ret = -EINVAL; 1288 ret = -EINVAL;
1283 goto free_host; 1289 goto free_host;
@@ -1331,9 +1337,8 @@ static int meson_mmc_probe(struct platform_device *pdev)
1331 writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN, 1337 writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN,
1332 host->regs + SD_EMMC_IRQ_EN); 1338 host->regs + SD_EMMC_IRQ_EN);
1333 1339
1334 ret = devm_request_threaded_irq(&pdev->dev, irq, meson_mmc_irq, 1340 ret = request_threaded_irq(host->irq, meson_mmc_irq,
1335 meson_mmc_irq_thread, IRQF_SHARED, 1341 meson_mmc_irq_thread, IRQF_SHARED, NULL, host);
1336 NULL, host);
1337 if (ret) 1342 if (ret)
1338 goto err_init_clk; 1343 goto err_init_clk;
1339 1344
@@ -1351,7 +1356,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
1351 if (host->bounce_buf == NULL) { 1356 if (host->bounce_buf == NULL) {
1352 dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); 1357 dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n");
1353 ret = -ENOMEM; 1358 ret = -ENOMEM;
1354 goto err_init_clk; 1359 goto err_free_irq;
1355 } 1360 }
1356 1361
1357 host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, 1362 host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
@@ -1370,6 +1375,8 @@ static int meson_mmc_probe(struct platform_device *pdev)
1370err_bounce_buf: 1375err_bounce_buf:
1371 dma_free_coherent(host->dev, host->bounce_buf_size, 1376 dma_free_coherent(host->dev, host->bounce_buf_size,
1372 host->bounce_buf, host->bounce_dma_addr); 1377 host->bounce_buf, host->bounce_dma_addr);
1378err_free_irq:
1379 free_irq(host->irq, host);
1373err_init_clk: 1380err_init_clk:
1374 clk_disable_unprepare(host->mmc_clk); 1381 clk_disable_unprepare(host->mmc_clk);
1375err_core_clk: 1382err_core_clk:
@@ -1387,6 +1394,7 @@ static int meson_mmc_remove(struct platform_device *pdev)
1387 1394
1388 /* disable interrupts */ 1395 /* disable interrupts */
1389 writel(0, host->regs + SD_EMMC_IRQ_EN); 1396 writel(0, host->regs + SD_EMMC_IRQ_EN);
1397 free_irq(host->irq, host);
1390 1398
1391 dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, 1399 dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
1392 host->descs, host->descs_dma_addr); 1400 host->descs, host->descs_dma_addr);
diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c
index 0db99057c44f..9d12c06c7fd6 100644
--- a/drivers/mmc/host/sdhci-iproc.c
+++ b/drivers/mmc/host/sdhci-iproc.c
@@ -296,7 +296,10 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
296 296
297 iproc_host->data = iproc_data; 297 iproc_host->data = iproc_data;
298 298
299 mmc_of_parse(host->mmc); 299 ret = mmc_of_parse(host->mmc);
300 if (ret)
301 goto err;
302
300 sdhci_get_property(pdev); 303 sdhci_get_property(pdev);
301 304
302 host->mmc->caps |= iproc_host->data->mmc_caps; 305 host->mmc->caps |= iproc_host->data->mmc_caps;
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 3b3f88ffab53..c05e4d50d43d 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -480,8 +480,6 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb);
480struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) 480struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
481{ 481{
482 struct can_priv *priv = netdev_priv(dev); 482 struct can_priv *priv = netdev_priv(dev);
483 struct sk_buff *skb = priv->echo_skb[idx];
484 struct canfd_frame *cf;
485 483
486 if (idx >= priv->echo_skb_max) { 484 if (idx >= priv->echo_skb_max) {
487 netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n", 485 netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
@@ -489,20 +487,21 @@ struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8
489 return NULL; 487 return NULL;
490 } 488 }
491 489
492 if (!skb) { 490 if (priv->echo_skb[idx]) {
493 netdev_err(dev, "%s: BUG! Trying to echo non existing skb: can_priv::echo_skb[%u]\n", 491 /* Using "struct canfd_frame::len" for the frame
494 __func__, idx); 492 * length is supported on both CAN and CANFD frames.
495 return NULL; 493 */
496 } 494 struct sk_buff *skb = priv->echo_skb[idx];
495 struct canfd_frame *cf = (struct canfd_frame *)skb->data;
496 u8 len = cf->len;
497 497
498 /* Using "struct canfd_frame::len" for the frame 498 *len_ptr = len;
499 * length is supported on both CAN and CANFD frames. 499 priv->echo_skb[idx] = NULL;
500 */
501 cf = (struct canfd_frame *)skb->data;
502 *len_ptr = cf->len;
503 priv->echo_skb[idx] = NULL;
504 500
505 return skb; 501 return skb;
502 }
503
504 return NULL;
506} 505}
507 506
508/* 507/*
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 0f36eafe3ac1..1c66fb2ad76b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1106,7 +1106,7 @@ static int flexcan_chip_start(struct net_device *dev)
1106 } 1106 }
1107 } else { 1107 } else {
1108 /* clear and invalidate unused mailboxes first */ 1108 /* clear and invalidate unused mailboxes first */
1109 for (i = FLEXCAN_TX_MB_RESERVED_OFF_FIFO; i <= priv->mb_count; i++) { 1109 for (i = FLEXCAN_TX_MB_RESERVED_OFF_FIFO; i < priv->mb_count; i++) {
1110 mb = flexcan_get_mb(priv, i); 1110 mb = flexcan_get_mb(priv, i);
1111 priv->write(FLEXCAN_MB_CODE_RX_INACTIVE, 1111 priv->write(FLEXCAN_MB_CODE_RX_INACTIVE,
1112 &mb->can_ctrl); 1112 &mb->can_ctrl);
@@ -1432,7 +1432,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
1432 gpr_np = of_find_node_by_phandle(phandle); 1432 gpr_np = of_find_node_by_phandle(phandle);
1433 if (!gpr_np) { 1433 if (!gpr_np) {
1434 dev_dbg(&pdev->dev, "could not find gpr node by phandle\n"); 1434 dev_dbg(&pdev->dev, "could not find gpr node by phandle\n");
1435 return PTR_ERR(gpr_np); 1435 return -ENODEV;
1436 } 1436 }
1437 1437
1438 priv = netdev_priv(dev); 1438 priv = netdev_priv(dev);
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 02921d877c08..aa1d1f5339d2 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -714,8 +714,10 @@ static struct phy_device *connect_local_phy(struct net_device *dev)
714 714
715 phydev = phy_connect(dev, phy_id_fmt, &altera_tse_adjust_link, 715 phydev = phy_connect(dev, phy_id_fmt, &altera_tse_adjust_link,
716 priv->phy_iface); 716 priv->phy_iface);
717 if (IS_ERR(phydev)) 717 if (IS_ERR(phydev)) {
718 netdev_err(dev, "Could not attach to PHY\n"); 718 netdev_err(dev, "Could not attach to PHY\n");
719 phydev = NULL;
720 }
719 721
720 } else { 722 } else {
721 int ret; 723 int ret;
diff --git a/drivers/net/ethernet/freescale/dpaa2/Kconfig b/drivers/net/ethernet/freescale/dpaa2/Kconfig
index 809a155eb193..f6d244c663fd 100644
--- a/drivers/net/ethernet/freescale/dpaa2/Kconfig
+++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig
@@ -9,8 +9,9 @@ config FSL_DPAA2_ETH
9 9
10config FSL_DPAA2_PTP_CLOCK 10config FSL_DPAA2_PTP_CLOCK
11 tristate "Freescale DPAA2 PTP Clock" 11 tristate "Freescale DPAA2 PTP Clock"
12 depends on FSL_DPAA2_ETH && POSIX_TIMERS 12 depends on FSL_DPAA2_ETH
13 select PTP_1588_CLOCK 13 imply PTP_1588_CLOCK
14 default y
14 help 15 help
15 This driver adds support for using the DPAA2 1588 timer module 16 This driver adds support for using the DPAA2 1588 timer module
16 as a PTP clock. 17 as a PTP clock.
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index ae0f88bce9aa..2370dc204202 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3467,7 +3467,7 @@ fec_probe(struct platform_device *pdev)
3467 if (ret) 3467 if (ret)
3468 goto failed_clk_ipg; 3468 goto failed_clk_ipg;
3469 3469
3470 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy"); 3470 fep->reg_phy = devm_regulator_get_optional(&pdev->dev, "phy");
3471 if (!IS_ERR(fep->reg_phy)) { 3471 if (!IS_ERR(fep->reg_phy)) {
3472 ret = regulator_enable(fep->reg_phy); 3472 ret = regulator_enable(fep->reg_phy);
3473 if (ret) { 3473 if (ret) {
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 098d8764c0ea..dd71d5db7274 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1313,7 +1313,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
1313 unsigned long lpar_rc; 1313 unsigned long lpar_rc;
1314 u16 mss = 0; 1314 u16 mss = 0;
1315 1315
1316restart_poll:
1317 while (frames_processed < budget) { 1316 while (frames_processed < budget) {
1318 if (!ibmveth_rxq_pending_buffer(adapter)) 1317 if (!ibmveth_rxq_pending_buffer(adapter))
1319 break; 1318 break;
@@ -1401,7 +1400,6 @@ restart_poll:
1401 napi_reschedule(napi)) { 1400 napi_reschedule(napi)) {
1402 lpar_rc = h_vio_signal(adapter->vdev->unit_address, 1401 lpar_rc = h_vio_signal(adapter->vdev->unit_address,
1403 VIO_IRQ_DISABLE); 1402 VIO_IRQ_DISABLE);
1404 goto restart_poll;
1405 } 1403 }
1406 } 1404 }
1407 1405
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index db909b6069b5..65f8a4b6ed0c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -306,14 +306,16 @@ static int mlx4_init_user_cqes(void *buf, int entries, int cqe_size)
306 306
307 if (entries_per_copy < entries) { 307 if (entries_per_copy < entries) {
308 for (i = 0; i < entries / entries_per_copy; i++) { 308 for (i = 0; i < entries / entries_per_copy; i++) {
309 err = copy_to_user(buf, init_ents, PAGE_SIZE); 309 err = copy_to_user((void __user *)buf, init_ents, PAGE_SIZE) ?
310 -EFAULT : 0;
310 if (err) 311 if (err)
311 goto out; 312 goto out;
312 313
313 buf += PAGE_SIZE; 314 buf += PAGE_SIZE;
314 } 315 }
315 } else { 316 } else {
316 err = copy_to_user(buf, init_ents, entries * cqe_size); 317 err = copy_to_user((void __user *)buf, init_ents, entries * cqe_size) ?
318 -EFAULT : 0;
317 } 319 }
318 320
319out: 321out:
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 7df728f1e5b5..6e501af0e532 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -2067,9 +2067,11 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,
2067{ 2067{
2068 struct mlx4_cmd_mailbox *mailbox; 2068 struct mlx4_cmd_mailbox *mailbox;
2069 __be32 *outbox; 2069 __be32 *outbox;
2070 u64 qword_field;
2070 u32 dword_field; 2071 u32 dword_field;
2071 int err; 2072 u16 word_field;
2072 u8 byte_field; 2073 u8 byte_field;
2074 int err;
2073 static const u8 a0_dmfs_query_hw_steering[] = { 2075 static const u8 a0_dmfs_query_hw_steering[] = {
2074 [0] = MLX4_STEERING_DMFS_A0_DEFAULT, 2076 [0] = MLX4_STEERING_DMFS_A0_DEFAULT,
2075 [1] = MLX4_STEERING_DMFS_A0_DYNAMIC, 2077 [1] = MLX4_STEERING_DMFS_A0_DYNAMIC,
@@ -2097,19 +2099,32 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,
2097 2099
2098 /* QPC/EEC/CQC/EQC/RDMARC attributes */ 2100 /* QPC/EEC/CQC/EQC/RDMARC attributes */
2099 2101
2100 MLX4_GET(param->qpc_base, outbox, INIT_HCA_QPC_BASE_OFFSET); 2102 MLX4_GET(qword_field, outbox, INIT_HCA_QPC_BASE_OFFSET);
2101 MLX4_GET(param->log_num_qps, outbox, INIT_HCA_LOG_QP_OFFSET); 2103 param->qpc_base = qword_field & ~((u64)0x1f);
2102 MLX4_GET(param->srqc_base, outbox, INIT_HCA_SRQC_BASE_OFFSET); 2104 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_QP_OFFSET);
2103 MLX4_GET(param->log_num_srqs, outbox, INIT_HCA_LOG_SRQ_OFFSET); 2105 param->log_num_qps = byte_field & 0x1f;
2104 MLX4_GET(param->cqc_base, outbox, INIT_HCA_CQC_BASE_OFFSET); 2106 MLX4_GET(qword_field, outbox, INIT_HCA_SRQC_BASE_OFFSET);
2105 MLX4_GET(param->log_num_cqs, outbox, INIT_HCA_LOG_CQ_OFFSET); 2107 param->srqc_base = qword_field & ~((u64)0x1f);
2106 MLX4_GET(param->altc_base, outbox, INIT_HCA_ALTC_BASE_OFFSET); 2108 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_SRQ_OFFSET);
2107 MLX4_GET(param->auxc_base, outbox, INIT_HCA_AUXC_BASE_OFFSET); 2109 param->log_num_srqs = byte_field & 0x1f;
2108 MLX4_GET(param->eqc_base, outbox, INIT_HCA_EQC_BASE_OFFSET); 2110 MLX4_GET(qword_field, outbox, INIT_HCA_CQC_BASE_OFFSET);
2109 MLX4_GET(param->log_num_eqs, outbox, INIT_HCA_LOG_EQ_OFFSET); 2111 param->cqc_base = qword_field & ~((u64)0x1f);
2110 MLX4_GET(param->num_sys_eqs, outbox, INIT_HCA_NUM_SYS_EQS_OFFSET); 2112 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_CQ_OFFSET);
2111 MLX4_GET(param->rdmarc_base, outbox, INIT_HCA_RDMARC_BASE_OFFSET); 2113 param->log_num_cqs = byte_field & 0x1f;
2112 MLX4_GET(param->log_rd_per_qp, outbox, INIT_HCA_LOG_RD_OFFSET); 2114 MLX4_GET(qword_field, outbox, INIT_HCA_ALTC_BASE_OFFSET);
2115 param->altc_base = qword_field;
2116 MLX4_GET(qword_field, outbox, INIT_HCA_AUXC_BASE_OFFSET);
2117 param->auxc_base = qword_field;
2118 MLX4_GET(qword_field, outbox, INIT_HCA_EQC_BASE_OFFSET);
2119 param->eqc_base = qword_field & ~((u64)0x1f);
2120 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_EQ_OFFSET);
2121 param->log_num_eqs = byte_field & 0x1f;
2122 MLX4_GET(word_field, outbox, INIT_HCA_NUM_SYS_EQS_OFFSET);
2123 param->num_sys_eqs = word_field & 0xfff;
2124 MLX4_GET(qword_field, outbox, INIT_HCA_RDMARC_BASE_OFFSET);
2125 param->rdmarc_base = qword_field & ~((u64)0x1f);
2126 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_RD_OFFSET);
2127 param->log_rd_per_qp = byte_field & 0x7;
2113 2128
2114 MLX4_GET(dword_field, outbox, INIT_HCA_FLAGS_OFFSET); 2129 MLX4_GET(dword_field, outbox, INIT_HCA_FLAGS_OFFSET);
2115 if (dword_field & (1 << INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN)) { 2130 if (dword_field & (1 << INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN)) {
@@ -2128,22 +2143,21 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,
2128 /* steering attributes */ 2143 /* steering attributes */
2129 if (param->steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) { 2144 if (param->steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) {
2130 MLX4_GET(param->mc_base, outbox, INIT_HCA_FS_BASE_OFFSET); 2145 MLX4_GET(param->mc_base, outbox, INIT_HCA_FS_BASE_OFFSET);
2131 MLX4_GET(param->log_mc_entry_sz, outbox, 2146 MLX4_GET(byte_field, outbox, INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET);
2132 INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET); 2147 param->log_mc_entry_sz = byte_field & 0x1f;
2133 MLX4_GET(param->log_mc_table_sz, outbox, 2148 MLX4_GET(byte_field, outbox, INIT_HCA_FS_LOG_TABLE_SZ_OFFSET);
2134 INIT_HCA_FS_LOG_TABLE_SZ_OFFSET); 2149 param->log_mc_table_sz = byte_field & 0x1f;
2135 MLX4_GET(byte_field, outbox, 2150 MLX4_GET(byte_field, outbox, INIT_HCA_FS_A0_OFFSET);
2136 INIT_HCA_FS_A0_OFFSET);
2137 param->dmfs_high_steer_mode = 2151 param->dmfs_high_steer_mode =
2138 a0_dmfs_query_hw_steering[(byte_field >> 6) & 3]; 2152 a0_dmfs_query_hw_steering[(byte_field >> 6) & 3];
2139 } else { 2153 } else {
2140 MLX4_GET(param->mc_base, outbox, INIT_HCA_MC_BASE_OFFSET); 2154 MLX4_GET(param->mc_base, outbox, INIT_HCA_MC_BASE_OFFSET);
2141 MLX4_GET(param->log_mc_entry_sz, outbox, 2155 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET);
2142 INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); 2156 param->log_mc_entry_sz = byte_field & 0x1f;
2143 MLX4_GET(param->log_mc_hash_sz, outbox, 2157 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_HASH_SZ_OFFSET);
2144 INIT_HCA_LOG_MC_HASH_SZ_OFFSET); 2158 param->log_mc_hash_sz = byte_field & 0x1f;
2145 MLX4_GET(param->log_mc_table_sz, outbox, 2159 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET);
2146 INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); 2160 param->log_mc_table_sz = byte_field & 0x1f;
2147 } 2161 }
2148 2162
2149 /* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */ 2163 /* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */
@@ -2167,15 +2181,18 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,
2167 /* TPT attributes */ 2181 /* TPT attributes */
2168 2182
2169 MLX4_GET(param->dmpt_base, outbox, INIT_HCA_DMPT_BASE_OFFSET); 2183 MLX4_GET(param->dmpt_base, outbox, INIT_HCA_DMPT_BASE_OFFSET);
2170 MLX4_GET(param->mw_enabled, outbox, INIT_HCA_TPT_MW_OFFSET); 2184 MLX4_GET(byte_field, outbox, INIT_HCA_TPT_MW_OFFSET);
2171 MLX4_GET(param->log_mpt_sz, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET); 2185 param->mw_enabled = byte_field >> 7;
2186 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET);
2187 param->log_mpt_sz = byte_field & 0x3f;
2172 MLX4_GET(param->mtt_base, outbox, INIT_HCA_MTT_BASE_OFFSET); 2188 MLX4_GET(param->mtt_base, outbox, INIT_HCA_MTT_BASE_OFFSET);
2173 MLX4_GET(param->cmpt_base, outbox, INIT_HCA_CMPT_BASE_OFFSET); 2189 MLX4_GET(param->cmpt_base, outbox, INIT_HCA_CMPT_BASE_OFFSET);
2174 2190
2175 /* UAR attributes */ 2191 /* UAR attributes */
2176 2192
2177 MLX4_GET(param->uar_page_sz, outbox, INIT_HCA_UAR_PAGE_SZ_OFFSET); 2193 MLX4_GET(param->uar_page_sz, outbox, INIT_HCA_UAR_PAGE_SZ_OFFSET);
2178 MLX4_GET(param->log_uar_sz, outbox, INIT_HCA_LOG_UAR_SZ_OFFSET); 2194 MLX4_GET(byte_field, outbox, INIT_HCA_LOG_UAR_SZ_OFFSET);
2195 param->log_uar_sz = byte_field & 0xf;
2179 2196
2180 /* phv_check enable */ 2197 /* phv_check enable */
2181 MLX4_GET(byte_field, outbox, INIT_HCA_CACHELINE_SZ_OFFSET); 2198 MLX4_GET(byte_field, outbox, INIT_HCA_CACHELINE_SZ_OFFSET);
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index ffc1ada4e6da..d28c8f9ca55b 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -343,7 +343,7 @@ static int ravb_ring_init(struct net_device *ndev, int q)
343 int i; 343 int i;
344 344
345 priv->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : ndev->mtu) + 345 priv->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : ndev->mtu) +
346 ETH_HLEN + VLAN_HLEN; 346 ETH_HLEN + VLAN_HLEN + sizeof(__sum16);
347 347
348 /* Allocate RX and TX skb rings */ 348 /* Allocate RX and TX skb rings */
349 priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q], 349 priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q],
@@ -524,13 +524,15 @@ static void ravb_rx_csum(struct sk_buff *skb)
524{ 524{
525 u8 *hw_csum; 525 u8 *hw_csum;
526 526
527 /* The hardware checksum is 2 bytes appended to packet data */ 527 /* The hardware checksum is contained in sizeof(__sum16) (2) bytes
528 if (unlikely(skb->len < 2)) 528 * appended to packet data
529 */
530 if (unlikely(skb->len < sizeof(__sum16)))
529 return; 531 return;
530 hw_csum = skb_tail_pointer(skb) - 2; 532 hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
531 skb->csum = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); 533 skb->csum = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum));
532 skb->ip_summed = CHECKSUM_COMPLETE; 534 skb->ip_summed = CHECKSUM_COMPLETE;
533 skb_trim(skb, skb->len - 2); 535 skb_trim(skb, skb->len - sizeof(__sum16));
534} 536}
535 537
536/* Packet receive function for Ethernet AVB */ 538/* Packet receive function for Ethernet AVB */
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index ee42d4a887d7..6062e99fa69b 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -6047,22 +6047,25 @@ static const struct efx_ef10_nvram_type_info efx_ef10_nvram_types[] = {
6047 { NVRAM_PARTITION_TYPE_ROMCONFIG_DEFAULTS, 0, 0, "sfc_exp_rom_cfg_dflt" }, 6047 { NVRAM_PARTITION_TYPE_ROMCONFIG_DEFAULTS, 0, 0, "sfc_exp_rom_cfg_dflt" },
6048 { NVRAM_PARTITION_TYPE_STATUS, 0, 0, "sfc_status" }, 6048 { NVRAM_PARTITION_TYPE_STATUS, 0, 0, "sfc_status" },
6049}; 6049};
6050#define EF10_NVRAM_PARTITION_COUNT ARRAY_SIZE(efx_ef10_nvram_types)
6050 6051
6051static int efx_ef10_mtd_probe_partition(struct efx_nic *efx, 6052static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
6052 struct efx_mcdi_mtd_partition *part, 6053 struct efx_mcdi_mtd_partition *part,
6053 unsigned int type) 6054 unsigned int type,
6055 unsigned long *found)
6054{ 6056{
6055 MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN); 6057 MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN);
6056 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_METADATA_OUT_LENMAX); 6058 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_METADATA_OUT_LENMAX);
6057 const struct efx_ef10_nvram_type_info *info; 6059 const struct efx_ef10_nvram_type_info *info;
6058 size_t size, erase_size, outlen; 6060 size_t size, erase_size, outlen;
6061 int type_idx = 0;
6059 bool protected; 6062 bool protected;
6060 int rc; 6063 int rc;
6061 6064
6062 for (info = efx_ef10_nvram_types; ; info++) { 6065 for (type_idx = 0; ; type_idx++) {
6063 if (info == 6066 if (type_idx == EF10_NVRAM_PARTITION_COUNT)
6064 efx_ef10_nvram_types + ARRAY_SIZE(efx_ef10_nvram_types))
6065 return -ENODEV; 6067 return -ENODEV;
6068 info = efx_ef10_nvram_types + type_idx;
6066 if ((type & ~info->type_mask) == info->type) 6069 if ((type & ~info->type_mask) == info->type)
6067 break; 6070 break;
6068 } 6071 }
@@ -6082,6 +6085,13 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
6082 /* Protected partitions are read only. */ 6085 /* Protected partitions are read only. */
6083 erase_size = 0; 6086 erase_size = 0;
6084 6087
6088 /* If we've already exposed a partition of this type, hide this
6089 * duplicate. All operations on MTDs are keyed by the type anyway,
6090 * so we can't act on the duplicate.
6091 */
6092 if (__test_and_set_bit(type_idx, found))
6093 return -EEXIST;
6094
6085 part->nvram_type = type; 6095 part->nvram_type = type;
6086 6096
6087 MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type); 6097 MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type);
@@ -6113,6 +6123,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
6113static int efx_ef10_mtd_probe(struct efx_nic *efx) 6123static int efx_ef10_mtd_probe(struct efx_nic *efx)
6114{ 6124{
6115 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX); 6125 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX);
6126 DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT);
6116 struct efx_mcdi_mtd_partition *parts; 6127 struct efx_mcdi_mtd_partition *parts;
6117 size_t outlen, n_parts_total, i, n_parts; 6128 size_t outlen, n_parts_total, i, n_parts;
6118 unsigned int type; 6129 unsigned int type;
@@ -6141,11 +6152,13 @@ static int efx_ef10_mtd_probe(struct efx_nic *efx)
6141 for (i = 0; i < n_parts_total; i++) { 6152 for (i = 0; i < n_parts_total; i++) {
6142 type = MCDI_ARRAY_DWORD(outbuf, NVRAM_PARTITIONS_OUT_TYPE_ID, 6153 type = MCDI_ARRAY_DWORD(outbuf, NVRAM_PARTITIONS_OUT_TYPE_ID,
6143 i); 6154 i);
6144 rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type); 6155 rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type,
6145 if (rc == 0) 6156 found);
6146 n_parts++; 6157 if (rc == -EEXIST || rc == -ENODEV)
6147 else if (rc != -ENODEV) 6158 continue;
6159 if (rc)
6148 goto fail; 6160 goto fail;
6161 n_parts++;
6149 } 6162 }
6150 6163
6151 rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); 6164 rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 9020b084b953..7ec4eb74fe21 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0+
2/* cassini.c: Sun Microsystems Cassini(+) ethernet driver. 2/* cassini.c: Sun Microsystems Cassini(+) ethernet driver.
3 * 3 *
4 * Copyright (C) 2004 Sun Microsystems Inc. 4 * Copyright (C) 2004 Sun Microsystems Inc.
5 * Copyright (C) 2003 Adrian Sun (asun@darksunrising.com) 5 * Copyright (C) 2003 Adrian Sun (asun@darksunrising.com)
6 * 6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * This driver uses the sungem driver (c) David Miller 7 * This driver uses the sungem driver (c) David Miller
21 * (davem@redhat.com) as its basis. 8 * (davem@redhat.com) as its basis.
22 * 9 *
diff --git a/drivers/net/ethernet/sun/cassini.h b/drivers/net/ethernet/sun/cassini.h
index 13f3860496a8..ae5f05f03f88 100644
--- a/drivers/net/ethernet/sun/cassini.h
+++ b/drivers/net/ethernet/sun/cassini.h
@@ -1,23 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0+ */
2/* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $ 2/* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $
3 * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver. 3 * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver.
4 * 4 *
5 * Copyright (C) 2004 Sun Microsystems Inc. 5 * Copyright (C) 2004 Sun Microsystems Inc.
6 * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com) 6 * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 *
21 * vendor id: 0x108E (Sun Microsystems, Inc.) 8 * vendor id: 0x108E (Sun Microsystems, Inc.)
22 * device id: 0xabba (Cassini) 9 * device id: 0xabba (Cassini)
23 * revision ids: 0x01 = Cassini 10 * revision ids: 0x01 = Cassini
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index ef6f766f6389..e859ae2e42d5 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -144,6 +144,8 @@ struct hv_netvsc_packet {
144 u32 total_data_buflen; 144 u32 total_data_buflen;
145}; 145};
146 146
147#define NETVSC_HASH_KEYLEN 40
148
147struct netvsc_device_info { 149struct netvsc_device_info {
148 unsigned char mac_adr[ETH_ALEN]; 150 unsigned char mac_adr[ETH_ALEN];
149 u32 num_chn; 151 u32 num_chn;
@@ -151,6 +153,8 @@ struct netvsc_device_info {
151 u32 recv_sections; 153 u32 recv_sections;
152 u32 send_section_size; 154 u32 send_section_size;
153 u32 recv_section_size; 155 u32 recv_section_size;
156
157 u8 rss_key[NETVSC_HASH_KEYLEN];
154}; 158};
155 159
156enum rndis_device_state { 160enum rndis_device_state {
@@ -160,8 +164,6 @@ enum rndis_device_state {
160 RNDIS_DEV_DATAINITIALIZED, 164 RNDIS_DEV_DATAINITIALIZED,
161}; 165};
162 166
163#define NETVSC_HASH_KEYLEN 40
164
165struct rndis_device { 167struct rndis_device {
166 struct net_device *ndev; 168 struct net_device *ndev;
167 169
@@ -209,7 +211,9 @@ int netvsc_recv_callback(struct net_device *net,
209void netvsc_channel_cb(void *context); 211void netvsc_channel_cb(void *context);
210int netvsc_poll(struct napi_struct *napi, int budget); 212int netvsc_poll(struct napi_struct *napi, int budget);
211 213
212int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev); 214int rndis_set_subchannel(struct net_device *ndev,
215 struct netvsc_device *nvdev,
216 struct netvsc_device_info *dev_info);
213int rndis_filter_open(struct netvsc_device *nvdev); 217int rndis_filter_open(struct netvsc_device *nvdev);
214int rndis_filter_close(struct netvsc_device *nvdev); 218int rndis_filter_close(struct netvsc_device *nvdev);
215struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, 219struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
@@ -1177,7 +1181,7 @@ enum ndis_per_pkt_info_type {
1177 1181
1178enum rndis_per_pkt_info_interal_type { 1182enum rndis_per_pkt_info_interal_type {
1179 RNDIS_PKTINFO_ID = 1, 1183 RNDIS_PKTINFO_ID = 1,
1180 /* Add more memebers here */ 1184 /* Add more members here */
1181 1185
1182 RNDIS_PKTINFO_MAX 1186 RNDIS_PKTINFO_MAX
1183}; 1187};
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 922054c1d544..813d195bbd57 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -84,7 +84,7 @@ static void netvsc_subchan_work(struct work_struct *w)
84 84
85 rdev = nvdev->extension; 85 rdev = nvdev->extension;
86 if (rdev) { 86 if (rdev) {
87 ret = rndis_set_subchannel(rdev->ndev, nvdev); 87 ret = rndis_set_subchannel(rdev->ndev, nvdev, NULL);
88 if (ret == 0) { 88 if (ret == 0) {
89 netif_device_attach(rdev->ndev); 89 netif_device_attach(rdev->ndev);
90 } else { 90 } else {
@@ -1331,7 +1331,7 @@ void netvsc_channel_cb(void *context)
1331 prefetch(hv_get_ring_buffer(rbi) + rbi->priv_read_index); 1331 prefetch(hv_get_ring_buffer(rbi) + rbi->priv_read_index);
1332 1332
1333 if (napi_schedule_prep(&nvchan->napi)) { 1333 if (napi_schedule_prep(&nvchan->napi)) {
1334 /* disable interupts from host */ 1334 /* disable interrupts from host */
1335 hv_begin_read(rbi); 1335 hv_begin_read(rbi);
1336 1336
1337 __napi_schedule_irqoff(&nvchan->napi); 1337 __napi_schedule_irqoff(&nvchan->napi);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 91ed15ea5883..256adbd044f5 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -370,7 +370,7 @@ static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
370{ 370{
371 int j = 0; 371 int j = 0;
372 372
373 /* Deal with compund pages by ignoring unused part 373 /* Deal with compound pages by ignoring unused part
374 * of the page. 374 * of the page.
375 */ 375 */
376 page += (offset >> PAGE_SHIFT); 376 page += (offset >> PAGE_SHIFT);
@@ -858,6 +858,39 @@ static void netvsc_get_channels(struct net_device *net,
858 } 858 }
859} 859}
860 860
861/* Alloc struct netvsc_device_info, and initialize it from either existing
862 * struct netvsc_device, or from default values.
863 */
864static struct netvsc_device_info *netvsc_devinfo_get
865 (struct netvsc_device *nvdev)
866{
867 struct netvsc_device_info *dev_info;
868
869 dev_info = kzalloc(sizeof(*dev_info), GFP_ATOMIC);
870
871 if (!dev_info)
872 return NULL;
873
874 if (nvdev) {
875 dev_info->num_chn = nvdev->num_chn;
876 dev_info->send_sections = nvdev->send_section_cnt;
877 dev_info->send_section_size = nvdev->send_section_size;
878 dev_info->recv_sections = nvdev->recv_section_cnt;
879 dev_info->recv_section_size = nvdev->recv_section_size;
880
881 memcpy(dev_info->rss_key, nvdev->extension->rss_key,
882 NETVSC_HASH_KEYLEN);
883 } else {
884 dev_info->num_chn = VRSS_CHANNEL_DEFAULT;
885 dev_info->send_sections = NETVSC_DEFAULT_TX;
886 dev_info->send_section_size = NETVSC_SEND_SECTION_SIZE;
887 dev_info->recv_sections = NETVSC_DEFAULT_RX;
888 dev_info->recv_section_size = NETVSC_RECV_SECTION_SIZE;
889 }
890
891 return dev_info;
892}
893
861static int netvsc_detach(struct net_device *ndev, 894static int netvsc_detach(struct net_device *ndev,
862 struct netvsc_device *nvdev) 895 struct netvsc_device *nvdev)
863{ 896{
@@ -909,7 +942,7 @@ static int netvsc_attach(struct net_device *ndev,
909 return PTR_ERR(nvdev); 942 return PTR_ERR(nvdev);
910 943
911 if (nvdev->num_chn > 1) { 944 if (nvdev->num_chn > 1) {
912 ret = rndis_set_subchannel(ndev, nvdev); 945 ret = rndis_set_subchannel(ndev, nvdev, dev_info);
913 946
914 /* if unavailable, just proceed with one queue */ 947 /* if unavailable, just proceed with one queue */
915 if (ret) { 948 if (ret) {
@@ -943,7 +976,7 @@ static int netvsc_set_channels(struct net_device *net,
943 struct net_device_context *net_device_ctx = netdev_priv(net); 976 struct net_device_context *net_device_ctx = netdev_priv(net);
944 struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); 977 struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
945 unsigned int orig, count = channels->combined_count; 978 unsigned int orig, count = channels->combined_count;
946 struct netvsc_device_info device_info; 979 struct netvsc_device_info *device_info;
947 int ret; 980 int ret;
948 981
949 /* We do not support separate count for rx, tx, or other */ 982 /* We do not support separate count for rx, tx, or other */
@@ -962,24 +995,26 @@ static int netvsc_set_channels(struct net_device *net,
962 995
963 orig = nvdev->num_chn; 996 orig = nvdev->num_chn;
964 997
965 memset(&device_info, 0, sizeof(device_info)); 998 device_info = netvsc_devinfo_get(nvdev);
966 device_info.num_chn = count; 999
967 device_info.send_sections = nvdev->send_section_cnt; 1000 if (!device_info)
968 device_info.send_section_size = nvdev->send_section_size; 1001 return -ENOMEM;
969 device_info.recv_sections = nvdev->recv_section_cnt; 1002
970 device_info.recv_section_size = nvdev->recv_section_size; 1003 device_info->num_chn = count;
971 1004
972 ret = netvsc_detach(net, nvdev); 1005 ret = netvsc_detach(net, nvdev);
973 if (ret) 1006 if (ret)
974 return ret; 1007 goto out;
975 1008
976 ret = netvsc_attach(net, &device_info); 1009 ret = netvsc_attach(net, device_info);
977 if (ret) { 1010 if (ret) {
978 device_info.num_chn = orig; 1011 device_info->num_chn = orig;
979 if (netvsc_attach(net, &device_info)) 1012 if (netvsc_attach(net, device_info))
980 netdev_err(net, "restoring channel setting failed\n"); 1013 netdev_err(net, "restoring channel setting failed\n");
981 } 1014 }
982 1015
1016out:
1017 kfree(device_info);
983 return ret; 1018 return ret;
984} 1019}
985 1020
@@ -1048,48 +1083,45 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
1048 struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); 1083 struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev);
1049 struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); 1084 struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
1050 int orig_mtu = ndev->mtu; 1085 int orig_mtu = ndev->mtu;
1051 struct netvsc_device_info device_info; 1086 struct netvsc_device_info *device_info;
1052 int ret = 0; 1087 int ret = 0;
1053 1088
1054 if (!nvdev || nvdev->destroy) 1089 if (!nvdev || nvdev->destroy)
1055 return -ENODEV; 1090 return -ENODEV;
1056 1091
1092 device_info = netvsc_devinfo_get(nvdev);
1093
1094 if (!device_info)
1095 return -ENOMEM;
1096
1057 /* Change MTU of underlying VF netdev first. */ 1097 /* Change MTU of underlying VF netdev first. */
1058 if (vf_netdev) { 1098 if (vf_netdev) {
1059 ret = dev_set_mtu(vf_netdev, mtu); 1099 ret = dev_set_mtu(vf_netdev, mtu);
1060 if (ret) 1100 if (ret)
1061 return ret; 1101 goto out;
1062 } 1102 }
1063 1103
1064 memset(&device_info, 0, sizeof(device_info));
1065 device_info.num_chn = nvdev->num_chn;
1066 device_info.send_sections = nvdev->send_section_cnt;
1067 device_info.send_section_size = nvdev->send_section_size;
1068 device_info.recv_sections = nvdev->recv_section_cnt;
1069 device_info.recv_section_size = nvdev->recv_section_size;
1070
1071 ret = netvsc_detach(ndev, nvdev); 1104 ret = netvsc_detach(ndev, nvdev);
1072 if (ret) 1105 if (ret)
1073 goto rollback_vf; 1106 goto rollback_vf;
1074 1107
1075 ndev->mtu = mtu; 1108 ndev->mtu = mtu;
1076 1109
1077 ret = netvsc_attach(ndev, &device_info); 1110 ret = netvsc_attach(ndev, device_info);
1078 if (ret) 1111 if (!ret)
1079 goto rollback; 1112 goto out;
1080
1081 return 0;
1082 1113
1083rollback:
1084 /* Attempt rollback to original MTU */ 1114 /* Attempt rollback to original MTU */
1085 ndev->mtu = orig_mtu; 1115 ndev->mtu = orig_mtu;
1086 1116
1087 if (netvsc_attach(ndev, &device_info)) 1117 if (netvsc_attach(ndev, device_info))
1088 netdev_err(ndev, "restoring mtu failed\n"); 1118 netdev_err(ndev, "restoring mtu failed\n");
1089rollback_vf: 1119rollback_vf:
1090 if (vf_netdev) 1120 if (vf_netdev)
1091 dev_set_mtu(vf_netdev, orig_mtu); 1121 dev_set_mtu(vf_netdev, orig_mtu);
1092 1122
1123out:
1124 kfree(device_info);
1093 return ret; 1125 return ret;
1094} 1126}
1095 1127
@@ -1674,7 +1706,7 @@ static int netvsc_set_ringparam(struct net_device *ndev,
1674{ 1706{
1675 struct net_device_context *ndevctx = netdev_priv(ndev); 1707 struct net_device_context *ndevctx = netdev_priv(ndev);
1676 struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); 1708 struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
1677 struct netvsc_device_info device_info; 1709 struct netvsc_device_info *device_info;
1678 struct ethtool_ringparam orig; 1710 struct ethtool_ringparam orig;
1679 u32 new_tx, new_rx; 1711 u32 new_tx, new_rx;
1680 int ret = 0; 1712 int ret = 0;
@@ -1694,26 +1726,29 @@ static int netvsc_set_ringparam(struct net_device *ndev,
1694 new_rx == orig.rx_pending) 1726 new_rx == orig.rx_pending)
1695 return 0; /* no change */ 1727 return 0; /* no change */
1696 1728
1697 memset(&device_info, 0, sizeof(device_info)); 1729 device_info = netvsc_devinfo_get(nvdev);
1698 device_info.num_chn = nvdev->num_chn; 1730
1699 device_info.send_sections = new_tx; 1731 if (!device_info)
1700 device_info.send_section_size = nvdev->send_section_size; 1732 return -ENOMEM;
1701 device_info.recv_sections = new_rx; 1733
1702 device_info.recv_section_size = nvdev->recv_section_size; 1734 device_info->send_sections = new_tx;
1735 device_info->recv_sections = new_rx;
1703 1736
1704 ret = netvsc_detach(ndev, nvdev); 1737 ret = netvsc_detach(ndev, nvdev);
1705 if (ret) 1738 if (ret)
1706 return ret; 1739 goto out;
1707 1740
1708 ret = netvsc_attach(ndev, &device_info); 1741 ret = netvsc_attach(ndev, device_info);
1709 if (ret) { 1742 if (ret) {
1710 device_info.send_sections = orig.tx_pending; 1743 device_info->send_sections = orig.tx_pending;
1711 device_info.recv_sections = orig.rx_pending; 1744 device_info->recv_sections = orig.rx_pending;
1712 1745
1713 if (netvsc_attach(ndev, &device_info)) 1746 if (netvsc_attach(ndev, device_info))
1714 netdev_err(ndev, "restoring ringparam failed"); 1747 netdev_err(ndev, "restoring ringparam failed");
1715 } 1748 }
1716 1749
1750out:
1751 kfree(device_info);
1717 return ret; 1752 return ret;
1718} 1753}
1719 1754
@@ -2088,7 +2123,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
2088 if (!netvsc_dev || rtnl_dereference(net_device_ctx->vf_netdev)) 2123 if (!netvsc_dev || rtnl_dereference(net_device_ctx->vf_netdev))
2089 return NOTIFY_DONE; 2124 return NOTIFY_DONE;
2090 2125
2091 /* if syntihetic interface is a different namespace, 2126 /* if synthetic interface is a different namespace,
2092 * then move the VF to that namespace; join will be 2127 * then move the VF to that namespace; join will be
2093 * done again in that context. 2128 * done again in that context.
2094 */ 2129 */
@@ -2167,7 +2202,7 @@ static int netvsc_probe(struct hv_device *dev,
2167{ 2202{
2168 struct net_device *net = NULL; 2203 struct net_device *net = NULL;
2169 struct net_device_context *net_device_ctx; 2204 struct net_device_context *net_device_ctx;
2170 struct netvsc_device_info device_info; 2205 struct netvsc_device_info *device_info = NULL;
2171 struct netvsc_device *nvdev; 2206 struct netvsc_device *nvdev;
2172 int ret = -ENOMEM; 2207 int ret = -ENOMEM;
2173 2208
@@ -2214,21 +2249,21 @@ static int netvsc_probe(struct hv_device *dev,
2214 netif_set_real_num_rx_queues(net, 1); 2249 netif_set_real_num_rx_queues(net, 1);
2215 2250
2216 /* Notify the netvsc driver of the new device */ 2251 /* Notify the netvsc driver of the new device */
2217 memset(&device_info, 0, sizeof(device_info)); 2252 device_info = netvsc_devinfo_get(NULL);
2218 device_info.num_chn = VRSS_CHANNEL_DEFAULT; 2253
2219 device_info.send_sections = NETVSC_DEFAULT_TX; 2254 if (!device_info) {
2220 device_info.send_section_size = NETVSC_SEND_SECTION_SIZE; 2255 ret = -ENOMEM;
2221 device_info.recv_sections = NETVSC_DEFAULT_RX; 2256 goto devinfo_failed;
2222 device_info.recv_section_size = NETVSC_RECV_SECTION_SIZE; 2257 }
2223 2258
2224 nvdev = rndis_filter_device_add(dev, &device_info); 2259 nvdev = rndis_filter_device_add(dev, device_info);
2225 if (IS_ERR(nvdev)) { 2260 if (IS_ERR(nvdev)) {
2226 ret = PTR_ERR(nvdev); 2261 ret = PTR_ERR(nvdev);
2227 netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); 2262 netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
2228 goto rndis_failed; 2263 goto rndis_failed;
2229 } 2264 }
2230 2265
2231 memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); 2266 memcpy(net->dev_addr, device_info->mac_adr, ETH_ALEN);
2232 2267
2233 /* We must get rtnl lock before scheduling nvdev->subchan_work, 2268 /* We must get rtnl lock before scheduling nvdev->subchan_work,
2234 * otherwise netvsc_subchan_work() can get rtnl lock first and wait 2269 * otherwise netvsc_subchan_work() can get rtnl lock first and wait
@@ -2236,7 +2271,7 @@ static int netvsc_probe(struct hv_device *dev,
2236 * netvsc_probe() can't get rtnl lock and as a result vmbus_onoffer() 2271 * netvsc_probe() can't get rtnl lock and as a result vmbus_onoffer()
2237 * -> ... -> device_add() -> ... -> __device_attach() can't get 2272 * -> ... -> device_add() -> ... -> __device_attach() can't get
2238 * the device lock, so all the subchannels can't be processed -- 2273 * the device lock, so all the subchannels can't be processed --
2239 * finally netvsc_subchan_work() hangs for ever. 2274 * finally netvsc_subchan_work() hangs forever.
2240 */ 2275 */
2241 rtnl_lock(); 2276 rtnl_lock();
2242 2277
@@ -2266,12 +2301,16 @@ static int netvsc_probe(struct hv_device *dev,
2266 2301
2267 list_add(&net_device_ctx->list, &netvsc_dev_list); 2302 list_add(&net_device_ctx->list, &netvsc_dev_list);
2268 rtnl_unlock(); 2303 rtnl_unlock();
2304
2305 kfree(device_info);
2269 return 0; 2306 return 0;
2270 2307
2271register_failed: 2308register_failed:
2272 rtnl_unlock(); 2309 rtnl_unlock();
2273 rndis_filter_device_remove(dev, nvdev); 2310 rndis_filter_device_remove(dev, nvdev);
2274rndis_failed: 2311rndis_failed:
2312 kfree(device_info);
2313devinfo_failed:
2275 free_percpu(net_device_ctx->vf_stats); 2314 free_percpu(net_device_ctx->vf_stats);
2276no_stats: 2315no_stats:
2277 hv_set_drvdata(dev, NULL); 2316 hv_set_drvdata(dev, NULL);
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 8b537a049c1e..73b60592de06 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -774,8 +774,8 @@ cleanup:
774 return ret; 774 return ret;
775} 775}
776 776
777int rndis_filter_set_rss_param(struct rndis_device *rdev, 777static int rndis_set_rss_param_msg(struct rndis_device *rdev,
778 const u8 *rss_key) 778 const u8 *rss_key, u16 flag)
779{ 779{
780 struct net_device *ndev = rdev->ndev; 780 struct net_device *ndev = rdev->ndev;
781 struct rndis_request *request; 781 struct rndis_request *request;
@@ -804,7 +804,7 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
804 rssp->hdr.type = NDIS_OBJECT_TYPE_RSS_PARAMETERS; 804 rssp->hdr.type = NDIS_OBJECT_TYPE_RSS_PARAMETERS;
805 rssp->hdr.rev = NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2; 805 rssp->hdr.rev = NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2;
806 rssp->hdr.size = sizeof(struct ndis_recv_scale_param); 806 rssp->hdr.size = sizeof(struct ndis_recv_scale_param);
807 rssp->flag = 0; 807 rssp->flag = flag;
808 rssp->hashinfo = NDIS_HASH_FUNC_TOEPLITZ | NDIS_HASH_IPV4 | 808 rssp->hashinfo = NDIS_HASH_FUNC_TOEPLITZ | NDIS_HASH_IPV4 |
809 NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 | 809 NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 |
810 NDIS_HASH_TCP_IPV6; 810 NDIS_HASH_TCP_IPV6;
@@ -829,9 +829,12 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
829 829
830 wait_for_completion(&request->wait_event); 830 wait_for_completion(&request->wait_event);
831 set_complete = &request->response_msg.msg.set_complete; 831 set_complete = &request->response_msg.msg.set_complete;
832 if (set_complete->status == RNDIS_STATUS_SUCCESS) 832 if (set_complete->status == RNDIS_STATUS_SUCCESS) {
833 memcpy(rdev->rss_key, rss_key, NETVSC_HASH_KEYLEN); 833 if (!(flag & NDIS_RSS_PARAM_FLAG_DISABLE_RSS) &&
834 else { 834 !(flag & NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED))
835 memcpy(rdev->rss_key, rss_key, NETVSC_HASH_KEYLEN);
836
837 } else {
835 netdev_err(ndev, "Fail to set RSS parameters:0x%x\n", 838 netdev_err(ndev, "Fail to set RSS parameters:0x%x\n",
836 set_complete->status); 839 set_complete->status);
837 ret = -EINVAL; 840 ret = -EINVAL;
@@ -842,6 +845,16 @@ cleanup:
842 return ret; 845 return ret;
843} 846}
844 847
848int rndis_filter_set_rss_param(struct rndis_device *rdev,
849 const u8 *rss_key)
850{
851 /* Disable RSS before change */
852 rndis_set_rss_param_msg(rdev, rss_key,
853 NDIS_RSS_PARAM_FLAG_DISABLE_RSS);
854
855 return rndis_set_rss_param_msg(rdev, rss_key, 0);
856}
857
845static int rndis_filter_query_device_link_status(struct rndis_device *dev, 858static int rndis_filter_query_device_link_status(struct rndis_device *dev,
846 struct netvsc_device *net_device) 859 struct netvsc_device *net_device)
847{ 860{
@@ -1121,7 +1134,9 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
1121 * This breaks overlap of processing the host message for the 1134 * This breaks overlap of processing the host message for the
1122 * new primary channel with the initialization of sub-channels. 1135 * new primary channel with the initialization of sub-channels.
1123 */ 1136 */
1124int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev) 1137int rndis_set_subchannel(struct net_device *ndev,
1138 struct netvsc_device *nvdev,
1139 struct netvsc_device_info *dev_info)
1125{ 1140{
1126 struct nvsp_message *init_packet = &nvdev->channel_init_pkt; 1141 struct nvsp_message *init_packet = &nvdev->channel_init_pkt;
1127 struct net_device_context *ndev_ctx = netdev_priv(ndev); 1142 struct net_device_context *ndev_ctx = netdev_priv(ndev);
@@ -1161,8 +1176,11 @@ int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev)
1161 wait_event(nvdev->subchan_open, 1176 wait_event(nvdev->subchan_open,
1162 atomic_read(&nvdev->open_chn) == nvdev->num_chn); 1177 atomic_read(&nvdev->open_chn) == nvdev->num_chn);
1163 1178
1164 /* ignore failues from setting rss parameters, still have channels */ 1179 /* ignore failures from setting rss parameters, still have channels */
1165 rndis_filter_set_rss_param(rdev, netvsc_hash_key); 1180 if (dev_info)
1181 rndis_filter_set_rss_param(rdev, dev_info->rss_key);
1182 else
1183 rndis_filter_set_rss_param(rdev, netvsc_hash_key);
1166 1184
1167 netif_set_real_num_tx_queues(ndev, nvdev->num_chn); 1185 netif_set_real_num_tx_queues(ndev, nvdev->num_chn);
1168 netif_set_real_num_rx_queues(ndev, nvdev->num_chn); 1186 netif_set_real_num_rx_queues(ndev, nvdev->num_chn);
diff --git a/drivers/net/phy/asix.c b/drivers/net/phy/asix.c
index 8ebe7f5484ae..f14ba5366b91 100644
--- a/drivers/net/phy/asix.c
+++ b/drivers/net/phy/asix.c
@@ -1,13 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0+
2/* Driver for Asix PHYs 2/* Driver for Asix PHYs
3 * 3 *
4 * Author: Michael Schmitz <schmitzmic@gmail.com> 4 * Author: Michael Schmitz <schmitzmic@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */ 5 */
12#include <linux/kernel.h> 6#include <linux/kernel.h>
13#include <linux/errno.h> 7#include <linux/errno.h>
diff --git a/drivers/net/phy/mdio-hisi-femac.c b/drivers/net/phy/mdio-hisi-femac.c
index b03fedd6c1d8..287f3ccf1da1 100644
--- a/drivers/net/phy/mdio-hisi-femac.c
+++ b/drivers/net/phy/mdio-hisi-femac.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Hisilicon Fast Ethernet MDIO Bus Driver 3 * Hisilicon Fast Ethernet MDIO Bus Driver
3 * 4 *
4 * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. 5 * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 6 */
19 7
20#include <linux/clk.h> 8#include <linux/clk.h>
@@ -163,4 +151,4 @@ module_platform_driver(hisi_femac_mdio_driver);
163 151
164MODULE_DESCRIPTION("Hisilicon Fast Ethernet MAC MDIO interface driver"); 152MODULE_DESCRIPTION("Hisilicon Fast Ethernet MAC MDIO interface driver");
165MODULE_AUTHOR("Dongpo Li <lidongpo@hisilicon.com>"); 153MODULE_AUTHOR("Dongpo Li <lidongpo@hisilicon.com>");
166MODULE_LICENSE("GPL v2"); 154MODULE_LICENSE("GPL");
diff --git a/drivers/net/phy/rockchip.c b/drivers/net/phy/rockchip.c
index f1da70b9b55f..95abf7072f32 100644
--- a/drivers/net/phy/rockchip.c
+++ b/drivers/net/phy/rockchip.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/** 2/**
2 * drivers/net/phy/rockchip.c 3 * drivers/net/phy/rockchip.c
3 * 4 *
@@ -6,12 +7,6 @@
6 * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd 7 * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
7 * 8 *
8 * David Wu <david.wu@rock-chips.com> 9 * David Wu <david.wu@rock-chips.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 */ 10 */
16 11
17#include <linux/ethtool.h> 12#include <linux/ethtool.h>
@@ -229,4 +224,4 @@ MODULE_DEVICE_TABLE(mdio, rockchip_phy_tbl);
229 224
230MODULE_AUTHOR("David Wu <david.wu@rock-chips.com>"); 225MODULE_AUTHOR("David Wu <david.wu@rock-chips.com>");
231MODULE_DESCRIPTION("Rockchip Ethernet PHY driver"); 226MODULE_DESCRIPTION("Rockchip Ethernet PHY driver");
232MODULE_LICENSE("GPL v2"); 227MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index b654f05b2ccd..3d93993e74da 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -739,8 +739,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
739 asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0); 739 asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0);
740 chipcode &= AX_CHIPCODE_MASK; 740 chipcode &= AX_CHIPCODE_MASK;
741 741
742 (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) : 742 ret = (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
743 ax88772a_hw_reset(dev, 0); 743 ax88772a_hw_reset(dev, 0);
744
745 if (ret < 0) {
746 netdev_dbg(dev->net, "Failed to reset AX88772: %d\n", ret);
747 return ret;
748 }
744 749
745 /* Read PHYID register *AFTER* the PHY was reset properly */ 750 /* Read PHYID register *AFTER* the PHY was reset properly */
746 phyid = asix_get_phyid(dev); 751 phyid = asix_get_phyid(dev);
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 3a4b8786f7ea..320edcac4699 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2761,6 +2761,11 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
2761 BIT(NL80211_CHAN_WIDTH_160); 2761 BIT(NL80211_CHAN_WIDTH_160);
2762 } 2762 }
2763 2763
2764 if (!n_limits) {
2765 err = -EINVAL;
2766 goto failed_hw;
2767 }
2768
2764 data->if_combination.n_limits = n_limits; 2769 data->if_combination.n_limits = n_limits;
2765 data->if_combination.max_interfaces = 2048; 2770 data->if_combination.max_interfaces = 2048;
2766 data->if_combination.limits = data->if_limits; 2771 data->if_combination.limits = data->if_limits;
diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c
index 64b218699656..3a93e4d9828b 100644
--- a/drivers/net/wireless/virt_wifi.c
+++ b/drivers/net/wireless/virt_wifi.c
@@ -530,8 +530,10 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev,
530 SET_NETDEV_DEV(dev, &priv->lowerdev->dev); 530 SET_NETDEV_DEV(dev, &priv->lowerdev->dev);
531 dev->ieee80211_ptr = kzalloc(sizeof(*dev->ieee80211_ptr), GFP_KERNEL); 531 dev->ieee80211_ptr = kzalloc(sizeof(*dev->ieee80211_ptr), GFP_KERNEL);
532 532
533 if (!dev->ieee80211_ptr) 533 if (!dev->ieee80211_ptr) {
534 err = -ENOMEM;
534 goto remove_handler; 535 goto remove_handler;
536 }
535 537
536 dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION; 538 dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
537 dev->ieee80211_ptr->wiphy = common_wiphy; 539 dev->ieee80211_ptr->wiphy = common_wiphy;
diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index 0cf58cabc9ed..3cf50274fadb 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -26,6 +26,12 @@ static int nvdimm_probe(struct device *dev)
26 struct nvdimm_drvdata *ndd; 26 struct nvdimm_drvdata *ndd;
27 int rc; 27 int rc;
28 28
29 rc = nvdimm_security_setup_events(dev);
30 if (rc < 0) {
31 dev_err(dev, "security event setup failed: %d\n", rc);
32 return rc;
33 }
34
29 rc = nvdimm_check_config_data(dev); 35 rc = nvdimm_check_config_data(dev);
30 if (rc) { 36 if (rc) {
31 /* not required for non-aliased nvdimm, ex. NVDIMM-N */ 37 /* not required for non-aliased nvdimm, ex. NVDIMM-N */
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 4890310df874..efe412a6b5b9 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -578,13 +578,25 @@ struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
578} 578}
579EXPORT_SYMBOL_GPL(__nvdimm_create); 579EXPORT_SYMBOL_GPL(__nvdimm_create);
580 580
581int nvdimm_security_setup_events(struct nvdimm *nvdimm) 581static void shutdown_security_notify(void *data)
582{ 582{
583 nvdimm->sec.overwrite_state = sysfs_get_dirent(nvdimm->dev.kobj.sd, 583 struct nvdimm *nvdimm = data;
584 "security"); 584
585 sysfs_put(nvdimm->sec.overwrite_state);
586}
587
588int nvdimm_security_setup_events(struct device *dev)
589{
590 struct nvdimm *nvdimm = to_nvdimm(dev);
591
592 if (nvdimm->sec.state < 0 || !nvdimm->sec.ops
593 || !nvdimm->sec.ops->overwrite)
594 return 0;
595 nvdimm->sec.overwrite_state = sysfs_get_dirent(dev->kobj.sd, "security");
585 if (!nvdimm->sec.overwrite_state) 596 if (!nvdimm->sec.overwrite_state)
586 return -ENODEV; 597 return -ENOMEM;
587 return 0; 598
599 return devm_add_action_or_reset(dev, shutdown_security_notify, nvdimm);
588} 600}
589EXPORT_SYMBOL_GPL(nvdimm_security_setup_events); 601EXPORT_SYMBOL_GPL(nvdimm_security_setup_events);
590 602
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index cfde992684e7..379bf4305e61 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -250,6 +250,7 @@ long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
250void nvdimm_set_aliasing(struct device *dev); 250void nvdimm_set_aliasing(struct device *dev);
251void nvdimm_set_locked(struct device *dev); 251void nvdimm_set_locked(struct device *dev);
252void nvdimm_clear_locked(struct device *dev); 252void nvdimm_clear_locked(struct device *dev);
253int nvdimm_security_setup_events(struct device *dev);
253#if IS_ENABLED(CONFIG_NVDIMM_KEYS) 254#if IS_ENABLED(CONFIG_NVDIMM_KEYS)
254int nvdimm_security_unlock(struct device *dev); 255int nvdimm_security_unlock(struct device *dev);
255#else 256#else
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index df4b3a6db51b..b9fff3b8ed1b 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -545,8 +545,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
545 timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0); 545 timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
546 ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) + 546 ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
547 ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc); 547 ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc);
548 if (!(ctrl->anacap & (1 << 6))) 548 ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32);
549 ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32);
550 549
551 if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) { 550 if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) {
552 dev_err(ctrl->device, 551 dev_err(ctrl->device,
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 0a2fd2949ad7..52abc3a6de12 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -119,6 +119,7 @@ struct nvme_rdma_ctrl {
119 119
120 struct nvme_ctrl ctrl; 120 struct nvme_ctrl ctrl;
121 bool use_inline_data; 121 bool use_inline_data;
122 u32 io_queues[HCTX_MAX_TYPES];
122}; 123};
123 124
124static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) 125static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl)
@@ -165,8 +166,8 @@ static inline int nvme_rdma_queue_idx(struct nvme_rdma_queue *queue)
165static bool nvme_rdma_poll_queue(struct nvme_rdma_queue *queue) 166static bool nvme_rdma_poll_queue(struct nvme_rdma_queue *queue)
166{ 167{
167 return nvme_rdma_queue_idx(queue) > 168 return nvme_rdma_queue_idx(queue) >
168 queue->ctrl->ctrl.opts->nr_io_queues + 169 queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] +
169 queue->ctrl->ctrl.opts->nr_write_queues; 170 queue->ctrl->io_queues[HCTX_TYPE_READ];
170} 171}
171 172
172static inline size_t nvme_rdma_inline_data_size(struct nvme_rdma_queue *queue) 173static inline size_t nvme_rdma_inline_data_size(struct nvme_rdma_queue *queue)
@@ -661,8 +662,21 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
661 nr_io_queues = min_t(unsigned int, nr_io_queues, 662 nr_io_queues = min_t(unsigned int, nr_io_queues,
662 ibdev->num_comp_vectors); 663 ibdev->num_comp_vectors);
663 664
664 nr_io_queues += min(opts->nr_write_queues, num_online_cpus()); 665 if (opts->nr_write_queues) {
665 nr_io_queues += min(opts->nr_poll_queues, num_online_cpus()); 666 ctrl->io_queues[HCTX_TYPE_DEFAULT] =
667 min(opts->nr_write_queues, nr_io_queues);
668 nr_io_queues += ctrl->io_queues[HCTX_TYPE_DEFAULT];
669 } else {
670 ctrl->io_queues[HCTX_TYPE_DEFAULT] = nr_io_queues;
671 }
672
673 ctrl->io_queues[HCTX_TYPE_READ] = nr_io_queues;
674
675 if (opts->nr_poll_queues) {
676 ctrl->io_queues[HCTX_TYPE_POLL] =
677 min(opts->nr_poll_queues, num_online_cpus());
678 nr_io_queues += ctrl->io_queues[HCTX_TYPE_POLL];
679 }
666 680
667 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); 681 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues);
668 if (ret) 682 if (ret)
@@ -1689,18 +1703,28 @@ static enum blk_eh_timer_return
1689nvme_rdma_timeout(struct request *rq, bool reserved) 1703nvme_rdma_timeout(struct request *rq, bool reserved)
1690{ 1704{
1691 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); 1705 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
1706 struct nvme_rdma_queue *queue = req->queue;
1707 struct nvme_rdma_ctrl *ctrl = queue->ctrl;
1692 1708
1693 dev_warn(req->queue->ctrl->ctrl.device, 1709 dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n",
1694 "I/O %d QID %d timeout, reset controller\n", 1710 rq->tag, nvme_rdma_queue_idx(queue));
1695 rq->tag, nvme_rdma_queue_idx(req->queue));
1696 1711
1697 /* queue error recovery */ 1712 if (ctrl->ctrl.state != NVME_CTRL_LIVE) {
1698 nvme_rdma_error_recovery(req->queue->ctrl); 1713 /*
1714 * Teardown immediately if controller times out while starting
1715 * or we are already started error recovery. all outstanding
1716 * requests are completed on shutdown, so we return BLK_EH_DONE.
1717 */
1718 flush_work(&ctrl->err_work);
1719 nvme_rdma_teardown_io_queues(ctrl, false);
1720 nvme_rdma_teardown_admin_queue(ctrl, false);
1721 return BLK_EH_DONE;
1722 }
1699 1723
1700 /* fail with DNR on cmd timeout */ 1724 dev_warn(ctrl->ctrl.device, "starting error recovery\n");
1701 nvme_req(rq)->status = NVME_SC_ABORT_REQ | NVME_SC_DNR; 1725 nvme_rdma_error_recovery(ctrl);
1702 1726
1703 return BLK_EH_DONE; 1727 return BLK_EH_RESET_TIMER;
1704} 1728}
1705 1729
1706static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, 1730static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
@@ -1779,17 +1803,15 @@ static int nvme_rdma_map_queues(struct blk_mq_tag_set *set)
1779 struct nvme_rdma_ctrl *ctrl = set->driver_data; 1803 struct nvme_rdma_ctrl *ctrl = set->driver_data;
1780 1804
1781 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; 1805 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0;
1782 set->map[HCTX_TYPE_READ].nr_queues = ctrl->ctrl.opts->nr_io_queues; 1806 set->map[HCTX_TYPE_DEFAULT].nr_queues =
1807 ctrl->io_queues[HCTX_TYPE_DEFAULT];
1808 set->map[HCTX_TYPE_READ].nr_queues = ctrl->io_queues[HCTX_TYPE_READ];
1783 if (ctrl->ctrl.opts->nr_write_queues) { 1809 if (ctrl->ctrl.opts->nr_write_queues) {
1784 /* separate read/write queues */ 1810 /* separate read/write queues */
1785 set->map[HCTX_TYPE_DEFAULT].nr_queues =
1786 ctrl->ctrl.opts->nr_write_queues;
1787 set->map[HCTX_TYPE_READ].queue_offset = 1811 set->map[HCTX_TYPE_READ].queue_offset =
1788 ctrl->ctrl.opts->nr_write_queues; 1812 ctrl->io_queues[HCTX_TYPE_DEFAULT];
1789 } else { 1813 } else {
1790 /* mixed read/write queues */ 1814 /* mixed read/write queues */
1791 set->map[HCTX_TYPE_DEFAULT].nr_queues =
1792 ctrl->ctrl.opts->nr_io_queues;
1793 set->map[HCTX_TYPE_READ].queue_offset = 0; 1815 set->map[HCTX_TYPE_READ].queue_offset = 0;
1794 } 1816 }
1795 blk_mq_rdma_map_queues(&set->map[HCTX_TYPE_DEFAULT], 1817 blk_mq_rdma_map_queues(&set->map[HCTX_TYPE_DEFAULT],
@@ -1799,12 +1821,12 @@ static int nvme_rdma_map_queues(struct blk_mq_tag_set *set)
1799 1821
1800 if (ctrl->ctrl.opts->nr_poll_queues) { 1822 if (ctrl->ctrl.opts->nr_poll_queues) {
1801 set->map[HCTX_TYPE_POLL].nr_queues = 1823 set->map[HCTX_TYPE_POLL].nr_queues =
1802 ctrl->ctrl.opts->nr_poll_queues; 1824 ctrl->io_queues[HCTX_TYPE_POLL];
1803 set->map[HCTX_TYPE_POLL].queue_offset = 1825 set->map[HCTX_TYPE_POLL].queue_offset =
1804 ctrl->ctrl.opts->nr_io_queues; 1826 ctrl->io_queues[HCTX_TYPE_DEFAULT];
1805 if (ctrl->ctrl.opts->nr_write_queues) 1827 if (ctrl->ctrl.opts->nr_write_queues)
1806 set->map[HCTX_TYPE_POLL].queue_offset += 1828 set->map[HCTX_TYPE_POLL].queue_offset +=
1807 ctrl->ctrl.opts->nr_write_queues; 1829 ctrl->io_queues[HCTX_TYPE_READ];
1808 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); 1830 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]);
1809 } 1831 }
1810 return 0; 1832 return 0;
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 265a0543b381..5f0a00425242 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1948,20 +1948,23 @@ nvme_tcp_timeout(struct request *rq, bool reserved)
1948 struct nvme_tcp_ctrl *ctrl = req->queue->ctrl; 1948 struct nvme_tcp_ctrl *ctrl = req->queue->ctrl;
1949 struct nvme_tcp_cmd_pdu *pdu = req->pdu; 1949 struct nvme_tcp_cmd_pdu *pdu = req->pdu;
1950 1950
1951 dev_dbg(ctrl->ctrl.device, 1951 dev_warn(ctrl->ctrl.device,
1952 "queue %d: timeout request %#x type %d\n", 1952 "queue %d: timeout request %#x type %d\n",
1953 nvme_tcp_queue_id(req->queue), rq->tag, 1953 nvme_tcp_queue_id(req->queue), rq->tag, pdu->hdr.type);
1954 pdu->hdr.type);
1955 1954
1956 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { 1955 if (ctrl->ctrl.state != NVME_CTRL_LIVE) {
1957 union nvme_result res = {}; 1956 /*
1958 1957 * Teardown immediately if controller times out while starting
1959 nvme_req(rq)->flags |= NVME_REQ_CANCELLED; 1958 * or we are already started error recovery. all outstanding
1960 nvme_end_request(rq, cpu_to_le16(NVME_SC_ABORT_REQ), res); 1959 * requests are completed on shutdown, so we return BLK_EH_DONE.
1960 */
1961 flush_work(&ctrl->err_work);
1962 nvme_tcp_teardown_io_queues(&ctrl->ctrl, false);
1963 nvme_tcp_teardown_admin_queue(&ctrl->ctrl, false);
1961 return BLK_EH_DONE; 1964 return BLK_EH_DONE;
1962 } 1965 }
1963 1966
1964 /* queue error recovery */ 1967 dev_warn(ctrl->ctrl.device, "starting error recovery\n");
1965 nvme_tcp_error_recovery(&ctrl->ctrl); 1968 nvme_tcp_error_recovery(&ctrl->ctrl);
1966 1969
1967 return BLK_EH_RESET_TIMER; 1970 return BLK_EH_RESET_TIMER;
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index a8d23eb80192..a884e3a0e8af 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -139,6 +139,10 @@ static void nvmet_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc);
139static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc); 139static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc);
140static void nvmet_rdma_qp_event(struct ib_event *event, void *priv); 140static void nvmet_rdma_qp_event(struct ib_event *event, void *priv);
141static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue); 141static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue);
142static void nvmet_rdma_free_rsp(struct nvmet_rdma_device *ndev,
143 struct nvmet_rdma_rsp *r);
144static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev,
145 struct nvmet_rdma_rsp *r);
142 146
143static const struct nvmet_fabrics_ops nvmet_rdma_ops; 147static const struct nvmet_fabrics_ops nvmet_rdma_ops;
144 148
@@ -182,9 +186,17 @@ nvmet_rdma_get_rsp(struct nvmet_rdma_queue *queue)
182 spin_unlock_irqrestore(&queue->rsps_lock, flags); 186 spin_unlock_irqrestore(&queue->rsps_lock, flags);
183 187
184 if (unlikely(!rsp)) { 188 if (unlikely(!rsp)) {
185 rsp = kmalloc(sizeof(*rsp), GFP_KERNEL); 189 int ret;
190
191 rsp = kzalloc(sizeof(*rsp), GFP_KERNEL);
186 if (unlikely(!rsp)) 192 if (unlikely(!rsp))
187 return NULL; 193 return NULL;
194 ret = nvmet_rdma_alloc_rsp(queue->dev, rsp);
195 if (unlikely(ret)) {
196 kfree(rsp);
197 return NULL;
198 }
199
188 rsp->allocated = true; 200 rsp->allocated = true;
189 } 201 }
190 202
@@ -197,6 +209,7 @@ nvmet_rdma_put_rsp(struct nvmet_rdma_rsp *rsp)
197 unsigned long flags; 209 unsigned long flags;
198 210
199 if (unlikely(rsp->allocated)) { 211 if (unlikely(rsp->allocated)) {
212 nvmet_rdma_free_rsp(rsp->queue->dev, rsp);
200 kfree(rsp); 213 kfree(rsp);
201 return; 214 return;
202 } 215 }
diff --git a/drivers/phy/qualcomm/phy-ath79-usb.c b/drivers/phy/qualcomm/phy-ath79-usb.c
index 6fd6e07ab345..09a77e556ece 100644
--- a/drivers/phy/qualcomm/phy-ath79-usb.c
+++ b/drivers/phy/qualcomm/phy-ath79-usb.c
@@ -31,7 +31,7 @@ static int ath79_usb_phy_power_on(struct phy *phy)
31 31
32 err = reset_control_deassert(priv->reset); 32 err = reset_control_deassert(priv->reset);
33 if (err && priv->no_suspend_override) 33 if (err && priv->no_suspend_override)
34 reset_control_assert(priv->no_suspend_override); 34 reset_control_deassert(priv->no_suspend_override);
35 35
36 return err; 36 return err;
37} 37}
@@ -69,7 +69,7 @@ static int ath79_usb_phy_probe(struct platform_device *pdev)
69 if (!priv) 69 if (!priv)
70 return -ENOMEM; 70 return -ENOMEM;
71 71
72 priv->reset = devm_reset_control_get(&pdev->dev, "usb-phy"); 72 priv->reset = devm_reset_control_get(&pdev->dev, "phy");
73 if (IS_ERR(priv->reset)) 73 if (IS_ERR(priv->reset))
74 return PTR_ERR(priv->reset); 74 return PTR_ERR(priv->reset);
75 75
diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
index 77fdaa551977..a52c5bb35033 100644
--- a/drivers/phy/ti/phy-gmii-sel.c
+++ b/drivers/phy/ti/phy-gmii-sel.c
@@ -204,11 +204,11 @@ static struct phy *phy_gmii_sel_of_xlate(struct device *dev,
204 204
205 if (args->args_count < 1) 205 if (args->args_count < 1)
206 return ERR_PTR(-EINVAL); 206 return ERR_PTR(-EINVAL);
207 if (!priv || !priv->if_phys)
208 return ERR_PTR(-ENODEV);
207 if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) && 209 if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) &&
208 args->args_count < 2) 210 args->args_count < 2)
209 return ERR_PTR(-EINVAL); 211 return ERR_PTR(-EINVAL);
210 if (!priv || !priv->if_phys)
211 return ERR_PTR(-ENODEV);
212 if (phy_id > priv->soc_data->num_ports) 212 if (phy_id > priv->soc_data->num_ports)
213 return ERR_PTR(-EINVAL); 213 return ERR_PTR(-EINVAL);
214 if (phy_id != priv->if_phys[phy_id - 1].id) 214 if (phy_id != priv->if_phys[phy_id - 1].id)
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c
index 194ffd5c8580..039b2074db7e 100644
--- a/drivers/s390/char/sclp_config.c
+++ b/drivers/s390/char/sclp_config.c
@@ -60,7 +60,9 @@ static void sclp_cpu_capability_notify(struct work_struct *work)
60 60
61static void __ref sclp_cpu_change_notify(struct work_struct *work) 61static void __ref sclp_cpu_change_notify(struct work_struct *work)
62{ 62{
63 lock_device_hotplug();
63 smp_rescan_cpus(); 64 smp_rescan_cpus();
65 unlock_device_hotplug();
64} 66}
65 67
66static void sclp_conf_receiver_fn(struct evbuf_header *evbuf) 68static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 634ddb90e7aa..7e56a11836c1 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1747,11 +1747,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1747 shost->max_sectors = (shost->sg_tablesize * 8) + 112; 1747 shost->max_sectors = (shost->sg_tablesize * 8) + 112;
1748 } 1748 }
1749 1749
1750 error = dma_set_max_seg_size(&pdev->dev, 1750 if (aac->adapter_info.options & AAC_OPT_NEW_COMM)
1751 (aac->adapter_info.options & AAC_OPT_NEW_COMM) ? 1751 shost->max_segment_size = shost->max_sectors << 9;
1752 (shost->max_sectors << 9) : 65536); 1752 else
1753 if (error) 1753 shost->max_segment_size = 65536;
1754 goto out_deinit;
1755 1754
1756 /* 1755 /*
1757 * Firmware printf works only with older firmware. 1756 * Firmware printf works only with older firmware.
diff --git a/drivers/scsi/csiostor/csio_attr.c b/drivers/scsi/csiostor/csio_attr.c
index 8a004036e3d7..9bd2bd8dc2be 100644
--- a/drivers/scsi/csiostor/csio_attr.c
+++ b/drivers/scsi/csiostor/csio_attr.c
@@ -594,12 +594,12 @@ csio_vport_create(struct fc_vport *fc_vport, bool disable)
594 } 594 }
595 595
596 fc_vport_set_state(fc_vport, FC_VPORT_INITIALIZING); 596 fc_vport_set_state(fc_vport, FC_VPORT_INITIALIZING);
597 ln->fc_vport = fc_vport;
597 598
598 if (csio_fcoe_alloc_vnp(hw, ln)) 599 if (csio_fcoe_alloc_vnp(hw, ln))
599 goto error; 600 goto error;
600 601
601 *(struct csio_lnode **)fc_vport->dd_data = ln; 602 *(struct csio_lnode **)fc_vport->dd_data = ln;
602 ln->fc_vport = fc_vport;
603 if (!fc_vport->node_name) 603 if (!fc_vport->node_name)
604 fc_vport->node_name = wwn_to_u64(csio_ln_wwnn(ln)); 604 fc_vport->node_name = wwn_to_u64(csio_ln_wwnn(ln));
605 if (!fc_vport->port_name) 605 if (!fc_vport->port_name)
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 4c66b19e6199..8c9f79042228 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -297,7 +297,8 @@ lpfc_nvme_localport_delete(struct nvme_fc_local_port *localport)
297 lport); 297 lport);
298 298
299 /* release any threads waiting for the unreg to complete */ 299 /* release any threads waiting for the unreg to complete */
300 complete(&lport->lport_unreg_done); 300 if (lport->vport->localport)
301 complete(lport->lport_unreg_cmp);
301} 302}
302 303
303/* lpfc_nvme_remoteport_delete 304/* lpfc_nvme_remoteport_delete
@@ -2545,7 +2546,8 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
2545 */ 2546 */
2546void 2547void
2547lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport, 2548lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport,
2548 struct lpfc_nvme_lport *lport) 2549 struct lpfc_nvme_lport *lport,
2550 struct completion *lport_unreg_cmp)
2549{ 2551{
2550#if (IS_ENABLED(CONFIG_NVME_FC)) 2552#if (IS_ENABLED(CONFIG_NVME_FC))
2551 u32 wait_tmo; 2553 u32 wait_tmo;
@@ -2557,8 +2559,7 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport,
2557 */ 2559 */
2558 wait_tmo = msecs_to_jiffies(LPFC_NVME_WAIT_TMO * 1000); 2560 wait_tmo = msecs_to_jiffies(LPFC_NVME_WAIT_TMO * 1000);
2559 while (true) { 2561 while (true) {
2560 ret = wait_for_completion_timeout(&lport->lport_unreg_done, 2562 ret = wait_for_completion_timeout(lport_unreg_cmp, wait_tmo);
2561 wait_tmo);
2562 if (unlikely(!ret)) { 2563 if (unlikely(!ret)) {
2563 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_IOERR, 2564 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_IOERR,
2564 "6176 Lport %p Localport %p wait " 2565 "6176 Lport %p Localport %p wait "
@@ -2592,12 +2593,12 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
2592 struct lpfc_nvme_lport *lport; 2593 struct lpfc_nvme_lport *lport;
2593 struct lpfc_nvme_ctrl_stat *cstat; 2594 struct lpfc_nvme_ctrl_stat *cstat;
2594 int ret; 2595 int ret;
2596 DECLARE_COMPLETION_ONSTACK(lport_unreg_cmp);
2595 2597
2596 if (vport->nvmei_support == 0) 2598 if (vport->nvmei_support == 0)
2597 return; 2599 return;
2598 2600
2599 localport = vport->localport; 2601 localport = vport->localport;
2600 vport->localport = NULL;
2601 lport = (struct lpfc_nvme_lport *)localport->private; 2602 lport = (struct lpfc_nvme_lport *)localport->private;
2602 cstat = lport->cstat; 2603 cstat = lport->cstat;
2603 2604
@@ -2608,13 +2609,14 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
2608 /* lport's rport list is clear. Unregister 2609 /* lport's rport list is clear. Unregister
2609 * lport and release resources. 2610 * lport and release resources.
2610 */ 2611 */
2611 init_completion(&lport->lport_unreg_done); 2612 lport->lport_unreg_cmp = &lport_unreg_cmp;
2612 ret = nvme_fc_unregister_localport(localport); 2613 ret = nvme_fc_unregister_localport(localport);
2613 2614
2614 /* Wait for completion. This either blocks 2615 /* Wait for completion. This either blocks
2615 * indefinitely or succeeds 2616 * indefinitely or succeeds
2616 */ 2617 */
2617 lpfc_nvme_lport_unreg_wait(vport, lport); 2618 lpfc_nvme_lport_unreg_wait(vport, lport, &lport_unreg_cmp);
2619 vport->localport = NULL;
2618 kfree(cstat); 2620 kfree(cstat);
2619 2621
2620 /* Regardless of the unregister upcall response, clear 2622 /* Regardless of the unregister upcall response, clear
diff --git a/drivers/scsi/lpfc/lpfc_nvme.h b/drivers/scsi/lpfc/lpfc_nvme.h
index cfd4719be25c..b234d0298994 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.h
+++ b/drivers/scsi/lpfc/lpfc_nvme.h
@@ -50,7 +50,7 @@ struct lpfc_nvme_ctrl_stat {
50/* Declare nvme-based local and remote port definitions. */ 50/* Declare nvme-based local and remote port definitions. */
51struct lpfc_nvme_lport { 51struct lpfc_nvme_lport {
52 struct lpfc_vport *vport; 52 struct lpfc_vport *vport;
53 struct completion lport_unreg_done; 53 struct completion *lport_unreg_cmp;
54 /* Add stats counters here */ 54 /* Add stats counters here */
55 struct lpfc_nvme_ctrl_stat *cstat; 55 struct lpfc_nvme_ctrl_stat *cstat;
56 atomic_t fc4NvmeLsRequests; 56 atomic_t fc4NvmeLsRequests;
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 6245f442d784..95fee83090eb 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1003,7 +1003,8 @@ lpfc_nvmet_targetport_delete(struct nvmet_fc_target_port *targetport)
1003 struct lpfc_nvmet_tgtport *tport = targetport->private; 1003 struct lpfc_nvmet_tgtport *tport = targetport->private;
1004 1004
1005 /* release any threads waiting for the unreg to complete */ 1005 /* release any threads waiting for the unreg to complete */
1006 complete(&tport->tport_unreg_done); 1006 if (tport->phba->targetport)
1007 complete(tport->tport_unreg_cmp);
1007} 1008}
1008 1009
1009static void 1010static void
@@ -1692,6 +1693,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba)
1692 struct lpfc_nvmet_tgtport *tgtp; 1693 struct lpfc_nvmet_tgtport *tgtp;
1693 struct lpfc_queue *wq; 1694 struct lpfc_queue *wq;
1694 uint32_t qidx; 1695 uint32_t qidx;
1696 DECLARE_COMPLETION_ONSTACK(tport_unreg_cmp);
1695 1697
1696 if (phba->nvmet_support == 0) 1698 if (phba->nvmet_support == 0)
1697 return; 1699 return;
@@ -1701,9 +1703,9 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba)
1701 wq = phba->sli4_hba.nvme_wq[qidx]; 1703 wq = phba->sli4_hba.nvme_wq[qidx];
1702 lpfc_nvmet_wqfull_flush(phba, wq, NULL); 1704 lpfc_nvmet_wqfull_flush(phba, wq, NULL);
1703 } 1705 }
1704 init_completion(&tgtp->tport_unreg_done); 1706 tgtp->tport_unreg_cmp = &tport_unreg_cmp;
1705 nvmet_fc_unregister_targetport(phba->targetport); 1707 nvmet_fc_unregister_targetport(phba->targetport);
1706 wait_for_completion_timeout(&tgtp->tport_unreg_done, 5); 1708 wait_for_completion_timeout(&tport_unreg_cmp, 5);
1707 lpfc_nvmet_cleanup_io_context(phba); 1709 lpfc_nvmet_cleanup_io_context(phba);
1708 } 1710 }
1709 phba->targetport = NULL; 1711 phba->targetport = NULL;
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.h b/drivers/scsi/lpfc/lpfc_nvmet.h
index 1aaff63f1f41..0ec1082ce7ef 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.h
+++ b/drivers/scsi/lpfc/lpfc_nvmet.h
@@ -34,7 +34,7 @@
34/* Used for NVME Target */ 34/* Used for NVME Target */
35struct lpfc_nvmet_tgtport { 35struct lpfc_nvmet_tgtport {
36 struct lpfc_hba *phba; 36 struct lpfc_hba *phba;
37 struct completion tport_unreg_done; 37 struct completion *tport_unreg_cmp;
38 38
39 /* Stats counters - lpfc_nvmet_unsol_ls_buffer */ 39 /* Stats counters - lpfc_nvmet_unsol_ls_buffer */
40 atomic_t rcv_ls_req_in; 40 atomic_t rcv_ls_req_in;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b13cc9288ba0..6d65ac584eba 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1842,8 +1842,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
1842 blk_queue_segment_boundary(q, shost->dma_boundary); 1842 blk_queue_segment_boundary(q, shost->dma_boundary);
1843 dma_set_seg_boundary(dev, shost->dma_boundary); 1843 dma_set_seg_boundary(dev, shost->dma_boundary);
1844 1844
1845 blk_queue_max_segment_size(q, 1845 blk_queue_max_segment_size(q, shost->max_segment_size);
1846 min(shost->max_segment_size, dma_get_max_seg_size(dev))); 1846 dma_set_max_seg_size(dev, shost->max_segment_size);
1847 1847
1848 /* 1848 /*
1849 * Set a reasonable default alignment: The larger of 32-byte (dword), 1849 * Set a reasonable default alignment: The larger of 32-byte (dword),
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 71334aaf1447..2ddf24466a62 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -108,13 +108,19 @@
108int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, 108int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
109 const char *prefix) 109 const char *prefix)
110{ 110{
111 u8 *regs; 111 u32 *regs;
112 size_t pos;
113
114 if (offset % 4 != 0 || len % 4 != 0) /* keep readl happy */
115 return -EINVAL;
112 116
113 regs = kzalloc(len, GFP_KERNEL); 117 regs = kzalloc(len, GFP_KERNEL);
114 if (!regs) 118 if (!regs)
115 return -ENOMEM; 119 return -ENOMEM;
116 120
117 memcpy_fromio(regs, hba->mmio_base + offset, len); 121 for (pos = 0; pos < len; pos += 4)
122 regs[pos / 4] = ufshcd_readl(hba, offset + pos);
123
118 ufshcd_hex_dump(prefix, regs, len); 124 ufshcd_hex_dump(prefix, regs, len);
119 kfree(regs); 125 kfree(regs);
120 126
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index a0802de8c3a1..6f5afab7c1a1 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -248,10 +248,10 @@ static void ion_dma_buf_detatch(struct dma_buf *dmabuf,
248 struct ion_dma_buf_attachment *a = attachment->priv; 248 struct ion_dma_buf_attachment *a = attachment->priv;
249 struct ion_buffer *buffer = dmabuf->priv; 249 struct ion_buffer *buffer = dmabuf->priv;
250 250
251 free_duped_table(a->table);
252 mutex_lock(&buffer->lock); 251 mutex_lock(&buffer->lock);
253 list_del(&a->list); 252 list_del(&a->list);
254 mutex_unlock(&buffer->lock); 253 mutex_unlock(&buffer->lock);
254 free_duped_table(a->table);
255 255
256 kfree(a); 256 kfree(a);
257} 257}
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 28cbd6b3d26c..dfee6985efa6 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -35,6 +35,7 @@ static const struct usb_device_id rtw_usb_id_tbl[] = {
35 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ 35 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
36 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ 36 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
37 {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ 37 {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
38 {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */
38 {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ 39 {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
39 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ 40 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
40 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ 41 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h
index bcc8dfa8e672..9efb4dcb9d3a 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -850,18 +850,18 @@ enum ieee80211_state {
850#define IP_FMT "%pI4" 850#define IP_FMT "%pI4"
851#define IP_ARG(x) (x) 851#define IP_ARG(x) (x)
852 852
853extern __inline int is_multicast_mac_addr(const u8 *addr) 853static inline int is_multicast_mac_addr(const u8 *addr)
854{ 854{
855 return ((addr[0] != 0xff) && (0x01 & addr[0])); 855 return ((addr[0] != 0xff) && (0x01 & addr[0]));
856} 856}
857 857
858extern __inline int is_broadcast_mac_addr(const u8 *addr) 858static inline int is_broadcast_mac_addr(const u8 *addr)
859{ 859{
860 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ 860 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
861 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); 861 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
862} 862}
863 863
864extern __inline int is_zero_mac_addr(const u8 *addr) 864static inline int is_zero_mac_addr(const u8 *addr)
865{ 865{
866 return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ 866 return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \
867 (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); 867 (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 9e17ec651bde..53f5a1cb4636 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -446,6 +446,7 @@ remote_event_wait(wait_queue_head_t *wq, struct remote_event *event)
446static inline void 446static inline void
447remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) 447remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event)
448{ 448{
449 event->fired = 1;
449 event->armed = 0; 450 event->armed = 0;
450 wake_up_all(wq); 451 wake_up_all(wq);
451} 452}
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 70c854d939ce..3d0badc34825 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -36,7 +36,7 @@ struct wilc_op_mode {
36struct wilc_reg_frame { 36struct wilc_reg_frame {
37 bool reg; 37 bool reg;
38 u8 reg_id; 38 u8 reg_id;
39 __le32 frame_type; 39 __le16 frame_type;
40} __packed; 40} __packed;
41 41
42struct wilc_drv_handler { 42struct wilc_drv_handler {
@@ -1744,7 +1744,6 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
1744 result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 1744 result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
1745 ARRAY_SIZE(wid_list), 1745 ARRAY_SIZE(wid_list),
1746 wilc_get_vif_idx(vif)); 1746 wilc_get_vif_idx(vif));
1747 kfree(gtk_key);
1748 } else if (mode == WILC_STATION_MODE) { 1747 } else if (mode == WILC_STATION_MODE) {
1749 struct wid wid; 1748 struct wid wid;
1750 1749
@@ -1754,9 +1753,9 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
1754 wid.val = (u8 *)gtk_key; 1753 wid.val = (u8 *)gtk_key;
1755 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, 1754 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
1756 wilc_get_vif_idx(vif)); 1755 wilc_get_vif_idx(vif));
1757 kfree(gtk_key);
1758 } 1756 }
1759 1757
1758 kfree(gtk_key);
1760 return result; 1759 return result;
1761} 1760}
1762 1761
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 3c5e9e030cad..489e5a5038f8 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1252,21 +1252,22 @@ static u32 init_chip(struct net_device *dev)
1252 ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, &reg); 1252 ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, &reg);
1253 if (!ret) { 1253 if (!ret) {
1254 netdev_err(dev, "fail read reg 0x1118\n"); 1254 netdev_err(dev, "fail read reg 0x1118\n");
1255 return ret; 1255 goto release;
1256 } 1256 }
1257 reg |= BIT(0); 1257 reg |= BIT(0);
1258 ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); 1258 ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg);
1259 if (!ret) { 1259 if (!ret) {
1260 netdev_err(dev, "fail write reg 0x1118\n"); 1260 netdev_err(dev, "fail write reg 0x1118\n");
1261 return ret; 1261 goto release;
1262 } 1262 }
1263 ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); 1263 ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71);
1264 if (!ret) { 1264 if (!ret) {
1265 netdev_err(dev, "fail write reg 0xc0000\n"); 1265 netdev_err(dev, "fail write reg 0xc0000\n");
1266 return ret; 1266 goto release;
1267 } 1267 }
1268 } 1268 }
1269 1269
1270release:
1270 release_bus(wilc, WILC_BUS_RELEASE_ONLY); 1271 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
1271 1272
1272 return ret; 1273 return ret;
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c34c88ef3319..5831e0eecea1 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1317,12 +1317,13 @@ static int tcmu_check_expired_cmd(int id, void *p, void *data)
1317 * target_complete_cmd will translate this to LUN COMM FAILURE 1317 * target_complete_cmd will translate this to LUN COMM FAILURE
1318 */ 1318 */
1319 scsi_status = SAM_STAT_CHECK_CONDITION; 1319 scsi_status = SAM_STAT_CHECK_CONDITION;
1320 list_del_init(&cmd->queue_entry);
1320 } else { 1321 } else {
1322 list_del_init(&cmd->queue_entry);
1321 idr_remove(&udev->commands, id); 1323 idr_remove(&udev->commands, id);
1322 tcmu_free_cmd(cmd); 1324 tcmu_free_cmd(cmd);
1323 scsi_status = SAM_STAT_TASK_SET_FULL; 1325 scsi_status = SAM_STAT_TASK_SET_FULL;
1324 } 1326 }
1325 list_del_init(&cmd->queue_entry);
1326 1327
1327 pr_debug("Timing out cmd %u on dev %s that is %s.\n", 1328 pr_debug("Timing out cmd %u on dev %s that is %s.\n",
1328 id, udev->name, is_running ? "inflight" : "queued"); 1329 id, udev->name, is_running ? "inflight" : "queued");
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
index 284cf2c5a8fd..8e1cf4d789be 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
@@ -84,7 +84,12 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \
84 struct pci_dev *pci_dev; \ 84 struct pci_dev *pci_dev; \
85 struct platform_device *pdev; \ 85 struct platform_device *pdev; \
86 struct proc_thermal_device *proc_dev; \ 86 struct proc_thermal_device *proc_dev; \
87\ 87 \
88 if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \
89 dev_warn(dev, "Attempted to get power limit before device was initialized!\n"); \
90 return 0; \
91 } \
92 \
88 if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \ 93 if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \
89 pdev = to_platform_device(dev); \ 94 pdev = to_platform_device(dev); \
90 proc_dev = platform_get_drvdata(pdev); \ 95 proc_dev = platform_get_drvdata(pdev); \
@@ -298,11 +303,6 @@ static int proc_thermal_add(struct device *dev,
298 *priv = proc_priv; 303 *priv = proc_priv;
299 304
300 ret = proc_thermal_read_ppcc(proc_priv); 305 ret = proc_thermal_read_ppcc(proc_priv);
301 if (!ret) {
302 ret = sysfs_create_group(&dev->kobj,
303 &power_limit_attribute_group);
304
305 }
306 if (ret) 306 if (ret)
307 return ret; 307 return ret;
308 308
@@ -316,8 +316,7 @@ static int proc_thermal_add(struct device *dev,
316 316
317 proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); 317 proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops);
318 if (IS_ERR(proc_priv->int340x_zone)) { 318 if (IS_ERR(proc_priv->int340x_zone)) {
319 ret = PTR_ERR(proc_priv->int340x_zone); 319 return PTR_ERR(proc_priv->int340x_zone);
320 goto remove_group;
321 } else 320 } else
322 ret = 0; 321 ret = 0;
323 322
@@ -331,9 +330,6 @@ static int proc_thermal_add(struct device *dev,
331 330
332remove_zone: 331remove_zone:
333 int340x_thermal_zone_remove(proc_priv->int340x_zone); 332 int340x_thermal_zone_remove(proc_priv->int340x_zone);
334remove_group:
335 sysfs_remove_group(&proc_priv->dev->kobj,
336 &power_limit_attribute_group);
337 333
338 return ret; 334 return ret;
339} 335}
@@ -364,7 +360,10 @@ static int int3401_add(struct platform_device *pdev)
364 platform_set_drvdata(pdev, proc_priv); 360 platform_set_drvdata(pdev, proc_priv);
365 proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV; 361 proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV;
366 362
367 return 0; 363 dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PLATFORM_DEV\n");
364
365 return sysfs_create_group(&pdev->dev.kobj,
366 &power_limit_attribute_group);
368} 367}
369 368
370static int int3401_remove(struct platform_device *pdev) 369static int int3401_remove(struct platform_device *pdev)
@@ -423,7 +422,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
423 proc_priv->soc_dts = intel_soc_dts_iosf_init( 422 proc_priv->soc_dts = intel_soc_dts_iosf_init(
424 INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0); 423 INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);
425 424
426 if (proc_priv->soc_dts && pdev->irq) { 425 if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) {
427 ret = pci_enable_msi(pdev); 426 ret = pci_enable_msi(pdev);
428 if (!ret) { 427 if (!ret) {
429 ret = request_threaded_irq(pdev->irq, NULL, 428 ret = request_threaded_irq(pdev->irq, NULL,
@@ -441,7 +440,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
441 dev_err(&pdev->dev, "No auxiliary DTSs enabled\n"); 440 dev_err(&pdev->dev, "No auxiliary DTSs enabled\n");
442 } 441 }
443 442
444 return 0; 443 dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PCI\n");
444
445 return sysfs_create_group(&pdev->dev.kobj,
446 &power_limit_attribute_group);
445} 447}
446 448
447static void proc_thermal_pci_remove(struct pci_dev *pdev) 449static void proc_thermal_pci_remove(struct pci_dev *pdev)
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 4164414d4c64..8bdf42bc8fc8 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -597,6 +597,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
597 /* too large for caller's buffer */ 597 /* too large for caller's buffer */
598 ret = -EOVERFLOW; 598 ret = -EOVERFLOW;
599 } else { 599 } else {
600 __set_current_state(TASK_RUNNING);
600 if (copy_to_user(buf, rbuf->buf, rbuf->count)) 601 if (copy_to_user(buf, rbuf->buf, rbuf->count))
601 ret = -EFAULT; 602 ret = -EFAULT;
602 else 603 else
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 189ab1212d9a..e441221e04b9 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1070,15 +1070,16 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
1070 1070
1071 ret = 0; 1071 ret = 0;
1072 } 1072 }
1073 }
1074 1073
1075 /* Initialise interrupt backoff work if required */ 1074 /* Initialise interrupt backoff work if required */
1076 if (up->overrun_backoff_time_ms > 0) { 1075 if (up->overrun_backoff_time_ms > 0) {
1077 uart->overrun_backoff_time_ms = up->overrun_backoff_time_ms; 1076 uart->overrun_backoff_time_ms =
1078 INIT_DELAYED_WORK(&uart->overrun_backoff, 1077 up->overrun_backoff_time_ms;
1079 serial_8250_overrun_backoff_work); 1078 INIT_DELAYED_WORK(&uart->overrun_backoff,
1080 } else { 1079 serial_8250_overrun_backoff_work);
1081 uart->overrun_backoff_time_ms = 0; 1080 } else {
1081 uart->overrun_backoff_time_ms = 0;
1082 }
1082 } 1083 }
1083 1084
1084 mutex_unlock(&serial_mutex); 1085 mutex_unlock(&serial_mutex);
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 241a48e5052c..debdd1b9e01a 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1697,7 +1697,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
1697 } 1697 }
1698 1698
1699 /* ask the core to calculate the divisor */ 1699 /* ask the core to calculate the divisor */
1700 baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16); 1700 baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 4);
1701 1701
1702 spin_lock_irqsave(&sport->port.lock, flags); 1702 spin_lock_irqsave(&sport->port.lock, flags);
1703 1703
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index a72d6d9fb983..38016609c7fa 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -225,7 +225,7 @@ static unsigned int qcom_geni_serial_get_mctrl(struct uart_port *uport)
225 unsigned int mctrl = TIOCM_DSR | TIOCM_CAR; 225 unsigned int mctrl = TIOCM_DSR | TIOCM_CAR;
226 u32 geni_ios; 226 u32 geni_ios;
227 227
228 if (uart_console(uport) || !uart_cts_enabled(uport)) { 228 if (uart_console(uport)) {
229 mctrl |= TIOCM_CTS; 229 mctrl |= TIOCM_CTS;
230 } else { 230 } else {
231 geni_ios = readl_relaxed(uport->membase + SE_GENI_IOS); 231 geni_ios = readl_relaxed(uport->membase + SE_GENI_IOS);
@@ -241,7 +241,7 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport,
241{ 241{
242 u32 uart_manual_rfr = 0; 242 u32 uart_manual_rfr = 0;
243 243
244 if (uart_console(uport) || !uart_cts_enabled(uport)) 244 if (uart_console(uport))
245 return; 245 return;
246 246
247 if (!(mctrl & TIOCM_RTS)) 247 if (!(mctrl & TIOCM_RTS))
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d4cca5bdaf1c..5c01bb6d1c24 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -550,10 +550,12 @@ static int uart_put_char(struct tty_struct *tty, unsigned char c)
550 int ret = 0; 550 int ret = 0;
551 551
552 circ = &state->xmit; 552 circ = &state->xmit;
553 if (!circ->buf) 553 port = uart_port_lock(state, flags);
554 if (!circ->buf) {
555 uart_port_unlock(port, flags);
554 return 0; 556 return 0;
557 }
555 558
556 port = uart_port_lock(state, flags);
557 if (port && uart_circ_chars_free(circ) != 0) { 559 if (port && uart_circ_chars_free(circ) != 0) {
558 circ->buf[circ->head] = c; 560 circ->buf[circ->head] = c;
559 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1); 561 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
@@ -586,11 +588,13 @@ static int uart_write(struct tty_struct *tty,
586 return -EL3HLT; 588 return -EL3HLT;
587 } 589 }
588 590
591 port = uart_port_lock(state, flags);
589 circ = &state->xmit; 592 circ = &state->xmit;
590 if (!circ->buf) 593 if (!circ->buf) {
594 uart_port_unlock(port, flags);
591 return 0; 595 return 0;
596 }
592 597
593 port = uart_port_lock(state, flags);
594 while (port) { 598 while (port) {
595 c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE); 599 c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
596 if (count < c) 600 if (count < c)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 23c6fd238422..21ffcce16927 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2189,7 +2189,8 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
2189 ld = tty_ldisc_ref_wait(tty); 2189 ld = tty_ldisc_ref_wait(tty);
2190 if (!ld) 2190 if (!ld)
2191 return -EIO; 2191 return -EIO;
2192 ld->ops->receive_buf(tty, &ch, &mbz, 1); 2192 if (ld->ops->receive_buf)
2193 ld->ops->receive_buf(tty, &ch, &mbz, 1);
2193 tty_ldisc_deref(ld); 2194 tty_ldisc_deref(ld);
2194 return 0; 2195 return 0;
2195} 2196}
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 41ec8e5010f3..bba75560d11e 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1272,6 +1272,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1272 if (con_is_visible(vc)) 1272 if (con_is_visible(vc))
1273 update_screen(vc); 1273 update_screen(vc);
1274 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); 1274 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num);
1275 notify_update(vc);
1275 return err; 1276 return err;
1276} 1277}
1277 1278
@@ -2764,8 +2765,8 @@ rescan_last_byte:
2764 con_flush(vc, draw_from, draw_to, &draw_x); 2765 con_flush(vc, draw_from, draw_to, &draw_x);
2765 vc_uniscr_debug_check(vc); 2766 vc_uniscr_debug_check(vc);
2766 console_conditional_schedule(); 2767 console_conditional_schedule();
2767 console_unlock();
2768 notify_update(vc); 2768 notify_update(vc);
2769 console_unlock();
2769 return n; 2770 return n;
2770} 2771}
2771 2772
@@ -2884,8 +2885,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
2884 unsigned char c; 2885 unsigned char c;
2885 static DEFINE_SPINLOCK(printing_lock); 2886 static DEFINE_SPINLOCK(printing_lock);
2886 const ushort *start; 2887 const ushort *start;
2887 ushort cnt = 0; 2888 ushort start_x, cnt;
2888 ushort myx;
2889 int kmsg_console; 2889 int kmsg_console;
2890 2890
2891 /* console busy or not yet initialized */ 2891 /* console busy or not yet initialized */
@@ -2898,10 +2898,6 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
2898 if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) 2898 if (kmsg_console && vc_cons_allocated(kmsg_console - 1))
2899 vc = vc_cons[kmsg_console - 1].d; 2899 vc = vc_cons[kmsg_console - 1].d;
2900 2900
2901 /* read `x' only after setting currcons properly (otherwise
2902 the `x' macro will read the x of the foreground console). */
2903 myx = vc->vc_x;
2904
2905 if (!vc_cons_allocated(fg_console)) { 2901 if (!vc_cons_allocated(fg_console)) {
2906 /* impossible */ 2902 /* impossible */
2907 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */ 2903 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */
@@ -2916,53 +2912,41 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
2916 hide_cursor(vc); 2912 hide_cursor(vc);
2917 2913
2918 start = (ushort *)vc->vc_pos; 2914 start = (ushort *)vc->vc_pos;
2919 2915 start_x = vc->vc_x;
2920 /* Contrived structure to try to emulate original need_wrap behaviour 2916 cnt = 0;
2921 * Problems caused when we have need_wrap set on '\n' character */
2922 while (count--) { 2917 while (count--) {
2923 c = *b++; 2918 c = *b++;
2924 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { 2919 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) {
2925 if (cnt > 0) { 2920 if (cnt && con_is_visible(vc))
2926 if (con_is_visible(vc)) 2921 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, start_x);
2927 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); 2922 cnt = 0;
2928 vc->vc_x += cnt;
2929 if (vc->vc_need_wrap)
2930 vc->vc_x--;
2931 cnt = 0;
2932 }
2933 if (c == 8) { /* backspace */ 2923 if (c == 8) { /* backspace */
2934 bs(vc); 2924 bs(vc);
2935 start = (ushort *)vc->vc_pos; 2925 start = (ushort *)vc->vc_pos;
2936 myx = vc->vc_x; 2926 start_x = vc->vc_x;
2937 continue; 2927 continue;
2938 } 2928 }
2939 if (c != 13) 2929 if (c != 13)
2940 lf(vc); 2930 lf(vc);
2941 cr(vc); 2931 cr(vc);
2942 start = (ushort *)vc->vc_pos; 2932 start = (ushort *)vc->vc_pos;
2943 myx = vc->vc_x; 2933 start_x = vc->vc_x;
2944 if (c == 10 || c == 13) 2934 if (c == 10 || c == 13)
2945 continue; 2935 continue;
2946 } 2936 }
2937 vc_uniscr_putc(vc, c);
2947 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); 2938 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos);
2948 notify_write(vc, c); 2939 notify_write(vc, c);
2949 cnt++; 2940 cnt++;
2950 if (myx == vc->vc_cols - 1) { 2941 if (vc->vc_x == vc->vc_cols - 1) {
2951 vc->vc_need_wrap = 1;
2952 continue;
2953 }
2954 vc->vc_pos += 2;
2955 myx++;
2956 }
2957 if (cnt > 0) {
2958 if (con_is_visible(vc))
2959 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x);
2960 vc->vc_x += cnt;
2961 if (vc->vc_x == vc->vc_cols) {
2962 vc->vc_x--;
2963 vc->vc_need_wrap = 1; 2942 vc->vc_need_wrap = 1;
2943 } else {
2944 vc->vc_pos += 2;
2945 vc->vc_x++;
2964 } 2946 }
2965 } 2947 }
2948 if (cnt && con_is_visible(vc))
2949 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, start_x);
2966 set_cursor(vc); 2950 set_cursor(vc);
2967 notify_update(vc); 2951 notify_update(vc);
2968 2952
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index e81de9ca8729..9b45aa422e69 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -316,7 +316,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
316 if (IS_ERR(data->usbmisc_data)) 316 if (IS_ERR(data->usbmisc_data))
317 return PTR_ERR(data->usbmisc_data); 317 return PTR_ERR(data->usbmisc_data);
318 318
319 if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) { 319 if ((of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC)
320 && data->usbmisc_data) {
320 pdata.flags |= CI_HDRC_IMX_IS_HSIC; 321 pdata.flags |= CI_HDRC_IMX_IS_HSIC;
321 data->usbmisc_data->hsic = 1; 322 data->usbmisc_data->hsic = 1;
322 data->pinctrl = devm_pinctrl_get(dev); 323 data->pinctrl = devm_pinctrl_get(dev);
diff --git a/drivers/usb/core/ledtrig-usbport.c b/drivers/usb/core/ledtrig-usbport.c
index dc7f7fd71684..c12ac56606c3 100644
--- a/drivers/usb/core/ledtrig-usbport.c
+++ b/drivers/usb/core/ledtrig-usbport.c
@@ -119,11 +119,6 @@ static const struct attribute_group ports_group = {
119 .attrs = ports_attrs, 119 .attrs = ports_attrs,
120}; 120};
121 121
122static const struct attribute_group *ports_groups[] = {
123 &ports_group,
124 NULL
125};
126
127/*************************************** 122/***************************************
128 * Adding & removing ports 123 * Adding & removing ports
129 ***************************************/ 124 ***************************************/
@@ -307,6 +302,7 @@ static int usbport_trig_notify(struct notifier_block *nb, unsigned long action,
307static int usbport_trig_activate(struct led_classdev *led_cdev) 302static int usbport_trig_activate(struct led_classdev *led_cdev)
308{ 303{
309 struct usbport_trig_data *usbport_data; 304 struct usbport_trig_data *usbport_data;
305 int err;
310 306
311 usbport_data = kzalloc(sizeof(*usbport_data), GFP_KERNEL); 307 usbport_data = kzalloc(sizeof(*usbport_data), GFP_KERNEL);
312 if (!usbport_data) 308 if (!usbport_data)
@@ -315,6 +311,9 @@ static int usbport_trig_activate(struct led_classdev *led_cdev)
315 311
316 /* List of ports */ 312 /* List of ports */
317 INIT_LIST_HEAD(&usbport_data->ports); 313 INIT_LIST_HEAD(&usbport_data->ports);
314 err = sysfs_create_group(&led_cdev->dev->kobj, &ports_group);
315 if (err)
316 goto err_free;
318 usb_for_each_dev(usbport_data, usbport_trig_add_usb_dev_ports); 317 usb_for_each_dev(usbport_data, usbport_trig_add_usb_dev_ports);
319 usbport_trig_update_count(usbport_data); 318 usbport_trig_update_count(usbport_data);
320 319
@@ -322,8 +321,11 @@ static int usbport_trig_activate(struct led_classdev *led_cdev)
322 usbport_data->nb.notifier_call = usbport_trig_notify; 321 usbport_data->nb.notifier_call = usbport_trig_notify;
323 led_set_trigger_data(led_cdev, usbport_data); 322 led_set_trigger_data(led_cdev, usbport_data);
324 usb_register_notify(&usbport_data->nb); 323 usb_register_notify(&usbport_data->nb);
325
326 return 0; 324 return 0;
325
326err_free:
327 kfree(usbport_data);
328 return err;
327} 329}
328 330
329static void usbport_trig_deactivate(struct led_classdev *led_cdev) 331static void usbport_trig_deactivate(struct led_classdev *led_cdev)
@@ -335,6 +337,8 @@ static void usbport_trig_deactivate(struct led_classdev *led_cdev)
335 usbport_trig_remove_port(usbport_data, port); 337 usbport_trig_remove_port(usbport_data, port);
336 } 338 }
337 339
340 sysfs_remove_group(&led_cdev->dev->kobj, &ports_group);
341
338 usb_unregister_notify(&usbport_data->nb); 342 usb_unregister_notify(&usbport_data->nb);
339 343
340 kfree(usbport_data); 344 kfree(usbport_data);
@@ -344,7 +348,6 @@ static struct led_trigger usbport_led_trigger = {
344 .name = "usbport", 348 .name = "usbport",
345 .activate = usbport_trig_activate, 349 .activate = usbport_trig_activate,
346 .deactivate = usbport_trig_deactivate, 350 .deactivate = usbport_trig_deactivate,
347 .groups = ports_groups,
348}; 351};
349 352
350static int __init usbport_trig_init(void) 353static int __init usbport_trig_init(void)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 68ad75a7460d..55ef3cc2701b 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -261,7 +261,7 @@ static void dwc2_gadget_wkup_alert_handler(struct dwc2_hsotg *hsotg)
261 261
262 if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) { 262 if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) {
263 dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); 263 dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__);
264 dwc2_clear_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT); 264 dwc2_set_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT);
265 dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG); 265 dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG);
266 } 266 }
267} 267}
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 07bd31bb2f8a..bed2ff42780b 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -177,6 +177,7 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
177 req->started = false; 177 req->started = false;
178 list_del(&req->list); 178 list_del(&req->list);
179 req->remaining = 0; 179 req->remaining = 0;
180 req->needs_extra_trb = false;
180 181
181 if (req->request.status == -EINPROGRESS) 182 if (req->request.status == -EINPROGRESS)
182 req->request.status = status; 183 req->request.status = status;
@@ -1984,6 +1985,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
1984 1985
1985 /* begin to receive SETUP packets */ 1986 /* begin to receive SETUP packets */
1986 dwc->ep0state = EP0_SETUP_PHASE; 1987 dwc->ep0state = EP0_SETUP_PHASE;
1988 dwc->link_state = DWC3_LINK_STATE_SS_DIS;
1987 dwc3_ep0_out_start(dwc); 1989 dwc3_ep0_out_start(dwc);
1988 1990
1989 dwc3_gadget_enable_irq(dwc); 1991 dwc3_gadget_enable_irq(dwc);
@@ -3379,6 +3381,8 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
3379 dwc3_disconnect_gadget(dwc); 3381 dwc3_disconnect_gadget(dwc);
3380 __dwc3_gadget_stop(dwc); 3382 __dwc3_gadget_stop(dwc);
3381 3383
3384 synchronize_irq(dwc->irq_gadget);
3385
3382 return 0; 3386 return 0;
3383} 3387}
3384 3388
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 9cdef108fb1b..ed68a4860b7d 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -838,7 +838,7 @@ static struct usb_function *source_sink_alloc_func(
838 838
839 ss = kzalloc(sizeof(*ss), GFP_KERNEL); 839 ss = kzalloc(sizeof(*ss), GFP_KERNEL);
840 if (!ss) 840 if (!ss)
841 return NULL; 841 return ERR_PTR(-ENOMEM);
842 842
843 ss_opts = container_of(fi, struct f_ss_opts, func_inst); 843 ss_opts = container_of(fi, struct f_ss_opts, func_inst);
844 844
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index f26109eafdbf..66ec1fdf9fe7 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -302,3 +302,4 @@ MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>");
302MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>"); 302MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>");
303MODULE_ALIAS("mv-ehci"); 303MODULE_ALIAS("mv-ehci");
304MODULE_LICENSE("GPL"); 304MODULE_LICENSE("GPL");
305MODULE_DEVICE_TABLE(of, ehci_mv_dt_ids);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1ab2a6191013..77ef4c481f3c 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1783,6 +1783,10 @@ static int ftdi_set_bitmode(struct usb_serial_port *port, u8 mode)
1783 int result; 1783 int result;
1784 u16 val; 1784 u16 val;
1785 1785
1786 result = usb_autopm_get_interface(serial->interface);
1787 if (result)
1788 return result;
1789
1786 val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value; 1790 val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value;
1787 result = usb_control_msg(serial->dev, 1791 result = usb_control_msg(serial->dev,
1788 usb_sndctrlpipe(serial->dev, 0), 1792 usb_sndctrlpipe(serial->dev, 0),
@@ -1795,6 +1799,8 @@ static int ftdi_set_bitmode(struct usb_serial_port *port, u8 mode)
1795 val, result); 1799 val, result);
1796 } 1800 }
1797 1801
1802 usb_autopm_put_interface(serial->interface);
1803
1798 return result; 1804 return result;
1799} 1805}
1800 1806
@@ -1846,9 +1852,15 @@ static int ftdi_read_cbus_pins(struct usb_serial_port *port)
1846 unsigned char *buf; 1852 unsigned char *buf;
1847 int result; 1853 int result;
1848 1854
1855 result = usb_autopm_get_interface(serial->interface);
1856 if (result)
1857 return result;
1858
1849 buf = kmalloc(1, GFP_KERNEL); 1859 buf = kmalloc(1, GFP_KERNEL);
1850 if (!buf) 1860 if (!buf) {
1861 usb_autopm_put_interface(serial->interface);
1851 return -ENOMEM; 1862 return -ENOMEM;
1863 }
1852 1864
1853 result = usb_control_msg(serial->dev, 1865 result = usb_control_msg(serial->dev,
1854 usb_rcvctrlpipe(serial->dev, 0), 1866 usb_rcvctrlpipe(serial->dev, 0),
@@ -1863,6 +1875,7 @@ static int ftdi_read_cbus_pins(struct usb_serial_port *port)
1863 } 1875 }
1864 1876
1865 kfree(buf); 1877 kfree(buf);
1878 usb_autopm_put_interface(serial->interface);
1866 1879
1867 return result; 1880 return result;
1868} 1881}
diff --git a/drivers/usb/serial/keyspan_usa26msg.h b/drivers/usb/serial/keyspan_usa26msg.h
index 09e21e84fc4e..a68f1fb25b8a 100644
--- a/drivers/usb/serial/keyspan_usa26msg.h
+++ b/drivers/usb/serial/keyspan_usa26msg.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: BSD-3-Clause */
1/* 2/*
2 usa26msg.h 3 usa26msg.h
3 4
diff --git a/drivers/usb/serial/keyspan_usa28msg.h b/drivers/usb/serial/keyspan_usa28msg.h
index dee454c4609a..a19f3fe5d98d 100644
--- a/drivers/usb/serial/keyspan_usa28msg.h
+++ b/drivers/usb/serial/keyspan_usa28msg.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: BSD-3-Clause */
1/* 2/*
2 usa28msg.h 3 usa28msg.h
3 4
diff --git a/drivers/usb/serial/keyspan_usa49msg.h b/drivers/usb/serial/keyspan_usa49msg.h
index 163b2dea2ec5..8c3970fdd868 100644
--- a/drivers/usb/serial/keyspan_usa49msg.h
+++ b/drivers/usb/serial/keyspan_usa49msg.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: BSD-3-Clause */
1/* 2/*
2 usa49msg.h 3 usa49msg.h
3 4
diff --git a/drivers/usb/serial/keyspan_usa67msg.h b/drivers/usb/serial/keyspan_usa67msg.h
index 20fa3e2f7187..dcf502fdbb44 100644
--- a/drivers/usb/serial/keyspan_usa67msg.h
+++ b/drivers/usb/serial/keyspan_usa67msg.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: BSD-3-Clause */
1/* 2/*
2 usa67msg.h 3 usa67msg.h
3 4
diff --git a/drivers/usb/serial/keyspan_usa90msg.h b/drivers/usb/serial/keyspan_usa90msg.h
index 86708ecd8735..c4ca0f631d20 100644
--- a/drivers/usb/serial/keyspan_usa90msg.h
+++ b/drivers/usb/serial/keyspan_usa90msg.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: BSD-3-Clause */
1/* 2/*
2 usa90msg.h 3 usa90msg.h
3 4
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 98e7a5df0f6d..bb3f9aa4a909 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -46,6 +46,7 @@ static const struct usb_device_id id_table[] = {
46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, 46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, 47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) },
48 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) }, 48 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) },
49 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_TB) },
49 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 50 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
50 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 51 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
51 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID), 52 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID),
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 4e2554d55362..559941ca884d 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -8,6 +8,7 @@
8 8
9#define PL2303_VENDOR_ID 0x067b 9#define PL2303_VENDOR_ID 0x067b
10#define PL2303_PRODUCT_ID 0x2303 10#define PL2303_PRODUCT_ID 0x2303
11#define PL2303_PRODUCT_ID_TB 0x2304
11#define PL2303_PRODUCT_ID_RSAQ2 0x04bb 12#define PL2303_PRODUCT_ID_RSAQ2 0x04bb
12#define PL2303_PRODUCT_ID_DCU11 0x1234 13#define PL2303_PRODUCT_ID_DCU11 0x1234
13#define PL2303_PRODUCT_ID_PHAROS 0xaaa0 14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
@@ -20,6 +21,7 @@
20#define PL2303_PRODUCT_ID_MOTOROLA 0x0307 21#define PL2303_PRODUCT_ID_MOTOROLA 0x0307
21#define PL2303_PRODUCT_ID_ZTEK 0xe1f1 22#define PL2303_PRODUCT_ID_ZTEK 0xe1f1
22 23
24
23#define ATEN_VENDOR_ID 0x0557 25#define ATEN_VENDOR_ID 0x0557
24#define ATEN_VENDOR_ID2 0x0547 26#define ATEN_VENDOR_ID2 0x0547
25#define ATEN_PRODUCT_ID 0x2008 27#define ATEN_PRODUCT_ID 0x2008
diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
index 4d0273508043..edbbb13d6de6 100644
--- a/drivers/usb/serial/usb-serial-simple.c
+++ b/drivers/usb/serial/usb-serial-simple.c
@@ -85,7 +85,8 @@ DEVICE(moto_modem, MOTO_IDS);
85/* Motorola Tetra driver */ 85/* Motorola Tetra driver */
86#define MOTOROLA_TETRA_IDS() \ 86#define MOTOROLA_TETRA_IDS() \
87 { USB_DEVICE(0x0cad, 0x9011) }, /* Motorola Solutions TETRA PEI */ \ 87 { USB_DEVICE(0x0cad, 0x9011) }, /* Motorola Solutions TETRA PEI */ \
88 { USB_DEVICE(0x0cad, 0x9012) } /* MTP6550 */ 88 { USB_DEVICE(0x0cad, 0x9012) }, /* MTP6550 */ \
89 { USB_DEVICE(0x0cad, 0x9016) } /* TPG2200 */
89DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS); 90DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS);
90 91
91/* Novatel Wireless GPS driver */ 92/* Novatel Wireless GPS driver */
diff --git a/drivers/usb/usbip/README b/drivers/usb/usbip/README
deleted file mode 100644
index 41a2cf2e77a6..000000000000
--- a/drivers/usb/usbip/README
+++ /dev/null
@@ -1,7 +0,0 @@
1TODO:
2 - more discussion about the protocol
3 - testing
4 - review of the userspace interface
5 - document the protocol
6
7Please send patches for this code to Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/vfio/pci/trace.h b/drivers/vfio/pci/trace.h
index 4d13e510590e..b2aa986ab9ed 100644
--- a/drivers/vfio/pci/trace.h
+++ b/drivers/vfio/pci/trace.h
@@ -1,13 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */ 1/* SPDX-License-Identifier: GPL-2.0-only */
2/* 2/*
3 * VFIO PCI mmap/mmap_fault tracepoints 3 * VFIO PCI mmap/mmap_fault tracepoints
4 * 4 *
5 * Copyright (C) 2018 IBM Corp. All rights reserved. 5 * Copyright (C) 2018 IBM Corp. All rights reserved.
6 * Author: Alexey Kardashevskiy <aik@ozlabs.ru> 6 * Author: Alexey Kardashevskiy <aik@ozlabs.ru>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 7 */
12 8
13#undef TRACE_SYSTEM 9#undef TRACE_SYSTEM
diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
index 054a2cf9dd8e..32f695ffe128 100644
--- a/drivers/vfio/pci/vfio_pci_nvlink2.c
+++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+ 1// SPDX-License-Identifier: GPL-2.0-only
2/* 2/*
3 * VFIO PCI NVIDIA Whitherspoon GPU support a.k.a. NVLink2. 3 * VFIO PCI NVIDIA Whitherspoon GPU support a.k.a. NVLink2.
4 * 4 *
5 * Copyright (C) 2018 IBM Corp. All rights reserved. 5 * Copyright (C) 2018 IBM Corp. All rights reserved.
6 * Author: Alexey Kardashevskiy <aik@ozlabs.ru> 6 * Author: Alexey Kardashevskiy <aik@ozlabs.ru>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Register an on-GPU RAM region for cacheable access. 8 * Register an on-GPU RAM region for cacheable access.
13 * 9 *
14 * Derived from original vfio_pci_igd.c: 10 * Derived from original vfio_pci_igd.c:
@@ -178,11 +174,11 @@ static int vfio_pci_nvgpu_add_capability(struct vfio_pci_device *vdev,
178 struct vfio_pci_region *region, struct vfio_info_cap *caps) 174 struct vfio_pci_region *region, struct vfio_info_cap *caps)
179{ 175{
180 struct vfio_pci_nvgpu_data *data = region->data; 176 struct vfio_pci_nvgpu_data *data = region->data;
181 struct vfio_region_info_cap_nvlink2_ssatgt cap = { 0 }; 177 struct vfio_region_info_cap_nvlink2_ssatgt cap = {
182 178 .header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT,
183 cap.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT; 179 .header.version = 1,
184 cap.header.version = 1; 180 .tgt = data->gpu_tgt
185 cap.tgt = data->gpu_tgt; 181 };
186 182
187 return vfio_info_add_capability(caps, &cap.header, sizeof(cap)); 183 return vfio_info_add_capability(caps, &cap.header, sizeof(cap));
188} 184}
@@ -365,18 +361,18 @@ static int vfio_pci_npu2_add_capability(struct vfio_pci_device *vdev,
365 struct vfio_pci_region *region, struct vfio_info_cap *caps) 361 struct vfio_pci_region *region, struct vfio_info_cap *caps)
366{ 362{
367 struct vfio_pci_npu2_data *data = region->data; 363 struct vfio_pci_npu2_data *data = region->data;
368 struct vfio_region_info_cap_nvlink2_ssatgt captgt = { 0 }; 364 struct vfio_region_info_cap_nvlink2_ssatgt captgt = {
369 struct vfio_region_info_cap_nvlink2_lnkspd capspd = { 0 }; 365 .header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT,
366 .header.version = 1,
367 .tgt = data->gpu_tgt
368 };
369 struct vfio_region_info_cap_nvlink2_lnkspd capspd = {
370 .header.id = VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD,
371 .header.version = 1,
372 .link_speed = data->link_speed
373 };
370 int ret; 374 int ret;
371 375
372 captgt.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT;
373 captgt.header.version = 1;
374 captgt.tgt = data->gpu_tgt;
375
376 capspd.header.id = VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD;
377 capspd.header.version = 1;
378 capspd.link_speed = data->link_speed;
379
380 ret = vfio_info_add_capability(caps, &captgt.header, sizeof(captgt)); 376 ret = vfio_info_add_capability(caps, &captgt.header, sizeof(captgt));
381 if (ret) 377 if (ret)
382 return ret; 378 return ret;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 09731b2f6815..c6b3bdbbdbc9 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -271,6 +271,7 @@ static void vgacon_scrollback_update(struct vc_data *c, int t, int count)
271 271
272static void vgacon_restore_screen(struct vc_data *c) 272static void vgacon_restore_screen(struct vc_data *c)
273{ 273{
274 c->vc_origin = c->vc_visible_origin;
274 vgacon_scrollback_cur->save = 0; 275 vgacon_scrollback_cur->save = 0;
275 276
276 if (!vga_is_gfx && !vgacon_scrollback_cur->restore) { 277 if (!vga_is_gfx && !vgacon_scrollback_cur->restore) {
@@ -287,8 +288,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
287 int start, end, count, soff; 288 int start, end, count, soff;
288 289
289 if (!lines) { 290 if (!lines) {
290 c->vc_visible_origin = c->vc_origin; 291 vgacon_restore_screen(c);
291 vga_set_mem_top(c);
292 return; 292 return;
293 } 293 }
294 294
@@ -298,6 +298,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
298 if (!vgacon_scrollback_cur->save) { 298 if (!vgacon_scrollback_cur->save) {
299 vgacon_cursor(c, CM_ERASE); 299 vgacon_cursor(c, CM_ERASE);
300 vgacon_save_screen(c); 300 vgacon_save_screen(c);
301 c->vc_origin = (unsigned long)c->vc_screenbuf;
301 vgacon_scrollback_cur->save = 1; 302 vgacon_scrollback_cur->save = 1;
302 } 303 }
303 304
@@ -335,7 +336,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
335 int copysize; 336 int copysize;
336 337
337 int diff = c->vc_rows - count; 338 int diff = c->vc_rows - count;
338 void *d = (void *) c->vc_origin; 339 void *d = (void *) c->vc_visible_origin;
339 void *s = (void *) c->vc_screenbuf; 340 void *s = (void *) c->vc_screenbuf;
340 341
341 count *= c->vc_size_row; 342 count *= c->vc_size_row;
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 989cf872b98c..bb7888429be6 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -645,7 +645,7 @@ xen_swiotlb_dma_mmap(struct device *dev, struct vm_area_struct *vma,
645 void *cpu_addr, dma_addr_t dma_addr, size_t size, 645 void *cpu_addr, dma_addr_t dma_addr, size_t size,
646 unsigned long attrs) 646 unsigned long attrs)
647{ 647{
648#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) 648#ifdef CONFIG_ARM
649 if (xen_get_dma_ops(dev)->mmap) 649 if (xen_get_dma_ops(dev)->mmap)
650 return xen_get_dma_ops(dev)->mmap(dev, vma, cpu_addr, 650 return xen_get_dma_ops(dev)->mmap(dev, vma, cpu_addr,
651 dma_addr, size, attrs); 651 dma_addr, size, attrs);
@@ -662,7 +662,7 @@ xen_swiotlb_get_sgtable(struct device *dev, struct sg_table *sgt,
662 void *cpu_addr, dma_addr_t handle, size_t size, 662 void *cpu_addr, dma_addr_t handle, size_t size,
663 unsigned long attrs) 663 unsigned long attrs)
664{ 664{
665#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) 665#ifdef CONFIG_ARM
666 if (xen_get_dma_ops(dev)->get_sgtable) { 666 if (xen_get_dma_ops(dev)->get_sgtable) {
667#if 0 667#if 0
668 /* 668 /*
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 94c026bba2c2..bba28a5034ba 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1035,6 +1035,8 @@ static void drop_inode_snap_realm(struct ceph_inode_info *ci)
1035 list_del_init(&ci->i_snap_realm_item); 1035 list_del_init(&ci->i_snap_realm_item);
1036 ci->i_snap_realm_counter++; 1036 ci->i_snap_realm_counter++;
1037 ci->i_snap_realm = NULL; 1037 ci->i_snap_realm = NULL;
1038 if (realm->ino == ci->i_vino.ino)
1039 realm->inode = NULL;
1038 spin_unlock(&realm->inodes_with_caps_lock); 1040 spin_unlock(&realm->inodes_with_caps_lock);
1039 ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc, 1041 ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc,
1040 realm); 1042 realm);
diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
index 03f4d24db8fe..9455d3aef0c3 100644
--- a/fs/ceph/quota.c
+++ b/fs/ceph/quota.c
@@ -3,19 +3,6 @@
3 * quota.c - CephFS quota 3 * quota.c - CephFS quota
4 * 4 *
5 * Copyright (C) 2017-2018 SUSE 5 * Copyright (C) 2017-2018 SUSE
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */ 6 */
20 7
21#include <linux/statfs.h> 8#include <linux/statfs.h>
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 593fb422d0f3..e92a2fee3c57 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -252,6 +252,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
252 seq_printf(m, ",ACL"); 252 seq_printf(m, ",ACL");
253#endif 253#endif
254 seq_putc(m, '\n'); 254 seq_putc(m, '\n');
255 seq_printf(m, "CIFSMaxBufSize: %d\n", CIFSMaxBufSize);
255 seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid); 256 seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
256 seq_printf(m, "Servers:"); 257 seq_printf(m, "Servers:");
257 258
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index e18915415e13..bb54ccf8481c 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1549,18 +1549,26 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server)
1549} 1549}
1550 1550
1551static int 1551static int
1552cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid) 1552__cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid,
1553 bool malformed)
1553{ 1554{
1554 int length; 1555 int length;
1555 struct cifs_readdata *rdata = mid->callback_data;
1556 1556
1557 length = cifs_discard_remaining_data(server); 1557 length = cifs_discard_remaining_data(server);
1558 dequeue_mid(mid, rdata->result); 1558 dequeue_mid(mid, malformed);
1559 mid->resp_buf = server->smallbuf; 1559 mid->resp_buf = server->smallbuf;
1560 server->smallbuf = NULL; 1560 server->smallbuf = NULL;
1561 return length; 1561 return length;
1562} 1562}
1563 1563
1564static int
1565cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1566{
1567 struct cifs_readdata *rdata = mid->callback_data;
1568
1569 return __cifs_readv_discard(server, mid, rdata->result);
1570}
1571
1564int 1572int
1565cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) 1573cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1566{ 1574{
@@ -1602,12 +1610,23 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1602 return -1; 1610 return -1;
1603 } 1611 }
1604 1612
1613 /* set up first two iov for signature check and to get credits */
1614 rdata->iov[0].iov_base = buf;
1615 rdata->iov[0].iov_len = 4;
1616 rdata->iov[1].iov_base = buf + 4;
1617 rdata->iov[1].iov_len = server->total_read - 4;
1618 cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
1619 rdata->iov[0].iov_base, rdata->iov[0].iov_len);
1620 cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",
1621 rdata->iov[1].iov_base, rdata->iov[1].iov_len);
1622
1605 /* Was the SMB read successful? */ 1623 /* Was the SMB read successful? */
1606 rdata->result = server->ops->map_error(buf, false); 1624 rdata->result = server->ops->map_error(buf, false);
1607 if (rdata->result != 0) { 1625 if (rdata->result != 0) {
1608 cifs_dbg(FYI, "%s: server returned error %d\n", 1626 cifs_dbg(FYI, "%s: server returned error %d\n",
1609 __func__, rdata->result); 1627 __func__, rdata->result);
1610 return cifs_readv_discard(server, mid); 1628 /* normal error on read response */
1629 return __cifs_readv_discard(server, mid, false);
1611 } 1630 }
1612 1631
1613 /* Is there enough to get to the rest of the READ_RSP header? */ 1632 /* Is there enough to get to the rest of the READ_RSP header? */
@@ -1651,14 +1670,6 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1651 server->total_read += length; 1670 server->total_read += length;
1652 } 1671 }
1653 1672
1654 /* set up first iov for signature check */
1655 rdata->iov[0].iov_base = buf;
1656 rdata->iov[0].iov_len = 4;
1657 rdata->iov[1].iov_base = buf + 4;
1658 rdata->iov[1].iov_len = server->total_read - 4;
1659 cifs_dbg(FYI, "0: iov_base=%p iov_len=%u\n",
1660 rdata->iov[0].iov_base, server->total_read);
1661
1662 /* how much data is in the response? */ 1673 /* how much data is in the response? */
1663#ifdef CONFIG_CIFS_SMB_DIRECT 1674#ifdef CONFIG_CIFS_SMB_DIRECT
1664 use_rdma_mr = rdata->mr; 1675 use_rdma_mr = rdata->mr;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 683310f26171..8463c940e0e5 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -720,6 +720,21 @@ server_unresponsive(struct TCP_Server_Info *server)
720 return false; 720 return false;
721} 721}
722 722
723static inline bool
724zero_credits(struct TCP_Server_Info *server)
725{
726 int val;
727
728 spin_lock(&server->req_lock);
729 val = server->credits + server->echo_credits + server->oplock_credits;
730 if (server->in_flight == 0 && val == 0) {
731 spin_unlock(&server->req_lock);
732 return true;
733 }
734 spin_unlock(&server->req_lock);
735 return false;
736}
737
723static int 738static int
724cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg) 739cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg)
725{ 740{
@@ -732,6 +747,12 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg)
732 for (total_read = 0; msg_data_left(smb_msg); total_read += length) { 747 for (total_read = 0; msg_data_left(smb_msg); total_read += length) {
733 try_to_freeze(); 748 try_to_freeze();
734 749
750 /* reconnect if no credits and no requests in flight */
751 if (zero_credits(server)) {
752 cifs_reconnect(server);
753 return -ECONNABORTED;
754 }
755
735 if (server_unresponsive(server)) 756 if (server_unresponsive(server))
736 return -ECONNABORTED; 757 return -ECONNABORTED;
737 if (cifs_rdma_enabled(server) && server->smbd_conn) 758 if (cifs_rdma_enabled(server) && server->smbd_conn)
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index f14533da3a93..01a76bccdb8d 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -293,6 +293,8 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
293 int rc; 293 int rc;
294 struct smb2_file_all_info *smb2_data; 294 struct smb2_file_all_info *smb2_data;
295 __u32 create_options = 0; 295 __u32 create_options = 0;
296 struct cifs_fid fid;
297 bool no_cached_open = tcon->nohandlecache;
296 298
297 *adjust_tz = false; 299 *adjust_tz = false;
298 *symlink = false; 300 *symlink = false;
@@ -301,6 +303,21 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
301 GFP_KERNEL); 303 GFP_KERNEL);
302 if (smb2_data == NULL) 304 if (smb2_data == NULL)
303 return -ENOMEM; 305 return -ENOMEM;
306
307 /* If it is a root and its handle is cached then use it */
308 if (!strlen(full_path) && !no_cached_open) {
309 rc = open_shroot(xid, tcon, &fid);
310 if (rc)
311 goto out;
312 rc = SMB2_query_info(xid, tcon, fid.persistent_fid,
313 fid.volatile_fid, smb2_data);
314 close_shroot(&tcon->crfid);
315 if (rc)
316 goto out;
317 move_smb2_info_to_cifs(data, smb2_data);
318 goto out;
319 }
320
304 if (backup_cred(cifs_sb)) 321 if (backup_cred(cifs_sb))
305 create_options |= CREATE_OPEN_BACKUP_INTENT; 322 create_options |= CREATE_OPEN_BACKUP_INTENT;
306 323
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 6a9c47541c53..7b8b58fb4d3f 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -648,6 +648,13 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
648 if (rsp->sync_hdr.Command != SMB2_OPLOCK_BREAK) 648 if (rsp->sync_hdr.Command != SMB2_OPLOCK_BREAK)
649 return false; 649 return false;
650 650
651 if (rsp->sync_hdr.CreditRequest) {
652 spin_lock(&server->req_lock);
653 server->credits += le16_to_cpu(rsp->sync_hdr.CreditRequest);
654 spin_unlock(&server->req_lock);
655 wake_up(&server->request_q);
656 }
657
651 if (rsp->StructureSize != 658 if (rsp->StructureSize !=
652 smb2_rsp_struct_sizes[SMB2_OPLOCK_BREAK_HE]) { 659 smb2_rsp_struct_sizes[SMB2_OPLOCK_BREAK_HE]) {
653 if (le16_to_cpu(rsp->StructureSize) == 44) 660 if (le16_to_cpu(rsp->StructureSize) == 44)
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index cf7eb891804f..153238fc4fa9 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -34,6 +34,7 @@
34#include "cifs_ioctl.h" 34#include "cifs_ioctl.h"
35#include "smbdirect.h" 35#include "smbdirect.h"
36 36
37/* Change credits for different ops and return the total number of credits */
37static int 38static int
38change_conf(struct TCP_Server_Info *server) 39change_conf(struct TCP_Server_Info *server)
39{ 40{
@@ -41,17 +42,15 @@ change_conf(struct TCP_Server_Info *server)
41 server->oplock_credits = server->echo_credits = 0; 42 server->oplock_credits = server->echo_credits = 0;
42 switch (server->credits) { 43 switch (server->credits) {
43 case 0: 44 case 0:
44 return -1; 45 return 0;
45 case 1: 46 case 1:
46 server->echoes = false; 47 server->echoes = false;
47 server->oplocks = false; 48 server->oplocks = false;
48 cifs_dbg(VFS, "disabling echoes and oplocks\n");
49 break; 49 break;
50 case 2: 50 case 2:
51 server->echoes = true; 51 server->echoes = true;
52 server->oplocks = false; 52 server->oplocks = false;
53 server->echo_credits = 1; 53 server->echo_credits = 1;
54 cifs_dbg(FYI, "disabling oplocks\n");
55 break; 54 break;
56 default: 55 default:
57 server->echoes = true; 56 server->echoes = true;
@@ -64,14 +63,15 @@ change_conf(struct TCP_Server_Info *server)
64 server->echo_credits = 1; 63 server->echo_credits = 1;
65 } 64 }
66 server->credits -= server->echo_credits + server->oplock_credits; 65 server->credits -= server->echo_credits + server->oplock_credits;
67 return 0; 66 return server->credits + server->echo_credits + server->oplock_credits;
68} 67}
69 68
70static void 69static void
71smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add, 70smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
72 const int optype) 71 const int optype)
73{ 72{
74 int *val, rc = 0; 73 int *val, rc = -1;
74
75 spin_lock(&server->req_lock); 75 spin_lock(&server->req_lock);
76 val = server->ops->get_credits_field(server, optype); 76 val = server->ops->get_credits_field(server, optype);
77 77
@@ -101,8 +101,26 @@ smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
101 } 101 }
102 spin_unlock(&server->req_lock); 102 spin_unlock(&server->req_lock);
103 wake_up(&server->request_q); 103 wake_up(&server->request_q);
104 if (rc) 104
105 cifs_reconnect(server); 105 if (server->tcpStatus == CifsNeedReconnect)
106 return;
107
108 switch (rc) {
109 case -1:
110 /* change_conf hasn't been executed */
111 break;
112 case 0:
113 cifs_dbg(VFS, "Possible client or server bug - zero credits\n");
114 break;
115 case 1:
116 cifs_dbg(VFS, "disabling echoes and oplocks\n");
117 break;
118 case 2:
119 cifs_dbg(FYI, "disabling oplocks\n");
120 break;
121 default:
122 cifs_dbg(FYI, "add %u credits total=%d\n", add, rc);
123 }
106} 124}
107 125
108static void 126static void
@@ -136,7 +154,11 @@ smb2_get_credits(struct mid_q_entry *mid)
136{ 154{
137 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf; 155 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf;
138 156
139 return le16_to_cpu(shdr->CreditRequest); 157 if (mid->mid_state == MID_RESPONSE_RECEIVED
158 || mid->mid_state == MID_RESPONSE_MALFORMED)
159 return le16_to_cpu(shdr->CreditRequest);
160
161 return 0;
140} 162}
141 163
142static int 164static int
@@ -165,14 +187,14 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
165 187
166 scredits = server->credits; 188 scredits = server->credits;
167 /* can deadlock with reopen */ 189 /* can deadlock with reopen */
168 if (scredits == 1) { 190 if (scredits <= 8) {
169 *num = SMB2_MAX_BUFFER_SIZE; 191 *num = SMB2_MAX_BUFFER_SIZE;
170 *credits = 0; 192 *credits = 0;
171 break; 193 break;
172 } 194 }
173 195
174 /* leave one credit for a possible reopen */ 196 /* leave some credits for reopen and other ops */
175 scredits--; 197 scredits -= 8;
176 *num = min_t(unsigned int, size, 198 *num = min_t(unsigned int, size,
177 scredits * SMB2_MAX_BUFFER_SIZE); 199 scredits * SMB2_MAX_BUFFER_SIZE);
178 200
@@ -3189,11 +3211,23 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
3189 server->ops->is_status_pending(buf, server, 0)) 3211 server->ops->is_status_pending(buf, server, 0))
3190 return -1; 3212 return -1;
3191 3213
3192 rdata->result = server->ops->map_error(buf, false); 3214 /* set up first two iov to get credits */
3215 rdata->iov[0].iov_base = buf;
3216 rdata->iov[0].iov_len = 4;
3217 rdata->iov[1].iov_base = buf + 4;
3218 rdata->iov[1].iov_len =
3219 min_t(unsigned int, buf_len, server->vals->read_rsp_size) - 4;
3220 cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
3221 rdata->iov[0].iov_base, rdata->iov[0].iov_len);
3222 cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",
3223 rdata->iov[1].iov_base, rdata->iov[1].iov_len);
3224
3225 rdata->result = server->ops->map_error(buf, true);
3193 if (rdata->result != 0) { 3226 if (rdata->result != 0) {
3194 cifs_dbg(FYI, "%s: server returned error %d\n", 3227 cifs_dbg(FYI, "%s: server returned error %d\n",
3195 __func__, rdata->result); 3228 __func__, rdata->result);
3196 dequeue_mid(mid, rdata->result); 3229 /* normal error on read response */
3230 dequeue_mid(mid, false);
3197 return 0; 3231 return 0;
3198 } 3232 }
3199 3233
@@ -3266,14 +3300,6 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
3266 return 0; 3300 return 0;
3267 } 3301 }
3268 3302
3269 /* set up first iov for signature check */
3270 rdata->iov[0].iov_base = buf;
3271 rdata->iov[0].iov_len = 4;
3272 rdata->iov[1].iov_base = buf + 4;
3273 rdata->iov[1].iov_len = server->vals->read_rsp_size - 4;
3274 cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
3275 rdata->iov[0].iov_base, server->vals->read_rsp_size);
3276
3277 length = rdata->copy_into_pages(server, rdata, &iter); 3303 length = rdata->copy_into_pages(server, rdata, &iter);
3278 3304
3279 kfree(bvec); 3305 kfree(bvec);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 50811a7dc0e0..2ff209ec4fab 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2816,6 +2816,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
2816 int resp_buftype = CIFS_NO_BUFFER; 2816 int resp_buftype = CIFS_NO_BUFFER;
2817 struct cifs_ses *ses = tcon->ses; 2817 struct cifs_ses *ses = tcon->ses;
2818 int flags = 0; 2818 int flags = 0;
2819 bool allocated = false;
2819 2820
2820 cifs_dbg(FYI, "Query Info\n"); 2821 cifs_dbg(FYI, "Query Info\n");
2821 2822
@@ -2855,14 +2856,21 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
2855 "Error %d allocating memory for acl\n", 2856 "Error %d allocating memory for acl\n",
2856 rc); 2857 rc);
2857 *dlen = 0; 2858 *dlen = 0;
2859 rc = -ENOMEM;
2858 goto qinf_exit; 2860 goto qinf_exit;
2859 } 2861 }
2862 allocated = true;
2860 } 2863 }
2861 } 2864 }
2862 2865
2863 rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset), 2866 rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),
2864 le32_to_cpu(rsp->OutputBufferLength), 2867 le32_to_cpu(rsp->OutputBufferLength),
2865 &rsp_iov, min_len, *data); 2868 &rsp_iov, min_len, *data);
2869 if (rc && allocated) {
2870 kfree(*data);
2871 *data = NULL;
2872 *dlen = 0;
2873 }
2866 2874
2867qinf_exit: 2875qinf_exit:
2868 SMB2_query_info_free(&rqst); 2876 SMB2_query_info_free(&rqst);
@@ -2916,9 +2924,10 @@ smb2_echo_callback(struct mid_q_entry *mid)
2916{ 2924{
2917 struct TCP_Server_Info *server = mid->callback_data; 2925 struct TCP_Server_Info *server = mid->callback_data;
2918 struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf; 2926 struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf;
2919 unsigned int credits_received = 1; 2927 unsigned int credits_received = 0;
2920 2928
2921 if (mid->mid_state == MID_RESPONSE_RECEIVED) 2929 if (mid->mid_state == MID_RESPONSE_RECEIVED
2930 || mid->mid_state == MID_RESPONSE_MALFORMED)
2922 credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); 2931 credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
2923 2932
2924 DeleteMidQEntry(mid); 2933 DeleteMidQEntry(mid);
@@ -3175,7 +3184,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
3175 struct TCP_Server_Info *server = tcon->ses->server; 3184 struct TCP_Server_Info *server = tcon->ses->server;
3176 struct smb2_sync_hdr *shdr = 3185 struct smb2_sync_hdr *shdr =
3177 (struct smb2_sync_hdr *)rdata->iov[0].iov_base; 3186 (struct smb2_sync_hdr *)rdata->iov[0].iov_base;
3178 unsigned int credits_received = 1; 3187 unsigned int credits_received = 0;
3179 struct smb_rqst rqst = { .rq_iov = rdata->iov, 3188 struct smb_rqst rqst = { .rq_iov = rdata->iov,
3180 .rq_nvec = 2, 3189 .rq_nvec = 2,
3181 .rq_pages = rdata->pages, 3190 .rq_pages = rdata->pages,
@@ -3214,6 +3223,9 @@ smb2_readv_callback(struct mid_q_entry *mid)
3214 task_io_account_read(rdata->got_bytes); 3223 task_io_account_read(rdata->got_bytes);
3215 cifs_stats_bytes_read(tcon, rdata->got_bytes); 3224 cifs_stats_bytes_read(tcon, rdata->got_bytes);
3216 break; 3225 break;
3226 case MID_RESPONSE_MALFORMED:
3227 credits_received = le16_to_cpu(shdr->CreditRequest);
3228 /* fall through */
3217 default: 3229 default:
3218 if (rdata->result != -ENODATA) 3230 if (rdata->result != -ENODATA)
3219 rdata->result = -EIO; 3231 rdata->result = -EIO;
@@ -3399,7 +3411,7 @@ smb2_writev_callback(struct mid_q_entry *mid)
3399 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 3411 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
3400 unsigned int written; 3412 unsigned int written;
3401 struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf; 3413 struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf;
3402 unsigned int credits_received = 1; 3414 unsigned int credits_received = 0;
3403 3415
3404 switch (mid->mid_state) { 3416 switch (mid->mid_state) {
3405 case MID_RESPONSE_RECEIVED: 3417 case MID_RESPONSE_RECEIVED:
@@ -3427,6 +3439,9 @@ smb2_writev_callback(struct mid_q_entry *mid)
3427 case MID_RETRY_NEEDED: 3439 case MID_RETRY_NEEDED:
3428 wdata->result = -EAGAIN; 3440 wdata->result = -EAGAIN;
3429 break; 3441 break;
3442 case MID_RESPONSE_MALFORMED:
3443 credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
3444 /* fall through */
3430 default: 3445 default:
3431 wdata->result = -EIO; 3446 wdata->result = -EIO;
3432 break; 3447 break;
diff --git a/fs/cifs/trace.c b/fs/cifs/trace.c
index bd4a546feec1..465483787193 100644
--- a/fs/cifs/trace.c
+++ b/fs/cifs/trace.c
@@ -3,16 +3,6 @@
3 * Copyright (C) 2018, Microsoft Corporation. 3 * Copyright (C) 2018, Microsoft Corporation.
4 * 4 *
5 * Author(s): Steve French <stfrench@microsoft.com> 5 * Author(s): Steve French <stfrench@microsoft.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU General Public License for more details.
16 */ 6 */
17#define CREATE_TRACE_POINTS 7#define CREATE_TRACE_POINTS
18#include "trace.h" 8#include "trace.h"
diff --git a/fs/cifs/trace.h b/fs/cifs/trace.h
index fb049809555f..59be48206932 100644
--- a/fs/cifs/trace.h
+++ b/fs/cifs/trace.h
@@ -3,16 +3,6 @@
3 * Copyright (C) 2018, Microsoft Corporation. 3 * Copyright (C) 2018, Microsoft Corporation.
4 * 4 *
5 * Author(s): Steve French <stfrench@microsoft.com> 5 * Author(s): Steve French <stfrench@microsoft.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU General Public License for more details.
16 */ 6 */
17#undef TRACE_SYSTEM 7#undef TRACE_SYSTEM
18#define TRACE_SYSTEM cifs 8#define TRACE_SYSTEM cifs
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 202e0e84efdd..53532bd3f50d 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -786,17 +786,8 @@ static void
786cifs_compound_callback(struct mid_q_entry *mid) 786cifs_compound_callback(struct mid_q_entry *mid)
787{ 787{
788 struct TCP_Server_Info *server = mid->server; 788 struct TCP_Server_Info *server = mid->server;
789 unsigned int optype = mid->optype;
790 unsigned int credits_received = 0;
791 789
792 if (mid->mid_state == MID_RESPONSE_RECEIVED) { 790 add_credits(server, server->ops->get_credits(mid), mid->optype);
793 if (mid->resp_buf)
794 credits_received = server->ops->get_credits(mid);
795 else
796 cifs_dbg(FYI, "Bad state for cancelled MID\n");
797 }
798
799 add_credits(server, credits_received, optype);
800} 791}
801 792
802static void 793static void
diff --git a/fs/direct-io.c b/fs/direct-io.c
index dbc1a1f080ce..ec2fb6fe6d37 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -679,6 +679,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
679 unsigned long fs_count; /* Number of filesystem-sized blocks */ 679 unsigned long fs_count; /* Number of filesystem-sized blocks */
680 int create; 680 int create;
681 unsigned int i_blkbits = sdio->blkbits + sdio->blkfactor; 681 unsigned int i_blkbits = sdio->blkbits + sdio->blkfactor;
682 loff_t i_size;
682 683
683 /* 684 /*
684 * If there was a memory error and we've overwritten all the 685 * If there was a memory error and we've overwritten all the
@@ -708,8 +709,8 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
708 */ 709 */
709 create = dio->op == REQ_OP_WRITE; 710 create = dio->op == REQ_OP_WRITE;
710 if (dio->flags & DIO_SKIP_HOLES) { 711 if (dio->flags & DIO_SKIP_HOLES) {
711 if (fs_startblk <= ((i_size_read(dio->inode) - 1) >> 712 i_size = i_size_read(dio->inode);
712 i_blkbits)) 713 if (i_size && fs_startblk <= (i_size - 1) >> i_blkbits)
713 create = 0; 714 create = 0;
714 } 715 }
715 716
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index b40168fcc94a..36855c1f8daf 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -331,11 +331,22 @@ struct inode_switch_wbs_context {
331 struct work_struct work; 331 struct work_struct work;
332}; 332};
333 333
334static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi)
335{
336 down_write(&bdi->wb_switch_rwsem);
337}
338
339static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi)
340{
341 up_write(&bdi->wb_switch_rwsem);
342}
343
334static void inode_switch_wbs_work_fn(struct work_struct *work) 344static void inode_switch_wbs_work_fn(struct work_struct *work)
335{ 345{
336 struct inode_switch_wbs_context *isw = 346 struct inode_switch_wbs_context *isw =
337 container_of(work, struct inode_switch_wbs_context, work); 347 container_of(work, struct inode_switch_wbs_context, work);
338 struct inode *inode = isw->inode; 348 struct inode *inode = isw->inode;
349 struct backing_dev_info *bdi = inode_to_bdi(inode);
339 struct address_space *mapping = inode->i_mapping; 350 struct address_space *mapping = inode->i_mapping;
340 struct bdi_writeback *old_wb = inode->i_wb; 351 struct bdi_writeback *old_wb = inode->i_wb;
341 struct bdi_writeback *new_wb = isw->new_wb; 352 struct bdi_writeback *new_wb = isw->new_wb;
@@ -344,6 +355,12 @@ static void inode_switch_wbs_work_fn(struct work_struct *work)
344 bool switched = false; 355 bool switched = false;
345 356
346 /* 357 /*
358 * If @inode switches cgwb membership while sync_inodes_sb() is
359 * being issued, sync_inodes_sb() might miss it. Synchronize.
360 */
361 down_read(&bdi->wb_switch_rwsem);
362
363 /*
347 * By the time control reaches here, RCU grace period has passed 364 * By the time control reaches here, RCU grace period has passed
348 * since I_WB_SWITCH assertion and all wb stat update transactions 365 * since I_WB_SWITCH assertion and all wb stat update transactions
349 * between unlocked_inode_to_wb_begin/end() are guaranteed to be 366 * between unlocked_inode_to_wb_begin/end() are guaranteed to be
@@ -428,6 +445,8 @@ skip_switch:
428 spin_unlock(&new_wb->list_lock); 445 spin_unlock(&new_wb->list_lock);
429 spin_unlock(&old_wb->list_lock); 446 spin_unlock(&old_wb->list_lock);
430 447
448 up_read(&bdi->wb_switch_rwsem);
449
431 if (switched) { 450 if (switched) {
432 wb_wakeup(new_wb); 451 wb_wakeup(new_wb);
433 wb_put(old_wb); 452 wb_put(old_wb);
@@ -468,9 +487,18 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
468 if (inode->i_state & I_WB_SWITCH) 487 if (inode->i_state & I_WB_SWITCH)
469 return; 488 return;
470 489
490 /*
491 * Avoid starting new switches while sync_inodes_sb() is in
492 * progress. Otherwise, if the down_write protected issue path
493 * blocks heavily, we might end up starting a large number of
494 * switches which will block on the rwsem.
495 */
496 if (!down_read_trylock(&bdi->wb_switch_rwsem))
497 return;
498
471 isw = kzalloc(sizeof(*isw), GFP_ATOMIC); 499 isw = kzalloc(sizeof(*isw), GFP_ATOMIC);
472 if (!isw) 500 if (!isw)
473 return; 501 goto out_unlock;
474 502
475 /* find and pin the new wb */ 503 /* find and pin the new wb */
476 rcu_read_lock(); 504 rcu_read_lock();
@@ -504,12 +532,14 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
504 * Let's continue after I_WB_SWITCH is guaranteed to be visible. 532 * Let's continue after I_WB_SWITCH is guaranteed to be visible.
505 */ 533 */
506 call_rcu(&isw->rcu_head, inode_switch_wbs_rcu_fn); 534 call_rcu(&isw->rcu_head, inode_switch_wbs_rcu_fn);
507 return; 535 goto out_unlock;
508 536
509out_free: 537out_free:
510 if (isw->new_wb) 538 if (isw->new_wb)
511 wb_put(isw->new_wb); 539 wb_put(isw->new_wb);
512 kfree(isw); 540 kfree(isw);
541out_unlock:
542 up_read(&bdi->wb_switch_rwsem);
513} 543}
514 544
515/** 545/**
@@ -887,6 +917,9 @@ fs_initcall(cgroup_writeback_init);
887 917
888#else /* CONFIG_CGROUP_WRITEBACK */ 918#else /* CONFIG_CGROUP_WRITEBACK */
889 919
920static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) { }
921static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi) { }
922
890static struct bdi_writeback * 923static struct bdi_writeback *
891locked_inode_to_wb_and_lock_list(struct inode *inode) 924locked_inode_to_wb_and_lock_list(struct inode *inode)
892 __releases(&inode->i_lock) 925 __releases(&inode->i_lock)
@@ -2413,8 +2446,11 @@ void sync_inodes_sb(struct super_block *sb)
2413 return; 2446 return;
2414 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 2447 WARN_ON(!rwsem_is_locked(&sb->s_umount));
2415 2448
2449 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
2450 bdi_down_write_wb_switch_rwsem(bdi);
2416 bdi_split_work_to_wbs(bdi, &work, false); 2451 bdi_split_work_to_wbs(bdi, &work, false);
2417 wb_wait_for_completion(bdi, &done); 2452 wb_wait_for_completion(bdi, &done);
2453 bdi_up_write_wb_switch_rwsem(bdi);
2418 2454
2419 wait_sb_inodes(sb); 2455 wait_sb_inodes(sb);
2420} 2456}
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 105576daca4a..798f1253141a 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -724,8 +724,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
724 return -EBADF; 724 return -EBADF;
725 725
726 /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */ 726 /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
727 if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) 727 if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
728 return -EINVAL; 728 ret = -EINVAL;
729 goto fput_and_out;
730 }
729 731
730 /* verify that this is indeed an inotify instance */ 732 /* verify that this is indeed an inotify instance */
731 if (unlikely(f.file->f_op != &inotify_fops)) { 733 if (unlikely(f.file->f_op != &inotify_fops)) {
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index c31157135598..07e02d6df5ad 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -190,6 +190,7 @@ struct backing_dev_info {
190 struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ 190 struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */
191 struct rb_root cgwb_congested_tree; /* their congested states */ 191 struct rb_root cgwb_congested_tree; /* their congested states */
192 struct mutex cgwb_release_mutex; /* protect shutdown of wb structs */ 192 struct mutex cgwb_release_mutex; /* protect shutdown of wb structs */
193 struct rw_semaphore wb_switch_rwsem; /* no cgwb switch while syncing */
193#else 194#else
194 struct bdi_writeback_congested *wb_congested; 195 struct bdi_writeback_congested *wb_congested;
195#endif 196#endif
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 5c7e7f859a24..d66bf5f32610 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -287,7 +287,7 @@ enum req_opf {
287 REQ_OP_DISCARD = 3, 287 REQ_OP_DISCARD = 3,
288 /* securely erase sectors */ 288 /* securely erase sectors */
289 REQ_OP_SECURE_ERASE = 5, 289 REQ_OP_SECURE_ERASE = 5,
290 /* seset a zone write pointer */ 290 /* reset a zone write pointer */
291 REQ_OP_ZONE_RESET = 6, 291 REQ_OP_ZONE_RESET = 6,
292 /* write the same sector many times */ 292 /* write the same sector many times */
293 REQ_OP_WRITE_SAME = 7, 293 REQ_OP_WRITE_SAME = 7,
diff --git a/include/linux/hid.h b/include/linux/hid.h
index d99287327ef2..f9707d1dcb58 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -430,7 +430,7 @@ struct hid_local {
430 */ 430 */
431 431
432struct hid_collection { 432struct hid_collection {
433 struct hid_collection *parent; 433 int parent_idx; /* device->collection */
434 unsigned type; 434 unsigned type;
435 unsigned usage; 435 unsigned usage;
436 unsigned level; 436 unsigned level;
@@ -658,7 +658,6 @@ struct hid_parser {
658 unsigned int *collection_stack; 658 unsigned int *collection_stack;
659 unsigned int collection_stack_ptr; 659 unsigned int collection_stack_ptr;
660 unsigned int collection_stack_size; 660 unsigned int collection_stack_size;
661 struct hid_collection *active_collection;
662 struct hid_device *device; 661 struct hid_device *device;
663 unsigned int scan_flags; 662 unsigned int scan_flags;
664}; 663};
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index f0885cc01db6..dcb6977afce9 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1159,8 +1159,9 @@ struct hv_ring_buffer_debug_info {
1159 u32 bytes_avail_towrite; 1159 u32 bytes_avail_towrite;
1160}; 1160};
1161 1161
1162void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info, 1162
1163 struct hv_ring_buffer_debug_info *debug_info); 1163int hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
1164 struct hv_ring_buffer_debug_info *debug_info);
1164 1165
1165/* Vmbus interface */ 1166/* Vmbus interface */
1166#define vmbus_driver_register(driver) \ 1167#define vmbus_driver_register(driver) \
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 6756fea18b69..e44746de95cd 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -54,6 +54,7 @@ static inline bool dev_is_mac_header_xmit(const struct net_device *dev)
54 case ARPHRD_IPGRE: 54 case ARPHRD_IPGRE:
55 case ARPHRD_VOID: 55 case ARPHRD_VOID:
56 case ARPHRD_NONE: 56 case ARPHRD_NONE:
57 case ARPHRD_RAWIP:
57 return false; 58 return false;
58 default: 59 default:
59 return true; 60 return true;
diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index 7315977b64da..ad609617aeb8 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -235,7 +235,6 @@ static inline struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus,
235 cmd_mask, num_flush, flush_wpq, NULL, NULL); 235 cmd_mask, num_flush, flush_wpq, NULL, NULL);
236} 236}
237 237
238int nvdimm_security_setup_events(struct nvdimm *nvdimm);
239const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd); 238const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd);
240const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd); 239const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd);
241u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd, 240u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index f492e21c4aa2..5d9d318bcf7a 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -176,7 +176,8 @@ static inline bool xa_is_internal(const void *entry)
176 */ 176 */
177static inline bool xa_is_err(const void *entry) 177static inline bool xa_is_err(const void *entry)
178{ 178{
179 return unlikely(xa_is_internal(entry)); 179 return unlikely(xa_is_internal(entry) &&
180 entry >= xa_mk_internal(-MAX_ERRNO));
180} 181}
181 182
182/** 183/**
@@ -286,7 +287,6 @@ struct xarray {
286 */ 287 */
287#define DEFINE_XARRAY_ALLOC(name) DEFINE_XARRAY_FLAGS(name, XA_FLAGS_ALLOC) 288#define DEFINE_XARRAY_ALLOC(name) DEFINE_XARRAY_FLAGS(name, XA_FLAGS_ALLOC)
288 289
289void xa_init_flags(struct xarray *, gfp_t flags);
290void *xa_load(struct xarray *, unsigned long index); 290void *xa_load(struct xarray *, unsigned long index);
291void *xa_store(struct xarray *, unsigned long index, void *entry, gfp_t); 291void *xa_store(struct xarray *, unsigned long index, void *entry, gfp_t);
292void *xa_erase(struct xarray *, unsigned long index); 292void *xa_erase(struct xarray *, unsigned long index);
@@ -304,6 +304,24 @@ unsigned int xa_extract(struct xarray *, void **dst, unsigned long start,
304void xa_destroy(struct xarray *); 304void xa_destroy(struct xarray *);
305 305
306/** 306/**
307 * xa_init_flags() - Initialise an empty XArray with flags.
308 * @xa: XArray.
309 * @flags: XA_FLAG values.
310 *
311 * If you need to initialise an XArray with special flags (eg you need
312 * to take the lock from interrupt context), use this function instead
313 * of xa_init().
314 *
315 * Context: Any context.
316 */
317static inline void xa_init_flags(struct xarray *xa, gfp_t flags)
318{
319 spin_lock_init(&xa->xa_lock);
320 xa->xa_flags = flags;
321 xa->xa_head = NULL;
322}
323
324/**
307 * xa_init() - Initialise an empty XArray. 325 * xa_init() - Initialise an empty XArray.
308 * @xa: XArray. 326 * @xa: XArray.
309 * 327 *
@@ -342,20 +360,45 @@ static inline bool xa_marked(const struct xarray *xa, xa_mark_t mark)
342} 360}
343 361
344/** 362/**
345 * xa_for_each() - Iterate over a portion of an XArray. 363 * xa_for_each_start() - Iterate over a portion of an XArray.
346 * @xa: XArray. 364 * @xa: XArray.
365 * @index: Index of @entry.
347 * @entry: Entry retrieved from array. 366 * @entry: Entry retrieved from array.
367 * @start: First index to retrieve from array.
368 *
369 * During the iteration, @entry will have the value of the entry stored
370 * in @xa at @index. You may modify @index during the iteration if you
371 * want to skip or reprocess indices. It is safe to modify the array
372 * during the iteration. At the end of the iteration, @entry will be set
373 * to NULL and @index will have a value less than or equal to max.
374 *
375 * xa_for_each_start() is O(n.log(n)) while xas_for_each() is O(n). You have
376 * to handle your own locking with xas_for_each(), and if you have to unlock
377 * after each iteration, it will also end up being O(n.log(n)).
378 * xa_for_each_start() will spin if it hits a retry entry; if you intend to
379 * see retry entries, you should use the xas_for_each() iterator instead.
380 * The xas_for_each() iterator will expand into more inline code than
381 * xa_for_each_start().
382 *
383 * Context: Any context. Takes and releases the RCU lock.
384 */
385#define xa_for_each_start(xa, index, entry, start) \
386 for (index = start, \
387 entry = xa_find(xa, &index, ULONG_MAX, XA_PRESENT); \
388 entry; \
389 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT))
390
391/**
392 * xa_for_each() - Iterate over present entries in an XArray.
393 * @xa: XArray.
348 * @index: Index of @entry. 394 * @index: Index of @entry.
349 * @max: Maximum index to retrieve from array. 395 * @entry: Entry retrieved from array.
350 * @filter: Selection criterion.
351 * 396 *
352 * Initialise @index to the lowest index you want to retrieve from the 397 * During the iteration, @entry will have the value of the entry stored
353 * array. During the iteration, @entry will have the value of the entry 398 * in @xa at @index. You may modify @index during the iteration if you want
354 * stored in @xa at @index. The iteration will skip all entries in the 399 * to skip or reprocess indices. It is safe to modify the array during the
355 * array which do not match @filter. You may modify @index during the 400 * iteration. At the end of the iteration, @entry will be set to NULL and
356 * iteration if you want to skip or reprocess indices. It is safe to modify 401 * @index will have a value less than or equal to max.
357 * the array during the iteration. At the end of the iteration, @entry will
358 * be set to NULL and @index will have a value less than or equal to max.
359 * 402 *
360 * xa_for_each() is O(n.log(n)) while xas_for_each() is O(n). You have 403 * xa_for_each() is O(n.log(n)) while xas_for_each() is O(n). You have
361 * to handle your own locking with xas_for_each(), and if you have to unlock 404 * to handle your own locking with xas_for_each(), and if you have to unlock
@@ -366,9 +409,36 @@ static inline bool xa_marked(const struct xarray *xa, xa_mark_t mark)
366 * 409 *
367 * Context: Any context. Takes and releases the RCU lock. 410 * Context: Any context. Takes and releases the RCU lock.
368 */ 411 */
369#define xa_for_each(xa, entry, index, max, filter) \ 412#define xa_for_each(xa, index, entry) \
370 for (entry = xa_find(xa, &index, max, filter); entry; \ 413 xa_for_each_start(xa, index, entry, 0)
371 entry = xa_find_after(xa, &index, max, filter)) 414
415/**
416 * xa_for_each_marked() - Iterate over marked entries in an XArray.
417 * @xa: XArray.
418 * @index: Index of @entry.
419 * @entry: Entry retrieved from array.
420 * @filter: Selection criterion.
421 *
422 * During the iteration, @entry will have the value of the entry stored
423 * in @xa at @index. The iteration will skip all entries in the array
424 * which do not match @filter. You may modify @index during the iteration
425 * if you want to skip or reprocess indices. It is safe to modify the array
426 * during the iteration. At the end of the iteration, @entry will be set to
427 * NULL and @index will have a value less than or equal to max.
428 *
429 * xa_for_each_marked() is O(n.log(n)) while xas_for_each_marked() is O(n).
430 * You have to handle your own locking with xas_for_each(), and if you have
431 * to unlock after each iteration, it will also end up being O(n.log(n)).
432 * xa_for_each_marked() will spin if it hits a retry entry; if you intend to
433 * see retry entries, you should use the xas_for_each_marked() iterator
434 * instead. The xas_for_each_marked() iterator will expand into more inline
435 * code than xa_for_each_marked().
436 *
437 * Context: Any context. Takes and releases the RCU lock.
438 */
439#define xa_for_each_marked(xa, index, entry, filter) \
440 for (index = 0, entry = xa_find(xa, &index, ULONG_MAX, filter); \
441 entry; entry = xa_find_after(xa, &index, ULONG_MAX, filter))
372 442
373#define xa_trylock(xa) spin_trylock(&(xa)->xa_lock) 443#define xa_trylock(xa) spin_trylock(&(xa)->xa_lock)
374#define xa_lock(xa) spin_lock(&(xa)->xa_lock) 444#define xa_lock(xa) spin_lock(&(xa)->xa_lock)
@@ -393,40 +463,13 @@ void *__xa_erase(struct xarray *, unsigned long index);
393void *__xa_store(struct xarray *, unsigned long index, void *entry, gfp_t); 463void *__xa_store(struct xarray *, unsigned long index, void *entry, gfp_t);
394void *__xa_cmpxchg(struct xarray *, unsigned long index, void *old, 464void *__xa_cmpxchg(struct xarray *, unsigned long index, void *old,
395 void *entry, gfp_t); 465 void *entry, gfp_t);
466int __xa_insert(struct xarray *, unsigned long index, void *entry, gfp_t);
396int __xa_alloc(struct xarray *, u32 *id, u32 max, void *entry, gfp_t); 467int __xa_alloc(struct xarray *, u32 *id, u32 max, void *entry, gfp_t);
397int __xa_reserve(struct xarray *, unsigned long index, gfp_t); 468int __xa_reserve(struct xarray *, unsigned long index, gfp_t);
398void __xa_set_mark(struct xarray *, unsigned long index, xa_mark_t); 469void __xa_set_mark(struct xarray *, unsigned long index, xa_mark_t);
399void __xa_clear_mark(struct xarray *, unsigned long index, xa_mark_t); 470void __xa_clear_mark(struct xarray *, unsigned long index, xa_mark_t);
400 471
401/** 472/**
402 * __xa_insert() - Store this entry in the XArray unless another entry is
403 * already present.
404 * @xa: XArray.
405 * @index: Index into array.
406 * @entry: New entry.
407 * @gfp: Memory allocation flags.
408 *
409 * If you would rather see the existing entry in the array, use __xa_cmpxchg().
410 * This function is for users who don't care what the entry is, only that
411 * one is present.
412 *
413 * Context: Any context. Expects xa_lock to be held on entry. May
414 * release and reacquire xa_lock if the @gfp flags permit.
415 * Return: 0 if the store succeeded. -EEXIST if another entry was present.
416 * -ENOMEM if memory could not be allocated.
417 */
418static inline int __xa_insert(struct xarray *xa, unsigned long index,
419 void *entry, gfp_t gfp)
420{
421 void *curr = __xa_cmpxchg(xa, index, NULL, entry, gfp);
422 if (!curr)
423 return 0;
424 if (xa_is_err(curr))
425 return xa_err(curr);
426 return -EEXIST;
427}
428
429/**
430 * xa_store_bh() - Store this entry in the XArray. 473 * xa_store_bh() - Store this entry in the XArray.
431 * @xa: XArray. 474 * @xa: XArray.
432 * @index: Index into array. 475 * @index: Index into array.
@@ -453,7 +496,7 @@ static inline void *xa_store_bh(struct xarray *xa, unsigned long index,
453} 496}
454 497
455/** 498/**
456 * xa_store_irq() - Erase this entry from the XArray. 499 * xa_store_irq() - Store this entry in the XArray.
457 * @xa: XArray. 500 * @xa: XArray.
458 * @index: Index into array. 501 * @index: Index into array.
459 * @entry: New entry. 502 * @entry: New entry.
@@ -615,24 +658,83 @@ static inline void *xa_cmpxchg_irq(struct xarray *xa, unsigned long index,
615 * @entry: New entry. 658 * @entry: New entry.
616 * @gfp: Memory allocation flags. 659 * @gfp: Memory allocation flags.
617 * 660 *
618 * If you would rather see the existing entry in the array, use xa_cmpxchg(). 661 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
619 * This function is for users who don't care what the entry is, only that 662 * if no entry is present. Inserting will fail if a reserved entry is
620 * one is present. 663 * present, even though loading from this index will return NULL.
621 * 664 *
622 * Context: Process context. Takes and releases the xa_lock. 665 * Context: Any context. Takes and releases the xa_lock. May sleep if
623 * May sleep if the @gfp flags permit. 666 * the @gfp flags permit.
624 * Return: 0 if the store succeeded. -EEXIST if another entry was present. 667 * Return: 0 if the store succeeded. -EEXIST if another entry was present.
625 * -ENOMEM if memory could not be allocated. 668 * -ENOMEM if memory could not be allocated.
626 */ 669 */
627static inline int xa_insert(struct xarray *xa, unsigned long index, 670static inline int xa_insert(struct xarray *xa, unsigned long index,
628 void *entry, gfp_t gfp) 671 void *entry, gfp_t gfp)
629{ 672{
630 void *curr = xa_cmpxchg(xa, index, NULL, entry, gfp); 673 int err;
631 if (!curr) 674
632 return 0; 675 xa_lock(xa);
633 if (xa_is_err(curr)) 676 err = __xa_insert(xa, index, entry, gfp);
634 return xa_err(curr); 677 xa_unlock(xa);
635 return -EEXIST; 678
679 return err;
680}
681
682/**
683 * xa_insert_bh() - Store this entry in the XArray unless another entry is
684 * already present.
685 * @xa: XArray.
686 * @index: Index into array.
687 * @entry: New entry.
688 * @gfp: Memory allocation flags.
689 *
690 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
691 * if no entry is present. Inserting will fail if a reserved entry is
692 * present, even though loading from this index will return NULL.
693 *
694 * Context: Any context. Takes and releases the xa_lock while
695 * disabling softirqs. May sleep if the @gfp flags permit.
696 * Return: 0 if the store succeeded. -EEXIST if another entry was present.
697 * -ENOMEM if memory could not be allocated.
698 */
699static inline int xa_insert_bh(struct xarray *xa, unsigned long index,
700 void *entry, gfp_t gfp)
701{
702 int err;
703
704 xa_lock_bh(xa);
705 err = __xa_insert(xa, index, entry, gfp);
706 xa_unlock_bh(xa);
707
708 return err;
709}
710
711/**
712 * xa_insert_irq() - Store this entry in the XArray unless another entry is
713 * already present.
714 * @xa: XArray.
715 * @index: Index into array.
716 * @entry: New entry.
717 * @gfp: Memory allocation flags.
718 *
719 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
720 * if no entry is present. Inserting will fail if a reserved entry is
721 * present, even though loading from this index will return NULL.
722 *
723 * Context: Process context. Takes and releases the xa_lock while
724 * disabling interrupts. May sleep if the @gfp flags permit.
725 * Return: 0 if the store succeeded. -EEXIST if another entry was present.
726 * -ENOMEM if memory could not be allocated.
727 */
728static inline int xa_insert_irq(struct xarray *xa, unsigned long index,
729 void *entry, gfp_t gfp)
730{
731 int err;
732
733 xa_lock_irq(xa);
734 err = __xa_insert(xa, index, entry, gfp);
735 xa_unlock_irq(xa);
736
737 return err;
636} 738}
637 739
638/** 740/**
@@ -970,8 +1072,8 @@ static inline bool xa_is_sibling(const void *entry)
970 (entry < xa_mk_sibling(XA_CHUNK_SIZE - 1)); 1072 (entry < xa_mk_sibling(XA_CHUNK_SIZE - 1));
971} 1073}
972 1074
973#define XA_ZERO_ENTRY xa_mk_internal(256) 1075#define XA_RETRY_ENTRY xa_mk_internal(256)
974#define XA_RETRY_ENTRY xa_mk_internal(257) 1076#define XA_ZERO_ENTRY xa_mk_internal(257)
975 1077
976/** 1078/**
977 * xa_is_zero() - Is the entry a zero entry? 1079 * xa_is_zero() - Is the entry a zero entry?
@@ -996,6 +1098,17 @@ static inline bool xa_is_retry(const void *entry)
996} 1098}
997 1099
998/** 1100/**
1101 * xa_is_advanced() - Is the entry only permitted for the advanced API?
1102 * @entry: Entry to be stored in the XArray.
1103 *
1104 * Return: %true if the entry cannot be stored by the normal API.
1105 */
1106static inline bool xa_is_advanced(const void *entry)
1107{
1108 return xa_is_internal(entry) && (entry <= XA_RETRY_ENTRY);
1109}
1110
1111/**
999 * typedef xa_update_node_t - A callback function from the XArray. 1112 * typedef xa_update_node_t - A callback function from the XArray.
1000 * @node: The node which is being processed 1113 * @node: The node which is being processed
1001 * 1114 *
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 3f9aea8087e3..8b7eb46ad72d 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -201,6 +201,18 @@ static inline void ax25_hold_route(ax25_route *ax25_rt)
201 201
202void __ax25_put_route(ax25_route *ax25_rt); 202void __ax25_put_route(ax25_route *ax25_rt);
203 203
204extern rwlock_t ax25_route_lock;
205
206static inline void ax25_route_lock_use(void)
207{
208 read_lock(&ax25_route_lock);
209}
210
211static inline void ax25_route_lock_unuse(void)
212{
213 read_unlock(&ax25_route_lock);
214}
215
204static inline void ax25_put_route(ax25_route *ax25_rt) 216static inline void ax25_put_route(ax25_route *ax25_rt)
205{ 217{
206 if (refcount_dec_and_test(&ax25_rt->refcount)) 218 if (refcount_dec_and_test(&ax25_rt->refcount))
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8ec1de856ee7..e665f111b0d2 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -985,6 +985,12 @@ struct snd_soc_dai_link {
985 /* Do not create a PCM for this DAI link (Backend link) */ 985 /* Do not create a PCM for this DAI link (Backend link) */
986 unsigned int ignore:1; 986 unsigned int ignore:1;
987 987
988 /*
989 * This driver uses legacy platform naming. Set by the core, machine
990 * drivers should not modify this value.
991 */
992 unsigned int legacy_platform:1;
993
988 struct list_head list; /* DAI link list of the soc card */ 994 struct list_head list; /* DAI link list of the soc card */
989 struct snd_soc_dobj dobj; /* For topology */ 995 struct snd_soc_dobj dobj; /* For topology */
990}; 996};
diff --git a/include/uapi/linux/android/binder_ctl.h b/include/uapi/linux/android/binderfs.h
index 65b2efd1a0a5..87410477aea9 100644
--- a/include/uapi/linux/android/binder_ctl.h
+++ b/include/uapi/linux/android/binderfs.h
@@ -4,8 +4,8 @@
4 * 4 *
5 */ 5 */
6 6
7#ifndef _UAPI_LINUX_BINDER_CTL_H 7#ifndef _UAPI_LINUX_BINDERFS_H
8#define _UAPI_LINUX_BINDER_CTL_H 8#define _UAPI_LINUX_BINDERFS_H
9 9
10#include <linux/android/binder.h> 10#include <linux/android/binder.h>
11#include <linux/types.h> 11#include <linux/types.h>
@@ -22,8 +22,8 @@
22 */ 22 */
23struct binderfs_device { 23struct binderfs_device {
24 char name[BINDERFS_MAX_NAME + 1]; 24 char name[BINDERFS_MAX_NAME + 1];
25 __u8 major; 25 __u32 major;
26 __u8 minor; 26 __u32 minor;
27}; 27};
28 28
29/** 29/**
@@ -31,5 +31,5 @@ struct binderfs_device {
31 */ 31 */
32#define BINDER_CTL_ADD _IOWR('b', 1, struct binderfs_device) 32#define BINDER_CTL_ADD _IOWR('b', 1, struct binderfs_device)
33 33
34#endif /* _UAPI_LINUX_BINDER_CTL_H */ 34#endif /* _UAPI_LINUX_BINDERFS_H */
35 35
diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h
index 6fa38d001d84..498eec813494 100644
--- a/include/uapi/linux/blkzoned.h
+++ b/include/uapi/linux/blkzoned.h
@@ -138,6 +138,7 @@ struct blk_zone_range {
138 * @BLKRESETZONE: Reset the write pointer of the zones in the specified 138 * @BLKRESETZONE: Reset the write pointer of the zones in the specified
139 * sector range. The sector range must be zone aligned. 139 * sector range. The sector range must be zone aligned.
140 * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors. 140 * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors.
141 * @BLKGETNRZONES: Get the total number of zones of the device.
141 */ 142 */
142#define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) 143#define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report)
143#define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range) 144#define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range)
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index fb78f6f500f3..f056b2a00d5c 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -26,13 +26,17 @@
26 */ 26 */
27 27
28struct input_event { 28struct input_event {
29#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL) 29#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
30 struct timeval time; 30 struct timeval time;
31#define input_event_sec time.tv_sec 31#define input_event_sec time.tv_sec
32#define input_event_usec time.tv_usec 32#define input_event_usec time.tv_usec
33#else 33#else
34 __kernel_ulong_t __sec; 34 __kernel_ulong_t __sec;
35#if defined(__sparc__) && defined(__arch64__)
36 unsigned int __usec;
37#else
35 __kernel_ulong_t __usec; 38 __kernel_ulong_t __usec;
39#endif
36#define input_event_sec __sec 40#define input_event_sec __sec
37#define input_event_usec __usec 41#define input_event_usec __usec
38#endif 42#endif
diff --git a/include/xen/arm/page-coherent.h b/include/xen/arm/page-coherent.h
index 59a260712a56..2ca9164a79bf 100644
--- a/include/xen/arm/page-coherent.h
+++ b/include/xen/arm/page-coherent.h
@@ -1,17 +1,6 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_ARM_XEN_PAGE_COHERENT_H 2#ifndef _XEN_ARM_PAGE_COHERENT_H
3#define _ASM_ARM_XEN_PAGE_COHERENT_H 3#define _XEN_ARM_PAGE_COHERENT_H
4
5#include <asm/page.h>
6#include <asm/dma-mapping.h>
7#include <linux/dma-mapping.h>
8
9static inline const struct dma_map_ops *xen_get_dma_ops(struct device *dev)
10{
11 if (dev && dev->archdata.dev_dma_ops)
12 return dev->archdata.dev_dma_ops;
13 return get_arch_dma_ops(NULL);
14}
15 4
16void __xen_dma_map_page(struct device *hwdev, struct page *page, 5void __xen_dma_map_page(struct device *hwdev, struct page *page,
17 dma_addr_t dev_addr, unsigned long offset, size_t size, 6 dma_addr_t dev_addr, unsigned long offset, size_t size,
@@ -21,87 +10,7 @@ void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
21 unsigned long attrs); 10 unsigned long attrs);
22void __xen_dma_sync_single_for_cpu(struct device *hwdev, 11void __xen_dma_sync_single_for_cpu(struct device *hwdev,
23 dma_addr_t handle, size_t size, enum dma_data_direction dir); 12 dma_addr_t handle, size_t size, enum dma_data_direction dir);
24
25void __xen_dma_sync_single_for_device(struct device *hwdev, 13void __xen_dma_sync_single_for_device(struct device *hwdev,
26 dma_addr_t handle, size_t size, enum dma_data_direction dir); 14 dma_addr_t handle, size_t size, enum dma_data_direction dir);
27 15
28static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, 16#endif /* _XEN_ARM_PAGE_COHERENT_H */
29 dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs)
30{
31 return xen_get_dma_ops(hwdev)->alloc(hwdev, size, dma_handle, flags, attrs);
32}
33
34static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
35 void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
36{
37 xen_get_dma_ops(hwdev)->free(hwdev, size, cpu_addr, dma_handle, attrs);
38}
39
40static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
41 dma_addr_t dev_addr, unsigned long offset, size_t size,
42 enum dma_data_direction dir, unsigned long attrs)
43{
44 unsigned long page_pfn = page_to_xen_pfn(page);
45 unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr);
46 unsigned long compound_pages =
47 (1<<compound_order(page)) * XEN_PFN_PER_PAGE;
48 bool local = (page_pfn <= dev_pfn) &&
49 (dev_pfn - page_pfn < compound_pages);
50
51 /*
52 * Dom0 is mapped 1:1, while the Linux page can span across
53 * multiple Xen pages, it's not possible for it to contain a
54 * mix of local and foreign Xen pages. So if the first xen_pfn
55 * == mfn the page is local otherwise it's a foreign page
56 * grant-mapped in dom0. If the page is local we can safely
57 * call the native dma_ops function, otherwise we call the xen
58 * specific function.
59 */
60 if (local)
61 xen_get_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
62 else
63 __xen_dma_map_page(hwdev, page, dev_addr, offset, size, dir, attrs);
64}
65
66static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
67 size_t size, enum dma_data_direction dir, unsigned long attrs)
68{
69 unsigned long pfn = PFN_DOWN(handle);
70 /*
71 * Dom0 is mapped 1:1, while the Linux page can be spanned accross
72 * multiple Xen page, it's not possible to have a mix of local and
73 * foreign Xen page. Dom0 is mapped 1:1, so calling pfn_valid on a
74 * foreign mfn will always return false. If the page is local we can
75 * safely call the native dma_ops function, otherwise we call the xen
76 * specific function.
77 */
78 if (pfn_valid(pfn)) {
79 if (xen_get_dma_ops(hwdev)->unmap_page)
80 xen_get_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);
81 } else
82 __xen_dma_unmap_page(hwdev, handle, size, dir, attrs);
83}
84
85static inline void xen_dma_sync_single_for_cpu(struct device *hwdev,
86 dma_addr_t handle, size_t size, enum dma_data_direction dir)
87{
88 unsigned long pfn = PFN_DOWN(handle);
89 if (pfn_valid(pfn)) {
90 if (xen_get_dma_ops(hwdev)->sync_single_for_cpu)
91 xen_get_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir);
92 } else
93 __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir);
94}
95
96static inline void xen_dma_sync_single_for_device(struct device *hwdev,
97 dma_addr_t handle, size_t size, enum dma_data_direction dir)
98{
99 unsigned long pfn = PFN_DOWN(handle);
100 if (pfn_valid(pfn)) {
101 if (xen_get_dma_ops(hwdev)->sync_single_for_device)
102 xen_get_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir);
103 } else
104 __xen_dma_sync_single_for_device(hwdev, handle, size, dir);
105}
106
107#endif /* _ASM_ARM_XEN_PAGE_COHERENT_H */
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index 4676c0a1eeca..c596a957f764 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -199,7 +199,7 @@ static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
199 XA_BUG_ON(xa, xa_store_index(xa, index + 1, GFP_KERNEL)); 199 XA_BUG_ON(xa, xa_store_index(xa, index + 1, GFP_KERNEL));
200 xa_set_mark(xa, index + 1, XA_MARK_0); 200 xa_set_mark(xa, index + 1, XA_MARK_0);
201 XA_BUG_ON(xa, xa_store_index(xa, index + 2, GFP_KERNEL)); 201 XA_BUG_ON(xa, xa_store_index(xa, index + 2, GFP_KERNEL));
202 xa_set_mark(xa, index + 2, XA_MARK_1); 202 xa_set_mark(xa, index + 2, XA_MARK_2);
203 XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL)); 203 XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL));
204 xa_store_order(xa, index, order, xa_mk_index(index), 204 xa_store_order(xa, index, order, xa_mk_index(index),
205 GFP_KERNEL); 205 GFP_KERNEL);
@@ -209,8 +209,8 @@ static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
209 void *entry; 209 void *entry;
210 210
211 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0)); 211 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0));
212 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_1)); 212 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_1));
213 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_2)); 213 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_2));
214 214
215 /* We should see two elements in the array */ 215 /* We should see two elements in the array */
216 rcu_read_lock(); 216 rcu_read_lock();
@@ -357,7 +357,7 @@ static noinline void check_cmpxchg(struct xarray *xa)
357static noinline void check_reserve(struct xarray *xa) 357static noinline void check_reserve(struct xarray *xa)
358{ 358{
359 void *entry; 359 void *entry;
360 unsigned long index = 0; 360 unsigned long index;
361 361
362 /* An array with a reserved entry is not empty */ 362 /* An array with a reserved entry is not empty */
363 XA_BUG_ON(xa, !xa_empty(xa)); 363 XA_BUG_ON(xa, !xa_empty(xa));
@@ -382,10 +382,12 @@ static noinline void check_reserve(struct xarray *xa)
382 xa_erase_index(xa, 12345678); 382 xa_erase_index(xa, 12345678);
383 XA_BUG_ON(xa, !xa_empty(xa)); 383 XA_BUG_ON(xa, !xa_empty(xa));
384 384
385 /* And so does xa_insert */ 385 /* But xa_insert does not */
386 xa_reserve(xa, 12345678, GFP_KERNEL); 386 xa_reserve(xa, 12345678, GFP_KERNEL);
387 XA_BUG_ON(xa, xa_insert(xa, 12345678, xa_mk_value(12345678), 0) != 0); 387 XA_BUG_ON(xa, xa_insert(xa, 12345678, xa_mk_value(12345678), 0) !=
388 xa_erase_index(xa, 12345678); 388 -EEXIST);
389 XA_BUG_ON(xa, xa_empty(xa));
390 XA_BUG_ON(xa, xa_erase(xa, 12345678) != NULL);
389 XA_BUG_ON(xa, !xa_empty(xa)); 391 XA_BUG_ON(xa, !xa_empty(xa));
390 392
391 /* Can iterate through a reserved entry */ 393 /* Can iterate through a reserved entry */
@@ -393,7 +395,7 @@ static noinline void check_reserve(struct xarray *xa)
393 xa_reserve(xa, 6, GFP_KERNEL); 395 xa_reserve(xa, 6, GFP_KERNEL);
394 xa_store_index(xa, 7, GFP_KERNEL); 396 xa_store_index(xa, 7, GFP_KERNEL);
395 397
396 xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) { 398 xa_for_each(xa, index, entry) {
397 XA_BUG_ON(xa, index != 5 && index != 7); 399 XA_BUG_ON(xa, index != 5 && index != 7);
398 } 400 }
399 xa_destroy(xa); 401 xa_destroy(xa);
@@ -812,17 +814,16 @@ static noinline void check_find_1(struct xarray *xa)
812static noinline void check_find_2(struct xarray *xa) 814static noinline void check_find_2(struct xarray *xa)
813{ 815{
814 void *entry; 816 void *entry;
815 unsigned long i, j, index = 0; 817 unsigned long i, j, index;
816 818
817 xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) { 819 xa_for_each(xa, index, entry) {
818 XA_BUG_ON(xa, true); 820 XA_BUG_ON(xa, true);
819 } 821 }
820 822
821 for (i = 0; i < 1024; i++) { 823 for (i = 0; i < 1024; i++) {
822 xa_store_index(xa, index, GFP_KERNEL); 824 xa_store_index(xa, index, GFP_KERNEL);
823 j = 0; 825 j = 0;
824 index = 0; 826 xa_for_each(xa, index, entry) {
825 xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) {
826 XA_BUG_ON(xa, xa_mk_index(index) != entry); 827 XA_BUG_ON(xa, xa_mk_index(index) != entry);
827 XA_BUG_ON(xa, index != j++); 828 XA_BUG_ON(xa, index != j++);
828 } 829 }
@@ -839,6 +840,7 @@ static noinline void check_find_3(struct xarray *xa)
839 840
840 for (i = 0; i < 100; i++) { 841 for (i = 0; i < 100; i++) {
841 for (j = 0; j < 100; j++) { 842 for (j = 0; j < 100; j++) {
843 rcu_read_lock();
842 for (k = 0; k < 100; k++) { 844 for (k = 0; k < 100; k++) {
843 xas_set(&xas, j); 845 xas_set(&xas, j);
844 xas_for_each_marked(&xas, entry, k, XA_MARK_0) 846 xas_for_each_marked(&xas, entry, k, XA_MARK_0)
@@ -847,6 +849,7 @@ static noinline void check_find_3(struct xarray *xa)
847 XA_BUG_ON(xa, 849 XA_BUG_ON(xa,
848 xas.xa_node != XAS_RESTART); 850 xas.xa_node != XAS_RESTART);
849 } 851 }
852 rcu_read_unlock();
850 } 853 }
851 xa_store_index(xa, i, GFP_KERNEL); 854 xa_store_index(xa, i, GFP_KERNEL);
852 xa_set_mark(xa, i, XA_MARK_0); 855 xa_set_mark(xa, i, XA_MARK_0);
@@ -1183,6 +1186,35 @@ static noinline void check_store_range(struct xarray *xa)
1183 } 1186 }
1184} 1187}
1185 1188
1189static void check_align_1(struct xarray *xa, char *name)
1190{
1191 int i;
1192 unsigned int id;
1193 unsigned long index;
1194 void *entry;
1195
1196 for (i = 0; i < 8; i++) {
1197 id = 0;
1198 XA_BUG_ON(xa, xa_alloc(xa, &id, UINT_MAX, name + i, GFP_KERNEL)
1199 != 0);
1200 XA_BUG_ON(xa, id != i);
1201 }
1202 xa_for_each(xa, index, entry)
1203 XA_BUG_ON(xa, xa_is_err(entry));
1204 xa_destroy(xa);
1205}
1206
1207static noinline void check_align(struct xarray *xa)
1208{
1209 char name[] = "Motorola 68000";
1210
1211 check_align_1(xa, name);
1212 check_align_1(xa, name + 1);
1213 check_align_1(xa, name + 2);
1214 check_align_1(xa, name + 3);
1215// check_align_2(xa, name);
1216}
1217
1186static LIST_HEAD(shadow_nodes); 1218static LIST_HEAD(shadow_nodes);
1187 1219
1188static void test_update_node(struct xa_node *node) 1220static void test_update_node(struct xa_node *node)
@@ -1332,6 +1364,7 @@ static int xarray_checks(void)
1332 check_create_range(&array); 1364 check_create_range(&array);
1333 check_store_range(&array); 1365 check_store_range(&array);
1334 check_store_iter(&array); 1366 check_store_iter(&array);
1367 check_align(&xa0);
1335 1368
1336 check_workingset(&array, 0); 1369 check_workingset(&array, 0);
1337 check_workingset(&array, 64); 1370 check_workingset(&array, 64);
diff --git a/lib/xarray.c b/lib/xarray.c
index 5f3f9311de89..81c3171ddde9 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -232,6 +232,8 @@ void *xas_load(struct xa_state *xas)
232 if (xas->xa_shift > node->shift) 232 if (xas->xa_shift > node->shift)
233 break; 233 break;
234 entry = xas_descend(xas, node); 234 entry = xas_descend(xas, node);
235 if (node->shift == 0)
236 break;
235 } 237 }
236 return entry; 238 return entry;
237} 239}
@@ -506,7 +508,7 @@ static void xas_free_nodes(struct xa_state *xas, struct xa_node *top)
506 for (;;) { 508 for (;;) {
507 void *entry = xa_entry_locked(xas->xa, node, offset); 509 void *entry = xa_entry_locked(xas->xa, node, offset);
508 510
509 if (xa_is_node(entry)) { 511 if (node->shift && xa_is_node(entry)) {
510 node = xa_to_node(entry); 512 node = xa_to_node(entry);
511 offset = 0; 513 offset = 0;
512 continue; 514 continue;
@@ -604,6 +606,7 @@ static int xas_expand(struct xa_state *xas, void *head)
604/* 606/*
605 * xas_create() - Create a slot to store an entry in. 607 * xas_create() - Create a slot to store an entry in.
606 * @xas: XArray operation state. 608 * @xas: XArray operation state.
609 * @allow_root: %true if we can store the entry in the root directly
607 * 610 *
608 * Most users will not need to call this function directly, as it is called 611 * Most users will not need to call this function directly, as it is called
609 * by xas_store(). It is useful for doing conditional store operations 612 * by xas_store(). It is useful for doing conditional store operations
@@ -613,7 +616,7 @@ static int xas_expand(struct xa_state *xas, void *head)
613 * If the slot was newly created, returns %NULL. If it failed to create the 616 * If the slot was newly created, returns %NULL. If it failed to create the
614 * slot, returns %NULL and indicates the error in @xas. 617 * slot, returns %NULL and indicates the error in @xas.
615 */ 618 */
616static void *xas_create(struct xa_state *xas) 619static void *xas_create(struct xa_state *xas, bool allow_root)
617{ 620{
618 struct xarray *xa = xas->xa; 621 struct xarray *xa = xas->xa;
619 void *entry; 622 void *entry;
@@ -628,6 +631,8 @@ static void *xas_create(struct xa_state *xas)
628 shift = xas_expand(xas, entry); 631 shift = xas_expand(xas, entry);
629 if (shift < 0) 632 if (shift < 0)
630 return NULL; 633 return NULL;
634 if (!shift && !allow_root)
635 shift = XA_CHUNK_SHIFT;
631 entry = xa_head_locked(xa); 636 entry = xa_head_locked(xa);
632 slot = &xa->xa_head; 637 slot = &xa->xa_head;
633 } else if (xas_error(xas)) { 638 } else if (xas_error(xas)) {
@@ -687,7 +692,7 @@ void xas_create_range(struct xa_state *xas)
687 xas->xa_sibs = 0; 692 xas->xa_sibs = 0;
688 693
689 for (;;) { 694 for (;;) {
690 xas_create(xas); 695 xas_create(xas, true);
691 if (xas_error(xas)) 696 if (xas_error(xas))
692 goto restore; 697 goto restore;
693 if (xas->xa_index <= (index | XA_CHUNK_MASK)) 698 if (xas->xa_index <= (index | XA_CHUNK_MASK))
@@ -754,7 +759,7 @@ void *xas_store(struct xa_state *xas, void *entry)
754 bool value = xa_is_value(entry); 759 bool value = xa_is_value(entry);
755 760
756 if (entry) 761 if (entry)
757 first = xas_create(xas); 762 first = xas_create(xas, !xa_is_node(entry));
758 else 763 else
759 first = xas_load(xas); 764 first = xas_load(xas);
760 765
@@ -1251,35 +1256,6 @@ void *xas_find_conflict(struct xa_state *xas)
1251EXPORT_SYMBOL_GPL(xas_find_conflict); 1256EXPORT_SYMBOL_GPL(xas_find_conflict);
1252 1257
1253/** 1258/**
1254 * xa_init_flags() - Initialise an empty XArray with flags.
1255 * @xa: XArray.
1256 * @flags: XA_FLAG values.
1257 *
1258 * If you need to initialise an XArray with special flags (eg you need
1259 * to take the lock from interrupt context), use this function instead
1260 * of xa_init().
1261 *
1262 * Context: Any context.
1263 */
1264void xa_init_flags(struct xarray *xa, gfp_t flags)
1265{
1266 unsigned int lock_type;
1267 static struct lock_class_key xa_lock_irq;
1268 static struct lock_class_key xa_lock_bh;
1269
1270 spin_lock_init(&xa->xa_lock);
1271 xa->xa_flags = flags;
1272 xa->xa_head = NULL;
1273
1274 lock_type = xa_lock_type(xa);
1275 if (lock_type == XA_LOCK_IRQ)
1276 lockdep_set_class(&xa->xa_lock, &xa_lock_irq);
1277 else if (lock_type == XA_LOCK_BH)
1278 lockdep_set_class(&xa->xa_lock, &xa_lock_bh);
1279}
1280EXPORT_SYMBOL(xa_init_flags);
1281
1282/**
1283 * xa_load() - Load an entry from an XArray. 1259 * xa_load() - Load an entry from an XArray.
1284 * @xa: XArray. 1260 * @xa: XArray.
1285 * @index: index into array. 1261 * @index: index into array.
@@ -1308,7 +1284,6 @@ static void *xas_result(struct xa_state *xas, void *curr)
1308{ 1284{
1309 if (xa_is_zero(curr)) 1285 if (xa_is_zero(curr))
1310 return NULL; 1286 return NULL;
1311 XA_NODE_BUG_ON(xas->xa_node, xa_is_internal(curr));
1312 if (xas_error(xas)) 1287 if (xas_error(xas))
1313 curr = xas->xa_node; 1288 curr = xas->xa_node;
1314 return curr; 1289 return curr;
@@ -1378,7 +1353,7 @@ void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp)
1378 XA_STATE(xas, xa, index); 1353 XA_STATE(xas, xa, index);
1379 void *curr; 1354 void *curr;
1380 1355
1381 if (WARN_ON_ONCE(xa_is_internal(entry))) 1356 if (WARN_ON_ONCE(xa_is_advanced(entry)))
1382 return XA_ERROR(-EINVAL); 1357 return XA_ERROR(-EINVAL);
1383 if (xa_track_free(xa) && !entry) 1358 if (xa_track_free(xa) && !entry)
1384 entry = XA_ZERO_ENTRY; 1359 entry = XA_ZERO_ENTRY;
@@ -1444,7 +1419,7 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
1444 XA_STATE(xas, xa, index); 1419 XA_STATE(xas, xa, index);
1445 void *curr; 1420 void *curr;
1446 1421
1447 if (WARN_ON_ONCE(xa_is_internal(entry))) 1422 if (WARN_ON_ONCE(xa_is_advanced(entry)))
1448 return XA_ERROR(-EINVAL); 1423 return XA_ERROR(-EINVAL);
1449 if (xa_track_free(xa) && !entry) 1424 if (xa_track_free(xa) && !entry)
1450 entry = XA_ZERO_ENTRY; 1425 entry = XA_ZERO_ENTRY;
@@ -1465,6 +1440,47 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
1465EXPORT_SYMBOL(__xa_cmpxchg); 1440EXPORT_SYMBOL(__xa_cmpxchg);
1466 1441
1467/** 1442/**
1443 * __xa_insert() - Store this entry in the XArray if no entry is present.
1444 * @xa: XArray.
1445 * @index: Index into array.
1446 * @entry: New entry.
1447 * @gfp: Memory allocation flags.
1448 *
1449 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1450 * if no entry is present. Inserting will fail if a reserved entry is
1451 * present, even though loading from this index will return NULL.
1452 *
1453 * Context: Any context. Expects xa_lock to be held on entry. May
1454 * release and reacquire xa_lock if @gfp flags permit.
1455 * Return: 0 if the store succeeded. -EEXIST if another entry was present.
1456 * -ENOMEM if memory could not be allocated.
1457 */
1458int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp)
1459{
1460 XA_STATE(xas, xa, index);
1461 void *curr;
1462
1463 if (WARN_ON_ONCE(xa_is_advanced(entry)))
1464 return -EINVAL;
1465 if (!entry)
1466 entry = XA_ZERO_ENTRY;
1467
1468 do {
1469 curr = xas_load(&xas);
1470 if (!curr) {
1471 xas_store(&xas, entry);
1472 if (xa_track_free(xa))
1473 xas_clear_mark(&xas, XA_FREE_MARK);
1474 } else {
1475 xas_set_err(&xas, -EEXIST);
1476 }
1477 } while (__xas_nomem(&xas, gfp));
1478
1479 return xas_error(&xas);
1480}
1481EXPORT_SYMBOL(__xa_insert);
1482
1483/**
1468 * __xa_reserve() - Reserve this index in the XArray. 1484 * __xa_reserve() - Reserve this index in the XArray.
1469 * @xa: XArray. 1485 * @xa: XArray.
1470 * @index: Index into array. 1486 * @index: Index into array.
@@ -1567,7 +1583,7 @@ void *xa_store_range(struct xarray *xa, unsigned long first,
1567 if (last + 1) 1583 if (last + 1)
1568 order = __ffs(last + 1); 1584 order = __ffs(last + 1);
1569 xas_set_order(&xas, last, order); 1585 xas_set_order(&xas, last, order);
1570 xas_create(&xas); 1586 xas_create(&xas, true);
1571 if (xas_error(&xas)) 1587 if (xas_error(&xas))
1572 goto unlock; 1588 goto unlock;
1573 } 1589 }
@@ -1609,7 +1625,7 @@ int __xa_alloc(struct xarray *xa, u32 *id, u32 max, void *entry, gfp_t gfp)
1609 XA_STATE(xas, xa, 0); 1625 XA_STATE(xas, xa, 0);
1610 int err; 1626 int err;
1611 1627
1612 if (WARN_ON_ONCE(xa_is_internal(entry))) 1628 if (WARN_ON_ONCE(xa_is_advanced(entry)))
1613 return -EINVAL; 1629 return -EINVAL;
1614 if (WARN_ON_ONCE(!xa_track_free(xa))) 1630 if (WARN_ON_ONCE(!xa_track_free(xa)))
1615 return -EINVAL; 1631 return -EINVAL;
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 8a8bb8796c6c..72e6d0c55cfa 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -689,6 +689,7 @@ static int cgwb_bdi_init(struct backing_dev_info *bdi)
689 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC); 689 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC);
690 bdi->cgwb_congested_tree = RB_ROOT; 690 bdi->cgwb_congested_tree = RB_ROOT;
691 mutex_init(&bdi->cgwb_release_mutex); 691 mutex_init(&bdi->cgwb_release_mutex);
692 init_rwsem(&bdi->wb_switch_rwsem);
692 693
693 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL); 694 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL);
694 if (!ret) { 695 if (!ret) {
diff --git a/mm/mincore.c b/mm/mincore.c
index f0f91461a9f4..218099b5ed31 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -42,14 +42,72 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
42 return 0; 42 return 0;
43} 43}
44 44
45static int mincore_unmapped_range(unsigned long addr, unsigned long end, 45/*
46 struct mm_walk *walk) 46 * Later we can get more picky about what "in core" means precisely.
47 * For now, simply check to see if the page is in the page cache,
48 * and is up to date; i.e. that no page-in operation would be required
49 * at this time if an application were to map and access this page.
50 */
51static unsigned char mincore_page(struct address_space *mapping, pgoff_t pgoff)
52{
53 unsigned char present = 0;
54 struct page *page;
55
56 /*
57 * When tmpfs swaps out a page from a file, any process mapping that
58 * file will not get a swp_entry_t in its pte, but rather it is like
59 * any other file mapping (ie. marked !present and faulted in with
60 * tmpfs's .fault). So swapped out tmpfs mappings are tested here.
61 */
62#ifdef CONFIG_SWAP
63 if (shmem_mapping(mapping)) {
64 page = find_get_entry(mapping, pgoff);
65 /*
66 * shmem/tmpfs may return swap: account for swapcache
67 * page too.
68 */
69 if (xa_is_value(page)) {
70 swp_entry_t swp = radix_to_swp_entry(page);
71 page = find_get_page(swap_address_space(swp),
72 swp_offset(swp));
73 }
74 } else
75 page = find_get_page(mapping, pgoff);
76#else
77 page = find_get_page(mapping, pgoff);
78#endif
79 if (page) {
80 present = PageUptodate(page);
81 put_page(page);
82 }
83
84 return present;
85}
86
87static int __mincore_unmapped_range(unsigned long addr, unsigned long end,
88 struct vm_area_struct *vma, unsigned char *vec)
47{ 89{
48 unsigned char *vec = walk->private;
49 unsigned long nr = (end - addr) >> PAGE_SHIFT; 90 unsigned long nr = (end - addr) >> PAGE_SHIFT;
91 int i;
50 92
51 memset(vec, 0, nr); 93 if (vma->vm_file) {
52 walk->private += nr; 94 pgoff_t pgoff;
95
96 pgoff = linear_page_index(vma, addr);
97 for (i = 0; i < nr; i++, pgoff++)
98 vec[i] = mincore_page(vma->vm_file->f_mapping, pgoff);
99 } else {
100 for (i = 0; i < nr; i++)
101 vec[i] = 0;
102 }
103 return nr;
104}
105
106static int mincore_unmapped_range(unsigned long addr, unsigned long end,
107 struct mm_walk *walk)
108{
109 walk->private += __mincore_unmapped_range(addr, end,
110 walk->vma, walk->private);
53 return 0; 111 return 0;
54} 112}
55 113
@@ -69,9 +127,8 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
69 goto out; 127 goto out;
70 } 128 }
71 129
72 /* We'll consider a THP page under construction to be there */
73 if (pmd_trans_unstable(pmd)) { 130 if (pmd_trans_unstable(pmd)) {
74 memset(vec, 1, nr); 131 __mincore_unmapped_range(addr, end, vma, vec);
75 goto out; 132 goto out;
76 } 133 }
77 134
@@ -80,17 +137,28 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
80 pte_t pte = *ptep; 137 pte_t pte = *ptep;
81 138
82 if (pte_none(pte)) 139 if (pte_none(pte))
83 *vec = 0; 140 __mincore_unmapped_range(addr, addr + PAGE_SIZE,
141 vma, vec);
84 else if (pte_present(pte)) 142 else if (pte_present(pte))
85 *vec = 1; 143 *vec = 1;
86 else { /* pte is a swap entry */ 144 else { /* pte is a swap entry */
87 swp_entry_t entry = pte_to_swp_entry(pte); 145 swp_entry_t entry = pte_to_swp_entry(pte);
88 146
89 /* 147 if (non_swap_entry(entry)) {
90 * migration or hwpoison entries are always 148 /*
91 * uptodate 149 * migration or hwpoison entries are always
92 */ 150 * uptodate
93 *vec = !!non_swap_entry(entry); 151 */
152 *vec = 1;
153 } else {
154#ifdef CONFIG_SWAP
155 *vec = mincore_page(swap_address_space(entry),
156 swp_offset(entry));
157#else
158 WARN_ON(1);
159 *vec = 1;
160#endif
161 }
94 } 162 }
95 vec++; 163 vec++;
96 } 164 }
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index 70417e9b932d..314bbc8010fb 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -114,6 +114,7 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
114 dst = (ax25_address *)(bp + 1); 114 dst = (ax25_address *)(bp + 1);
115 src = (ax25_address *)(bp + 8); 115 src = (ax25_address *)(bp + 8);
116 116
117 ax25_route_lock_use();
117 route = ax25_get_route(dst, NULL); 118 route = ax25_get_route(dst, NULL);
118 if (route) { 119 if (route) {
119 digipeat = route->digipeat; 120 digipeat = route->digipeat;
@@ -206,9 +207,8 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
206 ax25_queue_xmit(skb, dev); 207 ax25_queue_xmit(skb, dev);
207 208
208put: 209put:
209 if (route)
210 ax25_put_route(route);
211 210
211 ax25_route_lock_unuse();
212 return NETDEV_TX_OK; 212 return NETDEV_TX_OK;
213} 213}
214 214
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index a0eff323af12..66f74c85cf6b 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -40,7 +40,7 @@
40#include <linux/export.h> 40#include <linux/export.h>
41 41
42static ax25_route *ax25_route_list; 42static ax25_route *ax25_route_list;
43static DEFINE_RWLOCK(ax25_route_lock); 43DEFINE_RWLOCK(ax25_route_lock);
44 44
45void ax25_rt_device_down(struct net_device *dev) 45void ax25_rt_device_down(struct net_device *dev)
46{ 46{
@@ -335,6 +335,7 @@ const struct seq_operations ax25_rt_seqops = {
335 * Find AX.25 route 335 * Find AX.25 route
336 * 336 *
337 * Only routes with a reference count of zero can be destroyed. 337 * Only routes with a reference count of zero can be destroyed.
338 * Must be called with ax25_route_lock read locked.
338 */ 339 */
339ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev) 340ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
340{ 341{
@@ -342,7 +343,6 @@ ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
342 ax25_route *ax25_def_rt = NULL; 343 ax25_route *ax25_def_rt = NULL;
343 ax25_route *ax25_rt; 344 ax25_route *ax25_rt;
344 345
345 read_lock(&ax25_route_lock);
346 /* 346 /*
347 * Bind to the physical interface we heard them on, or the default 347 * Bind to the physical interface we heard them on, or the default
348 * route if none is found; 348 * route if none is found;
@@ -365,11 +365,6 @@ ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
365 if (ax25_spe_rt != NULL) 365 if (ax25_spe_rt != NULL)
366 ax25_rt = ax25_spe_rt; 366 ax25_rt = ax25_spe_rt;
367 367
368 if (ax25_rt != NULL)
369 ax25_hold_route(ax25_rt);
370
371 read_unlock(&ax25_route_lock);
372
373 return ax25_rt; 368 return ax25_rt;
374} 369}
375 370
@@ -400,9 +395,12 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
400 ax25_route *ax25_rt; 395 ax25_route *ax25_rt;
401 int err = 0; 396 int err = 0;
402 397
403 if ((ax25_rt = ax25_get_route(addr, NULL)) == NULL) 398 ax25_route_lock_use();
399 ax25_rt = ax25_get_route(addr, NULL);
400 if (!ax25_rt) {
401 ax25_route_lock_unuse();
404 return -EHOSTUNREACH; 402 return -EHOSTUNREACH;
405 403 }
406 if ((ax25->ax25_dev = ax25_dev_ax25dev(ax25_rt->dev)) == NULL) { 404 if ((ax25->ax25_dev = ax25_dev_ax25dev(ax25_rt->dev)) == NULL) {
407 err = -EHOSTUNREACH; 405 err = -EHOSTUNREACH;
408 goto put; 406 goto put;
@@ -437,8 +435,7 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
437 } 435 }
438 436
439put: 437put:
440 ax25_put_route(ax25_rt); 438 ax25_route_lock_unuse();
441
442 return err; 439 return err;
443} 440}
444 441
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 0af8f0db892a..79bb8afa9c0c 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -67,6 +67,9 @@
67 */ 67 */
68#define MAX_NFRAMES 256 68#define MAX_NFRAMES 256
69 69
70/* limit timers to 400 days for sending/timeouts */
71#define BCM_TIMER_SEC_MAX (400 * 24 * 60 * 60)
72
70/* use of last_frames[index].flags */ 73/* use of last_frames[index].flags */
71#define RX_RECV 0x40 /* received data for this element */ 74#define RX_RECV 0x40 /* received data for this element */
72#define RX_THR 0x80 /* element not been sent due to throttle feature */ 75#define RX_THR 0x80 /* element not been sent due to throttle feature */
@@ -140,6 +143,22 @@ static inline ktime_t bcm_timeval_to_ktime(struct bcm_timeval tv)
140 return ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC); 143 return ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC);
141} 144}
142 145
146/* check limitations for timeval provided by user */
147static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head)
148{
149 if ((msg_head->ival1.tv_sec < 0) ||
150 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) ||
151 (msg_head->ival1.tv_usec < 0) ||
152 (msg_head->ival1.tv_usec >= USEC_PER_SEC) ||
153 (msg_head->ival2.tv_sec < 0) ||
154 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) ||
155 (msg_head->ival2.tv_usec < 0) ||
156 (msg_head->ival2.tv_usec >= USEC_PER_SEC))
157 return true;
158
159 return false;
160}
161
143#define CFSIZ(flags) ((flags & CAN_FD_FRAME) ? CANFD_MTU : CAN_MTU) 162#define CFSIZ(flags) ((flags & CAN_FD_FRAME) ? CANFD_MTU : CAN_MTU)
144#define OPSIZ sizeof(struct bcm_op) 163#define OPSIZ sizeof(struct bcm_op)
145#define MHSIZ sizeof(struct bcm_msg_head) 164#define MHSIZ sizeof(struct bcm_msg_head)
@@ -873,6 +892,10 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
873 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) 892 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES)
874 return -EINVAL; 893 return -EINVAL;
875 894
895 /* check timeval limitations */
896 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
897 return -EINVAL;
898
876 /* check the given can_id */ 899 /* check the given can_id */
877 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); 900 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex);
878 if (op) { 901 if (op) {
@@ -1053,6 +1076,10 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1053 (!(msg_head->can_id & CAN_RTR_FLAG)))) 1076 (!(msg_head->can_id & CAN_RTR_FLAG))))
1054 return -EINVAL; 1077 return -EINVAL;
1055 1078
1079 /* check timeval limitations */
1080 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
1081 return -EINVAL;
1082
1056 /* check the given can_id */ 1083 /* check the given can_id */
1057 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); 1084 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex);
1058 if (op) { 1085 if (op) {
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d5718284db57..3661cdd927f1 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -3206,9 +3206,10 @@ void ceph_con_keepalive(struct ceph_connection *con)
3206 dout("con_keepalive %p\n", con); 3206 dout("con_keepalive %p\n", con);
3207 mutex_lock(&con->mutex); 3207 mutex_lock(&con->mutex);
3208 clear_standby(con); 3208 clear_standby(con);
3209 con_flag_set(con, CON_FLAG_KEEPALIVE_PENDING);
3209 mutex_unlock(&con->mutex); 3210 mutex_unlock(&con->mutex);
3210 if (con_flag_test_and_set(con, CON_FLAG_KEEPALIVE_PENDING) == 0 && 3211
3211 con_flag_test_and_set(con, CON_FLAG_WRITE_PENDING) == 0) 3212 if (con_flag_test_and_set(con, CON_FLAG_WRITE_PENDING) == 0)
3212 queue_con(con); 3213 queue_con(con);
3213} 3214}
3214EXPORT_SYMBOL(ceph_con_keepalive); 3215EXPORT_SYMBOL(ceph_con_keepalive);
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index a4bf22ee3aed..7c4a41dc04bb 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -25,6 +25,7 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <net/protocol.h> 26#include <net/protocol.h>
27#include <net/gre.h> 27#include <net/gre.h>
28#include <net/erspan.h>
28 29
29#include <net/icmp.h> 30#include <net/icmp.h>
30#include <net/route.h> 31#include <net/route.h>
@@ -119,6 +120,22 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
119 hdr_len += 4; 120 hdr_len += 4;
120 } 121 }
121 tpi->hdr_len = hdr_len; 122 tpi->hdr_len = hdr_len;
123
124 /* ERSPAN ver 1 and 2 protocol sets GRE key field
125 * to 0 and sets the configured key in the
126 * inner erspan header field
127 */
128 if (greh->protocol == htons(ETH_P_ERSPAN) ||
129 greh->protocol == htons(ETH_P_ERSPAN2)) {
130 struct erspan_base_hdr *ershdr;
131
132 if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
133 return -EINVAL;
134
135 ershdr = (struct erspan_base_hdr *)options;
136 tpi->key = cpu_to_be32(get_session_id(ershdr));
137 }
138
122 return hdr_len; 139 return hdr_len;
123} 140}
124EXPORT_SYMBOL(gre_parse_header); 141EXPORT_SYMBOL(gre_parse_header);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index cb1af42e374b..d1cef66820d3 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -268,20 +268,11 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
268 int len; 268 int len;
269 269
270 itn = net_generic(net, erspan_net_id); 270 itn = net_generic(net, erspan_net_id);
271 len = gre_hdr_len + sizeof(*ershdr);
272
273 /* Check based hdr len */
274 if (unlikely(!pskb_may_pull(skb, len)))
275 return PACKET_REJECT;
276 271
277 iph = ip_hdr(skb); 272 iph = ip_hdr(skb);
278 ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len); 273 ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
279 ver = ershdr->ver; 274 ver = ershdr->ver;
280 275
281 /* The original GRE header does not have key field,
282 * Use ERSPAN 10-bit session ID as key.
283 */
284 tpi->key = cpu_to_be32(get_session_id(ershdr));
285 tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, 276 tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
286 tpi->flags | TUNNEL_KEY, 277 tpi->flags | TUNNEL_KEY,
287 iph->saddr, iph->daddr, tpi->key); 278 iph->saddr, iph->daddr, tpi->key);
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 3a15ee1a775e..893f013d5369 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -671,13 +671,19 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
671 dst = tnl_params->daddr; 671 dst = tnl_params->daddr;
672 if (dst == 0) { 672 if (dst == 0) {
673 /* NBMA tunnel */ 673 /* NBMA tunnel */
674 struct ip_tunnel_info *tun_info;
674 675
675 if (!skb_dst(skb)) { 676 if (!skb_dst(skb)) {
676 dev->stats.tx_fifo_errors++; 677 dev->stats.tx_fifo_errors++;
677 goto tx_error; 678 goto tx_error;
678 } 679 }
679 680
680 if (skb->protocol == htons(ETH_P_IP)) { 681 tun_info = skb_tunnel_info(skb);
682 if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) &&
683 ip_tunnel_info_af(tun_info) == AF_INET &&
684 tun_info->key.u.ipv4.dst)
685 dst = tun_info->key.u.ipv4.dst;
686 else if (skb->protocol == htons(ETH_P_IP)) {
681 rt = skb_rtable(skb); 687 rt = skb_rtable(skb);
682 dst = rt_nexthop(rt, inner_iph->daddr); 688 dst = rt_nexthop(rt, inner_iph->daddr);
683 } 689 }
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 48cd36311901..dcb1d434f7da 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3530,8 +3530,8 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
3530 3530
3531 if (!addrconf_link_ready(dev)) { 3531 if (!addrconf_link_ready(dev)) {
3532 /* device is not ready yet. */ 3532 /* device is not ready yet. */
3533 pr_info("ADDRCONF(NETDEV_UP): %s: link is not ready\n", 3533 pr_debug("ADDRCONF(NETDEV_UP): %s: link is not ready\n",
3534 dev->name); 3534 dev->name);
3535 break; 3535 break;
3536 } 3536 }
3537 3537
@@ -5155,6 +5155,8 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
5155 if (idev) { 5155 if (idev) {
5156 err = in6_dump_addrs(idev, skb, cb, s_ip_idx, 5156 err = in6_dump_addrs(idev, skb, cb, s_ip_idx,
5157 &fillargs); 5157 &fillargs);
5158 if (err > 0)
5159 err = 0;
5158 } 5160 }
5159 goto put_tgt_net; 5161 goto put_tgt_net;
5160 } 5162 }
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c465d8a102f2..e081e69d534e 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -534,13 +534,9 @@ static int ip6erspan_rcv(struct sk_buff *skb,
534 struct ip6_tnl *tunnel; 534 struct ip6_tnl *tunnel;
535 u8 ver; 535 u8 ver;
536 536
537 if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
538 return PACKET_REJECT;
539
540 ipv6h = ipv6_hdr(skb); 537 ipv6h = ipv6_hdr(skb);
541 ershdr = (struct erspan_base_hdr *)skb->data; 538 ershdr = (struct erspan_base_hdr *)skb->data;
542 ver = ershdr->ver; 539 ver = ershdr->ver;
543 tpi->key = cpu_to_be32(get_session_id(ershdr));
544 540
545 tunnel = ip6gre_tunnel_lookup(skb->dev, 541 tunnel = ip6gre_tunnel_lookup(skb->dev,
546 &ipv6h->saddr, &ipv6h->daddr, tpi->key, 542 &ipv6h->saddr, &ipv6h->daddr, tpi->key,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index de65fe3ed9cc..2493c74c2d37 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1490,6 +1490,10 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1490 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 1490 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1491 sta->sta.tdls = true; 1491 sta->sta.tdls = true;
1492 1492
1493 if (sta->sta.tdls && sdata->vif.type == NL80211_IFTYPE_STATION &&
1494 !sdata->u.mgd.associated)
1495 return -EINVAL;
1496
1493 err = sta_apply_parameters(local, sta, params); 1497 err = sta_apply_parameters(local, sta, params);
1494 if (err) { 1498 if (err) {
1495 sta_info_free(local, sta); 1499 sta_info_free(local, sta);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 45aad3d3108c..bb4d71efb6fb 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -231,7 +231,7 @@ static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata,
231 struct ieee80211_hdr_3addr hdr; 231 struct ieee80211_hdr_3addr hdr;
232 u8 category; 232 u8 category;
233 u8 action_code; 233 u8 action_code;
234 } __packed action; 234 } __packed __aligned(2) action;
235 235
236 if (!sdata) 236 if (!sdata)
237 return; 237 return;
@@ -2723,7 +2723,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
2723 skb_set_queue_mapping(skb, q); 2723 skb_set_queue_mapping(skb, q);
2724 2724
2725 if (!--mesh_hdr->ttl) { 2725 if (!--mesh_hdr->ttl) {
2726 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl); 2726 if (!is_multicast_ether_addr(hdr->addr1))
2727 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh,
2728 dropped_frames_ttl);
2727 goto out; 2729 goto out;
2728 } 2730 }
2729 2731
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index ed8e006dae85..6200cd2b4b99 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -280,7 +280,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
280 280
281 if (saddr) { 281 if (saddr) {
282 fl6->saddr = saddr->v6.sin6_addr; 282 fl6->saddr = saddr->v6.sin6_addr;
283 fl6->fl6_sport = saddr->v6.sin6_port; 283 if (!fl6->fl6_sport)
284 fl6->fl6_sport = saddr->v6.sin6_port;
284 285
285 pr_debug("src=%pI6 - ", &fl6->saddr); 286 pr_debug("src=%pI6 - ", &fl6->saddr);
286 } 287 }
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 4e0eeb113ef5..6abc8b274270 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -440,7 +440,8 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
440 } 440 }
441 if (saddr) { 441 if (saddr) {
442 fl4->saddr = saddr->v4.sin_addr.s_addr; 442 fl4->saddr = saddr->v4.sin_addr.s_addr;
443 fl4->fl4_sport = saddr->v4.sin_port; 443 if (!fl4->fl4_sport)
444 fl4->fl4_sport = saddr->v4.sin_port;
444 } 445 }
445 446
446 pr_debug("%s: dst:%pI4, src:%pI4 - ", __func__, &fl4->daddr, 447 pr_debug("%s: dst:%pI4, src:%pI4 - ", __func__, &fl4->daddr,
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index f4ac6c592e13..d05c57664e36 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -495,7 +495,10 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
495 * 495 *
496 * [INIT ACK back to where the INIT came from.] 496 * [INIT ACK back to where the INIT came from.]
497 */ 497 */
498 retval->transport = chunk->transport; 498 if (chunk->transport)
499 retval->transport =
500 sctp_assoc_lookup_paddr(asoc,
501 &chunk->transport->ipaddr);
499 502
500 retval->subh.init_hdr = 503 retval->subh.init_hdr =
501 sctp_addto_chunk(retval, sizeof(initack), &initack); 504 sctp_addto_chunk(retval, sizeof(initack), &initack);
@@ -642,8 +645,10 @@ struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
642 * 645 *
643 * [COOKIE ACK back to where the COOKIE ECHO came from.] 646 * [COOKIE ACK back to where the COOKIE ECHO came from.]
644 */ 647 */
645 if (retval && chunk) 648 if (retval && chunk && chunk->transport)
646 retval->transport = chunk->transport; 649 retval->transport =
650 sctp_assoc_lookup_paddr(asoc,
651 &chunk->transport->ipaddr);
647 652
648 return retval; 653 return retval;
649} 654}
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 3892e7630f3a..80e0ae5534ec 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -585,9 +585,9 @@ struct sctp_chunk *sctp_process_strreset_outreq(
585 struct sctp_strreset_outreq *outreq = param.v; 585 struct sctp_strreset_outreq *outreq = param.v;
586 struct sctp_stream *stream = &asoc->stream; 586 struct sctp_stream *stream = &asoc->stream;
587 __u32 result = SCTP_STRRESET_DENIED; 587 __u32 result = SCTP_STRRESET_DENIED;
588 __u16 i, nums, flags = 0;
589 __be16 *str_p = NULL; 588 __be16 *str_p = NULL;
590 __u32 request_seq; 589 __u32 request_seq;
590 __u16 i, nums;
591 591
592 request_seq = ntohl(outreq->request_seq); 592 request_seq = ntohl(outreq->request_seq);
593 593
@@ -615,6 +615,15 @@ struct sctp_chunk *sctp_process_strreset_outreq(
615 if (!(asoc->strreset_enable & SCTP_ENABLE_RESET_STREAM_REQ)) 615 if (!(asoc->strreset_enable & SCTP_ENABLE_RESET_STREAM_REQ))
616 goto out; 616 goto out;
617 617
618 nums = (ntohs(param.p->length) - sizeof(*outreq)) / sizeof(__u16);
619 str_p = outreq->list_of_streams;
620 for (i = 0; i < nums; i++) {
621 if (ntohs(str_p[i]) >= stream->incnt) {
622 result = SCTP_STRRESET_ERR_WRONG_SSN;
623 goto out;
624 }
625 }
626
618 if (asoc->strreset_chunk) { 627 if (asoc->strreset_chunk) {
619 if (!sctp_chunk_lookup_strreset_param( 628 if (!sctp_chunk_lookup_strreset_param(
620 asoc, outreq->response_seq, 629 asoc, outreq->response_seq,
@@ -637,32 +646,19 @@ struct sctp_chunk *sctp_process_strreset_outreq(
637 sctp_chunk_put(asoc->strreset_chunk); 646 sctp_chunk_put(asoc->strreset_chunk);
638 asoc->strreset_chunk = NULL; 647 asoc->strreset_chunk = NULL;
639 } 648 }
640
641 flags = SCTP_STREAM_RESET_INCOMING_SSN;
642 } 649 }
643 650
644 nums = (ntohs(param.p->length) - sizeof(*outreq)) / sizeof(__u16); 651 if (nums)
645 if (nums) {
646 str_p = outreq->list_of_streams;
647 for (i = 0; i < nums; i++) {
648 if (ntohs(str_p[i]) >= stream->incnt) {
649 result = SCTP_STRRESET_ERR_WRONG_SSN;
650 goto out;
651 }
652 }
653
654 for (i = 0; i < nums; i++) 652 for (i = 0; i < nums; i++)
655 SCTP_SI(stream, ntohs(str_p[i]))->mid = 0; 653 SCTP_SI(stream, ntohs(str_p[i]))->mid = 0;
656 } else { 654 else
657 for (i = 0; i < stream->incnt; i++) 655 for (i = 0; i < stream->incnt; i++)
658 SCTP_SI(stream, i)->mid = 0; 656 SCTP_SI(stream, i)->mid = 0;
659 }
660 657
661 result = SCTP_STRRESET_PERFORMED; 658 result = SCTP_STRRESET_PERFORMED;
662 659
663 *evp = sctp_ulpevent_make_stream_reset_event(asoc, 660 *evp = sctp_ulpevent_make_stream_reset_event(asoc,
664 flags | SCTP_STREAM_RESET_OUTGOING_SSN, nums, str_p, 661 SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC);
665 GFP_ATOMIC);
666 662
667out: 663out:
668 sctp_update_strreset_result(asoc, result); 664 sctp_update_strreset_result(asoc, result);
@@ -738,9 +734,6 @@ struct sctp_chunk *sctp_process_strreset_inreq(
738 734
739 result = SCTP_STRRESET_PERFORMED; 735 result = SCTP_STRRESET_PERFORMED;
740 736
741 *evp = sctp_ulpevent_make_stream_reset_event(asoc,
742 SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC);
743
744out: 737out:
745 sctp_update_strreset_result(asoc, result); 738 sctp_update_strreset_result(asoc, result);
746err: 739err:
@@ -873,6 +866,14 @@ struct sctp_chunk *sctp_process_strreset_addstrm_out(
873 if (!(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) 866 if (!(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ))
874 goto out; 867 goto out;
875 868
869 in = ntohs(addstrm->number_of_streams);
870 incnt = stream->incnt + in;
871 if (!in || incnt > SCTP_MAX_STREAM)
872 goto out;
873
874 if (sctp_stream_alloc_in(stream, incnt, GFP_ATOMIC))
875 goto out;
876
876 if (asoc->strreset_chunk) { 877 if (asoc->strreset_chunk) {
877 if (!sctp_chunk_lookup_strreset_param( 878 if (!sctp_chunk_lookup_strreset_param(
878 asoc, 0, SCTP_PARAM_RESET_ADD_IN_STREAMS)) { 879 asoc, 0, SCTP_PARAM_RESET_ADD_IN_STREAMS)) {
@@ -896,14 +897,6 @@ struct sctp_chunk *sctp_process_strreset_addstrm_out(
896 } 897 }
897 } 898 }
898 899
899 in = ntohs(addstrm->number_of_streams);
900 incnt = stream->incnt + in;
901 if (!in || incnt > SCTP_MAX_STREAM)
902 goto out;
903
904 if (sctp_stream_alloc_in(stream, incnt, GFP_ATOMIC))
905 goto out;
906
907 stream->incnt = incnt; 900 stream->incnt = incnt;
908 901
909 result = SCTP_STRRESET_PERFORMED; 902 result = SCTP_STRRESET_PERFORMED;
@@ -973,9 +966,6 @@ struct sctp_chunk *sctp_process_strreset_addstrm_in(
973 966
974 result = SCTP_STRRESET_PERFORMED; 967 result = SCTP_STRRESET_PERFORMED;
975 968
976 *evp = sctp_ulpevent_make_stream_change_event(asoc,
977 0, 0, ntohs(addstrm->number_of_streams), GFP_ATOMIC);
978
979out: 969out:
980 sctp_update_strreset_result(asoc, result); 970 sctp_update_strreset_result(asoc, result);
981err: 971err:
@@ -1036,10 +1026,10 @@ struct sctp_chunk *sctp_process_strreset_resp(
1036 sout->mid_uo = 0; 1026 sout->mid_uo = 0;
1037 } 1027 }
1038 } 1028 }
1039
1040 flags = SCTP_STREAM_RESET_OUTGOING_SSN;
1041 } 1029 }
1042 1030
1031 flags |= SCTP_STREAM_RESET_OUTGOING_SSN;
1032
1043 for (i = 0; i < stream->outcnt; i++) 1033 for (i = 0; i < stream->outcnt; i++)
1044 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN; 1034 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
1045 1035
@@ -1058,6 +1048,8 @@ struct sctp_chunk *sctp_process_strreset_resp(
1058 nums = (ntohs(inreq->param_hdr.length) - sizeof(*inreq)) / 1048 nums = (ntohs(inreq->param_hdr.length) - sizeof(*inreq)) /
1059 sizeof(__u16); 1049 sizeof(__u16);
1060 1050
1051 flags |= SCTP_STREAM_RESET_INCOMING_SSN;
1052
1061 *evp = sctp_ulpevent_make_stream_reset_event(asoc, flags, 1053 *evp = sctp_ulpevent_make_stream_reset_event(asoc, flags,
1062 nums, str_p, GFP_ATOMIC); 1054 nums, str_p, GFP_ATOMIC);
1063 } else if (req->type == SCTP_PARAM_RESET_TSN_REQUEST) { 1055 } else if (req->type == SCTP_PARAM_RESET_TSN_REQUEST) {
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5e49492d5911..74150ad95823 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -555,7 +555,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
555 }, 555 },
556 [NL80211_ATTR_TIMEOUT] = NLA_POLICY_MIN(NLA_U32, 1), 556 [NL80211_ATTR_TIMEOUT] = NLA_POLICY_MIN(NLA_U32, 1),
557 [NL80211_ATTR_PEER_MEASUREMENTS] = 557 [NL80211_ATTR_PEER_MEASUREMENTS] =
558 NLA_POLICY_NESTED(NL80211_PMSR_FTM_REQ_ATTR_MAX, 558 NLA_POLICY_NESTED(NL80211_PMSR_ATTR_MAX,
559 nl80211_pmsr_attr_policy), 559 nl80211_pmsr_attr_policy),
560}; 560};
561 561
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ecfb1a06dbb2..dd58b9909ac9 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1024,8 +1024,13 @@ static void regdb_fw_cb(const struct firmware *fw, void *context)
1024 } 1024 }
1025 1025
1026 rtnl_lock(); 1026 rtnl_lock();
1027 if (WARN_ON(regdb && !IS_ERR(regdb))) { 1027 if (regdb && !IS_ERR(regdb)) {
1028 /* just restore and free new db */ 1028 /* negative case - a bug
1029 * positive case - can happen due to race in case of multiple cb's in
1030 * queue, due to usage of asynchronous callback
1031 *
1032 * Either case, just restore and free new db.
1033 */
1029 } else if (set_error) { 1034 } else if (set_error) {
1030 regdb = ERR_PTR(set_error); 1035 regdb = ERR_PTR(set_error);
1031 } else if (fw) { 1036 } else if (fw) {
@@ -1255,7 +1260,7 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd)
1255 * definitions (the "2.4 GHz band", the "5 GHz band" and the "60GHz band"), 1260 * definitions (the "2.4 GHz band", the "5 GHz band" and the "60GHz band"),
1256 * however it is safe for now to assume that a frequency rule should not be 1261 * however it is safe for now to assume that a frequency rule should not be
1257 * part of a frequency's band if the start freq or end freq are off by more 1262 * part of a frequency's band if the start freq or end freq are off by more
1258 * than 2 GHz for the 2.4 and 5 GHz bands, and by more than 10 GHz for the 1263 * than 2 GHz for the 2.4 and 5 GHz bands, and by more than 20 GHz for the
1259 * 60 GHz band. 1264 * 60 GHz band.
1260 * This resolution can be lowered and should be considered as we add 1265 * This resolution can be lowered and should be considered as we add
1261 * regulatory rule support for other "bands". 1266 * regulatory rule support for other "bands".
@@ -1270,7 +1275,7 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
1270 * with the Channel starting frequency above 45 GHz. 1275 * with the Channel starting frequency above 45 GHz.
1271 */ 1276 */
1272 u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ? 1277 u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ?
1273 10 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ; 1278 20 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ;
1274 if (abs(freq_khz - freq_range->start_freq_khz) <= limit) 1279 if (abs(freq_khz - freq_range->start_freq_khz) <= limit)
1275 return true; 1280 return true;
1276 if (abs(freq_khz - freq_range->end_freq_khz) <= limit) 1281 if (abs(freq_khz - freq_range->end_freq_khz) <= limit)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index a5b09e75e787..f7d2b373da0a 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -541,7 +541,8 @@ static int snd_compress_check_input(struct snd_compr_params *params)
541{ 541{
542 /* first let's check the buffer parameter's */ 542 /* first let's check the buffer parameter's */
543 if (params->buffer.fragment_size == 0 || 543 if (params->buffer.fragment_size == 0 ||
544 params->buffer.fragments > INT_MAX / params->buffer.fragment_size) 544 params->buffer.fragments > INT_MAX / params->buffer.fragment_size ||
545 params->buffer.fragments == 0)
545 return -EINVAL; 546 return -EINVAL;
546 547
547 /* now codec parameters */ 548 /* now codec parameters */
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 51cc6589443f..152f54137082 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -931,6 +931,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
931 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO), 931 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
932 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO), 932 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO),
933 SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO), 933 SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
934 SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
934 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 935 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
935 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE), 936 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
936 SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE), 937 SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0b3e7a18ca78..b4f472157ebd 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6926,7 +6926,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
6926 {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"}, 6926 {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
6927 {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"}, 6927 {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
6928 {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"}, 6928 {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
6929 {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"}, 6929 {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
6930 {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"}, 6930 {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
6931 {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"}, 6931 {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
6932 {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"}, 6932 {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 022a8912c8a2..3d58338fa3cf 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -611,14 +611,16 @@ static int acp3x_audio_probe(struct platform_device *pdev)
611 } 611 }
612 irqflags = *((unsigned int *)(pdev->dev.platform_data)); 612 irqflags = *((unsigned int *)(pdev->dev.platform_data));
613 613
614 adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data),
615 GFP_KERNEL);
616 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 614 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
617 if (!res) { 615 if (!res) {
618 dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n"); 616 dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n");
619 return -ENODEV; 617 return -ENODEV;
620 } 618 }
621 619
620 adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
621 if (!adata)
622 return -ENOMEM;
623
622 adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, 624 adata->acp3x_base = devm_ioremap(&pdev->dev, res->start,
623 resource_size(res)); 625 resource_size(res));
624 626
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 3ab2949c1dfa..b19d7a3e7a2c 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1890,51 +1890,31 @@ static void hdmi_codec_remove(struct snd_soc_component *component)
1890 pm_runtime_disable(&hdev->dev); 1890 pm_runtime_disable(&hdev->dev);
1891} 1891}
1892 1892
1893#ifdef CONFIG_PM 1893#ifdef CONFIG_PM_SLEEP
1894static int hdmi_codec_prepare(struct device *dev) 1894static int hdmi_codec_resume(struct device *dev)
1895{
1896 struct hdac_device *hdev = dev_to_hdac_dev(dev);
1897
1898 pm_runtime_get_sync(&hdev->dev);
1899
1900 /*
1901 * Power down afg.
1902 * codec_read is preferred over codec_write to set the power state.
1903 * This way verb is send to set the power state and response
1904 * is received. So setting power state is ensured without using loop
1905 * to read the state.
1906 */
1907 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
1908 AC_PWRST_D3);
1909
1910 return 0;
1911}
1912
1913static void hdmi_codec_complete(struct device *dev)
1914{ 1895{
1915 struct hdac_device *hdev = dev_to_hdac_dev(dev); 1896 struct hdac_device *hdev = dev_to_hdac_dev(dev);
1916 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1897 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1898 int ret;
1917 1899
1918 /* Power up afg */ 1900 ret = pm_runtime_force_resume(dev);
1919 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, 1901 if (ret < 0)
1920 AC_PWRST_D0); 1902 return ret;
1921
1922 hdac_hdmi_skl_enable_all_pins(hdev);
1923 hdac_hdmi_skl_enable_dp12(hdev);
1924
1925 /* 1903 /*
1926 * As the ELD notify callback request is not entertained while the 1904 * As the ELD notify callback request is not entertained while the
1927 * device is in suspend state. Need to manually check detection of 1905 * device is in suspend state. Need to manually check detection of
1928 * all pins here. pin capablity change is not support, so use the 1906 * all pins here. pin capablity change is not support, so use the
1929 * already set pin caps. 1907 * already set pin caps.
1908 *
1909 * NOTE: this is safe to call even if the codec doesn't actually resume.
1910 * The pin check involves only with DRM audio component hooks, so it
1911 * works even if the HD-audio side is still dreaming peacefully.
1930 */ 1912 */
1931 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); 1913 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false);
1932 1914 return 0;
1933 pm_runtime_put_sync(&hdev->dev);
1934} 1915}
1935#else 1916#else
1936#define hdmi_codec_prepare NULL 1917#define hdmi_codec_resume NULL
1937#define hdmi_codec_complete NULL
1938#endif 1918#endif
1939 1919
1940static const struct snd_soc_component_driver hdmi_hda_codec = { 1920static const struct snd_soc_component_driver hdmi_hda_codec = {
@@ -2135,75 +2115,6 @@ static int hdac_hdmi_dev_remove(struct hdac_device *hdev)
2135} 2115}
2136 2116
2137#ifdef CONFIG_PM 2117#ifdef CONFIG_PM
2138/*
2139 * Power management sequences
2140 * ==========================
2141 *
2142 * The following explains the PM handling of HDAC HDMI with its parent
2143 * device SKL and display power usage
2144 *
2145 * Probe
2146 * -----
2147 * In SKL probe,
2148 * 1. skl_probe_work() powers up the display (refcount++ -> 1)
2149 * 2. enumerates the codecs on the link
2150 * 3. powers down the display (refcount-- -> 0)
2151 *
2152 * In HDAC HDMI probe,
2153 * 1. hdac_hdmi_dev_probe() powers up the display (refcount++ -> 1)
2154 * 2. probe the codec
2155 * 3. put the HDAC HDMI device to runtime suspend
2156 * 4. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2157 *
2158 * Once children are runtime suspended, SKL device also goes to runtime
2159 * suspend
2160 *
2161 * HDMI Playback
2162 * -------------
2163 * Open HDMI device,
2164 * 1. skl_runtime_resume() invoked
2165 * 2. hdac_hdmi_runtime_resume() powers up the display (refcount++ -> 1)
2166 *
2167 * Close HDMI device,
2168 * 1. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2169 * 2. skl_runtime_suspend() invoked
2170 *
2171 * S0/S3 Cycle with playback in progress
2172 * -------------------------------------
2173 * When the device is opened for playback, the device is runtime active
2174 * already and the display refcount is 1 as explained above.
2175 *
2176 * Entering to S3,
2177 * 1. hdmi_codec_prepare() invoke the runtime resume of codec which just
2178 * increments the PM runtime usage count of the codec since the device
2179 * is in use already
2180 * 2. skl_suspend() powers down the display (refcount-- -> 0)
2181 *
2182 * Wakeup from S3,
2183 * 1. skl_resume() powers up the display (refcount++ -> 1)
2184 * 2. hdmi_codec_complete() invokes the runtime suspend of codec which just
2185 * decrements the PM runtime usage count of the codec since the device
2186 * is in use already
2187 *
2188 * Once playback is stopped, the display refcount is set to 0 as explained
2189 * above in the HDMI playback sequence. The PM handlings are designed in
2190 * such way that to balance the refcount of display power when the codec
2191 * device put to S3 while playback is going on.
2192 *
2193 * S0/S3 Cycle without playback in progress
2194 * ----------------------------------------
2195 * Entering to S3,
2196 * 1. hdmi_codec_prepare() invoke the runtime resume of codec
2197 * 2. skl_runtime_resume() invoked
2198 * 3. hdac_hdmi_runtime_resume() powers up the display (refcount++ -> 1)
2199 * 4. skl_suspend() powers down the display (refcount-- -> 0)
2200 *
2201 * Wakeup from S3,
2202 * 1. skl_resume() powers up the display (refcount++ -> 1)
2203 * 2. hdmi_codec_complete() invokes the runtime suspend of codec
2204 * 3. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2205 * 4. skl_runtime_suspend() invoked
2206 */
2207static int hdac_hdmi_runtime_suspend(struct device *dev) 2118static int hdac_hdmi_runtime_suspend(struct device *dev)
2208{ 2119{
2209 struct hdac_device *hdev = dev_to_hdac_dev(dev); 2120 struct hdac_device *hdev = dev_to_hdac_dev(dev);
@@ -2277,8 +2188,7 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
2277 2188
2278static const struct dev_pm_ops hdac_hdmi_pm = { 2189static const struct dev_pm_ops hdac_hdmi_pm = {
2279 SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL) 2190 SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL)
2280 .prepare = hdmi_codec_prepare, 2191 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, hdmi_codec_resume)
2281 .complete = hdmi_codec_complete,
2282}; 2192};
2283 2193
2284static const struct hda_device_id hdmi_list[] = { 2194static const struct hda_device_id hdmi_list[] = {
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 6cb1653be804..4cc24a5d5c31 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1400,24 +1400,20 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
1400 if (ret != 0) { 1400 if (ret != 0) {
1401 dev_err(component->dev, 1401 dev_err(component->dev,
1402 "Failed to set digital mute: %d\n", ret); 1402 "Failed to set digital mute: %d\n", ret);
1403 mutex_unlock(&pcm512x->mutex); 1403 goto unlock;
1404 return ret;
1405 } 1404 }
1406 1405
1407 regmap_read_poll_timeout(pcm512x->regmap, 1406 regmap_read_poll_timeout(pcm512x->regmap,
1408 PCM512x_ANALOG_MUTE_DET, 1407 PCM512x_ANALOG_MUTE_DET,
1409 mute_det, (mute_det & 0x3) == 0, 1408 mute_det, (mute_det & 0x3) == 0,
1410 200, 10000); 1409 200, 10000);
1411
1412 mutex_unlock(&pcm512x->mutex);
1413 } else { 1410 } else {
1414 pcm512x->mute &= ~0x1; 1411 pcm512x->mute &= ~0x1;
1415 ret = pcm512x_update_mute(pcm512x); 1412 ret = pcm512x_update_mute(pcm512x);
1416 if (ret != 0) { 1413 if (ret != 0) {
1417 dev_err(component->dev, 1414 dev_err(component->dev,
1418 "Failed to update digital mute: %d\n", ret); 1415 "Failed to update digital mute: %d\n", ret);
1419 mutex_unlock(&pcm512x->mutex); 1416 goto unlock;
1420 return ret;
1421 } 1417 }
1422 1418
1423 regmap_read_poll_timeout(pcm512x->regmap, 1419 regmap_read_poll_timeout(pcm512x->regmap,
@@ -1428,9 +1424,10 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
1428 200, 10000); 1424 200, 10000);
1429 } 1425 }
1430 1426
1427unlock:
1431 mutex_unlock(&pcm512x->mutex); 1428 mutex_unlock(&pcm512x->mutex);
1432 1429
1433 return 0; 1430 return ret;
1434} 1431}
1435 1432
1436static const struct snd_soc_dai_ops pcm512x_dai_ops = { 1433static const struct snd_soc_dai_ops pcm512x_dai_ops = {
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c
index 0ef966d56bac..e2855ab9a2c6 100644
--- a/sound/soc/codecs/rt274.c
+++ b/sound/soc/codecs/rt274.c
@@ -1128,8 +1128,11 @@ static int rt274_i2c_probe(struct i2c_client *i2c,
1128 return ret; 1128 return ret;
1129 } 1129 }
1130 1130
1131 regmap_read(rt274->regmap, 1131 ret = regmap_read(rt274->regmap,
1132 RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val); 1132 RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
1133 if (ret)
1134 return ret;
1135
1133 if (val != RT274_VENDOR_ID) { 1136 if (val != RT274_VENDOR_ID) {
1134 dev_err(&i2c->dev, 1137 dev_err(&i2c->dev,
1135 "Device with ID register %#x is not rt274\n", val); 1138 "Device with ID register %#x is not rt274\n", val);
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 4d46f4567c3a..bec2eefa8b0f 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -280,6 +280,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
280 280
281 rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), 281 rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
282 GFP_KERNEL); 282 GFP_KERNEL);
283 if (!rt5514_dsp)
284 return -ENOMEM;
283 285
284 rt5514_dsp->dev = &rt5514_spi->dev; 286 rt5514_dsp->dev = &rt5514_spi->dev;
285 mutex_init(&rt5514_dsp->dma_lock); 287 mutex_init(&rt5514_dsp->dma_lock);
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 34cfaf8f6f34..89c43b26c379 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2512,6 +2512,7 @@ static void rt5682_calibrate(struct rt5682_priv *rt5682)
2512 regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000); 2512 regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000);
2513 regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000); 2513 regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000);
2514 regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005); 2514 regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
2515 regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
2515 2516
2516 mutex_unlock(&rt5682->calibrate_mutex); 2517 mutex_unlock(&rt5682->calibrate_mutex);
2517 2518
diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h
index d82a8301fd74..96944cff0ed7 100644
--- a/sound/soc/codecs/rt5682.h
+++ b/sound/soc/codecs/rt5682.h
@@ -849,18 +849,18 @@
849#define RT5682_SCLK_SRC_PLL2 (0x2 << 13) 849#define RT5682_SCLK_SRC_PLL2 (0x2 << 13)
850#define RT5682_SCLK_SRC_SDW (0x3 << 13) 850#define RT5682_SCLK_SRC_SDW (0x3 << 13)
851#define RT5682_SCLK_SRC_RCCLK (0x4 << 13) 851#define RT5682_SCLK_SRC_RCCLK (0x4 << 13)
852#define RT5682_PLL1_SRC_MASK (0x3 << 10) 852#define RT5682_PLL2_SRC_MASK (0x3 << 10)
853#define RT5682_PLL1_SRC_SFT 10 853#define RT5682_PLL2_SRC_SFT 10
854#define RT5682_PLL1_SRC_MCLK (0x0 << 10) 854#define RT5682_PLL2_SRC_MCLK (0x0 << 10)
855#define RT5682_PLL1_SRC_BCLK1 (0x1 << 10) 855#define RT5682_PLL2_SRC_BCLK1 (0x1 << 10)
856#define RT5682_PLL1_SRC_SDW (0x2 << 10) 856#define RT5682_PLL2_SRC_SDW (0x2 << 10)
857#define RT5682_PLL1_SRC_RC (0x3 << 10) 857#define RT5682_PLL2_SRC_RC (0x3 << 10)
858#define RT5682_PLL2_SRC_MASK (0x3 << 8) 858#define RT5682_PLL1_SRC_MASK (0x3 << 8)
859#define RT5682_PLL2_SRC_SFT 8 859#define RT5682_PLL1_SRC_SFT 8
860#define RT5682_PLL2_SRC_MCLK (0x0 << 8) 860#define RT5682_PLL1_SRC_MCLK (0x0 << 8)
861#define RT5682_PLL2_SRC_BCLK1 (0x1 << 8) 861#define RT5682_PLL1_SRC_BCLK1 (0x1 << 8)
862#define RT5682_PLL2_SRC_SDW (0x2 << 8) 862#define RT5682_PLL1_SRC_SDW (0x2 << 8)
863#define RT5682_PLL2_SRC_RC (0x3 << 8) 863#define RT5682_PLL1_SRC_RC (0x3 << 8)
864 864
865 865
866 866
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index e2b5a11b16d1..f03195d2ab2e 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
822 case SND_SOC_BIAS_PREPARE: 822 case SND_SOC_BIAS_PREPARE:
823 break; 823 break;
824 case SND_SOC_BIAS_STANDBY: 824 case SND_SOC_BIAS_STANDBY:
825 /* Initial cold start */
826 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
827 break;
828
825 /* Switch off BCLK_N Divider */ 829 /* Switch off BCLK_N Divider */
826 snd_soc_component_update_bits(component, AIC32X4_BCLKN, 830 snd_soc_component_update_bits(component, AIC32X4_BCLKN,
827 AIC32X4_BCLKEN, 0); 831 AIC32X4_BCLKEN, 0);
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index 392d5eef356d..99e07b01a2ce 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -86,49 +86,49 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
86 if (!buf) 86 if (!buf)
87 return -ENOMEM; 87 return -ENOMEM;
88 88
89 ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", 89 ret = scnprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
90 pdcr, ptcr); 90 pdcr, ptcr);
91 91
92 if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR) 92 if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR)
93 ret += snprintf(buf + ret, PAGE_SIZE - ret, 93 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
94 "TxFS output from %s, ", 94 "TxFS output from %s, ",
95 audmux_port_string((ptcr >> 27) & 0x7)); 95 audmux_port_string((ptcr >> 27) & 0x7));
96 else 96 else
97 ret += snprintf(buf + ret, PAGE_SIZE - ret, 97 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
98 "TxFS input, "); 98 "TxFS input, ");
99 99
100 if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR) 100 if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR)
101 ret += snprintf(buf + ret, PAGE_SIZE - ret, 101 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
102 "TxClk output from %s", 102 "TxClk output from %s",
103 audmux_port_string((ptcr >> 22) & 0x7)); 103 audmux_port_string((ptcr >> 22) & 0x7));
104 else 104 else
105 ret += snprintf(buf + ret, PAGE_SIZE - ret, 105 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
106 "TxClk input"); 106 "TxClk input");
107 107
108 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n"); 108 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
109 109
110 if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) { 110 if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) {
111 ret += snprintf(buf + ret, PAGE_SIZE - ret, 111 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
112 "Port is symmetric"); 112 "Port is symmetric");
113 } else { 113 } else {
114 if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR) 114 if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR)
115 ret += snprintf(buf + ret, PAGE_SIZE - ret, 115 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
116 "RxFS output from %s, ", 116 "RxFS output from %s, ",
117 audmux_port_string((ptcr >> 17) & 0x7)); 117 audmux_port_string((ptcr >> 17) & 0x7));
118 else 118 else
119 ret += snprintf(buf + ret, PAGE_SIZE - ret, 119 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
120 "RxFS input, "); 120 "RxFS input, ");
121 121
122 if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR) 122 if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR)
123 ret += snprintf(buf + ret, PAGE_SIZE - ret, 123 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
124 "RxClk output from %s", 124 "RxClk output from %s",
125 audmux_port_string((ptcr >> 12) & 0x7)); 125 audmux_port_string((ptcr >> 12) & 0x7));
126 else 126 else
127 ret += snprintf(buf + ret, PAGE_SIZE - ret, 127 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
128 "RxClk input"); 128 "RxClk input");
129 } 129 }
130 130
131 ret += snprintf(buf + ret, PAGE_SIZE - ret, 131 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
132 "\nData received from %s\n", 132 "\nData received from %s\n",
133 audmux_port_string((pdcr >> 13) & 0x7)); 133 audmux_port_string((pdcr >> 13) & 0x7));
134 134
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index 99a62ba409df..bd9fd2035c55 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -91,7 +91,7 @@ config SND_SST_ATOM_HIFI2_PLATFORM_PCI
91config SND_SST_ATOM_HIFI2_PLATFORM_ACPI 91config SND_SST_ATOM_HIFI2_PLATFORM_ACPI
92 tristate "ACPI HiFi2 (Baytrail, Cherrytrail) Platforms" 92 tristate "ACPI HiFi2 (Baytrail, Cherrytrail) Platforms"
93 default ACPI 93 default ACPI
94 depends on X86 && ACPI 94 depends on X86 && ACPI && PCI
95 select SND_SST_IPC_ACPI 95 select SND_SST_IPC_ACPI
96 select SND_SST_ATOM_HIFI2_PLATFORM 96 select SND_SST_ATOM_HIFI2_PLATFORM
97 select SND_SOC_ACPI_INTEL_MATCH 97 select SND_SOC_ACPI_INTEL_MATCH
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index afc559866095..91a2436ce952 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream,
399 struct snd_pcm_hw_params *params, 399 struct snd_pcm_hw_params *params,
400 struct snd_soc_dai *dai) 400 struct snd_soc_dai *dai)
401{ 401{
402 snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 402 int ret;
403
404 ret =
405 snd_pcm_lib_malloc_pages(substream,
406 params_buffer_bytes(params));
407 if (ret)
408 return ret;
403 memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); 409 memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
404 return 0; 410 return 0;
405} 411}
diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c
index 68e6543e6cb0..99f2a0156ae8 100644
--- a/sound/soc/intel/boards/broadwell.c
+++ b/sound/soc/intel/boards/broadwell.c
@@ -192,7 +192,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
192 .stream_name = "Loopback", 192 .stream_name = "Loopback",
193 .cpu_dai_name = "Loopback Pin", 193 .cpu_dai_name = "Loopback Pin",
194 .platform_name = "haswell-pcm-audio", 194 .platform_name = "haswell-pcm-audio",
195 .dynamic = 0, 195 .dynamic = 1,
196 .codec_name = "snd-soc-dummy", 196 .codec_name = "snd-soc-dummy",
197 .codec_dai_name = "snd-soc-dummy-dai", 197 .codec_dai_name = "snd-soc-dummy-dai",
198 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 198 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c
index c74c4f17316f..8f83b182c4f9 100644
--- a/sound/soc/intel/boards/glk_rt5682_max98357a.c
+++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c
@@ -55,39 +55,6 @@ enum {
55 GLK_DPCM_AUDIO_HDMI3_PB, 55 GLK_DPCM_AUDIO_HDMI3_PB,
56}; 56};
57 57
58static int platform_clock_control(struct snd_soc_dapm_widget *w,
59 struct snd_kcontrol *k, int event)
60{
61 struct snd_soc_dapm_context *dapm = w->dapm;
62 struct snd_soc_card *card = dapm->card;
63 struct snd_soc_dai *codec_dai;
64 int ret = 0;
65
66 codec_dai = snd_soc_card_get_codec_dai(card, GLK_REALTEK_CODEC_DAI);
67 if (!codec_dai) {
68 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
69 return -EIO;
70 }
71
72 if (SND_SOC_DAPM_EVENT_OFF(event)) {
73 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
74 if (ret)
75 dev_err(card->dev, "failed to stop sysclk: %d\n", ret);
76 } else if (SND_SOC_DAPM_EVENT_ON(event)) {
77 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
78 GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
79 if (ret < 0) {
80 dev_err(card->dev, "can't set codec pll: %d\n", ret);
81 return ret;
82 }
83 }
84
85 if (ret)
86 dev_err(card->dev, "failed to start internal clk: %d\n", ret);
87
88 return ret;
89}
90
91static const struct snd_kcontrol_new geminilake_controls[] = { 58static const struct snd_kcontrol_new geminilake_controls[] = {
92 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 59 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
93 SOC_DAPM_PIN_SWITCH("Headset Mic"), 60 SOC_DAPM_PIN_SWITCH("Headset Mic"),
@@ -102,14 +69,10 @@ static const struct snd_soc_dapm_widget geminilake_widgets[] = {
102 SND_SOC_DAPM_SPK("HDMI1", NULL), 69 SND_SOC_DAPM_SPK("HDMI1", NULL),
103 SND_SOC_DAPM_SPK("HDMI2", NULL), 70 SND_SOC_DAPM_SPK("HDMI2", NULL),
104 SND_SOC_DAPM_SPK("HDMI3", NULL), 71 SND_SOC_DAPM_SPK("HDMI3", NULL),
105 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
106 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
107 SND_SOC_DAPM_POST_PMD),
108}; 72};
109 73
110static const struct snd_soc_dapm_route geminilake_map[] = { 74static const struct snd_soc_dapm_route geminilake_map[] = {
111 /* HP jack connectors - unknown if we have jack detection */ 75 /* HP jack connectors - unknown if we have jack detection */
112 { "Headphone Jack", NULL, "Platform Clock" },
113 { "Headphone Jack", NULL, "HPOL" }, 76 { "Headphone Jack", NULL, "HPOL" },
114 { "Headphone Jack", NULL, "HPOR" }, 77 { "Headphone Jack", NULL, "HPOR" },
115 78
@@ -117,7 +80,6 @@ static const struct snd_soc_dapm_route geminilake_map[] = {
117 { "Spk", NULL, "Speaker" }, 80 { "Spk", NULL, "Speaker" },
118 81
119 /* other jacks */ 82 /* other jacks */
120 { "Headset Mic", NULL, "Platform Clock" },
121 { "IN1P", NULL, "Headset Mic" }, 83 { "IN1P", NULL, "Headset Mic" },
122 84
123 /* digital mics */ 85 /* digital mics */
@@ -177,6 +139,13 @@ static int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
177 struct snd_soc_jack *jack; 139 struct snd_soc_jack *jack;
178 int ret; 140 int ret;
179 141
142 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
143 GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
144 if (ret < 0) {
145 dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
146 return ret;
147 }
148
180 /* Configure sysclk for codec */ 149 /* Configure sysclk for codec */
181 ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1, 150 ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1,
182 RT5682_PLL_FREQ, SND_SOC_CLOCK_IN); 151 RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c
index eab1f439dd3f..a4022983a7ce 100644
--- a/sound/soc/intel/boards/haswell.c
+++ b/sound/soc/intel/boards/haswell.c
@@ -146,7 +146,7 @@ static struct snd_soc_dai_link haswell_rt5640_dais[] = {
146 .stream_name = "Loopback", 146 .stream_name = "Loopback",
147 .cpu_dai_name = "Loopback Pin", 147 .cpu_dai_name = "Loopback Pin",
148 .platform_name = "haswell-pcm-audio", 148 .platform_name = "haswell-pcm-audio",
149 .dynamic = 0, 149 .dynamic = 1,
150 .codec_name = "snd-soc-dummy", 150 .codec_name = "snd-soc-dummy",
151 .codec_dai_name = "snd-soc-dummy-dai", 151 .codec_dai_name = "snd-soc-dummy-dai",
152 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 152 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 60c94836bf5b..4ed5b7e17d44 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -336,9 +336,6 @@ static int skl_suspend(struct device *dev)
336 skl->skl_sst->fw_loaded = false; 336 skl->skl_sst->fw_loaded = false;
337 } 337 }
338 338
339 if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
340 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
341
342 return 0; 339 return 0;
343} 340}
344 341
@@ -350,10 +347,6 @@ static int skl_resume(struct device *dev)
350 struct hdac_ext_link *hlink = NULL; 347 struct hdac_ext_link *hlink = NULL;
351 int ret; 348 int ret;
352 349
353 /* Turned OFF in HDMI codec driver after codec reconfiguration */
354 if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
355 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
356
357 /* 350 /*
358 * resume only when we are not in suspend active, otherwise need to 351 * resume only when we are not in suspend active, otherwise need to
359 * restore the device 352 * restore the device
@@ -446,8 +439,10 @@ static int skl_free(struct hdac_bus *bus)
446 snd_hdac_ext_bus_exit(bus); 439 snd_hdac_ext_bus_exit(bus);
447 440
448 cancel_work_sync(&skl->probe_work); 441 cancel_work_sync(&skl->probe_work);
449 if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) 442 if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
443 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
450 snd_hdac_i915_exit(bus); 444 snd_hdac_i915_exit(bus);
445 }
451 446
452 return 0; 447 return 0;
453} 448}
@@ -814,7 +809,7 @@ static void skl_probe_work(struct work_struct *work)
814 err = skl_platform_register(bus->dev); 809 err = skl_platform_register(bus->dev);
815 if (err < 0) { 810 if (err < 0) {
816 dev_err(bus->dev, "platform register failed: %d\n", err); 811 dev_err(bus->dev, "platform register failed: %d\n", err);
817 return; 812 goto out_err;
818 } 813 }
819 814
820 err = skl_machine_device_register(skl); 815 err = skl_machine_device_register(skl);
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index 5b986b74dd36..548eb4fa2da6 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -570,10 +570,10 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
570 prtd->audio_client = q6asm_audio_client_alloc(dev, 570 prtd->audio_client = q6asm_audio_client_alloc(dev,
571 (q6asm_cb)compress_event_handler, 571 (q6asm_cb)compress_event_handler,
572 prtd, stream_id, LEGACY_PCM_MODE); 572 prtd, stream_id, LEGACY_PCM_MODE);
573 if (!prtd->audio_client) { 573 if (IS_ERR(prtd->audio_client)) {
574 dev_err(dev, "Could not allocate memory\n"); 574 dev_err(dev, "Could not allocate memory\n");
575 kfree(prtd); 575 ret = PTR_ERR(prtd->audio_client);
576 return -ENOMEM; 576 goto free_prtd;
577 } 577 }
578 578
579 size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE * 579 size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
@@ -582,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
582 &prtd->dma_buffer); 582 &prtd->dma_buffer);
583 if (ret) { 583 if (ret) {
584 dev_err(dev, "Cannot allocate buffer(s)\n"); 584 dev_err(dev, "Cannot allocate buffer(s)\n");
585 return ret; 585 goto free_client;
586 } 586 }
587 587
588 if (pdata->sid < 0) 588 if (pdata->sid < 0)
@@ -595,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
595 runtime->private_data = prtd; 595 runtime->private_data = prtd;
596 596
597 return 0; 597 return 0;
598
599free_client:
600 q6asm_audio_client_free(prtd->audio_client);
601free_prtd:
602 kfree(prtd);
603
604 return ret;
598} 605}
599 606
600static int q6asm_dai_compr_free(struct snd_compr_stream *stream) 607static int q6asm_dai_compr_free(struct snd_compr_stream *stream)
@@ -874,7 +881,7 @@ static int of_q6asm_parse_dai_data(struct device *dev,
874 881
875 for_each_child_of_node(dev->of_node, node) { 882 for_each_child_of_node(dev->of_node, node) {
876 ret = of_property_read_u32(node, "reg", &id); 883 ret = of_property_read_u32(node, "reg", &id);
877 if (ret || id > MAX_SESSIONS || id < 0) { 884 if (ret || id >= MAX_SESSIONS || id < 0) {
878 dev_err(dev, "valid dai id not found:%d\n", ret); 885 dev_err(dev, "valid dai id not found:%d\n", ret);
879 continue; 886 continue;
880 } 887 }
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 1db8ef668223..6f66a58e23ca 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -158,17 +158,24 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream,
158 return ret; 158 return ret;
159} 159}
160 160
161static void sdm845_jack_free(struct snd_jack *jack)
162{
163 struct snd_soc_component *component = jack->private_data;
164
165 snd_soc_component_set_jack(component, NULL, NULL);
166}
167
161static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) 168static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
162{ 169{
163 struct snd_soc_component *component; 170 struct snd_soc_component *component;
164 struct snd_soc_dai_link *dai_link = rtd->dai_link;
165 struct snd_soc_card *card = rtd->card; 171 struct snd_soc_card *card = rtd->card;
172 struct snd_soc_dai *codec_dai = rtd->codec_dai;
173 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
166 struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); 174 struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card);
167 int i, rval; 175 struct snd_jack *jack;
176 int rval;
168 177
169 if (!pdata->jack_setup) { 178 if (!pdata->jack_setup) {
170 struct snd_jack *jack;
171
172 rval = snd_soc_card_jack_new(card, "Headset Jack", 179 rval = snd_soc_card_jack_new(card, "Headset Jack",
173 SND_JACK_HEADSET | 180 SND_JACK_HEADSET |
174 SND_JACK_HEADPHONE | 181 SND_JACK_HEADPHONE |
@@ -190,16 +197,22 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
190 pdata->jack_setup = true; 197 pdata->jack_setup = true;
191 } 198 }
192 199
193 for (i = 0 ; i < dai_link->num_codecs; i++) { 200 switch (cpu_dai->id) {
194 struct snd_soc_dai *dai = rtd->codec_dais[i]; 201 case PRIMARY_MI2S_RX:
202 jack = pdata->jack.jack;
203 component = codec_dai->component;
195 204
196 component = dai->component; 205 jack->private_data = component;
197 rval = snd_soc_component_set_jack( 206 jack->private_free = sdm845_jack_free;
198 component, &pdata->jack, NULL); 207 rval = snd_soc_component_set_jack(component,
208 &pdata->jack, NULL);
199 if (rval != 0 && rval != -ENOTSUPP) { 209 if (rval != 0 && rval != -ENOTSUPP) {
200 dev_warn(card->dev, "Failed to set jack: %d\n", rval); 210 dev_warn(card->dev, "Failed to set jack: %d\n", rval);
201 return rval; 211 return rval;
202 } 212 }
213 break;
214 default:
215 break;
203 } 216 }
204 217
205 return 0; 218 return 0;
diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
index 922fb6aa3ed1..5aee11c94f2a 100644
--- a/sound/soc/sh/dma-sh7760.c
+++ b/sound/soc/sh/dma-sh7760.c
@@ -202,7 +202,7 @@ static int camelot_prepare(struct snd_pcm_substream *substream)
202 struct snd_soc_pcm_runtime *rtd = substream->private_data; 202 struct snd_soc_pcm_runtime *rtd = substream->private_data;
203 struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; 203 struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
204 204
205 pr_debug("PCM data: addr 0x%08ulx len %d\n", 205 pr_debug("PCM data: addr 0x%08lx len %d\n",
206 (u32)runtime->dma_addr, runtime->dma_bytes); 206 (u32)runtime->dma_addr, runtime->dma_bytes);
207 207
208 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 208 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0462b3ec977a..aae450ba4f08 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -742,7 +742,7 @@ static struct snd_soc_component *soc_find_component(
742 if (of_node) { 742 if (of_node) {
743 if (component->dev->of_node == of_node) 743 if (component->dev->of_node == of_node)
744 return component; 744 return component;
745 } else if (strcmp(component->name, name) == 0) { 745 } else if (name && strcmp(component->name, name) == 0) {
746 return component; 746 return component;
747 } 747 }
748 } 748 }
@@ -1034,17 +1034,18 @@ static int snd_soc_init_platform(struct snd_soc_card *card,
1034 * this function should be removed in the future 1034 * this function should be removed in the future
1035 */ 1035 */
1036 /* convert Legacy platform link */ 1036 /* convert Legacy platform link */
1037 if (!platform) { 1037 if (!platform || dai_link->legacy_platform) {
1038 platform = devm_kzalloc(card->dev, 1038 platform = devm_kzalloc(card->dev,
1039 sizeof(struct snd_soc_dai_link_component), 1039 sizeof(struct snd_soc_dai_link_component),
1040 GFP_KERNEL); 1040 GFP_KERNEL);
1041 if (!platform) 1041 if (!platform)
1042 return -ENOMEM; 1042 return -ENOMEM;
1043 1043
1044 dai_link->platform = platform; 1044 dai_link->platform = platform;
1045 platform->name = dai_link->platform_name; 1045 dai_link->legacy_platform = 1;
1046 platform->of_node = dai_link->platform_of_node; 1046 platform->name = dai_link->platform_name;
1047 platform->dai_name = NULL; 1047 platform->of_node = dai_link->platform_of_node;
1048 platform->dai_name = NULL;
1048 } 1049 }
1049 1050
1050 /* if there's no platform we match on the empty platform */ 1051 /* if there's no platform we match on the empty platform */
@@ -1129,6 +1130,15 @@ static int soc_init_dai_link(struct snd_soc_card *card,
1129 link->name); 1130 link->name);
1130 return -EINVAL; 1131 return -EINVAL;
1131 } 1132 }
1133
1134 /*
1135 * Defer card registartion if platform dai component is not added to
1136 * component list.
1137 */
1138 if ((link->platform->of_node || link->platform->name) &&
1139 !soc_find_component(link->platform->of_node, link->platform->name))
1140 return -EPROBE_DEFER;
1141
1132 /* 1142 /*
1133 * CPU device may be specified by either name or OF node, but 1143 * CPU device may be specified by either name or OF node, but
1134 * can be left unspecified, and will be matched based on DAI 1144 * can be left unspecified, and will be matched based on DAI
@@ -1140,6 +1150,15 @@ static int soc_init_dai_link(struct snd_soc_card *card,
1140 link->name); 1150 link->name);
1141 return -EINVAL; 1151 return -EINVAL;
1142 } 1152 }
1153
1154 /*
1155 * Defer card registartion if cpu dai component is not added to
1156 * component list.
1157 */
1158 if ((link->cpu_of_node || link->cpu_name) &&
1159 !soc_find_component(link->cpu_of_node, link->cpu_name))
1160 return -EPROBE_DEFER;
1161
1143 /* 1162 /*
1144 * At least one of CPU DAI name or CPU device name/node must be 1163 * At least one of CPU DAI name or CPU device name/node must be
1145 * specified 1164 * specified
@@ -2739,15 +2758,18 @@ int snd_soc_register_card(struct snd_soc_card *card)
2739 if (!card->name || !card->dev) 2758 if (!card->name || !card->dev)
2740 return -EINVAL; 2759 return -EINVAL;
2741 2760
2761 mutex_lock(&client_mutex);
2742 for_each_card_prelinks(card, i, link) { 2762 for_each_card_prelinks(card, i, link) {
2743 2763
2744 ret = soc_init_dai_link(card, link); 2764 ret = soc_init_dai_link(card, link);
2745 if (ret) { 2765 if (ret) {
2746 dev_err(card->dev, "ASoC: failed to init link %s\n", 2766 dev_err(card->dev, "ASoC: failed to init link %s\n",
2747 link->name); 2767 link->name);
2768 mutex_unlock(&client_mutex);
2748 return ret; 2769 return ret;
2749 } 2770 }
2750 } 2771 }
2772 mutex_unlock(&client_mutex);
2751 2773
2752 dev_set_drvdata(card->dev, card); 2774 dev_set_drvdata(card->dev, card);
2753 2775
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a5178845065b..2c4c13419539 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2019,19 +2019,19 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
2019 out = is_connected_output_ep(w, NULL, NULL); 2019 out = is_connected_output_ep(w, NULL, NULL);
2020 } 2020 }
2021 2021
2022 ret = snprintf(buf, PAGE_SIZE, "%s: %s%s in %d out %d", 2022 ret = scnprintf(buf, PAGE_SIZE, "%s: %s%s in %d out %d",
2023 w->name, w->power ? "On" : "Off", 2023 w->name, w->power ? "On" : "Off",
2024 w->force ? " (forced)" : "", in, out); 2024 w->force ? " (forced)" : "", in, out);
2025 2025
2026 if (w->reg >= 0) 2026 if (w->reg >= 0)
2027 ret += snprintf(buf + ret, PAGE_SIZE - ret, 2027 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
2028 " - R%d(0x%x) mask 0x%x", 2028 " - R%d(0x%x) mask 0x%x",
2029 w->reg, w->reg, w->mask << w->shift); 2029 w->reg, w->reg, w->mask << w->shift);
2030 2030
2031 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n"); 2031 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
2032 2032
2033 if (w->sname) 2033 if (w->sname)
2034 ret += snprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n", 2034 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n",
2035 w->sname, 2035 w->sname,
2036 w->active ? "active" : "inactive"); 2036 w->active ? "active" : "inactive");
2037 2037
@@ -2044,7 +2044,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
2044 if (!p->connect) 2044 if (!p->connect)
2045 continue; 2045 continue;
2046 2046
2047 ret += snprintf(buf + ret, PAGE_SIZE - ret, 2047 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
2048 " %s \"%s\" \"%s\"\n", 2048 " %s \"%s\" \"%s\"\n",
2049 (rdir == SND_SOC_DAPM_DIR_IN) ? "in" : "out", 2049 (rdir == SND_SOC_DAPM_DIR_IN) ? "in" : "out",
2050 p->name ? p->name : "static", 2050 p->name ? p->name : "static",
diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
index eeda6d5565bc..a10fcb5963c6 100644
--- a/sound/soc/ti/davinci-mcasp.c
+++ b/sound/soc/ti/davinci-mcasp.c
@@ -108,7 +108,7 @@ struct davinci_mcasp {
108 /* Used for comstraint setting on the second stream */ 108 /* Used for comstraint setting on the second stream */
109 u32 channels; 109 u32 channels;
110 110
111#ifdef CONFIG_PM_SLEEP 111#ifdef CONFIG_PM
112 struct davinci_mcasp_context context; 112 struct davinci_mcasp_context context;
113#endif 113#endif
114 114
@@ -1486,74 +1486,6 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai)
1486 return 0; 1486 return 0;
1487} 1487}
1488 1488
1489#ifdef CONFIG_PM_SLEEP
1490static int davinci_mcasp_suspend(struct snd_soc_dai *dai)
1491{
1492 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
1493 struct davinci_mcasp_context *context = &mcasp->context;
1494 u32 reg;
1495 int i;
1496
1497 context->pm_state = pm_runtime_active(mcasp->dev);
1498 if (!context->pm_state)
1499 pm_runtime_get_sync(mcasp->dev);
1500
1501 for (i = 0; i < ARRAY_SIZE(context_regs); i++)
1502 context->config_regs[i] = mcasp_get_reg(mcasp, context_regs[i]);
1503
1504 if (mcasp->txnumevt) {
1505 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
1506 context->afifo_regs[0] = mcasp_get_reg(mcasp, reg);
1507 }
1508 if (mcasp->rxnumevt) {
1509 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
1510 context->afifo_regs[1] = mcasp_get_reg(mcasp, reg);
1511 }
1512
1513 for (i = 0; i < mcasp->num_serializer; i++)
1514 context->xrsr_regs[i] = mcasp_get_reg(mcasp,
1515 DAVINCI_MCASP_XRSRCTL_REG(i));
1516
1517 pm_runtime_put_sync(mcasp->dev);
1518
1519 return 0;
1520}
1521
1522static int davinci_mcasp_resume(struct snd_soc_dai *dai)
1523{
1524 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
1525 struct davinci_mcasp_context *context = &mcasp->context;
1526 u32 reg;
1527 int i;
1528
1529 pm_runtime_get_sync(mcasp->dev);
1530
1531 for (i = 0; i < ARRAY_SIZE(context_regs); i++)
1532 mcasp_set_reg(mcasp, context_regs[i], context->config_regs[i]);
1533
1534 if (mcasp->txnumevt) {
1535 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
1536 mcasp_set_reg(mcasp, reg, context->afifo_regs[0]);
1537 }
1538 if (mcasp->rxnumevt) {
1539 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
1540 mcasp_set_reg(mcasp, reg, context->afifo_regs[1]);
1541 }
1542
1543 for (i = 0; i < mcasp->num_serializer; i++)
1544 mcasp_set_reg(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i),
1545 context->xrsr_regs[i]);
1546
1547 if (!context->pm_state)
1548 pm_runtime_put_sync(mcasp->dev);
1549
1550 return 0;
1551}
1552#else
1553#define davinci_mcasp_suspend NULL
1554#define davinci_mcasp_resume NULL
1555#endif
1556
1557#define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000 1489#define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000
1558 1490
1559#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ 1491#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \
@@ -1571,8 +1503,6 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
1571 { 1503 {
1572 .name = "davinci-mcasp.0", 1504 .name = "davinci-mcasp.0",
1573 .probe = davinci_mcasp_dai_probe, 1505 .probe = davinci_mcasp_dai_probe,
1574 .suspend = davinci_mcasp_suspend,
1575 .resume = davinci_mcasp_resume,
1576 .playback = { 1506 .playback = {
1577 .channels_min = 1, 1507 .channels_min = 1,
1578 .channels_max = 32 * 16, 1508 .channels_max = 32 * 16,
@@ -1976,7 +1906,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1976 } 1906 }
1977 1907
1978 mcasp->num_serializer = pdata->num_serializer; 1908 mcasp->num_serializer = pdata->num_serializer;
1979#ifdef CONFIG_PM_SLEEP 1909#ifdef CONFIG_PM
1980 mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev, 1910 mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev,
1981 mcasp->num_serializer, sizeof(u32), 1911 mcasp->num_serializer, sizeof(u32),
1982 GFP_KERNEL); 1912 GFP_KERNEL);
@@ -2196,11 +2126,73 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
2196 return 0; 2126 return 0;
2197} 2127}
2198 2128
2129#ifdef CONFIG_PM
2130static int davinci_mcasp_runtime_suspend(struct device *dev)
2131{
2132 struct davinci_mcasp *mcasp = dev_get_drvdata(dev);
2133 struct davinci_mcasp_context *context = &mcasp->context;
2134 u32 reg;
2135 int i;
2136
2137 for (i = 0; i < ARRAY_SIZE(context_regs); i++)
2138 context->config_regs[i] = mcasp_get_reg(mcasp, context_regs[i]);
2139
2140 if (mcasp->txnumevt) {
2141 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
2142 context->afifo_regs[0] = mcasp_get_reg(mcasp, reg);
2143 }
2144 if (mcasp->rxnumevt) {
2145 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
2146 context->afifo_regs[1] = mcasp_get_reg(mcasp, reg);
2147 }
2148
2149 for (i = 0; i < mcasp->num_serializer; i++)
2150 context->xrsr_regs[i] = mcasp_get_reg(mcasp,
2151 DAVINCI_MCASP_XRSRCTL_REG(i));
2152
2153 return 0;
2154}
2155
2156static int davinci_mcasp_runtime_resume(struct device *dev)
2157{
2158 struct davinci_mcasp *mcasp = dev_get_drvdata(dev);
2159 struct davinci_mcasp_context *context = &mcasp->context;
2160 u32 reg;
2161 int i;
2162
2163 for (i = 0; i < ARRAY_SIZE(context_regs); i++)
2164 mcasp_set_reg(mcasp, context_regs[i], context->config_regs[i]);
2165
2166 if (mcasp->txnumevt) {
2167 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
2168 mcasp_set_reg(mcasp, reg, context->afifo_regs[0]);
2169 }
2170 if (mcasp->rxnumevt) {
2171 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
2172 mcasp_set_reg(mcasp, reg, context->afifo_regs[1]);
2173 }
2174
2175 for (i = 0; i < mcasp->num_serializer; i++)
2176 mcasp_set_reg(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i),
2177 context->xrsr_regs[i]);
2178
2179 return 0;
2180}
2181
2182#endif
2183
2184static const struct dev_pm_ops davinci_mcasp_pm_ops = {
2185 SET_RUNTIME_PM_OPS(davinci_mcasp_runtime_suspend,
2186 davinci_mcasp_runtime_resume,
2187 NULL)
2188};
2189
2199static struct platform_driver davinci_mcasp_driver = { 2190static struct platform_driver davinci_mcasp_driver = {
2200 .probe = davinci_mcasp_probe, 2191 .probe = davinci_mcasp_probe,
2201 .remove = davinci_mcasp_remove, 2192 .remove = davinci_mcasp_remove,
2202 .driver = { 2193 .driver = {
2203 .name = "davinci-mcasp", 2194 .name = "davinci-mcasp",
2195 .pm = &davinci_mcasp_pm_ops,
2204 .of_match_table = mcasp_dt_ids, 2196 .of_match_table = mcasp_dt_ids,
2205 }, 2197 },
2206}; 2198};
diff --git a/sound/soc/xilinx/Kconfig b/sound/soc/xilinx/Kconfig
index 25e287feb58c..723a583a8d57 100644
--- a/sound/soc/xilinx/Kconfig
+++ b/sound/soc/xilinx/Kconfig
@@ -1,5 +1,5 @@
1config SND_SOC_XILINX_I2S 1config SND_SOC_XILINX_I2S
2 tristate "Audio support for the the Xilinx I2S" 2 tristate "Audio support for the Xilinx I2S"
3 help 3 help
4 Select this option to enable Xilinx I2S Audio. This enables 4 Select this option to enable Xilinx I2S Audio. This enables
5 I2S playback and capture using xilinx soft IP. In transmitter 5 I2S playback and capture using xilinx soft IP. In transmitter
diff --git a/sound/soc/xilinx/xlnx_i2s.c b/sound/soc/xilinx/xlnx_i2s.c
index d4ae9eff41ce..8b353166ad44 100644
--- a/sound/soc/xilinx/xlnx_i2s.c
+++ b/sound/soc/xilinx/xlnx_i2s.c
@@ -1,12 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* 2//
3 * Xilinx ASoC I2S audio support 3// Xilinx ASoC I2S audio support
4 * 4//
5 * Copyright (C) 2018 Xilinx, Inc. 5// Copyright (C) 2018 Xilinx, Inc.
6 * 6//
7 * Author: Praveen Vuppala <praveenv@xilinx.com> 7// Author: Praveen Vuppala <praveenv@xilinx.com>
8 * Author: Maruthi Srinivas Bayyavarapu <maruthis@xilinx.com> 8// Author: Maruthi Srinivas Bayyavarapu <maruthis@xilinx.com>
9 */
10 9
11#include <linux/io.h> 10#include <linux/io.h>
12#include <linux/module.h> 11#include <linux/module.h>
diff --git a/tools/testing/nvdimm/dimm_devs.c b/tools/testing/nvdimm/dimm_devs.c
index e75238404555..2d4baf57822f 100644
--- a/tools/testing/nvdimm/dimm_devs.c
+++ b/tools/testing/nvdimm/dimm_devs.c
@@ -18,8 +18,8 @@ ssize_t security_show(struct device *dev,
18 * For the test version we need to poll the "hardware" in order 18 * For the test version we need to poll the "hardware" in order
19 * to get the updated status for unlock testing. 19 * to get the updated status for unlock testing.
20 */ 20 */
21 nvdimm->sec.state = nvdimm_security_state(nvdimm, false); 21 nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
22 nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, true); 22 nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, NVDIMM_MASTER);
23 23
24 switch (nvdimm->sec.state) { 24 switch (nvdimm->sec.state) {
25 case NVDIMM_SECURITY_DISABLED: 25 case NVDIMM_SECURITY_DISABLED:
diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
index f8d468f54e98..aaa1e9f083c3 100644
--- a/tools/testing/selftests/gpio/gpio-mockup-chardev.c
+++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
@@ -37,7 +37,7 @@ static int get_debugfs(char **path)
37 struct libmnt_table *tb; 37 struct libmnt_table *tb;
38 struct libmnt_iter *itr = NULL; 38 struct libmnt_iter *itr = NULL;
39 struct libmnt_fs *fs; 39 struct libmnt_fs *fs;
40 int found = 0; 40 int found = 0, ret;
41 41
42 cxt = mnt_new_context(); 42 cxt = mnt_new_context();
43 if (!cxt) 43 if (!cxt)
@@ -58,8 +58,11 @@ static int get_debugfs(char **path)
58 break; 58 break;
59 } 59 }
60 } 60 }
61 if (found) 61 if (found) {
62 asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); 62 ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
63 if (ret < 0)
64 err(EXIT_FAILURE, "failed to format string");
65 }
63 66
64 mnt_free_iter(itr); 67 mnt_free_iter(itr);
65 mnt_free_context(cxt); 68 mnt_free_context(cxt);
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 23022e9d32eb..b52cfdefecbf 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -571,7 +571,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
571 * already exist. 571 * already exist.
572 */ 572 */
573 region = (struct userspace_mem_region *) userspace_mem_region_find( 573 region = (struct userspace_mem_region *) userspace_mem_region_find(
574 vm, guest_paddr, guest_paddr + npages * vm->page_size); 574 vm, guest_paddr, (guest_paddr + npages * vm->page_size) - 1);
575 if (region != NULL) 575 if (region != NULL)
576 TEST_ASSERT(false, "overlapping userspace_mem_region already " 576 TEST_ASSERT(false, "overlapping userspace_mem_region already "
577 "exists\n" 577 "exists\n"
@@ -587,15 +587,10 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
587 region = region->next) { 587 region = region->next) {
588 if (region->region.slot == slot) 588 if (region->region.slot == slot)
589 break; 589 break;
590 if ((guest_paddr <= (region->region.guest_phys_addr
591 + region->region.memory_size))
592 && ((guest_paddr + npages * vm->page_size)
593 >= region->region.guest_phys_addr))
594 break;
595 } 590 }
596 if (region != NULL) 591 if (region != NULL)
597 TEST_ASSERT(false, "A mem region with the requested slot " 592 TEST_ASSERT(false, "A mem region with the requested slot "
598 "or overlapping physical memory range already exists.\n" 593 "already exists.\n"
599 " requested slot: %u paddr: 0x%lx npages: 0x%lx\n" 594 " requested slot: %u paddr: 0x%lx npages: 0x%lx\n"
600 " existing slot: %u paddr: 0x%lx size: 0x%lx", 595 " existing slot: %u paddr: 0x%lx size: 0x%lx",
601 slot, guest_paddr, npages, 596 slot, guest_paddr, npages,
diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
index ea3c73e8f4f6..c49c2a28b0eb 100644
--- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
@@ -103,6 +103,12 @@ int main(int argc, char *argv[])
103 103
104 vcpu_ioctl(vm, VCPU_ID, KVM_ENABLE_CAP, &enable_evmcs_cap); 104 vcpu_ioctl(vm, VCPU_ID, KVM_ENABLE_CAP, &enable_evmcs_cap);
105 105
106 /* KVM should return supported EVMCS version range */
107 TEST_ASSERT(((evmcs_ver >> 8) >= (evmcs_ver & 0xff)) &&
108 (evmcs_ver & 0xff) > 0,
109 "Incorrect EVMCS version range: %x:%x\n",
110 evmcs_ver & 0xff, evmcs_ver >> 8);
111
106 run = vcpu_state(vm, VCPU_ID); 112 run = vcpu_state(vm, VCPU_ID);
107 113
108 vcpu_regs_get(vm, VCPU_ID, &regs1); 114 vcpu_regs_get(vm, VCPU_ID, &regs1);
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index e20b017e7073..b2065536d407 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -145,15 +145,12 @@ TEST_F(rtc, alarm_alm_set) {
145 145
146 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); 146 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
147 ASSERT_NE(-1, rc); 147 ASSERT_NE(-1, rc);
148 EXPECT_NE(0, rc); 148 ASSERT_NE(0, rc);
149 149
150 /* Disable alarm interrupts */ 150 /* Disable alarm interrupts */
151 rc = ioctl(self->fd, RTC_AIE_OFF, 0); 151 rc = ioctl(self->fd, RTC_AIE_OFF, 0);
152 ASSERT_NE(-1, rc); 152 ASSERT_NE(-1, rc);
153 153
154 if (rc == 0)
155 return;
156
157 rc = read(self->fd, &data, sizeof(unsigned long)); 154 rc = read(self->fd, &data, sizeof(unsigned long));
158 ASSERT_NE(-1, rc); 155 ASSERT_NE(-1, rc);
159 TH_LOG("data: %lx", data); 156 TH_LOG("data: %lx", data);
@@ -202,7 +199,109 @@ TEST_F(rtc, alarm_wkalm_set) {
202 199
203 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); 200 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
204 ASSERT_NE(-1, rc); 201 ASSERT_NE(-1, rc);
205 EXPECT_NE(0, rc); 202 ASSERT_NE(0, rc);
203
204 rc = read(self->fd, &data, sizeof(unsigned long));
205 ASSERT_NE(-1, rc);
206
207 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
208 ASSERT_NE(-1, rc);
209
210 new = timegm((struct tm *)&tm);
211 ASSERT_EQ(new, secs);
212}
213
214TEST_F(rtc, alarm_alm_set_minute) {
215 struct timeval tv = { .tv_sec = 62 };
216 unsigned long data;
217 struct rtc_time tm;
218 fd_set readfds;
219 time_t secs, new;
220 int rc;
221
222 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
223 ASSERT_NE(-1, rc);
224
225 secs = timegm((struct tm *)&tm) + 60 - tm.tm_sec;
226 gmtime_r(&secs, (struct tm *)&tm);
227
228 rc = ioctl(self->fd, RTC_ALM_SET, &tm);
229 if (rc == -1) {
230 ASSERT_EQ(EINVAL, errno);
231 TH_LOG("skip alarms are not supported.");
232 return;
233 }
234
235 rc = ioctl(self->fd, RTC_ALM_READ, &tm);
236 ASSERT_NE(-1, rc);
237
238 TH_LOG("Alarm time now set to %02d:%02d:%02d.",
239 tm.tm_hour, tm.tm_min, tm.tm_sec);
240
241 /* Enable alarm interrupts */
242 rc = ioctl(self->fd, RTC_AIE_ON, 0);
243 ASSERT_NE(-1, rc);
244
245 FD_ZERO(&readfds);
246 FD_SET(self->fd, &readfds);
247
248 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
249 ASSERT_NE(-1, rc);
250 ASSERT_NE(0, rc);
251
252 /* Disable alarm interrupts */
253 rc = ioctl(self->fd, RTC_AIE_OFF, 0);
254 ASSERT_NE(-1, rc);
255
256 rc = read(self->fd, &data, sizeof(unsigned long));
257 ASSERT_NE(-1, rc);
258 TH_LOG("data: %lx", data);
259
260 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
261 ASSERT_NE(-1, rc);
262
263 new = timegm((struct tm *)&tm);
264 ASSERT_EQ(new, secs);
265}
266
267TEST_F(rtc, alarm_wkalm_set_minute) {
268 struct timeval tv = { .tv_sec = 62 };
269 struct rtc_wkalrm alarm = { 0 };
270 struct rtc_time tm;
271 unsigned long data;
272 fd_set readfds;
273 time_t secs, new;
274 int rc;
275
276 rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
277 ASSERT_NE(-1, rc);
278
279 secs = timegm((struct tm *)&alarm.time) + 60 - alarm.time.tm_sec;
280 gmtime_r(&secs, (struct tm *)&alarm.time);
281
282 alarm.enabled = 1;
283
284 rc = ioctl(self->fd, RTC_WKALM_SET, &alarm);
285 if (rc == -1) {
286 ASSERT_EQ(EINVAL, errno);
287 TH_LOG("skip alarms are not supported.");
288 return;
289 }
290
291 rc = ioctl(self->fd, RTC_WKALM_RD, &alarm);
292 ASSERT_NE(-1, rc);
293
294 TH_LOG("Alarm time now set to %02d/%02d/%02d %02d:%02d:%02d.",
295 alarm.time.tm_mday, alarm.time.tm_mon + 1,
296 alarm.time.tm_year + 1900, alarm.time.tm_hour,
297 alarm.time.tm_min, alarm.time.tm_sec);
298
299 FD_ZERO(&readfds);
300 FD_SET(self->fd, &readfds);
301
302 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
303 ASSERT_NE(-1, rc);
304 ASSERT_NE(0, rc);
206 305
207 rc = read(self->fd, &data, sizeof(unsigned long)); 306 rc = read(self->fd, &data, sizeof(unsigned long));
208 ASSERT_NE(-1, rc); 307 ASSERT_NE(-1, rc);
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index fce7f4ce0692..1760b3e39730 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark
9CFLAGS += -Wl,-no-as-needed -Wall 9CFLAGS += -Wl,-no-as-needed -Wall
10 10
11seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h 11seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
12 $(CC) $(CFLAGS) $(LDFLAGS) -lpthread $< -o $@ 12 $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
13 13
14TEST_PROGS += $(BINARIES) 14TEST_PROGS += $(BINARIES)
15EXTRA_CLEAN := $(BINARIES) 15EXTRA_CLEAN := $(BINARIES)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 067cb4607d6c..496a9a8c773a 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3044,7 +3044,7 @@ TEST(user_notification_basic)
3044 /* Check that the basic notification machinery works */ 3044 /* Check that the basic notification machinery works */
3045 listener = user_trap_syscall(__NR_getpid, 3045 listener = user_trap_syscall(__NR_getpid,
3046 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3046 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3047 EXPECT_GE(listener, 0); 3047 ASSERT_GE(listener, 0);
3048 3048
3049 /* Installing a second listener in the chain should EBUSY */ 3049 /* Installing a second listener in the chain should EBUSY */
3050 EXPECT_EQ(user_trap_syscall(__NR_getpid, 3050 EXPECT_EQ(user_trap_syscall(__NR_getpid,
@@ -3103,7 +3103,7 @@ TEST(user_notification_kill_in_middle)
3103 3103
3104 listener = user_trap_syscall(__NR_getpid, 3104 listener = user_trap_syscall(__NR_getpid,
3105 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3105 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3106 EXPECT_GE(listener, 0); 3106 ASSERT_GE(listener, 0);
3107 3107
3108 /* 3108 /*
3109 * Check that nothing bad happens when we kill the task in the middle 3109 * Check that nothing bad happens when we kill the task in the middle
@@ -3152,7 +3152,7 @@ TEST(user_notification_signal)
3152 3152
3153 listener = user_trap_syscall(__NR_gettid, 3153 listener = user_trap_syscall(__NR_gettid,
3154 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3154 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3155 EXPECT_GE(listener, 0); 3155 ASSERT_GE(listener, 0);
3156 3156
3157 pid = fork(); 3157 pid = fork();
3158 ASSERT_GE(pid, 0); 3158 ASSERT_GE(pid, 0);
@@ -3215,7 +3215,7 @@ TEST(user_notification_closed_listener)
3215 3215
3216 listener = user_trap_syscall(__NR_getpid, 3216 listener = user_trap_syscall(__NR_getpid,
3217 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3217 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3218 EXPECT_GE(listener, 0); 3218 ASSERT_GE(listener, 0);
3219 3219
3220 /* 3220 /*
3221 * Check that we get an ENOSYS when the listener is closed. 3221 * Check that we get an ENOSYS when the listener is closed.
@@ -3376,7 +3376,7 @@ TEST(seccomp_get_notif_sizes)
3376{ 3376{
3377 struct seccomp_notif_sizes sizes; 3377 struct seccomp_notif_sizes sizes;
3378 3378
3379 EXPECT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); 3379 ASSERT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0);
3380 EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif)); 3380 EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif));
3381 EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp)); 3381 EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp));
3382} 3382}
diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c
index 880b96fc80d4..c0534e298b51 100644
--- a/tools/testing/selftests/vm/gup_benchmark.c
+++ b/tools/testing/selftests/vm/gup_benchmark.c
@@ -25,6 +25,7 @@ struct gup_benchmark {
25 __u64 size; 25 __u64 size;
26 __u32 nr_pages_per_call; 26 __u32 nr_pages_per_call;
27 __u32 flags; 27 __u32 flags;
28 __u64 expansion[10]; /* For future use */
28}; 29};
29 30
30int main(int argc, char **argv) 31int main(int argc, char **argv)
diff --git a/tools/testing/selftests/x86/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c
index 50f7e9272481..bf1bb15b6fbe 100644
--- a/tools/testing/selftests/x86/mpx-mini-test.c
+++ b/tools/testing/selftests/x86/mpx-mini-test.c
@@ -1503,7 +1503,7 @@ exit:
1503 exit(20); 1503 exit(20);
1504 } 1504 }
1505 if (successes != total_nr_tests) { 1505 if (successes != total_nr_tests) {
1506 eprintf("ERROR: succeded fewer than number of tries (%d != %d)\n", 1506 eprintf("ERROR: succeeded fewer than number of tries (%d != %d)\n",
1507 successes, total_nr_tests); 1507 successes, total_nr_tests);
1508 exit(21); 1508 exit(21);
1509 } 1509 }
diff --git a/tools/testing/selftests/x86/unwind_vdso.c b/tools/testing/selftests/x86/unwind_vdso.c
index 00a26a82fa98..97311333700e 100644
--- a/tools/testing/selftests/x86/unwind_vdso.c
+++ b/tools/testing/selftests/x86/unwind_vdso.c
@@ -44,7 +44,6 @@ int main()
44#include <stdbool.h> 44#include <stdbool.h>
45#include <sys/ptrace.h> 45#include <sys/ptrace.h>
46#include <sys/user.h> 46#include <sys/user.h>
47#include <sys/ucontext.h>
48#include <link.h> 47#include <link.h>
49#include <sys/auxv.h> 48#include <sys/auxv.h>
50#include <dlfcn.h> 49#include <dlfcn.h>