Skip to content

Commit 3b9abc7

Browse files
committed
Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
* 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: TTY: ldisc, wait for ldisc infinitely in hangup TTY: ldisc, move wait idle to caller TTY: ldisc, allow waiting for ldisc arbitrarily long Revert "tty/serial: Prevent drop of DCD on suspend for Tegra UARTs" RS485: fix inconsistencies in the meaning of some variables pch_uart: Fix DMA resource leak issue serial,mfd: Fix CMSPAR setup tty/serial: Prevent drop of DCD on suspend for Tegra UARTs pch_uart: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor pch_uart: Support new device LAPIS Semiconductor ML7831 IOH pch_uart: Fix hw-flow control issue tty: hvc_dcc: Fix duplicate character inputs jsm: Change maintainership
2 parents 0cda569 + 0c73c08 commit 3b9abc7

10 files changed

Lines changed: 72 additions & 53 deletions

File tree

‎Documentation/serial/serial-rs485.txt‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,23 @@
9797

9898
struct serial_rs485 rs485conf;
9999

100-
/* Set RS485 mode: */
100+
/* Enable RS485 mode: */
101101
rs485conf.flags |= SER_RS485_ENABLED;
102102

103+
/* Set logical level for RTS pin equal to 1 when sending: */
104+
rs485conf.flags |= SER_RS485_RTS_ON_SEND;
105+
/* or, set logical level for RTS pin equal to 0 when sending: */
106+
rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND);
107+
108+
/* Set logical level for RTS pin equal to 1 after sending: */
109+
rs485conf.flags |= SER_RS485_RTS_AFTER_SEND;
110+
/* or, set logical level for RTS pin equal to 0 after sending: */
111+
rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);
112+
103113
/* Set rts delay before send, if needed: */
104-
rs485conf.flags |= SER_RS485_RTS_BEFORE_SEND;
105114
rs485conf.delay_rts_before_send = ...;
106115

107116
/* Set rts delay after send, if needed: */
108-
rs485conf.flags |= SER_RS485_RTS_AFTER_SEND;
109117
rs485conf.delay_rts_after_send = ...;
110118

111119
/* Set this flag if you want to receive data even whilst sending data */

‎MAINTAINERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3728,7 +3728,7 @@ F: fs/jbd2/
37283728
F: include/linux/jbd2.h
37293729

37303730
JSM Neo PCI based serial card
3731-
M: Breno Leitao <leitao@linux.vnet.ibm.com>
3731+
M: Lucas Tavares <lucaskt@linux.vnet.ibm.com>
37323732
L: linux-serial@vger.kernel.org
37333733
S: Maintained
37343734
F: drivers/tty/serial/jsm/

‎drivers/tty/hvc/hvc_dcc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static inline char __dcc_getchar(void)
4646

4747
asm volatile("mrc p14, 0, %0, c0, c5, 0 @ read comms data reg"
4848
: "=r" (__c));
49+
isb();
4950

5051
return __c;
5152
}
@@ -55,6 +56,7 @@ static inline void __dcc_putchar(char c)
5556
asm volatile("mcr p14, 0, %0, c0, c5, 0 @ write a char"
5657
: /* no output register */
5758
: "r" (c));
59+
isb();
5860
}
5961

6062
static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)

‎drivers/tty/serial/Kconfig‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,20 +1560,20 @@ config SERIAL_IFX6X60
15601560
Support for the IFX6x60 modem devices on Intel MID platforms.
15611561

15621562
config SERIAL_PCH_UART
1563-
tristate "Intel EG20T PCH / OKI SEMICONDUCTOR IOH(ML7213/ML7223) UART"
1563+
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) UART"
15641564
depends on PCI
15651565
select SERIAL_CORE
15661566
help
15671567
This driver is for PCH(Platform controller Hub) UART of Intel EG20T
15681568
which is an IOH(Input/Output Hub) for x86 embedded processor.
15691569
Enabling PCH_DMA, this PCH UART works as DMA mode.
15701570

