Page MenuHomeFreeBSD

firmware: Allow binary files to be loaded by /boot/loader
ClosedPublic

Authored by imp on Jan 20 2024, 5:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 21, 6:44 AM
Unknown Object (File)
Oct 21 2024, 9:35 AM
Unknown Object (File)
Oct 21 2024, 9:35 AM
Unknown Object (File)
Oct 21 2024, 9:35 AM
Unknown Object (File)
Oct 21 2024, 9:35 AM
Unknown Object (File)
Oct 21 2024, 9:35 AM
Unknown Object (File)
Oct 16 2024, 4:28 PM
Unknown Object (File)
Sep 24 2024, 4:16 PM

Details

Summary

Files loaded "-t firmware" (or module_type="firmware"). They are
registered with the firmware system using the full path to allow
the drivers to find them. There's only one firmware per file, and it is the
entire file.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 55596
Build 52485: arc lint + arc unit

Event Timeline

imp requested review of this revision.Jan 20 2024, 5:18 AM
imp created this revision.
This revision is now accepted and ready to land.Jan 20 2024, 7:07 AM

That's awesome, would it be hard to also have this for kldload ?

Minor typo.

sys/kern/subr_firmware.c
459
In D43522#992310, @manu wrote:

That's awesome, would it be hard to also have this for kldload ?

Unsure. I'll have to poke a bit. I had the same thought but wanted to get this in to see how hard it was and how well it worked.

Ideally, though, the driver would just do firmware_get like it does today and we'd load it in from some path automatically. Maybe with some mapping file, but likely not. Likely with a sane path like we have for .ko.

I also still prefer double spaces after periods in monospace text (code comments).

sys/kern/subr_firmware.c
487
499–503

I like your approach from your kldxref patch here better as it avoids the magic number of 4 all over. That is:

char *t;
....
t = strrchr(name, '.');
if (t != NULL && strcmp(t, ".bin") == 0)
    *t = '\0';
sys/kern/subr_firmware.c
499–503

Yea, I'll cut all that out.

505

We panic early in startup, here I think.... Kinda makes sense though...
Also, we need some kind of flag that says we can't free this firmware (right? since it's pre-loaded)

Change around a little how we're loading. Save the full filename and allow
subpath searches to succeed.

This revision now requires review to proceed.Jan 24 2024, 7:19 PM
imp marked 3 inline comments as done.Jan 24 2024, 7:27 PM

I think I've addressed everything (with a forthcoming typo fix)

sys/kern/subr_firmware.c
487

I think the new code doesn't need this blank like the old code did.

499–503

Just deleted this code entirely, so OBE.

imp marked an inline comment as done.

tpyo fix

sys/kern/subr_firmware.c
466

I think I'm going to change this to 'native' since 'native format' is defined by the creating application (in this case the hardware the firmware is for).

imp retitled this revision from firmware: Allow raw files to be loaded by /boot/loader to firmware: Allow native files to be loaded by /boot/loader.Jan 26 2024, 4:46 AM

Use 'native' instead of 'raw' to describe.

imp retitled this revision from firmware: Allow native files to be loaded by /boot/loader to firmware: Allow binary files to be loaded by /boot/loader.Feb 5 2024, 3:36 AM
imp edited the summary of this revision. (Show Details)

Shift to binary, update per review comments

If you do need the relative name lookups with some path components, then this is ok as-is to me.

sys/kern/subr_firmware.c
154

Do you want to fix this when registering the file instead? That is, only register the last component of the filename down in firmware_binary_files() instead? Oh, or are there requests that actually use partial paths? If so, I guess you have to do it this way.

This revision is now accepted and ready to land.Feb 7 2024, 11:15 PM
sys/kern/subr_firmware.c
154

There are requests with partial paths, though they often do other lookups w/o the path. I think the safest way is to match like this, but if it causes grief later, we can shift. I'm not sure that doing it at load time would suffice...

For example, rtw88 looks up rtw88/rtw8821c_fw.bin and then rtw8821c_fw.bin and then rtw88_rtw8821c_fw.bin and a few others.

sys/kern/subr_firmware.c
154

Also if i load /boot/precious/onering-fw.bin then i want that to work regardless of load path...