150f86aedSGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 206bfd3c8SLuis R. Rodriguezmenu "Firmware loader" 306bfd3c8SLuis R. Rodriguez 406bfd3c8SLuis R. Rodriguezconfig FW_LOADER 506bfd3c8SLuis R. Rodriguez tristate "Firmware loading facility" if EXPERT 606bfd3c8SLuis R. Rodriguez default y 706bfd3c8SLuis R. Rodriguez help 806bfd3c8SLuis R. Rodriguez This enables the firmware loading facility in the kernel. The kernel 906bfd3c8SLuis R. Rodriguez will first look for built-in firmware, if it has any. Next, it will 1006bfd3c8SLuis R. Rodriguez look for the requested firmware in a series of filesystem paths: 1106bfd3c8SLuis R. Rodriguez 1206bfd3c8SLuis R. Rodriguez o firmware_class path module parameter or kernel boot param 1306bfd3c8SLuis R. Rodriguez o /lib/firmware/updates/UTS_RELEASE 1406bfd3c8SLuis R. Rodriguez o /lib/firmware/updates 1506bfd3c8SLuis R. Rodriguez o /lib/firmware/UTS_RELEASE 1606bfd3c8SLuis R. Rodriguez o /lib/firmware 1706bfd3c8SLuis R. Rodriguez 1806bfd3c8SLuis R. Rodriguez Enabling this feature only increases your kernel image by about 1906bfd3c8SLuis R. Rodriguez 828 bytes, enable this option unless you are certain you don't 2006bfd3c8SLuis R. Rodriguez need firmware. 2106bfd3c8SLuis R. Rodriguez 2206bfd3c8SLuis R. Rodriguez You typically want this built-in (=y) but you can also enable this 2306bfd3c8SLuis R. Rodriguez as a module, in which case the firmware_class module will be built. 2406bfd3c8SLuis R. Rodriguez You also want to be sure to enable this built-in if you are going to 2506bfd3c8SLuis R. Rodriguez enable built-in firmware (CONFIG_EXTRA_FIRMWARE). 2606bfd3c8SLuis R. Rodriguez 2706bfd3c8SLuis R. Rodriguezif FW_LOADER 2806bfd3c8SLuis R. Rodriguez 2982fd7a81STakashi Iwaiconfig FW_LOADER_PAGED_BUF 3082fd7a81STakashi Iwai bool 3182fd7a81STakashi Iwai 3206bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE 3306bfd3c8SLuis R. Rodriguez string "Build named firmware blobs into the kernel binary" 3406bfd3c8SLuis R. Rodriguez help 3506bfd3c8SLuis R. Rodriguez Device drivers which require firmware can typically deal with 3606bfd3c8SLuis R. Rodriguez having the kernel load firmware from the various supported 3706bfd3c8SLuis R. Rodriguez /lib/firmware/ paths. This option enables you to build into the 3806bfd3c8SLuis R. Rodriguez kernel firmware files. Built-in firmware searches are preceded 3906bfd3c8SLuis R. Rodriguez over firmware lookups using your filesystem over the supported 4006bfd3c8SLuis R. Rodriguez /lib/firmware paths documented on CONFIG_FW_LOADER. 4106bfd3c8SLuis R. Rodriguez 4206bfd3c8SLuis R. Rodriguez This may be useful for testing or if the firmware is required early on 4306bfd3c8SLuis R. Rodriguez in boot and cannot rely on the firmware being placed in an initrd or 4406bfd3c8SLuis R. Rodriguez initramfs. 4506bfd3c8SLuis R. Rodriguez 4606bfd3c8SLuis R. Rodriguez This option is a string and takes the (space-separated) names of the 4706bfd3c8SLuis R. Rodriguez firmware files -- the same names that appear in MODULE_FIRMWARE() 4806bfd3c8SLuis R. Rodriguez and request_firmware() in the source. These files should exist under 4906bfd3c8SLuis R. Rodriguez the directory specified by the EXTRA_FIRMWARE_DIR option, which is 5006bfd3c8SLuis R. Rodriguez /lib/firmware by default. 5106bfd3c8SLuis R. Rodriguez 5206bfd3c8SLuis R. Rodriguez For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy 5306bfd3c8SLuis R. Rodriguez the usb8388.bin file into /lib/firmware, and build the kernel. Then 5406bfd3c8SLuis R. Rodriguez any request_firmware("usb8388.bin") will be satisfied internally 5506bfd3c8SLuis R. Rodriguez inside the kernel without ever looking at your filesystem at runtime. 5606bfd3c8SLuis R. Rodriguez 5706bfd3c8SLuis R. Rodriguez WARNING: If you include additional firmware files into your binary 5806bfd3c8SLuis R. Rodriguez kernel image that are not available under the terms of the GPL, 5906bfd3c8SLuis R. Rodriguez then it may be a violation of the GPL to distribute the resulting 6006bfd3c8SLuis R. Rodriguez image since it combines both GPL and non-GPL work. You should 6106bfd3c8SLuis R. Rodriguez consult a lawyer of your own before distributing such an image. 6206bfd3c8SLuis R. Rodriguez 6306bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE_DIR 6406bfd3c8SLuis R. Rodriguez string "Firmware blobs root directory" 6506bfd3c8SLuis R. Rodriguez depends on EXTRA_FIRMWARE != "" 6606bfd3c8SLuis R. Rodriguez default "/lib/firmware" 6706bfd3c8SLuis R. Rodriguez help 6806bfd3c8SLuis R. Rodriguez This option controls the directory in which the kernel build system 6906bfd3c8SLuis R. Rodriguez looks for the firmware files listed in the EXTRA_FIRMWARE option. 7006bfd3c8SLuis R. Rodriguez 7106bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER 7206bfd3c8SLuis R. Rodriguez bool "Enable the firmware sysfs fallback mechanism" 7382fd7a81STakashi Iwai select FW_LOADER_PAGED_BUF 7406bfd3c8SLuis R. Rodriguez help 7506bfd3c8SLuis R. Rodriguez This option enables a sysfs loading facility to enable firmware 7606bfd3c8SLuis R. Rodriguez loading to the kernel through userspace as a fallback mechanism 7706bfd3c8SLuis R. Rodriguez if and only if the kernel's direct filesystem lookup for the 7806bfd3c8SLuis R. Rodriguez firmware failed using the different /lib/firmware/ paths, or the 7906bfd3c8SLuis R. Rodriguez path specified in the firmware_class path module parameter, or the 8006bfd3c8SLuis R. Rodriguez firmware_class path kernel boot parameter if the firmware_class is 8106bfd3c8SLuis R. Rodriguez built-in. For details on how to work with the sysfs fallback mechanism 8206bfd3c8SLuis R. Rodriguez refer to Documentation/driver-api/firmware/fallback-mechanisms.rst. 8306bfd3c8SLuis R. Rodriguez 8406bfd3c8SLuis R. Rodriguez The direct filesystem lookup for firmware is always used first now. 8506bfd3c8SLuis R. Rodriguez 8606bfd3c8SLuis R. Rodriguez If the kernel's direct filesystem lookup for firmware fails to find 8706bfd3c8SLuis R. Rodriguez the requested firmware a sysfs fallback loading facility is made 8806bfd3c8SLuis R. Rodriguez available and userspace is informed about this through uevents. 8906bfd3c8SLuis R. Rodriguez The uevent can be suppressed if the driver explicitly requested it, 9006bfd3c8SLuis R. Rodriguez this is known as the driver using the custom fallback mechanism. 9106bfd3c8SLuis R. Rodriguez If the custom fallback mechanism is used userspace must always 9206bfd3c8SLuis R. Rodriguez acknowledge failure to find firmware as the timeout for the fallback 9306bfd3c8SLuis R. Rodriguez mechanism is disabled, and failed requests will linger forever. 9406bfd3c8SLuis R. Rodriguez 9506bfd3c8SLuis R. Rodriguez This used to be the default firmware loading facility, and udev used 9606bfd3c8SLuis R. Rodriguez to listen for uvents to load firmware for the kernel. The firmware 9706bfd3c8SLuis R. Rodriguez loading facility functionality in udev has been removed, as such it 9806bfd3c8SLuis R. Rodriguez can no longer be relied upon as a fallback mechanism. Linux no longer 9906bfd3c8SLuis R. Rodriguez relies on or uses a fallback mechanism in userspace. If you need to 10006bfd3c8SLuis R. Rodriguez rely on one refer to the permissively licensed firmwared: 10106bfd3c8SLuis R. Rodriguez 10206bfd3c8SLuis R. Rodriguez https://github.com/teg/firmwared 10306bfd3c8SLuis R. Rodriguez 10406bfd3c8SLuis R. Rodriguez Since this was the default firmware loading facility at one point, 10506bfd3c8SLuis R. Rodriguez old userspace may exist which relies upon it, and as such this 10606bfd3c8SLuis R. Rodriguez mechanism can never be removed from the kernel. 10706bfd3c8SLuis R. Rodriguez 10806bfd3c8SLuis R. Rodriguez You should only enable this functionality if you are certain you 10906bfd3c8SLuis R. Rodriguez require a fallback mechanism and have a userspace mechanism ready to 11006bfd3c8SLuis R. Rodriguez load firmware in case it is not found. One main reason for this may 11106bfd3c8SLuis R. Rodriguez be if you have drivers which require firmware built-in and for 11206bfd3c8SLuis R. Rodriguez whatever reason cannot place the required firmware in initramfs. 11306bfd3c8SLuis R. Rodriguez Another reason kernels may have this feature enabled is to support a 11406bfd3c8SLuis R. Rodriguez driver which explicitly relies on this fallback mechanism. Only two 11506bfd3c8SLuis R. Rodriguez drivers need this today: 11606bfd3c8SLuis R. Rodriguez 11706bfd3c8SLuis R. Rodriguez o CONFIG_LEDS_LP55XX_COMMON 11806bfd3c8SLuis R. Rodriguez o CONFIG_DELL_RBU 11906bfd3c8SLuis R. Rodriguez 12006bfd3c8SLuis R. Rodriguez Outside of supporting the above drivers, another reason for needing 12106bfd3c8SLuis R. Rodriguez this may be that your firmware resides outside of the paths the kernel 12206bfd3c8SLuis R. Rodriguez looks for and cannot possibly be specified using the firmware_class 12306bfd3c8SLuis R. Rodriguez path module parameter or kernel firmware_class path boot parameter 12406bfd3c8SLuis R. Rodriguez if firmware_class is built-in. 12506bfd3c8SLuis R. Rodriguez 12606bfd3c8SLuis R. Rodriguez A modern use case may be to temporarily mount a custom partition 12706bfd3c8SLuis R. Rodriguez during provisioning which is only accessible to userspace, and then 12806bfd3c8SLuis R. Rodriguez to use it to look for and fetch the required firmware. Such type of 12906bfd3c8SLuis R. Rodriguez driver functionality may not even ever be desirable upstream by 13006bfd3c8SLuis R. Rodriguez vendors, and as such is only required to be supported as an interface 13106bfd3c8SLuis R. Rodriguez for provisioning. Since udev's firmware loading facility has been 13206bfd3c8SLuis R. Rodriguez removed you can use firmwared or a fork of it to customize how you 13306bfd3c8SLuis R. Rodriguez want to load firmware based on uevents issued. 13406bfd3c8SLuis R. Rodriguez 13506bfd3c8SLuis R. Rodriguez Enabling this option will increase your kernel image size by about 13606bfd3c8SLuis R. Rodriguez 13436 bytes. 13706bfd3c8SLuis R. Rodriguez 13806bfd3c8SLuis R. Rodriguez If you are unsure about this, say N here, unless you are Linux 13906bfd3c8SLuis R. Rodriguez distribution and need to support the above two drivers, or you are 14006bfd3c8SLuis R. Rodriguez certain you need to support some really custom firmware loading 14106bfd3c8SLuis R. Rodriguez facility in userspace. 14206bfd3c8SLuis R. Rodriguez 14306bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER_FALLBACK 14406bfd3c8SLuis R. Rodriguez bool "Force the firmware sysfs fallback mechanism when possible" 14506bfd3c8SLuis R. Rodriguez depends on FW_LOADER_USER_HELPER 14606bfd3c8SLuis R. Rodriguez help 14706bfd3c8SLuis R. Rodriguez Enabling this option forces a sysfs userspace fallback mechanism 14806bfd3c8SLuis R. Rodriguez to be used for all firmware requests which explicitly do not disable a 14906bfd3c8SLuis R. Rodriguez a fallback mechanism. Firmware calls which do prohibit a fallback 15006bfd3c8SLuis R. Rodriguez mechanism is request_firmware_direct(). This option is kept for 15106bfd3c8SLuis R. Rodriguez backward compatibility purposes given this precise mechanism can also 15206bfd3c8SLuis R. Rodriguez be enabled by setting the proc sysctl value to true: 15306bfd3c8SLuis R. Rodriguez 15406bfd3c8SLuis R. Rodriguez /proc/sys/kernel/firmware_config/force_sysfs_fallback 15506bfd3c8SLuis R. Rodriguez 15606bfd3c8SLuis R. Rodriguez If you are unsure about this, say N here. 15706bfd3c8SLuis R. Rodriguez 15882fd7a81STakashi Iwaiconfig FW_LOADER_COMPRESS 15982fd7a81STakashi Iwai bool "Enable compressed firmware support" 16082fd7a81STakashi Iwai select FW_LOADER_PAGED_BUF 16182fd7a81STakashi Iwai select XZ_DEC 16282fd7a81STakashi Iwai help 16382fd7a81STakashi Iwai This option enables the support for loading compressed firmware 16482fd7a81STakashi Iwai files. The caller of firmware API receives the decompressed file 16582fd7a81STakashi Iwai content. The compressed file is loaded as a fallback, only after 16682fd7a81STakashi Iwai loading the raw file failed at first. 16782fd7a81STakashi Iwai 16882fd7a81STakashi Iwai Currently only XZ-compressed files are supported, and they have to 16982fd7a81STakashi Iwai be compressed with either none or crc32 integrity check type (pass 17082fd7a81STakashi Iwai "-C crc32" option to xz command). 17182fd7a81STakashi Iwai 172*030cc787SMark Salyzynconfig FW_CACHE 173*030cc787SMark Salyzyn bool "Enable firmware caching during suspend" 174*030cc787SMark Salyzyn depends on PM_SLEEP 175*030cc787SMark Salyzyn default y if PM_SLEEP 176*030cc787SMark Salyzyn help 177*030cc787SMark Salyzyn Because firmware caching generates uevent messages that are sent 178*030cc787SMark Salyzyn over a netlink socket, it can prevent suspend on many platforms. 179*030cc787SMark Salyzyn It is also not always useful, so on such platforms we have the 180*030cc787SMark Salyzyn option. 181*030cc787SMark Salyzyn 182*030cc787SMark Salyzyn If unsure, say Y. 183*030cc787SMark Salyzyn 18406bfd3c8SLuis R. Rodriguezendif # FW_LOADER 18506bfd3c8SLuis R. Rodriguezendmenu 186