1571-
This driver also can be used for OKI SEMICONDUCTOR IOH(Input/
1572-
Output Hub), ML7213 and ML7223.
1573-
ML7213 IOH is for IVI(In-Vehicle Infotainment) use and ML7223 IOH is
1574-
for MP(Media Phone) use.
1575-
ML7213/ML7223 is companion chip for Intel Atom E6xx series.
1576-
ML7213/ML7223 is completely compatible for Intel EG20T PCH.
1571+
This driver also can be used for LAPIS Semiconductor IOH(Input/
1572+
Output Hub), ML7213, ML7223 and ML7831.
1573+
ML7213 IOH is for IVI(In-Vehicle Infotainment) use, ML7223 IOH is
1574+
for MP(Media Phone) use and ML7831 IOH is for general purpose use.
1575+
ML7213/ML7223/ML7831 is companion chip for Intel Atom E6xx series.
1576+
ML7213/ML7223/ML7831 is completely compatible for Intel EG20T PCH.
15771577

15781578
config SERIAL_MSM_SMD
15791579
bool "Enable tty device interface for some SMD ports"

‎drivers/tty/serial/atmel_serial.c‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
228228
if (rs485conf->flags & SER_RS485_ENABLED) {
229229
dev_dbg(port->dev, "Setting UART to RS485\n");
230230
atmel_port->tx_done_mask = ATMEL_US_TXEMPTY;
231-
if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
231+
if ((rs485conf->delay_rts_after_send) > 0)
232232
UART_PUT_TTGR(port, rs485conf->delay_rts_after_send);
233233
mode |= ATMEL_US_USMODE_RS485;
234234
} else {
@@ -304,7 +304,7 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
304304

305305
if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
306306
dev_dbg(port->dev, "Setting UART to RS485\n");
307-
if (atmel_port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
307+
if ((atmel_port->rs485.delay_rts_after_send) > 0)
308308
UART_PUT_TTGR(port,
309309
atmel_port->rs485.delay_rts_after_send);
310310
mode |= ATMEL_US_USMODE_RS485;
@@ -1228,7 +1228,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
12281228

12291229
if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
12301230
dev_dbg(port->dev, "Setting UART to RS485\n");
1231-
if (atmel_port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
1231+
if ((atmel_port->rs485.delay_rts_after_send) > 0)
12321232
UART_PUT_TTGR(port,
12331233
atmel_port->rs485.delay_rts_after_send);
12341234
mode |= ATMEL_US_USMODE_RS485;
@@ -1447,16 +1447,6 @@ static void __devinit atmel_of_init_port(struct atmel_uart_port *atmel_port,
14471447
rs485conf->delay_rts_after_send = rs485_delay[1];
14481448
rs485conf->flags = 0;
14491449

1450-
if (rs485conf->delay_rts_before_send == 0 &&
1451-
rs485conf->delay_rts_after_send == 0) {
1452-
rs485conf->flags |= SER_RS485_RTS_ON_SEND;
1453-
} else {
1454-
if (rs485conf->delay_rts_before_send)
1455-
rs485conf->flags |= SER_RS485_RTS_BEFORE_SEND;
1456-
if (rs485conf->delay_rts_after_send)
1457-
rs485conf->flags |= SER_RS485_RTS_AFTER_SEND;
1458-
}
1459-
14601450
if (of_get_property(np, "rs485-rx-during-tx", NULL))
14611451
rs485conf->flags |= SER_RS485_RX_DURING_TX;
14621452

‎drivers/tty/serial/crisv10.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,9 +3234,8 @@ rs_write(struct tty_struct *tty,
32343234
e100_disable_rx(info);
32353235
e100_enable_rx_irq(info);
32363236
#endif
3237-
if ((info->rs485.flags & SER_RS485_RTS_BEFORE_SEND) &&
3238-
(info->rs485.delay_rts_before_send > 0))
3239-
msleep(info->rs485.delay_rts_before_send);
3237+
if (info->rs485.delay_rts_before_send > 0)
3238+
msleep(info->rs485.delay_rts_before_send);
32403239
}
32413240
#endif /* CONFIG_ETRAX_RS485 */
32423241

@@ -3693,10 +3692,6 @@ rs_ioctl(struct tty_struct *tty,
36933692

36943693
rs485data.delay_rts_before_send = rs485ctrl.delay_rts_before_send;
36953694
rs485data.flags = 0;
3696-
if (rs485data.delay_rts_before_send != 0)
3697-
rs485data.flags |= SER_RS485_RTS_BEFORE_SEND;
3698-
else
3699-
rs485data.flags &= ~(SER_RS485_RTS_BEFORE_SEND);
37003695

37013696
if (rs485ctrl.enabled)
37023697
rs485data.flags |= SER_RS485_ENABLED;
@@ -4531,7 +4526,6 @@ static int __init rs_init(void)
45314526
/* Set sane defaults */
45324527
info->rs485.flags &= ~(SER_RS485_RTS_ON_SEND);
45334528
info->rs485.flags |= SER_RS485_RTS_AFTER_SEND;
4534-
info->rs485.flags &= ~(SER_RS485_RTS_BEFORE_SEND);
45354529
info->rs485.delay_rts_before_send = 0;
45364530
info->rs485.flags &= ~(SER_RS485_ENABLED);
45374531
#endif

‎drivers/tty/serial/mfd.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
884884
{
885885
struct uart_hsu_port *up =
886886
container_of(port, struct uart_hsu_port, port);
887-
struct tty_struct *tty = port->state->port.tty;
888887
unsigned char cval, fcr = 0;
889888
unsigned long flags;
890889
unsigned int baud, quot;
@@ -907,8 +906,7 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
907906
}
908907

909908
/* CMSPAR isn't supported by this driver */
910-
if (tty)
911-
tty->termios->c_cflag &= ~CMSPAR;
909+
termios->c_cflag &= ~CMSPAR;
912910

913911
if (termios->c_cflag & CSTOPB)
914912
cval |= UART_LCR_STOP;

‎drivers/tty/serial/pch_uart.c‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
*Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD.
2+
*Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
33
*
44
*This program is free software; you can redistribute it and/or modify
55
*it under the terms of the GNU General Public License as published by
@@ -46,8 +46,8 @@ enum {
4646

4747
/* Set the max number of UART port
4848
* Intel EG20T PCH: 4 port
49-
* OKI SEMICONDUCTOR ML7213 IOH: 3 port
50-
* OKI SEMICONDUCTOR ML7223 IOH: 2 port
49+
* LAPIS Semiconductor ML7213 IOH: 3 port
50+
* LAPIS Semiconductor ML7223 IOH: 2 port
5151
*/
5252
#define PCH_UART_NR 4
5353

@@ -258,6 +258,8 @@ enum pch_uart_num_t {
258258
pch_ml7213_uart2,
259259
pch_ml7223_uart0,
260260
pch_ml7223_uart1,
261+
pch_ml7831_uart0,
262+
pch_ml7831_uart1,
261263
};
262264

263265
static struct pch_uart_driver_data drv_dat[] = {
@@ -270,6 +272,8 @@ static struct pch_uart_driver_data drv_dat[] = {
270272
[pch_ml7213_uart2] = {PCH_UART_2LINE, 2},
271273
[pch_ml7223_uart0] = {PCH_UART_8LINE, 0},
272274
[pch_ml7223_uart1] = {PCH_UART_2LINE, 1},
275+
[pch_ml7831_uart0] = {PCH_UART_8LINE, 0},
276+
[pch_ml7831_uart1] = {PCH_UART_2LINE, 1},
273277
};
274278

275279
static unsigned int default_baud = 9600;
@@ -628,6 +632,7 @@ static void pch_request_dma(struct uart_port *port)
628632
dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Rx)\n",
629633
__func__);
630634
dma_release_channel(priv->chan_tx);
635+
priv->chan_tx = NULL;
631636
return;
632637
}
633638

@@ -1215,8 +1220,7 @@ static void pch_uart_shutdown(struct uart_port *port)
12151220
dev_err(priv->port.dev,
12161221
"pch_uart_hal_set_fifo Failed(ret=%d)\n", ret);
12171222

1218-
if (priv->use_dma_flag)
1219-
pch_free_dma(port);
1223+
pch_free_dma(port);
12201224

12211225
free_irq(priv->port.irq, priv);
12221226
}
@@ -1280,6 +1284,7 @@ static void pch_uart_set_termios(struct uart_port *port,
12801284
if (rtn)
12811285
goto out;
12821286

1287+
pch_uart_set_mctrl(&priv->port, priv->port.mctrl);
12831288
/* Don't rewrite B0 */
12841289
if (tty_termios_baud_rate(termios))
12851290
tty_termios_encode_baud_rate(termios, baud, baud);
@@ -1552,6 +1557,10 @@ static DEFINE_PCI_DEVICE_TABLE(pch_uart_pci_id) = {
15521557
.driver_data = pch_ml7223_uart0},
15531558
{PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x800D),
15541559
.driver_data = pch_ml7223_uart1},
1560+
{PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8811),
1561+
.driver_data = pch_ml7831_uart0},
1562+
{PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8812),
1563+
.driver_data = pch_ml7831_uart1},
15551564
{0,},
15561565
};
15571566

