* question on correct error return from break_ctl()
@ 2023-11-30 13:09 Oliver Neukum
2023-11-30 13:48 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Neukum @ 2023-11-30 13:09 UTC (permalink / raw)
To: Johan Hovold; +Cc: Greg Kroah-Hartman, Jiri Slaby, USB list, linux-serial
Hi,
it seems inconsistent. The tty layer
in drivers/tty/tty_io.c::send_break()
static int send_break(struct tty_struct *tty, unsigned int duration)
{
int retval;
if (tty->ops->break_ctl == NULL)
return 0;
not supporting break_ctl() is treated as the operation
succeeding. Yet in drivers/usb/serial/usb-serial.c::serial_break()
static int serial_break(struct tty_struct *tty, int break_state)
{
struct usb_serial_port *port = tty->driver_data;
dev_dbg(&port->dev, "%s\n", __func__);
if (port->serial->type->break_ctl)
return port->serial->type->break_ctl(tty, break_state);
return -ENOTTY;
}
we are seeing that not supporting break_ctl() leads to returning
-ENOTTY, which drivers/tty/tty_io.c::send_break() will return to user space.
These reactions are at odds with each other. What is a driver supposed
to do?
Regards
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on correct error return from break_ctl()
2023-11-30 13:09 question on correct error return from break_ctl() Oliver Neukum
@ 2023-11-30 13:48 ` Greg Kroah-Hartman
2023-11-30 14:36 ` Oliver Neukum
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-11-30 13:48 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Johan Hovold, Jiri Slaby, USB list, linux-serial
On Thu, Nov 30, 2023 at 02:09:48PM +0100, Oliver Neukum wrote:
> Hi,
>
> it seems inconsistent. The tty layer
> in drivers/tty/tty_io.c::send_break()
>
> static int send_break(struct tty_struct *tty, unsigned int duration)
> {
> int retval;
>
> if (tty->ops->break_ctl == NULL)
> return 0;
>
> not supporting break_ctl() is treated as the operation
> succeeding. Yet in drivers/usb/serial/usb-serial.c::serial_break()
>
> static int serial_break(struct tty_struct *tty, int break_state)
> {
> struct usb_serial_port *port = tty->driver_data;
>
> dev_dbg(&port->dev, "%s\n", __func__);
>
> if (port->serial->type->break_ctl)
> return port->serial->type->break_ctl(tty, break_state);
>
> return -ENOTTY;
> }
>
> we are seeing that not supporting break_ctl() leads to returning
> -ENOTTY, which drivers/tty/tty_io.c::send_break() will return to user space.
> These reactions are at odds with each other. What is a driver supposed
> to do?
usb-serial should probably change, but given the fact that no one has
noticed this in the 20+ years it has been like this, is it really
needed? :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on correct error return from break_ctl()
2023-11-30 13:48 ` Greg Kroah-Hartman
@ 2023-11-30 14:36 ` Oliver Neukum
2023-11-30 14:42 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Neukum @ 2023-11-30 14:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Oliver Neukum
Cc: Johan Hovold, Jiri Slaby, USB list, linux-serial
On 30.11.23 14:48, Greg Kroah-Hartman wrote:
Hi,
> usb-serial should probably change, but given the fact that no one has
> noticed this in the 20+ years it has been like this, is it really
> needed? :)
I am afraid I need to point out that usb-serial has been changed _this_ _year_
to return -ENOTTY. CDC-ACM being also in this situation unfortunately
I need to decide between one of the alternatives.
Regards
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on correct error return from break_ctl()
2023-11-30 14:36 ` Oliver Neukum
@ 2023-11-30 14:42 ` Greg Kroah-Hartman
2023-11-30 15:12 ` Johan Hovold
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-11-30 14:42 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Johan Hovold, Jiri Slaby, USB list, linux-serial
On Thu, Nov 30, 2023 at 03:36:21PM +0100, Oliver Neukum wrote:
> On 30.11.23 14:48, Greg Kroah-Hartman wrote:
> Hi,
>
> > usb-serial should probably change, but given the fact that no one has
> > noticed this in the 20+ years it has been like this, is it really
> > needed? :)
>
> I am afraid I need to point out that usb-serial has been changed _this_ _year_
> to return -ENOTTY. CDC-ACM being also in this situation unfortunately
> I need to decide between one of the alternatives.
Ah, oops, then it should probably be changed back. Unless Johan, any
specific reason this was changed?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question on correct error return from break_ctl()
2023-11-30 14:42 ` Greg Kroah-Hartman
@ 2023-11-30 15:12 ` Johan Hovold
0 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2023-11-30 15:12 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Oliver Neukum, Jiri Slaby, USB list, linux-serial
On Thu, Nov 30, 2023 at 02:42:20PM +0000, Greg Kroah-Hartman wrote:
> On Thu, Nov 30, 2023 at 03:36:21PM +0100, Oliver Neukum wrote:
> > On 30.11.23 14:48, Greg Kroah-Hartman wrote:
> > I am afraid I need to point out that usb-serial has been changed _this_ _year_
> > to return -ENOTTY. CDC-ACM being also in this situation unfortunately
> > I need to decide between one of the alternatives.
>
> Ah, oops, then it should probably be changed back. Unless Johan, any
> specific reason this was changed?
Had to go back to lore to see why I changed this:
https://lore.kernel.org/all/20230604123505.4661-1-johan@kernel.org/
IIRC we had a user that was not expecting break signalling to only work
with one of the two ports of a Silabs device without user space being
notified about it.
In the cover letter I mention that the intent of "commit 9e98966c7bb9
("tty: rework break handling") from 2008 appears to be to allow missing
support to be reported to user space".
Reporting back an error also avoids waiting for the break period when a
subdriver does not support break (i.e. as when a tty driver does not
support break).
The inconsistency was discussed and if this turns out to be an issue we
can have the tty layer turn that -ENOTTY into 0 before returning:
https://lore.kernel.org/all/ZH8a12ZYtA2RzEK_@hovoldconsulting.com/
I haven't heard from anyone noticing any issues so far though.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-30 15:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-30 13:09 question on correct error return from break_ctl() Oliver Neukum
2023-11-30 13:48 ` Greg Kroah-Hartman
2023-11-30 14:36 ` Oliver Neukum
2023-11-30 14:42 ` Greg Kroah-Hartman
2023-11-30 15:12 ` Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox