aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Hu <whu@FreeBSD.org>2023-03-14 15:49:33 +0000
committerWei Hu <whu@FreeBSD.org>2023-03-18 07:07:54 +0000
commit8ea7fa16d9fe5acb7d42a223efbfa23627aa5e0c (patch)
tree03b442e28e5807748ec1b215ba19b0f3b6482530
parent927358dd98cb902160093e0dc0bac002d6b43858 (diff)
downloadsrc-8ea7fa16d9fe5acb7d42a223efbfa23627aa5e0c.tar.gz
src-8ea7fa16d9fe5acb7d42a223efbfa23627aa5e0c.zip
uart: Don't change settings or throttle putc for Hyper-V
Azure setup does not like it when FreeBSD overrides the settings of the UART device. When Hyper-V is detected, don't do this and also don't throttle putc() output. This is a workaround for the early boot hang of FreeBSD on Azure. Tested on Azure, ESXi (VM with serial port), and SG-8200 PR: 264267 Reviewed by: kevans, whu Tested by: whu Obtained from: Rubicon Communications, LLC (Netgate) MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate)
-rw-r--r--sys/dev/uart/uart_dev_ns8250.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c
index 475ab5d4425e..2c44e9e34b8b 100644
--- a/sys/dev/uart/uart_dev_ns8250.c
+++ b/sys/dev/uart/uart_dev_ns8250.c
@@ -249,6 +249,10 @@ ns8250_param(struct uart_bas *bas, int baudrate, int databits, int stopbits,
int divisor;
uint8_t lcr;
+ /* Don't change settings when running on Hyper-V */
+ if (vm_guest == VM_GUEST_HV)
+ return (0);
+
lcr = 0;
if (databits >= 8)
lcr |= LCR_8BITS;
@@ -374,9 +378,11 @@ ns8250_putc(struct uart_bas *bas, int c)
{
int limit;
- limit = 250000;
- while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0 && --limit)
- DELAY(4);
+ if (vm_guest != VM_GUEST_HV) {
+ limit = 250000;
+ while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0 && --limit)
+ DELAY(4);
+ }
uart_setreg(bas, REG_DATA, c);
uart_barrier(bas);
}
@@ -532,15 +538,15 @@ ns8250_bus_attach(struct uart_softc *sc)
#endif
if (!resource_int_value("uart", device_get_unit(sc->sc_dev), "flags",
&ivar)) {
- if (UART_FLAGS_FCR_RX_LOW(ivar))
+ if (UART_FLAGS_FCR_RX_LOW(ivar))
ns8250->fcr |= FCR_RX_LOW;
- else if (UART_FLAGS_FCR_RX_MEDL(ivar))
+ else if (UART_FLAGS_FCR_RX_MEDL(ivar))
ns8250->fcr |= FCR_RX_MEDL;
- else if (UART_FLAGS_FCR_RX_HIGH(ivar))
+ else if (UART_FLAGS_FCR_RX_HIGH(ivar))
ns8250->fcr |= FCR_RX_HIGH;
else
ns8250->fcr |= FCR_RX_MEDH;
- } else
+ } else
ns8250->fcr |= FCR_RX_MEDH;
/* Get IER mask */