From owner-freebsd-new-bus@FreeBSD.ORG Thu Jan 29 08:11:22 2004 Return-Path: Delivered-To: freebsd-new-bus@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2828A16A4CF; Thu, 29 Jan 2004 08:11:22 -0800 (PST) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id D7AAC43D31; Thu, 29 Jan 2004 08:11:20 -0800 (PST) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.10/8.12.9) with ESMTP id i0TGBAET045829; Thu, 29 Jan 2004 09:11:10 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 29 Jan 2004 09:11:09 -0700 (MST) Message-Id: <20040129.091109.27780542.imp@bsdimp.com> To: jhb@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <200401291050.40458.jhb@FreeBSD.org> References: <200401290635.i0T6ZO224579@jwlab.FEITH.COM> <200401291050.40458.jhb@FreeBSD.org> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: john@feith.com cc: new-bus@FreeBSD.org cc: mdodd@FreeBSD.org Subject: Re: nasty device_delete_child interaction X-BeenThere: freebsd-new-bus@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD's new-bus architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2004 16:11:22 -0000 In message: <200401291050.40458.jhb@FreeBSD.org> John Baldwin writes: : On Thursday 29 January 2004 01:35 am, John Wehle wrote: : > device_delete_child works by starting with the grandchildren : > working back towards the immediate child. Several drivers : > (i.e. if_xl.c, if_wx.c, iicbb.c) have code similar to: : > : > xxx_attach() : > { : > : > ... : > sc->child_dev = device_add_child ... : > } : > : > xxx_detach() : > { : > : > bus_generic_detach (); : > if (sc->child_dev) : > device_delete_child ... : > } Don't do that. You are duplicating the storage of children in two places. If you need to cache a copy of a child, that's fine. However, don't delete it explicitly in xxx_detach. I'd say that these drivers are wrong and should be fixed. : > It seems to me that any driver which calls device_delete_child : > as part of detaching must also implement something like: No. They should avoid the problem by using newbus correctly. This sort of solution just adds code to no good purpose. Warner