firmware_loader: Add firmware-upload support
authorRuss Weight <russell.h.weight@intel.com>
Thu, 21 Apr 2022 21:22:00 +0000 (14:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Apr 2022 10:34:28 +0000 (12:34 +0200)
commit97730bbb242cde22b7140acd202ffd88823886c9
treeb09e50663744488f3b91ed37a764837a06355bb2
parente0c11a8b985137aebf4bcd07cd957b80ac23924d
firmware_loader: Add firmware-upload support

Extend the firmware subsystem to support a persistent sysfs interface that
userspace may use to initiate a firmware update. For example, FPGA based
PCIe cards load firmware and FPGA images from local FLASH when the card
boots. The images in FLASH may be updated with new images provided by the
user at his/her convenience.

A device driver may call firmware_upload_register() to expose persistent
"loading" and "data" sysfs files. These files are used in the same way as
the fallback sysfs "loading" and "data" files. When 0 is written to
"loading" to complete the write of firmware data, the data is transferred
to the lower-level driver using pre-registered call-back functions. The
data transfer is done in the context of a kernel worker thread.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Tianfei zhang <tianfei.zhang@intel.com>
Tested-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Link: https://lore.kernel.org/r/20220421212204.36052-5-russell.h.weight@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 files changed:
Documentation/ABI/testing/sysfs-class-firmware [new file with mode: 0644]
Documentation/driver-api/firmware/fw_upload.rst [new file with mode: 0644]
Documentation/driver-api/firmware/index.rst
drivers/base/firmware_loader/Kconfig
drivers/base/firmware_loader/Makefile
drivers/base/firmware_loader/firmware.h
drivers/base/firmware_loader/main.c
drivers/base/firmware_loader/sysfs.c
drivers/base/firmware_loader/sysfs.h
drivers/base/firmware_loader/sysfs_upload.c [new file with mode: 0644]
drivers/base/firmware_loader/sysfs_upload.h [new file with mode: 0644]
include/linux/firmware.h