From owner-freebsd-hackers@FreeBSD.ORG Mon May 23 14:32:22 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1A711065670 for ; Mon, 23 May 2011 14:32:22 +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 A980B8FC0A for ; Mon, 23 May 2011 14:32:22 +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 50F8046CDC; Mon, 23 May 2011 10:32:22 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id DF1DB8A051; Mon, 23 May 2011 10:32:21 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org, philip-freebsd1@soeberg.net Date: Mon, 23 May 2011 10:32:19 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <4DDA6B95.3090704@soeberg.net> In-Reply-To: <4DDA6B95.3090704@soeberg.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201105231032.20084.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 23 May 2011 10:32:22 -0400 (EDT) Cc: jfv@gmail.com Subject: Re: device_detach() on a device used by ixgbe driver (FreeBSD 7-STABLE through to 9-CURRENT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2011 14:32:22 -0000 On Monday, May 23, 2011 10:13:41 am Philip Soeberg wrote: > Hi fellow FreeBSD hackers, > > I've just completed designing a new driver for the Intels IXGBE suite of > network adapters, but is building my driver as a kernel module to be > loaded after system boot. > > The current sys/dev/ixgbe/ixgbe.c driver which attach to Intels adapters > return a zero in it's probe() function (which equals to > BUS_PROBE_SPECIFIC).. This has the distinct disadvantage that I cannot, > through my module, call a device_detach() on the devices I support, and > afterward expect being probed for them. A BUS_PROBE_SPECIFIC, according > to wording in sys/sys/bus.h, inform the OS that "Only I can use this > device". > > I assume this (transcanding from FreeBSD 7.0-STABLE through to FreeBSD > 9-CURRENT) is in error? I would expect sys/dev/ixgbe/ixgbe.c's probe() > function to return BUS_PROBE_DEFAULT, which is the "Base OS default > driver".. Yes, that is true. > If this is true, then we should probably also update > sys/kern/device_if.m's description of the probe() method as to reflect > the BUS_PROBE_* return values in a clearer way than is currently described. > Do you want me to provide a patch? (it's really a one liner for ixgbe.c > and a couple of alterations to the device_if.m, if need be) device_if.m was probably just never updated from when BUS_PROBE_* were added. Updating it would be a good thing. > I would also expect the ixgbe.c driver to do a quick resource_disabled() > in it's attach() function, so that we can disable specific adapters > through kenv hint.ix.0.disabled=1.. That is not universally supported (i.e. it's not a part of new-bus specifically). For buses that support hinted devices, they do all generally support being able to disable a hinted device, but disabling bus-enumerated devices is not generally supported. > Given that I can't use device_detach() on a device hogged by the IXGBE > driver, can any one of you help me with a way around this problem? I > can't use the hints, and I can't detach() the device.. how can I get my > kernel module to attach the device? I think ixgbe has to be fixed to use BUS_PROBE_DEFAULT. Very few drivers should use '0' for their probe return value. -- John Baldwin