--- /dev/null
+From 4de437265eaac18f880d827f8e105b10de9b87a3 Mon Sep 17 00:00:00 2001
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Mon, 14 Aug 2017 14:28:14 +0100
+Subject: crypto: chacha20 - fix handling of chunked input
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 4de437265eaac18f880d827f8e105b10de9b87a3 upstream.
+
+Commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86 versions
+to skcipher") ported the existing chacha20 code to use the new skcipher
+API, and introduced a bug along the way. Unfortunately, the tcrypt tests
+did not catch the error, and it was only found recently by Tobias.
+
+Stefan kindly diagnosed the error, and proposed a fix which is similar
+to the one below, with the exception that 'walk.stride' is used rather
+than the hardcoded block size. This does not actually matter in this
+case, but it's a better example of how to use the skcipher walk API.
+
+Fixes: 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86 ...")
+Cc: Steffen Klassert <steffen.klassert@secunet.com>
+Reported-by: Tobias Brunner <tobias@strongswan.org>
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ crypto/chacha20_generic.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+--- a/crypto/chacha20_generic.c
++++ b/crypto/chacha20_generic.c
+@@ -91,9 +91,14 @@ int crypto_chacha20_crypt(struct skciphe
+ crypto_chacha20_init(state, ctx, walk.iv);
+
+ while (walk.nbytes > 0) {
++ unsigned int nbytes = walk.nbytes;
++
++ if (nbytes < walk.total)
++ nbytes = round_down(nbytes, walk.stride);
++
+ chacha20_docrypt(state, walk.dst.virt.addr, walk.src.virt.addr,
+- walk.nbytes);
+- err = skcipher_walk_done(&walk, 0);
++ nbytes);
++ err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
+ }
+
+ return err;
--- /dev/null
+From 3f9db52dc87b003a1732f3e03f7f5fc8701ef4ad Mon Sep 17 00:00:00 2001
+From: Anthony Martin <ality@pbrane.org>
+Date: Mon, 28 Aug 2017 10:26:12 -0700
+Subject: Input: synaptics - fix device info appearing different on reconnect
+
+From: Anthony Martin <ality@pbrane.org>
+
+commit 3f9db52dc87b003a1732f3e03f7f5fc8701ef4ad upstream.
+
+User-modified input settings no longer survive a suspend/resume cycle.
+Starting with 4.12, the touchpad is reinitialized on every reconnect
+because the hardware appears to be different. This can be reproduced
+by running the following as root:
+
+ echo -n reconnect >/sys/devices/platform/i8042/serio1/drvctl
+
+A line like the following will show up in dmesg:
+
+ [30378.295794] psmouse serio1: synaptics: hardware appears to be
+ different: id(149271-149271), model(114865-114865),
+ caps(d047b3-d047b1), ext(b40000-b40000).
+
+Note the single bit difference in caps: bit 1 (SYN_CAP_MULTIFINGER).
+
+This happens because we modify our stored copy of the device info
+capabilities when we enable advanced gesture mode but this change is
+not reflected in the actual hardware capabilities.
+
+It worked in the past because synaptics_query_hardware used to modify
+the stored synaptics_device_info struct instead of filling in a new
+one, as it does now.
+
+Fix it by no longer faking the SYN_CAP_MULTIFINGER bit when setting
+advanced gesture mode. This necessitated a small refactoring.
+
+Fixes: 6c53694fb222 ("Input: synaptics - split device info into a separate structure")
+Signed-off-by: Anthony Martin <ality@pbrane.org>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/mouse/synaptics.c | 35 ++++++++++++++++++++---------------
+ 1 file changed, 20 insertions(+), 15 deletions(-)
+
+--- a/drivers/input/mouse/synaptics.c
++++ b/drivers/input/mouse/synaptics.c
+@@ -535,16 +535,17 @@ static void synaptics_apply_quirks(struc
+ }
+ }
+
++static bool synaptics_has_agm(struct synaptics_data *priv)
++{
++ return (SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
++ SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c));
++}
++
+ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
+ {
+ static u8 param = 0xc8;
+- struct synaptics_data *priv = psmouse->private;
+ int error;
+
+- if (!(SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
+- SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)))
+- return 0;
+-
+ error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL);
+ if (error)
+ return error;
+@@ -553,9 +554,6 @@ static int synaptics_set_advanced_gestur
+ if (error)
+ return error;
+
+- /* Advanced gesture mode also sends multi finger data */
+- priv->info.capabilities |= BIT(1);
+-
+ return 0;
+ }
+
+@@ -578,7 +576,7 @@ static int synaptics_set_mode(struct psm
+ if (error)
+ return error;
+
+- if (priv->absolute_mode) {
++ if (priv->absolute_mode && synaptics_has_agm(priv)) {
+ error = synaptics_set_advanced_gesture_mode(psmouse);
+ if (error) {
+ psmouse_err(psmouse,
+@@ -766,9 +764,7 @@ static int synaptics_parse_hw_state(cons
+ ((buf[0] & 0x04) >> 1) |
+ ((buf[3] & 0x04) >> 2));
+
+- if ((SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
+- SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)) &&
+- hw->w == 2) {
++ if (synaptics_has_agm(priv) && hw->w == 2) {
+ synaptics_parse_agm(buf, priv, hw);
+ return 1;
+ }
+@@ -1033,6 +1029,15 @@ static void synaptics_image_sensor_proce
+ synaptics_report_mt_data(psmouse, sgm, num_fingers);
+ }
+
++static bool synaptics_has_multifinger(struct synaptics_data *priv)
++{
++ if (SYN_CAP_MULTIFINGER(priv->info.capabilities))
++ return true;
++
++ /* Advanced gesture mode also sends multi finger data */
++ return synaptics_has_agm(priv);
++}
++
+ /*
+ * called for each full received packet from the touchpad
+ */
+@@ -1079,7 +1084,7 @@ static void synaptics_process_packet(str
+ if (SYN_CAP_EXTENDED(info->capabilities)) {
+ switch (hw.w) {
+ case 0 ... 1:
+- if (SYN_CAP_MULTIFINGER(info->capabilities))
++ if (synaptics_has_multifinger(priv))
+ num_fingers = hw.w + 2;
+ break;
+ case 2:
+@@ -1123,7 +1128,7 @@ static void synaptics_process_packet(str
+ input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
+
+ input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
+- if (SYN_CAP_MULTIFINGER(info->capabilities)) {
++ if (synaptics_has_multifinger(priv)) {
+ input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
+ input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
+ }
+@@ -1283,7 +1288,7 @@ static void set_input_params(struct psmo
+ __set_bit(BTN_TOUCH, dev->keybit);
+ __set_bit(BTN_TOOL_FINGER, dev->keybit);
+
+- if (SYN_CAP_MULTIFINGER(info->capabilities)) {
++ if (synaptics_has_multifinger(priv)) {
+ __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
+ __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
+ }
--- /dev/null
+From f5308d1b83eba20e69df5e0926ba7257c8dd9074 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Thu, 31 Aug 2017 11:52:20 -0700
+Subject: Input: xpad - fix PowerA init quirk for some gamepad models
+
+From: Cameron Gutman <aicommander@gmail.com>
+
+commit f5308d1b83eba20e69df5e0926ba7257c8dd9074 upstream.
+
+The PowerA gamepad initialization quirk worked with the PowerA
+wired gamepad I had around (0x24c6:0x543a), but a user reported [0]
+that it didn't work for him, even though our gamepads shared the
+same vendor and product IDs.
+
+When I initially implemented the PowerA quirk, I wanted to avoid
+actually triggering the rumble action during init. My tests showed
+that my gamepad would work correctly even if it received a rumble
+of 0 intensity, so that's what I went with.
+
+Unfortunately, this apparently isn't true for all models (perhaps
+a firmware difference?). This non-working gamepad seems to require
+the real magic rumble packet that the Microsoft driver sends, which
+actually vibrates the gamepad. To counteract this effect, I still
+send the old zero-rumble PowerA quirk packet which cancels the
+rumble effect before the motors can spin up enough to vibrate.
+
+[0]: https://github.com/paroj/xpad/issues/48#issuecomment-313904867
+
+Reported-by: Kyle Beauchamp <kyleabeauchamp@gmail.com>
+Tested-by: Kyle Beauchamp <kyleabeauchamp@gmail.com>
+Fixes: 81093c9848a7 ("Input: xpad - support some quirky Xbox One pads")
+Signed-off-by: Cameron Gutman <aicommander@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 | 24 +++++++++++++++++++-----
+ 1 file changed, 19 insertions(+), 5 deletions(-)
+
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -389,10 +389,21 @@ static const u8 xboxone_hori_init[] = {
+ };
+
+ /*
+- * A rumble packet is required for some PowerA pads to start
++ * A specific rumble packet is required for some PowerA pads to start
+ * sending input reports. One of those pads is (0x24c6:0x543a).
+ */
+-static const u8 xboxone_zerorumble_init[] = {
++static const u8 xboxone_rumblebegin_init[] = {
++ 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
++ 0x1D, 0x1D, 0xFF, 0x00, 0x00
++};
++
++/*
++ * A rumble packet with zero FF intensity will immediately
++ * terminate the rumbling required to init PowerA pads.
++ * This should happen fast enough that the motors don't
++ * spin up to enough speed to actually vibrate the gamepad.
++ */
++static const u8 xboxone_rumbleend_init[] = {
+ 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+@@ -407,9 +418,12 @@ static const struct xboxone_init_packet
+ XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
+ XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
+ XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
+- XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_zerorumble_init),
+- XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_zerorumble_init),
+- XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_zerorumble_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumbleend_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumbleend_init),
++ XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init),
+ };
+
+ struct xpad_output_packet {
--- /dev/null
+From 2c0e8382386f618c85d20cb05e7cf7df8cdd382c Mon Sep 17 00:00:00 2001
+From: James Hogan <james.hogan@imgtec.com>
+Date: Sat, 12 Aug 2017 21:36:09 -0700
+Subject: irqchip: mips-gic: SYNC after enabling GIC region
+
+From: James Hogan <james.hogan@imgtec.com>
+
+commit 2c0e8382386f618c85d20cb05e7cf7df8cdd382c upstream.
+
+A SYNC is required between enabling the GIC region and actually trying
+to use it, even if the first access is a read, otherwise its possible
+depending on the timing (and in my case depending on the precise
+alignment of certain kernel code) to hit CM bus errors on that first
+access.
+
+Add the SYNC straight after setting the GIC base.
+
+[paul.burton@imgtec.com:
+ Changes later in this series increase our likelihood of hitting this
+ by reducing the amount of code that runs between enabling the GIC &
+ accessing it.]
+
+Fixes: a7057270c280 ("irqchip: mips-gic: Add device-tree support")
+Signed-off-by: James Hogan <james.hogan@imgtec.com>
+Signed-off-by: Paul Burton <paul.burton@imgtec.com>
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Jason Cooper <jason@lakedaemon.net>
+Cc: James Hogan <james.hogan@imgtec.com>
+Cc: linux-kernel@vger.kernel.org
+Cc: linux-mips@linux-mips.org
+Patchwork: https://patchwork.linux-mips.org/patch/17019/
+Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/irqchip/irq-mips-gic.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/irqchip/irq-mips-gic.c
++++ b/drivers/irqchip/irq-mips-gic.c
+@@ -1022,8 +1022,11 @@ static int __init gic_of_init(struct dev
+ gic_len = resource_size(&res);
+ }
+
+- if (mips_cm_present())
++ if (mips_cm_present()) {
+ write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK);
++ /* Ensure GIC region is enabled before trying to access it */
++ __sync();
++ }
+ gic_present = true;
+
+ __gic_init(gic_base, gic_len, cpu_vec, 0, node);
arm64-mm-abort-uaccess-retries-upon-fatal-signal.patch
x86-io-add-memory-clobber-to-insb-insw-insl-outsb-outsw-outsl.patch
+irqchip-mips-gic-sync-after-enabling-gic-region.patch
+input-synaptics-fix-device-info-appearing-different-on-reconnect.patch
+input-xpad-fix-powera-init-quirk-for-some-gamepad-models.patch
+crypto-chacha20-fix-handling-of-chunked-input.patch
--- /dev/null
+irqchip-mips-gic-sync-after-enabling-gic-region.patch
--- /dev/null
+irqchip-mips-gic-sync-after-enabling-gic-region.patch