Commit 6267f482 authored by Gregory CLEMENT's avatar Gregory CLEMENT Committed by Kelsey Skunberg

tty: n_gsm: Fix waking up upper tty layer when room available

BugLink: https://bugs.launchpad.net/bugs/1885932

[ Upstream commit 01dbb362 ]

Warn the upper layer when n_gms is ready to receive data
again. Without this the associated virtual tty remains blocked
indefinitely.

Fixes: e1eaea46 ("tty: n_gsm line discipline")
Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
Link: https://lore.kernel.org/r/20200512115323.1447922-4-gregory.clement@bootlin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent 10522881
...@@ -681,7 +681,7 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len, ...@@ -681,7 +681,7 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
* FIXME: lock against link layer control transmissions * FIXME: lock against link layer control transmissions
*/ */
static void gsm_data_kick(struct gsm_mux *gsm) static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
{ {
struct gsm_msg *msg, *nmsg; struct gsm_msg *msg, *nmsg;
int len; int len;
...@@ -713,6 +713,24 @@ static void gsm_data_kick(struct gsm_mux *gsm) ...@@ -713,6 +713,24 @@ static void gsm_data_kick(struct gsm_mux *gsm)
list_del(&msg->list); list_del(&msg->list);
kfree(msg); kfree(msg);
if (dlci) {
tty_port_tty_wakeup(&dlci->port);
} else {
int i = 0;
for (i = 0; i < NUM_DLCI; i++) {
struct gsm_dlci *dlci;
dlci = gsm->dlci[i];
if (dlci == NULL) {
i++;
continue;
}
tty_port_tty_wakeup(&dlci->port);
}
}
} }
} }
...@@ -764,7 +782,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) ...@@ -764,7 +782,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
/* Add to the actual output queue */ /* Add to the actual output queue */
list_add_tail(&msg->list, &gsm->tx_list); list_add_tail(&msg->list, &gsm->tx_list);
gsm->tx_bytes += msg->len; gsm->tx_bytes += msg->len;
gsm_data_kick(gsm); gsm_data_kick(gsm, dlci);
} }
/** /**
...@@ -1225,7 +1243,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, ...@@ -1225,7 +1243,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
gsm_control_reply(gsm, CMD_FCON, NULL, 0); gsm_control_reply(gsm, CMD_FCON, NULL, 0);
/* Kick the link in case it is idling */ /* Kick the link in case it is idling */
spin_lock_irqsave(&gsm->tx_lock, flags); spin_lock_irqsave(&gsm->tx_lock, flags);
gsm_data_kick(gsm); gsm_data_kick(gsm, NULL);
spin_unlock_irqrestore(&gsm->tx_lock, flags); spin_unlock_irqrestore(&gsm->tx_lock, flags);
break; break;
case CMD_FCOFF: case CMD_FCOFF:
...@@ -2423,7 +2441,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty) ...@@ -2423,7 +2441,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
/* Queue poll */ /* Queue poll */
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
spin_lock_irqsave(&gsm->tx_lock, flags); spin_lock_irqsave(&gsm->tx_lock, flags);
gsm_data_kick(gsm); gsm_data_kick(gsm, NULL);
if (gsm->tx_bytes < TX_THRESH_LO) { if (gsm->tx_bytes < TX_THRESH_LO) {
gsm_dlci_data_sweep(gsm); gsm_dlci_data_sweep(gsm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment