Skip to contentSkip to conversation

tty: amiserial: fix broken TIOCMIWAIT

PATCH In review Johan Hovold 3 participants 3 messages Sep 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: amiserial: fix broken TIOCMIWAIT

A change replacing interruptible_sleep_on() inadvertently broke the TIOCMIWAIT implementation which now immediately returns -EIO (unless there is a racing modem status update).

Replace the old hangup (and signal) detection with a check for the TTY_IO_ERROR flag which is set on hangup.

Fixes 591cee0a3563 ("tty/amiserial: avoid interruptible_sleep_on")
Reported-by [email protected]
Cc Arnd Bergmann <[email protected]>
---
 drivers/tty/amiserial.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/amiserial.c +4 -5
index 28af0fd98181..60f6060b893d 100644
@@ -1138,11 +1138,6 @@ static int rs_ioctl(struct tty_struct *tty,
 				local_irq_save(flags);
 				cnow = info->icount; /* atomic copy */
 				local_irq_restore(flags);
-				if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 
-				    cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
-					ret = -EIO; /* no change => error */
-					break;
-				}
 				if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
 				     ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
 				     ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
@@ -1150,6 +1145,10 @@ static int rs_ioctl(struct tty_struct *tty,
 					ret = 0;
 					break;
 				}
+				if (tty_io_error(tty)) {
+					ret = -EIO;
+					break;
+				}
 				schedule();
 				/* see if a signal did it */
 				if (signal_pending(current)) {
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Johan Hovold

A change replacing interruptible_sleep_on() inadvertently broke the TIOCMIWAIT implementation which now immediately returns -EIO (unless there is a racing modem status update).

Replace the old hangup (and signal) detection with a check for the TTY_IO_ERROR flag which is set on hangup.

You seem you opened a can of worms.

Quoted 37 lines
Fixes 591cee0a3563 ("tty/amiserial: avoid interruptible_sleep_on")
Reported-by [email protected]
Cc Arnd Bergmann <[email protected]>
---
  drivers/tty/amiserial.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/amiserial.c +4 -5
index 28af0fd98181..60f6060b893d 100644
@@ -1138,11 +1138,6 @@ static int rs_ioctl(struct tty_struct *tty,
  				local_irq_save(flags);
  				cnow = info->icount; /* atomic copy */
  				local_irq_restore(flags);
-				if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
-				    cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
-					ret = -EIO; /* no change => error */
-					break;
-				}
  				if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
  				     ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
  				     ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
@@ -1150,6 +1145,10 @@ static int rs_ioctl(struct tty_struct *tty,
  					ret = 0;
  					break;
  				}
+				if (tty_io_error(tty)) {
+					ret = -EIO;
+					break;
+				}
  				schedule();
  				/* see if a signal did it */
  				if (signal_pending(current)) {
Signature · 2 lines
js
suse labs
#2 lore raw
In reply to Johan Hovold
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

A change replacing interruptible_sleep_on() inadvertently broke the TIOCMIWAIT implementation which now immediately returns -EIO (unless there is a racing modem status update).

Replace the old hangup (and signal) detection with a check for the TTY_IO_ERROR flag which is set on hangup.

Quoted 6 lines
Fixes 591cee0a3563 ("tty/amiserial: avoid interruptible_sleep_on")
Reported-by [email protected]
Cc Arnd Bergmann <[email protected]>

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1