Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2009 17:57:13 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: MOD_UNLOAD and driver with cdev
Message-ID:  <20090121155713.GP58517@deviant.kiev.zoral.com.ua>
In-Reply-To: <4977444E.8050306@icyb.net.ua>
References:  <49773938.5010000@icyb.net.ua> <20090121153908.GO58517@deviant.kiev.zoral.com.ua> <4977444E.8050306@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--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/--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090121155713.GP58517>