--- /dev/null
+From 90f92c631b210c1e97080b53a9d863783281a932 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Tue, 13 Sep 2016 12:31:17 +0100
+Subject: ARM: 8613/1: Fix the uaccess crash on PB11MPCore
+
+From: Linus Walleij <linus.walleij@linaro.org>
+
+commit 90f92c631b210c1e97080b53a9d863783281a932 upstream.
+
+The following patch was sketched by Russell in response to my
+crashes on the PB11MPCore after the patch for software-based
+priviledged no access support for ARMv8.1. See this thread:
+http://marc.info/?l=linux-arm-kernel&m=144051749807214&w=2
+
+I am unsure what is going on, I suspect everyone involved in
+the discussion is. I just want to repost this to get the
+discussion restarted, as I still have to apply this patch
+with every kernel iteration to get my PB11MPCore Realview
+running.
+
+Testing by Neil Armstrong on the Oxnas NAS has revealed that
+this bug exist also on that widely deployed hardware, so
+we are probably currently regressing all ARM11MPCore systems.
+
+Cc: Russell King <linux@armlinux.org.uk>
+Cc: Will Deacon <will.deacon@arm.com>
+Fixes: a5e090acbf54 ("ARM: software-based priviledged-no-access support")
+Tested-by: Neil Armstrong <narmstrong@baylibre.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kernel/smp_tlb.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/arch/arm/kernel/smp_tlb.c
++++ b/arch/arm/kernel/smp_tlb.c
+@@ -9,6 +9,7 @@
+ */
+ #include <linux/preempt.h>
+ #include <linux/smp.h>
++#include <linux/uaccess.h>
+
+ #include <asm/smp_plat.h>
+ #include <asm/tlbflush.h>
+@@ -40,8 +41,11 @@ static inline void ipi_flush_tlb_mm(void
+ static inline void ipi_flush_tlb_page(void *arg)
+ {
+ struct tlb_args *ta = (struct tlb_args *)arg;
++ unsigned int __ua_flags = uaccess_save_and_enable();
+
+ local_flush_tlb_page(ta->ta_vma, ta->ta_start);
++
++ uaccess_restore(__ua_flags);
+ }
+
+ static inline void ipi_flush_tlb_kernel_page(void *arg)
+@@ -54,8 +58,11 @@ static inline void ipi_flush_tlb_kernel_
+ static inline void ipi_flush_tlb_range(void *arg)
+ {
+ struct tlb_args *ta = (struct tlb_args *)arg;
++ unsigned int __ua_flags = uaccess_save_and_enable();
+
+ local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end);
++
++ uaccess_restore(__ua_flags);
+ }
+
+ static inline void ipi_flush_tlb_kernel_range(void *arg)
--- /dev/null
+From 1d8d6d3f2f7d553c479f24ab93767974a8c2dfad Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:37 -0300
+Subject: ARM: dts: am33xx: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 1d8d6d3f2f7d553c479f24ab93767974a8c2dfad upstream.
+
+Commit f8bf01611c99 ("ARM: dts: am33xx: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: f8bf01611c99 ("ARM: dts: am33xx: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/am33xx.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/am33xx.dtsi
++++ b/arch/arm/boot/dts/am33xx.dtsi
+@@ -16,6 +16,7 @@
+ interrupt-parent = <&intc>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c0;
--- /dev/null
+From ce95077d0cdfcc8e40dea10a1680249831ccec77 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:38 -0300
+Subject: ARM: dts: am4372: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit ce95077d0cdfcc8e40dea10a1680249831ccec77 upstream.
+
+Commit 75813028bbd7 ("ARM: dts: am4372: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 75813028bbd7 ("ARM: dts: am4372: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/am4372.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/am4372.dtsi
++++ b/arch/arm/boot/dts/am4372.dtsi
+@@ -16,6 +16,7 @@
+ interrupt-parent = <&wakeupgen>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ memory@0 {
+ device_type = "memory";
--- /dev/null
+From 9536fd30d41ae4f30d04762676e5f5f602e16aa8 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:39 -0300
+Subject: ARM: dts: dm814x: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 9536fd30d41ae4f30d04762676e5f5f602e16aa8 upstream.
+
+Commit 76155b378c59 ("ARM: dts: dm814x: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 76155b378c59 ("ARM: dts: dm814x: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/dm814x.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/dm814x.dtsi
++++ b/arch/arm/boot/dts/dm814x.dtsi
+@@ -12,6 +12,7 @@
+ interrupt-parent = <&intc>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From 6ed80b3a232e61da6d0189bbbe2b2b9afaefe3b3 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:40 -0300
+Subject: ARM: dts: dm816x: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 6ed80b3a232e61da6d0189bbbe2b2b9afaefe3b3 upstream.
+
+Commit 06bfb9c19957 ("ARM: dts: dm816x: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 06bfb9c19957 ("ARM: dts: dm816x: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/dm816x.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/dm816x.dtsi
++++ b/arch/arm/boot/dts/dm816x.dtsi
+@@ -12,6 +12,7 @@
+ interrupt-parent = <&intc>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From 7f6c857b12911ed56b2056f9d5491e16b5fc95ea Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:41 -0300
+Subject: ARM: dts: dra7: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 7f6c857b12911ed56b2056f9d5491e16b5fc95ea upstream.
+
+Commit 55871eb6e2cc ("ARM: dts: dra7: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 55871eb6e2cc ("ARM: dts: dra7: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/dra7.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/dra7.dtsi
++++ b/arch/arm/boot/dts/dra7.dtsi
+@@ -18,6 +18,7 @@
+
+ compatible = "ti,dra7xx";
+ interrupt-parent = <&crossbar_mpu>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From 6ab5c2b662e2dcbb964099bf7f19e9dbc9ae5a41 Mon Sep 17 00:00:00 2001
+From: Gary Bisson <gary.bisson@boundarydevices.com>
+Date: Tue, 3 Jan 2017 12:22:46 +0100
+Subject: ARM: dts: imx6qdl-nitrogen6_max: fix sgtl5000 pinctrl init
+
+From: Gary Bisson <gary.bisson@boundarydevices.com>
+
+commit 6ab5c2b662e2dcbb964099bf7f19e9dbc9ae5a41 upstream.
+
+This patch fixes the following error:
+sgtl5000 0-000a: Error reading chip id -6
+imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
+imx-sgtl5000 sound: snd_soc_register_card failed (-517)
+
+The problem was that the pinctrl group was linked to the sound driver
+instead of the codec node. Since the codec is probed first, the sys_mclk
+was missing and it would therefore fail to initialize.
+
+Fixes: b32e700256bc ("ARM: dts: imx: add Boundary Devices Nitrogen6_Max board")
+Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
+Signed-off-by: Shawn Guo <shawnguo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
++++ b/arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
+@@ -319,8 +319,6 @@
+ compatible = "fsl,imx6q-nitrogen6_max-sgtl5000",
+ "fsl,imx-audio-sgtl5000";
+ model = "imx6q-nitrogen6_max-sgtl5000";
+- pinctrl-names = "default";
+- pinctrl-0 = <&pinctrl_sgtl5000>;
+ ssi-controller = <&ssi1>;
+ audio-codec = <&codec>;
+ audio-routing =
+@@ -402,6 +400,8 @@
+
+ codec: sgtl5000@0a {
+ compatible = "fsl,sgtl5000";
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_sgtl5000>;
+ reg = <0x0a>;
+ clocks = <&clks IMX6QDL_CLK_CKO>;
+ VDDA-supply = <®_2p5v>;
--- /dev/null
+From 3d37d41a148c32389ed360e10a9f8a7cd37ce166 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:33 -0300
+Subject: ARM: dts: omap2: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 3d37d41a148c32389ed360e10a9f8a7cd37ce166 upstream.
+
+Commit d1f3156fc8c7 ("ARM: dts: omap2: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: d1f3156fc8c7 ("ARM: dts: omap2: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/omap2.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/omap2.dtsi
++++ b/arch/arm/boot/dts/omap2.dtsi
+@@ -17,6 +17,7 @@
+ interrupt-parent = <&intc>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ serial0 = &uart1;
--- /dev/null
+From 23ab4c6183ac0679d80888b5c4cc1d528fcc21c2 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:34 -0300
+Subject: ARM: dts: omap3: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 23ab4c6183ac0679d80888b5c4cc1d528fcc21c2 upstream.
+
+Commit 008a2ebcd677 ("ARM: dts: omap3: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 008a2ebcd677 ("ARM: dts: omap3: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/omap3.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/omap3.dtsi
++++ b/arch/arm/boot/dts/omap3.dtsi
+@@ -17,6 +17,7 @@
+ interrupt-parent = <&intc>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From 1ea6af3216b092ec97129ac81bd95cf254c4b140 Mon Sep 17 00:00:00 2001
+From: Adam Ford <aford173@gmail.com>
+Date: Tue, 17 Jan 2017 13:34:06 -0600
+Subject: ARM: dts: omap3: Fix Card Detect and Write Protect on Logic PD SOM-LV
+
+From: Adam Ford <aford173@gmail.com>
+
+commit 1ea6af3216b092ec97129ac81bd95cf254c4b140 upstream.
+
+This fixes commit ab8dd3aed011 ("ARM: DTS: Add minimal Support for
+Logic PD DM3730 SOM-LV") where the Card Detect and Write Protect
+pins were improperly configured.
+
+Fixes: ab8dd3aed011 ("ARM: DTS: Add minimal Support for Logic PD DM3730 SOM-LV")
+Signed-off-by: Adam Ford <aford173@gmail.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts | 11 +++--------
+ 1 file changed, 3 insertions(+), 8 deletions(-)
+
+--- a/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
++++ b/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
+@@ -158,7 +158,7 @@
+ &mmc1 {
+ interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>;
+ pinctrl-names = "default";
+- pinctrl-0 = <&mmc1_pins &mmc1_cd>;
++ pinctrl-0 = <&mmc1_pins>;
+ wp-gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>; /* gpio_126 */
+ cd-gpios = <&gpio4 14 IRQ_TYPE_LEVEL_LOW>; /* gpio_110 */
+ vmmc-supply = <&vmmc1>;
+@@ -193,7 +193,8 @@
+ OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */
+ OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */
+ OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */
+- OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 sdmmc1_wp*/
++ OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 */
++ OMAP3_CORE1_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
+ >;
+ };
+
+@@ -242,12 +243,6 @@
+ OMAP3_WKUP_IOPAD(0x2a16, PIN_OUTPUT | PIN_OFF_OUTPUT_LOW | MUX_MODE4) /* sys_boot6.gpio_8 */
+ >;
+ };
+-
+- mmc1_cd: pinmux_mmc1_cd {
+- pinctrl-single,pins = <
+- OMAP3_WKUP_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
+- >;
+- };
+ };
+
+
--- /dev/null
+From 6c565d1a63ce241a0100f5d327c48dde87b4df76 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:35 -0300
+Subject: ARM: dts: omap4: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 6c565d1a63ce241a0100f5d327c48dde87b4df76 upstream.
+
+Commit da6269e7e3dd ("ARM: dts: omap4: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: da6269e7e3dd ("ARM: dts: omap4: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/omap4.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/omap4.dtsi
++++ b/arch/arm/boot/dts/omap4.dtsi
+@@ -15,6 +15,7 @@
+ interrupt-parent = <&wakeupgen>;
+ #address-cells = <1>;
+ #size-cells = <1>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From c9faa84cb9c34852ad70cb175457ae21fc06f39b Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Mon, 19 Dec 2016 11:44:36 -0300
+Subject: ARM: dts: omap5: Add an empty chosen node to top level DTSI
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit c9faa84cb9c34852ad70cb175457ae21fc06f39b upstream.
+
+Commit 76a8548ea987 ("ARM: dts: omap5: Remove skeleton.dtsi usage")
+removed the skeleton.dtsi usage since we want to get rid of it.
+
+But this can cause issues when booting a kernel with a boot-loader
+that doesn't create a chosen node if this isn't present in the DTB
+since the decompressor relies on a pre-existing chosen node to be
+available to insert the command line and merge other ATAGS info.
+
+Fixes: 76a8548ea987 ("ARM: dts: omap5: Remove skeleton.dtsi usage")
+Reported-by: Pali Rohar <pali.rohar@gmail.com>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/omap5.dtsi | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/boot/dts/omap5.dtsi
++++ b/arch/arm/boot/dts/omap5.dtsi
+@@ -17,6 +17,7 @@
+
+ compatible = "ti,omap5";
+ interrupt-parent = <&wakeupgen>;
++ chosen { };
+
+ aliases {
+ i2c0 = &i2c1;
--- /dev/null
+From f0e8faa7a5e894b0fc99d24be1b18685a92ea466 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 16 Nov 2016 16:20:37 +0100
+Subject: ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit f0e8faa7a5e894b0fc99d24be1b18685a92ea466 upstream.
+
+This function clearly never worked and always returns true,
+as pointed out by gcc-7:
+
+arch/arm/mach-ux500/pm.c: In function 'prcmu_is_cpu_in_wfi':
+arch/arm/mach-ux500/pm.c:137:212: error: ?:
+using integer constants in boolean context, the expression
+will always evaluate to 'true' [-Werror=int-in-bool-context]
+
+With the added braces, the condition actually makes sense.
+
+Fixes: 34fe6f107eab ("mfd : Check if the other db8500 core is in WFI")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/mach-ux500/pm.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/arm/mach-ux500/pm.c
++++ b/arch/arm/mach-ux500/pm.c
+@@ -134,8 +134,8 @@ bool prcmu_pending_irq(void)
+ */
+ bool prcmu_is_cpu_in_wfi(int cpu)
+ {
+- return readl(PRCM_ARM_WFI_STANDBY) & cpu ? PRCM_ARM_WFI_STANDBY_WFI1 :
+- PRCM_ARM_WFI_STANDBY_WFI0;
++ return readl(PRCM_ARM_WFI_STANDBY) &
++ (cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : PRCM_ARM_WFI_STANDBY_WFI0);
+ }
+
+ /*
--- /dev/null
+From 524dabe1c68e0bca25ce7b108099e5d89472a101 Mon Sep 17 00:00:00 2001
+From: Alexander Graf <agraf@suse.de>
+Date: Mon, 16 Jan 2017 12:46:33 +0100
+Subject: arm64: Fix swiotlb fallback allocation
+
+From: Alexander Graf <agraf@suse.de>
+
+commit 524dabe1c68e0bca25ce7b108099e5d89472a101 upstream.
+
+Commit b67a8b29df introduced logic to skip swiotlb allocation when all memory
+is DMA accessible anyway.
+
+While this is a great idea, __dma_alloc still calls swiotlb code unconditionally
+to allocate memory when there is no CMA memory available. The swiotlb code is
+called to ensure that we at least try get_free_pages().
+
+Without initialization, swiotlb allocation code tries to access io_tlb_list
+which is NULL. That results in a stack trace like this:
+
+ Unable to handle kernel NULL pointer dereference at virtual address 00000000
+ [...]
+ [<ffff00000845b908>] swiotlb_tbl_map_single+0xd0/0x2b0
+ [<ffff00000845be94>] swiotlb_alloc_coherent+0x10c/0x198
+ [<ffff000008099dc0>] __dma_alloc+0x68/0x1a8
+ [<ffff000000a1b410>] drm_gem_cma_create+0x98/0x108 [drm]
+ [<ffff000000abcaac>] drm_fbdev_cma_create_with_funcs+0xbc/0x368 [drm_kms_helper]
+ [<ffff000000abcd84>] drm_fbdev_cma_create+0x2c/0x40 [drm_kms_helper]
+ [<ffff000000abc040>] drm_fb_helper_initial_config+0x238/0x410 [drm_kms_helper]
+ [<ffff000000abce88>] drm_fbdev_cma_init_with_funcs+0x98/0x160 [drm_kms_helper]
+ [<ffff000000abcf90>] drm_fbdev_cma_init+0x40/0x58 [drm_kms_helper]
+ [<ffff000000b47980>] vc4_kms_load+0x90/0xf0 [vc4]
+ [<ffff000000b46a94>] vc4_drm_bind+0xec/0x168 [vc4]
+ [...]
+
+Thankfully swiotlb code just learned how to not do allocations with the FORCE_NO
+option. This patch configures the swiotlb code to use that if we decide not to
+initialize the swiotlb framework.
+
+Fixes: b67a8b29df ("arm64: mm: only initialize swiotlb when necessary")
+Signed-off-by: Alexander Graf <agraf@suse.de>
+CC: Jisheng Zhang <jszhang@marvell.com>
+CC: Geert Uytterhoeven <geert+renesas@glider.be>
+CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm64/mm/init.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/arch/arm64/mm/init.c
++++ b/arch/arm64/mm/init.c
+@@ -403,6 +403,8 @@ void __init mem_init(void)
+ {
+ if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
+ swiotlb_init(1);
++ else
++ swiotlb_force = SWIOTLB_NO_FORCE;
+
+ set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
+
--- /dev/null
+From 1c8a946bf3754a59cba1fc373949a8114bfe5aaa Mon Sep 17 00:00:00 2001
+From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
+Date: Wed, 18 Jan 2017 09:09:25 +0200
+Subject: arm64: mm: avoid name clash in __page_to_voff()
+
+From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
+
+commit 1c8a946bf3754a59cba1fc373949a8114bfe5aaa upstream.
+
+The arm64 __page_to_voff() macro takes a parameter called 'page', and
+also refers to 'struct page'. Thus, if the value passed in is not
+called 'page', we'll refer to the wrong struct name (which might not
+exist).
+
+Fixes: 3fa72fe9c614 ("arm64: mm: fix __page_to_voff definition")
+Acked-by: Mark Rutland <mark.rutland@arm.com>
+Suggested-by: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
+Signed-off-by: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm64/include/asm/memory.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/arm64/include/asm/memory.h
++++ b/arch/arm64/include/asm/memory.h
+@@ -217,7 +217,7 @@ static inline void *phys_to_virt(phys_ad
+ #define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+ #else
+ #define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page))
+-#define __page_to_voff(page) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
++#define __page_to_voff(kaddr) (((u64)(kaddr) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
+
+ #define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET))
+ #define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
--- /dev/null
+From c9205e18b41a6ef5ad73e1c4b86a78b2ea3ccb9b Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Thu, 14 Jul 2016 07:18:14 -0300
+Subject: [media] blackfin: check devm_pinctrl_get() for errors
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit c9205e18b41a6ef5ad73e1c4b86a78b2ea3ccb9b upstream.
+
+devm_pinctrl_get() can fail so we should check for that.
+
+Fixes: 0a6824bc10de ('[media] v4l2: blackfin: select proper pinctrl state in ppi_set_params if CONFIG_PINCTRL is enabled')
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/blackfin/ppi.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/media/platform/blackfin/ppi.c
++++ b/drivers/media/platform/blackfin/ppi.c
+@@ -214,6 +214,8 @@ static int ppi_set_params(struct ppi_if
+ if (params->dlen > 24 || params->dlen <= 0)
+ return -EINVAL;
+ pctrl = devm_pinctrl_get(ppi->dev);
++ if (IS_ERR(pctrl))
++ return PTR_ERR(pctrl);
+ pstate = pinctrl_lookup_state(pctrl,
+ pin_state[(params->dlen + 7) / 8 - 1]);
+ if (pinctrl_select_state(pctrl, pstate))
--- /dev/null
+From 6e09d0fb64402cec579f029ca4c7f39f5c48fc60 Mon Sep 17 00:00:00 2001
+From: "Yan, Zheng" <zyan@redhat.com>
+Date: Thu, 22 Dec 2016 16:05:43 +0800
+Subject: ceph: fix ceph_get_caps() interruption
+
+From: Yan, Zheng <zyan@redhat.com>
+
+commit 6e09d0fb64402cec579f029ca4c7f39f5c48fc60 upstream.
+
+Commit 5c341ee32881 ("ceph: fix scheduler warning due to nested
+blocking") causes infinite loop when process is interrupted. Fix it.
+
+Signed-off-by: Yan, Zheng <zyan@redhat.com>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ceph/caps.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/fs/ceph/caps.c
++++ b/fs/ceph/caps.c
+@@ -2511,8 +2511,13 @@ int ceph_get_caps(struct ceph_inode_info
+ add_wait_queue(&ci->i_cap_wq, &wait);
+
+ while (!try_get_cap_refs(ci, need, want, endoff,
+- true, &_got, &err))
++ true, &_got, &err)) {
++ if (signal_pending(current)) {
++ ret = -ERESTARTSYS;
++ break;
++ }
+ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
++ }
+
+ remove_wait_queue(&ci->i_cap_wq, &wait);
+
--- /dev/null
+From fe2ed42517533068ac03eed5630fffafff27eacf Mon Sep 17 00:00:00 2001
+From: Jeff Layton <jlayton@redhat.com>
+Date: Thu, 12 Jan 2017 14:42:39 -0500
+Subject: ceph: fix endianness bug in frag_tree_split_cmp
+
+From: Jeff Layton <jlayton@redhat.com>
+
+commit fe2ed42517533068ac03eed5630fffafff27eacf upstream.
+
+sparse says:
+
+ fs/ceph/inode.c:308:36: warning: incorrect type in argument 1 (different base types)
+ fs/ceph/inode.c:308:36: expected unsigned int [unsigned] [usertype] a
+ fs/ceph/inode.c:308:36: got restricted __le32 [usertype] frag
+ fs/ceph/inode.c:308:46: warning: incorrect type in argument 2 (different base types)
+ fs/ceph/inode.c:308:46: expected unsigned int [unsigned] [usertype] b
+ fs/ceph/inode.c:308:46: got restricted __le32 [usertype] frag
+
+We need to convert these values to host-endian before calling the
+comparator.
+
+Fixes: a407846ef7c6 ("ceph: don't assume frag tree splits in mds reply are sorted")
+Signed-off-by: Jeff Layton <jlayton@redhat.com>
+Reviewed-by: Sage Weil <sage@redhat.com>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ceph/inode.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/fs/ceph/inode.c
++++ b/fs/ceph/inode.c
+@@ -305,7 +305,8 @@ static int frag_tree_split_cmp(const voi
+ {
+ struct ceph_frag_tree_split *ls = (struct ceph_frag_tree_split*)l;
+ struct ceph_frag_tree_split *rs = (struct ceph_frag_tree_split*)r;
+- return ceph_frag_compare(ls->frag, rs->frag);
++ return ceph_frag_compare(le32_to_cpu(ls->frag),
++ le32_to_cpu(rs->frag));
+ }
+
+ static bool is_frag_child(u32 f, struct ceph_inode_frag *frag)
--- /dev/null
+From 1097680d759918ce4a8705381c0ab2ed7bd60cf1 Mon Sep 17 00:00:00 2001
+From: Jeff Layton <jlayton@redhat.com>
+Date: Thu, 12 Jan 2017 14:42:38 -0500
+Subject: ceph: fix endianness of getattr mask in ceph_d_revalidate
+
+From: Jeff Layton <jlayton@redhat.com>
+
+commit 1097680d759918ce4a8705381c0ab2ed7bd60cf1 upstream.
+
+sparse says:
+
+ fs/ceph/dir.c:1248:50: warning: incorrect type in assignment (different base types)
+ fs/ceph/dir.c:1248:50: expected restricted __le32 [usertype] mask
+ fs/ceph/dir.c:1248:50: got int [signed] [assigned] mask
+
+Fixes: 200fd27c8fa2 ("ceph: use lookup request to revalidate dentry")
+Signed-off-by: Jeff Layton <jlayton@redhat.com>
+Reviewed-by: Sage Weil <sage@redhat.com>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ceph/dir.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/fs/ceph/dir.c
++++ b/fs/ceph/dir.c
+@@ -1255,7 +1255,8 @@ static int ceph_d_revalidate(struct dent
+ struct ceph_mds_client *mdsc =
+ ceph_sb_to_client(dir->i_sb)->mdsc;
+ struct ceph_mds_request *req;
+- int op, mask, err;
++ int op, err;
++ u32 mask;
+
+ if (flags & LOOKUP_RCU)
+ return -ECHILD;
+@@ -1270,7 +1271,7 @@ static int ceph_d_revalidate(struct dent
+ mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
+ if (ceph_security_xattr_wanted(dir))
+ mask |= CEPH_CAP_XATTR_SHARED;
+- req->r_args.getattr.mask = mask;
++ req->r_args.getattr.mask = cpu_to_le32(mask);
+
+ err = ceph_mdsc_do_request(mdsc, NULL, req);
+ switch (err) {
--- /dev/null
+From 5c341ee32881c554727ec14b71ec3e8832f01989 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <kernel@kyup.com>
+Date: Tue, 11 Oct 2016 12:04:09 +0300
+Subject: ceph: fix scheduler warning due to nested blocking
+
+From: Nikolay Borisov <kernel@kyup.com>
+
+commit 5c341ee32881c554727ec14b71ec3e8832f01989 upstream.
+
+try_get_cap_refs can be used as a condition in a wait_event* calls.
+This is all fine until it has to call __ceph_do_pending_vmtruncate,
+which in turn acquires the i_truncate_mutex. This leads to a situation
+in which a task's state is !TASK_RUNNING and at the same time it's
+trying to acquire a sleeping primitive. In essence a nested sleeping
+primitives are being used. This causes the following warning:
+
+WARNING: CPU: 22 PID: 11064 at kernel/sched/core.c:7631 __might_sleep+0x9f/0xb0()
+do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff8109447d>] prepare_to_wait_event+0x5d/0x110
+ ipmi_msghandler tcp_scalable ib_qib dca ib_mad ib_core ib_addr ipv6
+CPU: 22 PID: 11064 Comm: fs_checker.pl Tainted: G O 4.4.20-clouder2 #6
+Hardware name: Supermicro X10DRi/X10DRi, BIOS 1.1a 10/16/2015
+ 0000000000000000 ffff8838b416fa88 ffffffff812f4409 ffff8838b416fad0
+ ffffffff81a034f2 ffff8838b416fac0 ffffffff81052b46 ffffffff81a0432c
+ 0000000000000061 0000000000000000 0000000000000000 ffff88167bda54a0
+Call Trace:
+ [<ffffffff812f4409>] dump_stack+0x67/0x9e
+ [<ffffffff81052b46>] warn_slowpath_common+0x86/0xc0
+ [<ffffffff81052bcc>] warn_slowpath_fmt+0x4c/0x50
+ [<ffffffff8109447d>] ? prepare_to_wait_event+0x5d/0x110
+ [<ffffffff8109447d>] ? prepare_to_wait_event+0x5d/0x110
+ [<ffffffff8107767f>] __might_sleep+0x9f/0xb0
+ [<ffffffff81612d30>] mutex_lock+0x20/0x40
+ [<ffffffffa04eea14>] __ceph_do_pending_vmtruncate+0x44/0x1a0 [ceph]
+ [<ffffffffa04fa692>] try_get_cap_refs+0xa2/0x320 [ceph]
+ [<ffffffffa04fd6f5>] ceph_get_caps+0x255/0x2b0 [ceph]
+ [<ffffffff81094370>] ? wait_woken+0xb0/0xb0
+ [<ffffffffa04f2c11>] ceph_write_iter+0x2b1/0xde0 [ceph]
+ [<ffffffff81613f22>] ? schedule_timeout+0x202/0x260
+ [<ffffffff8117f01a>] ? kmem_cache_free+0x1ea/0x200
+ [<ffffffff811b46ce>] ? iput+0x9e/0x230
+ [<ffffffff81077632>] ? __might_sleep+0x52/0xb0
+ [<ffffffff81156147>] ? __might_fault+0x37/0x40
+ [<ffffffff8119e123>] ? cp_new_stat+0x153/0x170
+ [<ffffffff81198cfa>] __vfs_write+0xaa/0xe0
+ [<ffffffff81199369>] vfs_write+0xa9/0x190
+ [<ffffffff811b6d01>] ? set_close_on_exec+0x31/0x70
+ [<ffffffff8119a056>] SyS_write+0x46/0xa0
+
+This happens since wait_event_interruptible can interfere with the
+mutex locking code, since they both fiddle with the task state.
+
+Fix the issue by using the newly-added nested blocking infrastructure
+in 61ada528dea0 ("sched/wait: Provide infrastructure to deal with
+nested blocking")
+
+Link: https://lwn.net/Articles/628628/
+Signed-off-by: Nikolay Borisov <kernel@kyup.com>
+Signed-off-by: Yan, Zheng <zyan@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ceph/caps.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+--- a/fs/ceph/caps.c
++++ b/fs/ceph/caps.c
+@@ -2507,9 +2507,15 @@ int ceph_get_caps(struct ceph_inode_info
+ if (err < 0)
+ ret = err;
+ } else {
+- ret = wait_event_interruptible(ci->i_cap_wq,
+- try_get_cap_refs(ci, need, want, endoff,
+- true, &_got, &err));
++ DEFINE_WAIT_FUNC(wait, woken_wake_function);
++ add_wait_queue(&ci->i_cap_wq, &wait);
++
++ while (!try_get_cap_refs(ci, need, want, endoff,
++ true, &_got, &err))
++ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
++
++ remove_wait_queue(&ci->i_cap_wq, &wait);
++
+ if (err == -EAGAIN)
+ continue;
+ if (err < 0)
--- /dev/null
+From 5c9e6c2b2ba3ec3a442e2fb5b4286498f8b4dcb7 Mon Sep 17 00:00:00 2001
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Fri, 16 Dec 2016 11:39:11 +0100
+Subject: dmaengine: pl330: Fix runtime PM support for terminated transfers
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+commit 5c9e6c2b2ba3ec3a442e2fb5b4286498f8b4dcb7 upstream.
+
+PL330 DMA engine driver is leaking a runtime reference after any terminated
+DMA transactions. This patch fixes this issue by tracking runtime PM state
+of the device and making additional call to pm_runtime_put() in terminate_all
+callback if needed.
+
+Fixes: ae43b3289186 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12")
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
+Signed-off-by: Vinod Koul <vinod.koul@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/dma/pl330.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+--- a/drivers/dma/pl330.c
++++ b/drivers/dma/pl330.c
+@@ -448,6 +448,9 @@ struct dma_pl330_chan {
+
+ /* for cyclic capability */
+ bool cyclic;
++
++ /* for runtime pm tracking */
++ bool active;
+ };
+
+ struct pl330_dmac {
+@@ -2031,6 +2034,7 @@ static void pl330_tasklet(unsigned long
+ _stop(pch->thread);
+ spin_unlock(&pch->thread->dmac->lock);
+ power_down = true;
++ pch->active = false;
+ } else {
+ /* Make sure the PL330 Channel thread is active */
+ spin_lock(&pch->thread->dmac->lock);
+@@ -2050,6 +2054,7 @@ static void pl330_tasklet(unsigned long
+ desc->status = PREP;
+ list_move_tail(&desc->node, &pch->work_list);
+ if (power_down) {
++ pch->active = true;
+ spin_lock(&pch->thread->dmac->lock);
+ _start(pch->thread);
+ spin_unlock(&pch->thread->dmac->lock);
+@@ -2164,6 +2169,7 @@ static int pl330_terminate_all(struct dm
+ unsigned long flags;
+ struct pl330_dmac *pl330 = pch->dmac;
+ LIST_HEAD(list);
++ bool power_down = false;
+
+ pm_runtime_get_sync(pl330->ddma.dev);
+ spin_lock_irqsave(&pch->lock, flags);
+@@ -2174,6 +2180,8 @@ static int pl330_terminate_all(struct dm
+ pch->thread->req[0].desc = NULL;
+ pch->thread->req[1].desc = NULL;
+ pch->thread->req_running = -1;
++ power_down = pch->active;
++ pch->active = false;
+
+ /* Mark all desc done */
+ list_for_each_entry(desc, &pch->submitted_list, node) {
+@@ -2191,6 +2199,8 @@ static int pl330_terminate_all(struct dm
+ list_splice_tail_init(&pch->completed_list, &pl330->desc_pool);
+ spin_unlock_irqrestore(&pch->lock, flags);
+ pm_runtime_mark_last_busy(pl330->ddma.dev);
++ if (power_down)
++ pm_runtime_put_autosuspend(pl330->ddma.dev);
+ pm_runtime_put_autosuspend(pl330->ddma.dev);
+
+ return 0;
+@@ -2350,6 +2360,7 @@ static void pl330_issue_pending(struct d
+ * updated on work_list emptiness status.
+ */
+ WARN_ON(list_empty(&pch->submitted_list));
++ pch->active = true;
+ pm_runtime_get_sync(pch->dmac->ddma.dev);
+ }
+ list_splice_tail_init(&pch->submitted_list, &pch->work_list);
--- /dev/null
+From 3139dc8ded6f27552a248d23fe9f086e3027fa12 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= <niklas.soderlund+renesas@ragnatech.se>
+Date: Wed, 11 Jan 2017 15:39:31 +0100
+Subject: dmaengine: rcar-dmac: unmap slave resource when channel is freed
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+
+commit 3139dc8ded6f27552a248d23fe9f086e3027fa12 upstream.
+
+The slave mapping should be removed together with other channel
+resources when the channel is freed. If it's not unmapped it will hang
+around forever after the channel is freed.
+
+Fixes: 9f878603dbdb7db3 ("dmaengine: rcar-dmac: add iommu support for slave transfers")
+Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Vinod Koul <vinod.koul@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/dma/sh/rcar-dmac.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+--- a/drivers/dma/sh/rcar-dmac.c
++++ b/drivers/dma/sh/rcar-dmac.c
+@@ -986,6 +986,7 @@ static void rcar_dmac_free_chan_resource
+ {
+ struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
+ struct rcar_dmac *dmac = to_rcar_dmac(chan->device);
++ struct rcar_dmac_chan_map *map = &rchan->map;
+ struct rcar_dmac_desc_page *page, *_page;
+ struct rcar_dmac_desc *desc;
+ LIST_HEAD(list);
+@@ -1019,6 +1020,13 @@ static void rcar_dmac_free_chan_resource
+ free_page((unsigned long)page);
+ }
+
++ /* Remove slave mapping if present. */
++ if (map->slave.xfer_size) {
++ dma_unmap_resource(chan->device->dev, map->addr,
++ map->slave.xfer_size, map->dir, 0);
++ map->slave.xfer_size = 0;
++ }
++
+ pm_runtime_put(chan->device->dev);
+ }
+
--- /dev/null
+From df94121f02ecce435d6b5277071eb94b764caa89 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <weiyongjun1@huawei.com>
+Date: Wed, 21 Sep 2016 10:09:39 -0300
+Subject: [media] gs1662: drop kfree for memory allocated with devm_kzalloc
+
+From: Wei Yongjun <weiyongjun1@huawei.com>
+
+commit df94121f02ecce435d6b5277071eb94b764caa89 upstream.
+
+It's not necessary to free memory allocated with devm_kzalloc
+and using kfree leads to a double free.
+
+Fixes: 7aae6e2df127 ("[media] Add GS1662 driver, a video serializer")
+
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/spi/gs1662.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/media/spi/gs1662.c
++++ b/drivers/media/spi/gs1662.c
+@@ -453,10 +453,9 @@ static int gs_probe(struct spi_device *s
+ static int gs_remove(struct spi_device *spi)
+ {
+ struct v4l2_subdev *sd = spi_get_drvdata(spi);
+- struct gs *gs = to_gs(sd);
+
+ v4l2_device_unregister_subdev(sd);
+- kfree(gs);
++
+ return 0;
+ }
+
--- /dev/null
+From 7ec03e60ef81c19b5d3a46dd070ee966774b860f Mon Sep 17 00:00:00 2001
+From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
+Date: Sat, 10 Sep 2016 13:59:49 -0300
+Subject: [media] ite-cir: initialize use_demodulator before using it
+
+From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
+
+commit 7ec03e60ef81c19b5d3a46dd070ee966774b860f upstream.
+
+Function ite_set_carrier_params() uses variable use_demodulator after
+having initialized it to false in some if branches, but this variable is
+never set to true otherwise.
+
+This bug has been found using clang -Wsometimes-uninitialized warning
+flag.
+
+Fixes: 620a32bba4a2 ("[media] rc: New rc-based ite-cir driver for
+several ITE CIRs")
+
+Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/rc/ite-cir.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/media/rc/ite-cir.c
++++ b/drivers/media/rc/ite-cir.c
+@@ -263,6 +263,8 @@ static void ite_set_carrier_params(struc
+
+ if (allowance > ITE_RXDCR_MAX)
+ allowance = ITE_RXDCR_MAX;
++
++ use_demodulator = true;
+ }
+ }
+
--- /dev/null
+From 124f930b8cbc4ac11236e6eb1c5f008318864588 Mon Sep 17 00:00:00 2001
+From: Ilya Dryomov <idryomov@gmail.com>
+Date: Mon, 16 Jan 2017 19:16:46 +0100
+Subject: libceph: make sure ceph_aes_crypt() IV is aligned
+
+From: Ilya Dryomov <idryomov@gmail.com>
+
+commit 124f930b8cbc4ac11236e6eb1c5f008318864588 upstream.
+
+... otherwise the crypto stack will align it for us with a GFP_ATOMIC
+allocation and a memcpy() -- see skcipher_walk_first().
+
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/ceph/crypto.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/ceph/crypto.c
++++ b/net/ceph/crypto.c
+@@ -164,7 +164,7 @@ static int ceph_aes_crypt(const struct c
+ SKCIPHER_REQUEST_ON_STACK(req, tfm);
+ struct sg_table sgt;
+ struct scatterlist prealloc_sg;
+- char iv[AES_BLOCK_SIZE];
++ char iv[AES_BLOCK_SIZE] __aligned(8);
+ int pad_byte = AES_BLOCK_SIZE - (in_len & (AES_BLOCK_SIZE - 1));
+ int crypt_len = encrypt ? in_len + pad_byte : in_len;
+ int ret;
--- /dev/null
+From 10ad1d754a434c024ce7eeb1cec9f69fd3ecc863 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Thu, 13 Oct 2016 11:30:39 +0300
+Subject: mtd: spi-nor: Fix some error codes in cqspi_setup_flash()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit 10ad1d754a434c024ce7eeb1cec9f69fd3ecc863 upstream.
+
+We return success or possibly uninitialized values on these error paths
+instead of proper error codes.
+
+Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
+Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/spi-nor/cadence-quadspi.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/mtd/spi-nor/cadence-quadspi.c
++++ b/drivers/mtd/spi-nor/cadence-quadspi.c
+@@ -1077,12 +1077,14 @@ static int cqspi_setup_flash(struct cqsp
+
+ /* Get flash device data */
+ for_each_available_child_of_node(dev->of_node, np) {
+- if (of_property_read_u32(np, "reg", &cs)) {
++ ret = of_property_read_u32(np, "reg", &cs);
++ if (ret) {
+ dev_err(dev, "Couldn't determine chip select.\n");
+ goto err;
+ }
+
+ if (cs >= CQSPI_MAX_CHIPSELECT) {
++ ret = -EINVAL;
+ dev_err(dev, "Chip select %d out of range.\n", cs);
+ goto err;
+ }
--- /dev/null
+From 193e87143c290ec16838f5368adc0e0bc94eb931 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Thu, 13 Oct 2016 11:06:47 +0300
+Subject: mtd: spi-nor: Off by one in cqspi_setup_flash()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit 193e87143c290ec16838f5368adc0e0bc94eb931 upstream.
+
+There are CQSPI_MAX_CHIPSELECT elements in the ->f_pdata array so the >
+should be >=.
+
+Fixes: 140623410536 ('mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller')
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Marek Vasut <marex@denx.de>
+Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/spi-nor/cadence-quadspi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/mtd/spi-nor/cadence-quadspi.c
++++ b/drivers/mtd/spi-nor/cadence-quadspi.c
+@@ -1082,7 +1082,7 @@ static int cqspi_setup_flash(struct cqsp
+ goto err;
+ }
+
+- if (cs > CQSPI_MAX_CHIPSELECT) {
++ if (cs >= CQSPI_MAX_CHIPSELECT) {
+ dev_err(dev, "Chip select %d out of range.\n", cs);
+ goto err;
+ }
--- /dev/null
+From ff681022c6639c194fbb6893c50ace9e52a44788 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Mon, 19 Sep 2016 09:46:30 -0300
+Subject: [media] platform: pxa_camera: add VIDEO_V4L2 dependency
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit ff681022c6639c194fbb6893c50ace9e52a44788 upstream.
+
+Moving the pxa_camera driver from soc_camera lots the implied
+VIDEO_V4L2 Kconfig dependency, and building the driver without
+V4L2 results in a kernel that cannot link:
+
+drivers/media/platform/pxa_camera.o: In function `pxa_camera_remove':
+pxa_camera.c:(.text.pxa_camera_remove+0x10): undefined reference to `v4l2_clk_unregister'
+pxa_camera.c:(.text.pxa_camera_remove+0x18): undefined reference to `v4l2_device_unregister'
+drivers/media/platform/pxa_camera.o: In function `pxa_camera_probe':
+pxa_camera.c:(.text.pxa_camera_probe+0x458): undefined reference to `v4l2_of_parse_endpoint'
+drivers/media/v4l2-core/videobuf2-core.o: In function `__enqueue_in_driver':
+drivers/media/v4l2-core/videobuf2-core.o: In function `vb2_core_streamon':
+videobuf2-core.c:(.text.vb2_core_streamon+0x1b4): undefined reference to `v4l_vb2q_enable_media_source'
+drivers/media/v4l2-core/videobuf2-v4l2.o: In function `vb2_ioctl_reqbufs':
+videobuf2-v4l2.c:(.text.vb2_ioctl_reqbufs+0xc): undefined reference to `video_devdata'
+
+This adds back an explicit dependency.
+
+Fixes: 3050b9985024 ("[media] media: platform: pxa_camera: move pxa_camera out of soc_camera")
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/platform/Kconfig
++++ b/drivers/media/platform/Kconfig
+@@ -93,7 +93,7 @@ config VIDEO_OMAP3_DEBUG
+
+ config VIDEO_PXA27x
+ tristate "PXA27x Quick Capture Interface driver"
+- depends on VIDEO_DEV && HAS_DMA
++ depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
+ depends on PXA27x || COMPILE_TEST
+ select VIDEOBUF2_DMA_SG
+ select SG_SPLIT
--- /dev/null
+From 32dd7731699765f21dbe6df9020e613d4ed73fc3 Mon Sep 17 00:00:00 2001
+From: Chanwoo Choi <cw00.choi@samsung.com>
+Date: Wed, 28 Dec 2016 20:52:36 +0900
+Subject: PM / devfreq: exynos-bus: Fix the wrong return value
+
+From: Chanwoo Choi <cw00.choi@samsung.com>
+
+commit 32dd7731699765f21dbe6df9020e613d4ed73fc3 upstream.
+
+This patch fixes the wrong return value. If devfreq driver requires the wrong
+and non-available governor, it is fail. So, this patch returns the error
+insead of -EPROBE_DEFER.
+
+Fixes: 403e0689d2a9 (PM / devfreq: exynos: Add support of bus frequency of sub-blocks using passive governor)
+Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/devfreq/exynos-bus.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/devfreq/exynos-bus.c
++++ b/drivers/devfreq/exynos-bus.c
+@@ -498,7 +498,7 @@ passive:
+ if (IS_ERR(bus->devfreq)) {
+ dev_err(dev,
+ "failed to add devfreq dev with passive governor\n");
+- ret = -EPROBE_DEFER;
++ ret = PTR_ERR(bus->devfreq);
+ goto err;
+ }
+
--- /dev/null
+From 73613b16cb5c5d5a659fc8832eff99eead3f9afb Mon Sep 17 00:00:00 2001
+From: Chanwoo Choi <cw00.choi@samsung.com>
+Date: Wed, 28 Dec 2016 20:52:35 +0900
+Subject: PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL
+
+From: Chanwoo Choi <cw00.choi@samsung.com>
+
+commit 73613b16cb5c5d5a659fc8832eff99eead3f9afb upstream.
+
+This patch fixes the bug of devfreq_add_device(). The devfreq device must
+have the default governor. If find_devfreq_governor() returns error,
+devfreq_add_device() fail to add the devfreq instance.
+
+Fixes: 1b5c1be2c88e (PM / devfreq: map devfreq drivers to governor using name)
+Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/devfreq/devfreq.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+--- a/drivers/devfreq/devfreq.c
++++ b/drivers/devfreq/devfreq.c
+@@ -593,11 +593,16 @@ struct devfreq *devfreq_add_device(struc
+ list_add(&devfreq->node, &devfreq_list);
+
+ governor = find_devfreq_governor(devfreq->governor_name);
+- if (!IS_ERR(governor))
+- devfreq->governor = governor;
+- if (devfreq->governor)
+- err = devfreq->governor->event_handler(devfreq,
+- DEVFREQ_GOV_START, NULL);
++ if (IS_ERR(governor)) {
++ dev_err(dev, "%s: Unable to find governor for the device\n",
++ __func__);
++ err = PTR_ERR(governor);
++ goto err_init;
++ }
++
++ devfreq->governor = governor;
++ err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START,
++ NULL);
+ if (err) {
+ dev_err(dev, "%s: Unable to start governor for the device\n",
+ __func__);
--- /dev/null
+From 63447646ac657fde00bb658ce21a3431940ae0ad Mon Sep 17 00:00:00 2001
+From: Loic Pallardy <loic.pallardy@st.com>
+Date: Thu, 15 Dec 2016 15:49:56 +0100
+Subject: rpmsg: virtio_rpmsg_bus: fix channel creation
+
+From: Loic Pallardy <loic.pallardy@st.com>
+
+commit 63447646ac657fde00bb658ce21a3431940ae0ad upstream.
+
+Since commit 4dffed5b3ac796b ("rpmsg: Name rpmsg devices based on
+channel id"), it is no more possible for a firmware to register twice
+a service (on different endpoints). rpmsg_register_device function
+is failing when calling device_add for the second time as second
+device has the same name as first one already register.
+It is because name is based only on service name and so is not more
+unique. Previously name was unique thanks to the use of rpmsg_dev_index.
+
+This patch adds destination and source endpoint numbers device name to
+create an unique identifier.
+
+Fixes: 4dffed5b3ac7 ("rpmsg: Name rpmsg devices based on channel id")
+Acked-by: Peter Griffin <peter.griffin@linaro.org>
+Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
+[bjorn: flipped name and address in device name]
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/rpmsg/rpmsg_core.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/rpmsg/rpmsg_core.c
++++ b/drivers/rpmsg/rpmsg_core.c
+@@ -411,8 +411,8 @@ int rpmsg_register_device(struct rpmsg_d
+ struct device *dev = &rpdev->dev;
+ int ret;
+
+- dev_set_name(&rpdev->dev, "%s:%s",
+- dev_name(dev->parent), rpdev->id.name);
++ dev_set_name(&rpdev->dev, "%s.%s.%d.%d", dev_name(dev->parent),
++ rpdev->id.name, rpdev->src, rpdev->dst);
+
+ rpdev->dev.bus = &rpmsg_bus;
+ rpdev->dev.release = rpmsg_release_device;
--- /dev/null
+From eadf081146ec327d6fbbb6aff28e3d9aac329dc6 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Thu, 13 Oct 2016 11:39:04 -0300
+Subject: [media] s5p-cec: mark PM functions as __maybe_unused again
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit eadf081146ec327d6fbbb6aff28e3d9aac329dc6 upstream.
+
+A bugfix removed the two callers of s5p_cec_runtime_suspend
+and s5p_cec_runtime_resume, leading to the return of a harmless
+warning that I had previously fixed in commit aee8937089b1
+("[media] s5p_cec: mark suspend/resume as __maybe_unused"):
+
+staging/media/s5p-cec/s5p_cec.c:234:12: error: ‘s5p_cec_runtime_suspend’ defined but not used [-Werror=unused-function]
+staging/media/s5p-cec/s5p_cec.c:242:12: error: ‘s5p_cec_runtime_resume’ defined but not used [-Werror=unused-function]
+
+This adds the __maybe_unused annotations to the function that
+were not removed and that are now unused when CONFIG_PM
+is disabled.
+
+Fixes: 57b978ada073 ("[media] s5p-cec: fix system and runtime PM integration")
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/staging/media/s5p-cec/s5p_cec.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/staging/media/s5p-cec/s5p_cec.c
++++ b/drivers/staging/media/s5p-cec/s5p_cec.c
+@@ -231,7 +231,7 @@ static int s5p_cec_remove(struct platfor
+ return 0;
+ }
+
+-static int s5p_cec_runtime_suspend(struct device *dev)
++static int __maybe_unused s5p_cec_runtime_suspend(struct device *dev)
+ {
+ struct s5p_cec_dev *cec = dev_get_drvdata(dev);
+
+@@ -239,7 +239,7 @@ static int s5p_cec_runtime_suspend(struc
+ return 0;
+ }
+
+-static int s5p_cec_runtime_resume(struct device *dev)
++static int __maybe_unused s5p_cec_runtime_resume(struct device *dev)
+ {
+ struct s5p_cec_dev *cec = dev_get_drvdata(dev);
+ int ret;
--- /dev/null
+From c0026c7bfb95c250c3e34fde59f96ad72fd730d6 Mon Sep 17 00:00:00 2001
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Mon, 14 Nov 2016 12:09:26 -0200
+Subject: [media] s5p-mfc: Fix clock management in s5p_mfc_release() function
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+commit c0026c7bfb95c250c3e34fde59f96ad72fd730d6 upstream.
+
+Clock control indirectly requires access to MFC device, so call it only
+if we are sure that the device exists in s5p_mfc_release function.
+s5p_mfc_remove() calls s5p_mfc_final_pm(), which releases all PM related
+resources, including clocks, so any call to clocks related functions
+is not valid after s5p_mfc_final_pm().
+
+Fixes: d695c12 ("[media] media: s5p-mfc fix invalid memory access from
+s5p_mfc_release()")
+
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
++++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
+@@ -926,10 +926,11 @@ static int s5p_mfc_release(struct file *
+ mfc_debug_enter();
+ if (dev)
+ mutex_lock(&dev->mfc_mutex);
+- s5p_mfc_clock_on();
+ vb2_queue_release(&ctx->vq_src);
+ vb2_queue_release(&ctx->vq_dst);
+ if (dev) {
++ s5p_mfc_clock_on();
++
+ /* Mark context as idle */
+ clear_work_bit_irqsave(ctx);
+ /*
+@@ -951,9 +952,9 @@ static int s5p_mfc_release(struct file *
+ if (s5p_mfc_power_off() < 0)
+ mfc_err("Power off failed\n");
+ }
++ mfc_debug(2, "Shutting down clock\n");
++ s5p_mfc_clock_off();
+ }
+- mfc_debug(2, "Shutting down clock\n");
+- s5p_mfc_clock_off();
+ if (dev)
+ dev->ctx[ctx->num] = NULL;
+ s5p_mfc_dec_ctrls_delete(ctx);
--- /dev/null
+From ffb58456589443ca572221fabbdef3db8483a779 Mon Sep 17 00:00:00 2001
+From: James Bottomley <James.Bottomley@HansenPartnership.com>
+Date: Sun, 1 Jan 2017 09:39:24 -0800
+Subject: scsi: mpt3sas: fix hang on ata passthrough commands
+
+From: James Bottomley <James.Bottomley@HansenPartnership.com>
+
+commit ffb58456589443ca572221fabbdef3db8483a779 upstream.
+
+mpt3sas has a firmware failure where it can only handle one pass through
+ATA command at a time. If another comes in, contrary to the SAT
+standard, it will hang until the first one completes (causing long
+commands like secure erase to timeout). The original fix was to block
+the device when an ATA command came in, but this caused a regression
+with
+
+commit 669f044170d8933c3d66d231b69ea97cb8447338
+Author: Bart Van Assche <bart.vanassche@sandisk.com>
+Date: Tue Nov 22 16:17:13 2016 -0800
+
+ scsi: srp_transport: Move queuecommand() wait code to SCSI core
+
+So fix the original fix of the secure erase timeout by properly
+returning SAM_STAT_BUSY like the SAT recommends. The original patch
+also had a concurrency problem since scsih_qcmd is lockless at that
+point (this is fixed by using atomic bitops to set and test the flag).
+
+[mkp: addressed feedback wrt. test_bit and fixed whitespace]
+
+Fixes: 18f6084a989ba1b (mpt3sas: Fix secure erase premature termination)
+Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
+Acked-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Reported-by: Ingo Molnar <mingo@kernel.org>
+Tested-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/mpt3sas/mpt3sas_base.h | 12 ++++++++++
+ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 40 ++++++++++++++++++++++-------------
+ 2 files changed, 38 insertions(+), 14 deletions(-)
+
+--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
++++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
+@@ -393,6 +393,7 @@ struct MPT3SAS_TARGET {
+ * @eedp_enable: eedp support enable bit
+ * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
+ * @eedp_block_length: block size
++ * @ata_command_pending: SATL passthrough outstanding for device
+ */
+ struct MPT3SAS_DEVICE {
+ struct MPT3SAS_TARGET *sas_target;
+@@ -402,6 +403,17 @@ struct MPT3SAS_DEVICE {
+ u8 block;
+ u8 tlr_snoop_check;
+ u8 ignore_delay_remove;
++ /*
++ * Bug workaround for SATL handling: the mpt2/3sas firmware
++ * doesn't return BUSY or TASK_SET_FULL for subsequent
++ * commands while a SATL pass through is in operation as the
++ * spec requires, it simply does nothing with them until the
++ * pass through completes, causing them possibly to timeout if
++ * the passthrough is a long executing command (like format or
++ * secure erase). This variable allows us to do the right
++ * thing while a SATL command is pending.
++ */
++ unsigned long ata_command_pending;
+ };
+
+ #define MPT3_CMD_NOT_USED 0x8000 /* free */
+--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+@@ -3885,9 +3885,18 @@ _scsih_temp_threshold_events(struct MPT3
+ }
+ }
+
+-static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
++static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
+ {
+- return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
++ struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
++
++ if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
++ return 0;
++
++ if (pending)
++ return test_and_set_bit(0, &priv->ata_command_pending);
++
++ clear_bit(0, &priv->ata_command_pending);
++ return 0;
+ }
+
+ /**
+@@ -3911,9 +3920,7 @@ _scsih_flush_running_cmds(struct MPT3SAS
+ if (!scmd)
+ continue;
+ count++;
+- if (ata_12_16_cmd(scmd))
+- scsi_internal_device_unblock(scmd->device,
+- SDEV_RUNNING);
++ _scsih_set_satl_pending(scmd, false);
+ mpt3sas_base_free_smid(ioc, smid);
+ scsi_dma_unmap(scmd);
+ if (ioc->pci_error_recovery)
+@@ -4044,13 +4051,6 @@ scsih_qcmd(struct Scsi_Host *shost, stru
+ if (ioc->logging_level & MPT_DEBUG_SCSI)
+ scsi_print_command(scmd);
+
+- /*
+- * Lock the device for any subsequent command until command is
+- * done.
+- */
+- if (ata_12_16_cmd(scmd))
+- scsi_internal_device_block(scmd->device);
+-
+ sas_device_priv_data = scmd->device->hostdata;
+ if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
+ scmd->result = DID_NO_CONNECT << 16;
+@@ -4064,6 +4064,19 @@ scsih_qcmd(struct Scsi_Host *shost, stru
+ return 0;
+ }
+
++ /*
++ * Bug work around for firmware SATL handling. The loop
++ * is based on atomic operations and ensures consistency
++ * since we're lockless at this point
++ */
++ do {
++ if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
++ scmd->result = SAM_STAT_BUSY;
++ scmd->scsi_done(scmd);
++ return 0;
++ }
++ } while (_scsih_set_satl_pending(scmd, true));
++
+ sas_target_priv_data = sas_device_priv_data->sas_target;
+
+ /* invalid device handle */
+@@ -4626,8 +4639,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *i
+ if (scmd == NULL)
+ return 1;
+
+- if (ata_12_16_cmd(scmd))
+- scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
++ _scsih_set_satl_pending(scmd, false);
+
+ mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
+
--- /dev/null
+From 9373eba6cfae48911b977d14323032cd5d161aae Mon Sep 17 00:00:00 2001
+From: "Ewan D. Milne" <emilne@redhat.com>
+Date: Mon, 9 Jan 2017 16:33:36 -0500
+Subject: scsi: ses: Fix SAS device detection in enclosure
+
+From: Ewan D. Milne <emilne@redhat.com>
+
+commit 9373eba6cfae48911b977d14323032cd5d161aae upstream.
+
+The call to scsi_is_sas_rphy() needs to be made on the SAS end_device,
+not on the SCSI device.
+
+Fixes: 835831c57e9b ("ses: use scsi_is_sas_rphy instead of is_sas_attached")
+Signed-off-by: Ewan D. Milne <emilne@redhat.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/ses.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/ses.c
++++ b/drivers/scsi/ses.c
+@@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struc
+
+ ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);
+
+- if (scsi_is_sas_rphy(&sdev->sdev_gendev))
++ if (scsi_is_sas_rphy(sdev->sdev_target->dev.parent))
+ efd.addr = sas_get_address(sdev);
+
+ if (efd.addr) {
--- /dev/null
+From df21d2fa733035e4d414379960f94b2516b41296 Mon Sep 17 00:00:00 2001
+From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
+Date: Mon, 19 Dec 2016 17:46:53 +0530
+Subject: selftest/powerpc: Wrong PMC initialized in pmc56_overflow test
+
+From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
+
+commit df21d2fa733035e4d414379960f94b2516b41296 upstream.
+
+Test uses PMC2 to count the event. But PMC1 is being initialized.
+Patch to fix it.
+
+Fixes: 3752e453f6ba ('selftests/powerpc: Add tests of PMU EBBs')
+Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
+@@ -66,7 +66,7 @@ int pmc56_overflow(void)
+
+ FAIL_IF(ebb_event_enable(&event));
+
+- mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
++ mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
+ mtspr(SPRN_PMC5, 0);
+ mtspr(SPRN_PMC6, 0);
+
libceph-switch-ceph_x_encrypt-to-ceph_crypt.patch
libceph-switch-ceph_x_decrypt-to-ceph_crypt.patch
libceph-remove-now-unused-ceph_-en-de-crypt-functions.patch
+arm-dts-dra7-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-dm816x-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-dm814x-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-am33xx-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-omap4-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-omap5-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-am4372-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-omap3-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-omap2-add-an-empty-chosen-node-to-top-level-dtsi.patch
+arm-dts-imx6qdl-nitrogen6_max-fix-sgtl5000-pinctrl-init.patch
+arm-dts-omap3-fix-card-detect-and-write-protect-on-logic-pd-som-lv.patch
+arm-ux500-fix-prcmu_is_cpu_in_wfi-calculation.patch
+arm-8613-1-fix-the-uaccess-crash-on-pb11mpcore.patch
+ceph-fix-scheduler-warning-due-to-nested-blocking.patch
+ceph-fix-ceph_get_caps-interruption.patch
+ceph-fix-endianness-of-getattr-mask-in-ceph_d_revalidate.patch
+ceph-fix-endianness-bug-in-frag_tree_split_cmp.patch
+libceph-make-sure-ceph_aes_crypt-iv-is-aligned.patch
+xprtrdma-make-frwr-send-queue-entry-accounting-more-accurate.patch
+xprtrdma-squelch-max-send-max-recv-messages-at-connect-time.patch
+arm64-mm-avoid-name-clash-in-__page_to_voff.patch
+arm64-fix-swiotlb-fallback-allocation.patch
+scsi-ses-fix-sas-device-detection-in-enclosure.patch
+scsi-mpt3sas-fix-hang-on-ata-passthrough-commands.patch
+pm-devfreq-exynos-bus-fix-the-wrong-return-value.patch
+pm-devfreq-fix-the-bug-of-devfreq_add_device-when-governor-is-null.patch
+mtd-spi-nor-off-by-one-in-cqspi_setup_flash.patch
+mtd-spi-nor-fix-some-error-codes-in-cqspi_setup_flash.patch
+rpmsg-virtio_rpmsg_bus-fix-channel-creation.patch
+blackfin-check-devm_pinctrl_get-for-errors.patch
+platform-pxa_camera-add-video_v4l2-dependency.patch
+gs1662-drop-kfree-for-memory-allocated-with-devm_kzalloc.patch
+ite-cir-initialize-use_demodulator-before-using-it.patch
+st-hva-fix-some-error-handling-in-hva_hw_probe.patch
+s5p-cec-mark-pm-functions-as-__maybe_unused-again.patch
+s5p-mfc-fix-clock-management-in-s5p_mfc_release-function.patch
+dmaengine-rcar-dmac-unmap-slave-resource-when-channel-is-freed.patch
+dmaengine-pl330-fix-runtime-pm-support-for-terminated-transfers.patch
+spi-pxa2xx-add-missed-break.patch
+soc-ti-wkup_m3_ipc-fix-error-return-code-in-wkup_m3_ipc_probe.patch
+selftest-powerpc-wrong-pmc-initialized-in-pmc56_overflow-test.patch
+tools-virtio-ringtest-fix-run-on-all.sh-for-offline-cpus.patch
--- /dev/null
+From 36b29eb30ee0f6c99f06bea406c23a3fd4cbb80b Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <weiyongjun1@huawei.com>
+Date: Thu, 12 Jan 2017 14:53:41 +0000
+Subject: soc: ti: wkup_m3_ipc: Fix error return code in wkup_m3_ipc_probe()
+
+From: Wei Yongjun <weiyongjun1@huawei.com>
+
+commit 36b29eb30ee0f6c99f06bea406c23a3fd4cbb80b upstream.
+
+Fix to return a negative error code from the kthread_run() error
+handling case instead of 0, as done elsewhere in this function.
+
+Fixes: cdd5de500b2c ("soc: ti: Add wkup_m3_ipc driver")
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/soc/ti/wkup_m3_ipc.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/soc/ti/wkup_m3_ipc.c
++++ b/drivers/soc/ti/wkup_m3_ipc.c
+@@ -459,6 +459,7 @@ static int wkup_m3_ipc_probe(struct plat
+
+ if (IS_ERR(task)) {
+ dev_err(dev, "can't create rproc_boot thread\n");
++ ret = PTR_ERR(task);
+ goto err_put_rproc;
+ }
+
--- /dev/null
+From a2dd8af00ca7fff4972425a4a6b19dd1840dc807 Mon Sep 17 00:00:00 2001
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Date: Mon, 2 Jan 2017 13:44:28 +0200
+Subject: spi: pxa2xx: add missed break
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+commit a2dd8af00ca7fff4972425a4a6b19dd1840dc807 upstream.
+
+The commit 7c7289a40425 ("spi: pxa2xx: Default thresholds to PXA
+configuration") while splitting up CE4100 code obviously missed a break
+condition in one chunk. Add it here.
+
+Looks like we have no active user of CE4100, though better to fix this later
+than never.
+
+Fixes: commit 7c7289a40425 ("spi: pxa2xx: Default thresholds to PXA configuration")
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi-pxa2xx.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/spi/spi-pxa2xx.c
++++ b/drivers/spi/spi-pxa2xx.c
+@@ -1690,6 +1690,7 @@ static int pxa2xx_spi_probe(struct platf
+ pxa2xx_spi_write(drv_data, SSCR1, tmp);
+ tmp = SSCR0_SCR(2) | SSCR0_Motorola | SSCR0_DataSize(8);
+ pxa2xx_spi_write(drv_data, SSCR0, tmp);
++ break;
+ default:
+ tmp = SSCR1_RxTresh(RX_THRESH_DFLT) |
+ SSCR1_TxTresh(TX_THRESH_DFLT);
--- /dev/null
+From 6b2bed891253c08e7f4c17dbd46b71fc87f22eef Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Fri, 14 Oct 2016 04:32:24 -0300
+Subject: [media] st-hva: fix some error handling in hva_hw_probe()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit 6b2bed891253c08e7f4c17dbd46b71fc87f22eef upstream.
+
+The devm_ioremap_resource() returns error pointers, never NULL. The
+platform_get_resource() returns NULL on error, never error pointers.
+The error code needs to be set, as well. The current code returns
+PTR_ERR(NULL) which is success.
+
+Fixes: 57b2c0628b60 ("[media] st-hva: multi-format video encoder V4L2 driver")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Acked-by: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/sti/hva/hva-hw.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/media/platform/sti/hva/hva-hw.c
++++ b/drivers/media/platform/sti/hva/hva-hw.c
+@@ -305,16 +305,16 @@ int hva_hw_probe(struct platform_device
+ /* get memory for registers */
+ regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ hva->regs = devm_ioremap_resource(dev, regs);
+- if (IS_ERR_OR_NULL(hva->regs)) {
++ if (IS_ERR(hva->regs)) {
+ dev_err(dev, "%s failed to get regs\n", HVA_PREFIX);
+ return PTR_ERR(hva->regs);
+ }
+
+ /* get memory for esram */
+ esram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+- if (IS_ERR_OR_NULL(esram)) {
++ if (!esram) {
+ dev_err(dev, "%s failed to get esram\n", HVA_PREFIX);
+- return PTR_ERR(esram);
++ return -ENODEV;
+ }
+ hva->esram_addr = esram->start;
+ hva->esram_size = resource_size(esram);
--- /dev/null
+From 21f5eda9b8671744539c8295b9df62991fffb2ce Mon Sep 17 00:00:00 2001
+From: Halil Pasic <pasic@linux.vnet.ibm.com>
+Date: Mon, 29 Aug 2016 18:25:22 +0200
+Subject: tools/virtio/ringtest: fix run-on-all.sh for offline cpus
+
+From: Halil Pasic <pasic@linux.vnet.ibm.com>
+
+commit 21f5eda9b8671744539c8295b9df62991fffb2ce upstream.
+
+Since ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work
+without /dev/cpu") run-on-all.sh uses seq 0 $HOST_AFFINITY as the list
+of ids of the CPUs to run the command on (assuming ids of online CPUs
+are consecutive and start from 0), where $HOST_AFFINITY is the highest
+CPU id in the system previously determined using lscpu. This can fail
+on systems with offline CPUs.
+
+Instead let's use lscpu to determine the list of online CPUs.
+
+Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Fixes: ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work without
+/dev/cpu")
+Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
+Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/virtio/ringtest/run-on-all.sh | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/tools/virtio/ringtest/run-on-all.sh
++++ b/tools/virtio/ringtest/run-on-all.sh
+@@ -1,12 +1,13 @@
+ #!/bin/sh
+
++CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
+ #use last CPU for host. Why not the first?
+ #many devices tend to use cpu0 by default so
+ #it tends to be busier
+-HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
++HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
+
+ #run command on all cpus
+-for cpu in $(seq 0 $HOST_AFFINITY)
++for cpu in $CPUS_ONLINE
+ do
+ #Don't run guest and host on same CPU
+ #It actually works ok if using signalling
--- /dev/null
+From 8d38de65644d900199f035277aa5f3da4aa9fc17 Mon Sep 17 00:00:00 2001
+From: Chuck Lever <chuck.lever@oracle.com>
+Date: Tue, 29 Nov 2016 10:52:16 -0500
+Subject: xprtrdma: Make FRWR send queue entry accounting more accurate
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+commit 8d38de65644d900199f035277aa5f3da4aa9fc17 upstream.
+
+Verbs providers may perform house-keeping on the Send Queue during
+each signaled send completion. It is necessary therefore for a verbs
+consumer (like xprtrdma) to occasionally force a signaled send
+completion if it runs unsignaled most of the time.
+
+xprtrdma does not require signaled completions for Send or FastReg
+Work Requests, but does signal some LocalInv Work Requests. To
+ensure that Send Queue house-keeping can run before the Send Queue
+is more than half-consumed, xprtrdma forces a signaled completion
+on occasion by counting the number of Send Queue Entries it
+consumes. It currently does this by counting each ib_post_send as
+one Entry.
+
+Commit c9918ff56dfb ("xprtrdma: Add ro_unmap_sync method for FRWR")
+introduced the ability for frwr_op_unmap_sync to post more than one
+Work Request with a single post_send. Thus the underlying assumption
+of one Send Queue Entry per ib_post_send is no longer true.
+
+Also, FastReg Work Requests are currently never signaled. They
+should be signaled once in a while, just as Send is, to keep the
+accounting of consumed SQEs accurate.
+
+While we're here, convert the CQCOUNT macros to the currently
+preferred kernel coding style, which is inline functions.
+
+Fixes: c9918ff56dfb ("xprtrdma: Add ro_unmap_sync method for FRWR")
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/sunrpc/xprtrdma/frwr_ops.c | 13 ++++++++++---
+ net/sunrpc/xprtrdma/verbs.c | 10 ++--------
+ net/sunrpc/xprtrdma/xprt_rdma.h | 20 ++++++++++++++++++--
+ 3 files changed, 30 insertions(+), 13 deletions(-)
+
+--- a/net/sunrpc/xprtrdma/frwr_ops.c
++++ b/net/sunrpc/xprtrdma/frwr_ops.c
+@@ -421,7 +421,7 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt,
+ IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
+ IB_ACCESS_REMOTE_READ;
+
+- DECR_CQCOUNT(&r_xprt->rx_ep);
++ rpcrdma_set_signaled(&r_xprt->rx_ep, ®_wr->wr);
+ rc = ib_post_send(ia->ri_id->qp, ®_wr->wr, &bad_wr);
+ if (rc)
+ goto out_senderr;
+@@ -486,7 +486,7 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *
+ struct rpcrdma_ia *ia = &r_xprt->rx_ia;
+ struct rpcrdma_mw *mw, *tmp;
+ struct rpcrdma_frmr *f;
+- int rc;
++ int count, rc;
+
+ dprintk("RPC: %s: req %p\n", __func__, req);
+
+@@ -496,6 +496,7 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *
+ * a single ib_post_send() call.
+ */
+ f = NULL;
++ count = 0;
+ invalidate_wrs = pos = prev = NULL;
+ list_for_each_entry(mw, &req->rl_registered, mw_list) {
+ if ((rep->rr_wc_flags & IB_WC_WITH_INVALIDATE) &&
+@@ -505,6 +506,7 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *
+ }
+
+ pos = __frwr_prepare_linv_wr(mw);
++ count++;
+
+ if (!invalidate_wrs)
+ invalidate_wrs = pos;
+@@ -523,7 +525,12 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *
+ f->fr_invwr.send_flags = IB_SEND_SIGNALED;
+ f->fr_cqe.done = frwr_wc_localinv_wake;
+ reinit_completion(&f->fr_linv_done);
+- INIT_CQCOUNT(&r_xprt->rx_ep);
++
++ /* Initialize CQ count, since there is always a signaled
++ * WR being posted here. The new cqcount depends on how
++ * many SQEs are about to be consumed.
++ */
++ rpcrdma_init_cqcount(&r_xprt->rx_ep, count);
+
+ /* Transport disconnect drains the receive CQ before it
+ * replaces the QP. The RPC reply handler won't call us
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -532,7 +532,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep,
+ ep->rep_cqinit = ep->rep_attr.cap.max_send_wr/2 - 1;
+ if (ep->rep_cqinit <= 2)
+ ep->rep_cqinit = 0; /* always signal? */
+- INIT_CQCOUNT(ep);
++ rpcrdma_init_cqcount(ep, 0);
+ init_waitqueue_head(&ep->rep_connect_wait);
+ INIT_DELAYED_WORK(&ep->rep_connect_worker, rpcrdma_connect_worker);
+
+@@ -1311,13 +1311,7 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia,
+ dprintk("RPC: %s: posting %d s/g entries\n",
+ __func__, send_wr->num_sge);
+
+- if (DECR_CQCOUNT(ep) > 0)
+- send_wr->send_flags = 0;
+- else { /* Provider must take a send completion every now and then */
+- INIT_CQCOUNT(ep);
+- send_wr->send_flags = IB_SEND_SIGNALED;
+- }
+-
++ rpcrdma_set_signaled(ep, send_wr);
+ rc = ib_post_send(ia->ri_id->qp, send_wr, &send_wr_fail);
+ if (rc)
+ goto out_postsend_err;
+--- a/net/sunrpc/xprtrdma/xprt_rdma.h
++++ b/net/sunrpc/xprtrdma/xprt_rdma.h
+@@ -95,8 +95,24 @@ struct rpcrdma_ep {
+ struct delayed_work rep_connect_worker;
+ };
+
+-#define INIT_CQCOUNT(ep) atomic_set(&(ep)->rep_cqcount, (ep)->rep_cqinit)
+-#define DECR_CQCOUNT(ep) atomic_sub_return(1, &(ep)->rep_cqcount)
++static inline void
++rpcrdma_init_cqcount(struct rpcrdma_ep *ep, int count)
++{
++ atomic_set(&ep->rep_cqcount, ep->rep_cqinit - count);
++}
++
++/* To update send queue accounting, provider must take a
++ * send completion every now and then.
++ */
++static inline void
++rpcrdma_set_signaled(struct rpcrdma_ep *ep, struct ib_send_wr *send_wr)
++{
++ send_wr->send_flags = 0;
++ if (unlikely(atomic_sub_return(1, &ep->rep_cqcount) <= 0)) {
++ rpcrdma_init_cqcount(ep, 0);
++ send_wr->send_flags = IB_SEND_SIGNALED;
++ }
++}
+
+ /* Pre-allocate extra Work Requests for handling backward receives
+ * and sends. This is a fixed value because the Work Queues are
--- /dev/null
+From 6d6bf72de914059b304f7b99530a7856e5c846aa Mon Sep 17 00:00:00 2001
+From: Chuck Lever <chuck.lever@oracle.com>
+Date: Tue, 29 Nov 2016 10:53:13 -0500
+Subject: xprtrdma: Squelch "max send, max recv" messages at connect time
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+commit 6d6bf72de914059b304f7b99530a7856e5c846aa upstream.
+
+Clean up: This message was intended to be a dprintk, as it is on the
+server-side.
+
+Fixes: 87cfb9a0c85c ('xprtrdma: Client-side support for ...')
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/sunrpc/xprtrdma/verbs.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -223,8 +223,8 @@ rpcrdma_update_connect_private(struct rp
+ cdata->inline_rsize = rsize;
+ if (wsize < cdata->inline_wsize)
+ cdata->inline_wsize = wsize;
+- pr_info("rpcrdma: max send %u, max recv %u\n",
+- cdata->inline_wsize, cdata->inline_rsize);
++ dprintk("RPC: %s: max send %u, max recv %u\n",
++ __func__, cdata->inline_wsize, cdata->inline_rsize);
+ rpcrdma_set_max_header_sizes(r_xprt);
+ }
+