xref: /linux/drivers/base/firmware_loader/Kconfig (revision a3a02a52bcfcbcc4a637d4b68bf1bc391c9fad02)
1# SPDX-License-Identifier: GPL-2.0
2menu "Firmware loader"
3
4config FW_LOADER
5	tristate "Firmware loading facility" if EXPERT
6	select CRYPTO_HASH if FW_LOADER_DEBUG
7	select CRYPTO_SHA256 if FW_LOADER_DEBUG
8	default y
9	help
10	  This enables the firmware loading facility in the kernel. The kernel
11	  will first look for built-in firmware, if it has any. Next, it will
12	  look for the requested firmware in a series of filesystem paths:
13
14		o firmware_class path module parameter or kernel boot param
15		o /lib/firmware/updates/UTS_RELEASE
16		o /lib/firmware/updates
17		o /lib/firmware/UTS_RELEASE
18		o /lib/firmware
19
20	  Enabling this feature only increases your kernel image by about
21	  828 bytes, enable this option unless you are certain you don't
22	  need firmware.
23
24	  You typically want this built-in (=y) but you can also enable this
25	  as a module, in which case the firmware_class module will be built.
26	  You also want to be sure to enable this built-in if you are going to
27	  enable built-in firmware (CONFIG_EXTRA_FIRMWARE).
28
29config FW_LOADER_DEBUG
30	bool "Log filenames and checksums for loaded firmware"
31	depends on CRYPTO = FW_LOADER || CRYPTO=y
32	depends on DYNAMIC_DEBUG
33	depends on FW_LOADER
34	default FW_LOADER
35	help
36	  Select this option to use dynamic debug to log firmware filenames and
37	  SHA256 checksums to the kernel log for each firmware file that is
38	  loaded.
39
40config RUST_FW_LOADER_ABSTRACTIONS
41	bool "Rust Firmware Loader abstractions"
42	depends on RUST
43	depends on FW_LOADER=y
44	help
45	  This enables the Rust abstractions for the firmware loader API.
46
47if FW_LOADER
48
49config FW_LOADER_PAGED_BUF
50	bool
51
52config FW_LOADER_SYSFS
53	bool
54
55config EXTRA_FIRMWARE
56	string "Build named firmware blobs into the kernel binary"
57	help
58	  Device drivers which require firmware can typically deal with
59	  having the kernel load firmware from the various supported
60	  /lib/firmware/ paths. This option enables you to build into the
61	  kernel firmware files. Built-in firmware searches are preceded
62	  over firmware lookups using your filesystem over the supported
63	  /lib/firmware paths documented on CONFIG_FW_LOADER.
64
65	  This may be useful for testing or if the firmware is required early on
66	  in boot and cannot rely on the firmware being placed in an initrd or
67	  initramfs.
68
69	  This option is a string and takes the (space-separated) names of the
70	  firmware files -- the same names that appear in MODULE_FIRMWARE()
71	  and request_firmware() in the source. These files should exist under
72	  the directory specified by the EXTRA_FIRMWARE_DIR option, which is
73	  /lib/firmware by default.
74
75	  For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy
76	  the usb8388.bin file into /lib/firmware, and build the kernel. Then
77	  any request_firmware("usb8388.bin") will be satisfied internally
78	  inside the kernel without ever looking at your filesystem at runtime.
79
80	  WARNING: If you include additional firmware files into your binary
81	  kernel image that are not available under the terms of the GPL,
82	  then it may be a violation of the GPL to distribute the resulting
83	  image since it combines both GPL and non-GPL work. You should
84	  consult a lawyer of your own before distributing such an image.
85
86	  NOTE: Compressed files are not supported in EXTRA_FIRMWARE.
87
88config EXTRA_FIRMWARE_DIR
89	string "Firmware blobs root directory"
90	depends on EXTRA_FIRMWARE != ""
91	default "/lib/firmware"
92	help
93	  This option controls the directory in which the kernel build system
94	  looks for the firmware files listed in the EXTRA_FIRMWARE option.
95
96config FW_LOADER_USER_HELPER
97	bool "Enable the firmware sysfs fallback mechanism"
98	select FW_LOADER_SYSFS
99	select FW_LOADER_PAGED_BUF
100	help
101	  This option enables a sysfs loading facility to enable firmware
102	  loading to the kernel through userspace as a fallback mechanism
103	  if and only if the kernel's direct filesystem lookup for the
104	  firmware failed using the different /lib/firmware/ paths, or the
105	  path specified in the firmware_class path module parameter, or the
106	  firmware_class path kernel boot parameter if the firmware_class is
107	  built-in. For details on how to work with the sysfs fallback mechanism
108	  refer to Documentation/driver-api/firmware/fallback-mechanisms.rst.
109
110	  The direct filesystem lookup for firmware is always used first now.
111
112	  If the kernel's direct filesystem lookup for firmware fails to find
113	  the requested firmware a sysfs fallback loading facility is made
114	  available and userspace is informed about this through uevents.
115	  The uevent can be suppressed if the driver explicitly requested it,
116	  this is known as the driver using the custom fallback mechanism.
117	  If the custom fallback mechanism is used userspace must always
118	  acknowledge failure to find firmware as the timeout for the fallback
119	  mechanism is disabled, and failed requests will linger forever.
120
121	  This used to be the default firmware loading facility, and udev used
122	  to listen for uvents to load firmware for the kernel. The firmware
123	  loading facility functionality in udev has been removed, as such it
124	  can no longer be relied upon as a fallback mechanism. Linux no longer
125	  relies on or uses a fallback mechanism in userspace. If you need to
126	  rely on one refer to the permissively licensed firmwared:
127
128	  https://github.com/teg/firmwared
129
130	  Since this was the default firmware loading facility at one point,
131	  old userspace may exist which relies upon it, and as such this
132	  mechanism can never be removed from the kernel.
133
134	  You should only enable this functionality if you are certain you
135	  require a fallback mechanism and have a userspace mechanism ready to
136	  load firmware in case it is not found. One main reason for this may
137	  be if you have drivers which require firmware built-in and for
138	  whatever reason cannot place the required firmware in initramfs.
139	  Another reason kernels may have this feature enabled is to support a
140	  driver which explicitly relies on this fallback mechanism. Only two
141	  drivers need this today:
142
143	    o CONFIG_LEDS_LP55XX_COMMON
144	    o CONFIG_DELL_RBU
145
146	  Outside of supporting the above drivers, another reason for needing
147	  this may be that your firmware resides outside of the paths the kernel
148	  looks for and cannot possibly be specified using the firmware_class
149	  path module parameter or kernel firmware_class path boot parameter
150	  if firmware_class is built-in.
151
152	  A modern use case may be to temporarily mount a custom partition
153	  during provisioning which is only accessible to userspace, and then
154	  to use it to look for and fetch the required firmware. Such type of
155	  driver functionality may not even ever be desirable upstream by
156	  vendors, and as such is only required to be supported as an interface
157	  for provisioning. Since udev's firmware loading facility has been
158	  removed you can use firmwared or a fork of it to customize how you
159	  want to load firmware based on uevents issued.
160
161	  Enabling this option will increase your kernel image size by about
162	  13436 bytes.
163
164	  If you are unsure about this, say N here, unless you are Linux
165	  distribution and need to support the above two drivers, or you are
166	  certain you need to support some really custom firmware loading
167	  facility in userspace.
168
169config FW_LOADER_USER_HELPER_FALLBACK
170	bool "Force the firmware sysfs fallback mechanism when possible"
171	depends on FW_LOADER_USER_HELPER
172	help
173	  Enabling this option forces a sysfs userspace fallback mechanism
174	  to be used for all firmware requests which explicitly do not disable a
175	  a fallback mechanism. Firmware calls which do prohibit a fallback
176	  mechanism is request_firmware_direct(). This option is kept for
177	  backward compatibility purposes given this precise mechanism can also
178	  be enabled by setting the proc sysctl value to true:
179
180	       /proc/sys/kernel/firmware_config/force_sysfs_fallback
181
182	  If you are unsure about this, say N here.
183
184config FW_LOADER_COMPRESS
185	bool "Enable compressed firmware support"
186	help
187	  This option enables the support for loading compressed firmware
188	  files. The caller of firmware API receives the decompressed file
189	  content. The compressed file is loaded as a fallback, only after
190	  loading the raw file failed at first.
191
192	  Compressed firmware support does not apply to firmware images
193	  that are built into the kernel image (CONFIG_EXTRA_FIRMWARE).
194
195if FW_LOADER_COMPRESS
196config FW_LOADER_COMPRESS_XZ
197	bool "Enable XZ-compressed firmware support"
198	select FW_LOADER_PAGED_BUF
199	select XZ_DEC
200	default y
201	help
202	  This option adds the support for XZ-compressed files.
203	  The files have to be compressed with either none or crc32
204	  integrity check type (pass "-C crc32" option to xz command).
205
206config FW_LOADER_COMPRESS_ZSTD
207	bool "Enable ZSTD-compressed firmware support"
208	select ZSTD_DECOMPRESS
209	help
210	  This option adds the support for ZSTD-compressed files.
211
212endif # FW_LOADER_COMPRESS
213
214config FW_CACHE
215	bool "Enable firmware caching during suspend"
216	depends on PM_SLEEP
217	default y if PM_SLEEP
218	help
219	  Because firmware caching generates uevent messages that are sent
220	  over a netlink socket, it can prevent suspend on many platforms.
221	  It is also not always useful, so on such platforms we have the
222	  option.
223
224	  If unsure, say Y.
225
226config FW_UPLOAD
227	bool "Enable users to initiate firmware updates using sysfs"
228	select FW_LOADER_SYSFS
229	select FW_LOADER_PAGED_BUF
230	help
231	  Enabling this option will allow device drivers to expose a persistent
232	  sysfs interface that allows firmware updates to be initiated from
233	  userspace. For example, FPGA based PCIe cards load firmware and FPGA
234	  images from local FLASH when the card boots. The images in FLASH may
235	  be updated with new images provided by the user. Enable this device
236	  to support cards that rely on user-initiated updates for firmware files.
237
238	  If unsure, say N.
239
240endif # FW_LOADER
241endmenu
242