Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b129a8cc authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[SERIAL] Clean up and fix tty transmission start/stoping



The start_tx and stop_tx methods were passed a flag to indicate
whether the start/stop was from the tty start/stop callbacks, and
some drivers used this flag to decide whether to ask the UART to
immediately stop transmission (where the UART supports such a
feature.)

There are other cases when we wish this to occur - when CTS is
lowered, or if we change from soft to hard flow control and CTS
is inactive.  In these cases, this flag was false, and we would
allow the transmitter to drain before stopping.

There is really only one case where we want to let the transmitter
drain before disabling, and that's when we run out of characters
to send.

Hence, re-jig the start_tx and stop_tx methods to eliminate this
flag, and introduce new functions for the special "disable and
allow transmitter to drain" case.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parents 6b39374a 194d0710
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -111,24 +111,17 @@ hardware.
	Interrupts: locally disabled.
	This call must not sleep

  stop_tx(port,tty_stop)
  stop_tx(port)
	Stop transmitting characters.  This might be due to the CTS
	line becoming inactive or the tty layer indicating we want
	to stop transmission.

	tty_stop: 1 if this call is due to the TTY layer issuing a
	          TTY stop to the driver (equiv to rs_stop).
	to stop transmission due to an XOFF character.

	Locking: port->lock taken.
	Interrupts: locally disabled.
	This call must not sleep

  start_tx(port,tty_start)
	start transmitting characters.  (incidentally, nonempty will
	always be nonzero, and shouldn't be used - it will be dropped).

	tty_start: 1 if this call was due to the TTY layer issuing
	           a TTY start to the driver (equiv to rs_start)
  start_tx(port)
	start transmitting characters.

	Locking: port->lock taken.
	Interrupts: locally disabled.
+4 −6
Original line number Diff line number Diff line
@@ -58,8 +58,7 @@ static const char serial21285_name[] = "Footbridge UART";
 *  int((BAUD_BASE - (baud >> 1)) / baud)
 */

static void
serial21285_stop_tx(struct uart_port *port, unsigned int tty_stop)
static void serial21285_stop_tx(struct uart_port *port)
{
	if (tx_enabled(port)) {
		disable_irq(IRQ_CONTX);
@@ -67,8 +66,7 @@ serial21285_stop_tx(struct uart_port *port, unsigned int tty_stop)
	}
}

static void
serial21285_start_tx(struct uart_port *port, unsigned int tty_start)
static void serial21285_start_tx(struct uart_port *port)
{
	if (!tx_enabled(port)) {
		enable_irq(IRQ_CONTX);
@@ -148,7 +146,7 @@ static irqreturn_t serial21285_tx_chars(int irq, void *dev_id, struct pt_regs *r
		goto out;
	}
	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
		serial21285_stop_tx(port, 0);
		serial21285_stop_tx(port);
		goto out;
	}

@@ -164,7 +162,7 @@ static irqreturn_t serial21285_tx_chars(int irq, void *dev_id, struct pt_regs *r
		uart_write_wakeup(port);

	if (uart_circ_empty(xmit))
		serial21285_stop_tx(port, 0);
		serial21285_stop_tx(port);

 out:
	return IRQ_HANDLED;
+7 −3
Original line number Diff line number Diff line
@@ -1001,7 +1001,7 @@ static inline void __stop_tx(struct uart_8250_port *p)
	}
}

static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
static void serial8250_stop_tx(struct uart_port *port)
{
	struct uart_8250_port *up = (struct uart_8250_port *)port;

@@ -1018,7 +1018,7 @@ static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)

static void transmit_chars(struct uart_8250_port *up);

static void serial8250_start_tx(struct uart_port *port, unsigned int tty_start)
static void serial8250_start_tx(struct uart_port *port)
{
	struct uart_8250_port *up = (struct uart_8250_port *)port;

@@ -1158,7 +1158,11 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
		up->port.x_char = 0;
		return;
	}
	if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
	if (uart_tx_stopped(&up->port)) {
		serial8250_stop_tx(&up->port);
		return;
	}
	if (uart_circ_empty(xmit)) {
		__stop_tx(up);
		return;
	}
+4 −4
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ struct uart_amba_port {
	unsigned int		old_status;
};

static void pl010_stop_tx(struct uart_port *port, unsigned int tty_stop)
static void pl010_stop_tx(struct uart_port *port)
{
	unsigned int cr;

@@ -114,7 +114,7 @@ static void pl010_stop_tx(struct uart_port *port, unsigned int tty_stop)
	UART_PUT_CR(port, cr);
}

static void pl010_start_tx(struct uart_port *port, unsigned int tty_start)
static void pl010_start_tx(struct uart_port *port)
{
	unsigned int cr;

@@ -219,7 +219,7 @@ static void pl010_tx_chars(struct uart_port *port)
		return;
	}
	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
		pl010_stop_tx(port, 0);
		pl010_stop_tx(port);
		return;
	}

@@ -236,7 +236,7 @@ static void pl010_tx_chars(struct uart_port *port)
		uart_write_wakeup(port);

	if (uart_circ_empty(xmit))
		pl010_stop_tx(port, 0);
		pl010_stop_tx(port);
}

static void pl010_modem_status(struct uart_port *port)
+4 −4
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ struct uart_amba_port {
	unsigned int		old_status;
};

static void pl011_stop_tx(struct uart_port *port, unsigned int tty_stop)
static void pl011_stop_tx(struct uart_port *port)
{
	struct uart_amba_port *uap = (struct uart_amba_port *)port;

@@ -82,7 +82,7 @@ static void pl011_stop_tx(struct uart_port *port, unsigned int tty_stop)
	writew(uap->im, uap->port.membase + UART011_IMSC);
}

static void pl011_start_tx(struct uart_port *port, unsigned int tty_start)
static void pl011_start_tx(struct uart_port *port)
{
	struct uart_amba_port *uap = (struct uart_amba_port *)port;

@@ -184,7 +184,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap)
		return;
	}
	if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
		pl011_stop_tx(&uap->port, 0);
		pl011_stop_tx(&uap->port);
		return;
	}

@@ -201,7 +201,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap)
		uart_write_wakeup(&uap->port);

	if (uart_circ_empty(xmit))
		pl011_stop_tx(&uap->port, 0);
		pl011_stop_tx(&uap->port);
}

static void pl011_modem_status(struct uart_amba_port *uap)
Loading