Skip to content

Commit 0938935

Browse files
committed
Merge tag 'tty-6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial driver fixes from Greg KH: "Here are a number of small tty and serial driver fixes for 6.1-rc6. They all resolve reported problems: - kernel doc build problems with the -rc1 serial driver documentation update - n_gsm reported problems - imx serial driver missing callback - lots of tiny 8250 driver fixes for reported issues. All of these have been in linux-next for over a week with no reported problems" * tag 'tty-6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: docs/driver-api/miscellaneous: Remove kernel-doc of serial_core.c serial: 8250: Flush DMA Rx on RLSI serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake serial: 8250_lpss: Configure DMA also w/o DMA filter serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send Revert "tty: n_gsm: replace kicktimer with delayed_work" Revert "tty: n_gsm: avoid call of sleeping functions from atomic context" serial: imx: Add missing .thaw_noirq hook tty: serial: fsl_lpuart: don't break the on-going transfer when global reset serial: 8250: omap: Flush PM QOS work on remove serial: 8250: omap: Fix unpaired pm_runtime_put_sync() in omap8250_remove() serial: 8250_omap: remove wait loop from Errata i202 workaround serial: 8250: omap: Fix missing PM runtime calls for omap8250_set_mctrl() serial: 8250: 8250_omap: Avoid RS485 RTS glitch on ->set_termios()
2 parents 63c8c0d + 3ec17cb commit 0938935

File tree

7 files changed

+138
-91
lines changed

7 files changed

+138
-91
lines changed

Documentation/driver-api/miscellaneous.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ Parallel Port Devices
1616
16x50 UART Driver
1717
=================
1818

19-
.. kernel-doc:: drivers/tty/serial/serial_core.c
20-
:export:
21-
2219
.. kernel-doc:: drivers/tty/serial/8250/8250_core.c
2320
:export:
2421

22+
See serial/driver.rst for related APIs.
23+
2524
Pulse-Width Modulation (PWM)
2625
============================
2726

drivers/tty/n_gsm.c

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ struct gsm_mux {
264264
bool constipated; /* Asked by remote to shut up */
265265
bool has_devices; /* Devices were registered */
266266

267-
struct mutex tx_mutex;
267+
spinlock_t tx_lock;
268268
unsigned int tx_bytes; /* TX data outstanding */
269269
#define TX_THRESH_HI 8192
270270
#define TX_THRESH_LO 2048
271271
struct list_head tx_ctrl_list; /* Pending control packets */
272272
struct list_head tx_data_list; /* Pending data packets */
273273

274274
/* Control messages */
275-
struct delayed_work kick_timeout; /* Kick TX queuing on timeout */
275+
struct timer_list kick_timer; /* Kick TX queuing on timeout */
276276
struct timer_list t2_timer; /* Retransmit timer for commands */
277277
int cretries; /* Command retry counter */
278278
struct gsm_control *pending_cmd;/* Our current pending command */
@@ -700,6 +700,7 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
700700
struct gsm_msg *msg;
701701
u8 *dp;
702702
int ocr;
703+
unsigned long flags;
703704

704705
msg = gsm_data_alloc(gsm, addr, 0, control);
705706
if (!msg)
@@ -721,10 +722,10 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
721722

722723
gsm_print_packet("Q->", addr, cr, control, NULL, 0);
723724

724-
mutex_lock(&gsm->tx_mutex);
725+
spin_lock_irqsave(&gsm->tx_lock, flags);
725726
list_add_tail(&msg->list, &gsm->tx_ctrl_list);
726727
gsm->tx_bytes += msg->len;
727-
mutex_unlock(&gsm->tx_mutex);
728+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
728729
gsmld_write_trigger(gsm);
729730

730731
return 0;
@@ -749,15 +750,15 @@ static void gsm_dlci_clear_queues(struct gsm_mux *gsm, struct gsm_dlci *dlci)
749750
spin_unlock_irqrestore(&dlci->lock, flags);
750751

751752
/* Clear data packets in MUX write queue */
752-
mutex_lock(&gsm->tx_mutex);
753+
spin_lock_irqsave(&gsm->tx_lock, flags);
753754
list_for_each_entry_safe(msg, nmsg, &gsm->tx_data_list, list) {
754755
if (msg->addr != addr)
755756
continue;
756757
gsm->tx_bytes -= msg->len;
757758
list_del(&msg->list);
758759
kfree(msg);
759760
}
760-
mutex_unlock(&gsm->tx_mutex);
761+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
761762
}
762763

