From owner-cvs-all@FreeBSD.ORG Tue Jun 13 00:50:50 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5518D16A418; Tue, 13 Jun 2006 00:50:50 +0000 (UTC) (envelope-from iedowse@iedowse.com) Received: from nowhere.iedowse.com (nowhere.iedowse.com [82.195.144.75]) by mx1.FreeBSD.org (Postfix) with SMTP id 0549A43D5C; Tue, 13 Jun 2006 00:50:48 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from localhost ([127.0.0.1] helo=iedowse.com) by nowhere.iedowse.com via local-iedowse id ; 13 Jun 2006 01:50:47 +0100 (IST) To: John Baldwin In-Reply-To: Your message of "Mon, 12 Jun 2006 16:31:06 EDT." <200606121631.07177.john@baldwin.cx> Date: Tue, 13 Jun 2006 01:50:43 +0100 From: Ian Dowse Message-ID: <200606130150.aa12882@nowhere.iedowse.com> Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org, Ian Dowse Subject: Re: cvs commit: src/sys/sys firmware.h src/sys/kern subr_firmware.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2006 00:50:50 -0000 In message <200606121631.07177.john@baldwin.cx>, John Baldwin writes: >On Saturday 10 June 2006 13:04, Ian Dowse wrote: >> Keep firmware images on the list until they have been unregistered >> with firmware_unregister(). Previously when the last driver reference >> had been dropped we would clear the list entry under the assumption >> that the firmware module was about to be unloaded, but this was not >> true if the firmware image had been loaded manually with kldload. > >I think you still need to clear the entire entry in unloadentry() and not just >clear fp->file. Otherwise, another thread could gain a reference on this >entry in the table after you drop the firmware mutex and before >firmware_unregister() is ran by the kernel linker. That would bring back the original issue where a manually kldloaded firmware image would be removed from the list when a driver calls firmware_put(), even though the kld will remain loaded; there is nothing that a driver can do to get the entry back on the list since calling linker_reference_module() will not result in a call to firmware_register() because the module is already (manually) loaded. Shouldn't this race be fixed by your other suggested change of having a firmware_unregister() failure preventing the image module from unloading? (I didn't realise it wasn't already checking) The firmware_unregister() function atomically checks for references and clears the full entry, so with your change there is no way for the module to be unloaded while a reference exists. Ian