Date: Tue, 8 Nov 2011 10:00:27 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: Navdeep Parhar <nparhar@gmail.com> Subject: Re: incorrect parent refcounting in subr_firmware.c? Message-ID: <201111081000.27332.jhb@freebsd.org> In-Reply-To: <CAPFoGT9bLzAStkUnSfsBm0F6gmGuCM6kQRHQxa%2Bbsah4mQvQVw@mail.gmail.com> References: <CAPFoGT9bLzAStkUnSfsBm0F6gmGuCM6kQRHQxa%2Bbsah4mQvQVw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, November 02, 2011 3:56:29 pm Navdeep Parhar wrote:
> I built a KLD with multiple firmware images, as shown here:
>
> KMOD=foo
> FIRMWS= foo.bin:foo:1.0.0.0
> FIRMWS+=bar.bin:bar:1.0.0.0
> FIRMWS+= ...
> .include <bsd.kmod.mk>
>
> "foo" is the parent firmware and a firmware_get(foo) can autoload the
> KLD. "bar" and the rest are available only if the KLD is loaded (by
> whatever means). This is reasonable and works as expected. But if I
> just get and then put "foo" back, the KLD is not unloaded automatically.
>
> The problem is that a reference is placed on the parent firmware when
> the other firmwares are registered (during module load). I think this
> reference should be placed during firmware_get on the child.
>
> What do people think about the attached patch? It fixes things for me.
Hmm, what about the use case where a driver does:
f = firmware_get("foo");
firmware_put(f)
f = firmware_get("bar");
firmware_put(f)
Is that going to trigger multiple loads/unloads with this change?
--
John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111081000.27332.jhb>
