--- /dev/null
+From fc4bf75ea300a5e62a2419f89dd0e22189dd7ab7 Mon Sep 17 00:00:00 2001
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Date: Mon, 25 Apr 2016 23:31:57 -0700
+Subject: aacraid: Fix for aac_command_thread hang
+
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+
+commit fc4bf75ea300a5e62a2419f89dd0e22189dd7ab7 upstream.
+
+Typically under error conditions, it is possible for aac_command_thread()
+to miss the wakeup from kthread_stop() and go back to sleep, causing it
+to hang aac_shutdown.
+
+In the observed scenario, the adapter is not functioning correctly and so
+aac_fib_send() never completes (or time-outs depending on how it was
+called). Shortly after aac_command_thread() starts it performs
+aac_fib_send(SendHostTime) which hangs. When aac_probe_one
+/aac_get_adapter_info send time outs, kthread_stop is called which breaks
+the command thread out of it's hang.
+
+The code will still go back to sleep in schedule_timeout() without
+checking kthread_should_stop() so it causes aac_probe_one to hang until
+the schedule_timeout() which is 30 minutes.
+
+Fixed by: Adding another kthread_should_stop() before schedule_timeout()
+Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/aacraid/commsup.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/scsi/aacraid/commsup.c
++++ b/drivers/scsi/aacraid/commsup.c
+@@ -1970,6 +1970,10 @@ int aac_command_thread(void *data)
+ if (difference <= 0)
+ difference = 1;
+ set_current_state(TASK_INTERRUPTIBLE);
++
++ if (kthread_should_stop())
++ break;
++
+ schedule_timeout(difference);
+
+ if (kthread_should_stop())
--- /dev/null
+From 78cbccd3bd683c295a44af8050797dc4a41376ff Mon Sep 17 00:00:00 2001
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Date: Mon, 25 Apr 2016 23:32:37 -0700
+Subject: aacraid: Fix for KDUMP driver hang
+
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+
+commit 78cbccd3bd683c295a44af8050797dc4a41376ff upstream.
+
+When KDUMP is triggered the driver first talks to the firmware in INTX
+mode, but the adapter firmware is still in MSIX mode. Therefore the first
+driver command hangs since the driver is waiting for an INTX response and
+firmware gives a MSIX response. If when the OS is installed on a RAID
+drive created by the adapter KDUMP will hang since the driver does not
+receive a response in sync mode.
+
+Fixed by: Change the firmware to INTX mode if it is in MSIX mode before
+sending the first sync command.
+
+Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/aacraid/aacraid.h | 1 +
+ drivers/scsi/aacraid/comminit.c | 24 ++++++++++++++++++++++++
+ 2 files changed, 25 insertions(+)
+
+--- a/drivers/scsi/aacraid/aacraid.h
++++ b/drivers/scsi/aacraid/aacraid.h
+@@ -29,6 +29,7 @@ enum {
+ #define AAC_INT_MODE_MSI (1<<1)
+ #define AAC_INT_MODE_AIF (1<<2)
+ #define AAC_INT_MODE_SYNC (1<<3)
++#define AAC_INT_MODE_MSIX (1<<16)
+
+ #define AAC_INT_ENABLE_TYPE1_INTX 0xfffffffb
+ #define AAC_INT_ENABLE_TYPE1_MSIX 0xfffffffa
+--- a/drivers/scsi/aacraid/comminit.c
++++ b/drivers/scsi/aacraid/comminit.c
+@@ -37,6 +37,7 @@
+ #include <linux/spinlock.h>
+ #include <linux/slab.h>
+ #include <linux/blkdev.h>
++#include <linux/delay.h>
+ #include <linux/completion.h>
+ #include <linux/mm.h>
+ #include <scsi/scsi_host.h>
+@@ -47,6 +48,20 @@ struct aac_common aac_config = {
+ .irq_mod = 1
+ };
+
++static inline int aac_is_msix_mode(struct aac_dev *dev)
++{
++ u32 status;
++
++ status = src_readl(dev, MUnit.OMR);
++ return (status & AAC_INT_MODE_MSIX);
++}
++
++static inline void aac_change_to_intx(struct aac_dev *dev)
++{
++ aac_src_access_devreg(dev, AAC_DISABLE_MSIX);
++ aac_src_access_devreg(dev, AAC_ENABLE_INTX);
++}
++
+ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign)
+ {
+ unsigned char *base;
+@@ -425,6 +440,15 @@ struct aac_dev *aac_init_adapter(struct
+ dev->comm_interface = AAC_COMM_PRODUCER;
+ dev->raw_io_interface = dev->raw_io_64 = 0;
+
++
++ /*
++ * Enable INTX mode, if not done already Enabled
++ */
++ if (aac_is_msix_mode(dev)) {
++ aac_change_to_intx(dev);
++ dev_info(&dev->pdev->dev, "Changed firmware to INTX mode");
++ }
++
+ if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
+ 0, 0, 0, 0, 0, 0,
+ status+0, status+1, status+2, status+3, NULL)) &&
--- /dev/null
+From 07beca2be24cc710461c0b131832524c9ee08910 Mon Sep 17 00:00:00 2001
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Date: Mon, 25 Apr 2016 23:31:26 -0700
+Subject: aacraid: Relinquish CPU during timeout wait
+
+From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+
+commit 07beca2be24cc710461c0b131832524c9ee08910 upstream.
+
+aac_fib_send has a special function case for initial commands during
+driver initialization using wait < 0(pseudo sync mode). In this case,
+the command does not sleep but rather spins checking for timeout.This
+loop is calls cpu_relax() in an attempt to allow other processes/threads
+to use the CPU, but this function does not relinquish the CPU and so the
+command will hog the processor. This was observed in a KDUMP
+"crashkernel" and that prevented the "command thread" (which is
+responsible for completing the command from being timed out) from
+starting because it could not get the CPU.
+
+Fixed by replacing "cpu_relax()" call with "schedule()"
+Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/aacraid/commsup.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/aacraid/commsup.c
++++ b/drivers/scsi/aacraid/commsup.c
+@@ -611,10 +611,10 @@ int aac_fib_send(u16 command, struct fib
+ }
+ return -EFAULT;
+ }
+- /* We used to udelay() here but that absorbed
+- * a CPU when a timeout occured. Not very
+- * useful. */
+- cpu_relax();
++ /*
++ * Allow other processes / CPUS to use core
++ */
++ schedule();
+ }
+ } else if (down_interruptible(&fibptr->event_wait)) {
+ /* Do nothing ... satisfy
--- /dev/null
+From 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a Mon Sep 17 00:00:00 2001
+From: Mikulas Patocka <mikulas@twibright.com>
+Date: Tue, 24 May 2016 22:48:33 +0200
+Subject: affs: fix remount failure when there are no options changed
+
+From: Mikulas Patocka <mikulas@twibright.com>
+
+commit 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a upstream.
+
+Commit c8f33d0bec99 ("affs: kstrdup() memory handling") checks if the
+kstrdup function returns NULL due to out-of-memory condition.
+
+However, if we are remounting a filesystem with no change to
+filesystem-specific options, the parameter data is NULL. In this case,
+kstrdup returns NULL (because it was passed NULL parameter), although no
+out of memory condition exists. The mount syscall then fails with
+ENOMEM.
+
+This patch fixes the bug. We fail with ENOMEM only if data is non-NULL.
+
+The patch also changes the call to replace_mount_options - if we didn't
+pass any filesystem-specific options, we don't call
+replace_mount_options (thus we don't erase existing reported options).
+
+Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling")
+Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/affs/super.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/fs/affs/super.c
++++ b/fs/affs/super.c
+@@ -528,7 +528,7 @@ affs_remount(struct super_block *sb, int
+ char *prefix = NULL;
+
+ new_opts = kstrdup(data, GFP_KERNEL);
+- if (!new_opts)
++ if (data && !new_opts)
+ return -ENOMEM;
+
+ pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
+@@ -546,7 +546,8 @@ affs_remount(struct super_block *sb, int
+ }
+
+ flush_delayed_work(&sbi->sb_work);
+- replace_mount_options(sb, new_opts);
++ if (new_opts)
++ replace_mount_options(sb, new_opts);
+
+ sbi->s_flags = mount_flags;
+ sbi->s_mode = mode;
--- /dev/null
+From b1f3a3b03eb5f61b4051e2da9aa15653e705e111 Mon Sep 17 00:00:00 2001
+From: Florian Vallee <fvallee@eukrea.fr>
+Date: Tue, 19 Apr 2016 17:50:05 +0200
+Subject: ARM: dts: at91: fix typo in sama5d2 PIN_PD24 description
+
+From: Florian Vallee <fvallee@eukrea.fr>
+
+commit b1f3a3b03eb5f61b4051e2da9aa15653e705e111 upstream.
+
+Fix a typo on PIN_PD24 for UTXD2 and FLEXCOM4_IO3 which were
+wrongly linked to PIN_PD23).
+
+Signed-off-by: Florian Vallee <fvallee@eukrea.fr>
+Fixes: 7f16cb676c00 ("ARM: at91/dt: add sama5d2 pinmux")
+[nicolas.ferre@atmel.com: add commit message, changed subject]
+Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/sama5d2-pinfunc.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/arm/boot/dts/sama5d2-pinfunc.h
++++ b/arch/arm/boot/dts/sama5d2-pinfunc.h
+@@ -837,8 +837,8 @@
+ #define PIN_PD23__ISC_FIELD PINMUX_PIN(PIN_PD23, 6, 4)
+ #define PIN_PD24 120
+ #define PIN_PD24__GPIO PINMUX_PIN(PIN_PD24, 0, 0)
+-#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD23, 1, 2)
+-#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD23, 3, 3)
++#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD24, 1, 2)
++#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD24, 3, 3)
+ #define PIN_PD25 121
+ #define PIN_PD25__GPIO PINMUX_PIN(PIN_PD25, 0, 0)
+ #define PIN_PD25__SPI1_SPCK PINMUX_PIN(PIN_PD25, 1, 3)
--- /dev/null
+From 330d12764e15f6e3e94ff34cda29db96d2589c24 Mon Sep 17 00:00:00 2001
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Fri, 6 May 2016 09:27:16 +0200
+Subject: ARM: dts: exynos: Add interrupt line to MAX8997 PMIC on exynos4210-trats
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+commit 330d12764e15f6e3e94ff34cda29db96d2589c24 upstream.
+
+MAX8997 PMIC requires interrupt and fails probing without it.
+
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Fixes: d105f0b1215d ("ARM: dts: Add basic dts file for Samsung Trats board")
+[k.kozlowski: Write commit message, add CC-stable]
+Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/exynos4210-trats.dts | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/arch/arm/boot/dts/exynos4210-trats.dts
++++ b/arch/arm/boot/dts/exynos4210-trats.dts
+@@ -298,6 +298,8 @@
+ compatible = "maxim,max8997-pmic";
+
+ reg = <0x66>;
++ interrupt-parent = <&gpx0>;
++ interrupts = <7 0>;
+
+ max8997,pmic-buck1-uses-gpio-dvs;
+ max8997,pmic-buck2-uses-gpio-dvs;
--- /dev/null
+From 3397c2c45b1b6f54834dfeae30a73046f33ca943 Mon Sep 17 00:00:00 2001
+From: Alexander Kurz <akurz@blala.de>
+Date: Thu, 14 Apr 2016 23:30:49 +0200
+Subject: ARM: dts: imx35: restore existing used clock enumeration
+
+From: Alexander Kurz <akurz@blala.de>
+
+commit 3397c2c45b1b6f54834dfeae30a73046f33ca943 upstream.
+
+A new element got inserted into enum mx35_clks with commit 3713e3f5e927
+("clk: imx35: define two clocks for rtc"). This insertion shifted most
+nummerical clock assignments to a new nummerical value which in turn
+rendered most hardcoded nummeric values in imx35.dtsi incorrect.
+
+Restore the existing order by moving the newly introduced clock to the
+end of the enum. Update the dts documentation accordingly.
+
+Signed-off-by: Alexander Kurz <akurz@blala.de>
+Fixes: 3713e3f5e927 ("clk: imx35: define two clocks for rtc")
+Signed-off-by: Shawn Guo <shawnguo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Documentation/devicetree/bindings/clock/imx35-clock.txt | 1 +
+ drivers/clk/imx/clk-imx35.c | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+--- a/Documentation/devicetree/bindings/clock/imx35-clock.txt
++++ b/Documentation/devicetree/bindings/clock/imx35-clock.txt
+@@ -94,6 +94,7 @@ clocks and IDs.
+ csi_sel 79
+ iim_gate 80
+ gpu2d_gate 81
++ ckli_gate 82
+
+ Examples:
+
+--- a/drivers/clk/imx/clk-imx35.c
++++ b/drivers/clk/imx/clk-imx35.c
+@@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll",
+ static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
+
+ enum mx35_clks {
+- ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
++ ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
+ arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
+ esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
+ spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
+@@ -79,7 +79,7 @@ enum mx35_clks {
+ rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate,
+ ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate,
+ wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate,
+- gpu2d_gate, clk_max
++ gpu2d_gate, ckil, clk_max
+ };
+
+ static struct clk *clk[clk_max];
--- /dev/null
+From 9800917cf92f5b5fe5cae706cb70db8d014f663c Mon Sep 17 00:00:00 2001
+From: Imre Kaloz <kaloz@openwrt.org>
+Date: Fri, 31 Jul 2015 20:42:00 +0200
+Subject: ARM: mvebu: fix GPIO config on the Linksys boards
+
+From: Imre Kaloz <kaloz@openwrt.org>
+
+commit 9800917cf92f5b5fe5cae706cb70db8d014f663c upstream.
+
+Some of the GPIO configs were wrong in the submitted DTS files,
+this patch fixes all affected boards.
+
+Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
+
+---
+ arch/arm/boot/dts/armada-385-linksys.dtsi | 6 +++---
+ arch/arm/boot/dts/armada-xp-linksys-mamba.dts | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+--- a/arch/arm/boot/dts/armada-385-linksys.dtsi
++++ b/arch/arm/boot/dts/armada-385-linksys.dtsi
+@@ -245,7 +245,7 @@
+ button@2 {
+ label = "Factory Reset Button";
+ linux,code = <KEY_RESTART>;
+- gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
++ gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+@@ -260,7 +260,7 @@
+ };
+
+ sata {
+- gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
++ gpios = <&gpio1 22 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+ };
+@@ -313,7 +313,7 @@
+
+ &pinctrl {
+ keys_pin: keys-pin {
+- marvell,pins = "mpp24", "mpp47";
++ marvell,pins = "mpp24", "mpp29";
+ marvell,function = "gpio";
+ };
+
+--- a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
++++ b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
+@@ -304,13 +304,13 @@
+ button@1 {
+ label = "WPS";
+ linux,code = <KEY_WPS_BUTTON>;
+- gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
++ gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
+ };
+
+ button@2 {
+ label = "Factory Reset Button";
+ linux,code = <KEY_RESTART>;
+- gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
++ gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
+ };
+ };
+
--- /dev/null
+From bec38aaafd9ec1463dd3857f02bc029707e4213d Mon Sep 17 00:00:00 2001
+From: Priit Laes <plaes@plaes.org>
+Date: Thu, 24 Mar 2016 21:52:16 +0200
+Subject: ARM: sun4i: dt: Enable dram gate 5 (tve0 clock) for simplefb TV output
+
+From: Priit Laes <plaes@plaes.org>
+
+commit bec38aaafd9ec1463dd3857f02bc029707e4213d upstream.
+
+Seems like dram_gate 5 was forgotten when DRAM gate driver was added.
+
+Enable it.
+
+Fixes: 82f8582feef4 (ARM: dts: sun4i: Add DRAM gates)
+Signed-off-by: Priit Laes <plaes@plaes.org>
+Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/sun4i-a10.dtsi | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/arm/boot/dts/sun4i-a10.dtsi
++++ b/arch/arm/boot/dts/sun4i-a10.dtsi
+@@ -96,7 +96,7 @@
+ allwinner,pipeline = "de_fe0-de_be0-lcd0-tve0";
+ clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>,
+ <&ahb_gates 44>, <&ahb_gates 46>,
+- <&dram_gates 25>, <&dram_gates 26>;
++ <&dram_gates 5>, <&dram_gates 25>, <&dram_gates 26>;
+ status = "disabled";
+ };
+ };
--- /dev/null
+From 4b8ccef22fb547007ac38c4e5a28a773adee1e6e Mon Sep 17 00:00:00 2001
+From: Priit Laes <plaes@plaes.org>
+Date: Thu, 24 Mar 2016 21:52:17 +0200
+Subject: ARM: sun7i: dt: Enable dram gate 5 (tve0 clock) for simplefb TV output
+
+From: Priit Laes <plaes@plaes.org>
+
+commit 4b8ccef22fb547007ac38c4e5a28a773adee1e6e upstream.
+
+Seems like dram_gate 5 was forgotten when DRAM gating driver was added.
+
+Add it.
+
+Fixes: 0b4bf5a5200b (ARM: dts: sun7i: Add DRAM gates)
+Signed-off-by: Priit Laes <plaes@plaes.org>
+Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/boot/dts/sun7i-a20.dtsi | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/arch/arm/boot/dts/sun7i-a20.dtsi
++++ b/arch/arm/boot/dts/sun7i-a20.dtsi
+@@ -85,8 +85,9 @@
+ compatible = "allwinner,simple-framebuffer",
+ "simple-framebuffer";
+ allwinner,pipeline = "de_be0-lcd0-tve0";
+- clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>,
+- <&ahb_gates 44>, <&dram_gates 26>;
++ clocks = <&pll5 1>,
++ <&ahb_gates 34>, <&ahb_gates 36>, <&ahb_gates 44>,
++ <&dram_gates 5>, <&dram_gates 26>;
+ status = "disabled";
+ };
+ };
--- /dev/null
+From d3030d11961a8c103cf07aed59905276ddfc06c2 Mon Sep 17 00:00:00 2001
+From: Mark Brown <broonie@kernel.org>
+Date: Wed, 18 May 2016 18:30:39 +0100
+Subject: ASoC: ak4642: Enable cache usage to fix crashes on resume
+
+From: Mark Brown <broonie@kernel.org>
+
+commit d3030d11961a8c103cf07aed59905276ddfc06c2 upstream.
+
+The ak4642 driver is using a regmap cache sync to restore the
+configuration of the chip on resume but (as Peter observed) does not
+actually define a register cache which means that the resume is never
+going to work and we trigger asserts in regmap. Fix this by enabling
+caching.
+
+Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Reported-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/soc/codecs/ak4642.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/sound/soc/codecs/ak4642.c
++++ b/sound/soc/codecs/ak4642.c
+@@ -560,6 +560,7 @@ static const struct regmap_config ak4642
+ .max_register = FIL1_3,
+ .reg_defaults = ak4642_reg,
+ .num_reg_defaults = NUM_AK4642_REG_DEFAULTS,
++ .cache_type = REGCACHE_RBTREE,
+ };
+
+ static const struct regmap_config ak4643_regmap = {
+@@ -568,6 +569,7 @@ static const struct regmap_config ak4643
+ .max_register = SPK_MS,
+ .reg_defaults = ak4643_reg,
+ .num_reg_defaults = ARRAY_SIZE(ak4643_reg),
++ .cache_type = REGCACHE_RBTREE,
+ };
+
+ static const struct regmap_config ak4648_regmap = {
+@@ -576,6 +578,7 @@ static const struct regmap_config ak4648
+ .max_register = EQ_FBEQE,
+ .reg_defaults = ak4648_reg,
+ .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
++ .cache_type = REGCACHE_RBTREE,
+ };
+
+ static const struct ak4642_drvdata ak4642_drvdata = {
--- /dev/null
+From 9ddc486aa09a3413a6c492fcf160ce61bfccb7b1 Mon Sep 17 00:00:00 2001
+From: Anilkumar Kolli <akolli@qti.qualcomm.com>
+Date: Fri, 11 Mar 2016 11:46:39 +0530
+Subject: ath10k: fix debugfs pktlog_filter write
+
+From: Anilkumar Kolli <akolli@qti.qualcomm.com>
+
+commit 9ddc486aa09a3413a6c492fcf160ce61bfccb7b1 upstream.
+
+It is observed that, we are disabling the packet log if we write same
+value to the pktlog_filter for the second time. Always enable pktlogs
+on non zero filter.
+
+Fixes: 90174455ae05 ("ath10k: add support to configure pktlog filter")
+Signed-off-by: Anilkumar Kolli <akolli@qti.qualcomm.com>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath10k/debug.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath/ath10k/debug.c
++++ b/drivers/net/wireless/ath/ath10k/debug.c
+@@ -2011,7 +2011,12 @@ static ssize_t ath10k_write_pktlog_filte
+ goto out;
+ }
+
+- if (filter && (filter != ar->debug.pktlog_filter)) {
++ if (filter == ar->debug.pktlog_filter) {
++ ret = count;
++ goto out;
++ }
++
++ if (filter) {
+ ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
+ if (ret) {
+ ath10k_warn(ar, "failed to enable pktlog filter %x: %d\n",
--- /dev/null
+From 8a75fc54745fd3ce9062ab1cc6429a9da9ac2a68 Mon Sep 17 00:00:00 2001
+From: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+Date: Wed, 2 Mar 2016 20:13:52 +0530
+Subject: ath10k: fix firmware assert in monitor mode
+
+From: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+
+commit 8a75fc54745fd3ce9062ab1cc6429a9da9ac2a68 upstream.
+
+commit 166de3f1895d ("ath10k: remove supported chain mask") had revealed
+an issue on monitor mode. Configuring NSS upon monitor interface
+creation is causing target assert in all qca9888x and qca6174 firmware.
+Firmware assert issue can be reproduced by below sequence even after
+reverting commit 166de3f1895d ("ath10k: remove supported chain mask").
+
+ip link set wlan0 down
+iw wlan0 set type monitor
+iw phy0 set antenna 7
+ip link set wlan0 up
+
+This issue is originally reported on qca9888 with 10.1 firmware.
+
+Fixes: 5572a95b4b ("ath10k: apply chainmask settings to vdev on creation")
+Reported-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath10k/mac.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath/ath10k/mac.c
++++ b/drivers/net/wireless/ath/ath10k/mac.c
+@@ -4474,7 +4474,10 @@ static int ath10k_add_interface(struct i
+ goto err_vdev_delete;
+ }
+
+- if (ar->cfg_tx_chainmask) {
++ /* Configuring number of spatial stream for monitor interface is causing
++ * target assert in qca9888 and qca6174.
++ */
++ if (ar->cfg_tx_chainmask && (vif->type != NL80211_IFTYPE_MONITOR)) {
+ u16 nss = get_nss_from_chainmask(ar->cfg_tx_chainmask);
+
+ vdev_param = ar->wmi.vdev_param->nss;
--- /dev/null
+From 4ad24a9d83bd4bf0a85e95bf144e18d3fda4fbf1 Mon Sep 17 00:00:00 2001
+From: Anilkumar Kolli <akolli@qti.qualcomm.com>
+Date: Tue, 26 Apr 2016 21:35:48 +0530
+Subject: ath10k: fix kernel panic, move arvifs list head init before htt init
+
+From: Anilkumar Kolli <akolli@qti.qualcomm.com>
+
+commit 4ad24a9d83bd4bf0a85e95bf144e18d3fda4fbf1 upstream.
+
+It is observed that while loading and unloading ath10k modules
+in an infinite loop, before ath10k_core_start() completion HTT
+rx frames are received, while processing these frames,
+dereferencing the arvifs list code is getting hit before
+initilizing the arvifs list, causing a kernel panic.
+
+This patch initilizes the arvifs list before initilizing htt.
+
+Fixes the below issue:
+ [<bf88b058>] (ath10k_htt_rx_pktlog_completion_handler+0x278/0xd08 [ath10k_core])
+ [<bf88b058>] (ath10k_htt_rx_pktlog_completion_handler [ath10k_core])
+ [<bf88c0dc>] (ath10k_htt_txrx_compl_task+0x5f4/0xeb0 [ath10k_core])
+ [<bf88c0dc>] (ath10k_htt_txrx_compl_task [ath10k_core])
+ [<c0234100>] (tasklet_action+0x8c/0xec)
+ [<c0234100>] (tasklet_action)
+ [<c02337c0>] (__do_softirq+0xf8/0x228)
+ [<c02337c0>] (__do_softirq) [<c0233920>] (run_ksoftirqd+0x30/0x90)
+ Code: e5954ad8 e2899008 e1540009 0a00000d (e5943008)
+ ---[ end trace 71de5c2e011dbf56 ]---
+ Kernel panic - not syncing: Fatal exception in interrupt
+
+Fixes: 500ff9f9389d ("ath10k: implement chanctx API")
+Signed-off-by: Anilkumar Kolli <akolli@qti.qualcomm.com>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath10k/core.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/drivers/net/wireless/ath/ath10k/core.c
++++ b/drivers/net/wireless/ath/ath10k/core.c
+@@ -1687,6 +1687,10 @@ int ath10k_core_start(struct ath10k *ar,
+ goto err_hif_stop;
+ }
+
++ ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
++
++ INIT_LIST_HEAD(&ar->arvifs);
++
+ /* we don't care about HTT in UTF mode */
+ if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
+ status = ath10k_htt_setup(&ar->htt);
+@@ -1700,10 +1704,6 @@ int ath10k_core_start(struct ath10k *ar,
+ if (status)
+ goto err_hif_stop;
+
+- ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
+-
+- INIT_LIST_HEAD(&ar->arvifs);
+-
+ return 0;
+
+ err_hif_stop:
--- /dev/null
+From 1ce8c1484e80010a6e4b9611c65668ff77556f45 Mon Sep 17 00:00:00 2001
+From: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+Date: Thu, 7 Apr 2016 12:11:54 +0530
+Subject: ath10k: fix rx_channel during hw reconfigure
+
+From: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+
+commit 1ce8c1484e80010a6e4b9611c65668ff77556f45 upstream.
+
+Upon firmware assert, restart work will be triggered so that mac80211
+will reconfigure the driver. An issue is reported that after restart
+work, survey dump data do not contain in-use (SURVEY_INFO_IN_USE) info
+for operating channel. During reconfigure, since mac80211 already has
+valid channel context for given radio, channel context iteration return
+num_chanctx > 0. Hence rx_channel is always NULL. Fix this by assigning
+channel context to rx_channel when driver restart is in progress.
+
+Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath10k/mac.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath/ath10k/mac.c
++++ b/drivers/net/wireless/ath/ath10k/mac.c
+@@ -6437,7 +6437,13 @@ ath10k_mac_update_rx_channel(struct ath1
+ def = &vifs[0].new_ctx->def;
+
+ ar->rx_channel = def->chan;
+- } else if (ctx && ath10k_mac_num_chanctxs(ar) == 0) {
++ } else if ((ctx && ath10k_mac_num_chanctxs(ar) == 0) ||
++ (ctx && (ar->state == ATH10K_STATE_RESTARTED))) {
++ /* During driver restart due to firmware assert, since mac80211
++ * already has valid channel context for given radio, channel
++ * context iteration return num_chanctx > 0. So fix rx_channel
++ * when restart is in progress.
++ */
+ ar->rx_channel = ctx->def.chan;
+ } else {
+ ar->rx_channel = NULL;
--- /dev/null
+From 7b9bc799a445aea95f64f15e0083cb19b5789abe Mon Sep 17 00:00:00 2001
+From: Joseph Salisbury <joseph.salisbury@canonical.com>
+Date: Mon, 14 Mar 2016 14:51:48 -0400
+Subject: ath5k: Change led pin configuration for compaq c700 laptop
+
+From: Joseph Salisbury <joseph.salisbury@canonical.com>
+
+commit 7b9bc799a445aea95f64f15e0083cb19b5789abe upstream.
+
+BugLink: http://bugs.launchpad.net/bugs/972604
+
+Commit 09c9bae26b0d3c9472cb6ae45010460a2cee8b8d ("ath5k: add led pin
+configuration for compaq c700 laptop") added a pin configuration for the Compaq
+c700 laptop. However, the polarity of the led pin is reversed. It should be
+red for wifi off and blue for wifi on, but it is the opposite. This bug was
+reported in the following bug report:
+http://pad.lv/972604
+
+Fixes: 09c9bae26b0d3c9472cb6ae45010460a2cee8b8d ("ath5k: add led pin configuration for compaq c700 laptop")
+Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath5k/led.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath/ath5k/led.c
++++ b/drivers/net/wireless/ath/ath5k/led.c
+@@ -77,7 +77,7 @@ static const struct pci_device_id ath5k_
+ /* HP Compaq CQ60-206US (ddreggors@jumptv.com) */
+ { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137a), ATH_LED(3, 1) },
+ /* HP Compaq C700 (nitrousnrg@gmail.com) */
+- { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
++ { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 0) },
+ /* LiteOn AR5BXB63 (magooz@salug.it) */
+ { ATH_SDEVICE(PCI_VENDOR_ID_ATHEROS, 0x3067), ATH_LED(3, 0) },
+ /* IBM-specific AR5212 (all others) */
--- /dev/null
+From cd84042ce9040ad038e958bc67a46fcfc015c736 Mon Sep 17 00:00:00 2001
+From: "Vittorio Gambaletta (VittGam)" <linux-wireless@vittgam.net>
+Date: Mon, 11 Apr 2016 04:48:54 +0200
+Subject: ath9k: Add a module parameter to invert LED polarity.
+
+From: Vittorio Gambaletta (VittGam) <linux-wireless@vittgam.net>
+
+commit cd84042ce9040ad038e958bc67a46fcfc015c736 upstream.
+
+The LED can be active high instead of active low on some hardware.
+
+Add the led_active_high module parameter. It defaults to -1 to obey
+platform data as before.
+
+Setting the parameter to 1 or 0 will force the LED respectively
+active high or active low.
+
+Cc: <linux-wireless@vger.kernel.org>
+Cc: <ath9k-devel@qca.qualcomm.com>
+Cc: <ath9k-devel@lists.ath9k.org>
+Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath9k/init.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -49,6 +49,10 @@ int ath9k_led_blink;
+ module_param_named(blink, ath9k_led_blink, int, 0444);
+ MODULE_PARM_DESC(blink, "Enable LED blink on activity");
+
++static int ath9k_led_active_high = -1;
++module_param_named(led_active_high, ath9k_led_active_high, int, 0444);
++MODULE_PARM_DESC(led_active_high, "Invert LED polarity");
++
+ static int ath9k_btcoex_enable;
+ module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444);
+ MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
+@@ -600,6 +604,9 @@ static int ath9k_init_softc(u16 devid, s
+ if (ret)
+ return ret;
+
++ if (ath9k_led_active_high != -1)
++ ah->config.led_active_high = ath9k_led_active_high == 1;
++
+ /*
+ * Enable WLAN/BT RX Antenna diversity only when:
+ *
--- /dev/null
+From 0f9edcdd88a993914fa1d1dc369b35dc503979db Mon Sep 17 00:00:00 2001
+From: "Vittorio Gambaletta (VittGam)" <linux-wireless@vittgam.net>
+Date: Mon, 11 Apr 2016 04:48:55 +0200
+Subject: ath9k: Fix LED polarity for some Mini PCI AR9220 MB92 cards.
+
+From: Vittorio Gambaletta (VittGam) <linux-wireless@vittgam.net>
+
+commit 0f9edcdd88a993914fa1d1dc369b35dc503979db upstream.
+
+The Wistron DNMA-92 and Compex WLM200NX have inverted LED polarity
+(active high instead of active low).
+
+The same PCI Subsystem ID is used by both cards, which are based on
+the same Atheros MB92 design.
+
+Cc: <linux-wireless@vger.kernel.org>
+Cc: <ath9k-devel@qca.qualcomm.com>
+Cc: <ath9k-devel@lists.ath9k.org>
+Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
+Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/ath/ath9k/pci.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/net/wireless/ath/ath9k/pci.c
++++ b/drivers/net/wireless/ath/ath9k/pci.c
+@@ -28,6 +28,16 @@ static const struct pci_device_id ath_pc
+ { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
+ { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
+ { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
++
++#ifdef CONFIG_ATH9K_PCOEM
++ /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
++ { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
++ 0x0029,
++ PCI_VENDOR_ID_ATHEROS,
++ 0x2096),
++ .driver_data = ATH9K_PCI_LED_ACT_HI },
++#endif
++
+ { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
+
+ #ifdef CONFIG_ATH9K_PCOEM
--- /dev/null
+From cb0ceaf77d93964a0d00477c79f4499123f6159c Mon Sep 17 00:00:00 2001
+From: Vladimir Zapolskiy <vz@mleia.com>
+Date: Tue, 8 Mar 2016 01:41:29 +0200
+Subject: clk: at91: fix check of clk_register() returned value
+
+From: Vladimir Zapolskiy <vz@mleia.com>
+
+commit cb0ceaf77d93964a0d00477c79f4499123f6159c upstream.
+
+The clk_register() function returns a valid pointer to struct clk or
+ERR_PTR() error code, this makes a check for returned NULL value
+useless and may lead to oops on error path.
+
+Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
+Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
+Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Fixes: bcc5fd49a0fd ("clk: at91: add a driver for the h32mx clock")
+Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/clk/at91/clk-h32mx.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/clk/at91/clk-h32mx.c
++++ b/drivers/clk/at91/clk-h32mx.c
+@@ -116,7 +116,7 @@ void __init of_sama5d4_clk_h32mx_setup(s
+ h32mxclk->pmc = pmc;
+
+ clk = clk_register(NULL, &h32mxclk->hw);
+- if (!clk) {
++ if (IS_ERR(clk)) {
+ kfree(h32mxclk);
+ return;
+ }
--- /dev/null
+From 959ca92a3235fc4b17c1e18483fc390b3d612254 Mon Sep 17 00:00:00 2001
+From: Martin Sperl <kernel@martin.sperl.org>
+Date: Mon, 29 Feb 2016 11:39:21 +0000
+Subject: clk: bcm2835: correctly enable fractional clock support
+
+From: Martin Sperl <kernel@martin.sperl.org>
+
+commit 959ca92a3235fc4b17c1e18483fc390b3d612254 upstream.
+
+The current driver calculates the clock divider with
+fractional support enabled.
+
+But it does not enable fractional support in the
+control register itself resulting in an integer only divider,
+but in clk_set_rate responds back the fractionally divided
+clock frequency.
+
+This patch enables fractional support in the control register
+whenever there is a fractional bit set in the requested clock divider.
+
+Mash clock limits are are also handled for the PWM clock
+applying the correct divider limits (2 and max_int) applicable to
+basic fractional divider support (mash order of 1).
+
+It also adds locking to protect the read/modify/write cycle of
+the register modification.
+
+Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the
+audio domain clocks")
+
+Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
+Signed-off-by: Eric Anholt <eric@anholt.net>
+Reviewed-by: Eric Anholt <eric@anholt.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/clk/bcm/clk-bcm2835.c | 45 ++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 39 insertions(+), 6 deletions(-)
+
+--- a/drivers/clk/bcm/clk-bcm2835.c
++++ b/drivers/clk/bcm/clk-bcm2835.c
+@@ -51,6 +51,7 @@
+ #define CM_GNRICCTL 0x000
+ #define CM_GNRICDIV 0x004
+ # define CM_DIV_FRAC_BITS 12
++# define CM_DIV_FRAC_MASK GENMASK(CM_DIV_FRAC_BITS - 1, 0)
+
+ #define CM_VPUCTL 0x008
+ #define CM_VPUDIV 0x00c
+@@ -115,6 +116,7 @@
+ # define CM_GATE BIT(CM_GATE_BIT)
+ # define CM_BUSY BIT(7)
+ # define CM_BUSYD BIT(8)
++# define CM_FRAC BIT(9)
+ # define CM_SRC_SHIFT 0
+ # define CM_SRC_BITS 4
+ # define CM_SRC_MASK 0xf
+@@ -634,6 +636,7 @@ struct bcm2835_clock_data {
+ u32 frac_bits;
+
+ bool is_vpu_clock;
++ bool is_mash_clock;
+ };
+
+ static const char *const bcm2835_clock_per_parents[] = {
+@@ -815,6 +818,7 @@ static const struct bcm2835_clock_data b
+ .div_reg = CM_PWMDIV,
+ .int_bits = 12,
+ .frac_bits = 12,
++ .is_mash_clock = true,
+ };
+
+ struct bcm2835_pll {
+@@ -1183,7 +1187,7 @@ static u32 bcm2835_clock_choose_div(stru
+ GENMASK(CM_DIV_FRAC_BITS - data->frac_bits, 0) >> 1;
+ u64 temp = (u64)parent_rate << CM_DIV_FRAC_BITS;
+ u64 rem;
+- u32 div;
++ u32 div, mindiv, maxdiv;
+
+ rem = do_div(temp, rate);
+ div = temp;
+@@ -1193,11 +1197,23 @@ static u32 bcm2835_clock_choose_div(stru
+ div += unused_frac_mask + 1;
+ div &= ~unused_frac_mask;
+
+- /* clamp to min divider of 1 */
+- div = max_t(u32, div, 1 << CM_DIV_FRAC_BITS);
+- /* clamp to the highest possible fractional divider */
+- div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
+- CM_DIV_FRAC_BITS - data->frac_bits));
++ /* different clamping limits apply for a mash clock */
++ if (data->is_mash_clock) {
++ /* clamp to min divider of 2 */
++ mindiv = 2 << CM_DIV_FRAC_BITS;
++ /* clamp to the highest possible integer divider */
++ maxdiv = (BIT(data->int_bits) - 1) << CM_DIV_FRAC_BITS;
++ } else {
++ /* clamp to min divider of 1 */
++ mindiv = 1 << CM_DIV_FRAC_BITS;
++ /* clamp to the highest possible fractional divider */
++ maxdiv = GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
++ CM_DIV_FRAC_BITS - data->frac_bits);
++ }
++
++ /* apply the clamping limits */
++ div = max_t(u32, div, mindiv);
++ div = min_t(u32, div, maxdiv);
+
+ return div;
+ }
+@@ -1291,9 +1307,26 @@ static int bcm2835_clock_set_rate(struct
+ struct bcm2835_cprman *cprman = clock->cprman;
+ const struct bcm2835_clock_data *data = clock->data;
+ u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate, false);
++ u32 ctl;
++
++ spin_lock(&cprman->regs_lock);
++
++ /*
++ * Setting up frac support
++ *
++ * In principle it is recommended to stop/start the clock first,
++ * but as we set CLK_SET_RATE_GATE during registration of the
++ * clock this requirement should be take care of by the
++ * clk-framework.
++ */
++ ctl = cprman_read(cprman, data->ctl_reg) & ~CM_FRAC;
++ ctl |= (div & CM_DIV_FRAC_MASK) ? CM_FRAC : 0;
++ cprman_write(cprman, data->ctl_reg, ctl);
+
+ cprman_write(cprman, data->div_reg, div);
+
++ spin_unlock(&cprman->regs_lock);
++
+ return 0;
+ }
+
--- /dev/null
+From 997f16bd5d2e9b3456027f96fcadfe1e2bf12f4e Mon Sep 17 00:00:00 2001
+From: Martin Sperl <kernel@martin.sperl.org>
+Date: Mon, 29 Feb 2016 11:39:20 +0000
+Subject: clk: bcm2835: divider value has to be 1 or more
+
+From: Martin Sperl <kernel@martin.sperl.org>
+
+commit 997f16bd5d2e9b3456027f96fcadfe1e2bf12f4e upstream.
+
+Current clamping of a normal divider allows a value < 1 to be valid.
+
+A divider of < 1 would actually only be possible if we had a PLL...
+
+So this patch clamps the divider to 1.
+
+Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the
+audio domain clocks")
+
+Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
+Signed-off-by: Eric Anholt <eric@anholt.net>
+Reviewed-by: Eric Anholt <eric@anholt.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/clk/bcm/clk-bcm2835.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/drivers/clk/bcm/clk-bcm2835.c
++++ b/drivers/clk/bcm/clk-bcm2835.c
+@@ -1193,8 +1193,9 @@ static u32 bcm2835_clock_choose_div(stru
+ div += unused_frac_mask + 1;
+ div &= ~unused_frac_mask;
+
+- /* Clamp to the limits. */
+- div = max(div, unused_frac_mask + 1);
++ /* clamp to min divider of 1 */
++ div = max_t(u32, div, 1 << CM_DIV_FRAC_BITS);
++ /* clamp to the highest possible fractional divider */
+ div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
+ CM_DIV_FRAC_BITS - data->frac_bits));
+
--- /dev/null
+From e708b383f4b94feca2e0d5d06e1cfc13cdfea100 Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Wed, 13 Apr 2016 13:05:03 -0700
+Subject: clk: bcm2835: Fix PLL poweron
+
+From: Eric Anholt <eric@anholt.net>
+
+commit e708b383f4b94feca2e0d5d06e1cfc13cdfea100 upstream.
+
+In poweroff, we set the reset bit and the power down bit, but only
+managed to unset the reset bit for poweron. This meant that if HDMI
+did -EPROBE_DEFER after it had grabbed its clocks, we'd power down the
+PLLH (that had been on at boot time) and never recover.
+
+Signed-off-by: Eric Anholt <eric@anholt.net>
+Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the audio domain clocks")
+Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/clk/bcm/clk-bcm2835.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/clk/bcm/clk-bcm2835.c
++++ b/drivers/clk/bcm/clk-bcm2835.c
+@@ -911,6 +911,10 @@ static int bcm2835_pll_on(struct clk_hw
+ const struct bcm2835_pll_data *data = pll->data;
+ ktime_t timeout;
+
++ cprman_write(cprman, data->a2w_ctrl_reg,
++ cprman_read(cprman, data->a2w_ctrl_reg) &
++ ~A2W_PLL_CTRL_PWRDN);
++
+ /* Take the PLL out of reset. */
+ cprman_write(cprman, data->cm_ctrl_reg,
+ cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
--- /dev/null
+From 6727f086cfe4ddcc651eb2bf4301abfcf619be06 Mon Sep 17 00:00:00 2001
+From: Martin Sperl <kernel@martin.sperl.org>
+Date: Mon, 29 Feb 2016 11:39:17 +0000
+Subject: clk: bcm2835: pll_off should only update CM_PLL_ANARST
+
+From: Martin Sperl <kernel@martin.sperl.org>
+
+commit 6727f086cfe4ddcc651eb2bf4301abfcf619be06 upstream.
+
+bcm2835_pll_off is currently assigning CM_PLL_ANARST to the control
+register, which may lose the other bits that are currently set by the
+clock dividers.
+
+It also now locks during the read/modify/write cycle of both
+registers.
+
+Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the
+audio domain clocks")
+
+Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
+Signed-off-by: Eric Anholt <eric@anholt.net>
+Reviewed-by: Eric Anholt <eric@anholt.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/clk/bcm/clk-bcm2835.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/drivers/clk/bcm/clk-bcm2835.c
++++ b/drivers/clk/bcm/clk-bcm2835.c
+@@ -900,8 +900,14 @@ static void bcm2835_pll_off(struct clk_h
+ struct bcm2835_cprman *cprman = pll->cprman;
+ const struct bcm2835_pll_data *data = pll->data;
+
+- cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST);
+- cprman_write(cprman, data->a2w_ctrl_reg, A2W_PLL_CTRL_PWRDN);
++ spin_lock(&cprman->regs_lock);
++ cprman_write(cprman, data->cm_ctrl_reg,
++ cprman_read(cprman, data->cm_ctrl_reg) |
++ CM_PLL_ANARST);
++ cprman_write(cprman, data->a2w_ctrl_reg,
++ cprman_read(cprman, data->a2w_ctrl_reg) |
++ A2W_PLL_CTRL_PWRDN);
++ spin_unlock(&cprman->regs_lock);
+ }
+
+ static int bcm2835_pll_on(struct clk_hw *hw)
--- /dev/null
+From e7387da52028b072489c45efeb7a916c0205ebd2 Mon Sep 17 00:00:00 2001
+From: Daniel Lezcano <daniel.lezcano@linaro.org>
+Date: Tue, 17 May 2016 16:54:00 +0200
+Subject: cpuidle: Fix cpuidle_state_is_coupled() argument in cpuidle_enter()
+
+From: Daniel Lezcano <daniel.lezcano@linaro.org>
+
+commit e7387da52028b072489c45efeb7a916c0205ebd2 upstream.
+
+Commit 0b89e9aa2856 (cpuidle: delay enabling interrupts until all
+coupled CPUs leave idle) rightfully fixed a regression by letting
+the coupled idle state framework to handle local interrupt enabling
+when the CPU is exiting an idle state.
+
+The current code checks if the idle state is coupled and, if so, it
+will let the coupled code to enable interrupts. This way, it can
+decrement the ready-count before handling the interrupt. This
+mechanism prevents the other CPUs from waiting for a CPU which is
+handling interrupts.
+
+But the check is done against the state index returned by the back
+end driver's ->enter functions which could be different from the
+initial index passed as parameter to the cpuidle_enter_state()
+function.
+
+ entered_state = target_state->enter(dev, drv, index);
+
+ [ ... ]
+
+ if (!cpuidle_state_is_coupled(drv, entered_state))
+ local_irq_enable();
+
+ [ ... ]
+
+If the 'index' is referring to a coupled idle state but the
+'entered_state' is *not* coupled, then the interrupts are enabled
+again. All CPUs blocked on the sync barrier may busy loop longer
+if the CPU has interrupts to handle before decrementing the
+ready-count. That's consuming more energy than saving.
+
+Fixes: 0b89e9aa2856 (cpuidle: delay enabling interrupts until all coupled CPUs leave idle)
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+[ rjw: Subject & changelog ]
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/cpuidle/cpuidle.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/cpuidle/cpuidle.c
++++ b/drivers/cpuidle/cpuidle.c
+@@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_d
+ tick_broadcast_exit();
+ }
+
+- if (!cpuidle_state_is_coupled(drv, entered_state))
++ if (!cpuidle_state_is_coupled(drv, index))
+ local_irq_enable();
+
+ diff = ktime_to_us(ktime_sub(time_end, time_start));
--- /dev/null
+From c998c07836f985b24361629dc98506ec7893e7a0 Mon Sep 17 00:00:00 2001
+From: Dave Gerlach <d-gerlach@ti.com>
+Date: Tue, 5 Apr 2016 14:05:38 -0500
+Subject: cpuidle: Indicate when a device has been unregistered
+
+From: Dave Gerlach <d-gerlach@ti.com>
+
+commit c998c07836f985b24361629dc98506ec7893e7a0 upstream.
+
+Currently the 'registered' member of the cpuidle_device struct is set
+to 1 during cpuidle_register_device. In this same function there are
+checks to see if the device is already registered to prevent duplicate
+calls to register the device, but this value is never set to 0 even on
+unregister of the device. Because of this, any attempt to call
+cpuidle_register_device after a call to cpuidle_unregister_device will
+fail which shouldn't be the case.
+
+To prevent this, set registered to 0 when the device is unregistered.
+
+Fixes: c878a52d3c7c (cpuidle: Check if device is already registered)
+Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
+Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/cpuidle/cpuidle.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/cpuidle/cpuidle.c
++++ b/drivers/cpuidle/cpuidle.c
+@@ -433,6 +433,8 @@ static void __cpuidle_unregister_device(
+ list_del(&dev->device_list);
+ per_cpu(cpuidle_devices, dev->cpu) = NULL;
+ module_put(drv->owner);
++
++ dev->registered = 0;
+ }
+
+ static void __cpuidle_device_init(struct cpuidle_device *dev)
--- /dev/null
+From 7a18afe8097731b8ffb6cb5b2b3b418ded77c105 Mon Sep 17 00:00:00 2001
+From: Akshay Bhat <akshay.bhat@timesys.com>
+Date: Mon, 18 Apr 2016 15:47:53 -0400
+Subject: hwmon: (ads7828) Enable internal reference
+
+From: Akshay Bhat <akshay.bhat@timesys.com>
+
+commit 7a18afe8097731b8ffb6cb5b2b3b418ded77c105 upstream.
+
+On ads7828 the internal reference defaults to off upon power up. When
+using internal reference, it needs to be turned on and the voltage needs
+to settle before normal conversion cycle can be started. Hence perform a
+dummy read in the probe to enable the internal reference allowing the
+voltage to settle before performing a normal read.
+
+Without this fix, the first read from the ADC when using internal
+reference always returns incorrect data.
+
+Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hwmon/ads7828.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/hwmon/ads7828.c
++++ b/drivers/hwmon/ads7828.c
+@@ -120,6 +120,7 @@ static int ads7828_probe(struct i2c_clie
+ unsigned int vref_mv = ADS7828_INT_VREF_MV;
+ bool diff_input = false;
+ bool ext_vref = false;
++ unsigned int regval;
+
+ data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
+ if (!data)
+@@ -154,6 +155,15 @@ static int ads7828_probe(struct i2c_clie
+ if (!diff_input)
+ data->cmd_byte |= ADS7828_CMD_SD_SE;
+
++ /*
++ * Datasheet specifies internal reference voltage is disabled by
++ * default. The internal reference voltage needs to be enabled and
++ * voltage needs to settle before getting valid ADC data. So perform a
++ * dummy read to enable the internal reference voltage.
++ */
++ if (!ext_vref)
++ regmap_read(data->regmap, data->cmd_byte, ®val);
++
+ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
+ data,
+ ads7828_groups);
--- /dev/null
+From f1925d78d7b710a1179828d53e918295f5f5d222 Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
+Date: Mon, 14 Mar 2016 09:07:13 +0900
+Subject: hwrng: exynos - Fix unbalanced PM runtime put on timeout error path
+
+From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
+
+commit f1925d78d7b710a1179828d53e918295f5f5d222 upstream.
+
+In case of timeout during read operation, the exit path lacked PM
+runtime put. This could lead to unbalanced runtime PM usage counter thus
+leaving the device in an active state.
+
+Fixes: d7fd6075a205 ("hwrng: exynos - Add timeout for waiting on init done")
+Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/char/hw_random/exynos-rng.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+--- a/drivers/char/hw_random/exynos-rng.c
++++ b/drivers/char/hw_random/exynos-rng.c
+@@ -89,6 +89,7 @@ static int exynos_read(struct hwrng *rng
+ struct exynos_rng, rng);
+ u32 *data = buf;
+ int retry = 100;
++ int ret = 4;
+
+ pm_runtime_get_sync(exynos_rng->dev);
+
+@@ -97,17 +98,20 @@ static int exynos_read(struct hwrng *rng
+ while (!(exynos_rng_readl(exynos_rng,
+ EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry)
+ cpu_relax();
+- if (!retry)
+- return -ETIMEDOUT;
++ if (!retry) {
++ ret = -ETIMEDOUT;
++ goto out;
++ }
+
+ exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET);
+
+ *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET);
+
++out:
+ pm_runtime_mark_last_busy(exynos_rng->dev);
+ pm_runtime_put_sync_autosuspend(exynos_rng->dev);
+
+- return 4;
++ return ret;
+ }
+
+ static int exynos_rng_probe(struct platform_device *pdev)
--- /dev/null
+From affa80bd97f7ca282d1faa91667b3ee9e4c590e6 Mon Sep 17 00:00:00 2001
+From: Ricky Liang <jcliang@chromium.org>
+Date: Fri, 20 May 2016 10:58:59 -0700
+Subject: Input: uinput - handle compat ioctl for UI_SET_PHYS
+
+From: Ricky Liang <jcliang@chromium.org>
+
+commit affa80bd97f7ca282d1faa91667b3ee9e4c590e6 upstream.
+
+When running a 32-bit userspace on a 64-bit kernel, the UI_SET_PHYS
+ioctl needs to be treated with special care, as it has the pointer
+size encoded in the command.
+
+Signed-off-by: Ricky Liang <jcliang@chromium.org>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/misc/uinput.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/input/misc/uinput.c
++++ b/drivers/input/misc/uinput.c
+@@ -981,9 +981,15 @@ static long uinput_ioctl(struct file *fi
+ }
+
+ #ifdef CONFIG_COMPAT
++
++#define UI_SET_PHYS_COMPAT _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t)
++
+ static long uinput_compat_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
+ {
++ if (cmd == UI_SET_PHYS_COMPAT)
++ cmd = UI_SET_PHYS;
++
+ return uinput_ioctl_handler(file, cmd, arg, compat_ptr(arg));
+ }
+ #endif
--- /dev/null
+From 4efc6939a83c54fb3417541be48991afd0290ba3 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Fri, 27 May 2016 16:22:25 -0700
+Subject: Input: xpad - move pending clear to the correct location
+
+From: Pavel Rojtberg <rojtberg@gmail.com>
+
+commit 4efc6939a83c54fb3417541be48991afd0290ba3 upstream.
+
+otherwise we lose ff commands: https://github.com/paroj/xpad/issues/27
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -754,6 +754,7 @@ static bool xpad_prepare_next_out_packet
+ if (packet) {
+ memcpy(xpad->odata, packet->data, packet->len);
+ xpad->irq_out->transfer_buffer_length = packet->len;
++ packet->pending = false;
+ return true;
+ }
+
+@@ -795,7 +796,6 @@ static void xpad_irq_out(struct urb *urb
+ switch (status) {
+ case 0:
+ /* success */
+- xpad->out_packets[xpad->last_out_packet].pending = false;
+ xpad->irq_out_active = xpad_prepare_next_out_packet(xpad);
+ break;
+
--- /dev/null
+From 1ff5fa3c6732f08e01ae12f12286d4728c9e4d86 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Fri, 27 May 2016 16:23:50 -0700
+Subject: Input: xpad - prevent spurious input from wired Xbox 360 controllers
+
+From: Cameron Gutman <aicommander@gmail.com>
+
+commit 1ff5fa3c6732f08e01ae12f12286d4728c9e4d86 upstream.
+
+After initially connecting a wired Xbox 360 controller or sending it
+a command to change LEDs, a status/response packet is interpreted as
+controller input. This causes the state of buttons represented in
+byte 2 of the controller data packet to be incorrect until the next
+valid input packet. Wireless Xbox 360 controllers are not affected.
+
+Writing a new value to the LED device while holding the Start button
+and running jstest is sufficient to reproduce this bug. An event will
+come through with the Start button released.
+
+Xboxdrv also won't attempt to read controller input from a packet
+where byte 0 is non-zero. It also checks that byte 1 is 0x14, but
+that value differs between wired and wireless controllers and this
+code is shared by both. I think just checking byte 0 is enough to
+eliminate unwanted packets.
+
+The following are some examples of 3-byte status packets I saw:
+01 03 02
+02 03 00
+03 03 03
+08 03 00
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/joystick/xpad.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -455,6 +455,10 @@ static void xpad_process_packet(struct u
+ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
+ u16 cmd, unsigned char *data)
+ {
++ /* valid pad data */
++ if (data[0] != 0x00)
++ return;
++
+ /* digital pad */
+ if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
+ /* dpad as buttons (left, right, up, down) */
--- /dev/null
+From baf43c6eace43868e490f18560287fa3481b2159 Mon Sep 17 00:00:00 2001
+From: Tiffany Lin <tiffany.lin@mediatek.com>
+Date: Mon, 14 Mar 2016 08:16:14 -0300
+Subject: [media] media: v4l2-compat-ioctl32: fix missing reserved field copy in put_v4l2_create32
+
+From: Tiffany Lin <tiffany.lin@mediatek.com>
+
+commit baf43c6eace43868e490f18560287fa3481b2159 upstream.
+
+In v4l2-compliance utility, test VIDIOC_CREATE_BUFS will check whether reserved
+filed of v4l2_create_buffers filled with zero
+Reserved field is filled with zero in v4l_create_bufs.
+This patch copy reserved field of v4l2_create_buffer from kernel space to user
+space
+
+Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com>
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+@@ -280,7 +280,8 @@ static int put_v4l2_format32(struct v4l2
+ static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
+ {
+ if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) ||
+- copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)))
++ copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)) ||
++ copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
+ return -EFAULT;
+ return __put_v4l2_format32(&kp->format, &up->format);
+ }
--- /dev/null
+From 41a3da2b8e1639d983192e3650670df4ecc94cf7 Mon Sep 17 00:00:00 2001
+From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Date: Mon, 18 Apr 2016 15:14:56 +0300
+Subject: mfd: intel-lpss: Save register context on suspend
+
+From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+
+commit 41a3da2b8e1639d983192e3650670df4ecc94cf7 upstream.
+
+All configurations are lost and the registers will have
+default values when the hardware is suspended and resumed,
+so saving the private register space context on suspend, and
+restoring it on resume.
+
+Fixes: 4b45efe85263 (mfd: Add support for Intel Sunrisepoint LPSS devices)
+Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Signed-off-by: Lee Jones <lee.jones@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mfd/intel-lpss.c | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+--- a/drivers/mfd/intel-lpss.c
++++ b/drivers/mfd/intel-lpss.c
+@@ -34,6 +34,7 @@
+ #define LPSS_DEV_SIZE 0x200
+ #define LPSS_PRIV_OFFSET 0x200
+ #define LPSS_PRIV_SIZE 0x100
++#define LPSS_PRIV_REG_COUNT (LPSS_PRIV_SIZE / 4)
+ #define LPSS_IDMA64_OFFSET 0x800
+ #define LPSS_IDMA64_SIZE 0x800
+
+@@ -76,6 +77,7 @@ struct intel_lpss {
+ struct mfd_cell *cell;
+ struct device *dev;
+ void __iomem *priv;
++ u32 priv_ctx[LPSS_PRIV_REG_COUNT];
+ int devid;
+ u32 caps;
+ u32 active_ltr;
+@@ -493,6 +495,16 @@ EXPORT_SYMBOL_GPL(intel_lpss_prepare);
+
+ int intel_lpss_suspend(struct device *dev)
+ {
++ struct intel_lpss *lpss = dev_get_drvdata(dev);
++ unsigned int i;
++
++ /* Save device context */
++ for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
++ lpss->priv_ctx[i] = readl(lpss->priv + i * 4);
++
++ /* Put the device into reset state */
++ writel(0, lpss->priv + LPSS_PRIV_RESETS);
++
+ return 0;
+ }
+ EXPORT_SYMBOL_GPL(intel_lpss_suspend);
+@@ -500,8 +512,13 @@ EXPORT_SYMBOL_GPL(intel_lpss_suspend);
+ int intel_lpss_resume(struct device *dev)
+ {
+ struct intel_lpss *lpss = dev_get_drvdata(dev);
++ unsigned int i;
+
+- intel_lpss_init_dev(lpss);
++ intel_lpss_deassert_reset(lpss);
++
++ /* Restore device context */
++ for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
++ writel(lpss->priv_ctx[i], lpss->priv + i * 4);
+
+ return 0;
+ }
--- /dev/null
+From 36e6d081cfb2cb64e6d8e5121cffb1e62f894d36 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
+Date: Fri, 22 Apr 2016 22:38:55 +0300
+Subject: mfd: intel_soc_pmic_core: Terminate panel control GPIO lookup table correctly
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Ville Syrjälä <ville.syrjala@linux.intel.com>
+
+commit 36e6d081cfb2cb64e6d8e5121cffb1e62f894d36 upstream.
+
+GPIO lookup tables are supposed to be zero terminated. Let's do that
+and avoid accidentally walking off the end.
+
+Fixes: 61dd2ca2d44e ("mfd: intel_soc_pmic_core: Add lookup table for Panel Control as GPIO signal")
+Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
+Acked-by: Linus Walleij <linus.walleij@linaro.org>
+Acked-by: Daniel Vetter <daniel@ffwll.ch>
+Signed-off-by: Lee Jones <lee.jones@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mfd/intel_soc_pmic_core.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/mfd/intel_soc_pmic_core.c
++++ b/drivers/mfd/intel_soc_pmic_core.c
+@@ -35,6 +35,7 @@ static struct gpiod_lookup_table panel_g
+ .table = {
+ /* Panel EN/DISABLE */
+ GPIO_LOOKUP("gpio_crystalcove", 94, "panel", GPIO_ACTIVE_HIGH),
++ { },
+ },
+ };
+
--- /dev/null
+From ad67b437f187ea818b2860524d10f878fadfdd99 Mon Sep 17 00:00:00 2001
+From: Prarit Bhargava <prarit@redhat.com>
+Date: Wed, 11 May 2016 12:27:16 -0400
+Subject: PCI: Disable all BAR sizing for devices with non-compliant BARs
+
+From: Prarit Bhargava <prarit@redhat.com>
+
+commit ad67b437f187ea818b2860524d10f878fadfdd99 upstream.
+
+b84106b4e229 ("PCI: Disable IO/MEM decoding for devices with non-compliant
+BARs") disabled BAR sizing for BARs 0-5 of devices that don't comply with
+the PCI spec. But it didn't do anything for expansion ROM BARs, so we
+still try to size them, resulting in warnings like this on Broadwell-EP:
+
+ pci 0000:ff:12.0: BAR 6: failed to assign [mem size 0x00000001 pref]
+
+Move the non-compliant BAR check from __pci_read_base() up to
+pci_read_bases() so it applies to the expansion ROM BAR as well as
+to BARs 0-5.
+
+Note that direct callers of __pci_read_base(), like sriov_init(), will now
+bypass this check. We haven't had reports of devices with broken SR-IOV
+BARs yet.
+
+[bhelgaas: changelog]
+Fixes: b84106b4e229 ("PCI: Disable IO/MEM decoding for devices with non-compliant BARs")
+Signed-off-by: Prarit Bhargava <prarit@redhat.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+CC: Thomas Gleixner <tglx@linutronix.de>
+CC: Ingo Molnar <mingo@redhat.com>
+CC: "H. Peter Anvin" <hpa@zytor.com>
+CC: Andi Kleen <ak@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/probe.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/pci/probe.c
++++ b/drivers/pci/probe.c
+@@ -179,9 +179,6 @@ int __pci_read_base(struct pci_dev *dev,
+ u16 orig_cmd;
+ struct pci_bus_region region, inverted_region;
+
+- if (dev->non_compliant_bars)
+- return 0;
+-
+ mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
+
+ /* No printks while decoding is disabled! */
+@@ -322,6 +319,9 @@ static void pci_read_bases(struct pci_de
+ {
+ unsigned int pos, reg;
+
++ if (dev->non_compliant_bars)
++ return;
++
+ for (pos = 0; pos < howmany; pos++) {
+ struct resource *res = &dev->resource[pos];
+ reg = PCI_BASE_ADDRESS_0 + (pos << 2);
--- /dev/null
+From 71324fdc72ef0163e57631aa814a9a81e9e4770b Mon Sep 17 00:00:00 2001
+From: Andrew Jeffery <andrew@aj.id.au>
+Date: Wed, 20 Apr 2016 11:24:17 +0930
+Subject: pinctrl: exynos5440: Use off-stack memory for pinctrl_gpio_range
+
+From: Andrew Jeffery <andrew@aj.id.au>
+
+commit 71324fdc72ef0163e57631aa814a9a81e9e4770b upstream.
+
+The range is registered into a linked list which can be referenced
+throughout the lifetime of the driver. Ensure the range's memory is useful
+for the same lifetime by adding it to the driver's private data structure.
+
+The bug was introduced in the driver's initial commit, which was present in
+v3.10.
+
+Fixes: f0b9a7e521fa ("pinctrl: exynos5440: add pinctrl driver for Samsung EXYNOS5440 SoC")
+Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
+Acked-by: Tomasz Figa <tomasz.figa@gmail.com>
+Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pinctrl/samsung/pinctrl-exynos5440.c | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+--- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c
++++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c
+@@ -107,6 +107,7 @@ struct exynos5440_pmx_func {
+ * @nr_groups: number of pin groups available.
+ * @pmx_functions: list of pin functions parsed from device tree.
+ * @nr_functions: number of pin functions available.
++ * @range: gpio range to register with pinctrl
+ */
+ struct exynos5440_pinctrl_priv_data {
+ void __iomem *reg_base;
+@@ -117,6 +118,7 @@ struct exynos5440_pinctrl_priv_data {
+ unsigned int nr_groups;
+ const struct exynos5440_pmx_func *pmx_functions;
+ unsigned int nr_functions;
++ struct pinctrl_gpio_range range;
+ };
+
+ /**
+@@ -742,7 +744,6 @@ static int exynos5440_pinctrl_register(s
+ struct pinctrl_desc *ctrldesc;
+ struct pinctrl_dev *pctl_dev;
+ struct pinctrl_pin_desc *pindesc, *pdesc;
+- struct pinctrl_gpio_range grange;
+ char *pin_names;
+ int pin, ret;
+
+@@ -794,12 +795,12 @@ static int exynos5440_pinctrl_register(s
+ return PTR_ERR(pctl_dev);
+ }
+
+- grange.name = "exynos5440-pctrl-gpio-range";
+- grange.id = 0;
+- grange.base = 0;
+- grange.npins = EXYNOS5440_MAX_PINS;
+- grange.gc = priv->gc;
+- pinctrl_add_gpio_range(pctl_dev, &grange);
++ priv->range.name = "exynos5440-pctrl-gpio-range";
++ priv->range.id = 0;
++ priv->range.base = 0;
++ priv->range.npins = EXYNOS5440_MAX_PINS;
++ priv->range.gc = priv->gc;
++ pinctrl_add_gpio_range(pctl_dev, &priv->range);
+ return 0;
+ }
+
--- /dev/null
+From 0ae3aeefabbeef26294e7a349b51f1c761d46c9f Mon Sep 17 00:00:00 2001
+From: Ulf Hansson <ulf.hansson@linaro.org>
+Date: Fri, 8 Apr 2016 13:10:23 +0200
+Subject: PM / Runtime: Fix error path in pm_runtime_force_resume()
+
+From: Ulf Hansson <ulf.hansson@linaro.org>
+
+commit 0ae3aeefabbeef26294e7a349b51f1c761d46c9f upstream.
+
+As pm_runtime_set_active() may fail because the device's parent isn't
+active, we can end up executing the ->runtime_resume() callback for the
+device when it isn't allowed.
+
+Fix this by invoking pm_runtime_set_active() before running the callback
+and let's also deal with the error code.
+
+Fixes: 37f204164dfb (PM: Add pm_runtime_suspend|resume_force functions)
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/base/power/runtime.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+--- a/drivers/base/power/runtime.c
++++ b/drivers/base/power/runtime.c
+@@ -1506,11 +1506,16 @@ int pm_runtime_force_resume(struct devic
+ goto out;
+ }
+
+- ret = callback(dev);
++ ret = pm_runtime_set_active(dev);
+ if (ret)
+ goto out;
+
+- pm_runtime_set_active(dev);
++ ret = callback(dev);
++ if (ret) {
++ pm_runtime_set_suspended(dev);
++ goto out;
++ }
++
+ pm_runtime_mark_last_busy(dev);
+ out:
+ pm_runtime_enable(dev);
--- /dev/null
+From 5e3ca2b349b1e2c80b060b51bbf2af37448fad85 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+Date: Wed, 23 Mar 2016 20:59:34 -0300
+Subject: regulator: Try to resolve regulators supplies on registration
+
+From: Javier Martinez Canillas <javier@osg.samsung.com>
+
+commit 5e3ca2b349b1e2c80b060b51bbf2af37448fad85 upstream.
+
+Commit 6261b06de565 ("regulator: Defer lookup of supply to regulator_get")
+moved the regulator supplies lookup logic from the regulators registration
+to the regulators get time.
+
+Unfortunately, that changed the behavior of the regulator core since now a
+parent supply with a child regulator marked as always-on, won't be enabled
+unless a client driver attempts to get the child regulator during boot.
+
+This patch tries to resolve the parent supply for the already registered
+regulators each time that a new regulator is registered. So the regulators
+that have child regulators marked as always on will be enabled regardless
+if a driver gets the child regulator or not.
+
+That was the behavior before the mentioned commit, since parent supplies
+were looked up at regulator registration time instead of during child get.
+
+Since regulator_resolve_supply() checks for rdev->supply, most of the times
+it will be a no-op. Errors aren't checked to keep the possible out of order
+dependencies which was the motivation for the mentioned commit.
+
+Also, the supply being available will be enforced on regulator get anyways
+in case the resolve fails on regulators registration.
+
+Fixes: 6261b06de565 ("regulator: Defer lookup of supply to regulator_get")
+Suggested-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/regulator/core.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/drivers/regulator/core.c
++++ b/drivers/regulator/core.c
+@@ -3823,6 +3823,11 @@ static void rdev_init_debugfs(struct reg
+ &rdev->bypass_count);
+ }
+
++static int regulator_register_resolve_supply(struct device *dev, void *data)
++{
++ return regulator_resolve_supply(dev_to_rdev(dev));
++}
++
+ /**
+ * regulator_register - register regulator
+ * @regulator_desc: regulator to register
+@@ -3969,6 +3974,10 @@ regulator_register(const struct regulato
+ }
+
+ rdev_init_debugfs(rdev);
++
++ /* try to resolve regulators supply since a new one was registered */
++ class_for_each_device(®ulator_class, NULL, NULL,
++ regulator_register_resolve_supply);
+ out:
+ mutex_unlock(®ulator_list_mutex);
+ kfree(config);
--- /dev/null
+From d65c8fff867a6450c58ce31572e883148a445ddf Mon Sep 17 00:00:00 2001
+From: "Martin K. Petersen" <martin.petersen@oracle.com>
+Date: Mon, 9 May 2016 21:39:43 -0400
+Subject: Revert "lpfc: Delete unnecessary checks before the function call mempool_destroy"
+
+From: Martin K. Petersen <martin.petersen@oracle.com>
+
+commit d65c8fff867a6450c58ce31572e883148a445ddf upstream.
+
+This reverts commit 9be321819c43417432a8376428b90fe3fe3a3510 which
+caused a regression on hardware using the SLI3 interface.
+
+Reported-by: Dick Kennedy <dick.kennedy@broadcom.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: James Bottomley <jejb@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/lpfc/lpfc_mem.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/lpfc/lpfc_mem.c
++++ b/drivers/scsi/lpfc/lpfc_mem.c
+@@ -231,13 +231,15 @@ lpfc_mem_free(struct lpfc_hba *phba)
+ if (phba->lpfc_hbq_pool)
+ pci_pool_destroy(phba->lpfc_hbq_pool);
+ phba->lpfc_hbq_pool = NULL;
+- mempool_destroy(phba->rrq_pool);
++
++ if (phba->rrq_pool)
++ mempool_destroy(phba->rrq_pool);
+ phba->rrq_pool = NULL;
+
+ /* Free NLP memory pool */
+ mempool_destroy(phba->nlp_mem_pool);
+ phba->nlp_mem_pool = NULL;
+- if (phba->sli_rev == LPFC_SLI_REV4) {
++ if (phba->sli_rev == LPFC_SLI_REV4 && phba->active_rrq_pool) {
+ mempool_destroy(phba->active_rrq_pool);
+ phba->active_rrq_pool = NULL;
+ }
--- /dev/null
+From baa1702290953295e421f0f433e2b1ff4815827c Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 16 Mar 2016 13:33:35 -0500
+Subject: rtlwifi: btcoexist: Implement antenna selection
+
+From: Larry Finger <Larry.Finger@lwfinger.net>
+
+commit baa1702290953295e421f0f433e2b1ff4815827c upstream.
+
+The previous patch added an option to rtl8723be to manually select the
+antenna for those cases when only a single antenna is present, and the
+on-board EEPROM is incorrectly programmed. This patch implements the
+necessary changes in the Bluetooth coexistence driver.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 9 ++-
+ drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 27 +++++++++-
+ drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 2
+ drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c | 5 +
+ 4 files changed, 38 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
++++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+@@ -1203,7 +1203,6 @@ static void btc8723b2ant_set_ant_path(st
+
+ /* Force GNT_BT to low */
+ btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
+- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
+
+ if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
+ /* tell firmware "no antenna inverse" */
+@@ -1211,19 +1210,25 @@ static void btc8723b2ant_set_ant_path(st
+ h2c_parameter[1] = 1; /* ext switch type */
+ btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
+ h2c_parameter);
++ btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
+ } else {
+ /* tell firmware "antenna inverse" */
+ h2c_parameter[0] = 1;
+ h2c_parameter[1] = 1; /* ext switch type */
+ btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
+ h2c_parameter);
++ btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
+ }
+ }
+
+ /* ext switch setting */
+ if (use_ext_switch) {
+ /* fixed internal switch S1->WiFi, S0->BT */
+- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
++ if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
++ btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
++ else
++ btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
++
+ switch (antpos_type) {
+ case BTC_ANT_WIFI_AT_MAIN:
+ /* ext switch main at wifi */
+--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
++++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+@@ -965,13 +965,38 @@ void exhalbtc_set_chip_type(u8 chip_type
+ }
+ }
+
+-void exhalbtc_set_ant_num(u8 type, u8 ant_num)
++void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
+ {
+ if (BT_COEX_ANT_TYPE_PG == type) {
+ gl_bt_coexist.board_info.pg_ant_num = ant_num;
+ gl_bt_coexist.board_info.btdm_ant_num = ant_num;
++ /* The antenna position:
++ * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
++ * The antenna position should be determined by
++ * auto-detect mechanism.
++ * The following is assumed to main,
++ * and those must be modified
++ * if y auto-detect mechanism is ready
++ */
++ if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
++ (gl_bt_coexist.board_info.btdm_ant_num == 1))
++ gl_bt_coexist.board_info.btdm_ant_pos =
++ BTC_ANTENNA_AT_MAIN_PORT;
++ else
++ gl_bt_coexist.board_info.btdm_ant_pos =
++ BTC_ANTENNA_AT_MAIN_PORT;
+ } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
+ gl_bt_coexist.board_info.btdm_ant_num = ant_num;
++ gl_bt_coexist.board_info.btdm_ant_pos =
++ BTC_ANTENNA_AT_MAIN_PORT;
++ } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
++ gl_bt_coexist.board_info.btdm_ant_num = ant_num;
++ if (rtlpriv->cfg->mod_params->ant_sel == 1)
++ gl_bt_coexist.board_info.btdm_ant_pos =
++ BTC_ANTENNA_AT_AUX_PORT;
++ else
++ gl_bt_coexist.board_info.btdm_ant_pos =
++ BTC_ANTENNA_AT_MAIN_PORT;
+ }
+ }
+
+--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
++++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+@@ -535,7 +535,7 @@ void exhalbtc_set_bt_patch_version(u16 b
+ void exhalbtc_update_min_bt_rssi(char bt_rssi);
+ void exhalbtc_set_bt_exist(bool bt_exist);
+ void exhalbtc_set_chip_type(u8 chip_type);
+-void exhalbtc_set_ant_num(u8 type, u8 ant_num);
++void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
+ void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
+ void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
+ u8 *rssi_wifi, u8 *rssi_bt);
+--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
++++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+@@ -72,7 +72,10 @@ void rtl_btc_init_hal_vars(struct rtl_pr
+ __func__, bt_type);
+ exhalbtc_set_chip_type(bt_type);
+
+- exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
++ if (rtlpriv->cfg->mod_params->ant_sel == 1)
++ exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1);
++ else
++ exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
+ }
+
+ void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
--- /dev/null
+From 873ffe154ae074c46ed2d72dbd9a2a99f06f55b4 Mon Sep 17 00:00:00 2001
+From: wang yanqing <udknight@gmail.com>
+Date: Tue, 3 May 2016 00:38:36 +0800
+Subject: rtlwifi: Fix logic error in enter/exit power-save mode
+
+From: wang yanqing <udknight@gmail.com>
+
+commit 873ffe154ae074c46ed2d72dbd9a2a99f06f55b4 upstream.
+
+In commit a269913c52ad ("rtlwifi: Rework rtl_lps_leave() and
+rtl_lps_enter() to use work queue"), the tests for enter/exit
+power-save mode were inverted. With this change applied, the
+wifi connection becomes much more stable.
+
+Fixes: a269913c52ad ("rtlwifi: Rework rtl_lps_leave() and rtl_lps_enter() to use work queue")
+Signed-off-by: Wang YanQing <udknight@gmail.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/realtek/rtlwifi/base.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/realtek/rtlwifi/base.c
++++ b/drivers/net/wireless/realtek/rtlwifi/base.c
+@@ -1660,9 +1660,9 @@ void rtl_watchdog_wq_callback(void *data
+ if (((rtlpriv->link_info.num_rx_inperiod +
+ rtlpriv->link_info.num_tx_inperiod) > 8) ||
+ (rtlpriv->link_info.num_rx_inperiod > 2))
+- rtl_lps_enter(hw);
+- else
+ rtl_lps_leave(hw);
++ else
++ rtl_lps_enter(hw);
+ }
+
+ rtlpriv->link_info.num_rx_inperiod = 0;
--- /dev/null
+From cf968937d27751296920e6b82ffa89735e3a0023 Mon Sep 17 00:00:00 2001
+From: wang yanqing <udknight@gmail.com>
+Date: Sat, 7 May 2016 00:33:53 +0800
+Subject: rtlwifi: pci: use dev_kfree_skb_irq instead of kfree_skb in rtl_pci_reset_trx_ring
+
+From: wang yanqing <udknight@gmail.com>
+
+commit cf968937d27751296920e6b82ffa89735e3a0023 upstream.
+
+We can't use kfree_skb in irq disable context, because spin_lock_irqsave
+make sure we are always in irq disable context, use dev_kfree_skb_irq
+instead of kfree_skb is better than dev_kfree_skb_any.
+
+This patch fix below kernel warning:
+[ 7612.095528] ------------[ cut here ]------------
+[ 7612.095546] WARNING: CPU: 3 PID: 4460 at kernel/softirq.c:150 __local_bh_enable_ip+0x58/0x80()
+[ 7612.095550] Modules linked in: rtl8723be x86_pkg_temp_thermal btcoexist rtl_pci rtlwifi rtl8723_common
+[ 7612.095567] CPU: 3 PID: 4460 Comm: ifconfig Tainted: G W 4.4.0+ #4
+[ 7612.095570] Hardware name: LENOVO 20DFA04FCD/20DFA04FCD, BIOS J5ET48WW (1.19 ) 08/27/2015
+[ 7612.095574] 00000000 00000000 da37fc70 c12ce7c5 00000000 da37fca0 c104cc59 c19d4454
+[ 7612.095584] 00000003 0000116c c19d4784 00000096 c10508a8 c10508a8 00000200 c1b42400
+[ 7612.095594] f29be780 da37fcb0 c104ccad 00000009 00000000 da37fcbc c10508a8 f21f08b8
+[ 7612.095604] Call Trace:
+[ 7612.095614] [<c12ce7c5>] dump_stack+0x41/0x5c
+[ 7612.095620] [<c104cc59>] warn_slowpath_common+0x89/0xc0
+[ 7612.095628] [<c10508a8>] ? __local_bh_enable_ip+0x58/0x80
+[ 7612.095634] [<c10508a8>] ? __local_bh_enable_ip+0x58/0x80
+[ 7612.095640] [<c104ccad>] warn_slowpath_null+0x1d/0x20
+[ 7612.095646] [<c10508a8>] __local_bh_enable_ip+0x58/0x80
+[ 7612.095653] [<c16b7d34>] destroy_conntrack+0x64/0xa0
+[ 7612.095660] [<c16b300f>] nf_conntrack_destroy+0xf/0x20
+[ 7612.095665] [<c1677565>] skb_release_head_state+0x55/0xa0
+[ 7612.095670] [<c16775bb>] skb_release_all+0xb/0x20
+[ 7612.095674] [<c167760b>] __kfree_skb+0xb/0x60
+[ 7612.095679] [<c16776f0>] kfree_skb+0x30/0x70
+[ 7612.095686] [<f81b869d>] ? rtl_pci_reset_trx_ring+0x22d/0x370 [rtl_pci]
+[ 7612.095692] [<f81b869d>] rtl_pci_reset_trx_ring+0x22d/0x370 [rtl_pci]
+[ 7612.095698] [<f81b87f9>] rtl_pci_start+0x19/0x190 [rtl_pci]
+[ 7612.095705] [<f81970e6>] rtl_op_start+0x56/0x90 [rtlwifi]
+[ 7612.095712] [<c17e3f16>] drv_start+0x36/0xc0
+[ 7612.095717] [<c17f5ab3>] ieee80211_do_open+0x2d3/0x890
+[ 7612.095725] [<c16820fe>] ? call_netdevice_notifiers_info+0x2e/0x60
+[ 7612.095730] [<c17f60bd>] ieee80211_open+0x4d/0x50
+[ 7612.095736] [<c16891b3>] __dev_open+0xa3/0x130
+[ 7612.095742] [<c183fa53>] ? _raw_spin_unlock_bh+0x13/0x20
+[ 7612.095748] [<c1689499>] __dev_change_flags+0x89/0x140
+[ 7612.095753] [<c127c70d>] ? selinux_capable+0xd/0x10
+[ 7612.095759] [<c1689589>] dev_change_flags+0x29/0x60
+[ 7612.095765] [<c1700b93>] devinet_ioctl+0x553/0x670
+[ 7612.095772] [<c12db758>] ? _copy_to_user+0x28/0x40
+[ 7612.095777] [<c17018b5>] inet_ioctl+0x85/0xb0
+[ 7612.095783] [<c166e647>] sock_ioctl+0x67/0x260
+[ 7612.095788] [<c166e5e0>] ? sock_fasync+0x80/0x80
+[ 7612.095795] [<c115c99b>] do_vfs_ioctl+0x6b/0x550
+[ 7612.095800] [<c127c812>] ? selinux_file_ioctl+0x102/0x1e0
+[ 7612.095807] [<c10a8914>] ? timekeeping_suspend+0x294/0x320
+[ 7612.095813] [<c10a256a>] ? __hrtimer_run_queues+0x14a/0x210
+[ 7612.095820] [<c1276e24>] ? security_file_ioctl+0x34/0x50
+[ 7612.095827] [<c115cef0>] SyS_ioctl+0x70/0x80
+[ 7612.095832] [<c1001804>] do_fast_syscall_32+0x84/0x120
+[ 7612.095839] [<c183ff91>] sysenter_past_esp+0x36/0x55
+[ 7612.095844] ---[ end trace 97e9c637a20e8348 ]---
+
+Signed-off-by: Wang YanQing <udknight@gmail.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/realtek/rtlwifi/pci.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
++++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
+@@ -1573,7 +1573,7 @@ int rtl_pci_reset_trx_ring(struct ieee80
+ true,
+ HW_DESC_TXBUFF_ADDR),
+ skb->len, PCI_DMA_TODEVICE);
+- kfree_skb(skb);
++ dev_kfree_skb_irq(skb);
+ ring->idx = (ring->idx + 1) % ring->entries;
+ }
+ ring->idx = 0;
--- /dev/null
+From c18d8f5095715c56bb3cd9cba64242542632054b Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 16 Mar 2016 13:33:34 -0500
+Subject: rtlwifi: rtl8723be: Add antenna select module parameter
+
+From: Larry Finger <Larry.Finger@lwfinger.net>
+
+commit c18d8f5095715c56bb3cd9cba64242542632054b upstream.
+
+A number of new laptops have been delivered with only a single antenna.
+In principle, this is OK; however, a problem arises when the on-board
+EEPROM is programmed to use the other antenna connection. The option
+of opening the computer and moving the connector is not always possible
+as it will void the warranty in some cases. In addition, this solution
+breaks the Windows driver when the box dual boots Linux and Windows.
+
+A fix involving a new module parameter has been developed. This commit
+adds the new parameter and implements the changes needed for the driver.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 5 +++++
+ drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 3 +++
+ drivers/net/wireless/realtek/rtlwifi/wifi.h | 3 +++
+ 3 files changed, 11 insertions(+)
+
+--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+@@ -2684,6 +2684,7 @@ void rtl8723be_read_bt_coexist_info_from
+ bool auto_load_fail, u8 *hwinfo)
+ {
+ struct rtl_priv *rtlpriv = rtl_priv(hw);
++ struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
+ u8 value;
+ u32 tmpu_32;
+
+@@ -2702,6 +2703,10 @@ void rtl8723be_read_bt_coexist_info_from
+ rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
+ }
+
++ /* override ant_num / ant_path */
++ if (mod_params->ant_sel)
++ rtlpriv->btcoexist.btc_info.ant_num =
++ (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
+ }
+
+ void rtl8723be_bt_reg_init(struct ieee80211_hw *hw)
+--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+@@ -273,6 +273,7 @@ static struct rtl_mod_params rtl8723be_m
+ .msi_support = false,
+ .disable_watchdog = false,
+ .debug = DBG_EMERG,
++ .ant_sel = 0,
+ };
+
+ static struct rtl_hal_cfg rtl8723be_hal_cfg = {
+@@ -394,6 +395,7 @@ module_param_named(fwlps, rtl8723be_mod_
+ module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444);
+ module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
+ bool, 0444);
++module_param_named(ant_sel, rtl8723be_mod_params.ant_sel, int, 0444);
+ MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
+ MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
+ MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
+@@ -402,6 +404,7 @@ MODULE_PARM_DESC(msi, "Set to 1 to use M
+ MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
+ MODULE_PARM_DESC(disable_watchdog,
+ "Set to 1 to disable the watchdog (default 0)\n");
++MODULE_PARM_DESC(ant_sel, "Set to 1 or 2 to force antenna number (default 0)\n");
+
+ static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
+
+--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
++++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
+@@ -2251,6 +2251,9 @@ struct rtl_mod_params {
+
+ /* default 0: 1 means do not disable interrupts */
+ bool int_clear;
++
++ /* select antenna */
++ int ant_sel;
+ };
+
+ struct rtl_hal_usbint_cfg {
mips-build-micromips-vdso-for-micromips-kernels.patch
mips-lib-mark-intrinsics-notrace.patch
mips-vdso-build-with-fno-strict-aliasing.patch
+affs-fix-remount-failure-when-there-are-no-options-changed.patch
+asoc-ak4642-enable-cache-usage-to-fix-crashes-on-resume.patch
+input-uinput-handle-compat-ioctl-for-ui_set_phys.patch
+input-xpad-move-pending-clear-to-the-correct-location.patch
+input-xpad-prevent-spurious-input-from-wired-xbox-360-controllers.patch
+arm-sun4i-dt-enable-dram-gate-5-tve0-clock-for-simplefb-tv-output.patch
+arm-sun7i-dt-enable-dram-gate-5-tve0-clock-for-simplefb-tv-output.patch
+arm-mvebu-fix-gpio-config-on-the-linksys-boards.patch
+arm-dts-at91-fix-typo-in-sama5d2-pin_pd24-description.patch
+arm-dts-exynos-add-interrupt-line-to-max8997-pmic-on-exynos4210-trats.patch
+arm-dts-imx35-restore-existing-used-clock-enumeration.patch
+ath9k-add-a-module-parameter-to-invert-led-polarity.patch
+ath9k-fix-led-polarity-for-some-mini-pci-ar9220-mb92-cards.patch
+ath10k-fix-debugfs-pktlog_filter-write.patch
+ath10k-fix-firmware-assert-in-monitor-mode.patch
+ath10k-fix-rx_channel-during-hw-reconfigure.patch
+ath10k-fix-kernel-panic-move-arvifs-list-head-init-before-htt-init.patch
+ath5k-change-led-pin-configuration-for-compaq-c700-laptop.patch
+hwrng-exynos-fix-unbalanced-pm-runtime-put-on-timeout-error-path.patch
+rtlwifi-rtl8723be-add-antenna-select-module-parameter.patch
+rtlwifi-btcoexist-implement-antenna-selection.patch
+rtlwifi-fix-logic-error-in-enter-exit-power-save-mode.patch
+rtlwifi-pci-use-dev_kfree_skb_irq-instead-of-kfree_skb-in-rtl_pci_reset_trx_ring.patch
+revert-lpfc-delete-unnecessary-checks-before-the-function-call-mempool_destroy.patch
+aacraid-relinquish-cpu-during-timeout-wait.patch
+aacraid-fix-for-aac_command_thread-hang.patch
+aacraid-fix-for-kdump-driver-hang.patch
+regulator-try-to-resolve-regulators-supplies-on-registration.patch
+hwmon-ads7828-enable-internal-reference.patch
+mfd-intel-lpss-save-register-context-on-suspend.patch
+mfd-intel_soc_pmic_core-terminate-panel-control-gpio-lookup-table-correctly.patch
+pm-runtime-fix-error-path-in-pm_runtime_force_resume.patch
+cpuidle-indicate-when-a-device-has-been-unregistered.patch
+cpuidle-fix-cpuidle_state_is_coupled-argument-in-cpuidle_enter.patch
+clk-bcm2835-fix-pll-poweron.patch
+clk-at91-fix-check-of-clk_register-returned-value.patch
+clk-bcm2835-pll_off-should-only-update-cm_pll_anarst.patch
+clk-bcm2835-divider-value-has-to-be-1-or-more.patch
+clk-bcm2835-correctly-enable-fractional-clock-support.patch
+pinctrl-exynos5440-use-off-stack-memory-for-pinctrl_gpio_range.patch
+pci-disable-all-bar-sizing-for-devices-with-non-compliant-bars.patch
+media-v4l2-compat-ioctl32-fix-missing-reserved-field-copy-in-put_v4l2_create32.patch