Module Name: src Committed By: riastradh Date: Mon Sep 5 14:18:51 UTC 2022
Modified Files: src/sys/arch/x86/pci: pci_machdep.c src/sys/arch/x86/x86: consinit.c Log Message: x86: Fix interaction between consinit, device_pci_register, and drm. Leave an essay on what's going on here in both places with cross-references. PR kern/56996 To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/arch/x86/pci/pci_machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/x86/consinit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/pci/pci_machdep.c diff -u src/sys/arch/x86/pci/pci_machdep.c:1.91 src/sys/arch/x86/pci/pci_machdep.c:1.92 --- src/sys/arch/x86/pci/pci_machdep.c:1.91 Tue May 24 14:00:23 2022 +++ src/sys/arch/x86/pci/pci_machdep.c Mon Sep 5 14:18:51 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.91 2022/05/24 14:00:23 bouyer Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.92 2022/09/05 14:18:51 riastradh Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.91 2022/05/24 14:00:23 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.92 2022/09/05 14:18:51 riastradh Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -1228,14 +1228,29 @@ device_pci_register(device_t dev, void * */ populate_fbinfo(dev, dict); -#if 1 && NWSDISPLAY > 0 && NGENFB > 0 - /* XXX */ - if (device_is_a(dev, "genfb")) { - prop_dictionary_set_bool(dict, "is_console", - genfb_is_console()); - } else -#endif - prop_dictionary_set_bool(dict, "is_console", true); + /* + * If the bootloader requested console=pc and + * specified a framebuffer, and if + * x86_genfb_cnattach succeeded in setting it + * up during consinit, then consinit will call + * genfb_cnattach which makes genfb_is_console + * return true. In this case, if it's the + * first genfb we've seen, we will instruct the + * genfb driver via the is_console property + * that it has been selected as the console. + * + * If not all of that happened, then consinit + * can't have selected a genfb console, so this + * device is definitely not the console. + * + * XXX What happens if there's more than one + * PCI display device, and the bootloader picks + * the second one's framebuffer as the console + * framebuffer address? Tough...but this has + * probably never worked. + */ + prop_dictionary_set_bool(dict, "is_console", + genfb_is_console()); prop_dictionary_set_bool(dict, "clear-screen", false); #if NWSDISPLAY > 0 && NGENFB > 0 Index: src/sys/arch/x86/x86/consinit.c diff -u src/sys/arch/x86/x86/consinit.c:1.34 src/sys/arch/x86/x86/consinit.c:1.35 --- src/sys/arch/x86/x86/consinit.c:1.34 Thu Oct 7 12:52:27 2021 +++ src/sys/arch/x86/x86/consinit.c Mon Sep 5 14:18:51 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: consinit.c,v 1.34 2021/10/07 12:52:27 msaitoh Exp $ */ +/* $NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $ */ /* * Copyright (c) 1998 @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.34 2021/10/07 12:52:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $"); #include "opt_kgdb.h" #include "opt_puc.h" @@ -195,6 +195,15 @@ consinit(void) int error; #if (NGENFB > 0) if (fbinfo && fbinfo->physaddr > 0) { + /* + * If we have a framebuffer address, and + * x86_genfb_cnattach can map it, then + * genfb_cnattach causes genfb_is_console to + * later return true. device_pci_register will + * use this to set up the device properties for + * a PCI display-class device to notify it that + * it has been selected as the console. + */ if (x86_genfb_cnattach() == -1) { initted = 0; /* defer */ return;