From owner-freebsd-hackers Fri Mar 21 6:17:33 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 DDCAF37B401; Fri, 21 Mar 2003 06:17:31 -0800 (PST) Received: from resnet.uoregon.edu (resnet.uoregon.edu [128.223.122.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3F3E943F3F; Fri, 21 Mar 2003 06:17:31 -0800 (PST) (envelope-from gurney_j@resnet.uoregon.edu) Received: by resnet.uoregon.edu (Postfix, from userid 1001) id 007371930F; Fri, 21 Mar 2003 06:17:18 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by resnet.uoregon.edu (Postfix) with ESMTP id DFA0C1D112; Fri, 21 Mar 2003 21:17:18 +0700 (ICT) Date: Fri, 21 Mar 2003 21:17:18 +0700 (ICT) From: John-Mark Gurney To: dfr@freebsd.org, Subject: bug in subr_bus.c? Message-ID: <20030321204808.A65800-100000@resnet.uoregon.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Hello, It's been a while since I've been doing FreeBSD work, but I was recently working on a device driver for the Pinicle Micro DC10+ (Zoran chip) video en/decoder board and was making full use of the newbus system. I've been doing my devel work on 5.0-R (I'm in Thailand right now so I don't have my normal devel environment) and doing it all on KLD to help speed up devel. Right now the problem I have is on kldunload, devclass_delete_driver gets called and calls the detach routine for all associated devices. This is a slight problem since device_detach doesn't know anything about the children, and if you look at device_delete_child, it deletes all the children, and then calls detach. So, the driver can: a) delete it's own children, but if it gets removed via device_delete_child, this work is already down for you. b) let the bus code remove your children, but then if you're a kld, your children won't be removed and you will cause a panic in devinfo and other nasties since a device's parent won't exist anymore. I believe that devclass_delete_driver should do a device_delete_child instead of a simple detach, but then there is much code that is broken in that it assumes that it needs to delete it's own children. So, do we have the *_detach routine delete it's children or have the bus code do it? If you look at sys/dev/iicbus/iicbb.c, in the detach routine it delete's the iicbus child, but that would already be gone in the delete_child case, but not in the simple detach case. So, which is correct? I'll fix this, but I need direction on which way to go. I think that letting the bus code delete the children is better. Comments? btw, I will post some scripts to autoload kld debug symbols to my home page (http://people.freebsd.org/~jmg/) soon. John-Mark Gurney To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message