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