From owner-freebsd-arch@FreeBSD.ORG Wed Jul 21 11:37:51 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA43F16A4CF; Wed, 21 Jul 2004 11:37:51 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 098CD43D48; Wed, 21 Jul 2004 11:37:51 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.11/8.12.11) with ESMTP id i6LBbok9082179; Wed, 21 Jul 2004 13:37:50 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Doug Rabson From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 21 Jul 2004 12:20:54 BST." <1090408854.7114.8.camel@builder02.qubesoft.com> Date: Wed, 21 Jul 2004 13:37:50 +0200 Message-ID: <82178.1090409870@critter.freebsd.dk> Sender: phk@critter.freebsd.dk cc: arch@freebsd.org cc: freebsd-arch@freebsd.org Subject: Re: kldunload DIAGNOSTIC idea... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2004 11:37:51 -0000 In message <1090408854.7114.8.camel@builder02.qubesoft.com>, Doug Rabson writes : >> There are three parts to it, a refcount on cdevsw which tells us if >> any thread is inside the driver using that route, a refcount on the >> individual cdev and a linkage between the two. > >The device_busy() counter is still simplest (as long as there is a >device_t at all). The implementation of devclass_delete_driver() will >automatically veto the unload (when its called from >driver_module_handler()). The problem is that I cannot find the device_t without dereferencing the struct cdev (either for si_driver[12] or the dev_t) and by then it is too late. There is no way we can avoid refcounting on the cdev. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.