763764
/**
@@ -1028,7 +1029,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
10281029
gsm->tx_bytes += msg->len;
10291030

10301031
gsmld_write_trigger(gsm);
1031-
schedule_delayed_work(&gsm->kick_timeout, 10 * gsm->t1 * HZ / 100);
1032+
mod_timer(&gsm->kick_timer, jiffies + 10 * gsm->t1 * HZ / 100);
10321033
}
10331034

10341035
/**
@@ -1043,9 +1044,10 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
10431044

10441045
static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
10451046
{
1046-
mutex_lock(&dlci->gsm->tx_mutex);
1047+
unsigned long flags;
1048+
spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
10471049
__gsm_data_queue(dlci, msg);
1048-
mutex_unlock(&dlci->gsm->tx_mutex);
1050+
spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
10491051
}
10501052

10511053
/**
@@ -1057,7 +1059,7 @@ static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
10571059
* is data. Keep to the MRU of the mux. This path handles the usual tty
10581060
* interface which is a byte stream with optional modem data.
10591061
*
1060-
* Caller must hold the tx_mutex of the mux.
1062+
* Caller must hold the tx_lock of the mux.
10611063
*/
10621064

10631065
static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
@@ -1117,7 +1119,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
11171119
* is data. Keep to the MRU of the mux. This path handles framed data
11181120
* queued as skbuffs to the DLCI.
11191121
*
1120-
* Caller must hold the tx_mutex of the mux.
1122+
* Caller must hold the tx_lock of the mux.
11211123
*/
11221124

11231125
static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
@@ -1133,7 +1135,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
11331135
if (dlci->adaption == 4)
11341136
overhead = 1;
11351137

1136-
/* dlci->skb is locked by tx_mutex */
1138+
/* dlci->skb is locked by tx_lock */
11371139
if (dlci->skb == NULL) {
11381140
dlci->skb = skb_dequeue_tail(&dlci->skb_list);
11391141
if (dlci->skb == NULL)
@@ -1187,7 +1189,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
11871189
* Push an empty frame in to the transmit queue to update the modem status
11881190
* bits and to transmit an optional break.
11891191
*
1190-
* Caller must hold the tx_mutex of the mux.
1192+
* Caller must hold the tx_lock of the mux.
11911193
*/
11921194

11931195
static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
@@ -1301,12 +1303,13 @@ static int gsm_dlci_data_sweep(struct gsm_mux *gsm)
13011303

13021304
static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
13031305
{
1306+
unsigned long flags;
13041307
int sweep;
13051308

13061309
if (dlci->constipated)
13071310
return;
13081311

1309-
mutex_lock(&dlci->gsm->tx_mutex);
1312+
spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
13101313
/* If we have nothing running then we need to fire up */
13111314
sweep = (dlci->gsm->tx_bytes < TX_THRESH_LO);
13121315
if (dlci->gsm->tx_bytes == 0) {
@@ -1317,7 +1320,7 @@ static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
13171320
}
13181321
if (sweep)
13191322
gsm_dlci_data_sweep(dlci->gsm);
1320-
mutex_unlock(&dlci->gsm->tx_mutex);
1323+
spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
13211324
}
13221325

13231326
/*
@@ -1708,7 +1711,7 @@ static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
17081711
unsigned int command, u8 *data, int clen)
17091712
{
17101713
struct gsm_control *ctrl = kzalloc(sizeof(struct gsm_control),
1711-
GFP_KERNEL);
1714+
GFP_ATOMIC);
17121715
unsigned long flags;
17131716
if (ctrl == NULL)
17141717
return NULL;
@@ -2019,23 +2022,24 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
20192022
}
20202023

20212024
/**
2022-
* gsm_kick_timeout - transmit if possible
2023-
* @work: work contained in our gsm object
2025+
* gsm_kick_timer - transmit if possible
2026+
* @t: timer contained in our gsm object
20242027
*
20252028
* Transmit data from DLCIs if the queue is empty. We can't rely on
20262029
* a tty wakeup except when we filled the pipe so we need to fire off
20272030
* new data ourselves in other cases.
20282031
*/
2029-
static void gsm_kick_timeout(struct work_struct *work)
2032+
static void gsm_kick_timer(struct timer_list *t)
20302033
{
2031-
struct gsm_mux *gsm = container_of(work, struct gsm_mux, kick_timeout.work);
2034+
struct gsm_mux *gsm = from_timer(gsm, t, kick_timer);
2035+
unsigned long flags;
20322036
int sent = 0;
20332037

2034-
mutex_lock(&gsm->tx_mutex);
2038+
spin_lock_irqsave(&gsm->tx_lock, flags);
20352039
/* If we have nothing running then we need to fire up */
20362040
if (gsm->tx_bytes < TX_THRESH_LO)
20372041
sent = gsm_dlci_data_sweep(gsm);
2038-
mutex_unlock(&gsm->tx_mutex);
2042+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
20392043

20402044
if (sent && debug & DBG_DATA)
20412045
pr_info("%s TX queue stalled\n", __func__);
@@ -2492,7 +2496,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)
24922496
}
24932497

24942498
/* Finish outstanding timers, making sure they are done */
2495-
cancel_delayed_work_sync(&gsm->kick_timeout);
2499+
del_timer_sync(&gsm->kick_timer);
24962500
del_timer_sync(&gsm->t2_timer);
24972501

24982502
/* Finish writing to ldisc */
@@ -2565,7 +2569,6 @@ static void gsm_free_mux(struct gsm_mux *gsm)
25652569
break;
25662570
}
25672571
}
2568-
mutex_destroy(&gsm->tx_mutex);
25692572
mutex_destroy(&gsm->mutex);
25702573
kfree(gsm->txframe);
25712574
kfree(gsm->buf);
@@ -2637,15 +2640,15 @@ static struct gsm_mux *gsm_alloc_mux(void)
26372640
}
26382641
spin_lock_init(&gsm->lock);
26392642
mutex_init(&gsm->mutex);
2640-
mutex_init(&gsm->tx_mutex);
26412643
kref_init(&gsm->ref);
26422644
INIT_LIST_HEAD(&gsm->tx_ctrl_list);
26432645
INIT_LIST_HEAD(&gsm->tx_data_list);
2644-
INIT_DELAYED_WORK(&gsm->kick_timeout, gsm_kick_timeout);
2646+
timer_setup(&gsm->kick_timer, gsm_kick_timer, 0);
26452647
timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0);
26462648
INIT_WORK(&gsm->tx_work, gsmld_write_task);
26472649
init_waitqueue_head(&gsm->event);
26482650
spin_lock_init(&gsm->control_lock);
2651+
spin_lock_init(&gsm->tx_lock);
26492652

