From owner-cvs-src@FreeBSD.ORG Mon Jun 19 14:12:38 2006 Return-Path: X-Original-To: cvs-src@freebsd.org Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1CBE816A4CB; Mon, 19 Jun 2006 14:12:38 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id E8A5E43D46; Mon, 19 Jun 2006 14:12:36 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k5JECVEM016579; Mon, 19 Jun 2006 10:12:35 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Ian Dowse Date: Mon, 19 Jun 2006 09:15:50 -0400 User-Agent: KMail/1.9.1 References: <200606170147.aa09815@nowhere.iedowse.com> In-Reply-To: <200606170147.aa09815@nowhere.iedowse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200606190915.50962.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [192.168.0.1]); Mon, 19 Jun 2006 10:12:35 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1549/Sat Jun 17 18:20:39 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx 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 X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jun 2006 14:12:38 -0000 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 =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org