Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Feb 2012 12:22:36 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Alexey Dokuchaev <danfe@freebsd.org>
Cc:        Bruce Cran <bruce@cran.org.uk>, freebsd-current@freebsd.org, Warner Losh <imp@freebsd.org>
Subject:   Re: Loading uart module fails
Message-ID:  <201202241222.37037.jhb@freebsd.org>
In-Reply-To: <20120223144116.GA99564@FreeBSD.org>
References:  <20110109140215.000011b8@unknown> <201202230828.48022.jhb@freebsd.org> <20120223144116.GA99564@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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)
@@ -1129,7 +1129,6 @@ 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;
@@ -2097,7 +2097,7 @@ 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
@@ -2604,6 +2606,7 @@ 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) {
@@ -2789,7 +2792,6 @@ 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202241222.37037.jhb>