From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 21 15:50:44 2009 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 14AD0106566C for ; Wed, 21 Jan 2009 15:50:44 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 430568FC17 for ; Wed, 21 Jan 2009 15:50:42 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id RAA10940; Wed, 21 Jan 2009 17:50:39 +0200 (EET) (envelope-from avg@icyb.net.ua) Message-ID: <4977444E.8050306@icyb.net.ua> Date: Wed, 21 Jan 2009 17:50:38 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.18 (X11/20081124) MIME-Version: 1.0 To: Kostik Belousov References: <49773938.5010000@icyb.net.ua> <20090121153908.GO58517@deviant.kiev.zoral.com.ua> In-Reply-To: <20090121153908.GO58517@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: MOD_UNLOAD and driver with cdev 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: Wed, 21 Jan 2009 15:50:45 -0000 on 21/01/2009 17:39 Kostik Belousov said the following: > On Wed, Jan 21, 2009 at 05:03:20PM +0200, Andriy Gapon wrote: >> Do I need to code for MOD_UNLOAD for driver module that also creates a cdev? >> I see in the current code that one strategy is to simply call >> destroy_dev(). I guess detach routines are called automatically and >> destroy_dev can be done there as well.. > What are the detach routines ? Do you mean newbus device detach ? Yes, device_detach. This seems to work and make_device_driver.sh also suggests it this way. But I am not sure about possible races. > Yes, the usual strategy is to call destroy_dev from unload handler. > >> Is it reasonable to refuse unload if cdev is in use (in MOD_QUIESCE)? >> How to check for that best? > > This cannot be checked race-free. So no point in trying? -- Andriy Gapon