linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: linux-serial@vger.kernel.org, linux-api@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: RFC: Serial port DTR/RTS - O_NRESETDEV
Date: Thu, 6 Nov 2025 23:53:23 -0800	[thread overview]
Message-ID: <bb44f856-10a2-40c7-a3f7-be50c8e4b0a9@zytor.com> (raw)

Hi,

I recently ran into a pretty serious issue due to the Unix/Linux (mis)behavior
of forcing DTR and RTS asserted when a serial port is set, losing the
pre-existing status in the process. Since it is impossible probe for the
current status or even if it is a functional serial port without a file
descriptor, this is very problematic. This came up in the context of probing
for serial ports from an application, so even if termios could be modified
without a file descriptor (which it can't) it would not be safe.

I noted there was a patchset for that on linux-serial from 2022 which
apparently got dropped and never merged, but I think it has a pretty serious
problem: it used a sysfs setting to control the behavior, which may be
reasonable for a default, but at the end of it this is really something that
is determined by the intent of the open() call, just like O_NONBLOCK replaced
the old callout devices we once had.

It seems to me that this may very well be a problem beyond ttys, in which case
a new open flag to request to a driver that the configuration and (observable)
state of the underlying hardware device -- whatever it may be -- should not be
disturbed by calling open(). This is of course already the case for many
devices, not to mention block and non-devices, in which case this flag is a
don't care.

The best name I came up with was O_NRESETDEV, but it's not something I'm
particularly attached to.

If the opinion is that this *doesn't* have a scope beyond ttys, then perhaps
abusing the O_DIRECT flag for this purpose would be an alternative.

Thoughts?

	-hpa


             reply	other threads:[~2025-11-07  7:53 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07  7:53 H. Peter Anvin [this message]
2025-11-07 17:37 ` RFC: Serial port DTR/RTS - O_NRESETDEV Theodore Ts'o
2025-11-09  2:25   ` H. Peter Anvin
2025-11-10  3:35     ` Theodore Ts'o
2025-11-10  5:00       ` H. Peter Anvin
2025-11-10 10:06         ` Maarten Brock
2025-11-10 20:19           ` Theodore Ts'o
2025-11-10 21:05             ` H. Peter Anvin
2025-11-11  3:51               ` Theodore Ts'o
2025-11-11  3:57                 ` H. Peter Anvin
2025-11-11  4:38                   ` Theodore Ts'o
2025-11-11 10:21                     ` Maarten Brock
2025-11-11 21:28                     ` H. Peter Anvin
2025-11-12 11:22                   ` Greg KH
2025-11-12 16:09                     ` H. Peter Anvin
2025-11-12 16:46                       ` Greg KH
2025-11-12 19:12                         ` H. Peter Anvin
2025-11-12 19:39                           ` Greg KH
2025-11-12 19:53                             ` H. Peter Anvin
2025-11-12 19:55                             ` H. Peter Anvin
2025-11-13 22:24                             ` RFC: Serial port DTR/RTS - O_<something> H. Peter Anvin
2025-11-14 10:26                               ` Maarten Brock
2025-11-14 18:49                               ` Maciej W. Rozycki
2025-11-14 18:53                                 ` H. Peter Anvin
2025-11-15 21:29                                   ` Ned Ulbricht
2025-11-15 22:29                                     ` H. Peter Anvin
2025-11-16  0:47                                     ` H. Peter Anvin
2025-11-18 16:33                                       ` Ned Ulbricht
2025-11-18 17:31                                         ` H. Peter Anvin
2025-11-18 18:05                                         ` H. Peter Anvin
2025-11-20 13:31                                           ` Ned Ulbricht
2025-11-10  5:20   ` RFC: Serial port DTR/RTS - O_NRESETDEV H. Peter Anvin
2025-11-09 20:43 ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb44f856-10a2-40c7-a3f7-be50c8e4b0a9@zytor.com \
    --to=hpa@zytor.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).