Skip to content

Commit

Permalink
tty: n_gsm: Fix waking up upper tty layer when room available
Browse files Browse the repository at this point in the history
Warn the upper layer when n_gms is ready to receive data
again. Without this the associated virtual tty remains blocked
indefinitely.

Fixes: e1eaea4 ("tty: n_gsm line discipline")
Signed-off-by: Gregory CLEMENT <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gclement authored and gregkh committed May 15, 2020
1 parent 84d6f81 commit 01dbb36
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions drivers/tty/n_gsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
* 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;
int len;
Expand Down Expand Up @@ -695,6 +695,24 @@ static void gsm_data_kick(struct gsm_mux *gsm)

list_del(&msg->list);
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);
}
}
}
}

Expand Down Expand Up @@ -746,7 +764,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
/* Add to the actual output queue */
list_add_tail(&msg->list, &gsm->tx_list);
gsm->tx_bytes += msg->len;
gsm_data_kick(gsm);
gsm_data_kick(gsm, dlci);
}

/**
Expand Down Expand Up @@ -1207,7 +1225,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
gsm_control_reply(gsm, CMD_FCON, NULL, 0);
/* Kick the link in case it is idling */
spin_lock_irqsave(&gsm->tx_lock, flags);
gsm_data_kick(gsm);
gsm_data_kick(gsm, NULL);
spin_unlock_irqrestore(&gsm->tx_lock, flags);
break;
case CMD_FCOFF:
Expand Down Expand Up @@ -2529,7 +2547,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
/* Queue poll */
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
spin_lock_irqsave(&gsm->tx_lock, flags);
gsm_data_kick(gsm);
gsm_data_kick(gsm, NULL);
if (gsm->tx_bytes < TX_THRESH_LO) {
gsm_dlci_data_sweep(gsm);
}
Expand Down

0 comments on commit 01dbb36

Please sign in to comment.