Public bug reported:

With linux kernel <=4.15.0-43 I can start reading serial device (TTY) in
block mode and write from another process at the same time
(simultaneously). After update to 4.15.0-45 I can't.

[Steps to reproduce]
1) Run in terminal:
cat /dev/ttyS0
"cat" must block terminal and wait for data.
2) Run in another terminal:
echo > /dev/ttyS0

Expected:
"cat" continue wait data and not exit.

Actual:
"cat" exit with return code "1" and show error -EAGAIN (-11): 
"cat: /dev/ttyS0: Resource temporarily unavailable"


I think it's regression in kernel, due to new ldisc checks in TTY driver. 
Please see:
git diff  Ubuntu-hwe-4.15.0-43.46_16.04.1 Ubuntu-hwe-4.15.0-45.48_16.04.1 -- 
drivers/tty/tty_ldisc.c
git diff  Ubuntu-hwe-4.15.0-43.46_16.04.1 Ubuntu-hwe-4.15.0-45.48_16.04.1 -- 
drivers/tty/n_tty.c

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 0fd18f5..48fe8d9 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -340,6 +340,11 @@ int tty_ldisc_lock(struct tty_struct *tty, unsigned long 
timeout)
 {
        int ret;
 
+       /* Kindly asking blocked readers to release the read side */
+       set_bit(TTY_LDISC_CHANGING, &tty->flags);
+       wake_up_interruptible_all(&tty->read_wait);
+       wake_up_interruptible_all(&tty->write_wait);
+
        ret = __tty_ldisc_lock(tty, timeout);
        if (!ret)
                return -EBUSY;


diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 63c593a..9805ac1 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2188,7 +2197,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct 
file *file,
                                        break;
                                if (!timeout)
                                        break;
-                               if (file->f_flags & O_NONBLOCK) {
+                               if (tty_io_nonblock(tty, file)) {
                                        retval = -EAGAIN;
                                        break;
                                }
@@ -2342,7 +2351,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct 
file *file,
                }
                if (!nr)
                        break;
-               if (file->f_flags & O_NONBLOCK) {
+               if (tty_io_nonblock(tty, file)) {
                        retval = -EAGAIN;
                        break;
                }

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-4.15.0-45-generic 4.15.0-45.48~16.04.1
ProcVersionSignature: Ubuntu 4.15.0-45.48~16.04.1-generic 4.15.18
Uname: Linux 4.15.0-45-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia_drm nvidia_modeset nvidia
ApportVersion: 2.20.1-0ubuntu2.18
Architecture: amd64
CurrentDesktop: MATE
Date: Thu Feb  7 11:42:43 2019
InstallationDate: Installed on 2017-08-01 (554 days ago)
InstallationMedia: Ubuntu 16.04.2 LTS "Xenial Xerus" - Release amd64 
(20170215.2)
SourcePackage: linux-signed-hwe
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: linux-signed-hwe (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug xenial

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1815021

Title:
  Can't read and write simultaneously from serial port

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-signed-hwe/+bug/1815021/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to