Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch It turned out that using some Open Firmware routine...



details:   https://anonhg.NetBSD.org/src/rev/fb893ab257ce
branches:  trunk
changeset: 1011712:fb893ab257ce
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Jul 07 02:33:54 2020 +0000

description:
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.

diffstat:

 sys/arch/macppc/include/autoconf.h    |   3 ++-
 sys/arch/macppc/macppc/machdep.c      |  22 ++++++++++++++++------
 sys/arch/ofppc/include/autoconf.h     |   3 ++-
 sys/arch/powerpc/oea/ofw_rascons.c    |  16 ++++++++++++++--
 sys/arch/powerpc/oea/ofwoea_machdep.c |  11 ++++++++---
 5 files changed, 42 insertions(+), 13 deletions(-)

diffs (175 lines):

diff -r 19f076a9b370 -r fb893ab257ce sys/arch/macppc/include/autoconf.h
--- a/sys/arch/macppc/include/autoconf.h        Tue Jul 07 02:10:20 2020 +0000
+++ b/sys/arch/macppc/include/autoconf.h        Tue Jul 07 02:33:54 2020 +0000
@@ -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_ */
diff -r 19f076a9b370 -r fb893ab257ce sys/arch/macppc/macppc/machdep.c
--- a/sys/arch/macppc/macppc/machdep.c  Tue Jul 07 02:10:20 2020 +0000
+++ b/sys/arch/macppc/macppc/machdep.c  Tue Jul 07 02:33:54 2020 +0000
@@ -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;
diff -r 19f076a9b370 -r fb893ab257ce sys/arch/ofppc/include/autoconf.h
--- a/sys/arch/ofppc/include/autoconf.h Tue Jul 07 02:10:20 2020 +0000
+++ b/sys/arch/ofppc/include/autoconf.h Tue Jul 07 02:33:54 2020 +0000
@@ -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
diff -r 19f076a9b370 -r fb893ab257ce sys/arch/powerpc/oea/ofw_rascons.c
--- a/sys/arch/powerpc/oea/ofw_rascons.c        Tue Jul 07 02:10:20 2020 +0000
+++ b/sys/arch/powerpc/oea/ofw_rascons.c        Tue Jul 07 02:33:54 2020 +0000
@@ -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 @@
                    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 */
diff -r 19f076a9b370 -r fb893ab257ce sys/arch/powerpc/oea/ofwoea_machdep.c
--- a/sys/arch/powerpc/oea/ofwoea_machdep.c     Tue Jul 07 02:10:20 2020 +0000
+++ b/sys/arch/powerpc/oea/ofwoea_machdep.c     Tue Jul 07 02:33:54 2020 +0000
@@ -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) {
@@ -191,6 +193,9 @@
 
        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);



Home | Main Index | Thread Index | Old Index