From 7c700abd2d04ee9a5b5d7713f2b00b260d5e9c11 Mon Sep 17 00:00:00 2001 From: imp Date: Sun, 22 Dec 2013 22:31:39 +0000 Subject: [PATCH] Direct commit: not relevant to other branches. Fix mountroot> prompt eating most of the characters by not enabling RXRDY interrupts in the attach routine. Instead, defer this until the first interrupt we see after the device is opened. Given the console use case, we're guaranteed to get a TXRDY interrupt before any reads are posted due to boot messages, which makes this work. The real fix is to use cngrab/cnungrab function pointers to disable RXRDY interrupts while grabbed. However, that touches the MI uart code, so was disallowed for 10.0 due to the lateness of the hour this fix was proposed. It works for mountroot, the most common atmel kernel prompt use cases, but wouldn't work for GELI since it prompts later in the boot process. Approved by: re@ (gjb@) git-svn-id: svn://svn.freebsd.org/base/releng/10.0@259748 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/arm/at91/uart_dev_at91usart.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/arm/at91/uart_dev_at91usart.c b/sys/arm/at91/uart_dev_at91usart.c index 9bc4dbf5..e3a812b3 100644 --- a/sys/arm/at91/uart_dev_at91usart.c +++ b/sys/arm/at91/uart_dev_at91usart.c @@ -72,6 +72,7 @@ struct at91_usart_softc { uint32_t flags; #define HAS_TIMEOUT 0x1 #define USE_RTS0_WORKAROUND 0x2 +#define NEEDS_RXRDY 0x4 bus_dma_tag_t rx_tag; struct at91_usart_rx ping_pong[2]; struct at91_usart_rx *ping; @@ -490,7 +491,13 @@ at91_usart_bus_attach(struct uart_softc *sc) WR4(&sc->sc_bas, USART_IER, USART_CSR_TIMEOUT | USART_CSR_RXBUFF | USART_CSR_ENDRX); } else { - WR4(&sc->sc_bas, USART_IER, USART_CSR_RXRDY); + /* + * Defer turning on the RXRDY bit until we're opened. This is to make the + * mountroot prompt work before we've opened the console. This is a workaround + * for not being able to change the UART interface for the 10.0 release. + */ + atsc->flags |= NEEDS_RXRDY; + /* WR4(&sc->sc_bas, USART_IER, USART_CSR_RXRDY); */ } WR4(&sc->sc_bas, USART_IER, USART_CSR_RXBRK | USART_DCE_CHANGE_BITS); @@ -612,6 +619,12 @@ at91_usart_bus_ipend(struct uart_softc *sc) uart_lock(sc->sc_hwmtx); csr = RD4(&sc->sc_bas, USART_CSR); + /* Kludge -- Enable the RXRDY we deferred in attach */ + if (sc->sc_opened && (atsc->flags & NEEDS_RXRDY)) { + WR4(&sc->sc_bas, USART_IER, USART_CSR_RXRDY); + atsc->flags &= ~NEEDS_RXRDY; + } + if (csr & USART_CSR_OVRE) { WR4(&sc->sc_bas, USART_CR, USART_CR_RSTSTA); ipend |= SER_INT_OVERRUN; -- 2.42.0