From owner-freebsd-bugs@FreeBSD.ORG  Mon Dec 31 21:00:03 2007
Return-Path: <owner-freebsd-bugs@FreeBSD.ORG>
Delivered-To: freebsd-bugs@hub.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 192D816A418
	for <freebsd-bugs@hub.freebsd.org>;
	Mon, 31 Dec 2007 21:00:03 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org
	[IPv6:2001:4f8:fff6::28])
	by mx1.freebsd.org (Postfix) with ESMTP id E67F713C46E
	for <freebsd-bugs@hub.freebsd.org>;
	Mon, 31 Dec 2007 21:00:02 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id lBVL023p036982
	for <freebsd-bugs@freefall.freebsd.org>; Mon, 31 Dec 2007 21:00:02 GMT
	(envelope-from gnats@freefall.freebsd.org)
Received: (from gnats@localhost)
	by freefall.freebsd.org (8.14.2/8.14.1/Submit) id lBVL02F1036981;
	Mon, 31 Dec 2007 21:00:02 GMT (envelope-from gnats)
Resent-Date: Mon, 31 Dec 2007 21:00:02 GMT
Resent-Message-Id: <200712312100.lBVL02F1036981@freefall.freebsd.org>
Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer)
Resent-To: freebsd-bugs@FreeBSD.org
Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org,
	Peter Jeremy <peterjeremy@optushome.com.au>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A16E516A417
	for <FreeBSD-gnats-submit@freebsd.org>;
	Mon, 31 Dec 2007 20:55:58 +0000 (UTC)
	(envelope-from peterjeremy@optushome.com.au)
Received: from turion.vk2pj.dyndns.org
	(c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82])
	by mx1.freebsd.org (Postfix) with ESMTP id E87AD13C467
	for <FreeBSD-gnats-submit@freebsd.org>;
	Mon, 31 Dec 2007 20:55:56 +0000 (UTC)
	(envelope-from peterjeremy@optushome.com.au)
Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])
	by turion.vk2pj.dyndns.org (8.14.2/8.14.2) with ESMTP id lBVKtuxo003756;
	Tue, 1 Jan 2008 07:55:56 +1100 (EST)
	(envelope-from peter@turion.vk2pj.dyndns.org)
Received: (from peter@localhost)
	by turion.vk2pj.dyndns.org (8.14.2/8.14.2/Submit) id lBVKtuKf003755;
	Tue, 1 Jan 2008 07:55:56 +1100 (EST) (envelope-from peter)
Message-Id: <200712312055.lBVKtuKf003755@turion.vk2pj.dyndns.org>
Date: Tue, 1 Jan 2008 07:55:56 +1100 (EST)
From: Peter Jeremy <peterjeremy@optushome.com.au>
To: FreeBSD-gnats-submit@FreeBSD.org
X-Send-Pr-Version: 3.113
Cc: 
Subject: kern/119202: [patch] Add generic support for disabling devices
X-BeenThere: freebsd-bugs@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: Peter Jeremy <peterjeremy@optushome.com.au>
List-Id: Bug reports <freebsd-bugs.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs>
List-Post: <mailto:freebsd-bugs@freebsd.org>
List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 31 Dec 2007 21:00:03 -0000


>Number:         119202
>Category:       kern
>Synopsis:       [patch] Add generic support for disabling devices
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 31 21:00:02 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Peter Jeremy
>Release:        FreeBSD 6.3-PRERELEASE amd64
>Organization:
n/a
>Environment:
System: FreeBSD turion.vk2pj.dyndns.org 6.3-PRERELEASE FreeBSD 6.3-PRERELEASE #31: Wed Dec 26 09:23:54 EST 2007 root@turion.vk2pj.dyndns.org:/usr/obj/usr/src/sys/turion amd64

>Description:
	FreeBSD supports a device.unit.disabled boot variable but this
	is only supported for some devices.  By adding the test into
	the generic device probing code, it is possible to disable any
	device.

>How-To-Repeat:
	Code inspection.
>Fix:
Index: sys/kern/subr_bus.c
===================================================================
RCS file: /usr/ncvs/src/sys/kern/subr_bus.c,v
retrieving revision 1.184.2.6
diff -u -r1.184.2.6 subr_bus.c
--- sys/kern/subr_bus.c	5 Nov 2007 11:49:44 -0000	1.184.2.6
+++ sys/kern/subr_bus.c	25 Dec 2007 20:41:41 -0000
@@ -1722,7 +1722,10 @@
 			resource_int_value(dl->driver->name, child->unit,
 			    "flags", &child->devflags);
 
-			result = DEVICE_PROBE(child);
+			if (resource_disabled(dl->driver->name, child->unit))
+				result = ENXIO;
+			else
+				result = DEVICE_PROBE(child);
 
 			/* Reset flags and devclass before the next probe. */
 			child->devflags = 0;
@@ -1805,7 +1808,8 @@
 			 * A bit bogus. Call the probe method again to make
 			 * sure that we have the right description.
 			 */
-			DEVICE_PROBE(child);
+			if (!resource_disabled(best->driver->name, child->unit))
+				DEVICE_PROBE(child);
 #if 0
 			child->flags |= DF_REBID;
 #endif
>Release-Note:
>Audit-Trail:
>Unformatted: