Skip to content

Commit 636110b

Browse files
committed
Merge tag 'tty-6.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull serial driver fixes from Greg KH: "Here are two small serial driver fixes for 6.13-rc3. They are: - ioport build fallout fix for the 8250 port driver that should resolve Guenter's runtime problems - sh-sci driver bugfix for a reported problem Both of these have been in linux-next for a while with no reported issues" * tag 'tty-6.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: serial: Work around warning backtrace in serial8250_set_defaults serial: sh-sci: Check if TX data was written to device in .tx_empty()
2 parents 3de4f6d + 4e450df commit 636110b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

drivers/tty/serial/8250/8250_port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ static void set_io_from_upio(struct uart_port *p)
467467
break;
468468
#endif
469469
default:
470-
WARN(1, "Unsupported UART type %x\n", p->iotype);
470+
WARN(p->iotype != UPIO_PORT || p->iobase,
471+
"Unsupported UART type %x\n", p->iotype);
471472
p->serial_in = no_serial_in;
472473
p->serial_out = no_serial_out;
473474
}

drivers/tty/serial/sh-sci.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct sci_port {
157157

158158
bool has_rtscts;
159159
bool autorts;
160+
bool tx_occurred;
160161
};
161162

162163
#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
@@ -850,6 +851,7 @@ static void sci_transmit_chars(struct uart_port *port)
850851
{
851852
struct tty_port *tport = &port->state->port;
852853
unsigned int stopped = uart_tx_stopped(port);
854+
struct sci_port *s = to_sci_port(port);
853855
unsigned short status;
854856
unsigned short ctrl;
855857
int count;
@@ -885,6 +887,7 @@ static void sci_transmit_chars(struct uart_port *port)
885887
}
886888

887889
sci_serial_out(port, SCxTDR, c);
890+
s->tx_occurred = true;
888891

889892
port->icount.tx++;
890893
} while (--count > 0);
@@ -1241,6 +1244,8 @@ static void sci_dma_tx_complete(void *arg)
12411244
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
12421245
uart_write_wakeup(port);
12431246

1247+
s->tx_occurred = true;
1248+
12441249
if (!kfifo_is_empty(&tport->xmit_fifo)) {
12451250
s->cookie_tx = 0;
12461251
schedule_work(&s->work_tx);
@@ -1731,6 +1736,19 @@ static void sci_flush_buffer(struct uart_port *port)
17311736
s->cookie_tx = -EINVAL;
17321737
}
17331738
}
1739+
1740+
static void sci_dma_check_tx_occurred(struct sci_port *s)
1741+
{
1742+
struct dma_tx_state state;
1743+
enum dma_status status;
1744+
1745+
if (!s->chan_tx)
1746+
return;
1747+
1748+
status = dmaengine_tx_status(s->chan_tx, s->cookie_tx, &state);
1749+
if (status == DMA_COMPLETE || status == DMA_IN_PROGRESS)
1750+
s->tx_occurred = true;
1751+
}
17341752
#else /* !CONFIG_SERIAL_SH_SCI_DMA */
17351753
static inline void sci_request_dma(struct uart_port *port)
17361754
{
@@ -1740,6 +1758,10 @@ static inline void sci_free_dma(struct uart_port *port)
17401758
{
17411759
}
17421760

1761+
static void sci_dma_check_tx_occurred(struct sci_port *s)
1762+
{
1763+
}
1764+
17431765
#define sci_flush_buffer NULL
17441766
#endif /* !CONFIG_SERIAL_SH_SCI_DMA */
17451767

@@ -2076,6 +2098,12 @@ static unsigned int sci_tx_empty(struct uart_port *port)
20762098
{
20772099
unsigned short status = sci_serial_in(port, SCxSR);
20782100
unsigned short in_tx_fifo = sci_txfill(port);
2101+
struct sci_port *s = to_sci_port(port);
2102+
2103+
sci_dma_check_tx_occurred(s);
2104+
2105+
if (!s->tx_occurred)
2106+
return TIOCSER_TEMT;
20792107

20802108
return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0;
20812109
}
@@ -2247,6 +2275,7 @@ static int sci_startup(struct uart_port *port)
22472275

22482276
dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
22492277

2278+
s->tx_occurred = false;
22502279
sci_request_dma(port);
22512280

22522281
ret = sci_request_irq(s);

0 commit comments

Comments
 (0)