aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-01-11 13:49:27 -0500
committerTakashi Iwai <tiwai@suse.de>2017-01-11 13:49:27 -0500
commit6cf4569ce3561dec560147e6051959d6896b23d1 (patch)
tree2b3dca47673824975c35a708a6d9d24ff46a2771
parent2e40795c3bf344cfb5220d94566205796e3ef19a (diff)
parent42e0ebdef53d91891939a475c6ef23970829ff99 (diff)
Merge tag 'asoc-fix-v4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v4.10 As well as the usual smattering of driver specific fixes collected since the merge window this has one particularly important fix to the core for handling of aux_devs which was broken during the merge window by some of the componentization refactoring.
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt13
-rw-r--r--Documentation/block/queue-sysfs.txt6
-rw-r--r--Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt4
-rw-r--r--Documentation/devicetree/bindings/power/supply/tps65217_charger.txt7
-rw-r--r--Documentation/driver-api/infrastructure.rst15
-rw-r--r--Documentation/networking/mpls-sysctl.txt4
-rw-r--r--Documentation/vfio-mediated-device.txt27
-rw-r--r--MAINTAINERS22
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig3
-rw-r--r--arch/arm/boot/dts/Makefile1
-rw-r--r--arch/arm/boot/dts/am335x-bone-common.dtsi8
-rw-r--r--arch/arm/boot/dts/am33xx.dtsi1
-rw-r--r--arch/arm/boot/dts/am4372.dtsi1
-rw-r--r--arch/arm/boot/dts/am571x-idk.dts10
-rw-r--r--arch/arm/boot/dts/am572x-idk.dts14
-rw-r--r--arch/arm/boot/dts/am57xx-idk-common.dtsi9
-rw-r--r--arch/arm/boot/dts/dm814x.dtsi1
-rw-r--r--arch/arm/boot/dts/dm816x.dtsi1
-rw-r--r--arch/arm/boot/dts/dra7.dtsi1
-rw-r--r--arch/arm/boot/dts/dra72-evm-tps65917.dtsi16
-rw-r--r--arch/arm/boot/dts/imx31.dtsi4
-rw-r--r--arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6sl.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6sx.dtsi1
-rw-r--r--arch/arm/boot/dts/omap2.dtsi1
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/boot/dts/omap3.dtsi1
-rw-r--r--arch/arm/boot/dts/omap4.dtsi1
-rw-r--r--arch/arm/boot/dts/omap5.dtsi1
-rw-r--r--arch/arm/boot/dts/qcom-apq8064.dtsi4
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts2
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts2
-rw-r--r--arch/arm/boot/dts/vf610-zii-dev-rev-b.dts3
-rw-r--r--arch/arm/mach-davinci/clock.c12
-rw-r--r--arch/arm/mach-davinci/clock.h2
-rw-r--r--arch/arm/mach-davinci/da850.c32
-rw-r--r--arch/arm/mach-davinci/usb-da8xx.c34
-rw-r--r--arch/arm/mach-exynos/platsmp.c31
-rw-r--r--arch/arm/mach-imx/mach-imx1.c1
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/board-generic.c2
-rw-r--r--arch/arm/mach-omap2/gpio.c160
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_common_data.h4
-rw-r--r--arch/arm/mach-omap2/prm_common.c4
-rw-r--r--arch/arm/mach-omap2/timer.c9
-rw-r--r--arch/arm/mach-s3c24xx/common.c76
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gx.dtsi16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi4
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl.dtsi6
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts16
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxm.dtsi4
-rw-r--r--arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts2
-rw-r--r--arch/arm64/boot/dts/qcom/msm8996.dtsi10
-rw-r--r--arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts2
-rw-r--r--arch/arm64/configs/defconfig1
-rw-r--r--arch/arm64/include/asm/current.h10
-rw-r--r--arch/arm64/mm/dma-mapping.c3
-rw-r--r--arch/arm64/mm/fault.c8
-rw-r--r--arch/arm64/mm/init.c3
-rw-r--r--arch/mips/kvm/entry.c5
-rw-r--r--arch/mips/kvm/mips.c4
-rw-r--r--arch/openrisc/kernel/vmlinux.lds.S2
-rw-r--r--arch/parisc/include/asm/thread_info.h1
-rw-r--r--arch/parisc/kernel/time.c23
-rw-r--r--arch/parisc/mm/fault.c2
-rw-r--r--arch/s390/include/asm/asm-prototypes.h8
-rw-r--r--arch/s390/kernel/vtime.c8
-rw-r--r--arch/x86/kernel/pci-swiotlb.c6
-rw-r--r--arch/x86/kvm/vmx.c14
-rw-r--r--arch/x86/kvm/x86.c9
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c2
-rw-r--r--arch/x86/xen/setup.c6
-rw-r--r--block/blk-wbt.c13
-rw-r--r--drivers/acpi/acpi_watchdog.c2
-rw-r--r--drivers/acpi/glue.c11
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/scan.c1
-rw-r--r--drivers/acpi/sysfs.c56
-rw-r--r--drivers/base/power/domain.c1
-rw-r--r--drivers/clk/clk-stm32f4.c4
-rw-r--r--drivers/clk/renesas/clk-mstp.c27
-rw-r--r--drivers/cpufreq/cpufreq-dt-platdev.c2
-rw-r--r--drivers/cpufreq/intel_pstate.c53
-rw-r--r--drivers/devfreq/devfreq.c15
-rw-r--r--drivers/devfreq/exynos-bus.c2
-rw-r--r--drivers/firmware/arm_scpi.c10
-rw-r--r--drivers/firmware/psci_checker.c4
-rw-r--r--drivers/gpu/drm/i915/gvt/cfg_space.c4
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.c55
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.h4
-rw-r--r--drivers/gpu/drm/i915/gvt/gvt.h1
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c64
-rw-r--r--drivers/gpu/drm/i915/gvt/opregion.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c33
-rw-r--r--drivers/gpu/drm/i915/i915_gem_request.h19
-rw-r--r--drivers/gpu/drm/i915/intel_display.c32
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c41
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c9
-rw-r--r--drivers/hid/hid-asus.c17
-rw-r--r--drivers/hid/hid-ids.h4
-rw-r--r--drivers/hid/hid-sensor-hub.c3
-rw-r--r--drivers/hid/hid-sony.c36
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/hwmon/lm90.c2
-rw-r--r--drivers/iio/accel/st_accel_core.c12
-rw-r--r--drivers/iio/adc/Kconfig2
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_buffer.c4
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c13
-rw-r--r--drivers/iio/counter/104-quad-8.c13
-rw-r--r--drivers/iio/imu/bmi160/bmi160_core.c25
-rw-r--r--drivers/iio/light/max44000.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c14
-rw-r--r--drivers/iommu/amd_iommu.c2
-rw-r--r--drivers/iommu/dmar.c6
-rw-r--r--drivers/iommu/intel-iommu.c42
-rw-r--r--drivers/misc/mei/bus.c2
-rw-r--r--drivers/misc/mei/client.c20
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c23
-rw-r--r--drivers/net/ethernet/cadence/macb_pci.c27
-rw-r--r--drivers/net/ethernet/cavium/Kconfig2
-rw-r--r--drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c12
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c4
-rw-r--r--drivers/net/ethernet/freescale/dpaa/dpaa_eth.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_clock.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/icm.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c28
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c51
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h32
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c15
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c3
-rw-r--r--drivers/net/ethernet/sfc/ef10.c3
-rw-r--r--drivers/net/ethernet/sfc/ethtool.c2
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h2
-rw-r--r--drivers/net/ethernet/sfc/siena.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c89
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c23
-rw-r--r--drivers/net/usb/asix_devices.c1
-rw-r--r--drivers/net/vrf.c3
-rw-r--r--drivers/net/wan/slic_ds26522.c2
-rw-r--r--drivers/nvme/host/core.c17
-rw-r--r--drivers/nvme/host/fc.c19
-rw-r--r--drivers/nvme/host/nvme.h1
-rw-r--r--drivers/nvme/host/pci.c13
-rw-r--r--drivers/nvme/host/scsi.c27
-rw-r--r--drivers/nvme/target/admin-cmd.c4
-rw-r--r--drivers/nvme/target/fcloop.c4
-rw-r--r--drivers/nvmem/core.c4
-rw-r--r--drivers/nvmem/imx-ocotp.c2
-rw-r--r--drivers/nvmem/qfprom.c14
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.c2
-rw-r--r--drivers/pinctrl/pinctrl-amd.c19
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.c91
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.h31
-rw-r--r--drivers/platform/x86/Kconfig2
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c42
-rw-r--r--drivers/staging/octeon/ethernet.c2
-rw-r--r--drivers/usb/core/config.c10
-rw-r--r--drivers/usb/core/hub.c59
-rw-r--r--drivers/usb/dwc2/gadget.c2
-rw-r--r--drivers/usb/dwc2/params.c30
-rw-r--r--drivers/usb/dwc3/core.h10
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c6
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c17
-rw-r--r--drivers/usb/dwc3/ep0.c46
-rw-r--r--drivers/usb/dwc3/gadget.c24
-rw-r--r--drivers/usb/gadget/composite.c12
-rw-r--r--drivers/usb/gadget/function/f_fs.c14
-rw-r--r--drivers/usb/gadget/function/f_hid.c2
-rw-r--r--drivers/usb/gadget/legacy/inode.c18
-rw-r--r--drivers/usb/gadget/udc/core.c6
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c6
-rw-r--r--drivers/usb/host/ohci-at91.c24
-rw-r--r--drivers/usb/host/xhci-mem.c46
-rw-r--r--drivers/usb/host/xhci-mtk.c4
-rw-r--r--drivers/usb/host/xhci-pci.c3
-rw-r--r--drivers/usb/host/xhci-ring.c251
-rw-r--r--drivers/usb/host/xhci.c4
-rw-r--r--drivers/usb/host/xhci.h5
-rw-r--r--drivers/usb/musb/blackfin.c1
-rw-r--r--drivers/usb/musb/musb_core.c2
-rw-r--r--drivers/usb/musb/musb_core.h7
-rw-r--r--drivers/usb/musb/musb_dsps.c12
-rw-r--r--drivers/usb/musb/musb_host.c10
-rw-r--r--drivers/usb/musb/musbhsdma.h2
-rw-r--r--drivers/usb/serial/cyberjack.c10
-rw-r--r--drivers/usb/serial/f81534.c8
-rw-r--r--drivers/usb/serial/garmin_gps.c1
-rw-r--r--drivers/usb/serial/io_edgeport.c5
-rw-r--r--drivers/usb/serial/io_ti.c22
-rw-r--r--drivers/usb/serial/iuu_phoenix.c11
-rw-r--r--drivers/usb/serial/keyspan_pda.c14
-rw-r--r--drivers/usb/serial/kobil_sct.c12
-rw-r--r--drivers/usb/serial/mos7720.c56
-rw-r--r--drivers/usb/serial/mos7840.c24
-rw-r--r--drivers/usb/serial/omninet.c13
-rw-r--r--drivers/usb/serial/oti6858.c16
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/quatech2.c4
-rw-r--r--drivers/usb/serial/spcp8x5.c14
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c7
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/vfio/mdev/mdev_core.c100
-rw-r--r--drivers/vfio/mdev/mdev_private.h29
-rw-r--r--drivers/vfio/mdev/mdev_sysfs.c8
-rw-r--r--drivers/vfio/mdev/vfio_mdev.c12
-rw-r--r--drivers/vfio/pci/vfio_pci.c4
-rw-r--r--drivers/vfio/pci/vfio_pci_rdwr.c5
-rw-r--r--drivers/vfio/vfio_iommu_type1.c98
-rw-r--r--drivers/video/fbdev/cobalt_lcdfb.c5
-rw-r--r--drivers/xen/arm-device.c8
-rw-r--r--drivers/xen/events/events_fifo.c3
-rw-r--r--drivers/xen/evtchn.c4
-rw-r--r--drivers/xen/swiotlb-xen.c8
-rw-r--r--drivers/xen/xenbus/xenbus_comms.h1
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c49
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/crypto/keyinfo.c3
-rw-r--r--fs/crypto/policy.c5
-rw-r--r--fs/notify/mark.c12
-rw-r--r--fs/xfs/libxfs/xfs_ag_resv.c3
-rw-r--r--fs/xfs/libxfs/xfs_refcount_btree.c9
-rw-r--r--fs/xfs/libxfs/xfs_refcount_btree.h3
-rw-r--r--fs/xfs/libxfs/xfs_rmap_btree.c14
-rw-r--r--fs/xfs/libxfs/xfs_rmap_btree.h3
-rw-r--r--fs/xfs/xfs_fsops.c14
-rw-r--r--fs/xfs/xfs_icache.c3
-rw-r--r--fs/xfs/xfs_refcount_item.c3
-rw-r--r--fs/xfs/xfs_sysfs.c4
-rw-r--r--include/asm-generic/asm-prototypes.h6
-rw-r--r--include/dt-bindings/mfd/tps65217.h26
-rw-r--r--include/linux/fsnotify_backend.h2
-rw-r--r--include/linux/genhd.h9
-rw-r--r--include/linux/iio/common/st_sensors.h12
-rw-r--r--include/linux/mdev.h56
-rw-r--r--include/linux/mlx4/device.h2
-rw-r--r--include/linux/mlx5/device.h5
-rw-r--r--include/linux/mlx5/driver.h1
-rw-r--r--include/linux/mlx5/mlx5_ifc.h93
-rw-r--r--include/linux/radix-tree.h4
-rw-r--r--include/linux/swiotlb.h11
-rw-r--r--include/sound/hdmi-codec.h8
-rw-r--r--include/sound/soc.h3
-rw-r--r--include/trace/events/swiotlb.h17
-rw-r--r--include/uapi/linux/usb/functionfs.h1
-rw-r--r--kernel/audit_tree.c18
-rw-r--r--lib/radix-tree.c11
-rw-r--r--lib/swiotlb.c52
-rw-r--r--mm/memory.c47
-rw-r--r--mm/workingset.c3
-rw-r--r--net/atm/lec.c2
-rw-r--r--net/core/drop_monitor.c39
-rw-r--r--net/core/flow_dissector.c5
-rw-r--r--net/core/rtnetlink.c6
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/igmp.c7
-rw-r--r--net/ipv4/ip_sockglue.c8
-rw-r--r--net/ipv4/route.c3
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/l2tp/l2tp_ip.c19
-rw-r--r--net/l2tp/l2tp_ip6.c24
-rw-r--r--net/mac80211/tx.c3
-rw-r--r--net/sched/cls_flower.c4
-rw-r--r--net/socket.c2
-rw-r--r--samples/Kconfig7
-rw-r--r--samples/Makefile3
-rw-r--r--samples/vfio-mdev/Makefile14
-rw-r--r--samples/vfio-mdev/mtty.c32
-rw-r--r--scripts/gcc-plugins/gcc-common.h85
-rw-r--r--scripts/gcc-plugins/latent_entropy_plugin.c4
-rw-r--r--sound/soc/codecs/nau8825.c9
-rw-r--r--sound/soc/codecs/nau8825.h7
-rw-r--r--sound/soc/codecs/rt5645.c3
-rw-r--r--sound/soc/codecs/tlv320aic3x.c13
-rw-r--r--sound/soc/codecs/wm_adsp.c25
-rw-r--r--sound/soc/dwc/designware_i2s.c25
-rw-r--r--sound/soc/fsl/fsl_ssi.c74
-rw-r--r--sound/soc/intel/boards/bytcr_rt5640.c18
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c3
-rw-r--r--sound/soc/intel/skylake/skl-sst.c3
-rw-r--r--sound/soc/sh/rcar/core.c4
-rw-r--r--sound/soc/soc-core.c10
-rw-r--r--sound/soc/soc-pcm.c4
-rw-r--r--sound/soc/soc-topology.c3
-rw-r--r--usr/Makefile16
299 files changed, 2614 insertions, 1718 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 21e2d8863705..be7c0d9506b1 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -106,6 +106,16 @@
106 use by PCI 106 use by PCI
107 Format: <irq>,<irq>... 107 Format: <irq>,<irq>...
108 108
109 acpi_mask_gpe= [HW,ACPI]
110 Due to the existence of _Lxx/_Exx, some GPEs triggered
111 by unsupported hardware/firmware features can result in
112 GPE floodings that cannot be automatically disabled by
113 the GPE dispatcher.
114 This facility can be used to prevent such uncontrolled
115 GPE floodings.
116 Format: <int>
117 Support masking of GPEs numbered from 0x00 to 0x7f.
118
109 acpi_no_auto_serialize [HW,ACPI] 119 acpi_no_auto_serialize [HW,ACPI]
110 Disable auto-serialization of AML methods 120 Disable auto-serialization of AML methods
111 AML control methods that contain the opcodes to create 121 AML control methods that contain the opcodes to create
@@ -3811,10 +3821,11 @@
3811 it if 0 is given (See Documentation/cgroup-v1/memory.txt) 3821 it if 0 is given (See Documentation/cgroup-v1/memory.txt)
3812 3822
3813 swiotlb= [ARM,IA-64,PPC,MIPS,X86] 3823 swiotlb= [ARM,IA-64,PPC,MIPS,X86]
3814 Format: { <int> | force } 3824 Format: { <int> | force | noforce }
3815 <int> -- Number of I/O TLB slabs 3825 <int> -- Number of I/O TLB slabs
3816 force -- force using of bounce buffers even if they 3826 force -- force using of bounce buffers even if they
3817 wouldn't be automatically used by the kernel 3827 wouldn't be automatically used by the kernel
3828 noforce -- Never use bounce buffers (for debugging)
3818 3829
3819 switches= [HW,M68k] 3830 switches= [HW,M68k]
3820 3831
diff --git a/Documentation/block/queue-sysfs.txt b/Documentation/block/queue-sysfs.txt
index 51642159aedb..c0a3bb5a6e4e 100644
--- a/Documentation/block/queue-sysfs.txt
+++ b/Documentation/block/queue-sysfs.txt
@@ -54,9 +54,9 @@ This is the hardware sector size of the device, in bytes.
54 54
55io_poll (RW) 55io_poll (RW)
56------------ 56------------
57When read, this file shows the total number of block IO polls and how 57When read, this file shows whether polling is enabled (1) or disabled
58many returned success. Writing '0' to this file will disable polling 58(0). Writing '0' to this file will disable polling for this device.
59for this device. Writing any non-zero value will enable this feature. 59Writing any non-zero value will enable this feature.
60 60
61io_poll_delay (RW) 61io_poll_delay (RW)
62------------------ 62------------------
diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
index 3e5b9793341f..8682ab6d4a50 100644
--- a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
@@ -8,8 +8,9 @@ This driver provides a simple power button event via an Interrupt.
8Required properties: 8Required properties:
9- compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton" 9- compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton"
10 10
11Required properties for TPS65218: 11Required properties:
12- interrupts: should be one of the following 12- interrupts: should be one of the following
13 - <2>: For controllers compatible with tps65217
13 - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218 14 - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218
14 15
15Examples: 16Examples:
@@ -17,6 +18,7 @@ Examples:
17&tps { 18&tps {
18 tps65217-pwrbutton { 19 tps65217-pwrbutton {
19 compatible = "ti,tps65217-pwrbutton"; 20 compatible = "ti,tps65217-pwrbutton";
21 interrupts = <2>;
20 }; 22 };
21}; 23};
22 24
diff --git a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
index 98d131acee95..a11072c5a866 100644
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
@@ -2,11 +2,16 @@ TPS65217 Charger
2 2
3Required Properties: 3Required Properties:
4-compatible: "ti,tps65217-charger" 4-compatible: "ti,tps65217-charger"
5-interrupts: TPS65217 interrupt numbers for the AC and USB charger input change.
6 Should be <0> for the USB charger and <1> for the AC adapter.
7-interrupt-names: Should be "USB" and "AC"
5 8
6This node is a subnode of the tps65217 PMIC. 9This node is a subnode of the tps65217 PMIC.
7 10
8Example: 11Example:
9 12
10 tps65217-charger { 13 tps65217-charger {
11 compatible = "ti,tps65090-charger"; 14 compatible = "ti,tps65217-charger";
15 interrupts = <0>, <1>;
16 interrupt-names = "USB", "AC";
12 }; 17 };
diff --git a/Documentation/driver-api/infrastructure.rst b/Documentation/driver-api/infrastructure.rst
index 0bb0b5fc9512..6d9ff316b608 100644
--- a/Documentation/driver-api/infrastructure.rst
+++ b/Documentation/driver-api/infrastructure.rst
@@ -55,21 +55,6 @@ Device Drivers DMA Management
55.. kernel-doc:: drivers/base/dma-mapping.c 55.. kernel-doc:: drivers/base/dma-mapping.c
56 :export: 56 :export:
57 57
58Device Drivers Power Management
59-------------------------------
60
61.. kernel-doc:: drivers/base/power/main.c
62 :export:
63
64Device Drivers ACPI Support
65---------------------------
66
67.. kernel-doc:: drivers/acpi/scan.c
68 :export:
69
70.. kernel-doc:: drivers/acpi/scan.c
71 :internal:
72
73Device drivers PnP support 58Device drivers PnP support
74-------------------------- 59--------------------------
75 60
diff --git a/Documentation/networking/mpls-sysctl.txt b/Documentation/networking/mpls-sysctl.txt
index 9ed15f86c17c..15d8d16934fd 100644
--- a/Documentation/networking/mpls-sysctl.txt
+++ b/Documentation/networking/mpls-sysctl.txt
@@ -5,8 +5,8 @@ platform_labels - INTEGER
5 possible to configure forwarding for label values equal to or 5 possible to configure forwarding for label values equal to or
6 greater than the number of platform labels. 6 greater than the number of platform labels.
7 7
8 A dense utliziation of the entries in the platform label table 8 A dense utilization of the entries in the platform label table
9 is possible and expected aas the platform labels are locally 9 is possible and expected as the platform labels are locally
10 allocated. 10 allocated.
11 11
12 If the number of platform label table entries is set to 0 no 12 If the number of platform label table entries is set to 0 no
diff --git a/Documentation/vfio-mediated-device.txt b/Documentation/vfio-mediated-device.txt
index b38afec35edc..d226c7a5ba8b 100644
--- a/Documentation/vfio-mediated-device.txt
+++ b/Documentation/vfio-mediated-device.txt
@@ -127,22 +127,22 @@ the VFIO when devices are unbound from the driver.
127Physical Device Driver Interface 127Physical Device Driver Interface
128-------------------------------- 128--------------------------------
129 129
130The physical device driver interface provides the parent_ops[3] structure to 130The physical device driver interface provides the mdev_parent_ops[3] structure
131define the APIs to manage work in the mediated core driver that is related to 131to define the APIs to manage work in the mediated core driver that is related
132the physical device. 132to the physical device.
133 133
134The structures in the parent_ops structure are as follows: 134The structures in the mdev_parent_ops structure are as follows:
135 135
136* dev_attr_groups: attributes of the parent device 136* dev_attr_groups: attributes of the parent device
137* mdev_attr_groups: attributes of the mediated device 137* mdev_attr_groups: attributes of the mediated device
138* supported_config: attributes to define supported configurations 138* supported_config: attributes to define supported configurations
139 139
140The functions in the parent_ops structure are as follows: 140The functions in the mdev_parent_ops structure are as follows:
141 141
142* create: allocate basic resources in a driver for a mediated device 142* create: allocate basic resources in a driver for a mediated device
143* remove: free resources in a driver when a mediated device is destroyed 143* remove: free resources in a driver when a mediated device is destroyed
144 144
145The callbacks in the parent_ops structure are as follows: 145The callbacks in the mdev_parent_ops structure are as follows:
146 146
147* open: open callback of mediated device 147* open: open callback of mediated device
148* close: close callback of mediated device 148* close: close callback of mediated device
@@ -151,14 +151,14 @@ The callbacks in the parent_ops structure are as follows:
151* write: write emulation callback 151* write: write emulation callback
152* mmap: mmap emulation callback 152* mmap: mmap emulation callback
153 153
154A driver should use the parent_ops structure in the function call to register 154A driver should use the mdev_parent_ops structure in the function call to
155itself with the mdev core driver: 155register itself with the mdev core driver:
156 156
157extern int mdev_register_device(struct device *dev, 157extern int mdev_register_device(struct device *dev,
158 const struct parent_ops *ops); 158 const struct mdev_parent_ops *ops);
159 159
160However, the parent_ops structure is not required in the function call that a 160However, the mdev_parent_ops structure is not required in the function call
161driver should use to unregister itself with the mdev core driver: 161that a driver should use to unregister itself with the mdev core driver:
162 162
163extern void mdev_unregister_device(struct device *dev); 163extern void mdev_unregister_device(struct device *dev);
164 164
@@ -223,6 +223,9 @@ Directories and files under the sysfs for Each Physical Device
223 223
224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name); 224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name);
225 225
226 (or using mdev_parent_dev(mdev) to arrive at the parent device outside
227 of the core mdev code)
228
226* device_api 229* device_api
227 230
228 This attribute should show which device API is being created, for example, 231 This attribute should show which device API is being created, for example,
@@ -394,5 +397,5 @@ References
394 397
395[1] See Documentation/vfio.txt for more information on VFIO. 398[1] See Documentation/vfio.txt for more information on VFIO.
396[2] struct mdev_driver in include/linux/mdev.h 399[2] struct mdev_driver in include/linux/mdev.h
397[3] struct parent_ops in include/linux/mdev.h 400[3] struct mdev_parent_ops in include/linux/mdev.h
398[4] struct vfio_iommu_driver_ops in include/linux/vfio.h 401[4] struct vfio_iommu_driver_ops in include/linux/vfio.h
diff --git a/MAINTAINERS b/MAINTAINERS
index cfff2c9e3d94..5f0420a0da5b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3800,6 +3800,7 @@ F: include/linux/devcoredump.h
3800DEVICE FREQUENCY (DEVFREQ) 3800DEVICE FREQUENCY (DEVFREQ)
3801M: MyungJoo Ham <myungjoo.ham@samsung.com> 3801M: MyungJoo Ham <myungjoo.ham@samsung.com>
3802M: Kyungmin Park <kyungmin.park@samsung.com> 3802M: Kyungmin Park <kyungmin.park@samsung.com>
3803R: Chanwoo Choi <cw00.choi@samsung.com>
3803L: linux-pm@vger.kernel.org 3804L: linux-pm@vger.kernel.org
3804T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git 3805T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git
3805S: Maintained 3806S: Maintained
@@ -5080,9 +5081,11 @@ F: drivers/net/wan/dlci.c
5080F: drivers/net/wan/sdla.c 5081F: drivers/net/wan/sdla.c
5081 5082
5082FRAMEBUFFER LAYER 5083FRAMEBUFFER LAYER
5084M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
5083L: linux-fbdev@vger.kernel.org 5085L: linux-fbdev@vger.kernel.org
5086T: git git://github.com/bzolnier/linux.git
5084Q: http://patchwork.kernel.org/project/linux-fbdev/list/ 5087Q: http://patchwork.kernel.org/project/linux-fbdev/list/
5085S: Orphan 5088S: Maintained
5086F: Documentation/fb/ 5089F: Documentation/fb/
5087F: drivers/video/ 5090F: drivers/video/
5088F: include/video/ 5091F: include/video/
@@ -5504,6 +5507,7 @@ M: Alex Elder <elder@kernel.org>
5504M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 5507M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5505S: Maintained 5508S: Maintained
5506F: drivers/staging/greybus/ 5509F: drivers/staging/greybus/
5510L: greybus-dev@lists.linaro.org
5507 5511
5508GREYBUS AUDIO PROTOCOLS DRIVERS 5512GREYBUS AUDIO PROTOCOLS DRIVERS
5509M: Vaibhav Agarwal <vaibhav.sr@gmail.com> 5513M: Vaibhav Agarwal <vaibhav.sr@gmail.com>
@@ -5961,6 +5965,7 @@ F: drivers/media/platform/sti/hva
5961Hyper-V CORE AND DRIVERS 5965Hyper-V CORE AND DRIVERS
5962M: "K. Y. Srinivasan" <kys@microsoft.com> 5966M: "K. Y. Srinivasan" <kys@microsoft.com>
5963M: Haiyang Zhang <haiyangz@microsoft.com> 5967M: Haiyang Zhang <haiyangz@microsoft.com>
5968M: Stephen Hemminger <sthemmin@microsoft.com>
5964L: devel@linuxdriverproject.org 5969L: devel@linuxdriverproject.org
5965S: Maintained 5970S: Maintained
5966F: arch/x86/include/asm/mshyperv.h 5971F: arch/x86/include/asm/mshyperv.h
@@ -8852,17 +8857,22 @@ F: drivers/video/fbdev/nvidia/
8852NVM EXPRESS DRIVER 8857NVM EXPRESS DRIVER
8853M: Keith Busch <keith.busch@intel.com> 8858M: Keith Busch <keith.busch@intel.com>
8854M: Jens Axboe <axboe@fb.com> 8859M: Jens Axboe <axboe@fb.com>
8860M: Christoph Hellwig <hch@lst.de>
8861M: Sagi Grimberg <sagi@grimberg.me>
8855L: linux-nvme@lists.infradead.org 8862L: linux-nvme@lists.infradead.org
8856T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 8863T: git://git.infradead.org/nvme.git
8857W: https://kernel.googlesource.com/pub/scm/linux/kernel/git/axboe/linux-block/ 8864W: http://git.infradead.org/nvme.git
8858S: Supported 8865S: Supported
8859F: drivers/nvme/host/ 8866F: drivers/nvme/host/
8860F: include/linux/nvme.h 8867F: include/linux/nvme.h
8868F: include/uapi/linux/nvme_ioctl.h
8861 8869
8862NVM EXPRESS TARGET DRIVER 8870NVM EXPRESS TARGET DRIVER
8863M: Christoph Hellwig <hch@lst.de> 8871M: Christoph Hellwig <hch@lst.de>
8864M: Sagi Grimberg <sagi@grimberg.me> 8872M: Sagi Grimberg <sagi@grimberg.me>
8865L: linux-nvme@lists.infradead.org 8873L: linux-nvme@lists.infradead.org
8874T: git://git.infradead.org/nvme.git
8875W: http://git.infradead.org/nvme.git
8866S: Supported 8876S: Supported
8867F: drivers/nvme/target/ 8877F: drivers/nvme/target/
8868 8878
@@ -9842,7 +9852,7 @@ M: Mark Rutland <mark.rutland@arm.com>
9842M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 9852M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
9843L: linux-arm-kernel@lists.infradead.org 9853L: linux-arm-kernel@lists.infradead.org
9844S: Maintained 9854S: Maintained
9845F: drivers/firmware/psci.c 9855F: drivers/firmware/psci*.c
9846F: include/linux/psci.h 9856F: include/linux/psci.h
9847F: include/uapi/linux/psci.h 9857F: include/uapi/linux/psci.h
9848 9858
@@ -13527,11 +13537,11 @@ F: arch/x86/xen/*swiotlb*
13527F: drivers/xen/*swiotlb* 13537F: drivers/xen/*swiotlb*
13528 13538
13529XFS FILESYSTEM 13539XFS FILESYSTEM
13530M: Dave Chinner <david@fromorbit.com> 13540M: Darrick J. Wong <darrick.wong@oracle.com>
13531M: linux-xfs@vger.kernel.org 13541M: linux-xfs@vger.kernel.org
13532L: linux-xfs@vger.kernel.org 13542L: linux-xfs@vger.kernel.org
13533W: http://xfs.org/ 13543W: http://xfs.org/
13534T: git git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git 13544T: git git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git
13535S: Supported 13545S: Supported
13536F: Documentation/filesystems/xfs.txt 13546F: Documentation/filesystems/xfs.txt
13537F: fs/xfs/ 13547F: fs/xfs/
diff --git a/Makefile b/Makefile
index 5470d599384a..5f1a84735ff6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 10 2PATCHLEVEL = 10
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc3
5NAME = Roaring Lionus 5NAME = Roaring Lionus
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5fab553fd03a..186c4c214e0a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1502,8 +1502,7 @@ source kernel/Kconfig.preempt
1502 1502
1503config HZ_FIXED 1503config HZ_FIXED
1504 int 1504 int
1505 default 200 if ARCH_EBSA110 || ARCH_S3C24XX || \ 1505 default 200 if ARCH_EBSA110
1506 ARCH_S5PV210 || ARCH_EXYNOS4
1507 default 128 if SOC_AT91RM9200 1506 default 128 if SOC_AT91RM9200
1508 default 0 1507 default 0
1509 1508
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..7327250f0bb6 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -501,6 +501,7 @@ dtb-$(CONFIG_ARCH_OMAP3) += \
501 am3517-evm.dtb \ 501 am3517-evm.dtb \
502 am3517_mt_ventoux.dtb \ 502 am3517_mt_ventoux.dtb \
503 logicpd-torpedo-37xx-devkit.dtb \ 503 logicpd-torpedo-37xx-devkit.dtb \
504 logicpd-som-lv-37xx-devkit.dtb \
504 omap3430-sdp.dtb \ 505 omap3430-sdp.dtb \
505 omap3-beagle.dtb \ 506 omap3-beagle.dtb \
506 omap3-beagle-xm.dtb \ 507 omap3-beagle-xm.dtb \
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index dc561d505bbe..3e32dd18fd25 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -6,8 +6,6 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <dt-bindings/mfd/tps65217.h>
10
11/ { 9/ {
12 cpus { 10 cpus {
13 cpu@0 { 11 cpu@0 {
@@ -319,13 +317,13 @@
319 ti,pmic-shutdown-controller; 317 ti,pmic-shutdown-controller;
320 318
321 charger { 319 charger {
322 interrupts = <TPS65217_IRQ_AC>, <TPS65217_IRQ_USB>; 320 interrupts = <0>, <1>;
323 interrupts-names = "AC", "USB"; 321 interrupt-names = "USB", "AC";
324 status = "okay"; 322 status = "okay";
325 }; 323 };
326 324
327 pwrbutton { 325 pwrbutton {
328 interrupts = <TPS65217_IRQ_PB>; 326 interrupts = <2>;
329 status = "okay"; 327 status = "okay";
330 }; 328 };
331 329
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 64c8aa9057a3..18d72a245e88 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -16,6 +16,7 @@
16 interrupt-parent = <&intc>; 16 interrupt-parent = <&intc>;
17 #address-cells = <1>; 17 #address-cells = <1>;
18 #size-cells = <1>; 18 #size-cells = <1>;
19 chosen { };
19 20
20 aliases { 21 aliases {
21 i2c0 = &i2c0; 22 i2c0 = &i2c0;
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index ac55f93fc91e..2df9e6050c2f 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -16,6 +16,7 @@
16 interrupt-parent = <&wakeupgen>; 16 interrupt-parent = <&wakeupgen>;
17 #address-cells = <1>; 17 #address-cells = <1>;
18 #size-cells = <1>; 18 #size-cells = <1>;
19 chosen { };
19 20
20 memory@0 { 21 memory@0 {
21 device_type = "memory"; 22 device_type = "memory";
diff --git a/arch/arm/boot/dts/am571x-idk.dts b/arch/arm/boot/dts/am571x-idk.dts
index d6e43e5184c1..ad68d1eb3bc3 100644
--- a/arch/arm/boot/dts/am571x-idk.dts
+++ b/arch/arm/boot/dts/am571x-idk.dts
@@ -62,11 +62,6 @@
62 linux,default-trigger = "mmc0"; 62 linux,default-trigger = "mmc0";
63 }; 63 };
64 }; 64 };
65
66 extcon_usb2: extcon_usb2 {
67 compatible = "linux,extcon-usb-gpio";
68 id-gpio = <&gpio5 7 GPIO_ACTIVE_HIGH>;
69 };
70}; 65};
71 66
72&mmc1 { 67&mmc1 {
@@ -79,3 +74,8 @@
79&omap_dwc3_2 { 74&omap_dwc3_2 {
80 extcon = <&extcon_usb2>; 75 extcon = <&extcon_usb2>;
81}; 76};
77
78&extcon_usb2 {
79 id-gpio = <&gpio5 7 GPIO_ACTIVE_HIGH>;
80 vbus-gpio = <&gpio7 22 GPIO_ACTIVE_HIGH>;
81};
diff --git a/arch/arm/boot/dts/am572x-idk.dts b/arch/arm/boot/dts/am572x-idk.dts
index 27d9149cedba..8350b4b34b08 100644
--- a/arch/arm/boot/dts/am572x-idk.dts
+++ b/arch/arm/boot/dts/am572x-idk.dts
@@ -23,11 +23,6 @@
23 reg = <0x0 0x80000000 0x0 0x80000000>; 23 reg = <0x0 0x80000000 0x0 0x80000000>;
24 }; 24 };
25 25
26 extcon_usb2: extcon_usb2 {
27 compatible = "linux,extcon-usb-gpio";
28 id-gpio = <&gpio3 16 GPIO_ACTIVE_HIGH>;
29 };
30
31 status-leds { 26 status-leds {
32 compatible = "gpio-leds"; 27 compatible = "gpio-leds";
33 cpu0-led { 28 cpu0-led {
@@ -76,6 +71,11 @@
76 extcon = <&extcon_usb2>; 71 extcon = <&extcon_usb2>;
77}; 72};
78 73
74&extcon_usb2 {
75 id-gpio = <&gpio3 16 GPIO_ACTIVE_HIGH>;
76 vbus-gpio = <&gpio3 26 GPIO_ACTIVE_HIGH>;
77};
78
79&mmc1 { 79&mmc1 {
80 status = "okay"; 80 status = "okay";
81 vmmc-supply = <&v3_3d>; 81 vmmc-supply = <&v3_3d>;
@@ -87,3 +87,7 @@
87&sn65hvs882 { 87&sn65hvs882 {
88 load-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>; 88 load-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
89}; 89};
90
91&pcie1 {
92 gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
93};
diff --git a/arch/arm/boot/dts/am57xx-idk-common.dtsi b/arch/arm/boot/dts/am57xx-idk-common.dtsi
index 555ae21f2b9a..814a720d5c3d 100644
--- a/arch/arm/boot/dts/am57xx-idk-common.dtsi
+++ b/arch/arm/boot/dts/am57xx-idk-common.dtsi
@@ -303,6 +303,13 @@
303 gpio-controller; 303 gpio-controller;
304 #gpio-cells = <2>; 304 #gpio-cells = <2>;
305 }; 305 };
306
307 extcon_usb2: tps659038_usb {
308 compatible = "ti,palmas-usb-vid";
309 ti,enable-vbus-detection;
310 ti,enable-id-detection;
311 /* ID & VBUS GPIOs provided in board dts */
312 };
306 }; 313 };
307}; 314};
308 315
@@ -369,7 +376,7 @@
369}; 376};
370 377
371&usb2 { 378&usb2 {
372 dr_mode = "otg"; 379 dr_mode = "peripheral";
373}; 380};
374 381
375&mmc2 { 382&mmc2 {
diff --git a/arch/arm/boot/dts/dm814x.dtsi b/arch/arm/boot/dts/dm814x.dtsi
index 1facc5f12cef..81b8cecb5820 100644
--- a/arch/arm/boot/dts/dm814x.dtsi
+++ b/arch/arm/boot/dts/dm814x.dtsi
@@ -12,6 +12,7 @@
12 interrupt-parent = <&intc>; 12 interrupt-parent = <&intc>;
13 #address-cells = <1>; 13 #address-cells = <1>;
14 #size-cells = <1>; 14 #size-cells = <1>;
15 chosen { };
15 16
16 aliases { 17 aliases {
17 i2c0 = &i2c1; 18 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 61dd2f6b02bc..6db652ae9bd5 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -12,6 +12,7 @@
12 interrupt-parent = <&intc>; 12 interrupt-parent = <&intc>;
13 #address-cells = <1>; 13 #address-cells = <1>;
14 #size-cells = <1>; 14 #size-cells = <1>;
15 chosen { };
15 16
16 aliases { 17 aliases {
17 i2c0 = &i2c1; 18 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index addb7530cfbe..1faf24acd521 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -18,6 +18,7 @@
18 18
19 compatible = "ti,dra7xx"; 19 compatible = "ti,dra7xx";
20 interrupt-parent = <&crossbar_mpu>; 20 interrupt-parent = <&crossbar_mpu>;
21 chosen { };
21 22
22 aliases { 23 aliases {
23 i2c0 = &i2c1; 24 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/dra72-evm-tps65917.dtsi b/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
index ee6dac44edf1..e6df676886c0 100644
--- a/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
+++ b/arch/arm/boot/dts/dra72-evm-tps65917.dtsi
@@ -132,3 +132,19 @@
132 ti,palmas-long-press-seconds = <6>; 132 ti,palmas-long-press-seconds = <6>;
133 }; 133 };
134}; 134};
135
136&usb2_phy1 {
137 phy-supply = <&ldo4_reg>;
138};
139
140&usb2_phy2 {
141 phy-supply = <&ldo4_reg>;
142};
143
144&dss {
145 vdda_video-supply = <&ldo5_reg>;
146};
147
148&mmc1 {
149 vmmc_aux-supply = <&ldo1_reg>;
150};
diff --git a/arch/arm/boot/dts/imx31.dtsi b/arch/arm/boot/dts/imx31.dtsi
index 685916e3d8a1..85cd8be22f71 100644
--- a/arch/arm/boot/dts/imx31.dtsi
+++ b/arch/arm/boot/dts/imx31.dtsi
@@ -31,11 +31,11 @@
31 }; 31 };
32 }; 32 };
33 33
34 avic: avic-interrupt-controller@60000000 { 34 avic: interrupt-controller@68000000 {
35 compatible = "fsl,imx31-avic", "fsl,avic"; 35 compatible = "fsl,imx31-avic", "fsl,avic";
36 interrupt-controller; 36 interrupt-controller;
37 #interrupt-cells = <1>; 37 #interrupt-cells = <1>;
38 reg = <0x60000000 0x100000>; 38 reg = <0x68000000 0x100000>;
39 }; 39 };
40 40
41 soc { 41 soc {
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
index e476d01959ea..26d060484728 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi
@@ -533,7 +533,6 @@
533 MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17071 533 MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17071
534 MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17071 534 MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17071
535 MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17071 535 MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17071
536 MX6QDL_PAD_NANDF_CS2__GPIO6_IO15 0x000b0
537 >; 536 >;
538 }; 537 };
539 538
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 53e6e63cbb02..89b834f3fa17 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1100,6 +1100,7 @@
1100 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>; 1100 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>;
1101 clocks = <&clks IMX6QDL_CLK_EIM_SLOW>; 1101 clocks = <&clks IMX6QDL_CLK_EIM_SLOW>;
1102 fsl,weim-cs-gpr = <&gpr>; 1102 fsl,weim-cs-gpr = <&gpr>;
1103 status = "disabled";
1103 }; 1104 };
1104 1105
1105 ocotp: ocotp@021bc000 { 1106 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi
index 4fd6de29f07d..19cbd879c448 100644
--- a/arch/arm/boot/dts/imx6sl.dtsi
+++ b/arch/arm/boot/dts/imx6sl.dtsi
@@ -900,6 +900,7 @@
900 reg = <0x021b8000 0x4000>; 900 reg = <0x021b8000 0x4000>;
901 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>; 901 interrupts = <0 14 IRQ_TYPE_LEVEL_HIGH>;
902 fsl,weim-cs-gpr = <&gpr>; 902 fsl,weim-cs-gpr = <&gpr>;
903 status = "disabled";
903 }; 904 };
904 905
905 ocotp: ocotp@021bc000 { 906 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/imx6sx.dtsi b/arch/arm/boot/dts/imx6sx.dtsi
index 076a30f9bcae..10f333016197 100644
--- a/arch/arm/boot/dts/imx6sx.dtsi
+++ b/arch/arm/boot/dts/imx6sx.dtsi
@@ -977,6 +977,7 @@
977 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; 977 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
978 clocks = <&clks IMX6SX_CLK_EIM_SLOW>; 978 clocks = <&clks IMX6SX_CLK_EIM_SLOW>;
979 fsl,weim-cs-gpr = <&gpr>; 979 fsl,weim-cs-gpr = <&gpr>;
980 status = "disabled";
980 }; 981 };
981 982
982 ocotp: ocotp@021bc000 { 983 ocotp: ocotp@021bc000 {
diff --git a/arch/arm/boot/dts/omap2.dtsi b/arch/arm/boot/dts/omap2.dtsi
index 4f793a025a72..f1d6de8b3c19 100644
--- a/arch/arm/boot/dts/omap2.dtsi
+++ b/arch/arm/boot/dts/omap2.dtsi
@@ -17,6 +17,7 @@
17 interrupt-parent = <&intc>; 17 interrupt-parent = <&intc>;
18 #address-cells = <1>; 18 #address-cells = <1>;
19 #size-cells = <1>; 19 #size-cells = <1>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 serial0 = &uart1; 23 serial0 = &uart1;
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 87ca50b53002..4d448f145ed1 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -734,6 +734,8 @@
734 vmmc_aux-supply = <&vsim>; 734 vmmc_aux-supply = <&vsim>;
735 bus-width = <8>; 735 bus-width = <8>;
736 non-removable; 736 non-removable;
737 no-sdio;
738 no-sd;
737}; 739};
738 740
739&mmc3 { 741&mmc3 {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index ecf5eb584c75..a3ff4933dbc1 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -17,6 +17,7 @@
17 interrupt-parent = <&intc>; 17 interrupt-parent = <&intc>;
18 #address-cells = <1>; 18 #address-cells = <1>;
19 #size-cells = <1>; 19 #size-cells = <1>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 i2c0 = &i2c1; 23 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 8087456b5fbe..578c53f08309 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -15,6 +15,7 @@
15 interrupt-parent = <&wakeupgen>; 15 interrupt-parent = <&wakeupgen>;
16 #address-cells = <1>; 16 #address-cells = <1>;
17 #size-cells = <1>; 17 #size-cells = <1>;
18 chosen { };
18 19
19 aliases { 20 aliases {
20 i2c0 = &i2c1; 21 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 968c67a49dbd..7cd92babc41a 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -17,6 +17,7 @@
17 17
18 compatible = "ti,omap5"; 18 compatible = "ti,omap5";
19 interrupt-parent = <&wakeupgen>; 19 interrupt-parent = <&wakeupgen>;
20 chosen { };
20 21
21 aliases { 22 aliases {
22 i2c0 = &i2c1; 23 i2c0 = &i2c1;
diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
index 268bd470c865..407a4610f4a7 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -4,6 +4,7 @@
4#include <dt-bindings/clock/qcom,gcc-msm8960.h> 4#include <dt-bindings/clock/qcom,gcc-msm8960.h>
5#include <dt-bindings/reset/qcom,gcc-msm8960.h> 5#include <dt-bindings/reset/qcom,gcc-msm8960.h>
6#include <dt-bindings/clock/qcom,mmcc-msm8960.h> 6#include <dt-bindings/clock/qcom,mmcc-msm8960.h>
7#include <dt-bindings/clock/qcom,rpmcc.h>
7#include <dt-bindings/soc/qcom,gsbi.h> 8#include <dt-bindings/soc/qcom,gsbi.h>
8#include <dt-bindings/interrupt-controller/irq.h> 9#include <dt-bindings/interrupt-controller/irq.h>
9#include <dt-bindings/interrupt-controller/arm-gic.h> 10#include <dt-bindings/interrupt-controller/arm-gic.h>
@@ -303,6 +304,9 @@
303 firmware { 304 firmware {
304 scm { 305 scm {
305 compatible = "qcom,scm-apq8064"; 306 compatible = "qcom,scm-apq8064";
307
308 clocks = <&rpmcc RPM_DAYTONA_FABRIC_CLK>;
309 clock-names = "core";
306 }; 310 };
307 }; 311 };
308 312
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
index 102838fcc588..15f4fd3f4695 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
@@ -81,7 +81,7 @@
81 #address-cells = <0>; 81 #address-cells = <0>;
82 interrupt-controller; 82 interrupt-controller;
83 reg = <0 0x2c001000 0 0x1000>, 83 reg = <0 0x2c001000 0 0x1000>,
84 <0 0x2c002000 0 0x1000>, 84 <0 0x2c002000 0 0x2000>,
85 <0 0x2c004000 0 0x2000>, 85 <0 0x2c004000 0 0x2000>,
86 <0 0x2c006000 0 0x2000>; 86 <0 0x2c006000 0 0x2000>;
87 interrupts = <1 9 0xf04>; 87 interrupts = <1 9 0xf04>;
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
index 45d08cc37b01..bd107c5a0226 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
@@ -131,7 +131,7 @@
131 #address-cells = <0>; 131 #address-cells = <0>;
132 interrupt-controller; 132 interrupt-controller;
133 reg = <0 0x2c001000 0 0x1000>, 133 reg = <0 0x2c001000 0 0x1000>,
134 <0 0x2c002000 0 0x1000>, 134 <0 0x2c002000 0 0x2000>,
135 <0 0x2c004000 0 0x2000>, 135 <0 0x2c004000 0 0x2000>,
136 <0 0x2c006000 0 0x2000>; 136 <0 0x2c006000 0 0x2000>;
137 interrupts = <1 9 0xf04>; 137 interrupts = <1 9 0xf04>;
diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 7ea617e47fe4..958b4c42d320 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -153,7 +153,8 @@
153 switch0phy1: switch1phy0@1 { 153 switch0phy1: switch1phy0@1 {
154 reg = <1>; 154 reg = <1>;
155 interrupt-parent = <&switch0>; 155 interrupt-parent = <&switch0>;
156 interrupts = <1 IRQ_TYPE_LEVEL_HIGH>; }; 156 interrupts = <1 IRQ_TYPE_LEVEL_HIGH>;
157 };
157 switch0phy2: switch1phy0@2 { 158 switch0phy2: switch1phy0@2 {
158 reg = <2>; 159 reg = <2>;
159 interrupt-parent = <&switch0>; 160 interrupt-parent = <&switch0>;
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index df42c93a93d6..f5dce9b4e617 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,10 +31,10 @@ static LIST_HEAD(clocks);
31static DEFINE_MUTEX(clocks_mutex); 31static DEFINE_MUTEX(clocks_mutex);
32static DEFINE_SPINLOCK(clockfw_lock); 32static DEFINE_SPINLOCK(clockfw_lock);
33 33
34static void __clk_enable(struct clk *clk) 34void davinci_clk_enable(struct clk *clk)
35{ 35{
36 if (clk->parent) 36 if (clk->parent)
37 __clk_enable(clk->parent); 37 davinci_clk_enable(clk->parent);
38 if (clk->usecount++ == 0) { 38 if (clk->usecount++ == 0) {
39 if (clk->flags & CLK_PSC) 39 if (clk->flags & CLK_PSC)
40 davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, 40 davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
@@ -44,7 +44,7 @@ static void __clk_enable(struct clk *clk)
44 } 44 }
45} 45}
46 46
47static void __clk_disable(struct clk *clk) 47void davinci_clk_disable(struct clk *clk)
48{ 48{
49 if (WARN_ON(clk->usecount == 0)) 49 if (WARN_ON(clk->usecount == 0))
50 return; 50 return;
@@ -56,7 +56,7 @@ static void __clk_disable(struct clk *clk)
56 clk->clk_disable(clk); 56 clk->clk_disable(clk);
57 } 57 }
58 if (clk->parent) 58 if (clk->parent)
59 __clk_disable(clk->parent); 59 davinci_clk_disable(clk->parent);
60} 60}
61 61
62int davinci_clk_reset(struct clk *clk, bool reset) 62int davinci_clk_reset(struct clk *clk, bool reset)
@@ -103,7 +103,7 @@ int clk_enable(struct clk *clk)
103 return -EINVAL; 103 return -EINVAL;
104 104
105 spin_lock_irqsave(&clockfw_lock, flags); 105 spin_lock_irqsave(&clockfw_lock, flags);
106 __clk_enable(clk); 106 davinci_clk_enable(clk);
107 spin_unlock_irqrestore(&clockfw_lock, flags); 107 spin_unlock_irqrestore(&clockfw_lock, flags);
108 108
109 return 0; 109 return 0;
@@ -118,7 +118,7 @@ void clk_disable(struct clk *clk)
118 return; 118 return;
119 119
120 spin_lock_irqsave(&clockfw_lock, flags); 120 spin_lock_irqsave(&clockfw_lock, flags);
121 __clk_disable(clk); 121 davinci_clk_disable(clk);
122 spin_unlock_irqrestore(&clockfw_lock, flags); 122 spin_unlock_irqrestore(&clockfw_lock, flags);
123} 123}
124EXPORT_SYMBOL(clk_disable); 124EXPORT_SYMBOL(clk_disable);
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index e2a5437a1aee..fa2b83752e03 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -132,6 +132,8 @@ int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
132int davinci_set_refclk_rate(unsigned long rate); 132int davinci_set_refclk_rate(unsigned long rate);
133int davinci_simple_set_rate(struct clk *clk, unsigned long rate); 133int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
134int davinci_clk_reset(struct clk *clk, bool reset); 134int davinci_clk_reset(struct clk *clk, bool reset);
135void davinci_clk_enable(struct clk *clk);
136void davinci_clk_disable(struct clk *clk);
135 137
136extern struct platform_device davinci_wdt_device; 138extern struct platform_device davinci_wdt_device;
137extern void davinci_watchdog_reset(struct platform_device *); 139extern void davinci_watchdog_reset(struct platform_device *);
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index e770c97ea45c..1d873d15b545 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -319,6 +319,16 @@ static struct clk emac_clk = {
319 .gpsc = 1, 319 .gpsc = 1,
320}; 320};
321 321
322/*
323 * In order to avoid adding the emac_clk to the clock lookup table twice (and
324 * screwing up the linked list in the process) create a separate clock for
325 * mdio inheriting the rate from emac_clk.
326 */
327static struct clk mdio_clk = {
328 .name = "mdio",
329 .parent = &emac_clk,
330};
331
322static struct clk mcasp_clk = { 332static struct clk mcasp_clk = {
323 .name = "mcasp", 333 .name = "mcasp",
324 .parent = &async3_clk, 334 .parent = &async3_clk,
@@ -367,6 +377,16 @@ static struct clk aemif_clk = {
367 .flags = ALWAYS_ENABLED, 377 .flags = ALWAYS_ENABLED,
368}; 378};
369 379
380/*
381 * In order to avoid adding the aemif_clk to the clock lookup table twice (and
382 * screwing up the linked list in the process) create a separate clock for
383 * nand inheriting the rate from aemif_clk.
384 */
385static struct clk aemif_nand_clk = {
386 .name = "nand",
387 .parent = &aemif_clk,
388};
389
370static struct clk usb11_clk = { 390static struct clk usb11_clk = {
371 .name = "usb11", 391 .name = "usb11",
372 .parent = &pll0_sysclk4, 392 .parent = &pll0_sysclk4,
@@ -529,7 +549,7 @@ static struct clk_lookup da850_clks[] = {
529 CLK(NULL, "arm", &arm_clk), 549 CLK(NULL, "arm", &arm_clk),
530 CLK(NULL, "rmii", &rmii_clk), 550 CLK(NULL, "rmii", &rmii_clk),
531 CLK("davinci_emac.1", NULL, &emac_clk), 551 CLK("davinci_emac.1", NULL, &emac_clk),
532 CLK("davinci_mdio.0", "fck", &emac_clk), 552 CLK("davinci_mdio.0", "fck", &mdio_clk),
533 CLK("davinci-mcasp.0", NULL, &mcasp_clk), 553 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
534 CLK("davinci-mcbsp.0", NULL, &mcbsp0_clk), 554 CLK("davinci-mcbsp.0", NULL, &mcbsp0_clk),
535 CLK("davinci-mcbsp.1", NULL, &mcbsp1_clk), 555 CLK("davinci-mcbsp.1", NULL, &mcbsp1_clk),
@@ -537,7 +557,15 @@ static struct clk_lookup da850_clks[] = {
537 CLK("da830-mmc.0", NULL, &mmcsd0_clk), 557 CLK("da830-mmc.0", NULL, &mmcsd0_clk),
538 CLK("da830-mmc.1", NULL, &mmcsd1_clk), 558 CLK("da830-mmc.1", NULL, &mmcsd1_clk),
539 CLK("ti-aemif", NULL, &aemif_clk), 559 CLK("ti-aemif", NULL, &aemif_clk),
540 CLK(NULL, "aemif", &aemif_clk), 560 /*
561 * The only user of this clock is davinci_nand and it get's it through
562 * con_id. The nand node itself is created from within the aemif
563 * driver to guarantee that it's probed after the aemif timing
564 * parameters are configured. of_dev_auxdata is not accessible from
565 * the aemif driver and can't be passed to of_platform_populate(). For
566 * that reason we're leaving the dev_id here as NULL.
567 */
568 CLK(NULL, "aemif", &aemif_nand_clk),
541 CLK("ohci-da8xx", "usb11", &usb11_clk), 569 CLK("ohci-da8xx", "usb11", &usb11_clk),
542 CLK("musb-da8xx", "usb20", &usb20_clk), 570 CLK("musb-da8xx", "usb20", &usb20_clk),
543 CLK("spi_davinci.0", NULL, &spi0_clk), 571 CLK("spi_davinci.0", NULL, &spi0_clk),
diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c
index c6feecf7ae24..9a6af0bd5dc3 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -22,6 +22,8 @@
22#define DA8XX_USB0_BASE 0x01e00000 22#define DA8XX_USB0_BASE 0x01e00000
23#define DA8XX_USB1_BASE 0x01e25000 23#define DA8XX_USB1_BASE 0x01e25000
24 24
25static struct clk *usb20_clk;
26
25static struct platform_device da8xx_usb_phy = { 27static struct platform_device da8xx_usb_phy = {
26 .name = "da8xx-usb-phy", 28 .name = "da8xx-usb-phy",
27 .id = -1, 29 .id = -1,
@@ -158,26 +160,13 @@ int __init da8xx_register_usb_refclkin(int rate)
158 160
159static void usb20_phy_clk_enable(struct clk *clk) 161static void usb20_phy_clk_enable(struct clk *clk)
160{ 162{
161 struct clk *usb20_clk;
162 int err;
163 u32 val; 163 u32 val;
164 u32 timeout = 500000; /* 500 msec */ 164 u32 timeout = 500000; /* 500 msec */
165 165
166 val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); 166 val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
167 167
168 usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
169 if (IS_ERR(usb20_clk)) {
170 pr_err("could not get usb20 clk: %ld\n", PTR_ERR(usb20_clk));
171 return;
172 }
173
174 /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ 168 /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */
175 err = clk_prepare_enable(usb20_clk); 169 davinci_clk_enable(usb20_clk);
176 if (err) {
177 pr_err("failed to enable usb20 clk: %d\n", err);
178 clk_put(usb20_clk);
179 return;
180 }
181 170
182 /* 171 /*
183 * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1 172 * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1
@@ -197,8 +186,7 @@ static void usb20_phy_clk_enable(struct clk *clk)
197 186
198 pr_err("Timeout waiting for USB 2.0 PHY clock good\n"); 187 pr_err("Timeout waiting for USB 2.0 PHY clock good\n");
199done: 188done:
200 clk_disable_unprepare(usb20_clk); 189 davinci_clk_disable(usb20_clk);
201 clk_put(usb20_clk);
202} 190}
203 191
204static void usb20_phy_clk_disable(struct clk *clk) 192static void usb20_phy_clk_disable(struct clk *clk)
@@ -285,11 +273,19 @@ static struct clk_lookup usb20_phy_clk_lookup =
285int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) 273int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin)
286{ 274{
287 struct clk *parent; 275 struct clk *parent;
288 int ret = 0; 276 int ret;
277
278 usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
279 ret = PTR_ERR_OR_ZERO(usb20_clk);
280 if (ret)
281 return ret;
289 282
290 parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); 283 parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux");
291 if (IS_ERR(parent)) 284 ret = PTR_ERR_OR_ZERO(parent);
292 return PTR_ERR(parent); 285 if (ret) {
286 clk_put(usb20_clk);
287 return ret;
288 }
293 289
294 usb20_phy_clk.parent = parent; 290 usb20_phy_clk.parent = parent;
295 ret = clk_register(&usb20_phy_clk); 291 ret = clk_register(&usb20_phy_clk);
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 98ffe1e62ad5..a5d68411a037 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -385,36 +385,6 @@ fail:
385 return pen_release != -1 ? ret : 0; 385 return pen_release != -1 ? ret : 0;
386} 386}
387 387
388/*
389 * Initialise the CPU possible map early - this describes the CPUs
390 * which may be present or become present in the system.
391 */
392
393static void __init exynos_smp_init_cpus(void)
394{
395 void __iomem *scu_base = scu_base_addr();
396 unsigned int i, ncores;
397
398 if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
399 ncores = scu_base ? scu_get_core_count(scu_base) : 1;
400 else
401 /*
402 * CPU Nodes are passed thru DT and set_cpu_possible
403 * is set by "arm_dt_init_cpu_maps".
404 */
405 return;
406
407 /* sanity check */
408 if (ncores > nr_cpu_ids) {
409 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
410 ncores, nr_cpu_ids);
411 ncores = nr_cpu_ids;
412 }
413
414 for (i = 0; i < ncores; i++)
415 set_cpu_possible(i, true);
416}
417
418static void __init exynos_smp_prepare_cpus(unsigned int max_cpus) 388static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
419{ 389{
420 int i; 390 int i;
@@ -479,7 +449,6 @@ static void exynos_cpu_die(unsigned int cpu)
479#endif /* CONFIG_HOTPLUG_CPU */ 449#endif /* CONFIG_HOTPLUG_CPU */
480 450
481const struct smp_operations exynos_smp_ops __initconst = { 451const struct smp_operations exynos_smp_ops __initconst = {
482 .smp_init_cpus = exynos_smp_init_cpus,
483 .smp_prepare_cpus = exynos_smp_prepare_cpus, 452 .smp_prepare_cpus = exynos_smp_prepare_cpus,
484 .smp_secondary_init = exynos_secondary_init, 453 .smp_secondary_init = exynos_secondary_init,
485 .smp_boot_secondary = exynos_boot_secondary, 454 .smp_boot_secondary = exynos_boot_secondary,
diff --git a/arch/arm/mach-imx/mach-imx1.c b/arch/arm/mach-imx/mach-imx1.c
index de5ab8d88549..3a8406e45b65 100644
--- a/arch/arm/mach-imx/mach-imx1.c
+++ b/arch/arm/mach-imx/mach-imx1.c
@@ -37,7 +37,6 @@ static const char * const imx1_dt_board_compat[] __initconst = {
37}; 37};
38 38
39DT_MACHINE_START(IMX1_DT, "Freescale i.MX1 (Device Tree Support)") 39DT_MACHINE_START(IMX1_DT, "Freescale i.MX1 (Device Tree Support)")
40 .map_io = debug_ll_io_init,
41 .init_early = imx1_init_early, 40 .init_early = imx1_init_early,
42 .init_irq = imx1_init_irq, 41 .init_irq = imx1_init_irq,
43 .dt_compat = imx1_dt_board_compat, 42 .dt_compat = imx1_dt_board_compat,
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 469894082fea..093458b62c8d 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -I$(srctree)/$(src)/include \
7 7
8# Common support 8# Common support
9obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \ 9obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \
10 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \ 10 common.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
11 omap_device.o omap-headsmp.o sram.o drm.o 11 omap_device.o omap-headsmp.o sram.o drm.o
12 12
13hwmod-common = omap_hwmod.o omap_hwmod_reset.o \ 13hwmod-common = omap_hwmod.o omap_hwmod_reset.o \
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 36d9943205ca..dc9e34e670a2 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -304,7 +304,7 @@ DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
304 .init_late = am43xx_init_late, 304 .init_late = am43xx_init_late,
305 .init_irq = omap_gic_of_init, 305 .init_irq = omap_gic_of_init,
306 .init_machine = omap_generic_init, 306 .init_machine = omap_generic_init,
307 .init_time = omap4_local_timer_init, 307 .init_time = omap3_gptimer_timer_init,
308 .dt_compat = am43_boards_compat, 308 .dt_compat = am43_boards_compat,
309 .restart = omap44xx_restart, 309 .restart = omap44xx_restart,
310MACHINE_END 310MACHINE_END
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
deleted file mode 100644
index 7a577145b68b..000000000000
--- a/arch/arm/mach-omap2/gpio.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/*
2 * OMAP2+ specific gpio initialization
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/gpio.h>
20#include <linux/err.h>
21#include <linux/slab.h>
22#include <linux/interrupt.h>
23#include <linux/of.h>
24#include <linux/platform_data/gpio-omap.h>
25
26#include "soc.h"
27#include "omap_hwmod.h"
28#include "omap_device.h"
29#include "omap-pm.h"
30
31#include "powerdomain.h"
32
33static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
34{
35 struct platform_device *pdev;
36 struct omap_gpio_platform_data *pdata;
37 struct omap_gpio_dev_attr *dev_attr;
38 char *name = "omap_gpio";
39 int id;
40 struct powerdomain *pwrdm;
41
42 /*
43 * extract the device id from name field available in the
44 * hwmod database and use the same for constructing ids for
45 * gpio devices.
46 * CAUTION: Make sure the name in the hwmod database does
47 * not change. If changed, make corresponding change here
48 * or make use of static variable mechanism to handle this.
49 */
50 sscanf(oh->name, "gpio%d", &id);
51
52 pdata = kzalloc(sizeof(struct omap_gpio_platform_data), GFP_KERNEL);
53 if (!pdata) {
54 pr_err("gpio%d: Memory allocation failed\n", id);
55 return -ENOMEM;
56 }
57
58 dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr;
59 pdata->bank_width = dev_attr->bank_width;
60 pdata->dbck_flag = dev_attr->dbck_flag;
61 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
62 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
63 if (!pdata->regs) {
64 pr_err("gpio%d: Memory allocation failed\n", id);
65 kfree(pdata);
66 return -ENOMEM;
67 }
68
69 switch (oh->class->rev) {
70 case 0:
71 if (id == 1)
72 /* non-wakeup GPIO pins for OMAP2 Bank1 */
73 pdata->non_wakeup_gpios = 0xe203ffc0;
74 else if (id == 2)
75 /* non-wakeup GPIO pins for OMAP2 Bank2 */
76 pdata->non_wakeup_gpios = 0x08700040;
77 /* fall through */
78
79 case 1:
80 pdata->regs->revision = OMAP24XX_GPIO_REVISION;
81 pdata->regs->direction = OMAP24XX_GPIO_OE;
82 pdata->regs->datain = OMAP24XX_GPIO_DATAIN;
83 pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT;
84 pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT;
85 pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT;
86 pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1;
87 pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2;
88 pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1;
89 pdata->regs->irqenable2 = OMAP24XX_GPIO_IRQENABLE2;
90 pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1;
91 pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
92 pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
93 pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
94 pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
95 pdata->regs->wkup_en = OMAP24XX_GPIO_WAKE_EN;
96 pdata->regs->leveldetect0 = OMAP24XX_GPIO_LEVELDETECT0;
97 pdata->regs->leveldetect1 = OMAP24XX_GPIO_LEVELDETECT1;
98 pdata->regs->risingdetect = OMAP24XX_GPIO_RISINGDETECT;
99 pdata->regs->fallingdetect = OMAP24XX_GPIO_FALLINGDETECT;
100 break;
101 case 2:
102 pdata->regs->revision = OMAP4_GPIO_REVISION;
103 pdata->regs->direction = OMAP4_GPIO_OE;
104 pdata->regs->datain = OMAP4_GPIO_DATAIN;
105 pdata->regs->dataout = OMAP4_GPIO_DATAOUT;
106 pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT;
107 pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT;
108 pdata->regs->irqstatus_raw0 = OMAP4_GPIO_IRQSTATUSRAW0;
109 pdata->regs->irqstatus_raw1 = OMAP4_GPIO_IRQSTATUSRAW1;
110 pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0;
111 pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
112 pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0;
113 pdata->regs->irqenable2 = OMAP4_GPIO_IRQSTATUSSET1;
114 pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0;
115 pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
116 pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
117 pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
118 pdata->regs->ctrl = OMAP4_GPIO_CTRL;
119 pdata->regs->wkup_en = OMAP4_GPIO_IRQWAKEN0;
120 pdata->regs->leveldetect0 = OMAP4_GPIO_LEVELDETECT0;
121 pdata->regs->leveldetect1 = OMAP4_GPIO_LEVELDETECT1;
122 pdata->regs->risingdetect = OMAP4_GPIO_RISINGDETECT;
123 pdata->regs->fallingdetect = OMAP4_GPIO_FALLINGDETECT;
124 break;
125 default:
126 WARN(1, "Invalid gpio bank_type\n");
127 kfree(pdata->regs);
128 kfree(pdata);
129 return -EINVAL;
130 }
131
132 pwrdm = omap_hwmod_get_pwrdm(oh);
133 pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
134
135 pdev = omap_device_build(name, id - 1, oh, pdata, sizeof(*pdata));
136 kfree(pdata);
137
138 if (IS_ERR(pdev)) {
139 WARN(1, "Can't build omap_device for %s:%s.\n",
140 name, oh->name);
141 return PTR_ERR(pdev);
142 }
143
144 return 0;
145}
146
147/*
148 * gpio_init needs to be done before
149 * machine_init functions access gpio APIs.
150 * Hence gpio_init is a omap_postcore_initcall.
151 */
152static int __init omap2_gpio_init(void)
153{
154 /* If dtb is there, the devices will be created dynamically */
155 if (of_have_populated_dt())
156 return -ENODEV;
157
158 return omap_hwmod_for_each_by_class("gpio", omap2_gpio_dev_init, NULL);
159}
160omap_postcore_initcall(omap2_gpio_init);
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 759e1d45ba25..e8b988714a09 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -741,14 +741,14 @@ static int _init_main_clk(struct omap_hwmod *oh)
741 int ret = 0; 741 int ret = 0;
742 char name[MOD_CLK_MAX_NAME_LEN]; 742 char name[MOD_CLK_MAX_NAME_LEN];
743 struct clk *clk; 743 struct clk *clk;
744 static const char modck[] = "_mod_ck";
744 745
745 /* +7 magic comes from '_mod_ck' suffix */ 746 if (strlen(oh->name) >= MOD_CLK_MAX_NAME_LEN - strlen(modck))
746 if (strlen(oh->name) + 7 > MOD_CLK_MAX_NAME_LEN)
747 pr_warn("%s: warning: cropping name for %s\n", __func__, 747 pr_warn("%s: warning: cropping name for %s\n", __func__,
748 oh->name); 748 oh->name);
749 749
750 strncpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - 7); 750 strlcpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - strlen(modck));
751 strcat(name, "_mod_ck"); 751 strlcat(name, modck, MOD_CLK_MAX_NAME_LEN);
752 752
753 clk = clk_get(NULL, name); 753 clk = clk_get(NULL, name);
754 if (!IS_ERR(clk)) { 754 if (!IS_ERR(clk)) {
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.h b/arch/arm/mach-omap2/omap_hwmod_common_data.h
index cdfbb44ceb0c..f22e9cb39f4a 100644
--- a/arch/arm/mach-omap2/omap_hwmod_common_data.h
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.h
@@ -121,10 +121,6 @@ extern struct omap_hwmod_irq_info omap2_uart3_mpu_irqs[];
121extern struct omap_hwmod_irq_info omap2_dispc_irqs[]; 121extern struct omap_hwmod_irq_info omap2_dispc_irqs[];
122extern struct omap_hwmod_irq_info omap2_i2c1_mpu_irqs[]; 122extern struct omap_hwmod_irq_info omap2_i2c1_mpu_irqs[];
123extern struct omap_hwmod_irq_info omap2_i2c2_mpu_irqs[]; 123extern struct omap_hwmod_irq_info omap2_i2c2_mpu_irqs[];
124extern struct omap_hwmod_irq_info omap2_gpio1_irqs[];
125extern struct omap_hwmod_irq_info omap2_gpio2_irqs[];
126extern struct omap_hwmod_irq_info omap2_gpio3_irqs[];
127extern struct omap_hwmod_irq_info omap2_gpio4_irqs[];
128extern struct omap_hwmod_irq_info omap2_dma_system_irqs[]; 124extern struct omap_hwmod_irq_info omap2_dma_system_irqs[];
129extern struct omap_hwmod_irq_info omap2_mcspi1_mpu_irqs[]; 125extern struct omap_hwmod_irq_info omap2_mcspi1_mpu_irqs[];
130extern struct omap_hwmod_irq_info omap2_mcspi2_mpu_irqs[]; 126extern struct omap_hwmod_irq_info omap2_mcspi2_mpu_irqs[];
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 5b2f5138d938..2b138b65129a 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -295,10 +295,8 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
295 GFP_KERNEL); 295 GFP_KERNEL);
296 296
297 if (!prcm_irq_chips || !prcm_irq_setup->saved_mask || 297 if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
298 !prcm_irq_setup->priority_mask) { 298 !prcm_irq_setup->priority_mask)
299 pr_err("PRCM: kzalloc failed\n");
300 goto err; 299 goto err;
301 }
302 300
303 memset(mask, 0, sizeof(mask)); 301 memset(mask, 0, sizeof(mask));
304 302
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 56128da23c3a..07dd692c4737 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -510,18 +510,19 @@ void __init omap3_secure_sync32k_timer_init(void)
510} 510}
511#endif /* CONFIG_ARCH_OMAP3 */ 511#endif /* CONFIG_ARCH_OMAP3 */
512 512
513#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) 513#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) || \
514 defined(CONFIG_SOC_AM43XX)
514void __init omap3_gptimer_timer_init(void) 515void __init omap3_gptimer_timer_init(void)
515{ 516{
516 __omap_sync32k_timer_init(2, "timer_sys_ck", NULL, 517 __omap_sync32k_timer_init(2, "timer_sys_ck", NULL,
517 1, "timer_sys_ck", "ti,timer-alwon", true); 518 1, "timer_sys_ck", "ti,timer-alwon", true);
518 519 if (of_have_populated_dt())
519 clocksource_probe(); 520 clocksource_probe();
520} 521}
521#endif 522#endif
522 523
523#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \ 524#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
524 defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM43XX) 525 defined(CONFIG_SOC_DRA7XX)
525static void __init omap4_sync32k_timer_init(void) 526static void __init omap4_sync32k_timer_init(void)
526{ 527{
527 __omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon", 528 __omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c
index f6c3f151d0d4..b59f4f4f256f 100644
--- a/arch/arm/mach-s3c24xx/common.c
+++ b/arch/arm/mach-s3c24xx/common.c
@@ -345,10 +345,40 @@ static struct s3c24xx_dma_channel s3c2410_dma_channels[DMACH_MAX] = {
345 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), }, 345 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, S3C24XX_DMA_CHANREQ(4, 3), },
346}; 346};
347 347
348static const struct dma_slave_map s3c2410_dma_slave_map[] = {
349 { "s3c2410-sdi", "rx-tx", (void *)DMACH_SDI },
350 { "s3c2410-spi.0", "rx", (void *)DMACH_SPI0_RX },
351 { "s3c2410-spi.0", "tx", (void *)DMACH_SPI0_TX },
352 { "s3c2410-spi.1", "rx", (void *)DMACH_SPI1_RX },
353 { "s3c2410-spi.1", "tx", (void *)DMACH_SPI1_TX },
354 /*
355 * The DMA request source[1] (DMACH_UARTx_SRC2) are
356 * not used in the UART driver.
357 */
358 { "s3c2410-uart.0", "rx", (void *)DMACH_UART0 },
359 { "s3c2410-uart.0", "tx", (void *)DMACH_UART0 },
360 { "s3c2410-uart.1", "rx", (void *)DMACH_UART1 },
361 { "s3c2410-uart.1", "tx", (void *)DMACH_UART1 },
362 { "s3c2410-uart.2", "rx", (void *)DMACH_UART2 },
363 { "s3c2410-uart.2", "tx", (void *)DMACH_UART2 },
364 { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
365 { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
366 { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
367 { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
368 { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
369 { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
370 { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
371 { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
372 { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
373 { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
374};
375
348static struct s3c24xx_dma_platdata s3c2410_dma_platdata = { 376static struct s3c24xx_dma_platdata s3c2410_dma_platdata = {
349 .num_phy_channels = 4, 377 .num_phy_channels = 4,
350 .channels = s3c2410_dma_channels, 378 .channels = s3c2410_dma_channels,
351 .num_channels = DMACH_MAX, 379 .num_channels = DMACH_MAX,
380 .slave_map = s3c2410_dma_slave_map,
381 .slavecnt = ARRAY_SIZE(s3c2410_dma_slave_map),
352}; 382};
353 383
354struct platform_device s3c2410_device_dma = { 384struct platform_device s3c2410_device_dma = {
@@ -388,10 +418,36 @@ static struct s3c24xx_dma_channel s3c2412_dma_channels[DMACH_MAX] = {
388 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 }, 418 [DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 },
389}; 419};
390 420
421static const struct dma_slave_map s3c2412_dma_slave_map[] = {
422 { "s3c2412-sdi", "rx-tx", (void *)DMACH_SDI },
423 { "s3c2412-spi.0", "rx", (void *)DMACH_SPI0_RX },
424 { "s3c2412-spi.0", "tx", (void *)DMACH_SPI0_TX },
425 { "s3c2412-spi.1", "rx", (void *)DMACH_SPI1_RX },
426 { "s3c2412-spi.1", "tx", (void *)DMACH_SPI1_TX },
427 { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
428 { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
429 { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
430 { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
431 { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
432 { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
433 { "s3c2412-iis", "rx", (void *)DMACH_I2S_IN },
434 { "s3c2412-iis", "tx", (void *)DMACH_I2S_OUT },
435 { "s3c-hsudc", "rx0", (void *)DMACH_USB_EP1 },
436 { "s3c-hsudc", "tx0", (void *)DMACH_USB_EP1 },
437 { "s3c-hsudc", "rx1", (void *)DMACH_USB_EP2 },
438 { "s3c-hsudc", "tx1", (void *)DMACH_USB_EP2 },
439 { "s3c-hsudc", "rx2", (void *)DMACH_USB_EP3 },
440 { "s3c-hsudc", "tx2", (void *)DMACH_USB_EP3 },
441 { "s3c-hsudc", "rx3", (void *)DMACH_USB_EP4 },
442 { "s3c-hsudc", "tx3", (void *)DMACH_USB_EP4 }
443};
444
391static struct s3c24xx_dma_platdata s3c2412_dma_platdata = { 445static struct s3c24xx_dma_platdata s3c2412_dma_platdata = {
392 .num_phy_channels = 4, 446 .num_phy_channels = 4,
393 .channels = s3c2412_dma_channels, 447 .channels = s3c2412_dma_channels,
394 .num_channels = DMACH_MAX, 448 .num_channels = DMACH_MAX,
449 .slave_map = s3c2412_dma_slave_map,
450 .slavecnt = ARRAY_SIZE(s3c2412_dma_slave_map),
395}; 451};
396 452
397struct platform_device s3c2412_device_dma = { 453struct platform_device s3c2412_device_dma = {
@@ -534,10 +590,30 @@ static struct s3c24xx_dma_channel s3c2443_dma_channels[DMACH_MAX] = {
534 [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 }, 590 [DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 },
535}; 591};
536 592
593static const struct dma_slave_map s3c2443_dma_slave_map[] = {
594 { "s3c2440-sdi", "rx-tx", (void *)DMACH_SDI },
595 { "s3c2443-spi.0", "rx", (void *)DMACH_SPI0_RX },
596 { "s3c2443-spi.0", "tx", (void *)DMACH_SPI0_TX },
597 { "s3c2443-spi.1", "rx", (void *)DMACH_SPI1_RX },
598 { "s3c2443-spi.1", "tx", (void *)DMACH_SPI1_TX },
599 { "s3c2440-uart.0", "rx", (void *)DMACH_UART0 },
600 { "s3c2440-uart.0", "tx", (void *)DMACH_UART0 },
601 { "s3c2440-uart.1", "rx", (void *)DMACH_UART1 },
602 { "s3c2440-uart.1", "tx", (void *)DMACH_UART1 },
603 { "s3c2440-uart.2", "rx", (void *)DMACH_UART2 },
604 { "s3c2440-uart.2", "tx", (void *)DMACH_UART2 },
605 { "s3c2440-uart.3", "rx", (void *)DMACH_UART3 },
606 { "s3c2440-uart.3", "tx", (void *)DMACH_UART3 },
607 { "s3c24xx-iis", "rx", (void *)DMACH_I2S_IN },
608 { "s3c24xx-iis", "tx", (void *)DMACH_I2S_OUT },
609};
610
537static struct s3c24xx_dma_platdata s3c2443_dma_platdata = { 611static struct s3c24xx_dma_platdata s3c2443_dma_platdata = {
538 .num_phy_channels = 6, 612 .num_phy_channels = 6,
539 .channels = s3c2443_dma_channels, 613 .channels = s3c2443_dma_channels,
540 .num_channels = DMACH_MAX, 614 .num_channels = DMACH_MAX,
615 .slave_map = s3c2443_dma_slave_map,
616 .slavecnt = ARRAY_SIZE(s3c2443_dma_slave_map),
541}; 617};
542 618
543struct platform_device s3c2443_device_dma = { 619struct platform_device s3c2443_device_dma = {
diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
index fc033c0d2a0f..eada0b58ba1c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -356,5 +356,21 @@
356 status = "disabled"; 356 status = "disabled";
357 }; 357 };
358 }; 358 };
359
360 vpu: vpu@d0100000 {
361 compatible = "amlogic,meson-gx-vpu";
362 reg = <0x0 0xd0100000 0x0 0x100000>,
363 <0x0 0xc883c000 0x0 0x1000>,
364 <0x0 0xc8838000 0x0 0x1000>;
365 reg-names = "vpu", "hhi", "dmc";
366 interrupts = <GIC_SPI 3 IRQ_TYPE_EDGE_RISING>;
367 #address-cells = <1>;
368 #size-cells = <0>;
369
370 /* CVBS VDAC output port */
371 cvbs_vdac_port: port@0 {
372 reg = <0>;
373 };
374 };
359 }; 375 };
360}; 376};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
index 969682092e0f..4cbd626a9e88 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
@@ -142,6 +142,16 @@
142 clocks = <&wifi32k>; 142 clocks = <&wifi32k>;
143 clock-names = "ext_clock"; 143 clock-names = "ext_clock";
144 }; 144 };
145
146 cvbs-connector {
147 compatible = "composite-video-connector";
148
149 port {
150 cvbs_connector_in: endpoint {
151 remote-endpoint = <&cvbs_vdac_out>;
152 };
153 };
154 };
145}; 155};
146 156
147&uart_AO { 157&uart_AO {
@@ -229,3 +239,9 @@
229 clocks = <&clkc CLKID_FCLK_DIV4>; 239 clocks = <&clkc CLKID_FCLK_DIV4>;
230 clock-names = "clkin0"; 240 clock-names = "clkin0";
231}; 241};
242
243&cvbs_vdac_port {
244 cvbs_vdac_out: endpoint {
245 remote-endpoint = <&cvbs_connector_in>;
246 };
247};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
index 203be28978d5..4a96e0f6f926 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-p20x.dtsi
@@ -125,6 +125,16 @@
125 clocks = <&wifi32k>; 125 clocks = <&wifi32k>;
126 clock-names = "ext_clock"; 126 clock-names = "ext_clock";
127 }; 127 };
128
129 cvbs-connector {
130 compatible = "composite-video-connector";
131
132 port {
133 cvbs_connector_in: endpoint {
134 remote-endpoint = <&cvbs_vdac_out>;
135 };
136 };
137 };
128}; 138};
129 139
130/* This UART is brought out to the DB9 connector */ 140/* This UART is brought out to the DB9 connector */
@@ -234,3 +244,9 @@
234 clocks = <&clkc CLKID_FCLK_DIV4>; 244 clocks = <&clkc CLKID_FCLK_DIV4>;
235 clock-names = "clkin0"; 245 clock-names = "clkin0";
236}; 246};
247
248&cvbs_vdac_port {
249 cvbs_vdac_out: endpoint {
250 remote-endpoint = <&cvbs_connector_in>;
251 };
252};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 51edd5b5c460..596240c38a9c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -506,3 +506,7 @@
506 <&clkc CLKID_FCLK_DIV2>; 506 <&clkc CLKID_FCLK_DIV2>;
507 clock-names = "core", "clkin0", "clkin1"; 507 clock-names = "core", "clkin0", "clkin1";
508}; 508};
509
510&vpu {
511 compatible = "amlogic,meson-gxbb-vpu", "amlogic,meson-gx-vpu";
512};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
index e99101ae9664..cea4a3eded9b 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-nexbox-a95x.dts
@@ -117,6 +117,16 @@
117 clocks = <&wifi32k>; 117 clocks = <&wifi32k>;
118 clock-names = "ext_clock"; 118 clock-names = "ext_clock";
119 }; 119 };
120
121 cvbs-connector {
122 compatible = "composite-video-connector";
123
124 port {
125 cvbs_connector_in: endpoint {
126 remote-endpoint = <&cvbs_vdac_out>;
127 };
128 };
129 };
120}; 130};
121 131
122&uart_AO { 132&uart_AO {
@@ -203,3 +213,9 @@
203 clocks = <&clkc CLKID_FCLK_DIV4>; 213 clocks = <&clkc CLKID_FCLK_DIV4>;
204 clock-names = "clkin0"; 214 clock-names = "clkin0";
205}; 215};
216
217&cvbs_vdac_port {
218 cvbs_vdac_out: endpoint {
219 remote-endpoint = <&cvbs_connector_in>;
220 };
221};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index 9f89b99c4806..69216246275d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -43,7 +43,7 @@
43 43
44#include "meson-gx.dtsi" 44#include "meson-gx.dtsi"
45#include <dt-bindings/clock/gxbb-clkc.h> 45#include <dt-bindings/clock/gxbb-clkc.h>
46#include <dt-bindings/gpio/meson-gxbb-gpio.h> 46#include <dt-bindings/gpio/meson-gxl-gpio.h>
47 47
48/ { 48/ {
49 compatible = "amlogic,meson-gxl"; 49 compatible = "amlogic,meson-gxl";
@@ -299,3 +299,7 @@
299 <&clkc CLKID_FCLK_DIV2>; 299 <&clkc CLKID_FCLK_DIV2>;
300 clock-names = "core", "clkin0", "clkin1"; 300 clock-names = "core", "clkin0", "clkin1";
301}; 301};
302
303&vpu {
304 compatible = "amlogic,meson-gxl-vpu", "amlogic,meson-gx-vpu";
305};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
index f859d75db8bd..5a337d339df1 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-nexbox-a1.dts
@@ -90,6 +90,16 @@
90 compatible = "mmc-pwrseq-emmc"; 90 compatible = "mmc-pwrseq-emmc";
91 reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>; 91 reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
92 }; 92 };
93
94 cvbs-connector {
95 compatible = "composite-video-connector";
96
97 port {
98 cvbs_connector_in: endpoint {
99 remote-endpoint = <&cvbs_vdac_out>;
100 };
101 };
102 };
93}; 103};
94 104
95/* This UART is brought out to the DB9 connector */ 105/* This UART is brought out to the DB9 connector */
@@ -167,3 +177,9 @@
167 max-speed = <1000>; 177 max-speed = <1000>;
168 }; 178 };
169}; 179};
180
181&cvbs_vdac_port {
182 cvbs_vdac_out: endpoint {
183 remote-endpoint = <&cvbs_connector_in>;
184 };
185};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
index c1974bbbddea..eb2f0c3e5e53 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
@@ -112,3 +112,7 @@
112 }; 112 };
113 }; 113 };
114}; 114};
115
116&vpu {
117 compatible = "amlogic,meson-gxm-vpu", "amlogic,meson-gx-vpu";
118};
diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
index a852e28a40e1..a83ed2c6bbf7 100644
--- a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
+++ b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
@@ -81,7 +81,7 @@
81 #address-cells = <0>; 81 #address-cells = <0>;
82 interrupt-controller; 82 interrupt-controller;
83 reg = <0x0 0x2c001000 0 0x1000>, 83 reg = <0x0 0x2c001000 0 0x1000>,
84 <0x0 0x2c002000 0 0x1000>, 84 <0x0 0x2c002000 0 0x2000>,
85 <0x0 0x2c004000 0 0x2000>, 85 <0x0 0x2c004000 0 0x2000>,
86 <0x0 0x2c006000 0 0x2000>; 86 <0x0 0x2c006000 0 0x2000>;
87 interrupts = <1 9 0xf04>; 87 interrupts = <1 9 0xf04>;
diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 9d1d7ad9b075..29ed6b61c737 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -64,6 +64,16 @@
64 reg = <0x0 0x86000000 0x0 0x200000>; 64 reg = <0x0 0x86000000 0x0 0x200000>;
65 no-map; 65 no-map;
66 }; 66 };
67
68 memory@85800000 {
69 reg = <0x0 0x85800000 0x0 0x800000>;
70 no-map;
71 };
72
73 memory@86200000 {
74 reg = <0x0 0x86200000 0x0 0x2600000>;
75 no-map;
76 };
67 }; 77 };
68 78
69 cpus { 79 cpus {
diff --git a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
index 6ffb0517421a..dbea2c3d8f0c 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
@@ -169,7 +169,7 @@
169 power-source = <3300>; 169 power-source = <3300>;
170 }; 170 };
171 171
172 sdhi0_pins_uhs: sd0 { 172 sdhi0_pins_uhs: sd0_uhs {
173 groups = "sdhi0_data4", "sdhi0_ctrl"; 173 groups = "sdhi0_data4", "sdhi0_ctrl";
174 function = "sdhi0"; 174 function = "sdhi0";
175 power-source = <1800>; 175 power-source = <1800>;
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 869dded0f09f..33b744d54739 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -331,6 +331,7 @@ CONFIG_DRM_VC4=m
331CONFIG_DRM_PANEL_SIMPLE=m 331CONFIG_DRM_PANEL_SIMPLE=m
332CONFIG_DRM_I2C_ADV7511=m 332CONFIG_DRM_I2C_ADV7511=m
333CONFIG_DRM_HISI_KIRIN=m 333CONFIG_DRM_HISI_KIRIN=m
334CONFIG_DRM_MESON=m
334CONFIG_FB=y 335CONFIG_FB=y
335CONFIG_FB_ARMCLCD=y 336CONFIG_FB_ARMCLCD=y
336CONFIG_BACKLIGHT_GENERIC=m 337CONFIG_BACKLIGHT_GENERIC=m
diff --git a/arch/arm64/include/asm/current.h b/arch/arm64/include/asm/current.h
index f2bcbe2d9889..86c404171305 100644
--- a/arch/arm64/include/asm/current.h
+++ b/arch/arm64/include/asm/current.h
@@ -9,9 +9,17 @@
9 9
10struct task_struct; 10struct task_struct;
11 11
12/*
13 * We don't use read_sysreg() as we want the compiler to cache the value where
14 * possible.
15 */
12static __always_inline struct task_struct *get_current(void) 16static __always_inline struct task_struct *get_current(void)
13{ 17{
14 return (struct task_struct *)read_sysreg(sp_el0); 18 unsigned long sp_el0;
19
20 asm ("mrs %0, sp_el0" : "=r" (sp_el0));
21
22 return (struct task_struct *)sp_el0;
15} 23}
16 24
17#define current get_current() 25#define current get_current()
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 290a84f3351f..e04082700bb1 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -524,7 +524,8 @@ EXPORT_SYMBOL(dummy_dma_ops);
524 524
525static int __init arm64_dma_init(void) 525static int __init arm64_dma_init(void)
526{ 526{
527 if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) 527 if (swiotlb_force == SWIOTLB_FORCE ||
528 max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
528 swiotlb = 1; 529 swiotlb = 1;
529 530
530 return atomic_pool_init(); 531 return atomic_pool_init();
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index a78a5c401806..156169c6981b 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -88,21 +88,21 @@ void show_pte(struct mm_struct *mm, unsigned long addr)
88 break; 88 break;
89 89
90 pud = pud_offset(pgd, addr); 90 pud = pud_offset(pgd, addr);
91 printk(", *pud=%016llx", pud_val(*pud)); 91 pr_cont(", *pud=%016llx", pud_val(*pud));
92 if (pud_none(*pud) || pud_bad(*pud)) 92 if (pud_none(*pud) || pud_bad(*pud))
93 break; 93 break;
94 94
95 pmd = pmd_offset(pud, addr); 95 pmd = pmd_offset(pud, addr);
96 printk(", *pmd=%016llx", pmd_val(*pmd)); 96 pr_cont(", *pmd=%016llx", pmd_val(*pmd));
97 if (pmd_none(*pmd) || pmd_bad(*pmd)) 97 if (pmd_none(*pmd) || pmd_bad(*pmd))
98 break; 98 break;
99 99
100 pte = pte_offset_map(pmd, addr); 100 pte = pte_offset_map(pmd, addr);
101 printk(", *pte=%016llx", pte_val(*pte)); 101 pr_cont(", *pte=%016llx", pte_val(*pte));
102 pte_unmap(pte); 102 pte_unmap(pte);
103 } while(0); 103 } while(0);
104 104
105 printk("\n"); 105 pr_cont("\n");
106} 106}
107 107
108#ifdef CONFIG_ARM64_HW_AFDBM 108#ifdef CONFIG_ARM64_HW_AFDBM
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 212c4d1e2f26..716d1226ba69 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -401,7 +401,8 @@ static void __init free_unused_memmap(void)
401 */ 401 */
402void __init mem_init(void) 402void __init mem_init(void)
403{ 403{
404 if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) 404 if (swiotlb_force == SWIOTLB_FORCE ||
405 max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
405 swiotlb_init(1); 406 swiotlb_init(1);
406 407
407 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 408 set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
diff --git a/arch/mips/kvm/entry.c b/arch/mips/kvm/entry.c
index 6a02b3a3fa65..e92fb190e2d6 100644
--- a/arch/mips/kvm/entry.c
+++ b/arch/mips/kvm/entry.c
@@ -521,6 +521,9 @@ void *kvm_mips_build_exit(void *addr)
521 uasm_i_and(&p, V0, V0, AT); 521 uasm_i_and(&p, V0, V0, AT);
522 uasm_i_lui(&p, AT, ST0_CU0 >> 16); 522 uasm_i_lui(&p, AT, ST0_CU0 >> 16);
523 uasm_i_or(&p, V0, V0, AT); 523 uasm_i_or(&p, V0, V0, AT);
524#ifdef CONFIG_64BIT
525 uasm_i_ori(&p, V0, V0, ST0_SX | ST0_UX);
526#endif
524 uasm_i_mtc0(&p, V0, C0_STATUS); 527 uasm_i_mtc0(&p, V0, C0_STATUS);
525 uasm_i_ehb(&p); 528 uasm_i_ehb(&p);
526 529
@@ -643,7 +646,7 @@ static void *kvm_mips_build_ret_to_guest(void *addr)
643 646
644 /* Setup status register for running guest in UM */ 647 /* Setup status register for running guest in UM */
645 uasm_i_ori(&p, V1, V1, ST0_EXL | KSU_USER | ST0_IE); 648 uasm_i_ori(&p, V1, V1, ST0_EXL | KSU_USER | ST0_IE);
646 UASM_i_LA(&p, AT, ~(ST0_CU0 | ST0_MX)); 649 UASM_i_LA(&p, AT, ~(ST0_CU0 | ST0_MX | ST0_SX | ST0_UX));
647 uasm_i_and(&p, V1, V1, AT); 650 uasm_i_and(&p, V1, V1, AT);
648 uasm_i_mtc0(&p, V1, C0_STATUS); 651 uasm_i_mtc0(&p, V1, C0_STATUS);
649 uasm_i_ehb(&p); 652 uasm_i_ehb(&p);
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 06a60b19acfb..29ec9ab3fd55 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -360,8 +360,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
360 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); 360 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run);
361 361
362 /* Invalidate the icache for these ranges */ 362 /* Invalidate the icache for these ranges */
363 local_flush_icache_range((unsigned long)gebase, 363 flush_icache_range((unsigned long)gebase,
364 (unsigned long)gebase + ALIGN(size, PAGE_SIZE)); 364 (unsigned long)gebase + ALIGN(size, PAGE_SIZE));
365 365
366 /* 366 /*
367 * Allocate comm page for guest kernel, a TLB will be reserved for 367 * Allocate comm page for guest kernel, a TLB will be reserved for
diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
index ef31fc24344e..552544616b9d 100644
--- a/arch/openrisc/kernel/vmlinux.lds.S
+++ b/arch/openrisc/kernel/vmlinux.lds.S
@@ -44,6 +44,8 @@ SECTIONS
44 /* Read-only sections, merged into text segment: */ 44 /* Read-only sections, merged into text segment: */
45 . = LOAD_BASE ; 45 . = LOAD_BASE ;
46 46
47 _text = .;
48
47 /* _s_kernel_ro must be page aligned */ 49 /* _s_kernel_ro must be page aligned */
48 . = ALIGN(PAGE_SIZE); 50 . = ALIGN(PAGE_SIZE);
49 _s_kernel_ro = .; 51 _s_kernel_ro = .;
diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
index 7581330ea35b..88fe0aad4390 100644
--- a/arch/parisc/include/asm/thread_info.h
+++ b/arch/parisc/include/asm/thread_info.h
@@ -49,7 +49,6 @@ struct thread_info {
49#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 49#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling TIF_NEED_RESCHED */
50#define TIF_32BIT 4 /* 32 bit binary */ 50#define TIF_32BIT 4 /* 32 bit binary */
51#define TIF_MEMDIE 5 /* is terminating due to OOM killer */ 51#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
52#define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */
53#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 52#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
54#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */ 53#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
55#define TIF_SINGLESTEP 9 /* single stepping? */ 54#define TIF_SINGLESTEP 9 /* single stepping? */
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index da0d9cb63403..1e22f981cd81 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -235,9 +235,26 @@ void __init time_init(void)
235 235
236 cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */ 236 cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */
237 237
238 /* register at clocksource framework */
239 clocksource_register_hz(&clocksource_cr16, cr16_hz);
240
241 /* register as sched_clock source */ 238 /* register as sched_clock source */
242 sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz); 239 sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz);
243} 240}
241
242static int __init init_cr16_clocksource(void)
243{
244 /*
245 * The cr16 interval timers are not syncronized across CPUs, so mark
246 * them unstable and lower rating on SMP systems.
247 */
248 if (num_online_cpus() > 1) {
249 clocksource_cr16.flags = CLOCK_SOURCE_UNSTABLE;
250 clocksource_cr16.rating = 0;
251 }
252
253 /* register at clocksource framework */
254 clocksource_register_hz(&clocksource_cr16,
255 100 * PAGE0->mem_10msec);
256
257 return 0;
258}
259
260device_initcall(init_cr16_clocksource);
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 8ff9253930af..1a0b4f63f0e9 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -234,7 +234,7 @@ show_signal_msg(struct pt_regs *regs, unsigned long code,
234 tsk->comm, code, address); 234 tsk->comm, code, address);
235 print_vma_addr(KERN_CONT " in ", regs->iaoq[0]); 235 print_vma_addr(KERN_CONT " in ", regs->iaoq[0]);
236 236
237 pr_cont(" trap #%lu: %s%c", code, trap_name(code), 237 pr_cont("\ntrap #%lu: %s%c", code, trap_name(code),
238 vma ? ',':'\n'); 238 vma ? ',':'\n');
239 239
240 if (vma) 240 if (vma)
diff --git a/arch/s390/include/asm/asm-prototypes.h b/arch/s390/include/asm/asm-prototypes.h
new file mode 100644
index 000000000000..2c3413b0ca52
--- /dev/null
+++ b/arch/s390/include/asm/asm-prototypes.h
@@ -0,0 +1,8 @@
1#ifndef _ASM_S390_PROTOTYPES_H
2
3#include <linux/kvm_host.h>
4#include <linux/ftrace.h>
5#include <asm/fpu/api.h>
6#include <asm-generic/asm-prototypes.h>
7
8#endif /* _ASM_S390_PROTOTYPES_H */
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 6b246aadf311..1b5c5ee9fc1b 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -94,7 +94,7 @@ static void update_mt_scaling(void)
94 * Update process times based on virtual cpu times stored by entry.S 94 * Update process times based on virtual cpu times stored by entry.S
95 * to the lowcore fields user_timer, system_timer & steal_clock. 95 * to the lowcore fields user_timer, system_timer & steal_clock.
96 */ 96 */
97static int do_account_vtime(struct task_struct *tsk, int hardirq_offset) 97static int do_account_vtime(struct task_struct *tsk)
98{ 98{
99 u64 timer, clock, user, system, steal; 99 u64 timer, clock, user, system, steal;
100 u64 user_scaled, system_scaled; 100 u64 user_scaled, system_scaled;
@@ -138,7 +138,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
138 } 138 }
139 account_user_time(tsk, user); 139 account_user_time(tsk, user);
140 tsk->utimescaled += user_scaled; 140 tsk->utimescaled += user_scaled;
141 account_system_time(tsk, hardirq_offset, system); 141 account_system_time(tsk, 0, system);
142 tsk->stimescaled += system_scaled; 142 tsk->stimescaled += system_scaled;
143 143
144 steal = S390_lowcore.steal_timer; 144 steal = S390_lowcore.steal_timer;
@@ -152,7 +152,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
152 152
153void vtime_task_switch(struct task_struct *prev) 153void vtime_task_switch(struct task_struct *prev)
154{ 154{
155 do_account_vtime(prev, 0); 155 do_account_vtime(prev);
156 prev->thread.user_timer = S390_lowcore.user_timer; 156 prev->thread.user_timer = S390_lowcore.user_timer;
157 prev->thread.system_timer = S390_lowcore.system_timer; 157 prev->thread.system_timer = S390_lowcore.system_timer;
158 S390_lowcore.user_timer = current->thread.user_timer; 158 S390_lowcore.user_timer = current->thread.user_timer;
@@ -166,7 +166,7 @@ void vtime_task_switch(struct task_struct *prev)
166 */ 166 */
167void vtime_account_user(struct task_struct *tsk) 167void vtime_account_user(struct task_struct *tsk)
168{ 168{
169 if (do_account_vtime(tsk, HARDIRQ_OFFSET)) 169 if (do_account_vtime(tsk))
170 virt_timer_expire(); 170 virt_timer_expire();
171} 171}
172 172
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index b47edb8f5256..410efb2c7b80 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -68,12 +68,10 @@ static struct dma_map_ops swiotlb_dma_ops = {
68 */ 68 */
69int __init pci_swiotlb_detect_override(void) 69int __init pci_swiotlb_detect_override(void)
70{ 70{
71 int use_swiotlb = swiotlb | swiotlb_force; 71 if (swiotlb_force == SWIOTLB_FORCE)
72
73 if (swiotlb_force)
74 swiotlb = 1; 72 swiotlb = 1;
75 73
76 return use_swiotlb; 74 return swiotlb;
77} 75}
78IOMMU_INIT_FINISH(pci_swiotlb_detect_override, 76IOMMU_INIT_FINISH(pci_swiotlb_detect_override,
79 pci_xen_swiotlb_detect, 77 pci_xen_swiotlb_detect,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 24db5fb6f575..a236decb81e4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -132,12 +132,6 @@ module_param_named(preemption_timer, enable_preemption_timer, bool, S_IRUGO);
132 132
133#define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5 133#define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5
134 134
135#define VMX_VPID_EXTENT_SUPPORTED_MASK \
136 (VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT | \
137 VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | \
138 VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT | \
139 VMX_VPID_EXTENT_SINGLE_NON_GLOBAL_BIT)
140
141/* 135/*
142 * Hyper-V requires all of these, so mark them as supported even though 136 * Hyper-V requires all of these, so mark them as supported even though
143 * they are just treated the same as all-context. 137 * they are just treated the same as all-context.
@@ -10473,12 +10467,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10473 !nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4)) { 10467 !nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4)) {
10474 nested_vmx_entry_failure(vcpu, vmcs12, 10468 nested_vmx_entry_failure(vcpu, vmcs12,
10475 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10469 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10476 goto out; 10470 return 1;
10477 } 10471 }
10478 if (vmcs12->vmcs_link_pointer != -1ull) { 10472 if (vmcs12->vmcs_link_pointer != -1ull) {
10479 nested_vmx_entry_failure(vcpu, vmcs12, 10473 nested_vmx_entry_failure(vcpu, vmcs12,
10480 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR); 10474 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR);
10481 goto out; 10475 return 1;
10482 } 10476 }
10483 10477
10484 /* 10478 /*
@@ -10498,7 +10492,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10498 ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) { 10492 ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) {
10499 nested_vmx_entry_failure(vcpu, vmcs12, 10493 nested_vmx_entry_failure(vcpu, vmcs12,
10500 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10494 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10501 goto out; 10495 return 1;
10502 } 10496 }
10503 } 10497 }
10504 10498
@@ -10516,7 +10510,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
10516 ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) { 10510 ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) {
10517 nested_vmx_entry_failure(vcpu, vmcs12, 10511 nested_vmx_entry_failure(vcpu, vmcs12,
10518 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); 10512 EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
10519 goto out; 10513 return 1;
10520 } 10514 }
10521 } 10515 }
10522 10516
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 51ccfe08e32f..2f22810a7e0c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3070,6 +3070,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
3070 memset(&events->reserved, 0, sizeof(events->reserved)); 3070 memset(&events->reserved, 0, sizeof(events->reserved));
3071} 3071}
3072 3072
3073static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags);
3074
3073static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, 3075static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
3074 struct kvm_vcpu_events *events) 3076 struct kvm_vcpu_events *events)
3075{ 3077{
@@ -3106,10 +3108,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
3106 vcpu->arch.apic->sipi_vector = events->sipi_vector; 3108 vcpu->arch.apic->sipi_vector = events->sipi_vector;
3107 3109
3108 if (events->flags & KVM_VCPUEVENT_VALID_SMM) { 3110 if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
3111 u32 hflags = vcpu->arch.hflags;
3109 if (events->smi.smm) 3112 if (events->smi.smm)
3110 vcpu->arch.hflags |= HF_SMM_MASK; 3113 hflags |= HF_SMM_MASK;
3111 else 3114 else
3112 vcpu->arch.hflags &= ~HF_SMM_MASK; 3115 hflags &= ~HF_SMM_MASK;
3116 kvm_set_hflags(vcpu, hflags);
3117
3113 vcpu->arch.smi_pending = events->smi.pending; 3118 vcpu->arch.smi_pending = events->smi.pending;
3114 if (events->smi.smm_inside_nmi) 3119 if (events->smi.smm_inside_nmi)
3115 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK; 3120 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index a9fafb5c8738..a0b36a9d5df1 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -48,7 +48,7 @@ int __init pci_xen_swiotlb_detect(void)
48 * activate this IOMMU. If running as PV privileged, activate it 48 * activate this IOMMU. If running as PV privileged, activate it
49 * irregardless. 49 * irregardless.
50 */ 50 */
51 if ((xen_initial_domain() || swiotlb || swiotlb_force)) 51 if (xen_initial_domain() || swiotlb || swiotlb_force == SWIOTLB_FORCE)
52 xen_swiotlb = 1; 52 xen_swiotlb = 1;
53 53
54 /* If we are running under Xen, we MUST disable the native SWIOTLB. 54 /* If we are running under Xen, we MUST disable the native SWIOTLB.
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 8c394e30e5fe..f3f7b41116f7 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -713,10 +713,9 @@ static void __init xen_reserve_xen_mfnlist(void)
713 size = PFN_PHYS(xen_start_info->nr_p2m_frames); 713 size = PFN_PHYS(xen_start_info->nr_p2m_frames);
714 } 714 }
715 715
716 if (!xen_is_e820_reserved(start, size)) { 716 memblock_reserve(start, size);
717 memblock_reserve(start, size); 717 if (!xen_is_e820_reserved(start, size))
718 return; 718 return;
719 }
720 719
721#ifdef CONFIG_X86_32 720#ifdef CONFIG_X86_32
722 /* 721 /*
@@ -727,6 +726,7 @@ static void __init xen_reserve_xen_mfnlist(void)
727 BUG(); 726 BUG();
728#else 727#else
729 xen_relocate_p2m(); 728 xen_relocate_p2m();
729 memblock_free(start, size);
730#endif 730#endif
731} 731}
732 732
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 6e82769f4042..f0a9c07b4c7a 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -544,6 +544,8 @@ static inline bool may_queue(struct rq_wb *rwb, struct rq_wait *rqw,
544 * the timer to kick off queuing again. 544 * the timer to kick off queuing again.
545 */ 545 */
546static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock) 546static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
547 __releases(lock)
548 __acquires(lock)
547{ 549{
548 struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd()); 550 struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd());
549 DEFINE_WAIT(wait); 551 DEFINE_WAIT(wait);
@@ -558,13 +560,12 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
558 if (may_queue(rwb, rqw, &wait, rw)) 560 if (may_queue(rwb, rqw, &wait, rw))
559 break; 561 break;
560 562
561 if (lock) 563 if (lock) {
562 spin_unlock_irq(lock); 564 spin_unlock_irq(lock);
563 565 io_schedule();
564 io_schedule();
565
566 if (lock)
567 spin_lock_irq(lock); 566 spin_lock_irq(lock);
567 } else
568 io_schedule();
568 } while (1); 569 } while (1);
569 570
570 finish_wait(&rqw->wait, &wait); 571 finish_wait(&rqw->wait, &wait);
@@ -595,7 +596,7 @@ static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio)
595 * in an irq held spinlock, if it holds one when calling this function. 596 * in an irq held spinlock, if it holds one when calling this function.
596 * If we do sleep, we'll release and re-grab it. 597 * If we do sleep, we'll release and re-grab it.
597 */ 598 */
598unsigned int wbt_wait(struct rq_wb *rwb, struct bio *bio, spinlock_t *lock) 599enum wbt_flags wbt_wait(struct rq_wb *rwb, struct bio *bio, spinlock_t *lock)
599{ 600{
600 unsigned int ret = 0; 601 unsigned int ret = 0;
601 602
diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
index 13caebd679f5..8c4e0a18460a 100644
--- a/drivers/acpi/acpi_watchdog.c
+++ b/drivers/acpi/acpi_watchdog.c
@@ -114,7 +114,7 @@ void __init acpi_watchdog_init(void)
114 pdev = platform_device_register_simple("wdat_wdt", PLATFORM_DEVID_NONE, 114 pdev = platform_device_register_simple("wdat_wdt", PLATFORM_DEVID_NONE,
115 resources, nresources); 115 resources, nresources);
116 if (IS_ERR(pdev)) 116 if (IS_ERR(pdev))
117 pr_err("Failed to create platform device\n"); 117 pr_err("Device creation failed: %ld\n", PTR_ERR(pdev));
118 118
119 kfree(resources); 119 kfree(resources);
120 120
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f8d65647ea79..fb19e1cdb641 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -98,7 +98,15 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
98 if (check_children && list_empty(&adev->children)) 98 if (check_children && list_empty(&adev->children))
99 return -ENODEV; 99 return -ENODEV;
100 100
101 return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; 101 /*
102 * If the device has a _HID (or _CID) returning a valid ACPI/PNP
103 * device ID, it is better to make it look less attractive here, so that
104 * the other device with the same _ADR value (that may not have a valid
105 * device ID) can be matched going forward. [This means a second spec
106 * violation in a row, so whatever we do here is best effort anyway.]
107 */
108 return sta_present && list_empty(&adev->pnp.ids) ?
109 FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
102} 110}
103 111
104struct acpi_device *acpi_find_child_device(struct acpi_device *parent, 112struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
@@ -250,7 +258,6 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
250 return 0; 258 return 0;
251 259
252 err: 260 err:
253 acpi_dma_deconfigure(dev);
254 ACPI_COMPANION_SET(dev, NULL); 261 ACPI_COMPANION_SET(dev, NULL);
255 put_device(dev); 262 put_device(dev);
256 put_device(&acpi_dev->dev); 263 put_device(&acpi_dev->dev);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 1b41a2739dac..0c452265c111 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -37,6 +37,7 @@ void acpi_amba_init(void);
37static inline void acpi_amba_init(void) {} 37static inline void acpi_amba_init(void) {}
38#endif 38#endif
39int acpi_sysfs_init(void); 39int acpi_sysfs_init(void);
40void acpi_gpe_apply_masked_gpes(void);
40void acpi_container_init(void); 41void acpi_container_init(void);
41void acpi_memory_hotplug_init(void); 42void acpi_memory_hotplug_init(void);
42#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 43#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 45dec874ea55..192691880d55 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2074,6 +2074,7 @@ int __init acpi_scan_init(void)
2074 } 2074 }
2075 } 2075 }
2076 2076
2077 acpi_gpe_apply_masked_gpes();
2077 acpi_update_all_gpes(); 2078 acpi_update_all_gpes();
2078 acpi_ec_ecdt_start(); 2079 acpi_ec_ecdt_start();
2079 2080
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 703c26e7022c..cf05ae973381 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -708,6 +708,62 @@ end:
708 return result ? result : size; 708 return result ? result : size;
709} 709}
710 710
711/*
712 * A Quirk Mechanism for GPE Flooding Prevention:
713 *
714 * Quirks may be needed to prevent GPE flooding on a specific GPE. The
715 * flooding typically cannot be detected and automatically prevented by
716 * ACPI_GPE_DISPATCH_NONE check because there is a _Lxx/_Exx prepared in
717 * the AML tables. This normally indicates a feature gap in Linux, thus
718 * instead of providing endless quirk tables, we provide a boot parameter
719 * for those who want this quirk. For example, if the users want to prevent
720 * the GPE flooding for GPE 00, they need to specify the following boot
721 * parameter:
722 * acpi_mask_gpe=0x00
723 * The masking status can be modified by the following runtime controlling
724 * interface:
725 * echo unmask > /sys/firmware/acpi/interrupts/gpe00
726 */
727
728/*
729 * Currently, the GPE flooding prevention only supports to mask the GPEs
730 * numbered from 00 to 7f.
731 */
732#define ACPI_MASKABLE_GPE_MAX 0x80
733
734static u64 __initdata acpi_masked_gpes;
735
736static int __init acpi_gpe_set_masked_gpes(char *val)
737{
738 u8 gpe;
739
740 if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)
741 return -EINVAL;
742 acpi_masked_gpes |= ((u64)1<<gpe);
743
744 return 1;
745}
746__setup("acpi_mask_gpe=", acpi_gpe_set_masked_gpes);
747
748void __init acpi_gpe_apply_masked_gpes(void)
749{
750 acpi_handle handle;
751 acpi_status status;
752 u8 gpe;
753
754 for (gpe = 0;
755 gpe < min_t(u8, ACPI_MASKABLE_GPE_MAX, acpi_current_gpe_count);
756 gpe++) {
757 if (acpi_masked_gpes & ((u64)1<<gpe)) {
758 status = acpi_get_gpe_device(gpe, &handle);
759 if (ACPI_SUCCESS(status)) {
760 pr_info("Masking GPE 0x%x.\n", gpe);
761 (void)acpi_mask_gpe(handle, gpe, TRUE);
762 }
763 }
764 }
765}
766
711void acpi_irq_stats_init(void) 767void acpi_irq_stats_init(void)
712{ 768{
713 acpi_status status; 769 acpi_status status;
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index a5e1262b964b..2997026b4dfb 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -626,6 +626,7 @@ static int genpd_runtime_resume(struct device *dev)
626 626
627 out: 627 out:
628 /* Measure resume latency. */ 628 /* Measure resume latency. */
629 time_start = 0;
629 if (timed && runtime_pm) 630 if (timed && runtime_pm)
630 time_start = ktime_get(); 631 time_start = ktime_get();
631 632
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
index 5eb05dbf59b8..fc585f370549 100644
--- a/drivers/clk/clk-stm32f4.c
+++ b/drivers/clk/clk-stm32f4.c
@@ -768,5 +768,5 @@ fail:
768 kfree(clks); 768 kfree(clks);
769 iounmap(base); 769 iounmap(base);
770} 770}
771CLK_OF_DECLARE(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init); 771CLK_OF_DECLARE_DRIVER(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init);
772CLK_OF_DECLARE(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init); 772CLK_OF_DECLARE_DRIVER(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init);
diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 9375777776d9..b533f99550e1 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -37,12 +37,14 @@
37 * @smstpcr: module stop control register 37 * @smstpcr: module stop control register
38 * @mstpsr: module stop status register (optional) 38 * @mstpsr: module stop status register (optional)
39 * @lock: protects writes to SMSTPCR 39 * @lock: protects writes to SMSTPCR
40 * @width_8bit: registers are 8-bit, not 32-bit
40 */ 41 */
41struct mstp_clock_group { 42struct mstp_clock_group {
42 struct clk_onecell_data data; 43 struct clk_onecell_data data;
43 void __iomem *smstpcr; 44 void __iomem *smstpcr;
44 void __iomem *mstpsr; 45 void __iomem *mstpsr;
45 spinlock_t lock; 46 spinlock_t lock;
47 bool width_8bit;
46}; 48};
47 49
48/** 50/**
@@ -59,6 +61,18 @@ struct mstp_clock {
59 61
60#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw) 62#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw)
61 63
64static inline u32 cpg_mstp_read(struct mstp_clock_group *group,
65 u32 __iomem *reg)
66{
67 return group->width_8bit ? readb(reg) : clk_readl(reg);
68}
69
70static inline void cpg_mstp_write(struct mstp_clock_group *group, u32 val,
71 u32 __iomem *reg)
72{
73 group->width_8bit ? writeb(val, reg) : clk_writel(val, reg);
74}
75
62static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) 76static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
63{ 77{
64 struct mstp_clock *clock = to_mstp_clock(hw); 78 struct mstp_clock *clock = to_mstp_clock(hw);
@@ -70,12 +84,12 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
70 84
71 spin_lock_irqsave(&group->lock, flags); 85 spin_lock_irqsave(&group->lock, flags);
72 86
73 value = clk_readl(group->smstpcr); 87 value = cpg_mstp_read(group, group->smstpcr);
74 if (enable) 88 if (enable)
75 value &= ~bitmask; 89 value &= ~bitmask;
76 else 90 else
77 value |= bitmask; 91 value |= bitmask;
78 clk_writel(value, group->smstpcr); 92 cpg_mstp_write(group, value, group->smstpcr);
79 93
80 spin_unlock_irqrestore(&group->lock, flags); 94 spin_unlock_irqrestore(&group->lock, flags);
81 95
@@ -83,7 +97,7 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
83 return 0; 97 return 0;
84 98
85 for (i = 1000; i > 0; --i) { 99 for (i = 1000; i > 0; --i) {
86 if (!(clk_readl(group->mstpsr) & bitmask)) 100 if (!(cpg_mstp_read(group, group->mstpsr) & bitmask))
87 break; 101 break;
88 cpu_relax(); 102 cpu_relax();
89 } 103 }
@@ -114,9 +128,9 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
114 u32 value; 128 u32 value;
115 129
116 if (group->mstpsr) 130 if (group->mstpsr)
117 value = clk_readl(group->mstpsr); 131 value = cpg_mstp_read(group, group->mstpsr);
118 else 132 else
119 value = clk_readl(group->smstpcr); 133 value = cpg_mstp_read(group, group->smstpcr);
120 134
121 return !(value & BIT(clock->bit_index)); 135 return !(value & BIT(clock->bit_index));
122} 136}
@@ -188,6 +202,9 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
188 return; 202 return;
189 } 203 }
190 204
205 if (of_device_is_compatible(np, "renesas,r7s72100-mstp-clocks"))
206 group->width_8bit = true;
207
191 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) 208 for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
192 clks[i] = ERR_PTR(-ENOENT); 209 clks[i] = ERR_PTR(-ENOENT);
193 210
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index bc97b6a4b1cf..7fcaf26e8f81 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -26,6 +26,8 @@ static const struct of_device_id machines[] __initconst = {
26 { .compatible = "allwinner,sun8i-a83t", }, 26 { .compatible = "allwinner,sun8i-a83t", },
27 { .compatible = "allwinner,sun8i-h3", }, 27 { .compatible = "allwinner,sun8i-h3", },
28 28
29 { .compatible = "apm,xgene-shadowcat", },
30
29 { .compatible = "arm,integrator-ap", }, 31 { .compatible = "arm,integrator-ap", },
30 { .compatible = "arm,integrator-cp", }, 32 { .compatible = "arm,integrator-cp", },
31 33
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 6acbd4af632e..f91c25718d16 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -857,13 +857,13 @@ static struct freq_attr *hwp_cpufreq_attrs[] = {
857 NULL, 857 NULL,
858}; 858};
859 859
860static void intel_pstate_hwp_set(const struct cpumask *cpumask) 860static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
861{ 861{
862 int min, hw_min, max, hw_max, cpu, range, adj_range; 862 int min, hw_min, max, hw_max, cpu, range, adj_range;
863 struct perf_limits *perf_limits = limits; 863 struct perf_limits *perf_limits = limits;
864 u64 value, cap; 864 u64 value, cap;
865 865
866 for_each_cpu(cpu, cpumask) { 866 for_each_cpu(cpu, policy->cpus) {
867 int max_perf_pct, min_perf_pct; 867 int max_perf_pct, min_perf_pct;
868 struct cpudata *cpu_data = all_cpu_data[cpu]; 868 struct cpudata *cpu_data = all_cpu_data[cpu];
869 s16 epp; 869 s16 epp;
@@ -949,7 +949,7 @@ skip_epp:
949static int intel_pstate_hwp_set_policy(struct cpufreq_policy *policy) 949static int intel_pstate_hwp_set_policy(struct cpufreq_policy *policy)
950{ 950{
951 if (hwp_active) 951 if (hwp_active)
952 intel_pstate_hwp_set(policy->cpus); 952 intel_pstate_hwp_set(policy);
953 953
954 return 0; 954 return 0;
955} 955}
@@ -968,19 +968,28 @@ static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)
968 968
969static int intel_pstate_resume(struct cpufreq_policy *policy) 969static int intel_pstate_resume(struct cpufreq_policy *policy)
970{ 970{
971 int ret;
972
971 if (!hwp_active) 973 if (!hwp_active)
972 return 0; 974 return 0;
973 975
976 mutex_lock(&intel_pstate_limits_lock);
977
974 all_cpu_data[policy->cpu]->epp_policy = 0; 978 all_cpu_data[policy->cpu]->epp_policy = 0;
975 979
976 return intel_pstate_hwp_set_policy(policy); 980 ret = intel_pstate_hwp_set_policy(policy);
981
982 mutex_unlock(&intel_pstate_limits_lock);
983
984 return ret;
977} 985}
978 986
979static void intel_pstate_hwp_set_online_cpus(void) 987static void intel_pstate_update_policies(void)
980{ 988{
981 get_online_cpus(); 989 int cpu;
982 intel_pstate_hwp_set(cpu_online_mask); 990
983 put_online_cpus(); 991 for_each_possible_cpu(cpu)
992 cpufreq_update_policy(cpu);
984} 993}
985 994
986/************************** debugfs begin ************************/ 995/************************** debugfs begin ************************/
@@ -1018,10 +1027,6 @@ static void __init intel_pstate_debug_expose_params(void)
1018 struct dentry *debugfs_parent; 1027 struct dentry *debugfs_parent;
1019 int i = 0; 1028 int i = 0;
1020 1029
1021 if (hwp_active ||
1022 pstate_funcs.get_target_pstate == get_target_pstate_use_cpu_load)
1023 return;
1024
1025 debugfs_parent = debugfs_create_dir("pstate_snb", NULL); 1030 debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
1026 if (IS_ERR_OR_NULL(debugfs_parent)) 1031 if (IS_ERR_OR_NULL(debugfs_parent))
1027 return; 1032 return;
@@ -1105,11 +1110,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
1105 1110
1106 limits->no_turbo = clamp_t(int, input, 0, 1); 1111 limits->no_turbo = clamp_t(int, input, 0, 1);
1107 1112
1108 if (hwp_active)
1109 intel_pstate_hwp_set_online_cpus();
1110
1111 mutex_unlock(&intel_pstate_limits_lock); 1113 mutex_unlock(&intel_pstate_limits_lock);
1112 1114
1115 intel_pstate_update_policies();
1116
1113 return count; 1117 return count;
1114} 1118}
1115 1119
@@ -1134,11 +1138,10 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
1134 limits->max_perf_pct); 1138 limits->max_perf_pct);
1135 limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); 1139 limits->max_perf = div_ext_fp(limits->max_perf_pct, 100);
1136 1140
1137 if (hwp_active)
1138 intel_pstate_hwp_set_online_cpus();
1139
1140 mutex_unlock(&intel_pstate_limits_lock); 1141 mutex_unlock(&intel_pstate_limits_lock);
1141 1142
1143 intel_pstate_update_policies();
1144
1142 return count; 1145 return count;
1143} 1146}
1144 1147
@@ -1163,11 +1166,10 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
1163 limits->min_perf_pct); 1166 limits->min_perf_pct);
1164 limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); 1167 limits->min_perf = div_ext_fp(limits->min_perf_pct, 100);
1165 1168
1166 if (hwp_active)
1167 intel_pstate_hwp_set_online_cpus();
1168
1169 mutex_unlock(&intel_pstate_limits_lock); 1169 mutex_unlock(&intel_pstate_limits_lock);
1170 1170
1171 intel_pstate_update_policies();
1172
1171 return count; 1173 return count;
1172} 1174}
1173 1175
@@ -2153,8 +2155,12 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
2153 if (per_cpu_limits) 2155 if (per_cpu_limits)
2154 perf_limits = cpu->perf_limits; 2156 perf_limits = cpu->perf_limits;
2155 2157
2158 mutex_lock(&intel_pstate_limits_lock);
2159
2156 intel_pstate_update_perf_limits(policy, perf_limits); 2160 intel_pstate_update_perf_limits(policy, perf_limits);
2157 2161
2162 mutex_unlock(&intel_pstate_limits_lock);
2163
2158 return 0; 2164 return 0;
2159} 2165}
2160 2166
@@ -2487,7 +2493,10 @@ hwp_cpu_matched:
2487 if (rc) 2493 if (rc)
2488 goto out; 2494 goto out;
2489 2495
2490 intel_pstate_debug_expose_params(); 2496 if (intel_pstate_driver == &intel_pstate && !hwp_active &&
2497 pstate_funcs.get_target_pstate != get_target_pstate_use_cpu_load)
2498 intel_pstate_debug_expose_params();
2499
2491 intel_pstate_sysfs_expose_params(); 2500 intel_pstate_sysfs_expose_params();
2492 2501
2493 if (hwp_active) 2502 if (hwp_active)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a324801d6a66..47206a21bb90 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -593,11 +593,16 @@ struct devfreq *devfreq_add_device(struct device *dev,
593 list_add(&devfreq->node, &devfreq_list); 593 list_add(&devfreq->node, &devfreq_list);
594 594
595 governor = find_devfreq_governor(devfreq->governor_name); 595 governor = find_devfreq_governor(devfreq->governor_name);
596 if (!IS_ERR(governor)) 596 if (IS_ERR(governor)) {
597 devfreq->governor = governor; 597 dev_err(dev, "%s: Unable to find governor for the device\n",
598 if (devfreq->governor) 598 __func__);
599 err = devfreq->governor->event_handler(devfreq, 599 err = PTR_ERR(governor);
600 DEVFREQ_GOV_START, NULL); 600 goto err_init;
601 }
602
603 devfreq->governor = governor;
604 err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START,
605 NULL);
601 if (err) { 606 if (err) {
602 dev_err(dev, "%s: Unable to start governor for the device\n", 607 dev_err(dev, "%s: Unable to start governor for the device\n",
603 __func__); 608 __func__);
diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index a8ed7792ece2..9af86f46fbec 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -497,7 +497,7 @@ passive:
497 if (IS_ERR(bus->devfreq)) { 497 if (IS_ERR(bus->devfreq)) {
498 dev_err(dev, 498 dev_err(dev,
499 "failed to add devfreq dev with passive governor\n"); 499 "failed to add devfreq dev with passive governor\n");
500 ret = -EPROBE_DEFER; 500 ret = PTR_ERR(bus->devfreq);
501 goto err; 501 goto err;
502 } 502 }
503 503
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 70e13230d8db..9ad0b1934be9 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -721,11 +721,17 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val)
721 721
722 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id), 722 ret = scpi_send_message(CMD_SENSOR_VALUE, &id, sizeof(id),
723 &buf, sizeof(buf)); 723 &buf, sizeof(buf));
724 if (!ret) 724 if (ret)
725 return ret;
726
727 if (scpi_info->is_legacy)
728 /* only 32-bits supported, hi_val can be junk */
729 *val = le32_to_cpu(buf.lo_val);
730 else
725 *val = (u64)le32_to_cpu(buf.hi_val) << 32 | 731 *val = (u64)le32_to_cpu(buf.hi_val) << 32 |
726 le32_to_cpu(buf.lo_val); 732 le32_to_cpu(buf.lo_val);
727 733
728 return ret; 734 return 0;
729} 735}
730 736
731static int scpi_device_get_power_state(u16 dev_id) 737static int scpi_device_get_power_state(u16 dev_id)
diff --git a/drivers/firmware/psci_checker.c b/drivers/firmware/psci_checker.c
index 44bdb78f837b..29d58feaf675 100644
--- a/drivers/firmware/psci_checker.c
+++ b/drivers/firmware/psci_checker.c
@@ -270,8 +270,7 @@ static int suspend_test_thread(void *arg)
270 struct cpuidle_device *dev; 270 struct cpuidle_device *dev;
271 struct cpuidle_driver *drv; 271 struct cpuidle_driver *drv;
272 /* No need for an actual callback, we just want to wake up the CPU. */ 272 /* No need for an actual callback, we just want to wake up the CPU. */
273 struct timer_list wakeup_timer = 273 struct timer_list wakeup_timer;
274 TIMER_INITIALIZER(dummy_callback, 0, 0);
275 274
276 /* Wait for the main thread to give the start signal. */ 275 /* Wait for the main thread to give the start signal. */
277 wait_for_completion(&suspend_threads_started); 276 wait_for_completion(&suspend_threads_started);
@@ -287,6 +286,7 @@ static int suspend_test_thread(void *arg)
287 pr_info("CPU %d entering suspend cycles, states 1 through %d\n", 286 pr_info("CPU %d entering suspend cycles, states 1 through %d\n",
288 cpu, drv->state_count - 1); 287 cpu, drv->state_count - 1);
289 288
289 setup_timer_on_stack(&wakeup_timer, dummy_callback, 0);
290 for (i = 0; i < NUM_SUSPEND_CYCLE; ++i) { 290 for (i = 0; i < NUM_SUSPEND_CYCLE; ++i) {
291 int index; 291 int index;
292 /* 292 /*
diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c
index db516382a4d4..711c31c8d8b4 100644
--- a/drivers/gpu/drm/i915/gvt/cfg_space.c
+++ b/drivers/gpu/drm/i915/gvt/cfg_space.c
@@ -123,6 +123,7 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu,
123 u8 changed = old ^ new; 123 u8 changed = old ^ new;
124 int ret; 124 int ret;
125 125
126 memcpy(vgpu_cfg_space(vgpu) + offset, p_data, bytes);
126 if (!(changed & PCI_COMMAND_MEMORY)) 127 if (!(changed & PCI_COMMAND_MEMORY))
127 return 0; 128 return 0;
128 129
@@ -142,7 +143,6 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu,
142 return ret; 143 return ret;
143 } 144 }
144 145
145 memcpy(vgpu_cfg_space(vgpu) + offset, p_data, bytes);
146 return 0; 146 return 0;
147} 147}
148 148
@@ -240,7 +240,7 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset,
240 if (WARN_ON(bytes > 4)) 240 if (WARN_ON(bytes > 4))
241 return -EINVAL; 241 return -EINVAL;
242 242
243 if (WARN_ON(offset + bytes >= INTEL_GVT_MAX_CFG_SPACE_SZ)) 243 if (WARN_ON(offset + bytes > INTEL_GVT_MAX_CFG_SPACE_SZ))
244 return -EINVAL; 244 return -EINVAL;
245 245
246 /* First check if it's PCI_COMMAND */ 246 /* First check if it's PCI_COMMAND */
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 7eaaf1c9ed2b..6c5fdf5b2ce2 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -1998,6 +1998,8 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
1998 INIT_LIST_HEAD(&gtt->oos_page_list_head); 1998 INIT_LIST_HEAD(&gtt->oos_page_list_head);
1999 INIT_LIST_HEAD(&gtt->post_shadow_list_head); 1999 INIT_LIST_HEAD(&gtt->post_shadow_list_head);
2000 2000
2001 intel_vgpu_reset_ggtt(vgpu);
2002
2001 ggtt_mm = intel_vgpu_create_mm(vgpu, INTEL_GVT_MM_GGTT, 2003 ggtt_mm = intel_vgpu_create_mm(vgpu, INTEL_GVT_MM_GGTT,
2002 NULL, 1, 0); 2004 NULL, 1, 0);
2003 if (IS_ERR(ggtt_mm)) { 2005 if (IS_ERR(ggtt_mm)) {
@@ -2206,6 +2208,7 @@ int intel_vgpu_g2v_destroy_ppgtt_mm(struct intel_vgpu *vgpu,
2206int intel_gvt_init_gtt(struct intel_gvt *gvt) 2208int intel_gvt_init_gtt(struct intel_gvt *gvt)
2207{ 2209{
2208 int ret; 2210 int ret;
2211 void *page_addr;
2209 2212
2210 gvt_dbg_core("init gtt\n"); 2213 gvt_dbg_core("init gtt\n");
2211 2214
@@ -2218,6 +2221,23 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt)
2218 return -ENODEV; 2221 return -ENODEV;
2219 } 2222 }
2220 2223
2224 gvt->gtt.scratch_ggtt_page =
2225 alloc_page(GFP_KERNEL | GFP_ATOMIC | __GFP_ZERO);
2226 if (!gvt->gtt.scratch_ggtt_page) {
2227 gvt_err("fail to allocate scratch ggtt page\n");
2228 return -ENOMEM;
2229 }
2230
2231 page_addr = page_address(gvt->gtt.scratch_ggtt_page);
2232
2233 gvt->gtt.scratch_ggtt_mfn =
2234 intel_gvt_hypervisor_virt_to_mfn(page_addr);
2235 if (gvt->gtt.scratch_ggtt_mfn == INTEL_GVT_INVALID_ADDR) {
2236 gvt_err("fail to translate scratch ggtt page\n");
2237 __free_page(gvt->gtt.scratch_ggtt_page);
2238 return -EFAULT;
2239 }
2240
2221 if (enable_out_of_sync) { 2241 if (enable_out_of_sync) {
2222 ret = setup_spt_oos(gvt); 2242 ret = setup_spt_oos(gvt);
2223 if (ret) { 2243 if (ret) {
@@ -2239,6 +2259,41 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt)
2239 */ 2259 */
2240void intel_gvt_clean_gtt(struct intel_gvt *gvt) 2260void intel_gvt_clean_gtt(struct intel_gvt *gvt)
2241{ 2261{
2262 __free_page(gvt->gtt.scratch_ggtt_page);
2263
2242 if (enable_out_of_sync) 2264 if (enable_out_of_sync)
2243 clean_spt_oos(gvt); 2265 clean_spt_oos(gvt);
2244} 2266}
2267
2268/**
2269 * intel_vgpu_reset_ggtt - reset the GGTT entry
2270 * @vgpu: a vGPU
2271 *
2272 * This function is called at the vGPU create stage
2273 * to reset all the GGTT entries.
2274 *
2275 */
2276void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu)
2277{
2278 struct intel_gvt *gvt = vgpu->gvt;
2279 struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;
2280 u32 index;
2281 u32 offset;
2282 u32 num_entries;
2283 struct intel_gvt_gtt_entry e;
2284
2285 memset(&e, 0, sizeof(struct intel_gvt_gtt_entry));
2286 e.type = GTT_TYPE_GGTT_PTE;
2287 ops->set_pfn(&e, gvt->gtt.scratch_ggtt_mfn);
2288 e.val64 |= _PAGE_PRESENT;
2289
2290 index = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT;
2291 num_entries = vgpu_aperture_sz(vgpu) >> PAGE_SHIFT;
2292 for (offset = 0; offset < num_entries; offset++)
2293 ops->set_entry(NULL, &e, index + offset, false, 0, vgpu);
2294
2295 index = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT;
2296 num_entries = vgpu_hidden_sz(vgpu) >> PAGE_SHIFT;
2297 for (offset = 0; offset < num_entries; offset++)
2298 ops->set_entry(NULL, &e, index + offset, false, 0, vgpu);
2299}
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h
index d250013bc37b..b315ab3593ec 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.h
+++ b/drivers/gpu/drm/i915/gvt/gtt.h
@@ -81,6 +81,9 @@ struct intel_gvt_gtt {
81 struct list_head oos_page_use_list_head; 81 struct list_head oos_page_use_list_head;
82 struct list_head oos_page_free_list_head; 82 struct list_head oos_page_free_list_head;
83 struct list_head mm_lru_list_head; 83 struct list_head mm_lru_list_head;
84
85 struct page *scratch_ggtt_page;
86 unsigned long scratch_ggtt_mfn;
84}; 87};
85 88
86enum { 89enum {
@@ -202,6 +205,7 @@ struct intel_vgpu_gtt {
202 205
203extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu); 206extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
204extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu); 207extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
208void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu);
205 209
206extern int intel_gvt_init_gtt(struct intel_gvt *gvt); 210extern int intel_gvt_init_gtt(struct intel_gvt *gvt);
207extern void intel_gvt_clean_gtt(struct intel_gvt *gvt); 211extern void intel_gvt_clean_gtt(struct intel_gvt *gvt);
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index ad0e9364ee70..0af17016f33f 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -175,6 +175,7 @@ struct intel_vgpu {
175 struct notifier_block group_notifier; 175 struct notifier_block group_notifier;
176 struct kvm *kvm; 176 struct kvm *kvm;
177 struct work_struct release_work; 177 struct work_struct release_work;
178 atomic_t released;
178 } vdev; 179 } vdev;
179#endif 180#endif
180}; 181};
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4dd6722a7339..faaae07ae487 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -114,12 +114,15 @@ out:
114static kvm_pfn_t gvt_cache_find(struct intel_vgpu *vgpu, gfn_t gfn) 114static kvm_pfn_t gvt_cache_find(struct intel_vgpu *vgpu, gfn_t gfn)
115{ 115{
116 struct gvt_dma *entry; 116 struct gvt_dma *entry;
117 kvm_pfn_t pfn;
117 118
118 mutex_lock(&vgpu->vdev.cache_lock); 119 mutex_lock(&vgpu->vdev.cache_lock);
120
119 entry = __gvt_cache_find(vgpu, gfn); 121 entry = __gvt_cache_find(vgpu, gfn);
120 mutex_unlock(&vgpu->vdev.cache_lock); 122 pfn = (entry == NULL) ? 0 : entry->pfn;
121 123
122 return entry == NULL ? 0 : entry->pfn; 124 mutex_unlock(&vgpu->vdev.cache_lock);
125 return pfn;
123} 126}
124 127
125static void gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn, kvm_pfn_t pfn) 128static void gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn, kvm_pfn_t pfn)
@@ -166,7 +169,7 @@ static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
166 169
167static void gvt_cache_remove(struct intel_vgpu *vgpu, gfn_t gfn) 170static void gvt_cache_remove(struct intel_vgpu *vgpu, gfn_t gfn)
168{ 171{
169 struct device *dev = &vgpu->vdev.mdev->dev; 172 struct device *dev = mdev_dev(vgpu->vdev.mdev);
170 struct gvt_dma *this; 173 struct gvt_dma *this;
171 unsigned long g1; 174 unsigned long g1;
172 int rc; 175 int rc;
@@ -195,7 +198,7 @@ static void gvt_cache_destroy(struct intel_vgpu *vgpu)
195{ 198{
196 struct gvt_dma *dma; 199 struct gvt_dma *dma;
197 struct rb_node *node = NULL; 200 struct rb_node *node = NULL;
198 struct device *dev = &vgpu->vdev.mdev->dev; 201 struct device *dev = mdev_dev(vgpu->vdev.mdev);
199 unsigned long gfn; 202 unsigned long gfn;
200 203
201 mutex_lock(&vgpu->vdev.cache_lock); 204 mutex_lock(&vgpu->vdev.cache_lock);
@@ -396,7 +399,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
396 struct device *pdev; 399 struct device *pdev;
397 void *gvt; 400 void *gvt;
398 401
399 pdev = mdev->parent->dev; 402 pdev = mdev_parent_dev(mdev);
400 gvt = kdev_to_i915(pdev)->gvt; 403 gvt = kdev_to_i915(pdev)->gvt;
401 404
402 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); 405 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
@@ -418,7 +421,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
418 mdev_set_drvdata(mdev, vgpu); 421 mdev_set_drvdata(mdev, vgpu);
419 422
420 gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n", 423 gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n",
421 dev_name(&mdev->dev)); 424 dev_name(mdev_dev(mdev)));
422 return 0; 425 return 0;
423} 426}
424 427
@@ -482,7 +485,7 @@ static int intel_vgpu_open(struct mdev_device *mdev)
482 vgpu->vdev.group_notifier.notifier_call = intel_vgpu_group_notifier; 485 vgpu->vdev.group_notifier.notifier_call = intel_vgpu_group_notifier;
483 486
484 events = VFIO_IOMMU_NOTIFY_DMA_UNMAP; 487 events = VFIO_IOMMU_NOTIFY_DMA_UNMAP;
485 ret = vfio_register_notifier(&mdev->dev, VFIO_IOMMU_NOTIFY, &events, 488 ret = vfio_register_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY, &events,
486 &vgpu->vdev.iommu_notifier); 489 &vgpu->vdev.iommu_notifier);
487 if (ret != 0) { 490 if (ret != 0) {
488 gvt_err("vfio_register_notifier for iommu failed: %d\n", ret); 491 gvt_err("vfio_register_notifier for iommu failed: %d\n", ret);
@@ -490,17 +493,26 @@ static int intel_vgpu_open(struct mdev_device *mdev)
490 } 493 }
491 494
492 events = VFIO_GROUP_NOTIFY_SET_KVM; 495 events = VFIO_GROUP_NOTIFY_SET_KVM;
493 ret = vfio_register_notifier(&mdev->dev, VFIO_GROUP_NOTIFY, &events, 496 ret = vfio_register_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY, &events,
494 &vgpu->vdev.group_notifier); 497 &vgpu->vdev.group_notifier);
495 if (ret != 0) { 498 if (ret != 0) {
496 gvt_err("vfio_register_notifier for group failed: %d\n", ret); 499 gvt_err("vfio_register_notifier for group failed: %d\n", ret);
497 goto undo_iommu; 500 goto undo_iommu;
498 } 501 }
499 502
500 return kvmgt_guest_init(mdev); 503 ret = kvmgt_guest_init(mdev);
504 if (ret)
505 goto undo_group;
506
507 atomic_set(&vgpu->vdev.released, 0);
508 return ret;
509
510undo_group:
511 vfio_unregister_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY,
512 &vgpu->vdev.group_notifier);
501 513
502undo_iommu: 514undo_iommu:
503 vfio_unregister_notifier(&mdev->dev, VFIO_IOMMU_NOTIFY, 515 vfio_unregister_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
504 &vgpu->vdev.iommu_notifier); 516 &vgpu->vdev.iommu_notifier);
505out: 517out:
506 return ret; 518 return ret;
@@ -509,17 +521,26 @@ out:
509static void __intel_vgpu_release(struct intel_vgpu *vgpu) 521static void __intel_vgpu_release(struct intel_vgpu *vgpu)
510{ 522{
511 struct kvmgt_guest_info *info; 523 struct kvmgt_guest_info *info;
524 int ret;
512 525
513 if (!handle_valid(vgpu->handle)) 526 if (!handle_valid(vgpu->handle))
514 return; 527 return;
515 528
516 vfio_unregister_notifier(&vgpu->vdev.mdev->dev, VFIO_IOMMU_NOTIFY, 529 if (atomic_cmpxchg(&vgpu->vdev.released, 0, 1))
530 return;
531
532 ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_IOMMU_NOTIFY,
517 &vgpu->vdev.iommu_notifier); 533 &vgpu->vdev.iommu_notifier);
518 vfio_unregister_notifier(&vgpu->vdev.mdev->dev, VFIO_GROUP_NOTIFY, 534 WARN(ret, "vfio_unregister_notifier for iommu failed: %d\n", ret);
535
536 ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_GROUP_NOTIFY,
519 &vgpu->vdev.group_notifier); 537 &vgpu->vdev.group_notifier);
538 WARN(ret, "vfio_unregister_notifier for group failed: %d\n", ret);
520 539
521 info = (struct kvmgt_guest_info *)vgpu->handle; 540 info = (struct kvmgt_guest_info *)vgpu->handle;
522 kvmgt_guest_exit(info); 541 kvmgt_guest_exit(info);
542
543 vgpu->vdev.kvm = NULL;
523 vgpu->handle = 0; 544 vgpu->handle = 0;
524} 545}
525 546
@@ -534,6 +555,7 @@ static void intel_vgpu_release_work(struct work_struct *work)
534{ 555{
535 struct intel_vgpu *vgpu = container_of(work, struct intel_vgpu, 556 struct intel_vgpu *vgpu = container_of(work, struct intel_vgpu,
536 vdev.release_work); 557 vdev.release_work);
558
537 __intel_vgpu_release(vgpu); 559 __intel_vgpu_release(vgpu);
538} 560}
539 561
@@ -1089,7 +1111,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1089 return 0; 1111 return 0;
1090} 1112}
1091 1113
1092static const struct parent_ops intel_vgpu_ops = { 1114static const struct mdev_parent_ops intel_vgpu_ops = {
1093 .supported_type_groups = intel_vgpu_type_groups, 1115 .supported_type_groups = intel_vgpu_type_groups,
1094 .create = intel_vgpu_create, 1116 .create = intel_vgpu_create,
1095 .remove = intel_vgpu_remove, 1117 .remove = intel_vgpu_remove,
@@ -1134,6 +1156,10 @@ static int kvmgt_write_protect_add(unsigned long handle, u64 gfn)
1134 1156
1135 idx = srcu_read_lock(&kvm->srcu); 1157 idx = srcu_read_lock(&kvm->srcu);
1136 slot = gfn_to_memslot(kvm, gfn); 1158 slot = gfn_to_memslot(kvm, gfn);
1159 if (!slot) {
1160 srcu_read_unlock(&kvm->srcu, idx);
1161 return -EINVAL;
1162 }
1137 1163
1138 spin_lock(&kvm->mmu_lock); 1164 spin_lock(&kvm->mmu_lock);
1139 1165
@@ -1164,6 +1190,10 @@ static int kvmgt_write_protect_remove(unsigned long handle, u64 gfn)
1164 1190
1165 idx = srcu_read_lock(&kvm->srcu); 1191 idx = srcu_read_lock(&kvm->srcu);
1166 slot = gfn_to_memslot(kvm, gfn); 1192 slot = gfn_to_memslot(kvm, gfn);
1193 if (!slot) {
1194 srcu_read_unlock(&kvm->srcu, idx);
1195 return -EINVAL;
1196 }
1167 1197
1168 spin_lock(&kvm->mmu_lock); 1198 spin_lock(&kvm->mmu_lock);
1169 1199
@@ -1311,18 +1341,14 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
1311 1341
1312static bool kvmgt_guest_exit(struct kvmgt_guest_info *info) 1342static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
1313{ 1343{
1314 struct intel_vgpu *vgpu;
1315
1316 if (!info) { 1344 if (!info) {
1317 gvt_err("kvmgt_guest_info invalid\n"); 1345 gvt_err("kvmgt_guest_info invalid\n");
1318 return false; 1346 return false;
1319 } 1347 }
1320 1348
1321 vgpu = info->vgpu;
1322
1323 kvm_page_track_unregister_notifier(info->kvm, &info->track_node); 1349 kvm_page_track_unregister_notifier(info->kvm, &info->track_node);
1324 kvmgt_protect_table_destroy(info); 1350 kvmgt_protect_table_destroy(info);
1325 gvt_cache_destroy(vgpu); 1351 gvt_cache_destroy(info->vgpu);
1326 vfree(info); 1352 vfree(info);
1327 1353
1328 return true; 1354 return true;
@@ -1372,7 +1398,7 @@ static unsigned long kvmgt_gfn_to_pfn(unsigned long handle, unsigned long gfn)
1372 return pfn; 1398 return pfn;
1373 1399
1374 pfn = INTEL_GVT_INVALID_ADDR; 1400 pfn = INTEL_GVT_INVALID_ADDR;
1375 dev = &info->vgpu->vdev.mdev->dev; 1401 dev = mdev_dev(info->vgpu->vdev.mdev);
1376 rc = vfio_pin_pages(dev, &gfn, 1, IOMMU_READ | IOMMU_WRITE, &pfn); 1402 rc = vfio_pin_pages(dev, &gfn, 1, IOMMU_READ | IOMMU_WRITE, &pfn);
1377 if (rc != 1) { 1403 if (rc != 1) {
1378 gvt_err("vfio_pin_pages failed for gfn 0x%lx: %d\n", gfn, rc); 1404 gvt_err("vfio_pin_pages failed for gfn 0x%lx: %d\n", gfn, rc);
diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
index d2a0fbc896c3..81cd921770c6 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -65,7 +65,7 @@ static int map_vgpu_opregion(struct intel_vgpu *vgpu, bool map)
65 int i, ret; 65 int i, ret;
66 66
67 for (i = 0; i < INTEL_GVT_OPREGION_PAGES; i++) { 67 for (i = 0; i < INTEL_GVT_OPREGION_PAGES; i++) {
68 mfn = intel_gvt_hypervisor_virt_to_mfn(vgpu_opregion(vgpu) 68 mfn = intel_gvt_hypervisor_virt_to_mfn(vgpu_opregion(vgpu)->va
69 + i * PAGE_SIZE); 69 + i * PAGE_SIZE);
70 if (mfn == INTEL_GVT_INVALID_ADDR) { 70 if (mfn == INTEL_GVT_INVALID_ADDR) {
71 gvt_err("fail to get MFN from VA\n"); 71 gvt_err("fail to get MFN from VA\n");
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4a31b7a891ec..3dd7fc662859 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -244,14 +244,16 @@ err_phys:
244 244
245static void 245static void
246__i915_gem_object_release_shmem(struct drm_i915_gem_object *obj, 246__i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
247 struct sg_table *pages) 247 struct sg_table *pages,
248 bool needs_clflush)
248{ 249{
249 GEM_BUG_ON(obj->mm.madv == __I915_MADV_PURGED); 250 GEM_BUG_ON(obj->mm.madv == __I915_MADV_PURGED);
250 251
251 if (obj->mm.madv == I915_MADV_DONTNEED) 252 if (obj->mm.madv == I915_MADV_DONTNEED)
252 obj->mm.dirty = false; 253 obj->mm.dirty = false;
253 254
254 if ((obj->base.read_domains & I915_GEM_DOMAIN_CPU) == 0 && 255 if (needs_clflush &&
256 (obj->base.read_domains & I915_GEM_DOMAIN_CPU) == 0 &&
255 !cpu_cache_is_coherent(obj->base.dev, obj->cache_level)) 257 !cpu_cache_is_coherent(obj->base.dev, obj->cache_level))
256 drm_clflush_sg(pages); 258 drm_clflush_sg(pages);
257 259
@@ -263,7 +265,7 @@ static void
263i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj, 265i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
264 struct sg_table *pages) 266 struct sg_table *pages)
265{ 267{
266 __i915_gem_object_release_shmem(obj, pages); 268 __i915_gem_object_release_shmem(obj, pages, false);
267 269
268 if (obj->mm.dirty) { 270 if (obj->mm.dirty) {
269 struct address_space *mapping = obj->base.filp->f_mapping; 271 struct address_space *mapping = obj->base.filp->f_mapping;
@@ -2231,7 +2233,7 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj,
2231 struct sgt_iter sgt_iter; 2233 struct sgt_iter sgt_iter;
2232 struct page *page; 2234 struct page *page;
2233 2235
2234 __i915_gem_object_release_shmem(obj, pages); 2236 __i915_gem_object_release_shmem(obj, pages, true);
2235 2237
2236 i915_gem_gtt_finish_pages(obj, pages); 2238 i915_gem_gtt_finish_pages(obj, pages);
2237 2239
@@ -2304,15 +2306,6 @@ unlock:
2304 mutex_unlock(&obj->mm.lock); 2306 mutex_unlock(&obj->mm.lock);
2305} 2307}
2306 2308
2307static unsigned int swiotlb_max_size(void)
2308{
2309#if IS_ENABLED(CONFIG_SWIOTLB)
2310 return rounddown(swiotlb_nr_tbl() << IO_TLB_SHIFT, PAGE_SIZE);
2311#else
2312 return 0;
2313#endif
2314}
2315
2316static void i915_sg_trim(struct sg_table *orig_st) 2309static void i915_sg_trim(struct sg_table *orig_st)
2317{ 2310{
2318 struct sg_table new_st; 2311 struct sg_table new_st;
@@ -2322,7 +2315,7 @@ static void i915_sg_trim(struct sg_table *orig_st)
2322 if (orig_st->nents == orig_st->orig_nents) 2315 if (orig_st->nents == orig_st->orig_nents)
2323 return; 2316 return;
2324 2317
2325 if (sg_alloc_table(&new_st, orig_st->nents, GFP_KERNEL)) 2318 if (sg_alloc_table(&new_st, orig_st->nents, GFP_KERNEL | __GFP_NOWARN))
2326 return; 2319 return;
2327 2320
2328 new_sg = new_st.sgl; 2321 new_sg = new_st.sgl;
@@ -2360,7 +2353,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
2360 GEM_BUG_ON(obj->base.read_domains & I915_GEM_GPU_DOMAINS); 2353 GEM_BUG_ON(obj->base.read_domains & I915_GEM_GPU_DOMAINS);
2361 GEM_BUG_ON(obj->base.write_domain & I915_GEM_GPU_DOMAINS); 2354 GEM_BUG_ON(obj->base.write_domain & I915_GEM_GPU_DOMAINS);
2362 2355
2363 max_segment = swiotlb_max_size(); 2356 max_segment = swiotlb_max_segment();
2364 if (!max_segment) 2357 if (!max_segment)
2365 max_segment = rounddown(UINT_MAX, PAGE_SIZE); 2358 max_segment = rounddown(UINT_MAX, PAGE_SIZE);
2366 2359
@@ -2728,6 +2721,7 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine)
2728 struct drm_i915_gem_request *request; 2721 struct drm_i915_gem_request *request;
2729 struct i915_gem_context *incomplete_ctx; 2722 struct i915_gem_context *incomplete_ctx;
2730 struct intel_timeline *timeline; 2723 struct intel_timeline *timeline;
2724 unsigned long flags;
2731 bool ring_hung; 2725 bool ring_hung;
2732 2726
2733 if (engine->irq_seqno_barrier) 2727 if (engine->irq_seqno_barrier)
@@ -2763,13 +2757,20 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine)
2763 if (i915_gem_context_is_default(incomplete_ctx)) 2757 if (i915_gem_context_is_default(incomplete_ctx))
2764 return; 2758 return;
2765 2759
2760 timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine);
2761
2762 spin_lock_irqsave(&engine->timeline->lock, flags);
2763 spin_lock(&timeline->lock);
2764
2766 list_for_each_entry_continue(request, &engine->timeline->requests, link) 2765 list_for_each_entry_continue(request, &engine->timeline->requests, link)
2767 if (request->ctx == incomplete_ctx) 2766 if (request->ctx == incomplete_ctx)
2768 reset_request(request); 2767 reset_request(request);
2769 2768
2770 timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine);
2771 list_for_each_entry(request, &timeline->requests, link) 2769 list_for_each_entry(request, &timeline->requests, link)
2772 reset_request(request); 2770 reset_request(request);
2771
2772 spin_unlock(&timeline->lock);
2773 spin_unlock_irqrestore(&engine->timeline->lock, flags);
2773} 2774}
2774 2775
2775void i915_gem_reset(struct drm_i915_private *dev_priv) 2776void i915_gem_reset(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index e2b077df2da0..d229f47d1028 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -413,6 +413,25 @@ i915_gem_active_set(struct i915_gem_active *active,
413 rcu_assign_pointer(active->request, request); 413 rcu_assign_pointer(active->request, request);
414} 414}
415 415
416/**
417 * i915_gem_active_set_retire_fn - updates the retirement callback
418 * @active - the active tracker
419 * @fn - the routine called when the request is retired
420 * @mutex - struct_mutex used to guard retirements
421 *
422 * i915_gem_active_set_retire_fn() updates the function pointer that
423 * is called when the final request associated with the @active tracker
424 * is retired.
425 */
426static inline void
427i915_gem_active_set_retire_fn(struct i915_gem_active *active,
428 i915_gem_retire_fn fn,
429 struct mutex *mutex)
430{
431 lockdep_assert_held(mutex);
432 active->retire = fn ?: i915_gem_retire_noop;
433}
434
416static inline struct drm_i915_gem_request * 435static inline struct drm_i915_gem_request *
417__i915_gem_active_peek(const struct i915_gem_active *active) 436__i915_gem_active_peek(const struct i915_gem_active *active)
418{ 437{
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6daad8613760..3dc8724df400 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -16791,7 +16791,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16791 16791
16792 for_each_intel_crtc(dev, crtc) { 16792 for_each_intel_crtc(dev, crtc) {
16793 struct intel_crtc_state *crtc_state = crtc->config; 16793 struct intel_crtc_state *crtc_state = crtc->config;
16794 int pixclk = 0;
16795 16794
16796 __drm_atomic_helper_crtc_destroy_state(&crtc_state->base); 16795 __drm_atomic_helper_crtc_destroy_state(&crtc_state->base);
16797 memset(crtc_state, 0, sizeof(*crtc_state)); 16796 memset(crtc_state, 0, sizeof(*crtc_state));
@@ -16803,23 +16802,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16803 crtc->base.enabled = crtc_state->base.enable; 16802 crtc->base.enabled = crtc_state->base.enable;
16804 crtc->active = crtc_state->base.active; 16803 crtc->active = crtc_state->base.active;
16805 16804
16806 if (crtc_state->base.active) { 16805 if (crtc_state->base.active)
16807 dev_priv->active_crtcs |= 1 << crtc->pipe; 16806 dev_priv->active_crtcs |= 1 << crtc->pipe;
16808 16807
16809 if (INTEL_GEN(dev_priv) >= 9 || IS_BROADWELL(dev_priv))
16810 pixclk = ilk_pipe_pixel_rate(crtc_state);
16811 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
16812 pixclk = crtc_state->base.adjusted_mode.crtc_clock;
16813 else
16814 WARN_ON(dev_priv->display.modeset_calc_cdclk);
16815
16816 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
16817 if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
16818 pixclk = DIV_ROUND_UP(pixclk * 100, 95);
16819 }
16820
16821 dev_priv->min_pixclk[crtc->pipe] = pixclk;
16822
16823 readout_plane_state(crtc); 16808 readout_plane_state(crtc);
16824 16809
16825 DRM_DEBUG_KMS("[CRTC:%d:%s] hw state readout: %s\n", 16810 DRM_DEBUG_KMS("[CRTC:%d:%s] hw state readout: %s\n",
@@ -16892,6 +16877,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16892 } 16877 }
16893 16878
16894 for_each_intel_crtc(dev, crtc) { 16879 for_each_intel_crtc(dev, crtc) {
16880 int pixclk = 0;
16881
16895 crtc->base.hwmode = crtc->config->base.adjusted_mode; 16882 crtc->base.hwmode = crtc->config->base.adjusted_mode;
16896 16883
16897 memset(&crtc->base.mode, 0, sizeof(crtc->base.mode)); 16884 memset(&crtc->base.mode, 0, sizeof(crtc->base.mode));
@@ -16919,10 +16906,23 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
16919 */ 16906 */
16920 crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED; 16907 crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED;
16921 16908
16909 if (INTEL_GEN(dev_priv) >= 9 || IS_BROADWELL(dev_priv))
16910 pixclk = ilk_pipe_pixel_rate(crtc->config);
16911 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
16912 pixclk = crtc->config->base.adjusted_mode.crtc_clock;
16913 else
16914 WARN_ON(dev_priv->display.modeset_calc_cdclk);
16915
16916 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
16917 if (IS_BROADWELL(dev_priv) && crtc->config->ips_enabled)
16918 pixclk = DIV_ROUND_UP(pixclk * 100, 95);
16919
16922 drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode); 16920 drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode);
16923 update_scanline_offset(crtc); 16921 update_scanline_offset(crtc);
16924 } 16922 }
16925 16923
16924 dev_priv->min_pixclk[crtc->pipe] = pixclk;
16925
16926 intel_pipe_config_sanity_check(dev_priv, crtc->config); 16926 intel_pipe_config_sanity_check(dev_priv, crtc->config);
16927 } 16927 }
16928} 16928}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d9bc19be855e..0b8e8eb85c19 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -355,7 +355,8 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev,
355 struct intel_dp *intel_dp); 355 struct intel_dp *intel_dp);
356static void 356static void
357intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, 357intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
358 struct intel_dp *intel_dp); 358 struct intel_dp *intel_dp,
359 bool force_disable_vdd);
359static void 360static void
360intel_dp_pps_init(struct drm_device *dev, struct intel_dp *intel_dp); 361intel_dp_pps_init(struct drm_device *dev, struct intel_dp *intel_dp);
361 362
@@ -516,7 +517,7 @@ vlv_power_sequencer_pipe(struct intel_dp *intel_dp)
516 517
517 /* init power sequencer on this pipe and port */ 518 /* init power sequencer on this pipe and port */
518 intel_dp_init_panel_power_sequencer(dev, intel_dp); 519 intel_dp_init_panel_power_sequencer(dev, intel_dp);
519 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 520 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true);
520 521
521 /* 522 /*
522 * Even vdd force doesn't work until we've made 523 * Even vdd force doesn't work until we've made
@@ -553,7 +554,7 @@ bxt_power_sequencer_idx(struct intel_dp *intel_dp)
553 * Only the HW needs to be reprogrammed, the SW state is fixed and 554 * Only the HW needs to be reprogrammed, the SW state is fixed and
554 * has been setup during connector init. 555 * has been setup during connector init.
555 */ 556 */
556 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 557 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
557 558
558 return 0; 559 return 0;
559} 560}
@@ -636,7 +637,7 @@ vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp)
636 port_name(port), pipe_name(intel_dp->pps_pipe)); 637 port_name(port), pipe_name(intel_dp->pps_pipe));
637 638
638 intel_dp_init_panel_power_sequencer(dev, intel_dp); 639 intel_dp_init_panel_power_sequencer(dev, intel_dp);
639 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 640 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
640} 641}
641 642
642void intel_power_sequencer_reset(struct drm_i915_private *dev_priv) 643void intel_power_sequencer_reset(struct drm_i915_private *dev_priv)
@@ -2912,7 +2913,7 @@ static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp)
2912 2913
2913 /* init power sequencer on this pipe and port */ 2914 /* init power sequencer on this pipe and port */
2914 intel_dp_init_panel_power_sequencer(dev, intel_dp); 2915 intel_dp_init_panel_power_sequencer(dev, intel_dp);
2915 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 2916 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true);
2916} 2917}
2917 2918
2918static void vlv_pre_enable_dp(struct intel_encoder *encoder, 2919static void vlv_pre_enable_dp(struct intel_encoder *encoder,
@@ -5055,7 +5056,8 @@ intel_dp_init_panel_power_sequencer(struct drm_device *dev,
5055 5056
5056static void 5057static void
5057intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, 5058intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
5058 struct intel_dp *intel_dp) 5059 struct intel_dp *intel_dp,
5060 bool force_disable_vdd)
5059{ 5061{
5060 struct drm_i915_private *dev_priv = to_i915(dev); 5062 struct drm_i915_private *dev_priv = to_i915(dev);
5061 u32 pp_on, pp_off, pp_div, port_sel = 0; 5063 u32 pp_on, pp_off, pp_div, port_sel = 0;
@@ -5068,6 +5070,31 @@ intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
5068 5070
5069 intel_pps_get_registers(dev_priv, intel_dp, &regs); 5071 intel_pps_get_registers(dev_priv, intel_dp, &regs);
5070 5072
5073 /*
5074 * On some VLV machines the BIOS can leave the VDD
5075 * enabled even on power seqeuencers which aren't
5076 * hooked up to any port. This would mess up the
5077 * power domain tracking the first time we pick
5078 * one of these power sequencers for use since
5079 * edp_panel_vdd_on() would notice that the VDD was
5080 * already on and therefore wouldn't grab the power
5081 * domain reference. Disable VDD first to avoid this.
5082 * This also avoids spuriously turning the VDD on as
5083 * soon as the new power seqeuencer gets initialized.
5084 */
5085 if (force_disable_vdd) {
5086 u32 pp = ironlake_get_pp_control(intel_dp);
5087
5088 WARN(pp & PANEL_POWER_ON, "Panel power already on\n");
5089
5090 if (pp & EDP_FORCE_VDD)
5091 DRM_DEBUG_KMS("VDD already on, disabling first\n");
5092
5093 pp &= ~EDP_FORCE_VDD;
5094
5095 I915_WRITE(regs.pp_ctrl, pp);
5096 }
5097
5071 pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) | 5098 pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |
5072 (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT); 5099 (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT);
5073 pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) | 5100 pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |
@@ -5122,7 +5149,7 @@ static void intel_dp_pps_init(struct drm_device *dev,
5122 vlv_initial_power_sequencer_setup(intel_dp); 5149 vlv_initial_power_sequencer_setup(intel_dp);
5123 } else { 5150 } else {
5124 intel_dp_init_panel_power_sequencer(dev, intel_dp); 5151 intel_dp_init_panel_power_sequencer(dev, intel_dp);
5125 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp); 5152 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false);
5126 } 5153 }
5127} 5154}
5128 5155
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index fd0e4dac7cc1..e589e17876dc 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -216,7 +216,8 @@ static void intel_overlay_submit_request(struct intel_overlay *overlay,
216{ 216{
217 GEM_BUG_ON(i915_gem_active_peek(&overlay->last_flip, 217 GEM_BUG_ON(i915_gem_active_peek(&overlay->last_flip,
218 &overlay->i915->drm.struct_mutex)); 218 &overlay->i915->drm.struct_mutex));
219 overlay->last_flip.retire = retire; 219 i915_gem_active_set_retire_fn(&overlay->last_flip, retire,
220 &overlay->i915->drm.struct_mutex);
220 i915_gem_active_set(&overlay->last_flip, req); 221 i915_gem_active_set(&overlay->last_flip, req);
221 i915_add_request(req); 222 i915_add_request(req);
222} 223}
@@ -839,8 +840,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
839 if (ret) 840 if (ret)
840 goto out_unpin; 841 goto out_unpin;
841 842
842 i915_gem_track_fb(overlay->vma->obj, new_bo, 843 i915_gem_track_fb(overlay->vma ? overlay->vma->obj : NULL,
843 INTEL_FRONTBUFFER_OVERLAY(pipe)); 844 vma->obj, INTEL_FRONTBUFFER_OVERLAY(pipe));
844 845
845 overlay->old_vma = overlay->vma; 846 overlay->old_vma = overlay->vma;
846 overlay->vma = vma; 847 overlay->vma = vma;
@@ -1430,6 +1431,8 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv)
1430 overlay->contrast = 75; 1431 overlay->contrast = 75;
1431 overlay->saturation = 146; 1432 overlay->saturation = 146;
1432 1433
1434 init_request_active(&overlay->last_flip, NULL);
1435
1433 regs = intel_overlay_map_regs(overlay); 1436 regs = intel_overlay_map_regs(overlay);
1434 if (!regs) 1437 if (!regs)
1435 goto out_unpin_bo; 1438 goto out_unpin_bo;
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index d40ed9fdf68d..70b12f89a193 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -64,7 +64,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
64#define QUIRK_SKIP_INPUT_MAPPING BIT(2) 64#define QUIRK_SKIP_INPUT_MAPPING BIT(2)
65#define QUIRK_IS_MULTITOUCH BIT(3) 65#define QUIRK_IS_MULTITOUCH BIT(3)
66 66
67#define NOTEBOOK_QUIRKS QUIRK_FIX_NOTEBOOK_REPORT 67#define KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
68 QUIRK_NO_INIT_REPORTS)
68#define TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \ 69#define TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \
69 QUIRK_SKIP_INPUT_MAPPING | \ 70 QUIRK_SKIP_INPUT_MAPPING | \
70 QUIRK_IS_MULTITOUCH) 71 QUIRK_IS_MULTITOUCH)
@@ -170,11 +171,11 @@ static int asus_raw_event(struct hid_device *hdev,
170 171
171static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi) 172static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
172{ 173{
174 struct input_dev *input = hi->input;
173 struct asus_drvdata *drvdata = hid_get_drvdata(hdev); 175 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
174 176
175 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) { 177 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
176 int ret; 178 int ret;
177 struct input_dev *input = hi->input;
178 179
179 input_set_abs_params(input, ABS_MT_POSITION_X, 0, MAX_X, 0, 0); 180 input_set_abs_params(input, ABS_MT_POSITION_X, 0, MAX_X, 0, 0);
180 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0); 181 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0);
@@ -191,10 +192,10 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
191 hid_err(hdev, "Asus input mt init slots failed: %d\n", ret); 192 hid_err(hdev, "Asus input mt init slots failed: %d\n", ret);
192 return ret; 193 return ret;
193 } 194 }
194
195 drvdata->input = input;
196 } 195 }
197 196
197 drvdata->input = input;
198
198 return 0; 199 return 0;
199} 200}
200 201
@@ -286,7 +287,11 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
286 goto err_stop_hw; 287 goto err_stop_hw;
287 } 288 }
288 289
289 drvdata->input->name = "Asus TouchPad"; 290 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
291 drvdata->input->name = "Asus TouchPad";
292 } else {
293 drvdata->input->name = "Asus Keyboard";
294 }
290 295
291 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) { 296 if (drvdata->quirks & QUIRK_IS_MULTITOUCH) {
292 ret = asus_start_multitouch(hdev); 297 ret = asus_start_multitouch(hdev);
@@ -315,7 +320,7 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
315 320
316static const struct hid_device_id asus_devices[] = { 321static const struct hid_device_id asus_devices[] = {
317 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, 322 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
318 USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), NOTEBOOK_QUIRKS}, 323 USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), KEYBOARD_QUIRKS},
319 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, 324 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
320 USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS }, 325 USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS },
321 { } 326 { }
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index ec277b96eaa1..54bd22dc1411 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -319,6 +319,7 @@
319#define USB_VENDOR_ID_DRAGONRISE 0x0079 319#define USB_VENDOR_ID_DRAGONRISE 0x0079
320#define USB_DEVICE_ID_DRAGONRISE_WIIU 0x1800 320#define USB_DEVICE_ID_DRAGONRISE_WIIU 0x1800
321#define USB_DEVICE_ID_DRAGONRISE_PS3 0x1801 321#define USB_DEVICE_ID_DRAGONRISE_PS3 0x1801
322#define USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR 0x1803
322#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE 0x1843 323#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE 0x1843
323 324
324#define USB_VENDOR_ID_DWAV 0x0eef 325#define USB_VENDOR_ID_DWAV 0x0eef
@@ -365,6 +366,9 @@
365#define USB_VENDOR_ID_FLATFROG 0x25b5 366#define USB_VENDOR_ID_FLATFROG 0x25b5
366#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002 367#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002
367 368
369#define USB_VENDOR_ID_FUTABA 0x0547
370#define USB_DEVICE_ID_LED_DISPLAY 0x7000
371
368#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f 372#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
369#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 373#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
370 374
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 5c925228847c..4ef73374a8f9 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -212,7 +212,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
212 __s32 value; 212 __s32 value;
213 int ret = 0; 213 int ret = 0;
214 214
215 memset(buffer, 0, buffer_size);
216 mutex_lock(&data->mutex); 215 mutex_lock(&data->mutex);
217 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); 216 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
218 if (!report || (field_index >= report->maxfield)) { 217 if (!report || (field_index >= report->maxfield)) {
@@ -256,6 +255,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
256 int buffer_index = 0; 255 int buffer_index = 0;
257 int i; 256 int i;
258 257
258 memset(buffer, 0, buffer_size);
259
259 mutex_lock(&data->mutex); 260 mutex_lock(&data->mutex);
260 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); 261 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
261 if (!report || (field_index >= report->maxfield) || 262 if (!report || (field_index >= report->maxfield) ||
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 7687c0875395..f405b07d0381 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1099,8 +1099,11 @@ struct sony_sc {
1099 u8 led_delay_on[MAX_LEDS]; 1099 u8 led_delay_on[MAX_LEDS];
1100 u8 led_delay_off[MAX_LEDS]; 1100 u8 led_delay_off[MAX_LEDS];
1101 u8 led_count; 1101 u8 led_count;
1102 bool ds4_dongle_connected;
1102}; 1103};
1103 1104
1105static void sony_set_leds(struct sony_sc *sc);
1106
1104static inline void sony_schedule_work(struct sony_sc *sc) 1107static inline void sony_schedule_work(struct sony_sc *sc)
1105{ 1108{
1106 if (!sc->defer_initialization) 1109 if (!sc->defer_initialization)
@@ -1430,6 +1433,31 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
1430 return -EILSEQ; 1433 return -EILSEQ;
1431 } 1434 }
1432 } 1435 }
1436
1437 /*
1438 * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates
1439 * if a DS4 is actually connected (indicated by '0').
1440 * For non-dongle, this bit is always 0 (connected).
1441 */
1442 if (sc->hdev->vendor == USB_VENDOR_ID_SONY &&
1443 sc->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
1444 bool connected = (rd[31] & 0x04) ? false : true;
1445
1446 if (!sc->ds4_dongle_connected && connected) {
1447 hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n");
1448 sony_set_leds(sc);
1449 sc->ds4_dongle_connected = true;
1450 } else if (sc->ds4_dongle_connected && !connected) {
1451 hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n");
1452 sc->ds4_dongle_connected = false;
1453 /* Return 0, so hidraw can get the report. */
1454 return 0;
1455 } else if (!sc->ds4_dongle_connected) {
1456 /* Return 0, so hidraw can get the report. */
1457 return 0;
1458 }
1459 }
1460
1433 dualshock4_parse_report(sc, rd, size); 1461 dualshock4_parse_report(sc, rd, size);
1434 } 1462 }
1435 1463
@@ -2390,6 +2418,12 @@ static int sony_check_add(struct sony_sc *sc)
2390 } 2418 }
2391 2419
2392 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); 2420 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
2421
2422 snprintf(sc->hdev->uniq, sizeof(sc->hdev->uniq),
2423 "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
2424 sc->mac_address[5], sc->mac_address[4],
2425 sc->mac_address[3], sc->mac_address[2],
2426 sc->mac_address[1], sc->mac_address[0]);
2393 } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || 2427 } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
2394 (sc->quirks & NAVIGATION_CONTROLLER_USB)) { 2428 (sc->quirks & NAVIGATION_CONTROLLER_USB)) {
2395 buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL); 2429 buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL);
@@ -2548,7 +2582,7 @@ static int sony_input_configured(struct hid_device *hdev,
2548 hid_err(sc->hdev, 2582 hid_err(sc->hdev,
2549 "Unable to initialize multi-touch slots: %d\n", 2583 "Unable to initialize multi-touch slots: %d\n",
2550 ret); 2584 ret);
2551 return ret; 2585 goto err_stop;
2552 } 2586 }
2553 2587
2554 sony_init_output_report(sc, dualshock4_send_output_report); 2588 sony_init_output_report(sc, dualshock4_send_output_report);
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index b3e01c82af05..e9d6cc7cdfc5 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -83,11 +83,13 @@ static const struct hid_blacklist {
83 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 83 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
84 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT }, 84 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT },
85 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3, HID_QUIRK_MULTI_INPUT }, 85 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3, HID_QUIRK_MULTI_INPUT },
86 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR, HID_QUIRK_MULTI_INPUT },
86 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE, HID_QUIRK_MULTI_INPUT }, 87 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE, HID_QUIRK_MULTI_INPUT },
87 { USB_VENDOR_ID_ELAN, HID_ANY_ID, HID_QUIRK_ALWAYS_POLL }, 88 { USB_VENDOR_ID_ELAN, HID_ANY_ID, HID_QUIRK_ALWAYS_POLL },
88 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 89 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
89 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 90 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
90 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 91 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
92 { USB_VENDOR_ID_FUTABA, USB_DEVICE_ID_LED_DISPLAY, HID_QUIRK_NO_INIT_REPORTS },
91 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL }, 93 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL },
92 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL }, 94 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL },
93 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, 95 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 322ed9272811..841f2428e84a 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1036,7 +1036,7 @@ static const u8 lm90_temp_emerg_index[3] = {
1036}; 1036};
1037 1037
1038static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 }; 1038static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
1039static const u8 lm90_max_alarm_bits[3] = { 0, 4, 12 }; 1039static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
1040static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 }; 1040static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
1041static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 }; 1041static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
1042static const u8 lm90_fault_bits[3] = { 0, 2, 10 }; 1042static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index f6b6d42385e1..784670e2736b 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -353,12 +353,12 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
353 [0] = { 353 [0] = {
354 .num = ST_ACCEL_FS_AVL_2G, 354 .num = ST_ACCEL_FS_AVL_2G,
355 .value = 0x00, 355 .value = 0x00,
356 .gain = IIO_G_TO_M_S_2(1024), 356 .gain = IIO_G_TO_M_S_2(1000),
357 }, 357 },
358 [1] = { 358 [1] = {
359 .num = ST_ACCEL_FS_AVL_6G, 359 .num = ST_ACCEL_FS_AVL_6G,
360 .value = 0x01, 360 .value = 0x01,
361 .gain = IIO_G_TO_M_S_2(340), 361 .gain = IIO_G_TO_M_S_2(3000),
362 }, 362 },
363 }, 363 },
364 }, 364 },
@@ -366,6 +366,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
366 .addr = 0x21, 366 .addr = 0x21,
367 .mask = 0x40, 367 .mask = 0x40,
368 }, 368 },
369 /*
370 * Data Alignment Setting - needs to be set to get
371 * left-justified data like all other sensors.
372 */
373 .das = {
374 .addr = 0x21,
375 .mask = 0x01,
376 },
369 .drdy_irq = { 377 .drdy_irq = {
370 .addr = 0x21, 378 .addr = 0x21,
371 .mask_int1 = 0x04, 379 .mask_int1 = 0x04,
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 38bc319904c4..9c8b558ba19e 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -561,7 +561,7 @@ config TI_ADS8688
561 561
562config TI_AM335X_ADC 562config TI_AM335X_ADC
563 tristate "TI's AM335X ADC driver" 563 tristate "TI's AM335X ADC driver"
564 depends on MFD_TI_AM335X_TSCADC 564 depends on MFD_TI_AM335X_TSCADC && HAS_DMA
565 select IIO_BUFFER 565 select IIO_BUFFER
566 select IIO_KFIFO_BUF 566 select IIO_KFIFO_BUF
567 help 567 help
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index fe7775bb3740..df4045203a07 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -30,7 +30,9 @@ static int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
30 30
31 for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) { 31 for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) {
32 const struct iio_chan_spec *channel = &indio_dev->channels[i]; 32 const struct iio_chan_spec *channel = &indio_dev->channels[i];
33 unsigned int bytes_to_read = channel->scan_type.realbits >> 3; 33 unsigned int bytes_to_read =
34 DIV_ROUND_UP(channel->scan_type.realbits +
35 channel->scan_type.shift, 8);
34 unsigned int storage_bytes = 36 unsigned int storage_bytes =
35 channel->scan_type.storagebits >> 3; 37 channel->scan_type.storagebits >> 3;
36 38
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 975a1f19f747..79c8c7cd70d5 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -401,6 +401,15 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
401 return err; 401 return err;
402 } 402 }
403 403
404 /* set DAS */
405 if (sdata->sensor_settings->das.addr) {
406 err = st_sensors_write_data_with_mask(indio_dev,
407 sdata->sensor_settings->das.addr,
408 sdata->sensor_settings->das.mask, 1);
409 if (err < 0)
410 return err;
411 }
412
404 if (sdata->int_pin_open_drain) { 413 if (sdata->int_pin_open_drain) {
405 dev_info(&indio_dev->dev, 414 dev_info(&indio_dev->dev,
406 "set interrupt line to open drain mode\n"); 415 "set interrupt line to open drain mode\n");
@@ -483,8 +492,10 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
483 int err; 492 int err;
484 u8 *outdata; 493 u8 *outdata;
485 struct st_sensor_data *sdata = iio_priv(indio_dev); 494 struct st_sensor_data *sdata = iio_priv(indio_dev);
486 unsigned int byte_for_channel = ch->scan_type.realbits >> 3; 495 unsigned int byte_for_channel;
487 496
497 byte_for_channel = DIV_ROUND_UP(ch->scan_type.realbits +
498 ch->scan_type.shift, 8);
488 outdata = kmalloc(byte_for_channel, GFP_KERNEL); 499 outdata = kmalloc(byte_for_channel, GFP_KERNEL);
489 if (!outdata) 500 if (!outdata)
490 return -ENOMEM; 501 return -ENOMEM;
diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c
index 2d2ee353dde7..a5913e97945e 100644
--- a/drivers/iio/counter/104-quad-8.c
+++ b/drivers/iio/counter/104-quad-8.c
@@ -153,7 +153,7 @@ static int quad8_write_raw(struct iio_dev *indio_dev,
153 ior_cfg = val | priv->preset_enable[chan->channel] << 1; 153 ior_cfg = val | priv->preset_enable[chan->channel] << 1;
154 154
155 /* Load I/O control configuration */ 155 /* Load I/O control configuration */
156 outb(0x40 | ior_cfg, base_offset); 156 outb(0x40 | ior_cfg, base_offset + 1);
157 157
158 return 0; 158 return 0;
159 case IIO_CHAN_INFO_SCALE: 159 case IIO_CHAN_INFO_SCALE:
@@ -233,7 +233,7 @@ static ssize_t quad8_read_set_to_preset_on_index(struct iio_dev *indio_dev,
233 const struct quad8_iio *const priv = iio_priv(indio_dev); 233 const struct quad8_iio *const priv = iio_priv(indio_dev);
234 234
235 return snprintf(buf, PAGE_SIZE, "%u\n", 235 return snprintf(buf, PAGE_SIZE, "%u\n",
236 priv->preset_enable[chan->channel]); 236 !priv->preset_enable[chan->channel]);
237} 237}
238 238
239static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev, 239static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
@@ -241,7 +241,7 @@ static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
241 size_t len) 241 size_t len)
242{ 242{
243 struct quad8_iio *const priv = iio_priv(indio_dev); 243 struct quad8_iio *const priv = iio_priv(indio_dev);
244 const int base_offset = priv->base + 2 * chan->channel; 244 const int base_offset = priv->base + 2 * chan->channel + 1;
245 bool preset_enable; 245 bool preset_enable;
246 int ret; 246 int ret;
247 unsigned int ior_cfg; 247 unsigned int ior_cfg;
@@ -250,6 +250,9 @@ static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
250 if (ret) 250 if (ret)
251 return ret; 251 return ret;
252 252
253 /* Preset enable is active low in Input/Output Control register */
254 preset_enable = !preset_enable;
255
253 priv->preset_enable[chan->channel] = preset_enable; 256 priv->preset_enable[chan->channel] = preset_enable;
254 257
255 ior_cfg = priv->ab_enable[chan->channel] | 258 ior_cfg = priv->ab_enable[chan->channel] |
@@ -362,7 +365,7 @@ static int quad8_set_synchronous_mode(struct iio_dev *indio_dev,
362 priv->synchronous_mode[chan->channel] = synchronous_mode; 365 priv->synchronous_mode[chan->channel] = synchronous_mode;
363 366
364 /* Load Index Control configuration to Index Control Register */ 367 /* Load Index Control configuration to Index Control Register */
365 outb(0x40 | idr_cfg, base_offset); 368 outb(0x60 | idr_cfg, base_offset);
366 369
367 return 0; 370 return 0;
368} 371}
@@ -444,7 +447,7 @@ static int quad8_set_index_polarity(struct iio_dev *indio_dev,
444 priv->index_polarity[chan->channel] = index_polarity; 447 priv->index_polarity[chan->channel] = index_polarity;
445 448
446 /* Load Index Control configuration to Index Control Register */ 449 /* Load Index Control configuration to Index Control Register */
447 outb(0x40 | idr_cfg, base_offset); 450 outb(0x60 | idr_cfg, base_offset);
448 451
449 return 0; 452 return 0;
450} 453}
diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 5355507f8fa1..c9e319bff58b 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -66,10 +66,8 @@
66 66
67#define BMI160_REG_DUMMY 0x7F 67#define BMI160_REG_DUMMY 0x7F
68 68
69#define BMI160_ACCEL_PMU_MIN_USLEEP 3200 69#define BMI160_ACCEL_PMU_MIN_USLEEP 3800
70#define BMI160_ACCEL_PMU_MAX_USLEEP 3800 70#define BMI160_GYRO_PMU_MIN_USLEEP 80000
71#define BMI160_GYRO_PMU_MIN_USLEEP 55000
72#define BMI160_GYRO_PMU_MAX_USLEEP 80000
73#define BMI160_SOFTRESET_USLEEP 1000 71#define BMI160_SOFTRESET_USLEEP 1000
74 72
75#define BMI160_CHANNEL(_type, _axis, _index) { \ 73#define BMI160_CHANNEL(_type, _axis, _index) { \
@@ -151,20 +149,9 @@ static struct bmi160_regs bmi160_regs[] = {
151 }, 149 },
152}; 150};
153 151
154struct bmi160_pmu_time { 152static unsigned long bmi160_pmu_time[] = {
155 unsigned long min; 153 [BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP,
156 unsigned long max; 154 [BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP,
157};
158
159static struct bmi160_pmu_time bmi160_pmu_time[] = {
160 [BMI160_ACCEL] = {
161 .min = BMI160_ACCEL_PMU_MIN_USLEEP,
162 .max = BMI160_ACCEL_PMU_MAX_USLEEP
163 },
164 [BMI160_GYRO] = {
165 .min = BMI160_GYRO_PMU_MIN_USLEEP,
166 .max = BMI160_GYRO_PMU_MIN_USLEEP,
167 },
168}; 155};
169 156
170struct bmi160_scale { 157struct bmi160_scale {
@@ -289,7 +276,7 @@ int bmi160_set_mode(struct bmi160_data *data, enum bmi160_sensor_type t,
289 if (ret < 0) 276 if (ret < 0)
290 return ret; 277 return ret;
291 278
292 usleep_range(bmi160_pmu_time[t].min, bmi160_pmu_time[t].max); 279 usleep_range(bmi160_pmu_time[t], bmi160_pmu_time[t] + 1000);
293 280
294 return 0; 281 return 0;
295} 282}
diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index a144ca3461fc..81bd8e8da4a6 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -113,7 +113,7 @@ static const char max44000_int_time_avail_str[] =
113 "0.100 " 113 "0.100 "
114 "0.025 " 114 "0.025 "
115 "0.00625 " 115 "0.00625 "
116 "0.001625"; 116 "0.0015625";
117 117
118/* Available scales (internal to ulux) with pretty manual alignment: */ 118/* Available scales (internal to ulux) with pretty manual alignment: */
119static const int max44000_scale_avail_ulux_array[] = { 119static const int max44000_scale_avail_ulux_array[] = {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c8413fc120e6..7031a8dd4d14 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1682,9 +1682,19 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
1682 size += ret; 1682 size += ret;
1683 } 1683 }
1684 1684
1685 if (mlx4_is_master(mdev->dev) && flow_type == MLX4_FS_REGULAR &&
1686 flow_attr->num_of_specs == 1) {
1687 struct _rule_hw *rule_header = (struct _rule_hw *)(ctrl + 1);
1688 enum ib_flow_spec_type header_spec =
1689 ((union ib_flow_spec *)(flow_attr + 1))->type;
1690
1691 if (header_spec == IB_FLOW_SPEC_ETH)
1692 mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
1693 }
1694
1685 ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0, 1695 ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
1686 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, 1696 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
1687 MLX4_CMD_WRAPPED); 1697 MLX4_CMD_NATIVE);
1688 if (ret == -ENOMEM) 1698 if (ret == -ENOMEM)
1689 pr_err("mcg table is full. Fail to register network rule.\n"); 1699 pr_err("mcg table is full. Fail to register network rule.\n");
1690 else if (ret == -ENXIO) 1700 else if (ret == -ENXIO)
@@ -1701,7 +1711,7 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
1701 int err; 1711 int err;
1702 err = mlx4_cmd(dev, reg_id, 0, 0, 1712 err = mlx4_cmd(dev, reg_id, 0, 0,
1703 MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, 1713 MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
1704 MLX4_CMD_WRAPPED); 1714 MLX4_CMD_NATIVE);
1705 if (err) 1715 if (err)
1706 pr_err("Fail to detach network rule. registration id = 0x%llx\n", 1716 pr_err("Fail to detach network rule. registration id = 0x%llx\n",
1707 reg_id); 1717 reg_id);
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 019e02707cd5..3ef0f42984f2 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1023,7 +1023,7 @@ again:
1023 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE; 1023 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;
1024 left = (head - next_tail) % CMD_BUFFER_SIZE; 1024 left = (head - next_tail) % CMD_BUFFER_SIZE;
1025 1025
1026 if (left <= 2) { 1026 if (left <= 0x20) {
1027 struct iommu_cmd sync_cmd; 1027 struct iommu_cmd sync_cmd;
1028 int ret; 1028 int ret;
1029 1029
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index a88576d50740..8ccbd7023194 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
903 x86_init.iommu.iommu_init = intel_iommu_init; 903 x86_init.iommu.iommu_init = intel_iommu_init;
904#endif 904#endif
905 905
906 acpi_put_table(dmar_tbl); 906 if (dmar_tbl) {
907 dmar_tbl = NULL; 907 acpi_put_table(dmar_tbl);
908 dmar_tbl = NULL;
909 }
908 up_write(&dmar_global_lock); 910 up_write(&dmar_global_lock);
909 911
910 return ret ? 1 : -ENODEV; 912 return ret ? 1 : -ENODEV;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c66c273dfd8a..8a185250ae5a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2037,6 +2037,25 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
2037 if (context_present(context)) 2037 if (context_present(context))
2038 goto out_unlock; 2038 goto out_unlock;
2039 2039
2040 /*
2041 * For kdump cases, old valid entries may be cached due to the
2042 * in-flight DMA and copied pgtable, but there is no unmapping
2043 * behaviour for them, thus we need an explicit cache flush for
2044 * the newly-mapped device. For kdump, at this point, the device
2045 * is supposed to finish reset at its driver probe stage, so no
2046 * in-flight DMA will exist, and we don't need to worry anymore
2047 * hereafter.
2048 */
2049 if (context_copied(context)) {
2050 u16 did_old = context_domain_id(context);
2051
2052 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap))
2053 iommu->flush.flush_context(iommu, did_old,
2054 (((u16)bus) << 8) | devfn,
2055 DMA_CCMD_MASK_NOBIT,
2056 DMA_CCMD_DEVICE_INVL);
2057 }
2058
2040 pgd = domain->pgd; 2059 pgd = domain->pgd;
2041 2060
2042 context_clear_entry(context); 2061 context_clear_entry(context);
@@ -5185,6 +5204,25 @@ static void intel_iommu_remove_device(struct device *dev)
5185} 5204}
5186 5205
5187#ifdef CONFIG_INTEL_IOMMU_SVM 5206#ifdef CONFIG_INTEL_IOMMU_SVM
5207#define MAX_NR_PASID_BITS (20)
5208static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
5209{
5210 /*
5211 * Convert ecap_pss to extend context entry pts encoding, also
5212 * respect the soft pasid_max value set by the iommu.
5213 * - number of PASID bits = ecap_pss + 1
5214 * - number of PASID table entries = 2^(pts + 5)
5215 * Therefore, pts = ecap_pss - 4
5216 * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
5217 */
5218 if (ecap_pss(iommu->ecap) < 5)
5219 return 0;
5220
5221 /* pasid_max is encoded as actual number of entries not the bits */
5222 return find_first_bit((unsigned long *)&iommu->pasid_max,
5223 MAX_NR_PASID_BITS) - 5;
5224}
5225
5188int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev) 5226int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
5189{ 5227{
5190 struct device_domain_info *info; 5228 struct device_domain_info *info;
@@ -5217,7 +5255,9 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
5217 5255
5218 if (!(ctx_lo & CONTEXT_PASIDE)) { 5256 if (!(ctx_lo & CONTEXT_PASIDE)) {
5219 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table); 5257 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
5220 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | ecap_pss(iommu->ecap); 5258 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
5259 intel_iommu_get_pts(iommu);
5260
5221 wmb(); 5261 wmb();
5222 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both 5262 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both
5223 * extended to permit requests-with-PASID if the PASIDE bit 5263 * extended to permit requests-with-PASID if the PASIDE bit
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 0037153c80a6..2d9c5dd06e42 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -450,7 +450,7 @@ bool mei_cldev_enabled(struct mei_cl_device *cldev)
450EXPORT_SYMBOL_GPL(mei_cldev_enabled); 450EXPORT_SYMBOL_GPL(mei_cldev_enabled);
451 451
452/** 452/**
453 * mei_cldev_enable_device - enable me client device 453 * mei_cldev_enable - enable me client device
454 * create connection with me client 454 * create connection with me client
455 * 455 *
456 * @cldev: me client device 456 * @cldev: me client device
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 391936c1aa04..b0395601c6ae 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -1541,7 +1541,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1541 1541
1542 rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1; 1542 rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1;
1543 if (rets < 0) 1543 if (rets < 0)
1544 return rets; 1544 goto err;
1545 1545
1546 if (rets == 0) { 1546 if (rets == 0) {
1547 cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); 1547 cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
@@ -1575,11 +1575,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1575 cb->buf.size, cb->buf_idx); 1575 cb->buf.size, cb->buf_idx);
1576 1576
1577 rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx); 1577 rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
1578 if (rets) { 1578 if (rets)
1579 cl->status = rets; 1579 goto err;
1580 list_move_tail(&cb->list, &cmpl_list->list);
1581 return rets;
1582 }
1583 1580
1584 cl->status = 0; 1581 cl->status = 0;
1585 cl->writing_state = MEI_WRITING; 1582 cl->writing_state = MEI_WRITING;
@@ -1587,14 +1584,21 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1587 cb->completed = mei_hdr.msg_complete == 1; 1584 cb->completed = mei_hdr.msg_complete == 1;
1588 1585
1589 if (first_chunk) { 1586 if (first_chunk) {
1590 if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) 1587 if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
1591 return -EIO; 1588 rets = -EIO;
1589 goto err;
1590 }
1592 } 1591 }
1593 1592
1594 if (mei_hdr.msg_complete) 1593 if (mei_hdr.msg_complete)
1595 list_move_tail(&cb->list, &dev->write_waiting_list.list); 1594 list_move_tail(&cb->list, &dev->write_waiting_list.list);
1596 1595
1597 return 0; 1596 return 0;
1597
1598err:
1599 cl->status = rets;
1600 list_move_tail(&cb->list, &cmpl_list->list);
1601 return rets;
1598} 1602}
1599 1603
1600/** 1604/**
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 25d1eb4933d0..7e8cf213fd81 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1012,15 +1012,6 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
1012 goto out; 1012 goto out;
1013 } 1013 }
1014 1014
1015 /* Insert TSB and checksum infos */
1016 if (priv->tsb_en) {
1017 skb = bcm_sysport_insert_tsb(skb, dev);
1018 if (!skb) {
1019 ret = NETDEV_TX_OK;
1020 goto out;
1021 }
1022 }
1023
1024 /* The Ethernet switch we are interfaced with needs packets to be at 1015 /* The Ethernet switch we are interfaced with needs packets to be at
1025 * least 64 bytes (including FCS) otherwise they will be discarded when 1016 * least 64 bytes (including FCS) otherwise they will be discarded when
1026 * they enter the switch port logic. When Broadcom tags are enabled, we 1017 * they enter the switch port logic. When Broadcom tags are enabled, we
@@ -1028,13 +1019,21 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
1028 * (including FCS and tag) because the length verification is done after 1019 * (including FCS and tag) because the length verification is done after
1029 * the Broadcom tag is stripped off the ingress packet. 1020 * the Broadcom tag is stripped off the ingress packet.
1030 */ 1021 */
1031 if (skb_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) { 1022 if (skb_put_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) {
1032 ret = NETDEV_TX_OK; 1023 ret = NETDEV_TX_OK;
1033 goto out; 1024 goto out;
1034 } 1025 }
1035 1026
1036 skb_len = skb->len < ETH_ZLEN + ENET_BRCM_TAG_LEN ? 1027 /* Insert TSB and checksum infos */
1037 ETH_ZLEN + ENET_BRCM_TAG_LEN : skb->len; 1028 if (priv->tsb_en) {
1029 skb = bcm_sysport_insert_tsb(skb, dev);
1030 if (!skb) {
1031 ret = NETDEV_TX_OK;
1032 goto out;
1033 }
1034 }
1035
1036 skb_len = skb->len;
1038 1037
1039 mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); 1038 mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
1040 if (dma_mapping_error(kdev, mapping)) { 1039 if (dma_mapping_error(kdev, mapping)) {
diff --git a/drivers/net/ethernet/cadence/macb_pci.c b/drivers/net/ethernet/cadence/macb_pci.c
index 92be2cd8f817..9906fda76087 100644
--- a/drivers/net/ethernet/cadence/macb_pci.c
+++ b/drivers/net/ethernet/cadence/macb_pci.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * macb_pci.c - Cadence GEM PCI wrapper. 2 * Cadence GEM PCI wrapper.
3 * 3 *
4 * Copyright (C) 2016 Cadence Design Systems - http://www.cadence.com 4 * Copyright (C) 2016 Cadence Design Systems - http://www.cadence.com
5 * 5 *
@@ -45,32 +45,27 @@ static int macb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
45 struct macb_platform_data plat_data; 45 struct macb_platform_data plat_data;
46 struct resource res[2]; 46 struct resource res[2];
47 47
48 /* sanity check */
49 if (!id)
50 return -EINVAL;
51
52 /* enable pci device */ 48 /* enable pci device */
53 err = pci_enable_device(pdev); 49 err = pcim_enable_device(pdev);
54 if (err < 0) { 50 if (err < 0) {
55 dev_err(&pdev->dev, "Enabling PCI device has failed: 0x%04X", 51 dev_err(&pdev->dev, "Enabling PCI device has failed: %d", err);
56 err); 52 return err;
57 return -EACCES;
58 } 53 }
59 54
60 pci_set_master(pdev); 55 pci_set_master(pdev);
61 56
62 /* set up resources */ 57 /* set up resources */
63 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res)); 58 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
64 res[0].start = pdev->resource[0].start; 59 res[0].start = pci_resource_start(pdev, 0);
65 res[0].end = pdev->resource[0].end; 60 res[0].end = pci_resource_end(pdev, 0);
66 res[0].name = PCI_DRIVER_NAME; 61 res[0].name = PCI_DRIVER_NAME;
67 res[0].flags = IORESOURCE_MEM; 62 res[0].flags = IORESOURCE_MEM;
68 res[1].start = pdev->irq; 63 res[1].start = pci_irq_vector(pdev, 0);
69 res[1].name = PCI_DRIVER_NAME; 64 res[1].name = PCI_DRIVER_NAME;
70 res[1].flags = IORESOURCE_IRQ; 65 res[1].flags = IORESOURCE_IRQ;
71 66
72 dev_info(&pdev->dev, "EMAC physical base addr = 0x%p\n", 67 dev_info(&pdev->dev, "EMAC physical base addr: %pa\n",
73 (void *)(uintptr_t)pci_resource_start(pdev, 0)); 68 &res[0].start);
74 69
75 /* set up macb platform data */ 70 /* set up macb platform data */
76 memset(&plat_data, 0, sizeof(plat_data)); 71 memset(&plat_data, 0, sizeof(plat_data));
@@ -100,7 +95,7 @@ static int macb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
100 plat_info.num_res = ARRAY_SIZE(res); 95 plat_info.num_res = ARRAY_SIZE(res);
101 plat_info.data = &plat_data; 96 plat_info.data = &plat_data;
102 plat_info.size_data = sizeof(plat_data); 97 plat_info.size_data = sizeof(plat_data);
103 plat_info.dma_mask = DMA_BIT_MASK(32); 98 plat_info.dma_mask = pdev->dma_mask;
104 99
105 /* register platform device */ 100 /* register platform device */
106 plat_dev = platform_device_register_full(&plat_info); 101 plat_dev = platform_device_register_full(&plat_info);
@@ -120,7 +115,6 @@ err_hclk_register:
120 clk_unregister(plat_data.pclk); 115 clk_unregister(plat_data.pclk);
121 116
122err_pclk_register: 117err_pclk_register:
123 pci_disable_device(pdev);
124 return err; 118 return err;
125} 119}
126 120
@@ -130,7 +124,6 @@ static void macb_remove(struct pci_dev *pdev)
130 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev); 124 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev);
131 125
132 platform_device_unregister(plat_dev); 126 platform_device_unregister(plat_dev);
133 pci_disable_device(pdev);
134 clk_unregister(plat_data->pclk); 127 clk_unregister(plat_data->pclk);
135 clk_unregister(plat_data->hclk); 128 clk_unregister(plat_data->hclk);
136} 129}
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index bbc8bd16cb97..dcbce6cac63e 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -77,7 +77,7 @@ config OCTEON_MGMT_ETHERNET
77config LIQUIDIO_VF 77config LIQUIDIO_VF
78 tristate "Cavium LiquidIO VF support" 78 tristate "Cavium LiquidIO VF support"
79 depends on 64BIT && PCI_MSI 79 depends on 64BIT && PCI_MSI
80 select PTP_1588_CLOCK 80 imply PTP_1588_CLOCK
81 ---help--- 81 ---help---
82 This driver supports Cavium LiquidIO Intelligent Server Adapter 82 This driver supports Cavium LiquidIO Intelligent Server Adapter
83 based on CN23XX chips. 83 based on CN23XX chips.
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
index 0f0de5b63622..d04a6c163445 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c
@@ -133,17 +133,15 @@ cxgb_find_route6(struct cxgb4_lld_info *lldi,
133 if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL) 133 if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)
134 fl6.flowi6_oif = sin6_scope_id; 134 fl6.flowi6_oif = sin6_scope_id;
135 dst = ip6_route_output(&init_net, NULL, &fl6); 135 dst = ip6_route_output(&init_net, NULL, &fl6);
136 if (!dst) 136 if (dst->error ||
137 goto out; 137 (!cxgb_our_interface(lldi, get_real_dev,
138 if (!cxgb_our_interface(lldi, get_real_dev, 138 ip6_dst_idev(dst)->dev) &&
139 ip6_dst_idev(dst)->dev) && 139 !(ip6_dst_idev(dst)->dev->flags & IFF_LOOPBACK))) {
140 !(ip6_dst_idev(dst)->dev->flags & IFF_LOOPBACK)) {
141 dst_release(dst); 140 dst_release(dst);
142 dst = NULL; 141 return NULL;
143 } 142 }
144 } 143 }
145 144
146out:
147 return dst; 145 return dst;
148} 146}
149EXPORT_SYMBOL(cxgb_find_route6); 147EXPORT_SYMBOL(cxgb_find_route6);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 7e1633bf5a22..225e9a4877d7 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5155,7 +5155,9 @@ static netdev_features_t be_features_check(struct sk_buff *skb,
5155 skb->inner_protocol_type != ENCAP_TYPE_ETHER || 5155 skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
5156 skb->inner_protocol != htons(ETH_P_TEB) || 5156 skb->inner_protocol != htons(ETH_P_TEB) ||
5157 skb_inner_mac_header(skb) - skb_transport_header(skb) != 5157 skb_inner_mac_header(skb) - skb_transport_header(skb) !=
5158 sizeof(struct udphdr) + sizeof(struct vxlanhdr)) 5158 sizeof(struct udphdr) + sizeof(struct vxlanhdr) ||
5159 !adapter->vxlan_port ||
5160 udp_hdr(skb)->dest != adapter->vxlan_port)
5159 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 5161 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
5160 5162
5161 return features; 5163 return features;
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 624ba9058dc4..c9b7ad65e563 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -733,6 +733,7 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn; 733 priv->cgr_data.cgr.cb = dpaa_eth_cgscn;
734 734
735 /* Enable Congestion State Change Notifications and CS taildrop */ 735 /* Enable Congestion State Change Notifications and CS taildrop */
736 memset(&initcgr, 0, sizeof(initcgr));
736 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES); 737 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES);
737 initcgr.cgr.cscn_en = QM_CGR_EN; 738 initcgr.cgr.cscn_en = QM_CGR_EN;
738 739
@@ -2291,7 +2292,8 @@ static int dpaa_open(struct net_device *net_dev)
2291 net_dev->phydev = mac_dev->init_phy(net_dev, priv->mac_dev); 2292 net_dev->phydev = mac_dev->init_phy(net_dev, priv->mac_dev);
2292 if (!net_dev->phydev) { 2293 if (!net_dev->phydev) {
2293 netif_err(priv, ifup, net_dev, "init_phy() failed\n"); 2294 netif_err(priv, ifup, net_dev, "init_phy() failed\n");
2294 return -ENODEV; 2295 err = -ENODEV;
2296 goto phy_init_failed;
2295 } 2297 }
2296 2298
2297 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { 2299 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -2314,6 +2316,7 @@ mac_start_failed:
2314 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) 2316 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++)
2315 fman_port_disable(mac_dev->port[i]); 2317 fman_port_disable(mac_dev->port[i]);
2316 2318
2319phy_init_failed:
2317 dpaa_eth_napi_disable(priv); 2320 dpaa_eth_napi_disable(priv);
2318 2321
2319 return err; 2322 return err;
@@ -2420,6 +2423,7 @@ static int dpaa_ingress_cgr_init(struct dpaa_priv *priv)
2420 } 2423 }
2421 2424
2422 /* Enable CS TD, but disable Congestion State Change Notifications. */ 2425 /* Enable CS TD, but disable Congestion State Change Notifications. */
2426 memset(&initcgr, 0, sizeof(initcgr));
2423 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES); 2427 initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES);
2424 initcgr.cgr.cscn_en = QM_CGR_EN; 2428 initcgr.cgr.cscn_en = QM_CGR_EN;
2425 cs_th = DPAA_INGRESS_CS_THRESHOLD; 2429 cs_th = DPAA_INGRESS_CS_THRESHOLD;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 015198c14fa8..504461a464c5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -245,13 +245,9 @@ static u32 freq_to_shift(u16 freq)
245{ 245{
246 u32 freq_khz = freq * 1000; 246 u32 freq_khz = freq * 1000;
247 u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC; 247 u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC;
248 u64 tmp_rounded = 248 u64 max_val_cycles_rounded = 1ULL << fls64(max_val_cycles - 1);
249 roundup_pow_of_two(max_val_cycles) > max_val_cycles ?
250 roundup_pow_of_two(max_val_cycles) - 1 : UINT_MAX;
251 u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ?
252 max_val_cycles : tmp_rounded;
253 /* calculate max possible multiplier in order to fit in 64bit */ 249 /* calculate max possible multiplier in order to fit in 64bit */
254 u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded); 250 u64 max_mul = div64_u64(ULLONG_MAX, max_val_cycles_rounded);
255 251
256 /* This comes from the reverse of clocksource_khz2mult */ 252 /* This comes from the reverse of clocksource_khz2mult */
257 return ilog2(div_u64(max_mul * freq_khz, 1000000)); 253 return ilog2(div_u64(max_mul * freq_khz, 1000000));
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 3c37e216bbf3..eac527e25ec9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -445,8 +445,14 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
445 ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn; 445 ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn;
446 446
447 ring->stride = stride; 447 ring->stride = stride;
448 if (ring->stride <= TXBB_SIZE) 448 if (ring->stride <= TXBB_SIZE) {
449 /* Stamp first unused send wqe */
450 __be32 *ptr = (__be32 *)ring->buf;
451 __be32 stamp = cpu_to_be32(1 << STAMP_SHIFT);
452 *ptr = stamp;
453 /* Move pointer to start of rx section */
449 ring->buf += TXBB_SIZE; 454 ring->buf += TXBB_SIZE;
455 }
450 456
451 ring->log_stride = ffs(ring->stride) - 1; 457 ring->log_stride = ffs(ring->stride) - 1;
452 ring->buf_size = ring->size * ring->stride; 458 ring->buf_size = ring->size * ring->stride;
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
index 2a9dd460a95f..e1f9e7cebf8f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
118 if (!buf) 118 if (!buf)
119 return -ENOMEM; 119 return -ENOMEM;
120 120
121 if (offset_in_page(buf)) {
122 dma_free_coherent(dev, PAGE_SIZE << order,
123 buf, sg_dma_address(mem));
124 return -ENOMEM;
125 }
126
121 sg_set_buf(mem, buf, PAGE_SIZE << order); 127 sg_set_buf(mem, buf, PAGE_SIZE << order);
122 BUG_ON(mem->offset);
123 sg_dma_len(mem) = PAGE_SIZE << order; 128 sg_dma_len(mem) = PAGE_SIZE << order;
124 return 0; 129 return 0;
125} 130}
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 5e7840a7a33b..bffa6f345f2f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -42,6 +42,7 @@
42#include <linux/io-mapping.h> 42#include <linux/io-mapping.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/kmod.h> 44#include <linux/kmod.h>
45#include <linux/etherdevice.h>
45#include <net/devlink.h> 46#include <net/devlink.h>
46 47
47#include <linux/mlx4/device.h> 48#include <linux/mlx4/device.h>
@@ -782,6 +783,23 @@ int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
782} 783}
783EXPORT_SYMBOL(mlx4_is_slave_active); 784EXPORT_SYMBOL(mlx4_is_slave_active);
784 785
786void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
787 struct _rule_hw *eth_header)
788{
789 if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
790 is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
791 struct mlx4_net_trans_rule_hw_eth *eth =
792 (struct mlx4_net_trans_rule_hw_eth *)eth_header;
793 struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
794 bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
795 next_rule->rsvd == 0;
796
797 if (last_rule)
798 ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
799 }
800}
801EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
802
785static void slave_adjust_steering_mode(struct mlx4_dev *dev, 803static void slave_adjust_steering_mode(struct mlx4_dev *dev,
786 struct mlx4_dev_cap *dev_cap, 804 struct mlx4_dev_cap *dev_cap,
787 struct mlx4_init_hca_param *hca_param) 805 struct mlx4_init_hca_param *hca_param)
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index c548beaaf910..56185a0b827d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -4164,22 +4164,6 @@ static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header,
4164 return 0; 4164 return 0;
4165} 4165}
4166 4166
4167static void handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
4168 struct _rule_hw *eth_header)
4169{
4170 if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
4171 is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
4172 struct mlx4_net_trans_rule_hw_eth *eth =
4173 (struct mlx4_net_trans_rule_hw_eth *)eth_header;
4174 struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
4175 bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
4176 next_rule->rsvd == 0;
4177
4178 if (last_rule)
4179 ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
4180 }
4181}
4182
4183/* 4167/*
4184 * In case of missing eth header, append eth header with a MAC address 4168 * In case of missing eth header, append eth header with a MAC address
4185 * assigned to the VF. 4169 * assigned to the VF.
@@ -4363,10 +4347,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
4363 header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id)); 4347 header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
4364 4348
4365 if (header_id == MLX4_NET_TRANS_RULE_ID_ETH) 4349 if (header_id == MLX4_NET_TRANS_RULE_ID_ETH)
4366 handle_eth_header_mcast_prio(ctrl, rule_header); 4350 mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
4367
4368 if (slave == dev->caps.function)
4369 goto execute;
4370 4351
4371 switch (header_id) { 4352 switch (header_id) {
4372 case MLX4_NET_TRANS_RULE_ID_ETH: 4353 case MLX4_NET_TRANS_RULE_ID_ETH:
@@ -4394,7 +4375,6 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
4394 goto err_put_qp; 4375 goto err_put_qp;
4395 } 4376 }
4396 4377
4397execute:
4398 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param, 4378 err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
4399 vhcr->in_modifier, 0, 4379 vhcr->in_modifier, 0,
4400 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, 4380 MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
@@ -4473,6 +4453,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4473 struct res_qp *rqp; 4453 struct res_qp *rqp;
4474 struct res_fs_rule *rrule; 4454 struct res_fs_rule *rrule;
4475 u64 mirr_reg_id; 4455 u64 mirr_reg_id;
4456 int qpn;
4476 4457
4477 if (dev->caps.steering_mode != 4458 if (dev->caps.steering_mode !=
4478 MLX4_STEERING_MODE_DEVICE_MANAGED) 4459 MLX4_STEERING_MODE_DEVICE_MANAGED)
@@ -4489,10 +4470,11 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4489 } 4470 }
4490 mirr_reg_id = rrule->mirr_rule_id; 4471 mirr_reg_id = rrule->mirr_rule_id;
4491 kfree(rrule->mirr_mbox); 4472 kfree(rrule->mirr_mbox);
4473 qpn = rrule->qpn;
4492 4474
4493 /* Release the rule form busy state before removal */ 4475 /* Release the rule form busy state before removal */
4494 put_res(dev, slave, vhcr->in_param, RES_FS_RULE); 4476 put_res(dev, slave, vhcr->in_param, RES_FS_RULE);
4495 err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp); 4477 err = get_res(dev, slave, qpn, RES_QP, &rqp);
4496 if (err) 4478 if (err)
4497 return err; 4479 return err;
4498 4480
@@ -4517,7 +4499,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
4517 if (!err) 4499 if (!err)
4518 atomic_dec(&rqp->ref_count); 4500 atomic_dec(&rqp->ref_count);
4519out: 4501out:
4520 put_res(dev, slave, rrule->qpn, RES_QP); 4502 put_res(dev, slave, qpn, RES_QP);
4521 return err; 4503 return err;
4522} 4504}
4523 4505
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 7f6c225666c1..f0b460f47f29 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -723,6 +723,9 @@ static void mlx5e_ets_init(struct mlx5e_priv *priv)
723 int i; 723 int i;
724 struct ieee_ets ets; 724 struct ieee_ets ets;
725 725
726 if (!MLX5_CAP_GEN(priv->mdev, ets))
727 return;
728
726 memset(&ets, 0, sizeof(ets)); 729 memset(&ets, 0, sizeof(ets));
727 ets.ets_cap = mlx5_max_tc(priv->mdev) + 1; 730 ets.ets_cap = mlx5_max_tc(priv->mdev) + 1;
728 for (i = 0; i < ets.ets_cap; i++) { 731 for (i = 0; i < ets.ets_cap; i++) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 352462af8d51..33a399a8b5d5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -171,7 +171,6 @@ static int mlx5e_get_sset_count(struct net_device *dev, int sset)
171 return NUM_SW_COUNTERS + 171 return NUM_SW_COUNTERS +
172 MLX5E_NUM_Q_CNTRS(priv) + 172 MLX5E_NUM_Q_CNTRS(priv) +
173 NUM_VPORT_COUNTERS + NUM_PPORT_COUNTERS + 173 NUM_VPORT_COUNTERS + NUM_PPORT_COUNTERS +
174 NUM_PCIE_COUNTERS +
175 MLX5E_NUM_RQ_STATS(priv) + 174 MLX5E_NUM_RQ_STATS(priv) +
176 MLX5E_NUM_SQ_STATS(priv) + 175 MLX5E_NUM_SQ_STATS(priv) +
177 MLX5E_NUM_PFC_COUNTERS(priv) + 176 MLX5E_NUM_PFC_COUNTERS(priv) +
@@ -219,14 +218,6 @@ static void mlx5e_fill_stats_strings(struct mlx5e_priv *priv, uint8_t *data)
219 strcpy(data + (idx++) * ETH_GSTRING_LEN, 218 strcpy(data + (idx++) * ETH_GSTRING_LEN,
220 pport_2819_stats_desc[i].format); 219 pport_2819_stats_desc[i].format);
221 220
222 for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++)
223 strcpy(data + (idx++) * ETH_GSTRING_LEN,
224 pcie_perf_stats_desc[i].format);
225
226 for (i = 0; i < NUM_PCIE_TAS_COUNTERS; i++)
227 strcpy(data + (idx++) * ETH_GSTRING_LEN,
228 pcie_tas_stats_desc[i].format);
229
230 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { 221 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
231 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) 222 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
232 sprintf(data + (idx++) * ETH_GSTRING_LEN, 223 sprintf(data + (idx++) * ETH_GSTRING_LEN,
@@ -339,14 +330,6 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
339 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.RFC_2819_counters, 330 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.RFC_2819_counters,
340 pport_2819_stats_desc, i); 331 pport_2819_stats_desc, i);
341 332
342 for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++)
343 data[idx++] = MLX5E_READ_CTR32_BE(&priv->stats.pcie.pcie_perf_counters,
344 pcie_perf_stats_desc, i);
345
346 for (i = 0; i < NUM_PCIE_TAS_COUNTERS; i++)
347 data[idx++] = MLX5E_READ_CTR32_BE(&priv->stats.pcie.pcie_tas_counters,
348 pcie_tas_stats_desc, i);
349
350 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { 333 for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
351 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) 334 for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
352 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[prio], 335 data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[prio],
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index 3691451c728c..d088effd7160 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -247,6 +247,7 @@ static int set_flow_attrs(u32 *match_c, u32 *match_v,
247 } 247 }
248 if (fs->flow_type & FLOW_MAC_EXT && 248 if (fs->flow_type & FLOW_MAC_EXT &&
249 !is_zero_ether_addr(fs->m_ext.h_dest)) { 249 !is_zero_ether_addr(fs->m_ext.h_dest)) {
250 mask_spec(fs->m_ext.h_dest, fs->h_ext.h_dest, ETH_ALEN);
250 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, 251 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
251 outer_headers_c, dmac_47_16), 252 outer_headers_c, dmac_47_16),
252 fs->m_ext.h_dest); 253 fs->m_ext.h_dest);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index cbfa38fc72c0..1236b27b1493 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -291,36 +291,12 @@ static void mlx5e_update_q_counter(struct mlx5e_priv *priv)
291 &qcnt->rx_out_of_buffer); 291 &qcnt->rx_out_of_buffer);
292} 292}
293 293
294static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
295{
296 struct mlx5e_pcie_stats *pcie_stats = &priv->stats.pcie;
297 struct mlx5_core_dev *mdev = priv->mdev;
298 int sz = MLX5_ST_SZ_BYTES(mpcnt_reg);
299 void *out;
300 u32 *in;
301
302 in = mlx5_vzalloc(sz);
303 if (!in)
304 return;
305
306 out = pcie_stats->pcie_perf_counters;
307 MLX5_SET(mpcnt_reg, in, grp, MLX5_PCIE_PERFORMANCE_COUNTERS_GROUP);
308 mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
309
310 out = pcie_stats->pcie_tas_counters;
311 MLX5_SET(mpcnt_reg, in, grp, MLX5_PCIE_TIMERS_AND_STATES_COUNTERS_GROUP);
312 mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
313
314 kvfree(in);
315}
316
317void mlx5e_update_stats(struct mlx5e_priv *priv) 294void mlx5e_update_stats(struct mlx5e_priv *priv)
318{ 295{
319 mlx5e_update_q_counter(priv); 296 mlx5e_update_q_counter(priv);
320 mlx5e_update_vport_counters(priv); 297 mlx5e_update_vport_counters(priv);
321 mlx5e_update_pport_counters(priv); 298 mlx5e_update_pport_counters(priv);
322 mlx5e_update_sw_counters(priv); 299 mlx5e_update_sw_counters(priv);
323 mlx5e_update_pcie_counters(priv);
324} 300}
325 301
326void mlx5e_update_stats_work(struct work_struct *work) 302void mlx5e_update_stats_work(struct work_struct *work)
@@ -3805,14 +3781,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3805 3781
3806 mlx5_lag_add(mdev, netdev); 3782 mlx5_lag_add(mdev, netdev);
3807 3783
3808 if (mlx5e_vxlan_allowed(mdev)) {
3809 rtnl_lock();
3810 udp_tunnel_get_rx_info(netdev);
3811 rtnl_unlock();
3812 }
3813
3814 mlx5e_enable_async_events(priv); 3784 mlx5e_enable_async_events(priv);
3815 queue_work(priv->wq, &priv->set_rx_mode_work);
3816 3785
3817 if (MLX5_CAP_GEN(mdev, vport_group_manager)) { 3786 if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
3818 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id); 3787 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
@@ -3822,6 +3791,18 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3822 rep.netdev = netdev; 3791 rep.netdev = netdev;
3823 mlx5_eswitch_register_vport_rep(esw, 0, &rep); 3792 mlx5_eswitch_register_vport_rep(esw, 0, &rep);
3824 } 3793 }
3794
3795 if (netdev->reg_state != NETREG_REGISTERED)
3796 return;
3797
3798 /* Device already registered: sync netdev system state */
3799 if (mlx5e_vxlan_allowed(mdev)) {
3800 rtnl_lock();
3801 udp_tunnel_get_rx_info(netdev);
3802 rtnl_unlock();
3803 }
3804
3805 queue_work(priv->wq, &priv->set_rx_mode_work);
3825} 3806}
3826 3807
3827static void mlx5e_nic_disable(struct mlx5e_priv *priv) 3808static void mlx5e_nic_disable(struct mlx5e_priv *priv)
@@ -3966,10 +3947,6 @@ void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3966 const struct mlx5e_profile *profile = priv->profile; 3947 const struct mlx5e_profile *profile = priv->profile;
3967 3948
3968 set_bit(MLX5E_STATE_DESTROYING, &priv->state); 3949 set_bit(MLX5E_STATE_DESTROYING, &priv->state);
3969 if (profile->disable)
3970 profile->disable(priv);
3971
3972 flush_workqueue(priv->wq);
3973 3950
3974 rtnl_lock(); 3951 rtnl_lock();
3975 if (netif_running(netdev)) 3952 if (netif_running(netdev))
@@ -3977,6 +3954,10 @@ void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3977 netif_device_detach(netdev); 3954 netif_device_detach(netdev);
3978 rtnl_unlock(); 3955 rtnl_unlock();
3979 3956
3957 if (profile->disable)
3958 profile->disable(priv);
3959 flush_workqueue(priv->wq);
3960
3980 mlx5e_destroy_q_counter(priv); 3961 mlx5e_destroy_q_counter(priv);
3981 profile->cleanup_rx(priv); 3962 profile->cleanup_rx(priv);
3982 mlx5e_close_drop_rq(priv); 3963 mlx5e_close_drop_rq(priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index f202f872f57f..ba5db1dd23a9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -39,7 +39,7 @@
39#define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \ 39#define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \
40 (*(u32 *)((char *)ptr + dsc[i].offset)) 40 (*(u32 *)((char *)ptr + dsc[i].offset))
41#define MLX5E_READ_CTR32_BE(ptr, dsc, i) \ 41#define MLX5E_READ_CTR32_BE(ptr, dsc, i) \
42 be32_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset)) 42 be64_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
43 43
44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld) 44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld) 45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld)
@@ -276,32 +276,6 @@ static const struct counter_desc pport_per_prio_pfc_stats_desc[] = {
276 { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) }, 276 { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) },
277}; 277};
278 278
279#define PCIE_PERF_OFF(c) \
280 MLX5_BYTE_OFF(mpcnt_reg, counter_set.pcie_perf_cntrs_grp_data_layout.c)
281#define PCIE_PERF_GET(pcie_stats, c) \
282 MLX5_GET(mpcnt_reg, pcie_stats->pcie_perf_counters, \
283 counter_set.pcie_perf_cntrs_grp_data_layout.c)
284#define PCIE_TAS_OFF(c) \
285 MLX5_BYTE_OFF(mpcnt_reg, counter_set.pcie_tas_cntrs_grp_data_layout.c)
286#define PCIE_TAS_GET(pcie_stats, c) \
287 MLX5_GET(mpcnt_reg, pcie_stats->pcie_tas_counters, \
288 counter_set.pcie_tas_cntrs_grp_data_layout.c)
289
290struct mlx5e_pcie_stats {
291 __be64 pcie_perf_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
292 __be64 pcie_tas_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
293};
294
295static const struct counter_desc pcie_perf_stats_desc[] = {
296 { "rx_pci_signal_integrity", PCIE_PERF_OFF(rx_errors) },
297 { "tx_pci_signal_integrity", PCIE_PERF_OFF(tx_errors) },
298};
299
300static const struct counter_desc pcie_tas_stats_desc[] = {
301 { "tx_pci_transport_nonfatal_msg", PCIE_TAS_OFF(non_fatal_err_msg_sent) },
302 { "tx_pci_transport_fatal_msg", PCIE_TAS_OFF(fatal_err_msg_sent) },
303};
304
305struct mlx5e_rq_stats { 279struct mlx5e_rq_stats {
306 u64 packets; 280 u64 packets;
307 u64 bytes; 281 u64 bytes;
@@ -386,8 +360,6 @@ static const struct counter_desc sq_stats_desc[] = {
386#define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc) 360#define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc)
387#define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc) 361#define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc)
388#define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc) 362#define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc)
389#define NUM_PCIE_PERF_COUNTERS ARRAY_SIZE(pcie_perf_stats_desc)
390#define NUM_PCIE_TAS_COUNTERS ARRAY_SIZE(pcie_tas_stats_desc)
391#define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \ 363#define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \
392 ARRAY_SIZE(pport_per_prio_traffic_stats_desc) 364 ARRAY_SIZE(pport_per_prio_traffic_stats_desc)
393#define NUM_PPORT_PER_PRIO_PFC_COUNTERS \ 365#define NUM_PPORT_PER_PRIO_PFC_COUNTERS \
@@ -397,7 +369,6 @@ static const struct counter_desc sq_stats_desc[] = {
397 NUM_PPORT_2819_COUNTERS + \ 369 NUM_PPORT_2819_COUNTERS + \
398 NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \ 370 NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \
399 NUM_PPORT_PRIO) 371 NUM_PPORT_PRIO)
400#define NUM_PCIE_COUNTERS (NUM_PCIE_PERF_COUNTERS + NUM_PCIE_TAS_COUNTERS)
401#define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc) 372#define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc)
402#define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc) 373#define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc)
403 374
@@ -406,7 +377,6 @@ struct mlx5e_stats {
406 struct mlx5e_qcounter_stats qcnt; 377 struct mlx5e_qcounter_stats qcnt;
407 struct mlx5e_vport_stats vport; 378 struct mlx5e_vport_stats vport;
408 struct mlx5e_pport_stats pport; 379 struct mlx5e_pport_stats pport;
409 struct mlx5e_pcie_stats pcie;
410 struct rtnl_link_stats64 vf_vport; 380 struct rtnl_link_stats64 vf_vport;
411}; 381};
412 382
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index d6807c3cc461..f14d9c9ba773 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1860,7 +1860,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
1860 1860
1861 if (!ESW_ALLOWED(esw)) 1861 if (!ESW_ALLOWED(esw))
1862 return -EPERM; 1862 return -EPERM;
1863 if (!LEGAL_VPORT(esw, vport)) 1863 if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
1864 return -EINVAL; 1864 return -EINVAL;
1865 1865
1866 mutex_lock(&esw->state_lock); 1866 mutex_lock(&esw->state_lock);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 466e161010f7..03293ed1cc22 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -695,6 +695,12 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
695 if (err) 695 if (err)
696 goto err_reps; 696 goto err_reps;
697 } 697 }
698
699 /* disable PF RoCE so missed packets don't go through RoCE steering */
700 mlx5_dev_list_lock();
701 mlx5_remove_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
702 mlx5_dev_list_unlock();
703
698 return 0; 704 return 0;
699 705
700err_reps: 706err_reps:
@@ -718,6 +724,11 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw)
718{ 724{
719 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs; 725 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
720 726
727 /* enable back PF RoCE */
728 mlx5_dev_list_lock();
729 mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
730 mlx5_dev_list_unlock();
731
721 mlx5_eswitch_disable_sriov(esw); 732 mlx5_eswitch_disable_sriov(esw);
722 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY); 733 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
723 if (err) { 734 if (err) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index a263d8904a4c..0ac7a2fc916c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1263,6 +1263,7 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
1263 nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD); 1263 nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD);
1264 handle = add_rule_fte(fte, fg, dest, dest_num, false); 1264 handle = add_rule_fte(fte, fg, dest, dest_num, false);
1265 if (IS_ERR(handle)) { 1265 if (IS_ERR(handle)) {
1266 unlock_ref_node(&fte->node);
1266 kfree(fte); 1267 kfree(fte);
1267 goto unlock_fg; 1268 goto unlock_fg;
1268 } 1269 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 54e5a786f191..6547f22e6b9b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -503,6 +503,13 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
503 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size, 503 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size,
504 to_fw_pkey_sz(dev, 128)); 504 to_fw_pkey_sz(dev, 128));
505 505
506 /* Check log_max_qp from HCA caps to set in current profile */
507 if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) {
508 mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n",
509 profile[prof_sel].log_max_qp,
510 MLX5_CAP_GEN_MAX(dev, log_max_qp));
511 profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
512 }
506 if (prof->mask & MLX5_PROF_MASK_QP_SIZE) 513 if (prof->mask & MLX5_PROF_MASK_QP_SIZE)
507 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp, 514 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
508 prof->log_max_qp); 515 prof->log_max_qp);
@@ -575,7 +582,6 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
575 struct mlx5_priv *priv = &mdev->priv; 582 struct mlx5_priv *priv = &mdev->priv;
576 struct msix_entry *msix = priv->msix_arr; 583 struct msix_entry *msix = priv->msix_arr;
577 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector; 584 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector;
578 int numa_node = priv->numa_node;
579 int err; 585 int err;
580 586
581 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) { 587 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) {
@@ -583,7 +589,7 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
583 return -ENOMEM; 589 return -ENOMEM;
584 } 590 }
585 591
586 cpumask_set_cpu(cpumask_local_spread(i, numa_node), 592 cpumask_set_cpu(cpumask_local_spread(i, priv->numa_node),
587 priv->irq_info[i].mask); 593 priv->irq_info[i].mask);
588 594
589 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask); 595 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask);
@@ -1189,6 +1195,8 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
1189{ 1195{
1190 int err = 0; 1196 int err = 0;
1191 1197
1198 mlx5_drain_health_wq(dev);
1199
1192 mutex_lock(&dev->intf_state_mutex); 1200 mutex_lock(&dev->intf_state_mutex);
1193 if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) { 1201 if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) {
1194 dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n", 1202 dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n",
@@ -1351,10 +1359,9 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
1351 1359
1352 mlx5_enter_error_state(dev); 1360 mlx5_enter_error_state(dev);
1353 mlx5_unload_one(dev, priv, false); 1361 mlx5_unload_one(dev, priv, false);
1354 /* In case of kernel call save the pci state and drain health wq */ 1362 /* In case of kernel call save the pci state */
1355 if (state) { 1363 if (state) {
1356 pci_save_state(pdev); 1364 pci_save_state(pdev);
1357 mlx5_drain_health_wq(dev);
1358 mlx5_pci_disable_device(dev); 1365 mlx5_pci_disable_device(dev);
1359 } 1366 }
1360 1367
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index f341c1bc7001..00fafabab1d0 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -819,6 +819,7 @@ static struct sh_eth_cpu_data sh7734_data = {
819 .tsu = 1, 819 .tsu = 1,
820 .hw_crc = 1, 820 .hw_crc = 1,
821 .select_mii = 1, 821 .select_mii = 1,
822 .shift_rd0 = 1,
822}; 823};
823 824
824/* SH7763 */ 825/* SH7763 */
@@ -1656,7 +1657,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
1656 else 1657 else
1657 goto out; 1658 goto out;
1658 1659
1659 if (!likely(mdp->irq_enabled)) { 1660 if (unlikely(!mdp->irq_enabled)) {
1660 sh_eth_write(ndev, 0, EESIPR); 1661 sh_eth_write(ndev, 0, EESIPR);
1661 goto out; 1662 goto out;
1662 } 1663 }
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index de2947ccc5ad..5eb0e684fd76 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -1323,7 +1323,8 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
1323 } 1323 }
1324 1324
1325 /* don't fail init if RSS setup doesn't work */ 1325 /* don't fail init if RSS setup doesn't work */
1326 efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table); 1326 rc = efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table);
1327 efx->rss_active = (rc == 0);
1327 1328
1328 return 0; 1329 return 0;
1329} 1330}
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 87bdc56b4e3a..18ebaea44e82 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -975,6 +975,8 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,
975 975
976 case ETHTOOL_GRXFH: { 976 case ETHTOOL_GRXFH: {
977 info->data = 0; 977 info->data = 0;
978 if (!efx->rss_active) /* No RSS */
979 return 0;
978 switch (info->flow_type) { 980 switch (info->flow_type) {
979 case UDP_V4_FLOW: 981 case UDP_V4_FLOW:
980 if (efx->rx_hash_udp_4tuple) 982 if (efx->rx_hash_udp_4tuple)
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index 1a635ced62d0..1c62c1a00fca 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -860,6 +860,7 @@ struct vfdi_status;
860 * @rx_hash_key: Toeplitz hash key for RSS 860 * @rx_hash_key: Toeplitz hash key for RSS
861 * @rx_indir_table: Indirection table for RSS 861 * @rx_indir_table: Indirection table for RSS
862 * @rx_scatter: Scatter mode enabled for receives 862 * @rx_scatter: Scatter mode enabled for receives
863 * @rss_active: RSS enabled on hardware
863 * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled 864 * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled
864 * @int_error_count: Number of internal errors seen recently 865 * @int_error_count: Number of internal errors seen recently
865 * @int_error_expire: Time at which error count will be expired 866 * @int_error_expire: Time at which error count will be expired
@@ -998,6 +999,7 @@ struct efx_nic {
998 u8 rx_hash_key[40]; 999 u8 rx_hash_key[40];
999 u32 rx_indir_table[128]; 1000 u32 rx_indir_table[128];
1000 bool rx_scatter; 1001 bool rx_scatter;
1002 bool rss_active;
1001 bool rx_hash_udp_4tuple; 1003 bool rx_hash_udp_4tuple;
1002 1004
1003 unsigned int_error_count; 1005 unsigned int_error_count;
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
index a3901bc96586..4e54e5dc9fcb 100644
--- a/drivers/net/ethernet/sfc/siena.c
+++ b/drivers/net/ethernet/sfc/siena.c
@@ -403,6 +403,7 @@ static int siena_init_nic(struct efx_nic *efx)
403 efx_writeo(efx, &temp, FR_AZ_RX_CFG); 403 efx_writeo(efx, &temp, FR_AZ_RX_CFG);
404 404
405 siena_rx_push_rss_config(efx, false, efx->rx_indir_table); 405 siena_rx_push_rss_config(efx, false, efx->rx_indir_table);
406 efx->rss_active = true;
406 407
407 /* Enable event logging */ 408 /* Enable event logging */
408 rc = efx_mcdi_log_ctrl(efx, true, false, 0); 409 rc = efx_mcdi_log_ctrl(efx, true, false, 0);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
index c35597586121..3dc7d279f805 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
@@ -60,8 +60,9 @@ struct oxnas_dwmac {
60 struct regmap *regmap; 60 struct regmap *regmap;
61}; 61};
62 62
63static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac) 63static int oxnas_dwmac_init(struct platform_device *pdev, void *priv)
64{ 64{
65 struct oxnas_dwmac *dwmac = priv;
65 unsigned int value; 66 unsigned int value;
66 int ret; 67 int ret;
67 68
@@ -105,20 +106,20 @@ static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
105 return 0; 106 return 0;
106} 107}
107 108
109static void oxnas_dwmac_exit(struct platform_device *pdev, void *priv)
110{
111 struct oxnas_dwmac *dwmac = priv;
112
113 clk_disable_unprepare(dwmac->clk);
114}
115
108static int oxnas_dwmac_probe(struct platform_device *pdev) 116static int oxnas_dwmac_probe(struct platform_device *pdev)
109{ 117{
110 struct plat_stmmacenet_data *plat_dat; 118 struct plat_stmmacenet_data *plat_dat;
111 struct stmmac_resources stmmac_res; 119 struct stmmac_resources stmmac_res;
112 struct device_node *sysctrl;
113 struct oxnas_dwmac *dwmac; 120 struct oxnas_dwmac *dwmac;
114 int ret; 121 int ret;
115 122
116 sysctrl = of_parse_phandle(pdev->dev.of_node, "oxsemi,sys-ctrl", 0);
117 if (!sysctrl) {
118 dev_err(&pdev->dev, "failed to get sys-ctrl node\n");
119 return -EINVAL;
120 }
121
122 ret = stmmac_get_platform_resources(pdev, &stmmac_res); 123 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
123 if (ret) 124 if (ret)
124 return ret; 125 return ret;
@@ -128,72 +129,48 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
128 return PTR_ERR(plat_dat); 129 return PTR_ERR(plat_dat);
129 130
130 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 131 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
131 if (!dwmac) 132 if (!dwmac) {
132 return -ENOMEM; 133 ret = -ENOMEM;
134 goto err_remove_config_dt;
135 }
133 136
134 dwmac->dev = &pdev->dev; 137 dwmac->dev = &pdev->dev;
135 plat_dat->bsp_priv = dwmac; 138 plat_dat->bsp_priv = dwmac;
139 plat_dat->init = oxnas_dwmac_init;
140 plat_dat->exit = oxnas_dwmac_exit;
136 141
137 dwmac->regmap = syscon_node_to_regmap(sysctrl); 142 dwmac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
143 "oxsemi,sys-ctrl");
138 if (IS_ERR(dwmac->regmap)) { 144 if (IS_ERR(dwmac->regmap)) {
139 dev_err(&pdev->dev, "failed to have sysctrl regmap\n"); 145 dev_err(&pdev->dev, "failed to have sysctrl regmap\n");
140 return PTR_ERR(dwmac->regmap); 146 ret = PTR_ERR(dwmac->regmap);
147 goto err_remove_config_dt;
141 } 148 }
142 149
143 dwmac->clk = devm_clk_get(&pdev->dev, "gmac"); 150 dwmac->clk = devm_clk_get(&pdev->dev, "gmac");
144 if (IS_ERR(dwmac->clk)) 151 if (IS_ERR(dwmac->clk)) {
145 return PTR_ERR(dwmac->clk); 152 ret = PTR_ERR(dwmac->clk);
153 goto err_remove_config_dt;
154 }
146 155
147 ret = oxnas_dwmac_init(dwmac); 156 ret = oxnas_dwmac_init(pdev, plat_dat->bsp_priv);
148 if (ret) 157 if (ret)
149 return ret; 158 goto err_remove_config_dt;
150 159
151 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 160 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
152 if (ret) 161 if (ret)
153 clk_disable_unprepare(dwmac->clk); 162 goto err_dwmac_exit;
154 163
155 return ret;
156}
157 164
158static int oxnas_dwmac_remove(struct platform_device *pdev) 165 return 0;
159{
160 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
161 int ret = stmmac_dvr_remove(&pdev->dev);
162
163 clk_disable_unprepare(dwmac->clk);
164
165 return ret;
166}
167
168#ifdef CONFIG_PM_SLEEP
169static int oxnas_dwmac_suspend(struct device *dev)
170{
171 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
172 int ret;
173
174 ret = stmmac_suspend(dev);
175 clk_disable_unprepare(dwmac->clk);
176
177 return ret;
178}
179
180static int oxnas_dwmac_resume(struct device *dev)
181{
182 struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
183 int ret;
184
185 ret = oxnas_dwmac_init(dwmac);
186 if (ret)
187 return ret;
188 166
189 ret = stmmac_resume(dev); 167err_dwmac_exit:
168 oxnas_dwmac_exit(pdev, plat_dat->bsp_priv);
169err_remove_config_dt:
170 stmmac_remove_config_dt(pdev, plat_dat);
190 171
191 return ret; 172 return ret;
192} 173}
193#endif /* CONFIG_PM_SLEEP */
194
195static SIMPLE_DEV_PM_OPS(oxnas_dwmac_pm_ops,
196 oxnas_dwmac_suspend, oxnas_dwmac_resume);
197 174
198static const struct of_device_id oxnas_dwmac_match[] = { 175static const struct of_device_id oxnas_dwmac_match[] = {
199 { .compatible = "oxsemi,ox820-dwmac" }, 176 { .compatible = "oxsemi,ox820-dwmac" },
@@ -203,10 +180,10 @@ MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
203 180
204static struct platform_driver oxnas_dwmac_driver = { 181static struct platform_driver oxnas_dwmac_driver = {
205 .probe = oxnas_dwmac_probe, 182 .probe = oxnas_dwmac_probe,
206 .remove = oxnas_dwmac_remove, 183 .remove = stmmac_pltfr_remove,
207 .driver = { 184 .driver = {
208 .name = "oxnas-dwmac", 185 .name = "oxnas-dwmac",
209 .pm = &oxnas_dwmac_pm_ops, 186 .pm = &stmmac_pltfr_pm_ops,
210 .of_match_table = oxnas_dwmac_match, 187 .of_match_table = oxnas_dwmac_match,
211 }, 188 },
212}; 189};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index bb40382e205d..39eb7a65bb9f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3339,13 +3339,6 @@ int stmmac_dvr_probe(struct device *device,
3339 3339
3340 spin_lock_init(&priv->lock); 3340 spin_lock_init(&priv->lock);
3341 3341
3342 ret = register_netdev(ndev);
3343 if (ret) {
3344 netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
3345 __func__, ret);
3346 goto error_netdev_register;
3347 }
3348
3349 /* If a specific clk_csr value is passed from the platform 3342 /* If a specific clk_csr value is passed from the platform
3350 * this means that the CSR Clock Range selection cannot be 3343 * this means that the CSR Clock Range selection cannot be
3351 * changed at run-time and it is fixed. Viceversa the driver'll try to 3344 * changed at run-time and it is fixed. Viceversa the driver'll try to
@@ -3372,11 +3365,21 @@ int stmmac_dvr_probe(struct device *device,
3372 } 3365 }
3373 } 3366 }
3374 3367
3375 return 0; 3368 ret = register_netdev(ndev);
3369 if (ret) {
3370 netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
3371 __func__, ret);
3372 goto error_netdev_register;
3373 }
3374
3375 return ret;
3376 3376
3377error_mdio_register:
3378 unregister_netdev(ndev);
3379error_netdev_register: 3377error_netdev_register:
3378 if (priv->hw->pcs != STMMAC_PCS_RGMII &&
3379 priv->hw->pcs != STMMAC_PCS_TBI &&
3380 priv->hw->pcs != STMMAC_PCS_RTBI)
3381 stmmac_mdio_unregister(ndev);
3382error_mdio_register:
3380 netif_napi_del(&priv->napi); 3383 netif_napi_del(&priv->napi);
3381error_hw_init: 3384error_hw_init:
3382 clk_disable_unprepare(priv->pclk); 3385 clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 6c646e228833..6e98ede997d3 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -1367,6 +1367,7 @@ static struct usb_driver asix_driver = {
1367 .probe = usbnet_probe, 1367 .probe = usbnet_probe,
1368 .suspend = asix_suspend, 1368 .suspend = asix_suspend,
1369 .resume = asix_resume, 1369 .resume = asix_resume,
1370 .reset_resume = asix_resume,
1370 .disconnect = usbnet_disconnect, 1371 .disconnect = usbnet_disconnect,
1371 .supports_autosuspend = 1, 1372 .supports_autosuspend = 1,
1372 .disable_hub_initiated_lpm = 1, 1373 .disable_hub_initiated_lpm = 1,
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 7532646c3b7b..23dfb0eac098 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -967,6 +967,7 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
967 */ 967 */
968 need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr); 968 need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr);
969 if (!ipv6_ndisc_frame(skb) && !need_strict) { 969 if (!ipv6_ndisc_frame(skb) && !need_strict) {
970 vrf_rx_stats(vrf_dev, skb->len);
970 skb->dev = vrf_dev; 971 skb->dev = vrf_dev;
971 skb->skb_iif = vrf_dev->ifindex; 972 skb->skb_iif = vrf_dev->ifindex;
972 973
@@ -1011,6 +1012,8 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev,
1011 goto out; 1012 goto out;
1012 } 1013 }
1013 1014
1015 vrf_rx_stats(vrf_dev, skb->len);
1016
1014 skb_push(skb, skb->mac_len); 1017 skb_push(skb, skb->mac_len);
1015 dev_queue_xmit_nit(skb, vrf_dev); 1018 dev_queue_xmit_nit(skb, vrf_dev);
1016 skb_pull(skb, skb->mac_len); 1019 skb_pull(skb, skb->mac_len);
diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index b776a0ab106c..9d9b4e0def2a 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -218,7 +218,7 @@ static int slic_ds26522_probe(struct spi_device *spi)
218 218
219 ret = slic_ds26522_init_configure(spi); 219 ret = slic_ds26522_init_configure(spi);
220 if (ret == 0) 220 if (ret == 0)
221 pr_info("DS26522 cs%d configurated\n", spi->chip_select); 221 pr_info("DS26522 cs%d configured\n", spi->chip_select);
222 222
223 return ret; 223 return ret;
224} 224}
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b40cfb076f02..2fc86dc7a8df 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1193,8 +1193,8 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
1193 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); 1193 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
1194 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); 1194 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
1195 } 1195 }
1196 if (ctrl->stripe_size) 1196 if (ctrl->quirks & NVME_QUIRK_STRIPE_SIZE)
1197 blk_queue_chunk_sectors(q, ctrl->stripe_size >> 9); 1197 blk_queue_chunk_sectors(q, ctrl->max_hw_sectors);
1198 blk_queue_virt_boundary(q, ctrl->page_size - 1); 1198 blk_queue_virt_boundary(q, ctrl->page_size - 1);
1199 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) 1199 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
1200 vwc = true; 1200 vwc = true;
@@ -1250,19 +1250,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1250 ctrl->max_hw_sectors = 1250 ctrl->max_hw_sectors =
1251 min_not_zero(ctrl->max_hw_sectors, max_hw_sectors); 1251 min_not_zero(ctrl->max_hw_sectors, max_hw_sectors);
1252 1252
1253 if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && id->vs[3]) {
1254 unsigned int max_hw_sectors;
1255
1256 ctrl->stripe_size = 1 << (id->vs[3] + page_shift);
1257 max_hw_sectors = ctrl->stripe_size >> (page_shift - 9);
1258 if (ctrl->max_hw_sectors) {
1259 ctrl->max_hw_sectors = min(max_hw_sectors,
1260 ctrl->max_hw_sectors);
1261 } else {
1262 ctrl->max_hw_sectors = max_hw_sectors;
1263 }
1264 }
1265
1266 nvme_set_queue_limits(ctrl, ctrl->admin_q); 1253 nvme_set_queue_limits(ctrl, ctrl->admin_q);
1267 ctrl->sgls = le32_to_cpu(id->sgls); 1254 ctrl->sgls = le32_to_cpu(id->sgls);
1268 ctrl->kas = le16_to_cpu(id->kas); 1255 ctrl->kas = le16_to_cpu(id->kas);
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 771e2e761872..aa0bc60810a7 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1491,19 +1491,20 @@ static int
1491nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) 1491nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)
1492{ 1492{
1493 struct nvme_fc_queue *queue = &ctrl->queues[1]; 1493 struct nvme_fc_queue *queue = &ctrl->queues[1];
1494 int i, j, ret; 1494 int i, ret;
1495 1495
1496 for (i = 1; i < ctrl->queue_count; i++, queue++) { 1496 for (i = 1; i < ctrl->queue_count; i++, queue++) {
1497 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); 1497 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize);
1498 if (ret) { 1498 if (ret)
1499 for (j = i-1; j >= 0; j--) 1499 goto delete_queues;
1500 __nvme_fc_delete_hw_queue(ctrl,
1501 &ctrl->queues[j], j);
1502 return ret;
1503 }
1504 } 1500 }
1505 1501
1506 return 0; 1502 return 0;
1503
1504delete_queues:
1505 for (; i >= 0; i--)
1506 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i);
1507 return ret;
1507} 1508}
1508 1509
1509static int 1510static int
@@ -2401,8 +2402,8 @@ __nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2401 WARN_ON_ONCE(!changed); 2402 WARN_ON_ONCE(!changed);
2402 2403
2403 dev_info(ctrl->ctrl.device, 2404 dev_info(ctrl->ctrl.device,
2404 "NVME-FC{%d}: new ctrl: NQN \"%s\" (%p)\n", 2405 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n",
2405 ctrl->cnum, ctrl->ctrl.opts->subsysnqn, &ctrl); 2406 ctrl->cnum, ctrl->ctrl.opts->subsysnqn);
2406 2407
2407 kref_get(&ctrl->ctrl.kref); 2408 kref_get(&ctrl->ctrl.kref);
2408 2409
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index bd5321441d12..6377e14586dc 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -135,7 +135,6 @@ struct nvme_ctrl {
135 135
136 u32 page_size; 136 u32 page_size;
137 u32 max_hw_sectors; 137 u32 max_hw_sectors;
138 u32 stripe_size;
139 u16 oncs; 138 u16 oncs;
140 u16 vid; 139 u16 vid;
141 atomic_t abort_limit; 140 atomic_t abort_limit;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3d21a154dce7..19beeb7b2ac2 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -712,15 +712,8 @@ static void __nvme_process_cq(struct nvme_queue *nvmeq, unsigned int *tag)
712 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe.command_id); 712 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe.command_id);
713 nvme_req(req)->result = cqe.result; 713 nvme_req(req)->result = cqe.result;
714 blk_mq_complete_request(req, le16_to_cpu(cqe.status) >> 1); 714 blk_mq_complete_request(req, le16_to_cpu(cqe.status) >> 1);
715
716 } 715 }
717 716
718 /* If the controller ignores the cq head doorbell and continuously
719 * writes to the queue, it is theoretically possible to wrap around
720 * the queue twice and mistakenly return IRQ_NONE. Linux only
721 * requires that 0.1% of your interrupts are handled, so this isn't
722 * a big problem.
723 */
724 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase) 717 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
725 return; 718 return;
726 719
@@ -1909,10 +1902,10 @@ static int nvme_dev_map(struct nvme_dev *dev)
1909 if (!dev->bar) 1902 if (!dev->bar)
1910 goto release; 1903 goto release;
1911 1904
1912 return 0; 1905 return 0;
1913 release: 1906 release:
1914 pci_release_mem_regions(pdev); 1907 pci_release_mem_regions(pdev);
1915 return -ENODEV; 1908 return -ENODEV;
1916} 1909}
1917 1910
1918static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1911static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c
index b71e95044b43..a5c09e703bd8 100644
--- a/drivers/nvme/host/scsi.c
+++ b/drivers/nvme/host/scsi.c
@@ -2160,30 +2160,6 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns,
2160 return nvme_trans_status_code(hdr, nvme_sc); 2160 return nvme_trans_status_code(hdr, nvme_sc);
2161} 2161}
2162 2162
2163static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2164 u8 *cmd)
2165{
2166 u8 immed, no_flush;
2167
2168 immed = cmd[1] & 0x01;
2169 no_flush = cmd[4] & 0x04;
2170
2171 if (immed != 0) {
2172 return nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION,
2173 ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB,
2174 SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
2175 } else {
2176 if (no_flush == 0) {
2177 /* Issue NVME FLUSH command prior to START STOP UNIT */
2178 int res = nvme_trans_synchronize_cache(ns, hdr);
2179 if (res)
2180 return res;
2181 }
2182
2183 return 0;
2184 }
2185}
2186
2187static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr, 2163static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2188 u8 *cmd) 2164 u8 *cmd)
2189{ 2165{
@@ -2439,9 +2415,6 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr)
2439 case SECURITY_PROTOCOL_OUT: 2415 case SECURITY_PROTOCOL_OUT:
2440 retcode = nvme_trans_security_protocol(ns, hdr, cmd); 2416 retcode = nvme_trans_security_protocol(ns, hdr, cmd);
2441 break; 2417 break;
2442 case START_STOP:
2443 retcode = nvme_trans_start_stop(ns, hdr, cmd);
2444 break;
2445 case SYNCHRONIZE_CACHE: 2418 case SYNCHRONIZE_CACHE:
2446 retcode = nvme_trans_synchronize_cache(ns, hdr); 2419 retcode = nvme_trans_synchronize_cache(ns, hdr);
2447 break; 2420 break;
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ec1ad2aa0a4c..95ae52390478 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -382,7 +382,6 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
382{ 382{
383 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; 383 struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
384 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]); 384 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
385 u64 val;
386 u32 val32; 385 u32 val32;
387 u16 status = 0; 386 u16 status = 0;
388 387
@@ -392,8 +391,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
392 (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16)); 391 (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
393 break; 392 break;
394 case NVME_FEAT_KATO: 393 case NVME_FEAT_KATO:
395 val = le64_to_cpu(req->cmd->prop_set.value); 394 val32 = le32_to_cpu(req->cmd->common.cdw10[1]);
396 val32 = val & 0xffff;
397 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); 395 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000);
398 nvmet_set_result(req, req->sq->ctrl->kato); 396 nvmet_set_result(req, req->sq->ctrl->kato);
399 break; 397 break;
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index bcb8ebeb01c5..4e8e6a22bce1 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -845,7 +845,7 @@ fcloop_create_remote_port(struct device *dev, struct device_attribute *attr,
845 rport->lport = nport->lport; 845 rport->lport = nport->lport;
846 nport->rport = rport; 846 nport->rport = rport;
847 847
848 return ret ? ret : count; 848 return count;
849} 849}
850 850
851 851
@@ -952,7 +952,7 @@ fcloop_create_target_port(struct device *dev, struct device_attribute *attr,
952 tport->lport = nport->lport; 952 tport->lport = nport->lport;
953 nport->tport = tport; 953 nport->tport = tport;
954 954
955 return ret ? ret : count; 955 return count;
956} 956}
957 957
958 958
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 965911d9b36a..398ea7f54826 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -981,8 +981,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
981 * @cell: nvmem cell to be read. 981 * @cell: nvmem cell to be read.
982 * @len: pointer to length of cell which will be populated on successful read. 982 * @len: pointer to length of cell which will be populated on successful read.
983 * 983 *
984 * Return: ERR_PTR() on error or a valid pointer to a char * buffer on success. 984 * Return: ERR_PTR() on error or a valid pointer to a buffer on success. The
985 * The buffer should be freed by the consumer with a kfree(). 985 * buffer should be freed by the consumer with a kfree().
986 */ 986 */
987void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) 987void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
988{ 988{
diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index ac27b9bac3b9..8e7b120696fa 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -71,7 +71,7 @@ static struct nvmem_config imx_ocotp_nvmem_config = {
71 71
72static const struct of_device_id imx_ocotp_dt_ids[] = { 72static const struct of_device_id imx_ocotp_dt_ids[] = {
73 { .compatible = "fsl,imx6q-ocotp", (void *)128 }, 73 { .compatible = "fsl,imx6q-ocotp", (void *)128 },
74 { .compatible = "fsl,imx6sl-ocotp", (void *)32 }, 74 { .compatible = "fsl,imx6sl-ocotp", (void *)64 },
75 { .compatible = "fsl,imx6sx-ocotp", (void *)128 }, 75 { .compatible = "fsl,imx6sx-ocotp", (void *)128 },
76 { }, 76 { },
77}; 77};
diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
index b5305f08b184..2bdb6c389328 100644
--- a/drivers/nvmem/qfprom.c
+++ b/drivers/nvmem/qfprom.c
@@ -21,11 +21,11 @@ static int qfprom_reg_read(void *context,
21 unsigned int reg, void *_val, size_t bytes) 21 unsigned int reg, void *_val, size_t bytes)
22{ 22{
23 void __iomem *base = context; 23 void __iomem *base = context;
24 u32 *val = _val; 24 u8 *val = _val;
25 int i = 0, words = bytes / 4; 25 int i = 0, words = bytes;
26 26
27 while (words--) 27 while (words--)
28 *val++ = readl(base + reg + (i++ * 4)); 28 *val++ = readb(base + reg + i++);
29 29
30 return 0; 30 return 0;
31} 31}
@@ -34,11 +34,11 @@ static int qfprom_reg_write(void *context,
34 unsigned int reg, void *_val, size_t bytes) 34 unsigned int reg, void *_val, size_t bytes)
35{ 35{
36 void __iomem *base = context; 36 void __iomem *base = context;
37 u32 *val = _val; 37 u8 *val = _val;
38 int i = 0, words = bytes / 4; 38 int i = 0, words = bytes;
39 39
40 while (words--) 40 while (words--)
41 writel(*val++, base + reg + (i++ * 4)); 41 writeb(*val++, base + reg + i++);
42 42
43 return 0; 43 return 0;
44} 44}
@@ -53,7 +53,7 @@ static int qfprom_remove(struct platform_device *pdev)
53static struct nvmem_config econfig = { 53static struct nvmem_config econfig = {
54 .name = "qfprom", 54 .name = "qfprom",
55 .owner = THIS_MODULE, 55 .owner = THIS_MODULE,
56 .stride = 4, 56 .stride = 1,
57 .word_size = 1, 57 .word_size = 1,
58 .reg_read = qfprom_reg_read, 58 .reg_read = qfprom_reg_read,
59 .reg_write = qfprom_reg_write, 59 .reg_write = qfprom_reg_write,
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index a579126832af..620c231a2889 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -212,7 +212,7 @@ static int meson_pmx_request_gpio(struct pinctrl_dev *pcdev,
212{ 212{
213 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 213 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev);
214 214
215 meson_pmx_disable_other_groups(pc, range->pin_base + offset, -1); 215 meson_pmx_disable_other_groups(pc, offset, -1);
216 216
217 return 0; 217 return 0;
218} 218}
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index aea310a91821..c9a146948192 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -382,26 +382,21 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
382{ 382{
383 int ret = 0; 383 int ret = 0;
384 u32 pin_reg; 384 u32 pin_reg;
385 unsigned long flags; 385 unsigned long flags, irq_flags;
386 bool level_trig;
387 u32 active_level;
388 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 386 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
389 struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 387 struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
390 388
391 spin_lock_irqsave(&gpio_dev->lock, flags); 389 spin_lock_irqsave(&gpio_dev->lock, flags);
392 pin_reg = readl(gpio_dev->base + (d->hwirq)*4); 390 pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
393 391
394 /* 392 /* Ignore the settings coming from the client and
395 * When level_trig is set EDGE and active_level is set HIGH in BIOS 393 * read the values from the ACPI tables
396 * default settings, ignore incoming settings from client and use 394 * while setting the trigger type
397 * BIOS settings to configure GPIO register.
398 */ 395 */
399 level_trig = !(pin_reg & (LEVEL_TRIGGER << LEVEL_TRIG_OFF));
400 active_level = pin_reg & (ACTIVE_LEVEL_MASK << ACTIVE_LEVEL_OFF);
401 396
402 if(level_trig && 397 irq_flags = irq_get_trigger_type(d->irq);
403 ((active_level >> ACTIVE_LEVEL_OFF) == ACTIVE_HIGH)) 398 if (irq_flags != IRQ_TYPE_NONE)
404 type = IRQ_TYPE_EDGE_FALLING; 399 type = irq_flags;
405 400
406 switch (type & IRQ_TYPE_SENSE_MASK) { 401 switch (type & IRQ_TYPE_SENSE_MASK) {
407 case IRQ_TYPE_EDGE_RISING: 402 case IRQ_TYPE_EDGE_RISING:
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 12f7d1eb65bc..07409fde02b2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -56,6 +56,17 @@ static const struct samsung_pin_bank_type bank_type_alive = {
56 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, }, 56 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, },
57}; 57};
58 58
59/* Exynos5433 has the 4bit widths for PINCFG_TYPE_DRV bitfields. */
60static const struct samsung_pin_bank_type exynos5433_bank_type_off = {
61 .fld_width = { 4, 1, 2, 4, 2, 2, },
62 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, },
63};
64
65static const struct samsung_pin_bank_type exynos5433_bank_type_alive = {
66 .fld_width = { 4, 1, 2, 4, },
67 .reg_offset = { 0x00, 0x04, 0x08, 0x0c, },
68};
69
59static void exynos_irq_mask(struct irq_data *irqd) 70static void exynos_irq_mask(struct irq_data *irqd)
60{ 71{
61 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 72 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
@@ -1335,82 +1346,82 @@ const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
1335 1346
1336/* pin banks of exynos5433 pin-controller - ALIVE */ 1347/* pin banks of exynos5433 pin-controller - ALIVE */
1337static const struct samsung_pin_bank_data exynos5433_pin_banks0[] = { 1348static const struct samsung_pin_bank_data exynos5433_pin_banks0[] = {
1338 EXYNOS_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00), 1349 EXYNOS5433_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00),
1339 EXYNOS_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04), 1350 EXYNOS5433_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04),
1340 EXYNOS_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08), 1351 EXYNOS5433_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08),
1341 EXYNOS_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c), 1352 EXYNOS5433_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c),
1342 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1), 1353 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1),
1343 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1), 1354 EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1),
1344 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1), 1355 EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1),
1345 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1), 1356 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1),
1346 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1), 1357 EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1),
1347}; 1358};
1348 1359
1349/* pin banks of exynos5433 pin-controller - AUD */ 1360/* pin banks of exynos5433 pin-controller - AUD */
1350static const struct samsung_pin_bank_data exynos5433_pin_banks1[] = { 1361static const struct samsung_pin_bank_data exynos5433_pin_banks1[] = {
1351 EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00), 1362 EXYNOS5433_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00),
1352 EXYNOS_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04), 1363 EXYNOS5433_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04),
1353}; 1364};
1354 1365
1355/* pin banks of exynos5433 pin-controller - CPIF */ 1366/* pin banks of exynos5433 pin-controller - CPIF */
1356static const struct samsung_pin_bank_data exynos5433_pin_banks2[] = { 1367static const struct samsung_pin_bank_data exynos5433_pin_banks2[] = {
1357 EXYNOS_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00), 1368 EXYNOS5433_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00),
1358}; 1369};
1359 1370
1360/* pin banks of exynos5433 pin-controller - eSE */ 1371/* pin banks of exynos5433 pin-controller - eSE */
1361static const struct samsung_pin_bank_data exynos5433_pin_banks3[] = { 1372static const struct samsung_pin_bank_data exynos5433_pin_banks3[] = {
1362 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00), 1373 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00),
1363}; 1374};
1364 1375
1365/* pin banks of exynos5433 pin-controller - FINGER */ 1376/* pin banks of exynos5433 pin-controller - FINGER */
1366static const struct samsung_pin_bank_data exynos5433_pin_banks4[] = { 1377static const struct samsung_pin_bank_data exynos5433_pin_banks4[] = {
1367 EXYNOS_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00), 1378 EXYNOS5433_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00),
1368}; 1379};
1369 1380
1370/* pin banks of exynos5433 pin-controller - FSYS */ 1381/* pin banks of exynos5433 pin-controller - FSYS */
1371static const struct samsung_pin_bank_data exynos5433_pin_banks5[] = { 1382static const struct samsung_pin_bank_data exynos5433_pin_banks5[] = {
1372 EXYNOS_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00), 1383 EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00),
1373 EXYNOS_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04), 1384 EXYNOS5433_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04),
1374 EXYNOS_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08), 1385 EXYNOS5433_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08),
1375 EXYNOS_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c), 1386 EXYNOS5433_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c),
1376 EXYNOS_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10), 1387 EXYNOS5433_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10),
1377 EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14), 1388 EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14),
1378}; 1389};
1379 1390
1380/* pin banks of exynos5433 pin-controller - IMEM */ 1391/* pin banks of exynos5433 pin-controller - IMEM */
1381static const struct samsung_pin_bank_data exynos5433_pin_banks6[] = { 1392static const struct samsung_pin_bank_data exynos5433_pin_banks6[] = {
1382 EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00), 1393 EXYNOS5433_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00),
1383}; 1394};
1384 1395
1385/* pin banks of exynos5433 pin-controller - NFC */ 1396/* pin banks of exynos5433 pin-controller - NFC */
1386static const struct samsung_pin_bank_data exynos5433_pin_banks7[] = { 1397static const struct samsung_pin_bank_data exynos5433_pin_banks7[] = {
1387 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00), 1398 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00),
1388}; 1399};
1389 1400
1390/* pin banks of exynos5433 pin-controller - PERIC */ 1401/* pin banks of exynos5433 pin-controller - PERIC */
1391static const struct samsung_pin_bank_data exynos5433_pin_banks8[] = { 1402static const struct samsung_pin_bank_data exynos5433_pin_banks8[] = {
1392 EXYNOS_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00), 1403 EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00),
1393 EXYNOS_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04), 1404 EXYNOS5433_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04),
1394 EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08), 1405 EXYNOS5433_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08),
1395 EXYNOS_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c), 1406 EXYNOS5433_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c),
1396 EXYNOS_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10), 1407 EXYNOS5433_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10),
1397 EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14), 1408 EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14),
1398 EXYNOS_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18), 1409 EXYNOS5433_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18),
1399 EXYNOS_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c), 1410 EXYNOS5433_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c),
1400 EXYNOS_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20), 1411 EXYNOS5433_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20),
1401 EXYNOS_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24), 1412 EXYNOS5433_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24),
1402 EXYNOS_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28), 1413 EXYNOS5433_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28),
1403 EXYNOS_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c), 1414 EXYNOS5433_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c),
1404 EXYNOS_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30), 1415 EXYNOS5433_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30),
1405 EXYNOS_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34), 1416 EXYNOS5433_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34),
1406 EXYNOS_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38), 1417 EXYNOS5433_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38),
1407 EXYNOS_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c), 1418 EXYNOS5433_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c),
1408 EXYNOS_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40), 1419 EXYNOS5433_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40),
1409}; 1420};
1410 1421
1411/* pin banks of exynos5433 pin-controller - TOUCH */ 1422/* pin banks of exynos5433 pin-controller - TOUCH */
1412static const struct samsung_pin_bank_data exynos5433_pin_banks9[] = { 1423static const struct samsung_pin_bank_data exynos5433_pin_banks9[] = {
1413 EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00), 1424 EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00),
1414}; 1425};
1415 1426
1416/* 1427/*
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.h b/drivers/pinctrl/samsung/pinctrl-exynos.h
index 5821525a2c84..a473092fb8d2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.h
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.h
@@ -90,6 +90,37 @@
90 .pctl_res_idx = pctl_idx, \ 90 .pctl_res_idx = pctl_idx, \
91 } \ 91 } \
92 92
93#define EXYNOS5433_PIN_BANK_EINTG(pins, reg, id, offs) \
94 { \
95 .type = &exynos5433_bank_type_off, \
96 .pctl_offset = reg, \
97 .nr_pins = pins, \
98 .eint_type = EINT_TYPE_GPIO, \
99 .eint_offset = offs, \
100 .name = id \
101 }
102
103#define EXYNOS5433_PIN_BANK_EINTW(pins, reg, id, offs) \
104 { \
105 .type = &exynos5433_bank_type_alive, \
106 .pctl_offset = reg, \
107 .nr_pins = pins, \
108 .eint_type = EINT_TYPE_WKUP, \
109 .eint_offset = offs, \
110 .name = id \
111 }
112
113#define EXYNOS5433_PIN_BANK_EINTW_EXT(pins, reg, id, offs, pctl_idx) \
114 { \
115 .type = &exynos5433_bank_type_alive, \
116 .pctl_offset = reg, \
117 .nr_pins = pins, \
118 .eint_type = EINT_TYPE_WKUP, \
119 .eint_offset = offs, \
120 .name = id, \
121 .pctl_res_idx = pctl_idx, \
122 } \
123
93/** 124/**
94 * struct exynos_weint_data: irq specific data for all the wakeup interrupts 125 * struct exynos_weint_data: irq specific data for all the wakeup interrupts
95 * generated by the external wakeup interrupt controller. 126 * generated by the external wakeup interrupt controller.
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 5fe8be089b8b..59aa8e302bc3 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1034,7 +1034,7 @@ config SURFACE_PRO3_BUTTON
1034 1034
1035config SURFACE_3_BUTTON 1035config SURFACE_3_BUTTON
1036 tristate "Power/home/volume buttons driver for Microsoft Surface 3 tablet" 1036 tristate "Power/home/volume buttons driver for Microsoft Surface 3 tablet"
1037 depends on ACPI && KEYBOARD_GPIO 1037 depends on ACPI && KEYBOARD_GPIO && I2C
1038 ---help--- 1038 ---help---
1039 This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. 1039 This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet.
1040 1040
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 61f39abf5dc8..82d67715ce76 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -177,43 +177,43 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
177 177
178#if IS_ENABLED(CONFIG_LEDS_CLASS) 178#if IS_ENABLED(CONFIG_LEDS_CLASS)
179static enum led_brightness logolamp_get(struct led_classdev *cdev); 179static enum led_brightness logolamp_get(struct led_classdev *cdev);
180static void logolamp_set(struct led_classdev *cdev, 180static int logolamp_set(struct led_classdev *cdev,
181 enum led_brightness brightness); 181 enum led_brightness brightness);
182 182
183static struct led_classdev logolamp_led = { 183static struct led_classdev logolamp_led = {
184 .name = "fujitsu::logolamp", 184 .name = "fujitsu::logolamp",
185 .brightness_get = logolamp_get, 185 .brightness_get = logolamp_get,
186 .brightness_set = logolamp_set 186 .brightness_set_blocking = logolamp_set
187}; 187};
188 188
189static enum led_brightness kblamps_get(struct led_classdev *cdev); 189static enum led_brightness kblamps_get(struct led_classdev *cdev);
190static void kblamps_set(struct led_classdev *cdev, 190static int kblamps_set(struct led_classdev *cdev,
191 enum led_brightness brightness); 191 enum led_brightness brightness);
192 192
193static struct led_classdev kblamps_led = { 193static struct led_classdev kblamps_led = {
194 .name = "fujitsu::kblamps", 194 .name = "fujitsu::kblamps",
195 .brightness_get = kblamps_get, 195 .brightness_get = kblamps_get,
196 .brightness_set = kblamps_set 196 .brightness_set_blocking = kblamps_set
197}; 197};
198 198
199static enum led_brightness radio_led_get(struct led_classdev *cdev); 199static enum led_brightness radio_led_get(struct led_classdev *cdev);
200static void radio_led_set(struct led_classdev *cdev, 200static int radio_led_set(struct led_classdev *cdev,
201 enum led_brightness brightness); 201 enum led_brightness brightness);
202 202
203static struct led_classdev radio_led = { 203static struct led_classdev radio_led = {
204 .name = "fujitsu::radio_led", 204 .name = "fujitsu::radio_led",
205 .brightness_get = radio_led_get, 205 .brightness_get = radio_led_get,
206 .brightness_set = radio_led_set 206 .brightness_set_blocking = radio_led_set
207}; 207};
208 208
209static enum led_brightness eco_led_get(struct led_classdev *cdev); 209static enum led_brightness eco_led_get(struct led_classdev *cdev);
210static void eco_led_set(struct led_classdev *cdev, 210static int eco_led_set(struct led_classdev *cdev,
211 enum led_brightness brightness); 211 enum led_brightness brightness);
212 212
213static struct led_classdev eco_led = { 213static struct led_classdev eco_led = {
214 .name = "fujitsu::eco_led", 214 .name = "fujitsu::eco_led",
215 .brightness_get = eco_led_get, 215 .brightness_get = eco_led_get,
216 .brightness_set = eco_led_set 216 .brightness_set_blocking = eco_led_set
217}; 217};
218#endif 218#endif
219 219
@@ -267,48 +267,48 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
267#if IS_ENABLED(CONFIG_LEDS_CLASS) 267#if IS_ENABLED(CONFIG_LEDS_CLASS)
268/* LED class callbacks */ 268/* LED class callbacks */
269 269
270static void logolamp_set(struct led_classdev *cdev, 270static int logolamp_set(struct led_classdev *cdev,
271 enum led_brightness brightness) 271 enum led_brightness brightness)
272{ 272{
273 if (brightness >= LED_FULL) { 273 if (brightness >= LED_FULL) {
274 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); 274 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
275 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON); 275 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
276 } else if (brightness >= LED_HALF) { 276 } else if (brightness >= LED_HALF) {
277 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); 277 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
278 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF); 278 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
279 } else { 279 } else {
280 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF); 280 return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
281 } 281 }
282} 282}
283 283
284static void kblamps_set(struct led_classdev *cdev, 284static int kblamps_set(struct led_classdev *cdev,
285 enum led_brightness brightness) 285 enum led_brightness brightness)
286{ 286{
287 if (brightness >= LED_FULL) 287 if (brightness >= LED_FULL)
288 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON); 288 return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
289 else 289 else
290 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF); 290 return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
291} 291}
292 292
293static void radio_led_set(struct led_classdev *cdev, 293static int radio_led_set(struct led_classdev *cdev,
294 enum led_brightness brightness) 294 enum led_brightness brightness)
295{ 295{
296 if (brightness >= LED_FULL) 296 if (brightness >= LED_FULL)
297 call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON); 297 return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON);
298 else 298 else
299 call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0); 299 return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0);
300} 300}
301 301
302static void eco_led_set(struct led_classdev *cdev, 302static int eco_led_set(struct led_classdev *cdev,
303 enum led_brightness brightness) 303 enum led_brightness brightness)
304{ 304{
305 int curr; 305 int curr;
306 306
307 curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0); 307 curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0);
308 if (brightness >= LED_FULL) 308 if (brightness >= LED_FULL)
309 call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON); 309 return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON);
310 else 310 else
311 call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON); 311 return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON);
312} 312}
313 313
314static enum led_brightness logolamp_get(struct led_classdev *cdev) 314static enum led_brightness logolamp_get(struct led_classdev *cdev)
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 8130dfe89745..4971aa54756a 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -770,6 +770,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
770 /* Initialize the device private structure. */ 770 /* Initialize the device private structure. */
771 struct octeon_ethernet *priv = netdev_priv(dev); 771 struct octeon_ethernet *priv = netdev_priv(dev);
772 772
773 SET_NETDEV_DEV(dev, &pdev->dev);
773 dev->netdev_ops = &cvm_oct_pow_netdev_ops; 774 dev->netdev_ops = &cvm_oct_pow_netdev_ops;
774 priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; 775 priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
775 priv->port = CVMX_PIP_NUM_INPUT_PORTS; 776 priv->port = CVMX_PIP_NUM_INPUT_PORTS;
@@ -816,6 +817,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
816 } 817 }
817 818
818 /* Initialize the device private structure. */ 819 /* Initialize the device private structure. */
820 SET_NETDEV_DEV(dev, &pdev->dev);
819 priv = netdev_priv(dev); 821 priv = netdev_priv(dev);
820 priv->netdev = dev; 822 priv->netdev = dev;
821 priv->of_node = cvm_oct_node_for_port(pip, interface, 823 priv->of_node = cvm_oct_node_for_port(pip, interface,
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 0aa9e7d697a5..25dbd8c7aec7 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -239,6 +239,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
239 if (ifp->desc.bNumEndpoints >= num_ep) 239 if (ifp->desc.bNumEndpoints >= num_ep)
240 goto skip_to_next_endpoint_or_interface_descriptor; 240 goto skip_to_next_endpoint_or_interface_descriptor;
241 241
242 /* Check for duplicate endpoint addresses */
243 for (i = 0; i < ifp->desc.bNumEndpoints; ++i) {
244 if (ifp->endpoint[i].desc.bEndpointAddress ==
245 d->bEndpointAddress) {
246 dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
247 cfgno, inum, asnum, d->bEndpointAddress);
248 goto skip_to_next_endpoint_or_interface_descriptor;
249 }
250 }
251
242 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; 252 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
243 ++ifp->desc.bNumEndpoints; 253 ++ifp->desc.bNumEndpoints;
244 254
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1fa5c0f29c64..a56c75e09786 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -103,8 +103,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
103 103
104static void hub_release(struct kref *kref); 104static void hub_release(struct kref *kref);
105static int usb_reset_and_verify_device(struct usb_device *udev); 105static int usb_reset_and_verify_device(struct usb_device *udev);
106static void hub_usb3_port_prepare_disable(struct usb_hub *hub, 106static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
107 struct usb_port *port_dev);
108 107
109static inline char *portspeed(struct usb_hub *hub, int portstatus) 108static inline char *portspeed(struct usb_hub *hub, int portstatus)
110{ 109{
@@ -903,34 +902,6 @@ static int hub_set_port_link_state(struct usb_hub *hub, int port1,
903} 902}
904 903
905/* 904/*
906 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
907 * a connection with a plugged-in cable but will signal the host when the cable
908 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
909 */
910static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
911{
912 struct usb_port *port_dev = hub->ports[port1 - 1];
913 struct usb_device *hdev = hub->hdev;
914 int ret = 0;
915
916 if (!hub->error) {
917 if (hub_is_superspeed(hub->hdev)) {
918 hub_usb3_port_prepare_disable(hub, port_dev);
919 ret = hub_set_port_link_state(hub, port_dev->portnum,
920 USB_SS_PORT_LS_U3);
921 } else {
922 ret = usb_clear_port_feature(hdev, port1,
923 USB_PORT_FEAT_ENABLE);
924 }
925 }
926 if (port_dev->child && set_state)
927 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
928 if (ret && ret != -ENODEV)
929 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
930 return ret;
931}
932
933/*
934 * Disable a port and mark a logical connect-change event, so that some 905 * Disable a port and mark a logical connect-change event, so that some
935 * time later hub_wq will disconnect() any existing usb_device on the port 906 * time later hub_wq will disconnect() any existing usb_device on the port
936 * and will re-enumerate if there actually is a device attached. 907 * and will re-enumerate if there actually is a device attached.
@@ -4162,6 +4133,34 @@ static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port,
4162 4133
4163#endif /* CONFIG_PM */ 4134#endif /* CONFIG_PM */
4164 4135
4136/*
4137 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
4138 * a connection with a plugged-in cable but will signal the host when the cable
4139 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
4140 */
4141static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
4142{
4143 struct usb_port *port_dev = hub->ports[port1 - 1];
4144 struct usb_device *hdev = hub->hdev;
4145 int ret = 0;
4146
4147 if (!hub->error) {
4148 if (hub_is_superspeed(hub->hdev)) {
4149 hub_usb3_port_prepare_disable(hub, port_dev);
4150 ret = hub_set_port_link_state(hub, port_dev->portnum,
4151 USB_SS_PORT_LS_U3);
4152 } else {
4153 ret = usb_clear_port_feature(hdev, port1,
4154 USB_PORT_FEAT_ENABLE);
4155 }
4156 }
4157 if (port_dev->child && set_state)
4158 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
4159 if (ret && ret != -ENODEV)
4160 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
4161 return ret;
4162}
4163
4165 4164
4166/* USB 2.0 spec, 7.1.7.3 / fig 7-29: 4165/* USB 2.0 spec, 7.1.7.3 / fig 7-29:
4167 * 4166 *
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index b95930f20d90..c55db4aa54d6 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3753,7 +3753,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
3753 hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, 3753 hs_ep->desc_list = dma_alloc_coherent(hsotg->dev,
3754 MAX_DMA_DESC_NUM_GENERIC * 3754 MAX_DMA_DESC_NUM_GENERIC *
3755 sizeof(struct dwc2_dma_desc), 3755 sizeof(struct dwc2_dma_desc),
3756 &hs_ep->desc_list_dma, GFP_KERNEL); 3756 &hs_ep->desc_list_dma, GFP_ATOMIC);
3757 if (!hs_ep->desc_list) { 3757 if (!hs_ep->desc_list) {
3758 ret = -ENOMEM; 3758 ret = -ENOMEM;
3759 goto error2; 3759 goto error2;
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a786256535b6..11fe68a4627b 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -247,8 +247,6 @@ MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
247static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, 247static void dwc2_get_device_property(struct dwc2_hsotg *hsotg,
248 char *property, u8 size, u64 *value) 248 char *property, u8 size, u64 *value)
249{ 249{
250 u8 val8;
251 u16 val16;
252 u32 val32; 250 u32 val32;
253 251
254 switch (size) { 252 switch (size) {
@@ -256,17 +254,7 @@ static void dwc2_get_device_property(struct dwc2_hsotg *hsotg,
256 *value = device_property_read_bool(hsotg->dev, property); 254 *value = device_property_read_bool(hsotg->dev, property);
257 break; 255 break;
258 case 1: 256 case 1:
259 if (device_property_read_u8(hsotg->dev, property, &val8))
260 return;
261
262 *value = val8;
263 break;
264 case 2: 257 case 2:
265 if (device_property_read_u16(hsotg->dev, property, &val16))
266 return;
267
268 *value = val16;
269 break;
270 case 4: 258 case 4:
271 if (device_property_read_u32(hsotg->dev, property, &val32)) 259 if (device_property_read_u32(hsotg->dev, property, &val32))
272 return; 260 return;
@@ -1100,13 +1088,13 @@ static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg)
1100 /* Buffer DMA */ 1088 /* Buffer DMA */
1101 dwc2_set_param_bool(hsotg, &p->g_dma, 1089 dwc2_set_param_bool(hsotg, &p->g_dma,
1102 false, "gadget-dma", 1090 false, "gadget-dma",
1103 true, false, 1091 dma_capable, false,
1104 dma_capable); 1092 dma_capable);
1105 1093
1106 /* DMA Descriptor */ 1094 /* DMA Descriptor */
1107 dwc2_set_param_bool(hsotg, &p->g_dma_desc, false, 1095 dwc2_set_param_bool(hsotg, &p->g_dma_desc, false,
1108 "gadget-dma-desc", 1096 "gadget-dma-desc",
1109 p->g_dma, false, 1097 !!hw->dma_desc_enable, false,
1110 !!hw->dma_desc_enable); 1098 !!hw->dma_desc_enable);
1111} 1099}
1112 1100
@@ -1130,8 +1118,14 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1130 1118
1131 dwc2_set_param_bool(hsotg, &p->host_dma, 1119 dwc2_set_param_bool(hsotg, &p->host_dma,
1132 false, "host-dma", 1120 false, "host-dma",
1133 true, false, 1121 dma_capable, false,
1134 dma_capable); 1122 dma_capable);
1123 dwc2_set_param_host_rx_fifo_size(hsotg,
1124 params->host_rx_fifo_size);
1125 dwc2_set_param_host_nperio_tx_fifo_size(hsotg,
1126 params->host_nperio_tx_fifo_size);
1127 dwc2_set_param_host_perio_tx_fifo_size(hsotg,
1128 params->host_perio_tx_fifo_size);
1135 } 1129 }
1136 dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable); 1130 dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable);
1137 dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable); 1131 dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable);
@@ -1140,12 +1134,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1140 params->host_support_fs_ls_low_power); 1134 params->host_support_fs_ls_low_power);
1141 dwc2_set_param_enable_dynamic_fifo(hsotg, 1135 dwc2_set_param_enable_dynamic_fifo(hsotg,
1142 params->enable_dynamic_fifo); 1136 params->enable_dynamic_fifo);
1143 dwc2_set_param_host_rx_fifo_size(hsotg,
1144 params->host_rx_fifo_size);
1145 dwc2_set_param_host_nperio_tx_fifo_size(hsotg,
1146 params->host_nperio_tx_fifo_size);
1147 dwc2_set_param_host_perio_tx_fifo_size(hsotg,
1148 params->host_perio_tx_fifo_size);
1149 dwc2_set_param_max_transfer_size(hsotg, 1137 dwc2_set_param_max_transfer_size(hsotg,
1150 params->max_transfer_size); 1138 params->max_transfer_size);
1151 dwc2_set_param_max_packet_count(hsotg, 1139 dwc2_set_param_max_packet_count(hsotg,
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index de5a8570be04..14b760209680 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -45,9 +45,7 @@
45#define DWC3_XHCI_RESOURCES_NUM 2 45#define DWC3_XHCI_RESOURCES_NUM 2
46 46
47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ 47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */
48#define DWC3_EVENT_SIZE 4 /* bytes */ 48#define DWC3_EVENT_BUFFERS_SIZE 4096
49#define DWC3_EVENT_MAX_NUM 64 /* 2 events/endpoint */
50#define DWC3_EVENT_BUFFERS_SIZE (DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM)
51#define DWC3_EVENT_TYPE_MASK 0xfe 49#define DWC3_EVENT_TYPE_MASK 0xfe
52 50
53#define DWC3_EVENT_TYPE_DEV 0 51#define DWC3_EVENT_TYPE_DEV 0
@@ -311,9 +309,8 @@
311#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ 309#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */
312#define DWC3_DCFG_SUPERSPEED (4 << 0) 310#define DWC3_DCFG_SUPERSPEED (4 << 0)
313#define DWC3_DCFG_HIGHSPEED (0 << 0) 311#define DWC3_DCFG_HIGHSPEED (0 << 0)
314#define DWC3_DCFG_FULLSPEED2 (1 << 0) 312#define DWC3_DCFG_FULLSPEED (1 << 0)
315#define DWC3_DCFG_LOWSPEED (2 << 0) 313#define DWC3_DCFG_LOWSPEED (2 << 0)
316#define DWC3_DCFG_FULLSPEED1 (3 << 0)
317 314
318#define DWC3_DCFG_NUMP_SHIFT 17 315#define DWC3_DCFG_NUMP_SHIFT 17
319#define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f) 316#define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f)
@@ -405,9 +402,8 @@
405#define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ 402#define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */
406#define DWC3_DSTS_SUPERSPEED (4 << 0) 403#define DWC3_DSTS_SUPERSPEED (4 << 0)
407#define DWC3_DSTS_HIGHSPEED (0 << 0) 404#define DWC3_DSTS_HIGHSPEED (0 << 0)
408#define DWC3_DSTS_FULLSPEED2 (1 << 0) 405#define DWC3_DSTS_FULLSPEED (1 << 0)
409#define DWC3_DSTS_LOWSPEED (2 << 0) 406#define DWC3_DSTS_LOWSPEED (2 << 0)
410#define DWC3_DSTS_FULLSPEED1 (3 << 0)
411 407
412/* Device Generic Command Register */ 408/* Device Generic Command Register */
413#define DWC3_DGCMD_SET_LMP 0x01 409#define DWC3_DGCMD_SET_LMP 0x01
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 29e80cc9b634..eb1b9cb3f9d1 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/irq.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/platform_data/dwc3-omap.h> 25#include <linux/platform_data/dwc3-omap.h>
@@ -510,7 +511,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
510 511
511 /* check the DMA Status */ 512 /* check the DMA Status */
512 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); 513 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
513 514 irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
514 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, 515 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
515 dwc3_omap_interrupt_thread, IRQF_SHARED, 516 dwc3_omap_interrupt_thread, IRQF_SHARED,
516 "dwc3-omap", omap); 517 "dwc3-omap", omap);
@@ -531,7 +532,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
531 } 532 }
532 533
533 dwc3_omap_enable_irqs(omap); 534 dwc3_omap_enable_irqs(omap);
534 535 enable_irq(omap->irq);
535 return 0; 536 return 0;
536 537
537err2: 538err2:
@@ -552,6 +553,7 @@ static int dwc3_omap_remove(struct platform_device *pdev)
552 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); 553 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb);
553 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); 554 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb);
554 dwc3_omap_disable_irqs(omap); 555 dwc3_omap_disable_irqs(omap);
556 disable_irq(omap->irq);
555 of_platform_depopulate(omap->dev); 557 of_platform_depopulate(omap->dev);
556 pm_runtime_put_sync(&pdev->dev); 558 pm_runtime_put_sync(&pdev->dev);
557 pm_runtime_disable(&pdev->dev); 559 pm_runtime_disable(&pdev->dev);
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 2b73339f286b..cce0a220b6b0 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -38,6 +38,7 @@
38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa 38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa 39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
41#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
41 42
42#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 43#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
43#define PCI_INTEL_BXT_FUNC_PMU_PWR 4 44#define PCI_INTEL_BXT_FUNC_PMU_PWR 4
@@ -73,16 +74,6 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
73{ 74{
74 struct platform_device *dwc3 = dwc->dwc3; 75 struct platform_device *dwc3 = dwc->dwc3;
75 struct pci_dev *pdev = dwc->pci; 76 struct pci_dev *pdev = dwc->pci;
76 int ret;
77
78 struct property_entry sysdev_property[] = {
79 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
80 { },
81 };
82
83 ret = platform_device_add_properties(dwc3, sysdev_property);
84 if (ret)
85 return ret;
86 77
87 if (pdev->vendor == PCI_VENDOR_ID_AMD && 78 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
88 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { 79 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
@@ -105,6 +96,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
105 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"), 96 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"),
106 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"), 97 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"),
107 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"), 98 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
99 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
108 { }, 100 { },
109 }; 101 };
110 102
@@ -115,7 +107,8 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
115 int ret; 107 int ret;
116 108
117 struct property_entry properties[] = { 109 struct property_entry properties[] = {
118 PROPERTY_ENTRY_STRING("dr-mode", "peripheral"), 110 PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
111 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
119 { } 112 { }
120 }; 113 };
121 114
@@ -167,6 +160,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
167 PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"), 160 PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"),
168 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"), 161 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
169 PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"), 162 PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"),
163 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
170 { }, 164 { },
171 }; 165 };
172 166
@@ -274,6 +268,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
274 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, 268 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
275 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, 269 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
276 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, 270 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
271 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
277 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 272 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
278 { } /* Terminating Entry */ 273 { } /* Terminating Entry */
279}; 274};
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 4878d187c7d4..9bb1f8526f3e 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -39,18 +39,13 @@ static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep);
39static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, 39static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
40 struct dwc3_ep *dep, struct dwc3_request *req); 40 struct dwc3_ep *dep, struct dwc3_request *req);
41 41
42static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, 42static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum,
43 u32 len, u32 type, bool chain) 43 dma_addr_t buf_dma, u32 len, u32 type, bool chain)
44{ 44{
45 struct dwc3_gadget_ep_cmd_params params;
46 struct dwc3_trb *trb; 45 struct dwc3_trb *trb;
47 struct dwc3_ep *dep; 46 struct dwc3_ep *dep;
48 47
49 int ret;
50
51 dep = dwc->eps[epnum]; 48 dep = dwc->eps[epnum];
52 if (dep->flags & DWC3_EP_BUSY)
53 return 0;
54 49
55 trb = &dwc->ep0_trb[dep->trb_enqueue]; 50 trb = &dwc->ep0_trb[dep->trb_enqueue];
56 51
@@ -71,15 +66,23 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
71 trb->ctrl |= (DWC3_TRB_CTRL_IOC 66 trb->ctrl |= (DWC3_TRB_CTRL_IOC
72 | DWC3_TRB_CTRL_LST); 67 | DWC3_TRB_CTRL_LST);
73 68
74 if (chain) 69 trace_dwc3_prepare_trb(dep, trb);
70}
71
72static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum)
73{
74 struct dwc3_gadget_ep_cmd_params params;
75 struct dwc3_ep *dep;
76 int ret;
77
78 dep = dwc->eps[epnum];
79 if (dep->flags & DWC3_EP_BUSY)
75 return 0; 80 return 0;
76 81
77 memset(&params, 0, sizeof(params)); 82 memset(&params, 0, sizeof(params));
78 params.param0 = upper_32_bits(dwc->ep0_trb_addr); 83 params.param0 = upper_32_bits(dwc->ep0_trb_addr);
79 params.param1 = lower_32_bits(dwc->ep0_trb_addr); 84 params.param1 = lower_32_bits(dwc->ep0_trb_addr);
80 85
81 trace_dwc3_prepare_trb(dep, trb);
82
83 ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params); 86 ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params);
84 if (ret < 0) 87 if (ret < 0)
85 return ret; 88 return ret;
@@ -280,8 +283,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
280 283
281 complete(&dwc->ep0_in_setup); 284 complete(&dwc->ep0_in_setup);
282 285
283 ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, 286 dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8,
284 DWC3_TRBCTL_CONTROL_SETUP, false); 287 DWC3_TRBCTL_CONTROL_SETUP, false);
288 ret = dwc3_ep0_start_trans(dwc, 0);
285 WARN_ON(ret < 0); 289 WARN_ON(ret < 0);
286} 290}
287 291
@@ -912,9 +916,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
912 916
913 dwc->ep0_next_event = DWC3_EP0_COMPLETE; 917 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
914 918
915 ret = dwc3_ep0_start_trans(dwc, epnum, 919 dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr,
916 dwc->ctrl_req_addr, 0, 920 0, DWC3_TRBCTL_CONTROL_DATA, false);
917 DWC3_TRBCTL_CONTROL_DATA, false); 921 ret = dwc3_ep0_start_trans(dwc, epnum);
918 WARN_ON(ret < 0); 922 WARN_ON(ret < 0);
919 } 923 }
920 } 924 }
@@ -993,9 +997,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
993 req->direction = !!dep->number; 997 req->direction = !!dep->number;
994 998
995 if (req->request.length == 0) { 999 if (req->request.length == 0) {
996 ret = dwc3_ep0_start_trans(dwc, dep->number, 1000 dwc3_ep0_prepare_one_trb(dwc, dep->number,
997 dwc->ctrl_req_addr, 0, 1001 dwc->ctrl_req_addr, 0,
998 DWC3_TRBCTL_CONTROL_DATA, false); 1002 DWC3_TRBCTL_CONTROL_DATA, false);
1003 ret = dwc3_ep0_start_trans(dwc, dep->number);
999 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) 1004 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
1000 && (dep->number == 0)) { 1005 && (dep->number == 0)) {
1001 u32 transfer_size = 0; 1006 u32 transfer_size = 0;
@@ -1011,7 +1016,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1011 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { 1016 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
1012 transfer_size = ALIGN(req->request.length - maxpacket, 1017 transfer_size = ALIGN(req->request.length - maxpacket,
1013 maxpacket); 1018 maxpacket);
1014 ret = dwc3_ep0_start_trans(dwc, dep->number, 1019 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1015 req->request.dma, 1020 req->request.dma,
1016 transfer_size, 1021 transfer_size,
1017 DWC3_TRBCTL_CONTROL_DATA, 1022 DWC3_TRBCTL_CONTROL_DATA,
@@ -1023,18 +1028,20 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1023 1028
1024 dwc->ep0_bounced = true; 1029 dwc->ep0_bounced = true;
1025 1030
1026 ret = dwc3_ep0_start_trans(dwc, dep->number, 1031 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1027 dwc->ep0_bounce_addr, transfer_size, 1032 dwc->ep0_bounce_addr, transfer_size,
1028 DWC3_TRBCTL_CONTROL_DATA, false); 1033 DWC3_TRBCTL_CONTROL_DATA, false);
1034 ret = dwc3_ep0_start_trans(dwc, dep->number);
1029 } else { 1035 } else {
1030 ret = usb_gadget_map_request_by_dev(dwc->sysdev, 1036 ret = usb_gadget_map_request_by_dev(dwc->sysdev,
1031 &req->request, dep->number); 1037 &req->request, dep->number);
1032 if (ret) 1038 if (ret)
1033 return; 1039 return;
1034 1040
1035 ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, 1041 dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma,
1036 req->request.length, DWC3_TRBCTL_CONTROL_DATA, 1042 req->request.length, DWC3_TRBCTL_CONTROL_DATA,
1037 false); 1043 false);
1044 ret = dwc3_ep0_start_trans(dwc, dep->number);
1038 } 1045 }
1039 1046
1040 WARN_ON(ret < 0); 1047 WARN_ON(ret < 0);
@@ -1048,8 +1055,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
1048 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 1055 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
1049 : DWC3_TRBCTL_CONTROL_STATUS2; 1056 : DWC3_TRBCTL_CONTROL_STATUS2;
1050 1057
1051 return dwc3_ep0_start_trans(dwc, dep->number, 1058 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1052 dwc->ctrl_req_addr, 0, type, false); 1059 dwc->ctrl_req_addr, 0, type, false);
1060 return dwc3_ep0_start_trans(dwc, dep->number);
1053} 1061}
1054 1062
1055static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) 1063static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index efddaf5d11d1..204c754cc647 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -180,11 +180,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
180 if (req->request.status == -EINPROGRESS) 180 if (req->request.status == -EINPROGRESS)
181 req->request.status = status; 181 req->request.status = status;
182 182
183 if (dwc->ep0_bounced && dep->number == 0) 183 if (dwc->ep0_bounced && dep->number <= 1)
184 dwc->ep0_bounced = false; 184 dwc->ep0_bounced = false;
185 else 185
186 usb_gadget_unmap_request_by_dev(dwc->sysdev, 186 usb_gadget_unmap_request_by_dev(dwc->sysdev,
187 &req->request, req->direction); 187 &req->request, req->direction);
188 188
189 trace_dwc3_gadget_giveback(req); 189 trace_dwc3_gadget_giveback(req);
190 190
@@ -1720,7 +1720,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
1720 reg |= DWC3_DCFG_LOWSPEED; 1720 reg |= DWC3_DCFG_LOWSPEED;
1721 break; 1721 break;
1722 case USB_SPEED_FULL: 1722 case USB_SPEED_FULL:
1723 reg |= DWC3_DCFG_FULLSPEED1; 1723 reg |= DWC3_DCFG_FULLSPEED;
1724 break; 1724 break;
1725 case USB_SPEED_HIGH: 1725 case USB_SPEED_HIGH:
1726 reg |= DWC3_DCFG_HIGHSPEED; 1726 reg |= DWC3_DCFG_HIGHSPEED;
@@ -2232,9 +2232,14 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
2232 2232
2233 dep = dwc->eps[epnum]; 2233 dep = dwc->eps[epnum];
2234 2234
2235 if (!(dep->flags & DWC3_EP_ENABLED) && 2235 if (!(dep->flags & DWC3_EP_ENABLED)) {
2236 !(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 2236 if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
2237 return; 2237 return;
2238
2239 /* Handle only EPCMDCMPLT when EP disabled */
2240 if (event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT)
2241 return;
2242 }
2238 2243
2239 if (epnum == 0 || epnum == 1) { 2244 if (epnum == 0 || epnum == 1) {
2240 dwc3_ep0_interrupt(dwc, event); 2245 dwc3_ep0_interrupt(dwc, event);
@@ -2531,8 +2536,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
2531 dwc->gadget.ep0->maxpacket = 64; 2536 dwc->gadget.ep0->maxpacket = 64;
2532 dwc->gadget.speed = USB_SPEED_HIGH; 2537 dwc->gadget.speed = USB_SPEED_HIGH;
2533 break; 2538 break;
2534 case DWC3_DSTS_FULLSPEED2: 2539 case DWC3_DSTS_FULLSPEED:
2535 case DWC3_DSTS_FULLSPEED1:
2536 dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64); 2540 dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
2537 dwc->gadget.ep0->maxpacket = 64; 2541 dwc->gadget.ep0->maxpacket = 64;
2538 dwc->gadget.speed = USB_SPEED_FULL; 2542 dwc->gadget.speed = USB_SPEED_FULL;
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 41ab61f9b6e0..002822d98fda 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1694,9 +1694,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1694 value = min(w_length, (u16) 1); 1694 value = min(w_length, (u16) 1);
1695 break; 1695 break;
1696 1696
1697 /* function drivers must handle get/set altsetting; if there's 1697 /* function drivers must handle get/set altsetting */
1698 * no get() method, we know only altsetting zero works.
1699 */
1700 case USB_REQ_SET_INTERFACE: 1698 case USB_REQ_SET_INTERFACE:
1701 if (ctrl->bRequestType != USB_RECIP_INTERFACE) 1699 if (ctrl->bRequestType != USB_RECIP_INTERFACE)
1702 goto unknown; 1700 goto unknown;
@@ -1705,7 +1703,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1705 f = cdev->config->interface[intf]; 1703 f = cdev->config->interface[intf];
1706 if (!f) 1704 if (!f)
1707 break; 1705 break;
1708 if (w_value && !f->set_alt) 1706
1707 /*
1708 * If there's no get_alt() method, we know only altsetting zero
1709 * works. There is no need to check if set_alt() is not NULL
1710 * as we check this in usb_add_function().
1711 */
1712 if (w_value && !f->get_alt)
1709 break; 1713 break;
1710 value = f->set_alt(f, w_index, w_value); 1714 value = f->set_alt(f, w_index, w_value);
1711 if (value == USB_GADGET_DELAYED_STATUS) { 1715 if (value == USB_GADGET_DELAYED_STATUS) {
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index aab3fc1dbb94..5e746adc8a2d 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2091,8 +2091,8 @@ static int __ffs_data_do_entity(enum ffs_entity_type type,
2091 2091
2092 case FFS_STRING: 2092 case FFS_STRING:
2093 /* 2093 /*
2094 * Strings are indexed from 1 (0 is magic ;) reserved 2094 * Strings are indexed from 1 (0 is reserved
2095 * for languages list or some such) 2095 * for languages list)
2096 */ 2096 */
2097 if (*valuep > helper->ffs->strings_count) 2097 if (*valuep > helper->ffs->strings_count)
2098 helper->ffs->strings_count = *valuep; 2098 helper->ffs->strings_count = *valuep;
@@ -2252,7 +2252,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
2252 2252
2253 if (len < sizeof(*d) || 2253 if (len < sizeof(*d) ||
2254 d->bFirstInterfaceNumber >= ffs->interfaces_count || 2254 d->bFirstInterfaceNumber >= ffs->interfaces_count ||
2255 !d->Reserved1) 2255 d->Reserved1)
2256 return -EINVAL; 2256 return -EINVAL;
2257 for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i) 2257 for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
2258 if (d->Reserved2[i]) 2258 if (d->Reserved2[i])
@@ -3666,6 +3666,7 @@ static void ffs_closed(struct ffs_data *ffs)
3666{ 3666{
3667 struct ffs_dev *ffs_obj; 3667 struct ffs_dev *ffs_obj;
3668 struct f_fs_opts *opts; 3668 struct f_fs_opts *opts;
3669 struct config_item *ci;
3669 3670
3670 ENTER(); 3671 ENTER();
3671 ffs_dev_lock(); 3672 ffs_dev_lock();
@@ -3689,8 +3690,11 @@ static void ffs_closed(struct ffs_data *ffs)
3689 || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) 3690 || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount))
3690 goto done; 3691 goto done;
3691 3692
3692 unregister_gadget_item(ffs_obj->opts-> 3693 ci = opts->func_inst.group.cg_item.ci_parent->ci_parent;
3693 func_inst.group.cg_item.ci_parent->ci_parent); 3694 ffs_dev_unlock();
3695
3696 unregister_gadget_item(ci);
3697 return;
3694done: 3698done:
3695 ffs_dev_unlock(); 3699 ffs_dev_unlock();
3696} 3700}
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 3151d2a0fe59..5f8139b8e601 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -593,7 +593,7 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
593 } 593 }
594 status = usb_ep_enable(hidg->out_ep); 594 status = usb_ep_enable(hidg->out_ep);
595 if (status < 0) { 595 if (status < 0) {
596 ERROR(cdev, "Enable IN endpoint FAILED!\n"); 596 ERROR(cdev, "Enable OUT endpoint FAILED!\n");
597 goto fail; 597 goto fail;
598 } 598 }
599 hidg->out_ep->driver_data = hidg; 599 hidg->out_ep->driver_data = hidg;
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index e8f4102d19df..6bde4396927c 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1126,7 +1126,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1126 /* data and/or status stage for control request */ 1126 /* data and/or status stage for control request */
1127 } else if (dev->state == STATE_DEV_SETUP) { 1127 } else if (dev->state == STATE_DEV_SETUP) {
1128 1128
1129 /* IN DATA+STATUS caller makes len <= wLength */ 1129 len = min_t(size_t, len, dev->setup_wLength);
1130 if (dev->setup_in) { 1130 if (dev->setup_in) {
1131 retval = setup_req (dev->gadget->ep0, dev->req, len); 1131 retval = setup_req (dev->gadget->ep0, dev->req, len);
1132 if (retval == 0) { 1132 if (retval == 0) {
@@ -1734,10 +1734,12 @@ static struct usb_gadget_driver gadgetfs_driver = {
1734 * such as configuration notifications. 1734 * such as configuration notifications.
1735 */ 1735 */
1736 1736
1737static int is_valid_config (struct usb_config_descriptor *config) 1737static int is_valid_config(struct usb_config_descriptor *config,
1738 unsigned int total)
1738{ 1739{
1739 return config->bDescriptorType == USB_DT_CONFIG 1740 return config->bDescriptorType == USB_DT_CONFIG
1740 && config->bLength == USB_DT_CONFIG_SIZE 1741 && config->bLength == USB_DT_CONFIG_SIZE
1742 && total >= USB_DT_CONFIG_SIZE
1741 && config->bConfigurationValue != 0 1743 && config->bConfigurationValue != 0
1742 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0 1744 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0
1743 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0; 1745 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0;
@@ -1762,7 +1764,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1762 } 1764 }
1763 spin_unlock_irq(&dev->lock); 1765 spin_unlock_irq(&dev->lock);
1764 1766
1765 if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) 1767 if ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) ||
1768 (len > PAGE_SIZE * 4))
1766 return -EINVAL; 1769 return -EINVAL;
1767 1770
1768 /* we might need to change message format someday */ 1771 /* we might need to change message format someday */
@@ -1786,7 +1789,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1786 /* full or low speed config */ 1789 /* full or low speed config */
1787 dev->config = (void *) kbuf; 1790 dev->config = (void *) kbuf;
1788 total = le16_to_cpu(dev->config->wTotalLength); 1791 total = le16_to_cpu(dev->config->wTotalLength);
1789 if (!is_valid_config (dev->config) || total >= length) 1792 if (!is_valid_config(dev->config, total) ||
1793 total > length - USB_DT_DEVICE_SIZE)
1790 goto fail; 1794 goto fail;
1791 kbuf += total; 1795 kbuf += total;
1792 length -= total; 1796 length -= total;
@@ -1795,10 +1799,13 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1795 if (kbuf [1] == USB_DT_CONFIG) { 1799 if (kbuf [1] == USB_DT_CONFIG) {
1796 dev->hs_config = (void *) kbuf; 1800 dev->hs_config = (void *) kbuf;
1797 total = le16_to_cpu(dev->hs_config->wTotalLength); 1801 total = le16_to_cpu(dev->hs_config->wTotalLength);
1798 if (!is_valid_config (dev->hs_config) || total >= length) 1802 if (!is_valid_config(dev->hs_config, total) ||
1803 total > length - USB_DT_DEVICE_SIZE)
1799 goto fail; 1804 goto fail;
1800 kbuf += total; 1805 kbuf += total;
1801 length -= total; 1806 length -= total;
1807 } else {
1808 dev->hs_config = NULL;
1802 } 1809 }
1803 1810
1804 /* could support multiple configs, using another encoding! */ 1811 /* could support multiple configs, using another encoding! */
@@ -1811,7 +1818,6 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1811 || dev->dev->bDescriptorType != USB_DT_DEVICE 1818 || dev->dev->bDescriptorType != USB_DT_DEVICE
1812 || dev->dev->bNumConfigurations != 1) 1819 || dev->dev->bNumConfigurations != 1)
1813 goto fail; 1820 goto fail;
1814 dev->dev->bNumConfigurations = 1;
1815 dev->dev->bcdUSB = cpu_to_le16 (0x0200); 1821 dev->dev->bcdUSB = cpu_to_le16 (0x0200);
1816 1822
1817 /* triggers gadgetfs_bind(); then we can enumerate. */ 1823 /* triggers gadgetfs_bind(); then we can enumerate. */
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 9483489080f6..0402177f93cd 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1317,7 +1317,11 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
1317 if (!ret) 1317 if (!ret)
1318 break; 1318 break;
1319 } 1319 }
1320 if (!ret && !udc->driver) 1320 if (ret)
1321 ret = -ENODEV;
1322 else if (udc->driver)
1323 ret = -EBUSY;
1324 else
1321 goto found; 1325 goto found;
1322 } else { 1326 } else {
1323 list_for_each_entry(udc, &udc_list, list) { 1327 list_for_each_entry(udc, &udc_list, list) {
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 02b14e91ae6c..c60abe3a68f9 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, struct dummy_ep *ep)
330/* caller must hold lock */ 330/* caller must hold lock */
331static void stop_activity(struct dummy *dum) 331static void stop_activity(struct dummy *dum)
332{ 332{
333 struct dummy_ep *ep; 333 int i;
334 334
335 /* prevent any more requests */ 335 /* prevent any more requests */
336 dum->address = 0; 336 dum->address = 0;
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy *dum)
338 /* The timer is left running so that outstanding URBs can fail */ 338 /* The timer is left running so that outstanding URBs can fail */
339 339
340 /* nuke any pending requests first, so driver i/o is quiesced */ 340 /* nuke any pending requests first, so driver i/o is quiesced */
341 list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) 341 for (i = 0; i < DUMMY_ENDPOINTS; ++i)
342 nuke(dum, ep); 342 nuke(dum, &dum->ep[i]);
343 343
344 /* driver now does any non-usb quiescing necessary */ 344 /* driver now does any non-usb quiescing necessary */
345} 345}
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index be9e63836881..414e3c376dbb 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -43,7 +43,6 @@ struct at91_usbh_data {
43 struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; 43 struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS];
44 u8 ports; /* number of ports on root hub */ 44 u8 ports; /* number of ports on root hub */
45 u8 overcurrent_supported; 45 u8 overcurrent_supported;
46 u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
47 u8 overcurrent_status[AT91_MAX_USBH_PORTS]; 46 u8 overcurrent_status[AT91_MAX_USBH_PORTS];
48 u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; 47 u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
49}; 48};
@@ -266,8 +265,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
266 if (!valid_port(port)) 265 if (!valid_port(port))
267 return; 266 return;
268 267
269 gpiod_set_value(pdata->vbus_pin[port], 268 gpiod_set_value(pdata->vbus_pin[port], enable);
270 pdata->vbus_pin_active_low[port] ^ enable);
271} 269}
272 270
273static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 271static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
@@ -275,8 +273,7 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
275 if (!valid_port(port)) 273 if (!valid_port(port))
276 return -EINVAL; 274 return -EINVAL;
277 275
278 return gpiod_get_value(pdata->vbus_pin[port]) ^ 276 return gpiod_get_value(pdata->vbus_pin[port]);
279 pdata->vbus_pin_active_low[port];
280} 277}
281 278
282/* 279/*
@@ -533,18 +530,17 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
533 pdata->ports = ports; 530 pdata->ports = ports;
534 531
535 at91_for_each_port(i) { 532 at91_for_each_port(i) {
536 pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev, 533 if (i >= pdata->ports)
537 "atmel,vbus-gpio", 534 break;
538 GPIOD_IN); 535
536 pdata->vbus_pin[i] =
537 devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus",
538 i, GPIOD_OUT_HIGH);
539 if (IS_ERR(pdata->vbus_pin[i])) { 539 if (IS_ERR(pdata->vbus_pin[i])) {
540 err = PTR_ERR(pdata->vbus_pin[i]); 540 err = PTR_ERR(pdata->vbus_pin[i]);
541 dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); 541 dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err);
542 continue; 542 continue;
543 } 543 }
544
545 pdata->vbus_pin_active_low[i] = gpiod_get_value(pdata->vbus_pin[i]);
546
547 ohci_at91_usb_set_power(pdata, i, 1);
548 } 544 }
549 545
550 at91_for_each_port(i) { 546 at91_for_each_port(i) {
@@ -552,8 +548,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
552 break; 548 break;
553 549
554 pdata->overcurrent_pin[i] = 550 pdata->overcurrent_pin[i] =
555 devm_gpiod_get_optional(&pdev->dev, 551 devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
556 "atmel,oc-gpio", GPIOD_IN); 552 i, GPIOD_IN);
557 if (IS_ERR(pdata->overcurrent_pin[i])) { 553 if (IS_ERR(pdata->overcurrent_pin[i])) {
558 err = PTR_ERR(pdata->overcurrent_pin[i]); 554 err = PTR_ERR(pdata->overcurrent_pin[i]);
559 dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); 555 dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 321de2e0161b..8414ed2a02de 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -979,6 +979,40 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
979 xhci->devs[slot_id] = NULL; 979 xhci->devs[slot_id] = NULL;
980} 980}
981 981
982/*
983 * Free a virt_device structure.
984 * If the virt_device added a tt_info (a hub) and has children pointing to
985 * that tt_info, then free the child first. Recursive.
986 * We can't rely on udev at this point to find child-parent relationships.
987 */
988void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
989{
990 struct xhci_virt_device *vdev;
991 struct list_head *tt_list_head;
992 struct xhci_tt_bw_info *tt_info, *next;
993 int i;
994
995 vdev = xhci->devs[slot_id];
996 if (!vdev)
997 return;
998
999 tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
1000 list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
1001 /* is this a hub device that added a tt_info to the tts list */
1002 if (tt_info->slot_id == slot_id) {
1003 /* are any devices using this tt_info? */
1004 for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
1005 vdev = xhci->devs[i];
1006 if (vdev && (vdev->tt_info == tt_info))
1007 xhci_free_virt_devices_depth_first(
1008 xhci, i);
1009 }
1010 }
1011 }
1012 /* we are now at a leaf device */
1013 xhci_free_virt_device(xhci, slot_id);
1014}
1015
982int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, 1016int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
983 struct usb_device *udev, gfp_t flags) 1017 struct usb_device *udev, gfp_t flags)
984{ 1018{
@@ -1795,7 +1829,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1795 int size; 1829 int size;
1796 int i, j, num_ports; 1830 int i, j, num_ports;
1797 1831
1798 del_timer_sync(&xhci->cmd_timer); 1832 cancel_delayed_work_sync(&xhci->cmd_timer);
1799 1833
1800 /* Free the Event Ring Segment Table and the actual Event Ring */ 1834 /* Free the Event Ring Segment Table and the actual Event Ring */
1801 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1835 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -1828,8 +1862,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1828 } 1862 }
1829 } 1863 }
1830 1864
1831 for (i = 1; i < MAX_HC_SLOTS; ++i) 1865 for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--)
1832 xhci_free_virt_device(xhci, i); 1866 xhci_free_virt_devices_depth_first(xhci, i);
1833 1867
1834 dma_pool_destroy(xhci->segment_pool); 1868 dma_pool_destroy(xhci->segment_pool);
1835 xhci->segment_pool = NULL; 1869 xhci->segment_pool = NULL;
@@ -2342,9 +2376,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2342 2376
2343 INIT_LIST_HEAD(&xhci->cmd_list); 2377 INIT_LIST_HEAD(&xhci->cmd_list);
2344 2378
2345 /* init command timeout timer */ 2379 /* init command timeout work */
2346 setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout, 2380 INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
2347 (unsigned long)xhci); 2381 init_completion(&xhci->cmd_ring_stop_completion);
2348 2382
2349 page_size = readl(&xhci->op_regs->page_size); 2383 page_size = readl(&xhci->op_regs->page_size);
2350 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2384 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 1094ebd2838f..bac961cd24ad 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -579,8 +579,10 @@ static int xhci_mtk_probe(struct platform_device *pdev)
579 goto disable_ldos; 579 goto disable_ldos;
580 580
581 irq = platform_get_irq(pdev, 0); 581 irq = platform_get_irq(pdev, 0);
582 if (irq < 0) 582 if (irq < 0) {
583 ret = irq;
583 goto disable_clk; 584 goto disable_clk;
585 }
584 586
585 /* Initialize dma_mask and coherent_dma_mask to 32-bits */ 587 /* Initialize dma_mask and coherent_dma_mask to 32-bits */
586 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); 588 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index e96ae80d107e..954abfd5014d 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -165,7 +165,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
165 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || 165 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || 167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { 168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
169 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) {
169 xhci->quirks |= XHCI_PME_STUCK_QUIRK; 170 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
170 } 171 }
171 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 172 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index bdf6b13d9b67..25f522b09dd9 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -279,23 +279,76 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
279 readl(&xhci->dba->doorbell[0]); 279 readl(&xhci->dba->doorbell[0]);
280} 280}
281 281
282static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) 282static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay)
283{
284 return mod_delayed_work(system_wq, &xhci->cmd_timer, delay);
285}
286
287static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci)
288{
289 return list_first_entry_or_null(&xhci->cmd_list, struct xhci_command,
290 cmd_list);
291}
292
293/*
294 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
295 * If there are other commands waiting then restart the ring and kick the timer.
296 * This must be called with command ring stopped and xhci->lock held.
297 */
298static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
299 struct xhci_command *cur_cmd)
300{
301 struct xhci_command *i_cmd;
302 u32 cycle_state;
303
304 /* Turn all aborted commands in list to no-ops, then restart */
305 list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) {
306
307 if (i_cmd->status != COMP_CMD_ABORT)
308 continue;
309
310 i_cmd->status = COMP_CMD_STOP;
311
312 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
313 i_cmd->command_trb);
314 /* get cycle state from the original cmd trb */
315 cycle_state = le32_to_cpu(
316 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
317 /* modify the command trb to no-op command */
318 i_cmd->command_trb->generic.field[0] = 0;
319 i_cmd->command_trb->generic.field[1] = 0;
320 i_cmd->command_trb->generic.field[2] = 0;
321 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
322 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
323
324 /*
325 * caller waiting for completion is called when command
326 * completion event is received for these no-op commands
327 */
328 }
329
330 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
331
332 /* ring command ring doorbell to restart the command ring */
333 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
334 !(xhci->xhc_state & XHCI_STATE_DYING)) {
335 xhci->current_cmd = cur_cmd;
336 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
337 xhci_ring_cmd_db(xhci);
338 }
339}
340
341/* Must be called with xhci->lock held, releases and aquires lock back */
342static int xhci_abort_cmd_ring(struct xhci_hcd *xhci, unsigned long flags)
283{ 343{
284 u64 temp_64; 344 u64 temp_64;
285 int ret; 345 int ret;
286 346
287 xhci_dbg(xhci, "Abort command ring\n"); 347 xhci_dbg(xhci, "Abort command ring\n");
288 348
289 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 349 reinit_completion(&xhci->cmd_ring_stop_completion);
290 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
291 350
292 /* 351 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
293 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
294 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
295 * but the completion event in never sent. Use the cmd timeout timer to
296 * handle those cases. Use twice the time to cover the bit polling retry
297 */
298 mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT));
299 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, 352 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
300 &xhci->op_regs->cmd_ring); 353 &xhci->op_regs->cmd_ring);
301 354
@@ -315,17 +368,30 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
315 udelay(1000); 368 udelay(1000);
316 ret = xhci_handshake(&xhci->op_regs->cmd_ring, 369 ret = xhci_handshake(&xhci->op_regs->cmd_ring,
317 CMD_RING_RUNNING, 0, 3 * 1000 * 1000); 370 CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
318 if (ret == 0) 371 if (ret < 0) {
319 return 0; 372 xhci_err(xhci, "Stopped the command ring failed, "
320 373 "maybe the host is dead\n");
321 xhci_err(xhci, "Stopped the command ring failed, " 374 xhci->xhc_state |= XHCI_STATE_DYING;
322 "maybe the host is dead\n"); 375 xhci_halt(xhci);
323 del_timer(&xhci->cmd_timer); 376 return -ESHUTDOWN;
324 xhci->xhc_state |= XHCI_STATE_DYING; 377 }
325 xhci_halt(xhci); 378 }
326 return -ESHUTDOWN; 379 /*
380 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
381 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
382 * but the completion event in never sent. Wait 2 secs (arbitrary
383 * number) to handle those cases after negation of CMD_RING_RUNNING.
384 */
385 spin_unlock_irqrestore(&xhci->lock, flags);
386 ret = wait_for_completion_timeout(&xhci->cmd_ring_stop_completion,
387 msecs_to_jiffies(2000));
388 spin_lock_irqsave(&xhci->lock, flags);
389 if (!ret) {
390 xhci_dbg(xhci, "No stop event for abort, ring start fail?\n");
391 xhci_cleanup_command_queue(xhci);
392 } else {
393 xhci_handle_stopped_cmd_ring(xhci, xhci_next_queued_cmd(xhci));
327 } 394 }
328
329 return 0; 395 return 0;
330} 396}
331 397
@@ -1207,101 +1273,62 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
1207 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT); 1273 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT);
1208} 1274}
1209 1275
1210/* 1276void xhci_handle_command_timeout(struct work_struct *work)
1211 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
1212 * If there are other commands waiting then restart the ring and kick the timer.
1213 * This must be called with command ring stopped and xhci->lock held.
1214 */
1215static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
1216 struct xhci_command *cur_cmd)
1217{
1218 struct xhci_command *i_cmd, *tmp_cmd;
1219 u32 cycle_state;
1220
1221 /* Turn all aborted commands in list to no-ops, then restart */
1222 list_for_each_entry_safe(i_cmd, tmp_cmd, &xhci->cmd_list,
1223 cmd_list) {
1224
1225 if (i_cmd->status != COMP_CMD_ABORT)
1226 continue;
1227
1228 i_cmd->status = COMP_CMD_STOP;
1229
1230 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
1231 i_cmd->command_trb);
1232 /* get cycle state from the original cmd trb */
1233 cycle_state = le32_to_cpu(
1234 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
1235 /* modify the command trb to no-op command */
1236 i_cmd->command_trb->generic.field[0] = 0;
1237 i_cmd->command_trb->generic.field[1] = 0;
1238 i_cmd->command_trb->generic.field[2] = 0;
1239 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
1240 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
1241
1242 /*
1243 * caller waiting for completion is called when command
1244 * completion event is received for these no-op commands
1245 */
1246 }
1247
1248 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
1249
1250 /* ring command ring doorbell to restart the command ring */
1251 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
1252 !(xhci->xhc_state & XHCI_STATE_DYING)) {
1253 xhci->current_cmd = cur_cmd;
1254 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
1255 xhci_ring_cmd_db(xhci);
1256 }
1257 return;
1258}
1259
1260
1261void xhci_handle_command_timeout(unsigned long data)
1262{ 1277{
1263 struct xhci_hcd *xhci; 1278 struct xhci_hcd *xhci;
1264 int ret; 1279 int ret;
1265 unsigned long flags; 1280 unsigned long flags;
1266 u64 hw_ring_state; 1281 u64 hw_ring_state;
1267 bool second_timeout = false;
1268 xhci = (struct xhci_hcd *) data;
1269 1282
1270 /* mark this command to be cancelled */ 1283 xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
1284
1271 spin_lock_irqsave(&xhci->lock, flags); 1285 spin_lock_irqsave(&xhci->lock, flags);
1272 if (xhci->current_cmd) { 1286
1273 if (xhci->current_cmd->status == COMP_CMD_ABORT) 1287 /*
1274 second_timeout = true; 1288 * If timeout work is pending, or current_cmd is NULL, it means we
1275 xhci->current_cmd->status = COMP_CMD_ABORT; 1289 * raced with command completion. Command is handled so just return.
1290 */
1291 if (!xhci->current_cmd || delayed_work_pending(&xhci->cmd_timer)) {
1292 spin_unlock_irqrestore(&xhci->lock, flags);
1293 return;
1276 } 1294 }
1295 /* mark this command to be cancelled */
1296 xhci->current_cmd->status = COMP_CMD_ABORT;
1277 1297
1278 /* Make sure command ring is running before aborting it */ 1298 /* Make sure command ring is running before aborting it */
1279 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 1299 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
1280 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && 1300 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
1281 (hw_ring_state & CMD_RING_RUNNING)) { 1301 (hw_ring_state & CMD_RING_RUNNING)) {
1282 spin_unlock_irqrestore(&xhci->lock, flags); 1302 /* Prevent new doorbell, and start command abort */
1303 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
1283 xhci_dbg(xhci, "Command timeout\n"); 1304 xhci_dbg(xhci, "Command timeout\n");
1284 ret = xhci_abort_cmd_ring(xhci); 1305 ret = xhci_abort_cmd_ring(xhci, flags);
1285 if (unlikely(ret == -ESHUTDOWN)) { 1306 if (unlikely(ret == -ESHUTDOWN)) {
1286 xhci_err(xhci, "Abort command ring failed\n"); 1307 xhci_err(xhci, "Abort command ring failed\n");
1287 xhci_cleanup_command_queue(xhci); 1308 xhci_cleanup_command_queue(xhci);
1309 spin_unlock_irqrestore(&xhci->lock, flags);
1288 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); 1310 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
1289 xhci_dbg(xhci, "xHCI host controller is dead.\n"); 1311 xhci_dbg(xhci, "xHCI host controller is dead.\n");
1312
1313 return;
1290 } 1314 }
1291 return; 1315
1316 goto time_out_completed;
1292 } 1317 }
1293 1318
1294 /* command ring failed to restart, or host removed. Bail out */ 1319 /* host removed. Bail out */
1295 if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) { 1320 if (xhci->xhc_state & XHCI_STATE_REMOVING) {
1296 spin_unlock_irqrestore(&xhci->lock, flags); 1321 xhci_dbg(xhci, "host removed, ring start fail?\n");
1297 xhci_dbg(xhci, "command timed out twice, ring start fail?\n");
1298 xhci_cleanup_command_queue(xhci); 1322 xhci_cleanup_command_queue(xhci);
1299 return; 1323
1324 goto time_out_completed;
1300 } 1325 }
1301 1326
1302 /* command timeout on stopped ring, ring can't be aborted */ 1327 /* command timeout on stopped ring, ring can't be aborted */
1303 xhci_dbg(xhci, "Command timeout on stopped ring\n"); 1328 xhci_dbg(xhci, "Command timeout on stopped ring\n");
1304 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); 1329 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd);
1330
1331time_out_completed:
1305 spin_unlock_irqrestore(&xhci->lock, flags); 1332 spin_unlock_irqrestore(&xhci->lock, flags);
1306 return; 1333 return;
1307} 1334}
@@ -1333,7 +1360,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1333 1360
1334 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); 1361 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
1335 1362
1336 del_timer(&xhci->cmd_timer); 1363 cancel_delayed_work(&xhci->cmd_timer);
1337 1364
1338 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); 1365 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
1339 1366
@@ -1341,7 +1368,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1341 1368
1342 /* If CMD ring stopped we own the trbs between enqueue and dequeue */ 1369 /* If CMD ring stopped we own the trbs between enqueue and dequeue */
1343 if (cmd_comp_code == COMP_CMD_STOP) { 1370 if (cmd_comp_code == COMP_CMD_STOP) {
1344 xhci_handle_stopped_cmd_ring(xhci, cmd); 1371 complete_all(&xhci->cmd_ring_stop_completion);
1345 return; 1372 return;
1346 } 1373 }
1347 1374
@@ -1359,8 +1386,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1359 */ 1386 */
1360 if (cmd_comp_code == COMP_CMD_ABORT) { 1387 if (cmd_comp_code == COMP_CMD_ABORT) {
1361 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 1388 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
1362 if (cmd->status == COMP_CMD_ABORT) 1389 if (cmd->status == COMP_CMD_ABORT) {
1390 if (xhci->current_cmd == cmd)
1391 xhci->current_cmd = NULL;
1363 goto event_handled; 1392 goto event_handled;
1393 }
1364 } 1394 }
1365 1395
1366 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); 1396 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3]));
@@ -1421,7 +1451,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1421 if (cmd->cmd_list.next != &xhci->cmd_list) { 1451 if (cmd->cmd_list.next != &xhci->cmd_list) {
1422 xhci->current_cmd = list_entry(cmd->cmd_list.next, 1452 xhci->current_cmd = list_entry(cmd->cmd_list.next,
1423 struct xhci_command, cmd_list); 1453 struct xhci_command, cmd_list);
1424 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 1454 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
1455 } else if (xhci->current_cmd == cmd) {
1456 xhci->current_cmd = NULL;
1425 } 1457 }
1426 1458
1427event_handled: 1459event_handled:
@@ -1939,8 +1971,9 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1939 struct xhci_ep_ctx *ep_ctx; 1971 struct xhci_ep_ctx *ep_ctx;
1940 u32 trb_comp_code; 1972 u32 trb_comp_code;
1941 u32 remaining, requested; 1973 u32 remaining, requested;
1942 bool on_data_stage; 1974 u32 trb_type;
1943 1975
1976 trb_type = TRB_FIELD_TO_TYPE(le32_to_cpu(ep_trb->generic.field[3]));
1944 slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); 1977 slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
1945 xdev = xhci->devs[slot_id]; 1978 xdev = xhci->devs[slot_id];
1946 ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; 1979 ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1;
@@ -1950,14 +1983,11 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1950 requested = td->urb->transfer_buffer_length; 1983 requested = td->urb->transfer_buffer_length;
1951 remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); 1984 remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
1952 1985
1953 /* not setup (dequeue), or status stage means we are at data stage */
1954 on_data_stage = (ep_trb != ep_ring->dequeue && ep_trb != td->last_trb);
1955
1956 switch (trb_comp_code) { 1986 switch (trb_comp_code) {
1957 case COMP_SUCCESS: 1987 case COMP_SUCCESS:
1958 if (ep_trb != td->last_trb) { 1988 if (trb_type != TRB_STATUS) {
1959 xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n", 1989 xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n",
1960 on_data_stage ? "data" : "setup"); 1990 (trb_type == TRB_DATA) ? "data" : "setup");
1961 *status = -ESHUTDOWN; 1991 *status = -ESHUTDOWN;
1962 break; 1992 break;
1963 } 1993 }
@@ -1967,15 +1997,25 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1967 *status = 0; 1997 *status = 0;
1968 break; 1998 break;
1969 case COMP_STOP_SHORT: 1999 case COMP_STOP_SHORT:
1970 if (on_data_stage) 2000 if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
1971 td->urb->actual_length = remaining; 2001 td->urb->actual_length = remaining;
1972 else 2002 else
1973 xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n"); 2003 xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
1974 goto finish_td; 2004 goto finish_td;
1975 case COMP_STOP: 2005 case COMP_STOP:
1976 if (on_data_stage) 2006 switch (trb_type) {
2007 case TRB_SETUP:
2008 td->urb->actual_length = 0;
2009 goto finish_td;
2010 case TRB_DATA:
2011 case TRB_NORMAL:
1977 td->urb->actual_length = requested - remaining; 2012 td->urb->actual_length = requested - remaining;
1978 goto finish_td; 2013 goto finish_td;
2014 default:
2015 xhci_warn(xhci, "WARN: unexpected TRB Type %d\n",
2016 trb_type);
2017 goto finish_td;
2018 }
1979 case COMP_STOP_INVAL: 2019 case COMP_STOP_INVAL:
1980 goto finish_td; 2020 goto finish_td;
1981 default: 2021 default:
@@ -1987,7 +2027,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1987 /* else fall through */ 2027 /* else fall through */
1988 case COMP_STALL: 2028 case COMP_STALL:
1989 /* Did we transfer part of the data (middle) phase? */ 2029 /* Did we transfer part of the data (middle) phase? */
1990 if (on_data_stage) 2030 if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
1991 td->urb->actual_length = requested - remaining; 2031 td->urb->actual_length = requested - remaining;
1992 else if (!td->urb_length_set) 2032 else if (!td->urb_length_set)
1993 td->urb->actual_length = 0; 2033 td->urb->actual_length = 0;
@@ -1995,14 +2035,15 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1995 } 2035 }
1996 2036
1997 /* stopped at setup stage, no data transferred */ 2037 /* stopped at setup stage, no data transferred */
1998 if (ep_trb == ep_ring->dequeue) 2038 if (trb_type == TRB_SETUP)
1999 goto finish_td; 2039 goto finish_td;
2000 2040
2001 /* 2041 /*
2002 * if on data stage then update the actual_length of the URB and flag it 2042 * if on data stage then update the actual_length of the URB and flag it
2003 * as set, so it won't be overwritten in the event for the last TRB. 2043 * as set, so it won't be overwritten in the event for the last TRB.
2004 */ 2044 */
2005 if (on_data_stage) { 2045 if (trb_type == TRB_DATA ||
2046 trb_type == TRB_NORMAL) {
2006 td->urb_length_set = true; 2047 td->urb_length_set = true;
2007 td->urb->actual_length = requested - remaining; 2048 td->urb->actual_length = requested - remaining;
2008 xhci_dbg(xhci, "Waiting for status stage event\n"); 2049 xhci_dbg(xhci, "Waiting for status stage event\n");
@@ -3790,9 +3831,9 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
3790 3831
3791 /* if there are no other commands queued we start the timeout timer */ 3832 /* if there are no other commands queued we start the timeout timer */
3792 if (xhci->cmd_list.next == &cmd->cmd_list && 3833 if (xhci->cmd_list.next == &cmd->cmd_list &&
3793 !timer_pending(&xhci->cmd_timer)) { 3834 !delayed_work_pending(&xhci->cmd_timer)) {
3794 xhci->current_cmd = cmd; 3835 xhci->current_cmd = cmd;
3795 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 3836 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
3796 } 3837 }
3797 3838
3798 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 3839 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1cd56417cbec..0c8deb9ed42d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3787,8 +3787,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3787 3787
3788 mutex_lock(&xhci->mutex); 3788 mutex_lock(&xhci->mutex);
3789 3789
3790 if (xhci->xhc_state) /* dying, removing or halted */ 3790 if (xhci->xhc_state) { /* dying, removing or halted */
3791 ret = -ESHUTDOWN;
3791 goto out; 3792 goto out;
3793 }
3792 3794
3793 if (!udev->slot_id) { 3795 if (!udev->slot_id) {
3794 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3796 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 8ccc11a974b8..2d7b6374b58d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1568,7 +1568,8 @@ struct xhci_hcd {
1568#define CMD_RING_STATE_STOPPED (1 << 2) 1568#define CMD_RING_STATE_STOPPED (1 << 2)
1569 struct list_head cmd_list; 1569 struct list_head cmd_list;
1570 unsigned int cmd_ring_reserved_trbs; 1570 unsigned int cmd_ring_reserved_trbs;
1571 struct timer_list cmd_timer; 1571 struct delayed_work cmd_timer;
1572 struct completion cmd_ring_stop_completion;
1572 struct xhci_command *current_cmd; 1573 struct xhci_command *current_cmd;
1573 struct xhci_ring *event_ring; 1574 struct xhci_ring *event_ring;
1574 struct xhci_erst erst; 1575 struct xhci_erst erst;
@@ -1934,7 +1935,7 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci,
1934 unsigned int slot_id, unsigned int ep_index, 1935 unsigned int slot_id, unsigned int ep_index,
1935 struct xhci_dequeue_state *deq_state); 1936 struct xhci_dequeue_state *deq_state);
1936void xhci_stop_endpoint_command_watchdog(unsigned long arg); 1937void xhci_stop_endpoint_command_watchdog(unsigned long arg);
1937void xhci_handle_command_timeout(unsigned long data); 1938void xhci_handle_command_timeout(struct work_struct *work);
1938 1939
1939void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 1940void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
1940 unsigned int ep_index, unsigned int stream_id); 1941 unsigned int ep_index, unsigned int stream_id);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 310238c6b5cd..896798071817 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -469,6 +469,7 @@ static const struct musb_platform_ops bfin_ops = {
469 .init = bfin_musb_init, 469 .init = bfin_musb_init,
470 .exit = bfin_musb_exit, 470 .exit = bfin_musb_exit,
471 471
472 .fifo_offset = bfin_fifo_offset,
472 .readb = bfin_readb, 473 .readb = bfin_readb,
473 .writeb = bfin_writeb, 474 .writeb = bfin_writeb,
474 .readw = bfin_readw, 475 .readw = bfin_readw,
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9e226468a13e..fca288bbc800 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2050,6 +2050,7 @@ struct musb_pending_work {
2050 struct list_head node; 2050 struct list_head node;
2051}; 2051};
2052 2052
2053#ifdef CONFIG_PM
2053/* 2054/*
2054 * Called from musb_runtime_resume(), musb_resume(), and 2055 * Called from musb_runtime_resume(), musb_resume(), and
2055 * musb_queue_resume_work(). Callers must take musb->lock. 2056 * musb_queue_resume_work(). Callers must take musb->lock.
@@ -2077,6 +2078,7 @@ static int musb_run_resume_work(struct musb *musb)
2077 2078
2078 return error; 2079 return error;
2079} 2080}
2081#endif
2080 2082
2081/* 2083/*
2082 * Called to run work if device is active or else queue the work to happen 2084 * Called to run work if device is active or else queue the work to happen
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a611e2f67bdc..ade902ea1221 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -216,6 +216,7 @@ struct musb_platform_ops {
216 void (*pre_root_reset_end)(struct musb *musb); 216 void (*pre_root_reset_end)(struct musb *musb);
217 void (*post_root_reset_end)(struct musb *musb); 217 void (*post_root_reset_end)(struct musb *musb);
218 int (*phy_callback)(enum musb_vbus_id_status status); 218 int (*phy_callback)(enum musb_vbus_id_status status);
219 void (*clear_ep_rxintr)(struct musb *musb, int epnum);
219}; 220};
220 221
221/* 222/*
@@ -626,6 +627,12 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb)
626 musb->ops->post_root_reset_end(musb); 627 musb->ops->post_root_reset_end(musb);
627} 628}
628 629
630static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum)
631{
632 if (musb->ops->clear_ep_rxintr)
633 musb->ops->clear_ep_rxintr(musb, epnum);
634}
635
629/* 636/*
630 * gets the "dr_mode" property from DT and converts it into musb_mode 637 * gets the "dr_mode" property from DT and converts it into musb_mode
631 * if the property is not found or not recognized returns MUSB_OTG 638 * if the property is not found or not recognized returns MUSB_OTG
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index feae1561b9ab..9f125e179acd 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -267,6 +267,17 @@ static void otg_timer(unsigned long _musb)
267 pm_runtime_put_autosuspend(dev); 267 pm_runtime_put_autosuspend(dev);
268} 268}
269 269
270void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum)
271{
272 u32 epintr;
273 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
274 const struct dsps_musb_wrapper *wrp = glue->wrp;
275
276 /* musb->lock might already been held */
277 epintr = (1 << epnum) << wrp->rxep_shift;
278 musb_writel(musb->ctrl_base, wrp->epintr_status, epintr);
279}
280
270static irqreturn_t dsps_interrupt(int irq, void *hci) 281static irqreturn_t dsps_interrupt(int irq, void *hci)
271{ 282{
272 struct musb *musb = hci; 283 struct musb *musb = hci;
@@ -622,6 +633,7 @@ static struct musb_platform_ops dsps_ops = {
622 633
623 .set_mode = dsps_musb_set_mode, 634 .set_mode = dsps_musb_set_mode,
624 .recover = dsps_musb_recover, 635 .recover = dsps_musb_recover,
636 .clear_ep_rxintr = dsps_musb_clear_ep_rxintr,
625}; 637};
626 638
627static u64 musb_dmamask = DMA_BIT_MASK(32); 639static u64 musb_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index f6cdbad00dac..ac3a4952abb4 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2374,12 +2374,11 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2374 int is_in = usb_pipein(urb->pipe); 2374 int is_in = usb_pipein(urb->pipe);
2375 int status = 0; 2375 int status = 0;
2376 u16 csr; 2376 u16 csr;
2377 struct dma_channel *dma = NULL;
2377 2378
2378 musb_ep_select(regs, hw_end); 2379 musb_ep_select(regs, hw_end);
2379 2380
2380 if (is_dma_capable()) { 2381 if (is_dma_capable()) {
2381 struct dma_channel *dma;
2382
2383 dma = is_in ? ep->rx_channel : ep->tx_channel; 2382 dma = is_in ? ep->rx_channel : ep->tx_channel;
2384 if (dma) { 2383 if (dma) {
2385 status = ep->musb->dma_controller->channel_abort(dma); 2384 status = ep->musb->dma_controller->channel_abort(dma);
@@ -2395,10 +2394,9 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2395 /* giveback saves bulk toggle */ 2394 /* giveback saves bulk toggle */
2396 csr = musb_h_flush_rxfifo(ep, 0); 2395 csr = musb_h_flush_rxfifo(ep, 0);
2397 2396
2398 /* REVISIT we still get an irq; should likely clear the 2397 /* clear the endpoint's irq status here to avoid bogus irqs */
2399 * endpoint's irq status here to avoid bogus irqs. 2398 if (is_dma_capable() && dma)
2400 * clearing that status is platform-specific... 2399 musb_platform_clear_ep_rxintr(musb, ep->epnum);
2401 */
2402 } else if (ep->epnum) { 2400 } else if (ep->epnum) {
2403 musb_h_tx_flush_fifo(ep); 2401 musb_h_tx_flush_fifo(ep);
2404 csr = musb_readw(epio, MUSB_TXCSR); 2402 csr = musb_readw(epio, MUSB_TXCSR);
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
index f7b13fd25257..a3dcbd55e436 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -157,5 +157,5 @@ struct musb_dma_controller {
157 void __iomem *base; 157 void __iomem *base;
158 u8 channel_count; 158 u8 channel_count;
159 u8 used_channels; 159 u8 used_channels;
160 u8 irq; 160 int irq;
161}; 161};
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 5f17a3b9916d..80260b08398b 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -50,6 +50,7 @@
50#define CYBERJACK_PRODUCT_ID 0x0100 50#define CYBERJACK_PRODUCT_ID 0x0100
51 51
52/* Function prototypes */ 52/* Function prototypes */
53static int cyberjack_attach(struct usb_serial *serial);
53static int cyberjack_port_probe(struct usb_serial_port *port); 54static int cyberjack_port_probe(struct usb_serial_port *port);
54static int cyberjack_port_remove(struct usb_serial_port *port); 55static int cyberjack_port_remove(struct usb_serial_port *port);
55static int cyberjack_open(struct tty_struct *tty, 56static int cyberjack_open(struct tty_struct *tty,
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjack_device = {
77 .description = "Reiner SCT Cyberjack USB card reader", 78 .description = "Reiner SCT Cyberjack USB card reader",
78 .id_table = id_table, 79 .id_table = id_table,
79 .num_ports = 1, 80 .num_ports = 1,
81 .attach = cyberjack_attach,
80 .port_probe = cyberjack_port_probe, 82 .port_probe = cyberjack_port_probe,
81 .port_remove = cyberjack_port_remove, 83 .port_remove = cyberjack_port_remove,
82 .open = cyberjack_open, 84 .open = cyberjack_open,
@@ -100,6 +102,14 @@ struct cyberjack_private {
100 short wrsent; /* Data already sent */ 102 short wrsent; /* Data already sent */
101}; 103};
102 104
105static int cyberjack_attach(struct usb_serial *serial)
106{
107 if (serial->num_bulk_out < serial->num_ports)
108 return -ENODEV;
109
110 return 0;
111}
112
103static int cyberjack_port_probe(struct usb_serial_port *port) 113static int cyberjack_port_probe(struct usb_serial_port *port)
104{ 114{
105 struct cyberjack_private *priv; 115 struct cyberjack_private *priv;
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 8282a6a18fee..22f23a429a95 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1237,6 +1237,7 @@ static int f81534_attach(struct usb_serial *serial)
1237static int f81534_port_probe(struct usb_serial_port *port) 1237static int f81534_port_probe(struct usb_serial_port *port)
1238{ 1238{
1239 struct f81534_port_private *port_priv; 1239 struct f81534_port_private *port_priv;
1240 int ret;
1240 1241
1241 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); 1242 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL);
1242 if (!port_priv) 1243 if (!port_priv)
@@ -1246,10 +1247,11 @@ static int f81534_port_probe(struct usb_serial_port *port)
1246 mutex_init(&port_priv->mcr_mutex); 1247 mutex_init(&port_priv->mcr_mutex);
1247 1248
1248 /* Assign logic-to-phy mapping */ 1249 /* Assign logic-to-phy mapping */
1249 port_priv->phy_num = f81534_logic_to_phy_port(port->serial, port); 1250 ret = f81534_logic_to_phy_port(port->serial, port);
1250 if (port_priv->phy_num < 0 || port_priv->phy_num >= F81534_NUM_PORT) 1251 if (ret < 0)
1251 return -ENODEV; 1252 return ret;
1252 1253
1254 port_priv->phy_num = ret;
1253 usb_set_serial_port_data(port, port_priv); 1255 usb_set_serial_port_data(port, port_priv);
1254 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, 1256 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__,
1255 port->port_number, port_priv->phy_num); 1257 port->port_number, port_priv->phy_num);
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 97cabf803c2f..b2f2e87aed94 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1043,6 +1043,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1043 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 1043 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
1044 __func__, status); 1044 __func__, status);
1045 count = status; 1045 count = status;
1046 kfree(buffer);
1046 } 1047 }
1047 1048
1048 /* we are done with this urb, so let the host driver 1049 /* we are done with this urb, so let the host driver
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index dcc0c58aaad5..d50e5773483f 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2751,6 +2751,11 @@ static int edge_startup(struct usb_serial *serial)
2751 EDGE_COMPATIBILITY_MASK1, 2751 EDGE_COMPATIBILITY_MASK1,
2752 EDGE_COMPATIBILITY_MASK2 }; 2752 EDGE_COMPATIBILITY_MASK2 };
2753 2753
2754 if (serial->num_bulk_in < 1 || serial->num_interrupt_in < 1) {
2755 dev_err(&serial->interface->dev, "missing endpoints\n");
2756 return -ENODEV;
2757 }
2758
2754 dev = serial->dev; 2759 dev = serial->dev;
2755 2760
2756 /* create our private serial structure */ 2761 /* create our private serial structure */
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index c339163698eb..9a0db2965fbb 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_serial *serial,
1499 1499
1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); 1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
1501 1501
1502 /* return an error on purpose */ 1502 return 1;
1503 return -ENODEV;
1504 } 1503 }
1505 1504
1506stayinbootmode: 1505stayinbootmode:
@@ -1508,7 +1507,7 @@ stayinbootmode:
1508 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); 1507 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
1509 serial->product_info.TiMode = TI_MODE_BOOT; 1508 serial->product_info.TiMode = TI_MODE_BOOT;
1510 1509
1511 return 0; 1510 return 1;
1512} 1511}
1513 1512
1514static int ti_do_config(struct edgeport_port *port, int feature, int on) 1513static int ti_do_config(struct edgeport_port *port, int feature, int on)
@@ -2546,6 +2545,13 @@ static int edge_startup(struct usb_serial *serial)
2546 int status; 2545 int status;
2547 u16 product_id; 2546 u16 product_id;
2548 2547
2548 /* Make sure we have the required endpoints when in download mode. */
2549 if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) {
2550 if (serial->num_bulk_in < serial->num_ports ||
2551 serial->num_bulk_out < serial->num_ports)
2552 return -ENODEV;
2553 }
2554
2549 /* create our private serial structure */ 2555 /* create our private serial structure */
2550 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2556 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2551 if (!edge_serial) 2557 if (!edge_serial)
@@ -2553,14 +2559,18 @@ static int edge_startup(struct usb_serial *serial)
2553 2559
2554 mutex_init(&edge_serial->es_lock); 2560 mutex_init(&edge_serial->es_lock);
2555 edge_serial->serial = serial; 2561 edge_serial->serial = serial;
2562 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2556 usb_set_serial_data(serial, edge_serial); 2563 usb_set_serial_data(serial, edge_serial);
2557 2564
2558 status = download_fw(edge_serial); 2565 status = download_fw(edge_serial);
2559 if (status) { 2566 if (status < 0) {
2560 kfree(edge_serial); 2567 kfree(edge_serial);
2561 return status; 2568 return status;
2562 } 2569 }
2563 2570
2571 if (status > 0)
2572 return 1; /* bind but do not register any ports */
2573
2564 product_id = le16_to_cpu( 2574 product_id = le16_to_cpu(
2565 edge_serial->serial->dev->descriptor.idProduct); 2575 edge_serial->serial->dev->descriptor.idProduct);
2566 2576
@@ -2572,7 +2582,6 @@ static int edge_startup(struct usb_serial *serial)
2572 } 2582 }
2573 } 2583 }
2574 2584
2575 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2576 edge_heartbeat_schedule(edge_serial); 2585 edge_heartbeat_schedule(edge_serial);
2577 2586
2578 return 0; 2587 return 0;
@@ -2580,6 +2589,9 @@ static int edge_startup(struct usb_serial *serial)
2580 2589
2581static void edge_disconnect(struct usb_serial *serial) 2590static void edge_disconnect(struct usb_serial *serial)
2582{ 2591{
2592 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2593
2594 cancel_delayed_work_sync(&edge_serial->heartbeat_work);
2583} 2595}
2584 2596
2585static void edge_release(struct usb_serial *serial) 2597static void edge_release(struct usb_serial *serial)
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 344b4eea4bd5..d57fb5199218 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -68,6 +68,16 @@ struct iuu_private {
68 u32 clk; 68 u32 clk;
69}; 69};
70 70
71static int iuu_attach(struct usb_serial *serial)
72{
73 unsigned char num_ports = serial->num_ports;
74
75 if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
76 return -ENODEV;
77
78 return 0;
79}
80
71static int iuu_port_probe(struct usb_serial_port *port) 81static int iuu_port_probe(struct usb_serial_port *port)
72{ 82{
73 struct iuu_private *priv; 83 struct iuu_private *priv;
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_device = {
1196 .tiocmset = iuu_tiocmset, 1206 .tiocmset = iuu_tiocmset,
1197 .set_termios = iuu_set_termios, 1207 .set_termios = iuu_set_termios,
1198 .init_termios = iuu_init_termios, 1208 .init_termios = iuu_init_termios,
1209 .attach = iuu_attach,
1199 .port_probe = iuu_port_probe, 1210 .port_probe = iuu_port_probe,
1200 .port_remove = iuu_port_remove, 1211 .port_remove = iuu_port_remove,
1201}; 1212};
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index e49ad0c63ad8..83523fcf6fb9 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
700#endif 700#endif
701 701
702static int keyspan_pda_attach(struct usb_serial *serial)
703{
704 unsigned char num_ports = serial->num_ports;
705
706 if (serial->num_bulk_out < num_ports ||
707 serial->num_interrupt_in < num_ports) {
708 dev_err(&serial->interface->dev, "missing endpoints\n");
709 return -ENODEV;
710 }
711
712 return 0;
713}
714
702static int keyspan_pda_port_probe(struct usb_serial_port *port) 715static int keyspan_pda_port_probe(struct usb_serial_port *port)
703{ 716{
704 717
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_pda_device = {
776 .break_ctl = keyspan_pda_break_ctl, 789 .break_ctl = keyspan_pda_break_ctl,
777 .tiocmget = keyspan_pda_tiocmget, 790 .tiocmget = keyspan_pda_tiocmget,
778 .tiocmset = keyspan_pda_tiocmset, 791 .tiocmset = keyspan_pda_tiocmset,
792 .attach = keyspan_pda_attach,
779 .port_probe = keyspan_pda_port_probe, 793 .port_probe = keyspan_pda_port_probe,
780 .port_remove = keyspan_pda_port_remove, 794 .port_remove = keyspan_pda_port_remove,
781}; 795};
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 2363654cafc9..813035f51fe7 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -51,6 +51,7 @@
51 51
52 52
53/* Function prototypes */ 53/* Function prototypes */
54static int kobil_attach(struct usb_serial *serial);
54static int kobil_port_probe(struct usb_serial_port *probe); 55static int kobil_port_probe(struct usb_serial_port *probe);
55static int kobil_port_remove(struct usb_serial_port *probe); 56static int kobil_port_remove(struct usb_serial_port *probe);
56static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); 57static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_device = {
86 .description = "KOBIL USB smart card terminal", 87 .description = "KOBIL USB smart card terminal",
87 .id_table = id_table, 88 .id_table = id_table,
88 .num_ports = 1, 89 .num_ports = 1,
90 .attach = kobil_attach,
89 .port_probe = kobil_port_probe, 91 .port_probe = kobil_port_probe,
90 .port_remove = kobil_port_remove, 92 .port_remove = kobil_port_remove,
91 .ioctl = kobil_ioctl, 93 .ioctl = kobil_ioctl,
@@ -113,6 +115,16 @@ struct kobil_private {
113}; 115};
114 116
115 117
118static int kobil_attach(struct usb_serial *serial)
119{
120 if (serial->num_interrupt_out < serial->num_ports) {
121 dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n");
122 return -ENODEV;
123 }
124
125 return 0;
126}
127
116static int kobil_port_probe(struct usb_serial_port *port) 128static int kobil_port_probe(struct usb_serial_port *port)
117{ 129{
118 struct usb_serial *serial = port->serial; 130 struct usb_serial *serial = port->serial;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index d52caa03679c..91bc170b408a 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -65,8 +65,6 @@ struct moschip_port {
65 struct urb *write_urb_pool[NUM_URBS]; 65 struct urb *write_urb_pool[NUM_URBS];
66}; 66};
67 67
68static struct usb_serial_driver moschip7720_2port_driver;
69
70#define USB_VENDOR_ID_MOSCHIP 0x9710 68#define USB_VENDOR_ID_MOSCHIP 0x9710
71#define MOSCHIP_DEVICE_ID_7720 0x7720 69#define MOSCHIP_DEVICE_ID_7720 0x7720
72#define MOSCHIP_DEVICE_ID_7715 0x7715 70#define MOSCHIP_DEVICE_ID_7715 0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
970 tty_port_tty_wakeup(&mos7720_port->port->port); 968 tty_port_tty_wakeup(&mos7720_port->port->port);
971} 969}
972 970
973/*
974 * mos77xx_probe
975 * this function installs the appropriate read interrupt endpoint callback
976 * depending on whether the device is a 7720 or 7715, thus avoiding costly
977 * run-time checks in the high-frequency callback routine itself.
978 */
979static int mos77xx_probe(struct usb_serial *serial,
980 const struct usb_device_id *id)
981{
982 if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
983 moschip7720_2port_driver.read_int_callback =
984 mos7715_interrupt_callback;
985 else
986 moschip7720_2port_driver.read_int_callback =
987 mos7720_interrupt_callback;
988
989 return 0;
990}
991
992static int mos77xx_calc_num_ports(struct usb_serial *serial) 971static int mos77xx_calc_num_ports(struct usb_serial *serial)
993{ 972{
994 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 973 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
@@ -1917,6 +1896,11 @@ static int mos7720_startup(struct usb_serial *serial)
1917 u16 product; 1896 u16 product;
1918 int ret_val; 1897 int ret_val;
1919 1898
1899 if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) {
1900 dev_err(&serial->interface->dev, "missing bulk endpoints\n");
1901 return -ENODEV;
1902 }
1903
1920 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1904 product = le16_to_cpu(serial->dev->descriptor.idProduct);
1921 dev = serial->dev; 1905 dev = serial->dev;
1922 1906
@@ -1941,19 +1925,18 @@ static int mos7720_startup(struct usb_serial *serial)
1941 tmp->interrupt_in_endpointAddress; 1925 tmp->interrupt_in_endpointAddress;
1942 serial->port[1]->interrupt_in_urb = NULL; 1926 serial->port[1]->interrupt_in_urb = NULL;
1943 serial->port[1]->interrupt_in_buffer = NULL; 1927 serial->port[1]->interrupt_in_buffer = NULL;
1928
1929 if (serial->port[0]->interrupt_in_urb) {
1930 struct urb *urb = serial->port[0]->interrupt_in_urb;
1931
1932 urb->complete = mos7715_interrupt_callback;
1933 }
1944 } 1934 }
1945 1935
1946 /* setting configuration feature to one */ 1936 /* setting configuration feature to one */
1947 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1937 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1948 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); 1938 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
1949 1939
1950 /* start the interrupt urb */
1951 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1952 if (ret_val)
1953 dev_err(&dev->dev,
1954 "%s - Error %d submitting control urb\n",
1955 __func__, ret_val);
1956
1957#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1940#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1958 if (product == MOSCHIP_DEVICE_ID_7715) { 1941 if (product == MOSCHIP_DEVICE_ID_7715) {
1959 ret_val = mos7715_parport_init(serial); 1942 ret_val = mos7715_parport_init(serial);
@@ -1961,6 +1944,13 @@ static int mos7720_startup(struct usb_serial *serial)
1961 return ret_val; 1944 return ret_val;
1962 } 1945 }
1963#endif 1946#endif
1947 /* start the interrupt urb */
1948 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1949 if (ret_val) {
1950 dev_err(&dev->dev, "failed to submit interrupt urb: %d\n",
1951 ret_val);
1952 }
1953
1964 /* LSR For Port 1 */ 1954 /* LSR For Port 1 */
1965 read_mos_reg(serial, 0, MOS7720_LSR, &data); 1955 read_mos_reg(serial, 0, MOS7720_LSR, &data);
1966 dev_dbg(&dev->dev, "LSR:%x\n", data); 1956 dev_dbg(&dev->dev, "LSR:%x\n", data);
@@ -1970,6 +1960,8 @@ static int mos7720_startup(struct usb_serial *serial)
1970 1960
1971static void mos7720_release(struct usb_serial *serial) 1961static void mos7720_release(struct usb_serial *serial)
1972{ 1962{
1963 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1964
1973#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1965#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1974 /* close the parallel port */ 1966 /* close the parallel port */
1975 1967
@@ -2019,11 +2011,6 @@ static int mos7720_port_probe(struct usb_serial_port *port)
2019 if (!mos7720_port) 2011 if (!mos7720_port)
2020 return -ENOMEM; 2012 return -ENOMEM;
2021 2013
2022 /* Initialize all port interrupt end point to port 0 int endpoint.
2023 * Our device has only one interrupt endpoint common to all ports.
2024 */
2025 port->interrupt_in_endpointAddress =
2026 port->serial->port[0]->interrupt_in_endpointAddress;
2027 mos7720_port->port = port; 2014 mos7720_port->port = port;
2028 2015
2029 usb_set_serial_port_data(port, mos7720_port); 2016 usb_set_serial_port_data(port, mos7720_port);
@@ -2053,7 +2040,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2053 .close = mos7720_close, 2040 .close = mos7720_close,
2054 .throttle = mos7720_throttle, 2041 .throttle = mos7720_throttle,
2055 .unthrottle = mos7720_unthrottle, 2042 .unthrottle = mos7720_unthrottle,
2056 .probe = mos77xx_probe,
2057 .attach = mos7720_startup, 2043 .attach = mos7720_startup,
2058 .release = mos7720_release, 2044 .release = mos7720_release,
2059 .port_probe = mos7720_port_probe, 2045 .port_probe = mos7720_port_probe,
@@ -2067,7 +2053,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2067 .chars_in_buffer = mos7720_chars_in_buffer, 2053 .chars_in_buffer = mos7720_chars_in_buffer,
2068 .break_ctl = mos7720_break, 2054 .break_ctl = mos7720_break,
2069 .read_bulk_callback = mos7720_bulk_in_callback, 2055 .read_bulk_callback = mos7720_bulk_in_callback,
2070 .read_int_callback = NULL /* dynamically assigned in probe() */ 2056 .read_int_callback = mos7720_interrupt_callback,
2071}; 2057};
2072 2058
2073static struct usb_serial_driver * const serial_drivers[] = { 2059static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 9a220b8e810f..ea27fb23967a 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -214,7 +214,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
214 214
215struct moschip_port { 215struct moschip_port {
216 int port_num; /*Actual port number in the device(1,2,etc) */ 216 int port_num; /*Actual port number in the device(1,2,etc) */
217 struct urb *write_urb; /* write URB for this port */
218 struct urb *read_urb; /* read URB for this port */ 217 struct urb *read_urb; /* read URB for this port */
219 __u8 shadowLCR; /* last LCR value received */ 218 __u8 shadowLCR; /* last LCR value received */
220 __u8 shadowMCR; /* last MCR value received */ 219 __u8 shadowMCR; /* last MCR value received */
@@ -1037,9 +1036,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1037 serial, 1036 serial,
1038 serial->port[0]->interrupt_in_urb->interval); 1037 serial->port[0]->interrupt_in_urb->interval);
1039 1038
1040 /* start interrupt read for mos7840 * 1039 /* start interrupt read for mos7840 */
1041 * will continue as long as mos7840 is connected */
1042
1043 response = 1040 response =
1044 usb_submit_urb(serial->port[0]->interrupt_in_urb, 1041 usb_submit_urb(serial->port[0]->interrupt_in_urb,
1045 GFP_KERNEL); 1042 GFP_KERNEL);
@@ -1186,7 +1183,6 @@ static void mos7840_close(struct usb_serial_port *port)
1186 } 1183 }
1187 } 1184 }
1188 1185
1189 usb_kill_urb(mos7840_port->write_urb);
1190 usb_kill_urb(mos7840_port->read_urb); 1186 usb_kill_urb(mos7840_port->read_urb);
1191 mos7840_port->read_urb_busy = false; 1187 mos7840_port->read_urb_busy = false;
1192 1188
@@ -1199,12 +1195,6 @@ static void mos7840_close(struct usb_serial_port *port)
1199 } 1195 }
1200 } 1196 }
1201 1197
1202 if (mos7840_port->write_urb) {
1203 /* if this urb had a transfer buffer already (old tx) free it */
1204 kfree(mos7840_port->write_urb->transfer_buffer);
1205 usb_free_urb(mos7840_port->write_urb);
1206 }
1207
1208 Data = 0x0; 1198 Data = 0x0;
1209 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); 1199 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
1210 1200
@@ -2113,6 +2103,17 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
2113 return mos7840_num_ports; 2103 return mos7840_num_ports;
2114} 2104}
2115 2105
2106static int mos7840_attach(struct usb_serial *serial)
2107{
2108 if (serial->num_bulk_in < serial->num_ports ||
2109 serial->num_bulk_out < serial->num_ports) {
2110 dev_err(&serial->interface->dev, "missing endpoints\n");
2111 return -ENODEV;
2112 }
2113
2114 return 0;
2115}
2116
2116static int mos7840_port_probe(struct usb_serial_port *port) 2117static int mos7840_port_probe(struct usb_serial_port *port)
2117{ 2118{
2118 struct usb_serial *serial = port->serial; 2119 struct usb_serial *serial = port->serial;
@@ -2388,6 +2389,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
2388 .tiocmset = mos7840_tiocmset, 2389 .tiocmset = mos7840_tiocmset,
2389 .tiocmiwait = usb_serial_generic_tiocmiwait, 2390 .tiocmiwait = usb_serial_generic_tiocmiwait,
2390 .get_icount = usb_serial_generic_get_icount, 2391 .get_icount = usb_serial_generic_get_icount,
2392 .attach = mos7840_attach,
2391 .port_probe = mos7840_port_probe, 2393 .port_probe = mos7840_port_probe,
2392 .port_remove = mos7840_port_remove, 2394 .port_remove = mos7840_port_remove,
2393 .read_bulk_callback = mos7840_bulk_in_callback, 2395 .read_bulk_callback = mos7840_bulk_in_callback,
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index f6c6900bccf0..a180b17d2432 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -38,6 +38,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
38 const unsigned char *buf, int count); 38 const unsigned char *buf, int count);
39static int omninet_write_room(struct tty_struct *tty); 39static int omninet_write_room(struct tty_struct *tty);
40static void omninet_disconnect(struct usb_serial *serial); 40static void omninet_disconnect(struct usb_serial *serial);
41static int omninet_attach(struct usb_serial *serial);
41static int omninet_port_probe(struct usb_serial_port *port); 42static int omninet_port_probe(struct usb_serial_port *port);
42static int omninet_port_remove(struct usb_serial_port *port); 43static int omninet_port_remove(struct usb_serial_port *port);
43 44
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_omninet_device = {
56 .description = "ZyXEL - omni.net lcd plus usb", 57 .description = "ZyXEL - omni.net lcd plus usb",
57 .id_table = id_table, 58 .id_table = id_table,
58 .num_ports = 1, 59 .num_ports = 1,
60 .attach = omninet_attach,
59 .port_probe = omninet_port_probe, 61 .port_probe = omninet_port_probe,
60 .port_remove = omninet_port_remove, 62 .port_remove = omninet_port_remove,
61 .open = omninet_open, 63 .open = omninet_open,
@@ -104,6 +106,17 @@ struct omninet_data {
104 __u8 od_outseq; /* Sequence number for bulk_out URBs */ 106 __u8 od_outseq; /* Sequence number for bulk_out URBs */
105}; 107};
106 108
109static int omninet_attach(struct usb_serial *serial)
110{
111 /* The second bulk-out endpoint is used for writing. */
112 if (serial->num_bulk_out < 2) {
113 dev_err(&serial->interface->dev, "missing endpoints\n");
114 return -ENODEV;
115 }
116
117 return 0;
118}
119
107static int omninet_port_probe(struct usb_serial_port *port) 120static int omninet_port_probe(struct usb_serial_port *port)
108{ 121{
109 struct omninet_data *od; 122 struct omninet_data *od;
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index a4b88bc038b6..b8bf52bf7a94 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
134static int oti6858_tiocmget(struct tty_struct *tty); 134static int oti6858_tiocmget(struct tty_struct *tty);
135static int oti6858_tiocmset(struct tty_struct *tty, 135static int oti6858_tiocmset(struct tty_struct *tty,
136 unsigned int set, unsigned int clear); 136 unsigned int set, unsigned int clear);
137static int oti6858_attach(struct usb_serial *serial);
137static int oti6858_port_probe(struct usb_serial_port *port); 138static int oti6858_port_probe(struct usb_serial_port *port);
138static int oti6858_port_remove(struct usb_serial_port *port); 139static int oti6858_port_remove(struct usb_serial_port *port);
139 140
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_device = {
158 .write_bulk_callback = oti6858_write_bulk_callback, 159 .write_bulk_callback = oti6858_write_bulk_callback,
159 .write_room = oti6858_write_room, 160 .write_room = oti6858_write_room,
160 .chars_in_buffer = oti6858_chars_in_buffer, 161 .chars_in_buffer = oti6858_chars_in_buffer,
162 .attach = oti6858_attach,
161 .port_probe = oti6858_port_probe, 163 .port_probe = oti6858_port_probe,
162 .port_remove = oti6858_port_remove, 164 .port_remove = oti6858_port_remove,
163}; 165};
@@ -324,6 +326,20 @@ static void send_data(struct work_struct *work)
324 usb_serial_port_softint(port); 326 usb_serial_port_softint(port);
325} 327}
326 328
329static int oti6858_attach(struct usb_serial *serial)
330{
331 unsigned char num_ports = serial->num_ports;
332
333 if (serial->num_bulk_in < num_ports ||
334 serial->num_bulk_out < num_ports ||
335 serial->num_interrupt_in < num_ports) {
336 dev_err(&serial->interface->dev, "missing endpoints\n");
337 return -ENODEV;
338 }
339
340 return 0;
341}
342
327static int oti6858_port_probe(struct usb_serial_port *port) 343static int oti6858_port_probe(struct usb_serial_port *port)
328{ 344{
329 struct oti6858_private *priv; 345 struct oti6858_private *priv;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ae682e4eeaef..46fca6b75846 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_serial *serial,
220static int pl2303_startup(struct usb_serial *serial) 220static int pl2303_startup(struct usb_serial *serial)
221{ 221{
222 struct pl2303_serial_private *spriv; 222 struct pl2303_serial_private *spriv;
223 unsigned char num_ports = serial->num_ports;
223 enum pl2303_type type = TYPE_01; 224 enum pl2303_type type = TYPE_01;
224 unsigned char *buf; 225 unsigned char *buf;
225 226
227 if (serial->num_bulk_in < num_ports ||
228 serial->num_bulk_out < num_ports ||
229 serial->num_interrupt_in < num_ports) {
230 dev_err(&serial->interface->dev, "missing endpoints\n");
231 return -ENODEV;
232 }
233
226 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 234 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
227 if (!spriv) 235 if (!spriv)
228 return -ENOMEM; 236 return -ENOMEM;
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 659cb8606bd9..5709cc93b083 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_port *port)
408{ 408{
409 struct usb_serial *serial; 409 struct usb_serial *serial;
410 struct qt2_port_private *port_priv; 410 struct qt2_port_private *port_priv;
411 unsigned long flags;
412 int i; 411 int i;
413 412
414 serial = port->serial; 413 serial = port->serial;
415 port_priv = usb_get_serial_port_data(port); 414 port_priv = usb_get_serial_port_data(port);
416 415
417 spin_lock_irqsave(&port_priv->urb_lock, flags);
418 usb_kill_urb(port_priv->write_urb); 416 usb_kill_urb(port_priv->write_urb);
419 port_priv->urb_in_use = false;
420 spin_unlock_irqrestore(&port_priv->urb_lock, flags);
421 417
422 /* flush the port transmit buffer */ 418 /* flush the port transmit buffer */
423 i = usb_control_msg(serial->dev, 419 i = usb_control_msg(serial->dev,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index ef0dbf0703c5..475e6c31b266 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial,
154 return 0; 154 return 0;
155} 155}
156 156
157static int spcp8x5_attach(struct usb_serial *serial)
158{
159 unsigned char num_ports = serial->num_ports;
160
161 if (serial->num_bulk_in < num_ports ||
162 serial->num_bulk_out < num_ports) {
163 dev_err(&serial->interface->dev, "missing endpoints\n");
164 return -ENODEV;
165 }
166
167 return 0;
168}
169
157static int spcp8x5_port_probe(struct usb_serial_port *port) 170static int spcp8x5_port_probe(struct usb_serial_port *port)
158{ 171{
159 const struct usb_device_id *id = usb_get_serial_data(port->serial); 172 const struct usb_device_id *id = usb_get_serial_data(port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = {
477 .tiocmget = spcp8x5_tiocmget, 490 .tiocmget = spcp8x5_tiocmget,
478 .tiocmset = spcp8x5_tiocmset, 491 .tiocmset = spcp8x5_tiocmset,
479 .probe = spcp8x5_probe, 492 .probe = spcp8x5_probe,
493 .attach = spcp8x5_attach,
480 .port_probe = spcp8x5_port_probe, 494 .port_probe = spcp8x5_port_probe,
481 .port_remove = spcp8x5_port_remove, 495 .port_remove = spcp8x5_port_remove,
482}; 496};
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 8db9d071d940..64b85b8dedf3 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -579,6 +579,13 @@ static int ti_startup(struct usb_serial *serial)
579 goto free_tdev; 579 goto free_tdev;
580 } 580 }
581 581
582 if (serial->num_bulk_in < serial->num_ports ||
583 serial->num_bulk_out < serial->num_ports) {
584 dev_err(&serial->interface->dev, "missing endpoints\n");
585 status = -ENODEV;
586 goto free_tdev;
587 }
588
582 return 0; 589 return 0;
583 590
584free_tdev: 591free_tdev:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index af3c7eecff91..16cc18369111 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2109,6 +2109,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114,
2109 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2109 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2110 US_FL_BROKEN_FUA ), 2110 US_FL_BROKEN_FUA ),
2111 2111
2112/* Reported-by George Cherian <george.cherian@cavium.com> */
2113UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
2114 "JMicron",
2115 "JMS56x",
2116 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2117 US_FL_NO_REPORT_OPCODES),
2118
2112/* 2119/*
2113 * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) 2120 * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
2114 * and Mac USB Dock USB-SCSI */ 2121 * and Mac USB Dock USB-SCSI */
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index be1ee89ee917..36d75c367d22 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -27,6 +27,45 @@ static LIST_HEAD(parent_list);
27static DEFINE_MUTEX(parent_list_lock); 27static DEFINE_MUTEX(parent_list_lock);
28static struct class_compat *mdev_bus_compat_class; 28static struct class_compat *mdev_bus_compat_class;
29 29
30static LIST_HEAD(mdev_list);
31static DEFINE_MUTEX(mdev_list_lock);
32
33struct device *mdev_parent_dev(struct mdev_device *mdev)
34{
35 return mdev->parent->dev;
36}
37EXPORT_SYMBOL(mdev_parent_dev);
38
39void *mdev_get_drvdata(struct mdev_device *mdev)
40{
41 return mdev->driver_data;
42}
43EXPORT_SYMBOL(mdev_get_drvdata);
44
45void mdev_set_drvdata(struct mdev_device *mdev, void *data)
46{
47 mdev->driver_data = data;
48}
49EXPORT_SYMBOL(mdev_set_drvdata);
50
51struct device *mdev_dev(struct mdev_device *mdev)
52{
53 return &mdev->dev;
54}
55EXPORT_SYMBOL(mdev_dev);
56
57struct mdev_device *mdev_from_dev(struct device *dev)
58{
59 return dev_is_mdev(dev) ? to_mdev_device(dev) : NULL;
60}
61EXPORT_SYMBOL(mdev_from_dev);
62
63uuid_le mdev_uuid(struct mdev_device *mdev)
64{
65 return mdev->uuid;
66}
67EXPORT_SYMBOL(mdev_uuid);
68
30static int _find_mdev_device(struct device *dev, void *data) 69static int _find_mdev_device(struct device *dev, void *data)
31{ 70{
32 struct mdev_device *mdev; 71 struct mdev_device *mdev;
@@ -42,7 +81,7 @@ static int _find_mdev_device(struct device *dev, void *data)
42 return 0; 81 return 0;
43} 82}
44 83
45static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid) 84static bool mdev_device_exist(struct mdev_parent *parent, uuid_le uuid)
46{ 85{
47 struct device *dev; 86 struct device *dev;
48 87
@@ -56,9 +95,9 @@ static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid)
56} 95}
57 96
58/* Should be called holding parent_list_lock */ 97/* Should be called holding parent_list_lock */
59static struct parent_device *__find_parent_device(struct device *dev) 98static struct mdev_parent *__find_parent_device(struct device *dev)
60{ 99{
61 struct parent_device *parent; 100 struct mdev_parent *parent;
62 101
63 list_for_each_entry(parent, &parent_list, next) { 102 list_for_each_entry(parent, &parent_list, next) {
64 if (parent->dev == dev) 103 if (parent->dev == dev)
@@ -69,8 +108,8 @@ static struct parent_device *__find_parent_device(struct device *dev)
69 108
70static void mdev_release_parent(struct kref *kref) 109static void mdev_release_parent(struct kref *kref)
71{ 110{
72 struct parent_device *parent = container_of(kref, struct parent_device, 111 struct mdev_parent *parent = container_of(kref, struct mdev_parent,
73 ref); 112 ref);
74 struct device *dev = parent->dev; 113 struct device *dev = parent->dev;
75 114
76 kfree(parent); 115 kfree(parent);
@@ -78,7 +117,7 @@ static void mdev_release_parent(struct kref *kref)
78} 117}
79 118
80static 119static
81inline struct parent_device *mdev_get_parent(struct parent_device *parent) 120inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
82{ 121{
83 if (parent) 122 if (parent)
84 kref_get(&parent->ref); 123 kref_get(&parent->ref);
@@ -86,7 +125,7 @@ inline struct parent_device *mdev_get_parent(struct parent_device *parent)
86 return parent; 125 return parent;
87} 126}
88 127
89static inline void mdev_put_parent(struct parent_device *parent) 128static inline void mdev_put_parent(struct mdev_parent *parent)
90{ 129{
91 if (parent) 130 if (parent)
92 kref_put(&parent->ref, mdev_release_parent); 131 kref_put(&parent->ref, mdev_release_parent);
@@ -95,7 +134,7 @@ static inline void mdev_put_parent(struct parent_device *parent)
95static int mdev_device_create_ops(struct kobject *kobj, 134static int mdev_device_create_ops(struct kobject *kobj,
96 struct mdev_device *mdev) 135 struct mdev_device *mdev)
97{ 136{
98 struct parent_device *parent = mdev->parent; 137 struct mdev_parent *parent = mdev->parent;
99 int ret; 138 int ret;
100 139
101 ret = parent->ops->create(kobj, mdev); 140 ret = parent->ops->create(kobj, mdev);
@@ -122,7 +161,7 @@ static int mdev_device_create_ops(struct kobject *kobj,
122 */ 161 */
123static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove) 162static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)
124{ 163{
125 struct parent_device *parent = mdev->parent; 164 struct mdev_parent *parent = mdev->parent;
126 int ret; 165 int ret;
127 166
128 /* 167 /*
@@ -153,10 +192,10 @@ static int mdev_device_remove_cb(struct device *dev, void *data)
153 * Add device to list of registered parent devices. 192 * Add device to list of registered parent devices.
154 * Returns a negative value on error, otherwise 0. 193 * Returns a negative value on error, otherwise 0.
155 */ 194 */
156int mdev_register_device(struct device *dev, const struct parent_ops *ops) 195int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
157{ 196{
158 int ret; 197 int ret;
159 struct parent_device *parent; 198 struct mdev_parent *parent;
160 199
161 /* check for mandatory ops */ 200 /* check for mandatory ops */
162 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) 201 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
@@ -229,7 +268,7 @@ EXPORT_SYMBOL(mdev_register_device);
229 268
230void mdev_unregister_device(struct device *dev) 269void mdev_unregister_device(struct device *dev)
231{ 270{
232 struct parent_device *parent; 271 struct mdev_parent *parent;
233 bool force_remove = true; 272 bool force_remove = true;
234 273
235 mutex_lock(&parent_list_lock); 274 mutex_lock(&parent_list_lock);
@@ -266,7 +305,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
266{ 305{
267 int ret; 306 int ret;
268 struct mdev_device *mdev; 307 struct mdev_device *mdev;
269 struct parent_device *parent; 308 struct mdev_parent *parent;
270 struct mdev_type *type = to_mdev_type(kobj); 309 struct mdev_type *type = to_mdev_type(kobj);
271 310
272 parent = mdev_get_parent(type->parent); 311 parent = mdev_get_parent(type->parent);
@@ -316,6 +355,11 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
316 dev_dbg(&mdev->dev, "MDEV: created\n"); 355 dev_dbg(&mdev->dev, "MDEV: created\n");
317 356
318 mutex_unlock(&parent->lock); 357 mutex_unlock(&parent->lock);
358
359 mutex_lock(&mdev_list_lock);
360 list_add(&mdev->next, &mdev_list);
361 mutex_unlock(&mdev_list_lock);
362
319 return ret; 363 return ret;
320 364
321create_failed: 365create_failed:
@@ -329,12 +373,30 @@ create_err:
329 373
330int mdev_device_remove(struct device *dev, bool force_remove) 374int mdev_device_remove(struct device *dev, bool force_remove)
331{ 375{
332 struct mdev_device *mdev; 376 struct mdev_device *mdev, *tmp;
333 struct parent_device *parent; 377 struct mdev_parent *parent;
334 struct mdev_type *type; 378 struct mdev_type *type;
335 int ret; 379 int ret;
380 bool found = false;
336 381
337 mdev = to_mdev_device(dev); 382 mdev = to_mdev_device(dev);
383
384 mutex_lock(&mdev_list_lock);
385 list_for_each_entry(tmp, &mdev_list, next) {
386 if (tmp == mdev) {
387 found = true;
388 break;
389 }
390 }
391
392 if (found)
393 list_del(&mdev->next);
394
395 mutex_unlock(&mdev_list_lock);
396
397 if (!found)
398 return -ENODEV;
399
338 type = to_mdev_type(mdev->type_kobj); 400 type = to_mdev_type(mdev->type_kobj);
339 parent = mdev->parent; 401 parent = mdev->parent;
340 mutex_lock(&parent->lock); 402 mutex_lock(&parent->lock);
@@ -342,6 +404,11 @@ int mdev_device_remove(struct device *dev, bool force_remove)
342 ret = mdev_device_remove_ops(mdev, force_remove); 404 ret = mdev_device_remove_ops(mdev, force_remove);
343 if (ret) { 405 if (ret) {
344 mutex_unlock(&parent->lock); 406 mutex_unlock(&parent->lock);
407
408 mutex_lock(&mdev_list_lock);
409 list_add(&mdev->next, &mdev_list);
410 mutex_unlock(&mdev_list_lock);
411
345 return ret; 412 return ret;
346 } 413 }
347 414
@@ -349,7 +416,8 @@ int mdev_device_remove(struct device *dev, bool force_remove)
349 device_unregister(dev); 416 device_unregister(dev);
350 mutex_unlock(&parent->lock); 417 mutex_unlock(&parent->lock);
351 mdev_put_parent(parent); 418 mdev_put_parent(parent);
352 return ret; 419
420 return 0;
353} 421}
354 422
355static int __init mdev_init(void) 423static int __init mdev_init(void)
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index d35097cbf3d7..a9cefd70a705 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -16,10 +16,33 @@
16int mdev_bus_register(void); 16int mdev_bus_register(void);
17void mdev_bus_unregister(void); 17void mdev_bus_unregister(void);
18 18
19struct mdev_parent {
20 struct device *dev;
21 const struct mdev_parent_ops *ops;
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
29struct mdev_device {
30 struct device dev;
31 struct mdev_parent *parent;
32 uuid_le uuid;
33 void *driver_data;
34 struct kref ref;
35 struct list_head next;
36 struct kobject *type_kobj;
37};
38
39#define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
40#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
41
19struct mdev_type { 42struct mdev_type {
20 struct kobject kobj; 43 struct kobject kobj;
21 struct kobject *devices_kobj; 44 struct kobject *devices_kobj;
22 struct parent_device *parent; 45 struct mdev_parent *parent;
23 struct list_head next; 46 struct list_head next;
24 struct attribute_group *group; 47 struct attribute_group *group;
25}; 48};
@@ -29,8 +52,8 @@ struct mdev_type {
29#define to_mdev_type(_kobj) \ 52#define to_mdev_type(_kobj) \
30 container_of(_kobj, struct mdev_type, kobj) 53 container_of(_kobj, struct mdev_type, kobj)
31 54
32int parent_create_sysfs_files(struct parent_device *parent); 55int parent_create_sysfs_files(struct mdev_parent *parent);
33void parent_remove_sysfs_files(struct parent_device *parent); 56void parent_remove_sysfs_files(struct mdev_parent *parent);
34 57
35int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type); 58int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
36void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type); 59void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 1a53deb2ee10..802df210929b 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -92,7 +92,7 @@ static struct kobj_type mdev_type_ktype = {
92 .release = mdev_type_release, 92 .release = mdev_type_release,
93}; 93};
94 94
95struct mdev_type *add_mdev_supported_type(struct parent_device *parent, 95struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
96 struct attribute_group *group) 96 struct attribute_group *group)
97{ 97{
98 struct mdev_type *type; 98 struct mdev_type *type;
@@ -158,7 +158,7 @@ static void remove_mdev_supported_type(struct mdev_type *type)
158 kobject_put(&type->kobj); 158 kobject_put(&type->kobj);
159} 159}
160 160
161static int add_mdev_supported_type_groups(struct parent_device *parent) 161static int add_mdev_supported_type_groups(struct mdev_parent *parent)
162{ 162{
163 int i; 163 int i;
164 164
@@ -183,7 +183,7 @@ static int add_mdev_supported_type_groups(struct parent_device *parent)
183} 183}
184 184
185/* mdev sysfs functions */ 185/* mdev sysfs functions */
186void parent_remove_sysfs_files(struct parent_device *parent) 186void parent_remove_sysfs_files(struct mdev_parent *parent)
187{ 187{
188 struct mdev_type *type, *tmp; 188 struct mdev_type *type, *tmp;
189 189
@@ -196,7 +196,7 @@ void parent_remove_sysfs_files(struct parent_device *parent)
196 kset_unregister(parent->mdev_types_kset); 196 kset_unregister(parent->mdev_types_kset);
197} 197}
198 198
199int parent_create_sysfs_files(struct parent_device *parent) 199int parent_create_sysfs_files(struct mdev_parent *parent)
200{ 200{
201 int ret; 201 int ret;
202 202
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
index ffc36758cb84..fa848a701b8b 100644
--- a/drivers/vfio/mdev/vfio_mdev.c
+++ b/drivers/vfio/mdev/vfio_mdev.c
@@ -27,7 +27,7 @@
27static int vfio_mdev_open(void *device_data) 27static int vfio_mdev_open(void *device_data)
28{ 28{
29 struct mdev_device *mdev = device_data; 29 struct mdev_device *mdev = device_data;
30 struct parent_device *parent = mdev->parent; 30 struct mdev_parent *parent = mdev->parent;
31 int ret; 31 int ret;
32 32
33 if (unlikely(!parent->ops->open)) 33 if (unlikely(!parent->ops->open))
@@ -46,7 +46,7 @@ static int vfio_mdev_open(void *device_data)
46static void vfio_mdev_release(void *device_data) 46static void vfio_mdev_release(void *device_data)
47{ 47{
48 struct mdev_device *mdev = device_data; 48 struct mdev_device *mdev = device_data;
49 struct parent_device *parent = mdev->parent; 49 struct mdev_parent *parent = mdev->parent;
50 50
51 if (likely(parent->ops->release)) 51 if (likely(parent->ops->release))
52 parent->ops->release(mdev); 52 parent->ops->release(mdev);
@@ -58,7 +58,7 @@ static long vfio_mdev_unlocked_ioctl(void *device_data,
58 unsigned int cmd, unsigned long arg) 58 unsigned int cmd, unsigned long arg)
59{ 59{
60 struct mdev_device *mdev = device_data; 60 struct mdev_device *mdev = device_data;
61 struct parent_device *parent = mdev->parent; 61 struct mdev_parent *parent = mdev->parent;
62 62
63 if (unlikely(!parent->ops->ioctl)) 63 if (unlikely(!parent->ops->ioctl))
64 return -EINVAL; 64 return -EINVAL;
@@ -70,7 +70,7 @@ static ssize_t vfio_mdev_read(void *device_data, char __user *buf,
70 size_t count, loff_t *ppos) 70 size_t count, loff_t *ppos)
71{ 71{
72 struct mdev_device *mdev = device_data; 72 struct mdev_device *mdev = device_data;
73 struct parent_device *parent = mdev->parent; 73 struct mdev_parent *parent = mdev->parent;
74 74
75 if (unlikely(!parent->ops->read)) 75 if (unlikely(!parent->ops->read))
76 return -EINVAL; 76 return -EINVAL;
@@ -82,7 +82,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
82 size_t count, loff_t *ppos) 82 size_t count, loff_t *ppos)
83{ 83{
84 struct mdev_device *mdev = device_data; 84 struct mdev_device *mdev = device_data;
85 struct parent_device *parent = mdev->parent; 85 struct mdev_parent *parent = mdev->parent;
86 86
87 if (unlikely(!parent->ops->write)) 87 if (unlikely(!parent->ops->write))
88 return -EINVAL; 88 return -EINVAL;
@@ -93,7 +93,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma) 93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma)
94{ 94{
95 struct mdev_device *mdev = device_data; 95 struct mdev_device *mdev = device_data;
96 struct parent_device *parent = mdev->parent; 96 struct mdev_parent *parent = mdev->parent;
97 97
98 if (unlikely(!parent->ops->mmap)) 98 if (unlikely(!parent->ops->mmap))
99 return -EINVAL; 99 return -EINVAL;
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index dcd7c2a99618..324c52e3a1a4 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1142,6 +1142,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
1142 return ret; 1142 return ret;
1143 1143
1144 vdev->barmap[index] = pci_iomap(pdev, index, 0); 1144 vdev->barmap[index] = pci_iomap(pdev, index, 0);
1145 if (!vdev->barmap[index]) {
1146 pci_release_selected_regions(pdev, 1 << index);
1147 return -ENOMEM;
1148 }
1145 } 1149 }
1146 1150
1147 vma->vm_private_data = vdev; 1151 vma->vm_private_data = vdev;
diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
index 5ffd1d9ad4bd..357243d76f10 100644
--- a/drivers/vfio/pci/vfio_pci_rdwr.c
+++ b/drivers/vfio/pci/vfio_pci_rdwr.c
@@ -193,7 +193,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
193 if (!vdev->has_vga) 193 if (!vdev->has_vga)
194 return -EINVAL; 194 return -EINVAL;
195 195
196 switch (pos) { 196 if (pos > 0xbfffful)
197 return -EINVAL;
198
199 switch ((u32)pos) {
197 case 0xa0000 ... 0xbffff: 200 case 0xa0000 ... 0xbffff:
198 count = min(count, (size_t)(0xc0000 - pos)); 201 count = min(count, (size_t)(0xc0000 - pos));
199 iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1); 202 iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index f3726ba12aa6..9266271a787a 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -268,28 +268,38 @@ static void vfio_lock_acct(struct task_struct *task, long npage)
268{ 268{
269 struct vwork *vwork; 269 struct vwork *vwork;
270 struct mm_struct *mm; 270 struct mm_struct *mm;
271 bool is_current;
271 272
272 if (!npage) 273 if (!npage)
273 return; 274 return;
274 275
275 mm = get_task_mm(task); 276 is_current = (task->mm == current->mm);
277
278 mm = is_current ? task->mm : get_task_mm(task);
276 if (!mm) 279 if (!mm)
277 return; /* process exited or nothing to do */ 280 return; /* process exited */
278 281
279 if (down_write_trylock(&mm->mmap_sem)) { 282 if (down_write_trylock(&mm->mmap_sem)) {
280 mm->locked_vm += npage; 283 mm->locked_vm += npage;
281 up_write(&mm->mmap_sem); 284 up_write(&mm->mmap_sem);
282 mmput(mm); 285 if (!is_current)
286 mmput(mm);
283 return; 287 return;
284 } 288 }
285 289
290 if (is_current) {
291 mm = get_task_mm(task);
292 if (!mm)
293 return;
294 }
295
286 /* 296 /*
287 * Couldn't get mmap_sem lock, so must setup to update 297 * Couldn't get mmap_sem lock, so must setup to update
288 * mm->locked_vm later. If locked_vm were atomic, we 298 * mm->locked_vm later. If locked_vm were atomic, we
289 * wouldn't need this silliness 299 * wouldn't need this silliness
290 */ 300 */
291 vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL); 301 vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL);
292 if (!vwork) { 302 if (WARN_ON(!vwork)) {
293 mmput(mm); 303 mmput(mm);
294 return; 304 return;
295 } 305 }
@@ -393,77 +403,71 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
393static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr, 403static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
394 long npage, unsigned long *pfn_base) 404 long npage, unsigned long *pfn_base)
395{ 405{
396 unsigned long limit; 406 unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
397 bool lock_cap = ns_capable(task_active_pid_ns(dma->task)->user_ns, 407 bool lock_cap = capable(CAP_IPC_LOCK);
398 CAP_IPC_LOCK); 408 long ret, pinned = 0, lock_acct = 0;
399 struct mm_struct *mm;
400 long ret, i = 0, lock_acct = 0;
401 bool rsvd; 409 bool rsvd;
402 dma_addr_t iova = vaddr - dma->vaddr + dma->iova; 410 dma_addr_t iova = vaddr - dma->vaddr + dma->iova;
403 411
404 mm = get_task_mm(dma->task); 412 /* This code path is only user initiated */
405 if (!mm) 413 if (!current->mm)
406 return -ENODEV; 414 return -ENODEV;
407 415
408 ret = vaddr_get_pfn(mm, vaddr, dma->prot, pfn_base); 416 ret = vaddr_get_pfn(current->mm, vaddr, dma->prot, pfn_base);
409 if (ret) 417 if (ret)
410 goto pin_pg_remote_exit; 418 return ret;
411 419
420 pinned++;
412 rsvd = is_invalid_reserved_pfn(*pfn_base); 421 rsvd = is_invalid_reserved_pfn(*pfn_base);
413 limit = task_rlimit(dma->task, RLIMIT_MEMLOCK) >> PAGE_SHIFT;
414 422
415 /* 423 /*
416 * Reserved pages aren't counted against the user, externally pinned 424 * Reserved pages aren't counted against the user, externally pinned
417 * pages are already counted against the user. 425 * pages are already counted against the user.
418 */ 426 */
419 if (!rsvd && !vfio_find_vpfn(dma, iova)) { 427 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
420 if (!lock_cap && mm->locked_vm + 1 > limit) { 428 if (!lock_cap && current->mm->locked_vm + 1 > limit) {
421 put_pfn(*pfn_base, dma->prot); 429 put_pfn(*pfn_base, dma->prot);
422 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__, 430 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
423 limit << PAGE_SHIFT); 431 limit << PAGE_SHIFT);
424 ret = -ENOMEM; 432 return -ENOMEM;
425 goto pin_pg_remote_exit;
426 } 433 }
427 lock_acct++; 434 lock_acct++;
428 } 435 }
429 436
430 i++; 437 if (unlikely(disable_hugepages))
431 if (likely(!disable_hugepages)) { 438 goto out;
432 /* Lock all the consecutive pages from pfn_base */
433 for (vaddr += PAGE_SIZE, iova += PAGE_SIZE; i < npage;
434 i++, vaddr += PAGE_SIZE, iova += PAGE_SIZE) {
435 unsigned long pfn = 0;
436 439
437 ret = vaddr_get_pfn(mm, vaddr, dma->prot, &pfn); 440 /* Lock all the consecutive pages from pfn_base */
438 if (ret) 441 for (vaddr += PAGE_SIZE, iova += PAGE_SIZE; pinned < npage;
439 break; 442 pinned++, vaddr += PAGE_SIZE, iova += PAGE_SIZE) {
443 unsigned long pfn = 0;
440 444
441 if (pfn != *pfn_base + i || 445 ret = vaddr_get_pfn(current->mm, vaddr, dma->prot, &pfn);
442 rsvd != is_invalid_reserved_pfn(pfn)) { 446 if (ret)
447 break;
448
449 if (pfn != *pfn_base + pinned ||
450 rsvd != is_invalid_reserved_pfn(pfn)) {
451 put_pfn(pfn, dma->prot);
452 break;
453 }
454
455 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
456 if (!lock_cap &&
457 current->mm->locked_vm + lock_acct + 1 > limit) {
443 put_pfn(pfn, dma->prot); 458 put_pfn(pfn, dma->prot);
459 pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n",
460 __func__, limit << PAGE_SHIFT);
444 break; 461 break;
445 } 462 }
446 463 lock_acct++;
447 if (!rsvd && !vfio_find_vpfn(dma, iova)) {
448 if (!lock_cap &&
449 mm->locked_vm + lock_acct + 1 > limit) {
450 put_pfn(pfn, dma->prot);
451 pr_warn("%s: RLIMIT_MEMLOCK (%ld) "
452 "exceeded\n", __func__,
453 limit << PAGE_SHIFT);
454 break;
455 }
456 lock_acct++;
457 }
458 } 464 }
459 } 465 }
460 466
461 vfio_lock_acct(dma->task, lock_acct); 467out:
462 ret = i; 468 vfio_lock_acct(current, lock_acct);
463 469
464pin_pg_remote_exit: 470 return pinned;
465 mmput(mm);
466 return ret;
467} 471}
468 472
469static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova, 473static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
@@ -473,10 +477,10 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
473 long unlocked = 0, locked = 0; 477 long unlocked = 0, locked = 0;
474 long i; 478 long i;
475 479
476 for (i = 0; i < npage; i++) { 480 for (i = 0; i < npage; i++, iova += PAGE_SIZE) {
477 if (put_pfn(pfn++, dma->prot)) { 481 if (put_pfn(pfn++, dma->prot)) {
478 unlocked++; 482 unlocked++;
479 if (vfio_find_vpfn(dma, iova + (i << PAGE_SHIFT))) 483 if (vfio_find_vpfn(dma, iova))
480 locked++; 484 locked++;
481 } 485 }
482 } 486 }
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 2d3b691f3fc4..038ac6934fe9 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -308,6 +308,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
308 info->screen_size = resource_size(res); 308 info->screen_size = resource_size(res);
309 info->screen_base = devm_ioremap(&dev->dev, res->start, 309 info->screen_base = devm_ioremap(&dev->dev, res->start,
310 info->screen_size); 310 info->screen_size);
311 if (!info->screen_base) {
312 framebuffer_release(info);
313 return -ENOMEM;
314 }
315
311 info->fbops = &cobalt_lcd_fbops; 316 info->fbops = &cobalt_lcd_fbops;
312 info->fix = cobalt_lcdfb_fix; 317 info->fix = cobalt_lcdfb_fix;
313 info->fix.smem_start = res->start; 318 info->fix.smem_start = res->start;
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 778acf80aacb..85dd20e05726 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
58 xen_pfn_t *gpfns; 58 xen_pfn_t *gpfns;
59 xen_ulong_t *idxs; 59 xen_ulong_t *idxs;
60 int *errs; 60 int *errs;
61 struct xen_add_to_physmap_range xatp;
62 61
63 for (i = 0; i < count; i++) { 62 for (i = 0; i < count; i++) {
63 struct xen_add_to_physmap_range xatp = {
64 .domid = DOMID_SELF,
65 .space = XENMAPSPACE_dev_mmio
66 };
67
64 r = &resources[i]; 68 r = &resources[i];
65 nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE); 69 nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
66 if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) 70 if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
87 idxs[j] = XEN_PFN_DOWN(r->start) + j; 91 idxs[j] = XEN_PFN_DOWN(r->start) + j;
88 } 92 }
89 93
90 xatp.domid = DOMID_SELF;
91 xatp.size = nr; 94 xatp.size = nr;
92 xatp.space = XENMAPSPACE_dev_mmio;
93 95
94 set_xen_guest_handle(xatp.gpfns, gpfns); 96 set_xen_guest_handle(xatp.gpfns, gpfns);
95 set_xen_guest_handle(xatp.idxs, idxs); 97 set_xen_guest_handle(xatp.idxs, idxs);
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index c03f9c86c7e3..3c41470c7fc4 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -369,8 +369,7 @@ static void evtchn_fifo_resume(void)
369 } 369 }
370 370
371 ret = init_control_block(cpu, control_block); 371 ret = init_control_block(cpu, control_block);
372 if (ret < 0) 372 BUG_ON(ret < 0);
373 BUG();
374 } 373 }
375 374
376 /* 375 /*
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index e8c7f09d01be..6890897a6f30 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -125,7 +125,7 @@ static int add_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
125 while (*new) { 125 while (*new) {
126 struct user_evtchn *this; 126 struct user_evtchn *this;
127 127
128 this = container_of(*new, struct user_evtchn, node); 128 this = rb_entry(*new, struct user_evtchn, node);
129 129
130 parent = *new; 130 parent = *new;
131 if (this->port < evtchn->port) 131 if (this->port < evtchn->port)
@@ -157,7 +157,7 @@ static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
157 while (node) { 157 while (node) {
158 struct user_evtchn *evtchn; 158 struct user_evtchn *evtchn;
159 159
160 evtchn = container_of(node, struct user_evtchn, node); 160 evtchn = rb_entry(node, struct user_evtchn, node);
161 161
162 if (evtchn->port < port) 162 if (evtchn->port < port)
163 node = node->rb_left; 163 node = node->rb_left;
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 478fb91e3df2..f905d6eeb048 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -275,6 +275,10 @@ retry:
275 rc = 0; 275 rc = 0;
276 } else 276 } else
277 rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs); 277 rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
278
279 if (!rc)
280 swiotlb_set_max_segment(PAGE_SIZE);
281
278 return rc; 282 return rc;
279error: 283error:
280 if (repeat--) { 284 if (repeat--) {
@@ -392,7 +396,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
392 if (dma_capable(dev, dev_addr, size) && 396 if (dma_capable(dev, dev_addr, size) &&
393 !range_straddles_page_boundary(phys, size) && 397 !range_straddles_page_boundary(phys, size) &&
394 !xen_arch_need_swiotlb(dev, phys, dev_addr) && 398 !xen_arch_need_swiotlb(dev, phys, dev_addr) &&
395 !swiotlb_force) { 399 (swiotlb_force != SWIOTLB_FORCE)) {
396 /* we are not interested in the dma_addr returned by 400 /* we are not interested in the dma_addr returned by
397 * xen_dma_map_page, only in the potential cache flushes executed 401 * xen_dma_map_page, only in the potential cache flushes executed
398 * by the function. */ 402 * by the function. */
@@ -552,7 +556,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
552 phys_addr_t paddr = sg_phys(sg); 556 phys_addr_t paddr = sg_phys(sg);
553 dma_addr_t dev_addr = xen_phys_to_bus(paddr); 557 dma_addr_t dev_addr = xen_phys_to_bus(paddr);
554 558
555 if (swiotlb_force || 559 if (swiotlb_force == SWIOTLB_FORCE ||
556 xen_arch_need_swiotlb(hwdev, paddr, dev_addr) || 560 xen_arch_need_swiotlb(hwdev, paddr, dev_addr) ||
557 !dma_capable(hwdev, dev_addr, sg->length) || 561 !dma_capable(hwdev, dev_addr, sg->length) ||
558 range_straddles_page_boundary(paddr, sg->length)) { 562 range_straddles_page_boundary(paddr, sg->length)) {
diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h
index e74f9c1fbd80..867a2e425208 100644
--- a/drivers/xen/xenbus/xenbus_comms.h
+++ b/drivers/xen/xenbus/xenbus_comms.h
@@ -42,7 +42,6 @@ int xb_write(const void *data, unsigned len);
42int xb_read(void *data, unsigned len); 42int xb_read(void *data, unsigned len);
43int xb_data_to_read(void); 43int xb_data_to_read(void);
44int xb_wait_for_data_to_read(void); 44int xb_wait_for_data_to_read(void);
45int xs_input_avail(void);
46extern struct xenstore_domain_interface *xen_store_interface; 45extern struct xenstore_domain_interface *xen_store_interface;
47extern int xen_store_evtchn; 46extern int xen_store_evtchn;
48extern enum xenstore_init xen_store_domain_type; 47extern enum xenstore_init xen_store_domain_type;
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 6c0ead4be784..79130b310247 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -302,6 +302,29 @@ static void watch_fired(struct xenbus_watch *watch,
302 mutex_unlock(&adap->dev_data->reply_mutex); 302 mutex_unlock(&adap->dev_data->reply_mutex);
303} 303}
304 304
305static int xenbus_command_reply(struct xenbus_file_priv *u,
306 unsigned int msg_type, const char *reply)
307{
308 struct {
309 struct xsd_sockmsg hdr;
310 const char body[16];
311 } msg;
312 int rc;
313
314 msg.hdr = u->u.msg;
315 msg.hdr.type = msg_type;
316 msg.hdr.len = strlen(reply) + 1;
317 if (msg.hdr.len > sizeof(msg.body))
318 return -E2BIG;
319
320 mutex_lock(&u->reply_mutex);
321 rc = queue_reply(&u->read_buffers, &msg, sizeof(msg.hdr) + msg.hdr.len);
322 wake_up(&u->read_waitq);
323 mutex_unlock(&u->reply_mutex);
324
325 return rc;
326}
327
305static int xenbus_write_transaction(unsigned msg_type, 328static int xenbus_write_transaction(unsigned msg_type,
306 struct xenbus_file_priv *u) 329 struct xenbus_file_priv *u)
307{ 330{
@@ -316,12 +339,12 @@ static int xenbus_write_transaction(unsigned msg_type,
316 rc = -ENOMEM; 339 rc = -ENOMEM;
317 goto out; 340 goto out;
318 } 341 }
319 } else if (msg_type == XS_TRANSACTION_END) { 342 } else if (u->u.msg.tx_id != 0) {
320 list_for_each_entry(trans, &u->transactions, list) 343 list_for_each_entry(trans, &u->transactions, list)
321 if (trans->handle.id == u->u.msg.tx_id) 344 if (trans->handle.id == u->u.msg.tx_id)
322 break; 345 break;
323 if (&trans->list == &u->transactions) 346 if (&trans->list == &u->transactions)
324 return -ESRCH; 347 return xenbus_command_reply(u, XS_ERROR, "ENOENT");
325 } 348 }
326 349
327 reply = xenbus_dev_request_and_reply(&u->u.msg); 350 reply = xenbus_dev_request_and_reply(&u->u.msg);
@@ -372,12 +395,12 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
372 path = u->u.buffer + sizeof(u->u.msg); 395 path = u->u.buffer + sizeof(u->u.msg);
373 token = memchr(path, 0, u->u.msg.len); 396 token = memchr(path, 0, u->u.msg.len);
374 if (token == NULL) { 397 if (token == NULL) {
375 rc = -EILSEQ; 398 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL");
376 goto out; 399 goto out;
377 } 400 }
378 token++; 401 token++;
379 if (memchr(token, 0, u->u.msg.len - (token - path)) == NULL) { 402 if (memchr(token, 0, u->u.msg.len - (token - path)) == NULL) {
380 rc = -EILSEQ; 403 rc = xenbus_command_reply(u, XS_ERROR, "EINVAL");
381 goto out; 404 goto out;
382 } 405 }
383 406
@@ -411,23 +434,7 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
411 } 434 }
412 435
413 /* Success. Synthesize a reply to say all is OK. */ 436 /* Success. Synthesize a reply to say all is OK. */
414 { 437 rc = xenbus_command_reply(u, msg_type, "OK");
415 struct {
416 struct xsd_sockmsg hdr;
417 char body[3];
418 } __packed reply = {
419 {
420 .type = msg_type,
421 .len = sizeof(reply.body)
422 },
423 "OK"
424 };
425
426 mutex_lock(&u->reply_mutex);
427 rc = queue_reply(&u->read_buffers, &reply, sizeof(reply));
428 wake_up(&u->read_waitq);
429 mutex_unlock(&u->reply_mutex);
430 }
431 438
432out: 439out:
433 return rc; 440 return rc;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6254cee8f8f3..5db5d1340d69 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -328,6 +328,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
328 struct file *file = iocb->ki_filp; 328 struct file *file = iocb->ki_filp;
329 struct inode *inode = bdev_file_inode(file); 329 struct inode *inode = bdev_file_inode(file);
330 struct block_device *bdev = I_BDEV(inode); 330 struct block_device *bdev = I_BDEV(inode);
331 struct blk_plug plug;
331 struct blkdev_dio *dio; 332 struct blkdev_dio *dio;
332 struct bio *bio; 333 struct bio *bio;
333 bool is_read = (iov_iter_rw(iter) == READ); 334 bool is_read = (iov_iter_rw(iter) == READ);
@@ -353,6 +354,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
353 dio->multi_bio = false; 354 dio->multi_bio = false;
354 dio->should_dirty = is_read && (iter->type == ITER_IOVEC); 355 dio->should_dirty = is_read && (iter->type == ITER_IOVEC);
355 356
357 blk_start_plug(&plug);
356 for (;;) { 358 for (;;) {
357 bio->bi_bdev = bdev; 359 bio->bi_bdev = bdev;
358 bio->bi_iter.bi_sector = pos >> 9; 360 bio->bi_iter.bi_sector = pos >> 9;
@@ -394,6 +396,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
394 submit_bio(bio); 396 submit_bio(bio);
395 bio = bio_alloc(GFP_KERNEL, nr_pages); 397 bio = bio_alloc(GFP_KERNEL, nr_pages);
396 } 398 }
399 blk_finish_plug(&plug);
397 400
398 if (!dio->is_sync) 401 if (!dio->is_sync)
399 return -EIOCBQUEUED; 402 return -EIOCBQUEUED;
diff --git a/fs/buffer.c b/fs/buffer.c
index d21771fcf7d3..0e87401cf335 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1660,7 +1660,7 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len)
1660 head = page_buffers(page); 1660 head = page_buffers(page);
1661 bh = head; 1661 bh = head;
1662 do { 1662 do {
1663 if (!buffer_mapped(bh)) 1663 if (!buffer_mapped(bh) || (bh->b_blocknr < block))
1664 goto next; 1664 goto next;
1665 if (bh->b_blocknr >= block + len) 1665 if (bh->b_blocknr >= block + len)
1666 break; 1666 break;
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 6eeea1dcba41..95cd4c3b06c3 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -248,7 +248,8 @@ retry:
248 goto out; 248 goto out;
249 249
250 if (fscrypt_dummy_context_enabled(inode)) { 250 if (fscrypt_dummy_context_enabled(inode)) {
251 memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE); 251 memset(raw_key, 0x42, keysize/2);
252 memset(raw_key+keysize/2, 0x24, keysize - (keysize/2));
252 goto got_key; 253 goto got_key;
253 } 254 }
254 255
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 6ed7c2eebeec..d6cd7ea4851d 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -179,6 +179,11 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
179 BUG_ON(1); 179 BUG_ON(1);
180 } 180 }
181 181
182 /* No restrictions on file types which are never encrypted */
183 if (!S_ISREG(child->i_mode) && !S_ISDIR(child->i_mode) &&
184 !S_ISLNK(child->i_mode))
185 return 1;
186
182 /* no restrictions if the parent directory is not encrypted */ 187 /* no restrictions if the parent directory is not encrypted */
183 if (!parent->i_sb->s_cop->is_encrypted(parent)) 188 if (!parent->i_sb->s_cop->is_encrypted(parent))
184 return 1; 189 return 1;
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index d3fea0bd89e2..6043306e8e21 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -510,18 +510,6 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group)
510 } 510 }
511} 511}
512 512
513void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old)
514{
515 assert_spin_locked(&old->lock);
516 new->inode = old->inode;
517 new->mnt = old->mnt;
518 if (old->group)
519 fsnotify_get_group(old->group);
520 new->group = old->group;
521 new->mask = old->mask;
522 new->free_mark = old->free_mark;
523}
524
525/* 513/*
526 * Nothing fancy, just initialize lists and locks and counters. 514 * Nothing fancy, just initialize lists and locks and counters.
527 */ 515 */
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index e5ebc3770460..d346d42c54d1 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -256,6 +256,9 @@ xfs_ag_resv_init(
256 goto out; 256 goto out;
257 } 257 }
258 258
259 ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved +
260 xfs_perag_resv(pag, XFS_AG_RESV_AGFL)->ar_reserved <=
261 pag->pagf_freeblks + pag->pagf_flcount);
259out: 262out:
260 return error; 263 return error;
261} 264}
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 6fb2215f8ff7..50add5272807 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -409,13 +409,14 @@ xfs_refcountbt_calc_size(
409 */ 409 */
410xfs_extlen_t 410xfs_extlen_t
411xfs_refcountbt_max_size( 411xfs_refcountbt_max_size(
412 struct xfs_mount *mp) 412 struct xfs_mount *mp,
413 xfs_agblock_t agblocks)
413{ 414{
414 /* Bail out if we're uninitialized, which can happen in mkfs. */ 415 /* Bail out if we're uninitialized, which can happen in mkfs. */
415 if (mp->m_refc_mxr[0] == 0) 416 if (mp->m_refc_mxr[0] == 0)
416 return 0; 417 return 0;
417 418
418 return xfs_refcountbt_calc_size(mp, mp->m_sb.sb_agblocks); 419 return xfs_refcountbt_calc_size(mp, agblocks);
419} 420}
420 421
421/* 422/*
@@ -430,22 +431,24 @@ xfs_refcountbt_calc_reserves(
430{ 431{
431 struct xfs_buf *agbp; 432 struct xfs_buf *agbp;
432 struct xfs_agf *agf; 433 struct xfs_agf *agf;
434 xfs_agblock_t agblocks;
433 xfs_extlen_t tree_len; 435 xfs_extlen_t tree_len;
434 int error; 436 int error;
435 437
436 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 438 if (!xfs_sb_version_hasreflink(&mp->m_sb))
437 return 0; 439 return 0;
438 440
439 *ask += xfs_refcountbt_max_size(mp);
440 441
441 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 442 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
442 if (error) 443 if (error)
443 return error; 444 return error;
444 445
445 agf = XFS_BUF_TO_AGF(agbp); 446 agf = XFS_BUF_TO_AGF(agbp);
447 agblocks = be32_to_cpu(agf->agf_length);
446 tree_len = be32_to_cpu(agf->agf_refcount_blocks); 448 tree_len = be32_to_cpu(agf->agf_refcount_blocks);
447 xfs_buf_relse(agbp); 449 xfs_buf_relse(agbp);
448 450
451 *ask += xfs_refcountbt_max_size(mp, agblocks);
449 *used += tree_len; 452 *used += tree_len;
450 453
451 return error; 454 return error;
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.h b/fs/xfs/libxfs/xfs_refcount_btree.h
index 3be7768bd51a..9db008b955b7 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.h
+++ b/fs/xfs/libxfs/xfs_refcount_btree.h
@@ -66,7 +66,8 @@ extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
66 66
67extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp, 67extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
68 unsigned long long len); 68 unsigned long long len);
69extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp); 69extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
70 xfs_agblock_t agblocks);
70 71
71extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp, 72extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
72 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 73 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index de25771764ba..74e5a54bc428 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -550,13 +550,14 @@ xfs_rmapbt_calc_size(
550 */ 550 */
551xfs_extlen_t 551xfs_extlen_t
552xfs_rmapbt_max_size( 552xfs_rmapbt_max_size(
553 struct xfs_mount *mp) 553 struct xfs_mount *mp,
554 xfs_agblock_t agblocks)
554{ 555{
555 /* Bail out if we're uninitialized, which can happen in mkfs. */ 556 /* Bail out if we're uninitialized, which can happen in mkfs. */
556 if (mp->m_rmap_mxr[0] == 0) 557 if (mp->m_rmap_mxr[0] == 0)
557 return 0; 558 return 0;
558 559
559 return xfs_rmapbt_calc_size(mp, mp->m_sb.sb_agblocks); 560 return xfs_rmapbt_calc_size(mp, agblocks);
560} 561}
561 562
562/* 563/*
@@ -571,25 +572,24 @@ xfs_rmapbt_calc_reserves(
571{ 572{
572 struct xfs_buf *agbp; 573 struct xfs_buf *agbp;
573 struct xfs_agf *agf; 574 struct xfs_agf *agf;
574 xfs_extlen_t pool_len; 575 xfs_agblock_t agblocks;
575 xfs_extlen_t tree_len; 576 xfs_extlen_t tree_len;
576 int error; 577 int error;
577 578
578 if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) 579 if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
579 return 0; 580 return 0;
580 581
581 /* Reserve 1% of the AG or enough for 1 block per record. */
582 pool_len = max(mp->m_sb.sb_agblocks / 100, xfs_rmapbt_max_size(mp));
583 *ask += pool_len;
584
585 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 582 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
586 if (error) 583 if (error)
587 return error; 584 return error;
588 585
589 agf = XFS_BUF_TO_AGF(agbp); 586 agf = XFS_BUF_TO_AGF(agbp);
587 agblocks = be32_to_cpu(agf->agf_length);
590 tree_len = be32_to_cpu(agf->agf_rmap_blocks); 588 tree_len = be32_to_cpu(agf->agf_rmap_blocks);
591 xfs_buf_relse(agbp); 589 xfs_buf_relse(agbp);
592 590
591 /* Reserve 1% of the AG or enough for 1 block per record. */
592 *ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
593 *used += tree_len; 593 *used += tree_len;
594 594
595 return error; 595 return error;
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.h b/fs/xfs/libxfs/xfs_rmap_btree.h
index 2a9ac472fb15..19c08e933049 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.h
+++ b/fs/xfs/libxfs/xfs_rmap_btree.h
@@ -60,7 +60,8 @@ extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
60 60
61extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp, 61extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
62 unsigned long long len); 62 unsigned long long len);
63extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp); 63extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
64 xfs_agblock_t agblocks);
64 65
65extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp, 66extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
66 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 67 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 93d12fa2670d..242e8091296d 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -631,6 +631,20 @@ xfs_growfs_data_private(
631 xfs_set_low_space_thresholds(mp); 631 xfs_set_low_space_thresholds(mp);
632 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); 632 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
633 633
634 /*
635 * If we expanded the last AG, free the per-AG reservation
636 * so we can reinitialize it with the new size.
637 */
638 if (new) {
639 struct xfs_perag *pag;
640
641 pag = xfs_perag_get(mp, agno);
642 error = xfs_ag_resv_free(pag);
643 xfs_perag_put(pag);
644 if (error)
645 goto out;
646 }
647
634 /* Reserve AG metadata blocks. */ 648 /* Reserve AG metadata blocks. */
635 error = xfs_fs_reserve_ag_blocks(mp); 649 error = xfs_fs_reserve_ag_blocks(mp);
636 if (error && error != -ENOSPC) 650 if (error && error != -ENOSPC)
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index ff4d6311c7f4..70ca4f608321 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1597,7 +1597,8 @@ xfs_inode_free_cowblocks(
1597 * If the mapping is dirty or under writeback we cannot touch the 1597 * If the mapping is dirty or under writeback we cannot touch the
1598 * CoW fork. Leave it alone if we're in the midst of a directio. 1598 * CoW fork. Leave it alone if we're in the midst of a directio.
1599 */ 1599 */
1600 if (mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) || 1600 if ((VFS_I(ip)->i_state & I_DIRTY_PAGES) ||
1601 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
1601 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) || 1602 mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) ||
1602 atomic_read(&VFS_I(ip)->i_dio_count)) 1603 atomic_read(&VFS_I(ip)->i_dio_count))
1603 return 0; 1604 return 0;
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index fe86a668a57e..6e4c7446c3d4 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -526,13 +526,14 @@ xfs_cui_recover(
526 xfs_refcount_finish_one_cleanup(tp, rcur, error); 526 xfs_refcount_finish_one_cleanup(tp, rcur, error);
527 error = xfs_defer_finish(&tp, &dfops, NULL); 527 error = xfs_defer_finish(&tp, &dfops, NULL);
528 if (error) 528 if (error)
529 goto abort_error; 529 goto abort_defer;
530 set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags); 530 set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags);
531 error = xfs_trans_commit(tp); 531 error = xfs_trans_commit(tp);
532 return error; 532 return error;
533 533
534abort_error: 534abort_error:
535 xfs_refcount_finish_one_cleanup(tp, rcur, error); 535 xfs_refcount_finish_one_cleanup(tp, rcur, error);
536abort_defer:
536 xfs_defer_cancel(&dfops); 537 xfs_defer_cancel(&dfops);
537 xfs_trans_cancel(tp); 538 xfs_trans_cancel(tp);
538 return error; 539 return error;
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 276d3023d60f..de6195e38910 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -396,7 +396,7 @@ max_retries_show(
396 int retries; 396 int retries;
397 struct xfs_error_cfg *cfg = to_error_cfg(kobject); 397 struct xfs_error_cfg *cfg = to_error_cfg(kobject);
398 398
399 if (cfg->retry_timeout == XFS_ERR_RETRY_FOREVER) 399 if (cfg->max_retries == XFS_ERR_RETRY_FOREVER)
400 retries = -1; 400 retries = -1;
401 else 401 else
402 retries = cfg->max_retries; 402 retries = cfg->max_retries;
@@ -422,7 +422,7 @@ max_retries_store(
422 return -EINVAL; 422 return -EINVAL;
423 423
424 if (val == -1) 424 if (val == -1)
425 cfg->retry_timeout = XFS_ERR_RETRY_FOREVER; 425 cfg->max_retries = XFS_ERR_RETRY_FOREVER;
426 else 426 else
427 cfg->max_retries = val; 427 cfg->max_retries = val;
428 return count; 428 return count;
diff --git a/include/asm-generic/asm-prototypes.h b/include/asm-generic/asm-prototypes.h
index df13637e4017..939869c772b1 100644
--- a/include/asm-generic/asm-prototypes.h
+++ b/include/asm-generic/asm-prototypes.h
@@ -1,7 +1,13 @@
1#include <linux/bitops.h> 1#include <linux/bitops.h>
2#undef __memset
2extern void *__memset(void *, int, __kernel_size_t); 3extern void *__memset(void *, int, __kernel_size_t);
4#undef __memcpy
3extern void *__memcpy(void *, const void *, __kernel_size_t); 5extern void *__memcpy(void *, const void *, __kernel_size_t);
6#undef __memmove
4extern void *__memmove(void *, const void *, __kernel_size_t); 7extern void *__memmove(void *, const void *, __kernel_size_t);
8#undef memset
5extern void *memset(void *, int, __kernel_size_t); 9extern void *memset(void *, int, __kernel_size_t);
10#undef memcpy
6extern void *memcpy(void *, const void *, __kernel_size_t); 11extern void *memcpy(void *, const void *, __kernel_size_t);
12#undef memmove
7extern void *memmove(void *, const void *, __kernel_size_t); 13extern void *memmove(void *, const void *, __kernel_size_t);
diff --git a/include/dt-bindings/mfd/tps65217.h b/include/dt-bindings/mfd/tps65217.h
deleted file mode 100644
index cafb9e60cf12..000000000000
--- a/include/dt-bindings/mfd/tps65217.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * This header provides macros for TI TPS65217 DT bindings.
3 *
4 * Copyright (C) 2016 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __DT_BINDINGS_TPS65217_H__
20#define __DT_BINDINGS_TPS65217_H__
21
22#define TPS65217_IRQ_USB 0
23#define TPS65217_IRQ_AC 1
24#define TPS65217_IRQ_PB 2
25
26#endif
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 0cf34d6cc253..487246546ebe 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -323,8 +323,6 @@ extern void fsnotify_init_mark(struct fsnotify_mark *mark, void (*free_mark)(str
323extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode); 323extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode);
324/* find (and take a reference) to a mark associated with group and vfsmount */ 324/* find (and take a reference) to a mark associated with group and vfsmount */
325extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt); 325extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt);
326/* copy the values from old into new */
327extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);
328/* set the ignored_mask of a mark */ 326/* set the ignored_mask of a mark */
329extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask); 327extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask);
330/* set the mask of a mark (might pin the object into memory */ 328/* set the mask of a mark (might pin the object into memory */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e0341af6950e..76f39754e7b0 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -146,15 +146,6 @@ enum {
146 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */ 146 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
147}; 147};
148 148
149#define BLK_SCSI_MAX_CMDS (256)
150#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
151
152struct blk_scsi_cmd_filter {
153 unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
154 unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
155 struct kobject kobj;
156};
157
158struct disk_part_tbl { 149struct disk_part_tbl {
159 struct rcu_head rcu_head; 150 struct rcu_head rcu_head;
160 int len; 151 int len;
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 228bd44efa4c..497f2b3a5a62 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -116,6 +116,16 @@ struct st_sensor_bdu {
116}; 116};
117 117
118/** 118/**
119 * struct st_sensor_das - ST sensor device data alignment selection
120 * @addr: address of the register.
121 * @mask: mask to write the das flag for left alignment.
122 */
123struct st_sensor_das {
124 u8 addr;
125 u8 mask;
126};
127
128/**
119 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt 129 * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
120 * @addr: address of the register. 130 * @addr: address of the register.
121 * @mask_int1: mask to enable/disable IRQ on INT1 pin. 131 * @mask_int1: mask to enable/disable IRQ on INT1 pin.
@@ -185,6 +195,7 @@ struct st_sensor_transfer_function {
185 * @enable_axis: Enable one or more axis of the sensor. 195 * @enable_axis: Enable one or more axis of the sensor.
186 * @fs: Full scale register and full scale list available. 196 * @fs: Full scale register and full scale list available.
187 * @bdu: Block data update register. 197 * @bdu: Block data update register.
198 * @das: Data Alignment Selection register.
188 * @drdy_irq: Data ready register of the sensor. 199 * @drdy_irq: Data ready register of the sensor.
189 * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. 200 * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read.
190 * @bootime: samples to discard when sensor passing from power-down to power-up. 201 * @bootime: samples to discard when sensor passing from power-down to power-up.
@@ -200,6 +211,7 @@ struct st_sensor_settings {
200 struct st_sensor_axis enable_axis; 211 struct st_sensor_axis enable_axis;
201 struct st_sensor_fullscale fs; 212 struct st_sensor_fullscale fs;
202 struct st_sensor_bdu bdu; 213 struct st_sensor_bdu bdu;
214 struct st_sensor_das das;
203 struct st_sensor_data_ready_irq drdy_irq; 215 struct st_sensor_data_ready_irq drdy_irq;
204 bool multi_read_bit; 216 bool multi_read_bit;
205 unsigned int bootime; 217 unsigned int bootime;
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index ec819e9a115a..b6e048e1045f 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -13,34 +13,10 @@
13#ifndef MDEV_H 13#ifndef MDEV_H
14#define MDEV_H 14#define MDEV_H
15 15
16/* Parent device */ 16struct mdev_device;
17struct parent_device {
18 struct device *dev;
19 const struct parent_ops *ops;
20
21 /* internal */
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
29/* Mediated device */
30struct mdev_device {
31 struct device dev;
32 struct parent_device *parent;
33 uuid_le uuid;
34 void *driver_data;
35
36 /* internal */
37 struct kref ref;
38 struct list_head next;
39 struct kobject *type_kobj;
40};
41 17
42/** 18/**
43 * struct parent_ops - Structure to be registered for each parent device to 19 * struct mdev_parent_ops - Structure to be registered for each parent device to
44 * register the device to mdev module. 20 * register the device to mdev module.
45 * 21 *
46 * @owner: The module owner. 22 * @owner: The module owner.
@@ -86,10 +62,9 @@ struct mdev_device {
86 * @mdev: mediated device structure 62 * @mdev: mediated device structure
87 * @vma: vma structure 63 * @vma: vma structure
88 * Parent device that support mediated device should be registered with mdev 64 * Parent device that support mediated device should be registered with mdev
89 * module with parent_ops structure. 65 * module with mdev_parent_ops structure.
90 **/ 66 **/
91 67struct mdev_parent_ops {
92struct parent_ops {
93 struct module *owner; 68 struct module *owner;
94 const struct attribute_group **dev_attr_groups; 69 const struct attribute_group **dev_attr_groups;
95 const struct attribute_group **mdev_attr_groups; 70 const struct attribute_group **mdev_attr_groups;
@@ -103,7 +78,7 @@ struct parent_ops {
103 size_t count, loff_t *ppos); 78 size_t count, loff_t *ppos);
104 ssize_t (*write)(struct mdev_device *mdev, const char __user *buf, 79 ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
105 size_t count, loff_t *ppos); 80 size_t count, loff_t *ppos);
106 ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd, 81 long (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
107 unsigned long arg); 82 unsigned long arg);
108 int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma); 83 int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
109}; 84};
@@ -142,27 +117,22 @@ struct mdev_driver {
142}; 117};
143 118
144#define to_mdev_driver(drv) container_of(drv, struct mdev_driver, driver) 119#define to_mdev_driver(drv) container_of(drv, struct mdev_driver, driver)
145#define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
146
147static inline void *mdev_get_drvdata(struct mdev_device *mdev)
148{
149 return mdev->driver_data;
150}
151 120
152static inline void mdev_set_drvdata(struct mdev_device *mdev, void *data) 121extern void *mdev_get_drvdata(struct mdev_device *mdev);
153{ 122extern void mdev_set_drvdata(struct mdev_device *mdev, void *data);
154 mdev->driver_data = data; 123extern uuid_le mdev_uuid(struct mdev_device *mdev);
155}
156 124
157extern struct bus_type mdev_bus_type; 125extern struct bus_type mdev_bus_type;
158 126
159#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
160
161extern int mdev_register_device(struct device *dev, 127extern int mdev_register_device(struct device *dev,
162 const struct parent_ops *ops); 128 const struct mdev_parent_ops *ops);
163extern void mdev_unregister_device(struct device *dev); 129extern void mdev_unregister_device(struct device *dev);
164 130
165extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner); 131extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
166extern void mdev_unregister_driver(struct mdev_driver *drv); 132extern void mdev_unregister_driver(struct mdev_driver *drv);
167 133
134extern struct device *mdev_parent_dev(struct mdev_device *mdev);
135extern struct device *mdev_dev(struct mdev_device *mdev);
136extern struct mdev_device *mdev_from_dev(struct device *dev);
137
168#endif /* MDEV_H */ 138#endif /* MDEV_H */
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 93bdb3485192..6533c16e27ad 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -1384,6 +1384,8 @@ int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
1384int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv); 1384int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
1385int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port, 1385int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
1386 bool *vlan_offload_disabled); 1386 bool *vlan_offload_disabled);
1387void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
1388 struct _rule_hw *eth_header);
1387int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx); 1389int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
1388int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 1390int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
1389int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 1391int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 9f489365b3d3..52b437431c6a 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -1071,11 +1071,6 @@ enum {
1071 MLX5_INFINIBAND_PORT_COUNTERS_GROUP = 0x20, 1071 MLX5_INFINIBAND_PORT_COUNTERS_GROUP = 0x20,
1072}; 1072};
1073 1073
1074enum {
1075 MLX5_PCIE_PERFORMANCE_COUNTERS_GROUP = 0x0,
1076 MLX5_PCIE_TIMERS_AND_STATES_COUNTERS_GROUP = 0x2,
1077};
1078
1079static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz) 1074static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
1080{ 1075{
1081 if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE) 1076 if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 0ae55361e674..735b36335f29 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -123,7 +123,6 @@ enum {
123 MLX5_REG_HOST_ENDIANNESS = 0x7004, 123 MLX5_REG_HOST_ENDIANNESS = 0x7004,
124 MLX5_REG_MCIA = 0x9014, 124 MLX5_REG_MCIA = 0x9014,
125 MLX5_REG_MLCR = 0x902b, 125 MLX5_REG_MLCR = 0x902b,
126 MLX5_REG_MPCNT = 0x9051,
127}; 126};
128 127
129enum mlx5_dcbx_oper_mode { 128enum mlx5_dcbx_oper_mode {
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 57bec544e20a..a852e9db6f0d 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1757,80 +1757,6 @@ struct mlx5_ifc_eth_802_3_cntrs_grp_data_layout_bits {
1757 u8 reserved_at_4c0[0x300]; 1757 u8 reserved_at_4c0[0x300];
1758}; 1758};
1759 1759
1760struct mlx5_ifc_pcie_perf_cntrs_grp_data_layout_bits {
1761 u8 life_time_counter_high[0x20];
1762
1763 u8 life_time_counter_low[0x20];
1764
1765 u8 rx_errors[0x20];
1766
1767 u8 tx_errors[0x20];
1768
1769 u8 l0_to_recovery_eieos[0x20];
1770
1771 u8 l0_to_recovery_ts[0x20];
1772
1773 u8 l0_to_recovery_framing[0x20];
1774
1775 u8 l0_to_recovery_retrain[0x20];
1776
1777 u8 crc_error_dllp[0x20];
1778
1779 u8 crc_error_tlp[0x20];
1780
1781 u8 reserved_at_140[0x680];
1782};
1783
1784struct mlx5_ifc_pcie_tas_cntrs_grp_data_layout_bits {
1785 u8 life_time_counter_high[0x20];
1786
1787 u8 life_time_counter_low[0x20];
1788
1789 u8 time_to_boot_image_start[0x20];
1790
1791 u8 time_to_link_image[0x20];
1792
1793 u8 calibration_time[0x20];
1794
1795 u8 time_to_first_perst[0x20];
1796
1797 u8 time_to_detect_state[0x20];
1798
1799 u8 time_to_l0[0x20];
1800
1801 u8 time_to_crs_en[0x20];
1802
1803 u8 time_to_plastic_image_start[0x20];
1804
1805 u8 time_to_iron_image_start[0x20];
1806
1807 u8 perst_handler[0x20];
1808
1809 u8 times_in_l1[0x20];
1810
1811 u8 times_in_l23[0x20];
1812
1813 u8 dl_down[0x20];
1814
1815 u8 config_cycle1usec[0x20];
1816
1817 u8 config_cycle2to7usec[0x20];
1818
1819 u8 config_cycle_8to15usec[0x20];
1820
1821 u8 config_cycle_16_to_63usec[0x20];
1822
1823 u8 config_cycle_64usec[0x20];
1824
1825 u8 correctable_err_msg_sent[0x20];
1826
1827 u8 non_fatal_err_msg_sent[0x20];
1828
1829 u8 fatal_err_msg_sent[0x20];
1830
1831 u8 reserved_at_2e0[0x4e0];
1832};
1833
1834struct mlx5_ifc_cmd_inter_comp_event_bits { 1760struct mlx5_ifc_cmd_inter_comp_event_bits {
1835 u8 command_completion_vector[0x20]; 1761 u8 command_completion_vector[0x20];
1836 1762
@@ -2995,12 +2921,6 @@ union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits {
2995 u8 reserved_at_0[0x7c0]; 2921 u8 reserved_at_0[0x7c0];
2996}; 2922};
2997 2923
2998union mlx5_ifc_pcie_cntrs_grp_data_layout_auto_bits {
2999 struct mlx5_ifc_pcie_perf_cntrs_grp_data_layout_bits pcie_perf_cntrs_grp_data_layout;
3000 struct mlx5_ifc_pcie_tas_cntrs_grp_data_layout_bits pcie_tas_cntrs_grp_data_layout;
3001 u8 reserved_at_0[0x7c0];
3002};
3003
3004union mlx5_ifc_event_auto_bits { 2924union mlx5_ifc_event_auto_bits {
3005 struct mlx5_ifc_comp_event_bits comp_event; 2925 struct mlx5_ifc_comp_event_bits comp_event;
3006 struct mlx5_ifc_dct_events_bits dct_events; 2926 struct mlx5_ifc_dct_events_bits dct_events;
@@ -7320,18 +7240,6 @@ struct mlx5_ifc_ppcnt_reg_bits {
7320 union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits counter_set; 7240 union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits counter_set;
7321}; 7241};
7322 7242
7323struct mlx5_ifc_mpcnt_reg_bits {
7324 u8 reserved_at_0[0x8];
7325 u8 pcie_index[0x8];
7326 u8 reserved_at_10[0xa];
7327 u8 grp[0x6];
7328
7329 u8 clr[0x1];
7330 u8 reserved_at_21[0x1f];
7331
7332 union mlx5_ifc_pcie_cntrs_grp_data_layout_auto_bits counter_set;
7333};
7334
7335struct mlx5_ifc_ppad_reg_bits { 7243struct mlx5_ifc_ppad_reg_bits {
7336 u8 reserved_at_0[0x3]; 7244 u8 reserved_at_0[0x3];
7337 u8 single_mac[0x1]; 7245 u8 single_mac[0x1];
@@ -7937,7 +7845,6 @@ union mlx5_ifc_ports_control_registers_document_bits {
7937 struct mlx5_ifc_pmtu_reg_bits pmtu_reg; 7845 struct mlx5_ifc_pmtu_reg_bits pmtu_reg;
7938 struct mlx5_ifc_ppad_reg_bits ppad_reg; 7846 struct mlx5_ifc_ppad_reg_bits ppad_reg;
7939 struct mlx5_ifc_ppcnt_reg_bits ppcnt_reg; 7847 struct mlx5_ifc_ppcnt_reg_bits ppcnt_reg;
7940 struct mlx5_ifc_mpcnt_reg_bits mpcnt_reg;
7941 struct mlx5_ifc_pplm_reg_bits pplm_reg; 7848 struct mlx5_ifc_pplm_reg_bits pplm_reg;
7942 struct mlx5_ifc_pplr_reg_bits pplr_reg; 7849 struct mlx5_ifc_pplr_reg_bits pplr_reg;
7943 struct mlx5_ifc_ppsc_reg_bits ppsc_reg; 7850 struct mlx5_ifc_ppsc_reg_bits ppsc_reg;
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 5dea8f6440e4..52bda854593b 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -306,7 +306,9 @@ void radix_tree_iter_replace(struct radix_tree_root *,
306void radix_tree_replace_slot(struct radix_tree_root *root, 306void radix_tree_replace_slot(struct radix_tree_root *root,
307 void **slot, void *item); 307 void **slot, void *item);
308void __radix_tree_delete_node(struct radix_tree_root *root, 308void __radix_tree_delete_node(struct radix_tree_root *root,
309 struct radix_tree_node *node); 309 struct radix_tree_node *node,
310 radix_tree_update_node_t update_node,
311 void *private);
310void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *); 312void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *);
311void *radix_tree_delete(struct radix_tree_root *, unsigned long); 313void *radix_tree_delete(struct radix_tree_root *, unsigned long);
312void radix_tree_clear_tags(struct radix_tree_root *root, 314void radix_tree_clear_tags(struct radix_tree_root *root,
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 183f37c8a5e1..4ee479f2f355 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -9,7 +9,13 @@ struct device;
9struct page; 9struct page;
10struct scatterlist; 10struct scatterlist;
11 11
12extern int swiotlb_force; 12enum swiotlb_force {
13 SWIOTLB_NORMAL, /* Default - depending on HW DMA mask etc. */
14 SWIOTLB_FORCE, /* swiotlb=force */
15 SWIOTLB_NO_FORCE, /* swiotlb=noforce */
16};
17
18extern enum swiotlb_force swiotlb_force;
13 19
14/* 20/*
15 * Maximum allowable number of contiguous slabs to map, 21 * Maximum allowable number of contiguous slabs to map,
@@ -108,11 +114,14 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask);
108 114
109#ifdef CONFIG_SWIOTLB 115#ifdef CONFIG_SWIOTLB
110extern void __init swiotlb_free(void); 116extern void __init swiotlb_free(void);
117unsigned int swiotlb_max_segment(void);
111#else 118#else
112static inline void swiotlb_free(void) { } 119static inline void swiotlb_free(void) { }
120static inline unsigned int swiotlb_max_segment(void) { return 0; }
113#endif 121#endif
114 122
115extern void swiotlb_print_info(void); 123extern void swiotlb_print_info(void);
116extern int is_swiotlb_buffer(phys_addr_t paddr); 124extern int is_swiotlb_buffer(phys_addr_t paddr);
125extern void swiotlb_set_max_segment(unsigned int);
117 126
118#endif /* __LINUX_SWIOTLB_H */ 127#endif /* __LINUX_SWIOTLB_H */
diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 530c57bdefa0..915c4357945c 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -36,10 +36,10 @@ struct hdmi_codec_daifmt {
36 HDMI_AC97, 36 HDMI_AC97,
37 HDMI_SPDIF, 37 HDMI_SPDIF,
38 } fmt; 38 } fmt;
39 int bit_clk_inv:1; 39 unsigned int bit_clk_inv:1;
40 int frame_clk_inv:1; 40 unsigned int frame_clk_inv:1;
41 int bit_clk_master:1; 41 unsigned int bit_clk_master:1;
42 int frame_clk_master:1; 42 unsigned int frame_clk_master:1;
43}; 43};
44 44
45/* 45/*
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2b502f6cc6d0..b86168a21d56 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -813,6 +813,7 @@ struct snd_soc_component {
813 unsigned int suspended:1; /* is in suspend PM state */ 813 unsigned int suspended:1; /* is in suspend PM state */
814 814
815 struct list_head list; 815 struct list_head list;
816 struct list_head card_aux_list; /* for auxiliary bound components */
816 struct list_head card_list; 817 struct list_head card_list;
817 818
818 struct snd_soc_dai_driver *dai_drv; 819 struct snd_soc_dai_driver *dai_drv;
@@ -1152,6 +1153,7 @@ struct snd_soc_card {
1152 */ 1153 */
1153 struct snd_soc_aux_dev *aux_dev; 1154 struct snd_soc_aux_dev *aux_dev;
1154 int num_aux_devs; 1155 int num_aux_devs;
1156 struct list_head aux_comp_list;
1155 1157
1156 const struct snd_kcontrol_new *controls; 1158 const struct snd_kcontrol_new *controls;
1157 int num_controls; 1159 int num_controls;
@@ -1547,6 +1549,7 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
1547 INIT_LIST_HEAD(&card->widgets); 1549 INIT_LIST_HEAD(&card->widgets);
1548 INIT_LIST_HEAD(&card->paths); 1550 INIT_LIST_HEAD(&card->paths);
1549 INIT_LIST_HEAD(&card->dapm_list); 1551 INIT_LIST_HEAD(&card->dapm_list);
1552 INIT_LIST_HEAD(&card->aux_comp_list);
1550 INIT_LIST_HEAD(&card->component_dev_list); 1553 INIT_LIST_HEAD(&card->component_dev_list);
1551} 1554}
1552 1555
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
index 7ea4c5e7c448..288c0c54a2b4 100644
--- a/include/trace/events/swiotlb.h
+++ b/include/trace/events/swiotlb.h
@@ -11,16 +11,16 @@ TRACE_EVENT(swiotlb_bounced,
11 TP_PROTO(struct device *dev, 11 TP_PROTO(struct device *dev,
12 dma_addr_t dev_addr, 12 dma_addr_t dev_addr,
13 size_t size, 13 size_t size,
14 int swiotlb_force), 14 enum swiotlb_force swiotlb_force),
15 15
16 TP_ARGS(dev, dev_addr, size, swiotlb_force), 16 TP_ARGS(dev, dev_addr, size, swiotlb_force),
17 17
18 TP_STRUCT__entry( 18 TP_STRUCT__entry(
19 __string( dev_name, dev_name(dev) ) 19 __string( dev_name, dev_name(dev) )
20 __field( u64, dma_mask ) 20 __field( u64, dma_mask )
21 __field( dma_addr_t, dev_addr ) 21 __field( dma_addr_t, dev_addr )
22 __field( size_t, size ) 22 __field( size_t, size )
23 __field( int, swiotlb_force ) 23 __field( enum swiotlb_force, swiotlb_force )
24 ), 24 ),
25 25
26 TP_fast_assign( 26 TP_fast_assign(
@@ -37,7 +37,10 @@ TRACE_EVENT(swiotlb_bounced,
37 __entry->dma_mask, 37 __entry->dma_mask,
38 (unsigned long long)__entry->dev_addr, 38 (unsigned long long)__entry->dev_addr,
39 __entry->size, 39 __entry->size,
40 __entry->swiotlb_force ? "swiotlb_force" : "" ) 40 __print_symbolic(__entry->swiotlb_force,
41 { SWIOTLB_NORMAL, "NORMAL" },
42 { SWIOTLB_FORCE, "FORCE" },
43 { SWIOTLB_NO_FORCE, "NO_FORCE" }))
41); 44);
42 45
43#endif /* _TRACE_SWIOTLB_H */ 46#endif /* _TRACE_SWIOTLB_H */
diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
index acc63697a0cc..b2a31a55a612 100644
--- a/include/uapi/linux/usb/functionfs.h
+++ b/include/uapi/linux/usb/functionfs.h
@@ -93,6 +93,7 @@ struct usb_ext_prop_desc {
93 * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 | 93 * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 |
94 * | 4 | length | LE32 | length of the whole data chunk | 94 * | 4 | length | LE32 | length of the whole data chunk |
95 * | 8 | flags | LE32 | combination of functionfs_flags | 95 * | 8 | flags | LE32 | combination of functionfs_flags |
96 * | | eventfd | LE32 | eventfd file descriptor |
96 * | | fs_count | LE32 | number of full-speed descriptors | 97 * | | fs_count | LE32 | number of full-speed descriptors |
97 * | | hs_count | LE32 | number of high-speed descriptors | 98 * | | hs_count | LE32 | number of high-speed descriptors |
98 * | | ss_count | LE32 | number of super-speed descriptors | 99 * | | ss_count | LE32 | number of super-speed descriptors |
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 8b1dde96a0fa..7b44195da81b 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -231,9 +231,11 @@ static void untag_chunk(struct node *p)
231 if (size) 231 if (size)
232 new = alloc_chunk(size); 232 new = alloc_chunk(size);
233 233
234 mutex_lock(&entry->group->mark_mutex);
234 spin_lock(&entry->lock); 235 spin_lock(&entry->lock);
235 if (chunk->dead || !entry->inode) { 236 if (chunk->dead || !entry->inode) {
236 spin_unlock(&entry->lock); 237 spin_unlock(&entry->lock);
238 mutex_unlock(&entry->group->mark_mutex);
237 if (new) 239 if (new)
238 free_chunk(new); 240 free_chunk(new);
239 goto out; 241 goto out;
@@ -251,6 +253,7 @@ static void untag_chunk(struct node *p)
251 list_del_rcu(&chunk->hash); 253 list_del_rcu(&chunk->hash);
252 spin_unlock(&hash_lock); 254 spin_unlock(&hash_lock);
253 spin_unlock(&entry->lock); 255 spin_unlock(&entry->lock);
256 mutex_unlock(&entry->group->mark_mutex);
254 fsnotify_destroy_mark(entry, audit_tree_group); 257 fsnotify_destroy_mark(entry, audit_tree_group);
255 goto out; 258 goto out;
256 } 259 }
@@ -258,8 +261,8 @@ static void untag_chunk(struct node *p)
258 if (!new) 261 if (!new)
259 goto Fallback; 262 goto Fallback;
260 263
261 fsnotify_duplicate_mark(&new->mark, entry); 264 if (fsnotify_add_mark_locked(&new->mark, entry->group, entry->inode,
262 if (fsnotify_add_mark(&new->mark, new->mark.group, new->mark.inode, NULL, 1)) { 265 NULL, 1)) {
263 fsnotify_put_mark(&new->mark); 266 fsnotify_put_mark(&new->mark);
264 goto Fallback; 267 goto Fallback;
265 } 268 }
@@ -293,6 +296,7 @@ static void untag_chunk(struct node *p)
293 owner->root = new; 296 owner->root = new;
294 spin_unlock(&hash_lock); 297 spin_unlock(&hash_lock);
295 spin_unlock(&entry->lock); 298 spin_unlock(&entry->lock);
299 mutex_unlock(&entry->group->mark_mutex);
296 fsnotify_destroy_mark(entry, audit_tree_group); 300 fsnotify_destroy_mark(entry, audit_tree_group);
297 fsnotify_put_mark(&new->mark); /* drop initial reference */ 301 fsnotify_put_mark(&new->mark); /* drop initial reference */
298 goto out; 302 goto out;
@@ -309,6 +313,7 @@ Fallback:
309 put_tree(owner); 313 put_tree(owner);
310 spin_unlock(&hash_lock); 314 spin_unlock(&hash_lock);
311 spin_unlock(&entry->lock); 315 spin_unlock(&entry->lock);
316 mutex_unlock(&entry->group->mark_mutex);
312out: 317out:
313 fsnotify_put_mark(entry); 318 fsnotify_put_mark(entry);
314 spin_lock(&hash_lock); 319 spin_lock(&hash_lock);
@@ -386,18 +391,21 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
386 391
387 chunk_entry = &chunk->mark; 392 chunk_entry = &chunk->mark;
388 393
394 mutex_lock(&old_entry->group->mark_mutex);
389 spin_lock(&old_entry->lock); 395 spin_lock(&old_entry->lock);
390 if (!old_entry->inode) { 396 if (!old_entry->inode) {
391 /* old_entry is being shot, lets just lie */ 397 /* old_entry is being shot, lets just lie */
392 spin_unlock(&old_entry->lock); 398 spin_unlock(&old_entry->lock);
399 mutex_unlock(&old_entry->group->mark_mutex);
393 fsnotify_put_mark(old_entry); 400 fsnotify_put_mark(old_entry);
394 free_chunk(chunk); 401 free_chunk(chunk);
395 return -ENOENT; 402 return -ENOENT;
396 } 403 }
397 404
398 fsnotify_duplicate_mark(chunk_entry, old_entry); 405 if (fsnotify_add_mark_locked(chunk_entry, old_entry->group,
399 if (fsnotify_add_mark(chunk_entry, chunk_entry->group, chunk_entry->inode, NULL, 1)) { 406 old_entry->inode, NULL, 1)) {
400 spin_unlock(&old_entry->lock); 407 spin_unlock(&old_entry->lock);
408 mutex_unlock(&old_entry->group->mark_mutex);
401 fsnotify_put_mark(chunk_entry); 409 fsnotify_put_mark(chunk_entry);
402 fsnotify_put_mark(old_entry); 410 fsnotify_put_mark(old_entry);
403 return -ENOSPC; 411 return -ENOSPC;
@@ -413,6 +421,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
413 chunk->dead = 1; 421 chunk->dead = 1;
414 spin_unlock(&chunk_entry->lock); 422 spin_unlock(&chunk_entry->lock);
415 spin_unlock(&old_entry->lock); 423 spin_unlock(&old_entry->lock);
424 mutex_unlock(&old_entry->group->mark_mutex);
416 425
417 fsnotify_destroy_mark(chunk_entry, audit_tree_group); 426 fsnotify_destroy_mark(chunk_entry, audit_tree_group);
418 427
@@ -445,6 +454,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
445 spin_unlock(&hash_lock); 454 spin_unlock(&hash_lock);
446 spin_unlock(&chunk_entry->lock); 455 spin_unlock(&chunk_entry->lock);
447 spin_unlock(&old_entry->lock); 456 spin_unlock(&old_entry->lock);
457 mutex_unlock(&old_entry->group->mark_mutex);
448 fsnotify_destroy_mark(old_entry, audit_tree_group); 458 fsnotify_destroy_mark(old_entry, audit_tree_group);
449 fsnotify_put_mark(chunk_entry); /* drop initial reference */ 459 fsnotify_put_mark(chunk_entry); /* drop initial reference */
450 fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */ 460 fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 6f382e07de77..0b92d605fb69 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -640,6 +640,7 @@ static inline void radix_tree_shrink(struct radix_tree_root *root,
640 update_node(node, private); 640 update_node(node, private);
641 } 641 }
642 642
643 WARN_ON_ONCE(!list_empty(&node->private_list));
643 radix_tree_node_free(node); 644 radix_tree_node_free(node);
644 } 645 }
645} 646}
@@ -666,6 +667,7 @@ static void delete_node(struct radix_tree_root *root,
666 root->rnode = NULL; 667 root->rnode = NULL;
667 } 668 }
668 669
670 WARN_ON_ONCE(!list_empty(&node->private_list));
669 radix_tree_node_free(node); 671 radix_tree_node_free(node);
670 672
671 node = parent; 673 node = parent;
@@ -767,6 +769,7 @@ static void radix_tree_free_nodes(struct radix_tree_node *node)
767 struct radix_tree_node *old = child; 769 struct radix_tree_node *old = child;
768 offset = child->offset + 1; 770 offset = child->offset + 1;
769 child = child->parent; 771 child = child->parent;
772 WARN_ON_ONCE(!list_empty(&node->private_list));
770 radix_tree_node_free(old); 773 radix_tree_node_free(old);
771 if (old == entry_to_node(node)) 774 if (old == entry_to_node(node))
772 return; 775 return;
@@ -1824,15 +1827,19 @@ EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot);
1824 * __radix_tree_delete_node - try to free node after clearing a slot 1827 * __radix_tree_delete_node - try to free node after clearing a slot
1825 * @root: radix tree root 1828 * @root: radix tree root
1826 * @node: node containing @index 1829 * @node: node containing @index
1830 * @update_node: callback for changing leaf nodes
1831 * @private: private data to pass to @update_node
1827 * 1832 *
1828 * After clearing the slot at @index in @node from radix tree 1833 * After clearing the slot at @index in @node from radix tree
1829 * rooted at @root, call this function to attempt freeing the 1834 * rooted at @root, call this function to attempt freeing the
1830 * node and shrinking the tree. 1835 * node and shrinking the tree.
1831 */ 1836 */
1832void __radix_tree_delete_node(struct radix_tree_root *root, 1837void __radix_tree_delete_node(struct radix_tree_root *root,
1833 struct radix_tree_node *node) 1838 struct radix_tree_node *node,
1839 radix_tree_update_node_t update_node,
1840 void *private)
1834{ 1841{
1835 delete_node(root, node, NULL, NULL); 1842 delete_node(root, node, update_node, private);
1836} 1843}
1837 1844
1838/** 1845/**
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index cb1b54ee8527..975b8fc4f1e1 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -53,7 +53,7 @@
53 */ 53 */
54#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) 54#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
55 55
56int swiotlb_force; 56enum swiotlb_force swiotlb_force;
57 57
58/* 58/*
59 * Used to do a quick range check in swiotlb_tbl_unmap_single and 59 * Used to do a quick range check in swiotlb_tbl_unmap_single and
@@ -83,6 +83,12 @@ static unsigned int *io_tlb_list;
83static unsigned int io_tlb_index; 83static unsigned int io_tlb_index;
84 84
85/* 85/*
86 * Max segment that we can provide which (if pages are contingous) will
87 * not be bounced (unless SWIOTLB_FORCE is set).
88 */
89unsigned int max_segment;
90
91/*
86 * We need to save away the original address corresponding to a mapped entry 92 * We need to save away the original address corresponding to a mapped entry
87 * for the sync operations. 93 * for the sync operations.
88 */ 94 */
@@ -106,8 +112,12 @@ setup_io_tlb_npages(char *str)
106 } 112 }
107 if (*str == ',') 113 if (*str == ',')
108 ++str; 114 ++str;
109 if (!strcmp(str, "force")) 115 if (!strcmp(str, "force")) {
110 swiotlb_force = 1; 116 swiotlb_force = SWIOTLB_FORCE;
117 } else if (!strcmp(str, "noforce")) {
118 swiotlb_force = SWIOTLB_NO_FORCE;
119 io_tlb_nslabs = 1;
120 }
111 121
112 return 0; 122 return 0;
113} 123}
@@ -120,6 +130,20 @@ unsigned long swiotlb_nr_tbl(void)
120} 130}
121EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); 131EXPORT_SYMBOL_GPL(swiotlb_nr_tbl);
122 132
133unsigned int swiotlb_max_segment(void)
134{
135 return max_segment;
136}
137EXPORT_SYMBOL_GPL(swiotlb_max_segment);
138
139void swiotlb_set_max_segment(unsigned int val)
140{
141 if (swiotlb_force == SWIOTLB_FORCE)
142 max_segment = 1;
143 else
144 max_segment = rounddown(val, PAGE_SIZE);
145}
146
123/* default to 64MB */ 147/* default to 64MB */
124#define IO_TLB_DEFAULT_SIZE (64UL<<20) 148#define IO_TLB_DEFAULT_SIZE (64UL<<20)
125unsigned long swiotlb_size_or_default(void) 149unsigned long swiotlb_size_or_default(void)
@@ -201,6 +225,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
201 if (verbose) 225 if (verbose)
202 swiotlb_print_info(); 226 swiotlb_print_info();
203 227
228 swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT);
204 return 0; 229 return 0;
205} 230}
206 231
@@ -279,6 +304,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
279 rc = swiotlb_late_init_with_tbl(vstart, io_tlb_nslabs); 304 rc = swiotlb_late_init_with_tbl(vstart, io_tlb_nslabs);
280 if (rc) 305 if (rc)
281 free_pages((unsigned long)vstart, order); 306 free_pages((unsigned long)vstart, order);
307
282 return rc; 308 return rc;
283} 309}
284 310
@@ -333,6 +359,8 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
333 359
334 late_alloc = 1; 360 late_alloc = 1;
335 361
362 swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT);
363
336 return 0; 364 return 0;
337 365
338cleanup4: 366cleanup4:
@@ -347,6 +375,7 @@ cleanup2:
347 io_tlb_end = 0; 375 io_tlb_end = 0;
348 io_tlb_start = 0; 376 io_tlb_start = 0;
349 io_tlb_nslabs = 0; 377 io_tlb_nslabs = 0;
378 max_segment = 0;
350 return -ENOMEM; 379 return -ENOMEM;
351} 380}
352 381
@@ -375,6 +404,7 @@ void __init swiotlb_free(void)
375 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); 404 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
376 } 405 }
377 io_tlb_nslabs = 0; 406 io_tlb_nslabs = 0;
407 max_segment = 0;
378} 408}
379 409
380int is_swiotlb_buffer(phys_addr_t paddr) 410int is_swiotlb_buffer(phys_addr_t paddr)
@@ -543,8 +573,15 @@ static phys_addr_t
543map_single(struct device *hwdev, phys_addr_t phys, size_t size, 573map_single(struct device *hwdev, phys_addr_t phys, size_t size,
544 enum dma_data_direction dir, unsigned long attrs) 574 enum dma_data_direction dir, unsigned long attrs)
545{ 575{
546 dma_addr_t start_dma_addr = phys_to_dma(hwdev, io_tlb_start); 576 dma_addr_t start_dma_addr;
547 577
578 if (swiotlb_force == SWIOTLB_NO_FORCE) {
579 dev_warn_ratelimited(hwdev, "Cannot do DMA to address %pa\n",
580 &phys);
581 return SWIOTLB_MAP_ERROR;
582 }
583
584 start_dma_addr = phys_to_dma(hwdev, io_tlb_start);
548 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, 585 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size,
549 dir, attrs); 586 dir, attrs);
550} 587}
@@ -721,6 +758,9 @@ static void
721swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, 758swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
722 int do_panic) 759 int do_panic)
723{ 760{
761 if (swiotlb_force == SWIOTLB_NO_FORCE)
762 return;
763
724 /* 764 /*
725 * Ran out of IOMMU space for this operation. This is very bad. 765 * Ran out of IOMMU space for this operation. This is very bad.
726 * Unfortunately the drivers cannot handle this operation properly. 766 * Unfortunately the drivers cannot handle this operation properly.
@@ -763,7 +803,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
763 * we can safely return the device addr and not worry about bounce 803 * we can safely return the device addr and not worry about bounce
764 * buffering it. 804 * buffering it.
765 */ 805 */
766 if (dma_capable(dev, dev_addr, size) && !swiotlb_force) 806 if (dma_capable(dev, dev_addr, size) && swiotlb_force != SWIOTLB_FORCE)
767 return dev_addr; 807 return dev_addr;
768 808
769 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force); 809 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
@@ -904,7 +944,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
904 phys_addr_t paddr = sg_phys(sg); 944 phys_addr_t paddr = sg_phys(sg);
905 dma_addr_t dev_addr = phys_to_dma(hwdev, paddr); 945 dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
906 946
907 if (swiotlb_force || 947 if (swiotlb_force == SWIOTLB_FORCE ||
908 !dma_capable(hwdev, dev_addr, sg->length)) { 948 !dma_capable(hwdev, dev_addr, sg->length)) {
909 phys_addr_t map = map_single(hwdev, sg_phys(sg), 949 phys_addr_t map = map_single(hwdev, sg_phys(sg),
910 sg->length, dir, attrs); 950 sg->length, dir, attrs);
diff --git a/mm/memory.c b/mm/memory.c
index 7d23b5050248..9f2c15cdb32c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3008,13 +3008,6 @@ static int do_set_pmd(struct vm_fault *vmf, struct page *page)
3008 ret = 0; 3008 ret = 0;
3009 count_vm_event(THP_FILE_MAPPED); 3009 count_vm_event(THP_FILE_MAPPED);
3010out: 3010out:
3011 /*
3012 * If we are going to fallback to pte mapping, do a
3013 * withdraw with pmd lock held.
3014 */
3015 if (arch_needs_pgtable_deposit() && ret == VM_FAULT_FALLBACK)
3016 vmf->prealloc_pte = pgtable_trans_huge_withdraw(vma->vm_mm,
3017 vmf->pmd);
3018 spin_unlock(vmf->ptl); 3011 spin_unlock(vmf->ptl);
3019 return ret; 3012 return ret;
3020} 3013}
@@ -3055,20 +3048,18 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
3055 3048
3056 ret = do_set_pmd(vmf, page); 3049 ret = do_set_pmd(vmf, page);
3057 if (ret != VM_FAULT_FALLBACK) 3050 if (ret != VM_FAULT_FALLBACK)
3058 goto fault_handled; 3051 return ret;
3059 } 3052 }
3060 3053
3061 if (!vmf->pte) { 3054 if (!vmf->pte) {
3062 ret = pte_alloc_one_map(vmf); 3055 ret = pte_alloc_one_map(vmf);
3063 if (ret) 3056 if (ret)
3064 goto fault_handled; 3057 return ret;
3065 } 3058 }
3066 3059
3067 /* Re-check under ptl */ 3060 /* Re-check under ptl */
3068 if (unlikely(!pte_none(*vmf->pte))) { 3061 if (unlikely(!pte_none(*vmf->pte)))
3069 ret = VM_FAULT_NOPAGE; 3062 return VM_FAULT_NOPAGE;
3070 goto fault_handled;
3071 }
3072 3063
3073 flush_icache_page(vma, page); 3064 flush_icache_page(vma, page);
3074 entry = mk_pte(page, vma->vm_page_prot); 3065 entry = mk_pte(page, vma->vm_page_prot);
@@ -3088,15 +3079,8 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
3088 3079
3089 /* no need to invalidate: a not-present page won't be cached */ 3080 /* no need to invalidate: a not-present page won't be cached */
3090 update_mmu_cache(vma, vmf->address, vmf->pte); 3081 update_mmu_cache(vma, vmf->address, vmf->pte);
3091 ret = 0;
3092 3082
3093fault_handled: 3083 return 0;
3094 /* preallocated pagetable is unused: free it */
3095 if (vmf->prealloc_pte) {
3096 pte_free(vmf->vma->vm_mm, vmf->prealloc_pte);
3097 vmf->prealloc_pte = 0;
3098 }
3099 return ret;
3100} 3084}
3101 3085
3102 3086
@@ -3360,15 +3344,24 @@ static int do_shared_fault(struct vm_fault *vmf)
3360static int do_fault(struct vm_fault *vmf) 3344static int do_fault(struct vm_fault *vmf)
3361{ 3345{
3362 struct vm_area_struct *vma = vmf->vma; 3346 struct vm_area_struct *vma = vmf->vma;
3347 int ret;
3363 3348
3364 /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */ 3349 /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */
3365 if (!vma->vm_ops->fault) 3350 if (!vma->vm_ops->fault)
3366 return VM_FAULT_SIGBUS; 3351 ret = VM_FAULT_SIGBUS;
3367 if (!(vmf->flags & FAULT_FLAG_WRITE)) 3352 else if (!(vmf->flags & FAULT_FLAG_WRITE))
3368 return do_read_fault(vmf); 3353 ret = do_read_fault(vmf);
3369 if (!(vma->vm_flags & VM_SHARED)) 3354 else if (!(vma->vm_flags & VM_SHARED))
3370 return do_cow_fault(vmf); 3355 ret = do_cow_fault(vmf);
3371 return do_shared_fault(vmf); 3356 else
3357 ret = do_shared_fault(vmf);
3358
3359 /* preallocated pagetable is unused: free it */
3360 if (vmf->prealloc_pte) {
3361 pte_free(vma->vm_mm, vmf->prealloc_pte);
3362 vmf->prealloc_pte = 0;
3363 }
3364 return ret;
3372} 3365}
3373 3366
3374static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, 3367static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
diff --git a/mm/workingset.c b/mm/workingset.c
index 241fa5d6b3b2..abb58ffa3c64 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -473,7 +473,8 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
473 if (WARN_ON_ONCE(node->exceptional)) 473 if (WARN_ON_ONCE(node->exceptional))
474 goto out_invalid; 474 goto out_invalid;
475 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM); 475 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM);
476 __radix_tree_delete_node(&mapping->page_tree, node); 476 __radix_tree_delete_node(&mapping->page_tree, node,
477 workingset_update_node, mapping);
477 478
478out_invalid: 479out_invalid:
479 spin_unlock(&mapping->tree_lock); 480 spin_unlock(&mapping->tree_lock);
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 019557d0a11d..09cfe87f0a44 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1059,7 +1059,9 @@ static void __exit lane_module_cleanup(void)
1059{ 1059{
1060 int i; 1060 int i;
1061 1061
1062#ifdef CONFIG_PROC_FS
1062 remove_proc_entry("lec", atm_proc_root); 1063 remove_proc_entry("lec", atm_proc_root);
1064#endif
1063 1065
1064 deregister_atm_ioctl(&lane_ioctl_ops); 1066 deregister_atm_ioctl(&lane_ioctl_ops);
1065 1067
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 8e0c0635ee97..fb55327dcfea 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
75 struct nlattr *nla; 75 struct nlattr *nla;
76 struct sk_buff *skb; 76 struct sk_buff *skb;
77 unsigned long flags; 77 unsigned long flags;
78 void *msg_header;
78 79
79 al = sizeof(struct net_dm_alert_msg); 80 al = sizeof(struct net_dm_alert_msg);
80 al += dm_hit_limit * sizeof(struct net_dm_drop_point); 81 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
@@ -82,21 +83,41 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
82 83
83 skb = genlmsg_new(al, GFP_KERNEL); 84 skb = genlmsg_new(al, GFP_KERNEL);
84 85
85 if (skb) { 86 if (!skb)
86 genlmsg_put(skb, 0, 0, &net_drop_monitor_family, 87 goto err;
87 0, NET_DM_CMD_ALERT); 88
88 nla = nla_reserve(skb, NLA_UNSPEC, 89 msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
89 sizeof(struct net_dm_alert_msg)); 90 0, NET_DM_CMD_ALERT);
90 msg = nla_data(nla); 91 if (!msg_header) {
91 memset(msg, 0, al); 92 nlmsg_free(skb);
92 } else { 93 skb = NULL;
93 mod_timer(&data->send_timer, jiffies + HZ / 10); 94 goto err;
95 }
96 nla = nla_reserve(skb, NLA_UNSPEC,
97 sizeof(struct net_dm_alert_msg));
98 if (!nla) {
99 nlmsg_free(skb);
100 skb = NULL;
101 goto err;
94 } 102 }
103 msg = nla_data(nla);
104 memset(msg, 0, al);
105 goto out;
95 106
107err:
108 mod_timer(&data->send_timer, jiffies + HZ / 10);
109out:
96 spin_lock_irqsave(&data->lock, flags); 110 spin_lock_irqsave(&data->lock, flags);
97 swap(data->skb, skb); 111 swap(data->skb, skb);
98 spin_unlock_irqrestore(&data->lock, flags); 112 spin_unlock_irqrestore(&data->lock, flags);
99 113
114 if (skb) {
115 struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
116 struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
117
118 genlmsg_end(skb, genlmsg_data(gnlh));
119 }
120
100 return skb; 121 return skb;
101} 122}
102 123
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index d6447dc10371..fe4e1531976c 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -468,8 +468,9 @@ ip_proto_again:
468 if (hdr->flags & GRE_ACK) 468 if (hdr->flags & GRE_ACK)
469 offset += sizeof(((struct pptp_gre_header *)0)->ack); 469 offset += sizeof(((struct pptp_gre_header *)0)->ack);
470 470
471 ppp_hdr = skb_header_pointer(skb, nhoff + offset, 471 ppp_hdr = __skb_header_pointer(skb, nhoff + offset,
472 sizeof(_ppp_hdr), _ppp_hdr); 472 sizeof(_ppp_hdr),
473 data, hlen, _ppp_hdr);
473 if (!ppp_hdr) 474 if (!ppp_hdr)
474 goto out_bad; 475 goto out_bad;
475 476
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 18b5aae99bec..75e3ea7bda08 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3898,6 +3898,9 @@ static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
3898 u32 filter_mask; 3898 u32 filter_mask;
3899 int err; 3899 int err;
3900 3900
3901 if (nlmsg_len(nlh) < sizeof(*ifsm))
3902 return -EINVAL;
3903
3901 ifsm = nlmsg_data(nlh); 3904 ifsm = nlmsg_data(nlh);
3902 if (ifsm->ifindex > 0) 3905 if (ifsm->ifindex > 0)
3903 dev = __dev_get_by_index(net, ifsm->ifindex); 3906 dev = __dev_get_by_index(net, ifsm->ifindex);
@@ -3947,6 +3950,9 @@ static int rtnl_stats_dump(struct sk_buff *skb, struct netlink_callback *cb)
3947 3950
3948 cb->seq = net->dev_base_seq; 3951 cb->seq = net->dev_base_seq;
3949 3952
3953 if (nlmsg_len(cb->nlh) < sizeof(*ifsm))
3954 return -EINVAL;
3955
3950 ifsm = nlmsg_data(cb->nlh); 3956 ifsm = nlmsg_data(cb->nlh);
3951 filter_mask = ifsm->filter_mask; 3957 filter_mask = ifsm->filter_mask;
3952 if (!filter_mask) 3958 if (!filter_mask)
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 3ff8938893ec..eae0332b0e8c 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -85,7 +85,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
85 if (tb) 85 if (tb)
86 return tb; 86 return tb;
87 87
88 if (id == RT_TABLE_LOCAL) 88 if (id == RT_TABLE_LOCAL && !net->ipv4.fib_has_custom_rules)
89 alias = fib_new_table(net, RT_TABLE_MAIN); 89 alias = fib_new_table(net, RT_TABLE_MAIN);
90 90
91 tb = fib_trie_table(id, alias); 91 tb = fib_trie_table(id, alias);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 68d622133f53..5b15459955f8 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -219,9 +219,14 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
219static void igmp_gq_start_timer(struct in_device *in_dev) 219static void igmp_gq_start_timer(struct in_device *in_dev)
220{ 220{
221 int tv = prandom_u32() % in_dev->mr_maxdelay; 221 int tv = prandom_u32() % in_dev->mr_maxdelay;
222 unsigned long exp = jiffies + tv + 2;
223
224 if (in_dev->mr_gq_running &&
225 time_after_eq(exp, (in_dev->mr_gq_timer).expires))
226 return;
222 227
223 in_dev->mr_gq_running = 1; 228 in_dev->mr_gq_running = 1;
224 if (!mod_timer(&in_dev->mr_gq_timer, jiffies+tv+2)) 229 if (!mod_timer(&in_dev->mr_gq_timer, exp))
225 in_dev_hold(in_dev); 230 in_dev_hold(in_dev);
226} 231}
227 232
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 57e1405e8282..53ae0c6315ad 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1225,8 +1225,14 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1225 * which has interface index (iif) as the first member of the 1225 * which has interface index (iif) as the first member of the
1226 * underlying inet{6}_skb_parm struct. This code then overlays 1226 * underlying inet{6}_skb_parm struct. This code then overlays
1227 * PKTINFO_SKB_CB and in_pktinfo also has iif as the first 1227 * PKTINFO_SKB_CB and in_pktinfo also has iif as the first
1228 * element so the iif is picked up from the prior IPCB 1228 * element so the iif is picked up from the prior IPCB. If iif
1229 * is the loopback interface, then return the sending interface
1230 * (e.g., process binds socket to eth0 for Tx which is
1231 * redirected to loopback in the rtable/dst).
1229 */ 1232 */
1233 if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
1234 pktinfo->ipi_ifindex = inet_iif(skb);
1235
1230 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); 1236 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1231 } else { 1237 } else {
1232 pktinfo->ipi_ifindex = 0; 1238 pktinfo->ipi_ifindex = 0;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a82a11747b3f..0fcac8e7a2b2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1914,7 +1914,8 @@ local_input:
1914 } 1914 }
1915 } 1915 }
1916 1916
1917 rth = rt_dst_alloc(net->loopback_dev, flags | RTCF_LOCAL, res.type, 1917 rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,
1918 flags | RTCF_LOCAL, res.type,
1918 IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache); 1919 IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache);
1919 if (!rth) 1920 if (!rth)
1920 goto e_nobufs; 1921 goto e_nobufs;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 70d0de404197..38122d04fadc 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1373,7 +1373,7 @@ emsgsize:
1373 */ 1373 */
1374 1374
1375 cork->length += length; 1375 cork->length += length;
1376 if (((length > mtu) || 1376 if ((((length + fragheaderlen) > mtu) ||
1377 (skb && skb_is_gso(skb))) && 1377 (skb && skb_is_gso(skb))) &&
1378 (sk->sk_protocol == IPPROTO_UDP) && 1378 (sk->sk_protocol == IPPROTO_UDP) &&
1379 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && 1379 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 8938b6ba57a0..3d73278b86ca 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -47,7 +47,8 @@ static inline struct l2tp_ip_sock *l2tp_ip_sk(const struct sock *sk)
47 return (struct l2tp_ip_sock *)sk; 47 return (struct l2tp_ip_sock *)sk;
48} 48}
49 49
50static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id) 50static struct sock *__l2tp_ip_bind_lookup(const struct net *net, __be32 laddr,
51 __be32 raddr, int dif, u32 tunnel_id)
51{ 52{
52 struct sock *sk; 53 struct sock *sk;
53 54
@@ -61,6 +62,7 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif
61 if ((l2tp->conn_id == tunnel_id) && 62 if ((l2tp->conn_id == tunnel_id) &&
62 net_eq(sock_net(sk), net) && 63 net_eq(sock_net(sk), net) &&
63 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && 64 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
65 (!inet->inet_daddr || !raddr || inet->inet_daddr == raddr) &&
64 (!sk->sk_bound_dev_if || !dif || 66 (!sk->sk_bound_dev_if || !dif ||
65 sk->sk_bound_dev_if == dif)) 67 sk->sk_bound_dev_if == dif))
66 goto found; 68 goto found;
@@ -71,15 +73,6 @@ found:
71 return sk; 73 return sk;
72} 74}
73 75
74static inline struct sock *l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id)
75{
76 struct sock *sk = __l2tp_ip_bind_lookup(net, laddr, dif, tunnel_id);
77 if (sk)
78 sock_hold(sk);
79
80 return sk;
81}
82
83/* When processing receive frames, there are two cases to 76/* When processing receive frames, there are two cases to
84 * consider. Data frames consist of a non-zero session-id and an 77 * consider. Data frames consist of a non-zero session-id and an
85 * optional cookie. Control frames consist of a regular L2TP header 78 * optional cookie. Control frames consist of a regular L2TP header
@@ -183,8 +176,8 @@ pass_up:
183 struct iphdr *iph = (struct iphdr *) skb_network_header(skb); 176 struct iphdr *iph = (struct iphdr *) skb_network_header(skb);
184 177
185 read_lock_bh(&l2tp_ip_lock); 178 read_lock_bh(&l2tp_ip_lock);
186 sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb), 179 sk = __l2tp_ip_bind_lookup(net, iph->daddr, iph->saddr,
187 tunnel_id); 180 inet_iif(skb), tunnel_id);
188 if (!sk) { 181 if (!sk) {
189 read_unlock_bh(&l2tp_ip_lock); 182 read_unlock_bh(&l2tp_ip_lock);
190 goto discard; 183 goto discard;
@@ -280,7 +273,7 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
280 inet->inet_saddr = 0; /* Use device */ 273 inet->inet_saddr = 0; /* Use device */
281 274
282 write_lock_bh(&l2tp_ip_lock); 275 write_lock_bh(&l2tp_ip_lock);
283 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, 276 if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, 0,
284 sk->sk_bound_dev_if, addr->l2tp_conn_id)) { 277 sk->sk_bound_dev_if, addr->l2tp_conn_id)) {
285 write_unlock_bh(&l2tp_ip_lock); 278 write_unlock_bh(&l2tp_ip_lock);
286 ret = -EADDRINUSE; 279 ret = -EADDRINUSE;
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index f092ac441fdd..331ccf5a7bad 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -59,12 +59,14 @@ static inline struct l2tp_ip6_sock *l2tp_ip6_sk(const struct sock *sk)
59 59
60static struct sock *__l2tp_ip6_bind_lookup(struct net *net, 60static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
61 struct in6_addr *laddr, 61 struct in6_addr *laddr,
62 const struct in6_addr *raddr,
62 int dif, u32 tunnel_id) 63 int dif, u32 tunnel_id)
63{ 64{
64 struct sock *sk; 65 struct sock *sk;
65 66
66 sk_for_each_bound(sk, &l2tp_ip6_bind_table) { 67 sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
67 const struct in6_addr *addr = inet6_rcv_saddr(sk); 68 const struct in6_addr *sk_laddr = inet6_rcv_saddr(sk);
69 const struct in6_addr *sk_raddr = &sk->sk_v6_daddr;
68 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk); 70 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);
69 71
70 if (l2tp == NULL) 72 if (l2tp == NULL)
@@ -72,7 +74,8 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
72 74
73 if ((l2tp->conn_id == tunnel_id) && 75 if ((l2tp->conn_id == tunnel_id) &&
74 net_eq(sock_net(sk), net) && 76 net_eq(sock_net(sk), net) &&
75 (!addr || ipv6_addr_equal(addr, laddr)) && 77 (!sk_laddr || ipv6_addr_any(sk_laddr) || ipv6_addr_equal(sk_laddr, laddr)) &&
78 (!raddr || ipv6_addr_any(sk_raddr) || ipv6_addr_equal(sk_raddr, raddr)) &&
76 (!sk->sk_bound_dev_if || !dif || 79 (!sk->sk_bound_dev_if || !dif ||
77 sk->sk_bound_dev_if == dif)) 80 sk->sk_bound_dev_if == dif))
78 goto found; 81 goto found;
@@ -83,17 +86,6 @@ found:
83 return sk; 86 return sk;
84} 87}
85 88
86static inline struct sock *l2tp_ip6_bind_lookup(struct net *net,
87 struct in6_addr *laddr,
88 int dif, u32 tunnel_id)
89{
90 struct sock *sk = __l2tp_ip6_bind_lookup(net, laddr, dif, tunnel_id);
91 if (sk)
92 sock_hold(sk);
93
94 return sk;
95}
96
97/* When processing receive frames, there are two cases to 89/* When processing receive frames, there are two cases to
98 * consider. Data frames consist of a non-zero session-id and an 90 * consider. Data frames consist of a non-zero session-id and an
99 * optional cookie. Control frames consist of a regular L2TP header 91 * optional cookie. Control frames consist of a regular L2TP header
@@ -197,8 +189,8 @@ pass_up:
197 struct ipv6hdr *iph = ipv6_hdr(skb); 189 struct ipv6hdr *iph = ipv6_hdr(skb);
198 190
199 read_lock_bh(&l2tp_ip6_lock); 191 read_lock_bh(&l2tp_ip6_lock);
200 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb), 192 sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
201 tunnel_id); 193 inet6_iif(skb), tunnel_id);
202 if (!sk) { 194 if (!sk) {
203 read_unlock_bh(&l2tp_ip6_lock); 195 read_unlock_bh(&l2tp_ip6_lock);
204 goto discard; 196 goto discard;
@@ -330,7 +322,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
330 rcu_read_unlock(); 322 rcu_read_unlock();
331 323
332 write_lock_bh(&l2tp_ip6_lock); 324 write_lock_bh(&l2tp_ip6_lock);
333 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if, 325 if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, NULL, bound_dev_if,
334 addr->l2tp_conn_id)) { 326 addr->l2tp_conn_id)) {
335 write_unlock_bh(&l2tp_ip6_lock); 327 write_unlock_bh(&l2tp_ip6_lock);
336 err = -EADDRINUSE; 328 err = -EADDRINUSE;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2c21b7039136..0d8b716e509e 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3287,7 +3287,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
3287 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); 3287 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
3288 int hw_headroom = sdata->local->hw.extra_tx_headroom; 3288 int hw_headroom = sdata->local->hw.extra_tx_headroom;
3289 struct ethhdr eth; 3289 struct ethhdr eth;
3290 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 3290 struct ieee80211_tx_info *info;
3291 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; 3291 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
3292 struct ieee80211_tx_data tx; 3292 struct ieee80211_tx_data tx;
3293 ieee80211_tx_result r; 3293 ieee80211_tx_result r;
@@ -3351,6 +3351,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
3351 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); 3351 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN);
3352 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); 3352 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN);
3353 3353
3354 info = IEEE80211_SKB_CB(skb);
3354 memset(info, 0, sizeof(*info)); 3355 memset(info, 0, sizeof(*info));
3355 info->band = fast_tx->band; 3356 info->band = fast_tx->band;
3356 info->control.vif = &sdata->vif; 3357 info->control.vif = &sdata->vif;
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 333f8e268431..970db7a41684 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -153,10 +153,14 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
153 153
154 switch (ip_tunnel_info_af(info)) { 154 switch (ip_tunnel_info_af(info)) {
155 case AF_INET: 155 case AF_INET:
156 skb_key.enc_control.addr_type =
157 FLOW_DISSECTOR_KEY_IPV4_ADDRS;
156 skb_key.enc_ipv4.src = key->u.ipv4.src; 158 skb_key.enc_ipv4.src = key->u.ipv4.src;
157 skb_key.enc_ipv4.dst = key->u.ipv4.dst; 159 skb_key.enc_ipv4.dst = key->u.ipv4.dst;
158 break; 160 break;
159 case AF_INET6: 161 case AF_INET6:
162 skb_key.enc_control.addr_type =
163 FLOW_DISSECTOR_KEY_IPV6_ADDRS;
160 skb_key.enc_ipv6.src = key->u.ipv6.src; 164 skb_key.enc_ipv6.src = key->u.ipv6.src;
161 skb_key.enc_ipv6.dst = key->u.ipv6.dst; 165 skb_key.enc_ipv6.dst = key->u.ipv6.dst;
162 break; 166 break;
diff --git a/net/socket.c b/net/socket.c
index 8487bf136e5c..a8c2307590b8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -537,7 +537,7 @@ int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)
537{ 537{
538 int err = simple_setattr(dentry, iattr); 538 int err = simple_setattr(dentry, iattr);
539 539
540 if (!err) { 540 if (!err && (iattr->ia_valid & ATTR_UID)) {
541 struct socket *sock = SOCKET_I(d_inode(dentry)); 541 struct socket *sock = SOCKET_I(d_inode(dentry));
542 542
543 sock->sk->sk_uid = iattr->ia_uid; 543 sock->sk->sk_uid = iattr->ia_uid;
diff --git a/samples/Kconfig b/samples/Kconfig
index a6d2a43bbf2e..b124f62ed6cb 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -105,4 +105,11 @@ config SAMPLE_BLACKFIN_GPTIMERS
105 help 105 help
106 Build samples of blackfin gptimers sample module. 106 Build samples of blackfin gptimers sample module.
107 107
108config SAMPLE_VFIO_MDEV_MTTY
109 tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
110 depends on VFIO_MDEV_DEVICE && m
111 help
112 Build a virtual tty sample driver for use as a VFIO
113 mediated device
114
108endif # SAMPLES 115endif # SAMPLES
diff --git a/samples/Makefile b/samples/Makefile
index e17d66d77f09..86a137e451d9 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -2,4 +2,5 @@
2 2
3obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \ 3obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \
4 hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \ 4 hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
5 configfs/ connector/ v4l/ trace_printk/ blackfin/ 5 configfs/ connector/ v4l/ trace_printk/ blackfin/ \
6 vfio-mdev/
diff --git a/samples/vfio-mdev/Makefile b/samples/vfio-mdev/Makefile
index a932edbe38eb..cbbd868a50a8 100644
--- a/samples/vfio-mdev/Makefile
+++ b/samples/vfio-mdev/Makefile
@@ -1,13 +1 @@
1# obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o
2# Makefile for mtty.c file
3#
4KERNEL_DIR:=/lib/modules/$(shell uname -r)/build
5
6obj-m:=mtty.o
7
8modules clean modules_install:
9 $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) $@
10
11default: modules
12
13module: modules
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 6b633a4ea333..1fc57a5093a7 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -164,7 +164,7 @@ static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid)
164 struct mdev_state *mds; 164 struct mdev_state *mds;
165 165
166 list_for_each_entry(mds, &mdev_devices_list, next) { 166 list_for_each_entry(mds, &mdev_devices_list, next) {
167 if (uuid_le_cmp(mds->mdev->uuid, uuid) == 0) 167 if (uuid_le_cmp(mdev_uuid(mds->mdev), uuid) == 0)
168 return mds; 168 return mds;
169 } 169 }
170 170
@@ -341,7 +341,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
341 pr_err("Serial port %d: Fifo level trigger\n", 341 pr_err("Serial port %d: Fifo level trigger\n",
342 index); 342 index);
343#endif 343#endif
344 mtty_trigger_interrupt(mdev_state->mdev->uuid); 344 mtty_trigger_interrupt(
345 mdev_uuid(mdev_state->mdev));
345 } 346 }
346 } else { 347 } else {
347#if defined(DEBUG_INTR) 348#if defined(DEBUG_INTR)
@@ -355,7 +356,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
355 */ 356 */
356 if (mdev_state->s[index].uart_reg[UART_IER] & 357 if (mdev_state->s[index].uart_reg[UART_IER] &
357 UART_IER_RLSI) 358 UART_IER_RLSI)
358 mtty_trigger_interrupt(mdev_state->mdev->uuid); 359 mtty_trigger_interrupt(
360 mdev_uuid(mdev_state->mdev));
359 } 361 }
360 mutex_unlock(&mdev_state->rxtx_lock); 362 mutex_unlock(&mdev_state->rxtx_lock);
361 break; 363 break;
@@ -374,7 +376,8 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
374 pr_err("Serial port %d: IER_THRI write\n", 376 pr_err("Serial port %d: IER_THRI write\n",
375 index); 377 index);
376#endif 378#endif
377 mtty_trigger_interrupt(mdev_state->mdev->uuid); 379 mtty_trigger_interrupt(
380 mdev_uuid(mdev_state->mdev));
378 } 381 }
379 382
380 mutex_unlock(&mdev_state->rxtx_lock); 383 mutex_unlock(&mdev_state->rxtx_lock);
@@ -445,7 +448,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
445#if defined(DEBUG_INTR) 448#if defined(DEBUG_INTR)
446 pr_err("Serial port %d: MCR_OUT2 write\n", index); 449 pr_err("Serial port %d: MCR_OUT2 write\n", index);
447#endif 450#endif
448 mtty_trigger_interrupt(mdev_state->mdev->uuid); 451 mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev));
449 } 452 }
450 453
451 if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) && 454 if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) &&
@@ -453,7 +456,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
453#if defined(DEBUG_INTR) 456#if defined(DEBUG_INTR)
454 pr_err("Serial port %d: MCR RTS/DTR write\n", index); 457 pr_err("Serial port %d: MCR RTS/DTR write\n", index);
455#endif 458#endif
456 mtty_trigger_interrupt(mdev_state->mdev->uuid); 459 mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev));
457 } 460 }
458 break; 461 break;
459 462
@@ -504,7 +507,8 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
504#endif 507#endif
505 if (mdev_state->s[index].uart_reg[UART_IER] & 508 if (mdev_state->s[index].uart_reg[UART_IER] &
506 UART_IER_THRI) 509 UART_IER_THRI)
507 mtty_trigger_interrupt(mdev_state->mdev->uuid); 510 mtty_trigger_interrupt(
511 mdev_uuid(mdev_state->mdev));
508 } 512 }
509 mutex_unlock(&mdev_state->rxtx_lock); 513 mutex_unlock(&mdev_state->rxtx_lock);
510 514
@@ -734,7 +738,7 @@ int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
734 738
735 for (i = 0; i < 2; i++) { 739 for (i = 0; i < 2; i++) {
736 snprintf(name, MTTY_STRING_LEN, "%s-%d", 740 snprintf(name, MTTY_STRING_LEN, "%s-%d",
737 dev_driver_string(mdev->parent->dev), i + 1); 741 dev_driver_string(mdev_parent_dev(mdev)), i + 1);
738 if (!strcmp(kobj->name, name)) { 742 if (!strcmp(kobj->name, name)) {
739 nr_ports = i + 1; 743 nr_ports = i + 1;
740 break; 744 break;
@@ -1298,10 +1302,8 @@ static ssize_t
1298sample_mdev_dev_show(struct device *dev, struct device_attribute *attr, 1302sample_mdev_dev_show(struct device *dev, struct device_attribute *attr,
1299 char *buf) 1303 char *buf)
1300{ 1304{
1301 struct mdev_device *mdev = to_mdev_device(dev); 1305 if (mdev_from_dev(dev))
1302 1306 return sprintf(buf, "This is MDEV %s\n", dev_name(dev));
1303 if (mdev)
1304 return sprintf(buf, "This is MDEV %s\n", dev_name(&mdev->dev));
1305 1307
1306 return sprintf(buf, "\n"); 1308 return sprintf(buf, "\n");
1307} 1309}
@@ -1402,7 +1404,7 @@ struct attribute_group *mdev_type_groups[] = {
1402 NULL, 1404 NULL,
1403}; 1405};
1404 1406
1405struct parent_ops mdev_fops = { 1407struct mdev_parent_ops mdev_fops = {
1406 .owner = THIS_MODULE, 1408 .owner = THIS_MODULE,
1407 .dev_attr_groups = mtty_dev_groups, 1409 .dev_attr_groups = mtty_dev_groups,
1408 .mdev_attr_groups = mdev_dev_groups, 1410 .mdev_attr_groups = mdev_dev_groups,
@@ -1447,6 +1449,7 @@ static int __init mtty_dev_init(void)
1447 1449
1448 if (IS_ERR(mtty_dev.vd_class)) { 1450 if (IS_ERR(mtty_dev.vd_class)) {
1449 pr_err("Error: failed to register mtty_dev class\n"); 1451 pr_err("Error: failed to register mtty_dev class\n");
1452 ret = PTR_ERR(mtty_dev.vd_class);
1450 goto failed1; 1453 goto failed1;
1451 } 1454 }
1452 1455
@@ -1458,7 +1461,8 @@ static int __init mtty_dev_init(void)
1458 if (ret) 1461 if (ret)
1459 goto failed2; 1462 goto failed2;
1460 1463
1461 if (mdev_register_device(&mtty_dev.dev, &mdev_fops) != 0) 1464 ret = mdev_register_device(&mtty_dev.dev, &mdev_fops);
1465 if (ret)
1462 goto failed3; 1466 goto failed3;
1463 1467
1464 mutex_init(&mdev_list_lock); 1468 mutex_init(&mdev_list_lock);
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 950fd2e64bb7..12262c0cc691 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -39,6 +39,9 @@
39#include "hash-map.h" 39#include "hash-map.h"
40#endif 40#endif
41 41
42#if BUILDING_GCC_VERSION >= 7000
43#include "memmodel.h"
44#endif
42#include "emit-rtl.h" 45#include "emit-rtl.h"
43#include "debug.h" 46#include "debug.h"
44#include "target.h" 47#include "target.h"
@@ -91,6 +94,9 @@
91#include "tree-ssa-alias.h" 94#include "tree-ssa-alias.h"
92#include "tree-ssa.h" 95#include "tree-ssa.h"
93#include "stringpool.h" 96#include "stringpool.h"
97#if BUILDING_GCC_VERSION >= 7000
98#include "tree-vrp.h"
99#endif
94#include "tree-ssanames.h" 100#include "tree-ssanames.h"
95#include "print-tree.h" 101#include "print-tree.h"
96#include "tree-eh.h" 102#include "tree-eh.h"
@@ -287,6 +293,22 @@ static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct c
287 return NULL; 293 return NULL;
288} 294}
289 295
296static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
297{
298 cgraph_node_ptr alias;
299
300 if (callback(node, data))
301 return true;
302
303 for (alias = node->same_body; alias; alias = alias->next) {
304 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
305 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
306 return true;
307 }
308
309 return false;
310}
311
290#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ 312#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
291 for ((node) = cgraph_first_function_with_gimple_body(); (node); \ 313 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
292 (node) = cgraph_next_function_with_gimple_body(node)) 314 (node) = cgraph_next_function_with_gimple_body(node))
@@ -399,6 +421,7 @@ typedef union gimple_statement_d gassign;
399typedef union gimple_statement_d gcall; 421typedef union gimple_statement_d gcall;
400typedef union gimple_statement_d gcond; 422typedef union gimple_statement_d gcond;
401typedef union gimple_statement_d gdebug; 423typedef union gimple_statement_d gdebug;
424typedef union gimple_statement_d ggoto;
402typedef union gimple_statement_d gphi; 425typedef union gimple_statement_d gphi;
403typedef union gimple_statement_d greturn; 426typedef union gimple_statement_d greturn;
404 427
@@ -452,6 +475,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
452 return stmt; 475 return stmt;
453} 476}
454 477
478static inline ggoto *as_a_ggoto(gimple stmt)
479{
480 return stmt;
481}
482
483static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
484{
485 return stmt;
486}
487
455static inline gphi *as_a_gphi(gimple stmt) 488static inline gphi *as_a_gphi(gimple stmt)
456{ 489{
457 return stmt; 490 return stmt;
@@ -496,6 +529,14 @@ static inline const greturn *as_a_const_greturn(const_gimple stmt)
496 529
497typedef struct rtx_def rtx_insn; 530typedef struct rtx_def rtx_insn;
498 531
532static inline const char *get_decl_section_name(const_tree decl)
533{
534 if (DECL_SECTION_NAME(decl) == NULL_TREE)
535 return NULL;
536
537 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
538}
539
499static inline void set_decl_section_name(tree node, const char *value) 540static inline void set_decl_section_name(tree node, const char *value)
500{ 541{
501 if (value) 542 if (value)
@@ -511,6 +552,7 @@ typedef struct gimple_statement_base gassign;
511typedef struct gimple_statement_call gcall; 552typedef struct gimple_statement_call gcall;
512typedef struct gimple_statement_base gcond; 553typedef struct gimple_statement_base gcond;
513typedef struct gimple_statement_base gdebug; 554typedef struct gimple_statement_base gdebug;
555typedef struct gimple_statement_base ggoto;
514typedef struct gimple_statement_phi gphi; 556typedef struct gimple_statement_phi gphi;
515typedef struct gimple_statement_base greturn; 557typedef struct gimple_statement_base greturn;
516 558
@@ -564,6 +606,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
564 return stmt; 606 return stmt;
565} 607}
566 608
609static inline ggoto *as_a_ggoto(gimple stmt)
610{
611 return stmt;
612}
613
614static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
615{
616 return stmt;
617}
618
567static inline gphi *as_a_gphi(gimple stmt) 619static inline gphi *as_a_gphi(gimple stmt)
568{ 620{
569 return as_a<gphi>(stmt); 621 return as_a<gphi>(stmt);
@@ -611,6 +663,11 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
611 663
612#define INSN_DELETED_P(insn) (insn)->deleted() 664#define INSN_DELETED_P(insn) (insn)->deleted()
613 665
666static inline const char *get_decl_section_name(const_tree decl)
667{
668 return DECL_SECTION_NAME(decl);
669}
670
614/* symtab/cgraph related */ 671/* symtab/cgraph related */
615#define debug_cgraph_node(node) (node)->debug() 672#define debug_cgraph_node(node) (node)->debug()
616#define cgraph_get_node(decl) cgraph_node::get(decl) 673#define cgraph_get_node(decl) cgraph_node::get(decl)
@@ -619,6 +676,7 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
619#define cgraph_n_nodes symtab->cgraph_count 676#define cgraph_n_nodes symtab->cgraph_count
620#define cgraph_max_uid symtab->cgraph_max_uid 677#define cgraph_max_uid symtab->cgraph_max_uid
621#define varpool_get_node(decl) varpool_node::get(decl) 678#define varpool_get_node(decl) varpool_node::get(decl)
679#define dump_varpool_node(file, node) (node)->dump(file)
622 680
623#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ 681#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
624 (caller)->create_edge((callee), (call_stmt), (count), (freq)) 682 (caller)->create_edge((callee), (call_stmt), (count), (freq))
@@ -674,6 +732,11 @@ static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
674 return node->get_alias_target(); 732 return node->get_alias_target();
675} 733}
676 734
735static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
736{
737 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
738}
739
677static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) 740static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
678{ 741{
679 return symtab->add_cgraph_insertion_hook(hook, data); 742 return symtab->add_cgraph_insertion_hook(hook, data);
@@ -731,6 +794,13 @@ static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree l
731 794
732template <> 795template <>
733template <> 796template <>
797inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
798{
799 return gs->code == GIMPLE_GOTO;
800}
801
802template <>
803template <>
734inline bool is_a_helper<const greturn *>::test(const_gimple gs) 804inline bool is_a_helper<const greturn *>::test(const_gimple gs)
735{ 805{
736 return gs->code == GIMPLE_RETURN; 806 return gs->code == GIMPLE_RETURN;
@@ -766,6 +836,16 @@ static inline const gcall *as_a_const_gcall(const_gimple stmt)
766 return as_a<const gcall *>(stmt); 836 return as_a<const gcall *>(stmt);
767} 837}
768 838
839static inline ggoto *as_a_ggoto(gimple stmt)
840{
841 return as_a<ggoto *>(stmt);
842}
843
844static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
845{
846 return as_a<const ggoto *>(stmt);
847}
848
769static inline gphi *as_a_gphi(gimple stmt) 849static inline gphi *as_a_gphi(gimple stmt)
770{ 850{
771 return as_a<gphi *>(stmt); 851 return as_a<gphi *>(stmt);
@@ -828,4 +908,9 @@ static inline void debug_gimple_stmt(const_gimple s)
828#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) 908#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
829#endif 909#endif
830 910
911#if BUILDING_GCC_VERSION >= 7000
912#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
913 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
914#endif
915
831#endif 916#endif
diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c
index 12541126575b..8ff203ad4809 100644
--- a/scripts/gcc-plugins/latent_entropy_plugin.c
+++ b/scripts/gcc-plugins/latent_entropy_plugin.c
@@ -328,9 +328,9 @@ static enum tree_code get_op(tree *rhs)
328 op = LROTATE_EXPR; 328 op = LROTATE_EXPR;
329 /* 329 /*
330 * This code limits the value of random_const to 330 * This code limits the value of random_const to
331 * the size of a wide int for the rotation 331 * the size of a long for the rotation
332 */ 332 */
333 random_const &= HOST_BITS_PER_WIDE_INT - 1; 333 random_const %= TYPE_PRECISION(long_unsigned_type_node);
334 break; 334 break;
335 } 335 }
336 336
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index efe3a44658d5..4576f987a4a5 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -561,9 +561,9 @@ static void nau8825_xtalk_prepare(struct nau8825 *nau8825)
561 nau8825_xtalk_backup(nau8825); 561 nau8825_xtalk_backup(nau8825);
562 /* Config IIS as master to output signal by codec */ 562 /* Config IIS as master to output signal by codec */
563 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 563 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
564 NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK | 564 NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
565 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER | 565 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER |
566 (0x2 << NAU8825_I2S_DRV_SFT) | 0x1); 566 (0x2 << NAU8825_I2S_LRC_DIV_SFT) | 0x1);
567 /* Ramp up headphone volume to 0dB to get better performance and 567 /* Ramp up headphone volume to 0dB to get better performance and
568 * avoid pop noise in headphone. 568 * avoid pop noise in headphone.
569 */ 569 */
@@ -657,7 +657,7 @@ static void nau8825_xtalk_clean(struct nau8825 *nau8825)
657 NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN); 657 NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN);
658 /* Recover default value for IIS */ 658 /* Recover default value for IIS */
659 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 659 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
660 NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK | 660 NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
661 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE); 661 NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE);
662 /* Restore value of specific register for cross talk */ 662 /* Restore value of specific register for cross talk */
663 nau8825_xtalk_restore(nau8825); 663 nau8825_xtalk_restore(nau8825);
@@ -2006,7 +2006,8 @@ static void nau8825_fll_apply(struct nau8825 *nau8825,
2006 NAU8825_FLL_INTEGER_MASK, fll_param->fll_int); 2006 NAU8825_FLL_INTEGER_MASK, fll_param->fll_int);
2007 /* FLL pre-scaler */ 2007 /* FLL pre-scaler */
2008 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4, 2008 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4,
2009 NAU8825_FLL_REF_DIV_MASK, fll_param->clk_ref_div); 2009 NAU8825_FLL_REF_DIV_MASK,
2010 fll_param->clk_ref_div << NAU8825_FLL_REF_DIV_SFT);
2010 /* select divided VCO input */ 2011 /* select divided VCO input */
2011 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5, 2012 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,
2012 NAU8825_FLL_CLK_SW_MASK, NAU8825_FLL_CLK_SW_REF); 2013 NAU8825_FLL_CLK_SW_MASK, NAU8825_FLL_CLK_SW_REF);
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 5d1704e73241..514fd13c2f46 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -137,7 +137,8 @@
137#define NAU8825_FLL_CLK_SRC_FS (0x3 << NAU8825_FLL_CLK_SRC_SFT) 137#define NAU8825_FLL_CLK_SRC_FS (0x3 << NAU8825_FLL_CLK_SRC_SFT)
138 138
139/* FLL4 (0x07) */ 139/* FLL4 (0x07) */
140#define NAU8825_FLL_REF_DIV_MASK (0x3 << 10) 140#define NAU8825_FLL_REF_DIV_SFT 10
141#define NAU8825_FLL_REF_DIV_MASK (0x3 << NAU8825_FLL_REF_DIV_SFT)
141 142
142/* FLL5 (0x08) */ 143/* FLL5 (0x08) */
143#define NAU8825_FLL_PDB_DAC_EN (0x1 << 15) 144#define NAU8825_FLL_PDB_DAC_EN (0x1 << 15)
@@ -247,8 +248,8 @@
247 248
248/* I2S_PCM_CTRL2 (0x1d) */ 249/* I2S_PCM_CTRL2 (0x1d) */
249#define NAU8825_I2S_TRISTATE (1 << 15) /* 0 - normal mode, 1 - Hi-Z output */ 250#define NAU8825_I2S_TRISTATE (1 << 15) /* 0 - normal mode, 1 - Hi-Z output */
250#define NAU8825_I2S_DRV_SFT 12 251#define NAU8825_I2S_LRC_DIV_SFT 12
251#define NAU8825_I2S_DRV_MASK (0x3 << NAU8825_I2S_DRV_SFT) 252#define NAU8825_I2S_LRC_DIV_MASK (0x3 << NAU8825_I2S_LRC_DIV_SFT)
252#define NAU8825_I2S_MS_SFT 3 253#define NAU8825_I2S_MS_SFT 3
253#define NAU8825_I2S_MS_MASK (1 << NAU8825_I2S_MS_SFT) 254#define NAU8825_I2S_MS_MASK (1 << NAU8825_I2S_MS_SFT)
254#define NAU8825_I2S_MS_MASTER (1 << NAU8825_I2S_MS_SFT) 255#define NAU8825_I2S_MS_MASTER (1 << NAU8825_I2S_MS_SFT)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 10c2a564a715..1ac96ef9ee20 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3833,6 +3833,9 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3833 } 3833 }
3834 } 3834 }
3835 3835
3836 regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
3837 RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
3838
3836 if (rt5645->pdata.jd_invert) { 3839 if (rt5645->pdata.jd_invert) {
3837 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, 3840 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
3838 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); 3841 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 8877b74b0510..bb94d50052d7 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -126,6 +126,16 @@ static const struct reg_default aic3x_reg[] = {
126 { 108, 0x00 }, { 109, 0x00 }, 126 { 108, 0x00 }, { 109, 0x00 },
127}; 127};
128 128
129static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
130{
131 switch (reg) {
132 case AIC3X_RESET:
133 return true;
134 default:
135 return false;
136 }
137}
138
129static const struct regmap_config aic3x_regmap = { 139static const struct regmap_config aic3x_regmap = {
130 .reg_bits = 8, 140 .reg_bits = 8,
131 .val_bits = 8, 141 .val_bits = 8,
@@ -133,6 +143,9 @@ static const struct regmap_config aic3x_regmap = {
133 .max_register = DAC_ICC_ADJ, 143 .max_register = DAC_ICC_ADJ,
134 .reg_defaults = aic3x_reg, 144 .reg_defaults = aic3x_reg,
135 .num_reg_defaults = ARRAY_SIZE(aic3x_reg), 145 .num_reg_defaults = ARRAY_SIZE(aic3x_reg),
146
147 .volatile_reg = aic3x_volatile_reg,
148
136 .cache_type = REGCACHE_RBTREE, 149 .cache_type = REGCACHE_RBTREE,
137}; 150};
138 151
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 593b7d1aed46..d72ccef9e238 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1551,7 +1551,7 @@ static int wm_adsp_load(struct wm_adsp *dsp)
1551 const struct wmfw_region *region; 1551 const struct wmfw_region *region;
1552 const struct wm_adsp_region *mem; 1552 const struct wm_adsp_region *mem;
1553 const char *region_name; 1553 const char *region_name;
1554 char *file, *text; 1554 char *file, *text = NULL;
1555 struct wm_adsp_buf *buf; 1555 struct wm_adsp_buf *buf;
1556 unsigned int reg; 1556 unsigned int reg;
1557 int regions = 0; 1557 int regions = 0;
@@ -1700,10 +1700,21 @@ static int wm_adsp_load(struct wm_adsp *dsp)
1700 regions, le32_to_cpu(region->len), offset, 1700 regions, le32_to_cpu(region->len), offset,
1701 region_name); 1701 region_name);
1702 1702
1703 if ((pos + le32_to_cpu(region->len) + sizeof(*region)) >
1704 firmware->size) {
1705 adsp_err(dsp,
1706 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
1707 file, regions, region_name,
1708 le32_to_cpu(region->len), firmware->size);
1709 ret = -EINVAL;
1710 goto out_fw;
1711 }
1712
1703 if (text) { 1713 if (text) {
1704 memcpy(text, region->data, le32_to_cpu(region->len)); 1714 memcpy(text, region->data, le32_to_cpu(region->len));
1705 adsp_info(dsp, "%s: %s\n", file, text); 1715 adsp_info(dsp, "%s: %s\n", file, text);
1706 kfree(text); 1716 kfree(text);
1717 text = NULL;
1707 } 1718 }
1708 1719
1709 if (reg) { 1720 if (reg) {
@@ -1748,6 +1759,7 @@ out_fw:
1748 regmap_async_complete(regmap); 1759 regmap_async_complete(regmap);
1749 wm_adsp_buf_free(&buf_list); 1760 wm_adsp_buf_free(&buf_list);
1750 release_firmware(firmware); 1761 release_firmware(firmware);
1762 kfree(text);
1751out: 1763out:
1752 kfree(file); 1764 kfree(file);
1753 1765
@@ -2233,6 +2245,17 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
2233 } 2245 }
2234 2246
2235 if (reg) { 2247 if (reg) {
2248 if ((pos + le32_to_cpu(blk->len) + sizeof(*blk)) >
2249 firmware->size) {
2250 adsp_err(dsp,
2251 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
2252 file, blocks, region_name,
2253 le32_to_cpu(blk->len),
2254 firmware->size);
2255 ret = -EINVAL;
2256 goto out_fw;
2257 }
2258
2236 buf = wm_adsp_buf_alloc(blk->data, 2259 buf = wm_adsp_buf_alloc(blk->data,
2237 le32_to_cpu(blk->len), 2260 le32_to_cpu(blk->len),
2238 &buf_list); 2261 &buf_list);
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 2998954a1c74..bdf8398cbc81 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -681,22 +681,19 @@ static int dw_i2s_probe(struct platform_device *pdev)
681 } 681 }
682 682
683 if (!pdata) { 683 if (!pdata) {
684 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 684 if (irq >= 0) {
685 if (ret == -EPROBE_DEFER) {
686 dev_err(&pdev->dev,
687 "failed to register PCM, deferring probe\n");
688 return ret;
689 } else if (ret) {
690 dev_err(&pdev->dev,
691 "Could not register DMA PCM: %d\n"
692 "falling back to PIO mode\n", ret);
693 ret = dw_pcm_register(pdev); 685 ret = dw_pcm_register(pdev);
694 if (ret) { 686 dev->use_pio = true;
695 dev_err(&pdev->dev, 687 } else {
696 "Could not register PIO PCM: %d\n", 688 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
689 0);
690 dev->use_pio = false;
691 }
692
693 if (ret) {
694 dev_err(&pdev->dev, "could not register pcm: %d\n",
697 ret); 695 ret);
698 goto err_clk_disable; 696 goto err_clk_disable;
699 }
700 } 697 }
701 } 698 }
702 699
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 50349437d961..fde08660b63b 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -224,6 +224,12 @@ struct fsl_ssi_soc_data {
224 * @dbg_stats: Debugging statistics 224 * @dbg_stats: Debugging statistics
225 * 225 *
226 * @soc: SoC specific data 226 * @soc: SoC specific data
227 *
228 * @fifo_watermark: the FIFO watermark setting. Notifies DMA when
229 * there are @fifo_watermark or fewer words in TX fifo or
230 * @fifo_watermark or more empty words in RX fifo.
231 * @dma_maxburst: max number of words to transfer in one go. So far,
232 * this is always the same as fifo_watermark.
227 */ 233 */
228struct fsl_ssi_private { 234struct fsl_ssi_private {
229 struct regmap *regs; 235 struct regmap *regs;
@@ -263,6 +269,9 @@ struct fsl_ssi_private {
263 269
264 const struct fsl_ssi_soc_data *soc; 270 const struct fsl_ssi_soc_data *soc;
265 struct device *dev; 271 struct device *dev;
272
273 u32 fifo_watermark;
274 u32 dma_maxburst;
266}; 275};
267 276
268/* 277/*
@@ -1051,21 +1060,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
1051 regmap_write(regs, CCSR_SSI_SRCR, srcr); 1060 regmap_write(regs, CCSR_SSI_SRCR, srcr);
1052 regmap_write(regs, CCSR_SSI_SCR, scr); 1061 regmap_write(regs, CCSR_SSI_SCR, scr);
1053 1062
1054 /* 1063 wm = ssi_private->fifo_watermark;
1055 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
1056 * use FIFO 1. We program the transmit water to signal a DMA transfer
1057 * if there are only two (or fewer) elements left in the FIFO. Two
1058 * elements equals one frame (left channel, right channel). This value,
1059 * however, depends on the depth of the transmit buffer.
1060 *
1061 * We set the watermark on the same level as the DMA burstsize. For
1062 * fiq it is probably better to use the biggest possible watermark
1063 * size.
1064 */
1065 if (ssi_private->use_dma)
1066 wm = ssi_private->fifo_depth - 2;
1067 else
1068 wm = ssi_private->fifo_depth;
1069 1064
1070 regmap_write(regs, CCSR_SSI_SFCSR, 1065 regmap_write(regs, CCSR_SSI_SFCSR,
1071 CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | 1066 CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
@@ -1373,12 +1368,8 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
1373 dev_dbg(&pdev->dev, "could not get baud clock: %ld\n", 1368 dev_dbg(&pdev->dev, "could not get baud clock: %ld\n",
1374 PTR_ERR(ssi_private->baudclk)); 1369 PTR_ERR(ssi_private->baudclk));
1375 1370
1376 /* 1371 ssi_private->dma_params_tx.maxburst = ssi_private->dma_maxburst;
1377 * We have burstsize be "fifo_depth - 2" to match the SSI 1372 ssi_private->dma_params_rx.maxburst = ssi_private->dma_maxburst;
1378 * watermark setting in fsl_ssi_startup().
1379 */
1380 ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2;
1381 ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2;
1382 ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0; 1373 ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0;
1383 ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0; 1374 ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0;
1384 1375
@@ -1543,6 +1534,47 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1543 /* Older 8610 DTs didn't have the fifo-depth property */ 1534 /* Older 8610 DTs didn't have the fifo-depth property */
1544 ssi_private->fifo_depth = 8; 1535 ssi_private->fifo_depth = 8;
1545 1536
1537 /*
1538 * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
1539 * use FIFO 1 but set the watermark appropriately nontheless.
1540 * We program the transmit water to signal a DMA transfer
1541 * if there are N elements left in the FIFO. For chips with 15-deep
1542 * FIFOs, set watermark to 8. This allows the SSI to operate at a
1543 * high data rate without channel slipping. Behavior is unchanged
1544 * for the older chips with a fifo depth of only 8. A value of 4
1545 * might be appropriate for the older chips, but is left at
1546 * fifo_depth-2 until sombody has a chance to test.
1547 *
1548 * We set the watermark on the same level as the DMA burstsize. For
1549 * fiq it is probably better to use the biggest possible watermark
1550 * size.
1551 */
1552 switch (ssi_private->fifo_depth) {
1553 case 15:
1554 /*
1555 * 2 samples is not enough when running at high data
1556 * rates (like 48kHz @ 16 bits/channel, 16 channels)
1557 * 8 seems to split things evenly and leave enough time
1558 * for the DMA to fill the FIFO before it's over/under
1559 * run.
1560 */
1561 ssi_private->fifo_watermark = 8;
1562 ssi_private->dma_maxburst = 8;
1563 break;
1564 case 8:
1565 default:
1566 /*
1567 * maintain old behavior for older chips.
1568 * Keeping it the same because I don't have an older
1569 * board to test with.
1570 * I suspect this could be changed to be something to
1571 * leave some more space in the fifo.
1572 */
1573 ssi_private->fifo_watermark = ssi_private->fifo_depth - 2;
1574 ssi_private->dma_maxburst = ssi_private->fifo_depth - 2;
1575 break;
1576 }
1577
1546 dev_set_drvdata(&pdev->dev, ssi_private); 1578 dev_set_drvdata(&pdev->dev, ssi_private);
1547 1579
1548 if (ssi_private->soc->imx) { 1580 if (ssi_private->soc->imx) {
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 507a86a5eafe..8d2fb2d6f532 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -142,7 +142,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
142 * for Jack detection and button press 142 * for Jack detection and button press
143 */ 143 */
144 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK, 144 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK,
145 0, 145 48000 * 512,
146 SND_SOC_CLOCK_IN); 146 SND_SOC_CLOCK_IN);
147 if (!ret) { 147 if (!ret) {
148 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk) 148 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk)
@@ -825,10 +825,20 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
825 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && (is_valleyview())) { 825 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && (is_valleyview())) {
826 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 826 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
827 if (IS_ERR(priv->mclk)) { 827 if (IS_ERR(priv->mclk)) {
828 ret_val = PTR_ERR(priv->mclk);
829
828 dev_err(&pdev->dev, 830 dev_err(&pdev->dev,
829 "Failed to get MCLK from pmc_plt_clk_3: %ld\n", 831 "Failed to get MCLK from pmc_plt_clk_3: %d\n",
830 PTR_ERR(priv->mclk)); 832 ret_val);
831 return PTR_ERR(priv->mclk); 833
834 /*
835 * Fall back to bit clock usage for -ENOENT (clock not
836 * available likely due to missing dependencies), bail
837 * for all other errors, including -EPROBE_DEFER
838 */
839 if (ret_val != -ENOENT)
840 return ret_val;
841 byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
832 } 842 }
833 } 843 }
834 844
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 84b5101e6ca6..6c6b63a6b338 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -180,6 +180,9 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
180 snd_pcm_set_sync(substream); 180 snd_pcm_set_sync(substream);
181 181
182 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream); 182 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
183 if (!mconfig)
184 return -EINVAL;
185
183 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps); 186 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
184 187
185 return 0; 188 return 0;
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 8fc3178bc79c..b30bd384c8d3 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -515,6 +515,9 @@ EXPORT_SYMBOL_GPL(skl_sst_init_fw);
515 515
516void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) 516void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
517{ 517{
518
519 if (ctx->dsp->fw)
520 release_firmware(ctx->dsp->fw);
518 skl_clear_module_table(ctx->dsp); 521 skl_clear_module_table(ctx->dsp);
519 skl_freeup_uuid_list(ctx); 522 skl_freeup_uuid_list(ctx);
520 skl_ipc_free(&ctx->ipc); 523 skl_ipc_free(&ctx->ipc);
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 4bd68de76130..99b5b0835c1e 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1030,10 +1030,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
1030 return -ENOMEM; 1030 return -ENOMEM;
1031 1031
1032 ret = snd_ctl_add(card, kctrl); 1032 ret = snd_ctl_add(card, kctrl);
1033 if (ret < 0) { 1033 if (ret < 0)
1034 snd_ctl_free_one(kctrl);
1035 return ret; 1034 return ret;
1036 }
1037 1035
1038 cfg->update = update; 1036 cfg->update = update;
1039 cfg->card = card; 1037 cfg->card = card;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f1901bb1466e..baa1afa41e3d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1748,6 +1748,7 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1748 1748
1749 component->init = aux_dev->init; 1749 component->init = aux_dev->init;
1750 component->auxiliary = 1; 1750 component->auxiliary = 1;
1751 list_add(&component->card_aux_list, &card->aux_comp_list);
1751 1752
1752 return 0; 1753 return 0;
1753 1754
@@ -1758,16 +1759,14 @@ err_defer:
1758 1759
1759static int soc_probe_aux_devices(struct snd_soc_card *card) 1760static int soc_probe_aux_devices(struct snd_soc_card *card)
1760{ 1761{
1761 struct snd_soc_component *comp; 1762 struct snd_soc_component *comp, *tmp;
1762 int order; 1763 int order;
1763 int ret; 1764 int ret;
1764 1765
1765 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 1766 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1766 order++) { 1767 order++) {
1767 list_for_each_entry(comp, &card->component_dev_list, card_list) { 1768 list_for_each_entry_safe(comp, tmp, &card->aux_comp_list,
1768 if (!comp->auxiliary) 1769 card_aux_list) {
1769 continue;
1770
1771 if (comp->driver->probe_order == order) { 1770 if (comp->driver->probe_order == order) {
1772 ret = soc_probe_component(card, comp); 1771 ret = soc_probe_component(card, comp);
1773 if (ret < 0) { 1772 if (ret < 0) {
@@ -1776,6 +1775,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)
1776 comp->name, ret); 1775 comp->name, ret);
1777 return ret; 1776 return ret;
1778 } 1777 }
1778 list_del(&comp->card_aux_list);
1779 } 1779 }
1780 } 1780 }
1781 } 1781 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e7a1eaa2772f..6aba14009c92 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2184,9 +2184,11 @@ static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
2184 break; 2184 break;
2185 case SNDRV_PCM_TRIGGER_STOP: 2185 case SNDRV_PCM_TRIGGER_STOP:
2186 case SNDRV_PCM_TRIGGER_SUSPEND: 2186 case SNDRV_PCM_TRIGGER_SUSPEND:
2187 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2188 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; 2187 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
2189 break; 2188 break;
2189 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2190 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
2191 break;
2190 } 2192 }
2191 2193
2192out: 2194out:
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 65670b2b408c..fbfb1fab88d5 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -514,13 +514,12 @@ static void remove_widget(struct snd_soc_component *comp,
514 == SND_SOC_TPLG_TYPE_MIXER) 514 == SND_SOC_TPLG_TYPE_MIXER)
515 kfree(kcontrol->tlv.p); 515 kfree(kcontrol->tlv.p);
516 516
517 snd_ctl_remove(card, kcontrol);
518
519 /* Private value is used as struct soc_mixer_control 517 /* Private value is used as struct soc_mixer_control
520 * for volume mixers or soc_bytes_ext for bytes 518 * for volume mixers or soc_bytes_ext for bytes
521 * controls. 519 * controls.
522 */ 520 */
523 kfree((void *)kcontrol->private_value); 521 kfree((void *)kcontrol->private_value);
522 snd_ctl_remove(card, kcontrol);
524 } 523 }
525 kfree(w->kcontrol_news); 524 kfree(w->kcontrol_news);
526 } 525 }
diff --git a/usr/Makefile b/usr/Makefile
index 17a513268325..0b87e71c00fc 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -5,8 +5,10 @@
5klibcdirs:; 5klibcdirs:;
6PHONY += klibcdirs 6PHONY += klibcdirs
7 7
8suffix_y = $(CONFIG_INITRAMFS_COMPRESSION) 8suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
9AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)" 9datafile_y = initramfs_data.cpio$(suffix_y)
10AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
11
10 12
11# Generate builtin.o based on initramfs_data.o 13# Generate builtin.o based on initramfs_data.o
12obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o 14obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
@@ -14,7 +16,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
14# initramfs_data.o contains the compressed initramfs_data.cpio image. 16# initramfs_data.o contains the compressed initramfs_data.cpio image.
15# The image is included using .incbin, a dependency which is not 17# The image is included using .incbin, a dependency which is not
16# tracked automatically. 18# tracked automatically.
17$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE 19$(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
18 20
19##### 21#####
20# Generate the initramfs cpio archive 22# Generate the initramfs cpio archive
@@ -38,10 +40,8 @@ endif
38quiet_cmd_initfs = GEN $@ 40quiet_cmd_initfs = GEN $@
39 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) 41 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
40 42
41targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \ 43targets := $(datafile_y)
42 initramfs_data.cpio.lzma initramfs_data.cpio.xz \ 44
43 initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
44 initramfs_data.cpio
45# do not try to update files included in initramfs 45# do not try to update files included in initramfs
46$(deps_initramfs): ; 46$(deps_initramfs): ;
47 47
@@ -51,6 +51,6 @@ $(deps_initramfs): klibcdirs
51# 2) There are changes in which files are included (added or deleted) 51# 2) There are changes in which files are included (added or deleted)
52# 3) If gen_init_cpio are newer than initramfs_data.cpio 52# 3) If gen_init_cpio are newer than initramfs_data.cpio
53# 4) arguments to gen_initramfs.sh changes 53# 4) arguments to gen_initramfs.sh changes
54$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs 54$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
55 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d 55 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
56 $(call if_changed,initfs) 56 $(call if_changed,initfs)