26502653
gsm->t1 = T1;
26512654
gsm->t2 = T2;
@@ -2670,7 +2673,6 @@ static struct gsm_mux *gsm_alloc_mux(void)
26702673
}
26712674
spin_unlock(&gsm_mux_lock);
26722675
if (i == MAX_MUX) {
2673-
mutex_destroy(&gsm->tx_mutex);
26742676
mutex_destroy(&gsm->mutex);
26752677
kfree(gsm->txframe);
26762678
kfree(gsm->buf);
@@ -2826,16 +2828,17 @@ static void gsmld_write_trigger(struct gsm_mux *gsm)
28262828
static void gsmld_write_task(struct work_struct *work)
28272829
{
28282830
struct gsm_mux *gsm = container_of(work, struct gsm_mux, tx_work);
2831+
unsigned long flags;
28292832
int i, ret;
28302833

28312834
/* All outstanding control channel and control messages and one data
28322835
* frame is sent.
28332836
*/
28342837
ret = -ENODEV;
2835-
mutex_lock(&gsm->tx_mutex);
2838+
spin_lock_irqsave(&gsm->tx_lock, flags);
28362839
if (gsm->tty)
28372840
ret = gsm_data_kick(gsm);
2838-
mutex_unlock(&gsm->tx_mutex);
2841+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
28392842

28402843
if (ret >= 0)
28412844
for (i = 0; i < NUM_DLCI; i++)
@@ -3042,20 +3045,21 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
30423045
const unsigned char *buf, size_t nr)
30433046
{
30443047
struct gsm_mux *gsm = tty->disc_data;
3048+
unsigned long flags;
30453049
int space;
30463050
int ret;
30473051

30483052
if (!gsm)
30493053
return -ENODEV;
30503054

30513055
ret = -ENOBUFS;
3052-
mutex_lock(&gsm->tx_mutex);
3056+
spin_lock_irqsave(&gsm->tx_lock, flags);
30533057
space = tty_write_room(tty);
30543058
if (space >= nr)
30553059
ret = tty->ops->write(tty, buf, nr);
30563060
else
30573061
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
3058-
mutex_unlock(&gsm->tx_mutex);
3062+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
30593063

30603064
return ret;
30613065
}
@@ -3352,13 +3356,14 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
33523356
static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk)
33533357
{
33543358
struct gsm_mux *gsm = dlci->gsm;
3359+
unsigned long flags;
33553360

33563361
if (dlci->state != DLCI_OPEN || dlci->adaption != 2)
33573362
return;
33583363

3359-
mutex_lock(&gsm->tx_mutex);
3364+
spin_lock_irqsave(&gsm->tx_lock, flags);
33603365
gsm_dlci_modem_output(gsm, dlci, brk);
3361-
mutex_unlock(&gsm->tx_mutex);
3366+
spin_unlock_irqrestore(&gsm->tx_lock, flags);
33623367
}
33633368

33643369
/**

drivers/tty/serial/8250/8250_lpss.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
174174
*/
175175
up->dma = dma;
176176

177+
lpss->dma_maxburst = 16;
178+
177179
port->set_termios = dw8250_do_set_termios;
178180

179181
return 0;
@@ -277,8 +279,13 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
277279
struct dw_dma_slave *rx_param, *tx_param;
278280
struct device *dev = port->port.dev;
279281

280-
if (!lpss->dma_param.dma_dev)
282+
if (!lpss->dma_param.dma_dev) {
283+
dma = port->dma;
284+
if (dma)
285+
goto out_configuration_only;
286+
281287
return 0;
288+
}
282289

283290
rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL);
284291
if (!rx_param)
@@ -289,16 +296,18 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
289296
return -ENOMEM;
290297

291298
*rx_param = lpss->dma_param;
292-
dma->rxconf.src_maxburst = lpss->dma_maxburst;
293-
294299
*tx_param = lpss->dma_param;
295-
dma->txconf.dst_maxburst = lpss->dma_maxburst;
296300

297301
dma->fn = lpss8250_dma_filter;
298302
dma->rx_param = rx_param;
299303
dma->tx_param = tx_param;
300304

301305
port->dma = dma;
306+
307+
out_configuration_only:
308+
dma->rxconf.src_maxburst = lpss->dma_maxburst;
309+
dma->txconf.dst_maxburst = lpss->dma_maxburst;
310+
302311
return 0;
303312
}
304313

0 commit comments

Comments
 (0)