From owner-freebsd-hackers Mon Mar 24 18: 4:52 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF71737B401; Mon, 24 Mar 2003 18:04:47 -0800 (PST) Received: from resnet.uoregon.edu (resnet.uoregon.edu [128.223.122.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4207443F3F; Mon, 24 Mar 2003 18:04:47 -0800 (PST) (envelope-from gurney_j@resnet.uoregon.edu) Received: by resnet.uoregon.edu (Postfix, from userid 1001) id 4E5641930E; Mon, 24 Mar 2003 18:04:34 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by resnet.uoregon.edu (Postfix) with ESMTP id 2AA821D112; Tue, 25 Mar 2003 09:04:34 +0700 (ICT) Date: Tue, 25 Mar 2003 09:04:34 +0700 (ICT) From: John-Mark Gurney To: "M. Warner Losh" Cc: mdodd@FreeBSD.ORG, , Subject: Re: bug in subr_bus.c? In-Reply-To: <20030323.092305.83978540.imp@bsdimp.com> Message-ID: <20030325085519.I97066-100000@resnet.uoregon.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-19.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 23 Mar 2003, M. Warner Losh wrote: > In message: <20030323174445.K36261-100000@resnet.uoregon.edu> > John-Mark Gurney writes: > : The bus code could use some locking in it... like you can't delete_child > : from child_detache... and/or better docs on how to handle children... I'm > : not even sure how I was doing things wrong, but I think it might of been > : problems with my code not calling bus_generic_detach before calling > : device_child_delete... > > I'm doing the locking, but you can do a bus_delete_child in a child's > detach routine. Cardbus does this right now and it works when you > unload the cardbus bridge... (btw, I'm using 1.117.2.1 as reference 5.0-R) I'm talking about child_detached (I forgot the d), not detach... so, say you have a bus driver that has a child_detached routine. When you unload the kld for the child, the kld will do a detach of the child. If you look at the device_detach, it will call the device's detach, then the parent's child_detached routine all before marking the device as NOTPRESENT. If you try to do a device_delete_child in the child_detached routine, device_delete_child will call device_detach again, and since the state is still ATTACHED, it will go through the detach procedure again, and either end up with a memory fault or a recursive loop. I just looked briefly at the cardbus code, and you don't have a child_detached routine. John-Mark To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message