From: Chris Patterson <cjp256@gmail.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
ian.jackson@eu.citrix.com, tim@xen.org,
Chris Patterson <pattersonc@ainfosec.com>,
jbeulich@suse.com
Subject: [PATCH v2] ns16550: mask transmit holding register empty interrupt when tx is stopped
Date: Sun, 21 Aug 2016 13:38:51 -0400 [thread overview]
Message-ID: <1471801131-23272-1-git-send-email-cjp256@gmail.com> (raw)
From: Chris Patterson <pattersonc@ainfosec.com>
The uart generates an interrupt whenever the transmit holding register is
empty and UART_IER_ETHREI is set in UART_IER. Currently, Xen's ns16550
driver does not currently mask this interrupt when transmit is stopped,
unlike other platforms such as Linux [1].
Toggle UART_IER_ETHREI flag in the UART_IER according to the state dictated
by stop_tx and start_tx hooks.
On the Tegra platform (forthcoming series), the reset via reading IIR does not
prevent re-assertion of THRE. This causes Xen to hang in the interrupt
handler's while loop whenever there is no data to transmit. This behavior (bug?)
is addressed by utilizing the start & stop tx hooks.
This has been tested on various x86 PCs for any obvious signs of regressions.
[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/8250/8250_port.c?id=refs/tags/v4.8-rc2#n1518
Signed-off-by: Chris Patterson <pattersonc@ainfosec.com>
---
xen/drivers/char/ns16550.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
Changes in v2:
- unsigned int to u8
- formatting fixes
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index b2b5f56..1da103a 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -656,8 +656,8 @@ static void ns16550_setup_postirq(struct ns16550 *uart)
ns_write_reg(uart,
UART_MCR, UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS);
- /* Enable receive and transmit interrupts. */
- ns_write_reg(uart, UART_IER, UART_IER_ERDAI | UART_IER_ETHREI);
+ /* Enable receive interrupts. */
+ ns_write_reg(uart, UART_IER, UART_IER_ERDAI);
}
if ( uart->irq >= 0 )
@@ -813,6 +813,26 @@ static int __init ns16550_irq(struct serial_port *port)
return ((uart->irq > 0) ? uart->irq : -1);
}
+static void ns16550_start_tx(struct serial_port *port)
+{
+ struct ns16550 *uart = port->uart;
+ u8 ier = ns_read_reg(uart, UART_IER);
+
+ /* Unmask transmit holding register empty interrupt if currently masked. */
+ if ( !(ier & UART_IER_ETHREI) )
+ ns_write_reg(uart, UART_IER, ier | UART_IER_ETHREI);
+}
+
+static void ns16550_stop_tx(struct serial_port *port)
+{
+ struct ns16550 *uart = port->uart;
+ u8 ier = ns_read_reg(uart, UART_IER);
+
+ /* Mask off transmit holding register empty interrupt if currently unmasked. */
+ if ( ier & UART_IER_ETHREI )
+ ns_write_reg(uart, UART_IER, ier & ~UART_IER_ETHREI);
+}
+
#ifdef CONFIG_ARM
static const struct vuart_info *ns16550_vuart_info(struct serial_port *port)
{
@@ -832,6 +852,8 @@ static struct uart_driver __read_mostly ns16550_driver = {
.putc = ns16550_putc,
.getc = ns16550_getc,
.irq = ns16550_irq,
+ .start_tx = ns16550_start_tx,
+ .stop_tx = ns16550_stop_tx,
#ifdef CONFIG_ARM
.vuart_info = ns16550_vuart_info,
#endif
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
reply other threads:[~2016-08-21 17:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471801131-23272-1-git-send-email-cjp256@gmail.com \
--to=cjp256@gmail.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=pattersonc@ainfosec.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.