Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jun 2006 09:15:50 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Ian Dowse <iedowse@iedowse.com>
Cc:        cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/sys firmware.h src/sys/kern subr_firmware.c
Message-ID:  <200606190915.50962.jhb@freebsd.org>
In-Reply-To: <200606170147.aa09815@nowhere.iedowse.com>
References:  <200606170147.aa09815@nowhere.iedowse.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 16 June 2006 20:47, Ian Dowse wrote:
> In message <200606161457.23420.jhb@freebsd.org>, John Baldwin writes:
> >But unloadentry() would never unload such a module because fp->file
> >is NULL.  unloadentry() would only call clearentry() and then=20
> >linker_file_unload() on an explicitly loaded firmware module.
>=20
>  - driver calls firmware_get, firmware image loaded and fp->file set to n=
on-NULL
>  - manually kldload some_module_that_depends_on_firmware_image
>  - driver calls firmware_put, unloadentry called and sets fp->file =3D NU=
LL
>=20
> If at this point the entry was cleared then all future calls to
> firmware_get would fail even though the module is still available,
> referenced and loaded.
>=20
> I'm not saying that these cases are particularly important or that
> there aren't bugs in the current code; just that mixing up the
> layers doesn't help ;-)

In practice no modules depend on firmware modules. :)  I think we should
take the approach of not clearing fp->file in unloadentry() however.
That would result in correct behavior in every case I can think of (or as
close to correct as you can get).  In the above case the
linker_file_unload() would have fail leaving the firmware module around.
If you later kldunload'ed the other module, the firmware module would still
be around and if a driver did another firmware_get/put sequence then the
module would finally be unloaded on the second firmware_put().

However, that case will be much more rare than the current standalone
firmware modules which can get into a funk where they can never be
unloaded since the firmware(9) code would have leaked a reference
(since it cleared fp->file just assuming that linker_file_unload() will
work, but it might fail) and the user can't use kldunload to unload it
even though the firmware isn't in use.

=2D-=20
John Baldwin <jhb@FreeBSD.org> =A0<>< =A0http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org



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