--- /dev/null
+From ab89f0bdd63a3721f7cd3f064f39fc4ac7ca14d4 Mon Sep 17 00:00:00 2001
+From: Szymon Janc <szymon.janc@codecoup.pl>
+Date: Mon, 24 Apr 2017 18:25:04 -0700
+Subject: Bluetooth: Fix user channel for 32bit userspace on 64bit kernel
+
+From: Szymon Janc <szymon.janc@codecoup.pl>
+
+commit ab89f0bdd63a3721f7cd3f064f39fc4ac7ca14d4 upstream.
+
+Running 32bit userspace on 64bit kernel results in MSG_CMSG_COMPAT being
+defined as 0x80000000. This results in sendmsg failure if used from 32bit
+userspace running on 64bit kernel. Fix this by accounting for MSG_CMSG_COMPAT
+in flags check in hci_sock_sendmsg.
+
+Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
+Signed-off-by: Marko Kiiskila <marko@runtime.io>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/bluetooth/hci_sock.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/net/bluetooth/hci_sock.c
++++ b/net/bluetooth/hci_sock.c
+@@ -1164,7 +1164,8 @@ static int hci_sock_sendmsg(struct socke
+ if (msg->msg_flags & MSG_OOB)
+ return -EOPNOTSUPP;
+
+- if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE))
++ if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE|
++ MSG_CMSG_COMPAT))
+ return -EINVAL;
+
+ if (len < 4 || len > HCI_MAX_FRAME_SIZE)
--- /dev/null
+From 95065a61e9bf25fb85295127fba893200c2bbbd8 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 29 Mar 2017 18:15:27 +0200
+Subject: Bluetooth: hci_bcm: add missing tty-device sanity check
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 95065a61e9bf25fb85295127fba893200c2bbbd8 upstream.
+
+Make sure to check the tty-device pointer before looking up the sibling
+platform device to avoid dereferencing a NULL-pointer when the tty is
+one end of a Unix98 pty.
+
+Fixes: 0395ffc1ee05 ("Bluetooth: hci_bcm: Add PM for BCM devices")
+Cc: Frederic Danis <frederic.danis@linux.intel.com>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/bluetooth/hci_bcm.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/bluetooth/hci_bcm.c
++++ b/drivers/bluetooth/hci_bcm.c
+@@ -287,6 +287,9 @@ static int bcm_open(struct hci_uart *hu)
+
+ hu->priv = bcm;
+
++ if (!hu->tty->dev)
++ goto out;
++
+ mutex_lock(&bcm_device_lock);
+ list_for_each(p, &bcm_device_list) {
+ struct bcm_device *dev = list_entry(p, struct bcm_device, list);
+@@ -307,7 +310,7 @@ static int bcm_open(struct hci_uart *hu)
+ }
+
+ mutex_unlock(&bcm_device_lock);
+-
++out:
+ return 0;
+ }
+
--- /dev/null
+From dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 29 Mar 2017 18:15:28 +0200
+Subject: Bluetooth: hci_intel: add missing tty-device sanity check
+
+From: Johan Hovold <johan@kernel.org>
+
+commit dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 upstream.
+
+Make sure to check the tty-device pointer before looking up the sibling
+platform device to avoid dereferencing a NULL-pointer when the tty is
+one end of a Unix98 pty.
+
+Fixes: 74cdad37cd24 ("Bluetooth: hci_intel: Add runtime PM support")
+Fixes: 1ab1f239bf17 ("Bluetooth: hci_intel: Add support for platform driver")
+Cc: Loic Poulain <loic.poulain@intel.com>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/bluetooth/hci_intel.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+--- a/drivers/bluetooth/hci_intel.c
++++ b/drivers/bluetooth/hci_intel.c
+@@ -307,6 +307,9 @@ static int intel_set_power(struct hci_ua
+ struct list_head *p;
+ int err = -ENODEV;
+
++ if (!hu->tty->dev)
++ return err;
++
+ mutex_lock(&intel_device_list_lock);
+
+ list_for_each(p, &intel_device_list) {
+@@ -379,6 +382,9 @@ static void intel_busy_work(struct work_
+ struct intel_data *intel = container_of(work, struct intel_data,
+ busy_work);
+
++ if (!intel->hu->tty->dev)
++ return;
++
+ /* Link is busy, delay the suspend */
+ mutex_lock(&intel_device_list_lock);
+ list_for_each(p, &intel_device_list) {
+@@ -913,6 +919,8 @@ done:
+ list_for_each(p, &intel_device_list) {
+ struct intel_device *dev = list_entry(p, struct intel_device,
+ list);
++ if (!hu->tty->dev)
++ break;
+ if (hu->tty->dev->parent == dev->pdev->dev.parent) {
+ if (device_may_wakeup(&dev->pdev->dev))
+ idev = dev;
+@@ -1094,6 +1102,9 @@ static int intel_enqueue(struct hci_uart
+
+ BT_DBG("hu %p skb %p", hu, skb);
+
++ if (!hu->tty->dev)
++ goto out_enqueue;
++
+ /* Be sure our controller is resumed and potential LPM transaction
+ * completed before enqueuing any packet.
+ */
+@@ -1110,7 +1121,7 @@ static int intel_enqueue(struct hci_uart
+ }
+ }
+ mutex_unlock(&intel_device_list_lock);
+-
++out_enqueue:
+ skb_queue_tail(&intel->txq, skb);
+
+ return 0;
--- /dev/null
+From 099bd73dc17ed77aa8c98323e043613b6e8f54fc Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Mon, 10 Apr 2017 11:21:38 +0200
+Subject: serial: omap: fix runtime-pm handling on unbind
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 099bd73dc17ed77aa8c98323e043613b6e8f54fc upstream.
+
+An unbalanced and misplaced synchronous put was used to suspend the
+device on driver unbind, something which with a likewise misplaced
+pm_runtime_disable leads to external aborts when an open port is being
+removed.
+
+Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa024010
+...
+[<c046e760>] (serial_omap_set_mctrl) from [<c046a064>] (uart_update_mctrl+0x50/0x60)
+[<c046a064>] (uart_update_mctrl) from [<c046a400>] (uart_shutdown+0xbc/0x138)
+[<c046a400>] (uart_shutdown) from [<c046bd2c>] (uart_hangup+0x94/0x190)
+[<c046bd2c>] (uart_hangup) from [<c045b760>] (__tty_hangup+0x404/0x41c)
+[<c045b760>] (__tty_hangup) from [<c045b794>] (tty_vhangup+0x1c/0x20)
+[<c045b794>] (tty_vhangup) from [<c046ccc8>] (uart_remove_one_port+0xec/0x260)
+[<c046ccc8>] (uart_remove_one_port) from [<c046ef4c>] (serial_omap_remove+0x40/0x60)
+[<c046ef4c>] (serial_omap_remove) from [<c04845e8>] (platform_drv_remove+0x34/0x4c)
+
+Fix this up by resuming the device before deregistering the port and by
+suspending and disabling runtime pm only after the port has been
+removed.
+
+Also make sure to disable autosuspend before disabling runtime pm so
+that the usage count is balanced and device actually suspended before
+returning.
+
+Note that due to a negative autosuspend delay being set in probe, the
+unbalanced put would actually suspend the device on first driver unbind,
+while rebinding and again unbinding would result in a negative
+power.usage_count.
+
+Fixes: 7e9c8e7dbf3b ("serial: omap: make sure to suspend device before remove")
+Cc: Felipe Balbi <balbi@kernel.org>
+Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Acked-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/omap-serial.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/tty/serial/omap-serial.c
++++ b/drivers/tty/serial/omap-serial.c
+@@ -1725,9 +1725,13 @@ static int serial_omap_remove(struct pla
+ {
+ struct uart_omap_port *up = platform_get_drvdata(dev);
+
++ pm_runtime_get_sync(up->dev);
++
++ uart_remove_one_port(&serial_omap_reg, &up->port);
++
++ pm_runtime_dont_use_autosuspend(up->dev);
+ pm_runtime_put_sync(up->dev);
+ pm_runtime_disable(up->dev);
+- uart_remove_one_port(&serial_omap_reg, &up->port);
+ pm_qos_remove_request(&up->pm_qos_request);
+ device_init_wakeup(&dev->dev, false);
+
--- /dev/null
+From 77e6fe7fd2b7cba0bf2f2dc8cde51d7b9a35bf74 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Mon, 10 Apr 2017 11:21:39 +0200
+Subject: serial: omap: suspend device on probe errors
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 77e6fe7fd2b7cba0bf2f2dc8cde51d7b9a35bf74 upstream.
+
+Make sure to actually suspend the device before returning after a failed
+(or deferred) probe.
+
+Note that autosuspend must be disabled before runtime pm is disabled in
+order to balance the usage count due to a negative autosuspend delay as
+well as to make the final put suspend the device synchronously.
+
+Fixes: 388bc2622680 ("omap-serial: Fix the error handling in the omap_serial probe")
+Cc: Shubhrajyoti D <shubhrajyoti@ti.com>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Acked-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/omap-serial.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/tty/serial/omap-serial.c
++++ b/drivers/tty/serial/omap-serial.c
+@@ -1712,7 +1712,8 @@ static int serial_omap_probe(struct plat
+ return 0;
+
+ err_add_port:
+- pm_runtime_put(&pdev->dev);
++ pm_runtime_dont_use_autosuspend(&pdev->dev);
++ pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+ pm_qos_remove_request(&up->pm_qos_request);
+ device_init_wakeup(up->dev, false);
--- /dev/null
+From 768d64f491a530062ddad50e016fb27125f8bd7c Mon Sep 17 00:00:00 2001
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Mon, 3 Apr 2017 08:20:59 +0200
+Subject: serial: samsung: Use right device for DMA-mapping calls
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+commit 768d64f491a530062ddad50e016fb27125f8bd7c upstream.
+
+Driver should provide its own struct device for all DMA-mapping calls instead
+of extracting device pointer from DMA engine channel. Although this is harmless
+from the driver operation perspective on ARM architecture, it is always good
+to use the DMA mapping API in a proper way. This patch fixes following DMA API
+debug warning:
+
+WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:1241 check_sync+0x520/0x9f4
+samsung-uart 12c20000.serial: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x000000006df0f580] [size=64 bytes]
+Modules linked in:
+CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.11.0-rc1-00137-g07ca963 #51
+Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
+[<c011aaa4>] (unwind_backtrace) from [<c01127c0>] (show_stack+0x20/0x24)
+[<c01127c0>] (show_stack) from [<c06ba5d8>] (dump_stack+0x84/0xa0)
+[<c06ba5d8>] (dump_stack) from [<c0139528>] (__warn+0x14c/0x180)
+[<c0139528>] (__warn) from [<c01395a4>] (warn_slowpath_fmt+0x48/0x50)
+[<c01395a4>] (warn_slowpath_fmt) from [<c0729058>] (check_sync+0x520/0x9f4)
+[<c0729058>] (check_sync) from [<c072967c>] (debug_dma_sync_single_for_device+0x88/0xc8)
+[<c072967c>] (debug_dma_sync_single_for_device) from [<c0803c10>] (s3c24xx_serial_start_tx_dma+0x100/0x2f8)
+[<c0803c10>] (s3c24xx_serial_start_tx_dma) from [<c0804338>] (s3c24xx_serial_tx_chars+0x198/0x33c)
+
+Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
+Fixes: 62c37eedb74c8 ("serial: samsung: add dma reqest/release functions")
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
+Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/samsung.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+--- a/drivers/tty/serial/samsung.c
++++ b/drivers/tty/serial/samsung.c
+@@ -900,14 +900,13 @@ static int s3c24xx_serial_request_dma(st
+ return -ENOMEM;
+ }
+
+- dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf,
++ dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf,
+ dma->rx_size, DMA_FROM_DEVICE);
+
+ spin_lock_irqsave(&p->port.lock, flags);
+
+ /* TX buffer */
+- dma->tx_addr = dma_map_single(dma->tx_chan->device->dev,
+- p->port.state->xmit.buf,
++ dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf,
+ UART_XMIT_SIZE, DMA_TO_DEVICE);
+
+ spin_unlock_irqrestore(&p->port.lock, flags);
+@@ -921,7 +920,7 @@ static void s3c24xx_serial_release_dma(s
+
+ if (dma->rx_chan) {
+ dmaengine_terminate_all(dma->rx_chan);
+- dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr,
++ dma_unmap_single(p->port.dev, dma->rx_addr,
+ dma->rx_size, DMA_FROM_DEVICE);
+ kfree(dma->rx_buf);
+ dma_release_channel(dma->rx_chan);
+@@ -930,7 +929,7 @@ static void s3c24xx_serial_release_dma(s
+
+ if (dma->tx_chan) {
+ dmaengine_terminate_all(dma->tx_chan);
+- dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr,
++ dma_unmap_single(p->port.dev, dma->tx_addr,
+ UART_XMIT_SIZE, DMA_TO_DEVICE);
+ dma_release_channel(dma->tx_chan);
+ dma->tx_chan = NULL;
cifs-add-misssing-sfm-mapping-for-doublequote.patch
padata-free-correct-variable.patch
arm64-kvm-fix-decoding-of-rt-rt2-when-trapping-aarch32-cp-accesses.patch
+serial-samsung-use-right-device-for-dma-mapping-calls.patch
+serial-omap-fix-runtime-pm-handling-on-unbind.patch
+serial-omap-suspend-device-on-probe-errors.patch
+tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch
+bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch
+bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch
+bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch
--- /dev/null
+From 77dae6134440420bac334581a3ccee94cee1c054 Mon Sep 17 00:00:00 2001
+From: Wang YanQing <udknight@gmail.com>
+Date: Wed, 22 Feb 2017 19:37:08 +0800
+Subject: tty: pty: Fix ldisc flush after userspace become aware of the data already
+
+From: Wang YanQing <udknight@gmail.com>
+
+commit 77dae6134440420bac334581a3ccee94cee1c054 upstream.
+
+While using emacs, cat or others' commands in konsole with recent
+kernels, I have met many times that CTRL-C freeze konsole. After
+konsole freeze I can't type anything, then I have to open a new one,
+it is very annoying.
+
+See bug report:
+https://bugs.kde.org/show_bug.cgi?id=175283
+
+The platform in that bug report is Solaris, but now the pty in linux
+has the same problem or the same behavior as Solaris :)
+
+It has high possibility to trigger the problem follow steps below:
+Note: In my test, BigFile is a text file whose size is bigger than 1G
+1:open konsole
+1:cat BigFile
+2:CTRL-C
+
+After some digging, I find out the reason is that commit 1d1d14da12e7
+("pty: Fix buffer flush deadlock") changes the behavior of pty_flush_buffer.
+
+Thread A Thread B
+-------- --------
+1:n_tty_poll return POLLIN
+ 2:CTRL-C trigger pty_flush_buffer
+ tty_buffer_flush
+ n_tty_flush_buffer
+3:attempt to check count of chars:
+ ioctl(fd, TIOCINQ, &available)
+ available is equal to 0
+
+4:read(fd, buffer, avaiable)
+ return 0
+
+5:konsole close fd
+
+Yes, I know we could use the same patch included in the BUG report as
+a workaround for linux platform too. But I think the data in ldisc is
+belong to application of another side, we shouldn't clear it when we
+want to flush write buffer of this side in pty_flush_buffer. So I think
+it is better to disable ldisc flush in pty_flush_buffer, because its new
+hehavior bring no benefit except that it mess up the behavior between
+POLLIN, and TIOCINQ or FIONREAD.
+
+Also I find no flush_buffer function in others' tty driver has the
+same behavior as current pty_flush_buffer.
+
+Fixes: 1d1d14da12e7 ("pty: Fix buffer flush deadlock")
+Signed-off-by: Wang YanQing <udknight@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/pty.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+--- a/drivers/tty/pty.c
++++ b/drivers/tty/pty.c
+@@ -216,16 +216,11 @@ static int pty_signal(struct tty_struct
+ static void pty_flush_buffer(struct tty_struct *tty)
+ {
+ struct tty_struct *to = tty->link;
+- struct tty_ldisc *ld;
+
+ if (!to)
+ return;
+
+- ld = tty_ldisc_ref(to);
+- tty_buffer_flush(to, ld);
+- if (ld)
+- tty_ldisc_deref(ld);
+-
++ tty_buffer_flush(to, NULL);
+ if (to->packet) {
+ spin_lock_irq(&tty->ctrl_lock);
+ tty->ctrl_status |= TIOCPKT_FLUSHWRITE;