Re: [PATCH 1/1] firmware_loader: Move module refcounts to allow unloading
From: Russ Weight
Date: Thu Oct 24 2024 - 10:58:57 EST
On Thu, Oct 24, 2024 at 04:35:20AM -0500, Kalra, Ashish wrote:
>
>
> On 10/23/2024 3:16 PM, Russ Weight wrote:
> >
> > On Tue, Oct 15, 2024 at 08:14:24PM +0000, Dionna Glaze wrote:
> >> If a kernel module registers a firmware upload API ops set, then it's
> >> unable to be moved due to effectively a cyclic reference that the module
> >> depends on the upload which depends on the module.
> >>
> >> Instead, only require the try_module_get when an upload is requested to
> >> disallow unloading a module only while the upload is in progress.
> >
> > Generally, the parent driver that registers for firmware_upload would
> > want the module to be present until it unregisters.
> >
> > Is there a case where this change is needed?
>
> We are using the firmware_upload_register() API interface for SEV firmware loader/update
> with the AMD Crypto CCP driver.
>
> Now, when we call firmware_upload_register() it does a module_get() and bumps the module refcnt and
> then we do the firmware_upload_unregister() as part of the CCP module's exit() callback, but the
> CCP module's exit() callback is never invoked as it's refcnt is non-zero, so it is like a catch 22
> situation, we want the module's exit() callback to be invoked to call firmware_upload_unregister()
> to do a module_put() and decrement module's refcnt, but the callback is never invoked as it's
> refcnt is non-zero.
That makes sense. Thanks for the explanation.
>
> Isn't the firmware_upload_register() API interface intended to be used by standalone drivers ?
Yes, it is.
Thanks,
- Russ