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