From owner-freebsd-current@FreeBSD.ORG Wed Apr 6 12:48:41 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D1B5106568B; Wed, 6 Apr 2011 12:48:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 75CF68FC16; Wed, 6 Apr 2011 12:48:41 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 2994646B38; Wed, 6 Apr 2011 08:48:41 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B2A7B8A027; Wed, 6 Apr 2011 08:48:40 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Wed, 6 Apr 2011 08:48:39 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201104051321.56319.hselasky@freebsd.org> <4D9B473F.8020607@FreeBSD.org> <201104060933.47350.hselasky@freebsd.org> In-Reply-To: <201104060933.47350.hselasky@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201104060848.40278.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 06 Apr 2011 08:48:40 -0400 (EDT) Cc: Andriy Gapon , Hans Petter Selasky , freebsd-usb@freebsd.org Subject: Re: use_generic and usb probing X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2011 12:48:41 -0000 On Wednesday, April 06, 2011 3:33:47 am Hans Petter Selasky wrote: > On Tuesday 05 April 2011 18:45:51 Andriy Gapon wrote: > > on 05/04/2011 15:55 Hans Petter Selasky said the following: > > > On Tuesday 05 April 2011 14:50:43 Andriy Gapon wrote: > > >> I believe that newbus already supports ordering of children on a bus. > > >> > > >> BTW, does USB have to pass anything from probe to attach? > > > > > > Mostly only the driver info field. To avoid duplicate lookups. > > > > > >> Duplicate lookup is of course not very nice, but duplicate probing pass > > >> is not nice either. > > > > > > This can all be avoided if the bus-drivers are sorted correctly before > > > probing! > > Hi, > > > > > Well, I think that that's what probe priorities actually for. > > I also think that typically ivars should be set by a bus driver. So maybe > > it's not such a good idea to pass data from probe to attach via ivars in > > child drivers. But I could be mistaken about that. > > > > The same device_t is used to do all the probes! > > > Practically speaking, you most likely don't have to worry about that for > > drivers that return BUS_PROBE_SPECIFIC (=0) from their probe methods. And > > there is only a few "generic" drivers that can be handled on a case by > > case basis. > > There are more drivers that needs patching! Please scan all of the kernel > files for usbdi.h and the use_generic flag. > > After looking at subr_usb.c I see your solution is fine as long as the PROBE() > method that it attaches is the last one called before ATTACH(). If this is > documented in how newbus should function, then please go ahead updating your > patch to cover all USB drivers using use_generic. Yes. The device_probe() routine is called for the "best" matching driver (based on the return values from device_probe()) before device_attach() is called. Check device_probe_child() for the gory details including: if (pri < 0) { /* * A bit bogus. Call the probe method again to make * sure that we have the right description. */ DEVICE_PROBE(child); #if 0 child->flags |= DF_REBID; #endif } else child->flags &= ~DF_REBID; child->state = DS_ALIVE; -- John Baldwin