tty: closing n_gsm line discipline always times out

From: Sascha Hauer
Date: Wed May 17 2017 - 09:45:03 EST


Hi All,

When the n_gsm line discipline is closed it wants to shutdown the line
discipline properly and asks the link partner to end the mux protocol. This is
done in gsm_cleanup_mux() around line 2050 in n_gsm.c:

if (dlci) {
gc = gsm_control_send(gsm, CMD_CLD, NULL, 0);
if (gc)
gsm_control_wait(gsm, gc);
}

The call stack is like this:

(struct tty_ldisc_ops).close
-> gsmld_close
-> gsmld_detach_gsm
-> gsm_cleanup_mux

(struct tty_ldisc_ops).close is called at tty_release time or when the line
discipline is changed. At tty_release time the tty is already shutdown, so we
cannot send anything anymore. In this case our link partner never closes the
mux protocol, which means we can never re-open it again. When instead the line
discipline is changed back to N_TTY to close the protocol, gsm_control_send
works fine, but the tty_ldisc is locked and thus the chars received by the UART
never make it to the line discipline and gsm_control_wait times out.

There's obviously something wrong here. Any ideas how to fix that? When we are
not allowed to send/receive at tty_release time, do we need a new n_gsm specific
ioctl to shutdown the mux?

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |