Page MenuHomeFreeBSD

LinuxKPI: firmware, implement deferred loading for "nowait"
ClosedPublic

Authored by bz on Jun 20 2021, 2:06 PM.

Details

Summary

Change linuxkpi_request_firmware_nowait() to deferred firmware loading
scheduling a task. This changes behaviour in some cases that we
return from loading the driver before the driver is finished
initialising if the driver does not deal with it (wait).
This brings the behaviour one would expect from when this function is
called and I implemented it to see if it would help a specific case.

Sponsored by: The FreeBSD Foundation
MFC after: 12 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bz requested review of this revision.Jun 20 2021, 2:06 PM

Looks good to my eye... it's super close to how I'd write it...

This revision is now accepted and ready to land.Jun 20 2021, 2:14 PM
hselasky added inline comments.
sys/compat/linuxkpi/common/src/linux_firmware.c
151

I suggest setting the "fw" to NULL here, because you pass this pointer on failure to the callback function.

163

Maybe print an error in dmesg on error. Makes it easier to locate missing firmware files.

164

Call lfwt->cont unconditionally?

bz marked 2 inline comments as done.Jun 20 2021, 2:59 PM
bz added inline comments.
sys/compat/linuxkpi/common/src/linux_firmware.c
151

That's only an issue in case we do the call unconditionally below; otherwise it should always be initialised or we don't call "cont".

163

_linuxkpi_request_firmware dos that for you.

164

Do we need to? We didn't do before but probably given there is no other error propagation, the only alternate for a driver to know would be to "timeout"?

bz marked 2 inline comments as done.

Make sure *fw is initialised in all cases.
Unconditionally call the callback function as it is the only feedback path
to the requester.

This revision now requires review to proceed.Jun 20 2021, 3:04 PM
bz marked an inline comment as done.Jun 20 2021, 3:04 PM

You may want to wait for pending tasks at linuxkpi module unload, if the driver doesn't do that.

--HPS

This revision is now accepted and ready to land.Jun 20 2021, 3:31 PM