Re: Loading uart module fails

From: John Baldwin <jhb_at_freebsd.org>
Date: Fri, 24 Feb 2012 12:22:36 -0500
On Thursday, February 23, 2012 9:41:16 am Alexey Dokuchaev wrote:
> On Thu, Feb 23, 2012 at 08:28:47AM -0500, John Baldwin wrote:
> > Hmm, can you see what 'dev->nameunit' is?  Maybe just do 'p *dev' actually
> > and reply with that.
> 
> (kgdb) p *dev
> $1 = {ops = 0xc50de000, link = {tqe_next = 0xc5271380, tqe_prev =
> 0xc5271184},
>   devlink = {tqe_next = 0xc5271380, tqe_prev = 0xc527118c},
>   parent = 0xc51fca80, children = {tqh_first = 0x0, tqh_last = 0xc5271318},
>   driver = 0x0, devclass = 0xc5270a40, unit = 0,
>   nameunit = 0xc5006a00 "uart0",
>   desc = 0xc5511205 <Address 0xc5511205 out of bounds>, busy = 0,
>   state = DS_NOTPRESENT, devflags = 0, flags = 35, order = 30,
>   ivars = 0xc5270d00, softc = 0x0, sysctl_ctx = {tqh_first = 0x0,
>     tqh_last = 0x0}, sysctl_tree = 0x0}

Try this for fixing the panic.  New-bus was not clearing the description
if a device's attach routine failed.

Index: subr_bus.c
===================================================================
--- subr_bus.c	(revision 231983)
+++ subr_bus.c	(working copy)
_at__at_ -1129,7 +1129,6 _at__at_ devclass_driver_deleted(devclass_t busclass, devcl
 			    dev->parent->devclass == busclass) {
 				if ((error = device_detach(dev)) != 0)
 					return (error);
-				(void)device_set_driver(dev, NULL);
 				BUS_PROBE_NOMATCH(dev->parent, dev);
 				devnomatch(dev);
 				dev->flags |= DF_DONENOMATCH;
_at__at_ -2097,7 +2097,7 _at__at_ device_probe_child(device_t dev, device_t child)
 	/* XXX What happens if we rebid and got no best? */
 	if (best) {
 		/*
-		 * If this device was atached, and we were asked to
+		 * If this device was attached, and we were asked to
 		 * rescan, and it is a different driver, then we have
 		 * to detach the old driver and reattach this new one.
 		 * Note, we don't have to check for DF_REBID here
_at__at_ -2604,6 +2606,7 _at__at_ device_set_driver(device_t dev, driver_t *driver)
 		free(dev->softc, M_BUS_SC);
 		dev->softc = NULL;
 	}
+	device_set_desc(dev, NULL);
 	kobj_delete((kobj_t) dev, NULL);
 	dev->driver = driver;
 	if (driver) {
_at__at_ -2789,7 +2792,6 _at__at_ device_detach(device_t dev)
 
 	dev->state = DS_NOTPRESENT;
 	(void)device_set_driver(dev, NULL);
-	device_set_desc(dev, NULL);
 	device_sysctl_fini(dev);
 
 	return (0);

-- 
John Baldwin
Received on Fri Feb 24 2012 - 16:54:39 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:24 UTC