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