xref: /OK3568_Linux_fs/kernel/Documentation/driver-api/firmware/direct-fs-lookup.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun========================
2*4882a593SmuzhiyunDirect filesystem lookup
3*4882a593Smuzhiyun========================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunDirect filesystem lookup is the most common form of firmware lookup performed
6*4882a593Smuzhiyunby the kernel. The kernel looks for the firmware directly on the root
7*4882a593Smuzhiyunfilesystem in the paths documented in the section 'Firmware search paths'.
8*4882a593SmuzhiyunThe filesystem lookup is implemented in fw_get_filesystem_firmware(), it
9*4882a593Smuzhiyunuses common core kernel file loader facility kernel_read_file_from_path().
10*4882a593SmuzhiyunThe max path allowed is PATH_MAX -- currently this is 4096 characters.
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunIt is recommended you keep /lib/firmware paths on your root filesystem,
13*4882a593Smuzhiyunavoid having a separate partition for them in order to avoid possible
14*4882a593Smuzhiyunraces with lookups and avoid uses of the custom fallback mechanisms
15*4882a593Smuzhiyundocumented below.
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunFirmware and initramfs
18*4882a593Smuzhiyun----------------------
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunDrivers which are built-in to the kernel should have the firmware integrated
21*4882a593Smuzhiyunalso as part of the initramfs used to boot the kernel given that otherwise
22*4882a593Smuzhiyuna race is possible with loading the driver and the real rootfs not yet being
23*4882a593Smuzhiyunavailable. Stuffing the firmware into initramfs resolves this race issue,
24*4882a593Smuzhiyunhowever note that using initrd does not suffice to address the same race.
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunThere are circumstances that justify not wanting to include firmware into
27*4882a593Smuzhiyuninitramfs, such as dealing with large firmware files for the
28*4882a593Smuzhiyunremote-proc subsystem. For such cases using a userspace fallback mechanism
29*4882a593Smuzhiyunis currently the only viable solution as only userspace can know for sure
30*4882a593Smuzhiyunwhen the real rootfs is ready and mounted.
31