Tue Jul 7 02:33:55 2020 UTC ()
It turned out that using some Open Firmware routines causes the system
freeze after calling OF_quiesce().
This is why setting color palette crash the system for some Power Mac G5
models, like PowerMac11,2.
Therefore, stop using color-palette and backlight callbacks for genfb(4)
in this case.
Also, postpone OF_quiesce() after rascons_init_rasops(), and initialize
color palette there if OF is going to be quiesced and color depth is 8.
Now, color palette for wscons is initialized correctly for PowerMac11,2.
(rin)
diff -r1.19 -r1.20 src/sys/arch/macppc/include/autoconf.h
diff -r1.169 -r1.170 src/sys/arch/macppc/macppc/machdep.c
diff -r1.16 -r1.17 src/sys/arch/ofppc/include/autoconf.h
diff -r1.15 -r1.16 src/sys/arch/powerpc/oea/ofw_rascons.c
diff -r1.49 -r1.50 src/sys/arch/powerpc/oea/ofwoea_machdep.c
--- src/sys/arch/macppc/include/autoconf.h 2019/01/08 07:46:10 1.19
+++ src/sys/arch/macppc/include/autoconf.h 2020/07/07 02:33:54 1.20
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.19 2019/01/08 07:46:10 mrg Exp $ */
+/* $NetBSD: autoconf.h,v 1.20 2020/07/07 02:33:54 rin Exp $ */
/*-
* Copyright (C) 1998 Internet Research Institute, Inc.
@@ -82,6 +82,7 @@
extern int console_node;
extern int console_instance;
+extern int ofw_quiesce;
extern char model_name[64];
#endif /* _MACHINE_AUTOCONF_H_ */
--- src/sys/arch/macppc/macppc/machdep.c 2019/01/28 02:25:01 1.169
+++ src/sys/arch/macppc/macppc/machdep.c 2020/07/07 02:33:54 1.170
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.169 2019/01/28 02:25:01 sevan Exp $ */
+/* $NetBSD: machdep.c,v 1.170 2020/07/07 02:33:54 rin Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.169 2019/01/28 02:25:01 sevan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.170 2020/07/07 02:33:54 rin Exp $");
#include "opt_compat_netbsd.h"
#include "opt_ddb.h"
@@ -277,11 +277,8 @@
uint32_t temp;
uint64_t cmap_cb, backlight_cb, brightness_cb;
int have_backlight = 0;
-#ifdef PMAC_G5
- int have_palette = 0;
-#else
int have_palette = 1;
-#endif
+
if (node != console_node) {
/*
* see if any child matches since OF attaches nodes for
@@ -349,6 +346,12 @@
if (temp != 0)
prop_dictionary_set_uint32(dict, "refclk", temp / 10);
+ if (have_palette && ofw_quiesce) {
+ aprint_debug(
+ "OFW has been quiesced - disabling palette callback\n");
+ have_palette = 0;
+ }
+
if (have_palette) {
gfb_cb.gcc_cookie = (void *)console_instance;
gfb_cb.gcc_set_mapreg = of_set_palette;
@@ -364,6 +367,13 @@
sizeof(temp)) == 4) {
have_backlight = 1;
}
+
+ if (have_backlight && ofw_quiesce) {
+ aprint_debug(
+ "OFW has been quiesced - disabling backlight callbacks\n");
+ have_palette = 0;
+ }
+
if (have_backlight) {
gpc_backlight.gpc_cookie = (void *)console_instance;
--- src/sys/arch/ofppc/include/autoconf.h 2019/01/08 07:46:10 1.16
+++ src/sys/arch/ofppc/include/autoconf.h 2020/07/07 02:33:54 1.17
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.16 2019/01/08 07:46:10 mrg Exp $ */
+/* $NetBSD: autoconf.h,v 1.17 2020/07/07 02:33:54 rin Exp $ */
#ifndef _OFPPC_AUTOCONF_H_
#define _OFPPC_AUTOCONF_H_
@@ -32,6 +32,7 @@
};
extern int console_node;
+extern int ofw_quiesce; /* XXX not used at the moment */
extern char model_name[64];
#ifdef _KERNEL
--- src/sys/arch/powerpc/oea/ofw_rascons.c 2020/07/07 02:10:20 1.15
+++ src/sys/arch/powerpc/oea/ofw_rascons.c 2020/07/07 02:33:54 1.16
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_rascons.c,v 1.15 2020/07/07 02:10:20 rin Exp $ */
+/* $NetBSD: ofw_rascons.c,v 1.16 2020/07/07 02:33:54 rin Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_rascons.c,v 1.15 2020/07/07 02:10:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_rascons.c,v 1.16 2020/07/07 02:33:54 rin Exp $");
#include "wsdisplay.h"
@@ -284,6 +284,18 @@
ri->ri_caps = WSSCREEN_WSCOLORS;
rasops_reconfig(ri, height / ri->ri_font->fontheight,
width / ri->ri_font->fontwidth);
+ }
+
+ if (depth == 8 && ofw_quiesce) {
+ /*
+ * Open Firmware will be quiesced. This is last chance to
+ * set color palette via ``color!'' method.
+ */
+ for (int i = 0; i < 256; i++) {
+ OF_call_method_1("color!", console_instance, 4,
+ rasops_cmap[3 * i], rasops_cmap[3 * i + 1],
+ rasops_cmap[3 * i + 2], i);
+ }
}
return true;
--- src/sys/arch/powerpc/oea/ofwoea_machdep.c 2020/07/06 10:59:37 1.49
+++ src/sys/arch/powerpc/oea/ofwoea_machdep.c 2020/07/07 02:33:54 1.50
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.49 2020/07/06 10:59:37 rin Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.50 2020/07/07 02:33:54 rin Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.49 2020/07/06 10:59:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.50 2020/07/07 02:33:54 rin Exp $");
#include "ksyms.h"
#include "wsdisplay.h"
@@ -126,6 +126,8 @@
u_int timebase_freq = 0;
#endif
+int ofw_quiesce;
+
extern int ofwmsr;
extern int chosen;
extern uint32_t ticks_per_sec;
@@ -176,7 +178,7 @@
if (strncmp(model_name, "PowerMac11,2", 12) == 0 ||
strncmp(model_name, "PowerMac12,1", 12) == 0)
- OF_quiesce();
+ ofw_quiesce = 1;
/* switch CPUs to full speed */
if (strncmp(model_name, "PowerMac7,", 10) == 0) {
@@ -190,6 +192,9 @@
ofwoea_bus_space_init();
ofwoea_consinit();
+
+ if (ofw_quiesce)
+ OF_quiesce();
#if defined(MULTIPROCESSOR) && defined(ofppc)
for (i=1; i < CPU_MAXNUM; i++) {