‎drivers/tty/tty_ldisc.c‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <linux/kmod.h>
3838
#include <linux/nsproxy.h>
39+
#include <linux/ratelimit.h>
3940

4041
/*
4142
* This guards the refcounted line discipline lists. The lock
@@ -547,15 +548,16 @@ static void tty_ldisc_flush_works(struct tty_struct *tty)
547548
/**
548549
* tty_ldisc_wait_idle - wait for the ldisc to become idle
549550
* @tty: tty to wait for
551+
* @timeout: for how long to wait at most
550552
*
551553
* Wait for the line discipline to become idle. The discipline must
552554
* have been halted for this to guarantee it remains idle.
553555
*/
554-
static int tty_ldisc_wait_idle(struct tty_struct *tty)
556+
static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout)
555557
{
556-
int ret;
558+
long ret;
557559
ret = wait_event_timeout(tty_ldisc_idle,
558-
atomic_read(&tty->ldisc->users) == 1, 5 * HZ);
560+
atomic_read(&tty->ldisc->users) == 1, timeout);
559561
if (ret < 0)
560562
return ret;
561563
return ret > 0 ? 0 : -EBUSY;
@@ -665,7 +667,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
665667

666668
tty_ldisc_flush_works(tty);
667669

668-
retval = tty_ldisc_wait_idle(tty);
670+
retval = tty_ldisc_wait_idle(tty, 5 * HZ);
669671

