]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Mon, 23 Mar 2020 17:11:50 +0000 (13:11 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 23 Mar 2020 17:11:50 +0000 (13:11 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.19/iio-light-vcnl4000-update-sampling-periods-for-vcnl4.patch [new file with mode: 0644]
queue-4.19/kbuild-disable-wpointer-to-enum-cast.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch [new file with mode: 0644]
queue-4.19/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch [new file with mode: 0644]

diff --git a/queue-4.19/iio-light-vcnl4000-update-sampling-periods-for-vcnl4.patch b/queue-4.19/iio-light-vcnl4000-update-sampling-periods-for-vcnl4.patch
new file mode 100644 (file)
index 0000000..67156de
--- /dev/null
@@ -0,0 +1,53 @@
+From 8b5c9d35ed3d888a30b7322577175bb2990b2267 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Feb 2020 16:44:50 +0100
+Subject: iio: light: vcnl4000: update sampling periods for vcnl4200
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Tomas Novotny <tomas@novotny.cz>
+
+[ Upstream commit b42aa97ed5f1169cfd37175ef388ea62ff2dcf43 ]
+
+Vishay has published a new version of "Designing the VCNL4200 Into an
+Application" application note in October 2019. The new version specifies
+that there is +-20% of part to part tolerance. This explains the drift
+seen during experiments. The proximity pulse width is also changed from
+32us to 30us. According to the support, the tolerance also applies to
+ambient light.
+
+So update the sampling periods. As the reading is blocking, current
+users may notice slightly longer response time.
+
+Fixes: be38866fbb97 ("iio: vcnl4000: add support for VCNL4200")
+Reviewed-by: Guido Günther <agx@sigxcpu.org>
+Signed-off-by: Tomas Novotny <tomas@novotny.cz>
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/light/vcnl4000.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
+index 04fd0d4b6f198..d3d65ecb30a5b 100644
+--- a/drivers/iio/light/vcnl4000.c
++++ b/drivers/iio/light/vcnl4000.c
+@@ -150,9 +150,10 @@ static int vcnl4200_init(struct vcnl4000_data *data)
+       data->al_scale = 24000;
+       data->vcnl4200_al.reg = VCNL4200_AL_DATA;
+       data->vcnl4200_ps.reg = VCNL4200_PS_DATA;
+-      /* Integration time is 50ms, but the experiments show 54ms in total. */
+-      data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000);
+-      data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000);
++      /* Default wait time is 50ms, add 20% tolerance. */
++      data->vcnl4200_al.sampling_rate = ktime_set(0, 60000 * 1000);
++      /* Default wait time is 4.8ms, add 20% tolerance. */
++      data->vcnl4200_ps.sampling_rate = ktime_set(0, 5760 * 1000);
+       data->vcnl4200_al.last_measurement = ktime_set(0, 0);
+       data->vcnl4200_ps.last_measurement = ktime_set(0, 0);
+       mutex_init(&data->vcnl4200_al.lock);
+-- 
+2.20.1
+
diff --git a/queue-4.19/kbuild-disable-wpointer-to-enum-cast.patch b/queue-4.19/kbuild-disable-wpointer-to-enum-cast.patch
new file mode 100644 (file)
index 0000000..94e16bf
--- /dev/null
@@ -0,0 +1,48 @@
+From aa5948294ceeeb830ecf856b14853857e6a06595 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Mar 2020 12:41:21 -0700
+Subject: kbuild: Disable -Wpointer-to-enum-cast
+
+From: Nathan Chancellor <natechancellor@gmail.com>
+
+commit 82f2bc2fcc0160d6f82dd1ac64518ae0a4dd183f upstream.
+
+Clang's -Wpointer-to-int-cast deviates from GCC in that it warns when
+casting to enums. The kernel does this in certain places, such as device
+tree matches to set the version of the device being used, which allows
+the kernel to avoid using a gigantic union.
+
+https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L428
+https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L402
+https://elixir.bootlin.com/linux/v5.5.8/source/include/linux/mod_devicetable.h#L264
+
+To avoid a ton of false positive warnings, disable this particular part
+of the warning, which has been split off into a separate diagnostic so
+that the entire warning does not need to be turned off for clang. It
+will be visible under W=1 in case people want to go about fixing these
+easily and enabling the warning treewide.
+
+Cc: stable@vger.kernel.org
+Link: https://github.com/ClangBuiltLinux/linux/issues/887
+Link: https://github.com/llvm/llvm-project/commit/2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/Makefile.extrawarn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
+index 8d5357053f865..486e135d3e30a 100644
+--- a/scripts/Makefile.extrawarn
++++ b/scripts/Makefile.extrawarn
+@@ -72,5 +72,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format)
+ KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
+ KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
+ KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
++KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
+ endif
+ endif
+-- 
+2.20.1
+
index 954cba346bba18bb6fed190ac66bf1e5fa16b7e0..56dc332d183860dc580b6bf1f3acd58d3338e56b 100644 (file)
@@ -49,3 +49,7 @@ mm-slub-be-more-careful-about-the-double-cmpxchg-of-freelist.patch
 mm-slub-prevent-kmalloc_node-crashes-and-memory-leaks.patch
 page-flags-fix-a-crash-at-setpageerror-thp_swap.patch
 x86-mm-split-vmalloc_sync_all.patch
+usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch
+usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch
+iio-light-vcnl4000-update-sampling-periods-for-vcnl4.patch
+kbuild-disable-wpointer-to-enum-cast.patch
diff --git a/queue-4.19/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch b/queue-4.19/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch
new file mode 100644 (file)
index 0000000..1ce3d18
--- /dev/null
@@ -0,0 +1,55 @@
+From fc1c789752566ce91ea042aed9b17751fa8ebcff Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 12 Mar 2020 14:31:00 +0100
+Subject: USB: cdc-acm: fix close_delay and closing_wait units in TIOCSSERIAL
+
+From: Anthony Mallet <anthony.mallet@laas.fr>
+
+[ Upstream commit 633e2b2ded739a34bd0fb1d8b5b871f7e489ea29 ]
+
+close_delay and closing_wait are specified in hundredth of a second but stored
+internally in jiffies. Use the jiffies_to_msecs() and msecs_to_jiffies()
+functions to convert from each other.
+
+Signed-off-by: Anthony Mallet <anthony.mallet@laas.fr>
+Cc: stable <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200312133101.7096-1-anthony.mallet@laas.fr
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/class/cdc-acm.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
+index 59675cc7aa017..709884b99b3e3 100644
+--- a/drivers/usb/class/cdc-acm.c
++++ b/drivers/usb/class/cdc-acm.c
+@@ -914,10 +914,10 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
+       memset(&tmp, 0, sizeof(tmp));
+       tmp.xmit_fifo_size = acm->writesize;
+       tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
+-      tmp.close_delay = acm->port.close_delay / 10;
++      tmp.close_delay = jiffies_to_msecs(acm->port.close_delay) / 10;
+       tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
+                               ASYNC_CLOSING_WAIT_NONE :
+-                              acm->port.closing_wait / 10;
++                              jiffies_to_msecs(acm->port.closing_wait) / 10;
+       if (copy_to_user(info, &tmp, sizeof(tmp)))
+               return -EFAULT;
+@@ -935,9 +935,10 @@ static int set_serial_info(struct acm *acm,
+       if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
+               return -EFAULT;
+-      close_delay = new_serial.close_delay * 10;
++      close_delay = msecs_to_jiffies(new_serial.close_delay * 10);
+       closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
+-                      ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
++                      ASYNC_CLOSING_WAIT_NONE :
++                      msecs_to_jiffies(new_serial.closing_wait * 10);
+       mutex_lock(&acm->port.mutex);
+-- 
+2.20.1
+
diff --git a/queue-4.19/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch b/queue-4.19/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch
new file mode 100644 (file)
index 0000000..07853fd
--- /dev/null
@@ -0,0 +1,84 @@
+From b4390180f6aafc4be3a962ff657d84c484bc3bf4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 12 Mar 2020 14:31:01 +0100
+Subject: USB: cdc-acm: fix rounding error in TIOCSSERIAL
+
+From: Anthony Mallet <anthony.mallet@laas.fr>
+
+[ Upstream commit b401f8c4f492cbf74f3f59c9141e5be3071071bb ]
+
+By default, tty_port_init() initializes those parameters to a multiple
+of HZ. For instance in line 69 of tty_port.c:
+   port->close_delay = (50 * HZ) / 100;
+https://github.com/torvalds/linux/blob/master/drivers/tty/tty_port.c#L69
+
+With e.g. CONFIG_HZ = 250 (as this is the case for Ubuntu 18.04
+linux-image-4.15.0-37-generic), the default setting for close_delay is
+thus 125.
+
+When ioctl(fd, TIOCGSERIAL, &s) is executed, the setting returned in
+user space is '12' (125/10). When ioctl(fd, TIOCSSERIAL, &s) is then
+executed with the same setting '12', the value is interpreted as '120'
+which is different from the current setting and a EPERM error may be
+raised by set_serial_info() if !CAP_SYS_ADMIN.
+https://github.com/torvalds/linux/blob/master/drivers/usb/class/cdc-acm.c#L919
+
+Fixes: ba2d8ce9db0a6 ("cdc-acm: implement TIOCSSERIAL to avoid blocking close(2)")
+Signed-off-by: Anthony Mallet <anthony.mallet@laas.fr>
+Cc: stable <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200312133101.7096-2-anthony.mallet@laas.fr
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/class/cdc-acm.c | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
+index 709884b99b3e3..8689bf7ba60ff 100644
+--- a/drivers/usb/class/cdc-acm.c
++++ b/drivers/usb/class/cdc-acm.c
+@@ -930,6 +930,7 @@ static int set_serial_info(struct acm *acm,
+ {
+       struct serial_struct new_serial;
+       unsigned int closing_wait, close_delay;
++      unsigned int old_closing_wait, old_close_delay;
+       int retval = 0;
+       if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
+@@ -940,18 +941,24 @@ static int set_serial_info(struct acm *acm,
+                       ASYNC_CLOSING_WAIT_NONE :
+                       msecs_to_jiffies(new_serial.closing_wait * 10);
++      /* we must redo the rounding here, so that the values match */
++      old_close_delay = jiffies_to_msecs(acm->port.close_delay) / 10;
++      old_closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
++                              ASYNC_CLOSING_WAIT_NONE :
++                              jiffies_to_msecs(acm->port.closing_wait) / 10;
++
+       mutex_lock(&acm->port.mutex);
+-      if (!capable(CAP_SYS_ADMIN)) {
+-              if ((close_delay != acm->port.close_delay) ||
+-                  (closing_wait != acm->port.closing_wait))
++      if ((new_serial.close_delay != old_close_delay) ||
++            (new_serial.closing_wait != old_closing_wait)) {
++              if (!capable(CAP_SYS_ADMIN))
+                       retval = -EPERM;
+-              else
+-                      retval = -EOPNOTSUPP;
+-      } else {
+-              acm->port.close_delay  = close_delay;
+-              acm->port.closing_wait = closing_wait;
+-      }
++              else {
++                      acm->port.close_delay  = close_delay;
++                      acm->port.closing_wait = closing_wait;
++              }
++      } else
++              retval = -EOPNOTSUPP;
+       mutex_unlock(&acm->port.mutex);
+       return retval;
+-- 
+2.20.1
+