Messages in this thread | | | From | Linus Torvalds <> | Date | Mon, 6 Dec 2021 10:07:30 -0800 | Subject | Re: [PATCH] tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous |
| |
On Mon, Dec 6, 2021 at 3:45 AM Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote: > > Linus suspected that "struct tty_ldisc"->ops->write_wakeup() must not > sleep, and Jiri confirmed it from include/linux/tty_ldisc.h. Thus, defer > n_hdlc_send_frames() from n_hdlc_tty_wakeup() to a WQ context like > net/nfc/nci/uart.c does.
Thanks, this looks good to me.
That said, I think there's pretty much the *exact* same pattern in
drivers/net/caif/caif_serial.c: write_wakeup() causes "handle_tx()", which then calls tty->ops->write().
drivers/net/hamradio/mkiss.c mkiss_write_wakeup() -> tty->ops->write()
drivers/tty/n_gsm.c: gsmld_write_wakeup -> gsm_data_kick() -> gsmld_output -> gsm->tty->ops->write()
so this does seem to be a common bug pattern for code that has never really seen a lot of testing.
The core tty stuff seems to get it right, but maybe I missed something in my quick "grep and look for patterns".
So I think this patch is good, but I do wonder if perhaps we should move the "work_struct" into the tty layer itself, and do the whole "schedule_work()" at that level.
Some code never wants it (most notably the regular n_tty one), but at least n_tty doesn't really care, I suspect. n_tty is using write_wakeup() literally just for fasync handling, so I suspect it's not exactly going to be performance-critical.
Of course, maybe the fix is to just fix caif_serial/mkiss and n_gsm. Or mark them broken - does anybody use them?
Linus
Linus
| |