aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-12 03:15:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-12 03:15:26 -0400
commitfc9104d5d7172d2cb6c672abeb964242aa735b34 (patch)
tree87f8aedceff2d578b073d33791e4696a7aba9185
parentab57f86198d6ff20371613d4a02fd4841972a5c0 (diff)
parent9395452b4aab7bc2475ef8935b4a4fb99d778d70 (diff)
Merge 4.8-rc6 into usb-next
We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--.mailmap1
-rw-r--r--Documentation/arm/CCN.txt16
-rw-r--r--Documentation/cpu-freq/cpufreq-stats.txt2
-rw-r--r--Documentation/i2c/slave-interface5
-rw-r--r--MAINTAINERS28
-rw-r--r--Makefile2
-rw-r--r--arch/Kconfig11
-rw-r--r--arch/arm/boot/dts/am335x-baltos.dtsi2
-rw-r--r--arch/arm/boot/dts/am335x-igep0033.dtsi2
-rw-r--r--arch/arm/boot/dts/am335x-phycore-som.dtsi2
-rw-r--r--arch/arm/boot/dts/armada-388-clearfog.dts8
-rw-r--r--arch/arm/boot/dts/exynos5410-odroidxu.dts3
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi2
-rw-r--r--arch/arm/boot/dts/imx6sx-sabreauto.dts2
-rw-r--r--arch/arm/boot/dts/imx7d-sdb.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-ib62x0.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-openrd.dtsi4
-rw-r--r--arch/arm/boot/dts/logicpd-som-lv.dtsi11
-rw-r--r--arch/arm/boot/dts/logicpd-torpedo-som.dtsi1
-rw-r--r--arch/arm/boot/dts/omap3-overo-base.dtsi4
-rw-r--r--arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi2
-rw-r--r--arch/arm/boot/dts/omap3-overo-tobi-common.dtsi2
-rw-r--r--arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi3
-rw-r--r--arch/arm/boot/dts/sun5i-a13.dtsi2
-rw-r--r--arch/arm/boot/dts/tegra114-dalmore.dts2
-rw-r--r--arch/arm/boot/dts/tegra114-roth.dts2
-rw-r--r--arch/arm/boot/dts/tegra114-tn7.dts2
-rw-r--r--arch/arm/boot/dts/tegra124-jetson-tk1.dts4
-rw-r--r--arch/arm/kernel/hyp-stub.S13
-rw-r--r--arch/arm/mach-imx/mach-imx6ul.c1
-rw-r--r--arch/arm/mach-imx/pm-imx6.c4
-rw-r--r--arch/arm/mach-omap2/cm33xx.c6
-rw-r--r--arch/arm/mach-omap2/cminst44xx.c6
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h4
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c2
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c12
-rw-r--r--arch/arm/mach-sa1100/clock.c5
-rw-r--r--arch/arm/mach-sa1100/generic.c4
-rw-r--r--arch/arm/mach-sa1100/generic.h2
-rw-r--r--arch/arm/mm/proc-v7.S1
-rw-r--r--arch/arm64/include/asm/percpu.h8
-rw-r--r--arch/arm64/include/asm/spinlock.h10
-rw-r--r--arch/ia64/include/asm/uaccess.h12
-rw-r--r--arch/powerpc/include/asm/uaccess.h19
-rw-r--r--arch/powerpc/lib/checksum_32.S7
-rw-r--r--arch/powerpc/mm/slb_low.S7
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c18
-rw-r--r--arch/powerpc/platforms/pseries/setup.c2
-rw-r--r--arch/powerpc/sysdev/xics/icp-opal.c12
-rw-r--r--arch/sparc/include/asm/uaccess_32.h9
-rw-r--r--arch/sparc/include/asm/uaccess_64.h7
-rw-r--r--arch/um/kernel/skas/syscall.c10
-rw-r--r--arch/x86/include/asm/uaccess.h4
-rw-r--r--arch/x86/mm/pat.c17
-rw-r--r--arch/x86/um/ptrace_32.c3
-rw-r--r--arch/x86/um/ptrace_64.c4
-rw-r--r--crypto/cryptd.c3
-rw-r--r--drivers/acpi/nfit/mce.c2
-rw-r--r--drivers/base/regmap/regcache-rbtree.c38
-rw-r--r--drivers/base/regmap/regcache.c5
-rw-r--r--drivers/base/regmap/regmap.c2
-rw-r--r--drivers/bus/arm-cci.c2
-rw-r--r--drivers/bus/arm-ccn.c112
-rw-r--r--drivers/bus/vexpress-config.c1
-rw-r--r--drivers/char/virtio_console.c23
-rw-r--r--drivers/crypto/caam/caamalg.c77
-rw-r--r--drivers/dax/dax.c2
-rw-r--r--drivers/firmware/arm_scpi.c5
-rw-r--r--drivers/firmware/dmi-id.c8
-rw-r--r--drivers/gpio/Kconfig1
-rw-r--r--drivers/gpio/gpio-mcp23s08.c2
-rw-r--r--drivers/gpio/gpio-sa1100.c2
-rw-r--r--drivers/gpio/gpiolib-of.c1
-rw-r--r--drivers/i2c/busses/i2c-bcm-kona.c2
-rw-r--r--drivers/i2c/busses/i2c-cadence.c2
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c16
-rw-r--r--drivers/i2c/busses/i2c-rcar.c2
-rw-r--r--drivers/i2c/busses/i2c-rk3x.c14
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c2
-rw-r--r--drivers/i2c/muxes/i2c-demux-pinctrl.c15
-rw-r--r--drivers/iio/accel/bmc150-accel-core.c11
-rw-r--r--drivers/iio/accel/kxsd9.c1
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-attributes.c4
-rw-r--r--drivers/iio/industrialio-buffer.c4
-rw-r--r--drivers/iio/industrialio-core.c5
-rw-r--r--drivers/infiniband/core/multicast.c13
-rw-r--r--drivers/infiniband/hw/cxgb4/qp.c2
-rw-r--r--drivers/infiniband/hw/hfi1/chip.c92
-rw-r--r--drivers/infiniband/hw/hfi1/chip.h1
-rw-r--r--drivers/infiniband/hw/hfi1/debugfs.c132
-rw-r--r--drivers/infiniband/hw/hfi1/hfi.h4
-rw-r--r--drivers/infiniband/hw/hfi1/init.c3
-rw-r--r--drivers/infiniband/hw/hfi1/mad.c12
-rw-r--r--drivers/infiniband/hw/hfi1/pio_copy.c12
-rw-r--r--drivers/infiniband/hw/hfi1/user_sdma.c5
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_hw.c1
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_main.c8
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c26
-rw-r--r--drivers/infiniband/hw/mlx5/cq.c22
-rw-r--r--drivers/infiniband/hw/mlx5/main.c6
-rw-r--r--drivers/infiniband/hw/mlx5/mem.c6
-rw-r--r--drivers/infiniband/hw/mlx5/mlx5_ib.h1
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c13
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c16
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c2
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c23
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.h2
-rw-r--r--drivers/mailbox/Kconfig1
-rw-r--r--drivers/mailbox/bcm-pdc-mailbox.c11
-rw-r--r--drivers/memory/omap-gpmc.c21
-rw-r--r--drivers/misc/lkdtm_usercopy.c25
-rw-r--r--drivers/nvdimm/bus.c6
-rw-r--r--drivers/nvme/host/Kconfig2
-rw-r--r--drivers/pinctrl/intel/pinctrl-cherryview.c5
-rw-r--r--drivers/pinctrl/pinctrl-pistachio.c12
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c4
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c4
-rw-r--r--drivers/regulator/max14577-regulator.c4
-rw-r--r--drivers/regulator/max77693-regulator.c4
-rw-r--r--drivers/regulator/qcom_smd-regulator.c30
-rw-r--r--drivers/scsi/constants.c5
-rw-r--r--drivers/scsi/scsi_devinfo.c4
-rw-r--r--drivers/scsi/scsi_transport_sas.c16
-rw-r--r--drivers/scsi/ses.c2
-rw-r--r--drivers/spi/spi-img-spfi.c2
-rw-r--r--drivers/spi/spi-mt65xx.c1
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c1
-rw-r--r--drivers/spi/spi-qup.c1
-rw-r--r--drivers/spi/spi-sh-msiof.c3
-rw-r--r--drivers/spi/spi.c10
-rw-r--r--drivers/thermal/rcar_thermal.c1
-rw-r--r--drivers/usb/chipidea/udc.c9
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c4
-rw-r--r--drivers/usb/dwc3/gadget.c5
-rw-r--r--drivers/usb/gadget/function/f_eem.c2
-rw-r--r--drivers/usb/gadget/udc/renesas_usb3.c2
-rw-r--r--drivers/usb/host/xhci-ring.c6
-rw-r--r--drivers/usb/phy/phy-generic.c8
-rw-r--r--drivers/usb/renesas_usbhs/mod.c11
-rw-r--r--drivers/virtio/virtio_ring.c2
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/extent-tree.c23
-rw-r--r--fs/btrfs/tree-log.c1
-rw-r--r--fs/ceph/dir.c2
-rw-r--r--fs/crypto/policy.c41
-rw-r--r--fs/ext4/ioctl.c2
-rw-r--r--fs/f2fs/file.c9
-rw-r--r--fs/fuse/file.c7
-rw-r--r--fs/overlayfs/super.c4
-rw-r--r--fs/proc/task_mmu.c2
-rw-r--r--include/linux/fscrypto.h5
-rw-r--r--include/linux/thread_info.h7
-rw-r--r--include/scsi/scsi_transport_sas.h5
-rw-r--r--kernel/memremap.c9
-rw-r--r--kernel/power/qos.c11
-rw-r--r--mm/huge_memory.c4
-rw-r--r--mm/usercopy.c61
-rwxr-xr-xscripts/package/builddeb4
-rw-r--r--security/Kconfig11
-rw-r--r--sound/core/rawmidi.c4
-rw-r--r--sound/core/timer.c34
-rw-r--r--sound/firewire/fireworks/fireworks.h1
-rw-r--r--sound/firewire/fireworks/fireworks_hwdep.c71
-rw-r--r--sound/firewire/fireworks/fireworks_proc.c4
-rw-r--r--sound/firewire/fireworks/fireworks_transaction.c5
-rw-r--r--sound/firewire/tascam/tascam-hwdep.c33
-rw-r--r--sound/pci/hda/patch_realtek.c15
-rw-r--r--sound/usb/quirks.c1
-rw-r--r--tools/iio/iio_generic_buffer.c2
171 files changed, 1050 insertions, 666 deletions
diff --git a/.mailmap b/.mailmap
index 093a8ac9996e..de22daefd9da 100644
--- a/.mailmap
+++ b/.mailmap
@@ -88,6 +88,7 @@ Kay Sievers <kay.sievers@vrfy.org>
88Kenneth W Chen <kenneth.w.chen@intel.com> 88Kenneth W Chen <kenneth.w.chen@intel.com>
89Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com> 89Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>
90Koushik <raghavendra.koushik@neterion.com> 90Koushik <raghavendra.koushik@neterion.com>
91Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski@samsung.com>
91Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com> 92Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com>
92Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 93Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
93Leonid I Ananiev <leonid.i.ananiev@intel.com> 94Leonid I Ananiev <leonid.i.ananiev@intel.com>
diff --git a/Documentation/arm/CCN.txt b/Documentation/arm/CCN.txt
index ffca443a19b4..15cdb7bc57c3 100644
--- a/Documentation/arm/CCN.txt
+++ b/Documentation/arm/CCN.txt
@@ -18,13 +18,17 @@ and config2 fields of the perf_event_attr structure. The "events"
18directory provides configuration templates for all documented 18directory provides configuration templates for all documented
19events, that can be used with perf tool. For example "xp_valid_flit" 19events, that can be used with perf tool. For example "xp_valid_flit"
20is an equivalent of "type=0x8,event=0x4". Other parameters must be 20is an equivalent of "type=0x8,event=0x4". Other parameters must be
21explicitly specified. For events originating from device, "node" 21explicitly specified.
22defines its index. All crosspoint events require "xp" (index),
23"port" (device port number) and "vc" (virtual channel ID) and
24"dir" (direction). Watchpoints (special "event" value 0xfe) also
25require comparator values ("cmp_l" and "cmp_h") and "mask", being
26index of the comparator mask.
27 22
23For events originating from device, "node" defines its index.
24
25Crosspoint PMU events require "xp" (index), "bus" (bus number)
26and "vc" (virtual channel ID).
27
28Crosspoint watchpoint-based events (special "event" value 0xfe)
29require "xp" and "vc" as as above plus "port" (device port index),
30"dir" (transmit/receive direction), comparator values ("cmp_l"
31and "cmp_h") and "mask", being index of the comparator mask.
28Masks are defined separately from the event description 32Masks are defined separately from the event description
29(due to limited number of the config values) in the "cmp_mask" 33(due to limited number of the config values) in the "cmp_mask"
30directory, with first 8 configurable by user and additional 34directory, with first 8 configurable by user and additional
diff --git a/Documentation/cpu-freq/cpufreq-stats.txt b/Documentation/cpu-freq/cpufreq-stats.txt
index fc647492e940..8d9773f23550 100644
--- a/Documentation/cpu-freq/cpufreq-stats.txt
+++ b/Documentation/cpu-freq/cpufreq-stats.txt
@@ -103,7 +103,7 @@ Config Main Menu
103 Power management options (ACPI, APM) ---> 103 Power management options (ACPI, APM) --->
104 CPU Frequency scaling ---> 104 CPU Frequency scaling --->
105 [*] CPU Frequency scaling 105 [*] CPU Frequency scaling
106 <*> CPU frequency translation statistics 106 [*] CPU frequency translation statistics
107 [*] CPU frequency translation statistics details 107 [*] CPU frequency translation statistics details
108 108
109 109
diff --git a/Documentation/i2c/slave-interface b/Documentation/i2c/slave-interface
index 80807adb8ded..7e2a228f21bc 100644
--- a/Documentation/i2c/slave-interface
+++ b/Documentation/i2c/slave-interface
@@ -145,6 +145,11 @@ If you want to add slave support to the bus driver:
145 145
146* Catch the slave interrupts and send appropriate i2c_slave_events to the backend. 146* Catch the slave interrupts and send appropriate i2c_slave_events to the backend.
147 147
148Note that most hardware supports being master _and_ slave on the same bus. So,
149if you extend a bus driver, please make sure that the driver supports that as
150well. In almost all cases, slave support does not need to disable the master
151functionality.
152
148Check the i2c-rcar driver as an example. 153Check the i2c-rcar driver as an example.
149 154
150 155
diff --git a/MAINTAINERS b/MAINTAINERS
index 5edc555323be..b3e939563402 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1624,7 +1624,7 @@ N: rockchip
1624 1624
1625ARM/SAMSUNG EXYNOS ARM ARCHITECTURES 1625ARM/SAMSUNG EXYNOS ARM ARCHITECTURES
1626M: Kukjin Kim <kgene@kernel.org> 1626M: Kukjin Kim <kgene@kernel.org>
1627M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 1627M: Krzysztof Kozlowski <krzk@kernel.org>
1628L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1628L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1629L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 1629L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
1630S: Maintained 1630S: Maintained
@@ -1644,7 +1644,6 @@ F: drivers/*/*s3c64xx*
1644F: drivers/*/*s5pv210* 1644F: drivers/*/*s5pv210*
1645F: drivers/memory/samsung/* 1645F: drivers/memory/samsung/*
1646F: drivers/soc/samsung/* 1646F: drivers/soc/samsung/*
1647F: drivers/spi/spi-s3c*
1648F: Documentation/arm/Samsung/ 1647F: Documentation/arm/Samsung/
1649F: Documentation/devicetree/bindings/arm/samsung/ 1648F: Documentation/devicetree/bindings/arm/samsung/
1650F: Documentation/devicetree/bindings/sram/samsung-sram.txt 1649F: Documentation/devicetree/bindings/sram/samsung-sram.txt
@@ -1832,6 +1831,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git
1832ARM/UNIPHIER ARCHITECTURE 1831ARM/UNIPHIER ARCHITECTURE
1833M: Masahiro Yamada <yamada.masahiro@socionext.com> 1832M: Masahiro Yamada <yamada.masahiro@socionext.com>
1834L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1833L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1834T: git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-uniphier.git
1835S: Maintained 1835S: Maintained
1836F: arch/arm/boot/dts/uniphier* 1836F: arch/arm/boot/dts/uniphier*
1837F: arch/arm/include/asm/hardware/cache-uniphier.h 1837F: arch/arm/include/asm/hardware/cache-uniphier.h
@@ -7465,7 +7465,8 @@ F: Documentation/devicetree/bindings/sound/max9860.txt
7465F: sound/soc/codecs/max9860.* 7465F: sound/soc/codecs/max9860.*
7466 7466
7467MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS 7467MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS
7468M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 7468M: Krzysztof Kozlowski <krzk@kernel.org>
7469M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
7469L: linux-pm@vger.kernel.org 7470L: linux-pm@vger.kernel.org
7470S: Supported 7471S: Supported
7471F: drivers/power/max14577_charger.c 7472F: drivers/power/max14577_charger.c
@@ -7481,7 +7482,8 @@ F: include/dt-bindings/*/*max77802.h
7481 7482
7482MAXIM PMIC AND MUIC DRIVERS FOR EXYNOS BASED BOARDS 7483MAXIM PMIC AND MUIC DRIVERS FOR EXYNOS BASED BOARDS
7483M: Chanwoo Choi <cw00.choi@samsung.com> 7484M: Chanwoo Choi <cw00.choi@samsung.com>
7484M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 7485M: Krzysztof Kozlowski <krzk@kernel.org>
7486M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
7485L: linux-kernel@vger.kernel.org 7487L: linux-kernel@vger.kernel.org
7486S: Supported 7488S: Supported
7487F: drivers/*/max14577*.c 7489F: drivers/*/max14577*.c
@@ -9247,7 +9249,7 @@ F: drivers/pinctrl/sh-pfc/
9247 9249
9248PIN CONTROLLER - SAMSUNG 9250PIN CONTROLLER - SAMSUNG
9249M: Tomasz Figa <tomasz.figa@gmail.com> 9251M: Tomasz Figa <tomasz.figa@gmail.com>
9250M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 9252M: Krzysztof Kozlowski <krzk@kernel.org>
9251M: Sylwester Nawrocki <s.nawrocki@samsung.com> 9253M: Sylwester Nawrocki <s.nawrocki@samsung.com>
9252L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 9254L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
9253L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 9255L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
@@ -10180,7 +10182,7 @@ S: Maintained
10180F: drivers/platform/x86/samsung-laptop.c 10182F: drivers/platform/x86/samsung-laptop.c
10181 10183
10182SAMSUNG AUDIO (ASoC) DRIVERS 10184SAMSUNG AUDIO (ASoC) DRIVERS
10183M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 10185M: Krzysztof Kozlowski <krzk@kernel.org>
10184M: Sangbeom Kim <sbkim73@samsung.com> 10186M: Sangbeom Kim <sbkim73@samsung.com>
10185M: Sylwester Nawrocki <s.nawrocki@samsung.com> 10187M: Sylwester Nawrocki <s.nawrocki@samsung.com>
10186L: alsa-devel@alsa-project.org (moderated for non-subscribers) 10188L: alsa-devel@alsa-project.org (moderated for non-subscribers)
@@ -10195,7 +10197,8 @@ F: drivers/video/fbdev/s3c-fb.c
10195 10197
10196SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS 10198SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS
10197M: Sangbeom Kim <sbkim73@samsung.com> 10199M: Sangbeom Kim <sbkim73@samsung.com>
10198M: Krzysztof Kozlowski <k.kozlowski@samsung.com> 10200M: Krzysztof Kozlowski <krzk@kernel.org>
10201M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
10199L: linux-kernel@vger.kernel.org 10202L: linux-kernel@vger.kernel.org
10200L: linux-samsung-soc@vger.kernel.org 10203L: linux-samsung-soc@vger.kernel.org
10201S: Supported 10204S: Supported
@@ -10254,6 +10257,17 @@ S: Supported
10254L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 10257L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
10255F: drivers/clk/samsung/ 10258F: drivers/clk/samsung/
10256 10259
10260SAMSUNG SPI DRIVERS
10261M: Kukjin Kim <kgene@kernel.org>
10262M: Krzysztof Kozlowski <krzk@kernel.org>
10263M: Andi Shyti <andi.shyti@samsung.com>
10264L: linux-spi@vger.kernel.org
10265L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
10266S: Maintained
10267F: Documentation/devicetree/bindings/spi/spi-samsung.txt
10268F: drivers/spi/spi-s3c*
10269F: include/linux/platform_data/spi-s3c64xx.h
10270
10257SAMSUNG SXGBE DRIVERS 10271SAMSUNG SXGBE DRIVERS
10258M: Byungho An <bh74.an@samsung.com> 10272M: Byungho An <bh74.an@samsung.com>
10259M: Girish K S <ks.giri@samsung.com> 10273M: Girish K S <ks.giri@samsung.com>
diff --git a/Makefile b/Makefile
index a4e6cc531f81..1a8c8ddcb22f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 8 2PATCHLEVEL = 8
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Psychotic Stoned Sheep 5NAME = Psychotic Stoned Sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/Kconfig b/arch/Kconfig
index e9c9334507dd..fd6e9712af81 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -336,17 +336,6 @@ config HAVE_ARCH_SECCOMP_FILTER
336 results in the system call being skipped immediately. 336 results in the system call being skipped immediately.
337 - seccomp syscall wired up 337 - seccomp syscall wired up
338 338
339 For best performance, an arch should use seccomp_phase1 and
340 seccomp_phase2 directly. It should call seccomp_phase1 for all
341 syscalls if TIF_SECCOMP is set, but seccomp_phase1 does not
342 need to be called from a ptrace-safe context. It must then
343 call seccomp_phase2 if seccomp_phase1 returns anything other
344 than SECCOMP_PHASE1_OK or SECCOMP_PHASE1_SKIP.
345
346 As an additional optimization, an arch may provide seccomp_data
347 directly to seccomp_phase1; this avoids multiple calls
348 to the syscall_xyz helpers for every syscall.
349
350config SECCOMP_FILTER 339config SECCOMP_FILTER
351 def_bool y 340 def_bool y
352 depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET 341 depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET
diff --git a/arch/arm/boot/dts/am335x-baltos.dtsi b/arch/arm/boot/dts/am335x-baltos.dtsi
index c8609d8d2c55..b689172632ef 100644
--- a/arch/arm/boot/dts/am335x-baltos.dtsi
+++ b/arch/arm/boot/dts/am335x-baltos.dtsi
@@ -226,7 +226,7 @@
226 226
227 #address-cells = <1>; 227 #address-cells = <1>;
228 #size-cells = <1>; 228 #size-cells = <1>;
229 elm_id = <&elm>; 229 ti,elm-id = <&elm>;
230 }; 230 };
231}; 231};
232 232
diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi
index df63484ef9b3..e7d9ca1305fa 100644
--- a/arch/arm/boot/dts/am335x-igep0033.dtsi
+++ b/arch/arm/boot/dts/am335x-igep0033.dtsi
@@ -161,7 +161,7 @@
161 161
162 #address-cells = <1>; 162 #address-cells = <1>;
163 #size-cells = <1>; 163 #size-cells = <1>;
164 elm_id = <&elm>; 164 ti,elm-id = <&elm>;
165 165
166 /* MTD partition table */ 166 /* MTD partition table */
167 partition@0 { 167 partition@0 {
diff --git a/arch/arm/boot/dts/am335x-phycore-som.dtsi b/arch/arm/boot/dts/am335x-phycore-som.dtsi
index 86f773165d5c..1263c9d4cba3 100644
--- a/arch/arm/boot/dts/am335x-phycore-som.dtsi
+++ b/arch/arm/boot/dts/am335x-phycore-som.dtsi
@@ -197,7 +197,7 @@
197 gpmc,wr-access-ns = <30>; 197 gpmc,wr-access-ns = <30>;
198 gpmc,wr-data-mux-bus-ns = <0>; 198 gpmc,wr-data-mux-bus-ns = <0>;
199 199
200 elm_id = <&elm>; 200 ti,elm-id = <&elm>;
201 201
202 #address-cells = <1>; 202 #address-cells = <1>;
203 #size-cells = <1>; 203 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/armada-388-clearfog.dts b/arch/arm/boot/dts/armada-388-clearfog.dts
index 2e0556af6e5e..d3e6bd805006 100644
--- a/arch/arm/boot/dts/armada-388-clearfog.dts
+++ b/arch/arm/boot/dts/armada-388-clearfog.dts
@@ -390,12 +390,12 @@
390 390
391 port@0 { 391 port@0 {
392 reg = <0>; 392 reg = <0>;
393 label = "lan1"; 393 label = "lan5";
394 }; 394 };
395 395
396 port@1 { 396 port@1 {
397 reg = <1>; 397 reg = <1>;
398 label = "lan2"; 398 label = "lan4";
399 }; 399 };
400 400
401 port@2 { 401 port@2 {
@@ -405,12 +405,12 @@
405 405
406 port@3 { 406 port@3 {
407 reg = <3>; 407 reg = <3>;
408 label = "lan4"; 408 label = "lan2";
409 }; 409 };
410 410
411 port@4 { 411 port@4 {
412 reg = <4>; 412 reg = <4>;
413 label = "lan5"; 413 label = "lan1";
414 }; 414 };
415 415
416 port@5 { 416 port@5 {
diff --git a/arch/arm/boot/dts/exynos5410-odroidxu.dts b/arch/arm/boot/dts/exynos5410-odroidxu.dts
index d9499310a301..f6d135245a4b 100644
--- a/arch/arm/boot/dts/exynos5410-odroidxu.dts
+++ b/arch/arm/boot/dts/exynos5410-odroidxu.dts
@@ -447,14 +447,11 @@
447 samsung,dw-mshc-ciu-div = <3>; 447 samsung,dw-mshc-ciu-div = <3>;
448 samsung,dw-mshc-sdr-timing = <0 4>; 448 samsung,dw-mshc-sdr-timing = <0 4>;
449 samsung,dw-mshc-ddr-timing = <0 2>; 449 samsung,dw-mshc-ddr-timing = <0 2>;
450 samsung,dw-mshc-hs400-timing = <0 2>;
451 samsung,read-strobe-delay = <90>;
452 pinctrl-names = "default"; 450 pinctrl-names = "default";
453 pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus1 &sd0_bus4 &sd0_bus8 &sd0_cd>; 451 pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus1 &sd0_bus4 &sd0_bus8 &sd0_cd>;
454 bus-width = <8>; 452 bus-width = <8>;
455 cap-mmc-highspeed; 453 cap-mmc-highspeed;
456 mmc-hs200-1_8v; 454 mmc-hs200-1_8v;
457 mmc-hs400-1_8v;
458 vmmc-supply = <&ldo20_reg>; 455 vmmc-supply = <&ldo20_reg>;
459 vqmmc-supply = <&ldo11_reg>; 456 vqmmc-supply = <&ldo11_reg>;
460}; 457};
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index b620ac884cfd..b13b0b2db881 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -243,7 +243,7 @@
243 clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>, 243 clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
244 <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>, 244 <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
245 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>, 245 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
246 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>, 246 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>,
247 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>; 247 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
248 clock-names = "core", "rxtx0", 248 clock-names = "core", "rxtx0",
249 "rxtx1", "rxtx2", 249 "rxtx1", "rxtx2",
diff --git a/arch/arm/boot/dts/imx6sx-sabreauto.dts b/arch/arm/boot/dts/imx6sx-sabreauto.dts
index 96ea936eeeb0..240a2864d044 100644
--- a/arch/arm/boot/dts/imx6sx-sabreauto.dts
+++ b/arch/arm/boot/dts/imx6sx-sabreauto.dts
@@ -64,7 +64,7 @@
64 cd-gpios = <&gpio7 11 GPIO_ACTIVE_LOW>; 64 cd-gpios = <&gpio7 11 GPIO_ACTIVE_LOW>;
65 no-1-8-v; 65 no-1-8-v;
66 keep-power-in-suspend; 66 keep-power-in-suspend;
67 enable-sdio-wakup; 67 wakeup-source;
68 status = "okay"; 68 status = "okay";
69}; 69};
70 70
diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts
index 95ee268ed510..2f33c463cbce 100644
--- a/arch/arm/boot/dts/imx7d-sdb.dts
+++ b/arch/arm/boot/dts/imx7d-sdb.dts
@@ -131,7 +131,7 @@
131 ti,y-min = /bits/ 16 <0>; 131 ti,y-min = /bits/ 16 <0>;
132 ti,y-max = /bits/ 16 <0>; 132 ti,y-max = /bits/ 16 <0>;
133 ti,pressure-max = /bits/ 16 <0>; 133 ti,pressure-max = /bits/ 16 <0>;
134 ti,x-plat-ohms = /bits/ 16 <400>; 134 ti,x-plate-ohms = /bits/ 16 <400>;
135 wakeup-source; 135 wakeup-source;
136 }; 136 };
137}; 137};
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index ef84d8699a76..5bf62897014c 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -113,7 +113,7 @@
113 113
114 partition@e0000 { 114 partition@e0000 {
115 label = "u-boot environment"; 115 label = "u-boot environment";
116 reg = <0xe0000 0x100000>; 116 reg = <0xe0000 0x20000>;
117 }; 117 };
118 118
119 partition@100000 { 119 partition@100000 {
diff --git a/arch/arm/boot/dts/kirkwood-openrd.dtsi b/arch/arm/boot/dts/kirkwood-openrd.dtsi
index e4ecab112601..7175511a92da 100644
--- a/arch/arm/boot/dts/kirkwood-openrd.dtsi
+++ b/arch/arm/boot/dts/kirkwood-openrd.dtsi
@@ -116,6 +116,10 @@
116 }; 116 };
117}; 117};
118 118
119&pciec {
120 status = "okay";
121};
122
119&pcie0 { 123&pcie0 {
120 status = "okay"; 124 status = "okay";
121}; 125};
diff --git a/arch/arm/boot/dts/logicpd-som-lv.dtsi b/arch/arm/boot/dts/logicpd-som-lv.dtsi
index 365f39ff58bb..0ff1c2de95bf 100644
--- a/arch/arm/boot/dts/logicpd-som-lv.dtsi
+++ b/arch/arm/boot/dts/logicpd-som-lv.dtsi
@@ -35,10 +35,15 @@
35 ranges = <0 0 0x00000000 0x1000000>; /* CS0: 16MB for NAND */ 35 ranges = <0 0 0x00000000 0x1000000>; /* CS0: 16MB for NAND */
36 36
37 nand@0,0 { 37 nand@0,0 {
38 linux,mtd-name = "micron,mt29f4g16abbda3w"; 38 compatible = "ti,omap2-nand";
39 reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ 39 reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
40 interrupt-parent = <&gpmc>;
41 interrupts = <0 IRQ_TYPE_NONE>, /* fifoevent */
42 <1 IRQ_TYPE_NONE>; /* termcount */
43 linux,mtd-name = "micron,mt29f4g16abbda3w";
40 nand-bus-width = <16>; 44 nand-bus-width = <16>;
41 ti,nand-ecc-opt = "bch8"; 45 ti,nand-ecc-opt = "bch8";
46 rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */
42 gpmc,sync-clk-ps = <0>; 47 gpmc,sync-clk-ps = <0>;
43 gpmc,cs-on-ns = <0>; 48 gpmc,cs-on-ns = <0>;
44 gpmc,cs-rd-off-ns = <44>; 49 gpmc,cs-rd-off-ns = <44>;
@@ -54,10 +59,6 @@
54 gpmc,wr-access-ns = <40>; 59 gpmc,wr-access-ns = <40>;
55 gpmc,wr-data-mux-bus-ns = <0>; 60 gpmc,wr-data-mux-bus-ns = <0>;
56 gpmc,device-width = <2>; 61 gpmc,device-width = <2>;
57
58 gpmc,page-burst-access-ns = <5>;
59 gpmc,cycle2cycle-delay-ns = <50>;
60
61 #address-cells = <1>; 62 #address-cells = <1>;
62 #size-cells = <1>; 63 #size-cells = <1>;
63 64
diff --git a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
index 5e9a13c0eaf7..1c2c74655416 100644
--- a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
+++ b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
@@ -46,6 +46,7 @@
46 linux,mtd-name = "micron,mt29f4g16abbda3w"; 46 linux,mtd-name = "micron,mt29f4g16abbda3w";
47 nand-bus-width = <16>; 47 nand-bus-width = <16>;
48 ti,nand-ecc-opt = "bch8"; 48 ti,nand-ecc-opt = "bch8";
49 rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */
49 gpmc,sync-clk-ps = <0>; 50 gpmc,sync-clk-ps = <0>;
50 gpmc,cs-on-ns = <0>; 51 gpmc,cs-on-ns = <0>;
51 gpmc,cs-rd-off-ns = <44>; 52 gpmc,cs-rd-off-ns = <44>;
diff --git a/arch/arm/boot/dts/omap3-overo-base.dtsi b/arch/arm/boot/dts/omap3-overo-base.dtsi
index de256fa8da48..3e946cac55f3 100644
--- a/arch/arm/boot/dts/omap3-overo-base.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-base.dtsi
@@ -223,7 +223,9 @@
223}; 223};
224 224
225&gpmc { 225&gpmc {
226 ranges = <0 0 0x00000000 0x20000000>; 226 ranges = <0 0 0x30000000 0x1000000>, /* CS0 */
227 <4 0 0x2b000000 0x1000000>, /* CS4 */
228 <5 0 0x2c000000 0x1000000>; /* CS5 */
227 229
228 nand@0,0 { 230 nand@0,0 {
229 compatible = "ti,omap2-nand"; 231 compatible = "ti,omap2-nand";
diff --git a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
index 7df27926ead2..4f4c6efbd518 100644
--- a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
@@ -55,8 +55,6 @@
55#include "omap-gpmc-smsc9221.dtsi" 55#include "omap-gpmc-smsc9221.dtsi"
56 56
57&gpmc { 57&gpmc {
58 ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */
59
60 ethernet@gpmc { 58 ethernet@gpmc {
61 reg = <5 0 0xff>; 59 reg = <5 0 0xff>;
62 interrupt-parent = <&gpio6>; 60 interrupt-parent = <&gpio6>;
diff --git a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
index 9e24b6a1d07b..1b304e2f1bd2 100644
--- a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
@@ -27,8 +27,6 @@
27#include "omap-gpmc-smsc9221.dtsi" 27#include "omap-gpmc-smsc9221.dtsi"
28 28
29&gpmc { 29&gpmc {
30 ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */
31
32 ethernet@gpmc { 30 ethernet@gpmc {
33 reg = <5 0 0xff>; 31 reg = <5 0 0xff>;
34 interrupt-parent = <&gpio6>; 32 interrupt-parent = <&gpio6>;
diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
index 334109e14613..82e98ee3023a 100644
--- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
+++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
@@ -15,9 +15,6 @@
15#include "omap-gpmc-smsc9221.dtsi" 15#include "omap-gpmc-smsc9221.dtsi"
16 16
17&gpmc { 17&gpmc {
18 ranges = <4 0 0x2b000000 0x1000000>, /* CS4 */
19 <5 0 0x2c000000 0x1000000>; /* CS5 */
20
21 smsc1: ethernet@gpmc { 18 smsc1: ethernet@gpmc {
22 reg = <5 0 0xff>; 19 reg = <5 0 0xff>;
23 interrupt-parent = <&gpio6>; 20 interrupt-parent = <&gpio6>;
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index e012890e0cf2..a17ba0243db3 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -84,7 +84,7 @@
84 trips { 84 trips {
85 cpu_alert0: cpu_alert0 { 85 cpu_alert0: cpu_alert0 {
86 /* milliCelsius */ 86 /* milliCelsius */
87 temperature = <850000>; 87 temperature = <85000>;
88 hysteresis = <2000>; 88 hysteresis = <2000>;
89 type = "passive"; 89 type = "passive";
90 }; 90 };
diff --git a/arch/arm/boot/dts/tegra114-dalmore.dts b/arch/arm/boot/dts/tegra114-dalmore.dts
index 1dfc492cc004..1444fbd543e7 100644
--- a/arch/arm/boot/dts/tegra114-dalmore.dts
+++ b/arch/arm/boot/dts/tegra114-dalmore.dts
@@ -897,7 +897,7 @@
897 palmas: tps65913@58 { 897 palmas: tps65913@58 {
898 compatible = "ti,palmas"; 898 compatible = "ti,palmas";
899 reg = <0x58>; 899 reg = <0x58>;
900 interrupts = <0 86 IRQ_TYPE_LEVEL_LOW>; 900 interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>;
901 901
902 #interrupt-cells = <2>; 902 #interrupt-cells = <2>;
903 interrupt-controller; 903 interrupt-controller;
diff --git a/arch/arm/boot/dts/tegra114-roth.dts b/arch/arm/boot/dts/tegra114-roth.dts
index 70cf40996c3f..966a7fc044af 100644
--- a/arch/arm/boot/dts/tegra114-roth.dts
+++ b/arch/arm/boot/dts/tegra114-roth.dts
@@ -802,7 +802,7 @@
802 palmas: pmic@58 { 802 palmas: pmic@58 {
803 compatible = "ti,palmas"; 803 compatible = "ti,palmas";
804 reg = <0x58>; 804 reg = <0x58>;
805 interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_LOW>; 805 interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
806 806
807 #interrupt-cells = <2>; 807 #interrupt-cells = <2>;
808 interrupt-controller; 808 interrupt-controller;
diff --git a/arch/arm/boot/dts/tegra114-tn7.dts b/arch/arm/boot/dts/tegra114-tn7.dts
index 17dd14545862..a161fa1dfb61 100644
--- a/arch/arm/boot/dts/tegra114-tn7.dts
+++ b/arch/arm/boot/dts/tegra114-tn7.dts
@@ -63,7 +63,7 @@
63 palmas: pmic@58 { 63 palmas: pmic@58 {
64 compatible = "ti,palmas"; 64 compatible = "ti,palmas";
65 reg = <0x58>; 65 reg = <0x58>;
66 interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_LOW>; 66 interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
67 67
68 #interrupt-cells = <2>; 68 #interrupt-cells = <2>;
69 interrupt-controller; 69 interrupt-controller;
diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
index 6403e0de540e..e52b82449a79 100644
--- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts
+++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
@@ -1382,7 +1382,7 @@
1382 * Pin 41: BR_UART1_TXD 1382 * Pin 41: BR_UART1_TXD
1383 * Pin 44: BR_UART1_RXD 1383 * Pin 44: BR_UART1_RXD
1384 */ 1384 */
1385 serial@0,70006000 { 1385 serial@70006000 {
1386 compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; 1386 compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
1387 status = "okay"; 1387 status = "okay";
1388 }; 1388 };
@@ -1394,7 +1394,7 @@
1394 * Pin 71: UART2_CTS_L 1394 * Pin 71: UART2_CTS_L
1395 * Pin 74: UART2_RTS_L 1395 * Pin 74: UART2_RTS_L
1396 */ 1396 */
1397 serial@0,70006040 { 1397 serial@70006040 {
1398 compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; 1398 compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
1399 status = "okay"; 1399 status = "okay";
1400 }; 1400 };
diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
index 0b1e4a93d67e..15d073ae5da2 100644
--- a/arch/arm/kernel/hyp-stub.S
+++ b/arch/arm/kernel/hyp-stub.S
@@ -142,6 +142,19 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE
142 and r7, #0x1f @ Preserve HPMN 142 and r7, #0x1f @ Preserve HPMN
143 mcr p15, 4, r7, c1, c1, 1 @ HDCR 143 mcr p15, 4, r7, c1, c1, 1 @ HDCR
144 144
145 @ Make sure NS-SVC is initialised appropriately
146 mrc p15, 0, r7, c1, c0, 0 @ SCTLR
147 orr r7, #(1 << 5) @ CP15 barriers enabled
148 bic r7, #(3 << 7) @ Clear SED/ITD for v8 (RES0 for v7)
149 bic r7, #(3 << 19) @ WXN and UWXN disabled
150 mcr p15, 0, r7, c1, c0, 0 @ SCTLR
151
152 mrc p15, 0, r7, c0, c0, 0 @ MIDR
153 mcr p15, 4, r7, c0, c0, 0 @ VPIDR
154
155 mrc p15, 0, r7, c0, c0, 5 @ MPIDR
156 mcr p15, 4, r7, c0, c0, 5 @ VMPIDR
157
145#if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER) 158#if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER)
146 @ make CNTP_* and CNTPCT accessible from PL1 159 @ make CNTP_* and CNTPCT accessible from PL1
147 mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1 160 mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1
diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c
index 5d9bfab279dd..6bb7d9cf1e38 100644
--- a/arch/arm/mach-imx/mach-imx6ul.c
+++ b/arch/arm/mach-imx/mach-imx6ul.c
@@ -64,6 +64,7 @@ static void __init imx6ul_init_machine(void)
64 if (parent == NULL) 64 if (parent == NULL)
65 pr_warn("failed to initialize soc device\n"); 65 pr_warn("failed to initialize soc device\n");
66 66
67 of_platform_default_populate(NULL, NULL, parent);
67 imx6ul_enet_init(); 68 imx6ul_enet_init();
68 imx_anatop_init(); 69 imx_anatop_init();
69 imx6ul_pm_init(); 70 imx6ul_pm_init();
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
index 58924b3844df..fe708e26d021 100644
--- a/arch/arm/mach-imx/pm-imx6.c
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -295,7 +295,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode)
295 val &= ~BM_CLPCR_SBYOS; 295 val &= ~BM_CLPCR_SBYOS;
296 if (cpu_is_imx6sl()) 296 if (cpu_is_imx6sl())
297 val |= BM_CLPCR_BYPASS_PMIC_READY; 297 val |= BM_CLPCR_BYPASS_PMIC_READY;
298 if (cpu_is_imx6sl() || cpu_is_imx6sx()) 298 if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())
299 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; 299 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
300 else 300 else
301 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS; 301 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
@@ -310,7 +310,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode)
310 val |= 0x3 << BP_CLPCR_STBY_COUNT; 310 val |= 0x3 << BP_CLPCR_STBY_COUNT;
311 val |= BM_CLPCR_VSTBY; 311 val |= BM_CLPCR_VSTBY;
312 val |= BM_CLPCR_SBYOS; 312 val |= BM_CLPCR_SBYOS;
313 if (cpu_is_imx6sl()) 313 if (cpu_is_imx6sl() || cpu_is_imx6sx())
314 val |= BM_CLPCR_BYPASS_PMIC_READY; 314 val |= BM_CLPCR_BYPASS_PMIC_READY;
315 if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) 315 if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())
316 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; 316 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c
index c073fb57dd13..6f2d0aec0513 100644
--- a/arch/arm/mach-omap2/cm33xx.c
+++ b/arch/arm/mach-omap2/cm33xx.c
@@ -220,9 +220,6 @@ static int am33xx_cm_wait_module_ready(u8 part, s16 inst, u16 clkctrl_offs,
220{ 220{
221 int i = 0; 221 int i = 0;
222 222
223 if (!clkctrl_offs)
224 return 0;
225
226 omap_test_timeout(_is_module_ready(inst, clkctrl_offs), 223 omap_test_timeout(_is_module_ready(inst, clkctrl_offs),
227 MAX_MODULE_READY_TIME, i); 224 MAX_MODULE_READY_TIME, i);
228 225
@@ -246,9 +243,6 @@ static int am33xx_cm_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
246{ 243{
247 int i = 0; 244 int i = 0;
248 245
249 if (!clkctrl_offs)
250 return 0;
251
252 omap_test_timeout((_clkctrl_idlest(inst, clkctrl_offs) == 246 omap_test_timeout((_clkctrl_idlest(inst, clkctrl_offs) ==
253 CLKCTRL_IDLEST_DISABLED), 247 CLKCTRL_IDLEST_DISABLED),
254 MAX_MODULE_READY_TIME, i); 248 MAX_MODULE_READY_TIME, i);
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index 2c0e07ed6b99..2ab27ade136a 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -278,9 +278,6 @@ static int omap4_cminst_wait_module_ready(u8 part, s16 inst, u16 clkctrl_offs,
278{ 278{
279 int i = 0; 279 int i = 0;
280 280
281 if (!clkctrl_offs)
282 return 0;
283
284 omap_test_timeout(_is_module_ready(part, inst, clkctrl_offs), 281 omap_test_timeout(_is_module_ready(part, inst, clkctrl_offs),
285 MAX_MODULE_READY_TIME, i); 282 MAX_MODULE_READY_TIME, i);
286 283
@@ -304,9 +301,6 @@ static int omap4_cminst_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
304{ 301{
305 int i = 0; 302 int i = 0;
306 303
307 if (!clkctrl_offs)
308 return 0;
309
310 omap_test_timeout((_clkctrl_idlest(part, inst, clkctrl_offs) == 304 omap_test_timeout((_clkctrl_idlest(part, inst, clkctrl_offs) ==
311 CLKCTRL_IDLEST_DISABLED), 305 CLKCTRL_IDLEST_DISABLED),
312 MAX_MODULE_DISABLE_TIME, i); 306 MAX_MODULE_DISABLE_TIME, i);
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 5b709383381c..1052b29697b8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1053,6 +1053,10 @@ static int _omap4_wait_target_disable(struct omap_hwmod *oh)
1053 if (oh->flags & HWMOD_NO_IDLEST) 1053 if (oh->flags & HWMOD_NO_IDLEST)
1054 return 0; 1054 return 0;
1055 1055
1056 if (!oh->prcm.omap4.clkctrl_offs &&
1057 !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))
1058 return 0;
1059
1056 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, 1060 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition,
1057 oh->clkdm->cm_inst, 1061 oh->clkdm->cm_inst,
1058 oh->prcm.omap4.clkctrl_offs, 0); 1062 oh->prcm.omap4.clkctrl_offs, 0);
@@ -2971,6 +2975,10 @@ static int _omap4_wait_target_ready(struct omap_hwmod *oh)
2971 if (!_find_mpu_rt_port(oh)) 2975 if (!_find_mpu_rt_port(oh))
2972 return 0; 2976 return 0;
2973 2977
2978 if (!oh->prcm.omap4.clkctrl_offs &&
2979 !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))
2980 return 0;
2981
2974 /* XXX check module SIDLEMODE, hardreset status */ 2982 /* XXX check module SIDLEMODE, hardreset status */
2975 2983
2976 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, 2984 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition,
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index 4041bad79a9a..78904017f18c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -443,8 +443,12 @@ struct omap_hwmod_omap2_prcm {
443 * HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT: Some IP blocks don't have a PRCM 443 * HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT: Some IP blocks don't have a PRCM
444 * module-level context loss register associated with them; this 444 * module-level context loss register associated with them; this
445 * flag bit should be set in those cases 445 * flag bit should be set in those cases
446 * HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET: Some IP blocks have a valid CLKCTRL
447 * offset of zero; this flag bit should be set in those cases to
448 * distinguish from hwmods that have no clkctrl offset.
446 */ 449 */
447#define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0) 450#define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0)
451#define HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET (1 << 1)
448 452
449/** 453/**
450 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data 454 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
index 55c5878577f4..e2d84aa7f595 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
@@ -29,6 +29,7 @@
29#define CLKCTRL(oh, clkctrl) ((oh).prcm.omap4.clkctrl_offs = (clkctrl)) 29#define CLKCTRL(oh, clkctrl) ((oh).prcm.omap4.clkctrl_offs = (clkctrl))
30#define RSTCTRL(oh, rstctrl) ((oh).prcm.omap4.rstctrl_offs = (rstctrl)) 30#define RSTCTRL(oh, rstctrl) ((oh).prcm.omap4.rstctrl_offs = (rstctrl))
31#define RSTST(oh, rstst) ((oh).prcm.omap4.rstst_offs = (rstst)) 31#define RSTST(oh, rstst) ((oh).prcm.omap4.rstst_offs = (rstst))
32#define PRCM_FLAGS(oh, flag) ((oh).prcm.omap4.flags = (flag))
32 33
33/* 34/*
34 * 'l3' class 35 * 'l3' class
@@ -1296,6 +1297,7 @@ static void omap_hwmod_am33xx_clkctrl(void)
1296 CLKCTRL(am33xx_i2c1_hwmod, AM33XX_CM_WKUP_I2C0_CLKCTRL_OFFSET); 1297 CLKCTRL(am33xx_i2c1_hwmod, AM33XX_CM_WKUP_I2C0_CLKCTRL_OFFSET);
1297 CLKCTRL(am33xx_wd_timer1_hwmod, AM33XX_CM_WKUP_WDT1_CLKCTRL_OFFSET); 1298 CLKCTRL(am33xx_wd_timer1_hwmod, AM33XX_CM_WKUP_WDT1_CLKCTRL_OFFSET);
1298 CLKCTRL(am33xx_rtc_hwmod, AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET); 1299 CLKCTRL(am33xx_rtc_hwmod, AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET);
1300 PRCM_FLAGS(am33xx_rtc_hwmod, HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET);
1299 CLKCTRL(am33xx_mmc2_hwmod, AM33XX_CM_PER_MMC2_CLKCTRL_OFFSET); 1301 CLKCTRL(am33xx_mmc2_hwmod, AM33XX_CM_PER_MMC2_CLKCTRL_OFFSET);
1300 CLKCTRL(am33xx_gpmc_hwmod, AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET); 1302 CLKCTRL(am33xx_gpmc_hwmod, AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET);
1301 CLKCTRL(am33xx_l4_ls_hwmod, AM33XX_CM_PER_L4LS_CLKCTRL_OFFSET); 1303 CLKCTRL(am33xx_l4_ls_hwmod, AM33XX_CM_PER_L4LS_CLKCTRL_OFFSET);
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index d72ee6185d5e..1cc4a6f3954e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -722,8 +722,20 @@ static struct omap_hwmod omap3xxx_dss_dispc_hwmod = {
722 * display serial interface controller 722 * display serial interface controller
723 */ 723 */
724 724
725static struct omap_hwmod_class_sysconfig omap3xxx_dsi_sysc = {
726 .rev_offs = 0x0000,
727 .sysc_offs = 0x0010,
728 .syss_offs = 0x0014,
729 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
730 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE |
731 SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
732 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
733 .sysc_fields = &omap_hwmod_sysc_type1,
734};
735
725static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = { 736static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = {
726 .name = "dsi", 737 .name = "dsi",
738 .sysc = &omap3xxx_dsi_sysc,
727}; 739};
728 740
729static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = { 741static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = {
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
index cbf53bb9c814..0db46895c82a 100644
--- a/arch/arm/mach-sa1100/clock.c
+++ b/arch/arm/mach-sa1100/clock.c
@@ -125,6 +125,8 @@ static unsigned long clk_36864_get_rate(struct clk *clk)
125} 125}
126 126
127static struct clkops clk_36864_ops = { 127static struct clkops clk_36864_ops = {
128 .enable = clk_cpu_enable,
129 .disable = clk_cpu_disable,
128 .get_rate = clk_36864_get_rate, 130 .get_rate = clk_36864_get_rate,
129}; 131};
130 132
@@ -140,9 +142,8 @@ static struct clk_lookup sa11xx_clkregs[] = {
140 CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864), 142 CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864),
141}; 143};
142 144
143static int __init sa11xx_clk_init(void) 145int __init sa11xx_clk_init(void)
144{ 146{
145 clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); 147 clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs));
146 return 0; 148 return 0;
147} 149}
148core_initcall(sa11xx_clk_init);
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 345e63f4eb71..3e09beddb6e8 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -34,6 +34,7 @@
34 34
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <mach/irqs.h> 36#include <mach/irqs.h>
37#include <mach/reset.h>
37 38
38#include "generic.h" 39#include "generic.h"
39#include <clocksource/pxa.h> 40#include <clocksource/pxa.h>
@@ -95,6 +96,8 @@ static void sa1100_power_off(void)
95 96
96void sa11x0_restart(enum reboot_mode mode, const char *cmd) 97void sa11x0_restart(enum reboot_mode mode, const char *cmd)
97{ 98{
99 clear_reset_status(RESET_STATUS_ALL);
100
98 if (mode == REBOOT_SOFT) { 101 if (mode == REBOOT_SOFT) {
99 /* Jump into ROM at address 0 */ 102 /* Jump into ROM at address 0 */
100 soft_restart(0); 103 soft_restart(0);
@@ -388,6 +391,7 @@ void __init sa1100_init_irq(void)
388 sa11x0_init_irq_nodt(IRQ_GPIO0_SC, irq_resource.start); 391 sa11x0_init_irq_nodt(IRQ_GPIO0_SC, irq_resource.start);
389 392
390 sa1100_init_gpio(); 393 sa1100_init_gpio();
394 sa11xx_clk_init();
391} 395}
392 396
393/* 397/*
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 0d92e119b36b..68199b603ff7 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -44,3 +44,5 @@ int sa11x0_pm_init(void);
44#else 44#else
45static inline int sa11x0_pm_init(void) { return 0; } 45static inline int sa11x0_pm_init(void) { return 0; }
46#endif 46#endif
47
48int sa11xx_clk_init(void);
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index a7123b4e129d..d00d52c9de3e 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -16,6 +16,7 @@
16#include <asm/hwcap.h> 16#include <asm/hwcap.h>
17#include <asm/pgtable-hwdef.h> 17#include <asm/pgtable-hwdef.h>
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/memory.h>
19 20
20#include "proc-macros.S" 21#include "proc-macros.S"
21 22
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index 0a456bef8c79..2fee2f59288c 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -199,19 +199,19 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val,
199#define _percpu_read(pcp) \ 199#define _percpu_read(pcp) \
200({ \ 200({ \
201 typeof(pcp) __retval; \ 201 typeof(pcp) __retval; \
202 preempt_disable(); \ 202 preempt_disable_notrace(); \
203 __retval = (typeof(pcp))__percpu_read(raw_cpu_ptr(&(pcp)), \ 203 __retval = (typeof(pcp))__percpu_read(raw_cpu_ptr(&(pcp)), \
204 sizeof(pcp)); \ 204 sizeof(pcp)); \
205 preempt_enable(); \ 205 preempt_enable_notrace(); \
206 __retval; \ 206 __retval; \
207}) 207})
208 208
209#define _percpu_write(pcp, val) \ 209#define _percpu_write(pcp, val) \
210do { \ 210do { \
211 preempt_disable(); \ 211 preempt_disable_notrace(); \
212 __percpu_write(raw_cpu_ptr(&(pcp)), (unsigned long)(val), \ 212 __percpu_write(raw_cpu_ptr(&(pcp)), (unsigned long)(val), \
213 sizeof(pcp)); \ 213 sizeof(pcp)); \
214 preempt_enable(); \ 214 preempt_enable_notrace(); \
215} while(0) \ 215} while(0) \
216 216
217#define _pcp_protect(operation, pcp, val) \ 217#define _pcp_protect(operation, pcp, val) \
diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
index e875a5a551d7..89206b568cd4 100644
--- a/arch/arm64/include/asm/spinlock.h
+++ b/arch/arm64/include/asm/spinlock.h
@@ -363,4 +363,14 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
363#define arch_read_relax(lock) cpu_relax() 363#define arch_read_relax(lock) cpu_relax()
364#define arch_write_relax(lock) cpu_relax() 364#define arch_write_relax(lock) cpu_relax()
365 365
366/*
367 * Accesses appearing in program order before a spin_lock() operation
368 * can be reordered with accesses inside the critical section, by virtue
369 * of arch_spin_lock being constructed using acquire semantics.
370 *
371 * In cases where this is problematic (e.g. try_to_wake_up), an
372 * smp_mb__before_spinlock() can restore the required ordering.
373 */
374#define smp_mb__before_spinlock() smp_mb()
375
366#endif /* __ASM_SPINLOCK_H */ 376#endif /* __ASM_SPINLOCK_H */
diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 465c70982f40..0472927ebb9b 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -241,8 +241,7 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
241static inline unsigned long 241static inline unsigned long
242__copy_to_user (void __user *to, const void *from, unsigned long count) 242__copy_to_user (void __user *to, const void *from, unsigned long count)
243{ 243{
244 if (!__builtin_constant_p(count)) 244 check_object_size(from, count, true);
245 check_object_size(from, count, true);
246 245
247 return __copy_user(to, (__force void __user *) from, count); 246 return __copy_user(to, (__force void __user *) from, count);
248} 247}
@@ -250,8 +249,7 @@ __copy_to_user (void __user *to, const void *from, unsigned long count)
250static inline unsigned long 249static inline unsigned long
251__copy_from_user (void *to, const void __user *from, unsigned long count) 250__copy_from_user (void *to, const void __user *from, unsigned long count)
252{ 251{
253 if (!__builtin_constant_p(count)) 252 check_object_size(to, count, false);
254 check_object_size(to, count, false);
255 253
256 return __copy_user((__force void __user *) to, from, count); 254 return __copy_user((__force void __user *) to, from, count);
257} 255}
@@ -265,8 +263,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
265 long __cu_len = (n); \ 263 long __cu_len = (n); \
266 \ 264 \
267 if (__access_ok(__cu_to, __cu_len, get_fs())) { \ 265 if (__access_ok(__cu_to, __cu_len, get_fs())) { \
268 if (!__builtin_constant_p(n)) \ 266 check_object_size(__cu_from, __cu_len, true); \
269 check_object_size(__cu_from, __cu_len, true); \
270 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ 267 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
271 } \ 268 } \
272 __cu_len; \ 269 __cu_len; \
@@ -280,8 +277,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
280 \ 277 \
281 __chk_user_ptr(__cu_from); \ 278 __chk_user_ptr(__cu_from); \
282 if (__access_ok(__cu_from, __cu_len, get_fs())) { \ 279 if (__access_ok(__cu_from, __cu_len, get_fs())) { \
283 if (!__builtin_constant_p(n)) \ 280 check_object_size(__cu_to, __cu_len, false); \
284 check_object_size(__cu_to, __cu_len, false); \
285 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ 281 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
286 } \ 282 } \
287 __cu_len; \ 283 __cu_len; \
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index c1dc6c14deb8..f1e382498bbb 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -311,14 +311,12 @@ static inline unsigned long copy_from_user(void *to,
311 unsigned long over; 311 unsigned long over;
312 312
313 if (access_ok(VERIFY_READ, from, n)) { 313 if (access_ok(VERIFY_READ, from, n)) {
314 if (!__builtin_constant_p(n)) 314 check_object_size(to, n, false);
315 check_object_size(to, n, false);
316 return __copy_tofrom_user((__force void __user *)to, from, n); 315 return __copy_tofrom_user((__force void __user *)to, from, n);
317 } 316 }
318 if ((unsigned long)from < TASK_SIZE) { 317 if ((unsigned long)from < TASK_SIZE) {
319 over = (unsigned long)from + n - TASK_SIZE; 318 over = (unsigned long)from + n - TASK_SIZE;
320 if (!__builtin_constant_p(n - over)) 319 check_object_size(to, n - over, false);
321 check_object_size(to, n - over, false);
322 return __copy_tofrom_user((__force void __user *)to, from, 320 return __copy_tofrom_user((__force void __user *)to, from,
323 n - over) + over; 321 n - over) + over;
324 } 322 }
@@ -331,14 +329,12 @@ static inline unsigned long copy_to_user(void __user *to,
331 unsigned long over; 329 unsigned long over;
332 330
333 if (access_ok(VERIFY_WRITE, to, n)) { 331 if (access_ok(VERIFY_WRITE, to, n)) {
334 if (!__builtin_constant_p(n)) 332 check_object_size(from, n, true);
335 check_object_size(from, n, true);
336 return __copy_tofrom_user(to, (__force void __user *)from, n); 333 return __copy_tofrom_user(to, (__force void __user *)from, n);
337 } 334 }
338 if ((unsigned long)to < TASK_SIZE) { 335 if ((unsigned long)to < TASK_SIZE) {
339 over = (unsigned long)to + n - TASK_SIZE; 336 over = (unsigned long)to + n - TASK_SIZE;
340 if (!__builtin_constant_p(n)) 337 check_object_size(from, n - over, true);
341 check_object_size(from, n - over, true);
342 return __copy_tofrom_user(to, (__force void __user *)from, 338 return __copy_tofrom_user(to, (__force void __user *)from,
343 n - over) + over; 339 n - over) + over;
344 } 340 }
@@ -383,8 +379,7 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
383 return 0; 379 return 0;
384 } 380 }
385 381
386 if (!__builtin_constant_p(n)) 382 check_object_size(to, n, false);
387 check_object_size(to, n, false);
388 383
389 return __copy_tofrom_user((__force void __user *)to, from, n); 384 return __copy_tofrom_user((__force void __user *)to, from, n);
390} 385}
@@ -412,8 +407,8 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
412 if (ret == 0) 407 if (ret == 0)
413 return 0; 408 return 0;
414 } 409 }
415 if (!__builtin_constant_p(n)) 410
416 check_object_size(from, n, true); 411 check_object_size(from, n, true);
417 412
418 return __copy_tofrom_user(to, (__force const void __user *)from, n); 413 return __copy_tofrom_user(to, (__force const void __user *)from, n);
419} 414}
diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_32.S
index 0a57fe6d49cc..aa8214f30c92 100644
--- a/arch/powerpc/lib/checksum_32.S
+++ b/arch/powerpc/lib/checksum_32.S
@@ -127,18 +127,19 @@ _GLOBAL(csum_partial_copy_generic)
127 stw r7,12(r1) 127 stw r7,12(r1)
128 stw r8,8(r1) 128 stw r8,8(r1)
129 129
130 rlwinm r0,r4,3,0x8
131 rlwnm r6,r6,r0,0,31 /* odd destination address: rotate one byte */
132 cmplwi cr7,r0,0 /* is destination address even ? */
133 addic r12,r6,0 130 addic r12,r6,0
134 addi r6,r4,-4 131 addi r6,r4,-4
135 neg r0,r4 132 neg r0,r4
136 addi r4,r3,-4 133 addi r4,r3,-4
137 andi. r0,r0,CACHELINE_MASK /* # bytes to start of cache line */ 134 andi. r0,r0,CACHELINE_MASK /* # bytes to start of cache line */
135 crset 4*cr7+eq
138 beq 58f 136 beq 58f
139 137
140 cmplw 0,r5,r0 /* is this more than total to do? */ 138 cmplw 0,r5,r0 /* is this more than total to do? */
141 blt 63f /* if not much to do */ 139 blt 63f /* if not much to do */
140 rlwinm r7,r6,3,0x8
141 rlwnm r12,r12,r7,0,31 /* odd destination address: rotate one byte */
142 cmplwi cr7,r7,0 /* is destination address even ? */
142 andi. r8,r0,3 /* get it word-aligned first */ 143 andi. r8,r0,3 /* get it word-aligned first */
143 mtctr r8 144 mtctr r8
144 beq+ 61f 145 beq+ 61f
diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
index dfdb90cb4403..9f1983404e1a 100644
--- a/arch/powerpc/mm/slb_low.S
+++ b/arch/powerpc/mm/slb_low.S
@@ -113,7 +113,12 @@ BEGIN_FTR_SECTION
113END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) 113END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
114 b slb_finish_load_1T 114 b slb_finish_load_1T
115 115
1160: 1160: /*
117 * For userspace addresses, make sure this is region 0.
118 */
119 cmpdi r9, 0
120 bne 8f
121
117 /* when using slices, we extract the psize off the slice bitmaps 122 /* when using slices, we extract the psize off the slice bitmaps
118 * and then we need to get the sllp encoding off the mmu_psize_defs 123 * and then we need to get the sllp encoding off the mmu_psize_defs
119 * array. 124 * array.
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 13218263e66e..c16d790808f1 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -162,11 +162,12 @@ static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb)
162static void pnv_ioda_free_pe(struct pnv_ioda_pe *pe) 162static void pnv_ioda_free_pe(struct pnv_ioda_pe *pe)
163{ 163{
164 struct pnv_phb *phb = pe->phb; 164 struct pnv_phb *phb = pe->phb;
165 unsigned int pe_num = pe->pe_number;
165 166
166 WARN_ON(pe->pdev); 167 WARN_ON(pe->pdev);
167 168
168 memset(pe, 0, sizeof(struct pnv_ioda_pe)); 169 memset(pe, 0, sizeof(struct pnv_ioda_pe));
169 clear_bit(pe->pe_number, phb->ioda.pe_alloc); 170 clear_bit(pe_num, phb->ioda.pe_alloc);
170} 171}
171 172
172/* The default M64 BAR is shared by all PEs */ 173/* The default M64 BAR is shared by all PEs */
@@ -3402,12 +3403,6 @@ static void pnv_ioda_release_pe(struct pnv_ioda_pe *pe)
3402 struct pnv_phb *phb = pe->phb; 3403 struct pnv_phb *phb = pe->phb;
3403 struct pnv_ioda_pe *slave, *tmp; 3404 struct pnv_ioda_pe *slave, *tmp;
3404 3405
3405 /* Release slave PEs in compound PE */
3406 if (pe->flags & PNV_IODA_PE_MASTER) {
3407 list_for_each_entry_safe(slave, tmp, &pe->slaves, list)
3408 pnv_ioda_release_pe(slave);
3409 }
3410
3411 list_del(&pe->list); 3406 list_del(&pe->list);
3412 switch (phb->type) { 3407 switch (phb->type) {
3413 case PNV_PHB_IODA1: 3408 case PNV_PHB_IODA1:
@@ -3422,6 +3417,15 @@ static void pnv_ioda_release_pe(struct pnv_ioda_pe *pe)
3422 3417
3423 pnv_ioda_release_pe_seg(pe); 3418 pnv_ioda_release_pe_seg(pe);
3424 pnv_ioda_deconfigure_pe(pe->phb, pe); 3419 pnv_ioda_deconfigure_pe(pe->phb, pe);
3420
3421 /* Release slave PEs in the compound PE */
3422 if (pe->flags & PNV_IODA_PE_MASTER) {
3423 list_for_each_entry_safe(slave, tmp, &pe->slaves, list) {
3424 list_del(&slave->list);
3425 pnv_ioda_free_pe(slave);
3426 }
3427 }
3428
3425 pnv_ioda_free_pe(pe); 3429 pnv_ioda_free_pe(pe);
3426} 3430}
3427 3431
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 4ffcaa6f8670..a39d20e8623d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -41,7 +41,6 @@
41#include <linux/root_dev.h> 41#include <linux/root_dev.h>
42#include <linux/of.h> 42#include <linux/of.h>
43#include <linux/of_pci.h> 43#include <linux/of_pci.h>
44#include <linux/kexec.h>
45 44
46#include <asm/mmu.h> 45#include <asm/mmu.h>
47#include <asm/processor.h> 46#include <asm/processor.h>
@@ -66,6 +65,7 @@
66#include <asm/eeh.h> 65#include <asm/eeh.h>
67#include <asm/reg.h> 66#include <asm/reg.h>
68#include <asm/plpar_wrappers.h> 67#include <asm/plpar_wrappers.h>
68#include <asm/kexec.h>
69 69
70#include "pseries.h" 70#include "pseries.h"
71 71
diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
index 57d72f10a97f..9114243fa1b5 100644
--- a/arch/powerpc/sysdev/xics/icp-opal.c
+++ b/arch/powerpc/sysdev/xics/icp-opal.c
@@ -23,10 +23,10 @@
23 23
24static void icp_opal_teardown_cpu(void) 24static void icp_opal_teardown_cpu(void)
25{ 25{
26 int cpu = smp_processor_id(); 26 int hw_cpu = hard_smp_processor_id();
27 27
28 /* Clear any pending IPI */ 28 /* Clear any pending IPI */
29 opal_int_set_mfrr(cpu, 0xff); 29 opal_int_set_mfrr(hw_cpu, 0xff);
30} 30}
31 31
32static void icp_opal_flush_ipi(void) 32static void icp_opal_flush_ipi(void)
@@ -101,14 +101,16 @@ static void icp_opal_eoi(struct irq_data *d)
101 101
102static void icp_opal_cause_ipi(int cpu, unsigned long data) 102static void icp_opal_cause_ipi(int cpu, unsigned long data)
103{ 103{
104 opal_int_set_mfrr(cpu, IPI_PRIORITY); 104 int hw_cpu = get_hard_smp_processor_id(cpu);
105
106 opal_int_set_mfrr(hw_cpu, IPI_PRIORITY);
105} 107}
106 108
107static irqreturn_t icp_opal_ipi_action(int irq, void *dev_id) 109static irqreturn_t icp_opal_ipi_action(int irq, void *dev_id)
108{ 110{
109 int cpu = smp_processor_id(); 111 int hw_cpu = hard_smp_processor_id();
110 112
111 opal_int_set_mfrr(cpu, 0xff); 113 opal_int_set_mfrr(hw_cpu, 0xff);
112 114
113 return smp_ipi_demux(); 115 return smp_ipi_demux();
114} 116}
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 341a5a133f48..e722c510bb1b 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -249,8 +249,7 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon
249static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) 249static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
250{ 250{
251 if (n && __access_ok((unsigned long) to, n)) { 251 if (n && __access_ok((unsigned long) to, n)) {
252 if (!__builtin_constant_p(n)) 252 check_object_size(from, n, true);
253 check_object_size(from, n, true);
254 return __copy_user(to, (__force void __user *) from, n); 253 return __copy_user(to, (__force void __user *) from, n);
255 } else 254 } else
256 return n; 255 return n;
@@ -258,16 +257,14 @@ static inline unsigned long copy_to_user(void __user *to, const void *from, unsi
258 257
259static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) 258static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
260{ 259{
261 if (!__builtin_constant_p(n)) 260 check_object_size(from, n, true);
262 check_object_size(from, n, true);
263 return __copy_user(to, (__force void __user *) from, n); 261 return __copy_user(to, (__force void __user *) from, n);
264} 262}
265 263
266static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) 264static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
267{ 265{
268 if (n && __access_ok((unsigned long) from, n)) { 266 if (n && __access_ok((unsigned long) from, n)) {
269 if (!__builtin_constant_p(n)) 267 check_object_size(to, n, false);
270 check_object_size(to, n, false);
271 return __copy_user((__force void __user *) to, from, n); 268 return __copy_user((__force void __user *) to, from, n);
272 } else 269 } else
273 return n; 270 return n;
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index 8bda94fab8e8..37a315d0ddd4 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -212,8 +212,7 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
212{ 212{
213 unsigned long ret; 213 unsigned long ret;
214 214
215 if (!__builtin_constant_p(size)) 215 check_object_size(to, size, false);
216 check_object_size(to, size, false);
217 216
218 ret = ___copy_from_user(to, from, size); 217 ret = ___copy_from_user(to, from, size);
219 if (unlikely(ret)) 218 if (unlikely(ret))
@@ -233,8 +232,8 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
233{ 232{
234 unsigned long ret; 233 unsigned long ret;
235 234
236 if (!__builtin_constant_p(size)) 235 check_object_size(from, size, true);
237 check_object_size(from, size, true); 236
238 ret = ___copy_to_user(to, from, size); 237 ret = ___copy_to_user(to, from, size);
239 if (unlikely(ret)) 238 if (unlikely(ret))
240 ret = copy_to_user_fixup(to, from, size); 239 ret = copy_to_user_fixup(to, from, size);
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
index ef4b8f949b51..b783ac87d98a 100644
--- a/arch/um/kernel/skas/syscall.c
+++ b/arch/um/kernel/skas/syscall.c
@@ -21,21 +21,17 @@ void handle_syscall(struct uml_pt_regs *r)
21 PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS); 21 PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
22 22
23 if (syscall_trace_enter(regs)) 23 if (syscall_trace_enter(regs))
24 return; 24 goto out;
25 25
26 /* Do the seccomp check after ptrace; failures should be fast. */ 26 /* Do the seccomp check after ptrace; failures should be fast. */
27 if (secure_computing(NULL) == -1) 27 if (secure_computing(NULL) == -1)
28 return; 28 goto out;
29 29
30 /* Update the syscall number after orig_ax has potentially been updated
31 * with ptrace.
32 */
33 UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
34 syscall = UPT_SYSCALL_NR(r); 30 syscall = UPT_SYSCALL_NR(r);
35
36 if (syscall >= 0 && syscall <= __NR_syscall_max) 31 if (syscall >= 0 && syscall <= __NR_syscall_max)
37 PT_REGS_SET_SYSCALL_RETURN(regs, 32 PT_REGS_SET_SYSCALL_RETURN(regs,
38 EXECUTE_SYSCALL(syscall, regs)); 33 EXECUTE_SYSCALL(syscall, regs));
39 34
35out:
40 syscall_trace_leave(regs); 36 syscall_trace_leave(regs);
41} 37}
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index c3f291195294..e3af86f58eaf 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -705,7 +705,7 @@ static inline void copy_user_overflow(int size, unsigned long count)
705 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); 705 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
706} 706}
707 707
708static inline unsigned long __must_check 708static __always_inline unsigned long __must_check
709copy_from_user(void *to, const void __user *from, unsigned long n) 709copy_from_user(void *to, const void __user *from, unsigned long n)
710{ 710{
711 int sz = __compiletime_object_size(to); 711 int sz = __compiletime_object_size(to);
@@ -725,7 +725,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
725 return n; 725 return n;
726} 726}
727 727
728static inline unsigned long __must_check 728static __always_inline unsigned long __must_check
729copy_to_user(void __user *to, const void *from, unsigned long n) 729copy_to_user(void __user *to, const void *from, unsigned long n)
730{ 730{
731 int sz = __compiletime_object_size(from); 731 int sz = __compiletime_object_size(from);
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index ecb1b69c1651..170cc4ff057b 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma)
927} 927}
928 928
929/* 929/*
930 * prot is passed in as a parameter for the new mapping. If the vma has a 930 * prot is passed in as a parameter for the new mapping. If the vma has
931 * linear pfn mapping for the entire range reserve the entire vma range with 931 * a linear pfn mapping for the entire range, or no vma is provided,
932 * single reserve_pfn_range call. 932 * reserve the entire pfn + size range with single reserve_pfn_range
933 * call.
933 */ 934 */
934int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, 935int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot,
935 unsigned long pfn, unsigned long addr, unsigned long size) 936 unsigned long pfn, unsigned long addr, unsigned long size)
@@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot,
938 enum page_cache_mode pcm; 939 enum page_cache_mode pcm;
939 940
940 /* reserve the whole chunk starting from paddr */ 941 /* reserve the whole chunk starting from paddr */
941 if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { 942 if (!vma || (addr == vma->vm_start
943 && size == (vma->vm_end - vma->vm_start))) {
942 int ret; 944 int ret;
943 945
944 ret = reserve_pfn_range(paddr, size, prot, 0); 946 ret = reserve_pfn_range(paddr, size, prot, 0);
945 if (!ret) 947 if (ret == 0 && vma)
946 vma->vm_flags |= VM_PAT; 948 vma->vm_flags |= VM_PAT;
947 return ret; 949 return ret;
948 } 950 }
@@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
997 resource_size_t paddr; 999 resource_size_t paddr;
998 unsigned long prot; 1000 unsigned long prot;
999 1001
1000 if (!(vma->vm_flags & VM_PAT)) 1002 if (vma && !(vma->vm_flags & VM_PAT))
1001 return; 1003 return;
1002 1004
1003 /* free the chunk starting from pfn or the whole chunk */ 1005 /* free the chunk starting from pfn or the whole chunk */
@@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
1011 size = vma->vm_end - vma->vm_start; 1013 size = vma->vm_end - vma->vm_start;
1012 } 1014 }
1013 free_pfn_range(paddr, size); 1015 free_pfn_range(paddr, size);
1014 vma->vm_flags &= ~VM_PAT; 1016 if (vma)
1017 vma->vm_flags &= ~VM_PAT;
1015} 1018}
1016 1019
1017/* 1020/*
diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c
index ebd4dd6ef73b..a7ef7b131e25 100644
--- a/arch/x86/um/ptrace_32.c
+++ b/arch/x86/um/ptrace_32.c
@@ -84,7 +84,10 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
84 case EAX: 84 case EAX:
85 case EIP: 85 case EIP:
86 case UESP: 86 case UESP:
87 break;
87 case ORIG_EAX: 88 case ORIG_EAX:
89 /* Update the syscall number. */
90 UPT_SYSCALL_NR(&child->thread.regs.regs) = value;
88 break; 91 break;
89 case FS: 92 case FS:
90 if (value && (value & 3) != 3) 93 if (value && (value & 3) != 3)
diff --git a/arch/x86/um/ptrace_64.c b/arch/x86/um/ptrace_64.c
index faab418876ce..0b5c184dd5b3 100644
--- a/arch/x86/um/ptrace_64.c
+++ b/arch/x86/um/ptrace_64.c
@@ -78,7 +78,11 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
78 case RSI: 78 case RSI:
79 case RDI: 79 case RDI:
80 case RBP: 80 case RBP:
81 break;
82
81 case ORIG_RAX: 83 case ORIG_RAX:
84 /* Update the syscall number. */
85 UPT_SYSCALL_NR(&child->thread.regs.regs) = value;
82 break; 86 break;
83 87
84 case FS: 88 case FS:
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index cf8037a87b2d..77207b41940c 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -733,13 +733,14 @@ static void cryptd_aead_crypt(struct aead_request *req,
733 rctx = aead_request_ctx(req); 733 rctx = aead_request_ctx(req);
734 compl = rctx->complete; 734 compl = rctx->complete;
735 735
736 tfm = crypto_aead_reqtfm(req);
737
736 if (unlikely(err == -EINPROGRESS)) 738 if (unlikely(err == -EINPROGRESS))
737 goto out; 739 goto out;
738 aead_request_set_tfm(req, child); 740 aead_request_set_tfm(req, child);
739 err = crypt( req ); 741 err = crypt( req );
740 742
741out: 743out:
742 tfm = crypto_aead_reqtfm(req);
743 ctx = crypto_aead_ctx(tfm); 744 ctx = crypto_aead_ctx(tfm);
744 refcnt = atomic_read(&ctx->refcnt); 745 refcnt = atomic_read(&ctx->refcnt);
745 746
diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c
index 4c745bf389fe..161f91539ae6 100644
--- a/drivers/acpi/nfit/mce.c
+++ b/drivers/acpi/nfit/mce.c
@@ -42,7 +42,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
42 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { 42 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
43 struct acpi_nfit_system_address *spa = nfit_spa->spa; 43 struct acpi_nfit_system_address *spa = nfit_spa->spa;
44 44
45 if (nfit_spa_type(spa) == NFIT_SPA_PM) 45 if (nfit_spa_type(spa) != NFIT_SPA_PM)
46 continue; 46 continue;
47 /* find the spa that covers the mce addr */ 47 /* find the spa that covers the mce addr */
48 if (spa->address > mce->addr) 48 if (spa->address > mce->addr)
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index aa56af87d941..b11af3f2c1db 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -404,6 +404,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
404 unsigned int new_base_reg, new_top_reg; 404 unsigned int new_base_reg, new_top_reg;
405 unsigned int min, max; 405 unsigned int min, max;
406 unsigned int max_dist; 406 unsigned int max_dist;
407 unsigned int dist, best_dist = UINT_MAX;
407 408
408 max_dist = map->reg_stride * sizeof(*rbnode_tmp) / 409 max_dist = map->reg_stride * sizeof(*rbnode_tmp) /
409 map->cache_word_size; 410 map->cache_word_size;
@@ -423,24 +424,41 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
423 &base_reg, &top_reg); 424 &base_reg, &top_reg);
424 425
425 if (base_reg <= max && top_reg >= min) { 426 if (base_reg <= max && top_reg >= min) {
426 new_base_reg = min(reg, base_reg); 427 if (reg < base_reg)
427 new_top_reg = max(reg, top_reg); 428 dist = base_reg - reg;
428 } else { 429 else if (reg > top_reg)
429 if (max < base_reg) 430 dist = reg - top_reg;
430 node = node->rb_left;
431 else 431 else
432 node = node->rb_right; 432 dist = 0;
433 433 if (dist < best_dist) {
434 continue; 434 rbnode = rbnode_tmp;
435 best_dist = dist;
436 new_base_reg = min(reg, base_reg);
437 new_top_reg = max(reg, top_reg);
438 }
435 } 439 }
436 440
437 ret = regcache_rbtree_insert_to_block(map, rbnode_tmp, 441 /*
442 * Keep looking, we want to choose the closest block,
443 * otherwise we might end up creating overlapping
444 * blocks, which breaks the rbtree.
445 */
446 if (reg < base_reg)
447 node = node->rb_left;
448 else if (reg > top_reg)
449 node = node->rb_right;
450 else
451 break;
452 }
453
454 if (rbnode) {
455 ret = regcache_rbtree_insert_to_block(map, rbnode,
438 new_base_reg, 456 new_base_reg,
439 new_top_reg, reg, 457 new_top_reg, reg,
440 value); 458 value);
441 if (ret) 459 if (ret)
442 return ret; 460 return ret;
443 rbtree_ctx->cached_rbnode = rbnode_tmp; 461 rbtree_ctx->cached_rbnode = rbnode;
444 return 0; 462 return 0;
445 } 463 }
446 464
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index df7ff7290821..4e582561e1e7 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -38,10 +38,11 @@ static int regcache_hw_init(struct regmap *map)
38 38
39 /* calculate the size of reg_defaults */ 39 /* calculate the size of reg_defaults */
40 for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++) 40 for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++)
41 if (!regmap_volatile(map, i * map->reg_stride)) 41 if (regmap_readable(map, i * map->reg_stride) &&
42 !regmap_volatile(map, i * map->reg_stride))
42 count++; 43 count++;
43 44
44 /* all registers are volatile, so just bypass */ 45 /* all registers are unreadable or volatile, so just bypass */
45 if (!count) { 46 if (!count) {
46 map->cache_bypass = true; 47 map->cache_bypass = true;
47 return 0; 48 return 0;
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 51fa7d66a393..25d26bb18970 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1474,6 +1474,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
1474 ret = map->bus->write(map->bus_context, buf, len); 1474 ret = map->bus->write(map->bus_context, buf, len);
1475 1475
1476 kfree(buf); 1476 kfree(buf);
1477 } else if (ret != 0 && !map->cache_bypass && map->format.parse_val) {
1478 regcache_drop_region(map, reg, reg + 1);
1477 } 1479 }
1478 1480
1479 trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes); 1481 trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes);
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 5755907f836f..ffa7c9dcbd7a 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -551,7 +551,7 @@ static struct attribute *cci5xx_pmu_event_attrs[] = {
551 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_wrq, 0xB), 551 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_wrq, 0xB),
552 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_cd_hs, 0xC), 552 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_cd_hs, 0xC),
553 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_rq_stall_addr_hazard, 0xD), 553 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_rq_stall_addr_hazard, 0xD),
554 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snopp_rq_stall_tt_full, 0xE), 554 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_stall_tt_full, 0xE),
555 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_tzmp1_prot, 0xF), 555 CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_tzmp1_prot, 0xF),
556 NULL 556 NULL
557}; 557};
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 97a9185af433..884c0305e290 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -187,6 +187,7 @@ struct arm_ccn {
187 struct arm_ccn_component *xp; 187 struct arm_ccn_component *xp;
188 188
189 struct arm_ccn_dt dt; 189 struct arm_ccn_dt dt;
190 int mn_id;
190}; 191};
191 192
192static DEFINE_MUTEX(arm_ccn_mutex); 193static DEFINE_MUTEX(arm_ccn_mutex);
@@ -212,6 +213,7 @@ static int arm_ccn_node_to_xp_port(int node)
212#define CCN_CONFIG_TYPE(_config) (((_config) >> 8) & 0xff) 213#define CCN_CONFIG_TYPE(_config) (((_config) >> 8) & 0xff)
213#define CCN_CONFIG_EVENT(_config) (((_config) >> 16) & 0xff) 214#define CCN_CONFIG_EVENT(_config) (((_config) >> 16) & 0xff)
214#define CCN_CONFIG_PORT(_config) (((_config) >> 24) & 0x3) 215#define CCN_CONFIG_PORT(_config) (((_config) >> 24) & 0x3)
216#define CCN_CONFIG_BUS(_config) (((_config) >> 24) & 0x3)
215#define CCN_CONFIG_VC(_config) (((_config) >> 26) & 0x7) 217#define CCN_CONFIG_VC(_config) (((_config) >> 26) & 0x7)
216#define CCN_CONFIG_DIR(_config) (((_config) >> 29) & 0x1) 218#define CCN_CONFIG_DIR(_config) (((_config) >> 29) & 0x1)
217#define CCN_CONFIG_MASK(_config) (((_config) >> 30) & 0xf) 219#define CCN_CONFIG_MASK(_config) (((_config) >> 30) & 0xf)
@@ -241,6 +243,7 @@ static CCN_FORMAT_ATTR(xp, "config:0-7");
241static CCN_FORMAT_ATTR(type, "config:8-15"); 243static CCN_FORMAT_ATTR(type, "config:8-15");
242static CCN_FORMAT_ATTR(event, "config:16-23"); 244static CCN_FORMAT_ATTR(event, "config:16-23");
243static CCN_FORMAT_ATTR(port, "config:24-25"); 245static CCN_FORMAT_ATTR(port, "config:24-25");
246static CCN_FORMAT_ATTR(bus, "config:24-25");
244static CCN_FORMAT_ATTR(vc, "config:26-28"); 247static CCN_FORMAT_ATTR(vc, "config:26-28");
245static CCN_FORMAT_ATTR(dir, "config:29-29"); 248static CCN_FORMAT_ATTR(dir, "config:29-29");
246static CCN_FORMAT_ATTR(mask, "config:30-33"); 249static CCN_FORMAT_ATTR(mask, "config:30-33");
@@ -253,6 +256,7 @@ static struct attribute *arm_ccn_pmu_format_attrs[] = {
253 &arm_ccn_pmu_format_attr_type.attr.attr, 256 &arm_ccn_pmu_format_attr_type.attr.attr,
254 &arm_ccn_pmu_format_attr_event.attr.attr, 257 &arm_ccn_pmu_format_attr_event.attr.attr,
255 &arm_ccn_pmu_format_attr_port.attr.attr, 258 &arm_ccn_pmu_format_attr_port.attr.attr,
259 &arm_ccn_pmu_format_attr_bus.attr.attr,
256 &arm_ccn_pmu_format_attr_vc.attr.attr, 260 &arm_ccn_pmu_format_attr_vc.attr.attr,
257 &arm_ccn_pmu_format_attr_dir.attr.attr, 261 &arm_ccn_pmu_format_attr_dir.attr.attr,
258 &arm_ccn_pmu_format_attr_mask.attr.attr, 262 &arm_ccn_pmu_format_attr_mask.attr.attr,
@@ -328,6 +332,7 @@ struct arm_ccn_pmu_event {
328static ssize_t arm_ccn_pmu_event_show(struct device *dev, 332static ssize_t arm_ccn_pmu_event_show(struct device *dev,
329 struct device_attribute *attr, char *buf) 333 struct device_attribute *attr, char *buf)
330{ 334{
335 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
331 struct arm_ccn_pmu_event *event = container_of(attr, 336 struct arm_ccn_pmu_event *event = container_of(attr,
332 struct arm_ccn_pmu_event, attr); 337 struct arm_ccn_pmu_event, attr);
333 ssize_t res; 338 ssize_t res;
@@ -349,10 +354,17 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
349 break; 354 break;
350 case CCN_TYPE_XP: 355 case CCN_TYPE_XP:
351 res += snprintf(buf + res, PAGE_SIZE - res, 356 res += snprintf(buf + res, PAGE_SIZE - res,
352 ",xp=?,port=?,vc=?,dir=?"); 357 ",xp=?,vc=?");
353 if (event->event == CCN_EVENT_WATCHPOINT) 358 if (event->event == CCN_EVENT_WATCHPOINT)
354 res += snprintf(buf + res, PAGE_SIZE - res, 359 res += snprintf(buf + res, PAGE_SIZE - res,
355 ",cmp_l=?,cmp_h=?,mask=?"); 360 ",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?");
361 else
362 res += snprintf(buf + res, PAGE_SIZE - res,
363 ",bus=?");
364
365 break;
366 case CCN_TYPE_MN:
367 res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id);
356 break; 368 break;
357 default: 369 default:
358 res += snprintf(buf + res, PAGE_SIZE - res, ",node=?"); 370 res += snprintf(buf + res, PAGE_SIZE - res, ",node=?");
@@ -383,9 +395,9 @@ static umode_t arm_ccn_pmu_events_is_visible(struct kobject *kobj,
383} 395}
384 396
385static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = { 397static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = {
386 CCN_EVENT_MN(eobarrier, "dir=0,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE), 398 CCN_EVENT_MN(eobarrier, "dir=1,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE),
387 CCN_EVENT_MN(ecbarrier, "dir=0,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE), 399 CCN_EVENT_MN(ecbarrier, "dir=1,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE),
388 CCN_EVENT_MN(dvmop, "dir=0,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE), 400 CCN_EVENT_MN(dvmop, "dir=1,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE),
389 CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY), 401 CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY),
390 CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY), 402 CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY),
391 CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY), 403 CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY),
@@ -733,9 +745,10 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
733 745
734 if (has_branch_stack(event) || event->attr.exclude_user || 746 if (has_branch_stack(event) || event->attr.exclude_user ||
735 event->attr.exclude_kernel || event->attr.exclude_hv || 747 event->attr.exclude_kernel || event->attr.exclude_hv ||
736 event->attr.exclude_idle) { 748 event->attr.exclude_idle || event->attr.exclude_host ||
749 event->attr.exclude_guest) {
737 dev_warn(ccn->dev, "Can't exclude execution levels!\n"); 750 dev_warn(ccn->dev, "Can't exclude execution levels!\n");
738 return -EOPNOTSUPP; 751 return -EINVAL;
739 } 752 }
740 753
741 if (event->cpu < 0) { 754 if (event->cpu < 0) {
@@ -759,6 +772,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
759 772
760 /* Validate node/xp vs topology */ 773 /* Validate node/xp vs topology */
761 switch (type) { 774 switch (type) {
775 case CCN_TYPE_MN:
776 if (node_xp != ccn->mn_id) {
777 dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp);
778 return -EINVAL;
779 }
780 break;
762 case CCN_TYPE_XP: 781 case CCN_TYPE_XP:
763 if (node_xp >= ccn->num_xps) { 782 if (node_xp >= ccn->num_xps) {
764 dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp); 783 dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp);
@@ -886,6 +905,10 @@ static void arm_ccn_pmu_xp_dt_config(struct perf_event *event, int enable)
886 struct arm_ccn_component *xp; 905 struct arm_ccn_component *xp;
887 u32 val, dt_cfg; 906 u32 val, dt_cfg;
888 907
908 /* Nothing to do for cycle counter */
909 if (hw->idx == CCN_IDX_PMU_CYCLE_COUNTER)
910 return;
911
889 if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP) 912 if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP)
890 xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)]; 913 xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)];
891 else 914 else
@@ -917,38 +940,17 @@ static void arm_ccn_pmu_event_start(struct perf_event *event, int flags)
917 arm_ccn_pmu_read_counter(ccn, hw->idx)); 940 arm_ccn_pmu_read_counter(ccn, hw->idx));
918 hw->state = 0; 941 hw->state = 0;
919 942
920 /*
921 * Pin the timer, so that the overflows are handled by the chosen
922 * event->cpu (this is the same one as presented in "cpumask"
923 * attribute).
924 */
925 if (!ccn->irq)
926 hrtimer_start(&ccn->dt.hrtimer, arm_ccn_pmu_timer_period(),
927 HRTIMER_MODE_REL_PINNED);
928
929 /* Set the DT bus input, engaging the counter */ 943 /* Set the DT bus input, engaging the counter */
930 arm_ccn_pmu_xp_dt_config(event, 1); 944 arm_ccn_pmu_xp_dt_config(event, 1);
931} 945}
932 946
933static void arm_ccn_pmu_event_stop(struct perf_event *event, int flags) 947static void arm_ccn_pmu_event_stop(struct perf_event *event, int flags)
934{ 948{
935 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu);
936 struct hw_perf_event *hw = &event->hw; 949 struct hw_perf_event *hw = &event->hw;
937 u64 timeout;
938 950
939 /* Disable counting, setting the DT bus to pass-through mode */ 951 /* Disable counting, setting the DT bus to pass-through mode */
940 arm_ccn_pmu_xp_dt_config(event, 0); 952 arm_ccn_pmu_xp_dt_config(event, 0);
941 953
942 if (!ccn->irq)
943 hrtimer_cancel(&ccn->dt.hrtimer);
944
945 /* Let the DT bus drain */
946 timeout = arm_ccn_pmu_read_counter(ccn, CCN_IDX_PMU_CYCLE_COUNTER) +
947 ccn->num_xps;
948 while (arm_ccn_pmu_read_counter(ccn, CCN_IDX_PMU_CYCLE_COUNTER) <
949 timeout)
950 cpu_relax();
951
952 if (flags & PERF_EF_UPDATE) 954 if (flags & PERF_EF_UPDATE)
953 arm_ccn_pmu_event_update(event); 955 arm_ccn_pmu_event_update(event);
954 956
@@ -988,7 +990,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event)
988 990
989 /* Comparison values */ 991 /* Comparison values */
990 writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp)); 992 writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp));
991 writel((cmp_l >> 32) & 0xefffffff, 993 writel((cmp_l >> 32) & 0x7fffffff,
992 source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4); 994 source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4);
993 writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp)); 995 writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp));
994 writel((cmp_h >> 32) & 0x0fffffff, 996 writel((cmp_h >> 32) & 0x0fffffff,
@@ -996,7 +998,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event)
996 998
997 /* Mask */ 999 /* Mask */
998 writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp)); 1000 writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp));
999 writel((mask_l >> 32) & 0xefffffff, 1001 writel((mask_l >> 32) & 0x7fffffff,
1000 source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4); 1002 source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4);
1001 writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp)); 1003 writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp));
1002 writel((mask_h >> 32) & 0x0fffffff, 1004 writel((mask_h >> 32) & 0x0fffffff,
@@ -1014,7 +1016,7 @@ static void arm_ccn_pmu_xp_event_config(struct perf_event *event)
1014 hw->event_base = CCN_XP_DT_CONFIG__DT_CFG__XP_PMU_EVENT(hw->config_base); 1016 hw->event_base = CCN_XP_DT_CONFIG__DT_CFG__XP_PMU_EVENT(hw->config_base);
1015 1017
1016 id = (CCN_CONFIG_VC(event->attr.config) << 4) | 1018 id = (CCN_CONFIG_VC(event->attr.config) << 4) |
1017 (CCN_CONFIG_PORT(event->attr.config) << 3) | 1019 (CCN_CONFIG_BUS(event->attr.config) << 3) |
1018 (CCN_CONFIG_EVENT(event->attr.config) << 0); 1020 (CCN_CONFIG_EVENT(event->attr.config) << 0);
1019 1021
1020 val = readl(source->base + CCN_XP_PMU_EVENT_SEL); 1022 val = readl(source->base + CCN_XP_PMU_EVENT_SEL);
@@ -1099,15 +1101,31 @@ static void arm_ccn_pmu_event_config(struct perf_event *event)
1099 spin_unlock(&ccn->dt.config_lock); 1101 spin_unlock(&ccn->dt.config_lock);
1100} 1102}
1101 1103
1104static int arm_ccn_pmu_active_counters(struct arm_ccn *ccn)
1105{
1106 return bitmap_weight(ccn->dt.pmu_counters_mask,
1107 CCN_NUM_PMU_EVENT_COUNTERS + 1);
1108}
1109
1102static int arm_ccn_pmu_event_add(struct perf_event *event, int flags) 1110static int arm_ccn_pmu_event_add(struct perf_event *event, int flags)
1103{ 1111{
1104 int err; 1112 int err;
1105 struct hw_perf_event *hw = &event->hw; 1113 struct hw_perf_event *hw = &event->hw;
1114 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu);
1106 1115
1107 err = arm_ccn_pmu_event_alloc(event); 1116 err = arm_ccn_pmu_event_alloc(event);
1108 if (err) 1117 if (err)
1109 return err; 1118 return err;
1110 1119
1120 /*
1121 * Pin the timer, so that the overflows are handled by the chosen
1122 * event->cpu (this is the same one as presented in "cpumask"
1123 * attribute).
1124 */
1125 if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 1)
1126 hrtimer_start(&ccn->dt.hrtimer, arm_ccn_pmu_timer_period(),
1127 HRTIMER_MODE_REL_PINNED);
1128
1111 arm_ccn_pmu_event_config(event); 1129 arm_ccn_pmu_event_config(event);
1112 1130
1113 hw->state = PERF_HES_STOPPED; 1131 hw->state = PERF_HES_STOPPED;
@@ -1120,9 +1138,14 @@ static int arm_ccn_pmu_event_add(struct perf_event *event, int flags)
1120 1138
1121static void arm_ccn_pmu_event_del(struct perf_event *event, int flags) 1139static void arm_ccn_pmu_event_del(struct perf_event *event, int flags)
1122{ 1140{
1141 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu);
1142
1123 arm_ccn_pmu_event_stop(event, PERF_EF_UPDATE); 1143 arm_ccn_pmu_event_stop(event, PERF_EF_UPDATE);
1124 1144
1125 arm_ccn_pmu_event_release(event); 1145 arm_ccn_pmu_event_release(event);
1146
1147 if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 0)
1148 hrtimer_cancel(&ccn->dt.hrtimer);
1126} 1149}
1127 1150
1128static void arm_ccn_pmu_event_read(struct perf_event *event) 1151static void arm_ccn_pmu_event_read(struct perf_event *event)
@@ -1130,6 +1153,24 @@ static void arm_ccn_pmu_event_read(struct perf_event *event)
1130 arm_ccn_pmu_event_update(event); 1153 arm_ccn_pmu_event_update(event);
1131} 1154}
1132 1155
1156static void arm_ccn_pmu_enable(struct pmu *pmu)
1157{
1158 struct arm_ccn *ccn = pmu_to_arm_ccn(pmu);
1159
1160 u32 val = readl(ccn->dt.base + CCN_DT_PMCR);
1161 val |= CCN_DT_PMCR__PMU_EN;
1162 writel(val, ccn->dt.base + CCN_DT_PMCR);
1163}
1164
1165static void arm_ccn_pmu_disable(struct pmu *pmu)
1166{
1167 struct arm_ccn *ccn = pmu_to_arm_ccn(pmu);
1168
1169 u32 val = readl(ccn->dt.base + CCN_DT_PMCR);
1170 val &= ~CCN_DT_PMCR__PMU_EN;
1171 writel(val, ccn->dt.base + CCN_DT_PMCR);
1172}
1173
1133static irqreturn_t arm_ccn_pmu_overflow_handler(struct arm_ccn_dt *dt) 1174static irqreturn_t arm_ccn_pmu_overflow_handler(struct arm_ccn_dt *dt)
1134{ 1175{
1135 u32 pmovsr = readl(dt->base + CCN_DT_PMOVSR); 1176 u32 pmovsr = readl(dt->base + CCN_DT_PMOVSR);
@@ -1252,6 +1293,8 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
1252 .start = arm_ccn_pmu_event_start, 1293 .start = arm_ccn_pmu_event_start,
1253 .stop = arm_ccn_pmu_event_stop, 1294 .stop = arm_ccn_pmu_event_stop,
1254 .read = arm_ccn_pmu_event_read, 1295 .read = arm_ccn_pmu_event_read,
1296 .pmu_enable = arm_ccn_pmu_enable,
1297 .pmu_disable = arm_ccn_pmu_disable,
1255 }; 1298 };
1256 1299
1257 /* No overflow interrupt? Have to use a timer instead. */ 1300 /* No overflow interrupt? Have to use a timer instead. */
@@ -1361,6 +1404,8 @@ static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region,
1361 1404
1362 switch (type) { 1405 switch (type) {
1363 case CCN_TYPE_MN: 1406 case CCN_TYPE_MN:
1407 ccn->mn_id = id;
1408 return 0;
1364 case CCN_TYPE_DT: 1409 case CCN_TYPE_DT:
1365 return 0; 1410 return 0;
1366 case CCN_TYPE_XP: 1411 case CCN_TYPE_XP:
@@ -1471,8 +1516,9 @@ static int arm_ccn_probe(struct platform_device *pdev)
1471 /* Can set 'disable' bits, so can acknowledge interrupts */ 1516 /* Can set 'disable' bits, so can acknowledge interrupts */
1472 writel(CCN_MN_ERRINT_STATUS__PMU_EVENTS__ENABLE, 1517 writel(CCN_MN_ERRINT_STATUS__PMU_EVENTS__ENABLE,
1473 ccn->base + CCN_MN_ERRINT_STATUS); 1518 ccn->base + CCN_MN_ERRINT_STATUS);
1474 err = devm_request_irq(ccn->dev, irq, arm_ccn_irq_handler, 0, 1519 err = devm_request_irq(ccn->dev, irq, arm_ccn_irq_handler,
1475 dev_name(ccn->dev), ccn); 1520 IRQF_NOBALANCING | IRQF_NO_THREAD,
1521 dev_name(ccn->dev), ccn);
1476 if (err) 1522 if (err)
1477 return err; 1523 return err;
1478 1524
diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c
index c3cb76b363c6..9efdf1de4035 100644
--- a/drivers/bus/vexpress-config.c
+++ b/drivers/bus/vexpress-config.c
@@ -178,6 +178,7 @@ static int vexpress_config_populate(struct device_node *node)
178 178
179 parent = class_find_device(vexpress_config_class, NULL, bridge, 179 parent = class_find_device(vexpress_config_class, NULL, bridge,
180 vexpress_config_node_match); 180 vexpress_config_node_match);
181 of_node_put(bridge);
181 if (WARN_ON(!parent)) 182 if (WARN_ON(!parent))
182 return -ENODEV; 183 return -ENODEV;
183 184
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index d2406fe25533..5da47e26a012 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -165,6 +165,12 @@ struct ports_device {
165 */ 165 */
166 struct virtqueue *c_ivq, *c_ovq; 166 struct virtqueue *c_ivq, *c_ovq;
167 167
168 /*
169 * A control packet buffer for guest->host requests, protected
170 * by c_ovq_lock.
171 */
172 struct virtio_console_control cpkt;
173
168 /* Array of per-port IO virtqueues */ 174 /* Array of per-port IO virtqueues */
169 struct virtqueue **in_vqs, **out_vqs; 175 struct virtqueue **in_vqs, **out_vqs;
170 176
@@ -560,28 +566,29 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id,
560 unsigned int event, unsigned int value) 566 unsigned int event, unsigned int value)
561{ 567{
562 struct scatterlist sg[1]; 568 struct scatterlist sg[1];
563 struct virtio_console_control cpkt;
564 struct virtqueue *vq; 569 struct virtqueue *vq;
565 unsigned int len; 570 unsigned int len;
566 571
567 if (!use_multiport(portdev)) 572 if (!use_multiport(portdev))
568 return 0; 573 return 0;
569 574
570 cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
571 cpkt.event = cpu_to_virtio16(portdev->vdev, event);
572 cpkt.value = cpu_to_virtio16(portdev->vdev, value);
573
574 vq = portdev->c_ovq; 575 vq = portdev->c_ovq;
575 576
576 sg_init_one(sg, &cpkt, sizeof(cpkt));
577
578 spin_lock(&portdev->c_ovq_lock); 577 spin_lock(&portdev->c_ovq_lock);
579 if (virtqueue_add_outbuf(vq, sg, 1, &cpkt, GFP_ATOMIC) == 0) { 578
579 portdev->cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
580 portdev->cpkt.event = cpu_to_virtio16(portdev->vdev, event);
581 portdev->cpkt.value = cpu_to_virtio16(portdev->vdev, value);
582
583 sg_init_one(sg, &portdev->cpkt, sizeof(struct virtio_console_control));
584
585 if (virtqueue_add_outbuf(vq, sg, 1, &portdev->cpkt, GFP_ATOMIC) == 0) {
580 virtqueue_kick(vq); 586 virtqueue_kick(vq);
581 while (!virtqueue_get_buf(vq, &len) 587 while (!virtqueue_get_buf(vq, &len)
582 && !virtqueue_is_broken(vq)) 588 && !virtqueue_is_broken(vq))
583 cpu_relax(); 589 cpu_relax();
584 } 590 }
591
585 spin_unlock(&portdev->c_ovq_lock); 592 spin_unlock(&portdev->c_ovq_lock);
586 return 0; 593 return 0;
587} 594}
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 6dc597126b79..b3044219772c 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -556,7 +556,10 @@ skip_enc:
556 556
557 /* Read and write assoclen bytes */ 557 /* Read and write assoclen bytes */
558 append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); 558 append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ);
559 append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); 559 if (alg->caam.geniv)
560 append_math_add_imm_u32(desc, VARSEQOUTLEN, REG3, IMM, ivsize);
561 else
562 append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ);
560 563
561 /* Skip assoc data */ 564 /* Skip assoc data */
562 append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); 565 append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF);
@@ -565,6 +568,14 @@ skip_enc:
565 append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | 568 append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG |
566 KEY_VLF); 569 KEY_VLF);
567 570
571 if (alg->caam.geniv) {
572 append_seq_load(desc, ivsize, LDST_CLASS_1_CCB |
573 LDST_SRCDST_BYTE_CONTEXT |
574 (ctx1_iv_off << LDST_OFFSET_SHIFT));
575 append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_CLASS2INFIFO |
576 (ctx1_iv_off << MOVE_OFFSET_SHIFT) | ivsize);
577 }
578
568 /* Load Counter into CONTEXT1 reg */ 579 /* Load Counter into CONTEXT1 reg */
569 if (is_rfc3686) 580 if (is_rfc3686)
570 append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM | 581 append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM |
@@ -2150,7 +2161,7 @@ static void init_authenc_job(struct aead_request *req,
2150 2161
2151 init_aead_job(req, edesc, all_contig, encrypt); 2162 init_aead_job(req, edesc, all_contig, encrypt);
2152 2163
2153 if (ivsize && (is_rfc3686 || !(alg->caam.geniv && encrypt))) 2164 if (ivsize && ((is_rfc3686 && encrypt) || !alg->caam.geniv))
2154 append_load_as_imm(desc, req->iv, ivsize, 2165 append_load_as_imm(desc, req->iv, ivsize,
2155 LDST_CLASS_1_CCB | 2166 LDST_CLASS_1_CCB |
2156 LDST_SRCDST_BYTE_CONTEXT | 2167 LDST_SRCDST_BYTE_CONTEXT |
@@ -2537,20 +2548,6 @@ static int aead_decrypt(struct aead_request *req)
2537 return ret; 2548 return ret;
2538} 2549}
2539 2550
2540static int aead_givdecrypt(struct aead_request *req)
2541{
2542 struct crypto_aead *aead = crypto_aead_reqtfm(req);
2543 unsigned int ivsize = crypto_aead_ivsize(aead);
2544
2545 if (req->cryptlen < ivsize)
2546 return -EINVAL;
2547
2548 req->cryptlen -= ivsize;
2549 req->assoclen += ivsize;
2550
2551 return aead_decrypt(req);
2552}
2553
2554/* 2551/*
2555 * allocate and map the ablkcipher extended descriptor for ablkcipher 2552 * allocate and map the ablkcipher extended descriptor for ablkcipher
2556 */ 2553 */
@@ -3210,7 +3207,7 @@ static struct caam_aead_alg driver_aeads[] = {
3210 .setkey = aead_setkey, 3207 .setkey = aead_setkey,
3211 .setauthsize = aead_setauthsize, 3208 .setauthsize = aead_setauthsize,
3212 .encrypt = aead_encrypt, 3209 .encrypt = aead_encrypt,
3213 .decrypt = aead_givdecrypt, 3210 .decrypt = aead_decrypt,
3214 .ivsize = AES_BLOCK_SIZE, 3211 .ivsize = AES_BLOCK_SIZE,
3215 .maxauthsize = MD5_DIGEST_SIZE, 3212 .maxauthsize = MD5_DIGEST_SIZE,
3216 }, 3213 },
@@ -3256,7 +3253,7 @@ static struct caam_aead_alg driver_aeads[] = {
3256 .setkey = aead_setkey, 3253 .setkey = aead_setkey,
3257 .setauthsize = aead_setauthsize, 3254 .setauthsize = aead_setauthsize,
3258 .encrypt = aead_encrypt, 3255 .encrypt = aead_encrypt,
3259 .decrypt = aead_givdecrypt, 3256 .decrypt = aead_decrypt,
3260 .ivsize = AES_BLOCK_SIZE, 3257 .ivsize = AES_BLOCK_SIZE,
3261 .maxauthsize = SHA1_DIGEST_SIZE, 3258 .maxauthsize = SHA1_DIGEST_SIZE,
3262 }, 3259 },
@@ -3302,7 +3299,7 @@ static struct caam_aead_alg driver_aeads[] = {
3302 .setkey = aead_setkey, 3299 .setkey = aead_setkey,
3303 .setauthsize = aead_setauthsize, 3300 .setauthsize = aead_setauthsize,
3304 .encrypt = aead_encrypt, 3301 .encrypt = aead_encrypt,
3305 .decrypt = aead_givdecrypt, 3302 .decrypt = aead_decrypt,
3306 .ivsize = AES_BLOCK_SIZE, 3303 .ivsize = AES_BLOCK_SIZE,
3307 .maxauthsize = SHA224_DIGEST_SIZE, 3304 .maxauthsize = SHA224_DIGEST_SIZE,
3308 }, 3305 },
@@ -3348,7 +3345,7 @@ static struct caam_aead_alg driver_aeads[] = {
3348 .setkey = aead_setkey, 3345 .setkey = aead_setkey,
3349 .setauthsize = aead_setauthsize, 3346 .setauthsize = aead_setauthsize,
3350 .encrypt = aead_encrypt, 3347 .encrypt = aead_encrypt,
3351 .decrypt = aead_givdecrypt, 3348 .decrypt = aead_decrypt,
3352 .ivsize = AES_BLOCK_SIZE, 3349 .ivsize = AES_BLOCK_SIZE,
3353 .maxauthsize = SHA256_DIGEST_SIZE, 3350 .maxauthsize = SHA256_DIGEST_SIZE,
3354 }, 3351 },
@@ -3394,7 +3391,7 @@ static struct caam_aead_alg driver_aeads[] = {
3394 .setkey = aead_setkey, 3391 .setkey = aead_setkey,
3395 .setauthsize = aead_setauthsize, 3392 .setauthsize = aead_setauthsize,
3396 .encrypt = aead_encrypt, 3393 .encrypt = aead_encrypt,
3397 .decrypt = aead_givdecrypt, 3394 .decrypt = aead_decrypt,
3398 .ivsize = AES_BLOCK_SIZE, 3395 .ivsize = AES_BLOCK_SIZE,
3399 .maxauthsize = SHA384_DIGEST_SIZE, 3396 .maxauthsize = SHA384_DIGEST_SIZE,
3400 }, 3397 },
@@ -3440,7 +3437,7 @@ static struct caam_aead_alg driver_aeads[] = {
3440 .setkey = aead_setkey, 3437 .setkey = aead_setkey,
3441 .setauthsize = aead_setauthsize, 3438 .setauthsize = aead_setauthsize,
3442 .encrypt = aead_encrypt, 3439 .encrypt = aead_encrypt,
3443 .decrypt = aead_givdecrypt, 3440 .decrypt = aead_decrypt,
3444 .ivsize = AES_BLOCK_SIZE, 3441 .ivsize = AES_BLOCK_SIZE,
3445 .maxauthsize = SHA512_DIGEST_SIZE, 3442 .maxauthsize = SHA512_DIGEST_SIZE,
3446 }, 3443 },
@@ -3486,7 +3483,7 @@ static struct caam_aead_alg driver_aeads[] = {
3486 .setkey = aead_setkey, 3483 .setkey = aead_setkey,
3487 .setauthsize = aead_setauthsize, 3484 .setauthsize = aead_setauthsize,
3488 .encrypt = aead_encrypt, 3485 .encrypt = aead_encrypt,
3489 .decrypt = aead_givdecrypt, 3486 .decrypt = aead_decrypt,
3490 .ivsize = DES3_EDE_BLOCK_SIZE, 3487 .ivsize = DES3_EDE_BLOCK_SIZE,
3491 .maxauthsize = MD5_DIGEST_SIZE, 3488 .maxauthsize = MD5_DIGEST_SIZE,
3492 }, 3489 },
@@ -3534,7 +3531,7 @@ static struct caam_aead_alg driver_aeads[] = {
3534 .setkey = aead_setkey, 3531 .setkey = aead_setkey,
3535 .setauthsize = aead_setauthsize, 3532 .setauthsize = aead_setauthsize,
3536 .encrypt = aead_encrypt, 3533 .encrypt = aead_encrypt,
3537 .decrypt = aead_givdecrypt, 3534 .decrypt = aead_decrypt,
3538 .ivsize = DES3_EDE_BLOCK_SIZE, 3535 .ivsize = DES3_EDE_BLOCK_SIZE,
3539 .maxauthsize = SHA1_DIGEST_SIZE, 3536 .maxauthsize = SHA1_DIGEST_SIZE,
3540 }, 3537 },
@@ -3582,7 +3579,7 @@ static struct caam_aead_alg driver_aeads[] = {
3582 .setkey = aead_setkey, 3579 .setkey = aead_setkey,
3583 .setauthsize = aead_setauthsize, 3580 .setauthsize = aead_setauthsize,
3584 .encrypt = aead_encrypt, 3581 .encrypt = aead_encrypt,
3585 .decrypt = aead_givdecrypt, 3582 .decrypt = aead_decrypt,
3586 .ivsize = DES3_EDE_BLOCK_SIZE, 3583 .ivsize = DES3_EDE_BLOCK_SIZE,
3587 .maxauthsize = SHA224_DIGEST_SIZE, 3584 .maxauthsize = SHA224_DIGEST_SIZE,
3588 }, 3585 },
@@ -3630,7 +3627,7 @@ static struct caam_aead_alg driver_aeads[] = {
3630 .setkey = aead_setkey, 3627 .setkey = aead_setkey,
3631 .setauthsize = aead_setauthsize, 3628 .setauthsize = aead_setauthsize,
3632 .encrypt = aead_encrypt, 3629 .encrypt = aead_encrypt,
3633 .decrypt = aead_givdecrypt, 3630 .decrypt = aead_decrypt,
3634 .ivsize = DES3_EDE_BLOCK_SIZE, 3631 .ivsize = DES3_EDE_BLOCK_SIZE,
3635 .maxauthsize = SHA256_DIGEST_SIZE, 3632 .maxauthsize = SHA256_DIGEST_SIZE,
3636 }, 3633 },
@@ -3678,7 +3675,7 @@ static struct caam_aead_alg driver_aeads[] = {
3678 .setkey = aead_setkey, 3675 .setkey = aead_setkey,
3679 .setauthsize = aead_setauthsize, 3676 .setauthsize = aead_setauthsize,
3680 .encrypt = aead_encrypt, 3677 .encrypt = aead_encrypt,
3681 .decrypt = aead_givdecrypt, 3678 .decrypt = aead_decrypt,
3682 .ivsize = DES3_EDE_BLOCK_SIZE, 3679 .ivsize = DES3_EDE_BLOCK_SIZE,
3683 .maxauthsize = SHA384_DIGEST_SIZE, 3680 .maxauthsize = SHA384_DIGEST_SIZE,
3684 }, 3681 },
@@ -3726,7 +3723,7 @@ static struct caam_aead_alg driver_aeads[] = {
3726 .setkey = aead_setkey, 3723 .setkey = aead_setkey,
3727 .setauthsize = aead_setauthsize, 3724 .setauthsize = aead_setauthsize,
3728 .encrypt = aead_encrypt, 3725 .encrypt = aead_encrypt,
3729 .decrypt = aead_givdecrypt, 3726 .decrypt = aead_decrypt,
3730 .ivsize = DES3_EDE_BLOCK_SIZE, 3727 .ivsize = DES3_EDE_BLOCK_SIZE,
3731 .maxauthsize = SHA512_DIGEST_SIZE, 3728 .maxauthsize = SHA512_DIGEST_SIZE,
3732 }, 3729 },
@@ -3772,7 +3769,7 @@ static struct caam_aead_alg driver_aeads[] = {
3772 .setkey = aead_setkey, 3769 .setkey = aead_setkey,
3773 .setauthsize = aead_setauthsize, 3770 .setauthsize = aead_setauthsize,
3774 .encrypt = aead_encrypt, 3771 .encrypt = aead_encrypt,
3775 .decrypt = aead_givdecrypt, 3772 .decrypt = aead_decrypt,
3776 .ivsize = DES_BLOCK_SIZE, 3773 .ivsize = DES_BLOCK_SIZE,
3777 .maxauthsize = MD5_DIGEST_SIZE, 3774 .maxauthsize = MD5_DIGEST_SIZE,
3778 }, 3775 },
@@ -3818,7 +3815,7 @@ static struct caam_aead_alg driver_aeads[] = {
3818 .setkey = aead_setkey, 3815 .setkey = aead_setkey,
3819 .setauthsize = aead_setauthsize, 3816 .setauthsize = aead_setauthsize,
3820 .encrypt = aead_encrypt, 3817 .encrypt = aead_encrypt,
3821 .decrypt = aead_givdecrypt, 3818 .decrypt = aead_decrypt,
3822 .ivsize = DES_BLOCK_SIZE, 3819 .ivsize = DES_BLOCK_SIZE,
3823 .maxauthsize = SHA1_DIGEST_SIZE, 3820 .maxauthsize = SHA1_DIGEST_SIZE,
3824 }, 3821 },
@@ -3864,7 +3861,7 @@ static struct caam_aead_alg driver_aeads[] = {
3864 .setkey = aead_setkey, 3861 .setkey = aead_setkey,
3865 .setauthsize = aead_setauthsize, 3862 .setauthsize = aead_setauthsize,
3866 .encrypt = aead_encrypt, 3863 .encrypt = aead_encrypt,
3867 .decrypt = aead_givdecrypt, 3864 .decrypt = aead_decrypt,
3868 .ivsize = DES_BLOCK_SIZE, 3865 .ivsize = DES_BLOCK_SIZE,
3869 .maxauthsize = SHA224_DIGEST_SIZE, 3866 .maxauthsize = SHA224_DIGEST_SIZE,
3870 }, 3867 },
@@ -3910,7 +3907,7 @@ static struct caam_aead_alg driver_aeads[] = {
3910 .setkey = aead_setkey, 3907 .setkey = aead_setkey,
3911 .setauthsize = aead_setauthsize, 3908 .setauthsize = aead_setauthsize,
3912 .encrypt = aead_encrypt, 3909 .encrypt = aead_encrypt,
3913 .decrypt = aead_givdecrypt, 3910 .decrypt = aead_decrypt,
3914 .ivsize = DES_BLOCK_SIZE, 3911 .ivsize = DES_BLOCK_SIZE,
3915 .maxauthsize = SHA256_DIGEST_SIZE, 3912 .maxauthsize = SHA256_DIGEST_SIZE,
3916 }, 3913 },
@@ -3956,7 +3953,7 @@ static struct caam_aead_alg driver_aeads[] = {
3956 .setkey = aead_setkey, 3953 .setkey = aead_setkey,
3957 .setauthsize = aead_setauthsize, 3954 .setauthsize = aead_setauthsize,
3958 .encrypt = aead_encrypt, 3955 .encrypt = aead_encrypt,
3959 .decrypt = aead_givdecrypt, 3956 .decrypt = aead_decrypt,
3960 .ivsize = DES_BLOCK_SIZE, 3957 .ivsize = DES_BLOCK_SIZE,
3961 .maxauthsize = SHA384_DIGEST_SIZE, 3958 .maxauthsize = SHA384_DIGEST_SIZE,
3962 }, 3959 },
@@ -4002,7 +3999,7 @@ static struct caam_aead_alg driver_aeads[] = {
4002 .setkey = aead_setkey, 3999 .setkey = aead_setkey,
4003 .setauthsize = aead_setauthsize, 4000 .setauthsize = aead_setauthsize,
4004 .encrypt = aead_encrypt, 4001 .encrypt = aead_encrypt,
4005 .decrypt = aead_givdecrypt, 4002 .decrypt = aead_decrypt,
4006 .ivsize = DES_BLOCK_SIZE, 4003 .ivsize = DES_BLOCK_SIZE,
4007 .maxauthsize = SHA512_DIGEST_SIZE, 4004 .maxauthsize = SHA512_DIGEST_SIZE,
4008 }, 4005 },
@@ -4051,7 +4048,7 @@ static struct caam_aead_alg driver_aeads[] = {
4051 .setkey = aead_setkey, 4048 .setkey = aead_setkey,
4052 .setauthsize = aead_setauthsize, 4049 .setauthsize = aead_setauthsize,
4053 .encrypt = aead_encrypt, 4050 .encrypt = aead_encrypt,
4054 .decrypt = aead_givdecrypt, 4051 .decrypt = aead_decrypt,
4055 .ivsize = CTR_RFC3686_IV_SIZE, 4052 .ivsize = CTR_RFC3686_IV_SIZE,
4056 .maxauthsize = MD5_DIGEST_SIZE, 4053 .maxauthsize = MD5_DIGEST_SIZE,
4057 }, 4054 },
@@ -4102,7 +4099,7 @@ static struct caam_aead_alg driver_aeads[] = {
4102 .setkey = aead_setkey, 4099 .setkey = aead_setkey,
4103 .setauthsize = aead_setauthsize, 4100 .setauthsize = aead_setauthsize,
4104 .encrypt = aead_encrypt, 4101 .encrypt = aead_encrypt,
4105 .decrypt = aead_givdecrypt, 4102 .decrypt = aead_decrypt,
4106 .ivsize = CTR_RFC3686_IV_SIZE, 4103 .ivsize = CTR_RFC3686_IV_SIZE,
4107 .maxauthsize = SHA1_DIGEST_SIZE, 4104 .maxauthsize = SHA1_DIGEST_SIZE,
4108 }, 4105 },
@@ -4153,7 +4150,7 @@ static struct caam_aead_alg driver_aeads[] = {
4153 .setkey = aead_setkey, 4150 .setkey = aead_setkey,
4154 .setauthsize = aead_setauthsize, 4151 .setauthsize = aead_setauthsize,
4155 .encrypt = aead_encrypt, 4152 .encrypt = aead_encrypt,
4156 .decrypt = aead_givdecrypt, 4153 .decrypt = aead_decrypt,
4157 .ivsize = CTR_RFC3686_IV_SIZE, 4154 .ivsize = CTR_RFC3686_IV_SIZE,
4158 .maxauthsize = SHA224_DIGEST_SIZE, 4155 .maxauthsize = SHA224_DIGEST_SIZE,
4159 }, 4156 },
@@ -4204,7 +4201,7 @@ static struct caam_aead_alg driver_aeads[] = {
4204 .setkey = aead_setkey, 4201 .setkey = aead_setkey,
4205 .setauthsize = aead_setauthsize, 4202 .setauthsize = aead_setauthsize,
4206 .encrypt = aead_encrypt, 4203 .encrypt = aead_encrypt,
4207 .decrypt = aead_givdecrypt, 4204 .decrypt = aead_decrypt,
4208 .ivsize = CTR_RFC3686_IV_SIZE, 4205 .ivsize = CTR_RFC3686_IV_SIZE,
4209 .maxauthsize = SHA256_DIGEST_SIZE, 4206 .maxauthsize = SHA256_DIGEST_SIZE,
4210 }, 4207 },
@@ -4255,7 +4252,7 @@ static struct caam_aead_alg driver_aeads[] = {
4255 .setkey = aead_setkey, 4252 .setkey = aead_setkey,
4256 .setauthsize = aead_setauthsize, 4253 .setauthsize = aead_setauthsize,
4257 .encrypt = aead_encrypt, 4254 .encrypt = aead_encrypt,
4258 .decrypt = aead_givdecrypt, 4255 .decrypt = aead_decrypt,
4259 .ivsize = CTR_RFC3686_IV_SIZE, 4256 .ivsize = CTR_RFC3686_IV_SIZE,
4260 .maxauthsize = SHA384_DIGEST_SIZE, 4257 .maxauthsize = SHA384_DIGEST_SIZE,
4261 }, 4258 },
@@ -4306,7 +4303,7 @@ static struct caam_aead_alg driver_aeads[] = {
4306 .setkey = aead_setkey, 4303 .setkey = aead_setkey,
4307 .setauthsize = aead_setauthsize, 4304 .setauthsize = aead_setauthsize,
4308 .encrypt = aead_encrypt, 4305 .encrypt = aead_encrypt,
4309 .decrypt = aead_givdecrypt, 4306 .decrypt = aead_decrypt,
4310 .ivsize = CTR_RFC3686_IV_SIZE, 4307 .ivsize = CTR_RFC3686_IV_SIZE,
4311 .maxauthsize = SHA512_DIGEST_SIZE, 4308 .maxauthsize = SHA512_DIGEST_SIZE,
4312 }, 4309 },
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index 803f3953b341..29f600f2c447 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -459,7 +459,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,
459 } 459 }
460 460
461 pgoff = linear_page_index(vma, pmd_addr); 461 pgoff = linear_page_index(vma, pmd_addr);
462 phys = pgoff_to_phys(dax_dev, pgoff, PAGE_SIZE); 462 phys = pgoff_to_phys(dax_dev, pgoff, PMD_SIZE);
463 if (phys == -1) { 463 if (phys == -1) {
464 dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__, 464 dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__,
465 pgoff); 465 pgoff);
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 438893762076..ce2bc2a38101 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -709,9 +709,10 @@ static int scpi_probe(struct platform_device *pdev)
709 struct mbox_client *cl = &pchan->cl; 709 struct mbox_client *cl = &pchan->cl;
710 struct device_node *shmem = of_parse_phandle(np, "shmem", idx); 710 struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
711 711
712 if (of_address_to_resource(shmem, 0, &res)) { 712 ret = of_address_to_resource(shmem, 0, &res);
713 of_node_put(shmem);
714 if (ret) {
713 dev_err(dev, "failed to get SCPI payload mem resource\n"); 715 dev_err(dev, "failed to get SCPI payload mem resource\n");
714 ret = -EINVAL;
715 goto err; 716 goto err;
716 } 717 }
717 718
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 94a58a082b99..44c01390d035 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -229,14 +229,14 @@ static int __init dmi_id_init(void)
229 229
230 ret = device_register(dmi_dev); 230 ret = device_register(dmi_dev);
231 if (ret) 231 if (ret)
232 goto fail_free_dmi_dev; 232 goto fail_put_dmi_dev;
233 233
234 return 0; 234 return 0;
235 235
236fail_free_dmi_dev: 236fail_put_dmi_dev:
237 kfree(dmi_dev); 237 put_device(dmi_dev);
238fail_class_unregister:
239 238
239fail_class_unregister:
240 class_unregister(&dmi_class); 240 class_unregister(&dmi_class);
241 241
242 return ret; 242 return ret;
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 66a94103798b..24caedb00a7a 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1131,6 +1131,7 @@ menu "SPI or I2C GPIO expanders"
1131 1131
1132config GPIO_MCP23S08 1132config GPIO_MCP23S08
1133 tristate "Microchip MCP23xxx I/O expander" 1133 tristate "Microchip MCP23xxx I/O expander"
1134 depends on OF_GPIO
1134 select GPIOLIB_IRQCHIP 1135 select GPIOLIB_IRQCHIP
1135 help 1136 help
1136 SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 1137 SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index ac22efc1840e..99d37b56c258 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -564,7 +564,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
564 mcp->chip.direction_output = mcp23s08_direction_output; 564 mcp->chip.direction_output = mcp23s08_direction_output;
565 mcp->chip.set = mcp23s08_set; 565 mcp->chip.set = mcp23s08_set;
566 mcp->chip.dbg_show = mcp23s08_dbg_show; 566 mcp->chip.dbg_show = mcp23s08_dbg_show;
567#ifdef CONFIG_OF 567#ifdef CONFIG_OF_GPIO
568 mcp->chip.of_gpio_n_cells = 2; 568 mcp->chip.of_gpio_n_cells = 2;
569 mcp->chip.of_node = dev->of_node; 569 mcp->chip.of_node = dev->of_node;
570#endif 570#endif
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index 0c99e8fb9af3..8d8ee0ebf14c 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -155,7 +155,7 @@ static int sa1100_gpio_irqdomain_map(struct irq_domain *d,
155{ 155{
156 irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, 156 irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip,
157 handle_edge_irq); 157 handle_edge_irq);
158 irq_set_noprobe(irq); 158 irq_set_probe(irq);
159 159
160 return 0; 160 return 0;
161} 161}
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 75e7b3919ea7..a28feb3edf33 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -16,7 +16,6 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/io-mapping.h>
20#include <linux/gpio/consumer.h> 19#include <linux/gpio/consumer.h>
21#include <linux/of.h> 20#include <linux/of.h>
22#include <linux/of_address.h> 21#include <linux/of_address.h>
diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c
index f98743277e3c..258cb9a40ab3 100644
--- a/drivers/i2c/busses/i2c-bcm-kona.c
+++ b/drivers/i2c/busses/i2c-bcm-kona.c
@@ -643,7 +643,7 @@ static int bcm_kona_i2c_xfer(struct i2c_adapter *adapter,
643 if (rc < 0) { 643 if (rc < 0) {
644 dev_err(dev->device, 644 dev_err(dev->device,
645 "restart cmd failed rc = %d\n", rc); 645 "restart cmd failed rc = %d\n", rc);
646 goto xfer_send_stop; 646 goto xfer_send_stop;
647 } 647 }
648 } 648 }
649 649
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 90bbd9f9dd8f..3c16a2f7c673 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -767,7 +767,7 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
767 * depending on the scaling direction. 767 * depending on the scaling direction.
768 * 768 *
769 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK 769 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK
770 * to acknowedge the change, NOTIFY_DONE if the notification is 770 * to acknowledge the change, NOTIFY_DONE if the notification is
771 * considered irrelevant. 771 * considered irrelevant.
772 */ 772 */
773static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long 773static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index c6922b806fb7..fcd973d5131e 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
367 dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); 367 dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
368 368
369 /* Configure SDA Hold Time if required */ 369 /* Configure SDA Hold Time if required */
370 if (dev->sda_hold_time) { 370 reg = dw_readl(dev, DW_IC_COMP_VERSION);
371 reg = dw_readl(dev, DW_IC_COMP_VERSION); 371 if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
372 if (reg >= DW_IC_SDA_HOLD_MIN_VERS) 372 if (dev->sda_hold_time) {
373 dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); 373 dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
374 else 374 } else {
375 dev_warn(dev->dev, 375 /* Keep previous hold time setting if no one set it */
376 "Hardware too old to adjust SDA hold time."); 376 dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD);
377 }
378 } else {
379 dev_warn(dev->dev,
380 "Hardware too old to adjust SDA hold time.\n");
377 } 381 }
378 382
379 /* Configure Tx/Rx FIFO threshold levels */ 383 /* Configure Tx/Rx FIFO threshold levels */
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 52407f3c9e1c..9bd849dacee8 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -378,7 +378,7 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
378 } 378 }
379 379
380 dma_addr = dma_map_single(chan->device->dev, buf, len, dir); 380 dma_addr = dma_map_single(chan->device->dev, buf, len, dir);
381 if (dma_mapping_error(dev, dma_addr)) { 381 if (dma_mapping_error(chan->device->dev, dma_addr)) {
382 dev_dbg(dev, "dma map failed, using PIO\n"); 382 dev_dbg(dev, "dma map failed, using PIO\n");
383 return; 383 return;
384 } 384 }
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index 2bc8b01153d6..5c5b7cada8be 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -918,7 +918,7 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate)
918 * Code adapted from i2c-cadence.c. 918 * Code adapted from i2c-cadence.c.
919 * 919 *
920 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK 920 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK
921 * to acknowedge the change, NOTIFY_DONE if the notification is 921 * to acknowledge the change, NOTIFY_DONE if the notification is
922 * considered irrelevant. 922 * considered irrelevant.
923 */ 923 */
924static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long 924static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
@@ -1111,6 +1111,15 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
1111 return ret < 0 ? ret : num; 1111 return ret < 0 ? ret : num;
1112} 1112}
1113 1113
1114static __maybe_unused int rk3x_i2c_resume(struct device *dev)
1115{
1116 struct rk3x_i2c *i2c = dev_get_drvdata(dev);
1117
1118 rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk));
1119
1120 return 0;
1121}
1122
1114static u32 rk3x_i2c_func(struct i2c_adapter *adap) 1123static u32 rk3x_i2c_func(struct i2c_adapter *adap)
1115{ 1124{
1116 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; 1125 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
@@ -1334,12 +1343,15 @@ static int rk3x_i2c_remove(struct platform_device *pdev)
1334 return 0; 1343 return 0;
1335} 1344}
1336 1345
1346static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);
1347
1337static struct platform_driver rk3x_i2c_driver = { 1348static struct platform_driver rk3x_i2c_driver = {
1338 .probe = rk3x_i2c_probe, 1349 .probe = rk3x_i2c_probe,
1339 .remove = rk3x_i2c_remove, 1350 .remove = rk3x_i2c_remove,
1340 .driver = { 1351 .driver = {
1341 .name = "rk3x-i2c", 1352 .name = "rk3x-i2c",
1342 .of_match_table = rk3x_i2c_match, 1353 .of_match_table = rk3x_i2c_match,
1354 .pm = &rk3x_i2c_pm_ops,
1343 }, 1355 },
1344}; 1356};
1345 1357
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 6fb3e2645992..05b1eeab9cf5 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -610,7 +610,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
610 return; 610 return;
611 611
612 dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); 612 dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir);
613 if (dma_mapping_error(pd->dev, dma_addr)) { 613 if (dma_mapping_error(chan->device->dev, dma_addr)) {
614 dev_dbg(pd->dev, "dma map failed, using PIO\n"); 614 dev_dbg(pd->dev, "dma map failed, using PIO\n");
615 return; 615 return;
616 } 616 }
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 215ac87f606d..b3893f6282ba 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -37,8 +37,6 @@ struct i2c_demux_pinctrl_priv {
37 struct i2c_demux_pinctrl_chan chan[]; 37 struct i2c_demux_pinctrl_chan chan[];
38}; 38};
39 39
40static struct property status_okay = { .name = "status", .length = 3, .value = "ok" };
41
42static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 40static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
43{ 41{
44 struct i2c_demux_pinctrl_priv *priv = adap->algo_data; 42 struct i2c_demux_pinctrl_priv *priv = adap->algo_data;
@@ -107,6 +105,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
107 of_changeset_revert(&priv->chan[new_chan].chgset); 105 of_changeset_revert(&priv->chan[new_chan].chgset);
108 err: 106 err:
109 dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); 107 dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret);
108 priv->cur_chan = -EINVAL;
110 return ret; 109 return ret;
111} 110}
112 111
@@ -192,6 +191,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
192{ 191{
193 struct device_node *np = pdev->dev.of_node; 192 struct device_node *np = pdev->dev.of_node;
194 struct i2c_demux_pinctrl_priv *priv; 193 struct i2c_demux_pinctrl_priv *priv;
194 struct property *props;
195 int num_chan, i, j, err; 195 int num_chan, i, j, err;
196 196
197 num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); 197 num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL);
@@ -202,7 +202,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
202 202
203 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) 203 priv = devm_kzalloc(&pdev->dev, sizeof(*priv)
204 + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); 204 + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL);
205 if (!priv) 205
206 props = devm_kcalloc(&pdev->dev, num_chan, sizeof(*props), GFP_KERNEL);
207
208 if (!priv || !props)
206 return -ENOMEM; 209 return -ENOMEM;
207 210
208 err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); 211 err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name);
@@ -220,8 +223,12 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
220 } 223 }
221 priv->chan[i].parent_np = adap_np; 224 priv->chan[i].parent_np = adap_np;
222 225
226 props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL);
227 props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
228 props[i].length = 3;
229
223 of_changeset_init(&priv->chan[i].chgset); 230 of_changeset_init(&priv->chan[i].chgset);
224 of_changeset_update_property(&priv->chan[i].chgset, adap_np, &status_okay); 231 of_changeset_update_property(&priv->chan[i].chgset, adap_np, &props[i]);
225 } 232 }
226 233
227 priv->num_chan = num_chan; 234 priv->num_chan = num_chan;
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index bf17aae66145..59b380dbf27f 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -67,6 +67,9 @@
67#define BMC150_ACCEL_REG_PMU_BW 0x10 67#define BMC150_ACCEL_REG_PMU_BW 0x10
68#define BMC150_ACCEL_DEF_BW 125 68#define BMC150_ACCEL_DEF_BW 125
69 69
70#define BMC150_ACCEL_REG_RESET 0x14
71#define BMC150_ACCEL_RESET_VAL 0xB6
72
70#define BMC150_ACCEL_REG_INT_MAP_0 0x19 73#define BMC150_ACCEL_REG_INT_MAP_0 0x19
71#define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2) 74#define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2)
72 75
@@ -1497,6 +1500,14 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
1497 int ret, i; 1500 int ret, i;
1498 unsigned int val; 1501 unsigned int val;
1499 1502
1503 /*
1504 * Reset chip to get it in a known good state. A delay of 1.8ms after
1505 * reset is required according to the data sheets of supported chips.
1506 */
1507 regmap_write(data->regmap, BMC150_ACCEL_REG_RESET,
1508 BMC150_ACCEL_RESET_VAL);
1509 usleep_range(1800, 2500);
1510
1500 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); 1511 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val);
1501 if (ret < 0) { 1512 if (ret < 0) {
1502 dev_err(dev, "Error: Reading chip id\n"); 1513 dev_err(dev, "Error: Reading chip id\n");
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index da5fb67ecb34..9d72d4bcf5e9 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -166,6 +166,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
166 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); 166 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
167 if (ret < 0) 167 if (ret < 0)
168 goto error_ret; 168 goto error_ret;
169 *val = 0;
169 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; 170 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];
170 ret = IIO_VAL_INT_PLUS_MICRO; 171 ret = IIO_VAL_INT_PLUS_MICRO;
171 break; 172 break;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index e81f434760f4..dc33c1dd5191 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -56,8 +56,8 @@ static struct {
56 {HID_USAGE_SENSOR_ALS, 0, 1, 0}, 56 {HID_USAGE_SENSOR_ALS, 0, 1, 0},
57 {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, 57 {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0},
58 58
59 {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0}, 59 {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0},
60 {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0}, 60 {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000},
61}; 61};
62 62
63static int pow_10(unsigned power) 63static int pow_10(unsigned power)
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 49bf9c59f117..158aaf44dd95 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -110,7 +110,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
110 DEFINE_WAIT_FUNC(wait, woken_wake_function); 110 DEFINE_WAIT_FUNC(wait, woken_wake_function);
111 size_t datum_size; 111 size_t datum_size;
112 size_t to_wait; 112 size_t to_wait;
113 int ret; 113 int ret = 0;
114 114
115 if (!indio_dev->info) 115 if (!indio_dev->info)
116 return -ENODEV; 116 return -ENODEV;
@@ -153,7 +153,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
153 ret = rb->access->read_first_n(rb, n, buf); 153 ret = rb->access->read_first_n(rb, n, buf);
154 if (ret == 0 && (filp->f_flags & O_NONBLOCK)) 154 if (ret == 0 && (filp->f_flags & O_NONBLOCK))
155 ret = -EAGAIN; 155 ret = -EAGAIN;
156 } while (ret == 0); 156 } while (ret == 0);
157 remove_wait_queue(&rb->pollq, &wait); 157 remove_wait_queue(&rb->pollq, &wait);
158 158
159 return ret; 159 return ret;
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index f914d5d140e4..d2b889918c3e 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -613,9 +613,8 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals)
613 return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); 613 return sprintf(buf, "%d.%09u\n", vals[0], vals[1]);
614 case IIO_VAL_FRACTIONAL: 614 case IIO_VAL_FRACTIONAL:
615 tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); 615 tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]);
616 vals[1] = do_div(tmp, 1000000000LL); 616 vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]);
617 vals[0] = tmp; 617 return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1]));
618 return sprintf(buf, "%d.%09u\n", vals[0], vals[1]);
619 case IIO_VAL_FRACTIONAL_LOG2: 618 case IIO_VAL_FRACTIONAL_LOG2:
620 tmp = (s64)vals[0] * 1000000000LL >> vals[1]; 619 tmp = (s64)vals[0] * 1000000000LL >> vals[1];
621 vals[1] = do_div(tmp, 1000000000LL); 620 vals[1] = do_div(tmp, 1000000000LL);
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c
index 3a3c5d73bbfc..51c79b2fb0b8 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -106,7 +106,6 @@ struct mcast_group {
106 atomic_t refcount; 106 atomic_t refcount;
107 enum mcast_group_state state; 107 enum mcast_group_state state;
108 struct ib_sa_query *query; 108 struct ib_sa_query *query;
109 int query_id;
110 u16 pkey_index; 109 u16 pkey_index;
111 u8 leave_state; 110 u8 leave_state;
112 int retries; 111 int retries;
@@ -340,11 +339,7 @@ static int send_join(struct mcast_group *group, struct mcast_member *member)
340 member->multicast.comp_mask, 339 member->multicast.comp_mask,
341 3000, GFP_KERNEL, join_handler, group, 340 3000, GFP_KERNEL, join_handler, group,
342 &group->query); 341 &group->query);
343 if (ret >= 0) { 342 return (ret > 0) ? 0 : ret;
344 group->query_id = ret;
345 ret = 0;
346 }
347 return ret;
348} 343}
349 344
350static int send_leave(struct mcast_group *group, u8 leave_state) 345static int send_leave(struct mcast_group *group, u8 leave_state)
@@ -364,11 +359,7 @@ static int send_leave(struct mcast_group *group, u8 leave_state)
364 IB_SA_MCMEMBER_REC_JOIN_STATE, 359 IB_SA_MCMEMBER_REC_JOIN_STATE,
365 3000, GFP_KERNEL, leave_handler, 360 3000, GFP_KERNEL, leave_handler,
366 group, &group->query); 361 group, &group->query);
367 if (ret >= 0) { 362 return (ret > 0) ? 0 : ret;
368 group->query_id = ret;
369 ret = 0;
370 }
371 return ret;
372} 363}
373 364
374static void join_group(struct mcast_group *group, struct mcast_member *member, 365static void join_group(struct mcast_group *group, struct mcast_member *member,
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index edb1172b6f54..690435229be7 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -683,7 +683,7 @@ static int build_inv_stag(union t4_wr *wqe, struct ib_send_wr *wr,
683 return 0; 683 return 0;
684} 684}
685 685
686void _free_qp(struct kref *kref) 686static void _free_qp(struct kref *kref)
687{ 687{
688 struct c4iw_qp *qhp; 688 struct c4iw_qp *qhp;
689 689
diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
index b32638d58ae8..cc38004cea42 100644
--- a/drivers/infiniband/hw/hfi1/chip.c
+++ b/drivers/infiniband/hw/hfi1/chip.c
@@ -9490,6 +9490,78 @@ static void init_lcb(struct hfi1_devdata *dd)
9490 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00); 9490 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);
9491} 9491}
9492 9492
9493/*
9494 * Perform a test read on the QSFP. Return 0 on success, -ERRNO
9495 * on error.
9496 */
9497static int test_qsfp_read(struct hfi1_pportdata *ppd)
9498{
9499 int ret;
9500 u8 status;
9501
9502 /* report success if not a QSFP */
9503 if (ppd->port_type != PORT_TYPE_QSFP)
9504 return 0;
9505
9506 /* read byte 2, the status byte */
9507 ret = one_qsfp_read(ppd, ppd->dd->hfi1_id, 2, &status, 1);
9508 if (ret < 0)
9509 return ret;
9510 if (ret != 1)
9511 return -EIO;
9512
9513 return 0; /* success */
9514}
9515
9516/*
9517 * Values for QSFP retry.
9518 *
9519 * Give up after 10s (20 x 500ms). The overall timeout was empirically
9520 * arrived at from experience on a large cluster.
9521 */
9522#define MAX_QSFP_RETRIES 20
9523#define QSFP_RETRY_WAIT 500 /* msec */
9524
9525/*
9526 * Try a QSFP read. If it fails, schedule a retry for later.
9527 * Called on first link activation after driver load.
9528 */
9529static void try_start_link(struct hfi1_pportdata *ppd)
9530{
9531 if (test_qsfp_read(ppd)) {
9532 /* read failed */
9533 if (ppd->qsfp_retry_count >= MAX_QSFP_RETRIES) {
9534 dd_dev_err(ppd->dd, "QSFP not responding, giving up\n");
9535 return;
9536 }
9537 dd_dev_info(ppd->dd,
9538 "QSFP not responding, waiting and retrying %d\n",
9539 (int)ppd->qsfp_retry_count);
9540 ppd->qsfp_retry_count++;
9541 queue_delayed_work(ppd->hfi1_wq, &ppd->start_link_work,
9542 msecs_to_jiffies(QSFP_RETRY_WAIT));
9543 return;
9544 }
9545 ppd->qsfp_retry_count = 0;
9546
9547 /*
9548 * Tune the SerDes to a ballpark setting for optimal signal and bit
9549 * error rate. Needs to be done before starting the link.
9550 */
9551 tune_serdes(ppd);
9552 start_link(ppd);
9553}
9554
9555/*
9556 * Workqueue function to start the link after a delay.
9557 */
9558void handle_start_link(struct work_struct *work)
9559{
9560 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
9561 start_link_work.work);
9562 try_start_link(ppd);
9563}
9564
9493int bringup_serdes(struct hfi1_pportdata *ppd) 9565int bringup_serdes(struct hfi1_pportdata *ppd)
9494{ 9566{
9495 struct hfi1_devdata *dd = ppd->dd; 9567 struct hfi1_devdata *dd = ppd->dd;
@@ -9525,14 +9597,8 @@ int bringup_serdes(struct hfi1_pportdata *ppd)
9525 set_qsfp_int_n(ppd, 1); 9597 set_qsfp_int_n(ppd, 1);
9526 } 9598 }
9527 9599
9528 /* 9600 try_start_link(ppd);
9529 * Tune the SerDes to a ballpark setting for 9601 return 0;
9530 * optimal signal and bit error rate
9531 * Needs to be done before starting the link
9532 */
9533 tune_serdes(ppd);
9534
9535 return start_link(ppd);
9536} 9602}
9537 9603
9538void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) 9604void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)
@@ -9549,6 +9615,10 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)
9549 ppd->driver_link_ready = 0; 9615 ppd->driver_link_ready = 0;
9550 ppd->link_enabled = 0; 9616 ppd->link_enabled = 0;
9551 9617
9618 ppd->qsfp_retry_count = MAX_QSFP_RETRIES; /* prevent more retries */
9619 flush_delayed_work(&ppd->start_link_work);
9620 cancel_delayed_work_sync(&ppd->start_link_work);
9621
9552 ppd->offline_disabled_reason = 9622 ppd->offline_disabled_reason =
9553 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED); 9623 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED);
9554 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0, 9624 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0,
@@ -12865,7 +12935,7 @@ fail:
12865 */ 12935 */
12866static int set_up_context_variables(struct hfi1_devdata *dd) 12936static int set_up_context_variables(struct hfi1_devdata *dd)
12867{ 12937{
12868 int num_kernel_contexts; 12938 unsigned long num_kernel_contexts;
12869 int total_contexts; 12939 int total_contexts;
12870 int ret; 12940 int ret;
12871 unsigned ngroups; 12941 unsigned ngroups;
@@ -12894,9 +12964,9 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
12894 */ 12964 */
12895 if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) { 12965 if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) {
12896 dd_dev_err(dd, 12966 dd_dev_err(dd,
12897 "Reducing # kernel rcv contexts to: %d, from %d\n", 12967 "Reducing # kernel rcv contexts to: %d, from %lu\n",
12898 (int)(dd->chip_send_contexts - num_vls - 1), 12968 (int)(dd->chip_send_contexts - num_vls - 1),
12899 (int)num_kernel_contexts); 12969 num_kernel_contexts);
12900 num_kernel_contexts = dd->chip_send_contexts - num_vls - 1; 12970 num_kernel_contexts = dd->chip_send_contexts - num_vls - 1;
12901 } 12971 }
12902 /* 12972 /*
diff --git a/drivers/infiniband/hw/hfi1/chip.h b/drivers/infiniband/hw/hfi1/chip.h
index ed11107c50fe..e29573769efc 100644
--- a/drivers/infiniband/hw/hfi1/chip.h
+++ b/drivers/infiniband/hw/hfi1/chip.h
@@ -706,6 +706,7 @@ void handle_link_up(struct work_struct *work);
706void handle_link_down(struct work_struct *work); 706void handle_link_down(struct work_struct *work);
707void handle_link_downgrade(struct work_struct *work); 707void handle_link_downgrade(struct work_struct *work);
708void handle_link_bounce(struct work_struct *work); 708void handle_link_bounce(struct work_struct *work);
709void handle_start_link(struct work_struct *work);
709void handle_sma_message(struct work_struct *work); 710void handle_sma_message(struct work_struct *work);
710void reset_qsfp(struct hfi1_pportdata *ppd); 711void reset_qsfp(struct hfi1_pportdata *ppd);
711void qsfp_event(struct work_struct *work); 712void qsfp_event(struct work_struct *work);
diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c
index a49cc88f08a2..5e9be16f6cd3 100644
--- a/drivers/infiniband/hw/hfi1/debugfs.c
+++ b/drivers/infiniband/hw/hfi1/debugfs.c
@@ -59,6 +59,40 @@
59 59
60static struct dentry *hfi1_dbg_root; 60static struct dentry *hfi1_dbg_root;
61 61
62/* wrappers to enforce srcu in seq file */
63static ssize_t hfi1_seq_read(
64 struct file *file,
65 char __user *buf,
66 size_t size,
67 loff_t *ppos)
68{
69 struct dentry *d = file->f_path.dentry;
70 int srcu_idx;
71 ssize_t r;
72
73 r = debugfs_use_file_start(d, &srcu_idx);
74 if (likely(!r))
75 r = seq_read(file, buf, size, ppos);
76 debugfs_use_file_finish(srcu_idx);
77 return r;
78}
79
80static loff_t hfi1_seq_lseek(
81 struct file *file,
82 loff_t offset,
83 int whence)
84{
85 struct dentry *d = file->f_path.dentry;
86 int srcu_idx;
87 loff_t r;
88
89 r = debugfs_use_file_start(d, &srcu_idx);
90 if (likely(!r))
91 r = seq_lseek(file, offset, whence);
92 debugfs_use_file_finish(srcu_idx);
93 return r;
94}
95
62#define private2dd(file) (file_inode(file)->i_private) 96#define private2dd(file) (file_inode(file)->i_private)
63#define private2ppd(file) (file_inode(file)->i_private) 97#define private2ppd(file) (file_inode(file)->i_private)
64 98
@@ -87,8 +121,8 @@ static int _##name##_open(struct inode *inode, struct file *s) \
87static const struct file_operations _##name##_file_ops = { \ 121static const struct file_operations _##name##_file_ops = { \
88 .owner = THIS_MODULE, \ 122 .owner = THIS_MODULE, \
89 .open = _##name##_open, \ 123 .open = _##name##_open, \
90 .read = seq_read, \ 124 .read = hfi1_seq_read, \
91 .llseek = seq_lseek, \ 125 .llseek = hfi1_seq_lseek, \
92 .release = seq_release \ 126 .release = seq_release \
93} 127}
94 128
@@ -105,11 +139,9 @@ do { \
105 DEBUGFS_FILE_CREATE(#name, parent, data, &_##name##_file_ops, S_IRUGO) 139 DEBUGFS_FILE_CREATE(#name, parent, data, &_##name##_file_ops, S_IRUGO)
106 140
107static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos) 141static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos)
108__acquires(RCU)
109{ 142{
110 struct hfi1_opcode_stats_perctx *opstats; 143 struct hfi1_opcode_stats_perctx *opstats;
111 144
112 rcu_read_lock();
113 if (*pos >= ARRAY_SIZE(opstats->stats)) 145 if (*pos >= ARRAY_SIZE(opstats->stats))
114 return NULL; 146 return NULL;
115 return pos; 147 return pos;
@@ -126,9 +158,7 @@ static void *_opcode_stats_seq_next(struct seq_file *s, void *v, loff_t *pos)
126} 158}
127 159
128static void _opcode_stats_seq_stop(struct seq_file *s, void *v) 160static void _opcode_stats_seq_stop(struct seq_file *s, void *v)
129__releases(RCU)
130{ 161{
131 rcu_read_unlock();
132} 162}
133 163
134static int _opcode_stats_seq_show(struct seq_file *s, void *v) 164static int _opcode_stats_seq_show(struct seq_file *s, void *v)
@@ -285,12 +315,10 @@ DEBUGFS_SEQ_FILE_OPEN(qp_stats)
285DEBUGFS_FILE_OPS(qp_stats); 315DEBUGFS_FILE_OPS(qp_stats);
286 316
287static void *_sdes_seq_start(struct seq_file *s, loff_t *pos) 317static void *_sdes_seq_start(struct seq_file *s, loff_t *pos)
288__acquires(RCU)
289{ 318{
290 struct hfi1_ibdev *ibd; 319 struct hfi1_ibdev *ibd;
291 struct hfi1_devdata *dd; 320 struct hfi1_devdata *dd;
292 321
293 rcu_read_lock();
294 ibd = (struct hfi1_ibdev *)s->private; 322 ibd = (struct hfi1_ibdev *)s->private;
295 dd = dd_from_dev(ibd); 323 dd = dd_from_dev(ibd);
296 if (!dd->per_sdma || *pos >= dd->num_sdma) 324 if (!dd->per_sdma || *pos >= dd->num_sdma)
@@ -310,9 +338,7 @@ static void *_sdes_seq_next(struct seq_file *s, void *v, loff_t *pos)
310} 338}
311 339
312static void _sdes_seq_stop(struct seq_file *s, void *v) 340static void _sdes_seq_stop(struct seq_file *s, void *v)
313__releases(RCU)
314{ 341{
315 rcu_read_unlock();
316} 342}
317 343
318static int _sdes_seq_show(struct seq_file *s, void *v) 344static int _sdes_seq_show(struct seq_file *s, void *v)
@@ -339,11 +365,9 @@ static ssize_t dev_counters_read(struct file *file, char __user *buf,
339 struct hfi1_devdata *dd; 365 struct hfi1_devdata *dd;
340 ssize_t rval; 366 ssize_t rval;
341 367
342 rcu_read_lock();
343 dd = private2dd(file); 368 dd = private2dd(file);
344 avail = hfi1_read_cntrs(dd, NULL, &counters); 369 avail = hfi1_read_cntrs(dd, NULL, &counters);
345 rval = simple_read_from_buffer(buf, count, ppos, counters, avail); 370 rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
346 rcu_read_unlock();
347 return rval; 371 return rval;
348} 372}
349 373
@@ -356,11 +380,9 @@ static ssize_t dev_names_read(struct file *file, char __user *buf,
356 struct hfi1_devdata *dd; 380 struct hfi1_devdata *dd;
357 ssize_t rval; 381 ssize_t rval;
358 382
359 rcu_read_lock();
360 dd = private2dd(file); 383 dd = private2dd(file);
361 avail = hfi1_read_cntrs(dd, &names, NULL); 384 avail = hfi1_read_cntrs(dd, &names, NULL);
362 rval = simple_read_from_buffer(buf, count, ppos, names, avail); 385 rval = simple_read_from_buffer(buf, count, ppos, names, avail);
363 rcu_read_unlock();
364 return rval; 386 return rval;
365} 387}
366 388
@@ -383,11 +405,9 @@ static ssize_t portnames_read(struct file *file, char __user *buf,
383 struct hfi1_devdata *dd; 405 struct hfi1_devdata *dd;
384 ssize_t rval; 406 ssize_t rval;
385 407
386 rcu_read_lock();
387 dd = private2dd(file); 408 dd = private2dd(file);
388 avail = hfi1_read_portcntrs(dd->pport, &names, NULL); 409 avail = hfi1_read_portcntrs(dd->pport, &names, NULL);
389 rval = simple_read_from_buffer(buf, count, ppos, names, avail); 410 rval = simple_read_from_buffer(buf, count, ppos, names, avail);
390 rcu_read_unlock();
391 return rval; 411 return rval;
392} 412}
393 413
@@ -400,11 +420,9 @@ static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf,
400 struct hfi1_pportdata *ppd; 420 struct hfi1_pportdata *ppd;
401 ssize_t rval; 421 ssize_t rval;
402 422
403 rcu_read_lock();
404 ppd = private2ppd(file); 423 ppd = private2ppd(file);
405 avail = hfi1_read_portcntrs(ppd, NULL, &counters); 424 avail = hfi1_read_portcntrs(ppd, NULL, &counters);
406 rval = simple_read_from_buffer(buf, count, ppos, counters, avail); 425 rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
407 rcu_read_unlock();
408 return rval; 426 return rval;
409} 427}
410 428
@@ -434,16 +452,13 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf,
434 int used; 452 int used;
435 int i; 453 int i;
436 454
437 rcu_read_lock();
438 ppd = private2ppd(file); 455 ppd = private2ppd(file);
439 dd = ppd->dd; 456 dd = ppd->dd;
440 size = PAGE_SIZE; 457 size = PAGE_SIZE;
441 used = 0; 458 used = 0;
442 tmp = kmalloc(size, GFP_KERNEL); 459 tmp = kmalloc(size, GFP_KERNEL);
443 if (!tmp) { 460 if (!tmp)
444 rcu_read_unlock();
445 return -ENOMEM; 461 return -ENOMEM;
446 }
447 462
448 scratch0 = read_csr(dd, ASIC_CFG_SCRATCH); 463 scratch0 = read_csr(dd, ASIC_CFG_SCRATCH);
449 used += scnprintf(tmp + used, size - used, 464 used += scnprintf(tmp + used, size - used,
@@ -470,7 +485,6 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf,
470 used += scnprintf(tmp + used, size - used, "Write bits to clear\n"); 485 used += scnprintf(tmp + used, size - used, "Write bits to clear\n");
471 486
472 ret = simple_read_from_buffer(buf, count, ppos, tmp, used); 487 ret = simple_read_from_buffer(buf, count, ppos, tmp, used);
473 rcu_read_unlock();
474 kfree(tmp); 488 kfree(tmp);
475 return ret; 489 return ret;
476} 490}
@@ -486,15 +500,12 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf,
486 u64 scratch0; 500 u64 scratch0;
487 u64 clear; 501 u64 clear;
488 502
489 rcu_read_lock();
490 ppd = private2ppd(file); 503 ppd = private2ppd(file);
491 dd = ppd->dd; 504 dd = ppd->dd;
492 505
493 buff = kmalloc(count + 1, GFP_KERNEL); 506 buff = kmalloc(count + 1, GFP_KERNEL);
494 if (!buff) { 507 if (!buff)
495 ret = -ENOMEM; 508 return -ENOMEM;
496 goto do_return;
497 }
498 509
499 ret = copy_from_user(buff, buf, count); 510 ret = copy_from_user(buff, buf, count);
500 if (ret > 0) { 511 if (ret > 0) {
@@ -527,8 +538,6 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf,
527 538
528 do_free: 539 do_free:
529 kfree(buff); 540 kfree(buff);
530 do_return:
531 rcu_read_unlock();
532 return ret; 541 return ret;
533} 542}
534 543
@@ -542,18 +551,14 @@ static ssize_t qsfp_debugfs_dump(struct file *file, char __user *buf,
542 char *tmp; 551 char *tmp;
543 int ret; 552 int ret;
544 553
545 rcu_read_lock();
546 ppd = private2ppd(file); 554 ppd = private2ppd(file);
547 tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); 555 tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
548 if (!tmp) { 556 if (!tmp)
549 rcu_read_unlock();
550 return -ENOMEM; 557 return -ENOMEM;
551 }
552 558
553 ret = qsfp_dump(ppd, tmp, PAGE_SIZE); 559 ret = qsfp_dump(ppd, tmp, PAGE_SIZE);
554 if (ret > 0) 560 if (ret > 0)
555 ret = simple_read_from_buffer(buf, count, ppos, tmp, ret); 561 ret = simple_read_from_buffer(buf, count, ppos, tmp, ret);
556 rcu_read_unlock();
557 kfree(tmp); 562 kfree(tmp);
558 return ret; 563 return ret;
559} 564}
@@ -569,7 +574,6 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf,
569 int offset; 574 int offset;
570 int total_written; 575 int total_written;
571 576
572 rcu_read_lock();
573 ppd = private2ppd(file); 577 ppd = private2ppd(file);
574 578
575 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ 579 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */
@@ -577,16 +581,12 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf,
577 offset = *ppos & 0xffff; 581 offset = *ppos & 0xffff;
578 582
579 /* explicitly reject invalid address 0 to catch cp and cat */ 583 /* explicitly reject invalid address 0 to catch cp and cat */
580 if (i2c_addr == 0) { 584 if (i2c_addr == 0)
581 ret = -EINVAL; 585 return -EINVAL;
582 goto _return;
583 }
584 586
585 buff = kmalloc(count, GFP_KERNEL); 587 buff = kmalloc(count, GFP_KERNEL);
586 if (!buff) { 588 if (!buff)
587 ret = -ENOMEM; 589 return -ENOMEM;
588 goto _return;
589 }
590 590
591 ret = copy_from_user(buff, buf, count); 591 ret = copy_from_user(buff, buf, count);
592 if (ret > 0) { 592 if (ret > 0) {
@@ -606,8 +606,6 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf,
606 606
607 _free: 607 _free:
608 kfree(buff); 608 kfree(buff);
609 _return:
610 rcu_read_unlock();
611 return ret; 609 return ret;
612} 610}
613 611
@@ -636,7 +634,6 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf,
636 int offset; 634 int offset;
637 int total_read; 635 int total_read;
638 636
639 rcu_read_lock();
640 ppd = private2ppd(file); 637 ppd = private2ppd(file);
641 638
642 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ 639 /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */
@@ -644,16 +641,12 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf,
644 offset = *ppos & 0xffff; 641 offset = *ppos & 0xffff;
645 642
646 /* explicitly reject invalid address 0 to catch cp and cat */ 643 /* explicitly reject invalid address 0 to catch cp and cat */
647 if (i2c_addr == 0) { 644 if (i2c_addr == 0)
648 ret = -EINVAL; 645 return -EINVAL;
649 goto _return;
650 }
651 646
652 buff = kmalloc(count, GFP_KERNEL); 647 buff = kmalloc(count, GFP_KERNEL);
653 if (!buff) { 648 if (!buff)
654 ret = -ENOMEM; 649 return -ENOMEM;
655 goto _return;
656 }
657 650
658 total_read = i2c_read(ppd, target, i2c_addr, offset, buff, count); 651 total_read = i2c_read(ppd, target, i2c_addr, offset, buff, count);
659 if (total_read < 0) { 652 if (total_read < 0) {
@@ -673,8 +666,6 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf,
673 666
674 _free: 667 _free:
675 kfree(buff); 668 kfree(buff);
676 _return:
677 rcu_read_unlock();
678 return ret; 669 return ret;
679} 670}
680 671
@@ -701,26 +692,20 @@ static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf,
701 int ret; 692 int ret;
702 int total_written; 693 int total_written;
703 694
704 rcu_read_lock(); 695 if (*ppos + count > QSFP_PAGESIZE * 4) /* base page + page00-page03 */
705 if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */ 696 return -EINVAL;
706 ret = -EINVAL;
707 goto _return;
708 }
709 697
710 ppd = private2ppd(file); 698 ppd = private2ppd(file);
711 699
712 buff = kmalloc(count, GFP_KERNEL); 700 buff = kmalloc(count, GFP_KERNEL);
713 if (!buff) { 701 if (!buff)
714 ret = -ENOMEM; 702 return -ENOMEM;
715 goto _return;
716 }
717 703
718 ret = copy_from_user(buff, buf, count); 704 ret = copy_from_user(buff, buf, count);
719 if (ret > 0) { 705 if (ret > 0) {
720 ret = -EFAULT; 706 ret = -EFAULT;
721 goto _free; 707 goto _free;
722 } 708 }
723
724 total_written = qsfp_write(ppd, target, *ppos, buff, count); 709 total_written = qsfp_write(ppd, target, *ppos, buff, count);
725 if (total_written < 0) { 710 if (total_written < 0) {
726 ret = total_written; 711 ret = total_written;
@@ -733,8 +718,6 @@ static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf,
733 718
734 _free: 719 _free:
735 kfree(buff); 720 kfree(buff);
736 _return:
737 rcu_read_unlock();
738 return ret; 721 return ret;
739} 722}
740 723
@@ -761,7 +744,6 @@ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf,
761 int ret; 744 int ret;
762 int total_read; 745 int total_read;
763 746
764 rcu_read_lock();
765 if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */ 747 if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */
766 ret = -EINVAL; 748 ret = -EINVAL;
767 goto _return; 749 goto _return;
@@ -794,7 +776,6 @@ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf,
794 _free: 776 _free:
795 kfree(buff); 777 kfree(buff);
796 _return: 778 _return:
797 rcu_read_unlock();
798 return ret; 779 return ret;
799} 780}
800 781
@@ -1010,7 +991,6 @@ void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd)
1010 debugfs_remove_recursive(ibd->hfi1_ibdev_dbg); 991 debugfs_remove_recursive(ibd->hfi1_ibdev_dbg);
1011out: 992out:
1012 ibd->hfi1_ibdev_dbg = NULL; 993 ibd->hfi1_ibdev_dbg = NULL;
1013 synchronize_rcu();
1014} 994}
1015 995
1016/* 996/*
@@ -1035,9 +1015,7 @@ static const char * const hfi1_statnames[] = {
1035}; 1015};
1036 1016
1037static void *_driver_stats_names_seq_start(struct seq_file *s, loff_t *pos) 1017static void *_driver_stats_names_seq_start(struct seq_file *s, loff_t *pos)
1038__acquires(RCU)
1039{ 1018{
1040 rcu_read_lock();
1041 if (*pos >= ARRAY_SIZE(hfi1_statnames)) 1019 if (*pos >= ARRAY_SIZE(hfi1_statnames))
1042 return NULL; 1020 return NULL;
1043 return pos; 1021 return pos;
@@ -1055,9 +1033,7 @@ static void *_driver_stats_names_seq_next(
1055} 1033}
1056 1034
1057static void _driver_stats_names_seq_stop(struct seq_file *s, void *v) 1035static void _driver_stats_names_seq_stop(struct seq_file *s, void *v)
1058__releases(RCU)
1059{ 1036{
1060 rcu_read_unlock();
1061} 1037}
1062 1038
1063static int _driver_stats_names_seq_show(struct seq_file *s, void *v) 1039static int _driver_stats_names_seq_show(struct seq_file *s, void *v)
@@ -1073,9 +1049,7 @@ DEBUGFS_SEQ_FILE_OPEN(driver_stats_names)
1073DEBUGFS_FILE_OPS(driver_stats_names); 1049DEBUGFS_FILE_OPS(driver_stats_names);
1074 1050
1075static void *_driver_stats_seq_start(struct seq_file *s, loff_t *pos) 1051static void *_driver_stats_seq_start(struct seq_file *s, loff_t *pos)
1076__acquires(RCU)
1077{ 1052{
1078 rcu_read_lock();
1079 if (*pos >= ARRAY_SIZE(hfi1_statnames)) 1053 if (*pos >= ARRAY_SIZE(hfi1_statnames))
1080 return NULL; 1054 return NULL;
1081 return pos; 1055 return pos;
@@ -1090,9 +1064,7 @@ static void *_driver_stats_seq_next(struct seq_file *s, void *v, loff_t *pos)
1090} 1064}
1091 1065
1092static void _driver_stats_seq_stop(struct seq_file *s, void *v) 1066static void _driver_stats_seq_stop(struct seq_file *s, void *v)
1093__releases(RCU)
1094{ 1067{
1095 rcu_read_unlock();
1096} 1068}
1097 1069
1098static u64 hfi1_sps_ints(void) 1070static u64 hfi1_sps_ints(void)
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index a021e660d482..325ec211370f 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -605,6 +605,7 @@ struct hfi1_pportdata {
605 struct work_struct freeze_work; 605 struct work_struct freeze_work;
606 struct work_struct link_downgrade_work; 606 struct work_struct link_downgrade_work;
607 struct work_struct link_bounce_work; 607 struct work_struct link_bounce_work;
608 struct delayed_work start_link_work;
608 /* host link state variables */ 609 /* host link state variables */
609 struct mutex hls_lock; 610 struct mutex hls_lock;
610 u32 host_link_state; 611 u32 host_link_state;
@@ -659,6 +660,7 @@ struct hfi1_pportdata {
659 u8 linkinit_reason; 660 u8 linkinit_reason;
660 u8 local_tx_rate; /* rate given to 8051 firmware */ 661 u8 local_tx_rate; /* rate given to 8051 firmware */
661 u8 last_pstate; /* info only */ 662 u8 last_pstate; /* info only */
663 u8 qsfp_retry_count;
662 664
663 /* placeholders for IB MAD packet settings */ 665 /* placeholders for IB MAD packet settings */
664 u8 overrun_threshold; 666 u8 overrun_threshold;
@@ -1804,7 +1806,7 @@ extern unsigned int hfi1_max_mtu;
1804extern unsigned int hfi1_cu; 1806extern unsigned int hfi1_cu;
1805extern unsigned int user_credit_return_threshold; 1807extern unsigned int user_credit_return_threshold;
1806extern int num_user_contexts; 1808extern int num_user_contexts;
1807extern unsigned n_krcvqs; 1809extern unsigned long n_krcvqs;
1808extern uint krcvqs[]; 1810extern uint krcvqs[];
1809extern int krcvqsset; 1811extern int krcvqsset;
1810extern uint kdeth_qp; 1812extern uint kdeth_qp;
diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index b7935451093c..384b43d2fd49 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -94,7 +94,7 @@ module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
94MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL"); 94MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL");
95 95
96/* computed based on above array */ 96/* computed based on above array */
97unsigned n_krcvqs; 97unsigned long n_krcvqs;
98 98
99static unsigned hfi1_rcvarr_split = 25; 99static unsigned hfi1_rcvarr_split = 25;
100module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO); 100module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO);
@@ -500,6 +500,7 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
500 INIT_WORK(&ppd->link_downgrade_work, handle_link_downgrade); 500 INIT_WORK(&ppd->link_downgrade_work, handle_link_downgrade);
501 INIT_WORK(&ppd->sma_message_work, handle_sma_message); 501 INIT_WORK(&ppd->sma_message_work, handle_sma_message);
502 INIT_WORK(&ppd->link_bounce_work, handle_link_bounce); 502 INIT_WORK(&ppd->link_bounce_work, handle_link_bounce);
503 INIT_DELAYED_WORK(&ppd->start_link_work, handle_start_link);
503 INIT_WORK(&ppd->linkstate_active_work, receive_interrupt_work); 504 INIT_WORK(&ppd->linkstate_active_work, receive_interrupt_work);
504 INIT_WORK(&ppd->qsfp_info.qsfp_work, qsfp_event); 505 INIT_WORK(&ppd->qsfp_info.qsfp_work, qsfp_event);
505 506
diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 39e42c373a01..7ffc14f21523 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -2604,7 +2604,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp,
2604 u8 lq, num_vls; 2604 u8 lq, num_vls;
2605 u8 res_lli, res_ler; 2605 u8 res_lli, res_ler;
2606 u64 port_mask; 2606 u64 port_mask;
2607 unsigned long port_num; 2607 u8 port_num;
2608 unsigned long vl; 2608 unsigned long vl;
2609 u32 vl_select_mask; 2609 u32 vl_select_mask;
2610 int vfi; 2610 int vfi;
@@ -2638,9 +2638,9 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp,
2638 */ 2638 */
2639 port_mask = be64_to_cpu(req->port_select_mask[3]); 2639 port_mask = be64_to_cpu(req->port_select_mask[3]);
2640 port_num = find_first_bit((unsigned long *)&port_mask, 2640 port_num = find_first_bit((unsigned long *)&port_mask,
2641 sizeof(port_mask)); 2641 sizeof(port_mask) * 8);
2642 2642
2643 if ((u8)port_num != port) { 2643 if (port_num != port) {
2644 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; 2644 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
2645 return reply((struct ib_mad_hdr *)pmp); 2645 return reply((struct ib_mad_hdr *)pmp);
2646 } 2646 }
@@ -2842,7 +2842,7 @@ static int pma_get_opa_porterrors(struct opa_pma_mad *pmp,
2842 */ 2842 */
2843 port_mask = be64_to_cpu(req->port_select_mask[3]); 2843 port_mask = be64_to_cpu(req->port_select_mask[3]);
2844 port_num = find_first_bit((unsigned long *)&port_mask, 2844 port_num = find_first_bit((unsigned long *)&port_mask,
2845 sizeof(port_mask)); 2845 sizeof(port_mask) * 8);
2846 2846
2847 if (port_num != port) { 2847 if (port_num != port) {
2848 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; 2848 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -3015,7 +3015,7 @@ static int pma_get_opa_errorinfo(struct opa_pma_mad *pmp,
3015 */ 3015 */
3016 port_mask = be64_to_cpu(req->port_select_mask[3]); 3016 port_mask = be64_to_cpu(req->port_select_mask[3]);
3017 port_num = find_first_bit((unsigned long *)&port_mask, 3017 port_num = find_first_bit((unsigned long *)&port_mask,
3018 sizeof(port_mask)); 3018 sizeof(port_mask) * 8);
3019 3019
3020 if (port_num != port) { 3020 if (port_num != port) {
3021 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; 3021 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -3252,7 +3252,7 @@ static int pma_set_opa_errorinfo(struct opa_pma_mad *pmp,
3252 */ 3252 */
3253 port_mask = be64_to_cpu(req->port_select_mask[3]); 3253 port_mask = be64_to_cpu(req->port_select_mask[3]);
3254 port_num = find_first_bit((unsigned long *)&port_mask, 3254 port_num = find_first_bit((unsigned long *)&port_mask,
3255 sizeof(port_mask)); 3255 sizeof(port_mask) * 8);
3256 3256
3257 if (port_num != port) { 3257 if (port_num != port) {
3258 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; 3258 pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
diff --git a/drivers/infiniband/hw/hfi1/pio_copy.c b/drivers/infiniband/hw/hfi1/pio_copy.c
index 8c25e1b58849..3a1ef3056282 100644
--- a/drivers/infiniband/hw/hfi1/pio_copy.c
+++ b/drivers/infiniband/hw/hfi1/pio_copy.c
@@ -771,6 +771,9 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes)
771 read_extra_bytes(pbuf, from, to_fill); 771 read_extra_bytes(pbuf, from, to_fill);
772 from += to_fill; 772 from += to_fill;
773 nbytes -= to_fill; 773 nbytes -= to_fill;
774 /* may not be enough valid bytes left to align */
775 if (extra > nbytes)
776 extra = nbytes;
774 777
775 /* ...now write carry */ 778 /* ...now write carry */
776 dest = pbuf->start + (pbuf->qw_written * sizeof(u64)); 779 dest = pbuf->start + (pbuf->qw_written * sizeof(u64));
@@ -798,6 +801,15 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes)
798 read_low_bytes(pbuf, from, extra); 801 read_low_bytes(pbuf, from, extra);
799 from += extra; 802 from += extra;
800 nbytes -= extra; 803 nbytes -= extra;
804 /*
805 * If no bytes are left, return early - we are done.
806 * NOTE: This short-circuit is *required* because
807 * "extra" may have been reduced in size and "from"
808 * is not aligned, as required when leaving this
809 * if block.
810 */
811 if (nbytes == 0)
812 return;
801 } 813 }
802 814
803 /* at this point, from is QW aligned */ 815 /* at this point, from is QW aligned */
diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
index 0ecf27903dc2..1694037d1eee 100644
--- a/drivers/infiniband/hw/hfi1/user_sdma.c
+++ b/drivers/infiniband/hw/hfi1/user_sdma.c
@@ -114,6 +114,8 @@ MODULE_PARM_DESC(sdma_comp_size, "Size of User SDMA completion ring. Default: 12
114#define KDETH_HCRC_LOWER_SHIFT 24 114#define KDETH_HCRC_LOWER_SHIFT 24
115#define KDETH_HCRC_LOWER_MASK 0xff 115#define KDETH_HCRC_LOWER_MASK 0xff
116 116
117#define AHG_KDETH_INTR_SHIFT 12
118
117#define PBC2LRH(x) ((((x) & 0xfff) << 2) - 4) 119#define PBC2LRH(x) ((((x) & 0xfff) << 2) - 4)
118#define LRH2PBC(x) ((((x) >> 2) + 1) & 0xfff) 120#define LRH2PBC(x) ((((x) >> 2) + 1) & 0xfff)
119 121
@@ -1480,7 +1482,8 @@ static int set_txreq_header_ahg(struct user_sdma_request *req,
1480 /* Clear KDETH.SH on last packet */ 1482 /* Clear KDETH.SH on last packet */
1481 if (unlikely(tx->flags & TXREQ_FLAGS_REQ_LAST_PKT)) { 1483 if (unlikely(tx->flags & TXREQ_FLAGS_REQ_LAST_PKT)) {
1482 val |= cpu_to_le16(KDETH_GET(hdr->kdeth.ver_tid_offset, 1484 val |= cpu_to_le16(KDETH_GET(hdr->kdeth.ver_tid_offset,
1483 INTR) >> 16); 1485 INTR) <<
1486 AHG_KDETH_INTR_SHIFT);
1484 val &= cpu_to_le16(~(1U << 13)); 1487 val &= cpu_to_le16(~(1U << 13));
1485 AHG_HEADER_SET(req->ahg, diff, 7, 16, 14, val); 1488 AHG_HEADER_SET(req->ahg, diff, 7, 16, 14, val);
1486 } else { 1489 } else {
diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c b/drivers/infiniband/hw/i40iw/i40iw_hw.c
index 3ee0cad96bc6..0c92a40b3e86 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_hw.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c
@@ -265,6 +265,7 @@ void i40iw_next_iw_state(struct i40iw_qp *iwqp,
265 info.dont_send_fin = false; 265 info.dont_send_fin = false;
266 if (iwqp->sc_qp.term_flags && (state == I40IW_QP_STATE_ERROR)) 266 if (iwqp->sc_qp.term_flags && (state == I40IW_QP_STATE_ERROR))
267 info.reset_tcp_conn = true; 267 info.reset_tcp_conn = true;
268 iwqp->hw_iwarp_state = state;
268 i40iw_hw_modify_qp(iwqp->iwdev, iwqp, &info, 0); 269 i40iw_hw_modify_qp(iwqp->iwdev, iwqp, &info, 0);
269} 270}
270 271
diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c
index 0cbbe4038298..445e230d5ff8 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_main.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
@@ -100,7 +100,7 @@ static struct notifier_block i40iw_net_notifier = {
100 .notifier_call = i40iw_net_event 100 .notifier_call = i40iw_net_event
101}; 101};
102 102
103static int i40iw_notifiers_registered; 103static atomic_t i40iw_notifiers_registered;
104 104
105/** 105/**
106 * i40iw_find_i40e_handler - find a handler given a client info 106 * i40iw_find_i40e_handler - find a handler given a client info
@@ -1342,12 +1342,11 @@ exit:
1342 */ 1342 */
1343static void i40iw_register_notifiers(void) 1343static void i40iw_register_notifiers(void)
1344{ 1344{
1345 if (!i40iw_notifiers_registered) { 1345 if (atomic_inc_return(&i40iw_notifiers_registered) == 1) {
1346 register_inetaddr_notifier(&i40iw_inetaddr_notifier); 1346 register_inetaddr_notifier(&i40iw_inetaddr_notifier);
1347 register_inet6addr_notifier(&i40iw_inetaddr6_notifier); 1347 register_inet6addr_notifier(&i40iw_inetaddr6_notifier);
1348 register_netevent_notifier(&i40iw_net_notifier); 1348 register_netevent_notifier(&i40iw_net_notifier);
1349 } 1349 }
1350 i40iw_notifiers_registered++;
1351} 1350}
1352 1351
1353/** 1352/**
@@ -1429,8 +1428,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset, bool del
1429 i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx); 1428 i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
1430 /* fallthrough */ 1429 /* fallthrough */
1431 case INET_NOTIFIER: 1430 case INET_NOTIFIER:
1432 if (i40iw_notifiers_registered > 0) { 1431 if (!atomic_dec_return(&i40iw_notifiers_registered)) {
1433 i40iw_notifiers_registered--;
1434 unregister_netevent_notifier(&i40iw_net_notifier); 1432 unregister_netevent_notifier(&i40iw_net_notifier);
1435 unregister_inetaddr_notifier(&i40iw_inetaddr_notifier); 1433 unregister_inetaddr_notifier(&i40iw_inetaddr_notifier);
1436 unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier); 1434 unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier);
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 006db6436e3b..5df63dacaaa3 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -687,12 +687,6 @@ repoll:
687 is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == 687 is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
688 MLX4_CQE_OPCODE_ERROR; 688 MLX4_CQE_OPCODE_ERROR;
689 689
690 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_OPCODE_NOP &&
691 is_send)) {
692 pr_warn("Completion for NOP opcode detected!\n");
693 return -EAGAIN;
694 }
695
696 /* Resize CQ in progress */ 690 /* Resize CQ in progress */
697 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) { 691 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) {
698 if (cq->resize_buf) { 692 if (cq->resize_buf) {
@@ -718,12 +712,6 @@ repoll:
718 */ 712 */
719 mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev, 713 mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev,
720 be32_to_cpu(cqe->vlan_my_qpn)); 714 be32_to_cpu(cqe->vlan_my_qpn));
721 if (unlikely(!mqp)) {
722 pr_warn("CQ %06x with entry for unknown QPN %06x\n",
723 cq->mcq.cqn, be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK);
724 return -EAGAIN;
725 }
726
727 *cur_qp = to_mibqp(mqp); 715 *cur_qp = to_mibqp(mqp);
728 } 716 }
729 717
@@ -736,11 +724,6 @@ repoll:
736 /* SRQ is also in the radix tree */ 724 /* SRQ is also in the radix tree */
737 msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev, 725 msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev,
738 srq_num); 726 srq_num);
739 if (unlikely(!msrq)) {
740 pr_warn("CQ %06x with entry for unknown SRQN %06x\n",
741 cq->mcq.cqn, srq_num);
742 return -EAGAIN;
743 }
744 } 727 }
745 728
746 if (is_send) { 729 if (is_send) {
@@ -891,7 +874,6 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
891 struct mlx4_ib_qp *cur_qp = NULL; 874 struct mlx4_ib_qp *cur_qp = NULL;
892 unsigned long flags; 875 unsigned long flags;
893 int npolled; 876 int npolled;
894 int err = 0;
895 struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device); 877 struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device);
896 878
897 spin_lock_irqsave(&cq->lock, flags); 879 spin_lock_irqsave(&cq->lock, flags);
@@ -901,8 +883,7 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
901 } 883 }
902 884
903 for (npolled = 0; npolled < num_entries; ++npolled) { 885 for (npolled = 0; npolled < num_entries; ++npolled) {
904 err = mlx4_ib_poll_one(cq, &cur_qp, wc + npolled); 886 if (mlx4_ib_poll_one(cq, &cur_qp, wc + npolled))
905 if (err)
906 break; 887 break;
907 } 888 }
908 889
@@ -911,10 +892,7 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
911out: 892out:
912 spin_unlock_irqrestore(&cq->lock, flags); 893 spin_unlock_irqrestore(&cq->lock, flags);
913 894
914 if (err == 0 || err == -EAGAIN) 895 return npolled;
915 return npolled;
916 else
917 return err;
918} 896}
919 897
920int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) 898int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
index 308a358e5b46..e4fac9292e4a 100644
--- a/drivers/infiniband/hw/mlx5/cq.c
+++ b/drivers/infiniband/hw/mlx5/cq.c
@@ -553,12 +553,6 @@ repoll:
553 * from the table. 553 * from the table.
554 */ 554 */
555 mqp = __mlx5_qp_lookup(dev->mdev, qpn); 555 mqp = __mlx5_qp_lookup(dev->mdev, qpn);
556 if (unlikely(!mqp)) {
557 mlx5_ib_warn(dev, "CQE@CQ %06x for unknown QPN %6x\n",
558 cq->mcq.cqn, qpn);
559 return -EINVAL;
560 }
561
562 *cur_qp = to_mibqp(mqp); 556 *cur_qp = to_mibqp(mqp);
563 } 557 }
564 558
@@ -619,13 +613,6 @@ repoll:
619 read_lock(&dev->mdev->priv.mkey_table.lock); 613 read_lock(&dev->mdev->priv.mkey_table.lock);
620 mmkey = __mlx5_mr_lookup(dev->mdev, 614 mmkey = __mlx5_mr_lookup(dev->mdev,
621 mlx5_base_mkey(be32_to_cpu(sig_err_cqe->mkey))); 615 mlx5_base_mkey(be32_to_cpu(sig_err_cqe->mkey)));
622 if (unlikely(!mmkey)) {
623 read_unlock(&dev->mdev->priv.mkey_table.lock);
624 mlx5_ib_warn(dev, "CQE@CQ %06x for unknown MR %6x\n",
625 cq->mcq.cqn, be32_to_cpu(sig_err_cqe->mkey));
626 return -EINVAL;
627 }
628
629 mr = to_mibmr(mmkey); 616 mr = to_mibmr(mmkey);
630 get_sig_err_item(sig_err_cqe, &mr->sig->err_item); 617 get_sig_err_item(sig_err_cqe, &mr->sig->err_item);
631 mr->sig->sig_err_exists = true; 618 mr->sig->sig_err_exists = true;
@@ -676,7 +663,6 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
676 unsigned long flags; 663 unsigned long flags;
677 int soft_polled = 0; 664 int soft_polled = 0;
678 int npolled; 665 int npolled;
679 int err = 0;
680 666
681 spin_lock_irqsave(&cq->lock, flags); 667 spin_lock_irqsave(&cq->lock, flags);
682 if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 668 if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
@@ -688,8 +674,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
688 soft_polled = poll_soft_wc(cq, num_entries, wc); 674 soft_polled = poll_soft_wc(cq, num_entries, wc);
689 675
690 for (npolled = 0; npolled < num_entries - soft_polled; npolled++) { 676 for (npolled = 0; npolled < num_entries - soft_polled; npolled++) {
691 err = mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled); 677 if (mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled))
692 if (err)
693 break; 678 break;
694 } 679 }
695 680
@@ -698,10 +683,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
698out: 683out:
699 spin_unlock_irqrestore(&cq->lock, flags); 684 spin_unlock_irqrestore(&cq->lock, flags);
700 685
701 if (err == 0 || err == -EAGAIN) 686 return soft_polled + npolled;
702 return soft_polled + npolled;
703 else
704 return err;
705} 687}
706 688
707int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) 689int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 1b4094baa2de..8150ea372c53 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1849,6 +1849,7 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
1849 int domain) 1849 int domain)
1850{ 1850{
1851 struct mlx5_ib_dev *dev = to_mdev(qp->device); 1851 struct mlx5_ib_dev *dev = to_mdev(qp->device);
1852 struct mlx5_ib_qp *mqp = to_mqp(qp);
1852 struct mlx5_ib_flow_handler *handler = NULL; 1853 struct mlx5_ib_flow_handler *handler = NULL;
1853 struct mlx5_flow_destination *dst = NULL; 1854 struct mlx5_flow_destination *dst = NULL;
1854 struct mlx5_ib_flow_prio *ft_prio; 1855 struct mlx5_ib_flow_prio *ft_prio;
@@ -1875,7 +1876,10 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
1875 } 1876 }
1876 1877
1877 dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR; 1878 dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR;
1878 dst->tir_num = to_mqp(qp)->raw_packet_qp.rq.tirn; 1879 if (mqp->flags & MLX5_IB_QP_RSS)
1880 dst->tir_num = mqp->rss_qp.tirn;
1881 else
1882 dst->tir_num = mqp->raw_packet_qp.rq.tirn;
1879 1883
1880 if (flow_attr->type == IB_FLOW_ATTR_NORMAL) { 1884 if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
1881 if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) { 1885 if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) {
diff --git a/drivers/infiniband/hw/mlx5/mem.c b/drivers/infiniband/hw/mlx5/mem.c
index 40df2cca0609..996b54e366b0 100644
--- a/drivers/infiniband/hw/mlx5/mem.c
+++ b/drivers/infiniband/hw/mlx5/mem.c
@@ -71,7 +71,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
71 71
72 addr = addr >> page_shift; 72 addr = addr >> page_shift;
73 tmp = (unsigned long)addr; 73 tmp = (unsigned long)addr;
74 m = find_first_bit(&tmp, sizeof(tmp)); 74 m = find_first_bit(&tmp, BITS_PER_LONG);
75 skip = 1 << m; 75 skip = 1 << m;
76 mask = skip - 1; 76 mask = skip - 1;
77 i = 0; 77 i = 0;
@@ -81,7 +81,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
81 for (k = 0; k < len; k++) { 81 for (k = 0; k < len; k++) {
82 if (!(i & mask)) { 82 if (!(i & mask)) {
83 tmp = (unsigned long)pfn; 83 tmp = (unsigned long)pfn;
84 m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp))); 84 m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));
85 skip = 1 << m; 85 skip = 1 << m;
86 mask = skip - 1; 86 mask = skip - 1;
87 base = pfn; 87 base = pfn;
@@ -89,7 +89,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
89 } else { 89 } else {
90 if (base + p != pfn) { 90 if (base + p != pfn) {
91 tmp = (unsigned long)p; 91 tmp = (unsigned long)p;
92 m = find_first_bit(&tmp, sizeof(tmp)); 92 m = find_first_bit(&tmp, BITS_PER_LONG);
93 skip = 1 << m; 93 skip = 1 << m;
94 mask = skip - 1; 94 mask = skip - 1;
95 base = pfn; 95 base = pfn;
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 372385d0f993..95146f4aa3e3 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -402,6 +402,7 @@ enum mlx5_ib_qp_flags {
402 /* QP uses 1 as its source QP number */ 402 /* QP uses 1 as its source QP number */
403 MLX5_IB_QP_SQPN_QP1 = 1 << 6, 403 MLX5_IB_QP_SQPN_QP1 = 1 << 6,
404 MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7, 404 MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7,
405 MLX5_IB_QP_RSS = 1 << 8,
405}; 406};
406 407
407struct mlx5_umr_wr { 408struct mlx5_umr_wr {
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 0dd7d93cac95..affc3f6598ca 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1449,6 +1449,7 @@ create_tir:
1449 kvfree(in); 1449 kvfree(in);
1450 /* qpn is reserved for that QP */ 1450 /* qpn is reserved for that QP */
1451 qp->trans_qp.base.mqp.qpn = 0; 1451 qp->trans_qp.base.mqp.qpn = 0;
1452 qp->flags |= MLX5_IB_QP_RSS;
1452 return 0; 1453 return 0;
1453 1454
1454err: 1455err:
@@ -3658,12 +3659,8 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
3658 struct ib_send_wr *wr, unsigned *idx, 3659 struct ib_send_wr *wr, unsigned *idx,
3659 int *size, int nreq) 3660 int *size, int nreq)
3660{ 3661{
3661 int err = 0; 3662 if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)))
3662 3663 return -ENOMEM;
3663 if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq))) {
3664 err = -ENOMEM;
3665 return err;
3666 }
3667 3664
3668 *idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1); 3665 *idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1);
3669 *seg = mlx5_get_send_wqe(qp, *idx); 3666 *seg = mlx5_get_send_wqe(qp, *idx);
@@ -3679,7 +3676,7 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
3679 *seg += sizeof(**ctrl); 3676 *seg += sizeof(**ctrl);
3680 *size = sizeof(**ctrl) / 16; 3677 *size = sizeof(**ctrl) / 16;
3681 3678
3682 return err; 3679 return 0;
3683} 3680}
3684 3681
3685static void finish_wqe(struct mlx5_ib_qp *qp, 3682static void finish_wqe(struct mlx5_ib_qp *qp,
@@ -3758,7 +3755,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
3758 num_sge = wr->num_sge; 3755 num_sge = wr->num_sge;
3759 if (unlikely(num_sge > qp->sq.max_gs)) { 3756 if (unlikely(num_sge > qp->sq.max_gs)) {
3760 mlx5_ib_warn(dev, "\n"); 3757 mlx5_ib_warn(dev, "\n");
3761 err = -ENOMEM; 3758 err = -EINVAL;
3762 *bad_wr = wr; 3759 *bad_wr = wr;
3763 goto out; 3760 goto out;
3764 } 3761 }
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 4f7d9b48df64..9dbfcc0ab577 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -478,6 +478,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
478 struct ipoib_ah *address, u32 qpn); 478 struct ipoib_ah *address, u32 qpn);
479void ipoib_reap_ah(struct work_struct *work); 479void ipoib_reap_ah(struct work_struct *work);
480 480
481struct ipoib_path *__path_find(struct net_device *dev, void *gid);
481void ipoib_mark_paths_invalid(struct net_device *dev); 482void ipoib_mark_paths_invalid(struct net_device *dev);
482void ipoib_flush_paths(struct net_device *dev); 483void ipoib_flush_paths(struct net_device *dev);
483int ipoib_check_sm_sendonly_fullmember_support(struct ipoib_dev_priv *priv); 484int ipoib_check_sm_sendonly_fullmember_support(struct ipoib_dev_priv *priv);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 951d9abcca8b..4ad297d3de89 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1318,6 +1318,8 @@ void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
1318 } 1318 }
1319} 1319}
1320 1320
1321#define QPN_AND_OPTIONS_OFFSET 4
1322
1321static void ipoib_cm_tx_start(struct work_struct *work) 1323static void ipoib_cm_tx_start(struct work_struct *work)
1322{ 1324{
1323 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, 1325 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
@@ -1326,6 +1328,7 @@ static void ipoib_cm_tx_start(struct work_struct *work)
1326 struct ipoib_neigh *neigh; 1328 struct ipoib_neigh *neigh;
1327 struct ipoib_cm_tx *p; 1329 struct ipoib_cm_tx *p;
1328 unsigned long flags; 1330 unsigned long flags;
1331 struct ipoib_path *path;
1329 int ret; 1332 int ret;
1330 1333
1331 struct ib_sa_path_rec pathrec; 1334 struct ib_sa_path_rec pathrec;
@@ -1338,7 +1341,19 @@ static void ipoib_cm_tx_start(struct work_struct *work)
1338 p = list_entry(priv->cm.start_list.next, typeof(*p), list); 1341 p = list_entry(priv->cm.start_list.next, typeof(*p), list);
1339 list_del_init(&p->list); 1342 list_del_init(&p->list);
1340 neigh = p->neigh; 1343 neigh = p->neigh;
1344
1341 qpn = IPOIB_QPN(neigh->daddr); 1345 qpn = IPOIB_QPN(neigh->daddr);
1346 /*
1347 * As long as the search is with these 2 locks,
1348 * path existence indicates its validity.
1349 */
1350 path = __path_find(dev, neigh->daddr + QPN_AND_OPTIONS_OFFSET);
1351 if (!path) {
1352 pr_info("%s ignore not valid path %pI6\n",
1353 __func__,
1354 neigh->daddr + QPN_AND_OPTIONS_OFFSET);
1355 goto free_neigh;
1356 }
1342 memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); 1357 memcpy(&pathrec, &p->path->pathrec, sizeof pathrec);
1343 1358
1344 spin_unlock_irqrestore(&priv->lock, flags); 1359 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1350,6 +1365,7 @@ static void ipoib_cm_tx_start(struct work_struct *work)
1350 spin_lock_irqsave(&priv->lock, flags); 1365 spin_lock_irqsave(&priv->lock, flags);
1351 1366
1352 if (ret) { 1367 if (ret) {
1368free_neigh:
1353 neigh = p->neigh; 1369 neigh = p->neigh;
1354 if (neigh) { 1370 if (neigh) {
1355 neigh->cm = NULL; 1371 neigh->cm = NULL;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 74bcaa064226..cc1c1b062ea5 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -485,7 +485,7 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
485 return -EINVAL; 485 return -EINVAL;
486} 486}
487 487
488static struct ipoib_path *__path_find(struct net_device *dev, void *gid) 488struct ipoib_path *__path_find(struct net_device *dev, void *gid)
489{ 489{
490 struct ipoib_dev_priv *priv = netdev_priv(dev); 490 struct ipoib_dev_priv *priv = netdev_priv(dev);
491 struct rb_node *n = priv->path_tree.rb_node; 491 struct rb_node *n = priv->path_tree.rb_node;
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 7914c14478cd..cae9bbcc27e7 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -403,6 +403,7 @@ isert_init_conn(struct isert_conn *isert_conn)
403 INIT_LIST_HEAD(&isert_conn->node); 403 INIT_LIST_HEAD(&isert_conn->node);
404 init_completion(&isert_conn->login_comp); 404 init_completion(&isert_conn->login_comp);
405 init_completion(&isert_conn->login_req_comp); 405 init_completion(&isert_conn->login_req_comp);
406 init_waitqueue_head(&isert_conn->rem_wait);
406 kref_init(&isert_conn->kref); 407 kref_init(&isert_conn->kref);
407 mutex_init(&isert_conn->mutex); 408 mutex_init(&isert_conn->mutex);
408 INIT_WORK(&isert_conn->release_work, isert_release_work); 409 INIT_WORK(&isert_conn->release_work, isert_release_work);
@@ -578,7 +579,8 @@ isert_connect_release(struct isert_conn *isert_conn)
578 BUG_ON(!device); 579 BUG_ON(!device);
579 580
580 isert_free_rx_descriptors(isert_conn); 581 isert_free_rx_descriptors(isert_conn);
581 if (isert_conn->cm_id) 582 if (isert_conn->cm_id &&
583 !isert_conn->dev_removed)
582 rdma_destroy_id(isert_conn->cm_id); 584 rdma_destroy_id(isert_conn->cm_id);
583 585
584 if (isert_conn->qp) { 586 if (isert_conn->qp) {
@@ -593,7 +595,10 @@ isert_connect_release(struct isert_conn *isert_conn)
593 595
594 isert_device_put(device); 596 isert_device_put(device);
595 597
596 kfree(isert_conn); 598 if (isert_conn->dev_removed)
599 wake_up_interruptible(&isert_conn->rem_wait);
600 else
601 kfree(isert_conn);
597} 602}
598 603
599static void 604static void
@@ -753,6 +758,7 @@ static int
753isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) 758isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
754{ 759{
755 struct isert_np *isert_np = cma_id->context; 760 struct isert_np *isert_np = cma_id->context;
761 struct isert_conn *isert_conn;
756 int ret = 0; 762 int ret = 0;
757 763
758 isert_info("%s (%d): status %d id %p np %p\n", 764 isert_info("%s (%d): status %d id %p np %p\n",
@@ -773,10 +779,21 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
773 break; 779 break;
774 case RDMA_CM_EVENT_ADDR_CHANGE: /* FALLTHRU */ 780 case RDMA_CM_EVENT_ADDR_CHANGE: /* FALLTHRU */
775 case RDMA_CM_EVENT_DISCONNECTED: /* FALLTHRU */ 781 case RDMA_CM_EVENT_DISCONNECTED: /* FALLTHRU */
776 case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */
777 case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */ 782 case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */
778 ret = isert_disconnected_handler(cma_id, event->event); 783 ret = isert_disconnected_handler(cma_id, event->event);
779 break; 784 break;
785 case RDMA_CM_EVENT_DEVICE_REMOVAL:
786 isert_conn = cma_id->qp->qp_context;
787 isert_conn->dev_removed = true;
788 isert_disconnected_handler(cma_id, event->event);
789 wait_event_interruptible(isert_conn->rem_wait,
790 isert_conn->state == ISER_CONN_DOWN);
791 kfree(isert_conn);
792 /*
793 * return non-zero from the callback to destroy
794 * the rdma cm id
795 */
796 return 1;
780 case RDMA_CM_EVENT_REJECTED: /* FALLTHRU */ 797 case RDMA_CM_EVENT_REJECTED: /* FALLTHRU */
781 case RDMA_CM_EVENT_UNREACHABLE: /* FALLTHRU */ 798 case RDMA_CM_EVENT_UNREACHABLE: /* FALLTHRU */
782 case RDMA_CM_EVENT_CONNECT_ERROR: 799 case RDMA_CM_EVENT_CONNECT_ERROR:
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index fc791efe3a10..c02ada57d7f5 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -158,6 +158,8 @@ struct isert_conn {
158 struct work_struct release_work; 158 struct work_struct release_work;
159 bool logout_posted; 159 bool logout_posted;
160 bool snd_w_inv; 160 bool snd_w_inv;
161 wait_queue_head_t rem_wait;
162 bool dev_removed;
161}; 163};
162 164
163#define ISERT_MAX_CQ 64 165#define ISERT_MAX_CQ 64
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 97c372908e78..7817d40d81e7 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -127,6 +127,7 @@ config XGENE_SLIMPRO_MBOX
127config BCM_PDC_MBOX 127config BCM_PDC_MBOX
128 tristate "Broadcom PDC Mailbox" 128 tristate "Broadcom PDC Mailbox"
129 depends on ARM64 || COMPILE_TEST 129 depends on ARM64 || COMPILE_TEST
130 depends on HAS_DMA
130 default ARCH_BCM_IPROC 131 default ARCH_BCM_IPROC
131 help 132 help
132 Mailbox implementation for the Broadcom PDC ring manager, 133 Mailbox implementation for the Broadcom PDC ring manager,
diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c
index cbe0c1ee4ba9..c19dd820ea9b 100644
--- a/drivers/mailbox/bcm-pdc-mailbox.c
+++ b/drivers/mailbox/bcm-pdc-mailbox.c
@@ -469,7 +469,7 @@ static const struct file_operations pdc_debugfs_stats = {
469 * this directory for a SPU. 469 * this directory for a SPU.
470 * @pdcs: PDC state structure 470 * @pdcs: PDC state structure
471 */ 471 */
472void pdc_setup_debugfs(struct pdc_state *pdcs) 472static void pdc_setup_debugfs(struct pdc_state *pdcs)
473{ 473{
474 char spu_stats_name[16]; 474 char spu_stats_name[16];
475 475
@@ -485,7 +485,7 @@ void pdc_setup_debugfs(struct pdc_state *pdcs)
485 &pdc_debugfs_stats); 485 &pdc_debugfs_stats);
486} 486}
487 487
488void pdc_free_debugfs(void) 488static void pdc_free_debugfs(void)
489{ 489{
490 if (debugfs_dir && simple_empty(debugfs_dir)) { 490 if (debugfs_dir && simple_empty(debugfs_dir)) {
491 debugfs_remove_recursive(debugfs_dir); 491 debugfs_remove_recursive(debugfs_dir);
@@ -1191,10 +1191,11 @@ static void pdc_shutdown(struct mbox_chan *chan)
1191{ 1191{
1192 struct pdc_state *pdcs = chan->con_priv; 1192 struct pdc_state *pdcs = chan->con_priv;
1193 1193
1194 if (pdcs) 1194 if (!pdcs)
1195 dev_dbg(&pdcs->pdev->dev, 1195 return;
1196 "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
1197 1196
1197 dev_dbg(&pdcs->pdev->dev,
1198 "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
1198 pdc_ring_free(pdcs); 1199 pdc_ring_free(pdcs);
1199} 1200}
1200 1201
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 869c83fb3c5d..f00f3e742265 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -2185,7 +2185,7 @@ static int gpmc_probe_dt(struct platform_device *pdev)
2185 return 0; 2185 return 0;
2186} 2186}
2187 2187
2188static int gpmc_probe_dt_children(struct platform_device *pdev) 2188static void gpmc_probe_dt_children(struct platform_device *pdev)
2189{ 2189{
2190 int ret; 2190 int ret;
2191 struct device_node *child; 2191 struct device_node *child;
@@ -2200,11 +2200,11 @@ static int gpmc_probe_dt_children(struct platform_device *pdev)
2200 else 2200 else
2201 ret = gpmc_probe_generic_child(pdev, child); 2201 ret = gpmc_probe_generic_child(pdev, child);
2202 2202
2203 if (ret) 2203 if (ret) {
2204 return ret; 2204 dev_err(&pdev->dev, "failed to probe DT child '%s': %d\n",
2205 child->name, ret);
2206 }
2205 } 2207 }
2206
2207 return 0;
2208} 2208}
2209#else 2209#else
2210static int gpmc_probe_dt(struct platform_device *pdev) 2210static int gpmc_probe_dt(struct platform_device *pdev)
@@ -2212,9 +2212,8 @@ static int gpmc_probe_dt(struct platform_device *pdev)
2212 return 0; 2212 return 0;
2213} 2213}
2214 2214
2215static int gpmc_probe_dt_children(struct platform_device *pdev) 2215static void gpmc_probe_dt_children(struct platform_device *pdev)
2216{ 2216{
2217 return 0;
2218} 2217}
2219#endif /* CONFIG_OF */ 2218#endif /* CONFIG_OF */
2220 2219
@@ -2369,16 +2368,10 @@ static int gpmc_probe(struct platform_device *pdev)
2369 goto setup_irq_failed; 2368 goto setup_irq_failed;
2370 } 2369 }
2371 2370
2372 rc = gpmc_probe_dt_children(pdev); 2371 gpmc_probe_dt_children(pdev);
2373 if (rc < 0) {
2374 dev_err(gpmc->dev, "failed to probe DT children\n");
2375 goto dt_children_failed;
2376 }
2377 2372
2378 return 0; 2373 return 0;
2379 2374
2380dt_children_failed:
2381 gpmc_free_irq(gpmc);
2382setup_irq_failed: 2375setup_irq_failed:
2383 gpmc_gpio_exit(gpmc); 2376 gpmc_gpio_exit(gpmc);
2384gpio_init_failed: 2377gpio_init_failed:
diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c
index 5525a204db93..1dd611423d8b 100644
--- a/drivers/misc/lkdtm_usercopy.c
+++ b/drivers/misc/lkdtm_usercopy.c
@@ -9,7 +9,15 @@
9#include <linux/uaccess.h> 9#include <linux/uaccess.h>
10#include <asm/cacheflush.h> 10#include <asm/cacheflush.h>
11 11
12static size_t cache_size = 1024; 12/*
13 * Many of the tests here end up using const sizes, but those would
14 * normally be ignored by hardened usercopy, so force the compiler
15 * into choosing the non-const path to make sure we trigger the
16 * hardened usercopy checks by added "unconst" to all the const copies,
17 * and making sure "cache_size" isn't optimized into a const.
18 */
19static volatile size_t unconst = 0;
20static volatile size_t cache_size = 1024;
13static struct kmem_cache *bad_cache; 21static struct kmem_cache *bad_cache;
14 22
15static const unsigned char test_text[] = "This is a test.\n"; 23static const unsigned char test_text[] = "This is a test.\n";
@@ -67,14 +75,14 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
67 if (to_user) { 75 if (to_user) {
68 pr_info("attempting good copy_to_user of local stack\n"); 76 pr_info("attempting good copy_to_user of local stack\n");
69 if (copy_to_user((void __user *)user_addr, good_stack, 77 if (copy_to_user((void __user *)user_addr, good_stack,
70 sizeof(good_stack))) { 78 unconst + sizeof(good_stack))) {
71 pr_warn("copy_to_user failed unexpectedly?!\n"); 79 pr_warn("copy_to_user failed unexpectedly?!\n");
72 goto free_user; 80 goto free_user;
73 } 81 }
74 82
75 pr_info("attempting bad copy_to_user of distant stack\n"); 83 pr_info("attempting bad copy_to_user of distant stack\n");
76 if (copy_to_user((void __user *)user_addr, bad_stack, 84 if (copy_to_user((void __user *)user_addr, bad_stack,
77 sizeof(good_stack))) { 85 unconst + sizeof(good_stack))) {
78 pr_warn("copy_to_user failed, but lacked Oops\n"); 86 pr_warn("copy_to_user failed, but lacked Oops\n");
79 goto free_user; 87 goto free_user;
80 } 88 }
@@ -88,14 +96,14 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
88 96
89 pr_info("attempting good copy_from_user of local stack\n"); 97 pr_info("attempting good copy_from_user of local stack\n");
90 if (copy_from_user(good_stack, (void __user *)user_addr, 98 if (copy_from_user(good_stack, (void __user *)user_addr,
91 sizeof(good_stack))) { 99 unconst + sizeof(good_stack))) {
92 pr_warn("copy_from_user failed unexpectedly?!\n"); 100 pr_warn("copy_from_user failed unexpectedly?!\n");
93 goto free_user; 101 goto free_user;
94 } 102 }
95 103
96 pr_info("attempting bad copy_from_user of distant stack\n"); 104 pr_info("attempting bad copy_from_user of distant stack\n");
97 if (copy_from_user(bad_stack, (void __user *)user_addr, 105 if (copy_from_user(bad_stack, (void __user *)user_addr,
98 sizeof(good_stack))) { 106 unconst + sizeof(good_stack))) {
99 pr_warn("copy_from_user failed, but lacked Oops\n"); 107 pr_warn("copy_from_user failed, but lacked Oops\n");
100 goto free_user; 108 goto free_user;
101 } 109 }
@@ -109,7 +117,7 @@ static void do_usercopy_heap_size(bool to_user)
109{ 117{
110 unsigned long user_addr; 118 unsigned long user_addr;
111 unsigned char *one, *two; 119 unsigned char *one, *two;
112 const size_t size = 1024; 120 size_t size = unconst + 1024;
113 121
114 one = kmalloc(size, GFP_KERNEL); 122 one = kmalloc(size, GFP_KERNEL);
115 two = kmalloc(size, GFP_KERNEL); 123 two = kmalloc(size, GFP_KERNEL);
@@ -285,13 +293,14 @@ void lkdtm_USERCOPY_KERNEL(void)
285 293
286 pr_info("attempting good copy_to_user from kernel rodata\n"); 294 pr_info("attempting good copy_to_user from kernel rodata\n");
287 if (copy_to_user((void __user *)user_addr, test_text, 295 if (copy_to_user((void __user *)user_addr, test_text,
288 sizeof(test_text))) { 296 unconst + sizeof(test_text))) {
289 pr_warn("copy_to_user failed unexpectedly?!\n"); 297 pr_warn("copy_to_user failed unexpectedly?!\n");
290 goto free_user; 298 goto free_user;
291 } 299 }
292 300
293 pr_info("attempting bad copy_to_user from kernel text\n"); 301 pr_info("attempting bad copy_to_user from kernel text\n");
294 if (copy_to_user((void __user *)user_addr, vm_mmap, PAGE_SIZE)) { 302 if (copy_to_user((void __user *)user_addr, vm_mmap,
303 unconst + PAGE_SIZE)) {
295 pr_warn("copy_to_user failed, but lacked Oops\n"); 304 pr_warn("copy_to_user failed, but lacked Oops\n");
296 goto free_user; 305 goto free_user;
297 } 306 }
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 458daf927336..935866fe5ec2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -185,8 +185,12 @@ long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
185 return -ENXIO; 185 return -ENXIO;
186 186
187 nd_desc = nvdimm_bus->nd_desc; 187 nd_desc = nvdimm_bus->nd_desc;
188 /*
189 * if ndctl does not exist, it's PMEM_LEGACY and
190 * we want to just pretend everything is handled.
191 */
188 if (!nd_desc->ndctl) 192 if (!nd_desc->ndctl)
189 return -ENXIO; 193 return len;
190 194
191 memset(&ars_cap, 0, sizeof(ars_cap)); 195 memset(&ars_cap, 0, sizeof(ars_cap));
192 ars_cap.address = phys; 196 ars_cap.address = phys;
diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig
index 0c644f7bdf80..f7d37a62f874 100644
--- a/drivers/nvme/host/Kconfig
+++ b/drivers/nvme/host/Kconfig
@@ -30,7 +30,7 @@ config NVME_FABRICS
30 30
31config NVME_RDMA 31config NVME_RDMA
32 tristate "NVM Express over Fabrics RDMA host driver" 32 tristate "NVM Express over Fabrics RDMA host driver"
33 depends on INFINIBAND 33 depends on INFINIBAND && BLOCK
34 select NVME_CORE 34 select NVME_CORE
35 select NVME_FABRICS 35 select NVME_FABRICS
36 select SG_POOL 36 select SG_POOL
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 5749a4eee746..0fe8fad25e4d 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1539,12 +1539,11 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
1539 offset += range->npins; 1539 offset += range->npins;
1540 } 1540 }
1541 1541
1542 /* Mask and clear all interrupts */ 1542 /* Clear all interrupts */
1543 chv_writel(0, pctrl->regs + CHV_INTMASK);
1544 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); 1543 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
1545 1544
1546 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, 1545 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
1547 handle_simple_irq, IRQ_TYPE_NONE); 1546 handle_bad_irq, IRQ_TYPE_NONE);
1548 if (ret) { 1547 if (ret) {
1549 dev_err(pctrl->dev, "failed to add IRQ chip\n"); 1548 dev_err(pctrl->dev, "failed to add IRQ chip\n");
1550 goto fail; 1549 goto fail;
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 7bad200bd67c..55375b1b3cc8 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -809,17 +809,17 @@ static const struct pistachio_pin_group pistachio_groups[] = {
809 PADS_FUNCTION_SELECT2, 12, 0x3), 809 PADS_FUNCTION_SELECT2, 12, 0x3),
810 MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, 810 MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
811 PADS_FUNCTION_SELECT2, 14, 0x3), 811 PADS_FUNCTION_SELECT2, 14, 0x3),
812 MFIO_MUX_PIN_GROUP(84, SYS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, 812 MFIO_MUX_PIN_GROUP(84, AUDIO_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
813 PADS_FUNCTION_SELECT2, 16, 0x3), 813 PADS_FUNCTION_SELECT2, 16, 0x3),
814 MFIO_MUX_PIN_GROUP(85, WIFI_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, 814 MFIO_MUX_PIN_GROUP(85, RPU_V_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
815 PADS_FUNCTION_SELECT2, 18, 0x3), 815 PADS_FUNCTION_SELECT2, 18, 0x3),
816 MFIO_MUX_PIN_GROUP(86, BT_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, 816 MFIO_MUX_PIN_GROUP(86, RPU_L_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
817 PADS_FUNCTION_SELECT2, 20, 0x3), 817 PADS_FUNCTION_SELECT2, 20, 0x3),
818 MFIO_MUX_PIN_GROUP(87, RPU_V_PLL_LOCK, DREQ2, SOCIF_DEBUG, 818 MFIO_MUX_PIN_GROUP(87, SYS_PLL_LOCK, DREQ2, SOCIF_DEBUG,
819 PADS_FUNCTION_SELECT2, 22, 0x3), 819 PADS_FUNCTION_SELECT2, 22, 0x3),
820 MFIO_MUX_PIN_GROUP(88, RPU_L_PLL_LOCK, DREQ3, SOCIF_DEBUG, 820 MFIO_MUX_PIN_GROUP(88, WIFI_PLL_LOCK, DREQ3, SOCIF_DEBUG,
821 PADS_FUNCTION_SELECT2, 24, 0x3), 821 PADS_FUNCTION_SELECT2, 24, 0x3),
822 MFIO_MUX_PIN_GROUP(89, AUDIO_PLL_LOCK, DREQ4, DREQ5, 822 MFIO_MUX_PIN_GROUP(89, BT_PLL_LOCK, DREQ4, DREQ5,
823 PADS_FUNCTION_SELECT2, 26, 0x3), 823 PADS_FUNCTION_SELECT2, 26, 0x3),
824 PIN_GROUP(TCK, "tck"), 824 PIN_GROUP(TCK, "tck"),
825 PIN_GROUP(TRSTN, "trstn"), 825 PIN_GROUP(TRSTN, "trstn"),
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
index ce483b03a263..f9d661e5c14a 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
@@ -485,12 +485,12 @@ static const struct sunxi_desc_pin sun8i_a23_pins[] = {
485 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), 485 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
486 SUNXI_FUNCTION(0x0, "gpio_in"), 486 SUNXI_FUNCTION(0x0, "gpio_in"),
487 SUNXI_FUNCTION(0x1, "gpio_out"), 487 SUNXI_FUNCTION(0x1, "gpio_out"),
488 SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ 488 SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
489 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */ 489 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */
490 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), 490 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
491 SUNXI_FUNCTION(0x0, "gpio_in"), 491 SUNXI_FUNCTION(0x0, "gpio_in"),
492 SUNXI_FUNCTION(0x1, "gpio_out"), 492 SUNXI_FUNCTION(0x1, "gpio_out"),
493 SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ 493 SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
494 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */ 494 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */
495 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), 495 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
496 SUNXI_FUNCTION(0x0, "gpio_in"), 496 SUNXI_FUNCTION(0x0, "gpio_in"),
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
index 3040abe6f73a..3131cac2b76f 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
@@ -407,12 +407,12 @@ static const struct sunxi_desc_pin sun8i_a33_pins[] = {
407 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), 407 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
408 SUNXI_FUNCTION(0x0, "gpio_in"), 408 SUNXI_FUNCTION(0x0, "gpio_in"),
409 SUNXI_FUNCTION(0x1, "gpio_out"), 409 SUNXI_FUNCTION(0x1, "gpio_out"),
410 SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ 410 SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
411 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */ 411 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */
412 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), 412 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
413 SUNXI_FUNCTION(0x0, "gpio_in"), 413 SUNXI_FUNCTION(0x0, "gpio_in"),
414 SUNXI_FUNCTION(0x1, "gpio_out"), 414 SUNXI_FUNCTION(0x1, "gpio_out"),
415 SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ 415 SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
416 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */ 416 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */
417 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), 417 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
418 SUNXI_FUNCTION(0x0, "gpio_in"), 418 SUNXI_FUNCTION(0x0, "gpio_in"),
diff --git a/drivers/regulator/max14577-regulator.c b/drivers/regulator/max14577-regulator.c
index b2daa6641417..c9ff26199711 100644
--- a/drivers/regulator/max14577-regulator.c
+++ b/drivers/regulator/max14577-regulator.c
@@ -2,7 +2,7 @@
2 * max14577.c - Regulator driver for the Maxim 14577/77836 2 * max14577.c - Regulator driver for the Maxim 14577/77836
3 * 3 *
4 * Copyright (C) 2013,2014 Samsung Electronics 4 * Copyright (C) 2013,2014 Samsung Electronics
5 * Krzysztof Kozlowski <k.kozlowski@samsung.com> 5 * Krzysztof Kozlowski <krzk@kernel.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -331,7 +331,7 @@ static void __exit max14577_regulator_exit(void)
331} 331}
332module_exit(max14577_regulator_exit); 332module_exit(max14577_regulator_exit);
333 333
334MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); 334MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
335MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver"); 335MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");
336MODULE_LICENSE("GPL"); 336MODULE_LICENSE("GPL");
337MODULE_ALIAS("platform:max14577-regulator"); 337MODULE_ALIAS("platform:max14577-regulator");
diff --git a/drivers/regulator/max77693-regulator.c b/drivers/regulator/max77693-regulator.c
index de730fd3f8a5..cfbb9512e486 100644
--- a/drivers/regulator/max77693-regulator.c
+++ b/drivers/regulator/max77693-regulator.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2013-2015 Samsung Electronics 4 * Copyright (C) 2013-2015 Samsung Electronics
5 * Jonghwa Lee <jonghwa3.lee@samsung.com> 5 * Jonghwa Lee <jonghwa3.lee@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski.k@gmail.com> 6 * Krzysztof Kozlowski <krzk@kernel.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -314,5 +314,5 @@ module_exit(max77693_pmic_cleanup);
314 314
315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver"); 315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver");
316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); 316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
317MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski.k@gmail.com>"); 317MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
318MODULE_LICENSE("GPL"); 318MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 5022fa8d10c6..8ed46a9a55c8 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -178,20 +178,21 @@ static const struct regulator_desc pma8084_hfsmps = {
178static const struct regulator_desc pma8084_ftsmps = { 178static const struct regulator_desc pma8084_ftsmps = {
179 .linear_ranges = (struct regulator_linear_range[]) { 179 .linear_ranges = (struct regulator_linear_range[]) {
180 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), 180 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
181 REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), 181 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
182 }, 182 },
183 .n_linear_ranges = 2, 183 .n_linear_ranges = 2,
184 .n_voltages = 340, 184 .n_voltages = 262,
185 .ops = &rpm_smps_ldo_ops, 185 .ops = &rpm_smps_ldo_ops,
186}; 186};
187 187
188static const struct regulator_desc pma8084_pldo = { 188static const struct regulator_desc pma8084_pldo = {
189 .linear_ranges = (struct regulator_linear_range[]) { 189 .linear_ranges = (struct regulator_linear_range[]) {
190 REGULATOR_LINEAR_RANGE(750000, 0, 30, 25000), 190 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
191 REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), 191 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
192 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
192 }, 193 },
193 .n_linear_ranges = 2, 194 .n_linear_ranges = 3,
194 .n_voltages = 100, 195 .n_voltages = 164,
195 .ops = &rpm_smps_ldo_ops, 196 .ops = &rpm_smps_ldo_ops,
196}; 197};
197 198
@@ -221,29 +222,30 @@ static const struct regulator_desc pm8x41_hfsmps = {
221static const struct regulator_desc pm8841_ftsmps = { 222static const struct regulator_desc pm8841_ftsmps = {
222 .linear_ranges = (struct regulator_linear_range[]) { 223 .linear_ranges = (struct regulator_linear_range[]) {
223 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), 224 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
224 REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), 225 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
225 }, 226 },
226 .n_linear_ranges = 2, 227 .n_linear_ranges = 2,
227 .n_voltages = 340, 228 .n_voltages = 262,
228 .ops = &rpm_smps_ldo_ops, 229 .ops = &rpm_smps_ldo_ops,
229}; 230};
230 231
231static const struct regulator_desc pm8941_boost = { 232static const struct regulator_desc pm8941_boost = {
232 .linear_ranges = (struct regulator_linear_range[]) { 233 .linear_ranges = (struct regulator_linear_range[]) {
233 REGULATOR_LINEAR_RANGE(4000000, 0, 15, 100000), 234 REGULATOR_LINEAR_RANGE(4000000, 0, 30, 50000),
234 }, 235 },
235 .n_linear_ranges = 1, 236 .n_linear_ranges = 1,
236 .n_voltages = 16, 237 .n_voltages = 31,
237 .ops = &rpm_smps_ldo_ops, 238 .ops = &rpm_smps_ldo_ops,
238}; 239};
239 240
240static const struct regulator_desc pm8941_pldo = { 241static const struct regulator_desc pm8941_pldo = {
241 .linear_ranges = (struct regulator_linear_range[]) { 242 .linear_ranges = (struct regulator_linear_range[]) {
242 REGULATOR_LINEAR_RANGE( 750000, 0, 30, 25000), 243 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
243 REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), 244 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
245 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
244 }, 246 },
245 .n_linear_ranges = 2, 247 .n_linear_ranges = 3,
246 .n_voltages = 100, 248 .n_voltages = 164,
247 .ops = &rpm_smps_ldo_ops, 249 .ops = &rpm_smps_ldo_ops,
248}; 250};
249 251
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 83458f7a2824..6dc96c8dfe75 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -361,8 +361,9 @@ static const char * const snstext[] = {
361 361
362/* Get sense key string or NULL if not available */ 362/* Get sense key string or NULL if not available */
363const char * 363const char *
364scsi_sense_key_string(unsigned char key) { 364scsi_sense_key_string(unsigned char key)
365 if (key <= 0xE) 365{
366 if (key < ARRAY_SIZE(snstext))
366 return snstext[key]; 367 return snstext[key];
367 return NULL; 368 return NULL;
368} 369}
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index eaccd651ccda..246456925335 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -246,6 +246,10 @@ static struct {
246 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 246 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
247 {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 247 {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
248 {"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 248 {"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
249 {"STK", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
250 {"NETAPP", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
251 {"LSI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
252 {"ENGENIO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
249 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, 253 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
250 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, 254 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
251 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ 255 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 3f0ff072184b..60b651bfaa01 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -341,22 +341,6 @@ static int do_sas_phy_delete(struct device *dev, void *data)
341} 341}
342 342
343/** 343/**
344 * is_sas_attached - check if device is SAS attached
345 * @sdev: scsi device to check
346 *
347 * returns true if the device is SAS attached
348 */
349int is_sas_attached(struct scsi_device *sdev)
350{
351 struct Scsi_Host *shost = sdev->host;
352
353 return shost->transportt->host_attrs.ac.class ==
354 &sas_host_class.class;
355}
356EXPORT_SYMBOL(is_sas_attached);
357
358
359/**
360 * sas_remove_children - tear down a devices SAS data structures 344 * sas_remove_children - tear down a devices SAS data structures
361 * @dev: device belonging to the sas object 345 * @dev: device belonging to the sas object
362 * 346 *
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 0e8601aa877a..8c9a35c91705 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
587 587
588 ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0); 588 ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);
589 589
590 if (is_sas_attached(sdev)) 590 if (scsi_is_sas_rphy(&sdev->sdev_gendev))
591 efd.addr = sas_get_address(sdev); 591 efd.addr = sas_get_address(sdev);
592 592
593 if (efd.addr) { 593 if (efd.addr) {
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index 823cbc92d1e7..7a37090dabbe 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -720,8 +720,6 @@ static int img_spfi_remove(struct platform_device *pdev)
720 clk_disable_unprepare(spfi->sys_clk); 720 clk_disable_unprepare(spfi->sys_clk);
721 } 721 }
722 722
723 spi_master_put(master);
724
725 return 0; 723 return 0;
726} 724}
727 725
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 0be89e052428..899d7a8f0889 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -685,7 +685,6 @@ static int mtk_spi_remove(struct platform_device *pdev)
685 pm_runtime_disable(&pdev->dev); 685 pm_runtime_disable(&pdev->dev);
686 686
687 mtk_spi_reset(mdata); 687 mtk_spi_reset(mdata);
688 spi_master_put(master);
689 688
690 return 0; 689 return 0;
691} 690}
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index f3df522db93b..58d2d48e16a5 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -214,6 +214,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
214 return PTR_ERR(ssp->clk); 214 return PTR_ERR(ssp->clk);
215 215
216 memset(&pi, 0, sizeof(pi)); 216 memset(&pi, 0, sizeof(pi));
217 pi.fwnode = dev->dev.fwnode;
217 pi.parent = &dev->dev; 218 pi.parent = &dev->dev;
218 pi.name = "pxa2xx-spi"; 219 pi.name = "pxa2xx-spi";
219 pi.id = ssp->port_id; 220 pi.id = ssp->port_id;
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index c338ef1136f6..7f1555621f8e 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -1030,7 +1030,6 @@ static int spi_qup_remove(struct platform_device *pdev)
1030 1030
1031 pm_runtime_put_noidle(&pdev->dev); 1031 pm_runtime_put_noidle(&pdev->dev);
1032 pm_runtime_disable(&pdev->dev); 1032 pm_runtime_disable(&pdev->dev);
1033 spi_master_put(master);
1034 1033
1035 return 0; 1034 return 0;
1036} 1035}
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0f83ad1d5a58..1de3a772eb7d 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -262,6 +262,9 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
262 262
263 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) { 263 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {
264 brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div); 264 brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);
265 /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */
266 if (sh_msiof_spi_div_table[k].div == 1 && brps > 2)
267 continue;
265 if (brps <= 32) /* max of brdv is 32 */ 268 if (brps <= 32) /* max of brdv is 32 */
266 break; 269 break;
267 } 270 }
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 51ad42fad567..200ca228d885 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -960,7 +960,7 @@ static int spi_transfer_one_message(struct spi_master *master,
960 struct spi_transfer *xfer; 960 struct spi_transfer *xfer;
961 bool keep_cs = false; 961 bool keep_cs = false;
962 int ret = 0; 962 int ret = 0;
963 unsigned long ms = 1; 963 unsigned long long ms = 1;
964 struct spi_statistics *statm = &master->statistics; 964 struct spi_statistics *statm = &master->statistics;
965 struct spi_statistics *stats = &msg->spi->statistics; 965 struct spi_statistics *stats = &msg->spi->statistics;
966 966
@@ -991,9 +991,13 @@ static int spi_transfer_one_message(struct spi_master *master,
991 991
992 if (ret > 0) { 992 if (ret > 0) {
993 ret = 0; 993 ret = 0;
994 ms = xfer->len * 8 * 1000 / xfer->speed_hz; 994 ms = 8LL * 1000LL * xfer->len;
995 do_div(ms, xfer->speed_hz);
995 ms += ms + 100; /* some tolerance */ 996 ms += ms + 100; /* some tolerance */
996 997
998 if (ms > UINT_MAX)
999 ms = UINT_MAX;
1000
997 ms = wait_for_completion_timeout(&master->xfer_completion, 1001 ms = wait_for_completion_timeout(&master->xfer_completion,
998 msecs_to_jiffies(ms)); 1002 msecs_to_jiffies(ms));
999 } 1003 }
@@ -1159,6 +1163,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
1159 if (ret < 0) { 1163 if (ret < 0) {
1160 dev_err(&master->dev, "Failed to power device: %d\n", 1164 dev_err(&master->dev, "Failed to power device: %d\n",
1161 ret); 1165 ret);
1166 mutex_unlock(&master->io_mutex);
1162 return; 1167 return;
1163 } 1168 }
1164 } 1169 }
@@ -1174,6 +1179,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
1174 1179
1175 if (master->auto_runtime_pm) 1180 if (master->auto_runtime_pm)
1176 pm_runtime_put(master->dev.parent); 1181 pm_runtime_put(master->dev.parent);
1182 mutex_unlock(&master->io_mutex);
1177 return; 1183 return;
1178 } 1184 }
1179 } 1185 }
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 71a339271fa5..5f817923f374 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -504,6 +504,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
504 if (IS_ERR(priv->zone)) { 504 if (IS_ERR(priv->zone)) {
505 dev_err(dev, "can't register thermal zone\n"); 505 dev_err(dev, "can't register thermal zone\n");
506 ret = PTR_ERR(priv->zone); 506 ret = PTR_ERR(priv->zone);
507 priv->zone = NULL;
507 goto error_unregister; 508 goto error_unregister;
508 } 509 }
509 510
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index dfec5a176315..b93356834bb5 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -949,6 +949,15 @@ static int isr_setup_status_phase(struct ci_hdrc *ci)
949 int retval; 949 int retval;
950 struct ci_hw_ep *hwep; 950 struct ci_hw_ep *hwep;
951 951
952 /*
953 * Unexpected USB controller behavior, caused by bad signal integrity
954 * or ground reference problems, can lead to isr_setup_status_phase
955 * being called with ci->status equal to NULL.
956 * If this situation occurs, you should review your USB hardware design.
957 */
958 if (WARN_ON_ONCE(!ci->status))
959 return -EPIPE;
960
952 hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in; 961 hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in;
953 ci->status->context = ci; 962 ci->status->context = ci;
954 ci->status->complete = isr_setup_status_complete; 963 ci->status->complete = isr_setup_status_complete;
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 0a32430f4c41..6df0f5dad9a4 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -249,7 +249,9 @@ static int dwc3_pci_runtime_resume(struct device *dev)
249 249
250 return pm_runtime_get(&dwc3->dev); 250 return pm_runtime_get(&dwc3->dev);
251} 251}
252#endif /* CONFIG_PM */
252 253
254#ifdef CONFIG_PM_SLEEP
253static int dwc3_pci_pm_dummy(struct device *dev) 255static int dwc3_pci_pm_dummy(struct device *dev)
254{ 256{
255 /* 257 /*
@@ -262,7 +264,7 @@ static int dwc3_pci_pm_dummy(struct device *dev)
262 */ 264 */
263 return 0; 265 return 0;
264} 266}
265#endif /* CONFIG_PM */ 267#endif /* CONFIG_PM_SLEEP */
266 268
267static struct dev_pm_ops dwc3_pci_dev_pm_ops = { 269static struct dev_pm_ops dwc3_pci_dev_pm_ops = {
268 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy) 270 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7a8d3d822b54..122e64df2f4d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -884,9 +884,12 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
884 return DWC3_TRB_NUM - 1; 884 return DWC3_TRB_NUM - 1;
885 } 885 }
886 886
887 trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1; 887 trbs_left = dep->trb_dequeue - dep->trb_enqueue;
888 trbs_left &= (DWC3_TRB_NUM - 1); 888 trbs_left &= (DWC3_TRB_NUM - 1);
889 889
890 if (dep->trb_dequeue < dep->trb_enqueue)
891 trbs_left--;
892
890 return trbs_left; 893 return trbs_left;
891} 894}
892 895
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index 8741fd740174..007ec6e4a5d4 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -342,7 +342,7 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
342 struct sk_buff *skb2 = NULL; 342 struct sk_buff *skb2 = NULL;
343 struct usb_ep *in = port->in_ep; 343 struct usb_ep *in = port->in_ep;
344 int headroom, tailroom, padlen = 0; 344 int headroom, tailroom, padlen = 0;
345 u16 len = skb->len; 345 u16 len;
346 346
347 if (!skb) 347 if (!skb)
348 return NULL; 348 return NULL;
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 93a3bec81df7..fb8fc34827ab 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -106,6 +106,7 @@
106 106
107/* DRD_CON */ 107/* DRD_CON */
108#define DRD_CON_PERI_CON BIT(24) 108#define DRD_CON_PERI_CON BIT(24)
109#define DRD_CON_VBOUT BIT(0)
109 110
110/* USB_INT_ENA_1 and USB_INT_STA_1 */ 111/* USB_INT_ENA_1 and USB_INT_STA_1 */
111#define USB_INT_1_B3_PLLWKUP BIT(31) 112#define USB_INT_1_B3_PLLWKUP BIT(31)
@@ -363,6 +364,7 @@ static void usb3_init_epc_registers(struct renesas_usb3 *usb3)
363{ 364{
364 /* FIXME: How to change host / peripheral mode as well? */ 365 /* FIXME: How to change host / peripheral mode as well? */
365 usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); 366 usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);
367 usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON);
366 368
367 usb3_write(usb3, ~0, USB3_USB_INT_STA_1); 369 usb3_write(usb3, ~0, USB3_USB_INT_STA_1);
368 usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); 370 usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index fd9fd12e4861..797137e26549 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -850,6 +850,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
850 spin_lock_irqsave(&xhci->lock, flags); 850 spin_lock_irqsave(&xhci->lock, flags);
851 851
852 ep->stop_cmds_pending--; 852 ep->stop_cmds_pending--;
853 if (xhci->xhc_state & XHCI_STATE_REMOVING) {
854 spin_unlock_irqrestore(&xhci->lock, flags);
855 return;
856 }
853 if (xhci->xhc_state & XHCI_STATE_DYING) { 857 if (xhci->xhc_state & XHCI_STATE_DYING) {
854 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 858 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
855 "Stop EP timer ran, but another timer marked " 859 "Stop EP timer ran, but another timer marked "
@@ -903,7 +907,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
903 spin_unlock_irqrestore(&xhci->lock, flags); 907 spin_unlock_irqrestore(&xhci->lock, flags);
904 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 908 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
905 "Calling usb_hc_died()"); 909 "Calling usb_hc_died()");
906 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); 910 usb_hc_died(xhci_to_hcd(xhci));
907 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 911 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
908 "xHCI host controller is dead."); 912 "xHCI host controller is dead.");
909} 913}
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 980c9dee09eb..427efb5eebae 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -144,14 +144,18 @@ static irqreturn_t nop_gpio_vbus_thread(int irq, void *data)
144int usb_gen_phy_init(struct usb_phy *phy) 144int usb_gen_phy_init(struct usb_phy *phy)
145{ 145{
146 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev); 146 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev);
147 int ret;
147 148
148 if (!IS_ERR(nop->vcc)) { 149 if (!IS_ERR(nop->vcc)) {
149 if (regulator_enable(nop->vcc)) 150 if (regulator_enable(nop->vcc))
150 dev_err(phy->dev, "Failed to enable power\n"); 151 dev_err(phy->dev, "Failed to enable power\n");
151 } 152 }
152 153
153 if (!IS_ERR(nop->clk)) 154 if (!IS_ERR(nop->clk)) {
154 clk_prepare_enable(nop->clk); 155 ret = clk_prepare_enable(nop->clk);
156 if (ret)
157 return ret;
158 }
155 159
156 nop_reset(nop); 160 nop_reset(nop);
157 161
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index d4be5d594896..28965ef4f824 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -282,9 +282,16 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
282 if (usbhs_mod_is_host(priv)) 282 if (usbhs_mod_is_host(priv))
283 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); 283 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);
284 284
285 usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); 285 /*
286 * The driver should not clear the xxxSTS after the line of
287 * "call irq callback functions" because each "if" statement is
288 * possible to call the callback function for avoiding any side effects.
289 */
290 if (irq_state.intsts0 & BRDY)
291 usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
286 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); 292 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
287 usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); 293 if (irq_state.intsts0 & BEMP)
294 usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
288 295
289 /* 296 /*
290 * call irq callback functions 297 * call irq callback functions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index e383ecdaca59..ed9c9eeedfe5 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -167,7 +167,7 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
167 * making all of the arch DMA ops work on the vring device itself 167 * making all of the arch DMA ops work on the vring device itself
168 * is a mess. For now, we use the parent device for DMA ops. 168 * is a mess. For now, we use the parent device for DMA ops.
169 */ 169 */
170struct device *vring_dma_dev(const struct vring_virtqueue *vq) 170static struct device *vring_dma_dev(const struct vring_virtqueue *vq)
171{ 171{
172 return vq->vq.vdev->dev.parent; 172 return vq->vq.vdev->dev.parent;
173} 173}
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index eff3993c77b3..33fe03551105 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -427,6 +427,7 @@ struct btrfs_space_info {
427 struct list_head ro_bgs; 427 struct list_head ro_bgs;
428 struct list_head priority_tickets; 428 struct list_head priority_tickets;
429 struct list_head tickets; 429 struct list_head tickets;
430 u64 tickets_id;
430 431
431 struct rw_semaphore groups_sem; 432 struct rw_semaphore groups_sem;
432 /* for block groups in our same type */ 433 /* for block groups in our same type */
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8c8a4d1e02b9..38c2df84cabd 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4966,12 +4966,12 @@ static void wake_all_tickets(struct list_head *head)
4966 */ 4966 */
4967static void btrfs_async_reclaim_metadata_space(struct work_struct *work) 4967static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
4968{ 4968{
4969 struct reserve_ticket *last_ticket = NULL;
4970 struct btrfs_fs_info *fs_info; 4969 struct btrfs_fs_info *fs_info;
4971 struct btrfs_space_info *space_info; 4970 struct btrfs_space_info *space_info;
4972 u64 to_reclaim; 4971 u64 to_reclaim;
4973 int flush_state; 4972 int flush_state;
4974 int commit_cycles = 0; 4973 int commit_cycles = 0;
4974 u64 last_tickets_id;
4975 4975
4976 fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); 4976 fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work);
4977 space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); 4977 space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
@@ -4984,8 +4984,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
4984 spin_unlock(&space_info->lock); 4984 spin_unlock(&space_info->lock);
4985 return; 4985 return;
4986 } 4986 }
4987 last_ticket = list_first_entry(&space_info->tickets, 4987 last_tickets_id = space_info->tickets_id;
4988 struct reserve_ticket, list);
4989 spin_unlock(&space_info->lock); 4988 spin_unlock(&space_info->lock);
4990 4989
4991 flush_state = FLUSH_DELAYED_ITEMS_NR; 4990 flush_state = FLUSH_DELAYED_ITEMS_NR;
@@ -5005,10 +5004,10 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
5005 space_info); 5004 space_info);
5006 ticket = list_first_entry(&space_info->tickets, 5005 ticket = list_first_entry(&space_info->tickets,
5007 struct reserve_ticket, list); 5006 struct reserve_ticket, list);
5008 if (last_ticket == ticket) { 5007 if (last_tickets_id == space_info->tickets_id) {
5009 flush_state++; 5008 flush_state++;
5010 } else { 5009 } else {
5011 last_ticket = ticket; 5010 last_tickets_id = space_info->tickets_id;
5012 flush_state = FLUSH_DELAYED_ITEMS_NR; 5011 flush_state = FLUSH_DELAYED_ITEMS_NR;
5013 if (commit_cycles) 5012 if (commit_cycles)
5014 commit_cycles--; 5013 commit_cycles--;
@@ -5384,6 +5383,7 @@ again:
5384 list_del_init(&ticket->list); 5383 list_del_init(&ticket->list);
5385 num_bytes -= ticket->bytes; 5384 num_bytes -= ticket->bytes;
5386 ticket->bytes = 0; 5385 ticket->bytes = 0;
5386 space_info->tickets_id++;
5387 wake_up(&ticket->wait); 5387 wake_up(&ticket->wait);
5388 } else { 5388 } else {
5389 ticket->bytes -= num_bytes; 5389 ticket->bytes -= num_bytes;
@@ -5426,6 +5426,7 @@ again:
5426 num_bytes -= ticket->bytes; 5426 num_bytes -= ticket->bytes;
5427 space_info->bytes_may_use += ticket->bytes; 5427 space_info->bytes_may_use += ticket->bytes;
5428 ticket->bytes = 0; 5428 ticket->bytes = 0;
5429 space_info->tickets_id++;
5429 wake_up(&ticket->wait); 5430 wake_up(&ticket->wait);
5430 } else { 5431 } else {
5431 trace_btrfs_space_reservation(fs_info, "space_info", 5432 trace_btrfs_space_reservation(fs_info, "space_info",
@@ -8216,6 +8217,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
8216{ 8217{
8217 int ret; 8218 int ret;
8218 struct btrfs_block_group_cache *block_group; 8219 struct btrfs_block_group_cache *block_group;
8220 struct btrfs_space_info *space_info;
8219 8221
8220 /* 8222 /*
8221 * Mixed block groups will exclude before processing the log so we only 8223 * Mixed block groups will exclude before processing the log so we only
@@ -8231,9 +8233,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
8231 if (!block_group) 8233 if (!block_group)
8232 return -EINVAL; 8234 return -EINVAL;
8233 8235
8234 ret = btrfs_add_reserved_bytes(block_group, ins->offset, 8236 space_info = block_group->space_info;
8235 ins->offset, 0); 8237 spin_lock(&space_info->lock);
8236 BUG_ON(ret); /* logic error */ 8238 spin_lock(&block_group->lock);
8239 space_info->bytes_reserved += ins->offset;
8240 block_group->reserved += ins->offset;
8241 spin_unlock(&block_group->lock);
8242 spin_unlock(&space_info->lock);
8243
8237 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, 8244 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid,
8238 0, owner, offset, ins, 1); 8245 0, owner, offset, ins, 1);
8239 btrfs_put_block_group(block_group); 8246 btrfs_put_block_group(block_group);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index e935035ac034..ef9c55bc7907 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2867,6 +2867,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2867 2867
2868 if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { 2868 if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) {
2869 blk_finish_plug(&plug); 2869 blk_finish_plug(&plug);
2870 list_del_init(&root_log_ctx.list);
2870 mutex_unlock(&log_root_tree->log_mutex); 2871 mutex_unlock(&log_root_tree->log_mutex);
2871 ret = root_log_ctx.log_ret; 2872 ret = root_log_ctx.log_ret;
2872 goto out; 2873 goto out;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index c64a0b794d49..df4b3e6fa563 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -597,7 +597,7 @@ static bool need_reset_readdir(struct ceph_file_info *fi, loff_t new_pos)
597 if (is_hash_order(new_pos)) { 597 if (is_hash_order(new_pos)) {
598 /* no need to reset last_name for a forward seek when 598 /* no need to reset last_name for a forward seek when
599 * dentries are sotred in hash order */ 599 * dentries are sotred in hash order */
600 } else if (fi->frag |= fpos_frag(new_pos)) { 600 } else if (fi->frag != fpos_frag(new_pos)) {
601 return true; 601 return true;
602 } 602 }
603 rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL; 603 rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL;
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 0f9961eede1e..ed115acb5dee 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -11,6 +11,7 @@
11#include <linux/random.h> 11#include <linux/random.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/fscrypto.h> 13#include <linux/fscrypto.h>
14#include <linux/mount.h>
14 15
15static int inode_has_encryption_context(struct inode *inode) 16static int inode_has_encryption_context(struct inode *inode)
16{ 17{
@@ -92,26 +93,42 @@ static int create_encryption_context_from_policy(struct inode *inode,
92 return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL); 93 return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL);
93} 94}
94 95
95int fscrypt_process_policy(struct inode *inode, 96int fscrypt_process_policy(struct file *filp,
96 const struct fscrypt_policy *policy) 97 const struct fscrypt_policy *policy)
97{ 98{
99 struct inode *inode = file_inode(filp);
100 int ret;
101
102 if (!inode_owner_or_capable(inode))
103 return -EACCES;
104
98 if (policy->version != 0) 105 if (policy->version != 0)
99 return -EINVAL; 106 return -EINVAL;
100 107
108 ret = mnt_want_write_file(filp);
109 if (ret)
110 return ret;
111
101 if (!inode_has_encryption_context(inode)) { 112 if (!inode_has_encryption_context(inode)) {
102 if (!inode->i_sb->s_cop->empty_dir) 113 if (!S_ISDIR(inode->i_mode))
103 return -EOPNOTSUPP; 114 ret = -EINVAL;
104 if (!inode->i_sb->s_cop->empty_dir(inode)) 115 else if (!inode->i_sb->s_cop->empty_dir)
105 return -ENOTEMPTY; 116 ret = -EOPNOTSUPP;
106 return create_encryption_context_from_policy(inode, policy); 117 else if (!inode->i_sb->s_cop->empty_dir(inode))
118 ret = -ENOTEMPTY;
119 else
120 ret = create_encryption_context_from_policy(inode,
121 policy);
122 } else if (!is_encryption_context_consistent_with_policy(inode,
123 policy)) {
124 printk(KERN_WARNING
125 "%s: Policy inconsistent with encryption context\n",
126 __func__);
127 ret = -EINVAL;
107 } 128 }
108 129
109 if (is_encryption_context_consistent_with_policy(inode, policy)) 130 mnt_drop_write_file(filp);
110 return 0; 131 return ret;
111
112 printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n",
113 __func__);
114 return -EINVAL;
115} 132}
116EXPORT_SYMBOL(fscrypt_process_policy); 133EXPORT_SYMBOL(fscrypt_process_policy);
117 134
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 10686fd67fb4..1bb7df5e4536 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -776,7 +776,7 @@ resizefs_out:
776 (struct fscrypt_policy __user *)arg, 776 (struct fscrypt_policy __user *)arg,
777 sizeof(policy))) 777 sizeof(policy)))
778 return -EFAULT; 778 return -EFAULT;
779 return fscrypt_process_policy(inode, &policy); 779 return fscrypt_process_policy(filp, &policy);
780#else 780#else
781 return -EOPNOTSUPP; 781 return -EOPNOTSUPP;
782#endif 782#endif
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 47abb96098e4..28f4f4cbb8d8 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1757,21 +1757,14 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
1757{ 1757{
1758 struct fscrypt_policy policy; 1758 struct fscrypt_policy policy;
1759 struct inode *inode = file_inode(filp); 1759 struct inode *inode = file_inode(filp);
1760 int ret;
1761 1760
1762 if (copy_from_user(&policy, (struct fscrypt_policy __user *)arg, 1761 if (copy_from_user(&policy, (struct fscrypt_policy __user *)arg,
1763 sizeof(policy))) 1762 sizeof(policy)))
1764 return -EFAULT; 1763 return -EFAULT;
1765 1764
1766 ret = mnt_want_write_file(filp);
1767 if (ret)
1768 return ret;
1769
1770 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 1765 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
1771 ret = fscrypt_process_policy(inode, &policy);
1772 1766
1773 mnt_drop_write_file(filp); 1767 return fscrypt_process_policy(filp, &policy);
1774 return ret;
1775} 1768}
1776 1769
1777static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) 1770static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f394aff59c36..3988b43c2f5a 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -530,13 +530,13 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos,
530 req->out.args[0].size = count; 530 req->out.args[0].size = count;
531} 531}
532 532
533static void fuse_release_user_pages(struct fuse_req *req, int write) 533static void fuse_release_user_pages(struct fuse_req *req, bool should_dirty)
534{ 534{
535 unsigned i; 535 unsigned i;
536 536
537 for (i = 0; i < req->num_pages; i++) { 537 for (i = 0; i < req->num_pages; i++) {
538 struct page *page = req->pages[i]; 538 struct page *page = req->pages[i];
539 if (write) 539 if (should_dirty)
540 set_page_dirty_lock(page); 540 set_page_dirty_lock(page);
541 put_page(page); 541 put_page(page);
542 } 542 }
@@ -1320,6 +1320,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
1320 loff_t *ppos, int flags) 1320 loff_t *ppos, int flags)
1321{ 1321{
1322 int write = flags & FUSE_DIO_WRITE; 1322 int write = flags & FUSE_DIO_WRITE;
1323 bool should_dirty = !write && iter_is_iovec(iter);
1323 int cuse = flags & FUSE_DIO_CUSE; 1324 int cuse = flags & FUSE_DIO_CUSE;
1324 struct file *file = io->file; 1325 struct file *file = io->file;
1325 struct inode *inode = file->f_mapping->host; 1326 struct inode *inode = file->f_mapping->host;
@@ -1363,7 +1364,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
1363 nres = fuse_send_read(req, io, pos, nbytes, owner); 1364 nres = fuse_send_read(req, io, pos, nbytes, owner);
1364 1365
1365 if (!io->async) 1366 if (!io->async)
1366 fuse_release_user_pages(req, !write); 1367 fuse_release_user_pages(req, should_dirty);
1367 if (req->out.h.error) { 1368 if (req->out.h.error) {
1368 err = req->out.h.error; 1369 err = req->out.h.error;
1369 break; 1370 break;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index a4585f961bf9..e2a94a26767b 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -835,11 +835,11 @@ retry:
835 goto out_dput; 835 goto out_dput;
836 836
837 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT); 837 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT);
838 if (err && err != -ENODATA) 838 if (err && err != -ENODATA && err != -EOPNOTSUPP)
839 goto out_dput; 839 goto out_dput;
840 840
841 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS); 841 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS);
842 if (err && err != -ENODATA) 842 if (err && err != -ENODATA && err != -EOPNOTSUPP)
843 goto out_dput; 843 goto out_dput;
844 844
845 /* Clear any inherited mode bits */ 845 /* Clear any inherited mode bits */
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 187d84ef9de9..f6fa99eca515 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -581,6 +581,8 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
581 mss->anonymous_thp += HPAGE_PMD_SIZE; 581 mss->anonymous_thp += HPAGE_PMD_SIZE;
582 else if (PageSwapBacked(page)) 582 else if (PageSwapBacked(page))
583 mss->shmem_thp += HPAGE_PMD_SIZE; 583 mss->shmem_thp += HPAGE_PMD_SIZE;
584 else if (is_zone_device_page(page))
585 /* pass */;
584 else 586 else
585 VM_BUG_ON_PAGE(1, page); 587 VM_BUG_ON_PAGE(1, page);
586 smaps_account(mss, page, true, pmd_young(*pmd), pmd_dirty(*pmd)); 588 smaps_account(mss, page, true, pmd_young(*pmd), pmd_dirty(*pmd));
diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h
index cfa6cde25f8e..76cff18bb032 100644
--- a/include/linux/fscrypto.h
+++ b/include/linux/fscrypto.h
@@ -274,8 +274,7 @@ extern void fscrypt_restore_control_page(struct page *);
274extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, 274extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t,
275 unsigned int); 275 unsigned int);
276/* policy.c */ 276/* policy.c */
277extern int fscrypt_process_policy(struct inode *, 277extern int fscrypt_process_policy(struct file *, const struct fscrypt_policy *);
278 const struct fscrypt_policy *);
279extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); 278extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *);
280extern int fscrypt_has_permitted_context(struct inode *, struct inode *); 279extern int fscrypt_has_permitted_context(struct inode *, struct inode *);
281extern int fscrypt_inherit_context(struct inode *, struct inode *, 280extern int fscrypt_inherit_context(struct inode *, struct inode *,
@@ -345,7 +344,7 @@ static inline int fscrypt_notsupp_zeroout_range(struct inode *i, pgoff_t p,
345} 344}
346 345
347/* policy.c */ 346/* policy.c */
348static inline int fscrypt_notsupp_process_policy(struct inode *i, 347static inline int fscrypt_notsupp_process_policy(struct file *f,
349 const struct fscrypt_policy *p) 348 const struct fscrypt_policy *p)
350{ 349{
351 return -EOPNOTSUPP; 350 return -EOPNOTSUPP;
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index cbd8990e2e77..2b5b10eed74f 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -118,10 +118,11 @@ static inline int arch_within_stack_frames(const void * const stack,
118extern void __check_object_size(const void *ptr, unsigned long n, 118extern void __check_object_size(const void *ptr, unsigned long n,
119 bool to_user); 119 bool to_user);
120 120
121static inline void check_object_size(const void *ptr, unsigned long n, 121static __always_inline void check_object_size(const void *ptr, unsigned long n,
122 bool to_user) 122 bool to_user)
123{ 123{
124 __check_object_size(ptr, n, to_user); 124 if (!__builtin_constant_p(n))
125 __check_object_size(ptr, n, to_user);
125} 126}
126#else 127#else
127static inline void check_object_size(const void *ptr, unsigned long n, 128static inline void check_object_size(const void *ptr, unsigned long n,
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 13c0b2ba1b6c..73d870918939 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -11,12 +11,12 @@ struct sas_rphy;
11struct request; 11struct request;
12 12
13#if !IS_ENABLED(CONFIG_SCSI_SAS_ATTRS) 13#if !IS_ENABLED(CONFIG_SCSI_SAS_ATTRS)
14static inline int is_sas_attached(struct scsi_device *sdev) 14static inline int scsi_is_sas_rphy(const struct device *sdev)
15{ 15{
16 return 0; 16 return 0;
17} 17}
18#else 18#else
19extern int is_sas_attached(struct scsi_device *sdev); 19extern int scsi_is_sas_rphy(const struct device *);
20#endif 20#endif
21 21
22static inline int sas_protocol_ata(enum sas_protocol proto) 22static inline int sas_protocol_ata(enum sas_protocol proto)
@@ -202,7 +202,6 @@ extern int sas_rphy_add(struct sas_rphy *);
202extern void sas_rphy_remove(struct sas_rphy *); 202extern void sas_rphy_remove(struct sas_rphy *);
203extern void sas_rphy_delete(struct sas_rphy *); 203extern void sas_rphy_delete(struct sas_rphy *);
204extern void sas_rphy_unlink(struct sas_rphy *); 204extern void sas_rphy_unlink(struct sas_rphy *);
205extern int scsi_is_sas_rphy(const struct device *);
206 205
207struct sas_port *sas_port_alloc(struct device *, int); 206struct sas_port *sas_port_alloc(struct device *, int);
208struct sas_port *sas_port_alloc_num(struct device *); 207struct sas_port *sas_port_alloc_num(struct device *);
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 251d16b4cb41..b501e390bb34 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
247 align_start = res->start & ~(SECTION_SIZE - 1); 247 align_start = res->start & ~(SECTION_SIZE - 1);
248 align_size = ALIGN(resource_size(res), SECTION_SIZE); 248 align_size = ALIGN(resource_size(res), SECTION_SIZE);
249 arch_remove_memory(align_start, align_size); 249 arch_remove_memory(align_start, align_size);
250 untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
250 pgmap_radix_release(res); 251 pgmap_radix_release(res);
251 dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, 252 dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc,
252 "%s: failed to free all reserved pages\n", __func__); 253 "%s: failed to free all reserved pages\n", __func__);
@@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
282 struct percpu_ref *ref, struct vmem_altmap *altmap) 283 struct percpu_ref *ref, struct vmem_altmap *altmap)
283{ 284{
284 resource_size_t key, align_start, align_size, align_end; 285 resource_size_t key, align_start, align_size, align_end;
286 pgprot_t pgprot = PAGE_KERNEL;
285 struct dev_pagemap *pgmap; 287 struct dev_pagemap *pgmap;
286 struct page_map *page_map; 288 struct page_map *page_map;
287 int error, nid, is_ram; 289 int error, nid, is_ram;
@@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
351 if (nid < 0) 353 if (nid < 0)
352 nid = numa_mem_id(); 354 nid = numa_mem_id();
353 355
356 error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0,
357 align_size);
358 if (error)
359 goto err_pfn_remap;
360
354 error = arch_add_memory(nid, align_start, align_size, true); 361 error = arch_add_memory(nid, align_start, align_size, true);
355 if (error) 362 if (error)
356 goto err_add_memory; 363 goto err_add_memory;
@@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
371 return __va(res->start); 378 return __va(res->start);
372 379
373 err_add_memory: 380 err_add_memory:
381 untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
382 err_pfn_remap:
374 err_radix: 383 err_radix:
375 pgmap_radix_release(res); 384 pgmap_radix_release(res);
376 devres_free(page_map); 385 devres_free(page_map);
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 97b0df71303e..168ff442ebde 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -482,7 +482,16 @@ void pm_qos_update_request(struct pm_qos_request *req,
482 return; 482 return;
483 } 483 }
484 484
485 cancel_delayed_work_sync(&req->work); 485 /*
486 * This function may be called very early during boot, for example,
487 * from of_clk_init(), where irq needs to stay disabled.
488 * cancel_delayed_work_sync() assumes that irq is enabled on
489 * invocation and re-enables it on return. Avoid calling it until
490 * workqueue is initialized.
491 */
492 if (keventd_up())
493 cancel_delayed_work_sync(&req->work);
494
486 __pm_qos_update_request(req, new_value); 495 __pm_qos_update_request(req, new_value);
487} 496}
488EXPORT_SYMBOL_GPL(pm_qos_update_request); 497EXPORT_SYMBOL_GPL(pm_qos_update_request);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 2db2112aa31e..a6abd76baa72 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1078,7 +1078,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
1078 goto out; 1078 goto out;
1079 1079
1080 page = pmd_page(*pmd); 1080 page = pmd_page(*pmd);
1081 VM_BUG_ON_PAGE(!PageHead(page), page); 1081 VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page);
1082 if (flags & FOLL_TOUCH) 1082 if (flags & FOLL_TOUCH)
1083 touch_pmd(vma, addr, pmd); 1083 touch_pmd(vma, addr, pmd);
1084 if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) { 1084 if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
@@ -1116,7 +1116,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
1116 } 1116 }
1117skip_mlock: 1117skip_mlock:
1118 page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; 1118 page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
1119 VM_BUG_ON_PAGE(!PageCompound(page), page); 1119 VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page);
1120 if (flags & FOLL_GET) 1120 if (flags & FOLL_GET)
1121 get_page(page); 1121 get_page(page);
1122 1122
diff --git a/mm/usercopy.c b/mm/usercopy.c
index a3cc3052f830..089328f2b920 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -134,31 +134,16 @@ static inline const char *check_bogus_address(const void *ptr, unsigned long n)
134 return NULL; 134 return NULL;
135} 135}
136 136
137static inline const char *check_heap_object(const void *ptr, unsigned long n, 137/* Checks for allocs that are marked in some way as spanning multiple pages. */
138 bool to_user) 138static inline const char *check_page_span(const void *ptr, unsigned long n,
139 struct page *page, bool to_user)
139{ 140{
140 struct page *page, *endpage; 141#ifdef CONFIG_HARDENED_USERCOPY_PAGESPAN
141 const void *end = ptr + n - 1; 142 const void *end = ptr + n - 1;
143 struct page *endpage;
142 bool is_reserved, is_cma; 144 bool is_reserved, is_cma;
143 145
144 /* 146 /*
145 * Some architectures (arm64) return true for virt_addr_valid() on
146 * vmalloced addresses. Work around this by checking for vmalloc
147 * first.
148 */
149 if (is_vmalloc_addr(ptr))
150 return NULL;
151
152 if (!virt_addr_valid(ptr))
153 return NULL;
154
155 page = virt_to_head_page(ptr);
156
157 /* Check slab allocator for flags and size. */
158 if (PageSlab(page))
159 return __check_heap_object(ptr, n, page);
160
161 /*
162 * Sometimes the kernel data regions are not marked Reserved (see 147 * Sometimes the kernel data regions are not marked Reserved (see
163 * check below). And sometimes [_sdata,_edata) does not cover 148 * check below). And sometimes [_sdata,_edata) does not cover
164 * rodata and/or bss, so check each range explicitly. 149 * rodata and/or bss, so check each range explicitly.
@@ -186,7 +171,7 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
186 ((unsigned long)end & (unsigned long)PAGE_MASK))) 171 ((unsigned long)end & (unsigned long)PAGE_MASK)))
187 return NULL; 172 return NULL;
188 173
189 /* Allow if start and end are inside the same compound page. */ 174 /* Allow if fully inside the same compound (__GFP_COMP) page. */
190 endpage = virt_to_head_page(end); 175 endpage = virt_to_head_page(end);
191 if (likely(endpage == page)) 176 if (likely(endpage == page))
192 return NULL; 177 return NULL;
@@ -199,20 +184,44 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
199 is_reserved = PageReserved(page); 184 is_reserved = PageReserved(page);
200 is_cma = is_migrate_cma_page(page); 185 is_cma = is_migrate_cma_page(page);
201 if (!is_reserved && !is_cma) 186 if (!is_reserved && !is_cma)
202 goto reject; 187 return "<spans multiple pages>";
203 188
204 for (ptr += PAGE_SIZE; ptr <= end; ptr += PAGE_SIZE) { 189 for (ptr += PAGE_SIZE; ptr <= end; ptr += PAGE_SIZE) {
205 page = virt_to_head_page(ptr); 190 page = virt_to_head_page(ptr);
206 if (is_reserved && !PageReserved(page)) 191 if (is_reserved && !PageReserved(page))
207 goto reject; 192 return "<spans Reserved and non-Reserved pages>";
208 if (is_cma && !is_migrate_cma_page(page)) 193 if (is_cma && !is_migrate_cma_page(page))
209 goto reject; 194 return "<spans CMA and non-CMA pages>";
210 } 195 }
196#endif
211 197
212 return NULL; 198 return NULL;
199}
200
201static inline const char *check_heap_object(const void *ptr, unsigned long n,
202 bool to_user)
203{
204 struct page *page;
205
206 /*
207 * Some architectures (arm64) return true for virt_addr_valid() on
208 * vmalloced addresses. Work around this by checking for vmalloc
209 * first.
210 */
211 if (is_vmalloc_addr(ptr))
212 return NULL;
213
214 if (!virt_addr_valid(ptr))
215 return NULL;
216
217 page = virt_to_head_page(ptr);
218
219 /* Check slab allocator for flags and size. */
220 if (PageSlab(page))
221 return __check_heap_object(ptr, n, page);
213 222
214reject: 223 /* Verify object does not incorrectly span multiple pages. */
215 return "<spans multiple pages>"; 224 return check_page_span(ptr, n, page, to_user);
216} 225}
217 226
218/* 227/*
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index e1c09e2f9be7..8ea9fd2b6573 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -332,7 +332,9 @@ if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then
332 (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" 332 (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles"
333fi 333fi
334(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" 334(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles"
335(cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" 335if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then
336 (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles"
337fi
336destdir=$kernel_headers_dir/usr/src/linux-headers-$version 338destdir=$kernel_headers_dir/usr/src/linux-headers-$version
337mkdir -p "$destdir" 339mkdir -p "$destdir"
338(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) 340(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -)
diff --git a/security/Kconfig b/security/Kconfig
index da10d9b573a4..118f4549404e 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -147,6 +147,17 @@ config HARDENED_USERCOPY
147 or are part of the kernel text. This kills entire classes 147 or are part of the kernel text. This kills entire classes
148 of heap overflow exploits and similar kernel memory exposures. 148 of heap overflow exploits and similar kernel memory exposures.
149 149
150config HARDENED_USERCOPY_PAGESPAN
151 bool "Refuse to copy allocations that span multiple pages"
152 depends on HARDENED_USERCOPY
153 depends on EXPERT
154 help
155 When a multi-page allocation is done without __GFP_COMP,
156 hardened usercopy will reject attempts to copy it. There are,
157 however, several cases of this in the kernel that have not all
158 been removed. This config is intended to be used only while
159 trying to find such users.
160
150source security/selinux/Kconfig 161source security/selinux/Kconfig
151source security/smack/Kconfig 162source security/smack/Kconfig
152source security/tomoyo/Kconfig 163source security/tomoyo/Kconfig
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 795437b10082..b450a27588c8 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1633,11 +1633,13 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1633 return -EBUSY; 1633 return -EBUSY;
1634 } 1634 }
1635 list_add_tail(&rmidi->list, &snd_rawmidi_devices); 1635 list_add_tail(&rmidi->list, &snd_rawmidi_devices);
1636 mutex_unlock(&register_mutex);
1636 err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, 1637 err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
1637 rmidi->card, rmidi->device, 1638 rmidi->card, rmidi->device,
1638 &snd_rawmidi_f_ops, rmidi, &rmidi->dev); 1639 &snd_rawmidi_f_ops, rmidi, &rmidi->dev);
1639 if (err < 0) { 1640 if (err < 0) {
1640 rmidi_err(rmidi, "unable to register\n"); 1641 rmidi_err(rmidi, "unable to register\n");
1642 mutex_lock(&register_mutex);
1641 list_del(&rmidi->list); 1643 list_del(&rmidi->list);
1642 mutex_unlock(&register_mutex); 1644 mutex_unlock(&register_mutex);
1643 return err; 1645 return err;
@@ -1645,6 +1647,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1645 if (rmidi->ops && rmidi->ops->dev_register && 1647 if (rmidi->ops && rmidi->ops->dev_register &&
1646 (err = rmidi->ops->dev_register(rmidi)) < 0) { 1648 (err = rmidi->ops->dev_register(rmidi)) < 0) {
1647 snd_unregister_device(&rmidi->dev); 1649 snd_unregister_device(&rmidi->dev);
1650 mutex_lock(&register_mutex);
1648 list_del(&rmidi->list); 1651 list_del(&rmidi->list);
1649 mutex_unlock(&register_mutex); 1652 mutex_unlock(&register_mutex);
1650 return err; 1653 return err;
@@ -1677,7 +1680,6 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1677 } 1680 }
1678 } 1681 }
1679#endif /* CONFIG_SND_OSSEMUL */ 1682#endif /* CONFIG_SND_OSSEMUL */
1680 mutex_unlock(&register_mutex);
1681 sprintf(name, "midi%d", rmidi->device); 1683 sprintf(name, "midi%d", rmidi->device);
1682 entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); 1684 entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root);
1683 if (entry) { 1685 if (entry) {
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 9a6157ea6881..fc144f43faa6 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -35,6 +35,9 @@
35#include <sound/initval.h> 35#include <sound/initval.h>
36#include <linux/kmod.h> 36#include <linux/kmod.h>
37 37
38/* internal flags */
39#define SNDRV_TIMER_IFLG_PAUSED 0x00010000
40
38#if IS_ENABLED(CONFIG_SND_HRTIMER) 41#if IS_ENABLED(CONFIG_SND_HRTIMER)
39#define DEFAULT_TIMER_LIMIT 4 42#define DEFAULT_TIMER_LIMIT 4
40#else 43#else
@@ -294,8 +297,21 @@ int snd_timer_open(struct snd_timer_instance **ti,
294 get_device(&timer->card->card_dev); 297 get_device(&timer->card->card_dev);
295 timeri->slave_class = tid->dev_sclass; 298 timeri->slave_class = tid->dev_sclass;
296 timeri->slave_id = slave_id; 299 timeri->slave_id = slave_id;
297 if (list_empty(&timer->open_list_head) && timer->hw.open) 300
298 timer->hw.open(timer); 301 if (list_empty(&timer->open_list_head) && timer->hw.open) {
302 int err = timer->hw.open(timer);
303 if (err) {
304 kfree(timeri->owner);
305 kfree(timeri);
306
307 if (timer->card)
308 put_device(&timer->card->card_dev);
309 module_put(timer->module);
310 mutex_unlock(&register_mutex);
311 return err;
312 }
313 }
314
299 list_add_tail(&timeri->open_list, &timer->open_list_head); 315 list_add_tail(&timeri->open_list, &timer->open_list_head);
300 snd_timer_check_master(timeri); 316 snd_timer_check_master(timeri);
301 mutex_unlock(&register_mutex); 317 mutex_unlock(&register_mutex);
@@ -526,6 +542,10 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
526 } 542 }
527 } 543 }
528 timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START); 544 timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
545 if (stop)
546 timeri->flags &= ~SNDRV_TIMER_IFLG_PAUSED;
547 else
548 timeri->flags |= SNDRV_TIMER_IFLG_PAUSED;
529 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : 549 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
530 SNDRV_TIMER_EVENT_CONTINUE); 550 SNDRV_TIMER_EVENT_CONTINUE);
531 unlock: 551 unlock:
@@ -587,6 +607,10 @@ int snd_timer_stop(struct snd_timer_instance *timeri)
587 */ 607 */
588int snd_timer_continue(struct snd_timer_instance *timeri) 608int snd_timer_continue(struct snd_timer_instance *timeri)
589{ 609{
610 /* timer can continue only after pause */
611 if (!(timeri->flags & SNDRV_TIMER_IFLG_PAUSED))
612 return -EINVAL;
613
590 if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) 614 if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
591 return snd_timer_start_slave(timeri, false); 615 return snd_timer_start_slave(timeri, false);
592 else 616 else
@@ -813,6 +837,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,
813 timer->tmr_subdevice = tid->subdevice; 837 timer->tmr_subdevice = tid->subdevice;
814 if (id) 838 if (id)
815 strlcpy(timer->id, id, sizeof(timer->id)); 839 strlcpy(timer->id, id, sizeof(timer->id));
840 timer->sticks = 1;
816 INIT_LIST_HEAD(&timer->device_list); 841 INIT_LIST_HEAD(&timer->device_list);
817 INIT_LIST_HEAD(&timer->open_list_head); 842 INIT_LIST_HEAD(&timer->open_list_head);
818 INIT_LIST_HEAD(&timer->active_list_head); 843 INIT_LIST_HEAD(&timer->active_list_head);
@@ -1817,6 +1842,9 @@ static int snd_timer_user_continue(struct file *file)
1817 tu = file->private_data; 1842 tu = file->private_data;
1818 if (!tu->timeri) 1843 if (!tu->timeri)
1819 return -EBADFD; 1844 return -EBADFD;
1845 /* start timer instead of continue if it's not used before */
1846 if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED))
1847 return snd_timer_user_start(file);
1820 tu->timeri->lost = 0; 1848 tu->timeri->lost = 0;
1821 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; 1849 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0;
1822} 1850}
@@ -1958,6 +1986,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
1958 tu->qused--; 1986 tu->qused--;
1959 spin_unlock_irq(&tu->qlock); 1987 spin_unlock_irq(&tu->qlock);
1960 1988
1989 mutex_lock(&tu->ioctl_lock);
1961 if (tu->tread) { 1990 if (tu->tread) {
1962 if (copy_to_user(buffer, &tu->tqueue[qhead], 1991 if (copy_to_user(buffer, &tu->tqueue[qhead],
1963 sizeof(struct snd_timer_tread))) 1992 sizeof(struct snd_timer_tread)))
@@ -1967,6 +1996,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
1967 sizeof(struct snd_timer_read))) 1996 sizeof(struct snd_timer_read)))
1968 err = -EFAULT; 1997 err = -EFAULT;
1969 } 1998 }
1999 mutex_unlock(&tu->ioctl_lock);
1970 2000
1971 spin_lock_irq(&tu->qlock); 2001 spin_lock_irq(&tu->qlock);
1972 if (err < 0) 2002 if (err < 0)
diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h
index 03ed35237e2b..d73c12b8753d 100644
--- a/sound/firewire/fireworks/fireworks.h
+++ b/sound/firewire/fireworks/fireworks.h
@@ -108,7 +108,6 @@ struct snd_efw {
108 u8 *resp_buf; 108 u8 *resp_buf;
109 u8 *pull_ptr; 109 u8 *pull_ptr;
110 u8 *push_ptr; 110 u8 *push_ptr;
111 unsigned int resp_queues;
112}; 111};
113 112
114int snd_efw_transaction_cmd(struct fw_unit *unit, 113int snd_efw_transaction_cmd(struct fw_unit *unit,
diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c
index 33df8655fe81..2e1d9a23920c 100644
--- a/sound/firewire/fireworks/fireworks_hwdep.c
+++ b/sound/firewire/fireworks/fireworks_hwdep.c
@@ -25,6 +25,7 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained,
25{ 25{
26 unsigned int length, till_end, type; 26 unsigned int length, till_end, type;
27 struct snd_efw_transaction *t; 27 struct snd_efw_transaction *t;
28 u8 *pull_ptr;
28 long count = 0; 29 long count = 0;
29 30
30 if (remained < sizeof(type) + sizeof(struct snd_efw_transaction)) 31 if (remained < sizeof(type) + sizeof(struct snd_efw_transaction))
@@ -38,8 +39,17 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained,
38 buf += sizeof(type); 39 buf += sizeof(type);
39 40
40 /* write into buffer as many responses as possible */ 41 /* write into buffer as many responses as possible */
41 while (efw->resp_queues > 0) { 42 spin_lock_irq(&efw->lock);
42 t = (struct snd_efw_transaction *)(efw->pull_ptr); 43
44 /*
45 * When another task reaches here during this task's access to user
46 * space, it picks up current position in buffer and can read the same
47 * series of responses.
48 */
49 pull_ptr = efw->pull_ptr;
50
51 while (efw->push_ptr != pull_ptr) {
52 t = (struct snd_efw_transaction *)(pull_ptr);
43 length = be32_to_cpu(t->length) * sizeof(__be32); 53 length = be32_to_cpu(t->length) * sizeof(__be32);
44 54
45 /* confirm enough space for this response */ 55 /* confirm enough space for this response */
@@ -49,26 +59,39 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained,
49 /* copy from ring buffer to user buffer */ 59 /* copy from ring buffer to user buffer */
50 while (length > 0) { 60 while (length > 0) {
51 till_end = snd_efw_resp_buf_size - 61 till_end = snd_efw_resp_buf_size -
52 (unsigned int)(efw->pull_ptr - efw->resp_buf); 62 (unsigned int)(pull_ptr - efw->resp_buf);
53 till_end = min_t(unsigned int, length, till_end); 63 till_end = min_t(unsigned int, length, till_end);
54 64
55 if (copy_to_user(buf, efw->pull_ptr, till_end)) 65 spin_unlock_irq(&efw->lock);
66
67 if (copy_to_user(buf, pull_ptr, till_end))
56 return -EFAULT; 68 return -EFAULT;
57 69
58 efw->pull_ptr += till_end; 70 spin_lock_irq(&efw->lock);
59 if (efw->pull_ptr >= efw->resp_buf + 71
60 snd_efw_resp_buf_size) 72 pull_ptr += till_end;
61 efw->pull_ptr -= snd_efw_resp_buf_size; 73 if (pull_ptr >= efw->resp_buf + snd_efw_resp_buf_size)
74 pull_ptr -= snd_efw_resp_buf_size;
62 75
63 length -= till_end; 76 length -= till_end;
64 buf += till_end; 77 buf += till_end;
65 count += till_end; 78 count += till_end;
66 remained -= till_end; 79 remained -= till_end;
67 } 80 }
68
69 efw->resp_queues--;
70 } 81 }
71 82
83 /*
84 * All of tasks can read from the buffer nearly simultaneously, but the
85 * last position for each task is different depending on the length of
86 * given buffer. Here, for simplicity, a position of buffer is set by
87 * the latest task. It's better for a listening application to allow one
88 * thread to read from the buffer. Unless, each task can read different
89 * sequence of responses depending on variation of buffer length.
90 */
91 efw->pull_ptr = pull_ptr;
92
93 spin_unlock_irq(&efw->lock);
94
72 return count; 95 return count;
73} 96}
74 97
@@ -76,14 +99,17 @@ static long
76hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count, 99hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count,
77 loff_t *offset) 100 loff_t *offset)
78{ 101{
79 union snd_firewire_event event; 102 union snd_firewire_event event = {
103 .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS,
104 };
80 105
81 memset(&event, 0, sizeof(event)); 106 spin_lock_irq(&efw->lock);
82 107
83 event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS;
84 event.lock_status.status = (efw->dev_lock_count > 0); 108 event.lock_status.status = (efw->dev_lock_count > 0);
85 efw->dev_lock_changed = false; 109 efw->dev_lock_changed = false;
86 110
111 spin_unlock_irq(&efw->lock);
112
87 count = min_t(long, count, sizeof(event.lock_status)); 113 count = min_t(long, count, sizeof(event.lock_status));
88 114
89 if (copy_to_user(buf, &event, count)) 115 if (copy_to_user(buf, &event, count))
@@ -98,10 +124,15 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
98{ 124{
99 struct snd_efw *efw = hwdep->private_data; 125 struct snd_efw *efw = hwdep->private_data;
100 DEFINE_WAIT(wait); 126 DEFINE_WAIT(wait);
127 bool dev_lock_changed;
128 bool queued;
101 129
102 spin_lock_irq(&efw->lock); 130 spin_lock_irq(&efw->lock);
103 131
104 while ((!efw->dev_lock_changed) && (efw->resp_queues == 0)) { 132 dev_lock_changed = efw->dev_lock_changed;
133 queued = efw->push_ptr != efw->pull_ptr;
134
135 while (!dev_lock_changed && !queued) {
105 prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE); 136 prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE);
106 spin_unlock_irq(&efw->lock); 137 spin_unlock_irq(&efw->lock);
107 schedule(); 138 schedule();
@@ -109,15 +140,17 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
109 if (signal_pending(current)) 140 if (signal_pending(current))
110 return -ERESTARTSYS; 141 return -ERESTARTSYS;
111 spin_lock_irq(&efw->lock); 142 spin_lock_irq(&efw->lock);
143 dev_lock_changed = efw->dev_lock_changed;
144 queued = efw->push_ptr != efw->pull_ptr;
112 } 145 }
113 146
114 if (efw->dev_lock_changed) 147 spin_unlock_irq(&efw->lock);
148
149 if (dev_lock_changed)
115 count = hwdep_read_locked(efw, buf, count, offset); 150 count = hwdep_read_locked(efw, buf, count, offset);
116 else if (efw->resp_queues > 0) 151 else if (queued)
117 count = hwdep_read_resp_buf(efw, buf, count, offset); 152 count = hwdep_read_resp_buf(efw, buf, count, offset);
118 153
119 spin_unlock_irq(&efw->lock);
120
121 return count; 154 return count;
122} 155}
123 156
@@ -160,7 +193,7 @@ hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait)
160 poll_wait(file, &efw->hwdep_wait, wait); 193 poll_wait(file, &efw->hwdep_wait, wait);
161 194
162 spin_lock_irq(&efw->lock); 195 spin_lock_irq(&efw->lock);
163 if (efw->dev_lock_changed || (efw->resp_queues > 0)) 196 if (efw->dev_lock_changed || efw->pull_ptr != efw->push_ptr)
164 events = POLLIN | POLLRDNORM; 197 events = POLLIN | POLLRDNORM;
165 else 198 else
166 events = 0; 199 events = 0;
diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c
index 0639dcb13f7d..beb0a0ffee57 100644
--- a/sound/firewire/fireworks/fireworks_proc.c
+++ b/sound/firewire/fireworks/fireworks_proc.c
@@ -188,8 +188,8 @@ proc_read_queues_state(struct snd_info_entry *entry,
188 else 188 else
189 consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr); 189 consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr);
190 190
191 snd_iprintf(buffer, "%d %d/%d\n", 191 snd_iprintf(buffer, "%d/%d\n",
192 efw->resp_queues, consumed, snd_efw_resp_buf_size); 192 consumed, snd_efw_resp_buf_size);
193} 193}
194 194
195static void 195static void
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
index f550808d1784..36a08ba51ec7 100644
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -121,11 +121,11 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
121 size_t capacity, till_end; 121 size_t capacity, till_end;
122 struct snd_efw_transaction *t; 122 struct snd_efw_transaction *t;
123 123
124 spin_lock_irq(&efw->lock);
125
126 t = (struct snd_efw_transaction *)data; 124 t = (struct snd_efw_transaction *)data;
127 length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length); 125 length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length);
128 126
127 spin_lock_irq(&efw->lock);
128
129 if (efw->push_ptr < efw->pull_ptr) 129 if (efw->push_ptr < efw->pull_ptr)
130 capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); 130 capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr);
131 else 131 else
@@ -155,7 +155,6 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
155 } 155 }
156 156
157 /* for hwdep */ 157 /* for hwdep */
158 efw->resp_queues++;
159 wake_up(&efw->hwdep_wait); 158 wake_up(&efw->hwdep_wait);
160 159
161 *rcode = RCODE_COMPLETE; 160 *rcode = RCODE_COMPLETE;
diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
index 131267c3a042..106406cbfaa3 100644
--- a/sound/firewire/tascam/tascam-hwdep.c
+++ b/sound/firewire/tascam/tascam-hwdep.c
@@ -16,31 +16,14 @@
16 16
17#include "tascam.h" 17#include "tascam.h"
18 18
19static long hwdep_read_locked(struct snd_tscm *tscm, char __user *buf,
20 long count)
21{
22 union snd_firewire_event event;
23
24 memset(&event, 0, sizeof(event));
25
26 event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS;
27 event.lock_status.status = (tscm->dev_lock_count > 0);
28 tscm->dev_lock_changed = false;
29
30 count = min_t(long, count, sizeof(event.lock_status));
31
32 if (copy_to_user(buf, &event, count))
33 return -EFAULT;
34
35 return count;
36}
37
38static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, 19static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
39 loff_t *offset) 20 loff_t *offset)
40{ 21{
41 struct snd_tscm *tscm = hwdep->private_data; 22 struct snd_tscm *tscm = hwdep->private_data;
42 DEFINE_WAIT(wait); 23 DEFINE_WAIT(wait);
43 union snd_firewire_event event; 24 union snd_firewire_event event = {
25 .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS,
26 };
44 27
45 spin_lock_irq(&tscm->lock); 28 spin_lock_irq(&tscm->lock);
46 29
@@ -54,10 +37,16 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
54 spin_lock_irq(&tscm->lock); 37 spin_lock_irq(&tscm->lock);
55 } 38 }
56 39
57 memset(&event, 0, sizeof(event)); 40 event.lock_status.status = (tscm->dev_lock_count > 0);
58 count = hwdep_read_locked(tscm, buf, count); 41 tscm->dev_lock_changed = false;
42
59 spin_unlock_irq(&tscm->lock); 43 spin_unlock_irq(&tscm->lock);
60 44
45 count = min_t(long, count, sizeof(event.lock_status));
46
47 if (copy_to_user(buf, &event, count))
48 return -EFAULT;
49
61 return count; 50 return count;
62} 51}
63 52
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 7100f05e651a..575cefd8cc4a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4855,6 +4855,7 @@ enum {
4855 ALC221_FIXUP_HP_FRONT_MIC, 4855 ALC221_FIXUP_HP_FRONT_MIC,
4856 ALC292_FIXUP_TPT460, 4856 ALC292_FIXUP_TPT460,
4857 ALC298_FIXUP_SPK_VOLUME, 4857 ALC298_FIXUP_SPK_VOLUME,
4858 ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
4858}; 4859};
4859 4860
4860static const struct hda_fixup alc269_fixups[] = { 4861static const struct hda_fixup alc269_fixups[] = {
@@ -5516,6 +5517,15 @@ static const struct hda_fixup alc269_fixups[] = {
5516 .chained = true, 5517 .chained = true,
5517 .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, 5518 .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
5518 }, 5519 },
5520 [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
5521 .type = HDA_FIXUP_PINS,
5522 .v.pins = (const struct hda_pintbl[]) {
5523 { 0x1b, 0x90170151 },
5524 { }
5525 },
5526 .chained = true,
5527 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
5528 },
5519}; 5529};
5520 5530
5521static const struct snd_pci_quirk alc269_fixup_tbl[] = { 5531static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5560,6 +5570,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5560 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), 5570 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
5561 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), 5571 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
5562 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), 5572 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
5573 SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
5563 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), 5574 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
5564 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), 5575 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
5565 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), 5576 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
@@ -5895,6 +5906,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5895 {0x12, 0x90a60170}, 5906 {0x12, 0x90a60170},
5896 {0x14, 0x90170120}, 5907 {0x14, 0x90170120},
5897 {0x21, 0x02211030}), 5908 {0x21, 0x02211030}),
5909 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5910 {0x12, 0x90a60180},
5911 {0x14, 0x90170120},
5912 {0x21, 0x02211030}),
5898 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5913 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5899 ALC256_STANDARD_PINS), 5914 ALC256_STANDARD_PINS),
5900 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, 5915 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 6cf1f3597455..152292e5ee2b 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1141,6 +1141,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1141 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ 1141 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
1142 case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ 1142 case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
1143 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ 1143 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
1144 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
1144 case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ 1145 case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
1145 case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ 1146 case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
1146 case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */ 1147 case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index ae68bf0e2d51..f39c0e9c0d5c 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -456,7 +456,7 @@ int main(int argc, char **argv)
456 456
457 if (notrigger) { 457 if (notrigger) {
458 printf("trigger-less mode selected\n"); 458 printf("trigger-less mode selected\n");
459 } if (trig_num >= 0) { 459 } else if (trig_num >= 0) {
460 char *trig_dev_name; 460 char *trig_dev_name;
461 ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num); 461 ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num);
462 if (ret < 0) { 462 if (ret < 0) {