Skip to content

Commit 69c37a9

Browse files
committed
Merge tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some tty/serial driver fixes for 4.4-rc6 that resolve some reported problems. All of these have been in linux-next. The details are in the shortlog" * tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: Fix GPF in flush_to_ldisc() serial: earlycon: Add missing spinlock initialization serial: sh-sci: Fix length of scatterlist n_tty: Fix poll() after buffer-limited eof push read serial: 8250_uniphier: fix dl_read and dl_write functions
2 parents 24b0d5e + 9ce119f commit 69c37a9

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

drivers/tty/n_tty.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,13 +2054,13 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
20542054
size_t eol;
20552055
size_t tail;
20562056
int ret, found = 0;
2057-
bool eof_push = 0;
20582057

20592058
/* N.B. avoid overrun if nr == 0 */
2060-
n = min(*nr, smp_load_acquire(&ldata->canon_head) - ldata->read_tail);
2061-
if (!n)
2059+
if (!*nr)
20622060
return 0;
20632061

2062+
n = min(*nr + 1, smp_load_acquire(&ldata->canon_head) - ldata->read_tail);
2063+
20642064
tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1);
20652065
size = min_t(size_t, tail + n, N_TTY_BUF_SIZE);
20662066

@@ -2081,12 +2081,11 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
20812081
n = eol - tail;
20822082
if (n > N_TTY_BUF_SIZE)
20832083
n += N_TTY_BUF_SIZE;
2084-
n += found;
2085-
c = n;
2084+
c = n + found;
20862085

2087-
if (found && !ldata->push && read_buf(ldata, eol) == __DISABLED_CHAR) {
2088-
n--;
2089-
eof_push = !n && ldata->read_tail != ldata->line_start;
2086+
if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) {
2087+
c = min(*nr, c);
2088+
n = c;
20902089
}
20912090

20922091
n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu size:%zu more:%zu\n",
@@ -2116,7 +2115,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
21162115
ldata->push = 0;
21172116
tty_audit_push(tty);
21182117
}
2119-
return eof_push ? -EAGAIN : 0;
2118+
return 0;
21202119
}
21212120

21222121
extern ssize_t redirected_tty_write(struct file *, const char __user *,
@@ -2273,10 +2272,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
22732272

22742273
if (ldata->icanon && !L_EXTPROC(tty)) {
22752274
retval = canon_copy_from_read_buf(tty, &b, &nr);
2276-
if (retval == -EAGAIN) {
2277-
retval = 0;
2278-
continue;
2279-
} else if (retval)
2275+
if (retval)
22802276
break;
22812277
} else {
22822278
int uncopied;

drivers/tty/serial/8250/8250_uniphier.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,16 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value)
115115
*/
116116
static int uniphier_serial_dl_read(struct uart_8250_port *up)
117117
{
118-
return readl(up->port.membase + UNIPHIER_UART_DLR);
118+
int offset = UNIPHIER_UART_DLR << up->port.regshift;
119+
120+
return readl(up->port.membase + offset);
119121
}
120122

121123
static void uniphier_serial_dl_write(struct uart_8250_port *up, int value)
122124
{
123-
writel(value, up->port.membase + UNIPHIER_UART_DLR);
125+
int offset = UNIPHIER_UART_DLR << up->port.regshift;
126+
127+
writel(value, up->port.membase + offset);
124128
}
125129

126130
static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port,

drivers/tty/serial/earlycon.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
115115
if (buf && !parse_options(&early_console_dev, buf))
116116
buf = NULL;
117117

118+
spin_lock_init(&port->lock);
118119
port->uartclk = BASE_BAUD * 16;
119120
if (port->mapbase)
120121
port->membase = earlycon_map(port->mapbase, 64);
@@ -202,6 +203,7 @@ int __init of_setup_earlycon(unsigned long addr,
202203
int err;
203204
struct uart_port *port = &early_console_dev.port;
204205

206+
spin_lock_init(&port->lock);
205207
port->iotype = UPIO_MEM;
206208
port->mapbase = addr;
207209
port->uartclk = BASE_BAUD * 16;

drivers/tty/serial/sh-sci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ static void sci_request_dma(struct uart_port *port)
14371437
sg_init_table(sg, 1);
14381438
s->rx_buf[i] = buf;
14391439
sg_dma_address(sg) = dma;
1440-
sg->length = s->buf_len_rx;
1440+
sg_dma_len(sg) = s->buf_len_rx;
14411441

14421442
buf += s->buf_len_rx;
14431443
dma += s->buf_len_rx;

drivers/tty/tty_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count)
450450
count = disc->ops->receive_buf2(tty, p, f, count);
451451
else {
452452
count = min_t(int, count, tty->receive_room);
453-
if (count)
453+
if (count && disc->ops->receive_buf)
454454
disc->ops->receive_buf(tty, p, f, count);
455455
}
456456
return count;

0 commit comments

Comments
 (0)