Source-Changes-HG archive

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

[src/trunk]: src/sys workaround a problem with the pegasos firmware interface:



details:   https://anonhg.NetBSD.org/src/rev/1aea8c5892ce
branches:  trunk
changeset: 447355:1aea8c5892ce
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Jan 08 07:46:10 2019 +0000

description:
workaround a problem with the pegasos firmware interface:
attempting to use /dev/openfirm on this machine hangs hard.

this isn't a new problem, and i've been meaning to try to
figure it out for years, but it's become a problem since
the xf86-video-radeon driver gained code to look for the
macppc model using this interface.

this is why xorg-server 1.18 and 1.20 hang recently on the
pegasosII.


this change is fairly ugly but i couldn't think of a less
ugly method to avoid /dev/openfirm working just on this
one platform.  introduce new __OPENFIRMIO_OPEN_CHECK_BROKEN
macro and associated __openfirmio_open_check_broken(), and
use them in the new openfirmopen() to fail opens.

include proplib.h in macppc and ofppc autoconf.h since they
use it.

diffstat:

 sys/arch/macppc/include/autoconf.h  |   6 ++++--
 sys/arch/ofppc/include/autoconf.h   |   4 +++-
 sys/arch/powerpc/include/types.h    |   4 +++-
 sys/arch/powerpc/powerpc/openfirm.c |  13 +++++++++++--
 sys/dev/ofw/openfirmio.c            |  22 +++++++++++++++++-----
 5 files changed, 38 insertions(+), 11 deletions(-)

diffs (145 lines):

diff -r 113780d8bfff -r 1aea8c5892ce sys/arch/macppc/include/autoconf.h
--- a/sys/arch/macppc/include/autoconf.h        Tue Jan 08 07:34:22 2019 +0000
+++ b/sys/arch/macppc/include/autoconf.h        Tue Jan 08 07:46:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.h,v 1.18 2011/07/01 21:02:15 dyoung Exp $     */
+/*     $NetBSD: autoconf.h,v 1.19 2019/01/08 07:46:10 mrg Exp $        */
 
 /*-
  * Copyright (C) 1998  Internet Research Institute, Inc.
@@ -34,7 +34,9 @@
 #ifndef _MACHINE_AUTOCONF_H_
 #define _MACHINE_AUTOCONF_H_
 
-#include <sys/bus.h>   /* for bus_space_tag_t */
+#include <sys/bus.h>
+
+#include <prop/proplib.h>
 
 struct confargs {
        const char *ca_name;
diff -r 113780d8bfff -r 1aea8c5892ce sys/arch/ofppc/include/autoconf.h
--- a/sys/arch/ofppc/include/autoconf.h Tue Jan 08 07:34:22 2019 +0000
+++ b/sys/arch/ofppc/include/autoconf.h Tue Jan 08 07:46:10 2019 +0000
@@ -1,10 +1,12 @@
-/*     $NetBSD: autoconf.h,v 1.15 2011/07/01 21:02:15 dyoung Exp $     */
+/*     $NetBSD: autoconf.h,v 1.16 2019/01/08 07:46:10 mrg Exp $        */
 
 #ifndef _OFPPC_AUTOCONF_H_
 #define _OFPPC_AUTOCONF_H_
 
 #include <sys/bus.h>
 
+#include <prop/proplib.h>
+
 struct confargs {
        const char      *ca_name;
        u_int           ca_node;
diff -r 113780d8bfff -r 1aea8c5892ce sys/arch/powerpc/include/types.h
--- a/sys/arch/powerpc/include/types.h  Tue Jan 08 07:34:22 2019 +0000
+++ b/sys/arch/powerpc/include/types.h  Tue Jan 08 07:46:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.56 2017/01/27 17:22:39 christos Exp $      */
+/*     $NetBSD: types.h,v 1.57 2019/01/08 07:46:11 mrg Exp $   */
 
 /*-
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -87,6 +87,8 @@
 #define        __HAVE___LWP_GETTCB_FAST
 #define        __HAVE___LWP_SETTCB
 #define        __HAVE_TLS_VARIANT_I
+#define        __OPENFIRMIO_OPEN_CHECK_BROKEN
+int __openfirmio_open_check_broken(void);
 
 #if defined(_KERNEL) || defined(_KMEMUSER)
 #define        PCU_FPU         0       /* FPU */
diff -r 113780d8bfff -r 1aea8c5892ce sys/arch/powerpc/powerpc/openfirm.c
--- a/sys/arch/powerpc/powerpc/openfirm.c       Tue Jan 08 07:34:22 2019 +0000
+++ b/sys/arch/powerpc/powerpc/openfirm.c       Tue Jan 08 07:46:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openfirm.c,v 1.26 2018/09/03 16:29:26 riastradh Exp $  */
+/*     $NetBSD: openfirm.c,v 1.27 2019/01/08 07:46:11 mrg Exp $        */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.26 2018/09/03 16:29:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.27 2019/01/08 07:46:11 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,6 +42,7 @@
 #include <uvm/uvm_extern.h>
 
 #include <machine/psl.h>
+#include <machine/autoconf.h>
 
 #include <dev/ofw/openfirm.h>
 
@@ -757,3 +758,11 @@
        while (len-- > 0)
                *dp++ = *sp++;
 }
+
+#ifdef __OPENFIRMIO_OPEN_CHECK_BROKEN
+int
+__openfirmio_open_check_broken(void)
+{
+       return strncmp(model_name, "Pegasos", 7) == 0 ? ENXIO : 0;
+}
+#endif
diff -r 113780d8bfff -r 1aea8c5892ce sys/dev/ofw/openfirmio.c
--- a/sys/dev/ofw/openfirmio.c  Tue Jan 08 07:34:22 2019 +0000
+++ b/sys/dev/ofw/openfirmio.c  Tue Jan 08 07:46:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openfirmio.c,v 1.13 2014/07/25 08:10:37 dholland Exp $ */
+/*     $NetBSD: openfirmio.c,v 1.14 2019/01/08 07:46:11 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: openfirmio.c,v 1.13 2014/07/25 08:10:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirmio.c,v 1.14 2019/01/08 07:46:11 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,10 +63,11 @@
 
 void openfirmattach (int);
 
-dev_type_ioctl(openfirmioctl);
+static dev_type_open(openfirmopen);
+static dev_type_ioctl(openfirmioctl);
 
 const struct cdevsw openfirm_cdevsw = {
-       .d_open = nullopen,
+       .d_open = openfirmopen,
        .d_close = nullclose,
        .d_read = noread,
        .d_write = nowrite,
@@ -117,7 +118,18 @@
        return (error);
 }
 
-int
+static int
+openfirmopen(dev_t dev, int flag, int mode, struct lwp *l)
+{
+
+#ifdef __OPENFIRMIO_OPEN_CHECK_BROKEN
+       return __openfirmio_open_check_broken();
+#else
+       return 0;
+#endif
+}
+
+static int
 openfirmioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
 {
        struct ofiocdesc *of;



Home | Main Index | Thread Index | Old Index