670672
tty_lock();
671673
mutex_lock(&tty->ldisc_mutex);
@@ -762,8 +764,6 @@ static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
762764
if (IS_ERR(ld))
763765
return -1;
764766

765-
WARN_ON_ONCE(tty_ldisc_wait_idle(tty));
766-
767767
tty_ldisc_close(tty, tty->ldisc);
768768
tty_ldisc_put(tty->ldisc);
769769
tty->ldisc = NULL;
@@ -838,7 +838,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
838838
tty_unlock();
839839
cancel_work_sync(&tty->buf.work);
840840
mutex_unlock(&tty->ldisc_mutex);
841-
841+
retry:
842842
tty_lock();
843843
mutex_lock(&tty->ldisc_mutex);
844844

@@ -847,6 +847,22 @@ void tty_ldisc_hangup(struct tty_struct *tty)
847847
it means auditing a lot of other paths so this is
848848
a FIXME */
849849
if (tty->ldisc) { /* Not yet closed */
850+
if (atomic_read(&tty->ldisc->users) != 1) {
851+
char cur_n[TASK_COMM_LEN], tty_n[64];
852+
long timeout = 3 * HZ;
853+
tty_unlock();
854+
855+
while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) {
856+
timeout = MAX_SCHEDULE_TIMEOUT;
857+
printk_ratelimited(KERN_WARNING
858+
"%s: waiting (%s) for %s took too long, but we keep waiting...\n",
859+
__func__, get_task_comm(cur_n, current),
860+
tty_name(tty, tty_n));
861+
}
862+
mutex_unlock(&tty->ldisc_mutex);
863+
goto retry;
864+
}
865+
850866
if (reset == 0) {
851867

852868
if (!tty_ldisc_reinit(tty, tty->termios->c_line))

‎include/linux/serial.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ struct serial_icounter_struct {
207207

208208
struct serial_rs485 {
209209
__u32 flags; /* RS485 feature flags */
210-
#define SER_RS485_ENABLED (1 << 0)
211-
#define SER_RS485_RTS_ON_SEND (1 << 1)
212-
#define SER_RS485_RTS_AFTER_SEND (1 << 2)
213-
#define SER_RS485_RTS_BEFORE_SEND (1 << 3)
210+
#define SER_RS485_ENABLED (1 << 0) /* If enabled */
211+
#define SER_RS485_RTS_ON_SEND (1 << 1) /* Logical level for
212+
RTS pin when
213+
sending */
214+
#define SER_RS485_RTS_AFTER_SEND (1 << 2) /* Logical level for
215+
RTS pin after sent*/
214216
#define SER_RS485_RX_DURING_TX (1 << 4)
215-
__u32 delay_rts_before_send; /* Milliseconds */
216-
__u32 delay_rts_after_send; /* Milliseconds */
217+
__u32 delay_rts_before_send; /* Delay before send (milliseconds) */
218+
__u32 delay_rts_after_send; /* Delay after send (milliseconds) */
217219
__u32 padding[5]; /* Memory is cheap, new structs
218220
are a royal PITA .. */
219221
};

0 commit comments

Comments
 (0)