tty: Always allow tcflow(TCOON) to unwedge terminal
RFC 1/1 tty: Always allow tcflow(TCOON) to unwedge terminal
This patch changes user-space behavior (for the better) but I'm not sure that it's consequence-free. Also, it might not be enough to unwedge the terminal if the driver got its own flow control state mangled.
Thoughts?
--- >% ---
Subject: [RFC] tty: Always allow tcflow(TCOON) to unwedge terminal
If terminal flow has been stopped, the terminal can be unwedged by:
tcflow(fd, TCOOFF); tcflow(fd, TCOON);
This works because tcflow(TCOOFF) ensures that ->flow_stopped is set, which allows tcflow(TCOON) to override the terminal flow state in __start_tty().
Instead, allow unwedging with only:
tcflow(fd, TCOON);
by disregarding the existing ->flow_stopped state.
--- drivers/tty/tty_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/tty_ioctl.c +2 -4
@@ -1157,10 +1157,8 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,break ;case TCOON :spin_lock_irq (&tty->flow_lock); -if (tty->flow_stopped) { - tty->flow_stopped =0 ; -__start_tty (tty); - } + tty->flow_stopped =0 ; +__start_tty (tty);spin_unlock_irq (&tty->flow_lock);break ;case TCIOFF :
Signature · 1 line
2.1.0
Greg Kroah-Hartman
maintainerQuoted 13 lines · Peter Hurley
This patch changes user-space behavior (for the better) but I'm not sure that it's consequence-free. Also, it might not be enough to unwedge the terminal if the driver got its own flow control state mangled.
Thoughts?
--- >% ---
Subject: [RFC] tty: Always allow tcflow(TCOON) to unwedge terminalIf terminal flow has been stopped, the terminal can be unwedged by:
tcflow(fd, TCOOFF); tcflow(fd, TCOON);
Quoted 7 lines
This works because tcflow(TCOOFF) ensures that ->flow_stopped is set, which allows tcflow(TCOON) to override the terminal flow state in
__start_tty().Instead, allow unwedging with only:
tcflow(fd, TCOON);by disregarding the existing ->flow_stopped state.
I don't see the benifit here, what are you trying to solve? Sending one extra tcflow command?
thanks,
greg k-h
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 lines · Peter Hurley
This patch changes user-space behavior (for the better) but I'm not sure that it's consequence-free. Also, it might not be enough to unwedge the terminal if the driver got its own flow control state mangled.
Thoughts?
--- >% ---
Subject: [RFC] tty: Always allow tcflow(TCOON) to unwedge terminalIf terminal flow has been stopped, the terminal can be unwedged by:
tcflow(fd, TCOOFF); tcflow(fd, TCOON);This works because tcflow(TCOOFF) ensures that ->flow_stopped is set, which allows tcflow(TCOON) to override the terminal flow state in
__start_tty().
Quoted 6 lines
Quoted 3 lines
Instead, allow unwedging with only:
tcflow(fd, TCOON);by disregarding the existing ->flow_stopped state.
I don't see the benifit here, what are you trying to solve? Sending one extra tcflow command?
It's not common knowledge (and its certainly counterintuitive) that turning off output when output is already turned off (ie., tcflow(TCOOFF)) is the required trickery to unwedge a terminal.
Unwedging directly seems the straightforward approach.
Regards,
Peter Hurley
Greg Kroah-Hartman
maintainerQuoted 23 lines · Peter Hurley
Quoted 22 lines · Greg Kroah-Hartman
Quoted 20 lines · Peter Hurley
This patch changes user-space behavior (for the better) but I'm not sure that it's consequence-free. Also, it might not be enough to unwedge the terminal if the driver got its own flow control state mangled.
Thoughts?
--- >% ---
Subject: [RFC] tty: Always allow tcflow(TCOON) to unwedge terminalIf terminal flow has been stopped, the terminal can be unwedged by:
tcflow(fd, TCOOFF); tcflow(fd, TCOON);This works because tcflow(TCOOFF) ensures that ->flow_stopped is set, which allows tcflow(TCOON) to override the terminal flow state in
__start_tty().Instead, allow unwedging with only:
tcflow(fd, TCOON);by disregarding the existing ->flow_stopped state.
Quoted 8 lines
Quoted 2 lines
I don't see the benifit here, what are you trying to solve? Sending one extra tcflow command?
It's not common knowledge (and its certainly counterintuitive) that turning off output when output is already turned off (ie., tcflow(TCOOFF)) is the required trickery to unwedge a terminal.
Unwedging directly seems the straightforward approach.
What's the odds we break POSIX with this type of change?
I'm all for working around broken hardware in the kernel, but this seems like a very old issue, if it's even one at all, that we would be changing for no one who has reported it (that I know of...)
In other words, I'm really leary of changing userspace functionality without having a real need/reason to.
thanks,
greg k-h
Quoted 27 lines · Greg Kroah-Hartman
Quoted 26 lines · Peter Hurley
Quoted 24 lines · Greg Kroah-Hartman
Quoted 13 lines · Peter Hurley
This patch changes user-space behavior (for the better) but I'm not sure that it's consequence-free. Also, it might not be enough to unwedge the terminal if the driver got its own flow control state mangled.
Thoughts?
--- >% ---
Subject: [RFC] tty: Always allow tcflow(TCOON) to unwedge terminalIf terminal flow has been stopped, the terminal can be unwedged by:
tcflow(fd, TCOOFF); tcflow(fd, TCOON);Quoted 7 lines
This works because tcflow(TCOOFF) ensures that ->flow_stopped is set, which allows tcflow(TCOON) to override the terminal flow state in
__start_tty().Instead, allow unwedging with only:
tcflow(fd, TCOON);by disregarding the existing ->flow_stopped state.
I don't see the benifit here, what are you trying to solve? Sending one extra tcflow command?
Quoted 7 lines
Quoted 5 lines
It's not common knowledge (and its certainly counterintuitive) that turning off output when output is already turned off (ie., tcflow(TCOOFF)) is the required trickery to unwedge a terminal.
Unwedging directly seems the straightforward approach.
What's the odds we break POSIX with this type of change?
SUSv3 and v4 do not specify how tcflow() interacts with flow control from the remote side, so POSIX breakage is not possible.
Quoted 3 lines
I'm all for working around broken hardware in the kernel, but this seems like a very old issue, if it's even one at all, that we would be changing for no one who has reported it (that I know of...)
How to unwedge a terminal comes up from time to time.
Quoted 2 lines
In other words, I'm really leary of changing userspace functionality without having a real need/reason to.
It's possible that this may cause userspace breakage. Some app may call tcflow(TCOON) thus accidently overriding the flow control state when it would have had no effect before.
I'm not invested in this patch so I have no problem if you don't want to take this.
Regards,
Peter Hurley
Quoted 5 lines · Peter Hurley
Quoted 3 lines
I'm all for working around broken hardware in the kernel, but this seems like a very old issue, if it's even one at all, that we would be changing for no one who has reported it (that I know of...)
How to unwedge a terminal comes up from time to time.
Are you trying to unwedge a terminal using hardware flow control, or software flow control?
For software flow control, this is a guarantee that we can make wrt to the behavior of tcflow(). For hardware flow control, we can't make any guarantees, whether it's with tcflow(TCOON) or tcflow(TCOOF); tcflow(TCOON).
Quoted 3 lines
It's possible that this may cause userspace breakage. Some app may call tcflow(TCOON) thus accidently overriding the flow control state when it would have had no effect before.
It's very likely that an application that would be using tcflow() at all would first be sending a TCOOFF, and then sending a TCOON. So this doesn't worry me that much.
Indeed, given that the definition of how TCION and TCIOFF is worded (send a START or STOP command), it's completely reasonable to interpret TCOON and TCOOFF as emulating what would happen if the system received a START or STOP command. (Note though that part of this is that Posix doesn't define CRTSCTS, so POSIX is entirely silent on the subject of hardware flow control).
Cheers,
- Ted
Quoted 9 lines · Theodore Ts'o
Quoted 5 lines · Peter Hurley
Quoted 3 lines
I'm all for working around broken hardware in the kernel, but this seems like a very old issue, if it's even one at all, that we would be changing for no one who has reported it (that I know of...)
How to unwedge a terminal comes up from time to time.
Are you trying to unwedge a terminal using hardware flow control, or software flow control?
For unwedging software flow control.
Like you point out, unwedging hardware flow control would be more complicated and less predictable.
Quoted 13 lines
For software flow control, this is a guarantee that we can make wrt to the behavior of
tcflow(). For hardware flow control, we can't make any guarantees, whether it's with tcflow(TCOON) or tcflow(TCOOF); tcflow(TCOON).Quoted 3 lines
It's possible that this may cause userspace breakage. Some app may call tcflow(TCOON) thus accidently overriding the flow control state when it would have had no effect before.
It's very likely that an application that would be using
tcflow()at all would first be sending a TCOOFF, and then sending a TCOON. So this doesn't worry me that much.
Quoted 6 lines
Indeed, given that the definition of how TCION and TCIOFF is worded (send a START or STOP command), it's completely reasonable to interpret TCOON and TCOOFF as emulating what would happen if the system received a START or STOP command. (Note though that part of this is that Posix doesn't define CRTSCTS, so POSIX is entirely silent on the subject of hardware flow control).
This is the basic interpretation I assumed, and most of what the tty core already did.
Regards,
Peter Hurley
Quoted 3 lines · Peter Hurley
This is the basic interpretation I assumed, and most of what the tty core already did.
Yes, I know. :-)
So it's been a long time since I've had anything to do with the tty code, but FWIW, I'd agree with merging Peter's patch.
Cheers,
- Ted
Quoted 5 lines
It's not common knowledge (and its certainly counterintuitive) that turning off output when output is already turned off (ie., tcflow(TCOOFF)) is the required trickery to unwedge a terminal.
Unwedging directly seems the straightforward approach.
Putting the off/on in the man page might be safer still ?
Quoted 7 lines · One Thousand Gnomes
Quoted 5 lines
It's not common knowledge (and its certainly counterintuitive) that turning off output when output is already turned off (ie., tcflow(TCOOFF)) is the required trickery to unwedge a terminal.
Unwedging directly seems the straightforward approach.
Putting the off/on in the man page might be safer still ?
That's my plan if this patch fails to launch.
Regards,
Peter Hurley