Module Name: src
Committed By: riastradh
Date: Wed Mar 1 08:42:34 UTC 2023
Modified Files:
src/sys/dev/wscons: wsdisplay.c wsdisplayvar.h
src/sys/external/bsd/drm2/nouveau: nouveau_pci.c
Log Message:
nouveau: Kick out genfb on firmware framebuffer before initializing.
PR kern/53126
To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/wscons/wsdisplay.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/wscons/wsdisplayvar.h
cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/drm2/nouveau/nouveau_pci.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/dev/wscons/wsdisplay.c
diff -u src/sys/dev/wscons/wsdisplay.c:1.165 src/sys/dev/wscons/wsdisplay.c:1.166
--- src/sys/dev/wscons/wsdisplay.c:1.165 Sun Jul 17 11:43:39 2022
+++ src/sys/dev/wscons/wsdisplay.c Wed Mar 1 08:42:33 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.165 2022/07/17 11:43:39 riastradh Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.166 2023/03/01 08:42:33 riastradh Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.165 2022/07/17 11:43:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.166 2023/03/01 08:42:33 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_wsdisplay_compat.h"
@@ -982,6 +982,15 @@ wsdisplay_preattach(const struct wsscree
}
void
+wsdisplay_predetach(void)
+{
+ KASSERT(wsdisplay_console_initted == 1);
+
+ cn_tab = wsdisplay_ocn;
+ wsdisplay_console_initted = 0;
+}
+
+void
wsdisplay_cndetach(void)
{
KASSERT(wsdisplay_console_initted == 2);
Index: src/sys/dev/wscons/wsdisplayvar.h
diff -u src/sys/dev/wscons/wsdisplayvar.h:1.56 src/sys/dev/wscons/wsdisplayvar.h:1.57
--- src/sys/dev/wscons/wsdisplayvar.h:1.56 Sat Jan 29 01:19:30 2022
+++ src/sys/dev/wscons/wsdisplayvar.h Wed Mar 1 08:42:33 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplayvar.h,v 1.56 2022/01/29 01:19:30 uwe Exp $ */
+/* $NetBSD: wsdisplayvar.h,v 1.57 2023/03/01 08:42:33 riastradh Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -172,6 +172,7 @@ void wsdisplay_cnattach(const struct wss
long);
void wsdisplay_preattach(const struct wsscreen_descr *, void *, int, int,
long);
+void wsdisplay_predetach(void);
void wsdisplay_cndetach(void);
void wsdisplay_multicons_suspend(bool);
Index: src/sys/external/bsd/drm2/nouveau/nouveau_pci.c
diff -u src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.36 src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.37
--- src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.36 Mon Jul 18 23:34:02 2022
+++ src/sys/external/bsd/drm2/nouveau/nouveau_pci.c Wed Mar 1 08:42:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_pci.c,v 1.36 2022/07/18 23:34:02 riastradh Exp $ */
+/* $NetBSD: nouveau_pci.c,v 1.37 2023/03/01 08:42:34 riastradh Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.36 2022/07/18 23:34:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.37 2023/03/01 08:42:34 riastradh Exp $");
#ifdef _KERNEL_OPT
+#include "genfb.h"
#if defined(__arm__) || defined(__aarch64__)
#include "opt_fdt.h"
#endif
@@ -49,6 +50,11 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_pci.
#include <dev/fdt/fdtvar.h>
#endif
+#if NGENFB > 0
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wsfb/genfbvar.h>
+#endif
+
#include <drm/drm_pci.h>
#include <core/device.h>
@@ -220,6 +226,24 @@ nouveau_pci_attach_real(device_t self)
}
sc->sc_pci_attached = true;
+#if NGENFB > 0
+ /*
+ * If MD initialization has selected this as the console device
+ * with a firmware-provided framebuffer address, we may have to
+ * turn it off early, before we are ready to switch the console
+ * over -- something goes wrong if we're still writing to the
+ * firmware-provided framebuffer during nouveau initialization.
+ */
+ {
+ bool is_console;
+ if (prop_dictionary_get_bool(device_properties(self), "is_console",
+ &is_console) &&
+ is_console &&
+ genfb_is_console())
+ wsdisplay_predetach();
+ }
+#endif
+
/* XXX errno Linux->NetBSD */
error = -nouveau_drm_device_init(sc->sc_drm_dev);
if (error) {