Module Name:    src
Committed By:   rin
Date:           Tue Jul  7 02:33:55 UTC 2020

Modified Files:
        src/sys/arch/macppc/include: autoconf.h
        src/sys/arch/macppc/macppc: machdep.c
        src/sys/arch/ofppc/include: autoconf.h
        src/sys/arch/powerpc/oea: ofw_rascons.c ofwoea_machdep.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/macppc/include/autoconf.h
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/macppc/macppc/machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/ofppc/include/autoconf.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/oea/ofw_rascons.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/powerpc/oea/ofwoea_machdep.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/macppc/include/autoconf.h
diff -u src/sys/arch/macppc/include/autoconf.h:1.19 src/sys/arch/macppc/include/autoconf.h:1.20
--- src/sys/arch/macppc/include/autoconf.h:1.19	Tue Jan  8 07:46:10 2019
+++ src/sys/arch/macppc/include/autoconf.h	Tue Jul  7 02:33:54 2020
@@ -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 @@ int rascons_cnattach(void);
 
 extern int console_node;
 extern int console_instance;
+extern int ofw_quiesce;
 extern char model_name[64];
 
 #endif /* _MACHINE_AUTOCONF_H_ */

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.169 src/sys/arch/macppc/macppc/machdep.c:1.170
--- src/sys/arch/macppc/macppc/machdep.c:1.169	Mon Jan 28 02:25:01 2019
+++ src/sys/arch/macppc/macppc/machdep.c	Tue Jul  7 02:33:54 2020
@@ -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 @@ copy_disp_props(device_t dev, int node, 
 	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 @@ copy_disp_props(device_t dev, int node, 
 	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 @@ copy_disp_props(device_t dev, int node, 
 		    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;

Index: src/sys/arch/ofppc/include/autoconf.h
diff -u src/sys/arch/ofppc/include/autoconf.h:1.16 src/sys/arch/ofppc/include/autoconf.h:1.17
--- src/sys/arch/ofppc/include/autoconf.h:1.16	Tue Jan  8 07:46:10 2019
+++ src/sys/arch/ofppc/include/autoconf.h	Tue Jul  7 02:33:54 2020
@@ -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 @@ struct model_data {
 };
 
 extern int console_node;
+extern int ofw_quiesce;		/* XXX not used at the moment */
 extern char model_name[64];
 
 #ifdef _KERNEL

Index: src/sys/arch/powerpc/oea/ofw_rascons.c
diff -u src/sys/arch/powerpc/oea/ofw_rascons.c:1.15 src/sys/arch/powerpc/oea/ofw_rascons.c:1.16
--- src/sys/arch/powerpc/oea/ofw_rascons.c:1.15	Tue Jul  7 02:10:20 2020
+++ src/sys/arch/powerpc/oea/ofw_rascons.c	Tue Jul  7 02:33:54 2020
@@ -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"
 
@@ -286,6 +286,18 @@ rascons_init_rasops(int node, struct ras
 		    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;
 }
 #else	/* NWSDISPLAY > 0 */

Index: src/sys/arch/powerpc/oea/ofwoea_machdep.c
diff -u src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.49 src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.50
--- src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.49	Mon Jul  6 10:59:37 2020
+++ src/sys/arch/powerpc/oea/ofwoea_machdep.c	Tue Jul  7 02:33:54 2020
@@ -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 = TIMEBASE_FREQ;
 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 @@ ofwoea_initppc(u_int startkernel, u_int 
 
 	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) {
@@ -191,6 +193,9 @@ ofwoea_initppc(u_int startkernel, u_int 
 
 	ofwoea_consinit();
 
+	if (ofw_quiesce)
+		OF_quiesce();
+
 #if defined(MULTIPROCESSOR) && defined(ofppc)
 	for (i=1; i < CPU_MAXNUM; i++) {
 		snprintf(cpupath, sizeof(cpupath), "/cpus/@%x", i);

Reply via email to