uart: Don't check SPCR tables if !late_console

On x86 systems, the debug.late_console tunable makes it possible to set
up the console before we call pmap_bootstrap.  (The tunable is turned
on by default; setting late_console=0 results in consoles being probed
early.)

Unfortunately this is not compatible with using the ACPI SPCR table to
find the console, since consulting ACPI tables requires mapping memory
addresses.  As such, we skip the call to uart_cpu_acpi_spcr from
uart_cpu_x86 in the !late_console case.

Reviewed by:	imp
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D35794
This commit is contained in:
Colin Percival 2022-07-12 17:39:00 -07:00
parent 2e66649e4f
commit 07007f3147
3 changed files with 10 additions and 6 deletions

View File

@ -202,6 +202,7 @@ int cold = 1;
long Maxmem = 0;
long realmem = 0;
int late_console = 1;
struct kva_md_info kmi;
@ -1301,7 +1302,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
struct user_segment_descriptor *gdt;
struct region_descriptor r_gdt;
size_t kstack0_sz;
int late_console;
TSRAW(&thread0, TS_ENTER, __func__, NULL);
@ -1521,7 +1521,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
* Default to late console initialization to support these drivers.
* This loses mainly printf()s in getmemsize() and early debugging.
*/
late_console = 1;
TUNABLE_INT_FETCH("debug.late_console", &late_console);
if (!late_console) {
cninit();

View File

@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$");
bus_space_tag_t uart_bus_space_io = X86_BUS_SPACE_IO;
bus_space_tag_t uart_bus_space_mem = X86_BUS_SPACE_MEM;
extern int late_console;
int
uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
{
@ -66,8 +68,12 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
return (0);
#ifdef DEV_ACPI
/* Check if SPCR can tell us what console to use. */
if (uart_cpu_acpi_spcr(devtype, di) == 0)
/*
* Check if SPCR can tell us what console to use. If running with
* !late_console, we haven't set up our own page tables yet, so we
* can't map ACPI tables to look at them.
*/
if (late_console && uart_cpu_acpi_spcr(devtype, di) == 0)
return (0);
#endif

View File

@ -178,6 +178,7 @@ int cold = 1;
long Maxmem = 0;
long realmem = 0;
int late_console = 1;
#ifdef PAE
FEATURE(pae, "Physical Address Extensions");
@ -1396,7 +1397,6 @@ init386(int first)
caddr_t kmdp;
vm_offset_t addend;
size_t ucode_len;
int late_console;
thread0.td_kstack = proc0kstack;
thread0.td_kstack_pages = TD0_KSTACK_PAGES;
@ -1541,7 +1541,6 @@ init386(int first)
* Default to late console initialization to support these drivers.
* This loses mainly printf()s in getmemsize() and early debugging.
*/
late_console = 1;
TUNABLE_INT_FETCH("debug.late_console", &late_console);
if (!late_console) {
cninit();