]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jan 2020 23:05:20 +0000 (00:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jan 2020 23:05:20 +0000 (00:05 +0100)
added patches:
compat_ioctl-handle-siocoutqnsd.patch
f2fs-fix-potential-overflow.patch
media-exynos4-is-fix-recursive-locking-in-isp_video_release.patch
mtd-spi-nor-fix-silent-truncation-in-spi_nor_read.patch
pci-ptm-remove-spurious-d-from-granularity-message.patch
powerpc-powernv-disable-native-pcie-port-management.patch
rtc-msm6242-fix-reading-of-10-hour-digit.patch
rtlwifi-remove-unnecessary-null-check-in-rtl_regd_init.patch
spi-atmel-fix-handling-of-cs_change-set-on-non-last-xfer.patch
tty-serial-imx-use-the-sg-count-from-dma_map_sg.patch
tty-serial-pch_uart-correct-usage-of-dma_unmap_sg.patch

12 files changed:
queue-4.9/compat_ioctl-handle-siocoutqnsd.patch [new file with mode: 0644]
queue-4.9/f2fs-fix-potential-overflow.patch [new file with mode: 0644]
queue-4.9/media-exynos4-is-fix-recursive-locking-in-isp_video_release.patch [new file with mode: 0644]
queue-4.9/mtd-spi-nor-fix-silent-truncation-in-spi_nor_read.patch [new file with mode: 0644]
queue-4.9/pci-ptm-remove-spurious-d-from-granularity-message.patch [new file with mode: 0644]
queue-4.9/powerpc-powernv-disable-native-pcie-port-management.patch [new file with mode: 0644]
queue-4.9/rtc-msm6242-fix-reading-of-10-hour-digit.patch [new file with mode: 0644]
queue-4.9/rtlwifi-remove-unnecessary-null-check-in-rtl_regd_init.patch [new file with mode: 0644]
queue-4.9/series
queue-4.9/spi-atmel-fix-handling-of-cs_change-set-on-non-last-xfer.patch [new file with mode: 0644]
queue-4.9/tty-serial-imx-use-the-sg-count-from-dma_map_sg.patch [new file with mode: 0644]
queue-4.9/tty-serial-pch_uart-correct-usage-of-dma_unmap_sg.patch [new file with mode: 0644]

diff --git a/queue-4.9/compat_ioctl-handle-siocoutqnsd.patch b/queue-4.9/compat_ioctl-handle-siocoutqnsd.patch
new file mode 100644 (file)
index 0000000..b79f168
--- /dev/null
@@ -0,0 +1,34 @@
+From 9d7bf41fafa5b5ddd4c13eb39446b0045f0a8167 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Mon, 3 Jun 2019 23:06:00 +0200
+Subject: compat_ioctl: handle SIOCOUTQNSD
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 9d7bf41fafa5b5ddd4c13eb39446b0045f0a8167 upstream.
+
+Unlike the normal SIOCOUTQ, SIOCOUTQNSD was never handled in compat
+mode. Add it to the common socket compat handler along with similar
+ones.
+
+Fixes: 2f4e1b397097 ("tcp: ioctl type SIOCOUTQNSD returns amount of data not sent")
+Cc: Eric Dumazet <edumazet@google.com>
+Cc: netdev@vger.kernel.org
+Cc: "David S. Miller" <davem@davemloft.net>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/socket.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/net/socket.c
++++ b/net/socket.c
+@@ -3160,6 +3160,7 @@ static int compat_sock_ioctl_trans(struc
+       case SIOCSARP:
+       case SIOCGARP:
+       case SIOCDARP:
++      case SIOCOUTQNSD:
+       case SIOCATMARK:
+               return sock_do_ioctl(net, sock, cmd, arg);
+       }
diff --git a/queue-4.9/f2fs-fix-potential-overflow.patch b/queue-4.9/f2fs-fix-potential-overflow.patch
new file mode 100644 (file)
index 0000000..ea95bf9
--- /dev/null
@@ -0,0 +1,48 @@
+From 1f0d5c911b64165c9754139a26c8c2fad352c132 Mon Sep 17 00:00:00 2001
+From: Chao Yu <chao@kernel.org>
+Date: Thu, 7 Nov 2019 17:29:00 +0800
+Subject: f2fs: fix potential overflow
+
+From: Chao Yu <yuchao0@huawei.com>
+
+commit 1f0d5c911b64165c9754139a26c8c2fad352c132 upstream.
+
+We expect 64-bit calculation result from below statement, however
+in 32-bit machine, looped left shift operation on pgoff_t type
+variable may cause overflow issue, fix it by forcing type cast.
+
+page->index << PAGE_SHIFT;
+
+Fixes: 26de9b117130 ("f2fs: avoid unnecessary updating inode during fsync")
+Fixes: 0a2aa8fbb969 ("f2fs: refactor __exchange_data_block for speed up")
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/f2fs/data.c |    2 +-
+ fs/f2fs/file.c |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/f2fs/data.c
++++ b/fs/f2fs/data.c
+@@ -1267,7 +1267,7 @@ static int f2fs_write_data_page(struct p
+       loff_t i_size = i_size_read(inode);
+       const pgoff_t end_index = ((unsigned long long) i_size)
+                                                       >> PAGE_SHIFT;
+-      loff_t psize = (page->index + 1) << PAGE_SHIFT;
++      loff_t psize = (loff_t)(page->index + 1) << PAGE_SHIFT;
+       unsigned offset = 0;
+       bool need_balance_fs = false;
+       int err = 0;
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -980,7 +980,7 @@ static int __clone_blkaddrs(struct inode
+                               }
+                               dn.ofs_in_node++;
+                               i++;
+-                              new_size = (dst + i) << PAGE_SHIFT;
++                              new_size = (loff_t)(dst + i) << PAGE_SHIFT;
+                               if (dst_inode->i_size < new_size)
+                                       f2fs_i_size_write(dst_inode, new_size);
+                       } while (--ilen && (do_replace[i] || blkaddr[i] == NULL_ADDR));
diff --git a/queue-4.9/media-exynos4-is-fix-recursive-locking-in-isp_video_release.patch b/queue-4.9/media-exynos4-is-fix-recursive-locking-in-isp_video_release.patch
new file mode 100644 (file)
index 0000000..8397a24
--- /dev/null
@@ -0,0 +1,36 @@
+From 704c6c80fb471d1bb0ef0d61a94617d1d55743cd Mon Sep 17 00:00:00 2001
+From: Seung-Woo Kim <sw0312.kim@samsung.com>
+Date: Fri, 18 Oct 2019 07:20:52 -0300
+Subject: media: exynos4-is: Fix recursive locking in isp_video_release()
+
+From: Seung-Woo Kim <sw0312.kim@samsung.com>
+
+commit 704c6c80fb471d1bb0ef0d61a94617d1d55743cd upstream.
+
+>From isp_video_release(), &isp->video_lock is held and subsequent
+vb2_fop_release() tries to lock vdev->lock which is same with the
+previous one. Replace vb2_fop_release() with _vb2_fop_release() to
+fix the recursive locking.
+
+Fixes: 1380f5754cb0 ("[media] videobuf2: Add missing lock held on vb2_fop_release")
+Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
+Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/exynos4-is/fimc-isp-video.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
++++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
+@@ -316,7 +316,7 @@ static int isp_video_release(struct file
+               ivc->streaming = 0;
+       }
+-      vb2_fop_release(file);
++      _vb2_fop_release(file, NULL);
+       if (v4l2_fh_is_singular_file(file)) {
+               fimc_pipeline_call(&ivc->ve, close);
diff --git a/queue-4.9/mtd-spi-nor-fix-silent-truncation-in-spi_nor_read.patch b/queue-4.9/mtd-spi-nor-fix-silent-truncation-in-spi_nor_read.patch
new file mode 100644 (file)
index 0000000..509f6ce
--- /dev/null
@@ -0,0 +1,34 @@
+From a719a75a7761e4139dd099330d9fe3589d844f9b Mon Sep 17 00:00:00 2001
+From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
+Date: Wed, 30 Oct 2019 21:48:59 +0300
+Subject: mtd: spi-nor: fix silent truncation in spi_nor_read()
+
+From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
+
+commit a719a75a7761e4139dd099330d9fe3589d844f9b upstream.
+
+spi_nor_read() assigns the result of 'ssize_t spi_nor_read_data()'
+to the 'int ret' variable, while 'ssize_t' is a 64-bit type and *int*
+is a 32-bit type on the 64-bit machines. This silent truncation isn't
+really valid, so fix up the variable's type.
+
+Fixes: 59451e1233bd ("mtd: spi-nor: change return value of read/write")
+Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
+Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/spi-nor/spi-nor.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/mtd/spi-nor/spi-nor.c
++++ b/drivers/mtd/spi-nor/spi-nor.c
+@@ -1046,7 +1046,7 @@ static int spi_nor_read(struct mtd_info
+                       size_t *retlen, u_char *buf)
+ {
+       struct spi_nor *nor = mtd_to_spi_nor(mtd);
+-      int ret;
++      ssize_t ret;
+       dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);
diff --git a/queue-4.9/pci-ptm-remove-spurious-d-from-granularity-message.patch b/queue-4.9/pci-ptm-remove-spurious-d-from-granularity-message.patch
new file mode 100644 (file)
index 0000000..7ba8662
--- /dev/null
@@ -0,0 +1,37 @@
+From 127a7709495db52a41012deaebbb7afc231dad91 Mon Sep 17 00:00:00 2001
+From: Bjorn Helgaas <bhelgaas@google.com>
+Date: Wed, 6 Nov 2019 15:30:48 -0600
+Subject: PCI/PTM: Remove spurious "d" from granularity message
+
+From: Bjorn Helgaas <bhelgaas@google.com>
+
+commit 127a7709495db52a41012deaebbb7afc231dad91 upstream.
+
+The granularity message has an extra "d":
+
+  pci 0000:02:00.0: PTM enabled, 4dns granularity
+
+Remove the "d" so the message is simply "PTM enabled, 4ns granularity".
+
+Fixes: 8b2ec318eece ("PCI: Add PTM clock granularity information")
+Link: https://lore.kernel.org/r/20191106222420.10216-2-helgaas@kernel.org
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Reviewed-by: Andrew Murray <andrew.murray@arm.com>
+Cc: Jonathan Yong <jonathan.yong@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/pcie/ptm.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/pci/pcie/ptm.c
++++ b/drivers/pci/pcie/ptm.c
+@@ -29,7 +29,7 @@ static void pci_ptm_info(struct pci_dev
+               snprintf(clock_desc, sizeof(clock_desc), ">254ns");
+               break;
+       default:
+-              snprintf(clock_desc, sizeof(clock_desc), "%udns",
++              snprintf(clock_desc, sizeof(clock_desc), "%uns",
+                        dev->ptm_granularity);
+               break;
+       }
diff --git a/queue-4.9/powerpc-powernv-disable-native-pcie-port-management.patch b/queue-4.9/powerpc-powernv-disable-native-pcie-port-management.patch
new file mode 100644 (file)
index 0000000..cf0aeea
--- /dev/null
@@ -0,0 +1,76 @@
+From 9d72dcef891030545f39ad386a30cf91df517fb2 Mon Sep 17 00:00:00 2001
+From: Oliver O'Halloran <oohall@gmail.com>
+Date: Mon, 18 Nov 2019 17:55:53 +1100
+Subject: powerpc/powernv: Disable native PCIe port management
+
+From: Oliver O'Halloran <oohall@gmail.com>
+
+commit 9d72dcef891030545f39ad386a30cf91df517fb2 upstream.
+
+On PowerNV the PCIe topology is (currently) managed by the powernv platform
+code in Linux in cooperation with the platform firmware. Linux's native
+PCIe port service drivers operate independently of both and this can cause
+problems.
+
+The main issue is that the portbus driver will conflict with the platform
+specific hotplug driver (pnv_php) over ownership of the MSI used to notify
+the host when a hotplug event occurs. The portbus driver claims this MSI on
+behalf of the individual port services because the same interrupt is used
+for hotplug events, PMEs (on root ports), and link bandwidth change
+notifications. The portbus driver will always claim the interrupt even if
+the individual port service drivers, such as pciehp, are compiled out.
+
+The second, bigger, problem is that the hotplug port service driver
+fundamentally does not work on PowerNV. The platform assumes that all
+PCI devices have a corresponding arch-specific handle derived from the DT
+node for the device (pci_dn) and without one the platform will not allow
+a PCI device to be enabled. This problem is largely due to historical
+baggage, but it can't be resolved without significant re-factoring of the
+platform PCI support.
+
+We can fix these problems in the interim by setting the
+"pcie_ports_disabled" flag during platform initialisation. The flag
+indicates the platform owns the PCIe ports which stops the portbus driver
+from being registered.
+
+This does have the side effect of disabling all port services drivers
+that is: AER, PME, BW notifications, hotplug, and DPC. However, this is
+not a huge disadvantage on PowerNV since these services are either unused
+or handled through other means.
+
+Fixes: 66725152fb9f ("PCI/hotplug: PowerPC PowerNV PCI hotplug driver")
+Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20191118065553.30362-1-oohall@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/platforms/powernv/pci.c |   17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+--- a/arch/powerpc/platforms/powernv/pci.c
++++ b/arch/powerpc/platforms/powernv/pci.c
+@@ -923,6 +923,23 @@ void __init pnv_pci_init(void)
+       if (!firmware_has_feature(FW_FEATURE_OPAL))
+               return;
++#ifdef CONFIG_PCIEPORTBUS
++      /*
++       * On PowerNV PCIe devices are (currently) managed in cooperation
++       * with firmware. This isn't *strictly* required, but there's enough
++       * assumptions baked into both firmware and the platform code that
++       * it's unwise to allow the portbus services to be used.
++       *
++       * We need to fix this eventually, but for now set this flag to disable
++       * the portbus driver. The AER service isn't required since that AER
++       * events are handled via EEH. The pciehp hotplug driver can't work
++       * without kernel changes (and portbus binding breaks pnv_php). The
++       * other services also require some thinking about how we're going
++       * to integrate them.
++       */
++      pcie_ports_disabled = true;
++#endif
++
+       /* Look for IODA IO-Hubs. */
+       for_each_compatible_node(np, NULL, "ibm,ioda-hub") {
+               pnv_pci_init_ioda_hub(np);
diff --git a/queue-4.9/rtc-msm6242-fix-reading-of-10-hour-digit.patch b/queue-4.9/rtc-msm6242-fix-reading-of-10-hour-digit.patch
new file mode 100644 (file)
index 0000000..307c5f9
--- /dev/null
@@ -0,0 +1,40 @@
+From e34494c8df0cd96fc432efae121db3212c46ae48 Mon Sep 17 00:00:00 2001
+From: Kars de Jong <jongk@linux-m68k.org>
+Date: Sat, 16 Nov 2019 12:05:48 +0100
+Subject: rtc: msm6242: Fix reading of 10-hour digit
+
+From: Kars de Jong <jongk@linux-m68k.org>
+
+commit e34494c8df0cd96fc432efae121db3212c46ae48 upstream.
+
+The driver was reading the wrong register as the 10-hour digit due to
+a misplaced ')'. It was in fact reading the 1-second digit register due
+to this bug.
+
+Also remove the use of a magic number for the hour mask and use the define
+for it which was already present.
+
+Fixes: 4f9b9bba1dd1 ("rtc: Add an RTC driver for the Oki MSM6242")
+Tested-by: Kars de Jong <jongk@linux-m68k.org>
+Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
+Link: https://lore.kernel.org/r/20191116110548.8562-1-jongk@linux-m68k.org
+Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/rtc/rtc-msm6242.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/rtc/rtc-msm6242.c
++++ b/drivers/rtc/rtc-msm6242.c
+@@ -132,7 +132,8 @@ static int msm6242_read_time(struct devi
+                     msm6242_read(priv, MSM6242_SECOND1);
+       tm->tm_min  = msm6242_read(priv, MSM6242_MINUTE10) * 10 +
+                     msm6242_read(priv, MSM6242_MINUTE1);
+-      tm->tm_hour = (msm6242_read(priv, MSM6242_HOUR10 & 3)) * 10 +
++      tm->tm_hour = (msm6242_read(priv, MSM6242_HOUR10) &
++                     MSM6242_HOUR10_HR_MASK) * 10 +
+                     msm6242_read(priv, MSM6242_HOUR1);
+       tm->tm_mday = msm6242_read(priv, MSM6242_DAY10) * 10 +
+                     msm6242_read(priv, MSM6242_DAY1);
diff --git a/queue-4.9/rtlwifi-remove-unnecessary-null-check-in-rtl_regd_init.patch b/queue-4.9/rtlwifi-remove-unnecessary-null-check-in-rtl_regd_init.patch
new file mode 100644 (file)
index 0000000..d34c6c7
--- /dev/null
@@ -0,0 +1,51 @@
+From 091c6e9c083f7ebaff00b37ad13562d51464d175 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <natechancellor@gmail.com>
+Date: Tue, 22 Oct 2019 17:47:03 -0700
+Subject: rtlwifi: Remove unnecessary NULL check in rtl_regd_init
+
+From: Nathan Chancellor <natechancellor@gmail.com>
+
+commit 091c6e9c083f7ebaff00b37ad13562d51464d175 upstream.
+
+When building with Clang + -Wtautological-pointer-compare:
+
+drivers/net/wireless/realtek/rtlwifi/regd.c:389:33: warning: comparison
+of address of 'rtlpriv->regd' equal to a null pointer is always false
+[-Wtautological-pointer-compare]
+        if (wiphy == NULL || &rtlpriv->regd == NULL)
+                              ~~~~~~~~~^~~~    ~~~~
+1 warning generated.
+
+The address of an array member is never NULL unless it is the first
+struct member so remove the unnecessary check. This was addressed in
+the staging version of the driver in commit f986978b32b3 ("Staging:
+rtlwifi: remove unnecessary NULL check").
+
+While we are here, fix the following checkpatch warning:
+
+CHECK: Comparison to NULL could be written "!wiphy"
+35: FILE: drivers/net/wireless/realtek/rtlwifi/regd.c:389:
++       if (wiphy == NULL)
+
+Fixes: 0c8173385e54 ("rtl8192ce: Add new driver")
+Link:https://github.com/ClangBuiltLinux/linux/issues/750
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Acked-by: Ping-Ke Shih <pkshih@realtek.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/wireless/realtek/rtlwifi/regd.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/realtek/rtlwifi/regd.c
++++ b/drivers/net/wireless/realtek/rtlwifi/regd.c
+@@ -427,7 +427,7 @@ int rtl_regd_init(struct ieee80211_hw *h
+       struct wiphy *wiphy = hw->wiphy;
+       struct country_code_to_enum_rd *country = NULL;
+-      if (wiphy == NULL || &rtlpriv->regd == NULL)
++      if (!wiphy)
+               return -EINVAL;
+       /* init country_code from efuse channel plan */
index a43463f2a76e2ff7d51cbe401e4895107f801d10..303ed63c890932f3718f9d233f9327229a2058cb 100644 (file)
@@ -29,3 +29,14 @@ platform-x86-asus-wmi-fix-keyboard-brightness-cannot-be-set-to-0.patch
 iio-imu-adis16480-assign-bias-value-only-if-operation-succeeded.patch
 mei-fix-modalias-documentation.patch
 clk-samsung-exynos5420-preserve-cpu-clocks-configuration-during-suspend-resume.patch
+compat_ioctl-handle-siocoutqnsd.patch
+pci-ptm-remove-spurious-d-from-granularity-message.patch
+powerpc-powernv-disable-native-pcie-port-management.patch
+tty-serial-imx-use-the-sg-count-from-dma_map_sg.patch
+tty-serial-pch_uart-correct-usage-of-dma_unmap_sg.patch
+media-exynos4-is-fix-recursive-locking-in-isp_video_release.patch
+mtd-spi-nor-fix-silent-truncation-in-spi_nor_read.patch
+spi-atmel-fix-handling-of-cs_change-set-on-non-last-xfer.patch
+rtlwifi-remove-unnecessary-null-check-in-rtl_regd_init.patch
+f2fs-fix-potential-overflow.patch
+rtc-msm6242-fix-reading-of-10-hour-digit.patch
diff --git a/queue-4.9/spi-atmel-fix-handling-of-cs_change-set-on-non-last-xfer.patch b/queue-4.9/spi-atmel-fix-handling-of-cs_change-set-on-non-last-xfer.patch
new file mode 100644 (file)
index 0000000..8f921a3
--- /dev/null
@@ -0,0 +1,63 @@
+From fed8d8c7a6dc2a76d7764842853d81c770b0788e Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Fri, 18 Oct 2019 17:35:04 +0200
+Subject: spi: atmel: fix handling of cs_change set on non-last xfer
+
+From: Mans Rullgard <mans@mansr.com>
+
+commit fed8d8c7a6dc2a76d7764842853d81c770b0788e upstream.
+
+The driver does the wrong thing when cs_change is set on a non-last
+xfer in a message.  When cs_change is set, the driver deactivates the
+CS and leaves it off until a later xfer again has cs_change set whereas
+it should be briefly toggling CS off and on again.
+
+This patch brings the behaviour of the driver back in line with the
+documentation and common sense.  The delay of 10 us is the same as is
+used by the default spi_transfer_one_message() function in spi.c.
+[gregory: rebased on for-5.5 from spi tree]
+Fixes: 8090d6d1a415 ("spi: atmel: Refactor spi-atmel to use SPI framework queue")
+Signed-off-by: Mans Rullgard <mans@mansr.com>
+Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
+Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
+Link: https://lore.kernel.org/r/20191018153504.4249-1-gregory.clement@bootlin.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/spi/spi-atmel.c |   10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+--- a/drivers/spi/spi-atmel.c
++++ b/drivers/spi/spi-atmel.c
+@@ -315,7 +315,6 @@ struct atmel_spi {
+       struct atmel_spi_dma    dma;
+       bool                    keep_cs;
+-      bool                    cs_active;
+       u32                     fifo_size;
+ };
+@@ -1404,11 +1403,9 @@ static int atmel_spi_one_transfer(struct
+                                &msg->transfers)) {
+                       as->keep_cs = true;
+               } else {
+-                      as->cs_active = !as->cs_active;
+-                      if (as->cs_active)
+-                              cs_activate(as, msg->spi);
+-                      else
+-                              cs_deactivate(as, msg->spi);
++                      cs_deactivate(as, msg->spi);
++                      udelay(10);
++                      cs_activate(as, msg->spi);
+               }
+       }
+@@ -1431,7 +1428,6 @@ static int atmel_spi_transfer_one_messag
+       atmel_spi_lock(as);
+       cs_activate(as, spi);
+-      as->cs_active = true;
+       as->keep_cs = false;
+       msg->status = 0;
diff --git a/queue-4.9/tty-serial-imx-use-the-sg-count-from-dma_map_sg.patch b/queue-4.9/tty-serial-imx-use-the-sg-count-from-dma_map_sg.patch
new file mode 100644 (file)
index 0000000..0b4ac66
--- /dev/null
@@ -0,0 +1,33 @@
+From 596fd8dffb745afcebc0ec6968e17fe29f02044c Mon Sep 17 00:00:00 2001
+From: Peng Fan <peng.fan@nxp.com>
+Date: Thu, 7 Nov 2019 06:42:53 +0000
+Subject: tty: serial: imx: use the sg count from dma_map_sg
+
+From: Peng Fan <peng.fan@nxp.com>
+
+commit 596fd8dffb745afcebc0ec6968e17fe29f02044c upstream.
+
+The dmaengine_prep_slave_sg needs to use sg count returned
+by dma_map_sg, not use sport->dma_tx_nents, because the return
+value of dma_map_sg is not always same with "nents".
+
+Fixes: b4cdc8f61beb ("serial: imx: add DMA support for imx6q")
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Link: https://lore.kernel.org/r/1573108875-26530-1-git-send-email-peng.fan@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/imx.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/tty/serial/imx.c
++++ b/drivers/tty/serial/imx.c
+@@ -548,7 +548,7 @@ static void imx_dma_tx(struct imx_port *
+               dev_err(dev, "DMA mapping error for TX.\n");
+               return;
+       }
+-      desc = dmaengine_prep_slave_sg(chan, sgl, sport->dma_tx_nents,
++      desc = dmaengine_prep_slave_sg(chan, sgl, ret,
+                                       DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
+       if (!desc) {
+               dma_unmap_sg(dev, sgl, sport->dma_tx_nents,
diff --git a/queue-4.9/tty-serial-pch_uart-correct-usage-of-dma_unmap_sg.patch b/queue-4.9/tty-serial-pch_uart-correct-usage-of-dma_unmap_sg.patch
new file mode 100644 (file)
index 0000000..fe231eb
--- /dev/null
@@ -0,0 +1,65 @@
+From 74887542fdcc92ad06a48c0cca17cdf09fc8aa00 Mon Sep 17 00:00:00 2001
+From: Peng Fan <peng.fan@nxp.com>
+Date: Wed, 13 Nov 2019 05:37:42 +0000
+Subject: tty: serial: pch_uart: correct usage of dma_unmap_sg
+
+From: Peng Fan <peng.fan@nxp.com>
+
+commit 74887542fdcc92ad06a48c0cca17cdf09fc8aa00 upstream.
+
+Per Documentation/DMA-API-HOWTO.txt,
+To unmap a scatterlist, just call:
+       dma_unmap_sg(dev, sglist, nents, direction);
+
+.. note::
+
+       The 'nents' argument to the dma_unmap_sg call must be
+       the _same_ one you passed into the dma_map_sg call,
+       it should _NOT_ be the 'count' value _returned_ from the
+       dma_map_sg call.
+
+However in the driver, priv->nent is directly assigned with value
+returned from dma_map_sg, and dma_unmap_sg use priv->nent for unmap,
+this breaks the API usage.
+
+So introduce a new entry orig_nent to remember 'nents'.
+
+Fixes: da3564ee027e ("pch_uart: add multi-scatter processing")
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Link: https://lore.kernel.org/r/1573623259-6339-1-git-send-email-peng.fan@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/pch_uart.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/tty/serial/pch_uart.c
++++ b/drivers/tty/serial/pch_uart.c
+@@ -252,6 +252,7 @@ struct eg20t_port {
+       struct dma_chan                 *chan_rx;
+       struct scatterlist              *sg_tx_p;
+       int                             nent;
++      int                             orig_nent;
+       struct scatterlist              sg_rx;
+       int                             tx_dma_use;
+       void                            *rx_buf_virt;
+@@ -806,9 +807,10 @@ static void pch_dma_tx_complete(void *ar
+       }
+       xmit->tail &= UART_XMIT_SIZE - 1;
+       async_tx_ack(priv->desc_tx);
+-      dma_unmap_sg(port->dev, sg, priv->nent, DMA_TO_DEVICE);
++      dma_unmap_sg(port->dev, sg, priv->orig_nent, DMA_TO_DEVICE);
+       priv->tx_dma_use = 0;
+       priv->nent = 0;
++      priv->orig_nent = 0;
+       kfree(priv->sg_tx_p);
+       pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_TX_INT);
+ }
+@@ -1033,6 +1035,7 @@ static unsigned int dma_handle_tx(struct
+               dev_err(priv->port.dev, "%s:dma_map_sg Failed\n", __func__);
+               return 0;
+       }
++      priv->orig_nent = num;
+       priv->nent = nent;
+       for (i = 0; i < nent; i++, sg++) {