From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 21 15:57:18 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 5253D1065670 for ; Wed, 21 Jan 2009 15:57:18 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id EC0E58FC1D for ; Wed, 21 Jan 2009 15:57:17 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1LPfS8-000L34-Lj; Wed, 21 Jan 2009 17:57:16 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n0LFvDQF020642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Jan 2009 17:57:13 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n0LFvDjp045411; Wed, 21 Jan 2009 17:57:13 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n0LFvDv5045410; Wed, 21 Jan 2009 17:57:13 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 21 Jan 2009 17:57:13 +0200 From: Kostik Belousov To: Andriy Gapon Message-ID: <20090121155713.GP58517@deviant.kiev.zoral.com.ua> References: <49773938.5010000@icyb.net.ua> <20090121153908.GO58517@deviant.kiev.zoral.com.ua> <4977444E.8050306@icyb.net.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FbmEh7Ek6NM6xKh/" Content-Disposition: inline In-Reply-To: <4977444E.8050306@icyb.net.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1LPfS8-000L34-Lj 82b12179c113a912744efbcce1eac9ee X-Terabit: YES 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:57:18 -0000 --FbmEh7Ek6NM6xKh/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 21, 2009 at 05:50:38PM +0200, Andriy Gapon wrote: > 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 ? >=20 > 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. >=20 > > Yes, the usual strategy is to call destroy_dev from unload handler. > >=20 > >> Is it reasonable to refuse unload if cdev is in use (in MOD_QUIESCE)? > >> How to check for that best? > >=20 > > This cannot be checked race-free. >=20 > So no point in trying? I would say no. You could use count_dev(), but my own experience shown that ability to unload driver is more important then unadvertently knock out filedescriptor from under the running program. --FbmEh7Ek6NM6xKh/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkl3RdkACgkQC3+MBN1Mb4g3UACgnTrYA02QZeOjXrEJmrGnDCdE SEQAn1a85AOQLOH1HLVZ+ivEcpFxuPl2 =2Y5h -----END PGP SIGNATURE----- --FbmEh7Ek6NM6xKh/--