git: 637fce654017 - stable/14 - uart: Set the bus space tag before parsing hw.uart.console

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 16:24:21 UTC
The branch stable/14 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=637fce6540174ac062f3750511e09d644fded9cc

commit 637fce6540174ac062f3750511e09d644fded9cc
Author:     Rick Richard <rick@sloservers.com>
AuthorDate: 2026-10-03 16:00:00 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-11-12 16:23:28 +0000

    uart: Set the bus space tag before parsing hw.uart.console
    
    uart_cpu_getdev() lets hw.uart.console override the FDT, but
    uart_getenv() maps an "mm:" address with uart_bus_space_mem, which is
    only assigned after the FDT probe.  On riscv and arm it is still NULL
    at that point, so bus_space_map() faults before there is a console.
    On riscv this happens on any EFI boot where the firmware provides an
    SPCR table, since the loader turns it into hw.uart.console.
    
    Initialize uart_bus_space_mem to fdtbus_bs_tag, as uart_cpu_arm64.c
    does with &memmap_bus (See also 0624eddcffefe).
    
    PR:             299089
    Reviewed by:    mhorne
    MFC after:      1 week
    Signed-off-by:  Rick Richard <rick@sloservers.com>
    
    (cherry picked from commit 9db8ae83e62e9a1391674a14b0b7d76de2e3c3f7)
---
 sys/dev/uart/uart_cpu_fdt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/dev/uart/uart_cpu_fdt.c b/sys/dev/uart/uart_cpu_fdt.c
index 1cc1c795f29f..f0056b7fdc28 100644
--- a/sys/dev/uart/uart_cpu_fdt.c
+++ b/sys/dev/uart/uart_cpu_fdt.c
@@ -50,6 +50,8 @@
 #include <dev/uart/uart_cpu.h>
 #include <dev/uart/uart_cpu_fdt.h>
 
+extern bus_space_tag_t fdtbus_bs_tag;
+
 /*
  * UART console routines.
  */
@@ -78,6 +80,8 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 	u_int shift, iowidth, rclk;
 	int br, err;
 
+	uart_bus_space_mem = fdtbus_bs_tag;
+
 	/* Allow overriding the FDT using the environment. */
 	class = &uart_ns8250_class;
 	err = uart_getenv(devtype, di, class);