Re: Can not boot 7.0-BETA3 with puc

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Frank Behrens
Date: Friday, November 23, 2007 - 7:57 am

Hi, dear FreeBSD developers!

Frank Behrens <frank@pinky.sax.de> wrote on 23 Nov 2007 11:20:

Meanwhile I was able to restore the previous behavior. My RELENG_7 kernel boots with right 
sio port assignments. :-))

IMHO the reason for the error in 7.0 is, that it calls device_add_child(dev, NULL, -1);
The unit is not determined, so the bus subsystem assigns the 1st sio unit. That is 0 and 
wrong in my case. The patch uses some code from RELENG_6 to determine the 1st free sio 
unit. I know this is a hack, but you should see, where the problem is to be searched.

Regards,
    Frank

===================================================================
RCS file: /data/freebsd/src/sys/dev/puc/puc.c,v
retrieving revision 1.50
diff -u -w -p -r1.50 puc.c
--- puc.c	6 Jun 2007 22:17:01 -0000	1.50
+++ puc.c	23 Nov 2007 14:17:29 -0000
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD: src/sys/dev/puc/puc.
 #include <dev/puc/puc_bfe.h>
 
 #define	PUC_ISRCCNT	5
+#define PUC_DEBUG	1
 
 struct puc_port {
 	struct puc_bar	*p_bar;
@@ -70,6 +71,31 @@ const char puc_driver_name[] = "puc";
 
 MALLOC_DEFINE(M_PUC, "PUC", "PUC driver");
 
+
+static int
+puc_find_free_unit(device_t dev, char *name)
+{
+        devclass_t dc;
+        int start;
+        int unit;
+
+        unit = 0;
+        start = 0;
+        while (resource_int_value(name, unit, "port", &start) == 0 &&
+            start > 0)
+                unit++;
+        dc = devclass_find(name);
+        if (dc == NULL)
+                return (-1);
+        while (devclass_get_device(dc, unit))
+                unit++;
+#if PUC_DEBUG
+        device_printf(dev, "Using %s%d\n", name, unit);
+#endif
+        return (unit);
+}
+
+
 struct puc_bar *
 puc_get_bar(struct puc_softc *sc, int rid)
 {
@@ -201,6 +227,13 @@ puc_bfe_attach(device_t dev)
 	bus_space_handle_t bsh;
 	bus_space_tag_t bst;
 	int error, idx;
+#if PUC_DEBUG
+	int oldverbose = bootverbose;
+        bootverbose = 1;
+
+        device_printf(dev, "puc_bfe_attach\n");
+#endif
+
 
 	sc = device_get_softc(dev);
 
@@ -296,9 +329,16 @@ puc_bfe_attach(device_t dev)
 			goto fail;
 		port->p_rclk = res;
 
-		port->p_dev = device_add_child(dev, NULL, -1);
+		port->p_dev = device_add_child(dev, "sio", puc_find_free_unit(dev, "sio"));
 		if (port->p_dev != NULL)
 			device_set_ivars(port->p_dev, (void *)port);
+#if PUC_DEBUG
+                device_printf(dev, "child attached: nr %d, start %x, offset %x, dev %s\n",
+                    port->p_nr,
+                    start,
+                    ofs,
+		    device_get_nameunit(port->p_dev));
+#endif
 	}
 
 	error = puc_config(sc, PUC_CFG_GET_ILR, 0, &res);
@@ -352,6 +392,10 @@ puc_bfe_attach(device_t dev)
 	if (sc->sc_serdevs == 0UL)
 		bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
 
+#if PUC_DEBUG
+        bootverbose = oldverbose;
+#endif
+
 	return (0);
 
 fail:
@@ -377,6 +421,9 @@ fail:
 	rman_fini(&sc->sc_ioport);
 	free(__DECONST(void *, sc->sc_ioport.rm_descr), M_PUC);
 	free(sc->sc_port, M_PUC);
+#if PUC_DEBUG
+        bootverbose = oldverbose;
+#endif
 	return (error);
 }
 
-- 
Frank Behrens, Osterwieck, Germany
PGP-key 0x5B7C47ED on public servers available.

_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Can not boot 7.0-BETA3 with IPSEC, Frank Behrens, (Thu Nov 22, 1:46 am)
Re: Can not boot 7.0-BETA3 with IPSEC, Bjoern A. Zeeb, (Thu Nov 22, 6:47 am)
Re: Can not boot 7.0-BETA3 with IPSEC, Frank Behrens, (Thu Nov 22, 8:31 am)
Re: Can not boot 7.0-BETA3 with puc, Frank Behrens, (Fri Nov 23, 7:57 am)
Re: Can not boot 7.0-BETA3 with puc, Marcel Moolenaar, (Sat Nov 24, 11:20 am)
Re: Can not boot 7.0-BETA3 with puc, Frank Behrens, (Sun Nov 25, 5:46 am)
Re: Can not boot 7.0-BETA3 with puc, Marcel Moolenaar, (Sun Nov 25, 2:56 pm)
Re: Can not boot 7.0-BETA3 with puc, Frank Behrens, (Mon Nov 26, 7:27 am)
Re: Can not boot 7.0-BETA3 with puc, Marcel Moolenaar, (Mon Nov 26, 10:59 am)