diff options
author | norly <ny-git@enpas.org> | 2022-04-29 03:33:27 +0200 |
---|---|---|
committer | norly <ny-git@enpas.org> | 2022-04-29 03:38:57 +0200 |
commit | 91f53cf7f2e763704123174ecad6a0d20a612d1b (patch) | |
tree | 6494b6c309b4c15b58ff5e7fee321ca3855912a9 /module | |
parent | f4e74d69c980221ca7a0b34691e94c8ccbb078b9 (diff) |
Only netif_wake_queue() when ELM327 is really idle
That is, when it is receiving, as that's the default state the driver
tries its best to keep it in.
Diffstat (limited to 'module')
-rw-r--r-- | module/elmcan.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/module/elmcan.c b/module/elmcan.c index 85c6565..3afbbc4 100644 --- a/module/elmcan.c +++ b/module/elmcan.c @@ -161,9 +161,7 @@ static void elm327_send(struct elmcan *elm, const void *buf, size_t len) elm->txleft = len - written; elm->txhead = elm->txbuf + written; - if (!elm->txleft) - netif_wake_queue(elm->dev); - else + if (elm->txleft) set_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); } @@ -573,6 +571,11 @@ static void elm327_handle_prompt(struct elmcan *elm) elm327_send(elm, "ATMA\r", 5); elm->state = ELM327_STATE_RECEIVING; + /* We will be in the default state once this command is + * send, so enable the TX packet queue. + */ + netif_wake_queue(elm->dev); + return; } @@ -646,6 +649,11 @@ static void elm327_handle_prompt(struct elmcan *elm) elm->drop_next_line = 1; elm->state = ELM327_STATE_RECEIVING; + + /* We will be in the default state once this command is + * send, so enable the TX packet queue. + */ + netif_wake_queue(elm->dev); } elm327_send(elm, local_txbuf, strlen(local_txbuf)); @@ -824,15 +832,12 @@ static int elmcan_netdev_close(struct net_device *dev) elm327_send(elm, ELM327_DUMMY_STRING, 1); spin_unlock_bh(&elm->lock); - /* Give UART one final chance to flush. - * This may netif_wake_queue(), so don't netif_stop_queue() - * before flushing the worker. - */ + netif_stop_queue(dev); + + /* Give UART one final chance to flush. */ clear_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); flush_work(&elm->tx_work); - netif_stop_queue(dev); - can_rx_offload_disable(&elm->offload); elm->can.state = CAN_STATE_STOPPED; can_rx_offload_del(&elm->offload); @@ -1004,7 +1009,6 @@ static void elmcan_ldisc_tx_worker(struct work_struct *work) if (!elm->txleft) { clear_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); spin_unlock_bh(&elm->lock); - netif_wake_queue(elm->dev); } else { spin_unlock_bh(&elm->lock); } |