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 6bedee105SArnd Bergmann select CRYPTO_HASH if FW_LOADER_DEBUG 7bedee105SArnd Bergmann select CRYPTO_SHA256 if FW_LOADER_DEBUG 806bfd3c8SLuis R. Rodriguez default y 906bfd3c8SLuis R. Rodriguez help 1006bfd3c8SLuis R. Rodriguez This enables the firmware loading facility in the kernel. The kernel 1106bfd3c8SLuis R. Rodriguez will first look for built-in firmware, if it has any. Next, it will 1206bfd3c8SLuis R. Rodriguez look for the requested firmware in a series of filesystem paths: 1306bfd3c8SLuis R. Rodriguez 1406bfd3c8SLuis R. Rodriguez o firmware_class path module parameter or kernel boot param 1506bfd3c8SLuis R. Rodriguez o /lib/firmware/updates/UTS_RELEASE 1606bfd3c8SLuis R. Rodriguez o /lib/firmware/updates 1706bfd3c8SLuis R. Rodriguez o /lib/firmware/UTS_RELEASE 1806bfd3c8SLuis R. Rodriguez o /lib/firmware 1906bfd3c8SLuis R. Rodriguez 2006bfd3c8SLuis R. Rodriguez Enabling this feature only increases your kernel image by about 2106bfd3c8SLuis R. Rodriguez 828 bytes, enable this option unless you are certain you don't 2206bfd3c8SLuis R. Rodriguez need firmware. 2306bfd3c8SLuis R. Rodriguez 2406bfd3c8SLuis R. Rodriguez You typically want this built-in (=y) but you can also enable this 2506bfd3c8SLuis R. Rodriguez as a module, in which case the firmware_class module will be built. 2606bfd3c8SLuis R. Rodriguez You also want to be sure to enable this built-in if you are going to 2706bfd3c8SLuis R. Rodriguez enable built-in firmware (CONFIG_EXTRA_FIRMWARE). 2806bfd3c8SLuis R. Rodriguez 2902fe26f2SAmadeusz Sławińskiconfig FW_LOADER_DEBUG 3002fe26f2SAmadeusz Sławiński bool "Log filenames and checksums for loaded firmware" 31bedee105SArnd Bergmann depends on CRYPTO = FW_LOADER || CRYPTO=y 3202fe26f2SAmadeusz Sławiński depends on DYNAMIC_DEBUG 3302fe26f2SAmadeusz Sławiński depends on FW_LOADER 3402fe26f2SAmadeusz Sławiński default FW_LOADER 3502fe26f2SAmadeusz Sławiński help 3602fe26f2SAmadeusz Sławiński Select this option to use dynamic debug to log firmware filenames and 3702fe26f2SAmadeusz Sławiński SHA256 checksums to the kernel log for each firmware file that is 3802fe26f2SAmadeusz Sławiński loaded. 3902fe26f2SAmadeusz Sławiński 40*de658283SDanilo Krummrichconfig RUST_FW_LOADER_ABSTRACTIONS 41*de658283SDanilo Krummrich bool "Rust Firmware Loader abstractions" 42*de658283SDanilo Krummrich depends on RUST 43*de658283SDanilo Krummrich depends on FW_LOADER=y 44*de658283SDanilo Krummrich help 45*de658283SDanilo Krummrich This enables the Rust abstractions for the firmware loader API. 46*de658283SDanilo Krummrich 4706bfd3c8SLuis R. Rodriguezif FW_LOADER 4806bfd3c8SLuis R. Rodriguez 4982fd7a81STakashi Iwaiconfig FW_LOADER_PAGED_BUF 5082fd7a81STakashi Iwai bool 5182fd7a81STakashi Iwai 52e0c11a8bSRuss Weightconfig FW_LOADER_SYSFS 53e0c11a8bSRuss Weight bool 54e0c11a8bSRuss Weight 5506bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE 5606bfd3c8SLuis R. Rodriguez string "Build named firmware blobs into the kernel binary" 5706bfd3c8SLuis R. Rodriguez help 5806bfd3c8SLuis R. Rodriguez Device drivers which require firmware can typically deal with 5906bfd3c8SLuis R. Rodriguez having the kernel load firmware from the various supported 6006bfd3c8SLuis R. Rodriguez /lib/firmware/ paths. This option enables you to build into the 6106bfd3c8SLuis R. Rodriguez kernel firmware files. Built-in firmware searches are preceded 6206bfd3c8SLuis R. Rodriguez over firmware lookups using your filesystem over the supported 6306bfd3c8SLuis R. Rodriguez /lib/firmware paths documented on CONFIG_FW_LOADER. 6406bfd3c8SLuis R. Rodriguez 6506bfd3c8SLuis R. Rodriguez This may be useful for testing or if the firmware is required early on 6606bfd3c8SLuis R. Rodriguez in boot and cannot rely on the firmware being placed in an initrd or 6706bfd3c8SLuis R. Rodriguez initramfs. 6806bfd3c8SLuis R. Rodriguez 6906bfd3c8SLuis R. Rodriguez This option is a string and takes the (space-separated) names of the 7006bfd3c8SLuis R. Rodriguez firmware files -- the same names that appear in MODULE_FIRMWARE() 7106bfd3c8SLuis R. Rodriguez and request_firmware() in the source. These files should exist under 7206bfd3c8SLuis R. Rodriguez the directory specified by the EXTRA_FIRMWARE_DIR option, which is 7306bfd3c8SLuis R. Rodriguez /lib/firmware by default. 7406bfd3c8SLuis R. Rodriguez 7506bfd3c8SLuis R. Rodriguez For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy 7606bfd3c8SLuis R. Rodriguez the usb8388.bin file into /lib/firmware, and build the kernel. Then 7706bfd3c8SLuis R. Rodriguez any request_firmware("usb8388.bin") will be satisfied internally 7806bfd3c8SLuis R. Rodriguez inside the kernel without ever looking at your filesystem at runtime. 7906bfd3c8SLuis R. Rodriguez 8006bfd3c8SLuis R. Rodriguez WARNING: If you include additional firmware files into your binary 8106bfd3c8SLuis R. Rodriguez kernel image that are not available under the terms of the GPL, 8206bfd3c8SLuis R. Rodriguez then it may be a violation of the GPL to distribute the resulting 8306bfd3c8SLuis R. Rodriguez image since it combines both GPL and non-GPL work. You should 8406bfd3c8SLuis R. Rodriguez consult a lawyer of your own before distributing such an image. 8506bfd3c8SLuis R. Rodriguez 8636744c11SRandy Dunlap NOTE: Compressed files are not supported in EXTRA_FIRMWARE. 8736744c11SRandy Dunlap 8806bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE_DIR 8906bfd3c8SLuis R. Rodriguez string "Firmware blobs root directory" 9006bfd3c8SLuis R. Rodriguez depends on EXTRA_FIRMWARE != "" 9106bfd3c8SLuis R. Rodriguez default "/lib/firmware" 9206bfd3c8SLuis R. Rodriguez help 9306bfd3c8SLuis R. Rodriguez This option controls the directory in which the kernel build system 9406bfd3c8SLuis R. Rodriguez looks for the firmware files listed in the EXTRA_FIRMWARE option. 9506bfd3c8SLuis R. Rodriguez 9606bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER 9706bfd3c8SLuis R. Rodriguez bool "Enable the firmware sysfs fallback mechanism" 98e0c11a8bSRuss Weight select FW_LOADER_SYSFS 9982fd7a81STakashi Iwai select FW_LOADER_PAGED_BUF 10006bfd3c8SLuis R. Rodriguez help 10106bfd3c8SLuis R. Rodriguez This option enables a sysfs loading facility to enable firmware 10206bfd3c8SLuis R. Rodriguez loading to the kernel through userspace as a fallback mechanism 10306bfd3c8SLuis R. Rodriguez if and only if the kernel's direct filesystem lookup for the 10406bfd3c8SLuis R. Rodriguez firmware failed using the different /lib/firmware/ paths, or the 10506bfd3c8SLuis R. Rodriguez path specified in the firmware_class path module parameter, or the 10606bfd3c8SLuis R. Rodriguez firmware_class path kernel boot parameter if the firmware_class is 10706bfd3c8SLuis R. Rodriguez built-in. For details on how to work with the sysfs fallback mechanism 10806bfd3c8SLuis R. Rodriguez refer to Documentation/driver-api/firmware/fallback-mechanisms.rst. 10906bfd3c8SLuis R. Rodriguez 11006bfd3c8SLuis R. Rodriguez The direct filesystem lookup for firmware is always used first now. 11106bfd3c8SLuis R. Rodriguez 11206bfd3c8SLuis R. Rodriguez If the kernel's direct filesystem lookup for firmware fails to find 11306bfd3c8SLuis R. Rodriguez the requested firmware a sysfs fallback loading facility is made 11406bfd3c8SLuis R. Rodriguez available and userspace is informed about this through uevents. 11506bfd3c8SLuis R. Rodriguez The uevent can be suppressed if the driver explicitly requested it, 11606bfd3c8SLuis R. Rodriguez this is known as the driver using the custom fallback mechanism. 11706bfd3c8SLuis R. Rodriguez If the custom fallback mechanism is used userspace must always 11806bfd3c8SLuis R. Rodriguez acknowledge failure to find firmware as the timeout for the fallback 11906bfd3c8SLuis R. Rodriguez mechanism is disabled, and failed requests will linger forever. 12006bfd3c8SLuis R. Rodriguez 12106bfd3c8SLuis R. Rodriguez This used to be the default firmware loading facility, and udev used 12206bfd3c8SLuis R. Rodriguez to listen for uvents to load firmware for the kernel. The firmware 12306bfd3c8SLuis R. Rodriguez loading facility functionality in udev has been removed, as such it 12406bfd3c8SLuis R. Rodriguez can no longer be relied upon as a fallback mechanism. Linux no longer 12506bfd3c8SLuis R. Rodriguez relies on or uses a fallback mechanism in userspace. If you need to 12606bfd3c8SLuis R. Rodriguez rely on one refer to the permissively licensed firmwared: 12706bfd3c8SLuis R. Rodriguez 12806bfd3c8SLuis R. Rodriguez https://github.com/teg/firmwared 12906bfd3c8SLuis R. Rodriguez 13006bfd3c8SLuis R. Rodriguez Since this was the default firmware loading facility at one point, 13106bfd3c8SLuis R. Rodriguez old userspace may exist which relies upon it, and as such this 13206bfd3c8SLuis R. Rodriguez mechanism can never be removed from the kernel. 13306bfd3c8SLuis R. Rodriguez 13406bfd3c8SLuis R. Rodriguez You should only enable this functionality if you are certain you 13506bfd3c8SLuis R. Rodriguez require a fallback mechanism and have a userspace mechanism ready to 13606bfd3c8SLuis R. Rodriguez load firmware in case it is not found. One main reason for this may 13706bfd3c8SLuis R. Rodriguez be if you have drivers which require firmware built-in and for 13806bfd3c8SLuis R. Rodriguez whatever reason cannot place the required firmware in initramfs. 13906bfd3c8SLuis R. Rodriguez Another reason kernels may have this feature enabled is to support a 14006bfd3c8SLuis R. Rodriguez driver which explicitly relies on this fallback mechanism. Only two 14106bfd3c8SLuis R. Rodriguez drivers need this today: 14206bfd3c8SLuis R. Rodriguez 14306bfd3c8SLuis R. Rodriguez o CONFIG_LEDS_LP55XX_COMMON 14406bfd3c8SLuis R. Rodriguez o CONFIG_DELL_RBU 14506bfd3c8SLuis R. Rodriguez 14606bfd3c8SLuis R. Rodriguez Outside of supporting the above drivers, another reason for needing 14706bfd3c8SLuis R. Rodriguez this may be that your firmware resides outside of the paths the kernel 14806bfd3c8SLuis R. Rodriguez looks for and cannot possibly be specified using the firmware_class 14906bfd3c8SLuis R. Rodriguez path module parameter or kernel firmware_class path boot parameter 15006bfd3c8SLuis R. Rodriguez if firmware_class is built-in. 15106bfd3c8SLuis R. Rodriguez 15206bfd3c8SLuis R. Rodriguez A modern use case may be to temporarily mount a custom partition 15306bfd3c8SLuis R. Rodriguez during provisioning which is only accessible to userspace, and then 15406bfd3c8SLuis R. Rodriguez to use it to look for and fetch the required firmware. Such type of 15506bfd3c8SLuis R. Rodriguez driver functionality may not even ever be desirable upstream by 15606bfd3c8SLuis R. Rodriguez vendors, and as such is only required to be supported as an interface 15706bfd3c8SLuis R. Rodriguez for provisioning. Since udev's firmware loading facility has been 15806bfd3c8SLuis R. Rodriguez removed you can use firmwared or a fork of it to customize how you 15906bfd3c8SLuis R. Rodriguez want to load firmware based on uevents issued. 16006bfd3c8SLuis R. Rodriguez 16106bfd3c8SLuis R. Rodriguez Enabling this option will increase your kernel image size by about 16206bfd3c8SLuis R. Rodriguez 13436 bytes. 16306bfd3c8SLuis R. Rodriguez 16406bfd3c8SLuis R. Rodriguez If you are unsure about this, say N here, unless you are Linux 16506bfd3c8SLuis R. Rodriguez distribution and need to support the above two drivers, or you are 16606bfd3c8SLuis R. Rodriguez certain you need to support some really custom firmware loading 16706bfd3c8SLuis R. Rodriguez facility in userspace. 16806bfd3c8SLuis R. Rodriguez 16906bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER_FALLBACK 17006bfd3c8SLuis R. Rodriguez bool "Force the firmware sysfs fallback mechanism when possible" 17106bfd3c8SLuis R. Rodriguez depends on FW_LOADER_USER_HELPER 17206bfd3c8SLuis R. Rodriguez help 17306bfd3c8SLuis R. Rodriguez Enabling this option forces a sysfs userspace fallback mechanism 17406bfd3c8SLuis R. Rodriguez to be used for all firmware requests which explicitly do not disable a 17506bfd3c8SLuis R. Rodriguez a fallback mechanism. Firmware calls which do prohibit a fallback 17606bfd3c8SLuis R. Rodriguez mechanism is request_firmware_direct(). This option is kept for 17706bfd3c8SLuis R. Rodriguez backward compatibility purposes given this precise mechanism can also 17806bfd3c8SLuis R. Rodriguez be enabled by setting the proc sysctl value to true: 17906bfd3c8SLuis R. Rodriguez 18006bfd3c8SLuis R. Rodriguez /proc/sys/kernel/firmware_config/force_sysfs_fallback 18106bfd3c8SLuis R. Rodriguez 18206bfd3c8SLuis R. Rodriguez If you are unsure about this, say N here. 18306bfd3c8SLuis R. Rodriguez 18482fd7a81STakashi Iwaiconfig FW_LOADER_COMPRESS 18582fd7a81STakashi Iwai bool "Enable compressed firmware support" 18682fd7a81STakashi Iwai help 18782fd7a81STakashi Iwai This option enables the support for loading compressed firmware 18882fd7a81STakashi Iwai files. The caller of firmware API receives the decompressed file 18982fd7a81STakashi Iwai content. The compressed file is loaded as a fallback, only after 19082fd7a81STakashi Iwai loading the raw file failed at first. 19182fd7a81STakashi Iwai 19236744c11SRandy Dunlap Compressed firmware support does not apply to firmware images 19336744c11SRandy Dunlap that are built into the kernel image (CONFIG_EXTRA_FIRMWARE). 19436744c11SRandy Dunlap 19523cfbc6eSTakashi Iwaiif FW_LOADER_COMPRESS 19623cfbc6eSTakashi Iwaiconfig FW_LOADER_COMPRESS_XZ 19723cfbc6eSTakashi Iwai bool "Enable XZ-compressed firmware support" 19823cfbc6eSTakashi Iwai select FW_LOADER_PAGED_BUF 19923cfbc6eSTakashi Iwai select XZ_DEC 20007953c54SLinus Torvalds default y 20123cfbc6eSTakashi Iwai help 20223cfbc6eSTakashi Iwai This option adds the support for XZ-compressed files. 20323cfbc6eSTakashi Iwai The files have to be compressed with either none or crc32 20423cfbc6eSTakashi Iwai integrity check type (pass "-C crc32" option to xz command). 20523cfbc6eSTakashi Iwai 20623cfbc6eSTakashi Iwaiconfig FW_LOADER_COMPRESS_ZSTD 20723cfbc6eSTakashi Iwai bool "Enable ZSTD-compressed firmware support" 20823cfbc6eSTakashi Iwai select ZSTD_DECOMPRESS 20923cfbc6eSTakashi Iwai help 21023cfbc6eSTakashi Iwai This option adds the support for ZSTD-compressed files. 21123cfbc6eSTakashi Iwai 21223cfbc6eSTakashi Iwaiendif # FW_LOADER_COMPRESS 21323cfbc6eSTakashi Iwai 214030cc787SMark Salyzynconfig FW_CACHE 215030cc787SMark Salyzyn bool "Enable firmware caching during suspend" 216030cc787SMark Salyzyn depends on PM_SLEEP 217030cc787SMark Salyzyn default y if PM_SLEEP 218030cc787SMark Salyzyn help 219030cc787SMark Salyzyn Because firmware caching generates uevent messages that are sent 220030cc787SMark Salyzyn over a netlink socket, it can prevent suspend on many platforms. 221030cc787SMark Salyzyn It is also not always useful, so on such platforms we have the 222030cc787SMark Salyzyn option. 223030cc787SMark Salyzyn 224030cc787SMark Salyzyn If unsure, say Y. 225030cc787SMark Salyzyn 22697730bbbSRuss Weightconfig FW_UPLOAD 22797730bbbSRuss Weight bool "Enable users to initiate firmware updates using sysfs" 22897730bbbSRuss Weight select FW_LOADER_SYSFS 22997730bbbSRuss Weight select FW_LOADER_PAGED_BUF 23097730bbbSRuss Weight help 23197730bbbSRuss Weight Enabling this option will allow device drivers to expose a persistent 23297730bbbSRuss Weight sysfs interface that allows firmware updates to be initiated from 23397730bbbSRuss Weight userspace. For example, FPGA based PCIe cards load firmware and FPGA 23497730bbbSRuss Weight images from local FLASH when the card boots. The images in FLASH may 23597730bbbSRuss Weight be updated with new images provided by the user. Enable this device 23697730bbbSRuss Weight to support cards that rely on user-initiated updates for firmware files. 23797730bbbSRuss Weight 23897730bbbSRuss Weight If unsure, say N. 23997730bbbSRuss Weight 24006bfd3c8SLuis R. Rodriguezendif # FW_LOADER 24106bfd3c8SLuis R. Rodriguezendmenu 242