xref: /linux/drivers/base/firmware_loader/Kconfig (revision 50f86aedfa96c53498971a416d1b34cf1b13282e)
1*50f86aedSGreg 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
606bfd3c8SLuis R. Rodriguez	default y
706bfd3c8SLuis R. Rodriguez	help
806bfd3c8SLuis R. Rodriguez	  This enables the firmware loading facility in the kernel. The kernel
906bfd3c8SLuis R. Rodriguez	  will first look for built-in firmware, if it has any. Next, it will
1006bfd3c8SLuis R. Rodriguez	  look for the requested firmware in a series of filesystem paths:
1106bfd3c8SLuis R. Rodriguez
1206bfd3c8SLuis R. Rodriguez		o firmware_class path module parameter or kernel boot param
1306bfd3c8SLuis R. Rodriguez		o /lib/firmware/updates/UTS_RELEASE
1406bfd3c8SLuis R. Rodriguez		o /lib/firmware/updates
1506bfd3c8SLuis R. Rodriguez		o /lib/firmware/UTS_RELEASE
1606bfd3c8SLuis R. Rodriguez		o /lib/firmware
1706bfd3c8SLuis R. Rodriguez
1806bfd3c8SLuis R. Rodriguez	  Enabling this feature only increases your kernel image by about
1906bfd3c8SLuis R. Rodriguez	  828 bytes, enable this option unless you are certain you don't
2006bfd3c8SLuis R. Rodriguez	  need firmware.
2106bfd3c8SLuis R. Rodriguez
2206bfd3c8SLuis R. Rodriguez	  You typically want this built-in (=y) but you can also enable this
2306bfd3c8SLuis R. Rodriguez	  as a module, in which case the firmware_class module will be built.
2406bfd3c8SLuis R. Rodriguez	  You also want to be sure to enable this built-in if you are going to
2506bfd3c8SLuis R. Rodriguez	  enable built-in firmware (CONFIG_EXTRA_FIRMWARE).
2606bfd3c8SLuis R. Rodriguez
2706bfd3c8SLuis R. Rodriguezif FW_LOADER
2806bfd3c8SLuis R. Rodriguez
2906bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE
3006bfd3c8SLuis R. Rodriguez	string "Build named firmware blobs into the kernel binary"
3106bfd3c8SLuis R. Rodriguez	help
3206bfd3c8SLuis R. Rodriguez	  Device drivers which require firmware can typically deal with
3306bfd3c8SLuis R. Rodriguez	  having the kernel load firmware from the various supported
3406bfd3c8SLuis R. Rodriguez	  /lib/firmware/ paths. This option enables you to build into the
3506bfd3c8SLuis R. Rodriguez	  kernel firmware files. Built-in firmware searches are preceded
3606bfd3c8SLuis R. Rodriguez	  over firmware lookups using your filesystem over the supported
3706bfd3c8SLuis R. Rodriguez	  /lib/firmware paths documented on CONFIG_FW_LOADER.
3806bfd3c8SLuis R. Rodriguez
3906bfd3c8SLuis R. Rodriguez	  This may be useful for testing or if the firmware is required early on
4006bfd3c8SLuis R. Rodriguez	  in boot and cannot rely on the firmware being placed in an initrd or
4106bfd3c8SLuis R. Rodriguez	  initramfs.
4206bfd3c8SLuis R. Rodriguez
4306bfd3c8SLuis R. Rodriguez	  This option is a string and takes the (space-separated) names of the
4406bfd3c8SLuis R. Rodriguez	  firmware files -- the same names that appear in MODULE_FIRMWARE()
4506bfd3c8SLuis R. Rodriguez	  and request_firmware() in the source. These files should exist under
4606bfd3c8SLuis R. Rodriguez	  the directory specified by the EXTRA_FIRMWARE_DIR option, which is
4706bfd3c8SLuis R. Rodriguez	  /lib/firmware by default.
4806bfd3c8SLuis R. Rodriguez
4906bfd3c8SLuis R. Rodriguez	  For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy
5006bfd3c8SLuis R. Rodriguez	  the usb8388.bin file into /lib/firmware, and build the kernel. Then
5106bfd3c8SLuis R. Rodriguez	  any request_firmware("usb8388.bin") will be satisfied internally
5206bfd3c8SLuis R. Rodriguez	  inside the kernel without ever looking at your filesystem at runtime.
5306bfd3c8SLuis R. Rodriguez
5406bfd3c8SLuis R. Rodriguez	  WARNING: If you include additional firmware files into your binary
5506bfd3c8SLuis R. Rodriguez	  kernel image that are not available under the terms of the GPL,
5606bfd3c8SLuis R. Rodriguez	  then it may be a violation of the GPL to distribute the resulting
5706bfd3c8SLuis R. Rodriguez	  image since it combines both GPL and non-GPL work. You should
5806bfd3c8SLuis R. Rodriguez	  consult a lawyer of your own before distributing such an image.
5906bfd3c8SLuis R. Rodriguez
6006bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE_DIR
6106bfd3c8SLuis R. Rodriguez	string "Firmware blobs root directory"
6206bfd3c8SLuis R. Rodriguez	depends on EXTRA_FIRMWARE != ""
6306bfd3c8SLuis R. Rodriguez	default "/lib/firmware"
6406bfd3c8SLuis R. Rodriguez	help
6506bfd3c8SLuis R. Rodriguez	  This option controls the directory in which the kernel build system
6606bfd3c8SLuis R. Rodriguez	  looks for the firmware files listed in the EXTRA_FIRMWARE option.
6706bfd3c8SLuis R. Rodriguez
6806bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER
6906bfd3c8SLuis R. Rodriguez	bool "Enable the firmware sysfs fallback mechanism"
7006bfd3c8SLuis R. Rodriguez	help
7106bfd3c8SLuis R. Rodriguez	  This option enables a sysfs loading facility to enable firmware
7206bfd3c8SLuis R. Rodriguez	  loading to the kernel through userspace as a fallback mechanism
7306bfd3c8SLuis R. Rodriguez	  if and only if the kernel's direct filesystem lookup for the
7406bfd3c8SLuis R. Rodriguez	  firmware failed using the different /lib/firmware/ paths, or the
7506bfd3c8SLuis R. Rodriguez	  path specified in the firmware_class path module parameter, or the
7606bfd3c8SLuis R. Rodriguez	  firmware_class path kernel boot parameter if the firmware_class is
7706bfd3c8SLuis R. Rodriguez	  built-in. For details on how to work with the sysfs fallback mechanism
7806bfd3c8SLuis R. Rodriguez	  refer to Documentation/driver-api/firmware/fallback-mechanisms.rst.
7906bfd3c8SLuis R. Rodriguez
8006bfd3c8SLuis R. Rodriguez	  The direct filesystem lookup for firmware is always used first now.
8106bfd3c8SLuis R. Rodriguez
8206bfd3c8SLuis R. Rodriguez	  If the kernel's direct filesystem lookup for firmware fails to find
8306bfd3c8SLuis R. Rodriguez	  the requested firmware a sysfs fallback loading facility is made
8406bfd3c8SLuis R. Rodriguez	  available and userspace is informed about this through uevents.
8506bfd3c8SLuis R. Rodriguez	  The uevent can be suppressed if the driver explicitly requested it,
8606bfd3c8SLuis R. Rodriguez	  this is known as the driver using the custom fallback mechanism.
8706bfd3c8SLuis R. Rodriguez	  If the custom fallback mechanism is used userspace must always
8806bfd3c8SLuis R. Rodriguez	  acknowledge failure to find firmware as the timeout for the fallback
8906bfd3c8SLuis R. Rodriguez	  mechanism is disabled, and failed requests will linger forever.
9006bfd3c8SLuis R. Rodriguez
9106bfd3c8SLuis R. Rodriguez	  This used to be the default firmware loading facility, and udev used
9206bfd3c8SLuis R. Rodriguez	  to listen for uvents to load firmware for the kernel. The firmware
9306bfd3c8SLuis R. Rodriguez	  loading facility functionality in udev has been removed, as such it
9406bfd3c8SLuis R. Rodriguez	  can no longer be relied upon as a fallback mechanism. Linux no longer
9506bfd3c8SLuis R. Rodriguez	  relies on or uses a fallback mechanism in userspace. If you need to
9606bfd3c8SLuis R. Rodriguez	  rely on one refer to the permissively licensed firmwared:
9706bfd3c8SLuis R. Rodriguez
9806bfd3c8SLuis R. Rodriguez	  https://github.com/teg/firmwared
9906bfd3c8SLuis R. Rodriguez
10006bfd3c8SLuis R. Rodriguez	  Since this was the default firmware loading facility at one point,
10106bfd3c8SLuis R. Rodriguez	  old userspace may exist which relies upon it, and as such this
10206bfd3c8SLuis R. Rodriguez	  mechanism can never be removed from the kernel.
10306bfd3c8SLuis R. Rodriguez
10406bfd3c8SLuis R. Rodriguez	  You should only enable this functionality if you are certain you
10506bfd3c8SLuis R. Rodriguez	  require a fallback mechanism and have a userspace mechanism ready to
10606bfd3c8SLuis R. Rodriguez	  load firmware in case it is not found. One main reason for this may
10706bfd3c8SLuis R. Rodriguez	  be if you have drivers which require firmware built-in and for
10806bfd3c8SLuis R. Rodriguez	  whatever reason cannot place the required firmware in initramfs.
10906bfd3c8SLuis R. Rodriguez	  Another reason kernels may have this feature enabled is to support a
11006bfd3c8SLuis R. Rodriguez	  driver which explicitly relies on this fallback mechanism. Only two
11106bfd3c8SLuis R. Rodriguez	  drivers need this today:
11206bfd3c8SLuis R. Rodriguez
11306bfd3c8SLuis R. Rodriguez	    o CONFIG_LEDS_LP55XX_COMMON
11406bfd3c8SLuis R. Rodriguez	    o CONFIG_DELL_RBU
11506bfd3c8SLuis R. Rodriguez
11606bfd3c8SLuis R. Rodriguez	  Outside of supporting the above drivers, another reason for needing
11706bfd3c8SLuis R. Rodriguez	  this may be that your firmware resides outside of the paths the kernel
11806bfd3c8SLuis R. Rodriguez	  looks for and cannot possibly be specified using the firmware_class
11906bfd3c8SLuis R. Rodriguez	  path module parameter or kernel firmware_class path boot parameter
12006bfd3c8SLuis R. Rodriguez	  if firmware_class is built-in.
12106bfd3c8SLuis R. Rodriguez
12206bfd3c8SLuis R. Rodriguez	  A modern use case may be to temporarily mount a custom partition
12306bfd3c8SLuis R. Rodriguez	  during provisioning which is only accessible to userspace, and then
12406bfd3c8SLuis R. Rodriguez	  to use it to look for and fetch the required firmware. Such type of
12506bfd3c8SLuis R. Rodriguez	  driver functionality may not even ever be desirable upstream by
12606bfd3c8SLuis R. Rodriguez	  vendors, and as such is only required to be supported as an interface
12706bfd3c8SLuis R. Rodriguez	  for provisioning. Since udev's firmware loading facility has been
12806bfd3c8SLuis R. Rodriguez	  removed you can use firmwared or a fork of it to customize how you
12906bfd3c8SLuis R. Rodriguez	  want to load firmware based on uevents issued.
13006bfd3c8SLuis R. Rodriguez
13106bfd3c8SLuis R. Rodriguez	  Enabling this option will increase your kernel image size by about
13206bfd3c8SLuis R. Rodriguez	  13436 bytes.
13306bfd3c8SLuis R. Rodriguez
13406bfd3c8SLuis R. Rodriguez	  If you are unsure about this, say N here, unless you are Linux
13506bfd3c8SLuis R. Rodriguez	  distribution and need to support the above two drivers, or you are
13606bfd3c8SLuis R. Rodriguez	  certain you need to support some really custom firmware loading
13706bfd3c8SLuis R. Rodriguez	  facility in userspace.
13806bfd3c8SLuis R. Rodriguez
13906bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER_FALLBACK
14006bfd3c8SLuis R. Rodriguez	bool "Force the firmware sysfs fallback mechanism when possible"
14106bfd3c8SLuis R. Rodriguez	depends on FW_LOADER_USER_HELPER
14206bfd3c8SLuis R. Rodriguez	help
14306bfd3c8SLuis R. Rodriguez	  Enabling this option forces a sysfs userspace fallback mechanism
14406bfd3c8SLuis R. Rodriguez	  to be used for all firmware requests which explicitly do not disable a
14506bfd3c8SLuis R. Rodriguez	  a fallback mechanism. Firmware calls which do prohibit a fallback
14606bfd3c8SLuis R. Rodriguez	  mechanism is request_firmware_direct(). This option is kept for
14706bfd3c8SLuis R. Rodriguez          backward compatibility purposes given this precise mechanism can also
14806bfd3c8SLuis R. Rodriguez	  be enabled by setting the proc sysctl value to true:
14906bfd3c8SLuis R. Rodriguez
15006bfd3c8SLuis R. Rodriguez	       /proc/sys/kernel/firmware_config/force_sysfs_fallback
15106bfd3c8SLuis R. Rodriguez
15206bfd3c8SLuis R. Rodriguez	  If you are unsure about this, say N here.
15306bfd3c8SLuis R. Rodriguez
15406bfd3c8SLuis R. Rodriguezendif # FW_LOADER
15506bfd3c8SLuis R. Rodriguezendmenu
156